# player_base.h

Go to the documentation of this file.

    00001 /* $Id: player_base.h 12090 2008-02-09 02:49:33Z belugas $ */
    00002
    00005 #ifndef PLAYER_BASE_H
    00006 #define PLAYER_BASE_H
    00007
    00008 #include "road_type.h"
    00009 #include "rail_type.h"
    00010 #include "date_type.h"
    00011 #include "engine.h"
    00012 #include "livery.h"
    00013 #include "autoreplace_type.h"
    00014 #include "economy_type.h"
    00015 #include "tile_type.h"
    00016
    00017 struct PlayerEconomyEntry {
    00018   Money income;
    00019   Money expenses;
    00020   int32 delivered_cargo;
    00021   int32 performance_history;
    00022   Money company_value;
    00023 };
    00024
    00025 struct Player {
    00026   uint32 name_2;
    00027   uint16 name_1;
    00028   char *name;
    00029
    00030   uint16 president_name_1;
    00031   uint32 president_name_2;
    00032   char *president_name;
    00033
    00034   PlayerFace face;
    00035
    00036   Money player_money;
    00037   Money current_loan;
    00038
    00039   byte player_color;
    00040   Livery livery[LS_END];
    00041   byte player_money_fraction;
    00042   RailTypes avail_railtypes;
    00043   RoadTypes avail_roadtypes;
    00044   byte block_preview;
    00045   PlayerByte index;
    00046
    00047   uint16 cargo_types;
    00048
    00049   TileIndex location_of_house;
    00050   TileIndex last_build_coordinate;
    00051
    00052   PlayerByte share_owners[4];
    00053
    00054   Year inaugurated_year;
    00055   byte num_valid_stat_ent;
    00056
    00057   byte quarters_of_bankrupcy;
    00058   byte bankrupt_asked;
    00059   int16 bankrupt_timeout;
    00060   Money bankrupt_value;
    00061
    00062   bool is_active;
    00063   bool is_ai;
    00064
    00065   Money yearly_expenses[3][EXPENSES_END];
    00066   PlayerEconomyEntry cur_economy;
    00067   PlayerEconomyEntry old_economy[24];
    00068   EngineRenewList engine_renew_list;
    00069   bool engine_renew;
    00070   bool renew_keep_length;
    00071   int16 engine_renew_months;
    00072   uint32 engine_renew_money;
    00073   uint16 num_engines[TOTAL_NUM_ENGINES];
    00074 };
    00075
    00076 extern Player _players[MAX_PLAYERS];
    00077 #define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
    00078
    00079 static inline byte ActivePlayerCount()
    00080 {
    00081   const Player *p;
    00082   byte count = 0;
    00083
    00084   FOR_ALL_PLAYERS(p) {
    00085     if (p->is_active) count++;
    00086   }
    00087
    00088   return count;
    00089 }
    00090
    00091 static inline Player *GetPlayer(PlayerID i)
    00092 {
    00093   assert(IsInsideBS(i, PLAYER_FIRST, lengthof(_players)));
    00094   return &_players[i];
    00095 }
    00096
    00097 Money CalculateCompanyValue(const Player *p);
    00098
    00099 #endif /* PLAYER_BASE_H */