src/variables.h
changeset 6423 8e10e79e0fd1
parent 6344 e5edb531b27e
child 6427 7dc1012757d8
equal deleted inserted replaced
6422:6679df1c05ba 6423:8e10e79e0fd1
     1 /* $Id$ */
     1 /* $Id$ */
       
     2 
       
     3 /** @file variables.h */
     2 
     4 
     3 #ifndef VARIABLES_H
     5 #ifndef VARIABLES_H
     4 #define VARIABLES_H
     6 #define VARIABLES_H
     5 
     7 
     6 #include "yapf/yapf_settings.h"
     8 #include "yapf/yapf_settings.h"
     7 
     9 
     8 // ********* START OF SAVE REGION
    10 /* ********* START OF SAVE REGION */
     9 #if !defined(MAX_PATH)
    11 #if !defined(MAX_PATH)
    10 # define MAX_PATH 260
    12 # define MAX_PATH 260
    11 #endif
    13 #endif
    12 
    14 
    13 #include "gfx.h"
    15 #include "gfx.h"
    14 
    16 
    15 // Prices and also the fractional part.
    17 /* Prices and also the fractional part. */
    16 VARDEF Prices _price;
    18 VARDEF Prices _price;
    17 VARDEF uint16 _price_frac[NUM_PRICES];
    19 VARDEF uint16 _price_frac[NUM_PRICES];
    18 
    20 
    19 VARDEF uint32 _cargo_payment_rates[NUM_CARGO];
    21 VARDEF uint32 _cargo_payment_rates[NUM_CARGO];
    20 VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];
    22 VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];
    36 VARDEF GameOptions _opt;
    38 VARDEF GameOptions _opt;
    37 
    39 
    38 /* These are the default options for a new game */
    40 /* These are the default options for a new game */
    39 VARDEF GameOptions _opt_newgame;
    41 VARDEF GameOptions _opt_newgame;
    40 
    42 
    41 // Pointer to one of the two _opt OR _opt_newgame structs
    43 /* Pointer to one of the two _opt OR _opt_newgame structs */
    42 VARDEF GameOptions *_opt_ptr;
    44 VARDEF GameOptions *_opt_ptr;
    43 
    45 
    44 // Amount of game ticks
    46 /* Amount of game ticks */
    45 VARDEF uint16 _tick_counter;
    47 VARDEF uint16 _tick_counter;
    46 
    48 
    47 // This one is not used anymore.
    49 /* This one is not used anymore. */
    48 VARDEF VehicleID _vehicle_id_ctr_day;
    50 VARDEF VehicleID _vehicle_id_ctr_day;
    49 
    51 
    50 // Skip aging of cargo?
    52 /* Skip aging of cargo? */
    51 VARDEF byte _age_cargo_skip_counter;
    53 VARDEF byte _age_cargo_skip_counter;
    52 
    54 
    53 // Position in tile loop
    55 /* Position in tile loop */
    54 VARDEF TileIndex _cur_tileloop_tile;
    56 VARDEF TileIndex _cur_tileloop_tile;
    55 
    57 
    56 // Also save scrollpos_x, scrollpos_y and zoom
    58 /* Also save scrollpos_x, scrollpos_y and zoom */
    57 VARDEF uint16 _disaster_delay;
    59 VARDEF uint16 _disaster_delay;
    58 
    60 
    59 // Determines what station to operate on in the
    61 /* Determines what station to operate on in the
    60 //  tick handler.
    62  *  tick handler. */
    61 VARDEF uint16 _station_tick_ctr;
    63 VARDEF uint16 _station_tick_ctr;
    62 
    64 
    63 VARDEF uint32 _random_seeds[2][2];
    65 VARDEF uint32 _random_seeds[2][2];
    64 
    66 
    65 // Iterator through all towns in OnTick_Town
    67 /* Iterator through all towns in OnTick_Town */
    66 VARDEF uint32 _cur_town_ctr;
    68 VARDEF uint32 _cur_town_ctr;
    67 // Frequency iterator at the same place
    69 /* Frequency iterator at the same place */
    68 VARDEF uint32 _cur_town_iter;
    70 VARDEF uint32 _cur_town_iter;
    69 
    71 
    70 VARDEF uint _cur_player_tick_index;
    72 VARDEF uint _cur_player_tick_index;
    71 VARDEF uint _next_competitor_start;
    73 VARDEF uint _next_competitor_start;
    72 
    74 
    73 // Determines how often to run the tree loop
    75 /* Determines how often to run the tree loop */
    74 VARDEF byte _trees_tick_ctr;
    76 VARDEF byte _trees_tick_ctr;
    75 
    77 
    76 // Keep track of current game position
    78 /* Keep track of current game position */
    77 VARDEF int _saved_scrollpos_x;
    79 VARDEF int _saved_scrollpos_x;
    78 VARDEF int _saved_scrollpos_y;
    80 VARDEF int _saved_scrollpos_y;
    79 VARDEF byte _saved_scrollpos_zoom;
    81 VARDEF byte _saved_scrollpos_zoom;
    80 
    82 
    81 // ********* END OF SAVE REGION
    83 /* ********* END OF SAVE REGION */
    82 
    84 
    83 struct Patches {
    85 struct Patches {
    84 	bool modified_catchment;            // different-size catchment areas
    86 	bool modified_catchment;            // different-size catchment areas
    85 	bool vehicle_speed;                 // show vehicle speed
    87 	bool vehicle_speed;                 // show vehicle speed
    86 	bool build_on_slopes;               // allow building on slopes
    88 	bool build_on_slopes;               // allow building on slopes
   199 	 * of not being perfect anymore. This will probably be fixed in a more
   201 	 * of not being perfect anymore. This will probably be fixed in a more
   200 	 * sophisticated way sometime soon
   202 	 * sophisticated way sometime soon
   201 	 */
   203 	 */
   202 	uint32 npf_max_search_nodes;
   204 	uint32 npf_max_search_nodes;
   203 
   205 
   204 	uint32 npf_rail_firstred_penalty;      /* The penalty for when the first signal is red (and it is not an exit or combo signal) */
   206 	uint32 npf_rail_firstred_penalty;      // The penalty for when the first signal is red (and it is not an exit or combo signal)
   205 	uint32 npf_rail_firstred_exit_penalty; /* The penalty for when the first signal is red (and it is an exit or combo signal) */
   207 	uint32 npf_rail_firstred_exit_penalty; // The penalty for when the first signal is red (and it is an exit or combo signal)
   206 	uint32 npf_rail_lastred_penalty;       /* The penalty for when the last signal is red */
   208 	uint32 npf_rail_lastred_penalty;       // The penalty for when the last signal is red
   207 	uint32 npf_rail_station_penalty;       /* The penalty for station tiles */
   209 	uint32 npf_rail_station_penalty;       // The penalty for station tiles
   208 	uint32 npf_rail_slope_penalty;         /* The penalty for sloping upwards */
   210 	uint32 npf_rail_slope_penalty;         // The penalty for sloping upwards
   209 	uint32 npf_rail_curve_penalty;         /* The penalty for curves */
   211 	uint32 npf_rail_curve_penalty;         // The penalty for curves
   210 	uint32 npf_rail_depot_reverse_penalty; /* The penalty for reversing in depots */
   212 	uint32 npf_rail_depot_reverse_penalty; // The penalty for reversing in depots
   211 	uint32 npf_buoy_penalty;               /* The penalty for going over (through) a buoy */
   213 	uint32 npf_buoy_penalty;               // The penalty for going over (through) a buoy
   212 	uint32 npf_water_curve_penalty;        /* The penalty for curves */
   214 	uint32 npf_water_curve_penalty;        // The penalty for curves
   213 	uint32 npf_road_curve_penalty;         /* The penalty for curves */
   215 	uint32 npf_road_curve_penalty;         // The penalty for curves
   214 	uint32 npf_crossing_penalty;           /* The penalty for level crossings */
   216 	uint32 npf_crossing_penalty;           // The penalty for level crossings
   215 	uint32 npf_road_drive_through_penalty; /* The penalty for going through a drive-through road stop */
   217 	uint32 npf_road_drive_through_penalty; // The penalty for going through a drive-through road stop
   216 
   218 
   217 	bool population_in_label; // Show the population of a town in his label?
   219 	bool population_in_label; // Show the population of a town in his label?
   218 
   220 
   219 	uint8 freight_trains; ///< Value to multiply the weight of cargo by
   221 	uint8 freight_trains; // Value to multiply the weight of cargo by
   220 
   222 
   221 	/** YAPF settings */
   223 	/** YAPF settings */
   222 	YapfSettings  yapf;
   224 	YapfSettings  yapf;
   223 
   225 
   224 	uint8 scrollwheel_scrolling;
   226 	uint8 scrollwheel_scrolling;
   232 	bool been_used; // has this cheat been used before?
   234 	bool been_used; // has this cheat been used before?
   233 	bool value;     // tells if the bool cheat is active or not
   235 	bool value;     // tells if the bool cheat is active or not
   234 };
   236 };
   235 
   237 
   236 
   238 
   237 // WARNING! Do _not_ remove entries in Cheats struct or change the order
   239 /* WARNING! Do _not_ remove entries in Cheats struct or change the order
   238 // of the existing ones! Would break downward compatibility.
   240  * of the existing ones! Would break downward compatibility.
   239 // Only add new entries at the end of the struct!
   241  * Only add new entries at the end of the struct! */
   240 
   242 
   241 struct Cheats {
   243 struct Cheats {
   242 	Cheat magic_bulldozer;  // dynamite industries, unmovables
   244 	Cheat magic_bulldozer;  // dynamite industries, unmovables
   243 	Cheat switch_player;    // change to another player
   245 	Cheat switch_player;    // change to another player
   244 	Cheat money;            // get rich
   246 	Cheat money;            // get rich
   266 	char *second_data_dir;
   268 	char *second_data_dir;
   267 };
   269 };
   268 
   270 
   269 VARDEF Paths _paths;
   271 VARDEF Paths _paths;
   270 
   272 
   271 // NOSAVE: Used in palette animations only, not really important.
   273 /* NOSAVE: Used in palette animations only, not really important. */
   272 VARDEF int _timer_counter;
   274 VARDEF int _timer_counter;
   273 
   275 
   274 
   276 
   275 VARDEF uint32 _frame_counter;
   277 VARDEF uint32 _frame_counter;
   276 
   278 
   289 
   291 
   290 VARDEF uint32 _decode_parameters[20];
   292 VARDEF uint32 _decode_parameters[20];
   291 
   293 
   292 VARDEF bool _rightclick_emulate;
   294 VARDEF bool _rightclick_emulate;
   293 
   295 
   294 // IN/OUT parameters to commands
   296 /* IN/OUT parameters to commands */
   295 VARDEF byte _yearly_expenses_type;
   297 VARDEF byte _yearly_expenses_type;
   296 VARDEF TileIndex _terraform_err_tile;
   298 VARDEF TileIndex _terraform_err_tile;
   297 VARDEF TileIndex _build_tunnel_endtile;
   299 VARDEF TileIndex _build_tunnel_endtile;
   298 VARDEF bool _generating_world;
   300 VARDEF bool _generating_world;
   299 
   301 
   300 // Deals with the type of the savegame, independent of extension
   302 /* Deals with the type of the savegame, independent of extension */
   301 struct SmallFiosItem {
   303 struct SmallFiosItem {
   302 	int mode;             // savegame/scenario type (old, new)
   304 	int mode;             // savegame/scenario type (old, new)
   303 	char name[MAX_PATH];  // name
   305 	char name[MAX_PATH];  // name
   304 	char title[255];      // internal name of the game
   306 	char title[255];      // internal name of the game
   305 };
   307 };
   306 
   308 
   307 // Used when switching from the intro menu.
   309 /* Used when switching from the intro menu. */
   308 VARDEF byte _switch_mode;
   310 VARDEF byte _switch_mode;
   309 VARDEF StringID _switch_mode_errorstr;
   311 VARDEF StringID _switch_mode_errorstr;
   310 VARDEF SmallFiosItem _file_to_saveload;
   312 VARDEF SmallFiosItem _file_to_saveload;
   311 
   313 
   312 
   314 
   370 {
   372 {
   371 	assert(n < lengthof(_decode_parameters));
   373 	assert(n < lengthof(_decode_parameters));
   372 	return _decode_parameters[n];
   374 	return _decode_parameters[n];
   373 }
   375 }
   374 
   376 
   375 // Used to bind a C string name to a dparam number.
   377 /* Used to bind a C string name to a dparam number.
   376 // NOTE: This has a short lifetime. You can't
   378  * NOTE: This has a short lifetime. You can't
   377 //       use this string much later or it will be gone.
   379  *       use this string much later or it will be gone. */
   378 void SetDParamStr(uint n, const char *str);
   380 void SetDParamStr(uint n, const char *str);
   379 
   381 
   380 // This function takes a C-string and allocates a temporary string ID.
   382 /** This function takes a C-string and allocates a temporary string ID.
   381 // The duration of the bound string is valid only until the next acll to GetString,
   383  * The duration of the bound string is valid only until the next acll to GetString,
   382 // so be careful.
   384  * so be careful. */
   383 StringID BindCString(const char *str);
   385 StringID BindCString(const char *str);
   384 
   386 
   385 
   387 
   386 #define COPY_IN_DPARAM(offs,src,num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num))
   388 #define COPY_IN_DPARAM(offs,src,num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num))
   387 #define COPY_OUT_DPARAM(dst,offs,num) memcpy(dst,_decode_parameters + offs, sizeof(uint32) * (num))
   389 #define COPY_OUT_DPARAM(dst,offs,num) memcpy(dst,_decode_parameters + offs, sizeof(uint32) * (num))
   388 
   390 
   389 
   391 
   390 #define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;
   392 #define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;
   391 
   393 
   392 /* landscape.c */
   394 /* landscape.cpp */
   393 extern const byte _tileh_to_sprite[32];
   395 extern const byte _tileh_to_sprite[32];
   394 extern const Slope _inclined_tileh[16];
   396 extern const Slope _inclined_tileh[16];
   395 
   397 
   396 extern const TileTypeProcs * const _tile_type_procs[16];
   398 extern const TileTypeProcs * const _tile_type_procs[16];
   397 
   399