(svn r1833) byte -> char transition: the rest
authortron
Sun, 06 Feb 2005 22:25:27 +0000
changeset 1329 a8a0d60b0a8e
parent 1328 e069d2db0e4c
child 1330 8a67d04016ce
(svn r1833) byte -> char transition: the rest
console_cmds.c
engine.c
engine.h
functions.h
main_gui.c
misc_gui.c
network.c
network.h
network_udp.c
network_udp.h
newgrf.c
news_gui.c
players.c
settings.c
spritecache.c
station_gui.c
ttd.c
variables.h
--- a/console_cmds.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/console_cmds.c	Sun Feb 06 22:25:27 2005 +0000
@@ -554,8 +554,8 @@
 DEF_CONSOLE_CMD(ConNetworkConnect)
 {
 	char* ip;
-	const byte *port = NULL;
-	const byte *player = NULL;
+	const char *port = NULL;
+	const char *player = NULL;
 	uint16 rport;
 
 	if (argc<2) return NULL;
--- a/engine.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/engine.c	Sun Feb 06 22:25:27 2005 +0000
@@ -625,7 +625,7 @@
 
 static char *_engine_custom_names[256];
 
-void SetCustomEngineName(int engine, char *name)
+void SetCustomEngineName(int engine, const char *name)
 {
 	_engine_custom_names[engine] = strdup(name);
 }
--- a/engine.h	Sun Feb 06 20:53:31 2005 +0000
+++ b/engine.h	Sun Feb 06 22:25:27 2005 +0000
@@ -114,7 +114,7 @@
 };
 void TriggerVehicle(Vehicle *veh, enum VehicleTrigger trigger);
 
-void SetCustomEngineName(int engine, char *name);
+void SetCustomEngineName(int engine, const char *name);
 StringID GetCustomEngineName(int engine);
 
 
--- a/functions.h	Sun Feb 06 20:53:31 2005 +0000
+++ b/functions.h	Sun Feb 06 22:25:27 2005 +0000
@@ -147,7 +147,7 @@
 void NetworkGameLoop(void);
 void NetworkUDPGameLoop(void);
 bool NetworkServerStart(void);
-bool NetworkClientConnectGame(const byte* host, unsigned short port);
+bool NetworkClientConnectGame(const char* host, unsigned short port);
 void NetworkReboot(void);
 void NetworkDisconnect(void);
 void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
--- a/main_gui.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/main_gui.c	Sun Feb 06 22:25:27 2005 +0000
@@ -2102,10 +2102,11 @@
 static bool DrawScrollingStatusText(NewsItem *ni, int pos)
 {
 	StringID str;
-	byte *s, *d;
+	const char *s;
+	char *d;
 	DrawPixelInfo tmp_dpi, *old_dpi;
 	int x;
-	byte buffer[256];
+	char buffer[256];
 
 	if (ni->display_mode == 3) {
 		str = _get_news_string_callback[ni->callback](ni);
@@ -2127,7 +2128,7 @@
 		} else if (*s == 0x0D) {
 			d[0] = d[1] = d[2] = d[3] = ' ';
 			d+=4;
-		} else if (*s >= ' ' && (*s < 0x88 || *s >= 0x99)) {
+		} else if ((byte)*s >= ' ' && ((byte)*s < 0x88 || (byte)*s >= 0x99)) {
 			*d++ = *s;
 		}
 	}
--- a/misc_gui.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/misc_gui.c	Sun Feb 06 22:25:27 2005 +0000
@@ -678,7 +678,7 @@
 static void DrawStationCoverageText(const uint *accepts, int str_x, int str_y, uint mask)
 {
 	int i;
-	byte *b;
+	char *b;
 
 	b = _userstring;
 	b[0] = 0x81;
@@ -698,7 +698,7 @@
 		}
 	}
 
