tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef VARIABLES_H truelight@0: #define VARIABLES_H truelight@0: truelight@0: // ********* START OF SAVE REGION 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: 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: // 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: 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: // 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]; 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 { 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 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 peter1138@2456: bool wagon_speed_limits; // enable wagon speed limits matthijs@1247: bool forbid_90_deg; // forbid trains to make 90 deg turns 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 peter1138@2619: bool link_terraform_toolbar; // display terraform toolbar when displaying rail, road, water and airport toolbars tron@2680: bool reverse_scroll; // Right-Click-Scrolling scrolls in the opposite direction 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@1282: UnitID max_trains; //max trains in game per player (these are 16bit because the unitnumber field can't hold more) truelight@1282: UnitID max_roadveh; //max trucks in game per player truelight@1282: UnitID max_aircraft; //max planes in game per player truelight@1282: UnitID 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: 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?" bjarni@2672: byte max_num_autosaves; // controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1) 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: tron@1218: uint map_x; // Size of map tron@1218: uint map_y; tron@1218: darkvater@58: byte drag_signals_density; // many signals density truelight@84: bool ainew_active; // Is the new AI active? truelight@2682: bool ai_in_multiplayer; // Do we allow AIs in multiplayer truelight@835: matthijs@1700: /* matthijs@1700: * New Path Finding matthijs@1700: */ matthijs@1247: bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */ matthijs@1247: matthijs@1700: /** matthijs@1700: * The maximum amount of search nodes a single NPF run should take. This matthijs@1700: * limit should make sure performance stays at acceptable levels at the cost matthijs@1700: * of not being perfect anymore. This will probably be fixed in a more matthijs@1700: * sophisticated way sometime soon matthijs@1700: */ matthijs@1700: uint32 npf_max_search_nodes; matthijs@1700: matthijs@1643: 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) */ matthijs@1459: uint32 npf_rail_lastred_penalty; /* The penalty for when the last signal is red */ matthijs@1247: uint32 npf_rail_station_penalty; /* The penalty for station tiles */ matthijs@1247: uint32 npf_rail_slope_penalty; /* The penalty for sloping upwards */ matthijs@1460: uint32 npf_rail_curve_penalty; /* The penalty for curves */ matthijs@1777: uint32 npf_rail_depot_reverse_penalty; /* The penalty for reversing in depots */ matthijs@1751: uint32 npf_buoy_penalty; /* The penalty for going over (through) a buoy */ matthijs@1751: uint32 npf_water_curve_penalty; /* The penalty for curves */ matthijs@1941: uint32 npf_road_curve_penalty; /* The penalty for curves */ matthijs@2006: uint32 npf_crossing_penalty; /* The penalty for level crossings */ matthijs@1247: 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: // 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: 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 byte _pause; truelight@0: VARDEF int _caret_timer; Darkvater@1688: VARDEF uint32 _news_display_opt; Darkvater@1688: VARDEF bool _news_ticker_sound; 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: 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; tron@1977: VARDEF TileIndex _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 { 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 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: // 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: // 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 Darkvater@1500: struct { Darkvater@1500: char *name; Darkvater@1500: char *file; Darkvater@1500: } 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 _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: // NOSAVE: These can be recalculated from InitializeLandscapeVariables truelight@0: typedef struct { truelight@0: StringID names_s[NUM_CARGO]; ludde@2084: StringID names_long[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: 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]; tron@1958: extern const byte _inclined_tileh[8]; 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 tron@1417: extern const byte _airport_size_x[]; tron@1417: extern const byte _airport_size_y[]; truelight@0: truelight@0: /* misc */ truelight@0: VARDEF char _screenshot_name[128]; truelight@0: VARDEF byte _vehicle_design_names; truelight@0: truelight@0: /* tunnelbridge */ truelight@0: #define MAX_BRIDGES 13 truelight@0: matthijs@1777: /* For new pathfinding. Define here so it is globally available without having matthijs@1777: * to include npf.h */ matthijs@1247: #define NPF_TILE_LENGTH 100 matthijs@1247: truelight@704: /* Forking stuff */ truelight@704: VARDEF bool _dedicated_forks; truelight@704: truelight@0: #endif /* VARIABLES_H */