1
0
Fork 0

(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to

release/0.5
tron 2006-09-01 13:35:43 +00:00
parent 47b0d41d63
commit 8ef52bc43c
6 changed files with 43 additions and 41 deletions

View File

@ -196,8 +196,6 @@ void ChangeTownRating(Town *t, int add, int max);
uint GetTownRadiusGroup(const Town* t, TileIndex tile); uint GetTownRadiusGroup(const Town* t, TileIndex tile);
void ShowNetworkChatQueryWindow(byte desttype, byte dest); void ShowNetworkChatQueryWindow(byte desttype, byte dest);
void ShowNetworkGiveMoneyWindow(byte player); void ShowNetworkGiveMoneyWindow(byte player);
void ShowNetworkNeedGamePassword(void);
void ShowNetworkNeedCompanyPassword(void);
int FindFirstBit(uint32 x); int FindFirstBit(uint32 x);
void ShowHighscoreTable(int difficulty, int8 rank); void ShowHighscoreTable(int difficulty, int8 rank);
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng); TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng);

View File

@ -37,7 +37,6 @@ static const Widget _select_game_widgets[] = {
}; };
extern void HandleOnEditText(WindowEvent *e); extern void HandleOnEditText(WindowEvent *e);
extern void HandleOnEditTextCancel(void);
static inline void SetNewLandscapeType(byte landscape) static inline void SetNewLandscapeType(byte landscape)
{ {
@ -83,7 +82,6 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
break; break;
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break;
} }
} }

View File

@ -47,17 +47,6 @@ static RailType _last_built_railtype;
extern void GenerateIndustries(void); extern void GenerateIndustries(void);
extern bool GenerateTowns(void); extern bool GenerateTowns(void);
void HandleOnEditTextCancel(void)
{
switch (_rename_what) {
#ifdef ENABLE_NETWORK
case 4:
NetworkDisconnect();
ShowNetworkGameWindow();
break;
#endif /* ENABLE_NETWORK */
}
}
void HandleOnEditText(WindowEvent *e) void HandleOnEditText(WindowEvent *e)
{ {
@ -97,9 +86,6 @@ void HandleOnEditText(WindowEvent *e)
} }
break; break;
} }
case 4: /* Game-Password and Company-Password */
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(id, e->edittext.str);
break;
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
} }
} }
@ -330,19 +316,6 @@ void ShowNetworkGiveMoneyWindow(byte player)
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, 1, 0, CS_NUMERAL); ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, 1, 0, CS_NUMERAL);
} }
void ShowNetworkNeedGamePassword(void)
{
_rename_id = NETWORK_GAME_PASSWORD;
_rename_what = 4;
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_GAME_PASSWORD_CAPTION, 20, 180, WC_SELECT_GAME, 0, CS_ALPHANUMERAL);
}
void ShowNetworkNeedCompanyPassword(void)
{
_rename_id = NETWORK_COMPANY_PASSWORD;
_rename_what = 4;
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, 20, 180, WC_SELECT_GAME, 0, CS_ALPHANUMERAL);
}
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */

View File

@ -13,6 +13,7 @@
#include "functions.h" #include "functions.h"
#include "network_client.h" #include "network_client.h"
#include "network_gamelist.h" #include "network_gamelist.h"
#include "network_gui.h"
#include "saveload.h" #include "saveload.h"
#include "command.h" #include "command.h"
#include "window.h" #include "window.h"
@ -423,18 +424,16 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_ERROR)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEED_PASSWORD) DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEED_PASSWORD)
{ {
NetworkPasswordType type; NetworkPasswordType type = NetworkRecv_uint8(MY_CLIENT, p);
type = NetworkRecv_uint8(MY_CLIENT, p);
if (type == NETWORK_GAME_PASSWORD) { switch (type) {
ShowNetworkNeedGamePassword(); case NETWORK_GAME_PASSWORD:
return NETWORK_RECV_STATUS_OKAY; case NETWORK_COMPANY_PASSWORD:
} else if (type == NETWORK_COMPANY_PASSWORD) { ShowNetworkNeedPassword(type);
ShowNetworkNeedCompanyPassword();
return NETWORK_RECV_STATUS_OKAY; return NETWORK_RECV_STATUS_OKAY;
default: return NETWORK_RECV_STATUS_MALFORMED_PACKET;
} }
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
} }
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WELCOME) DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WELCOME)

View File

@ -1395,6 +1395,24 @@ void ShowClientList(void)
AllocateWindowDescFront(&_client_list_desc, 0); AllocateWindowDescFront(&_client_list_desc, 0);
} }
static NetworkPasswordType pw_type;
void ShowNetworkNeedPassword(NetworkPasswordType npt)
{
StringID caption;
pw_type = npt;
switch (npt) {
default: NOT_REACHED();
case NETWORK_GAME_PASSWORD: caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION;
case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION;
}
ShowQueryString(STR_EMPTY, caption, 20, 180, WC_NETWORK_STATUS_WINDOW, 0, CS_ALPHANUMERAL);
}
static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
{ {
switch (e->event) { switch (e->event) {
@ -1438,6 +1456,14 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
} }
break; break;
case WE_ON_EDIT_TEXT_CANCEL:
NetworkDisconnect();
ShowNetworkGameWindow();
break;
case WE_ON_EDIT_TEXT:
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->edittext.str);
break;
} }
} }

8
network_gui.h 100644
View File

@ -0,0 +1,8 @@
/* $Id$ */
#ifndef NETWORK_GUI_H
#define NETWORK_GUI_H
void ShowNetworkNeedPassword(NetworkPasswordType npt);
#endif