-	if (b == (byte*)&_userstring[3]) {
+	if (b == &_userstring[3]) {
 		b[0] = 0x81;
 		b[1] = STR_00D0_NOTHING;
 		b[2] = STR_00D0_NOTHING >> 8;
@@ -779,7 +779,7 @@
  * [IN]buf: string to be checked
  * [OUT]count: gets set to the count of characters
  * [OUT]width: gets set to the pixels width */
-static void GetCurrentStringSize(const byte *buf, int *count, int *width)
+static void GetCurrentStringSize(const char *buf, int *count, int *width)
 {
 	*count = 0;
 	*width = -1;
@@ -788,7 +788,7 @@
 		if (*++buf == 0)
 			break;
 		(*count)++;
-		(*width) += _stringwidth_table[*buf - 32];
+		(*width) += _stringwidth_table[(byte)*buf - 32];
 	} while (1);
 }
 
--- a/network.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/network.c	Sun Feb 06 22:25:27 2005 +0000
@@ -425,9 +425,9 @@
 // connection_string will be re-terminated to seperate out the hostname, and player and port will
 // be set to the player and port strings given by the user, inside the memory area originally
 // occupied by connection_string.
-void ParseConnectionString(const byte **player, const byte **port, byte *connection_string)
+void ParseConnectionString(const char **player, const char **port, char *connection_string)
 {
-	byte *p;
+	char *p;
 	for (p = connection_string; *p != '\0'; p++) {
 		if (*p == '#') {
 			*player = p + 1;
@@ -819,7 +819,7 @@
 // Query a server to fetch his game-info
 //  If game_info is true, only the gameinfo is fetched,
 //   else only the client_info is fetched
-NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info)
+NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info)
 {
 	if (!_network_available) return NULL;
 
@@ -853,13 +853,13 @@
 /* Validates an address entered as a string and adds the server to
  * the list. If you use this functions, the games will be marked
  * as manually added. */
-void NetworkAddServer(const byte *b)
+void NetworkAddServer(const char *b)
 {
 	if (*b != '\0') {
 		NetworkGameList *item;
-		const byte *port = NULL;
-		const byte *player = NULL;
-		byte host[NETWORK_HOSTNAME_LENGTH];
+		const char *port = NULL;
+		const char *player = NULL;
+		char host[NETWORK_HOSTNAME_LENGTH];
 		uint16 rport;
 
 		ttd_strlcpy(host, b, lengthof(host));
@@ -896,7 +896,7 @@
 }
 
 // Used by clients, to connect to a server
-bool NetworkClientConnectGame(const byte* host, unsigned short port)
+bool NetworkClientConnectGame(const char* host, unsigned short port)
 {
 	if (!_network_available) return false;
 
--- a/network.h	Sun Feb 06 20:53:31 2005 +0000
+++ b/network.h	Sun Feb 06 22:25:27 2005 +0000
@@ -196,7 +196,7 @@
 
 VARDEF uint16 _network_restart_game_date;    // If this year is reached, the server automaticly restarts
 
-NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info);
+NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info);
 
 #endif /* ENABLE_NETWORK */
 
@@ -211,9 +211,9 @@
 VARDEF bool _network_dedicated; // are we a dedicated server?
 VARDEF byte _network_playas; // an id to play as..
 
-void ParseConnectionString(const byte **player, const byte **port, byte *connection_string);
+void ParseConnectionString(const char **player, const char **port, char *connection_string);
 void NetworkUpdateClientInfo(uint16 client_index);
-void NetworkAddServer(const byte *b);
+void NetworkAddServer(const char *b);
 void NetworkRebuildHostList(void);
 void NetworkChangeCompanyPassword(const char *str);
 
--- a/network_udp.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/network_udp.c	Sun Feb 06 22:25:27 2005 +0000
@@ -516,7 +516,7 @@
 	_network_udp_broadcast = 300; // Stay searching for 300 ticks
 }
 
-NetworkGameList *NetworkUDPQueryServer(const byte* host, unsigned short port)
+NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port)
 {
 	struct sockaddr_in out_addr;
 	Packet *p;
--- a/network_udp.h	Sun Feb 06 20:53:31 2005 +0000
+++ b/network_udp.h	Sun Feb 06 22:25:27 2005 +0000
@@ -8,7 +8,7 @@
 void NetworkUDPReceive(SOCKET udp);
 void NetworkUDPSearchGame(void);
 void NetworkUDPQueryMasterServer(void);
-NetworkGameList *NetworkUDPQueryServer(const byte* host, unsigned short port);
+NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port);
 void NetworkUDPAdvertise(void);
 void NetworkUDPRemoveAdvertise(void);
 
--- a/newgrf.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/newgrf.c	Sun Feb 06 22:25:27 2005 +0000
@@ -1509,6 +1509,7 @@
 	uint8 lang;
 	uint8 id;
 	uint8 endid;
+	const char* name;
 
 	check_length(len, 6, "VehicleNewName");
 	feature = buf[1];
@@ -1530,17 +1531,19 @@
 		return;
 	}
 
