misc.c
changeset 2828 996de8e891c7
parent 2706 d31bd0aa0096
child 2848 cb4b1cc0bf65
equal deleted inserted replaced
2827:61e2ac8b0801 2828:996de8e891c7
   120 void StartupDisasters(void);
   120 void StartupDisasters(void);
   121 void GenerateTrees(void);
   121 void GenerateTrees(void);
   122 
   122 
   123 void ConvertGroundTilesIntoWaterTiles(void);
   123 void ConvertGroundTilesIntoWaterTiles(void);
   124 
   124 
   125 void InitializeGame(uint size_x, uint size_y)
   125 void InitializeGame(int mode, uint size_x, uint size_y)
   126 {
   126 {
   127 	AllocateMap(size_x, size_y);
   127 	AllocateMap(size_x, size_y);
   128 
   128 
   129 	AddTypeToEngines(); // make sure all engines have a type
   129 	AddTypeToEngines(); // make sure all engines have a type
   130 
   130 
   134 	_fast_forward = 0;
   134 	_fast_forward = 0;
   135 	_tick_counter = 0;
   135 	_tick_counter = 0;
   136 	_date_fract = 0;
   136 	_date_fract = 0;
   137 	_cur_tileloop_tile = 0;
   137 	_cur_tileloop_tile = 0;
   138 
   138 
   139 	{
   139 	if ((mode & IG_DATE_RESET) == IG_DATE_RESET) {
   140 		uint starting = ConvertIntDate(_patches.starting_date);
   140 		uint starting = ConvertIntDate(_patches.starting_date);
   141 		if ( starting == (uint)-1) starting = 10958;
   141 		if ( starting == (uint)-1) starting = 10958;
   142 		SetDate(starting);
   142 		SetDate(starting);
   143 	}
   143 	}
   144 
   144 
   187 
   187 
   188 	// Make sure everything is done via OWNER_NONE
   188 	// Make sure everything is done via OWNER_NONE
   189 	_current_player = OWNER_NONE;
   189 	_current_player = OWNER_NONE;
   190 
   190 
   191 	_generating_world = true;
   191 	_generating_world = true;
   192 	InitializeGame(size_x, size_y);
   192 	InitializeGame(mode == GW_RANDOM ? 0 : IG_DATE_RESET, size_x, size_y);
   193 	SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0);
   193 	SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0);
   194 
   194 
   195 	// Must start economy early because of the costs.
   195 	// Must start economy early because of the costs.
   196 	StartupEconomy();
   196 	StartupEconomy();
   197 
   197 
   198 	// Don't generate landscape items when in the scenario editor.
   198 	// Don't generate landscape items when in the scenario editor.
   199 	if (mode == 1) {
   199 	if (mode == GW_EMPTY) {
   200 		// empty world in scenario editor
   200 		// empty world in scenario editor
   201 		ConvertGroundTilesIntoWaterTiles();
   201 		ConvertGroundTilesIntoWaterTiles();
   202 	} else {
   202 	} else {
   203 		GenerateLandscape();
   203 		GenerateLandscape();
   204 		GenerateClearTile();
   204 		GenerateClearTile();
   205 
   205 
   206 		// only generate towns, tree and industries in newgame mode.
   206 		// only generate towns, tree and industries in newgame mode.
   207 		if (mode == 0) {
   207 		if (mode == GW_NEWGAME) {
   208 			GenerateTowns();
   208 			GenerateTowns();
   209 			GenerateTrees();
   209 			GenerateTrees();
   210 			GenerateIndustries();
   210 			GenerateIndustries();
   211 			GenerateUnmovables();
   211 			GenerateUnmovables();
   212 		}
   212 		}
   217 	StartupEngines();
   217 	StartupEngines();
   218 	StartupDisasters();
   218 	StartupDisasters();
   219 	_generating_world = false;
   219 	_generating_world = false;
   220 
   220 
   221 	// No need to run the tile loop in the scenario editor.
   221 	// No need to run the tile loop in the scenario editor.
   222 	if (mode != 1) {
   222 	if (mode != GW_EMPTY) {
   223 		for(i=0x500; i!=0; i--)
   223 		for(i=0x500; i!=0; i--)
   224 			RunTileLoop();
   224 			RunTileLoop();
   225 	}
   225 	}
   226 
   226 
   227 	ResetObjectToPlace();
   227 	ResetObjectToPlace();