# misc.cpp

Go to the documentation of this file.

    00001 /* $Id: misc.cpp 17158 2009-08-12 15:22:50Z 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   SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
    00063
    00064   _pause_game = 0;
    00065   _fast_forward = 0;
    00066   _tick_counter = 0;
    00067   _realtime_tick = 0;
    00068   _date_fract = 0;
    00069   _cur_tileloop_tile = 0;
    00070   _thd.redsq = INVALID_TILE;
    00071   if (reset_settings) MakeNewgameSettingsLive();
    00072
    00073   if (reset_date) {
    00074     SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
    00075     InitializeOldNames();
    00076   }
    00077
    00078   InitializeEngineRenews();
    00079   InitializeVehicles();
    00080   InitializeWaypoints();
    00081   InitializeDepots();
    00082   InitializeOrders();
    00083   InitializeGroup();
    00084
    00085   InitNewsItemStructs();
    00086   InitializeLandscape();
    00087   InitializeClearLand();
    00088   InitializeRailGui();
    00089   InitializeRoadGui();
    00090   InitializeAirportGui();
    00091   InitializeDockGui();
    00092   InitializeTowns();
    00093   InitializeTrees();
    00094   InitializeSigns();
    00095   InitializeStations();
    00096   InitializeCargoPackets();
    00097   InitializeIndustries();
    00098   InitializeBuildingCounts();
    00099
    00100   InitializeTrains();
    00101   InitializeNPF();
    00102
    00103   InitializeCompanies();
    00104   AI::Initialize();
    00105   InitializeCheats();
    00106
    00107   InitTextEffects();
    00108 #ifdef ENABLE_NETWORK
    00109   NetworkInitChatMessage();
    00110 #endif /* ENABLE_NETWORK */
    00111   InitializeAnimatedTiles();
    00112
    00113   InitializeLandscapeVariables(false);
    00114
    00115   ResetObjectToPlace();
    00116
    00117   GamelogReset();
    00118   GamelogStartAction(GLAT_START);
    00119   GamelogRevision();
    00120   GamelogMode();
    00121   GamelogGRFAddList(_grfconfig);
    00122   GamelogStopAction();
    00123 }
    00124
    00125
    00126 /* Calculate constants that depend on the landscape type. */
    00127 void InitializeLandscapeVariables(bool only_constants)
    00128 {
    00129   if (only_constants) return;
    00130
    00131   for (CargoID i = 0; i < NUM_CARGO; i++) {
    00132     _cargo_payment_rates[i] = GetCargo(i)->initial_payment;
    00133     _cargo_payment_rates_frac[i] = 0;
    00134   }
    00135 }