-	buf += 5, len -= 5;
+	name = (const char*)(buf + 5);
+	len -= 5;
 	for (; id < endid && len > 0; id++) {
-		int ofs = strlen(buf) + 1;
+		int ofs = strlen(name) + 1;
 
 		if (ofs < 128) {
-			DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, buf);
-			SetCustomEngineName(id, buf);
+			DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name);
+			SetCustomEngineName(id, name);
 		} else {
 			DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs);
 		}
-		buf += ofs, len -= ofs;
+		name += ofs;
+		len -= ofs;
 	}
 }
 
@@ -1712,14 +1715,14 @@
 	/* TODO: Check version. (We should have own versioning done somehow.) */
 	uint8 version;
 	uint32 grfid;
-	char *name;
-	char *info;
+	const char *name;
+	const char *info;
 
 	check_length(len, 9, "GRFInfo");
 	version = buf[1];
 	/* this is de facto big endian - grf_load_dword() unsuitable */
 	grfid = buf[2] << 24 | buf[3] << 16 | buf[4] << 8 | buf[5];
-	name = buf + 6;
+	name = (const char*)(buf + 6);
 	info = name + strlen(name) + 1;
 
 	_cur_grffile->grfid = grfid;
--- a/news_gui.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/news_gui.c	Sun Feb 06 22:25:27 2005 +0000
@@ -503,10 +503,11 @@
 }
 
 // cut string after len pixels
-static void GetNewsString(NewsItem *ni, byte *buffer, uint max)
+static void GetNewsString(NewsItem *ni, char *buffer, uint max)
 {
 	StringID str;
-	byte *s, *d;
+	const char *s;
+	char *d;
 	uint len = 0;
 
 	if (ni->display_mode == 3) {
@@ -537,8 +538,8 @@
 		} else if (*s == '\r') {
 			d[0] = d[1] = d[2] = d[3] = ' ';
 			d += 4;
-		} else if (*s >= ' ' && (*s < 0x88 || *s >= 0x99)) {
-			len += _stringwidth_table[*s - 32];
+		} else if ((byte)*s >= ' ' && ((byte)*s < 0x88 || (byte)*s >= 0x99)) {
+			len += _stringwidth_table[(byte)*s - 32];
 			*d++ = *s;
 		}
 	}
