summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-05-08 13:20:54 +0000
committerglx <glx@openttd.org>2008-05-08 13:20:54 +0000
commite48a351f8e006b19d9e2c7bf9ef672a1e141d85f (patch)
tree8d4f7ac36d25e220f571af8ff584b7fa76c13cc1
parentf7b6a02b1e9850c4cdb281148a1cee78c2a3f2a8 (diff)
downloadopenttd-e48a351f8e006b19d9e2c7bf9ef672a1e141d85f.tar.xz
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
-rw-r--r--src/fileio.cpp10
-rw-r--r--src/fileio.h6
-rw-r--r--src/network/network_gui.cpp6
-rw-r--r--src/network/network_udp.cpp2
-rw-r--r--src/newgrf.cpp66
-rw-r--r--src/newgrf_config.cpp2
-rw-r--r--src/settings.cpp24
-rw-r--r--src/spritecache.cpp2
-rw-r--r--src/string_func.h4
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/win32.cpp5
11 files changed, 64 insertions, 65 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index b28a27a6b..7fbb3789a 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -27,7 +27,7 @@
struct Fio {
byte *buffer, *buffer_end; ///< position pointer in local buffer and last valid byte of buffer
- uint32 pos; ///< current (system) position in file
+ size_t pos; ///< current (system) position in file
FILE *cur_fh; ///< current file handle
const char *filename; ///< current filename
FILE *handles[MAX_FILE_SLOTS]; ///< array of file handles we can have open
@@ -125,7 +125,7 @@ uint32 FioReadDword()
return (FioReadWord() << 16) | b;
}
-void FioReadBlock(void *ptr, uint size)
+void FioReadBlock(void *ptr, size_t size)
{
FioSeekTo(FioGetPos(), SEEK_SET);
_fio.pos += fread(ptr, 1, size, _fio.cur_fh);
@@ -480,7 +480,7 @@ static bool TarListAddFile(const char *filename)
TarHeader th;
char buf[sizeof(th.name) + 1], *end;
char name[sizeof(th.prefix) + 1 + sizeof(th.name) + 1];
- int num = 0, pos = 0;
+ size_t num = 0, pos = 0;
/* Make a char of 512 empty bytes */
char empty[512];
@@ -499,7 +499,7 @@ static bool TarListAddFile(const char *filename)
}
name[0] = '\0';
- int len = 0;
+ size_t len = 0;
/* The prefix contains the directory-name */
if (th.prefix[0] != '\0') {
@@ -550,7 +550,7 @@ static bool TarListAddFile(const char *filename)
return true;
}
-static int ScanPathForTarFiles(const char *path, int basepath_length)
+static int ScanPathForTarFiles(const char *path, size_t basepath_length)
{
extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb);
diff --git a/src/fileio.h b/src/fileio.h
index 881c983f3..ed2a8b506 100644
--- a/src/fileio.h
+++ b/src/fileio.h
@@ -18,7 +18,7 @@ uint16 FioReadWord();
uint32 FioReadDword();
void FioCloseAll();
void FioOpenFile(int slot, const char *filename);
-void FioReadBlock(void *ptr, uint size);
+void FioReadBlock(void *ptr, size_t size);
void FioSkipBytes(int n);
void FioCreateDirectory(const char *filename);
@@ -70,8 +70,8 @@ struct TarListEntry {
};
struct TarFileListEntry {
TarListEntry *tar;
- int size;
- int position;
+ size_t size;
+ size_t position;
};
typedef std::map<std::string, TarListEntry *> TarList;
typedef std::map<std::string, TarFileListEntry> TarFileList;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 569db534b..8dd90d37d 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1778,7 +1778,7 @@ static void ChatTabCompletion(Window *w)
{
static char _chat_tab_completion_buf[lengthof(_edit_str_net_buf)];
Textbuf *tb = &WP(w, chatquerystr_d).text;
- uint len, tb_len;
+ size_t len, tb_len;
uint item;
char *tb_buf, *pre_buf;
const char *cur_name;
@@ -1799,8 +1799,8 @@ static void ChatTabCompletion(Window *w)
/* We are pressing TAB again on the same name, is there an other name
* that starts with this? */
if (!second_scan) {
- uint offset;
- uint length;
+ size_t offset;
+ size_t length;
/* If we are completing at the begin of the line, skip the ': ' we added */
if (tb_buf == pre_buf) {
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 302100823..636bf67fb 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -205,7 +205,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_GET_NEWGRFS)
const GRFConfig *in_reply[NETWORK_MAX_GRF_COUNT];
uint8 in_reply_count = 0;
- uint packet_len = 0;
+ size_t packet_len = 0;
DEBUG(net, 6, "[udp] newgrf data request from %s:%d", inet_ntoa(client_addr->sin_addr), ntohs(client_addr->sin_port));
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index cf050e455..4567e7ae3 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -96,7 +96,7 @@ static byte _grf_data_blocks;
static GrfDataType _grf_data_type;
-typedef void (*SpecialSpriteHandler)(byte *buf, int len);
+typedef void (*SpecialSpriteHandler)(byte *buf, size_t len);
enum {
MAX_STATIONS = 256,
@@ -152,7 +152,7 @@ void CDECL grfmsg(int severity, const char *str, ...)
DEBUG(grf, severity, "[%s:%d] %s", _cur_grfconfig->filename, _nfo_line, buf);
}
-static inline bool check_length(int real, int wanted, const char *str)
+static inline bool check_length(size_t real, size_t wanted, const char *str)
{
if (real >= wanted) return true;
grfmsg(0, "%s: Invalid pseudo sprite length %d (expected %d)!", str, real, wanted);
@@ -2248,7 +2248,7 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
}
/* Action 0x00 */
-static void FeatureChangeInfo(byte *buf, int len)
+static void FeatureChangeInfo(byte *buf, size_t len)
{
byte *bufend = buf + len;
@@ -2363,7 +2363,7 @@ static void FeatureChangeInfo(byte *buf, int len)
}
/* Action 0x00 (GLS_SAFETYSCAN) */
-static void SafeChangeInfo(byte *buf, int len)
+static void SafeChangeInfo(byte *buf, size_t len)
{
if (!check_length(len, 6, "SafeChangeInfo")) return;
buf++;
@@ -2386,7 +2386,7 @@ static void SafeChangeInfo(byte *buf, int len)
}
/* Action 0x00 (GLS_RESERVE) */
-static void ReserveChangeInfo(byte *buf, int len)
+static void ReserveChangeInfo(byte *buf, size_t len)
{
byte *bufend = buf + len;
@@ -2482,7 +2482,7 @@ static const SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites
}
/* Action 0x01 */
-static void NewSpriteSet(byte *buf, int len)
+static void NewSpriteSet(byte *buf, size_t len)
{
/* <01> <feature> <num-sets> <num-ent>
*
@@ -2518,7 +2518,7 @@ static void NewSpriteSet(byte *buf, int len)
}
/* Action 0x01 (SKIP) */
-static void SkipAct1(byte *buf, int len)
+static void SkipAct1(byte *buf, size_t len)
{
if (!check_length(len, 4, "SkipAct1")) return;
buf++;
@@ -2577,7 +2577,7 @@ static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte
}
/* Action 0x02 */
-static void NewSpriteGroup(byte *buf, int len)
+static void NewSpriteGroup(byte *buf, size_t len)
{
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...>
*
@@ -3182,7 +3182,7 @@ static void CargoMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount)
/* Action 0x03 */
-static void FeatureMapSpriteGroup(byte *buf, int len)
+static void FeatureMapSpriteGroup(byte *buf, size_t len)
{
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid>
* id-list := [<id>] [id-list]
@@ -3267,7 +3267,7 @@ static void FeatureMapSpriteGroup(byte *buf, int len)
}
/* Action 0x04 */
-static void FeatureNewName(byte *buf, int len)
+static void FeatureNewName(byte *buf, size_t len)
{
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...>
*
@@ -3421,7 +3421,7 @@ static uint16 SanitizeSpriteOffset(uint16& num, uint16 offset, int max_sprites,
}
/* Action 0x05 */
-static void GraphicsNew(byte *buf, int len)
+static void GraphicsNew(byte *buf, size_t len)
{
/* <05> <graphics-type> <num-sprites> <other data...>
*
@@ -3535,7 +3535,7 @@ static void GraphicsNew(byte *buf, int len)
}
/* Action 0x05 (SKIP) */
-static void SkipAct5(byte *buf, int len)
+static void SkipAct5(byte *buf, size_t len)
{
if (!check_length(len, 2, "SkipAct5")) return;
buf++;
@@ -3711,7 +3711,7 @@ static uint32 GetParamVal(byte param, uint32 *cond_val)
}
/* Action 0x06 */
-static void CfgApply(byte *buf, int len)
+static void CfgApply(byte *buf, size_t len)
{
/* <06> <param-num> <param-size> <offset> ... <FF>
*
@@ -3799,7 +3799,7 @@ static void CfgApply(byte *buf, int len)
/* Action 0x07 */
/* Action 0x09 */
-static void SkipIf(byte *buf, int len)
+static void SkipIf(byte *buf, size_t len)
{
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites>
*
@@ -3954,7 +3954,7 @@ static void SkipIf(byte *buf, int len)
/* Action 0x08 (GLS_FILESCAN) */
-static void ScanInfo(byte *buf, int len)
+static void ScanInfo(byte *buf, size_t len)
{
if (!check_length(len, 8, "Info")) return;
buf++;
@@ -3981,7 +3981,7 @@ static void ScanInfo(byte *buf, int len)
}
/* Action 0x08 */
-static void GRFInfo(byte *buf, int len)
+static void GRFInfo(byte *buf, size_t len)
{
/* <08> <version> <grf-id> <name> <info>
*
@@ -4005,7 +4005,7 @@ static void GRFInfo(byte *buf, int len)
}
/* Action 0x0A */
-static void SpriteReplace(byte *buf, int len)
+static void SpriteReplace(byte *buf, size_t len)
{
/* <0A> <num-sets> <set1> [<set2> ...]
* <set>: <num-sprites> <first-sprite>
@@ -4041,7 +4041,7 @@ static void SpriteReplace(byte *buf, int len)
}
/* Action 0x0A (SKIP) */
-static void SkipActA(byte *buf, int len)
+static void SkipActA(byte *buf, size_t len)
{
buf++;
uint8 num_sets = grf_load_byte(&buf);
@@ -4057,7 +4057,7 @@ static void SkipActA(byte *buf, int len)
}
/* Action 0x0B */
-static void GRFLoadError(byte *buf, int len)
+static void GRFLoadError(byte *buf, size_t len)
{
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>]
*
@@ -4167,7 +4167,7 @@ static void GRFLoadError(byte *buf, int len)
}
/* Action 0x0C */
-static void GRFComment(byte *buf, int len)
+static void GRFComment(byte *buf, size_t len)
{
/* <0C> [<ignored...>]
*
@@ -4175,13 +4175,13 @@ static void GRFComment(byte *buf, int len)
if (len == 1) return;
- int text_len = len - 1;
+ size_t text_len = len - 1;
const char *text = (const char*)(buf + 1);
grfmsg(2, "GRFComment: %.*s", text_len, text);
}
/* Action 0x0D (GLS_SAFETYSCAN) */
-static void SafeParamSet(byte *buf, int len)
+static void SafeParamSet(byte *buf, size_t len)
{
if (!check_length(len, 5, "SafeParamSet")) return;
buf++;
@@ -4313,7 +4313,7 @@ static uint32 PerformGRM(uint32 *grm, uint16 num_ids, uint16 count, uint8 op, ui
/* Action 0x0D */
-static void ParamSet(byte *buf, int len)
+static void ParamSet(byte *buf, size_t len)
{
/* <0D> <target> <operation> <source1> <source2> [<data>]
*
@@ -4604,7 +4604,7 @@ static void ParamSet(byte *buf, int len)
}
/* Action 0x0E (GLS_SAFETYSCAN) */
-static void SafeGRFInhibit(byte *buf, int len)
+static void SafeGRFInhibit(byte *buf, size_t len)
{
/* <0E> <num> <grfids...>
*
@@ -4632,7 +4632,7 @@ static void SafeGRFInhibit(byte *buf, int len)
}
/* Action 0x0E */
-static void GRFInhibit(byte *buf, int len)
+static void GRFInhibit(byte *buf, size_t len)
{
/* <0E> <num> <grfids...>
*
@@ -4657,7 +4657,7 @@ static void GRFInhibit(byte *buf, int len)
}
/* Action 0x0F */
-static void FeatureTownName(byte *buf, int len)
+static void FeatureTownName(byte *buf, size_t len)
{
/* <0F> <id> <style-name> <num-parts> <parts>
*
@@ -4757,7 +4757,7 @@ static void FeatureTownName(byte *buf, int len)
}
/* Action 0x10 */
-static void DefineGotoLabel(byte *buf, int len)
+static void DefineGotoLabel(byte *buf, size_t len)
{
/* <10> <label> [<comment>]
*
@@ -4787,7 +4787,7 @@ static void DefineGotoLabel(byte *buf, int len)
}
/* Action 0x11 */
-static void GRFSound(byte *buf, int len)
+static void GRFSound(byte *buf, size_t len)
{
/* <11> <num>
*
@@ -4804,7 +4804,7 @@ static void GRFSound(byte *buf, int len)
}
/* Action 0x11 (SKIP) */
-static void SkipAct11(byte *buf, int len)
+static void SkipAct11(byte *buf, size_t len)
{
/* <11> <num>
*
@@ -4930,7 +4930,7 @@ static void LoadGRFSound(byte *buf, int len)
}
/* Action 0x12 */
-static void LoadFontGlyph(byte *buf, int len)
+static void LoadFontGlyph(byte *buf, size_t len)
{
/* <12> <num_def> <font_size> <num_char> <base_char>
*
@@ -4962,7 +4962,7 @@ static void LoadFontGlyph(byte *buf, int len)
}
/* Action 0x12 (SKIP) */
-static void SkipAct12(byte *buf, int len)
+static void SkipAct12(byte *buf, size_t len)
{
/* <12> <num_def> <font_size> <num_char> <base_char>
*
@@ -4992,7 +4992,7 @@ static void SkipAct12(byte *buf, int len)
}
/* Action 0x13 */
-static void TranslateGRFStrings(byte *buf, int len)
+static void TranslateGRFStrings(byte *buf, size_t len)
{
/* <13> <grfid> <num-ent> <offset> <text...>
*
@@ -5086,7 +5086,7 @@ static void GRFDataBlock(byte *buf, int len)
/* Used during safety scan on unsafe actions */
-static void GRFUnsafe(byte *buf, int len)
+static void GRFUnsafe(byte *buf, size_t len)
{
SetBit(_cur_grfconfig->flags, GCF_UNSAFE);
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 903ad7fb3..03cb0aa41 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -309,7 +309,7 @@ static bool ScanPathAddGrf(const char *filename)
}
/* Scan a path for NewGRFs */
-static uint ScanPath(const char *path, int basepath_length)
+static uint ScanPath(const char *path, size_t basepath_length)
{
extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb);
diff --git a/src/settings.cpp b/src/settings.cpp
index a9e2ac1fb..9c7338fac 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -78,18 +78,18 @@ typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *
typedef void SettingDescProcList(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc);
static void pool_init(SettingsMemoryPool **pool);
-static void *pool_alloc(SettingsMemoryPool **pool, uint size);
-static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size);
+static void *pool_alloc(SettingsMemoryPool **pool, size_t size);
+static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, size_t size);
static void pool_free(SettingsMemoryPool **pool);
static bool IsSignedVarMemType(VarType vt);
struct SettingsMemoryPool {
- uint pos, size;
+ size_t pos, size;
SettingsMemoryPool *next;
byte mem[1];
};
-static SettingsMemoryPool *pool_new(uint minsize)
+static SettingsMemoryPool *pool_new(size_t minsize)
{
SettingsMemoryPool *p;
if (minsize < 4096 - 12) minsize = 4096 - 12;
@@ -106,9 +106,9 @@ static void pool_init(SettingsMemoryPool **pool)
*pool = pool_new(0);
}
-static void *pool_alloc(SettingsMemoryPool **pool, uint size)
+static void *pool_alloc(SettingsMemoryPool **pool, size_t size)
{
- uint pos;
+ size_t pos;
SettingsMemoryPool *p = *pool;
size = Align(size, sizeof(void*));
@@ -129,7 +129,7 @@ static void *pool_alloc(SettingsMemoryPool **pool, uint size)
return p->mem + pos;
}
-static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size)
+static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, size_t size)
{
byte *p = (byte*)pool_alloc(pool, size + 1);
p[size] = 0;
@@ -186,7 +186,7 @@ static IniFile *ini_alloc()
}
/** allocate an ini group object */
-static IniGroup *ini_group_alloc(IniFile *ini, const char *grpt, int len)
+static IniGroup *ini_group_alloc(IniFile *ini, const char *grpt, size_t len)
{
IniGroup *grp = (IniGroup*)pool_alloc(&ini->pool, sizeof(IniGroup));
grp->ini = ini;
@@ -205,7 +205,7 @@ static IniGroup *ini_group_alloc(IniFile *ini, const char *grpt, int len)
return grp;
}
-static IniItem *ini_item_alloc(IniGroup *group, const char *name, int len)
+static IniItem *ini_item_alloc(IniGroup *group, const char *name, size_t len)
{
IniItem *item = (IniItem*)pool_alloc(&group->ini->pool, sizeof(IniItem));
item->name = (char*)pool_strdup(&group->ini->pool, name, len);
@@ -324,7 +324,7 @@ static IniFile *ini_load(const char *filename)
}
/** lookup a group or make a new one */
-static IniGroup *ini_getgroup(IniFile *ini, const char *name, int len)
+static IniGroup *ini_getgroup(IniFile *ini, const char *name, size_t len)
{
IniGroup *group;
@@ -345,7 +345,7 @@ static IniGroup *ini_getgroup(IniFile *ini, const char *name, int len)
static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
{
IniItem *item;
- uint len = strlen(name);
+ size_t len = strlen(name);
for (item = group->item; item; item = item->next)
if (strcmp(item->name, name) == 0) return item;
@@ -404,7 +404,7 @@ static void ini_free(IniFile *ini)
* @param one the current value of the setting for which a value needs found
* @param onelen force calculation of the *one parameter
* @return the integer index of the full-list, or -1 if not found */
-static int lookup_oneofmany(const char *many, const char *one, int onelen)
+static int lookup_oneofmany(const char *many, const char *one, size_t onelen)
{
const char *s;
int idx;
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 1fdbc4f81..b3b669c32 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -61,7 +61,7 @@ static SpriteCache *AllocateSpriteCache(uint index)
struct MemBlock {
- uint32 size;
+ size_t size;
byte data[VARARRAY_SIZE];
};
diff --git a/src/string_func.h b/src/string_func.h
index 0733931f3..0e7aa5331 100644
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -45,10 +45,10 @@ static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
/** Get the length of a string, within a limited buffer */
-static inline int ttd_strnlen(const char *str, int maxlen)
+static inline size_t ttd_strnlen(const char *str, size_t maxlen)
{
const char *t;
- for (t = str; *t != '\0' && t - str < maxlen; t++) {}
+ for (t = str; *t != '\0' && (size_t)(t - str) < maxlen; t++) {}
return t - str;
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 73f2bb0d6..9b8325832 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2691,7 +2691,7 @@ void BackuppedVehicle::BackupVehicle(Vehicle *v)
{
int length = CountVehiclesInChain(v);
- uint cargo_packages_count = 1;
+ size_t cargo_packages_count = 1;
for (const Vehicle *v_count = v; v_count != NULL; v_count=v_count->Next()) {
/* Now we count how many cargo packets we need to store.
* We started with an offset by one because we also need an end of array marker. */
diff --git a/src/win32.cpp b/src/win32.cpp
index 5f3a1388a..e2f010fff 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -206,16 +206,15 @@ static char *PrintModuleList(char *output)
HMODULE modules[100];
DWORD needed;
BOOL res;
- int count, i;
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
if (proc != NULL) {
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
CloseHandle(proc);
if (res) {
- count = min(needed / sizeof(HMODULE), lengthof(modules));
+ size_t count = min(needed / sizeof(HMODULE), lengthof(modules));
- for (i = 0; i != count; i++) output = PrintModuleInfo(output, modules[i]);
+ for (size_t i = 0; i != count; i++) output = PrintModuleInfo(output, modules[i]);
return output;
}
}