# misc.cpp

Go to the documentation of this file.

    00001 /* $Id: misc.cpp 18300 2009-11-26 16:53:41Z rubidium $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "openttd.h"
    00007 #include "landscape.h"
    00008 #include "news_func.h"
    00009 #include "variables.h"
    00010 #include "ai/ai.hpp"
    00011 #include "newgrf_house.h"
    00012 #include "cargotype.h"
    00013 #include "group.h"
    00014 #include "economy_func.h"
    00015 #include "functions.h"
    00016 #include "map_func.h"
    00017 #include "date_func.h"
    00018 #include "vehicle_func.h"
    00019 #include "texteff.hpp"
    00020 #include "gfx_func.h"
    00021 #include "gamelog.h"
    00022 #include "animated_tile_func.h"
    00023 #include "settings_type.h"
    00024 #include "tilehighlight_func.h"
    00025 #include "network/network_func.h"
    00026 #include "window_func.h"
    00027
    00028 #include "table/sprites.h"
    00029
    00030 extern TileIndex _cur_tileloop_tile;
    00031 extern void MakeNewgameSettingsLive();
    00032
    00033 void InitializeVehicles();
    00034 void InitializeWaypoints();
    00035 void InitializeDepots();
    00036 void InitializeEngineRenews();
    00037 void InitializeOrders();
    00038 void InitializeClearLand();
    00039 void InitializeRailGui();
    00040 void InitializeRoadGui();
    00041 void InitializeAirportGui();
    00042 void InitializeDockGui();
    00043 void InitializeIndustries();
    00044 void InitializeTowns();
    00045 void InitializeTrees();
    00046 void InitializeSigns();
    00047 void InitializeStations();
    00048 void InitializeCargoPackets();
    00049 void InitializeCompanies();
    00050 void InitializeCheats();
    00051 void InitializeNPF();
    00052 void InitializeOldNames();
    00053
    00054 void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
    00055 {
    00056   /* Make sure there isn't any window that can influence anything
    00057    * related to the new game we're about to start/load. */
    00058   UnInitWindowSystem();
    00059
    00060   AllocateMap(size_x, size_y);
    00061
    00062   _pause_game = 0;
    00063   _fast_forward = 0;
    00064   _tick_counter = 0;
    00065   _realtime_tick = 0;
    00066   _date_fract = 0;
    00067   _cur_tileloop_tile = 0;
    00068   _thd.redsq = INVALID_TILE;
    00069   if (reset_settings) MakeNewgameSettingsLive();
    00070
    00071   if (reset_date) {
    00072     SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
    00073     InitializeOldNames();
    00074   }
    00075
    00076   InitializeEngineRenews();
    00077   InitializeVehicles();
    00078   InitializeWaypoints();
    00079   InitializeDepots();
    00080   InitializeOrders();
    00081   InitializeGroup();
    00082
    00083   InitNewsItemStructs();
    00084   InitializeLandscape();
    00085   InitializeClearLand();
    00086   InitializeRailGui();
    00087   InitializeRoadGui();
    00088   InitializeAirportGui();
    00089   InitializeDockGui();
    00090   InitializeTowns();
    00091   InitializeTrees();
    00092   InitializeSigns();
    00093   InitializeStations();
    00094   InitializeCargoPackets();
    00095   InitializeIndustries();
    00096   InitializeBuildingCounts();
    00097
    00098   InitializeTrains();
    00099   InitializeNPF();
    00100
    00101   InitializeCompanies();
    00102   AI::Initialize();
    00103   InitializeCheats();
    00104
    00105   InitTextEffects();
    00106 #ifdef ENABLE_NETWORK
    00107   NetworkInitChatMessage();
    00108 #endif /* ENABLE_NETWORK */
    00109   InitializeAnimatedTiles();
    00110
    00111   InitializeLandscapeVariables(false);
    00112
    00113   ResetObjectToPlace();
    00114
    00115   GamelogReset();
    00116   GamelogStartAction(GLAT_START);
    00117   GamelogRevision();
    00118   GamelogMode();
    00119   GamelogGRFAddList(_grfconfig);
    00120   GamelogStopAction();
    00121 }
    00122
    00123
    00124 /* Calculate constants that depend on the landscape type. */
    00125 void InitializeLandscapeVariables(bool only_constants)
    00126 {
    00127   if (only_constants) return;
    00128
    00129   for (CargoID i = 0; i < NUM_CARGO; i++) {
    00130     _cargo_payment_rates[i] = GetCargo(i)->initial_payment;
    00131     _cargo_payment_rates_frac[i] = 0;
    00132   }
    00133 }