summaryrefslogtreecommitdiff
path: root/src/oldloader.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-10 18:56:51 +0000
committerrubidium <rubidium@openttd.org>2007-01-10 18:56:51 +0000
commita7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7 (patch)
tree1a1c59c13ddb1d152052f3a3a0bcffe4fb531173 /src/oldloader.cpp
parentce75f6549dd379b506c9f1e9383bd881aa7cf5c7 (diff)
downloadopenttd-a7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7.tar.xz
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
Diffstat (limited to 'src/oldloader.cpp')
-rw-r--r--src/oldloader.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index f6a56fdd6..98a1e9223 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -80,6 +80,8 @@ typedef enum OldChunkTypes {
OC_END = 0 ///< End of the whole chunk, all 32bits set to zero
} OldChunkType;
+DECLARE_ENUM_AS_BIT_SET(OldChunkType);
+
typedef bool OldChunkProc(LoadgameState *ls, int num);
typedef struct OldChunks {
@@ -97,9 +99,9 @@ assert_compile(sizeof(TileIndex) == 4);
static uint32 _bump_assert_value;
static bool _read_ttdpatch_flags;
-static OldChunkType GetOldChunkType(OldChunkType type) {return GB(type, 0, 8);}
-static OldChunkType GetOldChunkVarType(OldChunkType type) {return GB(type, 8, 8) << 8;}
-static OldChunkType GetOldChunkFileType(OldChunkType type) {return GB(type, 16, 8) << 16;}
+static OldChunkType GetOldChunkType(OldChunkType type) {return (OldChunkType)GB(type, 0, 8);}
+static OldChunkType GetOldChunkVarType(OldChunkType type) {return (OldChunkType)(GB(type, 8, 8) << 8);}
+static OldChunkType GetOldChunkFileType(OldChunkType type) {return (OldChunkType)(GB(type, 16, 8) << 16);}
static inline byte CalcOldVarLen(OldChunkType type)
{
@@ -189,10 +191,10 @@ static inline uint32 ReadUint32(LoadgameState *ls)
static bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
{
const OldChunks *chunk = chunks;
- byte *base_ptr = base;
+ byte *base_ptr = (byte*)base;
while (chunk->type != OC_END) {
- byte* ptr = chunk->ptr;
+ byte* ptr = (byte*)chunk->ptr;
uint i;
for (i = 0; i < chunk->amount; i++) {
@@ -959,9 +961,9 @@ static const OldChunks player_chunk[] = {
static bool LoadOldPlayer(LoadgameState *ls, int num)
{
- Player *p = GetPlayer(num);
+ Player *p = GetPlayer((PlayerID)num);
- _current_player_id = num;
+ _current_player_id = (PlayerID)num;
if (!LoadChunk(ls, p, player_chunk)) return false;
@@ -996,7 +998,7 @@ static bool LoadOldPlayer(LoadgameState *ls, int num)
* really figured out as of now, p->ai.cur_veh; needed for 'sell vehicle'
* is NULL and the function will crash. To fix this, just change the state
* to some harmless state, like 'loop vehicle'; 1 */
- if (!IsHumanPlayer(num) && p->ai.state == 20) p->ai.state = 1;
+ if (!IsHumanPlayer((PlayerID)num) && p->ai.state == 20) p->ai.state = 1;
if (p->is_ai && (!_networking || _network_server) && _ai.enabled)
AI_StartNewAI(p->index);