29 #include "../../idlib/precompiled.h"
34 #include "../Session_local.h"
89 memset(
dlChecksums, 0,
sizeof(
int ) * MAX_PURE_PAKS );
118 common->
Printf(
"Couldn't open client network port.\n" );
162 common->
DWarning(
"idAsyncClient::HandleGuiCommand: unknown cmd %s", cmd );
190 common->
Printf(
"Can't connect to a server as dedicated\n" );
237 serverNum = atoi( address );
272 msg.
Init( msgBuf,
sizeof( msgBuf ) );
277 common->
Error(
"client->server reliable messages overflow\n" );
306 msg.
Init( msgBuf,
sizeof( msgBuf ) );
322 if ( address && *address !=
'\0' ) {
324 common->
Printf(
"Couldn't get server address for \"%s\"\n", address );
365 msg.
Init( msgBuf,
sizeof( msgBuf ) );
393 msg.
Init( msgBuf,
sizeof( msgBuf ) );
457 msg.
Init( msgBuf,
sizeof( msgBuf ) );
563 int i, previousIndex, currentIndex;
591 msg.
Init( msgBuf,
sizeof( msgBuf ) );
596 common->
Error(
"client->server reliable messages overflow\n" );
623 msg.
Init( msgBuf,
sizeof( msgBuf ) );
651 msg.
Init( msgBuf,
sizeof( msgBuf ) );
670 int i, numUsercmds,
index;
686 msg.
Init( msgBuf,
sizeof( msgBuf ) );
735 int i,
j,
index,
id, numDuplicatedUsercmds, aheadOfServer, numUsercmds, delta;
736 int serverGameInitId, serverGameFrame, serverGameTime;
747 common->
Printf(
"received empty message from server\n" );
753 common->
Printf(
"received ping message from server\n" );
762 pureWait = serverSI.
GetBool(
"si_pure" );
764 InitGame( serverGameInitId, serverGameFrame, serverGameTime, serverSI );
794 common->
Printf(
"ignoring snapshot with != gameInitId\n" );
802 numDuplicatedUsercmds = msg.
ReadByte();
815 for ( j = 0; j < numUsercmds; j++ ) {
866 common->
Printf(
"unknown unreliable server message %d\n",
id );
880 int inChecksums[ MAX_PURE_PAKS ];
883 int serverGameInitId;
890 common->
DPrintf(
"ignoring pure server checksum from an outdated gameInitId (%d)\n", serverGameInitId );
900 common->
Printf(
"received new pure server info. ExecuteMapChange and report back\n" );
908 outMsg.
Init( msgBuf,
sizeof( msgBuf ) );
914 while ( inChecksums[ i ] ) {
921 common->
Error(
"client->server reliable messages overflow\n" );
946 msg.
Init( msgBuf,
sizeof( msgBuf ) );
956 bool haveBase = ( msg.
ReadBits( 1 ) != 0 );
958 #if ID_CLIENTINFO_TAGS
961 if ( checksum != srv_checksum ) {
962 common->
DPrintf(
"SERVER_RELIABLE_MESSAGE_CLIENTINFO %d (haveBase: %s): != checksums srv: 0x%x local: 0x%x\n", clientNum, haveBase ?
"true" :
"false", checksum, srv_checksum );
965 common->
DPrintf(
"SERVER_RELIABLE_MESSAGE_CLIENTINFO %d (haveBase: %s): checksums ok 0x%x\n", clientNum, haveBase ?
"true" :
"false", checksum );
1020 common->
Error(
"couldn't apply snapshot %d", sequence );
1060 common->
Printf(
"Unwanted challenge response received.\n" );
1077 common->
Printf(
"The server is running Doom3: Resurrection of Evil expansion pack. RoE is not installed on this client. Aborting the connection..\n" );
1081 common->
Printf(
"The server is running a different mod (%s-%s). Restarting..\n", serverGameBase, serverGame );
1106 int serverGameInitId, serverGameFrame, serverGameTime;
1114 common->
Printf(
"Connect response packet while not connecting.\n" );
1118 common->
Printf(
"Connect response from a different server.\n" );
1135 InitGame( serverGameInitId, serverGameFrame, serverGameTime, serverSI );
1151 common->
Printf(
"Disconnect packet while not connected.\n" );
1155 common->
Printf(
"Disconnect packet from unknown server.\n" );
1171 bool verbose =
false;
1178 serverInfo.
adr = from;
1215 const char *retpass;
1236 }
else if ( game_opcode ==
ALLOW_NO ) {
1279 common->
Printf(
"clientState != CS_CONNECTING, not waiting for game auth, authKey ignored\n" );
1285 valid[ 0 ] = valid[ 1 ] =
true;
1288 switch ( authBadStatus ) {
1290 valid[ 0 ] = ( msg.
ReadByte() == 1 );
1291 valid[ 1 ] = ( msg.
ReadByte() == 1 );
1299 valid[ key_index ] =
false;
1306 valid[ key_index ] =
false;
1312 auth_msg = read_string;
1360 common->
Printf(
"ProcessVersionMessage: version reply, != UPDATE_SENT\n" );
1382 int i, numChecksums, numMissingChecksums;
1383 int inChecksums[ MAX_PURE_PAKS ];
1384 int inGamePakChecksum;
1385 int missingChecksums[ MAX_PURE_PAKS ];
1386 int missingGamePakChecksum;
1395 inChecksums[ numChecksums++ ] =
i;
1397 if ( numChecksums >= MAX_PURE_PAKS ) {
1398 common->
Warning(
"MAX_PURE_PAKS ( %d ) exceeded in idAsyncClient::ProcessPureMessage\n", MAX_PURE_PAKS );
1402 inChecksums[ numChecksums ] = 0;
1403 inGamePakChecksum = msg.
ReadLong();
1420 while ( missingChecksums[ i ] ) {
1421 checksums +=
va(
"0x%x ", missingChecksums[ i++ ] );
1423 numMissingChecksums =
i;
1429 if ( numMissingChecksums > 0 ) {
1432 if ( missingGamePakChecksum ) {
1446 common->
DPrintf(
"missing %d paks: %s\n", numMissingChecksums + ( missingGamePakChecksum ? 1 : 0 ), checksums.
c_str() );
1447 if ( missingGamePakChecksum ) {
1448 common->
DPrintf(
"game code pak: 0x%x\n", missingGamePakChecksum );
1454 dlmsg.
Init( msgBuf,
sizeof( msgBuf ) );
1462 dlmsg.
WriteLong( missingGamePakChecksum );
1465 while ( missingChecksums[ i ] ) {
1466 dlmsg.
WriteLong( missingChecksums[ i++ ] );
1493 int inChecksums[ MAX_PURE_PAKS ];
1494 int gamePakChecksum;
1497 common->
Printf(
"clientState != CS_CONNECTING, pure msg ignored\n" );
1506 outMsg.
Init( msgBuf,
sizeof( msgBuf ) );
1512 while ( inChecksums[ i ] ) {
1531 if (
idStr::Icmp(
string,
"infoResponse" ) == 0 ) {
1562 if (
idStr::Icmp(
string,
"challengeResponse" ) == 0 ) {
1568 if (
idStr::Icmp(
string,
"connectResponse" ) == 0 ) {
1592 if (
idStr::Icmp(
string,
"downloadInfo" ) == 0 ) {
1596 if (
idStr::Icmp(
string,
"authrequired" ) == 0 ) {
1662 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1669 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1690 common->
Printf(
"net_LANServer is set, connecting in LAN mode\n" );
1730 outMsg.
Init( msgBuf,
sizeof( msgBuf ) );
1734 common->
Error(
"client->server reliable messages overflow\n" );
1796 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1805 }
while( newPacket );
1916 common->
DPrintf(
"up-to-date check was already performed\n" );
1921 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1950 msg.
Init( msgBuf,
sizeof( msgBuf ) );
2038 int progress_start, progress_end;
2043 if (
dlList[ 0 ].url[ 0 ] ==
'\0' ) {
2068 if ( numPaks > 1 ) {
2069 dltitle +=
va(
" (%d/%d)", pakCount, numPaks );
2081 const int CHUNK_SIZE = 1024 * 1024;
2096 remainlen = f->
Tell();
2098 while ( remainlen ) {
2099 readlen =
Min( remainlen, CHUNK_SIZE );
2100 retlen = f->
Read( buf, readlen );
2101 if ( retlen != readlen ) {
2102 common->
FatalError(
"short read %d of %d in idFileSystem::HandleDownload", retlen, readlen );
2104 retlen = saveas->
Write( buf, readlen );
2105 if ( retlen != readlen ) {
2106 common->
FatalError(
"short write %d of %d in idFileSystem::HandleDownload", retlen, readlen );
2108 remainlen -= readlen;
2119 if ( !checksum || checksum !=
dlList[ 0 ].checksum ) {
2160 msg.
Init( msgBuf,
sizeof( msgBuf ) );
2201 bool gotAllFiles =
true;
2203 bool gotGame =
false;
2224 common->
Warning(
"tried to process a download list while already busy downloading things" );
2234 if ( pakIndex == 0 ) {
2257 gotAllFiles =
false;
2265 gotAllFiles =
false;
2287 if ( !gotAllFiles ) {
2320 assert( !checksums[ count ] );
2321 if ( memcmp(
dlChecksums + 1, checksums,
sizeof(
int ) * count ) || gamePakChecksum !=
dlChecksums[ 0 ] ) {
2325 memcpy(
dlChecksums + 1, checksums,
sizeof(
int ) * MAX_PURE_PAKS );
2329 dlCount = count + ( gamePakChecksum ? 1 : 0 );
void ProcessAuthKeyMessage(const netadr_t from, const idBitMsg &msg)
int InfoResponse(networkServer_t &server)
virtual const idDict * SetUserInfo(int clientNum, const idDict &userInfo, bool isClient, bool canModify)=0
const int MAX_ASYNC_CLIENTS
static int snPrintf(char *dest, int size, const char *fmt,...) id_attribute((format(printf
usercmd_t userCmds[MAX_USERCMD_BACKUP][MAX_ASYNC_CLIENTS]
virtual const char * GetFullPath(void)
int SendMessage(idPort &port, const int time, const idBitMsg &msg)
void ProcessInfoResponseMessage(const netadr_t from, const idBitMsg &msg)
virtual int Read(void *buffer, int len)
backgroundDownload_t backgroundDownload
assert(prefInfo.fullscreenBtn)
int dlChecksums[MAX_PURE_PAKS]
int Cmp(const char *text) const
bool IsActive(void) const
idCVarSystem * cvarSystem
void SendPingResponseToServer(int time)
void ProcessChallengeResponseMessage(const netadr_t from, const idBitMsg &msg)
virtual void CDKeysAuthReply(bool valid, const char *auth_msg)=0
bool Process(const netadr_t from, int time, idBitMsg &msg, int &sequence)
virtual void SetStateString(const char *varName, const char *value)=0
virtual void virtual void virtual const idLangDict * GetLanguageDict(void)=0
void HandleDownloads(void)
int GetDownloadRequest(const int checksums[MAX_PURE_PAKS], int count, int gamePakChecksum)
static const char * HandleGuiCommand(const char *cmd)
#define CONNECTIONLESS_MESSAGE_ID_MASK
void ProcessReliableServerMessages(void)
static idCVar clientPrediction
const int ASYNC_PROTOCOL_VERSION
char dlerror[MAX_STRING_CHARS]
virtual const char * MessageBox(msgBoxType_t type, const char *message, const char *title=NULL, bool wait=false, const char *fire_yes=NULL, const char *fire_no=NULL, bool network=false)=0
virtual void ClearPureChecksums(void)=0
virtual void ClearCDKey(bool valid[2])=0
static idCVar clientDownload
#define ASYNC_PROTOCOL_MAJOR
int GetOutgoingRate(void) const
bool Sys_CompareNetAdrBase(const netadr_t a, const netadr_t b)
virtual int GetCVarInteger(const char *name) const =0
static idAsyncClient client
int GetRemaingData(void) const
int Sys_Milliseconds(void)
static idCVar clientMaxPrediction
void GetServerInfo(const netadr_t adr)
idFileSystem * fileSystem
bool SendReliableMessage(const idBitMsg &msg)
void SendReliableGameMessage(const idBitMsg &msg)
void Init(const netadr_t adr, const int id)
bool Sys_StringToNetAdr(const char *s, netadr_t *a, bool doDNSResolve)
void ConnectToServer(const netadr_t adr)
GLenum GLsizei const GLvoid * string
virtual int Seek(long offset, fsOrigin_t origin)
float GetIncomingCompression(void) const
virtual void SetCVarString(const char *name, const char *value, int flags=0)=0
void SendEmptyToServer(bool force=false, bool mapLoad=false)
idUserInterface * guiNetMenu
void SendVersionDLUpdate(int state)
void SendNextFragment(idPort &port, const int time)
int ReadString(char *buffer, int bufferSize) const
void WriteString(const char *s, int maxLength=-1, bool make7Bit=true)
virtual void StartMenu(bool playIntro=false)=0
idList< pakDlEntry_t > dlList
void ClearPendingPackets(void)
static idCVar clientRemoteConsoleAddress
static int ClampInt(int min, int max, int value)
virtual void BackgroundDownload(backgroundDownload_t *bgl)=0
idUserInterfaceManager * uiManager
void SendVersionCheck(bool fromMenu=false)
virtual void ClientProcessReliableMessage(int clientNum, const idBitMsg &msg)=0
netadr_t GetRemoteAddress(void) const
virtual gameReturn_t ClientPrediction(int clientNum, const usercmd_t *clientCmds, bool lastPredictFrame)=0
char nickname[MAX_NICKLEN][MAX_ASYNC_CLIENTS]
int Icmp(const char *text) const
int BestUnit(const char *format, float value, Measure_t measure)
void Init(byte *data, int length)
bool updateDirectDownload
void WriteData(const void *data, int length)
virtual idUserInterface * FindGui(const char *qpath, bool autoLoad=false, bool needUnique=false, bool forceUnique=false)=0
static idCVar clientUsercmdBackup
bool GetPacket(netadr_t &from, void *data, int &size, int maxSize)
virtual void RemoveFile(const char *relativePath)=0
virtual int GetChecksum(void) const =0
virtual void BufferCommandText(cmdExecution_t exec, const char *text)=0
const int GAME_INIT_ID_INVALID
void WriteNetadr(const netadr_t adr)
bool ReadDeltaDict(idDict &dict, const idDict *base) const
void ExtractFileName(idStr &dest) const
GLuint GLuint GLsizei count
int UpdateTime(int clamp)
void SendPacket(const netadr_t to, const void *data, int size)
virtual void OpenURL(const char *url, bool quit)=0
void ProcessPrintMessage(const netadr_t from, const idBitMsg &msg)
const int GAME_INIT_ID_MAP_LOAD
const char * GetString(const char *key, const char *defaultString="") const
const int SETUP_CONNECTION_RESEND_TIME
int rate[MAX_ASYNC_CLIENTS]
const int ASYNC_PROTOCOL_MINOR
static idAsyncServer server
static void WriteUserCmdDelta(idBitMsg &msg, const usercmd_t &cmd, const usercmd_t *base)
static void BuildInvalidKeyMsg(idStr &msg, bool valid[2])
int GetPrediction(void) const
virtual idFile * MakeTemporaryFile(void)=0
bool GetReliableMessage(idBitMsg &msg)
virtual void SetRestartChecksums(const int pureChecksums[MAX_PURE_PAKS], int gamePakChecksum)=0
void PacifierUpdate(void)
virtual void virtual void virtual void DWarning(const char *fmt,...) id_attribute((format(printf
const int MAX_USERCMD_RELAY
const char * HandleGuiCommandInternal(const char *cmd)
float GetIncomingPacketLoss(void) const
virtual fsPureReply_t SetPureServerChecksums(const int pureChecksums[MAX_PURE_PAKS], int gamePakChecksum, int missingChecksums[MAX_PURE_PAKS], int *missingGamePakChecksum)=0
bool GetBool(const char *key, const char *defaultString="0") const
virtual void DownloadProgressBox(backgroundDownload_t *bgl, const char *title, int progress_start=0, int progress_end=100)=0
virtual const char * GetCVarString(const char *name) const =0
void BeginReading(void) const
virtual void virtual void FatalError(const char *fmt,...) id_attribute((format(printf
virtual idFile * OpenFileWrite(const char *relativePath, const char *basePath="fs_savepath")=0
void ProcessUnreliableServerMessage(const idBitMsg &msg)
const char * GetString(const char *str) const
idDict userInfo[MAX_ASYNC_CLIENTS]
bool InitForPort(int portNumber)
virtual void StartProcess(const char *exePath, bool quit)=0
void AddServer(int id, const char *srv)
virtual void StopBox(void)=0
float GetOutgoingCompression(void) const
void SetupConnection(void)
void StartServers(bool timeout)
virtual const char * GetName(void)
idUsercmdGen * usercmdGen
void PrintLocalServerInfo(void)
clientUpdateState_t updateState
void ProcessMessage(const netadr_t from, idBitMsg &msg)
static idCVar allowCheats
GLubyte GLubyte GLubyte a
virtual void Printf(const char *fmt,...) id_attribute((format(printf
void ProcessServersListMessage(const netadr_t from, const idBitMsg &msg)
static netadr_t GetMasterAddress(void)
int GetOutgoingRate(void) const
void ExecuteMapChange(bool noFadeWipe=false)
void AppendPath(const char *text)
const char * Sys_NetAdrToString(const netadr_t a)
virtual const char * GetCDKey(bool xp)=0
bool ValidatePureServerChecksums(const netadr_t from, const idBitMsg &msg)
idDeclManager * declManager
mapSpawnData_t mapSpawnData
virtual void ThrottleUserInfo(void)=0
virtual bool CheckKey(const char *key, bool netConnect, bool offline_valid[2])=0
const int MAX_SERVER_PORTS
bool IsNumeric(void) const
virtual void GetPureServerChecksums(int checksums[MAX_PURE_PAKS], int OS, int *gamePakChecksum)=0
void InitGame(int serverGameInitId, int serverGameFrame, int serverGameTime, const idDict &serverSI)
idUserInterface * GetActiveMenu()
virtual void SetMute(bool mute)=0
virtual int GetModifiedFlags(void) const =0
float GetIncomingCompression(void) const
int Append(const type &obj)
LPCSTR GetString(LPCSTR psPrompt)
static void ExecuteSessionCommand(const char *sessCmd)
const int PREDICTION_FAST_ADJUST
virtual idFile * OpenExplicitFileWrite(const char *OSPath)=0
bool UnsentFragmentsLeft(void) const
static idCVar clientRemoteConsolePassword
#define CONNECTIONLESS_MESSAGE_ID
void ProcessPureMessage(const netadr_t from, const idBitMsg &msg)
int serverMessageSequence
bool RemoveIndex(int index)
bool WriteDeltaDict(const idDict &dict, const idDict *base)
int GetIncomingRate(void) const
virtual void ResetFlaggedVariables(int flags)=0
float GetIncomingPacketLoss(void) const
idSoundSystem * soundSystem
static bool DuplicateUsercmd(const usercmd_t &previousUserCmd, usercmd_t ¤tUserCmd, int frame, int time)
virtual int Write(const void *buffer, int len)
void ProcessReliableMessagePure(const idBitMsg &msg)
bool SendAuthCheck(const char *cdkey, const char *xpkey)
short pings[MAX_ASYNC_CLIENTS]
const char * c_str(void) const
void DuplicateUsercmds(int frame, int time)
void RemoteConsole(const char *command)
void ProcessDisconnectMessage(const netadr_t from, const idBitMsg &msg)
virtual bool GetCVarBool(const char *name) const =0
void SetBool(const bool value)
void ProcessDownloadInfoMessage(const netadr_t from, const idBitMsg &msg)
int GetTimeSinceLastPacket(void) const
char sessionCommand[MAX_STRING_CHARS]
virtual const idDict * MoveCVarsToDict(int flags) const =0
void * Mem_Alloc(const int size)
bool GetPacketBlocking(netadr_t &from, void *data, int &size, int maxSize, int timeout)
virtual void CreateOSPath(const char *OSPath)=0
const int MAX_USERCMD_BACKUP
char * va(const char *fmt,...)
void SendUserInfoToServer(void)
void WriteBits(int value, int numBits)
virtual void CloseFile(idFile *f)=0
virtual void ClientReadSnapshot(int clientNum, int sequence, const int gameFrame, const int gameTime, const int dupeUsercmds, const int aheadOfServer, const idBitMsg &msg)=0
virtual void DPrintf(const char *fmt,...) id_attribute((format(printf
void SendUsercmdsToServer(void)
virtual void Error(const char *fmt,...) id_attribute((format(printf
virtual bool ClientApplySnapshot(int clientNum, int sequence)=0
static idCVar clientServerTimeout
static void ReadUserCmdDelta(const idBitMsg &msg, usercmd_t &cmd, const usercmd_t *base)
int GetIncomingRate(void) const
virtual usercmd_t GetDirectUsercmd(void)=0
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
void ProcessVersionMessage(const netadr_t from, const idBitMsg &msg)
ID_INLINE T Min(T x, T y)
void ReadLocalizedServerString(const idBitMsg &msg, char *out, int maxLen)
int ReadBits(int numBits) const
int sprintf(idStr &string, const char *fmt,...)
void DisconnectFromServer(void)
virtual void ClearModifiedFlags(int flags)=0
void ProcessConnectResponseMessage(const netadr_t from, const idBitMsg &msg)
virtual bool HasD3XP(void)=0
const int EMPTY_RESEND_TIME
virtual void SetGUI(idUserInterface *gui, HandleGuiCommand_t handle)=0
float GetOutgoingCompression(void) const
virtual bool WaitingForGameAuth(void)=0
clientState_t clientState
virtual int AddZipFile(const char *path)=0
virtual void SetCVarsFromDict(const idDict &dict)=0
int ReadShort(void) const
void ConnectionlessMessage(const netadr_t from, const idBitMsg &msg)