2005-07-24 15:12:37 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 16:11:33 +01:00
|
|
|
/** @file misc.cpp Misc functions that shouldn't be here. */
|
2007-03-03 04:04:22 +00:00
|
|
|
|
2004-08-09 18:04:08 +01:00
|
|
|
#include "stdafx.h"
|
2005-06-02 20:30:21 +01:00
|
|
|
#include "openttd.h"
|
2005-08-07 15:45:50 +01:00
|
|
|
#include "currency.h"
|
2007-04-12 14:07:15 +01:00
|
|
|
#include "landscape.h"
|
2008-03-28 08:53:36 +00:00
|
|
|
#include "news_func.h"
|
2005-05-03 00:59:11 +01:00
|
|
|
#include "vehicle_gui.h"
|
2005-07-21 23:15:02 +01:00
|
|
|
#include "variables.h"
|
2008-04-17 22:21:01 +01:00
|
|
|
#include "cheat_func.h"
|
2005-11-30 16:10:19 +00:00
|
|
|
#include "ai/ai.h"
|
2007-03-19 11:27:30 +00:00
|
|
|
#include "newgrf_house.h"
|
2007-02-20 22:09:21 +00:00
|
|
|
#include "cargotype.h"
|
2007-05-19 10:40:18 +01:00
|
|
|
#include "group.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2007-12-21 22:50:51 +00:00
|
|
|
#include "economy_func.h"
|
2007-12-23 10:56:02 +00:00
|
|
|
#include "zoom_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "functions.h"
|
2007-12-26 11:45:43 +00:00
|
|
|
#include "map_func.h"
|
2007-12-26 13:50:40 +00:00
|
|
|
#include "date_func.h"
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_func.h"
|
|
|
|
#include "texteff.hpp"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "gfx_func.h"
|
2008-04-13 20:25:14 +01:00
|
|
|
#include "core/alloc_type.hpp"
|
2008-06-03 19:35:58 +01:00
|
|
|
#include "gamelog.h"
|
2008-04-20 09:22:59 +01:00
|
|
|
#include "animated_tile_func.h"
|
2008-05-07 14:10:15 +01:00
|
|
|
#include "tilehighlight_func.h"
|
2008-05-17 21:54:18 +01:00
|
|
|
#include "core/bitmath_func.hpp"
|
2008-08-11 23:45:11 +01:00
|
|
|
#include "network/network_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/sprites.h"
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-04-18 11:16:51 +01:00
|
|
|
extern TileIndex _cur_tileloop_tile;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeVehicles();
|
|
|
|
void InitializeWaypoints();
|
|
|
|
void InitializeDepots();
|
2008-09-13 16:49:29 +01:00
|
|
|
void InitializeEngineRenews();
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeOrders();
|
|
|
|
void InitializeClearLand();
|
|
|
|
void InitializeRailGui();
|
|
|
|
void InitializeRoadGui();
|
|
|
|
void InitializeAirportGui();
|
|
|
|
void InitializeDockGui();
|
|
|
|
void InitializeIndustries();
|
|
|
|
void InitializeTowns();
|
|
|
|
void InitializeTrees();
|
|
|
|
void InitializeSigns();
|
|
|
|
void InitializeStations();
|
2007-06-22 12:58:59 +01:00
|
|
|
void InitializeCargoPackets();
|
2008-09-30 21:39:50 +01:00
|
|
|
void InitializeCompanies();
|
2008-04-17 22:21:01 +01:00
|
|
|
void InitializeCheats();
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeNPF();
|
2008-04-19 09:21:55 +01:00
|
|
|
void InitializeOldNames();
|
2005-01-22 20:23:18 +00:00
|
|
|
|
2008-05-29 10:54:47 +01:00
|
|
|
void InitializeGame(uint size_x, uint size_y, bool reset_date)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2005-07-13 20:51:31 +01:00
|
|
|
AllocateMap(size_x, size_y);
|
|
|
|
|
2007-11-15 18:28:00 +00:00
|
|
|
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-06 20:59:52 +00:00
|
|
|
_pause_game = 0;
|
2004-08-09 18:04:08 +01:00
|
|
|
_fast_forward = 0;
|
|
|
|
_tick_counter = 0;
|
2007-06-22 21:04:21 +01:00
|
|
|
_realtime_tick = 0;
|
2004-08-09 18:04:08 +01:00
|
|
|
_date_fract = 0;
|
|
|
|
_cur_tileloop_tile = 0;
|
2008-05-29 16:13:28 +01:00
|
|
|
_settings_game = _settings_newgame;
|
2004-09-11 10:55:19 +01:00
|
|
|
|
2008-05-29 10:54:47 +01:00
|
|
|
if (reset_date) {
|
2008-05-29 16:13:28 +01:00
|
|
|
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
|
2008-05-04 23:19:44 +01:00
|
|
|
InitializeOldNames();
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2008-09-13 16:49:29 +01:00
|
|
|
InitializeEngineRenews();
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeVehicles();
|
2005-03-24 17:03:37 +00:00
|
|
|
InitializeWaypoints();
|
2006-08-22 16:39:22 +01:00
|
|
|
InitializeDepots();
|
2005-01-15 19:06:22 +00:00
|
|
|
InitializeOrders();
|
2007-05-19 10:40:18 +01:00
|
|
|
InitializeGroup();
|
2004-08-09 18:04:08 +01:00
|
|
|
|
|
|
|
InitNewsItemStructs();
|
2005-07-13 20:51:31 +01:00
|
|
|
InitializeLandscape();
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeClearLand();
|
|
|
|
InitializeRailGui();
|
|
|
|
InitializeRoadGui();
|
|
|
|
InitializeAirportGui();
|
|
|
|
InitializeDockGui();
|
|
|
|
InitializeTowns();
|
|
|
|
InitializeTrees();
|
2005-01-12 11:21:28 +00:00
|
|
|
InitializeSigns();
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeStations();
|
2007-06-22 12:58:59 +01:00
|
|
|
InitializeCargoPackets();
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeIndustries();
|
2007-03-19 11:27:30 +00:00
|
|
|
InitializeBuildingCounts();
|
2004-09-11 10:55:19 +01:00
|
|
|
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeTrains();
|
2005-01-31 11:23:10 +00:00
|
|
|
InitializeNPF();
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-09-30 21:39:50 +01:00
|
|
|
InitializeCompanies();
|
2008-07-18 17:40:29 +01:00
|
|
|
AI_Initialize();
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeCheats();
|
|
|
|
|
|
|
|
InitTextEffects();
|
2008-08-11 23:45:11 +01:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
NetworkInitChatMessage();
|
|
|
|
#endif /* ENABLE_NETWORK */
|
2004-08-09 18:04:08 +01:00
|
|
|
InitializeAnimatedTiles();
|
|
|
|
|
|
|
|
InitializeLandscapeVariables(false);
|
|
|
|
|
|
|
|
ResetObjectToPlace();
|
2008-06-03 19:35:58 +01:00
|
|
|
|
|
|
|
GamelogReset();
|
|
|
|
GamelogStartAction(GLAT_START);
|
|
|
|
GamelogRevision();
|
|
|
|
GamelogMode();
|
|
|
|
GamelogGRFAddList(_grfconfig);
|
|
|
|
GamelogStopAction();
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
|
2007-03-03 04:04:22 +00:00
|
|
|
/* Calculate constants that depend on the landscape type. */
|
2004-08-09 18:04:08 +01:00
|
|
|
void InitializeLandscapeVariables(bool only_constants)
|
|
|
|
{
|
2007-02-20 22:09:21 +00:00
|
|
|
if (only_constants) return;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-21 13:19:01 +00:00
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
2007-02-20 22:09:21 +00:00
|
|
|
_cargo_payment_rates[i] = GetCargo(i)->initial_payment;
|
|
|
|
_cargo_payment_rates_frac[i] = 0;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
}
|