openttd.c
changeset 2395 d1629f64d157
parent 2383 7589e75b873a
child 2437 15ebf7766f40
equal deleted inserted replaced
2394:cf308d5bbbe1 2395:d1629f64d157
    37 #include "screenshot.h"
    37 #include "screenshot.h"
    38 #include "network.h"
    38 #include "network.h"
    39 #include "signs.h"
    39 #include "signs.h"
    40 #include "depot.h"
    40 #include "depot.h"
    41 #include "waypoint.h"
    41 #include "waypoint.h"
       
    42 #include "ai/ai.h"
    42 
    43 
    43 #include <stdarg.h>
    44 #include <stdarg.h>
    44 
    45 
    45 #ifdef GPMI
    46 #ifdef GPMI
    46 #include <gpmi.h>
    47 #include <gpmi.h>
    48 #endif /* GPMI */
    49 #endif /* GPMI */
    49 
    50 
    50 void GenerateWorld(int mode, uint size_x, uint size_y);
    51 void GenerateWorld(int mode, uint size_x, uint size_y);
    51 void CallLandscapeTick(void);
    52 void CallLandscapeTick(void);
    52 void IncreaseDate(void);
    53 void IncreaseDate(void);
    53 void RunOtherPlayersLoop(void);
       
    54 void DoPaletteAnimations(void);
    54 void DoPaletteAnimations(void);
    55 void MusicLoop(void);
    55 void MusicLoop(void);
    56 void ResetMusic(void);
    56 void ResetMusic(void);
    57 void InitializeStations(void);
    57 void InitializeStations(void);
    58 void DeleteAllPlayerStations(void);
    58 void DeleteAllPlayerStations(void);
   450 	InitializeAirports();
   450 	InitializeAirports();
   451 
   451 
   452 	/* initialize all variables that are allocated dynamically */
   452 	/* initialize all variables that are allocated dynamically */
   453 	InitializeDynamicVariables();
   453 	InitializeDynamicVariables();
   454 
   454 
       
   455 	/* start the AI */
       
   456 	AI_Initialize();
       
   457 
   455 	// Sample catalogue
   458 	// Sample catalogue
   456 	DEBUG(misc, 1) ("Loading sound effects...");
   459 	DEBUG(misc, 1) ("Loading sound effects...");
   457 	MxInitialize(11025);
   460 	MxInitialize(11025);
   458 	SoundInitialize("sample.cat");
   461 	SoundInitialize("sample.cat");
   459 
   462 
   532 	// uninitialize airport state machines
   535 	// uninitialize airport state machines
   533 	UnInitializeAirports();
   536 	UnInitializeAirports();
   534 
   537 
   535 	/* uninitialize variables that are allocated dynamic */
   538 	/* uninitialize variables that are allocated dynamic */
   536 	UnInitializeDynamicVariables();
   539 	UnInitializeDynamicVariables();
       
   540 
       
   541 	/* stop the AI */
       
   542 	AI_Uninitialize();
   537 
   543 
   538 	/* Close all and any open filehandles */
   544 	/* Close all and any open filehandles */
   539 	FioCloseAll();
   545 	FioCloseAll();
   540 	UnInitializeGame();
   546 	UnInitializeGame();
   541 
   547 
   868 		IncreaseDate();
   874 		IncreaseDate();
   869 		RunTileLoop();
   875 		RunTileLoop();
   870 		CallVehicleTicks();
   876 		CallVehicleTicks();
   871 		CallLandscapeTick();
   877 		CallLandscapeTick();
   872 
   878 
   873 		// To bad the AI does not work in multiplayer, because states are not saved
   879 		AI_RunGameLoop();
   874 		//  perfectly
       
   875 		if (!_networking)
       
   876 			RunOtherPlayersLoop();
       
   877 
   880 
   878 		CallWindowTickEvent();
   881 		CallWindowTickEvent();
   879 		NewsLoop();
   882 		NewsLoop();
   880 		_current_player = p;
   883 		_current_player = p;
   881 	}
   884 	}