diff --git a/console_cmds.c b/console_cmds.c index e534ef25c8..11f9dffc05 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 \"\". Use * as 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 8a48788127..87f445cee3 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 2a2a657322..6cc66d4ee2 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 155a123bc8..a29c1a285e 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 5fbefe9493..e292dd6d53 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 f5d775b78e..a1d335f4db 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 6a96eb6903..e879172f5d 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 d70a3ef04e..1c442e107e 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 ea3ec21e85..40f9d113dc 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 785f10c3e5..3b145010c2 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 1c0861c5ea..aa79fdbb70 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 031fc073b2..14f435628a 100644 --- a/lang/hungarian.txt +++ b/lang/hungarian.txt @@ -1954,7 +1954,7 @@ STR_683B_HOSTILE :Ellens ##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 cbf5230d8b..8b2ade4fc1 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 bde2a667ac..a6044f88e5 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 69b75504dd..8ae1910fff 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 cfdcfdca60..aa02c230bb 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 30b775db0c..75ab255981 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 bb924de1b1..c0cc749be8 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 6f65fb271e..0bc856ee91 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 d8c4a2bf43..887d5c483b 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 diff --git a/network.c b/network.c index 3f2d1e9d4b..b2d42ca46e 100644 --- a/network.c +++ b/network.c @@ -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) {} diff --git a/network.h b/network.h index e666391336..7fd1d4ebb1 100644 --- a/network.h +++ b/network.h @@ -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 4eaea2d81d..7f8bdc18bb 100644 --- a/network_core.h +++ b/network_core.h @@ -13,7 +13,7 @@ # include # include # 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 8301c0258f..89d35caf12 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;