summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-10 08:58:52 +0000
committerrubidium <rubidium@openttd.org>2008-05-10 08:58:52 +0000
commit2c96ce4506163ad1528db6a4340964af99fc1de2 (patch)
tree746df1921c03a63762ea8a5c0a05a16d672c34fe /src
parent8ebfbc2bd3c8a74693057ac4c38844d1f50e3995 (diff)
downloadopenttd-2c96ce4506163ad1528db6a4340964af99fc1de2.tar.xz
(svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
Diffstat (limited to 'src')
-rw-r--r--src/build_vehicle_gui.cpp3
-rw-r--r--src/genworld_gui.cpp4
-rw-r--r--src/industry_gui.cpp3
-rw-r--r--src/misc_gui.cpp3
-rw-r--r--src/network/network_gui.cpp19
-rw-r--r--src/newgrf_gui.cpp3
-rw-r--r--src/player_gui.cpp3
-rw-r--r--src/settings_gui.cpp6
-rw-r--r--src/station_gui.cpp3
-rw-r--r--src/timetable_gui.cpp2
-rw-r--r--src/town_gui.cpp3
-rw-r--r--src/window_gui.h1
12 files changed, 32 insertions, 21 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index d3d6cb02c..86b27a20d 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -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, WindowEvent *e)
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) {
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index da8b450f8..13867c0e0 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -525,7 +525,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
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 *w, WindowEvent *e)
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) {
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 5e2c7f652..996210bb9 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -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 *w, WindowEvent *e)
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;
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 06af009d8..dc224d3f4 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1040,7 +1040,8 @@ static void QueryStringWndProc(Window *w, WindowEvent *e)
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);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index b3b4f5a25..2ec0afe13 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -579,8 +579,10 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
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 NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
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 NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
}
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;
}
}
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index dca4db5f1..64548cf66 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -516,8 +516,9 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
/* parse_intlist returns -1 on error */
if (c->num_params == (byte)-1) c->num_params = 0;
+
+ w->SetDirty();
}
- w->SetDirty();
break;
case WE_DESTROY:
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 78f5120d2..70414cd7f 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -979,6 +979,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
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 *w, WindowEvent *e)
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) {
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 5145644f6..887690e8a 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1059,7 +1059,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
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 *w, WindowEvent *e)
} 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 *w, WindowEvent *e)
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;
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 578fcc832..dcf26efcc 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -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, WindowEvent *e)
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));
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index e63e8f305..5115b1063 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -249,6 +249,8 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
} 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);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 83a487659..b39cc5b46 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -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, WindowEvent *e)
} 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));
diff --git a/src/window_gui.h b/src/window_gui.h
index 1f21f94bd..cafd5b060 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -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,