truelight@0: #ifndef VARIABLES_H truelight@0: #define VARIABLES_H truelight@0: truelight@0: #include "player.h" truelight@0: //enum { DPARAM_SIZE = 32 }; truelight@0: truelight@0: truelight@0: // ********* START OF SAVE REGION truelight@0: truelight@0: #if !defined(MAX_PATH) truelight@0: # define MAX_PATH 260 truelight@0: #endif truelight@0: truelight@0: // Prices and also the fractional part. truelight@0: VARDEF Prices _price; truelight@0: VARDEF uint16 _price_frac[NUM_PRICES]; truelight@0: truelight@0: VARDEF uint32 _cargo_payment_rates[NUM_CARGO]; truelight@0: VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO]; truelight@0: truelight@0: typedef struct { truelight@0: GameDifficulty diff; truelight@0: byte diff_level; truelight@0: byte currency; truelight@0: bool kilometers; truelight@0: byte town_name; truelight@0: byte landscape; truelight@0: byte snow_line; truelight@0: byte autosave; truelight@0: byte road_side; truelight@0: } GameOptions; truelight@0: truelight@0: // These are the options for the current game truelight@0: VARDEF GameOptions _opt; truelight@0: truelight@0: // These are the options for the new game truelight@0: VARDEF GameOptions _new_opt; truelight@0: truelight@0: // Current date truelight@0: VARDEF uint16 _date; truelight@0: VARDEF uint16 _date_fract; truelight@0: truelight@0: // Amount of game ticks truelight@0: VARDEF uint16 _tick_counter; truelight@0: truelight@0: // Used when calling OnNewDay truelight@0: VARDEF VehicleID _vehicle_id_ctr_day; truelight@0: truelight@0: // Skip aging of cargo? truelight@0: VARDEF byte _age_cargo_skip_counter; truelight@0: truelight@0: // Available aircraft types truelight@0: VARDEF byte _avail_aircraft; truelight@0: truelight@0: // Position in tile loop truelight@0: VARDEF TileIndex _cur_tileloop_tile; truelight@0: truelight@0: // Also save scrollpos_x, scrollpos_y and zoom truelight@0: VARDEF uint16 _disaster_delay; truelight@0: truelight@0: // Determines what station to operate on in the truelight@0: // tick handler. truelight@0: VARDEF uint16 _station_tick_ctr; truelight@0: truelight@0: VARDEF uint32 _random_seed_1, _random_seed_2; truelight@0: // Iterator through all towns in OnTick_Town truelight@0: VARDEF byte _cur_town_ctr; truelight@0: truelight@0: VARDEF uint _cur_player_tick_index; truelight@0: VARDEF uint _next_competitor_start; truelight@0: truelight@0: // Determines how often to run the tree loop truelight@0: VARDEF byte _trees_tick_ctr; truelight@0: truelight@0: // Keep track of current game position truelight@0: VARDEF int _saved_scrollpos_x; truelight@0: VARDEF int _saved_scrollpos_y; truelight@0: VARDEF byte _saved_scrollpos_zoom; truelight@0: truelight@0: // ********* END OF SAVE REGION truelight@0: truelight@0: typedef struct Patches { truelight@0: bool vehicle_speed; // show vehicle speed truelight@0: bool build_on_slopes; // allow building on slopes truelight@0: bool mammoth_trains; // allow very long trains truelight@0: bool join_stations; // allow joining of train stations truelight@0: bool full_load_any; // new full load calculation, any cargo must be full truelight@0: byte station_spread; // amount a station may spread truelight@0: bool inflation; // disable inflation truelight@0: bool no_train_service; // never automatically send trains to service truelight@0: bool selectgoods; // only send the goods to station if a train has been there truelight@0: bool longbridges; // allow 100 tile long bridges truelight@0: bool gotodepot; // allow goto depot in orders truelight@0: bool build_rawmaterial_ind; // allow building raw material industries truelight@0: bool multiple_industry_per_town; // allow many industries of the same type per town truelight@0: bool same_industry_close; // allow same type industries to be built close to each other truelight@0: uint16 lost_train_days; // if a train doesn't switch order in this amount of days, a train is lost warning is shown truelight@0: bool train_income_warn; // if train is generating little income, show a warning truelight@0: bool status_long_date; // always show long date in status bar truelight@0: bool signal_side; // show signals on right side truelight@0: bool show_finances; // show finances at end of year truelight@0: bool new_nonstop; // ttdpatch compatible nonstop handling truelight@0: bool roadveh_queue; // buggy road vehicle queueing truelight@0: bool autoscroll; // scroll when moving mouse to the edge. truelight@0: byte errmsg_duration; // duration of error message truelight@0: byte snow_line_height; // a number 0-15 that configured snow line height truelight@0: bool bribe; // enable bribing the local authority truelight@0: bool new_depot_finding; // use new algorithm to find a depot. truelight@0: bool nonuniform_stations;// allow nonuniform train stations truelight@0: bool always_small_airport; // always allow small airports truelight@0: bool realistic_acceleration; // realistic acceleration for trains truelight@0: truelight@0: byte max_trains; //max trains in game per player (these are 8bit because the unitnumber field can't hold more) truelight@0: byte max_roadveh; //max trucks in game per player truelight@0: byte max_aircraft; //max planes in game per player truelight@0: byte max_ships; //max ships in game per player truelight@0: truelight@0: uint16 servint_trains; // service interval for trains truelight@0: uint16 servint_roadveh; // service interval for road vehicles truelight@0: uint16 servint_aircraft;// service interval for aircraft truelight@0: uint16 servint_ships; // service interval for ships truelight@0: truelight@0: bool autorenew; truelight@0: uint16 autorenew_months; truelight@0: truelight@0: bool new_pathfinding; // use optimized pathfinding algoritm for trains truelight@0: byte pf_maxdepth; // maximum recursion depth when searching for a train route for new pathfinder truelight@0: uint16 pf_maxlength; // maximum length when searching for a train route for new pathfinder truelight@0: truelight@0: bool build_in_pause; // build while in pause mode truelight@0: bool bridge_pillars; // show bridge pillars for high bridges truelight@0: truelight@0: byte ai_disable_veh; // mask of vehicle types to disable for ai truelight@0: uint32 starting_date; // starting date truelight@0: uint32 colored_news_date; // when does newspaper become colored? truelight@0: truelight@0: bool keep_all_autosave; // name the autosave in a different way. truelight@0: bool extra_dynamite; // extra dynamite truelight@0: truelight@0: bool never_expire_vehicles; // never expire vehicles truelight@0: byte extend_vehicle_life; // extend vehicle life by this many years truelight@0: truelight@0: bool auto_euro; // automatically switch to euro in 2002 truelight@0: bool serviceathelipad; // service helicopters at helipads automatically (no need to send to depot) truelight@0: bool smooth_economy; // smooth economy truelight@0: byte dist_local_authority; // distance for town local authority, default 20 truelight@0: truelight@0: byte wait_oneway_signal; //waitingtime in days before a oneway signal truelight@0: byte wait_twoway_signal; //waitingtime in days before a twoway signal truelight@0: truelight@0: } Patches; truelight@0: truelight@0: enum { truelight@0: DISABLE_TRAINS = 1<<0, truelight@0: DISABLE_ROADVEH = 1 << 1, truelight@0: DISABLE_AIRCRAFT = 1 << 2, truelight@0: DISABLE_SHIPS = 1 << 3, truelight@0: }; truelight@0: truelight@0: VARDEF Patches _patches; truelight@0: truelight@0: truelight@0: typedef struct Cheat { truelight@0: bool been_used; // has this cheat been used before? truelight@0: byte value; // active? truelight@0: } Cheat; truelight@0: truelight@0: truelight@0: // WARNING! Do _not_ remove entries in Cheats struct or change the order truelight@0: // of the existing ones! Would break downward compatibility. truelight@0: // Only add new entries at the end of the struct! truelight@0: truelight@0: typedef struct Cheats { truelight@0: Cheat magic_bulldozer; // dynamite industries, unmovables truelight@0: Cheat switch_player; // change to another player truelight@0: Cheat money; // get rich truelight@0: Cheat crossing_tunnels; // allow tunnels that cross each other truelight@0: } Cheats; truelight@0: truelight@0: VARDEF Cheats _cheats; truelight@0: truelight@0: typedef struct Paths { truelight@0: char *personal_dir; // includes cfg file and save folder truelight@0: char *game_data_dir; // includes data, gm, lang truelight@0: char *data_dir; truelight@0: char *gm_dir; truelight@0: char *lang_dir; truelight@0: char *save_dir; truelight@0: char *autosave_dir; truelight@0: char *scenario_dir; truelight@0: } Paths; truelight@0: truelight@0: VARDEF Paths _path; truelight@0: truelight@0: // Which options struct does options modify? truelight@0: VARDEF GameOptions *_opt_mod_ptr; truelight@0: truelight@0: // NOSAVE: Used in palette animations only, not really important. truelight@0: VARDEF int _timer_counter; truelight@0: truelight@0: truelight@0: // NOSAVE: can be determined from _date truelight@0: VARDEF byte _cur_year; truelight@0: VARDEF byte _cur_month; truelight@0: truelight@0: // NOSAVE: can be determined from player structs truelight@0: VARDEF byte _player_colors[MAX_PLAYERS]; truelight@0: truelight@0: VARDEF bool _in_state_game_loop; truelight@0: VARDEF int32 _frame_counter; truelight@0: truelight@0: VARDEF int32 _frame_counter_max; // for networking, this is the frame that we are not allowed to execute yet. truelight@0: VARDEF int32 _frame_counter_srv; // for networking, this is the last known framecounter of the server. it is always less than frame_counter_max. truelight@0: truelight@0: // networking settings truelight@0: VARDEF uint _network_port; truelight@0: VARDEF uint _network_sync_freq; truelight@0: VARDEF uint _network_ahead_frames; truelight@0: truelight@0: VARDEF uint32 _network_ip_list[10]; // Network IPs truelight@0: VARDEF char * _network_detected_serverip; // UDP Broadcast detected Server truelight@0: VARDEF uint32 _network_detected_serverport; // UDP Broadcast detected server-port truelight@0: truelight@0: VARDEF uint32 _sync_seed_1, _sync_seed_2; truelight@0: truelight@0: VARDEF bool _is_ai_player; // current player is an AI player? truelight@0: truelight@0: VARDEF bool _do_autosave; truelight@0: VARDEF int _autosave_ctr; truelight@0: truelight@0: VARDEF byte _local_player; truelight@0: VARDEF byte _display_opt; truelight@0: VARDEF byte _pause; truelight@0: VARDEF int _caret_timer; truelight@0: VARDEF uint16 _news_display_opt; truelight@0: VARDEF byte _game_mode; truelight@0: truelight@0: VARDEF StringID _error_message; truelight@0: VARDEF StringID _error_message_2; truelight@0: VARDEF int32 _additional_cash_required; truelight@0: truelight@0: VARDEF uint32 _decode_parameters[10]; truelight@0: VARDEF byte _current_player; truelight@0: truelight@0: VARDEF int _docommand_recursive; truelight@0: truelight@0: VARDEF uint32 _pressed_key; // Low 8 bits = ASCII, High 16 bits = keycode truelight@0: VARDEF bool _ctrl_pressed; // Is Ctrl pressed? truelight@0: VARDEF bool _shift_pressed; // Is Alt pressed? truelight@0: VARDEF byte _dirkeys; // 1=left, 2=up, 4=right, 8=down truelight@0: truelight@0: VARDEF bool _fullscreen; truelight@0: VARDEF bool _double_size; truelight@0: VARDEF uint _display_hz; truelight@0: VARDEF bool _force_full_redraw; truelight@0: VARDEF uint _fullscreen_bpp; truelight@0: VARDEF bool _fast_forward; truelight@0: VARDEF bool _rightclick_emulate; truelight@0: truelight@0: // IN/OUT parameters to commands truelight@0: VARDEF byte _yearly_expenses_type; truelight@0: VARDEF TileIndex _terraform_err_tile; truelight@0: VARDEF uint _build_tunnel_endtile; truelight@0: VARDEF bool _generating_world; truelight@0: VARDEF int _new_town_size; truelight@0: VARDEF uint _returned_refit_amount; truelight@0: truelight@0: // Deals with the type of the savegame, independent of extension truelight@0: typedef struct { truelight@0: int mode; // savegame/scenario type (old, new) truelight@0: byte name[MAX_PATH]; // name truelight@0: } SmallFiosItem; truelight@0: truelight@0: // Used when switching from the intro menu. truelight@0: VARDEF byte _switch_mode; truelight@0: VARDEF bool _exit_game; truelight@0: VARDEF SmallFiosItem _file_to_saveload; truelight@0: VARDEF byte _make_screenshot; truelight@0: truelight@0: VARDEF bool _networking; truelight@0: VARDEF bool _networking_sync; // if we use network mode and the games must stay in sync. truelight@0: VARDEF bool _networking_server; truelight@0: VARDEF bool _networking_queuing; // queueing only? truelight@0: truelight@0: VARDEF byte _network_playas; // an id to play as.. truelight@0: truelight@0: VARDEF byte _get_z_hint; // used as a hint to getslopez to return the right height at a bridge. truelight@0: truelight@0: VARDEF char *_newgrf_files[32]; truelight@0: truelight@0: truelight@0: VARDEF Vehicle *_place_clicked_vehicle; truelight@0: truelight@0: VARDEF char _ini_videodriver[16], _ini_musicdriver[16], _ini_sounddriver[16]; truelight@0: truelight@0: VARDEF bool _cache_sprites; truelight@0: truelight@0: // debug features truelight@0: VARDEF char _savedump_path[64]; truelight@0: VARDEF uint _savedump_first, _savedump_freq, _savedump_last; truelight@0: // end of debug features truelight@0: truelight@0: truelight@0: typedef struct { truelight@0: char *name; truelight@0: char *file; truelight@0: } DynLangEnt; truelight@0: truelight@0: // Used for dynamic language support truelight@0: typedef struct { truelight@0: int num; // number of languages truelight@0: int curr; // currently selected language index truelight@0: char curr_file[32]; // currently selected language file truelight@0: StringID dropdown[32 + 1]; // used in settings dialog truelight@0: DynLangEnt ent[32]; truelight@0: } DynamicLanguages; truelight@0: truelight@0: VARDEF DynamicLanguages _dynlang; truelight@0: truelight@0: VARDEF int _num_resolutions; truelight@0: VARDEF uint16 _resolutions[32][2]; truelight@0: VARDEF uint16 _cur_resolution[2]; truelight@0: truelight@0: VARDEF char _screenshot_format_name[8]; truelight@0: VARDEF int _num_screenshot_formats, _cur_screenshot_format; truelight@0: truelight@0: VARDEF char _savegame_format[8]; truelight@0: truelight@0: VARDEF char *_config_file; truelight@0: truelight@0: // NOSAVE: These can be recalculated from InitializeLandscapeVariables truelight@0: typedef struct { truelight@0: StringID names_s[NUM_CARGO]; truelight@0: StringID names_p[NUM_CARGO]; truelight@0: StringID names_long_s[NUM_CARGO]; truelight@0: StringID names_long_p[NUM_CARGO]; truelight@0: StringID names_short[NUM_CARGO]; truelight@0: byte weights[NUM_CARGO]; truelight@0: SpriteID sprites[NUM_CARGO]; truelight@0: byte transit_days_1[NUM_CARGO]; truelight@0: byte transit_days_2[NUM_CARGO]; truelight@0: byte ai_railwagon[3][NUM_CARGO]; truelight@0: byte ai_roadveh_start[NUM_CARGO]; truelight@0: byte ai_roadveh_count[NUM_CARGO]; truelight@0: } CargoConst; truelight@0: truelight@0: VARDEF CargoConst _cargoc; truelight@0: truelight@0: typedef byte TownNameGenerator(byte *buf, uint32 seed); truelight@0: extern TownNameGenerator * const _town_name_generators[]; truelight@0: truelight@0: #define SET_DPARAM32(n, v) (_decode_parameters[n] = (v)) truelight@0: #define SET_DPARAMX32(s, n, v) ((s)[n] = (v)) truelight@0: #define GET_DPARAM32(n) (_decode_parameters[n]) truelight@0: truelight@0: #define SET_DPARAM(n, v) (_decode_parameters[n] = (v)) truelight@0: #define SET_DPARAMX(s, n, v) ((s)[n] = (v)) truelight@0: #define GET_DPARAM(n) (_decode_parameters[n]) truelight@0: truelight@0: static void FORCEINLINE SET_DPARAM64(int n, int64 v) truelight@0: { truelight@0: _decode_parameters[n] = (uint32)v; truelight@0: _decode_parameters[n+1] = (uint32)((uint64)v >> 32); truelight@0: } truelight@0: truelight@0: #if defined(TTD_LITTLE_ENDIAN) truelight@0: #define SET_DPARAMX16(s, n, v) ( ((uint16*)(s+n))[0] = (v)) truelight@0: #define SET_DPARAMX8(s, n, v) ( ((uint8*)(s+n))[0] = (v)) truelight@0: #define GET_DPARAMX16(s, n) ( ((uint16*)(s+n))[0]) truelight@0: #define GET_DPARAMX8(s, n) ( ((uint8*)(s+n))[0]) truelight@0: #elif defined(TTD_BIG_ENDIAN) truelight@0: #define SET_DPARAMX16(s, n, v) ( ((uint16*)(s+n))[1] = (v)) truelight@0: #define SET_DPARAMX8(s, n, v) ( ((uint8*)(s+n))[3] = (v)) truelight@0: #define GET_DPARAMX16(s, n) ( ((uint16*)(s+n))[1]) truelight@0: #define GET_DPARAMX8(s, n) ( ((uint8*)(s+n))[3]) truelight@0: #endif truelight@0: truelight@0: #define SET_DPARAM16(n, v) SET_DPARAMX16(_decode_parameters, n, v) truelight@0: #define SET_DPARAM8(n, v) SET_DPARAMX8(_decode_parameters, n, v) truelight@0: #define GET_DPARAM16(n) GET_DPARAMX16(_decode_parameters, n) truelight@0: #define GET_DPARAM8(n) GET_DPARAMX8(_decode_parameters, n) truelight@0: truelight@0: #define COPY_IN_DPARAM(offs,src,num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num)) truelight@0: #define COPY_OUT_DPARAM(dst,offs,num) memcpy(dst,_decode_parameters + offs, sizeof(uint32) * (num)) truelight@0: truelight@0: #define INJECT_DPARAM(n) InjectDparam(n); truelight@0: truelight@0: #define SET_EXPENSES_TYPE(x) if (x) _yearly_expenses_type=x; truelight@0: truelight@0: /* landscape.c */ truelight@0: extern const byte _tileh_to_sprite[32]; truelight@0: extern byte _map_type_and_height[TILES_X * TILES_Y]; truelight@0: extern byte _map5[TILES_X * TILES_Y]; truelight@0: extern byte _map3_lo[TILES_X * TILES_Y]; truelight@0: extern byte _map3_hi[TILES_X * TILES_Y]; truelight@0: extern byte _map_owner[TILES_X * TILES_Y]; truelight@0: extern byte _map2[TILES_X * TILES_Y]; truelight@0: extern byte _map_extra_bits[TILES_X * TILES_Y/4]; truelight@0: truelight@0: static const byte _inclined_tileh[] = { truelight@0: 3,9,3,6,12,6,12,9, truelight@0: }; truelight@0: truelight@0: extern const TileTypeProcs * const _tile_type_procs[16]; truelight@0: truelight@0: /* station_cmd.c */ truelight@0: // there are 5 types of airport (Country (3x4) , City(6x6), Metropolitan(6x6), International(7x7), Heliport(1x1) truelight@0: // will become obsolete once airports are loaded from seperate file truelight@0: extern const byte _airport_size_x[5]; truelight@0: extern const byte _airport_size_y[5]; truelight@0: truelight@0: extern const TileIndexDiff _tileoffs_by_dir[4]; truelight@0: truelight@0: /* misc */ truelight@0: VARDEF byte str_buffr[512]; truelight@0: VARDEF char _screenshot_name[128]; truelight@0: VARDEF char _userstring[128]; truelight@0: VARDEF byte _vehicle_design_names; truelight@0: truelight@0: VARDEF SignStruct _sign_list[40]; truelight@0: VARDEF SignStruct *_new_sign_struct; truelight@0: truelight@0: VARDEF bool _ignore_wrong_grf; truelight@0: truelight@0: /* tunnelbridge */ truelight@0: #define MAX_BRIDGES 13 truelight@0: truelight@0: /* Debugging levels */ truelight@0: VARDEF int _debug_spritecache_level; truelight@0: VARDEF int _debug_misc_level; truelight@0: truelight@0: void CDECL debug(const char *s, ...); truelight@0: #define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug truelight@0: truelight@0: #endif /* VARIABLES_H */