@@ -549,7 +550,6 @@
 {
 	switch (e->event) {
 	case WE_PAINT: {
-		byte buffer[256];
 		int y = 19;
 		byte p, show;
 		NewsItem *ni;
@@ -560,6 +560,8 @@
 		show = min(_total_news, w->vscroll.cap);
 
 		for (p = w->vscroll.pos; p < w->vscroll.pos + show; p++) {
+			char buffer[256];
+
 			// get news in correct order
 			ni = &_news_items[getNews(p)];
 
--- a/players.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/players.c	Sun Feb 06 22:25:27 2005 +0000
@@ -775,7 +775,7 @@
 	for (i = 0; i < lengthof(_highscore_table[0]); i++) {
 		/* You are in the TOP5. Move all values one down and save us there */
 		if (hs[i].score <= score) {
-			byte buf[sizeof(hs[i].company)];
+			char buf[sizeof(hs[i].company)];
 
 			// move all elements one down starting from the replaced one
 			memmove(&hs[i + 1], &hs[i], sizeof(HighScore) * (lengthof(_highscore_table[0]) - i - 1));
@@ -820,7 +820,6 @@
 
 	{
 		HighScore *hs;
-		byte buf[sizeof(_highscore_table[0]->company)];
 		Player* const *p_cur = &player_sort[0];
 		uint8 i;
 
@@ -828,6 +827,8 @@
 
 		/* Copy over Top5 companies */
 		for (i = 0; i < lengthof(_highscore_table[LAST_HS_ITEM]) && i < (uint8)count; i++) {
+			char buf[sizeof(_highscore_table[0]->company)];
+
 			hs = &_highscore_table[LAST_HS_ITEM][i];
 			SetDParam(0, (*p_cur)->president_name_1);
 			SetDParam(1, (*p_cur)->president_name_2);
--- a/settings.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/settings.c	Sun Feb 06 22:25:27 2005 +0000
@@ -158,7 +158,7 @@
 	IniGroup *group = NULL;
 	IniItem *item;
 
-	byte *comment = NULL;
+	char *comment = NULL;
 	uint comment_size = 0;
 	uint comment_alloc = 0;
 
--- a/spritecache.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/spritecache.c	Sun Feb 06 22:25:27 2005 +0000
@@ -786,7 +786,7 @@
 
 #if !defined(WIN32)
 	if (f == NULL) {
-		byte *s;
+		char *s;
 	// make lower case and check again
 		for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
 			*s = tolower(*s);
--- a/station_gui.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/station_gui.c	Sun Feb 06 22:25:27 2005 +0000
@@ -317,8 +317,6 @@
 	int pos;
 	StringID str;
 	uint16 station_id;
-	byte *b;
-
 
 	station_id = (uint16)w->window_number;
 
@@ -401,6 +399,8 @@
 	} while (pos > -5 && ++i != 12);
 
 	if (IsWindowOfPrototype(w, _station_view_widgets)) {
+		char *b;
+
 		b = _userstring;
 		b[0] = 0x81;
 		b[1] = STR_000C_ACCEPTS;
@@ -408,7 +408,7 @@
 		b += 3;
 
 		for(i=0; i!=NUM_CARGO; i++) {
-			if ((b - (byte *) &_userstring) + 5 > USERSTRING_LEN - 1)
+			if ((b - _userstring) + 5 > USERSTRING_LEN - 1)
 				break;
 			if (st->goods[i].waiting_acceptance & 0x8000) {
 				b[0] = 0x81;
@@ -418,7 +418,7 @@
 			}
 		}
 
-		if (b == (byte*)&_userstring[3]) {
+		if (b == &_userstring[3]) {
 			b[0] = 0x81;
 			b[1] = STR_00D0_NOTHING;
 			b[2] = STR_00D0_NOTHING >> 8;
--- a/ttd.c	Sun Feb 06 20:53:31 2005 +0000
+++ b/ttd.c	Sun Feb 06 22:25:27 2005 +0000
@@ -647,8 +647,8 @@
 #ifdef ENABLE_NETWORK
 	if ((network) && (_network_available)) {
 		if (network_conn != NULL) {
-			const byte *port = NULL;
-			const byte *player = NULL;
+			const char *port = NULL;
+			const char *player = NULL;
 			uint16 rport;
 
 			rport = NETWORK_DEFAULT_PORT;
--- a/variables.h	Sun Feb 06 20:53:31 2005 +0000
+++ b/variables.h	Sun Feb 06 22:25:27 2005 +0000
@@ -303,7 +303,7 @@
 // Deals with the type of the savegame, independent of extension
 typedef struct {
 	int mode;						// savegame/scenario type (old, new)
-	byte name[MAX_PATH];	// name
+	char name[MAX_PATH];	// name
 } SmallFiosItem;
 
 // Used when switching from the intro menu.