1
0
Fork 0

(svn r2405) Simplify a few '? true : false' and '? false : true', especially the latter is confusing

release/0.4.5
tron 2005-06-04 07:35:12 +00:00
parent 7f0caaa89a
commit 43f7974f6d
5 changed files with 8 additions and 8 deletions

View File

@ -473,7 +473,7 @@ bool GetArgumentInteger(uint32 *value, const char *arg)
} }
*value = strtoul(arg, &endptr, 0); *value = strtoul(arg, &endptr, 0);
return (arg == endptr) ? false : true; return arg != endptr;
} }
// * ************************* * // // * ************************* * //

View File

@ -925,7 +925,7 @@ static void NetworkInitGameInfo(void)
_network_game_info.map_height = MapSizeY(); _network_game_info.map_height = MapSizeY();
_network_game_info.map_set = _opt.landscape; _network_game_info.map_set = _opt.landscape;
_network_game_info.use_password = (_network_server_password[0] == '\0') ? 0 : 1; _network_game_info.use_password = (_network_server_password[0] != '\0');
// We use _network_client_info[MAX_CLIENT_INFO - 1] to store the server-data in it // We use _network_client_info[MAX_CLIENT_INFO - 1] to store the server-data in it
// The index is NETWORK_SERVER_INDEX ( = 1) // The index is NETWORK_SERVER_INDEX ( = 1)

View File

@ -488,7 +488,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
switch (e->event) { switch (e->event) {
case WE_CREATE: /* focus input box */ case WE_CREATE: /* focus input box */
_selected_field = 3; _selected_field = 3;
_network_game_info.use_password = (_network_server_password[0] == '\0') ? 0 : 1; _network_game_info.use_password = (_network_server_password[0] != '\0');
break; break;
case WE_PAINT: { case WE_PAINT: {
@ -591,7 +591,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
switch(e->dropdown.button) { switch(e->dropdown.button) {
case 8: case 8:
_network_advertise = (e->dropdown.index == 0) ? false : true; _network_advertise = (e->dropdown.index != 0);
break; break;
case 10: case 10:
_network_game_info.clients_max = e->dropdown.index + 2; _network_game_info.clients_max = e->dropdown.index + 2;
@ -617,7 +617,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT: {
const char *b = e->edittext.str; const char *b = e->edittext.str;
ttd_strlcpy(_network_server_password, b, sizeof(_network_server_password)); ttd_strlcpy(_network_server_password, b, sizeof(_network_server_password));
_network_game_info.use_password = (_network_server_password[0] == '\0') ? 0 : 1; _network_game_info.use_password = (_network_server_password[0] != '\0');
SetWindowDirty(w); SetWindowDirty(w);
} break; } break;
} }

2
unix.c
View File

@ -559,7 +559,7 @@ bool InsertTextBufferClipboard(Textbuf *tb)
static pthread_t thread1 = 0; static pthread_t thread1 = 0;
bool CreateOTTDThread(void *func, void *param) bool CreateOTTDThread(void *func, void *param)
{ {
return (pthread_create(&thread1, NULL, func, param) == 0) ? true : false; return pthread_create(&thread1, NULL, func, param) == 0;
} }
void CloseOTTDThread(void) {return;} void CloseOTTDThread(void) {return;}

View File

@ -2251,7 +2251,7 @@ bool CreateOTTDThread(void *func, void *param)
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, param, 0, &dwThreadId); hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, param, 0, &dwThreadId);
SetThreadPriority(hThread, THREAD_PRIORITY_BELOW_NORMAL); SetThreadPriority(hThread, THREAD_PRIORITY_BELOW_NORMAL);
return (hThread == NULL) ? false : true; return hThread != NULL;
} }
void CloseOTTDThread(void) void CloseOTTDThread(void)