diff options
-rw-r--r-- | console_cmds.c | 12 | ||||
-rw-r--r-- | lang/american.txt | 2 | ||||
-rw-r--r-- | lang/catalan.txt | 2 | ||||
-rw-r--r-- | lang/czech.txt | 2 | ||||
-rw-r--r-- | lang/danish.txt | 2 | ||||
-rw-r--r-- | lang/dutch.txt | 2 | ||||
-rw-r--r-- | lang/english.txt | 5 | ||||
-rw-r--r-- | lang/finnish.txt | 2 | ||||
-rw-r--r-- | lang/french.txt | 2 | ||||
-rw-r--r-- | lang/galician.txt | 2 | ||||
-rw-r--r-- | lang/german.txt | 2 | ||||
-rw-r--r-- | lang/hungarian.txt | 2 | ||||
-rw-r--r-- | lang/italian.txt | 2 | ||||
-rw-r--r-- | lang/norwegian.txt | 2 | ||||
-rw-r--r-- | lang/polish.txt | 2 | ||||
-rw-r--r-- | lang/portuguese.txt | 2 | ||||
-rw-r--r-- | lang/romanian.txt | 2 | ||||
-rw-r--r-- | lang/slovak.txt | 2 | ||||
-rw-r--r-- | lang/spanish.txt | 2 | ||||
-rw-r--r-- | lang/swedish.txt | 2 | ||||
-rw-r--r-- | network.c | 14 | ||||
-rw-r--r-- | network.h | 1 | ||||
-rw-r--r-- | network_core.h | 2 | ||||
-rw-r--r-- | player_gui.c | 85 |
24 files changed, 99 insertions, 56 deletions
diff --git a/console_cmds.c b/console_cmds.c index e534ef25c..11f9dffc0 100644 --- a/console_cmds.c +++ b/console_cmds.c @@ -682,17 +682,11 @@ DEF_CONSOLE_CMD(ConSet) { return NULL; } if (argc == 3) { - if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) { - _network_player_info[_local_player].password[0] = '\0'; - } else { - ttd_strlcpy(_network_player_info[_local_player].password, argv[2], sizeof(_network_player_info[_local_player].password)); - } - if (!_network_server) - SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password); - IConsolePrintF(_iconsole_color_warning, "Company protected with '%s'", _network_player_info[_local_player].password); + NetworkChangeCompanyPassword(argv[2]); } else { - IConsolePrint(_iconsole_color_default, "'set company_pw' sets a password on your company, so no-one without the correct password can join."); + IConsolePrint(_iconsole_color_default, "'set company_pw' sets a password for your company, so no-one without the correct password can join."); IConsolePrint(_iconsole_color_warning, "Usage: set company_pw \"<password>\". Use * as <password> to set no password."); + IConsolePrintF(_iconsole_color_warning, "Current password is: '%s'", _network_player_info[_local_player].password); } return NULL; } diff --git a/lang/american.txt b/lang/american.txt index 8a4878812..87f445cee 100644 --- a/lang/american.txt +++ b/lang/american.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :Hostile ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Player {COMMA16}) STR_7004_NEW_FACE :{BLACK}New Face STR_7005_COLOR_SCHEME :{BLACK}Color Scheme diff --git a/lang/catalan.txt b/lang/catalan.txt index 2a2a65732..6cc66d4ee 100644 --- a/lang/catalan.txt +++ b/lang/catalan.txt @@ -1944,7 +1944,7 @@ STR_683B_HOSTILE :Hostil ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Jugador {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nova Cara STR_7005_COLOR_SCHEME :{BLACK}Esquema de Colors diff --git a/lang/czech.txt b/lang/czech.txt index 155a123bc..a29c1a285 100644 --- a/lang/czech.txt +++ b/lang/czech.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :zaujatý ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(hrac {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nový oblicej STR_7005_COLOR_SCHEME :{BLACK}Barva diff --git a/lang/danish.txt b/lang/danish.txt index 5fbefe949..e292dd6d5 100644 --- a/lang/danish.txt +++ b/lang/danish.txt @@ -1803,7 +1803,7 @@ STR_683B_HOSTILE :Fjendtlig ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Spiller {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nyt Ansigt STR_7005_COLOR_SCHEME :{BLACK}Farvetema diff --git a/lang/dutch.txt b/lang/dutch.txt index f5d775b78..a1d335f4d 100644 --- a/lang/dutch.txt +++ b/lang/dutch.txt @@ -1944,7 +1944,7 @@ STR_683B_HOSTILE :Negatief ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Speler {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nieuw gezicht STR_7005_COLOR_SCHEME :{BLACK}Kleurenschema diff --git a/lang/english.txt b/lang/english.txt index 6a96eb690..e879172f5 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :Hostile ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Player {COMMA16}) STR_7004_NEW_FACE :{BLACK}New Face STR_7005_COLOR_SCHEME :{BLACK}Colour Scheme @@ -2071,6 +2071,9 @@ STR_RELOCATE_COMPANY_HEADQUARTERS :{BLACK}Rebuild company headquarters elsewh STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS :{WHITE}Can't build company headquarters... STR_7072_VIEW_HQ :{BLACK}View HQ STR_RELOCATE_HQ :{BLACK}Relocate HQ +STR_COMPANY_PASSWORD :{BLACK}Password +STR_COMPANY_PASSWORD_TOOLTIP :{BLACK}Password-protect your company to prevent unauthorised users from joining. Use '*' to empty password. +STR_SET_COMPANY_PASSWORD :Set company password STR_7073_WORLD_RECESSION_FINANCIAL :{BIGFONT}{BLACK}World Recession!{}{}Financial experts fear worst as economy slumps! STR_7074_RECESSION_OVER_UPTURN_IN :{BIGFONT}{BLACK}Recession Over!{}{}Upturn in trade gives confidence to industries as economy strengthens! STR_7075_TOGGLE_LARGE_SMALL_WINDOW :{BLACK}Toggle large/small window size diff --git a/lang/finnish.txt b/lang/finnish.txt index d70a3ef04..1c442e107 100644 --- a/lang/finnish.txt +++ b/lang/finnish.txt @@ -1936,7 +1936,7 @@ STR_683B_HOSTILE :Vihamielinen ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Pelaaja {COMMA16}) STR_7004_NEW_FACE :{BLACK}Uudet kasvot STR_7005_COLOR_SCHEME :{BLACK}Väriteema diff --git a/lang/french.txt b/lang/french.txt index ea3ec21e8..40f9d113d 100644 --- a/lang/french.txt +++ b/lang/french.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :Hostile ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Joueur {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nouveau visage STR_7005_COLOR_SCHEME :{BLACK}Couleur diff --git a/lang/galician.txt b/lang/galician.txt index 785f10c3e..3b145010c 100644 --- a/lang/galician.txt +++ b/lang/galician.txt @@ -1881,7 +1881,7 @@ STR_683B_HOSTILE :Hostil ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Xogador {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nova Cara STR_7005_COLOR_SCHEME :{BLACK}Esquema de Cor diff --git a/lang/german.txt b/lang/german.txt index 1c0861c5e..aa79fdbb7 100644 --- a/lang/german.txt +++ b/lang/german.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :Feindlich ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Spieler {COMMA16}) STR_7004_NEW_FACE :{BLACK}Neues Gesicht STR_7005_COLOR_SCHEME :{BLACK}Farbauswahl diff --git a/lang/hungarian.txt b/lang/hungarian.txt index 031fc073b..14f435628 100644 --- a/lang/hungarian.txt +++ b/lang/hungarian.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :Ellenséges ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :({COMMA16}. játékos) STR_7004_NEW_FACE :{BLACK}Új arc STR_7005_COLOR_SCHEME :{BLACK}Szín váltása diff --git a/lang/italian.txt b/lang/italian.txt index cbf5230d8..8b2ade4fc 100644 --- a/lang/italian.txt +++ b/lang/italian.txt @@ -1803,7 +1803,7 @@ STR_683B_HOSTILE :Ostile ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Giocatore {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nuova Faccia STR_7005_COLOR_SCHEME :{BLACK}Colore Societŕ diff --git a/lang/norwegian.txt b/lang/norwegian.txt index bde2a667a..a6044f88e 100644 --- a/lang/norwegian.txt +++ b/lang/norwegian.txt @@ -1922,7 +1922,7 @@ STR_683B_HOSTILE :Fientlig ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Spiller {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nytt ansikt STR_7005_COLOR_SCHEME :{BLACK}Firmafarge diff --git a/lang/polish.txt b/lang/polish.txt index 69b75504d..8ae1910ff 100644 --- a/lang/polish.txt +++ b/lang/polish.txt @@ -1939,7 +1939,7 @@ STR_683B_HOSTILE :Wrogie ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Gracz {COMMA16}) STR_7004_NEW_FACE :{BLACK}nowa twarz STR_7005_COLOR_SCHEME :{BLACK}Schemat koloru diff --git a/lang/portuguese.txt b/lang/portuguese.txt index cfdcfdca6..aa02c230b 100644 --- a/lang/portuguese.txt +++ b/lang/portuguese.txt @@ -1863,7 +1863,7 @@ STR_683B_HOSTILE :Hostil ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Jogador {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nova Cara STR_7005_COLOR_SCHEME :{BLACK}Cores diff --git a/lang/romanian.txt b/lang/romanian.txt index 30b775db0..75ab25598 100644 --- a/lang/romanian.txt +++ b/lang/romanian.txt @@ -1944,7 +1944,7 @@ STR_683B_HOSTILE :ostilă ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Jucătorul {COMMA16}) STR_7004_NEW_FACE :{BLACK}Schimbă foto STR_7005_COLOR_SCHEME :{BLACK}Culoare diff --git a/lang/slovak.txt b/lang/slovak.txt index bb924de1b..c0cc749be 100644 --- a/lang/slovak.txt +++ b/lang/slovak.txt @@ -1909,7 +1909,7 @@ STR_683B_HOSTILE :Nepriatelsky ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Hrac {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nova tvar STR_7005_COLOR_SCHEME :{BLACK}Farebna schema diff --git a/lang/spanish.txt b/lang/spanish.txt index 6f65fb271..0bc856ee9 100644 --- a/lang/spanish.txt +++ b/lang/spanish.txt @@ -1942,7 +1942,7 @@ STR_683B_HOSTILE :Hostil ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Jugador {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nueva Cara STR_7005_COLOR_SCHEME :{BLACK}Esquema Color diff --git a/lang/swedish.txt b/lang/swedish.txt index d8c4a2bf4..887d5c483 100644 --- a/lang/swedish.txt +++ b/lang/swedish.txt @@ -1942,7 +1942,7 @@ STR_683B_HOSTILE :Fientlig ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{STRING}{BLACK}{STRING} +STR_7001 :{WHITE}{STRING} {BLACK}{STRING} STR_7002_PLAYER :(Spelare {COMMA16}) STR_7004_NEW_FACE :{BLACK}Nytt ansikte STR_7005_COLOR_SCHEME :{BLACK}Färgval @@ -1360,6 +1360,20 @@ void NetworkShutDown(void) #endif } +void NetworkChangeCompanyPassword(const char *str) +{ + if (strncmp(str, "*", sizeof(_network_player_info[_local_player].password)) == 0) { + _network_player_info[_local_player].password[0] = '\0'; + IConsolePrint(_iconsole_color_warning, "Company password protection removed."); + } else { + ttd_strlcpy(_network_player_info[_local_player].password, str, sizeof(_network_player_info[_local_player].password)); + IConsolePrintF(_iconsole_color_warning, "Company protected with password '%s'.", _network_player_info[_local_player].password); + } + + if (!_network_server) + SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password); +} + #else void ParseConnectionString(const byte **player, const byte **port, byte *connection_string) {} @@ -200,5 +200,6 @@ void NetworkUpdateClientInfo(uint16 client_index); void NetworkAddServer(const byte *b); void NetworkRebuildHostList(); NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info); +void NetworkChangeCompanyPassword(const char *str); #endif /* NETWORK_H */ diff --git a/network_core.h b/network_core.h index 4eaea2d81..7f8bdc18b 100644 --- a/network_core.h +++ b/network_core.h @@ -13,7 +13,7 @@ # include <winsock2.h> # include <ws2tcpip.h> # pragma comment (lib, "ws2_32.lib") -# define ENABLE_NETWORK // On windows, the network is always enabled +//# define ENABLE_NETWORK // On windows, the network is always enabled # define GET_LAST_ERROR() WSAGetLastError() # define EWOULDBLOCK WSAEWOULDBLOCK // Windows has some different names for some types.. diff --git a/player_gui.c b/player_gui.c index 8301c0258..89d35caf1 100644 --- a/player_gui.c +++ b/player_gui.c @@ -9,6 +9,12 @@ #include "command.h" #include "vehicle.h" #include "economy.h" +#include "network.h" + +#ifdef ENABLE_NETWORK +#include "network_data.h" +#include "network_client.h" +#endif static void DoShowPlayerFinances(int player, bool small); @@ -349,14 +355,16 @@ static const WindowDesc _select_player_face_desc = { }; static const Widget _my_player_company_widgets[] = { -{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_IMGBTN, 14, 0, 359, 14, 157, 0x0, STR_NULL}, -{ WWT_PUSHTXTBTN, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, -{ WWT_PUSHTXTBTN, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, -{ WWT_PUSHTXTBTN, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, -{ WWT_PUSHTXTBTN, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, -{ WWT_PUSHTXTBTN, 14, 266, 355, 18, 29, STR_706F_BUILD_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, +{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, +{ WWT_CAPTION, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_IMGBTN, 14, 0, 359, 14, 157, 0x0, STR_NULL}, +{ WWT_PUSHTXTBTN, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, +{ WWT_PUSHTXTBTN, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, +{ WWT_PUSHTXTBTN, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, +{ WWT_PUSHTXTBTN, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, +{ WWT_PUSHTXTBTN, 14, 266, 355, 18, 29, STR_706F_BUILD_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, +{ WWT_EMPTY, 14, 266, 355, 32, 43, 0x0, STR_NULL}, +{ WWT_PUSHTXTBTN, 14, 266, 355, 138, 149, STR_COMPANY_PASSWORD, STR_COMPANY_PASSWORD_TOOLTIP}, { WIDGETS_END}, }; @@ -376,15 +384,16 @@ static const Widget _other_player_company_widgets[] = { }; static const Widget _my_player_company_bh_widgets[] = { -{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_IMGBTN, 14, 0, 359, 14, 157, 0x0, STR_NULL}, -{ WWT_PUSHTXTBTN, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, -{ WWT_PUSHTXTBTN, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, -{ WWT_PUSHTXTBTN, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, -{ WWT_PUSHTXTBTN, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, -{ WWT_PUSHTXTBTN, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, -{ WWT_PUSHTXTBTN, 14, 266, 355, 32, 43, STR_RELOCATE_HQ, STR_RELOCATE_COMPANY_HEADQUARTERS}, +{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, +{ WWT_CAPTION, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_IMGBTN, 14, 0, 359, 14, 157, 0x0, STR_NULL}, +{ WWT_PUSHTXTBTN, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, +{ WWT_PUSHTXTBTN, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, +{ WWT_PUSHTXTBTN, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, +{ WWT_PUSHTXTBTN, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, +{ WWT_PUSHTXTBTN, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, +{ WWT_PUSHTXTBTN, 14, 266, 355, 32, 43, STR_RELOCATE_HQ, STR_RELOCATE_COMPANY_HEADQUARTERS}, +{ WWT_PUSHTXTBTN, 14, 266, 355, 138, 149, STR_COMPANY_PASSWORD, STR_COMPANY_PASSWORD_TOOLTIP}, { WIDGETS_END}, }; @@ -481,8 +490,10 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) Player *p = DEREF_PLAYER(w->window_number); uint32 dis; - if (w->widget != _other_player_company_widgets) - w->widget = (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets; + if (w->widget != _other_player_company_widgets) { + w->widget = (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets; + if (!_networking) w->hidden_state |= (1 << 9); // hide company-password widget + } SetDParam(0, p->name_1); SetDParam(1, p->name_2); @@ -569,9 +580,19 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) SetObjectToPlaceWnd(0x2D0, 1, w); SetTileSelectSize(2, 2); break; - case 9: /* buy 25% */ - DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); - break; + case 9: {/* buy 25% or password protect your company */ + #ifdef ENABLE_NETWORK + if (w->widget != _other_player_company_widgets) { + StringID str; + WP(w,def_d).byte_1 = 2; + str = AllocateName(_network_player_info[_local_player].password, 0); + ShowQueryString(str, STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w->window_class, w->window_number); + DeleteName(str); + } else + #endif + DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); + + } break; case 10: /* sell 25% */ DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); @@ -600,14 +621,24 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - byte *b = e->edittext.str; - if (*b == 0) + char *b = (char*)e->edittext.str; + + if (*b == 0 && WP(w,def_d).byte_1 != 2) // empty string is allowed for password return; + memcpy(_decode_parameters, b, 32); - if (WP(w,def_d).byte_1) { - DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME)); - } else { + switch (WP(w,def_d).byte_1) { + case 0: /* Change president name */ DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT)); + break; + case 1: /* Change company name */ + DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME)); + break; + #ifdef ENABLE_NETWORK + case 2: /* Change company password */ + if (*b == 0) *b = '*'; // empty password is a '*' because of console argument + NetworkChangeCompanyPassword(b); + #endif } } break; |