changeset 2026:480a107508f8 draft

(svn r2535) Tabs
author tron <tron@openttd.org>
date Fri, 08 Jul 2005 22:25:24 +0000
parents f8a8dc5bdb1f
children 5465e050eef5
files console_cmds.c disaster_cmd.c network_client.c openttd.c queue.c saveload.c sdl.c spritecache.c station_gui.c unmovable_cmd.c viewport.c waypoint.c widget.c win32.c window.c
diffstat 15 files changed, 92 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -707,7 +707,7 @@
 	if (!CloseConsoleLogIfActive()) {
 		if (argc < 2) return false;
 
-		IConsolePrintF(_icolour_def, "file output started to: %s",	argv[1]);
+		IConsolePrintF(_icolour_def, "file output started to: %s", argv[1]);
 		_iconsole_output_file = fopen(argv[1], "ab");
 		if (_iconsole_output_file == NULL) IConsoleError("could not open file");
 	}
@@ -902,31 +902,31 @@
 		const IConsoleAlias *alias;
 
 		cmd = IConsoleCmdGet(argv[1]);
-	 	if (cmd != NULL) {
-	 		cmd->proc(0, NULL);
-	 		return true;
-	 	}
+		if (cmd != NULL) {
+			cmd->proc(0, NULL);
+			return true;
+		}
 
-	 	alias = IConsoleAliasGet(argv[1]);
-	 	if (alias != NULL) {
-	 		cmd = IConsoleCmdGet(alias->cmdline);
-	 		if (cmd != NULL) {
-	 			cmd->proc(0, NULL);
-	 			return true;
-	 		}
-	 		IConsolePrintF(_icolour_err, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
-	 		return true;
-	 	}
+		alias = IConsoleAliasGet(argv[1]);
+		if (alias != NULL) {
+			cmd = IConsoleCmdGet(alias->cmdline);
+			if (cmd != NULL) {
+				cmd->proc(0, NULL);
+				return true;
+			}
+			IConsolePrintF(_icolour_err, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
+			return true;
+		}
 
-	 	var = IConsoleVarGet(argv[1]);
-   	if (var != NULL && var->help != NULL) {
-   		IConsoleHelp(var->help);
-   		return true;
-   	}
+		var = IConsoleVarGet(argv[1]);
+		if (var != NULL && var->help != NULL) {
+			IConsoleHelp(var->help);
+			return true;
+		}
 
-   	IConsoleError("command or variable not found");
-   	return true;
-  }
+		IConsoleError("command or variable not found");
+		return true;
+	}
 
 	IConsolePrint(13, " ---- OpenTTD Console Help ---- ");
 	IConsolePrint( 1, " - variables: [command to list all variables: list_vars]");
