src/engine.cpp
branchcustombridgeheads
changeset 5650 aefc131bf5ce
parent 5649 55c8267c933f
child 6014 f3f333d167c4
equal deleted inserted replaced
5649:55c8267c933f 5650:aefc131bf5ce
   127 
   127 
   128 	for (e = _engines, ei = _engine_info; e != endof(_engines); e++, ei++) {
   128 	for (e = _engines, ei = _engine_info; e != endof(_engines); e++, ei++) {
   129 		uint32 r;
   129 		uint32 r;
   130 
   130 
   131 		e->age = 0;
   131 		e->age = 0;
   132 		e->railtype = ei->railtype;
   132 		e->railtype = (RailType)ei->railtype;
   133 		e->flags = 0;
   133 		e->flags = 0;
   134 		e->player_avail = 0;
   134 		e->player_avail = 0;
   135 
   135 
   136 		// The magic value of 729 days below comes from the NewGRF spec. If the
   136 		// The magic value of 729 days below comes from the NewGRF spec. If the
   137 		// base intro date is before 1922 then the random number of days is not
   137 		// base intro date is before 1922 then the random number of days is not
   187 
   187 
   188 	assert(e->railtype < RAILTYPE_END);
   188 	assert(e->railtype < RAILTYPE_END);
   189 	SETBIT(e->player_avail, player);
   189 	SETBIT(e->player_avail, player);
   190 	SETBIT(p->avail_railtypes, e->railtype);
   190 	SETBIT(p->avail_railtypes, e->railtype);
   191 
   191 
   192 	e->preview_player = 0xFF;
   192 	e->preview_player = INVALID_PLAYER;
   193 	if (player == _local_player) {
   193 	if (player == _local_player) {
   194 		InvalidateWindowClassesData(WC_BUILD_VEHICLE);
   194 		InvalidateWindowClassesData(WC_BUILD_VEHICLE);
   195 		InvalidateWindowClasses(WC_REPLACE_VEHICLE);
   195 		InvalidateWindowClasses(WC_REPLACE_VEHICLE);
   196 	}
   196 	}
   197 }
   197 }
   215 		}
   215 		}
   216 
   216 
   217 		if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR;
   217 		if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR;
   218 
   218 
   219 		SETBIT(mask, best_player);
   219 		SETBIT(mask, best_player);
   220 	} while (--pp != 0);
   220 	} while (pp--, pp != 0);
   221 
   221 
   222 	return best_player;
   222 	return best_player;
   223 }
   223 }
   224 
   224 
   225 void EnginesDailyLoop(void)
   225 void EnginesDailyLoop(void)
   240 				}
   240 				}
   241 			} else if (e->preview_player != 0xFF) {
   241 			} else if (e->preview_player != 0xFF) {
   242 				PlayerID best_player = GetBestPlayer(e->preview_player);
   242 				PlayerID best_player = GetBestPlayer(e->preview_player);
   243 
   243 
   244 				if (best_player == PLAYER_SPECTATOR) {
   244 				if (best_player == PLAYER_SPECTATOR) {
   245 					e->preview_player = 0xFF;
   245 					e->preview_player = INVALID_PLAYER;
   246 					continue;
   246 					continue;
   247 				}
   247 				}
   248 
   248 
   249 				if (!IsHumanPlayer(best_player)) {
   249 				if (!IsHumanPlayer(best_player)) {
   250 					/* XXX - TTDBUG: TTD has a bug here ???? */
   250 					/* XXX - TTDBUG: TTD has a bug here ???? */
   362 				// Introduction date has passed.. show introducing dialog to one player.
   362 				// Introduction date has passed.. show introducing dialog to one player.
   363 				e->flags |= ENGINE_INTRODUCING;
   363 				e->flags |= ENGINE_INTRODUCING;
   364 
   364 
   365 				// Do not introduce new rail wagons
   365 				// Do not introduce new rail wagons
   366 				if (!IsWagon(e - _engines))
   366 				if (!IsWagon(e - _engines))
   367 					e->preview_player = 1; // Give to the player with the highest rating.
   367 					e->preview_player = (PlayerID)1; // Give to the player with the highest rating.
   368 			}
   368 			}
   369 		}
   369 		}
   370 	}
   370 	}
   371 	AdjustAvailAircraft();
   371 	AdjustAvailAircraft();
   372 }
   372 }
   634 static void LoadSave_ENGS(void)
   634 static void LoadSave_ENGS(void)
   635 {
   635 {
   636 	SlArray(_engine_name_strings, lengthof(_engine_name_strings), SLE_STRINGID);
   636 	SlArray(_engine_name_strings, lengthof(_engine_name_strings), SLE_STRINGID);
   637 }
   637 }
   638 
   638 
   639 const ChunkHandler _engine_chunk_handlers[] = {
   639 extern const ChunkHandler _engine_chunk_handlers[] = {
   640 	{ 'ENGN', Save_ENGN,     Load_ENGN,     CH_ARRAY          },
   640 	{ 'ENGN', Save_ENGN,     Load_ENGN,     CH_ARRAY          },
   641 	{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF           },
   641 	{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF           },
   642 	{ 'ERNW', Save_ERNW,     Load_ERNW,     CH_ARRAY | CH_LAST},
   642 	{ 'ERNW', Save_ERNW,     Load_ERNW,     CH_ARRAY | CH_LAST},
   643 };
   643 };
   644 
   644