tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef VARIABLES_H truelight@0: #define VARIABLES_H truelight@0: KUDr@3900: #include "yapf/yapf_settings.h" KUDr@3900: truelight@0: // ********* START OF SAVE REGION truelight@0: #if !defined(MAX_PATH) truelight@0: # define MAX_PATH 260 truelight@0: #endif truelight@0: celestar@5936: #include "gfx.h" celestar@5936: 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; peter1138@3342: byte units; 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: Darkvater@1500: /* These are the options for the current game Darkvater@1500: * either ingame, or loaded. Also used for networking games */ truelight@0: VARDEF GameOptions _opt; truelight@0: Darkvater@1500: /* These are the default options for a new game */ Darkvater@1500: VARDEF GameOptions _opt_newgame; Darkvater@1500: Darkvater@1500: // Pointer to one of the two _opt OR _opt_newgame structs Darkvater@1500: VARDEF GameOptions *_opt_ptr; truelight@0: truelight@0: // Amount of game ticks truelight@0: VARDEF uint16 _tick_counter; truelight@0: ludde@2090: // This one is not used anymore. 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: // 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]; ludde@2073: truelight@0: // Iterator through all towns in OnTick_Town pasky@1517: VARDEF uint32 _cur_town_ctr; pasky@1529: // Frequency iterator at the same place pasky@1529: VARDEF uint32 _cur_town_iter; 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 { rubidium@4344: bool modified_catchment; // different-size catchment areas rubidium@4344: bool vehicle_speed; // show vehicle speed rubidium@4344: bool build_on_slopes; // allow building on slopes rubidium@4344: bool mammoth_trains; // allow very long trains rubidium@4344: bool join_stations; // allow joining of train stations rubidium@4344: bool full_load_any; // new full load calculation, any cargo must be full rubidium@4344: bool improved_load; // improved loading algorithm peter1138@5211: bool gradual_loading; // load vehicles gradually rubidium@4344: byte station_spread; // amount a station may spread rubidium@4344: bool inflation; // disable inflation rubidium@4344: bool selectgoods; // only send the goods to station if a train has been there rubidium@4344: bool longbridges; // allow 100 tile long bridges rubidium@4344: bool gotodepot; // allow goto depot in orders rubidium@4344: bool build_rawmaterial_ind; // allow building raw material industries rubidium@4344: bool multiple_industry_per_town; // allow many industries of the same type per town rubidium@4344: bool same_industry_close; // allow same type industries to be built close to each other KUDr@4870: bool lost_train_warn; // if a train can't find its destination, show a warning dominik@55: uint8 order_review_system; rubidium@4344: bool train_income_warn; // if train is generating little income, show a warning rubidium@4344: bool status_long_date; // always show long date in status bar rubidium@4344: bool signal_side; // show signals on right side rubidium@4344: bool show_finances; // show finances at end of year rubidium@4344: bool new_nonstop; // ttdpatch compatible nonstop handling rubidium@4344: bool roadveh_queue; // buggy road vehicle queueing rubidium@4344: bool autoscroll; // scroll when moving mouse to the edge. rubidium@4344: byte errmsg_duration; // duration of error message rubidium@4344: byte land_generator; // the landscape generator rubidium@4344: byte oil_refinery_limit; // distance oil refineries allowed from map edge rubidium@4344: byte snow_line_height; // a number 0-15 that configured snow line height rubidium@4344: byte tgen_smoothness; // how rough is the terrain from 0-3 rubidium@4344: uint32 generation_seed; // noise seed for world generation rubidium@4344: byte tree_placer; // the tree placer algorithm rubidium@4344: byte heightmap_rotation; // rotation director for the heightmap rubidium@4344: byte se_flat_world_height; // land height a flat world gets in SE rubidium@4344: bool bribe; // enable bribing the local authority rubidium@4344: bool nonuniform_stations; // allow nonuniform train stations rubidium@4344: bool always_small_airport; // always allow small airports rubidium@4344: bool realistic_acceleration; // realistic acceleration for trains rubidium@4344: bool wagon_speed_limits; // enable wagon speed limits rubidium@4344: bool forbid_90_deg; // forbid trains to make 90 deg turns rubidium@4344: 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 rubidium@4344: bool link_terraform_toolbar; // display terraform toolbar when displaying rail, road, water and airport toolbars rubidium@4344: bool reverse_scroll; // Right-Click-Scrolling scrolls in the opposite direction KUDr@5116: bool disable_elrails; // when true, the elrails are disabled Darkvater@4834: bool measure_tooltip; // Show a permanent tooltip when dragging tools peter1138@4616: byte liveries; // Options for displaying company liveries, 0=none, 1=self, 2=all Darkvater@5107: bool prefer_teamchat; // Choose the chat message target with , true=all players, false=your team truelight@0: rubidium@4344: uint8 toolbar_pos; // position of toolbars, 0=left, 1=center, 2=right rubidium@4344: uint8 window_snap_radius; // Windows snap at each other if closer than this truelight@0: rubidium@4344: UnitID max_trains; // max trains in game per player (these are 16bit because the unitnumber field can't hold more) rubidium@4344: UnitID max_roadveh; // max trucks in game per player rubidium@4344: UnitID max_aircraft; // max planes in game per player rubidium@4344: UnitID max_ships; // max ships in game per player rubidium@4344: rubidium@4344: bool servint_ispercent; // service intervals are in percents rubidium@4344: uint16 servint_trains; // service interval for trains rubidium@4344: uint16 servint_roadveh; // service interval for road vehicles rubidium@4344: uint16 servint_aircraft; // service interval for aircraft rubidium@4344: 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: rubidium@4344: byte pf_maxdepth; // maximum recursion depth when searching for a train route for new pathfinder rubidium@4344: uint16 pf_maxlength; // maximum length when searching for a train route for new pathfinder truelight@0: truelight@193: rubidium@4344: bool bridge_pillars; // show bridge pillars for high bridges truelight@0: rubidium@4344: bool ai_disable_veh_train; // disable types for AI rubidium@4344: bool ai_disable_veh_roadveh; // disable types for AI rubidium@4344: bool ai_disable_veh_aircraft; // disable types for AI rubidium@4344: bool ai_disable_veh_ship; // disable types for AI rubidium@4344: Year starting_year; // starting date rubidium@4344: Year ending_year; // end of the game (just show highscore) rubidium@4344: Year colored_news_year; // when does newspaper become colored? truelight@0: rubidium@4344: bool keep_all_autosave; // name the autosave in a different way. rubidium@4344: bool autosave_on_exit; // save an autosave when you quit the game, but do not ask "Do you really want to quit?" rubidium@4344: byte max_num_autosaves; // controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1) rubidium@4344: bool extra_dynamite; // extra dynamite KUDr@6254: bool road_stop_on_town_road; // allow building of drive-through road stops on town owned roads truelight@0: rubidium@4344: bool never_expire_vehicles; // never expire vehicles rubidium@4344: byte extend_vehicle_life; // extend vehicle life by this many years truelight@0: rubidium@4344: bool auto_euro; // automatically switch to euro in 2002 rubidium@4344: bool serviceathelipad; // service helicopters at helipads automatically (no need to send to depot) rubidium@4344: bool smooth_economy; // smooth economy rubidium@4344: bool allow_shares; // allow the buying/selling of shares rubidium@4344: byte dist_local_authority; // distance for town local authority, default 20 rubidium@4344: rubidium@4344: byte wait_oneway_signal; // waitingtime in days before a oneway signal rubidium@4344: byte wait_twoway_signal; // waitingtime in days before a twoway signal rubidium@4344: rubidium@4344: uint8 map_x; // Size of map bjarni@3126: uint8 map_y; tron@1218: rubidium@4344: byte drag_signals_density; // many signals density maedhros@5939: Year semaphore_build_before; // Build semaphore signals automatically before this year rubidium@4344: bool ainew_active; // Is the new AI active? rubidium@4344: bool ai_in_multiplayer; // Do we allow AIs in multiplayer truelight@835: matthijs@1700: /* rubidium@4549: * New Path Finding rubidium@4549: */ matthijs@1247: bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */ matthijs@1247: matthijs@1700: /** rubidium@4549: * The maximum amount of search nodes a single NPF run should take. This rubidium@4549: * limit should make sure performance stays at acceptable levels at the cost rubidium@4549: * of not being perfect anymore. This will probably be fixed in a more rubidium@4549: * sophisticated way sometime soon rubidium@4549: */ matthijs@1700: uint32 npf_max_search_nodes; matthijs@1700: rubidium@4344: uint32 npf_rail_firstred_penalty; /* The penalty for when the first signal is red (and it is not an exit or combo signal) */ matthijs@1643: uint32 npf_rail_firstred_exit_penalty; /* The penalty for when the first signal is red (and it is an exit or combo signal) */ rubidium@4344: uint32 npf_rail_lastred_penalty; /* The penalty for when the last signal is red */ rubidium@4344: uint32 npf_rail_station_penalty; /* The penalty for station tiles */ rubidium@4344: uint32 npf_rail_slope_penalty; /* The penalty for sloping upwards */ rubidium@4344: uint32 npf_rail_curve_penalty; /* The penalty for curves */ matthijs@1777: uint32 npf_rail_depot_reverse_penalty; /* The penalty for reversing in depots */ rubidium@4344: uint32 npf_buoy_penalty; /* The penalty for going over (through) a buoy */ rubidium@4344: uint32 npf_water_curve_penalty; /* The penalty for curves */ rubidium@4344: uint32 npf_road_curve_penalty; /* The penalty for curves */ rubidium@4344: uint32 npf_crossing_penalty; /* The penalty for level crossings */ KUDr@6254: uint32 npf_road_drive_through_penalty; /* The penalty for going through a drive-through road stop */ matthijs@1247: truelight@835: bool population_in_label; // Show the population of a town in his label? KUDr@3900: peter1138@5163: uint8 freight_trains; ///< Value to multiply the weight of cargo by peter1138@5163: KUDr@3900: /** YAPF settings */ KUDr@3900: YapfSettings yapf; KUDr@3900: truelight@0: } Patches; truelight@0: truelight@0: VARDEF Patches _patches; truelight@0: truelight@0: truelight@0: typedef struct Cheat { bjarni@4237: bool been_used; // has this cheat been used before? bjarni@4237: bool value; // tells if the bool cheat is active or not 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 { rubidium@4344: Cheat magic_bulldozer; // dynamite industries, unmovables rubidium@4344: Cheat switch_player; // change to another player rubidium@4344: Cheat money; // get rich rubidium@4344: Cheat crossing_tunnels; // allow tunnels that cross each other rubidium@4344: Cheat build_in_pause; // build while in pause mode rubidium@4344: Cheat no_jetcrash; // no jet will crash on small airports anymore dominik@100: Cheat switch_climate; rubidium@4344: Cheat change_date; // changes date ingame rubidium@4344: Cheat setup_prod; // setup raw-material production in game KUDr@5116: Cheat dummy; // empty cheat (enable running el-engines on normal rail) 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; truelight@4300: char *heightmap_dir; bjarni@561: char *second_data_dir; truelight@0: } Paths; truelight@0: Darkvater@5296: VARDEF Paths _paths; truelight@0: truelight@0: // NOSAVE: Used in palette animations only, not really important. truelight@0: VARDEF int _timer_counter; truelight@0: truelight@0: signde@206: VARDEF uint32 _frame_counter; truelight@0: truelight@2422: VARDEF bool _is_old_ai_player; // current player is an oldAI player? (enables a lot of cheats..) truelight@0: truelight@0: VARDEF bool _do_autosave; truelight@0: VARDEF int _autosave_ctr; truelight@0: truelight@0: VARDEF byte _display_opt; truelight@0: VARDEF int _caret_timer; Darkvater@1688: VARDEF uint32 _news_display_opt; Darkvater@1688: VARDEF bool _news_ticker_sound; truelight@0: truelight@0: VARDEF StringID _error_message; truelight@0: VARDEF int32 _additional_cash_required; truelight@0: tron@472: VARDEF uint32 _decode_parameters[20]; truelight@0: 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; tron@1977: VARDEF TileIndex _build_tunnel_endtile; truelight@0: VARDEF bool _generating_world; truelight@0: truelight@0: // Deals with the type of the savegame, independent of extension truelight@0: typedef struct { Darkvater@2099: int mode; // savegame/scenario type (old, new) Darkvater@2099: char name[MAX_PATH]; // name Darkvater@2099: char title[255]; // internal name of the game 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 SmallFiosItem _file_to_saveload; truelight@0: truelight@0: truelight@0: truelight@0: VARDEF Vehicle *_place_clicked_vehicle; truelight@0: Darkvater@6136: VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32]; 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 peter1138@5108: char curr_file[MAX_LANG]; // currently selected language file peter1138@5108: StringID dropdown[MAX_LANG + 1]; // used in settings dialog Darkvater@1500: struct { Darkvater@1500: char *name; Darkvater@1500: char *file; peter1138@5108: } ent[MAX_LANG]; 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 _savegame_format[8]; truelight@0: truelight@0: VARDEF char *_config_file; darkvater@983: VARDEF char *_highscore_file; truelight@704: VARDEF char *_log_file; 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: ludde@2055: // Used to bind a C string name to a dparam number. ludde@2055: // NOTE: This has a short lifetime. You can't ludde@2055: // use this string much later or it will be gone. ludde@2055: void SetDParamStr(uint n, const char *str); ludde@2055: ludde@2055: // This function takes a C-string and allocates a temporary string ID. ludde@2055: // The duration of the bound string is valid only until the next acll to GetString, ludde@2055: // so be careful. ludde@2055: StringID BindCString(const char *str); ludde@2055: 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: 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]; rubidium@5838: extern const Slope _inclined_tileh[16]; truelight@0: truelight@0: extern const TileTypeProcs * const _tile_type_procs[16]; truelight@0: truelight@0: /* misc */ truelight@0: VARDEF char _screenshot_name[128]; truelight@0: VARDEF byte _vehicle_design_names; truelight@0: truelight@704: /* Forking stuff */ truelight@704: VARDEF bool _dedicated_forks; truelight@704: truelight@0: #endif /* VARIABLES_H */