Changeset - r4321:baa916e5dd65
[Not reviewed]
master
0 11 0
truelight - 18 years ago 2006-08-20 12:09:32
truelight@openttd.org
(svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
11 files changed with 14 insertions and 14 deletions:
0 comments (0 inline, 0 general)
bmp.c
Show inline comments
 
@@ -6,25 +6,25 @@
 
#include "bmp.h"
 
#include "macros.h"
 

	
 
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file) {
 
	buffer->pos      = -1;
 
	buffer->file     = file;
 
	buffer->read     = 0;
 
	buffer->real_pos = ftell(file);
 
}
 

	
 
static inline void AdvanceBuffer(BmpBuffer *buffer)
 
{
 
	buffer->read = fread(buffer->data, 1, BMP_BUFFER_SIZE, buffer->file);
 
	buffer->read = (int)fread(buffer->data, 1, BMP_BUFFER_SIZE, buffer->file);
 
	buffer->pos  = 0;
 
}
 

	
 
static inline bool EndOfBuffer(BmpBuffer *buffer)
 
{
 
	if (buffer->pos == buffer->read || buffer->pos < 0) AdvanceBuffer(buffer);
 
	return buffer->pos == buffer->read;
 
}
 

	
 
static inline byte ReadByte(BmpBuffer *buffer)
 
{
 
	if (buffer->pos == buffer->read || buffer->pos < 0) AdvanceBuffer(buffer);
console.c
Show inline comments
 
@@ -671,25 +671,25 @@ IConsoleAlias *IConsoleAliasGet(const ch
 
	IConsoleAlias* item;
 

	
 
	for (item = _iconsole_aliases; item != NULL; item = item->next) {
 
		if (strcmp(item->name, name) == 0) return item;
 
	}
 

	
 
	return NULL;
 
}
 

	
 
/** copy in an argument into the aliasstream */
 
static inline int IConsoleCopyInParams(char *dst, const char *src, uint bufpos)
 
{
 
	int len = min(ICON_MAX_STREAMSIZE - bufpos, strlen(src));
 
	int len = min(ICON_MAX_STREAMSIZE - bufpos, (int)strlen(src));
 
	strncpy(dst, src, len);
 

	
 
	return len;
 
}
 

	
 
/**
 
 * An alias is just another name for a command, or for more commands
 
 * Execute it as well.
 
 * @param *alias is the alias of the command
 
 * @param tokencount the number of parameters passed
 
 * @param *tokens are the parameters given to the original command (0 is the first param)
 
 */
misc.c
Show inline comments
 
@@ -244,25 +244,25 @@ int FindFirstBit(uint32 value)
 
	if (value & 0x00000002) { i += 1; }
 
	return i;
 
}
 

	
 

	
 
static void Save_NAME(void)
 
{
 
	int i;
 

	
 
	for (i = 0; i != lengthof(_name_array); ++i) {
 
		if (_name_array[i][0] != '\0') {
 
			SlSetArrayIndex(i);
 
			SlArray(_name_array[i], strlen(_name_array[i]), SLE_UINT8);
 
			SlArray(_name_array[i], (uint)strlen(_name_array[i]), SLE_UINT8);
 
		}
 
	}
 
}
 

	
 
static void Load_NAME(void)
 
{
 
	int index;
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		SlArray(_name_array[index],SlGetFieldLength(),SLE_UINT8);
 
	}
 
}
namegen.c
Show inline comments
 
