(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.

This commit is contained in:
rubidium 2008-05-27 21:41:00 +00:00
parent 49a0bd7f90
commit 5c5ee7eb57
28 changed files with 88 additions and 83 deletions

View File

@ -116,7 +116,7 @@ static void Load_ANIT()
return; 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 */ /* Determine a nice rounded size for the amount of allocated tiles */
_animated_tile_allocated = 256; _animated_tile_allocated = 256;

View File

@ -30,7 +30,7 @@ static void Save_CHTS()
static void Load_CHTS() static void Load_CHTS()
{ {
Cheat *cht = (Cheat*)&_cheats; Cheat *cht = (Cheat*)&_cheats;
uint count = SlGetFieldLength() / 2; size_t count = SlGetFieldLength() / 2;
for (uint i = 0; i < count; i++) { for (uint i = 0; i < count; i++) {
cht[i].been_used = (SlReadByte() != 0); cht[i].been_used = (SlReadByte() != 0);

View File

@ -74,7 +74,7 @@ void CDECL debug(const char *dbg, ...)
char buf2[lengthof(buf) + 32]; char buf2[lengthof(buf) + 32];
snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf); 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 } else
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
{ {

View File

@ -43,7 +43,7 @@ struct Fio {
static Fio _fio; static Fio _fio;
/* Get current position in file */ /* Get current position in file */
uint32 FioGetPos() size_t FioGetPos()
{ {
return _fio.pos + (_fio.buffer - _fio.buffer_end); return _fio.pos + (_fio.buffer - _fio.buffer_end);
} }
@ -53,7 +53,7 @@ const char *FioGetFilename(uint8 slot)
return _fio.shortnames[slot]; return _fio.shortnames[slot];
} }
void FioSeekTo(uint32 pos, int mode) void FioSeekTo(size_t pos, int mode)
{ {
if (mode == SEEK_CUR) pos += FioGetPos(); if (mode == SEEK_CUR) pos += FioGetPos();
_fio.buffer = _fio.buffer_end = _fio.buffer_start + FIO_BUFFER_SIZE; _fio.buffer = _fio.buffer_end = _fio.buffer_start + FIO_BUFFER_SIZE;

View File

@ -9,9 +9,9 @@
#include <string> #include <string>
#include "core/enum_type.hpp" #include "core/enum_type.hpp"
void FioSeekTo(uint32 pos, int mode); void FioSeekTo(size_t pos, int mode);
void FioSeekToFile(uint8 slot, uint32 pos); void FioSeekToFile(uint8 slot, size_t pos);
uint32 FioGetPos(); size_t FioGetPos();
const char *FioGetFilename(uint8 slot); const char *FioGetFilename(uint8 slot);
byte FioReadByte(); byte FioReadByte();
uint16 FioReadWord(); uint16 FioReadWord();

View File

@ -1183,7 +1183,7 @@ m3_m4_offset:
break; break;
} }
*out_len = op - out; *out_len = (lzo_uint)(op - out);
return pd(in_end,ii); return pd(in_end,ii);
} }
@ -1233,7 +1233,7 @@ DO_COMPRESS ( const lzo_byte *in , lzo_uint in_len,
*op++ = 0; *op++ = 0;
*op++ = 0; *op++ = 0;
*out_len = op - out; *out_len = (lzo_uint)(op - out);
return LZO_E_OK; return LZO_E_OK;
} }
@ -1555,7 +1555,7 @@ match_next:
eof_found: eof_found:
assert(t == 1); assert(t == 1);
*out_len = op - out; *out_len = (lzo_uint)(op - out);
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));

View File