@@ -1050,7 +1050,7 @@
 {
 	if (argc == 0) {
 		IConsoleHelp("Chat to a certain player in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
-  	IConsoleHelp("For client-id's, see the command 'clients'");
+		IConsoleHelp("For client-id's, see the command 'clients'");
 		return true;
 	}
 
@@ -1252,9 +1252,9 @@
 	IConsoleCmdRegister("screenshot",   ConScreenShot);
 	IConsoleCmdRegister("script",       ConScript);
 	IConsoleCmdRegister("scrollto",     ConScrollToTile);
-	IConsoleCmdRegister("alias",	      ConAlias);
-	IConsoleCmdRegister("load",			    ConLoad);
-	IConsoleCmdRegister("save",			    ConSave);
+	IConsoleCmdRegister("alias",        ConAlias);
+	IConsoleCmdRegister("load",         ConLoad);
+	IConsoleCmdRegister("save",         ConSave);
 	IConsoleCmdRegister("ls",           ConListFiles);
 	IConsoleCmdRegister("cd",           ConChangeDirectory);
 	IConsoleCmdRegister("pwd",          ConPrintWorkingDirectory);
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -262,7 +262,7 @@
 // fly around randomly
 		int x = TileX(v->dest_tile) * 16;
 		int y = TileY(v->dest_tile) * 16;
-		if (abs(x - v->x_pos) +	abs(y - v->y_pos) >= 16) {
+		if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
 			v->direction = GetDirectionTowards(v, x, y);
 			GetNewVehiclePos(v, &gp);
 			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -331,8 +331,8 @@
 {
 	TileIndex tile;
 
-	for(tile=0; tile != MapSize(); tile++) {
-		if (IsTileType(tile, MP_INDUSTRY) &&	_map2[tile] == i->index) {
+	for (tile = 0; tile != MapSize(); tile++) {
+		if (IsTileType(tile, MP_INDUSTRY) && _map2[tile] == i->index) {
 			_map_owner[tile] = 0;
 			MarkTileDirtyByTile(tile);
 		}
@@ -563,7 +563,7 @@
 
 		int x = TileX(v->dest_tile) * 16;
 		int y = TileY(v->dest_tile) * 16;
-		if (abs(x - v->x_pos) +	abs(y - v->y_pos) >= 16) {
+		if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
 			v->direction = GetDirectionTowards(v, x, y);
 			GetNewVehiclePos(v, &gp);
 			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -907,7 +907,7 @@
 
 	do {
 		FOR_ALL_INDUSTRIES(i) {
-			if (i->xy != 0 && i->type == IT_COAL_MINE	&& --index < 0) {
+			if (i->xy != 0 && i->type == IT_COAL_MINE && --index < 0) {
 
 				SetDParam(0, i->town->index);
 				AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
--- a/network_client.c
+++ b/network_client.c
@@ -848,7 +848,7 @@
 		byte type = NetworkRecv_uint8(MY_CLIENT, p);
 		if (type < PACKET_END && _network_client_packet[type] != NULL && !MY_CLIENT->quited) {
 			res = _network_client_packet[type](p);
-		}	else {
+		} else {
 			res = NETWORK_RECV_STATUS_MALFORMED_PACKET;
 			DEBUG(net, 0)("[NET][client] Received invalid packet type %d", type);
 		}
--- a/openttd.c
+++ b/openttd.c
@@ -141,7 +141,7 @@
 		GameLoop();
 		_screen.dst_ptr = _null_video_mem;
 		UpdateWindows();
-	}	while (--i);
+	} while (--i);
 	return ML_QUIT;
 }
 
@@ -584,7 +584,7 @@
 			_config_file = strdup(mgo.opt);
 			break;
 		case -2:
- 		case 'h':
+		case 'h':
 			showhelp();
 			return 0;
 		}
@@ -751,7 +751,7 @@
 	// In a dedicated server, the server does not play
 	if (_network_dedicated) {
 		_local_player = OWNER_SPECTATOR;
-	}	else {
+	} else {
 		// Create a single player
 		DoStartupNewPlayer(false);
 
@@ -1220,7 +1220,7 @@
 					Build an array town_blocked[ town_id ][ player_id ]
 				 that stores if at least one station in that town is blocked for a player
 			2.) Go through that array, if you find a town that is not blocked for
-				 	one player, but for all others, then give him exclusivity.
+					one player, but for all others, then give him exclusivity.
 	*/
 }
 
--- a/queue.c
+++ b/queue.c
@@ -534,7 +534,7 @@
 		if (usage[i]) {
 			printf("%d:%d ", i, usage[i]);
 /*
- 			if (i>0){
+			if (i>0){
 				uint j;
 				for (j=0;j<(usage[i] * 160 / 800);j++)
 					printf("#");
@@ -566,7 +566,7 @@
 				HashNode* prev = node;
 				node = node->next;
 				if (free_values)
-			 		free(prev->value);
+					free(prev->value);
 				free(prev);
 			}
 		}
--- a/saveload.c
+++ b/saveload.c
@@ -218,7 +218,7 @@
 		next_offs = SlGetOffs() + length;
 
 		switch (_sl.block_mode) {
-		case CH_SPARSE_ARRAY:	index = SlReadSparseIndex(); break;
+		case CH_SPARSE_ARRAY: index = SlReadSparseIndex(); break;
 		case CH_ARRAY:        index = _sl.array_index++; break;
 		default:
 			DEBUG(misc, 0) ("SlIterateArray: error");
@@ -326,7 +326,7 @@
 		// Write the value to the file and check if its value is in the desired range
 		switch (conv & 0xF) {
 		case SLE_FILE_I8: assert(x >= -128 && x <= 127);     SlWriteByte(x);break;
-		case SLE_FILE_U8:	assert(x >= 0 && x <= 255);        SlWriteByte(x);break;
+		case SLE_FILE_U8: assert(x >= 0 && x <= 255);        SlWriteByte(x);break;
 		case SLE_FILE_I16:assert(x >= -32768 && x <= 32767); SlWriteUint16(x);break;
 		case SLE_FILE_STRINGID:
 		case SLE_FILE_U16:assert(x >= 0 && x <= 65535);      SlWriteUint16(x);break;
@@ -465,7 +465,7 @@
 			length++; // a byte is logically of size 1
 		} else if (sld->cmd == SL_INCLUDE) {
 			length += SlCalcObjLength(NULL, _sl.includes[sld->version_from]);
-		}	else
+		} else
 			assert(sld->cmd == SL_END);
 	}
 	return length;
@@ -526,7 +526,7 @@
 		 * include_index: common code to include from _desc_includes[], abused by sld->version_from */
 		} else if (sld->cmd == SL_INCLUDE) {
 			SlObject(ptr, _sl.includes[sld->version_from]);
-		}	else
+		} else
 			assert(sld->cmd == SL_END);
 	}
 }
@@ -941,7 +941,7 @@
 	do {
 		z->next_out = buf;
 		z->avail_out = sizeof(buf);
-		r	= deflate(z, mode);
+		r = deflate(z, mode);
 			// bytes were emitted?
 		if ((n=sizeof(buf) - z->avail_out) != 0) {
 			if (fwrite(buf, n, 1, _sl.fh) != 1) SlError("file write error");
@@ -1437,7 +1437,7 @@
 	f = fopen(file, "rb");
 	if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
 		printf("Savegame is obsolete or invalid format.\n");
-		mode = SL_LOAD;	// don't try to get filename, just show name as it is written
+		mode = SL_LOAD; // don't try to get filename, just show name as it is written
 	}
 	else {
 		// see if we have any loader for this type.
--- a/sdl.c
+++ b/sdl.c
@@ -399,7 +399,7 @@
 
 static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
 {
-	const VkMapping	*map;
+	const VkMapping *map;
 	uint key = 0;
 	for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
 		if ((uint)(sym->sym - map->vk_from) <= map->vk_count) {
@@ -573,7 +573,7 @@
 		while ((i = PollEvent()) == -1) {}
 		if (i >= 0) return i;
 
-		if (_exit_game)	return ML_QUIT;
+		if (_exit_game) return ML_QUIT;
 
 		mod = SDL_CALL SDL_GetModState();
 		keys = SDL_CALL SDL_GetKeyState(&numkeys);
@@ -613,7 +613,7 @@
 				CheckPaletteAnim();
 				pal_tick = 1;
 			}
- 			DrawSurfaceToScreen();
+			DrawSurfaceToScreen();
 		} else {
 			SDL_CALL SDL_Delay(1);
 			_screen.dst_ptr = _sdl_screen->pixels;
--- a/spritecache.c
+++ b/spritecache.c
@@ -706,7 +706,7 @@
 #if defined(WANT_NEW_LRU)
 	_sprite_lru_new[sprite] = ++_sprite_lru_counter;
 #else
-	_sprite_lru_cur[sprite]	= ++_sprite_lru_counter;
+	_sprite_lru_cur[sprite] = ++_sprite_lru_counter;
 	_sprite_lru[sprite] = 0;
 #endif
 
@@ -727,7 +727,7 @@
 
 #define OPENTTD_SPRITES_COUNT 98
 static const uint16 _openttd_grf_indexes[] = {
-	SPR_OPENTTD_BASE+0,	SPR_OPENTTD_BASE+7, // icons etc
+	SPR_OPENTTD_BASE + 0, SPR_OPENTTD_BASE + 7, // icons etc
 	134, 134,  // euro symbol medium size
 	582, 582,  // euro symbol large size
 	358, 358,  // euro symbol tiny
--- a/station_gui.c
+++ b/station_gui.c
@@ -72,7 +72,7 @@
 		GetString(_bufcache, st->string_id);
 	}
 
-	return strcmp(buf1, _bufcache);	// sort by name
+	return strcmp(buf1, _bufcache); // sort by name
 }
 
 static void GlobalSortStationList(void)
@@ -93,7 +93,7 @@
 		if(st->xy && st->owner != OWNER_NONE) {
 			_station_sort[n].index = st->index;
 			_station_sort[n++].owner = st->owner;
-			_num_station_sort[st->owner]++;	// add number of stations of player
+			_num_station_sort[st->owner]++; // add number of stations of player
 		}
 	}
 
@@ -117,11 +117,11 @@
 	uint32 n = 0;
 
 	if (owner == 0) { // first element starts at 0th element and has n elements as described above
-		firstelement =	&_station_sort[0];
-		n =							_num_station_sort[0];
-	}	else { // nth element starts at the end of the previous one, and has n elements as described above
-		firstelement =	&_station_sort[_num_station_sort[owner-1]];
-		n =							_num_station_sort[owner] - _num_station_sort[owner-1];
+		firstelement = &_station_sort[0];
+		n = _num_station_sort[0];
+	} else { // nth element starts at the end of the previous one, and has n elements as described above
+		firstelement = &_station_sort[_num_station_sort[owner - 1]];
+		n = _num_station_sort[owner] - _num_station_sort[owner - 1];
 	}
 
 	_last_station_idx = 0; // used for "cache" in namesorting
@@ -165,18 +165,18 @@
 			byte p = 0;
 			Station *st;
 			int x,xb = 2;
-			int y = 16;	// offset from top of widget
+			int y = 16; // offset from top of widget
 			int j;
 
-			if (w->vscroll.count == 0) {	// player has no stations
+			if (w->vscroll.count == 0) { // player has no stations
 				DrawString(xb, y, STR_304A_NONE, 0);
 				return;
 			}
 
-			i += w->vscroll.pos;	// offset from sorted station list of current player
+			i += w->vscroll.pos; // offset from sorted station list of current player
 			assert(i < _num_station_sort[window_number]); // at least one station must exist
 
-			while (i < _num_station_sort[window_number]) {	// do until max number of stations of owner
+			while (i < _num_station_sort[window_number]) { // do until max number of stations of owner
 				st = GetStation(_station_sort[i].index);
 
 				assert(st->xy && st->owner == window_number);
@@ -194,7 +194,7 @@
 					}
 				}
 				y += 10;
-				i++;	// next station
+				i++; // next station
 				if (++p == w->vscroll.cap) { break;} // max number of stations in 1 window
 			}
 		}
@@ -211,7 +211,7 @@
 			{
 				const byte owner = (byte)w->window_number;
 				Station *st;
-				id_v	+= (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list
+				id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list
 
 				if (id_v >= _num_station_sort[owner]) { return;} // click out of station bound
 
@@ -470,7 +470,7 @@
 			SetDParam(0, st->town->townnametype);
 			SetDParam(1, st->town->townnameparts);
 			ShowQueryString(st->string_id, STR_3030_RENAME_STATION_LOADING, 31, 180, w->window_class, w->window_number);
-		}	break;
+		} break;
 
 		case 10: { /* Show a list of scheduled trains to this station */
 			const Station *st = GetStation(w->window_number);
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -25,7 +25,7 @@
 	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
 
 	/* Find player that has HQ flooded, and reset their location_of_house */
-	if (_current_player == OWNER_WATER)	{
+	if (_current_player == OWNER_WATER) {
 		bool dodelete = false;
 
 		FOR_ALL_PLAYERS(p) {
@@ -171,7 +171,7 @@
 		DrawGroundSprite(t->ground_sprite | ormod);
 
 		foreach_draw_tile_seq(dtss, t->seq) {
-			image =	dtss->image;
+			image = dtss->image;
 			if (_display_opt & DO_TRANS_BUILDINGS) {
 				image = (image & 0x3FFF) | 0x03224000;
 			} else {
@@ -202,7 +202,7 @@
 		return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
 	}
 
-	if (m5 == 3)	// company owned land
+	if (m5 == 3) // company owned land
 		return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
 
 	// checks if you're allowed to remove unmovable things
@@ -398,7 +398,7 @@
 
 	if (_map5[tile]==3 && new_player != 255) {
 		SetTileOwner(tile, new_player);
-	}	else {
+	} else {
 		DoClearSquare(tile);
 	}
 }
--- a/viewport.c
+++ b/viewport.c
@@ -339,7 +339,7 @@
 
 	vp = w->viewport;
 
-	if (in)	{
+	if (in) {
 		x = ( (_cursor.pos.x - vp->left ) >> 1) + (vp->width >> 2);
 		y = ( (_cursor.pos.y - vp->top ) >> 1) + (vp->height >> 2);
 	}
--- a/waypoint.c
+++ b/waypoint.c
@@ -320,7 +320,7 @@
 		} else {
 			DeleteName(str);
 		}
-	}	else {
+	} else {
 		if (flags & DC_EXEC) {
 			wp = GetWaypoint(p1);
 			if (wp->string != STR_NULL)
@@ -434,8 +434,8 @@
 	SLE_CONDVAR(Waypoint, xy, SLE_UINT32, 6, 255),
 	SLE_CONDVAR(Waypoint, town_index, SLE_UINT16, 12, 255),
 	SLE_CONDVAR(Waypoint, town_cn, SLE_UINT8, 12, 255),
-	SLE_VAR(Waypoint,string,		SLE_UINT16),
-	SLE_VAR(Waypoint,deleted,						SLE_UINT8),
+	SLE_VAR(Waypoint, string, SLE_UINT16),
+	SLE_VAR(Waypoint, deleted, SLE_UINT8),
 
 	SLE_CONDVAR(Waypoint, build_date, SLE_UINT16, 3, 255),
 	SLE_CONDVAR(Waypoint, stat_id, SLE_UINT8, 3, 255),
--- a/widget.c
+++ b/widget.c
@@ -20,7 +20,7 @@
 	count = sb->count;
 	cap = sb->cap;
 
-	if (count != 0)	top += height * pos / count;
+	if (count != 0) top += height * pos / count;
 
 	if (cap > count) cap = count;
 	if (count != 0)
@@ -160,7 +160,8 @@
 	uint32 dparam_backup[20];
 	uint32 cur_click, cur_disabled, cur_hidden;
 
-	if (w->desc_flags & WDF_RESTORE_DPARAM)	COPY_OUT_DPARAM(dparam_backup, 0, lengthof(dparam_backup));
+	if (w->desc_flags & WDF_RESTORE_DPARAM)
+		COPY_OUT_DPARAM(dparam_backup, 0, lengthof(dparam_backup));
 
 	wi = w->widget;
 
@@ -425,7 +426,8 @@
 
 			DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84);
 restore_dparam:;
-			if (w->desc_flags & WDF_RESTORE_DPARAM)	COPY_IN_DPARAM(0, dparam_backup, lengthof(dparam_backup));
+			if (w->desc_flags & WDF_RESTORE_DPARAM)
+				COPY_IN_DPARAM(0, dparam_backup, lengthof(dparam_backup));
 draw_default:;
 			if (cur_disabled & 1) {
 				GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | 0x8000);
--- a/win32.c
+++ b/win32.c
@@ -103,7 +103,7 @@
 #define AS(x, z) {x, 0, z}
 #define AM(x, y, z, w) {x, y - x, z}
 
-#ifndef	VK_OEM_3
+#ifndef VK_OEM_3
 #define VK_OEM_3 0xC0
 #endif
 
@@ -148,9 +148,9 @@
 		}
 	}
 
-	if (GetAsyncKeyState(VK_SHIFT)<0)	key |= WKC_SHIFT;
-	if (GetAsyncKeyState(VK_CONTROL)<0)	key |= WKC_CTRL;
-	if (GetAsyncKeyState(VK_MENU)<0)	key |= WKC_ALT;
+	if (GetAsyncKeyState(VK_SHIFT)   < 0) key |= WKC_SHIFT;
+	if (GetAsyncKeyState(VK_CONTROL) < 0) key |= WKC_CTRL;
+	if (GetAsyncKeyState(VK_MENU)    < 0) key |= WKC_ALT;
 	return key;
 }
 
@@ -318,7 +318,7 @@
 			ClientSizeChanged(_wnd.width, _wnd.height);
 			MarkWholeScreenDirty();
 		}
-	}	break;
+	} break;
 
 	case WM_SYSKEYDOWN: /* user presses F10 or Alt, both activating the title-menu */
 		switch (wParam) {
@@ -1073,7 +1073,8 @@
 
 static void MakeCRCTable(uint32 *table) {
 	uint32 crc, poly = 0xEDB88320L;
-	int	i, j;
+	int i;
+	int j;
 
 	_crc_table = table;
 
--- a/window.c
+++ b/window.c
@@ -155,7 +155,7 @@
 
 	while (++v != _last_window) {
 		if (right > v->left &&
-		 		bottom > v->top &&
+				bottom > v->top &&
 				left < v->left + v->width &&
 				top < v->top + v->height) {
 
@@ -660,13 +660,13 @@
 		if (pt.x > _screen.width + 10 - desc->width)
 			pt.x = (_screen.width + 10 - desc->width) - 20;
 		pt.y = w->top + 10;
-	} else if (desc->cls == WC_BUILD_TOOLBAR) {	// open Build Toolbars aligned
+	} else if (desc->cls == WC_BUILD_TOOLBAR) { // open Build Toolbars aligned
 		/* Override the position if a toolbar is opened according to the place of the maintoolbar
 		 * The main toolbar (WC_MAIN_TOOLBAR) is 640px in width */
 		switch (_patches.toolbar_pos) {
-		case 1:		pt.x = ((_screen.width + 640) >> 1) - desc->width; break;
-		case 2:		pt.x = _screen.width - desc->width; break;
-		default:	pt.x = 640 - desc->width;
+			case 1:  pt.x = ((_screen.width + 640) >> 1) - desc->width; break;
+			case 2:  pt.x = _screen.width - desc->width; break;
+			default: pt.x = 640 - desc->width;
 		}
 		pt.y = desc->top;
 	} else {
@@ -1641,9 +1641,9 @@
 		w = FindWindowById(WC_MAIN_TOOLBAR, 0);
 
 	switch (_patches.toolbar_pos) {
-		case 1:		w->left = (_screen.width - w->width) >> 1; break;
-		case 2:		w->left = _screen.width - w->width; break;
-		default:	w->left = 0;
+		case 1:  w->left = (_screen.width - w->width) >> 1; break;
+		case 2:  w->left = _screen.width - w->width; break;
+		default: w->left = 0;
 	}
 	SetDirtyBlocks(0, 0, _screen.width, w->height); // invalidate the whole top part
 	return w->left;