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: dominik@759: enum { dominik@759: CF_NOEURO = 0, dominik@759: CF_ISEURO = 1, dominik@759: }; dominik@759: dominik@759: typedef struct { dominik@759: uint16 rate; dominik@759: char separator; dominik@759: uint16 to_euro; dominik@788: char prefix[16]; dominik@788: char suffix[16]; dominik@759: } CurrencySpec; dominik@759: darkvater@761: VARDEF CurrencySpec _currency_specs[24]; dominik@759: 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: signde@206: VARDEF uint32 _random_seeds[2][2]; signde@206: VARDEF uint32 _player_seeds[MAX_PLAYERS][2]; signde@206: 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 { Celestar@568: bool modified_catchment; //different-size catchment areas 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 tron@523: bool improved_load; // improved loading algorithm truelight@0: byte station_spread; // amount a station may spread truelight@0: bool inflation; // disable inflation 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 dominik@55: uint8 order_review_system; 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 dominik@91: bool invisible_trees; // don't show trees when buildings are transparent darkvater@1037: bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled truelight@193: darkvater@68: uint8 toolbar_pos; // position of toolbars, 0=left, 1=center, 2=right tron@350: uint8 window_snap_radius; // Windows snap at each other if closer than this 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: darkvater@156: bool servint_ispercent; // service intervals are in percents 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@26: int16 autorenew_months; truelight@26: int32 autorenew_money; 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@193: truelight@0: bool bridge_pillars; // show bridge pillars for high bridges truelight@0: truelight@20: bool ai_disable_veh_train; // disable types for AI truelight@20: bool ai_disable_veh_roadveh; // disable types for AI truelight@20: bool ai_disable_veh_aircraft; // disable types for AI truelight@20: bool ai_disable_veh_ship; // disable types for AI truelight@0: uint32 starting_date; // starting date darkvater@998: uint32 ending_date; // end of the game (just show highscore) 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. dominik@643: bool autosave_on_exit; // save an autosave when you quit the game, but do not ask "Do you really want to quit?" 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 darkvater@930: bool allow_shares; // allow the buying/selling of shares 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: darkvater@58: byte drag_signals_density; // many signals density truelight@84: bool ainew_active; // Is the new AI active? truelight@835: truelight@835: bool population_in_label; // Show the population of a town in his label? truelight@0: } Patches; 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@193: // 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 dominik@100: Cheat build_in_pause; // build while in pause mode dominik@100: Cheat no_jetcrash; // no jet will crash on small airports anymore dominik@100: Cheat switch_climate; dominik@108: Cheat change_date; //changes date ingame miham@1176: Cheat setup_prod; //setup raw-material production in game truelight@0: } Cheats; truelight@0: truelight@0: VARDEF Cheats _cheats; truelight@0: truelight@0: typedef struct Paths { truelight@193: 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; bjarni@561: char *second_data_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@543: VARDEF GameOptions _opt_mod_temp; 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; signde@206: VARDEF uint32 _frame_counter; truelight@0: truelight@84: VARDEF bool _is_ai_player; // current player is an AI player? - Can be removed if new AI is done 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: tron@472: VARDEF uint32 _decode_parameters[20]; 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; darkvater@172: VARDEF StringID _switch_mode_errorstr; truelight@0: VARDEF bool _exit_game; truelight@0: VARDEF SmallFiosItem _file_to_saveload; truelight@0: VARDEF byte _make_screenshot; 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; darkvater@983: VARDEF char *_highscore_file; truelight@704: VARDEF char *_log_file; truelight@704: VARDEF FILE *_log_file_fd; 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: tron@534: static inline void SetDParamX(uint32 *s, uint n, uint32 v) truelight@0: { tron@534: s[n] = v; truelight@0: } truelight@0: tron@534: static inline uint32 GetDParamX(const uint32 *s, uint n) tron@534: { tron@534: return s[n]; tron@534: } truelight@0: tron@534: static inline void SetDParam(uint n, uint32 v) tron@534: { tron@534: assert(n < lengthof(_decode_parameters)); tron@534: _decode_parameters[n] = v; tron@534: } tron@534: tron@534: static inline void SetDParam64(uint n, uint64 v) tron@534: { tron@534: assert(n + 1 < lengthof(_decode_parameters)); tron@534: _decode_parameters[n + 0] = v & 0xffffffff; tron@534: _decode_parameters[n + 1] = v >> 32; tron@534: } tron@534: tron@534: static inline uint32 GetDParam(uint n) tron@534: { tron@534: assert(n < lengthof(_decode_parameters)); tron@534: return _decode_parameters[n]; tron@534: } tron@534: 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: darkvater@889: #define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x; truelight@0: truelight@0: /* landscape.c */ truelight@0: extern const byte _tileh_to_sprite[32]; 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: /* misc */ truelight@0: VARDEF byte str_buffr[512]; truelight@0: VARDEF char _screenshot_name[128]; pasky@485: #define USERSTRING_LEN 128 pasky@485: VARDEF char _userstring[USERSTRING_LEN]; truelight@0: VARDEF byte _vehicle_design_names; truelight@0: truelight@0: /* tunnelbridge */ truelight@0: #define MAX_BRIDGES 13 truelight@0: bjarni@842: /* Autoreplace vehicle stuff*/ bjarni@1128: VARDEF byte _autoreplace_array[256]; bjarni@1128: VARDEF uint16 _player_num_engines[256]; bjarni@1178: VARDEF byte _railtype_selected_in_replace_gui; bjarni@842: truelight@0: /* Debugging levels */ truelight@0: VARDEF int _debug_spritecache_level; truelight@0: VARDEF int _debug_misc_level; darkvater@65: VARDEF int _debug_grf_level; truelight@84: VARDEF int _debug_ai_level; truelight@185: VARDEF int _debug_net_level; truelight@0: truelight@704: /* Forking stuff */ truelight@704: VARDEF bool _dedicated_forks; truelight@704: VARDEF bool _dedicated_enabled; truelight@708: #ifdef UNIX truelight@708: VARDEF pid_t _dedicated_pid; truelight@708: #endif truelight@704: truelight@0: void CDECL debug(const char *s, ...); darkvater@66: #ifdef NO_DEBUG_MESSAGES darkvater@66: #define DEBUG(name, level) darkvater@66: #else darkvater@66: #define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug darkvater@66: #endif truelight@0: truelight@0: #endif /* VARIABLES_H */