diff options
author | rubidium <rubidium@openttd.org> | 2008-05-27 21:41:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-05-27 21:41:00 +0000 |
commit | 33e18c236da7a21e796b2d130060367759753acd (patch) | |
tree | 086ec523744482fc8374da46db2a402e4b5c5d0a /src | |
parent | 0682b0304603150e4c0d365f687a60a2bc5bc350 (diff) | |
download | openttd-33e18c236da7a21e796b2d130060367759753acd.tar.xz |
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
Diffstat (limited to 'src')
-rw-r--r-- | src/animated_tile.cpp | 2 | ||||
-rw-r--r-- | src/cheat.cpp | 2 | ||||
-rw-r--r-- | src/debug.cpp | 2 | ||||
-rw-r--r-- | src/fileio.cpp | 4 | ||||
-rw-r--r-- | src/fileio.h | 6 | ||||
-rw-r--r-- | src/minilzo.cpp | 6 | ||||
-rw-r--r-- | src/misc_gui.cpp | 6 | ||||
-rw-r--r-- | src/mixer.cpp | 6 | ||||
-rw-r--r-- | src/mixer.h | 2 | ||||
-rw-r--r-- | src/newgrf.cpp | 2 | ||||
-rw-r--r-- | src/newgrf.h | 2 | ||||
-rw-r--r-- | src/order_cmd.cpp | 2 | ||||
-rw-r--r-- | src/saveload.cpp | 68 | ||||
-rw-r--r-- | src/saveload.h | 4 | ||||
-rw-r--r-- | src/sound.cpp | 2 | ||||
-rw-r--r-- | src/sound_type.h | 4 | ||||
-rw-r--r-- | src/spritecache.cpp | 10 | ||||
-rw-r--r-- | src/spriteloader/grf.cpp | 2 | ||||
-rw-r--r-- | src/spriteloader/grf.hpp | 2 | ||||
-rw-r--r-- | src/spriteloader/png.cpp | 6 | ||||
-rw-r--r-- | src/spriteloader/png.hpp | 2 | ||||
-rw-r--r-- | src/spriteloader/spriteloader.hpp | 2 | ||||
-rw-r--r-- | src/station_gui.cpp | 4 | ||||
-rw-r--r-- | src/stdafx.h | 5 | ||||
-rw-r--r-- | src/string_func.h | 4 | ||||
-rw-r--r-- | src/town_gui.cpp | 4 | ||||
-rw-r--r-- | src/widgets/dropdown.cpp | 6 | ||||
-rw-r--r-- | src/win32.cpp | 4 |
28 files changed, 88 insertions, 83 deletions
diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index dfc0d2cb0..a66225ae6 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -116,7 +116,7 @@ static void Load_ANIT() return; } - _animated_tile_count = SlGetFieldLength() / sizeof(*_animated_tile_list); + _animated_tile_count = (uint)SlGetFieldLength() / sizeof(*_animated_tile_list); /* Determine a nice rounded size for the amount of allocated tiles */ _animated_tile_allocated = 256; diff --git a/src/cheat.cpp b/src/cheat.cpp index f0b41d430..8a7d2e04c 100644 --- a/src/cheat.cpp +++ b/src/cheat.cpp @@ -30,7 +30,7 @@ static void Save_CHTS() static void Load_CHTS() { Cheat *cht = (Cheat*)&_cheats; - uint count = SlGetFieldLength() / 2; + size_t count = SlGetFieldLength() / 2; for (uint i = 0; i < count; i++) { cht[i].been_used = (SlReadByte() != 0); diff --git a/src/debug.cpp b/src/debug.cpp index eb829efed..6584b9e7f 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -74,7 +74,7 @@ void CDECL debug(const char *dbg, ...) char buf2[lengthof(buf) + 32]; snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf); - send(_debug_socket, buf2, strlen(buf2), 0); + send(_debug_socket, buf2, (int)strlen(buf2), 0); } else #endif /* ENABLE_NETWORK */ { diff --git a/src/fileio.cpp b/src/fileio.cpp index 7fbb3789a..0b9a92769 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -43,7 +43,7 @@ struct Fio { static Fio _fio; /* Get current position in file */ -uint32 FioGetPos() +size_t FioGetPos() { return _fio.pos + (_fio.buffer - _fio.buffer_end); } @@ -53,7 +53,7 @@ const char *FioGetFilename(uint8 slot) return _fio.shortnames[slot]; } -void FioSeekTo(uint32 pos, int mode) +void FioSeekTo(size_t pos, int mode) { if (mode == SEEK_CUR) pos += FioGetPos(); _fio.buffer = _fio.buffer_end = _fio.buffer_start + FIO_BUFFER_SIZE; diff --git a/src/fileio.h b/src/fileio.h index ed2a8b506..c361f849a 100644 --- a/src/fileio.h +++ b/src/fileio.h @@ -9,9 +9,9 @@ #include <string> #include "core/enum_type.hpp" -void FioSeekTo(uint32 pos, int mode); -void FioSeekToFile(uint8 slot, uint32 pos); -uint32 FioGetPos(); +void FioSeekTo(size_t pos, int mode); +void FioSeekToFile(uint8 slot, size_t pos); +size_t FioGetPos(); const char *FioGetFilename(uint8 slot); byte FioReadByte(); uint16 FioReadWord(); diff --git a/src/minilzo.cpp b/src/minilzo.cpp index 1a3a306d0..67cfa2b89 100644 --- a/src/minilzo.cpp +++ b/src/minilzo.cpp @@ -1183,7 +1183,7 @@ m3_m4_offset: break; } - *out_len = op - out; + *out_len = (lzo_uint)(op - out); return pd(in_end,ii); } @@ -1233,7 +1233,7 @@ DO_COMPRESS ( const lzo_byte *in , lzo_uint in_len, *op++ = 0; *op++ = 0; - *out_len = op - out; + *out_len = (lzo_uint)(op - out); return LZO_E_OK; } @@ -1555,7 +1555,7 @@ match_next: eof_found: assert(t == 1); - *out_len = op - out; + *out_len = (lzo_uint)(op - out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index e9a084bce..9cf128662 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -751,7 +751,7 @@ static void DelChar(Textbuf *tb, bool backspace) if (backspace) s = Utf8PrevChar(s); - size_t len = Utf8Decode(&c, s); + uint16 len = (uint16)Utf8Decode(&c, s); uint width = GetCharacterWidth(FS_NORMAL, c); tb->width -= width; @@ -807,7 +807,7 @@ void DeleteTextBufferAll(Textbuf *tb) bool InsertTextBufferChar(Textbuf *tb, WChar key) { const byte charwidth = GetCharacterWidth(FS_NORMAL, key); - size_t len = Utf8CharLen(key); + uint16 len = (uint16)Utf8CharLen(key); if (tb->length < (tb->maxlength - len) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1); Utf8Encode(tb->buf + tb->caretpos, key); @@ -847,7 +847,7 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode) if (tb->caretpos < tb->length) { WChar c; - tb->caretpos += Utf8Decode(&c, tb->buf + tb->caretpos); + tb->caretpos += (uint16)Utf8Decode(&c, tb->buf + tb->caretpos); tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c); return true; diff --git a/src/mixer.cpp b/src/mixer.cpp index 3b6557cde..b4ea66994 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -104,7 +104,7 @@ MixerChannel *MxAllocateChannel() return NULL; } -void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, uint size, uint rate, uint flags) +void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, size_t size, uint rate, uint flags) { mc->memory = mem; mc->flags = flags; @@ -114,12 +114,12 @@ void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, uint size, uint rate, uint mc->frac_speed = (rate << 16) / _play_rate; /* adjust the magnitude to prevent overflow */ - while (size & 0xFFFF0000) { + while (size & ~0xFFFF) { size >>= 1; rate = (rate >> 1) + 1; } - mc->samples_left = size * _play_rate / rate; + mc->samples_left = (uint)size * _play_rate / rate; } void MxSetChannelVolume(MixerChannel *mc, uint left, uint right) diff --git a/src/mixer.h b/src/mixer.h index 289cb19a7..562954d5f 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -18,7 +18,7 @@ bool MxInitialize(uint rate); void MxMixSamples(void *buffer, uint samples); MixerChannel *MxAllocateChannel(); -void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, uint size, uint rate, uint flags); +void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, size_t size, uint rate, uint flags); void MxSetChannelVolume(MixerChannel *mc, uint left, uint right); void MxActivateChannel(MixerChannel*); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 83b1ef79a..a6ff6062d 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3707,7 +3707,7 @@ static void CfgApply(byte *buf, size_t len) * to place where parameter is to be stored. */ /* Preload the next sprite */ - uint32 pos = FioGetPos(); + size_t pos = FioGetPos(); uint16 num = FioReadWord(); uint8 type = FioReadByte(); diff --git a/src/newgrf.h b/src/newgrf.h index c25baaeaf..253d8f334 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -52,7 +52,7 @@ enum GrfSpecFeature { struct GRFLabel { byte label; uint32 nfo_line; - uint32 pos; + size_t pos; struct GRFLabel *next; }; diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 20872f7cc..c4b9af6ab 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1836,7 +1836,7 @@ static void Load_ORDR() if (CheckSavegameVersionOldStyle(5, 2)) { /* Version older than 5.2 did not have a ->next pointer. Convert them (in the old days, the orderlist was 5000 items big) */ - uint len = SlGetFieldLength(); + size_t len = SlGetFieldLength(); uint i; if (CheckSavegameVersion(5)) { diff --git a/src/saveload.cpp b/src/saveload.cpp index d9fecbd97..8b346d75c 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -43,8 +43,8 @@ uint32 _ttdp_version; ///< version of TTDP savegame (if applicable) uint16 _sl_version; ///< the major savegame version identifier byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! -typedef void WriterProc(uint len); -typedef uint ReaderProc(); +typedef void WriterProc(size_t len); +typedef size_t ReaderProc(); /** The saveload struct, containing reader-writer functions, bufffer, version, etc. */ static struct { @@ -53,10 +53,10 @@ static struct { byte block_mode; ///< ??? bool error; ///< did an error occur or not - int obj_len; ///< the length of the current object we are busy with + size_t obj_len; ///< the length of the current object we are busy with int array_index, last_array_index; ///< in the case of an array, the current and last positions - uint32 offs_base; ///< the offset in number of bytes since we started writing data (eg uncompressed savegame size) + size_t offs_base; ///< the offset in number of bytes since we started writing data (eg uncompressed savegame size) WriterProc *write_bytes; ///< savegame writer function ReaderProc *read_bytes; ///< savegame loader function @@ -123,7 +123,7 @@ void ProcessAsyncSaveFinish() */ static void SlReadFill() { - uint len = _sl.read_bytes(); + size_t len = _sl.read_bytes(); if (len == 0) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Unexpected end of chunk"); _sl.bufp = _sl.buf; @@ -131,7 +131,7 @@ static void SlReadFill() _sl.offs_base += len; } -static inline uint32 SlGetOffs() {return _sl.offs_base - (_sl.bufe - _sl.bufp);} +static inline size_t SlGetOffs() {return _sl.offs_base - (_sl.bufe - _sl.bufp);} /** Return the size in bytes of a certain type of normal/atomic variable * as it appears in memory. See VarTypes @@ -283,27 +283,27 @@ static uint SlReadSimpleGamma() * @param i Index being written */ -static void SlWriteSimpleGamma(uint i) +static void SlWriteSimpleGamma(size_t i) { if (i >= (1 << 7)) { if (i >= (1 << 14)) { if (i >= (1 << 21)) { assert(i < (1 << 28)); - SlWriteByte((byte)0xE0 | (i >> 24)); + SlWriteByte((byte)(0xE0 | (i >> 24))); SlWriteByte((byte)(i >> 16)); } else { - SlWriteByte((byte)0xC0 | (i >> 16)); + SlWriteByte((byte)(0xC0 | (i >> 16))); } SlWriteByte((byte)(i >> 8)); } else { SlWriteByte((byte)(0x80 | (i >> 8))); } } - SlWriteByte(i); + SlWriteByte((byte)i); } /** Return how many bytes used to encode a gamma value */ -static inline uint SlGetGammaLength(uint i) +static inline uint SlGetGammaLength(size_t i) { return 1 + (i >= (1 << 7)) + (i >= (1 << 14)) + (i >= (1 << 21)); } @@ -312,8 +312,8 @@ static inline uint SlReadSparseIndex() {return SlReadSimpleGamma();} static inline void SlWriteSparseIndex(uint index) {SlWriteSimpleGamma(index);} static inline uint SlReadArrayLength() {return SlReadSimpleGamma();} -static inline void SlWriteArrayLength(uint length) {SlWriteSimpleGamma(length);} -static inline uint SlGetArrayLength(uint length) {return SlGetGammaLength(length);} +static inline void SlWriteArrayLength(size_t length) {SlWriteSimpleGamma(length);} +static inline uint SlGetArrayLength(size_t length) {return SlGetGammaLength(length);} void SlSetArrayIndex(uint index) { @@ -321,7 +321,7 @@ void SlSetArrayIndex(uint index) _sl.array_index = index; } -static uint32 _next_offs; +static size_t _next_offs; /** * Iterate through the elements of an array and read the whole thing @@ -375,7 +375,7 @@ void SlSetLength(size_t length) * The lower 24 bits are normal * The uppermost 4 bits are bits 24:27 */ assert(length < (1 << 28)); - SlWriteUint32((length & 0xFFFFFF) | ((length >> 24) << 28)); + SlWriteUint32((uint32)((length & 0xFFFFFF) | ((length >> 24) << 28))); break; case CH_ARRAY: assert(_sl.last_array_index <= _sl.array_index); @@ -390,7 +390,7 @@ void SlSetLength(size_t length) default: NOT_REACHED(); } break; case NL_CALCLENGTH: - _sl.obj_len += length; + _sl.obj_len += (int)length; break; } } @@ -422,7 +422,7 @@ static inline void SlSkipBytes(size_t length) } /* Get the length of the current object */ -uint SlGetFieldLength() {return _sl.obj_len;} +size_t SlGetFieldLength() {return _sl.obj_len;} /** Return a signed-long version of the value of a setting * @param ptr pointer to the variable @@ -628,7 +628,7 @@ static void SlString(void *ptr, size_t length, VarType conv) * @param length The length of the array counted in elements * @param conv VarType type of the variable that is used in calculating the size */ -static inline size_t SlCalcArrayLen(uint length, VarType conv) +static inline size_t SlCalcArrayLen(size_t length, VarType conv) { return SlCalcConvFileLen(conv) * length; } @@ -639,7 +639,7 @@ static inline size_t SlCalcArrayLen(uint length, VarType conv) * @param length The length of the array in elements * @param conv VarType type of the atomic array (int, byte, uint64, etc.) */ -void SlArray(void *array, uint length, VarType conv) +void SlArray(void *array, size_t length, VarType conv) { /* Automatically calculate the length? */ if (_sl.need_length != NL_NONE) { @@ -710,7 +710,7 @@ void SlList(void *list, SLRefType conv) std::list<void *> *l = (std::list<void *> *) list; if (_sl.save) { - SlWriteUint32(l->size()); + SlWriteUint32((uint32)l->size()); std::list<void *>::iterator iter; for (iter = l->begin(); iter != l->end(); ++iter) { @@ -884,7 +884,7 @@ void SlGlobList(const SaveLoadGlobVarList *sldg) */ void SlAutolength(AutolengthProc *proc, void *arg) { - uint32 offs; + size_t offs; assert(_sl.save); @@ -912,8 +912,8 @@ void SlAutolength(AutolengthProc *proc, void *arg) static void SlLoadChunk(const ChunkHandler *ch) { byte m = SlReadByte(); - uint32 len; - uint32 endoffs; + size_t len; + size_t endoffs; _sl.block_mode = m; _sl.obj_len = 0; @@ -1052,7 +1052,7 @@ static void SlLoadChunks() #include "minilzo.h" -static uint ReadLZO() +static size_t ReadLZO() { byte out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8]; uint32 tmp[2]; @@ -1085,13 +1085,13 @@ static uint ReadLZO() /* p contains the pointer to the buffer, len contains the pointer to the length. * len bytes will be written, p and l will be updated to reflect the next buffer. */ -static void WriteLZO(uint size) +static void WriteLZO(size_t size) { byte out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8]; byte wrkmem[sizeof(byte*)*4096]; uint outlen; - lzo1x_1_compress(_sl.buf, size, out + sizeof(uint32)*2, &outlen, wrkmem); + lzo1x_1_compress(_sl.buf, (lzo_uint)size, out + sizeof(uint32)*2, &outlen, wrkmem); ((uint32*)out)[1] = TO_BE32(outlen); ((uint32*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32), outlen + sizeof(uint32))); if (fwrite(out, outlen + sizeof(uint32)*2, 1, _sl.fh) != 1) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE); @@ -1112,12 +1112,12 @@ static void UninitLZO() /********************************************* ******** START OF NOCOMP CODE (uncompressed)* *********************************************/ -static uint ReadNoComp() +static size_t ReadNoComp() { return fread(_sl.buf, 1, LZO_SIZE, _sl.fh); } -static void WriteNoComp(uint size) +static void WriteNoComp(size_t size) { if (fwrite(_sl.buf, 1, size, _sl.fh) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE); } @@ -1170,9 +1170,9 @@ static void UnInitMem() _Savegame_pool.CleanPool(); } -static void WriteMem(uint size) +static void WriteMem(size_t size) { - _ts.count += size; + _ts.count += (uint)size; /* Allocate new block and new buffer-pointer */ _Savegame_pool.AddBlockIfNeeded(_ts.count); _sl.buf = GetSavegame(_ts.count); @@ -1197,7 +1197,7 @@ static bool InitReadZlib() return true; } -static uint ReadZlib() +static size_t ReadZlib() { int r; @@ -1237,13 +1237,13 @@ static bool InitWriteZlib() return true; } -static void WriteZlibLoop(z_streamp z, byte *p, uint len, int mode) +static void WriteZlibLoop(z_streamp z, byte *p, size_t len, int mode) { byte buf[1024]; // output buffer int r; uint n; z->next_in = p; - z->avail_in = len; + z->avail_in = (uInt)len; do { z->next_out = buf; z->avail_out = sizeof(buf); @@ -1258,7 +1258,7 @@ static void WriteZlibLoop(z_streamp z, byte *p, uint len, int mode) } while (z->avail_in || !z->avail_out); } -static void WriteZlib(uint len) +static void WriteZlib(size_t len) { WriteZlibLoop(&_z, _sl.buf, len, 0); } diff --git a/src/saveload.h b/src/saveload.h index 68fa4d2f8..b2f20a548 100644 --- a/src/saveload.h +++ b/src/saveload.h @@ -314,7 +314,7 @@ void SlSetArrayIndex(uint index); int SlIterateArray(); void SlAutolength(AutolengthProc *proc, void *arg); -uint SlGetFieldLength(); +size_t SlGetFieldLength(); void SlSetLength(size_t length); size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld); @@ -322,7 +322,7 @@ byte SlReadByte(); void SlWriteByte(byte b); void SlGlobList(const SaveLoadGlobVarList *sldg); -void SlArray(void *array, uint length, VarType conv); +void SlArray(void *array, size_t length, VarType conv); void SlObject(void *object, const SaveLoad *sld); bool SlObjectMember(void *object, const SaveLoad *sld); diff --git a/src/sound.cpp b/src/sound.cpp index 74663cff7..e610c53a7 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -29,7 +29,7 @@ static void OpenBankFile(const char *filename) uint i; FioOpenFile(SOUND_SLOT, filename); - uint pos = FioGetPos(); + size_t pos = FioGetPos(); uint count = FioReadDword() / 8; /* Simple check for the correct number of original sounds. */ diff --git a/src/sound_type.h b/src/sound_type.h index 319a8a06f..3fdf3aef5 100644 --- a/src/sound_type.h +++ b/src/sound_type.h @@ -20,8 +20,8 @@ struct MusicFileSettings { struct FileEntry { uint8 file_slot; - uint32 file_offset; - uint32 file_size; + size_t file_offset; + size_t file_size; uint16 rate; uint8 bits_per_sample; uint8 channels; diff --git a/src/spritecache.cpp b/src/spritecache.cpp index b3b669c32..adc0145df 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -25,7 +25,7 @@ uint _sprite_cache_size = 4; struct SpriteCache { void *ptr; uint32 id; - uint32 file_pos; + size_t file_pos; uint16 file_slot; int16 lru; }; @@ -123,7 +123,7 @@ void* AllocSprite(size_t); static void* ReadSprite(SpriteCache *sc, SpriteID id, bool real_sprite) { uint8 file_slot = sc->file_slot; - uint32 file_pos = sc->file_pos; + size_t file_pos = sc->file_pos; DEBUG(sprite, 9, "Load sprite %d", id); @@ -241,7 +241,7 @@ static void* ReadSprite(SpriteCache *sc, SpriteID id, bool real_sprite) bool LoadNextSprite(int load_index, byte file_slot, uint file_sprite_id) { SpriteCache *sc; - uint32 file_pos = FioGetPos(); + size_t file_pos = FioGetPos(); if (!ReadSpriteHeaderSkipData()) return false; @@ -279,9 +279,9 @@ static inline MemBlock* NextBlock(MemBlock* block) return (MemBlock*)((byte*)block + (block->size & ~S_FREE_MASK)); } -static uint32 GetSpriteCacheUsage() +static size_t GetSpriteCacheUsage() { - uint32 tot_size = 0; + size_t tot_size = 0; MemBlock* s; for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) { diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index 4fcad5386..6f01ee713 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -9,7 +9,7 @@ #include "../core/alloc_func.hpp" #include "grf.hpp" -bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, uint32 file_pos) +bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos) { /* Open the right file and go to the correct position */ FioSeekToFile(file_slot, file_pos); diff --git a/src/spriteloader/grf.hpp b/src/spriteloader/grf.hpp index f1e68aaa1..aff4c57cb 100644 --- a/src/spriteloader/grf.hpp +++ b/src/spriteloader/grf.hpp @@ -12,7 +12,7 @@ public: /** * Load a sprite from the disk and return a sprite struct which is the same for all loaders. */ - bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, uint32 file_pos); + bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos); }; #endif /* SPRITELOADER_GRF_HPP */ diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp index 153a2d698..54d04a3a8 100644 --- a/src/spriteloader/png.cpp +++ b/src/spriteloader/png.cpp @@ -170,11 +170,11 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i return true; } -bool SpriteLoaderPNG::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, uint32 file_pos) +bool SpriteLoaderPNG::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos) { const char *filename = FioGetFilename(file_slot); - if (!LoadPNG(sprite, filename, file_pos, false)) return false; - if (!LoadPNG(sprite, filename, file_pos, true)) return false; + if (!LoadPNG(sprite, filename, (uint32)file_pos, false)) return false; + if (!LoadPNG(sprite, filename, (uint32)file_pos, true)) return false; return true; } diff --git a/src/spriteloader/png.hpp b/src/spriteloader/png.hpp index 314e25e89..62c30db75 100644 --- a/src/spriteloader/png.hpp +++ b/src/spriteloader/png.hpp @@ -12,7 +12,7 @@ public: /** * Load a sprite from the disk and return a sprite struct which is the same for all loaders. */ - bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, uint32 file_pos); + bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos); }; #endif /* SPRITELOADER_PNG_HPP */ diff --git a/src/spriteloader/spriteloader.hpp b/src/spriteloader/spriteloader.hpp index 6e107811a..69b51c2f0 100644 --- a/src/spriteloader/spriteloader.hpp +++ b/src/spriteloader/spriteloader.hpp @@ -26,7 +26,7 @@ public: /** * Load a sprite from the disk and return a sprite struct which is the same for all loaders. */ - virtual bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, uint32 file_pos) = 0; + virtual bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos) = 0; virtual ~SpriteLoader() { } }; diff --git a/src/station_gui.cpp b/src/station_gui.cpp index b3598c8a2..cf7935ef5 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -682,7 +682,7 @@ typedef std::list<CargoData> CargoDataList; */ struct StationViewWindow : public Window { uint32 cargo; ///< Bitmask of cargo types to expand - uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type + size_t cargo_rows[NUM_CARGO]; ///< Header row for each cargo type StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { @@ -751,7 +751,7 @@ struct StationViewWindow : public Window { } } } - SetVScrollCount(this, cargolist.size() + 1); // update scrollbar + SetVScrollCount(this, (int)cargolist.size() + 1); // update scrollbar /* disable some buttons */ this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player); diff --git a/src/stdafx.h b/src/stdafx.h index 53289c438..9eb1a4e11 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -201,6 +201,11 @@ typedef _W64 unsigned int UINT_PTR, *PUINT_PTR; #endif /* WIN32 && !_WIN64 && !WIN64 */ + #if defined(_WIN64) || defined(WIN64) + #define fseek _fseeki64 + #endif /* _WIN64 || WIN64 */ + + #define GCC_PACK /* This is needed to zlib uses the stdcall calling convention on visual studio */ diff --git a/src/string_func.h b/src/string_func.h index 0e7aa5331..82530ae65 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -81,7 +81,7 @@ static inline WChar Utf8Consume(const char **s) * @param c Unicode character. * @return Length of UTF-8 encoding for character. */ -static inline size_t Utf8CharLen(WChar c) +static inline int8 Utf8CharLen(WChar c) { if (c < 0x80) return 1; if (c < 0x800) return 2; @@ -100,7 +100,7 @@ static inline size_t Utf8CharLen(WChar c) * @param c char to query length of * @return requested size */ -static inline size_t Utf8EncodedCharLen(char c) +static inline int8 Utf8EncodedCharLen(char c) { if (GB(c, 3, 5) == 0x1E) return 4; if (GB(c, 4, 4) == 0x0E) return 3; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index aed740d8f..ed0d77f1f 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -464,7 +464,7 @@ private: static const Town *last_town; /* Constants for sorting towns */ - static const GUITownList::SortFunction * const sorter_funcs[]; + static GUITownList::SortFunction * const sorter_funcs[]; GUITownList towns; @@ -637,7 +637,7 @@ Listing TownDirectoryWindow::last_sorting = {false, 0}; const Town *TownDirectoryWindow::last_town = NULL; /* Available town directory sorting functions */ -const GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = { +GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = { &TownNameSorter, &TownPopulationSorter, }; diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index c16e4a367..d0c5d04b7 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -274,7 +274,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u } else { /* ... and lastly if it won't, enable the scroll bar and fit the * list in below the widget */ - int avg_height = list_height / list->size(); + int avg_height = list_height / (int)list->size(); int rows = (screen_bottom - 4 - top) / avg_height; height = rows * avg_height; scroll = true; @@ -306,8 +306,8 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u dw->widget[0].right -= 12; /* Capacity is the average number of items visible */ - dw->vscroll.cap = height * list->size() / list_height; - dw->vscroll.count = list->size(); + dw->vscroll.cap = height * (uint16)list->size() / list_height; + dw->vscroll.count = (uint16)list->size(); } dw->desc_flags = WDF_DEF_WIDGET; diff --git a/src/win32.cpp b/src/win32.cpp index 0b20032e6..ba35b7e9c 100644 --- a/src/win32.cpp +++ b/src/win32.cpp @@ -1090,7 +1090,7 @@ bool InsertTextBufferClipboard(Textbuf *tb) const char *ptr; WChar c; - size_t width, length; + uint16 width, length; if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { OpenClipboard(NULL); @@ -1122,7 +1122,7 @@ bool InsertTextBufferClipboard(Textbuf *tb) for (ptr = utf8_buf; (c = Utf8Consume(&ptr)) != '\0';) { if (!IsPrintable(c)) break; - size_t len = Utf8CharLen(c); + byte len = Utf8CharLen(c); if (tb->length + length >= tb->maxlength - len) break; byte charwidth = GetCharacterWidth(FS_NORMAL, c); |