player.h
changeset 2436 7d5df545bd5d
parent 2425 e755ee29133a
child 2447 071e4afe707c
equal deleted inserted replaced
2435:9b9d43988058 2436:7d5df545bd5d
   167 	uint16 cargo_types; /* which cargo types were transported the last year */
   167 	uint16 cargo_types; /* which cargo types were transported the last year */
   168 
   168 
   169 	TileIndex location_of_house;
   169 	TileIndex location_of_house;
   170 	TileIndex last_build_coordinate;
   170 	TileIndex last_build_coordinate;
   171 
   171 
   172 	byte share_owners[4];
   172 	PlayerID share_owners[4];
   173 
   173 
   174 	byte inaugurated_year;
   174 	byte inaugurated_year;
   175 	byte num_valid_stat_ent;
   175 	byte num_valid_stat_ent;
   176 
   176 
   177 	byte quarters_of_bankrupcy;
   177 	byte quarters_of_bankrupcy;
   191 	bool engine_renew;
   191 	bool engine_renew;
   192 	int16 engine_renew_months;
   192 	int16 engine_renew_months;
   193 	uint32 engine_renew_money;
   193 	uint32 engine_renew_money;
   194 } Player;
   194 } Player;
   195 
   195 
   196 void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player);
   196 void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player);
   197 void GetNameOfOwner(byte owner, TileIndex tile);
   197 void GetNameOfOwner(PlayerID owner, TileIndex tile);
   198 int64 CalculateCompanyValue(Player *p);
   198 int64 CalculateCompanyValue(Player *p);
   199 void InvalidatePlayerWindows(Player *p);
   199 void InvalidatePlayerWindows(Player *p);
   200 void AiDoGameLoop(Player *p);
   200 void AiDoGameLoop(Player *p);
   201 void UpdatePlayerMoney32(Player *p);
   201 void UpdatePlayerMoney32(Player *p);
   202 #define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
   202 #define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
   207 #define MAX_PLAYERS 8
   207 #define MAX_PLAYERS 8
   208 VARDEF Player _players[MAX_PLAYERS];
   208 VARDEF Player _players[MAX_PLAYERS];
   209 // NOSAVE: can be determined from player structs
   209 // NOSAVE: can be determined from player structs
   210 VARDEF byte _player_colors[MAX_PLAYERS];
   210 VARDEF byte _player_colors[MAX_PLAYERS];
   211 
   211 
   212 static inline Player* GetPlayer(uint i)
   212 static inline Player* GetPlayer(PlayerID i)
   213 {
   213 {
   214 	assert(i < lengthof(_players));
   214 	assert(i < lengthof(_players));
   215 	return &_players[i];
   215 	return &_players[i];
   216 }
   216 }
   217 
   217 
   221 }
   221 }
   222 
   222 
   223 /** Returns the number of rail types the player can build
   223 /** Returns the number of rail types the player can build
   224   * @param *p Player in question
   224   * @param *p Player in question
   225   */
   225   */
   226 static inline int GetNumRailtypes(Player *p)
   226 static inline int GetNumRailtypes(const Player *p)
   227 {
   227 {
   228 	int num = 0;
   228 	int num = 0;
   229 	int i;
   229 	int i;
   230 
   230 
   231 	for (i = 0; i < (int)sizeof(p->avail_railtypes) * 8; i++)
   231 	for (i = 0; i < (int)sizeof(p->avail_railtypes) * 8; i++)
   237 
   237 
   238 byte GetPlayerRailtypes(int p);
   238 byte GetPlayerRailtypes(int p);
   239 
   239 
   240 /** Finds out if a Player has a certain railtype available
   240 /** Finds out if a Player has a certain railtype available
   241   */
   241   */
   242 static inline bool HasRailtypeAvail(Player *p, RailType Railtype)
   242 static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
   243 {
   243 {
   244 	return HASBIT(p->avail_railtypes, Railtype);
   244 	return HASBIT(p->avail_railtypes, Railtype);
   245 }
   245 }
   246 
   246 
   247 /* Validate functions for rail building */
   247 /* Validate functions for rail building */
   252   * have our own priority list here. When adding
   252   * have our own priority list here. When adding
   253   * new railtypes, modify this function
   253   * new railtypes, modify this function
   254   * @param p the player "in action"
   254   * @param p the player "in action"
   255   * @return The "best" railtype a player has available
   255   * @return The "best" railtype a player has available
   256   */
   256   */
   257 static inline byte GetBestRailtype(Player *p)
   257 static inline byte GetBestRailtype(const Player *p)
   258 {
   258 {
   259 	if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
   259 	if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
   260 	if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
   260 	if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
   261 	return RAILTYPE_RAIL;
   261 	return RAILTYPE_RAIL;
   262 }
   262 }