Changeset - r9164:ed127223717e
[Not reviewed]
master
0 12 0
rubidium - 16 years ago 2008-05-10 08:58:52
rubidium@openttd.org
(svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
12 files changed with 32 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -27,6 +27,7 @@
 
#include "settings_type.h"
 
#include "gfx_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "string_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
@@ -1136,7 +1137,7 @@ static void NewVehicleWndProc(Window *w,
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				StringID str = STR_NULL;
 
				_cmd_text = e->we.edittext.str;
 
				switch (bv->vehicle_type) {
src/genworld_gui.cpp
Show inline comments
 
@@ -525,7 +525,7 @@ static void GenerateLandscapeWndProc(Win
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str != NULL) {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				int32 value = atoi(e->we.edittext.str);
 

	
 
				switch (WP(w, generate_d).widget_id) {
 
@@ -740,7 +740,7 @@ static void CreateScenarioWndProc(Window
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str != NULL) {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				int32 value = atoi(e->we.edittext.str);
 

	
 
				switch (WP(w, generate_d).widget_id) {
src/industry_gui.cpp
Show inline comments
 
@@ -25,6 +25,7 @@
 
#include "player_func.h"
 
#include "settings_type.h"
 
#include "tilehighlight_func.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
@@ -592,7 +593,7 @@ static void IndustryViewWndProc(Window *
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				Industry* i = GetIndustry(w->window_number);
 
				int line = WP(w, indview_d).editbox_line;
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -1040,7 +1040,8 @@ static void QueryStringWndProc(Window *w
 
				Window *parent = w->parent;
 

	
 
				qs->handled = true;
 
				e.event = WE_ON_EDIT_TEXT_CANCEL;
 
				e.event = WE_ON_EDIT_TEXT;
 
				e.we.edittext.str = NULL;
 
				parent->HandleWindowEvent(&e);
 
			}
 
			ClrBit(_no_scroll, SCROLL_EDIT);
src/network/network_gui.cpp
Show inline comments
 
@@ -579,8 +579,10 @@ static void NetworkGameWindowWndProc(Win
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			NetworkAddServer(e->we.edittext.str);
 
			NetworkRebuildHostList();
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				NetworkAddServer(e->we.edittext.str);
 
				NetworkRebuildHostList();
 
			}
 
			break;
 

	
 
		case WE_RESIZE: {
 
@@ -917,7 +919,7 @@ static void NetworkStartServerWindowWndP
 

	
 
			if (nd->widget_id == NSSW_SETPWD) {
 
				ttd_strlcpy(_network_server_password, e->we.edittext.str, lengthof(_network_server_password));
 
				_network_game_info.use_password = (_network_server_password[0] != '\0');
 
				_network_game_info.use_password = !StrEmpty(_network_server_password);
 
			} else {
 
				int32 value = atoi(e->we.edittext.str);
 
				w->InvalidateWidget(nd->widget_id);
 
@@ -1673,15 +1675,14 @@ static void NetworkJoinStatusWindowWndPr
 
			}
 
			break;
 

	
 
			/* If the server asks for a password, we need to fill it in */
 
			case WE_ON_EDIT_TEXT_CANCEL:
 
		case WE_ON_EDIT_TEXT:
 
			if (StrEmpty(e->we.edittext.str)) {
 
				NetworkDisconnect();
 
				ShowNetworkGameWindow();
 
				break;
 

	
 
			case WE_ON_EDIT_TEXT:
 
			} else {
 
				SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str);
 
				break;
 
			}
 
			break;
 
	}
 
}
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -516,8 +516,9 @@ static void NewGRFWndProc(Window *w, Win
 

	
 
				/* parse_intlist returns -1 on error */
 
				if (c->num_params == (byte)-1) c->num_params = 0;
 

	
 
				w->SetDirty();
 
			}
 
			w->SetDirty();
 
			break;
 

	
 
		case WE_DESTROY:
src/player_gui.cpp
Show inline comments
 
@@ -979,6 +979,7 @@ static void SelectPlayerFaceWndProc(Wind
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str == NULL) break;
 
			/* Set a new player face number */
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				*pf = strtoul(e->we.edittext.str, NULL, 10);
 
@@ -1331,7 +1332,7 @@ static void PlayerCompanyWndProc(Window 
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (StrEmpty(e->we.edittext.str)) return;
 
			if (StrEmpty(e->we.edittext.str)) break;
 

	
 
			_cmd_text = e->we.edittext.str;
 
			switch (WP(w, def_d).byte_1) {
src/settings_gui.cpp
Show inline comments
 
@@ -1059,7 +1059,7 @@ static void PatchesSelectionWndProc(Wind
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str != NULL) {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w, def_d).data_3];
 
				const SettingDesc *sd = pe->setting;
 
				int32 value = atoi(e->we.edittext.str);
 
@@ -1271,6 +1271,8 @@ static void CustCurrencyWndProc(Window *
 
		} break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			if (e->we.edittext.str == NULL) break;
 

	
 
			const char *b = e->we.edittext.str;
 

	
 
			switch (WP(w, def_d).data_2) {
 
@@ -1279,7 +1281,7 @@ static void CustCurrencyWndProc(Window *
 
					break;
 

	
 
				case CUSTCURR_SEPARATOR: /* Thousands seperator */
 
					_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
 
					_custom_currency.separator = StrEmpty(b) ? ' ' : b[0];
 
					ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
 
					break;
 

	
src/station_gui.cpp
Show inline comments
 
@@ -25,6 +25,7 @@
 
#include "gfx_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "newgrf_cargo.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
@@ -1002,7 +1003,7 @@ static void StationViewWndProc(Window *w
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				_cmd_text = e->we.edittext.str;
 
				DoCommandP(0, w->window_number, 0, NULL,
 
					CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
src/timetable_gui.cpp
Show inline comments
 
@@ -249,6 +249,8 @@ static void TimetableWndProc(Window *w, 
 
		} break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			if (we->we.edittext.str == NULL) break;
 

	
 
			const Vehicle *v = GetVehicle(w->window_number);
 

	
 
			uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel);
src/town_gui.cpp
Show inline comments
 
@@ -23,6 +23,7 @@
 
#include "core/alloc_func.hpp"
 
#include "settings_type.h"
 
#include "tilehighlight_func.h"
 
#include "string_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
@@ -360,7 +361,7 @@ static void TownViewWndProc(Window *w, W
 
			} break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				_cmd_text = e->we.edittext.str;
 
				DoCommandP(0, w->window_number, 0, NULL,
 
					CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN));
src/window_gui.h
Show inline comments
 
@@ -125,7 +125,6 @@ enum WindowEventCodes {
 
	WE_PLACE_OBJ,
 
	WE_ABORT_PLACE_OBJ,
 
	WE_ON_EDIT_TEXT,
 
	WE_ON_EDIT_TEXT_CANCEL,
 
	WE_DRAGDROP,
 
	WE_PLACE_DRAG,
 
	WE_PLACE_MOUSEUP,
0 comments (0 inline, 0 general)