latest novapolis client for 1.5

--HG--
branch : novattd150
This commit is contained in:
Pavel Stupnikov
2015-03-16 03:20:50 +03:00
parent d201932121
commit e48d2d58e0
69 changed files with 3756 additions and 486 deletions
+2 -1
View File
@@ -83,7 +83,7 @@ bool _network_udp_server; ///< Is the UDP server started?
uint16 _network_udp_broadcast; ///< Timeout for the UDP broadcasts.
uint8 _network_advertise_retries; ///< The number of advertisement retries we did.
CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies.
bool _novarole = false;
/* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);
assert_compile((int)NETWORK_COMPANY_NAME_LENGTH == MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH);
@@ -117,6 +117,7 @@ NetworkClientInfo::~NetworkClientInfo()
{
/* Delete the chat window, if you were chatting with this client. */
InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_CLIENT, this->client_id);
InvalidateWindowData(WC_WATCH_COMPANYA, this->client_id, 2);
}
/**
+72 -2
View File
@@ -34,10 +34,13 @@
#include "table/strings.h"
#include "../safeguards.h"
#include "../town.h"
#include "network_func.h"
#include "../safeguards.h"
/* This file handles all the client-commands */
void SyncCBClient(byte * msg);
/** Read some packets, and when do use that data as initial load filter. */
struct PacketReader : LoadFilter {
@@ -265,6 +268,11 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
if (_network_first_time) {
_network_first_time = false;
SendAck();
extern bool novahost();
if(novahost()){
NetworkClientSendChatToServer("!check 1444"); //check version
CB_SetCB(false);
}
}
_sync_frame = 0;
@@ -614,6 +622,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Pac
strecpy(ci->client_name, name, lastof(ci->client_name));
SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
SetWindowClassesDirty(WC_WATCH_COMPANY);
InvalidateWindowData(WC_WATCH_COMPANYA, ci->client_id, 1);
SetWindowClassesDirty(WC_WATCH_COMPANYA);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -633,6 +645,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Pac
strecpy(ci->client_name, name, lastof(ci->client_name));
SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
SetWindowClassesDirty(WC_WATCH_COMPANY);
InvalidateWindowData(WC_WATCH_COMPANYA, ci->client_id, 1);
SetWindowClassesDirty(WC_WATCH_COMPANYA);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -984,7 +1000,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
}
if (ci != NULL) {
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
if (strncmp(msg, "synccbclient", 12) == 0) SyncCBClient(p->buffer);
else NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
}
return NETWORK_RECV_STATUS_OKAY;
}
@@ -1021,6 +1038,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p)
}
SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowClassesData( WC_WATCH_COMPANYA, 0 );
SetWindowClassesDirty( WC_WATCH_COMPANYA );
/* If we come here it means we could not locate the client.. strange :s */
return NETWORK_RECV_STATUS_OKAY;
@@ -1107,6 +1126,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p)
if (client_id == _network_own_client_id) {
SetLocalCompany(company_id);
}
InvalidateWindowClassesData( WC_WATCH_COMPANYA, 0 );
SetWindowClassesDirty( WC_WATCH_COMPANYA );
return NETWORK_RECV_STATUS_OKAY;
}
@@ -1253,6 +1274,10 @@ void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const
MyClient::SendChat(action, type, dest, msg, data);
}
void NetworkClientSendChatToServer(const char * msg)
{
NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, CLIENT_ID_SERVER, msg);
}
/**
* Set/Reset company password on the client side.
* @param password Password to be set.
@@ -1298,4 +1323,49 @@ bool NetworkMaxSpectatorsReached()
return NetworkSpectatorCount() >= (_network_server ? _settings_client.network.max_spectators : _network_server_max_spectators);
}
void SyncCBClient(byte *msg){ //len = 3 + 6 + 12 + 3 + 6*cargo
size_t pos = 21;
size_t length = pos;
byte tmp;
while(msg[length] != '\0'){ length++; }
_novarole = msg[pos++] == 'A';
if(length == pos) return;
CB_SetCB(true);
tmp = msg[pos++];
_settings_client.gui.cb_distance_check = (tmp == 0xFF) ? 0 : tmp;
tmp = msg[pos++];
CB_SetStorage((tmp == 0xFF) ? 0 : (uint)tmp);
for(int i = 0; i < NUM_CARGO; i++){
CB_SetRequirements(i, 0, 0, 0);
}
//IConsolePrintF(CC_INFO, "cb check %i, storage %i", _settings_client.gui.cb_distance_check, tmp);
uint8 cargo;
uint req, from, decay;
while(pos < length){ //CargoID NUM_CARGO
cargo = msg[pos++];
if(cargo == 0xFF) cargo = 0;
tmp = msg[pos++];
req = (tmp == 0xFF) ? 0 : tmp;
tmp = msg[pos++];
req += (tmp == 0xFF) ? 0 : (tmp << 8);
tmp = msg[pos++];
from = (tmp == 0xFF) ? 0 : tmp;
tmp = msg[pos++];
from += (tmp == 0xFF) ? 0 : (tmp << 8);
tmp = msg[pos++];
decay = (tmp == 0xFF) ? 0 : tmp;
CB_SetRequirements(cargo, req, from, decay);
//IConsolePrintF(CC_INFO, "cargo#%i %i/%i/%i", cargo, req, from, decay);
}
}
#endif /* ENABLE_NETWORK */
+2 -1
View File
@@ -39,7 +39,7 @@ extern uint8 _network_reconnect;
extern StringList _network_bind_list;
extern StringList _network_host_list;
extern StringList _network_ban_list;
extern bool _novarole;
byte NetworkSpectatorCount();
void NetworkUpdateClientName();
bool NetworkCompanyHasClients(CompanyID company);
@@ -58,6 +58,7 @@ void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const c
void NetworkClientRequestMove(CompanyID company, const char *pass = "");
void NetworkClientSendRcon(const char *password, const char *command);
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
void NetworkClientSendChatToServer(const char * msg);
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
bool NetworkCompanyIsPassworded(CompanyID company_id);
bool NetworkMaxCompaniesReached();
+46 -3
View File
@@ -38,6 +38,7 @@
#include "../table/sprites.h"
#include "../stringfilter_type.h"
#include "../watch_gui.h"
#include "../safeguards.h"
@@ -234,6 +235,7 @@ protected:
Scrollbar *vscroll; ///< vertical scrollbar of the list of servers
QueryString name_editbox; ///< Client name editbox.
QueryString filter_editbox; ///< Editbox for filter on servers
bool UDP_CC_queried;
int lock_offset; ///< Left offset for lock icon.
int blot_offset; ///< Left offset for green/yellow/red compatibility icon.
@@ -474,6 +476,7 @@ public:
this->querystrings[WID_NG_FILTER] = &this->filter_editbox;
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
this->UDP_CC_queried = false;
this->SetFocusedWidget(WID_NG_FILTER);
this->last_joined = NetworkGameListAddItem(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port));
@@ -782,6 +785,23 @@ public:
case WID_NG_NEWGRF_MISSING: // Find missing content online
if (this->server != NULL) ShowMissingContentWindow(this->server->info.grfconfig);
break;
case WID_NG_NICE:
case WID_NG_BTPRO:
case WID_NG_REDDIT:
case WID_NG_NOVA:
if(!UDP_CC_queried){
NetworkUDPQueryMasterServer();
UDP_CC_queried = true;
}
if(widget == WID_NG_NICE) this->filter_editbox.text.Assign("n-ice");
else if(widget == WID_NG_BTPRO) this->filter_editbox.text.Assign("BTPro");
else if(widget == WID_NG_NOVA) this->filter_editbox.text.Assign("Novapolis");
else if(widget == WID_NG_REDDIT) this->filter_editbox.text.Assign("reddit");
this->servers.ForceRebuild();
this->BuildGUINetworkGameList();
this->ScrollToSelectedServer();
this->SetDirty();
break;
}
}
@@ -909,7 +929,7 @@ public:
}
};
Listing NetworkGameWindow::last_sorting = {false, 5};
Listing NetworkGameWindow::last_sorting = {false, 0};
GUIGameServerList::SortFunction * const NetworkGameWindow::sorter_funcs[] = {
&NGameNameSorter,
&NGameClientSorter,
@@ -946,6 +966,10 @@ static const NWidgetPart _nested_network_game_widgets[] = {
NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NG_CONN_BTN),
SetDataTip(STR_BLACK_STRING, STR_NETWORK_SERVER_LIST_ADVERTISED_TOOLTIP),
NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_REDDIT), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_REDDIT, STR_NETWORK_SELECT_SERVER_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NICE), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_NICE, STR_NETWORK_SELECT_SERVER_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_BTPRO), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_BTPRO, STR_NETWORK_SELECT_SERVER_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NOVA), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_NOVA, STR_NETWORK_SELECT_SERVER_TOOLTIP),
EndContainer(),
NWidget(NWID_HORIZONTAL), SetPIP(0, 7, 0),
NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_FILTER_LABEL), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
@@ -1691,6 +1715,14 @@ static void ClientList_Ban(const NetworkClientInfo *ci)
NetworkServerKickOrBanIP(ci->client_id, true);
}
static void ClientList_Watch(const NetworkClientInfo *ci)
{
if (ci != NULL){
CompanyID cid = (CompanyID)ci->client_id;
ShowWatchWindow(cid, 1);
}
}
static void ClientList_GiveMoney(const NetworkClientInfo *ci)
{
ShowNetworkGiveMoneyWindow(ci->client_playas);
@@ -1767,6 +1799,9 @@ struct NetworkClientListPopupWindow : Window {
this->AddAction(STR_NETWORK_CLIENTLIST_BAN, &ClientList_Ban);
}
if (_network_own_client_id != ci->client_id && ci->client_id != CLIENT_ID_SERVER && _novarole) {
this->AddAction(STR_XI_WATCH, &ClientList_Watch);
}
this->InitNested(client_id);
CLRBITS(this->flags, WF_WHITE_BORDER);
}
@@ -1908,8 +1943,11 @@ struct NetworkClientListWindow : Window {
FOR_ALL_CLIENT_INFOS(ci) {
width = max(width, GetStringBoundingBox(ci->client_name).width);
}
size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + width + WD_FRAMERECT_RIGHT;
SetDParam(0, 0xFFFF);
SetDParam(1, INVALID_COMPANY);
uint width2 = GetStringBoundingBox(STR_NETWORK_CLIENT_EXTRA).width;
size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + width + WD_FRAMERECT_RIGHT + width2;
//size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + width + WD_FRAMERECT_RIGHT;
}
virtual void OnPaint()
@@ -1960,6 +1998,11 @@ struct NetworkClientListWindow : Window {
DrawString(name_left, name_right, y, ci->client_name, colour);
uint extra = GetStringBoundingBox(ci->client_name).width + 15;
SetDParam(0, ci->client_id);
SetDParam(1, ci->client_playas == INVALID_COMPANY ? ci->client_playas : ci->client_playas + 1);
DrawString(name_left + extra, right, y, STR_NETWORK_CLIENT_EXTRA, TC_FROMSTRING, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
}
}