misc.c
changeset 2989 99c95a3ebcaa
parent 2952 6a26eeda9679
child 3033 e4f7c60a1742
equal deleted inserted replaced
2988:032feb8d9d8a 2989:99c95a3ebcaa
    76 }
    76 }
    77 
    77 
    78 void SetDate(uint date)
    78 void SetDate(uint date)
    79 {
    79 {
    80 	YearMonthDay ymd;
    80 	YearMonthDay ymd;
    81 	ConvertDayToYMD(&ymd, _date = date);
    81 
       
    82 	_date = date;
       
    83 	ConvertDayToYMD(&ymd, date);
    82 	_cur_year = ymd.year;
    84 	_cur_year = ymd.year;
    83 	_cur_month = ymd.month;
    85 	_cur_month = ymd.month;
    84 #ifdef ENABLE_NETWORK
    86 #ifdef ENABLE_NETWORK
    85 	_network_last_advertise_frame = 0;
    87 	_network_last_advertise_frame = 0;
    86 	_network_need_advertise = true;
    88 	_network_need_advertise = true;
   184 	ResetObjectToPlace();
   186 	ResetObjectToPlace();
   185 }
   187 }
   186 
   188 
   187 void GenerateWorld(int mode, uint size_x, uint size_y)
   189 void GenerateWorld(int mode, uint size_x, uint size_y)
   188 {
   190 {
   189 	int i;
       
   190 
       
   191 	// Make sure everything is done via OWNER_NONE
   191 	// Make sure everything is done via OWNER_NONE
   192 	_current_player = OWNER_NONE;
   192 	_current_player = OWNER_NONE;
   193 
   193 
   194 	_generating_world = true;
   194 	_generating_world = true;
   195 	InitializeGame(mode == GW_RANDOM ? 0 : IG_DATE_RESET, size_x, size_y);
   195 	InitializeGame(mode == GW_RANDOM ? 0 : IG_DATE_RESET, size_x, size_y);
   221 	StartupDisasters();
   221 	StartupDisasters();
   222 	_generating_world = false;
   222 	_generating_world = false;
   223 
   223 
   224 	// No need to run the tile loop in the scenario editor.
   224 	// No need to run the tile loop in the scenario editor.
   225 	if (mode != GW_EMPTY) {
   225 	if (mode != GW_EMPTY) {
   226 		for (i = 0x500; i != 0; i--) RunTileLoop();
   226 		uint i;
       
   227 
       
   228 		for (i = 0; i < 0x500; i++) RunTileLoop();
   227 	}
   229 	}
   228 
   230 
   229 	ResetObjectToPlace();
   231 	ResetObjectToPlace();
   230 }
   232 }
   231 
   233 
   408 
   410 
   409 // Calculate constants that depend on the landscape type.
   411 // Calculate constants that depend on the landscape type.
   410 void InitializeLandscapeVariables(bool only_constants)
   412 void InitializeLandscapeVariables(bool only_constants)
   411 {
   413 {
   412 	const LandscapePredefVar *lpd;
   414 	const LandscapePredefVar *lpd;
   413 	int i;
   415 	uint i;
   414 	StringID str;
   416 	StringID str;
   415 
   417 
   416 	lpd = &_landscape_predef_var[_opt.landscape];
   418 	lpd = &_landscape_predef_var[_opt.landscape];
   417 
   419 
   418 	memcpy(_cargoc.ai_railwagon, lpd->railwagon_by_cargo, sizeof(lpd->railwagon_by_cargo));
   420 	memcpy(_cargoc.ai_railwagon, lpd->railwagon_by_cargo, sizeof(lpd->railwagon_by_cargo));
   485 /**
   487 /**
   486  * Runs the day_proc for every DAY_TICKS vehicle starting at daytick.
   488  * Runs the day_proc for every DAY_TICKS vehicle starting at daytick.
   487  */
   489  */
   488 static void RunVehicleDayProc(uint daytick)
   490 static void RunVehicleDayProc(uint daytick)
   489 {
   491 {
   490 	uint i, total = _vehicle_pool.total_items;
   492 	uint total = _vehicle_pool.total_items;
       
   493 	uint i;
   491 
   494 
   492 	for (i = daytick; i < total; i += DAY_TICKS) {
   495 	for (i = daytick; i < total; i += DAY_TICKS) {
   493 		Vehicle* v = GetVehicle(i);
   496 		Vehicle* v = GetVehicle(i);
   494 
   497 
   495 		if (v->type != 0) _on_new_vehicle_day_proc[v->type - 0x10](v);
   498 		if (v->type != 0) _on_new_vehicle_day_proc[v->type - 0x10](v);
   974 	}
   977 	}
   975 }
   978 }
   976 
   979 
   977 static void Load_CHTS(void)
   980 static void Load_CHTS(void)
   978 {
   981 {
   979 	Cheat* cht = (Cheat*) &_cheats;
   982 	Cheat* cht = (Cheat*)&_cheats;
   980 
   983 	uint count = SlGetFieldLength() / 2;
   981 	uint count = SlGetFieldLength()/2;
   984 	uint i;
   982 	for (; count; count--, cht++)
   985 
   983 	{
   986 	for (i = 0; i < count; i++) {
   984 		cht->been_used = (byte)SlReadByte();
   987 		cht[i].been_used = SlReadByte();
   985 		cht->value = (byte)SlReadByte();
   988 		cht[i].value     = SlReadByte();
   986 	}
   989 	}
   987 }
   990 }
   988 
   991 
   989 
   992 
   990 const ChunkHandler _misc_chunk_handlers[] = {
   993 const ChunkHandler _misc_chunk_handlers[] = {