mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
This commit is contained in:
parent
47b0d41d63
commit
8ef52bc43c
@ -196,8 +196,6 @@ void ChangeTownRating(Town *t, int add, int max);
|
||||
uint GetTownRadiusGroup(const Town* t, TileIndex tile);
|
||||
void ShowNetworkChatQueryWindow(byte desttype, byte dest);
|
||||
void ShowNetworkGiveMoneyWindow(byte player);
|
||||
void ShowNetworkNeedGamePassword(void);
|
||||
void ShowNetworkNeedCompanyPassword(void);
|
||||
int FindFirstBit(uint32 x);
|
||||
void ShowHighscoreTable(int difficulty, int8 rank);
|
||||
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng);
|
||||
|
@ -37,7 +37,6 @@ static const Widget _select_game_widgets[] = {
|
||||
};
|
||||
|
||||
extern void HandleOnEditText(WindowEvent *e);
|
||||
extern void HandleOnEditTextCancel(void);
|
||||
|
||||
static inline void SetNewLandscapeType(byte landscape)
|
||||
{
|
||||
@ -83,7 +82,6 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
|
||||
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
|
||||
case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
27
main_gui.c
27
main_gui.c
@ -47,17 +47,6 @@ static RailType _last_built_railtype;
|
||||
extern void GenerateIndustries(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)
|
||||
{
|
||||
@ -97,9 +86,6 @@ void HandleOnEditText(WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: /* Game-Password and Company-Password */
|
||||
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(id, e->edittext.str);
|
||||
break;
|
||||
#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);
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "functions.h"
|
||||
#include "network_client.h"
|
||||
#include "network_gamelist.h"
|
||||
#include "network_gui.h"
|
||||
#include "saveload.h"
|
||||
#include "command.h"
|
||||
#include "window.h"
|
||||
@ -423,18 +424,16 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_ERROR)
|
||||
|
||||
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEED_PASSWORD)
|
||||
{
|
||||
NetworkPasswordType type;
|
||||
type = NetworkRecv_uint8(MY_CLIENT, p);
|
||||
NetworkPasswordType type = NetworkRecv_uint8(MY_CLIENT, p);
|
||||
|
||||
if (type == NETWORK_GAME_PASSWORD) {
|
||||
ShowNetworkNeedGamePassword();
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
} else if (type == NETWORK_COMPANY_PASSWORD) {
|
||||
ShowNetworkNeedCompanyPassword();
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
switch (type) {
|
||||
case NETWORK_GAME_PASSWORD:
|
||||
case NETWORK_COMPANY_PASSWORD:
|
||||
ShowNetworkNeedPassword(type);
|
||||
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)
|
||||
|
@ -1395,6 +1395,24 @@ void ShowClientList(void)
|
||||
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)
|
||||
{
|
||||
switch (e->event) {
|
||||
@ -1438,6 +1456,14 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
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
Normal file
8
network_gui.h
Normal file
@ -0,0 +1,8 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef NETWORK_GUI_H
|
||||
#define NETWORK_GUI_H
|
||||
|
||||
void ShowNetworkNeedPassword(NetworkPasswordType npt);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user