mirror of https://github.com/OpenTTD/OpenTTD
Change: Increase cargo type limit to 64.
parent
7eca4a9b47
commit
11ab3c4ea2
|
@ -63,14 +63,14 @@ enum CargoType {
|
||||||
CT_PLASTIC = 10,
|
CT_PLASTIC = 10,
|
||||||
CT_FIZZY_DRINKS = 11,
|
CT_FIZZY_DRINKS = 11,
|
||||||
|
|
||||||
NUM_CARGO = 32, ///< Maximal number of cargo types in a game.
|
NUM_CARGO = 64, ///< Maximal number of cargo types in a game.
|
||||||
|
|
||||||
CT_AUTO_REFIT = 0xFD, ///< Automatically choose cargo type when doing auto refitting.
|
CT_AUTO_REFIT = 0xFD, ///< Automatically choose cargo type when doing auto refitting.
|
||||||
CT_NO_REFIT = 0xFE, ///< Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
|
CT_NO_REFIT = 0xFE, ///< Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
|
||||||
CT_INVALID = 0xFF, ///< Invalid cargo type.
|
CT_INVALID = 0xFF, ///< Invalid cargo type.
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint32 CargoTypes;
|
typedef uint64 CargoTypes;
|
||||||
|
|
||||||
static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT32_MAX;
|
static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT32_MAX;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
/* Bitmasks of company and cargo indices that shouldn't be drawn. */
|
/* Bitmasks of company and cargo indices that shouldn't be drawn. */
|
||||||
static uint _legend_excluded_companies;
|
static CompanyMask _legend_excluded_companies;
|
||||||
static uint _legend_excluded_cargo;
|
static CargoTypes _legend_excluded_cargo;
|
||||||
|
|
||||||
/* Apparently these don't play well with enums. */
|
/* Apparently these don't play well with enums. */
|
||||||
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
|
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
|
||||||
|
@ -166,14 +166,14 @@ struct ValuesInterval {
|
||||||
|
|
||||||
struct BaseGraphWindow : Window {
|
struct BaseGraphWindow : Window {
|
||||||
protected:
|
protected:
|
||||||
static const int GRAPH_MAX_DATASETS = 32;
|
static const int GRAPH_MAX_DATASETS = 64;
|
||||||
static const int GRAPH_AXIS_LINE_COLOUR = PC_BLACK;
|
static const int GRAPH_AXIS_LINE_COLOUR = PC_BLACK;
|
||||||
static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph.
|
static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph.
|
||||||
|
|
||||||
static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw.
|
static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw.
|
||||||
static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines.
|
static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines.
|
||||||
|
|
||||||
uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
|
uint64 excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
|
||||||
byte num_dataset;
|
byte num_dataset;
|
||||||
byte num_on_x_axis;
|
byte num_on_x_axis;
|
||||||
byte num_vert_lines;
|
byte num_vert_lines;
|
||||||
|
@ -561,7 +561,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateStatistics(bool initialize)
|
void UpdateStatistics(bool initialize)
|
||||||
{
|
{
|
||||||
uint excluded_companies = _legend_excluded_companies;
|
CompanyMask excluded_companies = _legend_excluded_companies;
|
||||||
|
|
||||||
/* Exclude the companies which aren't valid */
|
/* Exclude the companies which aren't valid */
|
||||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||||
|
|
|
@ -350,7 +350,8 @@ static const SaveLoad _company_economy_desc[] = {
|
||||||
SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION),
|
SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDVAR(CompanyEconomyEntry, delivered_cargo[NUM_CARGO - 1], SLE_INT32, 0, 169),
|
SLE_CONDVAR(CompanyEconomyEntry, delivered_cargo[NUM_CARGO - 1], SLE_INT32, 0, 169),
|
||||||
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, NUM_CARGO, 170, SL_MAX_VERSION),
|
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, 32, 170, 198),
|
||||||
|
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, NUM_CARGO, 199, SL_MAX_VERSION),
|
||||||
SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32),
|
SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32),
|
||||||
|
|
||||||
SLE_END()
|
SLE_END()
|
||||||
|
|
|
@ -29,7 +29,7 @@ static void Load_PRIC()
|
||||||
/** Cargo payment rates in pre 126 savegames */
|
/** Cargo payment rates in pre 126 savegames */
|
||||||
static void Load_CAPR()
|
static void Load_CAPR()
|
||||||
{
|
{
|
||||||
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO;
|
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
|
||||||
int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64;
|
int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64;
|
||||||
SlArray(NULL, num_cargo, vt | SLE_VAR_NULL);
|
SlArray(NULL, num_cargo, vt | SLE_VAR_NULL);
|
||||||
SlArray(NULL, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL);
|
SlArray(NULL, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL);
|
||||||
|
|
|
@ -266,8 +266,9 @@
|
||||||
* 196 27778 1.7.x
|
* 196 27778 1.7.x
|
||||||
* 197 27978 1.8.x
|
* 197 27978 1.8.x
|
||||||
* 198
|
* 198
|
||||||
|
* 199
|
||||||
*/
|
*/
|
||||||
extern const uint16 SAVEGAME_VERSION = 198; ///< Current savegame version of OpenTTD.
|
extern const uint16 SAVEGAME_VERSION = 199; ///< Current savegame version of OpenTTD.
|
||||||
|
|
||||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.
|
FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.
|
||||||
|
|
|
@ -329,6 +329,7 @@ static void Load_STNS()
|
||||||
_cargo_days = 0;
|
_cargo_days = 0;
|
||||||
_cargo_feeder_share = 0;
|
_cargo_feeder_share = 0;
|
||||||
|
|
||||||
|
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
|
||||||
int index;
|
int index;
|
||||||
while ((index = SlIterateArray()) != -1) {
|
while ((index = SlIterateArray()) != -1) {
|
||||||
Station *st = new (index) Station();
|
Station *st = new (index) Station();
|
||||||
|
@ -337,7 +338,6 @@ static void Load_STNS()
|
||||||
|
|
||||||
_waiting_acceptance = 0;
|
_waiting_acceptance = 0;
|
||||||
|
|
||||||
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO;
|
|
||||||
for (CargoID i = 0; i < num_cargo; i++) {
|
for (CargoID i = 0; i < num_cargo; i++) {
|
||||||
GoodsEntry *ge = &st->goods[i];
|
GoodsEntry *ge = &st->goods[i];
|
||||||
SlObject(ge, GetGoodsDesc());
|
SlObject(ge, GetGoodsDesc());
|
||||||
|
@ -377,10 +377,11 @@ static void Ptrs_STNS()
|
||||||
/* Don't run when savegame version is higher than or equal to 123. */
|
/* Don't run when savegame version is higher than or equal to 123. */
|
||||||
if (!IsSavegameVersionBefore(123)) return;
|
if (!IsSavegameVersionBefore(123)) return;
|
||||||
|
|
||||||
|
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (!IsSavegameVersionBefore(68)) {
|
if (!IsSavegameVersionBefore(68)) {
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
for (CargoID i = 0; i < num_cargo; i++) {
|
||||||
GoodsEntry *ge = &st->goods[i];
|
GoodsEntry *ge = &st->goods[i];
|
||||||
SwapPackets(ge);
|
SwapPackets(ge);
|
||||||
SlObject(ge, GetGoodsDesc());
|
SlObject(ge, GetGoodsDesc());
|
||||||
|
@ -440,7 +441,8 @@ static const SaveLoad _station_desc[] = {
|
||||||
SLE_VAR(Station, last_vehicle_type, SLE_UINT8),
|
SLE_VAR(Station, last_vehicle_type, SLE_UINT8),
|
||||||
SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
|
SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
|
||||||
SLE_LST(Station, loading_vehicles, REF_VEHICLE),
|
SLE_LST(Station, loading_vehicles, REF_VEHICLE),
|
||||||
SLE_CONDVAR(Station, always_accepted, SLE_UINT32, 127, SL_MAX_VERSION),
|
SLE_CONDVAR(Station, always_accepted, SLE_FILE_U32 | SLE_VAR_U64, 127, 198),
|
||||||
|
SLE_CONDVAR(Station, always_accepted, SLE_UINT64, 199, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
@ -520,6 +522,7 @@ static void Load_STNN()
|
||||||
{
|
{
|
||||||
_num_flows = 0;
|
_num_flows = 0;
|
||||||
|
|
||||||
|
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
|
||||||
int index;
|
int index;
|
||||||
while ((index = SlIterateArray()) != -1) {
|
while ((index = SlIterateArray()) != -1) {
|
||||||
bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;
|
bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;
|
||||||
|
@ -538,7 +541,7 @@ static void Load_STNN()
|
||||||
memcpy(st->airport.psa->storage, _old_st_persistent_storage.storage, sizeof(st->airport.psa->storage));
|
memcpy(st->airport.psa->storage, _old_st_persistent_storage.storage, sizeof(st->airport.psa->storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
for (CargoID i = 0; i < num_cargo; i++) {
|
||||||
SlObject(&st->goods[i], GetGoodsDesc());
|
SlObject(&st->goods[i], GetGoodsDesc());
|
||||||
FlowSaveLoad flow;
|
FlowSaveLoad flow;
|
||||||
FlowStat *fs = NULL;
|
FlowStat *fs = NULL;
|
||||||
|
@ -580,9 +583,10 @@ static void Ptrs_STNN()
|
||||||
/* Don't run when savegame version lower than 123. */
|
/* Don't run when savegame version lower than 123. */
|
||||||
if (IsSavegameVersionBefore(123)) return;
|
if (IsSavegameVersionBefore(123)) return;
|
||||||
|
|
||||||
|
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
for (CargoID i = 0; i < num_cargo; i++) {
|
||||||
GoodsEntry *ge = &st->goods[i];
|
GoodsEntry *ge = &st->goods[i];
|
||||||
if (IsSavegameVersionBefore(183)) {
|
if (IsSavegameVersionBefore(183)) {
|
||||||
SwapPackets(ge);
|
SwapPackets(ge);
|
||||||
|
|
|
@ -192,7 +192,8 @@ static const SaveLoad _town_desc[] = {
|
||||||
|
|
||||||
SLE_CONDLST(Town, psa_list, REF_STORAGE, 161, SL_MAX_VERSION),
|
SLE_CONDLST(Town, psa_list, REF_STORAGE, 161, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDVAR(Town, cargo_produced, SLE_UINT32, 166, SL_MAX_VERSION),
|
SLE_CONDVAR(Town, cargo_produced, SLE_FILE_U32 | SLE_VAR_U64, 166, 198),
|
||||||
|
SLE_CONDVAR(Town, cargo_produced, SLE_UINT64, 199, SL_MAX_VERSION),
|
||||||
|
|
||||||
/* reserve extra space in savegame here. (currently 30 bytes) */
|
/* reserve extra space in savegame here. (currently 30 bytes) */
|
||||||
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
|
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
|
||||||
|
@ -274,12 +275,13 @@ static void Save_TOWN()
|
||||||
static void Load_TOWN()
|
static void Load_TOWN()
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
|
||||||
|
|
||||||
while ((index = SlIterateArray()) != -1) {
|
while ((index = SlIterateArray()) != -1) {
|
||||||
Town *t = new (index) Town();
|
Town *t = new (index) Town();
|
||||||
SlObject(t, _town_desc);
|
SlObject(t, _town_desc);
|
||||||
|
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
for (CargoID i = 0; i < num_cargo; i++) {
|
||||||
SlObject(&t->supplied[i], _town_supplied_desc);
|
SlObject(&t->supplied[i], _town_supplied_desc);
|
||||||
}
|
}
|
||||||
for (int i = TE_BEGIN; i < TE_END; i++) {
|
for (int i = TE_BEGIN; i < TE_END; i++) {
|
||||||
|
|
|
@ -1147,7 +1147,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCC_CARGO_LIST: { // {CARGO_LIST}
|
case SCC_CARGO_LIST: { // {CARGO_LIST}
|
||||||
CargoTypes cmask = args->GetInt32(SCC_CARGO_LIST);
|
CargoTypes cmask = args->GetInt64(SCC_CARGO_LIST);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
const CargoSpec *cs;
|
const CargoSpec *cs;
|
||||||
|
|
Loading…
Reference in New Issue