@ -751,7 +751,7 @@ static void DelChar(Textbuf *tb, bool backspace)
if (backspace) s = Utf8PrevChar(s); if (backspace) s = Utf8PrevChar(s);
size_t len = Utf8Decode(&c, s); uint16 len = (uint16)Utf8Decode(&c, s);
uint width = GetCharacterWidth(FS_NORMAL, c); uint width = GetCharacterWidth(FS_NORMAL, c);
tb->width -= width; tb->width -= width;
@ -807,7 +807,7 @@ void DeleteTextBufferAll(Textbuf *tb)
bool InsertTextBufferChar(Textbuf *tb, WChar key) bool InsertTextBufferChar(Textbuf *tb, WChar key)
{ {
const byte charwidth = GetCharacterWidth(FS_NORMAL, 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)) { 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); memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1);
Utf8Encode(tb->buf + tb->caretpos, key); Utf8Encode(tb->buf + tb->caretpos, key);
@ -847,7 +847,7 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode)
if (tb->caretpos < tb->length) { if (tb->caretpos < tb->length) {
WChar c; 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); tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c);
return true; return true;

View File

@ -104,7 +104,7 @@ MixerChannel *MxAllocateChannel()
return NULL; 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->memory = mem;
mc->flags = flags; 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; mc->frac_speed = (rate << 16) / _play_rate;
/* adjust the magnitude to prevent overflow */ /* adjust the magnitude to prevent overflow */
while (size & 0xFFFF0000) { while (size & ~0xFFFF) {
size >>= 1; size >>= 1;
rate = (rate >> 1) + 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) void MxSetChannelVolume(MixerChannel *mc, uint left, uint right)

View File

@ -18,7 +18,7 @@ bool MxInitialize(uint rate);
void MxMixSamples(void *buffer, uint samples); void MxMixSamples(void *buffer, uint samples);
MixerChannel *MxAllocateChannel(); 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 MxSetChannelVolume(MixerChannel *mc, uint left, uint right);
void MxActivateChannel(MixerChannel*); void MxActivateChannel(MixerChannel*);

View File

@ -3707,7 +3707,7 @@ static void CfgApply(byte *buf, size_t len)
* to place where parameter is to be stored. */ * to place where parameter is to be stored. */
/* Preload the next sprite */ /* Preload the next sprite */
uint32 pos = FioGetPos(); size_t pos = FioGetPos();
uint16 num = FioReadWord(); uint16 num = FioReadWord();
uint8 type = FioReadByte(); uint8 type = FioReadByte();

View File

@ -52,7 +52,7 @@ enum GrfSpecFeature {
struct GRFLabel { struct GRFLabel {
byte label; byte label;
uint32 nfo_line; uint32 nfo_line;
uint32 pos; size_t pos;
struct GRFLabel *next; struct GRFLabel *next;
}; };

View File

@ -1836,7 +1836,7 @@ static void Load_ORDR()
if (CheckSavegameVersionOldStyle(5, 2)) { if (CheckSavegameVersionOldStyle(5, 2)) {
/* Version older than 5.2 did not have a ->next pointer. Convert them /* Version older than 5.2 did not have a ->next pointer. Convert them
(in the old days, the orderlist was 5000 items big) */ (in the old days, the orderlist was 5000 items big) */
uint len = SlGetFieldLength(); size_t len = SlGetFieldLength();
uint i; uint i;
if (CheckSavegameVersion(5)) { if (CheckSavegameVersion(5)) {

View File

@ -43,8 +43,8 @@ uint32 _ttdp_version; ///< version of TTDP savegame (if applicable)
uint16 _sl_version; ///< the major savegame version identifier uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
typedef void WriterProc(uint len); typedef void WriterProc(size_t len);
typedef uint ReaderProc(); typedef size_t ReaderProc();
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */ /** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
static struct { static struct {
@ -53,10 +53,10 @@ static struct {
byte block_mode; ///< ??? byte block_mode; ///< ???
bool error; ///< did an error occur or not 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 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 WriterProc *write_bytes; ///< savegame writer function
ReaderProc *read_bytes; ///< savegame loader function ReaderProc *read_bytes; ///< savegame loader function
@ -123,7 +123,7 @@ void ProcessAsyncSaveFinish()
*/ */
static void SlReadFill() 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"); if (len == 0) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Unexpected end of chunk");
_sl.bufp = _sl.buf; _sl.bufp = _sl.buf;
@ -131,7 +131,7 @@ static void SlReadFill()
_sl.offs_base += len; _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 /** Return the size in bytes of a certain type of normal/atomic variable
* as it appears in memory. See VarTypes * as it appears in memory. See VarTypes
@ -283,27 +283,27 @@ static uint SlReadSimpleGamma()
* @param i Index being written * @param i Index being written
*/ */
static void SlWriteSimpleGamma(uint i) static void SlWriteSimpleGamma(size_t i)
{ {
if (i >= (1 << 7)) { if (i >= (1 << 7)) {
if (i >= (1 << 14)) { if (i >= (1 << 14)) {
if (i >= (1 << 21)) { if (i >= (1 << 21)) {
assert(i < (1 << 28)); assert(i < (1 << 28));
SlWriteByte((byte)0xE0 | (i >> 24)); SlWriteByte((byte)(0xE0 | (i >> 24)));
SlWriteByte((byte)(i >> 16)); SlWriteByte((byte)(i >> 16));
} else { } else {
SlWriteByte((byte)0xC0 | (i >> 16)); SlWriteByte((byte)(0xC0 | (i >> 16)));
} }
SlWriteByte((byte)(i >> 8)); SlWriteByte((byte)(i >> 8));
} else { } else {
SlWriteByte((byte)(0x80 | (i >> 8))); SlWriteByte((byte)(0x80 | (i >> 8)));
} }
} }
SlWriteByte(i); SlWriteByte((byte)i);
} }
/** Return how many bytes used to encode a gamma value */ /** 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)); 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 void SlWriteSparseIndex(uint index) {SlWriteSimpleGamma(index);}
static inline uint SlReadArrayLength() {return SlReadSimpleGamma();} static inline uint SlReadArrayLength() {return SlReadSimpleGamma();}
static inline void SlWriteArrayLength(uint length) {SlWriteSimpleGamma(length);} static inline void SlWriteArrayLength(size_t length) {SlWriteSimpleGamma(length);}
static inline uint SlGetArrayLength(uint length) {return SlGetGammaLength(length);} static inline uint SlGetArrayLength(size_t length) {return SlGetGammaLength(length);}
void SlSetArrayIndex(uint index) void SlSetArrayIndex(uint index)
{ {
@ -321,7 +321,7 @@ void SlSetArrayIndex(uint index)
_sl.array_index = 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 * 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 lower 24 bits are normal
* The uppermost 4 bits are bits 24:27 */ * The uppermost 4 bits are bits 24:27 */
assert(length < (1 << 28)); assert(length < (1 << 28));
SlWriteUint32((length & 0xFFFFFF) | ((length >> 24) << 28)); SlWriteUint32((uint32)((length & 0xFFFFFF) | ((length >> 24) << 28)));
break; break;
case CH_ARRAY: case CH_ARRAY:
assert(_sl.last_array_index <= _sl.array_index); assert(_sl.last_array_index <= _sl.array_index);
@ -390,7 +390,7 @@ void SlSetLength(size_t length)
default: NOT_REACHED(); default: NOT_REACHED();
} break; } break;
case NL_CALCLENGTH: case NL_CALCLENGTH:
_sl.obj_len += length; _sl.obj_len += (int)length;
break; break;
} }
} }
@ -422,7 +422,7 @@ static inline void SlSkipBytes(size_t length)
} }
/* Get the length of the current object */ /* 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 /** Return a signed-long version of the value of a setting
* @param ptr pointer to the variable * @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 length The length of the array counted in elements
* @param conv VarType type of the variable that is used in calculating the size * @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; 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 length The length of the array in elements
* @param conv VarType type of the atomic array (int, byte, uint64, etc.) * @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? */ /* Automatically calculate the length? */
if (_sl.need_length != NL_NONE) { if (_sl.need_length != NL_NONE) {
@ -710,7 +710,7 @@ void SlList(void *list, SLRefType conv)
std::list<void *> *l = (std::list<void *> *) list; std::list<void *> *l = (std::list<void *> *) list;
if (_sl.save) { if (_sl.save) {
SlWriteUint32(l->size()); SlWriteUint32((uint32)l->size());
std::list<void *>::iterator iter; std::list<void *>::iterator iter;
for (iter = l->begin(); iter != l->end(); ++iter) { for (iter = l->begin(); iter != l->end(); ++iter) {
@ -884,7 +884,7 @@ void SlGlobList(const SaveLoadGlobVarList *sldg)
*/ */
void SlAutolength(AutolengthProc *proc, void *arg) void SlAutolength(AutolengthProc *proc, void *arg)
{ {
uint32 offs; size_t offs;
assert(_sl.save); assert(_sl.save);
@ -912,8 +912,8 @@ void SlAutolength(AutolengthProc *proc, void *arg)
static void SlLoadChunk(const ChunkHandler *ch) static void SlLoadChunk(const ChunkHandler *ch)
{ {
byte m = SlReadByte(); byte m = SlReadByte();
uint32 len; size_t len;
uint32 endoffs; size_t endoffs;
_sl.block_mode = m; _sl.block_mode = m;
_sl.obj_len = 0; _sl.obj_len = 0;
@ -1052,7 +1052,7 @@ static void SlLoadChunks()
#include "minilzo.h" #include "minilzo.h"
static uint ReadLZO() static size_t ReadLZO()
{ {
byte out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8]; byte out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8];
uint32 tmp[2]; uint32 tmp[2];
@ -1085,13 +1085,13 @@ static uint ReadLZO()
/* p contains the pointer to the buffer, len contains the pointer to the length. /* 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. */ * 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 out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8];
byte wrkmem[sizeof(byte*)*4096]; byte wrkmem[sizeof(byte*)*4096];
uint outlen; 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)[1] = TO_BE32(outlen);
((uint32*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32), outlen + sizeof(uint32))); ((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); 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)* ******** START OF NOCOMP CODE (uncompressed)*
*********************************************/ *********************************************/
static uint ReadNoComp() static size_t ReadNoComp()
{ {
return fread(_sl.buf, 1, LZO_SIZE, _sl.fh); 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); 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(); _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 */ /* Allocate new block and new buffer-pointer */
_Savegame_pool.AddBlockIfNeeded(_ts.count); _Savegame_pool.AddBlockIfNeeded(_ts.count);
_sl.buf = GetSavegame(_ts.count); _sl.buf = GetSavegame(_ts.count);
@ -1197,7 +1197,7 @@ static bool InitReadZlib()
return true; return true;
} }
static uint ReadZlib() static size_t ReadZlib()
{ {
int r; int r;
@ -1237,13 +1237,13 @@ static bool InitWriteZlib()
return true; 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 byte buf[1024]; // output buffer
int r; int r;
uint n; uint n;
z->next_in = p; z->next_in = p;
z->avail_in = len; z->avail_in = (uInt)len;
do { do {
z->next_out = buf; z->next_out = buf;
z->avail_out = sizeof(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); } while (z->avail_in || !z->avail_out);
} }
static void WriteZlib(uint len) static void WriteZlib(size_t len)
{ {
WriteZlibLoop(&_z, _sl.buf, len, 0); WriteZlibLoop(&_z, _sl.buf, len, 0);
} }

View File

@ -314,7 +314,7 @@ void SlSetArrayIndex(uint index);
int SlIterateArray(); int SlIterateArray();
void SlAutolength(AutolengthProc *proc, void *arg); void SlAutolength(AutolengthProc *proc, void *arg);
uint SlGetFieldLength(); size_t SlGetFieldLength();
void SlSetLength(size_t length); void SlSetLength(size_t length);
size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld); size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld);
@ -322,7 +322,7 @@ byte SlReadByte();
void SlWriteByte(byte b); void SlWriteByte(byte b);
void SlGlobList(const SaveLoadGlobVarList *sldg); 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); void SlObject(void *object, const SaveLoad *sld);
bool SlObjectMember(void *object, const SaveLoad *sld); bool SlObjectMember(void *object, const SaveLoad *sld);

View File

@ -29,7 +29,7 @@ static void OpenBankFile(const char *filename)
uint i; uint i;
FioOpenFile(SOUND_SLOT, filename); FioOpenFile(SOUND_SLOT, filename);
uint pos = FioGetPos(); size_t pos = FioGetPos();
uint count = FioReadDword() / 8; uint count = FioReadDword() / 8;
/* Simple check for the correct number of original sounds. */ /* Simple check for the correct number of original sounds. */

View File

@ -20,8 +20,8 @@ struct MusicFileSettings {
struct FileEntry { struct FileEntry {
uint8 file_slot; uint8 file_slot;
uint32 file_offset; size_t file_offset;
uint32 file_size; size_t file_size;
uint16 rate; uint16 rate;
uint8 bits_per_sample; uint8 bits_per_sample;
uint8 channels; uint8 channels;

View File

@ -25,7 +25,7 @@ uint _sprite_cache_size = 4;
struct SpriteCache { struct SpriteCache {
void *ptr; void *ptr;
uint32 id; uint32 id;
uint32 file_pos; size_t file_pos;
uint16 file_slot; uint16 file_slot;
int16 lru; int16 lru;
}; };
@ -123,7 +123,7 @@ void* AllocSprite(size_t);
static void* ReadSprite(SpriteCache *sc, SpriteID id, bool real_sprite) static void* ReadSprite(SpriteCache *sc, SpriteID id, bool real_sprite)
{ {
uint8 file_slot = sc->file_slot; 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); 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) bool LoadNextSprite(int load_index, byte file_slot, uint file_sprite_id)
{ {
SpriteCache *sc; SpriteCache *sc;
uint32 file_pos = FioGetPos(); size_t file_pos = FioGetPos();
if (!ReadSpriteHeaderSkipData()) return false; if (!ReadSpriteHeaderSkipData()) return false;
@ -279,9 +279,9 @@ static inline MemBlock* NextBlock(MemBlock* block)
return (MemBlock*)((byte*)block + (block->size & ~S_FREE_MASK)); 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; MemBlock* s;
for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) { for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) {

View File

@ -9,7 +9,7 @@
#include "../core/alloc_func.hpp" #include "../core/alloc_func.hpp"
#include "grf.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 */ /* Open the right file and go to the correct position */
FioSeekToFile(file_slot, file_pos); FioSeekToFile(file_slot, file_pos);

View File

@ -12,7 +12,7 @@ public:
/** /**
* Load a sprite from the disk and return a sprite struct which is the same for all loaders. * 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 */ #endif /* SPRITELOADER_GRF_HPP */

View File

@ -170,11 +170,11 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
return true; 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); const char *filename = FioGetFilename(file_slot);
if (!LoadPNG(sprite, filename, file_pos, false)) return false; if (!LoadPNG(sprite, filename, (uint32)file_pos, false)) return false;
if (!LoadPNG(sprite, filename, file_pos, true)) return false; if (!LoadPNG(sprite, filename, (uint32)file_pos, true)) return false;
return true; return true;
} }

View File

@ -12,7 +12,7 @@ public:
/** /**
* Load a sprite from the disk and return a sprite struct which is the same for all loaders. * 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 */ #endif /* SPRITELOADER_PNG_HPP */

View File

@ -26,7 +26,7 @@ public:
/** /**
* Load a sprite from the disk and return a sprite struct which is the same for all loaders. * 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() { } virtual ~SpriteLoader() { }
}; };

View File

@ -682,7 +682,7 @@ typedef std::list<CargoData> CargoDataList;
*/ */
struct StationViewWindow : public Window { struct StationViewWindow : public Window {
uint32 cargo; ///< Bitmask of cargo types to expand 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) 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 */ /* disable some buttons */
this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player); this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player);

View File

@ -201,6 +201,11 @@
typedef _W64 unsigned int UINT_PTR, *PUINT_PTR; typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
#endif /* WIN32 && !_WIN64 && !WIN64 */ #endif /* WIN32 && !_WIN64 && !WIN64 */
#if defined(_WIN64) || defined(WIN64)
#define fseek _fseeki64
#endif /* _WIN64 || WIN64 */
#define GCC_PACK #define GCC_PACK
/* This is needed to zlib uses the stdcall calling convention on visual studio */ /* This is needed to zlib uses the stdcall calling convention on visual studio */

View File

@ -81,7 +81,7 @@ static inline WChar Utf8Consume(const char **s)
* @param c Unicode character. * @param c Unicode character.
* @return Length of UTF-8 encoding for 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 < 0x80) return 1;
if (c < 0x800) return 2; if (c < 0x800) return 2;
@ -100,7 +100,7 @@ static inline size_t Utf8CharLen(WChar c)
* @param c char to query length of * @param c char to query length of
* @return requested size * @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, 3, 5) == 0x1E) return 4;
if (GB(c, 4, 4) == 0x0E) return 3; if (GB(c, 4, 4) == 0x0E) return 3;

View File

@ -464,7 +464,7 @@ private:
static const Town *last_town; static const Town *last_town;
/* Constants for sorting towns */ /* Constants for sorting towns */
static const GUITownList::SortFunction * const sorter_funcs[]; static GUITownList::SortFunction * const sorter_funcs[];
GUITownList towns; GUITownList towns;
@ -637,7 +637,7 @@ Listing TownDirectoryWindow::last_sorting = {false, 0};
const Town *TownDirectoryWindow::last_town = NULL; const Town *TownDirectoryWindow::last_town = NULL;
/* Available town directory sorting functions */ /* Available town directory sorting functions */
const GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = { GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = {
&TownNameSorter, &TownNameSorter,
&TownPopulationSorter, &TownPopulationSorter,
}; };

View File

@ -274,7 +274,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u
} else { } else {
/* ... and lastly if it won't, enable the scroll bar and fit the /* ... and lastly if it won't, enable the scroll bar and fit the
* list in below the widget */ * 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; int rows = (screen_bottom - 4 - top) / avg_height;
height = rows * avg_height; height = rows * avg_height;
scroll = true; scroll = true;
@ -306,8 +306,8 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u
dw->widget[0].right -= 12; dw->widget[0].right -= 12;
/* Capacity is the average number of items visible */ /* Capacity is the average number of items visible */
dw->vscroll.cap = height * list->size() / list_height; dw->vscroll.cap = height * (uint16)list->size() / list_height;
dw->vscroll.count = list->size(); dw->vscroll.count = (uint16)list->size();
} }
dw->desc_flags = WDF_DEF_WIDGET; dw->desc_flags = WDF_DEF_WIDGET;

View File

@ -1090,7 +1090,7 @@ bool InsertTextBufferClipboard(Textbuf *tb)
const char *ptr; const char *ptr;
WChar c; WChar c;
size_t width, length; uint16 width, length;
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
OpenClipboard(NULL); OpenClipboard(NULL);
@ -1122,7 +1122,7 @@ bool InsertTextBufferClipboard(Textbuf *tb)
for (ptr = utf8_buf; (c = Utf8Consume(&ptr)) != '\0';) { for (ptr = utf8_buf; (c = Utf8Consume(&ptr)) != '\0';) {
if (!IsPrintable(c)) break; if (!IsPrintable(c)) break;
size_t len = Utf8CharLen(c); byte len = Utf8CharLen(c);
if (tb->length + length >= tb->maxlength - len) break; if (tb->length + length >= tb->maxlength - len) break;
byte charwidth = GetCharacterWidth(FS_NORMAL, c); byte charwidth = GetCharacterWidth(FS_NORMAL, c);