src/variables.h
branchnoai
changeset 9723 eee46cb39750
parent 9722 ebf0ece7d8f6
child 9724 b39bc69bb2f2
equal deleted inserted replaced
9722:ebf0ece7d8f6 9723:eee46cb39750
     3 /** @file variables.h */
     3 /** @file variables.h */
     4 
     4 
     5 #ifndef VARIABLES_H
     5 #ifndef VARIABLES_H
     6 #define VARIABLES_H
     6 #define VARIABLES_H
     7 
     7 
     8 #include "yapf/yapf_settings.h"
     8 #include "settings_type.h"
     9 
     9 #include "tile_type.h"
    10 /* ********* START OF SAVE REGION */
    10 #include "strings_type.h"
    11 
       
    12 #include "gfx.h"
       
    13 
       
    14 /* Prices and also the fractional part. */
       
    15 VARDEF Prices _price;
       
    16 VARDEF uint16 _price_frac[NUM_PRICES];
       
    17 
       
    18 VARDEF Money  _cargo_payment_rates[NUM_CARGO];
       
    19 VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];
       
    20 
       
    21 struct GameOptions {
       
    22 	GameDifficulty diff;
       
    23 	byte diff_level;
       
    24 	byte currency;
       
    25 	byte units;
       
    26 	byte town_name;
       
    27 	byte landscape;
       
    28 	byte snow_line;
       
    29 	byte autosave;
       
    30 	byte road_side;
       
    31 };
       
    32 
       
    33 /* These are the options for the current game
       
    34  * either ingame, or loaded. Also used for networking games */
       
    35 VARDEF GameOptions _opt;
       
    36 
       
    37 /* These are the default options for a new game */
       
    38 VARDEF GameOptions _opt_newgame;
       
    39 
       
    40 /* Pointer to one of the two _opt OR _opt_newgame structs */
       
    41 VARDEF GameOptions *_opt_ptr;
       
    42 
    11 
    43 /* Amount of game ticks */
    12 /* Amount of game ticks */
    44 VARDEF uint16 _tick_counter;
    13 VARDEF uint16 _tick_counter;
    45 
       
    46 /* This one is not used anymore. */
       
    47 VARDEF VehicleID _vehicle_id_ctr_day;
       
    48 
    14 
    49 /* Skip aging of cargo? */
    15 /* Skip aging of cargo? */
    50 VARDEF byte _age_cargo_skip_counter;
    16 VARDEF byte _age_cargo_skip_counter;
    51 
    17 
    52 /* Position in tile loop */
    18 /* Position in tile loop */
    56 VARDEF uint16 _disaster_delay;
    22 VARDEF uint16 _disaster_delay;
    57 
    23 
    58 /* Determines what station to operate on in the
    24 /* Determines what station to operate on in the
    59  *  tick handler. */
    25  *  tick handler. */
    60 VARDEF uint16 _station_tick_ctr;
    26 VARDEF uint16 _station_tick_ctr;
    61 
       
    62 VARDEF uint32 _random_seeds[2][2];
       
    63 
    27 
    64 /* Iterator through all towns in OnTick_Town */
    28 /* Iterator through all towns in OnTick_Town */
    65 VARDEF uint32 _cur_town_ctr;
    29 VARDEF uint32 _cur_town_ctr;
    66 /* Frequency iterator at the same place */
    30 /* Frequency iterator at the same place */
    67 VARDEF uint32 _cur_town_iter;
    31 VARDEF uint32 _cur_town_iter;
    73 VARDEF byte _trees_tick_ctr;
    37 VARDEF byte _trees_tick_ctr;
    74 
    38 
    75 /* Keep track of current game position */
    39 /* Keep track of current game position */
    76 VARDEF int _saved_scrollpos_x;
    40 VARDEF int _saved_scrollpos_x;
    77 VARDEF int _saved_scrollpos_y;
    41 VARDEF int _saved_scrollpos_y;
    78 
       
    79 /* ********* END OF SAVE REGION */
       
    80 
       
    81 struct Patches {
       
    82 	bool modified_catchment;            // different-size catchment areas
       
    83 	bool vehicle_speed;                 // show vehicle speed
       
    84 	bool build_on_slopes;               // allow building on slopes
       
    85 	bool mammoth_trains;                // allow very long trains
       
    86 	bool join_stations;                 // allow joining of train stations
       
    87 	bool full_load_any;                 // new full load calculation, any cargo must be full
       
    88 	bool improved_load;                 // improved loading algorithm
       
    89 	bool gradual_loading;               // load vehicles gradually
       
    90 	byte station_spread;                // amount a station may spread
       
    91 	bool inflation;                     // disable inflation
       
    92 	bool selectgoods;                   // only send the goods to station if a train has been there
       
    93 	bool longbridges;                   // allow 100 tile long bridges
       
    94 	bool gotodepot;                     // allow goto depot in orders
       
    95 	uint8 raw_industry_construction;    ///< Type of (raw) industry construction (none, "normal", prospecting)
       
    96 	bool multiple_industry_per_town;    // allow many industries of the same type per town
       
    97 	bool same_industry_close;           // allow same type industries to be built close to each other
       
    98 	bool lost_train_warn;               // if a train can't find its destination, show a warning
       
    99 	uint8 order_review_system;
       
   100 	bool train_income_warn;             // if train is generating little income, show a warning
       
   101 	bool status_long_date;              // always show long date in status bar
       
   102 	bool signal_side;                   // show signals on right side
       
   103 	bool show_finances;                 // show finances at end of year
       
   104 	bool new_nonstop;                   // ttdpatch compatible nonstop handling
       
   105 	bool roadveh_queue;                 // buggy road vehicle queueing
       
   106 	bool autoscroll;                    // scroll when moving mouse to the edge.
       
   107 	byte errmsg_duration;               // duration of error message
       
   108 	byte land_generator;                // the landscape generator
       
   109 	byte oil_refinery_limit;            // distance oil refineries allowed from map edge
       
   110 	byte snow_line_height;              // a number 0-15 that configured snow line height
       
   111 	byte tgen_smoothness;               // how rough is the terrain from 0-3
       
   112 	uint32 generation_seed;             // noise seed for world generation
       
   113 	byte tree_placer;                   // the tree placer algorithm
       
   114 	byte heightmap_rotation;            // rotation director for the heightmap
       
   115 	byte se_flat_world_height;          // land height a flat world gets in SE
       
   116 	bool bribe;                         // enable bribing the local authority
       
   117 	bool nonuniform_stations;           // allow nonuniform train stations
       
   118 	bool adjacent_stations;             // allow stations to be built directly adjacent to other stations
       
   119 	bool always_small_airport;          // always allow small airports
       
   120 	bool realistic_acceleration;        // realistic acceleration for trains
       
   121 	bool wagon_speed_limits;            // enable wagon speed limits
       
   122 	bool forbid_90_deg;                 // forbid trains to make 90 deg turns
       
   123 	bool invisible_trees;               // don't show trees when buildings are transparent
       
   124 	bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled
       
   125 	bool link_terraform_toolbar;        // display terraform toolbar when displaying rail, road, water and airport toolbars
       
   126 	bool reverse_scroll;                // Right-Click-Scrolling scrolls in the opposite direction
       
   127 	bool smooth_scroll;                 ///< Smooth scroll viewports
       
   128 	bool disable_elrails;               // when true, the elrails are disabled
       
   129 	bool measure_tooltip;               // Show a permanent tooltip when dragging tools
       
   130 	byte liveries;                      // Options for displaying company liveries, 0=none, 1=self, 2=all
       
   131 	bool prefer_teamchat;               // Choose the chat message target with <ENTER>, true=all players, false=your team
       
   132 	uint8 advanced_vehicle_list;        // Use the "advanced" vehicle list
       
   133 	uint8 loading_indicators;           // Show loading indicators
       
   134 	uint8 default_rail_type;            ///< The default rail type for the rail GUI
       
   135 
       
   136 	uint8 toolbar_pos;                  // position of toolbars, 0=left, 1=center, 2=right
       
   137 	uint8 window_snap_radius;           // Windows snap at each other if closer than this
       
   138 
       
   139 	bool always_build_infrastructure;   ///< Always allow building of infrastructure, even when you do not have the vehicles for it
       
   140 	UnitID max_trains;                  // max trains in game per player (these are 16bit because the unitnumber field can't hold more)
       
   141 	UnitID max_roadveh;                 // max trucks in game per player
       
   142 	UnitID max_aircraft;                // max planes in game per player
       
   143 	UnitID max_ships;                   // max ships in game per player
       
   144 
       
   145 	bool servint_ispercent;             // service intervals are in percents
       
   146 	uint16 servint_trains;              // service interval for trains
       
   147 	uint16 servint_roadveh;             // service interval for road vehicles
       
   148 	uint16 servint_aircraft;            // service interval for aircraft
       
   149 	uint16 servint_ships;               // service interval for ships
       
   150 
       
   151 	bool autorenew;
       
   152 	int16 autorenew_months;
       
   153 	int32 autorenew_money;
       
   154 
       
   155 	byte pf_maxdepth;                   // maximum recursion depth when searching for a train route for new pathfinder
       
   156 	uint16 pf_maxlength;                // maximum length when searching for a train route for new pathfinder
       
   157 
       
   158 
       
   159 	bool bridge_pillars;                // show bridge pillars for high bridges
       
   160 
       
   161 	bool ai_disable_veh_train;          // disable types for AI
       
   162 	bool ai_disable_veh_roadveh;        // disable types for AI
       
   163 	bool ai_disable_veh_aircraft;       // disable types for AI
       
   164 	bool ai_disable_veh_ship;           // disable types for AI
       
   165 	Year starting_year;                 // starting date
       
   166 	Year ending_year;                   // end of the game (just show highscore)
       
   167 	Year colored_news_year;             // when does newspaper become colored?
       
   168 
       
   169 	bool keep_all_autosave;             // name the autosave in a different way.
       
   170 	bool autosave_on_exit;              // save an autosave when you quit the game, but do not ask "Do you really want to quit?"
       
   171 	byte max_num_autosaves;             // controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
       
   172 	bool extra_dynamite;                // extra dynamite
       
   173 	bool road_stop_on_town_road;        // allow building of drive-through road stops on town owned roads
       
   174 
       
   175 	bool never_expire_vehicles;         // never expire vehicles
       
   176 	byte extend_vehicle_life;           // extend vehicle life by this many years
       
   177 
       
   178 	bool auto_euro;                     // automatically switch to euro in 2002
       
   179 	bool serviceathelipad;              // service helicopters at helipads automatically (no need to send to depot)
       
   180 	bool smooth_economy;                // smooth economy
       
   181 	bool allow_shares;                  // allow the buying/selling of shares
       
   182 	byte dist_local_authority;          // distance for town local authority, default 20
       
   183 
       
   184 	byte wait_oneway_signal;            // waitingtime in days before a oneway signal
       
   185 	byte wait_twoway_signal;            // waitingtime in days before a twoway signal
       
   186 
       
   187 	uint8 map_x;                        // Size of map
       
   188 	uint8 map_y;
       
   189 
       
   190 	byte drag_signals_density;          // many signals density
       
   191 	Year semaphore_build_before;        // Build semaphore signals automatically before this year
       
   192 	bool ai_in_multiplayer;             // Do we allow AIs in multiplayer
       
   193 
       
   194 	/*
       
   195 	 * New Path Finding
       
   196 	 */
       
   197 	bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */
       
   198 
       
   199 	/**
       
   200 	 * The maximum amount of search nodes a single NPF run should take. This
       
   201 	 * limit should make sure performance stays at acceptable levels at the cost
       
   202 	 * of not being perfect anymore. This will probably be fixed in a more
       
   203 	 * sophisticated way sometime soon
       
   204 	 */
       
   205 	uint32 npf_max_search_nodes;
       
   206 
       
   207 	uint32 npf_rail_firstred_penalty;      // The penalty for when the first signal is red (and it is not an exit or combo signal)
       
   208 	uint32 npf_rail_firstred_exit_penalty; // The penalty for when the first signal is red (and it is an exit or combo signal)
       
   209 	uint32 npf_rail_lastred_penalty;       // The penalty for when the last signal is red
       
   210 	uint32 npf_rail_station_penalty;       // The penalty for station tiles
       
   211 	uint32 npf_rail_slope_penalty;         // The penalty for sloping upwards
       
   212 	uint32 npf_rail_curve_penalty;         // The penalty for curves
       
   213 	uint32 npf_rail_depot_reverse_penalty; // The penalty for reversing in depots
       
   214 	uint32 npf_buoy_penalty;               // The penalty for going over (through) a buoy
       
   215 	uint32 npf_water_curve_penalty;        // The penalty for curves
       
   216 	uint32 npf_road_curve_penalty;         // The penalty for curves
       
   217 	uint32 npf_crossing_penalty;           // The penalty for level crossings
       
   218 	uint32 npf_road_drive_through_penalty; // The penalty for going through a drive-through road stop
       
   219 
       
   220 	bool population_in_label; // Show the population of a town in his label?
       
   221 
       
   222 	uint8 freight_trains; // Value to multiply the weight of cargo by
       
   223 
       
   224 	/** YAPF settings */
       
   225 	YapfSettings  yapf;
       
   226 
       
   227 	uint8 right_mouse_btn_emulation;
       
   228 
       
   229 	uint8 scrollwheel_scrolling;
       
   230 	uint8 scrollwheel_multiplier;
       
   231 
       
   232 	uint8 town_growth_rate;  ///< Town growth rate
       
   233 	uint8 larger_towns;      ///< The number of cities to build. These start off larger and grow twice as fast
       
   234 	uint8 initial_city_size; ///< Multiplier for the initial size of the cities compared to towns
       
   235 
       
   236 	bool pause_on_newgame;   ///< Whether to start new games paused or not.
       
   237 
       
   238 	TownLayoutByte town_layout;  ///< Select town layout
       
   239 
       
   240 	bool timetabling;        ///< Whether to allow timetabling.
       
   241 	bool timetable_in_ticks; ///< Whether to show the timetable in ticks rather than days.
       
   242 
       
   243 	bool autoslope;          ///< Allow terraforming under things.
       
   244 
       
   245 	bool mod_road_rebuild;   ///< Roadworks remove unneccesary RoadBits
       
   246 
       
   247 	bool exclusive_rights;   ///< allow buying exclusive rights
       
   248 	bool give_money;         ///< allow giving other players money
       
   249 };
       
   250 
       
   251 VARDEF Patches _patches;
       
   252 
       
   253 
    42 
   254 struct Cheat {
    43 struct Cheat {
   255 	bool been_used; // has this cheat been used before?
    44 	bool been_used; // has this cheat been used before?
   256 	bool value;     // tells if the bool cheat is active or not
    45 	bool value;     // tells if the bool cheat is active or not
   257 };
    46 };
   290 VARDEF int _caret_timer;
    79 VARDEF int _caret_timer;
   291 VARDEF uint32 _news_display_opt;
    80 VARDEF uint32 _news_display_opt;
   292 VARDEF bool _news_ticker_sound;
    81 VARDEF bool _news_ticker_sound;
   293 
    82 
   294 VARDEF StringID _error_message;
    83 VARDEF StringID _error_message;
   295 VARDEF Money _additional_cash_required;
       
   296 
    84 
   297 VARDEF bool _rightclick_emulate;
    85 VARDEF bool _rightclick_emulate;
   298 
    86 
   299 VARDEF PlayerFace _player_face; ///< for player face storage in openttd.cfg
    87 VARDEF PlayerFace _player_face; ///< for player face storage in openttd.cfg
   300 
    88 
   301 /* IN/OUT parameters to commands */
    89 /* IN/OUT parameters to commands */
   302 VARDEF byte _yearly_expenses_type;
       
   303 VARDEF TileIndex _terraform_err_tile;
       
   304 VARDEF TileIndex _build_tunnel_endtile;
    90 VARDEF TileIndex _build_tunnel_endtile;
   305 VARDEF bool _generating_world;
    91 VARDEF bool _generating_world;
   306 
       
   307 /* Deals with the type of the savegame, independent of extension */
       
   308 struct SmallFiosItem {
       
   309 	int mode;             // savegame/scenario type (old, new)
       
   310 	char name[MAX_PATH];  // name
       
   311 	char title[255];      // internal name of the game
       
   312 };
       
   313 
    92 
   314 /* Used when switching from the intro menu. */
    93 /* Used when switching from the intro menu. */
   315 VARDEF byte _switch_mode;
    94 VARDEF byte _switch_mode;
   316 VARDEF StringID _switch_mode_errorstr;
    95 VARDEF StringID _switch_mode_errorstr;
   317 VARDEF SmallFiosItem _file_to_saveload;
       
   318 
       
   319 
       
   320 
       
   321 VARDEF Vehicle *_place_clicked_vehicle;
       
   322 
    96 
   323 VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32], _ini_blitter[32];
    97 VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32], _ini_blitter[32];
   324 
    98 
   325 VARDEF int _num_resolutions;
    99 VARDEF int _num_resolutions;
   326 VARDEF uint16 _resolutions[32][2];
   100 VARDEF uint16 _resolutions[32][2];
   331 VARDEF char *_config_file;
   105 VARDEF char *_config_file;
   332 VARDEF char *_highscore_file;
   106 VARDEF char *_highscore_file;
   333 VARDEF char *_log_file;
   107 VARDEF char *_log_file;
   334 
   108 
   335 
   109 
   336 #define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;
       
   337 
       
   338 /* landscape.cpp */
   110 /* landscape.cpp */
   339 extern const byte _tileh_to_sprite[32];
   111 extern const byte _tileh_to_sprite[32];
   340 
       
   341 extern const TileTypeProcs * const _tile_type_procs[16];
       
   342 
   112 
   343 extern bool _draw_bounding_boxes;
   113 extern bool _draw_bounding_boxes;
   344 
   114 
   345 /* misc */
   115 /* misc */
   346 VARDEF char _screenshot_name[128];
   116 VARDEF char _screenshot_name[128];