@@ -466,57 +466,57 @@ static byte MakeCzechTownName(char *buf,
 
		assert(gender != CZG_FREE && gender != CZG_NFREE);
 
	}
 

	
 
	if (do_prefix && (name_czech_adj[prefix].choose & choose) != choose) {
 
		// Throw away non-matching prefix.
 
		do_prefix = false;
 
	}
 

	
 
	// Now finally construct the name
 

	
 
	if (do_prefix) {
 
		CzechPattern pattern = name_czech_adj[prefix].pattern;
 
		int endpos;
 
		size_t endpos;
 

	
 
		strcat(buf, name_czech_adj[prefix].name);
 
		endpos = strlen(buf) - 1;
 
		if (gender == CZG_SMASC && pattern == CZP_PRIVL) {
 
			/* -ovX -> -uv */
 
			buf[endpos - 2] = 'u';
 
			assert(buf[endpos - 1] == 'v');
 
			buf[endpos] = '\0';
 
		} else {
 
			buf[endpos] = name_czech_patmod[gender][pattern];
 
		}
 

	
 
		strcat(buf, " ");
 
	}
 

	
 
	if (dynamic_subst) {
 
		strcat(buf, name_czech_subst_stem[stem].name);
 
		if (postfix < lengthof(name_czech_subst_postfix)) {
 
			const char *poststr = name_czech_subst_postfix[postfix];
 
			const char *endstr = name_czech_subst_ending[ending].name;
 
			int postlen, endlen;
 
			size_t postlen, endlen;
 

	
 
			postlen = strlen(poststr);
 
			endlen = strlen(endstr);
 
			assert(postlen > 0 && endlen > 0);
 

	
 
			// Kill the "avava" and "Jananna"-like cases
 
			if (postlen < 2 || postlen > endlen || (
 
						(poststr[1] != 'v' || poststr[1] != endstr[1]) &&
 
						poststr[2] != endstr[1])
 
					) {
 
				uint buflen;
 
				size_t buflen;
 
				strcat(buf, poststr);
 
				buflen = strlen(buf);
 

	
 
				// k-i -> c-i, h-i -> z-i
 
				if (endstr[0] == 'i') {
 
					switch (buf[buflen - 1]) {
 
						case 'k': buf[buflen - 1] = 'c'; break;
 
						case 'h': buf[buflen - 1] = 'z'; break;
 
						default: break;
 
					}
 
				}
 
			}
network_server.c
Show inline comments
 
@@ -304,25 +304,25 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MA
 
		cs->status = STATUS_MAP;
 
		/* Mark the start of download */
 
		cs->last_frame = _frame_counter;
 
		cs->last_frame_server = _frame_counter;
 
	}
 

	
 
	if (cs->status == STATUS_MAP) {
 
		uint i;
 
		int res;
 
		for (i = 0; i < sent_packets; i++) {
 
			Packet *p = NetworkSend_Init(PACKET_SERVER_MAP);
 
			NetworkSend_uint8(p, MAP_PACKET_NORMAL);
 
			res = fread(p->buffer + p->size, 1, SEND_MTU - p->size, file_pointer);
 
			res = (int)fread(p->buffer + p->size, 1, SEND_MTU - p->size, file_pointer);
 
			if (ferror(file_pointer)) {
 
				error("Error reading temporary network savegame!");
 
			}
 
			p->size += res;
 
			NetworkSend_Packet(p, cs);
 
			if (feof(file_pointer)) {
 
				// Done reading!
 
				Packet *p = NetworkSend_Init(PACKET_SERVER_MAP);
 
				NetworkSend_uint8(p, MAP_PACKET_END);
 
				NetworkSend_Packet(p, cs);
 

	
 
				// Set the status to DONE_MAP, no we will wait for the client
newgrf.c
Show inline comments
 
@@ -1867,25 +1867,25 @@ static void FeatureNewName(byte *buf, in
 
#endif
 
			}
 
		} else {
 
			/* ofs is the string length + 1, so if the string is empty, ofs
 
			 * is 1 */
 
			if (ofs == 1) {
 
				DEBUG(grf, 7) ("FeatureNewName: Can't add empty name");
 
			} else {
 
				DEBUG(grf, 7) ("FeatureNewName: Too long a name (%d)", ofs);
 
			}
 
		}
 
		name += ofs;
 
		len -= ofs;
 
		len -= (int)ofs;
 
	}
 
}
 

	
 
/* Action 0x05 */
 
static void GraphicsNew(byte *buf, int len)
 
{
 
	/* <05> <graphics-type> <num-sprites> <other data...>
 
	 *
 
	 * B graphics-type What set of graphics the sprites define.
 
	 * E num-sprites   How many sprites are in this set?
 
	 * V other data    Graphics type specific data.  Currently unused. */
 
	/* TODO */
oldloader.c
Show inline comments
 
@@ -111,25 +111,25 @@ static inline byte CalcOldVarLen(OldChun
 

	
 
/**
 
 *
 
 * Reads a byte from a file (do not call yourself, use ReadByte())
 
 *
 
 */
 
static byte ReadByteFromFile(LoadgameState *ls)
 
{
 
	/* To avoid slow reads, we read BUFFER_SIZE of bytes per time
 
	and just return a byte per time */
 
	if (ls->buffer_cur >= ls->buffer_count) {
 
		/* Read some new bytes from the file */
 
		int count = fread(ls->buffer, 1, BUFFER_SIZE, ls->file);
 
		int count = (int)fread(ls->buffer, 1, BUFFER_SIZE, ls->file);
 

	
 
		/* We tried to read, but there is nothing in the file anymore.. */
 
		if (count == 0) {
 
			DEBUG(oldloader, 1)("[OldLoader] Read past end of file, loading failed");
 
			ls->failed = true;
 
		}
 

	
 
		ls->buffer_count = count;
 
		ls->buffer_cur   = 0;
 
	}
 

	
 
	return ls->buffer[ls->buffer_cur++];
 
@@ -367,25 +367,25 @@ static void FixOldVehicles(void)
 
 */
 

	
 

	
 
/* Help:
 
 *  - OCL_SVAR: load 'type' to offset 'offset' in a struct of type 'base', which must also
 
 *       be given via base in LoadChunk() as real pointer
 
 *  - OCL_VAR: load 'type' to a global var
 
 *  - OCL_END: every struct must end with this
 
 *  - OCL_NULL: read 'amount' of bytes and send them to /dev/null or something
 
 *  - OCL_CHUNK: load an other proc to load a part of the savegame, 'amount' times
 
 *  - OCL_ASSERT: to check if we are really at the place we expect to be.. because old savegames are too binary to be sure ;)
 
 */
 
#define OCL_SVAR(type, base, offset)         { type,          1, NULL,    offsetof(base, offset), NULL }
 
#define OCL_SVAR(type, base, offset)         { type,          1, NULL,    (uint)offsetof(base, offset), NULL }
 
#define OCL_VAR(type, amount, pointer)       { type,     amount, pointer, 0,                      NULL }
 
#define OCL_END()                                   { OC_END,        0, NULL,    0,                      NULL }
 
#define OCL_NULL(amount)                            { OC_NULL,  amount, NULL,    0,                      NULL }
 
#define OCL_CHUNK(amount, proc)                     { OC_CHUNK, amount, NULL,    0,                      proc }
 
#define OCL_ASSERT(size)                            { OC_ASSERT,     1, NULL, size,                      NULL }
 

	
 
/* The savegames has some hard-coded pointers, because it always enters the same
 
    piece of memory.. we don't.. so we need to remap ;)
 
   Old Towns are 94 bytes big
 
   Old Orders are 2 bytes big */
 
#define REMAP_TOWN_IDX(x) ((x) - (0x0459154 - 0x0458EF0)) / 94
 
#define REMAP_ORDER_IDX(x) ((x) - (0x045AB08 - 0x0458EF0)) / 2
players.c
Show inline comments
 
@@ -1056,25 +1056,25 @@ int8 SaveHighScoreValueNetwork(void)
 
/* Save HighScore table to file */
 
void SaveToHighScore(void)
 
{
 
	FILE *fp = fopen(_highscore_file, "wb");
 

	
 
	if (fp != NULL) {
 
		uint i;
 
		HighScore *hs;
 

	
 
		for (i = 0; i < LAST_HS_ITEM; i++) { // don't save network highscores
 
			for (hs = _highscore_table[i]; hs != endof(_highscore_table[i]); hs++) {
 
				/* First character is a command character, so strlen will fail on that */
 
				byte length = min(sizeof(hs->company), (hs->company[0] == '\0') ? 0 : strlen(&hs->company[1]) + 1);
 
				byte length = min(sizeof(hs->company), (hs->company[0] == '\0') ? 0 : (int)strlen(&hs->company[1]) + 1);
 

	
 
				fwrite(&length, sizeof(length), 1, fp); // write away string length
 
				fwrite(hs->company, length, 1, fp);
 
				fwrite(&hs->score, sizeof(hs->score), 1, fp);
 
				fwrite("", 2, 1, fp); /* XXX - placeholder for hs->title, not saved anymore; compatibility */
 
			}
 
		}
 
		fclose(fp);
 
	}
 
}
 

	
 
/* Initialize the highscore table to 0 and if any file exists, load in values */
spritecache.c
Show inline comments
 
@@ -183,25 +183,25 @@ void SkipSprites(uint count)
 
}
 

	
 

	
 
#define S_FREE_MASK 1
 

	
 
static inline MemBlock* NextBlock(MemBlock* block)
 
{
 
	return (MemBlock*)((byte*)block + (block->size & ~S_FREE_MASK));
 
}
 

	
 
static uint32 GetSpriteCacheUsage(void)
 
{
 
	size_t tot_size = 0;
 
	uint32 tot_size = 0;
 
	MemBlock* s;
 

	
 
	for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s))
 
		if (!(s->size & S_FREE_MASK)) tot_size += s->size;
 

	
 
	return tot_size;
 
}
 

	
 

	
 
void IncreaseSpriteLRU(void)
 
{
 
	int i;
strings.c
Show inline comments
 
@@ -1220,25 +1220,25 @@ void InitializeLanguagePacks(void)
 

	
 
	char lang[] = "en";
 
	const char *env = GetCurrentLocale("LC_MESSAGES");
 

	
 
	if (env != NULL) snprintf(lang, lengthof(lang), "%.2s", env);
 
	n = GetLanguageList(files, lengthof(files));
 

	
 
	def = -1;
 
	fallback = 0;
 

	
 
	// go through the language files and make sure that they are valid.
 
	for (i = m = 0; i != n; i++) {
 
		int j;
 
		size_t j;
 

	
 
		char *s = str_fmt("%s%s", _path.lang_dir, files[i]);
 
		in = fopen(s, "rb");
 
		free(s);
 
		if (in == NULL ||
 
				(j = fread(&hdr, sizeof(hdr), 1, in), fclose(in), j) != 1 ||
 
				hdr.ident != TO_LE32(LANGUAGE_PACK_IDENT) ||
 
				hdr.version != TO_LE32(LANGUAGE_PACK_VERSION)) {
 
			free(files[i]);
 
			continue;
 
		}
 

	
win32.c
Show inline comments
 
@@ -256,25 +256,25 @@ static const char *SubmitCrashReport(HWN
 

	
 
	inet = _wininet.InternetOpen("OTTD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
 
	if (inet == NULL) { err = "internetopen failed"; goto error1; }
 

	
 
	conn = _wininet.InternetConnect(inet, "openttd.com", INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0);
 
	if (conn == NULL) { err = "internetconnect failed"; goto error2; }
 

	
 
	sprintf(buff, "/crash.php?file=%s&ident=%d", arg, _ident);
 

	
 
	http = _wininet.HttpOpenRequest(conn, "POST", buff, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE , 0);
 
	if (http == NULL) { err = "httpopenrequest failed"; goto error3; }
 

	
 
	if (!_wininet.HttpSendRequest(http, "Content-type: application/binary", -1, msg, msglen)) { err = "httpsendrequest failed"; goto error4; }
 
	if (!_wininet.HttpSendRequest(http, "Content-type: application/binary", -1, msg, (DWORD)msglen)) { err = "httpsendrequest failed"; goto error4; }
 

	
 
	len = sizeof(code);
 
	if (!_wininet.HttpQueryInfo(http, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &code, &len, 0)) { err = "httpqueryinfo failed"; goto error4; }
 

	
 
	if (code != 200) {
 
		int l = sprintf(buf, "Server said: %d ", code);
 
		len = sizeof(buf) - l;
 
		_wininet.HttpQueryInfo(http, HTTP_QUERY_STATUS_TEXT, buf + l, &len, 0);
 
		err = buf;
 
	}
 

	
 
error4:
0 comments (0 inline, 0 general)