summaryrefslogtreecommitdiff
path: root/src/player.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-01-09 21:05:03 +0000
committerrubidium <rubidium@openttd.org>2008-01-09 21:05:03 +0000
commit998d7644f6a1b58de0b06d539c0436808b1f1e95 (patch)
tree6b9fc11a0135e1ccdb74151dd8962e4fd5264843 /src/player.h
parent82fe2885abb359c813908b0c844533bfec2c2b22 (diff)
downloadopenttd-998d7644f6a1b58de0b06d539c0436808b1f1e95.tar.xz
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
Diffstat (limited to 'src/player.h')
-rw-r--r--src/player.h59
1 files changed, 4 insertions, 55 deletions
diff --git a/src/player.h b/src/player.h
index 1d17c7f26..5ebe5d37d 100644
--- a/src/player.h
+++ b/src/player.h
@@ -5,11 +5,11 @@
#ifndef PLAYER_H
#define PLAYER_H
-#include "road_func.h"
+#include "road_type.h"
+#include "rail_type.h"
#include "date_type.h"
#include "engine.h"
#include "livery.h"
-#include "genworld.h"
#include "autoreplace_type.h"
struct PlayerEconomyEntry {
@@ -41,8 +41,8 @@ struct Player {
byte player_color;
Livery livery[LS_END];
byte player_money_fraction;
- byte avail_railtypes;
- byte avail_roadtypes;
+ RailTypes avail_railtypes;
+ RoadTypes avail_roadtypes;
byte block_preview;
PlayerByte index;
@@ -119,37 +119,6 @@ static inline bool IsValidPlayer(PlayerID pi)
return IsInsideBS(pi, PLAYER_FIRST, MAX_PLAYERS);
}
-byte GetPlayerRailtypes(PlayerID p);
-byte GetPlayerRoadtypes(PlayerID p);
-
-/** Finds out if a Player has a certain railtype available
- * @param p Player in question
- * @param Railtype requested RailType
- * @return true if player has requested RailType available
- */
-static inline bool HasRailtypeAvail(const Player *p, const RailType Railtype)
-{
- return HasBit(p->avail_railtypes, Railtype);
-}
-
-/** Finds out, whether given player has all given RoadTypes available
- * @param PlayerID ID of player
- * @param rts RoadTypes to test
- * @return true if player has all requested RoadTypes available
- */
-static inline bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts)
-{
- RoadTypes avail_roadtypes;
-
- if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
- avail_roadtypes = ROADTYPES_ROAD;
- } else {
- if (!IsValidPlayer(p)) return false;
- avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
- }
- return (rts & ~avail_roadtypes) == 0;
-}
-
static inline bool IsHumanPlayer(PlayerID pi)
{
return !GetPlayer(pi)->is_ai;
@@ -162,26 +131,6 @@ static inline bool IsInteractivePlayer(PlayerID pi)
void DrawPlayerIcon(PlayerID p, int x, int y);
-/* Validate functions for rail building */
-static inline bool ValParamRailtype(const uint32 rail) { return HasBit(GetPlayer(_current_player)->avail_railtypes, rail);}
-
-/* Validate functions for road building */
-static inline bool ValParamRoadType(const RoadType rt) { return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt));}
-
-/** Returns the "best" railtype a player can build.
- * As the AI doesn't know what the BEST one is, we have our own priority list
- * here. When adding new railtypes, modify this function
- * @param p the player "in action"
- * @return The "best" railtype a player has available
- */
-static inline RailType GetBestRailtype(const Player *p)
-{
- if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
- if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
- if (HasRailtypeAvail(p, RAILTYPE_ELECTRIC)) return RAILTYPE_ELECTRIC;
- return RAILTYPE_RAIL;
-}
-
struct HighScore {
char company[100];
StringID title; ///< NO_SAVE, has troubles with changing string-numbers.