src/player.h
changeset 5587 167d9a91ef02
parent 5475 2e6990a8c7c4
child 5729 8f03461d5706
equal deleted inserted replaced
5586:2d4126d81ebb 5587:167d9a91ef02
    36 	uint32 state_counter; // Can hold tile index!
    36 	uint32 state_counter; // Can hold tile index!
    37 	uint16 timeout_counter;
    37 	uint16 timeout_counter;
    38 
    38 
    39 	byte state_mode;
    39 	byte state_mode;
    40 	byte banned_tile_count;
    40 	byte banned_tile_count;
    41 	byte railtype_to_use;
    41 	RailTypeByte railtype_to_use;
    42 
    42 
    43 	CargoID cargo_type;
    43 	CargoID cargo_type;
    44 	byte num_wagons;
    44 	byte num_wagons;
    45 	byte build_kind;
    45 	byte build_kind;
    46 	byte num_build_rec;
    46 	byte num_build_rec;
   130 
   130 
   131 	bool from_deliver; // True if this is the station that GIVES cargo
   131 	bool from_deliver; // True if this is the station that GIVES cargo
   132 	bool to_deliver;
   132 	bool to_deliver;
   133 
   133 
   134 	TileIndex depot_tile;
   134 	TileIndex depot_tile;
   135 	byte depot_direction;
   135 	DiagDirectionByte depot_direction;
   136 
   136 
   137 	byte amount_veh;       // How many vehicles we are going to build in this route
   137 	byte amount_veh;       // How many vehicles we are going to build in this route
   138 	byte cur_veh;          // How many vehicles did we bought?
   138 	byte cur_veh;          // How many vehicles did we bought?
   139 	VehicleID veh_id;      // Used when bought a vehicle
   139 	VehicleID veh_id;      // Used when bought a vehicle
   140 	VehicleID veh_main_id; // The ID of the first vehicle, for shared copy
   140 	VehicleID veh_main_id; // The ID of the first vehicle, for shared copy
   164 	byte player_color;
   164 	byte player_color;
   165 	Livery livery[LS_END];
   165 	Livery livery[LS_END];
   166 	byte player_money_fraction;
   166 	byte player_money_fraction;
   167 	byte avail_railtypes;
   167 	byte avail_railtypes;
   168 	byte block_preview;
   168 	byte block_preview;
   169 	PlayerID index;
   169 	PlayerByte index;
   170 
   170 
   171 	uint16 cargo_types; /* which cargo types were transported the last year */
   171 	uint16 cargo_types; /* which cargo types were transported the last year */
   172 
   172 
   173 	TileIndex location_of_house;
   173 	TileIndex location_of_house;
   174 	TileIndex last_build_coordinate;
   174 	TileIndex last_build_coordinate;
   175 
   175 
   176 	PlayerID share_owners[4];
   176 	PlayerByte share_owners[4];
   177 
   177 
   178 	Year inaugurated_year;
   178 	Year inaugurated_year;
   179 	byte num_valid_stat_ent;
   179 	byte num_valid_stat_ent;
   180 
   180 
   181 	byte quarters_of_bankrupcy;
   181 	byte quarters_of_bankrupcy;
   210 #define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
   210 #define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
   211 
   211 
   212 VARDEF PlayerID _local_player;
   212 VARDEF PlayerID _local_player;
   213 VARDEF PlayerID _current_player;
   213 VARDEF PlayerID _current_player;
   214 
   214 
   215 /* Player identifiers All players below MAX_PLAYERS are playable
       
   216  * players, above, they are special, computer controlled players */
       
   217 enum Players {
       
   218 	PLAYER_INACTIVE_CLIENT = 253,
       
   219 	PLAYER_NEW_COMPANY = 254, ///< Command 'player' in Multiplayer to create a new company
       
   220 	PLAYER_SPECTATOR   = 255, ///< Spectator in Multiplayer or the player in the scenario editor
       
   221 	MAX_PLAYERS        = 8,
       
   222 };
       
   223 
       
   224 VARDEF Player _players[MAX_PLAYERS];
   215 VARDEF Player _players[MAX_PLAYERS];
   225 // NOSAVE: can be determined from player structs
   216 // NOSAVE: can be determined from player structs
   226 VARDEF byte _player_colors[MAX_PLAYERS];
   217 VARDEF byte _player_colors[MAX_PLAYERS];
   227 
   218 
   228 static inline byte ActivePlayerCount(void)
   219 static inline byte ActivePlayerCount(void)
   237 	return count;
   228 	return count;
   238 }
   229 }
   239 
   230 
   240 static inline Player* GetPlayer(PlayerID i)
   231 static inline Player* GetPlayer(PlayerID i)
   241 {
   232 {
   242 	assert(i < lengthof(_players));
   233 	assert(i < (PlayerID)lengthof(_players));
   243 	return &_players[i];
   234 	return &_players[i];
   244 }
   235 }
   245 
   236 
   246 static inline bool IsLocalPlayer(void)
   237 static inline bool IsLocalPlayer(void)
   247 {
   238 {