novaclient v13

This commit is contained in:
Pavel Stupnikov
2014-03-25 15:41:13 +04:00
parent 810a227789
commit 8bf059877e
61 changed files with 2838 additions and 458 deletions

View File

@@ -31,10 +31,11 @@
#include "network_base.h"
#include "network_client.h"
#include "../core/backup_type.hpp"
#include "../town.h"
#include "table/strings.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. */
@@ -263,6 +264,12 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
if (_network_first_time) {
_network_first_time = false;
SendAck();
extern bool novahost();
if(novahost()){
NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, CLIENT_ID_SERVER, "!check 1400");//check version
NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, CLIENT_ID_SERVER, "!synccb"); //CB cargo data
CB_SetCB(false);
}
}
_sync_frame = 0;
@@ -612,6 +619,8 @@ 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 );
return NETWORK_RECV_STATUS_OKAY;
}
@@ -631,6 +640,8 @@ 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 );
return NETWORK_RECV_STATUS_OKAY;
}
@@ -982,7 +993,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;
}
@@ -1019,6 +1031,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p)
}
SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowClassesData( WC_WATCH_COMPANY, 0 );
SetWindowClassesDirty( WC_WATCH_COMPANY );
/* If we come here it means we could not locate the client.. strange :s */
return NETWORK_RECV_STATUS_OKAY;
@@ -1105,6 +1119,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p)
if (client_id == _network_own_client_id) {
SetLocalCompany(company_id);
}
InvalidateWindowClassesData( WC_WATCH_COMPANY, 0 );
SetWindowClassesDirty( WC_WATCH_COMPANY );
return NETWORK_RECV_STATUS_OKAY;
}
@@ -1296,4 +1312,41 @@ bool NetworkMaxSpectatorsReached()
return NetworkSpectatorCount() >= (_network_server ? _settings_client.network.max_spectators : _network_server_max_spectators);
}
void SyncCBClient(byte *msg){ //len = 3 + 6 + 12 + 2 + 6*cargo
size_t pos = 21;
size_t length = pos;
byte tmp;
while(msg[length] != '\0'){ length++; }
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);
//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 */