Compare commits

..

15 Commits

Author SHA1 Message Date
Alibek Omarov
215feb3ba9 engine: client: support GoldSrc signon and refactor parsing delta entities for current and legacy protocols 2024-10-07 21:44:25 +03:00
Alibek Omarov
150e2607d9 engine: client: support parsing GoldSrc event messages 2024-10-07 21:16:00 +03:00
Alibek Omarov
e8452c68d7 engine: client: add support for parsing GoldSrc messages 2024-10-07 21:09:57 +03:00
Alibek Omarov
7fe0aba71c engine: client: refactor and implement GoldSrc-specific parsing bits in common message parsing code 2024-10-07 21:09:57 +03:00
Alibek Omarov
adcc9eb0df engine: client: add support for parsing GoldSrc svc_temp_entity 2024-10-07 21:09:57 +03:00
Alibek Omarov
081d1da640 engine: client: get rid of PROTOCOL_GOLDSRC_VERSION, as connprotocol_t enum does it's job 2024-10-07 21:09:57 +03:00
Alibek Omarov
4aadea40a3 engine: common: add GoldSrc delta support 2024-10-07 21:09:57 +03:00
Alibek Omarov
8deea9dc7e engine: common: add GoldSrc bitbuf operations, add support for GoldSrc signed integers 2024-10-07 19:34:19 +03:00
Alibek Omarov
d650d8c271 engine: common: add support for GoldSrc split packet 2024-10-07 19:11:30 +03:00
Alibek Omarov
eb89c8b222 engine: client: rename CL_LegacyMode to CL_Protocol 2024-10-07 19:04:24 +03:00
Alibek Omarov
659ffc4519 engine: common: add GoldSrc netchan support 2024-10-07 18:57:52 +03:00
Alibek Omarov
63a63a52de engine: common: add buffer munge functions 2024-10-07 18:57:52 +03:00
Alibek Omarov
e082d76a45 engine: remove unused svc_deltapacketbones 2024-10-07 18:57:52 +03:00
Alibek Omarov
cb8e2a4f9f 3rdparty: bzip2: add wscript for bzip2, check for system-wide bzip2, add readme note 2024-10-07 18:57:52 +03:00
Alibek Omarov
5f55930cb7 3rdparty: add bzip2 submodule 2024-10-07 18:10:06 +03:00
105 changed files with 1156 additions and 5075 deletions

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2017-2018 Alexander Belkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,25 +0,0 @@
# MultiEmulator
**MultiEmulator** - project for GoldSource Engine, which provides ability to generate tickets with a specific SteamID key, using all available emulators for this engine.
Ticket is processed by the game server of Half-Life 1 and modifications using **DProto** or **ReUnion** modules. If the server does not have these modules, then MultiEmulator won't work.
# Ticket generators
Currently available ticket generators:
* OldRevEmu
* AVSMP
* Setti
* SteamEmu
* RevEmu
* SC2009
* RevEmu2013
Currently under development generators:
* SmartSteamEmu (SSE3)
# How to use?
Each file in the **MultiEmulator\Source\Emulators** folder contains a **Generate** function that writes a ticket to the **pDest** argument for the emulator of the same name as a header file. As a result of the function, the size of the written ticket is returned. If the generator can set an arbitrary SteamID, the function will have the **nSteamID** argument, in which the required SteamID is specified.
# Examples
As an example, the DLL was developed that searches InitiateGameConnection method in ISteamUser interface, which generates Steam ticket, and inserts in its place own generator, which creates RevEmu2013 ticket with SteamID equal to 3333333. You can find this project in **Example** folder, you just need to compile it and perform DLL injection in hl.exe process with any known injection method.

View File

@@ -1,37 +0,0 @@
#ifndef MULTI_EMULATOR_H
#define MULTI_EMULATOR_H
#if defined( __GNUC__ )
#if defined( __i386__ )
#define ME_EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer ))
#else
#define ME_EXPORT __attribute__(( visibility ( "default" )))
#endif
#else
#if defined( _MSC_VER )
#define ME_EXPORT __declspec( dllexport )
#else
#define ME_EXPORT
#endif
#endif
#include <string.h>
#if __cplusplus
extern "C"
{
#endif
int ME_EXPORT GenerateRevEmu2013( void *pDest, int nSteamID );
int ME_EXPORT GenerateSC2009( void *pDest, int nSteamID );
int ME_EXPORT GenerateOldRevEmu( void *pDest, int nSteamID );
int ME_EXPORT GenerateSteamEmu( void *pDest, int nSteamID );
int ME_EXPORT GenerateRevEmu( void *pDest, int nSteamID );
int ME_EXPORT GenerateSetti( void *pDest );
int ME_EXPORT GenerateAVSMP( void *pDest, int nSteamID, int bUniverse );
#if __cplusplus
}
#endif
#endif // MULTI_EMULATOR_H

View File

@@ -1,13 +0,0 @@
#include "multi_emulator.h"
/* bUniverse param is "y" value in "STEAM_x:y:z" */
int GenerateAVSMP(void *pDest, int nSteamID, int bUniverse)
{
auto pTicket = (int *)pDest;
pTicket[0] = 0x14; // +0, header
pTicket[3] = (nSteamID << 1) | (bUniverse ? 1 : 0); // +12, SteamId, Low part
pTicket[4] = 0x01100001; // +16, SteamId, High part
return 28;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,187 +0,0 @@
#ifndef __RIJNDAEL_H__
#define __RIJNDAEL_H__
#include <exception>
#include <stdexcept>
#include <cstring>
#include <string>
using namespace std;
//Rijndael (pronounced Reindaal) is a block cipher, designed by Joan Daemen and Vincent Rijmen as a candidate algorithm for the AES.
//The cipher has a variable block length and key length. The authors currently specify how to use keys with a length
//of 128, 192, or 256 bits to encrypt blocks with al length of 128, 192 or 256 bits (all nine combinations of
//key length and block length are possible). Both block length and key length can be extended very easily to
// multiples of 32 bits.
//Rijndael can be implemented very efficiently on a wide range of processors and in hardware.
//This implementation is based on the Java Implementation used with the Cryptix toolkit found at:
//http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael.zip
//Java code authors: Raif S. Naffah, Paulo S. L. M. Barreto
//This Implementation was tested against KAT test published by the authors of the method and the
//results were identical.
class CRijndael
{
public:
//Operation Modes
//The Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB) modes
//are implemented.
//In ECB mode if the same block is encrypted twice with the same key, the resulting
//ciphertext blocks are the same.
//In CBC Mode a ciphertext block is obtained by first xoring the
//plaintext block with the previous ciphertext block, and encrypting the resulting value.
//In CFB mode a ciphertext block is obtained by encrypting the previous ciphertext block
//and xoring the resulting value with the plaintext.
enum { ECB = 0, CBC = 1, CFB = 2 };
private:
enum { DEFAULT_BLOCK_SIZE = 16 };
enum { MAX_BLOCK_SIZE = 32, MAX_ROUNDS = 14, MAX_KC = 8, MAX_BC = 8 };
//Auxiliary Functions
//Multiply two elements of GF(2^m)
static int Mul(int a, int b)
{
return (a != 0 && b != 0) ? sm_alog[(sm_log[a & 0xFF] + sm_log[b & 0xFF]) % 255] : 0;
}
//Convenience method used in generating Transposition Boxes
static int Mul4(int a, char b[])
{
if (a == 0)
return 0;
a = sm_log[a & 0xFF];
int a0 = (b[0] != 0) ? sm_alog[(a + sm_log[b[0] & 0xFF]) % 255] & 0xFF : 0;
int a1 = (b[1] != 0) ? sm_alog[(a + sm_log[b[1] & 0xFF]) % 255] & 0xFF : 0;
int a2 = (b[2] != 0) ? sm_alog[(a + sm_log[b[2] & 0xFF]) % 255] & 0xFF : 0;
int a3 = (b[3] != 0) ? sm_alog[(a + sm_log[b[3] & 0xFF]) % 255] & 0xFF : 0;
return a0 << 24 | a1 << 16 | a2 << 8 | a3;
}
public:
//CONSTRUCTOR
CRijndael();
//DESTRUCTOR
virtual ~CRijndael();
//Expand a user-supplied key material into a session key.
// key - The 128/192/256-bit user-key to use.
// chain - initial chain block for CBC and CFB modes.
// keylength - 16, 24 or 32 bytes
// blockSize - The block size in bytes of this Rijndael (16, 24 or 32 bytes).
void MakeKey(char const* key, char const* chain, int keylength = DEFAULT_BLOCK_SIZE, int blockSize = DEFAULT_BLOCK_SIZE);
private:
//Auxiliary Function
void Xor(char* buff, char const* chain)
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
for (int i = 0; i<m_blockSize; i++)
*(buff++) ^= *(chain++);
}
//Convenience method to encrypt exactly one block of plaintext, assuming
//Rijndael's default block size (128-bit).
// in - The plaintext
// result - The ciphertext generated from a plaintext using the key
void DefEncryptBlock(char const* in, char* result);
//Convenience method to decrypt exactly one block of plaintext, assuming
//Rijndael's default block size (128-bit).
// in - The ciphertext.
// result - The plaintext generated from a ciphertext using the session key.
void DefDecryptBlock(char const* in, char* result);
public:
//Encrypt exactly one block of plaintext.
// in - The plaintext.
// result - The ciphertext generated from a plaintext using the key.
void EncryptBlock(char const* in, char* result);
//Decrypt exactly one block of ciphertext.
// in - The ciphertext.
// result - The plaintext generated from a ciphertext using the session key.
void DecryptBlock(char const* in, char* result);
void Encrypt(char const* in, char* result, size_t n, int iMode = ECB);
void Decrypt(char const* in, char* result, size_t n, int iMode = ECB);
//Get Key Length
int GetKeyLength()
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
return m_keylength;
}
//Block Size
int GetBlockSize()
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
return m_blockSize;
}
//Number of Rounds
int GetRounds()
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
return m_iROUNDS;
}
void ResetChain()
{
memcpy(m_chain, m_chain0, m_blockSize);
}
public:
//Null chain
static char const* sm_chain0;
private:
static const int sm_alog[256];
static const int sm_log[256];
static const char sm_S[256];
static const char sm_Si[256];
static const int sm_T1[256];
static const int sm_T2[256];
static const int sm_T3[256];
static const int sm_T4[256];
static const int sm_T5[256];
static const int sm_T6[256];
static const int sm_T7[256];
static const int sm_T8[256];
static const int sm_U1[256];
static const int sm_U2[256];
static const int sm_U3[256];
static const int sm_U4[256];
static const char sm_rcon[30];
static const int sm_shifts[3][4][2];
//Error Messages
static char const* sm_szErrorMsg1;
static char const* sm_szErrorMsg2;
//Key Initialization Flag
bool m_bKeyInit;
//Encryption (m_Ke) round key
int m_Ke[MAX_ROUNDS + 1][MAX_BC];
//Decryption (m_Kd) round key
int m_Kd[MAX_ROUNDS + 1][MAX_BC];
//Key Length
int m_keylength;
//Block Size
int m_blockSize;
//Number of Rounds
int m_iROUNDS;
//Chain Block
char m_chain0[MAX_BLOCK_SIZE];
char m_chain[MAX_BLOCK_SIZE];
//Auxiliary private use buffers
int tk[MAX_KC];
int a[MAX_BC];
int t[MAX_BC];
};
#endif // __RIJNDAEL_H__

View File

@@ -1,128 +0,0 @@
//DoubleBuffering.cpp Source File
#include "DoubleBuffering.h"
#include <cassert>
#include <exception>
#include <string.h>
using namespace std;
CDoubleBuffering::CDoubleBuffering(ifstream& in, char* pcBuff, int iSize, int iDataLen) : m_rin(in),
m_iDataLen(iDataLen), m_bEOF(false), m_iSize(iSize), m_iSize2(iSize >> 1), m_pcBuff(pcBuff)
{
//m_iSize should be even
if(m_iSize%2 != 0)
throw runtime_error("CDoubleBuffering: m_iSize should be Even Number!");
//Check file
if(!in.is_open() || in.bad())
throw runtime_error("CDoubleBuffering: Referenced File not Opened or in Bad State!");
//Check construction data
if(m_iDataLen<1 || m_iSize2<m_iDataLen)
throw runtime_error("CDoubleBuffering: Illegal Construction Data!");
in.read(m_pcBuff, m_iSize2);
m_iEnd = m_rin.gcount();
m_iCurPos = 0;
m_iBuf = 0;
}
int CDoubleBuffering::GetData(char* pszDataBuf, int iDataLen)
{
if(-1 == iDataLen)
iDataLen = m_iDataLen;
if(iDataLen<1 || m_iSize2<iDataLen)
throw runtime_error("CDoubleBuffering::GetData(): Illegal iDataLen!");
if(true == m_bEOF)
return 0;
//Estimate the next position
int iCurPos = m_iCurPos + iDataLen;
if(0 == m_iBuf) //First Buffer
{
if(iCurPos >= m_iEnd)
{
//Read the next buffer
if(m_rin.eof())
{
m_bEOF = true;
//Take everything remained
int iRead = m_iEnd-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
return iRead;
}
else
{
m_rin.read(m_pcBuff+m_iEnd, m_iSize2);
m_iEnd += m_rin.gcount();
if(iCurPos > m_iEnd) //Still greater, then EOF attained
{
assert(m_rin.eof());
m_bEOF = true;
//Take everything remained
int iRead = m_iEnd-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
return iRead;
}
else
{
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iDataLen);
m_iCurPos = iCurPos;
assert(m_iCurPos >= m_iSize2);
m_iBuf = 1;
return iDataLen;
}
}
}
else
{
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iDataLen);
m_iCurPos = iCurPos;
return iDataLen;
}
}
else //1 == m_iBuf, Second Buffer
{
if(iCurPos >= m_iEnd)
{
//Read the next buffer
if(m_rin.eof())
{
m_bEOF = true;
//Take everything remained
int iRead = m_iEnd-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
return iRead;
}
else
{
m_rin.read(m_pcBuff, m_iSize2);
m_iEnd = m_rin.gcount();
iCurPos %= m_iSize;
if(iCurPos > m_iEnd) //Still greater, then EOF attained
{
assert(m_rin.eof());
m_bEOF = true;
//Take everything remained
int iRead = m_iSize-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
memcpy(pszDataBuf+iRead, m_pcBuff, m_iEnd);
return iRead + m_iEnd;
}
else
{
int iRead = m_iSize-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
memcpy(pszDataBuf+iRead, m_pcBuff, iDataLen-iRead);
m_iCurPos = iCurPos;
assert(m_iCurPos < m_iSize2);
m_iBuf = 0;
return iDataLen;
}
}
}
else
{
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iDataLen);
m_iCurPos = iCurPos;
return iDataLen;
}
}
}

View File

@@ -1,40 +0,0 @@
//DoubleBuffering.h Header File
#ifndef __DOUBLEBUFFERING_H__
#define __DOUBLEBUFFERING_H__
//Typical DISCLAIMER:
//The code in this project is Copyright (C) 2003 by George Anescu. You have the right to
//use and distribute the code in any way you see fit as long as this paragraph is included
//with the distribution. No warranties or claims are made as to the validity of the
//information and code contained herein, so use it at your own risk.
#include <fstream>
using namespace std;
class CDoubleBuffering
{
public:
//Constructor
CDoubleBuffering(ifstream& in, char* pcBuff, int iSize, int iDataLen);
//Get Next Data Buffer
int GetData(char* pszDataBuf, int iDataLen=-1);
private:
ifstream& m_rin;
int m_iSize;
int m_iSize2; //m_iSize/2
int m_iDataLen;
//Current Position
int m_iCurPos;
//End Position
int m_iEnd;
//Which Buffer
int m_iBuf;
char* m_pcBuff;
//EOF attained
bool m_bEOF;
};
#endif //__DOUBLEBUFFERING_H__

View File

@@ -1,38 +0,0 @@
//MessageDigest.cpp
#include "MessageDigest.h"
#include "DoubleBuffering.h"
#include <exception>
#include <fstream>
#include <strstream>
using namespace std;
//Digesting a Full File
void IMessageDigest::DigestFile(string const& rostrFileIn, char* pcDigest)
{
//Is the User's responsability to ensure that pcDigest is appropriately allocated
//Open Input File
ifstream in(rostrFileIn.c_str(), ios::binary);
if(!in)
{
ostrstream ostr;
ostr << "FileDigest ERROR: in IMessageDigest::DigestFile(): Cannot open File " << rostrFileIn << "!" << ends;
string ostrMsg = ostr.str();
ostr.freeze(false);
throw runtime_error(ostrMsg);
}
//Resetting first
Reset();
//Reading from file
char szLargeBuff[BUFF_LEN+1] = {0};
char szBuff[DATA_LEN+1] = {0};
CDoubleBuffering oDoubleBuffering(in, szLargeBuff, BUFF_LEN, DATA_LEN);
int iRead;
while((iRead=oDoubleBuffering.GetData(szBuff)) > 0)
AddData(szBuff, iRead);
in.close();
//Final Step
FinalDigest(pcDigest);
}

View File

@@ -1,47 +0,0 @@
//MessageDigest.h
#ifndef __MESSAGEDIGEST_H__
#define __MESSAGEDIGEST_H__
#include <string>
using namespace std;
//Typical DISCLAIMER:
//The code in this project is Copyright (C) 2003 by George Anescu. You have the right to
//use and distribute the code in any way you see fit as long as this paragraph is included
//with the distribution. No warranties or claims are made as to the validity of the
//information and code contained herein, so use it at your own risk.
//General Message Digest Interface
class IMessageDigest
{
public:
//CONSTRUCTOR
IMessageDigest() : m_bAddData(false) {}
//DESTRUCTOR
virtual ~IMessageDigest() {}
//Update context to reflect the concatenation of another buffer of bytes
virtual void AddData(char const* pcData, int iDataLength) = 0;
//Final wrapup - pad to BLOCKSIZE-byte boundary with the bit pattern
//10000...(64-bit count of bits processed, MSB-first)
virtual void FinalDigest(char* pcDigest) = 0;
//Reset current operation in order to prepare for a new one
virtual void Reset() = 0;
//Digesting a Full File
void DigestFile(string const& rostrFileIn, char* pcDigest);
protected:
enum { BLOCKSIZE=64 };
//Control Flag
bool m_bAddData;
//The core of the MessageDigest algorithm, this alters an existing MessageDigest hash to
//reflect the addition of 64 bytes of new data
virtual void Transform() = 0;
private:
enum { DATA_LEN=384, BUFF_LEN=1024 };
};
#endif // __MESSAGEDIGEST_H__

View File

@@ -1,13 +0,0 @@
#include "multi_emulator.h"
int GenerateOldRevEmu(void* pDest, int nSteamID)
{
auto pTicket = (int*)pDest;
auto pbTicket = (unsigned char*)pDest;
pTicket[0] = 0xFFFF; // +0, header
pTicket[1] = (nSteamID ^ 0xC9710266) << 1; // +4, SteamId
*(short *)&pbTicket[8] = 0; // +8, unknown, in original emulator must be 0
return 10;
}

View File

@@ -1,27 +0,0 @@
#include "multi_emulator.h"
#include "StrUtils.h"
#include "RevSpoofer.h"
int GenerateRevEmu(void *pDest, int nSteamID)
{
char szhwid[64];
CreateRandomString(szhwid, 16);
if (!RevSpoofer::Spoof(szhwid, nSteamID))
return 0;
auto pTicket = (int *)pDest;
auto revHash = RevSpoofer::Hash(szhwid);
pTicket[0] = 'J'; // +0, header
pTicket[1] = revHash; // +4, hash of string at +24 offset
pTicket[2] = 'r' << 16 | 'e' << 8 | 'v';// +8, magic number
pTicket[3] = 0; // +12, unknown number, must always be 0
pTicket[4] = revHash << 1; // +16, SteamId, Low part
pTicket[5] = 0x01100001; // +20, SteamId, High part
strcpy((char *)&pTicket[6], szhwid); // +24, string for hash
return 152;
}

View File

@@ -1,55 +0,0 @@
#include "multi_emulator.h"
#include "StrUtils.h"
#include "RevSpoofer.h"
#include "CRijndael.h"
#include "SHA.h"
#include <time.h>
int GenerateRevEmu2013(void *pDest, int nSteamID)
{
char szhwid[64];
CreateRandomString(szhwid, 32);
if (!RevSpoofer::Spoof(szhwid, nSteamID))
return 0;
auto pTicket = (int *)pDest;
auto pbTicket = (unsigned char *)pDest;
auto revHash = RevSpoofer::Hash(szhwid);
pTicket[0] = 'S'; // +0
pTicket[1] = revHash; // +4
pTicket[2] = 'r' << 16 | 'e' << 8 | 'v';;// +8
pTicket[3] = 0; // +12
pTicket[4] = revHash << 1; // +16
pTicket[5] = 0x01100001; // +20
pTicket[6] = (int)time(0) + 90123; // +24
pbTicket[27] = ~(pbTicket[27] + pbTicket[24]);
pTicket[7] = ~(int)time(0); // +28
pTicket[8] = revHash * 2 >> 3; // +32
pTicket[9] = 0; // +36
static const char c_szAESKeyRand[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
char szAESHashRand[32];
auto AESRand = CRijndael();
AESRand.MakeKey(c_szAESKeyRand, CRijndael::sm_chain0, 32, 32);
AESRand.EncryptBlock(szhwid, szAESHashRand);
memcpy(&pbTicket[40], szAESHashRand, 32);
static const char c_szAESKeyRev[] = "_YOU_SERIOUSLY_NEED_TO_GET_LAID_";
char AESHashRev[32];
auto AESRev = CRijndael();
AESRev.MakeKey(c_szAESKeyRev, CRijndael::sm_chain0, 32, 32);
AESRev.EncryptBlock(c_szAESKeyRand, AESHashRev);
memcpy(&pbTicket[72], AESHashRev, 32);
char szSHAHash[32];
auto sha = CSHA(CSHA::SHA256);
sha.AddData(szhwid, 32);
sha.FinalDigest(szSHAHash);
memcpy(&pbTicket[104], szSHAHash, 32);
return 194;
}

View File

@@ -1,96 +0,0 @@
#include "RevSpoofer.h"
#include <string.h>
#define astrlen(x) sizeof(x) - 1
static char s_szDictionary[] = { "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
static int iInputLen;
static unsigned int uTreasure;
bool ScanLast3(char *pszInput, unsigned int uPrevHash)
{
unsigned int h1, h2, h3, hh;
for (int i1 = 0; i1 < astrlen(s_szDictionary); i1++)
{
h1 = uPrevHash ^ ((uPrevHash >> 2) + (uPrevHash << 5) + s_szDictionary[i1]);
hh = h1 ^ ((h1 >> 2) + (h1 << 5));
hh = hh ^ ((hh >> 2) + (hh << 5));
if ((hh ^ uTreasure) >> (8 + 5 + 3))
continue;
for (int i2 = 0; i2 < astrlen(s_szDictionary); i2++)
{
h2 = h1 ^ ((h1 >> 2) + (h1 << 5) + s_szDictionary[i2]);
hh = h2 ^ ((h2 >> 2) + (h2 << 5));
if ((hh ^ uTreasure) >> (8 + 3))
continue;
for (int i3 = 0; i3 < astrlen(s_szDictionary); i3++)
{
h3 = h2 ^ ((h2 >> 2) + (h2 << 5) + s_szDictionary[i3]);
if (h3 == uTreasure)
{
pszInput[iInputLen - 3] = s_szDictionary[i1];
pszInput[iInputLen - 2] = s_szDictionary[i2];
pszInput[iInputLen - 1] = s_szDictionary[i3];
return true;
}
}
}
}
return false;
}
bool ScanNext(char* pszInput, int uIndex, unsigned int uPrevHash)
{
bool res;
for (int i = 0; i < astrlen(s_szDictionary); i++)
{
auto h = uPrevHash ^ ((uPrevHash >> 2) + (uPrevHash << 5) + s_szDictionary[i]);
if (uIndex + 1 < iInputLen - 3)
res = ScanNext(pszInput, uIndex + 1, h);
else
res = ScanLast3(pszInput, h);
if (res)
{
pszInput[uIndex] = s_szDictionary[i];
return true;
}
}
return false;
}
namespace RevSpoofer
{
bool Spoof(char *pszDest, int uSID)
{
uTreasure = uSID;
iInputLen = strlen(pszDest);
auto i = iInputLen - 7;
i = (i < 0) ? 0 : i;
pszDest[i] = '\0';
auto h = Hash(pszDest);
return ScanNext(pszDest, i, h);
}
unsigned int Hash(char *pszString)
{
int i = 0;
unsigned int nHash = 0x4E67C6A7;
int c = pszString[i++];
while (c)
{
nHash = nHash ^ ((nHash >> 2) + (nHash << 5) + c);
c = pszString[i++];
}
return nHash;
}
}

View File

@@ -1,7 +0,0 @@
#pragma once
namespace RevSpoofer
{
bool Spoof(char *pszDest, int uSID);
unsigned int Hash(char *pszString);
}

View File

@@ -1,52 +0,0 @@
#include "multi_emulator.h"
#include "StrUtils.h"
#include "RevSpoofer.h"
#include "CRijndael.h"
#include "SHA.h"
int GenerateSC2009(void* pDest, int nSteamID)
{
char hwid[64];
CreateRandomString(hwid, 32);
if (!RevSpoofer::Spoof(hwid, nSteamID))
return 0;
auto pTicket = (int*)pDest;
auto pbTicket = (unsigned char*)pDest;
auto revHash = RevSpoofer::Hash(hwid);
pTicket[0] = 'S'; // +0
pTicket[1] = revHash; // +4
pTicket[2] = 'r' << 16 | 'e' << 8 | 'v';;// +8
pTicket[3] = 0; // +12
pTicket[4] = revHash << 1; // +16
pTicket[5] = 0x01100001; // +20
/* Encrypt HWID with AESKeyRand key and save it in the ticket. */
static const char AESKeyRand[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
char AESHashRand[32];
auto AESRand = CRijndael();
AESRand.MakeKey(AESKeyRand, CRijndael::sm_chain0, 32, 32);
AESRand.EncryptBlock(hwid, AESHashRand);
memcpy(&pbTicket[24], AESHashRand, 32);
/* Encrypt AESKeyRand with AESKeyRev key and save it in the ticket.
* AESKeyRev key is identical to the key in dproto/reunion. */
static const char AESKeyRev[] = "_YOU_SERIOUSLY_NEED_TO_GET_LAID_";
char AESHashRev[32];
auto AESRev = CRijndael();
AESRev.MakeKey(AESKeyRev, CRijndael::sm_chain0, 32, 32);
AESRev.EncryptBlock(AESKeyRand, AESHashRev);
memcpy(&pbTicket[56], AESHashRev, 32);
/* Perform HWID hashing and save hash to the ticket. */
char SHAHash[32];
auto sha = CSHA(CSHA::SHA256);
sha.AddData(hwid, 32);
sha.FinalDigest(SHAHash);
memcpy(&pbTicket[88], SHAHash, 32);
return 178;
}

View File

@@ -1,734 +0,0 @@
//SHA.cpp
#include "SHA.h"
#include <exception>
#include <strstream>
#include <string.h>
using namespace std;
const unsigned int CSHA::sm_K160[4] =
{
0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
};
const unsigned int CSHA::sm_H160[SHA160LENGTH] =
{
0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0
};
const unsigned int CSHA::sm_K256[64] =
{
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
const unsigned int CSHA::sm_H256[SHA256LENGTH] =
{
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
const SUI64 CSHA::sm_H384[SHA512LENGTH] =
{
{0xcbbb9d5d, 0xc1059ed8},
{0x629a292a, 0x367cd507},
{0x9159015a, 0x3070dd17},
{0x152fecd8, 0xf70e5939},
{0x67332667, 0xffc00b31},
{0x8eb44a87, 0x68581511},
{0xdb0c2e0d, 0x64f98fa7},
{0x47b5481d, 0xbefa4fa4}
};
const SUI64 CSHA::sm_K512[80] =
{
{0x428a2f98, 0xd728ae22}, {0x71374491, 0x23ef65cd},
{0xb5c0fbcf, 0xec4d3b2f}, {0xe9b5dba5, 0x8189dbbc},
{0x3956c25b, 0xf348b538}, {0x59f111f1, 0xb605d019},
{0x923f82a4, 0xaf194f9b}, {0xab1c5ed5, 0xda6d8118},
{0xd807aa98, 0xa3030242}, {0x12835b01, 0x45706fbe},
{0x243185be, 0x4ee4b28c}, {0x550c7dc3, 0xd5ffb4e2},
{0x72be5d74, 0xf27b896f}, {0x80deb1fe, 0x3b1696b1},
{0x9bdc06a7, 0x25c71235}, {0xc19bf174, 0xcf692694},
{0xe49b69c1, 0x9ef14ad2}, {0xefbe4786, 0x384f25e3},
{0x0fc19dc6, 0x8b8cd5b5}, {0x240ca1cc, 0x77ac9c65},
{0x2de92c6f, 0x592b0275}, {0x4a7484aa, 0x6ea6e483},
{0x5cb0a9dc, 0xbd41fbd4}, {0x76f988da, 0x831153b5},
{0x983e5152, 0xee66dfab}, {0xa831c66d, 0x2db43210},
{0xb00327c8, 0x98fb213f}, {0xbf597fc7, 0xbeef0ee4},
{0xc6e00bf3, 0x3da88fc2}, {0xd5a79147, 0x930aa725},
{0x06ca6351, 0xe003826f}, {0x14292967, 0x0a0e6e70},
{0x27b70a85, 0x46d22ffc}, {0x2e1b2138, 0x5c26c926},
{0x4d2c6dfc, 0x5ac42aed}, {0x53380d13, 0x9d95b3df},
{0x650a7354, 0x8baf63de}, {0x766a0abb, 0x3c77b2a8},
{0x81c2c92e, 0x47edaee6}, {0x92722c85, 0x1482353b},
{0xa2bfe8a1, 0x4cf10364}, {0xa81a664b, 0xbc423001},
{0xc24b8b70, 0xd0f89791}, {0xc76c51a3, 0x0654be30},
{0xd192e819, 0xd6ef5218}, {0xd6990624, 0x5565a910},
{0xf40e3585, 0x5771202a}, {0x106aa070, 0x32bbd1b8},
{0x19a4c116, 0xb8d2d0c8}, {0x1e376c08, 0x5141ab53},
{0x2748774c, 0xdf8eeb99}, {0x34b0bcb5, 0xe19b48a8},
{0x391c0cb3, 0xc5c95a63}, {0x4ed8aa4a, 0xe3418acb},
{0x5b9cca4f, 0x7763e373}, {0x682e6ff3, 0xd6b2b8a3},
{0x748f82ee, 0x5defb2fc}, {0x78a5636f, 0x43172f60},
{0x84c87814, 0xa1f0ab72}, {0x8cc70208, 0x1a6439ec},
{0x90befffa, 0x23631e28}, {0xa4506ceb, 0xde82bde9},
{0xbef9a3f7, 0xb2c67915}, {0xc67178f2, 0xe372532b},
{0xca273ece, 0xea26619c}, {0xd186b8c7, 0x21c0c207},
{0xeada7dd6, 0xcde0eb1e}, {0xf57d4f7f, 0xee6ed178},
{0x06f067aa, 0x72176fba}, {0x0a637dc5, 0xa2c898a6},
{0x113f9804, 0xbef90dae}, {0x1b710b35, 0x131c471b},
{0x28db77f5, 0x23047d84}, {0x32caab7b, 0x40c72493},
{0x3c9ebe0a, 0x15c9bebc}, {0x431d67c4, 0x9c100d4c},
{0x4cc5d4be, 0xcb3e42b6}, {0x597f299c, 0xfc657e2a},
{0x5fcb6fab, 0x3ad6faec}, {0x6c44198c, 0x4a475817}
};
const SUI64 CSHA::sm_H512[SHA512LENGTH] =
{
{0x6a09e667, 0xf3bcc908},
{0xbb67ae85, 0x84caa73b},
{0x3c6ef372, 0xfe94f82b},
{0xa54ff53a, 0x5f1d36f1},
{0x510e527f, 0xade682d1},
{0x9b05688c, 0x2b3e6c1f},
{0x1f83d9ab, 0xfb41bd6b},
{0x5be0cd19, 0x137e2179}
};
//CONSTRUCTOR
CSHA::CSHA(int iMethod)
{
//Check the method
switch(iMethod)
{
case SHA160:
{
for(int i=0; i<SHA160LENGTH; i++)
m_auiBuf[i] = sm_H160[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA256:
{
for(int i=0; i<SHA256LENGTH; i++)
m_auiBuf[i] = sm_H256[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA384:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H384[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
break;
case SHA512:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H512[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
break;
default:
{
ostrstream ostr;
ostr << "FileDigest ERROR: in CSHA() Constructor, Illegal Method " << iMethod << "!" << ends;
string ostrMsg = ostr.str();
ostr.freeze(false);
throw runtime_error(ostrMsg);
}
}
m_iMethod = iMethod;
}
//Update context to reflect the concatenation of another buffer of bytes.
void CSHA::AddData(char const* pcData, int iDataLength)
{
if(iDataLength < 0)
throw runtime_error(string("FileDigest ERROR: in CSHA::AddData(), Data Length should be >= 0!"));
unsigned int uiT;
switch(m_iMethod)
{
case SHA160:
case SHA256:
{
//Update bitcount
uiT = m_auiBits[0];
if((m_auiBits[0] = uiT + ((unsigned int)iDataLength << 3)) < uiT)
m_auiBits[1]++; //Carry from low to high
m_auiBits[1] += iDataLength >> 29;
uiT = (uiT >> 3) & (BLOCKSIZE-1); //Bytes already
//Handle any leading odd-sized chunks
if(uiT != 0)
{
unsigned char* puc = (unsigned char*)m_aucIn + uiT;
uiT = BLOCKSIZE - uiT;
if(iDataLength < uiT)
{
memcpy(puc, pcData, iDataLength);
return;
}
memcpy(puc, pcData, uiT);
Transform();
pcData += uiT;
iDataLength -= uiT;
}
//Process data in 64-byte chunks
while(iDataLength >= BLOCKSIZE)
{
memcpy(m_aucIn, pcData, BLOCKSIZE);
Transform();
pcData += BLOCKSIZE;
iDataLength -= BLOCKSIZE;
}
//Handle any remaining bytes of data
memcpy(m_aucIn, pcData, iDataLength);
}
break;
case SHA384:
case SHA512:
{
uiT = m_aoui64Bits[0].m_uiRight;
unsigned int uiU = m_aoui64Bits[0].m_uiLeft;
if((m_aoui64Bits[0].m_uiRight = uiT + ((unsigned int)iDataLength << 3)) < uiT)
m_aoui64Bits[0].m_uiLeft++; //Carry from low to high
unsigned int uiV = m_aoui64Bits[1].m_uiRight;
if((m_aoui64Bits[0].m_uiLeft += iDataLength >> 29) < uiU)
m_aoui64Bits[1].m_uiRight++;
if(m_aoui64Bits[1].m_uiRight < uiV)
m_aoui64Bits[1].m_uiLeft++;
uiT = (uiT >> 3) & (BLOCKSIZE2-1); //Bytes already
//Handle any leading odd-sized chunks
if(uiT != 0)
{
unsigned char* puc = (unsigned char*)m_aucIn + uiT;
uiT = BLOCKSIZE2 - uiT;
if(iDataLength < uiT)
{
memcpy(puc, pcData, iDataLength);
return;
}
memcpy(puc, pcData, uiT);
Transform();
pcData += uiT;
iDataLength -= uiT;
}
//Process data in 64-byte chunks
while(iDataLength >= BLOCKSIZE2)
{
memcpy(m_aucIn, pcData, BLOCKSIZE2);
Transform();
pcData += BLOCKSIZE2;
iDataLength -= BLOCKSIZE2;
}
//Handle any remaining bytes of data
memcpy(m_aucIn, pcData, iDataLength);
}
break;
}
//Set the flag
m_bAddData = true;
}
//Final wrapup - pad to 64-byte boundary with the bit pattern
//1 0*(64-bit count of bits processed, MSB-first)
void CSHA::FinalDigest(char* pcDigest)
{
//Is the User's responsability to ensure that pcDigest is properly allocated 20, 32,
//48 or 64 bytes, depending on the method
if(false == m_bAddData)
throw runtime_error(string("FileDigest ERROR: in CSHA::FinalDigest(), No data Added before call!"));
switch(m_iMethod)
{
case SHA160:
case SHA256:
{
unsigned int uiCount;
unsigned char *puc;
//Compute number of bytes mod 64
uiCount = (m_auiBits[0] >> 3) & (BLOCKSIZE-1);
//Set the first char of padding to 0x80. This is safe since there is
//always at least one byte free
puc = m_aucIn + uiCount;
*puc++ = 0x80;
//Bytes of padding needed to make 64 bytes
uiCount = BLOCKSIZE - uiCount - 1;
//Pad out to 56 mod 64
if(uiCount < 8)
{
//Two lots of padding: Pad the first block to 64 bytes
memset(puc, 0, uiCount);
Transform();
//Now fill the next block with 56 bytes
memset(m_aucIn, 0, BLOCKSIZE-8);
}
else
{
//Pad block to 56 bytes
memset(puc, 0, uiCount - 8);
}
//Append length in bits and transform
Word2Bytes(m_auiBits[1], &m_aucIn[BLOCKSIZE-8]);
Word2Bytes(m_auiBits[0], &m_aucIn[BLOCKSIZE-4]);
Transform();
switch(m_iMethod)
{
case SHA160:
{
for(int i=0; i<SHA160LENGTH; i++,pcDigest+=4)
Word2Bytes(m_auiBuf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
case SHA256:
{
for(int i=0; i<SHA256LENGTH; i++,pcDigest+=4)
Word2Bytes(m_auiBuf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
}
}
break;
case SHA384:
case SHA512:
{
unsigned char *puc;
//Compute number of bytes mod 128
unsigned int uiCount = (m_aoui64Bits[0].m_uiRight >> 3) & (BLOCKSIZE2-1);
//Set the first char of padding to 0x80. This is safe since there is
//always at least one byte free
puc = m_aucIn + uiCount;
*puc++ = 0x80;
//Bytes of padding needed to make 128 bytes
uiCount = BLOCKSIZE2 - uiCount - 1;
//Pad out to 112 mod 128
if(uiCount < 16)
{
//Two lots of padding: Pad the first block to 128 bytes
memset(puc, 0, uiCount);
Transform();
//Now fill the next block with 112 bytes
memset(m_aucIn, 0, BLOCKSIZE2-16);
}
else
{
//Pad block to 112 bytes
memset(puc, 0, uiCount - 16);
}
//Append length in bits and transform
Word2Bytes(m_aoui64Bits[1], &m_aucIn[BLOCKSIZE2-16]);
Word2Bytes(m_aoui64Bits[0], &m_aucIn[BLOCKSIZE2-8]);
Transform();
switch(m_iMethod)
{
case SHA384:
{
for(int i=0; i<SHA384LENGTH; i++,pcDigest+=8)
Word2Bytes(m_aoui64Buf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
case SHA512:
{
for(int i=0; i<SHA512LENGTH; i++,pcDigest+=8)
Word2Bytes(m_aoui64Buf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
}
}
break;
}
//Reinitialize
Reset();
}
//Reset current operation in order to prepare a new one
void CSHA::Reset()
{
//Reinitialize
switch(m_iMethod)
{
case SHA160:
{
for(int i=0; i<SHA160LENGTH; i++)
m_auiBuf[i] = sm_H160[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA256:
{
for(int i=0; i<SHA256LENGTH; i++)
m_auiBuf[i] = sm_H256[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA384:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H384[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
break;
case SHA512:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H512[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
}
//Reset the flag
m_bAddData = false;
}
//The core of the SHA algorithm, this alters an existing SHA hash to
//reflect the addition of 16 longwords of new data.
void CSHA::Transform()
{
switch(m_iMethod)
{
case SHA160:
{
//Expansion of m_aucIn
unsigned char* pucIn = m_aucIn;
unsigned int auiW[80];
int i;
for(i=0; i<16; i++,pucIn+=4)
Bytes2Word(pucIn, auiW[i]);
for(i=16; i<80; i++)
auiW[i] = CircularShift(1, auiW[i-3]^auiW[i-8]^auiW[i-14]^auiW[i-16]);
unsigned int temp;
unsigned int A, B, C, D, E;
A = m_auiBuf[0];
B = m_auiBuf[1];
C = m_auiBuf[2];
D = m_auiBuf[3];
E = m_auiBuf[4];
for(i=0; i<20; i++)
{
temp = CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + auiW[i] + sm_K160[0];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for(i=20; i<40; i++)
{
temp = CircularShift(5, A) + (B ^ C ^ D) + E + auiW[i] + sm_K160[1];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for(i=40; i<60; i++)
{
temp = CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + auiW[i] + sm_K160[2];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for(i=60; i<80; i++)
{
temp = CircularShift(5, A) + (B ^ C ^ D) + E + auiW[i] + sm_K160[3];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
m_auiBuf[0] += A;
m_auiBuf[1] += B;
m_auiBuf[2] += C;
m_auiBuf[3] += D;
m_auiBuf[4] += E;
}
break;
case SHA256:
{
//Expansion of m_aucIn
unsigned char* pucIn = m_aucIn;
unsigned int auiW[64];
int i;
for(i=0; i<16; i++,pucIn+=4)
Bytes2Word(pucIn, auiW[i]);
for(i=16; i<64; i++)
auiW[i] = sig1(auiW[i-2]) + auiW[i-7] + sig0(auiW[i-15]) + auiW[i-16];
//OR
//for(i=0; i<48; i++)
// auiW[i+16] = sig1(auiW[i+14]) + auiW[i+9] + sig0(auiW[i+1]) + auiW[i];
unsigned int a, b, c, d, e, f, g, h, t;
a = m_auiBuf[0];
b = m_auiBuf[1];
c = m_auiBuf[2];
d = m_auiBuf[3];
e = m_auiBuf[4];
f = m_auiBuf[5];
g = m_auiBuf[6];
h = m_auiBuf[7];
t = h + SIG1(e) + CH(e, f, g) + sm_K256[0] + auiW[0]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[1] + auiW[1]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[2] + auiW[2]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[3] + auiW[3]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[4] + auiW[4]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[5] + auiW[5]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[6] + auiW[6]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[7] + auiW[7]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[8] + auiW[8]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[9] + auiW[9]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[10] + auiW[10]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[11] + auiW[11]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[12] + auiW[12]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[13] + auiW[13]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[14] + auiW[14]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[15] + auiW[15]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[16] + auiW[16]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[17] + auiW[17]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[18] + auiW[18]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[19] + auiW[19]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[20] + auiW[20]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[21] + auiW[21]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[22] + auiW[22]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[23] + auiW[23]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[24] + auiW[24]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[25] + auiW[25]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[26] + auiW[26]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[27] + auiW[27]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[28] + auiW[28]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[29] + auiW[29]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[30] + auiW[30]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[31] + auiW[31]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[32] + auiW[32]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[33] + auiW[33]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[34] + auiW[34]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[35] + auiW[35]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[36] + auiW[36]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[37] + auiW[37]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[38] + auiW[38]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[39] + auiW[39]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[40] + auiW[40]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[41] + auiW[41]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[42] + auiW[42]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[43] + auiW[43]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[44] + auiW[44]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[45] + auiW[45]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[46] + auiW[46]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[47] + auiW[47]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[48] + auiW[48]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[49] + auiW[49]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[50] + auiW[50]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[51] + auiW[51]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[52] + auiW[52]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[53] + auiW[53]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[54] + auiW[54]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[55] + auiW[55]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[56] + auiW[56]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[57] + auiW[57]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[58] + auiW[58]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[59] + auiW[59]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[60] + auiW[60]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[61] + auiW[61]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[62] + auiW[62]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[63] + auiW[63]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
//OR
/*
unsigned int a, b, c, d, e, f, g, h, t1, t2;
a = m_auiBuf[0];
b = m_auiBuf[1];
c = m_auiBuf[2];
d = m_auiBuf[3];
e = m_auiBuf[4];
f = m_auiBuf[5];
g = m_auiBuf[6];
h = m_auiBuf[7];
//
for(i=0; i<64; i++)
{
t1 = h + SIG1(e) + CH(e, f, g) + sm_K256[i] + auiW[i];
t2 = SIG0(a) + MAJ(a, b, c);
h = g;
g = f;
f = e;
e = d+t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
*/
m_auiBuf[0] += a;
m_auiBuf[1] += b;
m_auiBuf[2] += c;
m_auiBuf[3] += d;
m_auiBuf[4] += e;
m_auiBuf[5] += f;
m_auiBuf[6] += g;
m_auiBuf[7] += h;
}
break;
case SHA384:
case SHA512:
{
//Expansion of m_aucIn
unsigned char* pucIn = m_aucIn;
SUI64 aoui64W[80];
int i;
for(i=0; i<16; i++,pucIn+=8)
Bytes2Word(pucIn, aoui64W[i]);
for(i=16; i<80; i++)
aoui64W[i] = sig1(aoui64W[i-2]) + aoui64W[i-7] + sig0(aoui64W[i-15]) + aoui64W[i-16];
SUI64 a, b, c, d, e, f, g, h, t;
a = m_aoui64Buf[0];
b = m_aoui64Buf[1];
c = m_aoui64Buf[2];
d = m_aoui64Buf[3];
e = m_aoui64Buf[4];
f = m_aoui64Buf[5];
g = m_aoui64Buf[6];
h = m_aoui64Buf[7];
t = h + SIG1(e) + CH(e, f, g) + sm_K512[0] + aoui64W[0]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[1] + aoui64W[1]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[2] + aoui64W[2]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[3] + aoui64W[3]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[4] + aoui64W[4]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[5] + aoui64W[5]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[6] + aoui64W[6]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[7] + aoui64W[7]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[8] + aoui64W[8]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[9] + aoui64W[9]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[10] + aoui64W[10]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[11] + aoui64W[11]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[12] + aoui64W[12]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[13] + aoui64W[13]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[14] + aoui64W[14]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[15] + aoui64W[15]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[16] + aoui64W[16]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[17] + aoui64W[17]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[18] + aoui64W[18]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[19] + aoui64W[19]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[20] + aoui64W[20]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[21] + aoui64W[21]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[22] + aoui64W[22]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[23] + aoui64W[23]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[24] + aoui64W[24]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[25] + aoui64W[25]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[26] + aoui64W[26]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[27] + aoui64W[27]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[28] + aoui64W[28]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[29] + aoui64W[29]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[30] + aoui64W[30]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[31] + aoui64W[31]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[32] + aoui64W[32]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[33] + aoui64W[33]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[34] + aoui64W[34]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[35] + aoui64W[35]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[36] + aoui64W[36]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[37] + aoui64W[37]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[38] + aoui64W[38]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[39] + aoui64W[39]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[40] + aoui64W[40]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[41] + aoui64W[41]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[42] + aoui64W[42]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[43] + aoui64W[43]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[44] + aoui64W[44]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[45] + aoui64W[45]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[46] + aoui64W[46]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[47] + aoui64W[47]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[48] + aoui64W[48]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[49] + aoui64W[49]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[50] + aoui64W[50]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[51] + aoui64W[51]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[52] + aoui64W[52]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[53] + aoui64W[53]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[54] + aoui64W[54]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[55] + aoui64W[55]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[56] + aoui64W[56]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[57] + aoui64W[57]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[58] + aoui64W[58]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[59] + aoui64W[59]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[60] + aoui64W[60]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[61] + aoui64W[61]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[62] + aoui64W[62]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[63] + aoui64W[63]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[64] + aoui64W[64]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[65] + aoui64W[65]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[66] + aoui64W[66]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[67] + aoui64W[67]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[68] + aoui64W[68]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[69] + aoui64W[69]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[70] + aoui64W[70]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[71] + aoui64W[71]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[72] + aoui64W[72]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[73] + aoui64W[73]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[74] + aoui64W[74]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[75] + aoui64W[75]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[76] + aoui64W[76]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[77] + aoui64W[77]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[78] + aoui64W[78]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[79] + aoui64W[79]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
m_aoui64Buf[0] += a;
m_aoui64Buf[1] += b;
m_aoui64Buf[2] += c;
m_aoui64Buf[3] += d;
m_aoui64Buf[4] += e;
m_aoui64Buf[5] += f;
m_aoui64Buf[6] += g;
m_aoui64Buf[7] += h;
}
break;
}
}

View File

@@ -1,379 +0,0 @@
//SHA.h
#ifndef __SHA_H__
#define __SHA_H__
#include "MessageDigest.h"
//Typical DISCLAIMER:
//The code in this project is Copyright (C) 2003 by George Anescu. You have the right to
//use and distribute the code in any way you see fit as long as this paragraph is included
//with the distribution. No warranties or claims are made as to the validity of the
//information and code contained herein, so use it at your own risk.
//Structure for representing an Unsigned Integer on 64 bits
struct SUI64
{
//Data
unsigned int m_uiLeft;
unsigned int m_uiRight;
//Operators
SUI64& operator++()
{
unsigned int uiTemp = m_uiRight;
m_uiRight++;
if(m_uiRight < uiTemp)
m_uiLeft++;
return *this;
}
SUI64& operator--()
{
unsigned int uiTemp = m_uiRight;
m_uiRight--;
if(m_uiRight > uiTemp)
m_uiLeft--;
return *this;
}
SUI64& operator+=(SUI64 const& roUI64)
{
m_uiRight += roUI64.m_uiRight;
if(m_uiRight < roUI64.m_uiRight)
m_uiLeft++;
m_uiLeft += roUI64.m_uiLeft;
return *this;
}
SUI64& operator|=(SUI64 const& roUI64)
{
m_uiRight |= roUI64.m_uiRight;
m_uiLeft |= roUI64.m_uiLeft;
return *this;
}
SUI64& operator&=(SUI64 const& roUI64)
{
m_uiRight &= roUI64.m_uiRight;
m_uiLeft &= roUI64.m_uiLeft;
return *this;
}
SUI64& operator^=(SUI64 const& roUI64)
{
m_uiRight ^= roUI64.m_uiRight;
m_uiLeft ^= roUI64.m_uiLeft;
return *this;
}
SUI64& operator<<=(unsigned int uiBits)
{
if(uiBits < 32)
{
(m_uiLeft <<= uiBits) |= (m_uiRight >> (32-uiBits));
m_uiRight <<= uiBits;
}
else
{
m_uiLeft = m_uiRight << (uiBits-32);
m_uiRight = 0;
}
return *this;
}
SUI64& operator>>=(unsigned int uiBits)
{
if(uiBits < 32)
{
(m_uiRight >>= uiBits) |= (m_uiLeft << (32-uiBits));
m_uiLeft >>= uiBits;
}
else
{
m_uiRight = m_uiLeft >> (uiBits-32);
m_uiLeft = 0;
}
return *this;
}
bool operator>(SUI64 const& roUI64) const
{
if(m_uiLeft == roUI64.m_uiLeft)
return m_uiRight > roUI64.m_uiRight;
else
return m_uiLeft > roUI64.m_uiLeft;
}
bool operator<(SUI64 const& roUI64) const
{
if(m_uiLeft == roUI64.m_uiLeft)
return m_uiRight < roUI64.m_uiRight;
else
return m_uiLeft < roUI64.m_uiLeft;
}
};
inline SUI64 operator+(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp += roUI64_2;
return temp;
}
inline SUI64 operator|(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp |= roUI64_2;
return temp;
}
inline SUI64 operator&(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp &= roUI64_2;
return temp;
}
inline SUI64 operator^(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp ^= roUI64_2;
return temp;
}
inline SUI64 operator<<(SUI64 const& roUI64, unsigned int uiBits)
{
SUI64 temp = roUI64;
temp <<= uiBits;
return temp;
}
inline SUI64 operator>>(SUI64 const& roUI64, unsigned int uiBits)
{
SUI64 temp = roUI64;
temp >>= uiBits;
return temp;
}
inline bool operator>(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
return roUI64_1.operator>(roUI64_2);
}
inline bool operator<(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
return roUI64_1.operator<(roUI64_2);
}
//SHA Message Digest algorithm
//SHA160 TEST VALUES:
//1)"abc"
//"A9993E364706816ABA3E25717850C26C9CD0D89D"
//
//2)"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
//"84983E441C3BD26EBAAE4AA1F95129E5E54670F1"
//
//3)1,000,000 repetitions of "a".
//"34AA973CD4C4DAA4F61EEB2BDBAD27316534016F"
//
//SHA256 TEST VALUES:
//1)One-Block Message "abc"
//"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
//
//2)"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
//"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
//
//3)Multi-Block Message "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
//"CF5B16A778AF8380036CE59E7B0492370B249B11E8F07A51AFAC45037AFEE9D1"
//
//4)Long Message "a" 1,000,000 times
//"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"
//
//SHA384 TEST VALUES:
//1)One-Block Message "abc"
//"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"
//
//2)Multi-Block Message "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
//"09330C33F71147E83D192FC782CD1B4753111B173B3B05D22FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039"
//
//3)Long Message "a" 1,000,000 times
//"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"
//
//SHA512 TEST VALUES:
//1)One-Block Message "abc"
//"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a8
//36ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"
//
//2)"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
//"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4
//331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"
//
//3)""
//"CF83E1357EEFB8BDF1542850D66D8007D620E4050B5715DC83F4A921D36CE9CE47D0D13C5D85F2B0
//FF8318D2877EEC2F63B931BD47417A81A538327AF927DA3E"
//
//4)Long Message "a" 1,000,000 times
//"E718483D0CE769644E2E42C7BC15B4638E1F98B13B2044285632A803AFA973EBDE0FF244877EA60A
//4CB0432CE577C31BEB009C5C2C49AA2E4EADB217AD8CC09B"
class CSHA : public IMessageDigest
{
public:
enum { SHA160=0, SHA256=1, SHA384=2, SHA512=3 };
//CONSTRUCTOR
CSHA(int iMethod=SHA160);
//Update context to reflect the concatenation of another buffer of bytes.
void AddData(char const* pcData, int iDataLength);
//Final wrapup - pad to 64-byte boundary with the bit pattern
//1 0*(64-bit count of bits processed, MSB-first)
void FinalDigest(char* pcDigest);
//Reset current operation in order to prepare a new one
void Reset();
private:
//Transformation Function
void Transform();
//The Method
int m_iMethod;
enum { BLOCKSIZE2 = BLOCKSIZE<<1 };
//For 32 bits Integers
enum { SHA160LENGTH=5, SHA256LENGTH=8 };
//Context Variables
unsigned int m_auiBuf[SHA256LENGTH]; //Maximum for SHA256
unsigned int m_auiBits[2];
unsigned char m_aucIn[BLOCKSIZE2]; //128 bytes for SHA384, SHA512
//Internal auxiliary static functions
static unsigned int CircularShift(unsigned int uiBits, unsigned int uiWord);
static unsigned int CH(unsigned int x, unsigned int y, unsigned int z);
static unsigned int MAJ(unsigned int x, unsigned int y, unsigned int z);
static unsigned int SIG0(unsigned int x);
static unsigned int SIG1(unsigned int x);
static unsigned int sig0(unsigned int x);
static unsigned int sig1(unsigned int x);
static void Bytes2Word(unsigned char const* pcBytes, unsigned int& ruiWord);
static void Word2Bytes(unsigned int const& ruiWord, unsigned char* pcBytes);
static const unsigned int sm_K160[4];
static const unsigned int sm_H160[SHA160LENGTH];
static const unsigned int sm_K256[64];
static const unsigned int sm_H256[SHA256LENGTH];
//For 64 bits Integers
enum { SHA384LENGTH=6, SHA512LENGTH=8 };
//Context Variables
SUI64 m_aoui64Buf[SHA512LENGTH]; //Maximum for SHA512
SUI64 m_aoui64Bits[2];
//Internal auxiliary static functions
static SUI64 CircularShift(unsigned int uiBits, SUI64 const& roui64Word);
static SUI64 CH(SUI64 const& x, SUI64 const& y, SUI64 const& z);
static SUI64 MAJ(SUI64 const& x, SUI64 const& y, SUI64 const& z);
static SUI64 SIG0(SUI64 const& x);
static SUI64 SIG1(SUI64 const& x);
static SUI64 sig0(SUI64 const& x);
static SUI64 sig1(SUI64 const& x);
static void Bytes2Word(unsigned char const* pcBytes, SUI64& ruiWord);
static void Word2Bytes(SUI64 const& ruiWord, unsigned char* pcBytes);
static const SUI64 sm_H384[SHA512LENGTH]; //Dim is as 512
static const SUI64 sm_K512[80];
static const SUI64 sm_H512[SHA512LENGTH];
};
inline unsigned int CSHA::CircularShift(unsigned int uiBits, unsigned int uiWord)
{
return (uiWord << uiBits) | (uiWord >> (32-uiBits));
}
inline unsigned int CSHA::CH(unsigned int x, unsigned int y, unsigned int z)
{
return ((x&(y^z))^z);
}
inline unsigned int CSHA::MAJ(unsigned int x, unsigned int y, unsigned int z)
{
return (((x|y)&z)|(x&y));
}
inline unsigned int CSHA::SIG0(unsigned int x)
{
return ((x >> 2)|(x << 30)) ^ ((x >> 13)|(x << 19)) ^ ((x >> 22)|(x << 10));
}
inline unsigned int CSHA::SIG1(unsigned int x)
{
return ((x >> 6)|(x << 26)) ^ ((x >> 11)|(x << 21)) ^ ((x >> 25)|(x << 7));
}
inline unsigned int CSHA::sig0(unsigned int x)
{
return ((x >> 7)|(x << 25)) ^ ((x >> 18)|(x << 14)) ^ (x >> 3);
}
inline unsigned int CSHA::sig1(unsigned int x)
{
return ((x >> 17)|(x << 15)) ^ ((x >> 19)|(x << 13)) ^ (x >> 10);
}
inline void CSHA::Bytes2Word(unsigned char const* pcBytes, unsigned int& ruiWord)
{
ruiWord = (unsigned int)*(pcBytes+3) | (unsigned int)(*(pcBytes+2)<<8) |
(unsigned int)(*(pcBytes+1)<<16) | (unsigned int)(*pcBytes<<24);
}
inline void CSHA::Word2Bytes(unsigned int const& ruiWord, unsigned char* pcBytes)
{
pcBytes += 3;
*pcBytes = ruiWord & 0xff;
*--pcBytes = (ruiWord>>8) & 0xff;
*--pcBytes = (ruiWord>>16) & 0xff;
*--pcBytes = (ruiWord>>24) & 0xff;
}
inline SUI64 CSHA::CircularShift(unsigned int uiBits, SUI64 const& roui64Word)
{
return (roui64Word << uiBits) | (roui64Word >> (64-uiBits));
}
inline SUI64 CSHA::CH(SUI64 const& x, SUI64 const& y, SUI64 const& z)
{
return ((x&(y^z))^z);
}
inline SUI64 CSHA::MAJ(SUI64 const& x, SUI64 const& y, SUI64 const& z)
{
return (((x|y)&z)|(x&y));
}
inline SUI64 CSHA::SIG0(SUI64 const& x)
{
return ((x >> 28)|(x << 36)) ^ ((x >> 34)|(x << 30)) ^ ((x >> 39)|(x << 25));
}
inline SUI64 CSHA::SIG1(SUI64 const& x)
{
return ((x >> 14)|(x << 50)) ^ ((x >> 18)|(x << 46)) ^ ((x >> 41)|(x << 23));
}
inline SUI64 CSHA::sig0(SUI64 const& x)
{
return ((x >> 1)|(x << 63)) ^ ((x >> 8)|(x << 56)) ^ (x >> 7);
}
inline SUI64 CSHA::sig1(SUI64 const& x)
{
return ((x >> 19)|(x << 45)) ^ ((x >> 61)|(x << 3)) ^ (x >> 6);
}
inline void CSHA::Bytes2Word(unsigned char const* pcBytes, SUI64& ruiWord)
{
Bytes2Word(pcBytes+4, ruiWord.m_uiRight);
Bytes2Word(pcBytes, ruiWord.m_uiLeft);
}
inline void CSHA::Word2Bytes(SUI64 const& ruiWord, unsigned char* pcBytes)
{
Word2Bytes(ruiWord.m_uiRight, pcBytes+4);
Word2Bytes(ruiWord.m_uiLeft, pcBytes);
}
#endif // __SHA_H__

View File

@@ -1,13 +0,0 @@
#include "multi_emulator.h"
int GenerateSetti(void *pDest)
{
auto pTicket = (int *)pDest;
pTicket[0] = 0xD4CA7F7B;
pTicket[1] = 0xC7DB6023;
pTicket[2] = 0x6D6A2E1F;
pTicket[5] = 0xB4C43105;
return 768;
}

View File

@@ -1,18 +0,0 @@
#include "multi_emulator.h"
int GenerateSteamEmu(void *pDest, int nSteamID)
{
auto pTicket = (int *)pDest;
pTicket[20] = -1; // +80, dproto/reunion wants this value to be -1, but if this value
// does not match -1, then instead of SteamID in [21] cell
// client IP address that xored with 0x25730981 number should
// be used. But dproto/reunion will just skip ticket validation
// in that case.
pTicket[21] = nSteamID; // +84, SteamId, low part. Actually, this is just system volume serial
// number, which comes from GetVolumeInformationA() function. If
// function failed (returned 0), then instead of volume serial number
// 777 number will be written to the ticket.
return 768;
}

View File

@@ -1,12 +0,0 @@
#include "StrUtils.h"
#include <stdlib.h>
void CreateRandomString(char *pszDest, int nLength)
{
static const char c_szAlphaNum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int i = 0; i < nLength; ++i)
pszDest[i] = c_szAlphaNum[rand() % (sizeof(c_szAlphaNum) - 1)];
pszDest[nLength] = '\0';
}

View File

@@ -1,3 +0,0 @@
#pragma once
void CreateRandomString(char *pszDest, int nLength);

View File

@@ -1,24 +0,0 @@
#! /usr/bin/env python
# encoding: utf-8
# mittorn, 2018
from waflib import Logs
import os
top = '.'
def options(opt):
return
def configure(conf):
return
def build(bld):
bld.stlib(
source = bld.path.ant_glob(['src/*.cpp']),
target = 'MultiEmulator',
features = 'cxx',
includes = ['include/', 'src/'],
export_includes = ['include/'],
subsystem = bld.env.MSVC_SUBSYSTEM
)

View File

@@ -1 +0,0 @@
#define BZ_VERSION "1.1.0-fwgs"

View File

@@ -1,12 +1,15 @@
#! /usr/bin/env python
# encoding: utf-8
BZIP_CHECK='''#include <bzlib.h>
int main(void) { return BZ2_bzlibVersion() != NULL; }
'''
def options(opt):
pass
def configure(conf):
conf.define('_GNU_SOURCE', 1)
conf.define('BZ_NO_STDIO', 1)
if conf.env.DEST_OS == 'win32':
conf.define('BZ_LCCWIN32', 1)
@@ -14,21 +17,19 @@ def configure(conf):
conf.define('BZ_UNIX', 1)
def build(bld):
# bld(
# features = 'subst',
# source = 'bzip2/bz_version.h.in',
# target = 'bz_version.h',
# BZ_VERSION='1.1.0-fwgs'
# )
bz_sources = ['bzip2/blocksort.c', 'bzip2/huffman.c', 'bzip2/crctable.c', 'bzip2/randtable.c', 'bzip2/compress.c', 'bzip2/decompress.c', 'bzip2/bzlib.c']
bld(
features = 'subst',
source = 'bzip2/bz_version.h.in',
target = 'bz_version.h',
BZ_VERSION='1.1.0-fwgs'
)
bld.stlib(
source = bz_sources,
source = bld.path.ant_glob(['bzip2/*.c']),
target = 'bzip2',
# use = 'bz_version.h',
use = 'bz_version.h',
features = 'c',
includes = ['.', 'bzip2/'],
includes = ['bzip2/', '.'],
subsystem = bld.env.MSVC_SUBSYSTEM,
export_includes = ['bzip2/']
)

View File

@@ -1,14 +0,0 @@
# Support for GoldSrc network protocol
This feature is still work-in-progress, but for now it's available for all users, and we appreciate any bug-reports and contributions around it.
For connecting to GoldSrc-based servers, use this command:
```
connect ip:port gs
```
But keep in mind, there are requirement for server to be able to accept connections from Xash3D-based clients: it should accept HLTV connections.
Without this requirement, you will just get "Steam validation rejected" error on connecting.
That is because proper authorization with Steam API is not implemented in engine yet (but we have plans on it).
In case of ReHLDS with Reunion plugin, by default it rejects HLTV clients. But connections from HLTV can be easily enabled in `reunion.cfg` file.

View File

@@ -11,12 +11,12 @@ Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://ww
If you like Xash3D FWGS, consider supporting individual engine maintainers. By supporting us, you help to continue developing this game engine further. The sponsorship links are available in [documentation](Documentation/donate.md).
## Fork features
* Steam Half-Life (HLSDK 2.5) support.
* Steam Half-Life (HLSDK 2.4) support.
* Crossplatform and modern compilers support: supports Windows, Linux, BSD & Android on x86 & ARM and [many more](Documentation/ports.md).
* Better multiplayer: multiple master servers, headless dedicated server, voice chat, [GoldSrc protocol support](Documentation/goldsrc-protocol-support.md) and IPv6 support.
* Better multiplayer support: multiple master servers, headless dedicated server, voice chat and IPv6 support.
* Multiple renderers support: OpenGL, GLESv1, GLESv2 and Software.
* Advanced virtual filesystem: `.pk3` and `.pk3dir` support, compatibility with GoldSrc FS module, fast case-insensitivity emulation for crossplatform.
* Mobility API: better game integration on mobile devices (vibration, touch controls).
* Mobility API: better game integration on mobile devices (vibration, touch controls)
* Different input methods: touch and gamepad in addition to mouse & keyboard.
* TrueType font rendering, as a part of mainui_cpp.
* External VGUI support module.
@@ -35,16 +35,17 @@ You still needed to copy `valve` directory as all game resources located there.
For additional info, run Xash3D with `-help` command line key.
## Contributing
* Before sending an issue, check if someone already reported your issue. Make sure you're following "How To Ask Questions The Smart Way" guide by Eric Steven Raymond. Read more: http://www.catb.org/~esr/faqs/smart-questions.html.
* Issues are accepted in both English and Russian.
* Before sending an issue, check if someone already reported your issue. Make sure you're following "How To Ask Questions The Smart Way" guide by Eric Steven Raymond. Read more: http://www.catb.org/~esr/faqs/smart-questions.html
* Issues are accepted in both English and Russian
* Before sending a PR, check if you followed our contribution guide in CONTRIBUTING.md file.
## Build instructions
We are using Waf build system. If you have some Waf-related questions, I recommend you to read [Waf Book](https://waf.io/book/).
We are using Waf build system. If you have some Waf-related questions, I recommend you to read https://waf.io/book/
NOTE: NEVER USE GitHub's ZIP ARCHIVES. GitHub doesn't include external dependencies we're using!
### Prerequisites
If your CPU is x86 compatible and you're on Windows or Linux, we are building 32-bit code by default. This was done to maintain compatibility with Steam releases of Half-Life and based on it's engine games.
Even if Xash3D FWGS does support targetting 64-bit, you can't load games without recompiling them from source code!
@@ -61,39 +62,31 @@ This repository contains our fork of HLSDK and restored source code for Half-Lif
#### GNU/Linux
##### Debian/Ubuntu
* For 32-bit engine on 64-bit x86 operating system:
* Enable i386 on your system: `$ sudo dpkg --add-architecture i386`.
* Install development tools: `$ sudo apt install build-essential gcc-multilib g++-multilib python libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-dev:i386 libopus-dev:i386 libbz2-dev:i386`.
* Set PKG_CONFIG_PATH environment variable to point at 32-bit libraries: `$ export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig`.
* Enable i386 on your system, if you're compiling 32-bit engine on amd64. If not, skip this
* For non-x86 systems:
* Install development tools: `$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev libopus-dev libbz2-dev`.
* Clone this repostory: `$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`.
##### RedHat/Fedora
* For 32-bit engine on 64-bit x86 operating system:
* Install development tools: `$ sudo dnf install gcc gcc-c++ glibc-devel.i686 SDL2-devel.i686 opus-devel.i686 fontconfig-devel.i686 freetype-devel.i686 bzip2-devel.i686`.
* Set PKG_CONFIG_PATH environment variable to point at 32-bit libraries: `$ export PKG_CONFIG_PATH=/usr/lib/pkgconfig`.
* For non-x86 systems:
* Install development tools: `$ sudo dnf install gcc gcc-c++ SDL2-devel opus-devel fontconfig-devel freetype-devel bzip2-devel`.
* Clone this repostory: `$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`.
`$ sudo dpkg --add-architecture i386`
* Install development tools
* For 32-bit engine on amd64: \
`$ sudo apt install build-essential gcc-multilib g++-multilib python libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-dev:i386 libopus-dev:i386 libbz2-dev:i386`
* For everything else: \
`$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev libopus-dev libbz2-dev`
* Clone this repostory:
`$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`
### Building
#### Windows (Visual Studio)
0) Open command line.
0) Open command line
1) Navigate to `xash3d-fwgs` directory.
2) (optional) Examine which build options are available: `waf --help`.
3) Configure build: `waf configure --sdl2=c:/path/to/SDL2`.
4) Compile: `waf build`.
5) Install: `waf install --destdir=c:/path/to/any/output/directory`.
2) Carefully examine which build options are available: `waf --help`
3) Configure build: `waf configure -T release --sdl2=c:/path/to/SDL2`
4) Compile: `waf build`
5) Install: `waf install --destdir=c:/path/to/any/output/directory`
#### Linux
If compiling 32-bit on amd64, make sure `PKG_CONFIG_PATH` from the previous step is set correctly, prior to running configure.
If compiling 32-bit on amd64, you may need to supply `export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig` prior to running configure.
0) (optional) Examine which build options are available: `./waf --help`.
1) Configure build: `./waf configure` (you need to pass `-8` to compile 64-bit engine on 64-bit x86 processor).
2) Compile: `./waf build`.
3) Install: `./waf install --destdir=/path/to/any/output/directory`.
0) Examine which build options are available: `./waf --help`
1) Configure build: `./waf configure -T release`
(You need to pass `-8` to compile 64-bit engine on 64-bit x86 processor)
2) Compile: `./waf build`
3) Install(optional): `./waf install --destdir=/path/to/any/output/directory`

View File

@@ -25,16 +25,13 @@ static CVAR_DEFINE_AUTO( tracerspeed, "6000", 0, "tracer speed" );
static CVAR_DEFINE_AUTO( tracerlength, "0.8", 0, "tracer length factor" );
static CVAR_DEFINE_AUTO( traceroffset, "30", 0, "tracer starting offset" );
static particle_t *cl_active_particles;
static particle_t *cl_active_tracers;
static particle_t *cl_free_particles;
static particle_t *cl_particles = NULL; // particle pool
particle_t *cl_active_particles;
particle_t *cl_active_tracers;
particle_t *cl_free_particles;
particle_t *cl_particles = NULL; // particle pool
static vec3_t cl_avelocities[NUMVERTEXNORMALS];
static float cl_lasttimewarn = 0.0f;
// expand debugging BBOX particle hulls by this many units.
#define BOX_GAP 0.0f
/*
================
R_LookupColor
@@ -265,9 +262,9 @@ VIEWBEAMS MANAGEMENT
==============================================================
*/
static BEAM *cl_active_beams;
static BEAM *cl_free_beams;
static BEAM *cl_viewbeams = NULL; // beams pool
BEAM *cl_active_beams;
BEAM *cl_free_beams;
BEAM *cl_viewbeams = NULL; // beams pool
/*
@@ -1604,73 +1601,6 @@ void GAME_EXPORT R_RocketTrail( vec3_t start, vec3_t end, int type )
}
}
/*
===============
PM_ParticleLine
draw line from particles
================
*/
static void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel )
{
float len, curdist;
vec3_t diff, pos;
// determine distance
VectorSubtract( end, start, diff );
len = VectorNormalizeLength( diff );
curdist = 0;
while( curdist <= len )
{
VectorMA( start, curdist, diff, pos );
CL_Particle( pos, pcolor, life, 0, zvel );
curdist += 2.0f;
}
}
/*
================
PM_DrawRectangle
================
*/
static void PM_DrawRectangle( const vec3_t tl, const vec3_t bl, const vec3_t tr, const vec3_t br, int pcolor, float life )
{
PM_ParticleLine( tl, bl, pcolor, life, 0 );
PM_ParticleLine( bl, br, pcolor, life, 0 );
PM_ParticleLine( br, tr, pcolor, life, 0 );
PM_ParticleLine( tr, tl, pcolor, life, 0 );
}
/*
================
PM_DrawBBox
================
*/
static void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int pcolor, float life )
{
vec3_t p[8], tmp;
float gap = BOX_GAP;
int i;
for( i = 0; i < 8; i++ )
{
tmp[0] = (i & 1) ? mins[0] - gap : maxs[0] + gap;
tmp[1] = (i & 2) ? mins[1] - gap : maxs[1] + gap ;
tmp[2] = (i & 4) ? mins[2] - gap : maxs[2] + gap ;
VectorAdd( tmp, origin, tmp );
VectorCopy( tmp, p[i] );
}
for( i = 0; i < 6; i++ )
{
PM_DrawRectangle( p[boxpnt[i][1]], p[boxpnt[i][0]], p[boxpnt[i][2]], p[boxpnt[i][3]], pcolor, life );
}
}
/*
================
R_ParticleLine
@@ -1834,6 +1764,25 @@ void GAME_EXPORT R_StreakSplash( const vec3_t pos, const vec3_t dir, int color,
}
}
/*
===============
R_DebugParticle
just for debug purposes
===============
*/
void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b )
{
particle_t *p;
p = R_AllocParticle( NULL );
if( !p ) return;
VectorCopy( pos, p->org );
p->color = R_LookupColor( r, g, b );
p->die = cl.time + 0.01f;
}
/*
===============
CL_Particle

View File

@@ -422,12 +422,14 @@ void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
int event_index;
int i, num_events;
int packet_index;
const event_args_t nullargs = { 0 };
event_args_t args = { 0 };
event_args_t nullargs, args;
entity_state_t *state;
float delay;
int entity_bits;
memset( &nullargs, 0, sizeof( nullargs ));
memset( &args, 0, sizeof( args ));
num_events = MSG_ReadUBitLong( msg, 5 );
if( proto == PROTO_GOLDSRC )
@@ -442,18 +444,16 @@ void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
if( MSG_ReadOneBit( msg ))
{
packet_index = MSG_ReadUBitLong( msg, entity_bits );
if( MSG_ReadOneBit( msg ))
{
if( proto == PROTO_GOLDSRC )
Delta_ReadGSFields( msg, DT_EVENT_T, &nullargs, &args, 0.0f );
else MSG_ReadDeltaEvent( msg, &nullargs, &args );
}
}
else packet_index = -1;
if( MSG_ReadOneBit( msg ))
{
if( proto == PROTO_GOLDSRC )
Delta_ReadGSFields( msg, DT_EVENT_T, &nullargs, &args, 0.0f );
else MSG_ReadDeltaEvent( msg, &nullargs, &args );
}
if( MSG_ReadOneBit( msg ))
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
else delay = 0.0f;

View File

@@ -174,7 +174,7 @@ static qboolean CL_EntityCustomLerp( cl_entity_t *e )
// INTERPOLATION IN GRAVGUNMOD COOP
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
case MOVETYPE_TOSS:
if( cls.legacymode == PROTO_LEGACY && e->model && e->model->type == mod_studio )
if( cls.legacymode && e->model && e->model->type == mod_studio )
return false;
}
@@ -1265,7 +1265,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
// INTERPOLATION IN GRAVGUNMOD COOP
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
else if( cls.legacymode == PROTO_LEGACY && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
else if( cls.legacymode && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
{
if( !CL_InterpolateModel( ent ))
continue;

View File

@@ -34,10 +34,10 @@ GNU General Public License for more details.
#define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
#define TEXT_MSGNAME "TextMessage%i"
static char cl_textbuffer[MAX_TEXTCHANNELS][2048];
static client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS];
char cl_textbuffer[MAX_TEXTCHANNELS][2048];
client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS];
static const dllfunc_t cdll_exports[] =
static dllfunc_t cdll_exports[] =
{
{ "Initialize", (void **)&clgame.dllFuncs.pfnInitialize },
{ "HUD_VidInit", (void **)&clgame.dllFuncs.pfnVidInit },
@@ -80,7 +80,7 @@ static const dllfunc_t cdll_exports[] =
};
// optional exports
static const dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and higher
static dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and higher
{
{ "HUD_GetStudioModelInterface", (void **)&clgame.dllFuncs.pfnGetStudioModelInterface },
{ "HUD_DirectorMessage", (void **)&clgame.dllFuncs.pfnDirectorMessage },
@@ -140,7 +140,11 @@ returns true if thirdperson is enabled
*/
qboolean CL_IsThirdPerson( void )
{
return clgame.dllFuncs.CL_IsThirdPerson() ? true : false;
cl.local.thirdperson = clgame.dllFuncs.CL_IsThirdPerson();
if( cl.local.thirdperson )
return true;
return false;
}
/*
@@ -1015,8 +1019,7 @@ void CL_DrawHUD( int state )
CL_DrawCrosshair ();
CL_DrawCenterPrint ();
clgame.dllFuncs.pfnRedraw( cl.time, cl.intermission );
if( showpause.value )
CL_DrawLoadingOrPaused( cls.pauseIcon );
CL_DrawLoadingOrPaused( cls.pauseIcon );
break;
case CL_LOADING:
CL_DrawLoadingOrPaused( cls.loadingBar );

View File

@@ -30,7 +30,6 @@ GNU General Public License for more details.
#define CL_CONNECTION_RETRIES 10
#define CL_TEST_RETRIES 5
CVAR_DEFINE_AUTO( showpause, "1", 0, "show pause logo when paused" );
CVAR_DEFINE_AUTO( mp_decals, "300", FCVAR_ARCHIVE, "decals limit in multiplayer" );
static CVAR_DEFINE_AUTO( dev_overview, "0", 0, "draw level in overview-mode" );
static CVAR_DEFINE_AUTO( cl_resend, "6.0", 0, "time to resend connect" );
@@ -76,7 +75,7 @@ static CVAR_DEFINE_AUTO( cl_upmax, "1200", FCVAR_ARCHIVE, "max allowed incoming
CVAR_DEFINE_AUTO( cl_lw, "1", FCVAR_ARCHIVE|FCVAR_USERINFO, "enable client weapon predicting" );
CVAR_DEFINE_AUTO( cl_charset, "utf-8", FCVAR_ARCHIVE, "1-byte charset to use (iconv style)" );
CVAR_DEFINE_AUTO( cl_trace_stufftext, "0", FCVAR_ARCHIVE, "enable stufftext (server-to-client console commands) tracing (good for developers)" );
CVAR_DEFINE_AUTO( cl_trace_stufftext, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable stufftext (server-to-client console commands) tracing (good for developers)" );
CVAR_DEFINE_AUTO( cl_trace_messages, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable message names tracing (good for developers)" );
CVAR_DEFINE_AUTO( cl_trace_events, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable events tracing (good for developers)" );
static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" );
@@ -599,7 +598,7 @@ static void CL_CreateCmd( void )
int input_override;
int i, ms;
if( cls.state <= ca_connected || cls.state == ca_cinematic )
if( cls.state < ca_connected || cls.state == ca_cinematic )
return;
// store viewangles in case it's will be freeze
@@ -650,7 +649,7 @@ static void CL_CreateCmd( void )
active = (( cls.signon == SIGNONS ) && !cl.paused && !cls.demoplayback );
Platform_PreCreateMove();
clgame.dllFuncs.CL_CreateMove( host.frametime, cmd, active );
IN_EngineAppendMove( host.frametime, cmd, active );
IN_EngineAppendMove( host.frametime, cmd, active );
CL_PopPMStates();
@@ -680,17 +679,21 @@ static void CL_CreateCmd( void )
void CL_WriteUsercmd( sizebuf_t *msg, int from, int to )
{
const usercmd_t nullcmd = { 0 };
const usercmd_t *f;
usercmd_t *t;
usercmd_t nullcmd;
usercmd_t *f, *t;
Assert( from == -1 || ( from >= 0 && from < MULTIPLAYER_BACKUP ));
Assert( to >= 0 && to < MULTIPLAYER_BACKUP );
if( from == -1 )
{
memset( &nullcmd, 0, sizeof( nullcmd ));
f = &nullcmd;
}
else
{
f = &cl.commands[from].cmd;
}
t = &cl.commands[to].cmd;
@@ -718,8 +721,8 @@ static void CL_WritePacket( void )
qboolean send_command = false;
byte data[MAX_CMD_BUFFER];
int i, from, to, key, size;
int numbackup = 2, maxbackup;
int numcmds, maxcmds;
int numbackup = 2;
int numcmds;
int newcmds;
int cmdnumber;
@@ -727,41 +730,24 @@ static void CL_WritePacket( void )
if( cls.demoplayback || cls.state < ca_connected || cls.state == ca_cinematic )
return;
if( cls.state <= ca_validate )
{
Netchan_TransmitBits( &cls.netchan, 0, "" );
return;
}
CL_ComputePacketLoss ();
memset( data, 0, sizeof( data ));
MSG_Init( &buf, "ClientData", data, sizeof( data ));
// Determine number of backup commands to send along
switch( cls.legacymode )
{
case PROTO_GOLDSRC:
maxbackup = MAX_GOLDSRC_BACKUP_CMDS;
maxcmds = MAX_GOLDSRC_TOTAL_CMDS;
break;
case PROTO_LEGACY:
maxbackup = MAX_LEGACY_BACKUP_CMDS;
maxcmds = MAX_LEGACY_TOTAL_CMDS;
break;
default:
maxbackup = MAX_BACKUP_COMMANDS;
maxcmds = MAX_TOTAL_CMDS;
break;
}
numbackup = bound( 0, cl_cmdbackup.value, maxbackup );
numbackup = bound( 0, cl_cmdbackup.value, cls.legacymode ? MAX_LEGACY_BACKUP_CMDS : MAX_BACKUP_COMMANDS );
if( cls.state == ca_connected ) numbackup = 0;
// clamp cmdrate
if( cl_cmdrate.value < 10.0f )
{
Cvar_DirectSet( &cl_cmdrate, "10" );
}
else if( cl_cmdrate.value > 100.0f )
{
Cvar_DirectSet( &cl_cmdrate, "100" );
}
// Check to see if we can actually send this command
@@ -818,14 +804,14 @@ static void CL_WritePacket( void )
MSG_BeginClientCmd( &buf, clc_move );
if( cls.legacymode == PROTO_GOLDSRC )
MSG_WriteByte( &buf, 0 ); // length
MSG_WriteByte( &buf, 0 );
// save the position for a checksum byte
key = MSG_GetRealBytesWritten( &buf );
MSG_WriteByte( &buf, 0 );
// write packet lossage percentation
MSG_WriteByte( &buf, bound( 0, (int)cls.packet_loss, 100 ) );
MSG_WriteByte( &buf, cls.packet_loss );
// say how many backups we'll be sending
MSG_WriteByte( &buf, numbackup );
@@ -834,10 +820,8 @@ static void CL_WritePacket( void )
newcmds = ( cls.netchan.outgoing_sequence - cls.lastoutgoingcommand );
// put an upper/lower bound on this
newcmds = bound( 0, newcmds, maxcmds );
if( cls.state == ca_connected )
newcmds = 0;
newcmds = bound( 0, newcmds, cls.legacymode ? MAX_LEGACY_TOTAL_CMDS: MAX_TOTAL_CMDS );
if( cls.state == ca_connected ) newcmds = 0;
MSG_WriteByte( &buf, newcmds );
@@ -858,20 +842,16 @@ static void CL_WritePacket( void )
}
// calculate a checksum over the move commands
size = MSG_GetRealBytesWritten( &buf ) - key - 1;
if( cls.legacymode == PROTO_GOLDSRC )
{
size = MSG_GetRealBytesWritten( &buf ) - key - 1;
buf.pData[key - 1] = Q_min( size, 255 );
buf.pData[key] = CRC32_BlockSequence( buf.pData + key + 1, size, cls.netchan.outgoing_sequence );
COM_Munge( buf.pData + key + 1, Q_min( size, 255 ), cls.netchan.outgoing_sequence );
size = Q_min( size, 255 );
buf.pData[key - 1] = size;
}
else
{
size = MSG_GetRealBytesWritten( &buf ) - key - 1;
buf.pData[key] = CRC32_BlockSequence( buf.pData + key + 1, size, cls.netchan.outgoing_sequence );
buf.pData[key] = CRC32_BlockSequence( buf.pData + key + 1, size, cls.netchan.outgoing_sequence );
}
if( cls.legacymode == PROTO_GOLDSRC )
COM_Munge( buf.pData + key + 1, size, cls.netchan.outgoing_sequence );
// message we are constructing.
i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
@@ -1041,62 +1021,6 @@ void CL_Drop( void )
CL_Disconnect();
}
static void CL_GetCDKey( char *protinfo, size_t protinfosize )
{
byte hash[16] = { 0 };
MD5Context_t ctx = { 0 };
char key[64];
int keylength;
keylength = Q_snprintf( key, sizeof( key ), "%u", COM_RandomLong( 0, 0x7fffffff ));
MD5Init( &ctx );
MD5Update( &ctx, key, keylength );
MD5Final( hash, &ctx );
Q_strnlwr( MD5_Print( hash ), key, sizeof( key ));
Info_SetValueForKey( protinfo, "cdkey", key, protinfosize );
}
#include "multi_emulator.h"
static CVAR_DEFINE_AUTO( cl_ticket_generator, "revemu2013", FCVAR_ARCHIVE, "you wouldn't steal a car" );
static size_t CL_GenerateSteamTicket( byte *buf, size_t size )
{
const char *s = ID_GetMD5();
uint32_t crc;
CRC32_Init( &crc );
CRC32_ProcessBuffer( &crc, s, Q_strlen( s ));
crc = CRC32_Final( crc );
if( !Q_stricmp( cl_ticket_generator.string, "revemu2013" ))
return GenerateRevEmu2013( buf, crc );
if( !Q_stricmp( cl_ticket_generator.string, "sc2009" ))
return GenerateSC2009( buf, crc );
if( !Q_stricmp( cl_ticket_generator.string, "oldrevemu" ))
return GenerateOldRevEmu( buf, crc );
if( !Q_stricmp( cl_ticket_generator.string, "steamemu" ))
return GenerateSteamEmu( buf, crc );
if( !Q_stricmp( cl_ticket_generator.string, "revemu" ))
return GenerateRevEmu( buf, crc );
if( !Q_stricmp( cl_ticket_generator.string, "setti" ))
return GenerateSetti( buf );
if( !Q_stricmp( cl_ticket_generator.string, "avsmp" ))
return GenerateAVSMP( buf, crc, true );
Con_Printf( "%s: unknown generator %s, supported are: revemu2003, sc2009, oldrevemu, steamemu, revemu, setti, avsmp\n", __func__, cl_ticket_generator.string );
memset( buf, 0, size );
return size;
}
/*
=======================
CL_SendConnectPacket
@@ -1136,68 +1060,42 @@ static void CL_SendConnectPacket( void )
input_devices = IN_CollectInputDevices();
IN_LockInputDevices( true );
// GoldSrc doesn't need sv_cheats set to 0, it's handled by svc_goldsrc_sendextrainfo
// it also doesn't need useragent string
if( cls.legacymode != PROTO_GOLDSRC )
{
Cvar_SetCheatState();
Cvar_FullSet( "sv_cheats", "0", FCVAR_READ_ONLY | FCVAR_SERVER );
Cvar_SetCheatState();
Cvar_FullSet( "sv_cheats", "0", FCVAR_READ_ONLY | FCVAR_SERVER );
Info_SetValueForKeyf( protinfo, "d", sizeof( protinfo ), "%d", input_devices );
Info_SetValueForKey( protinfo, "v", XASH_VERSION, sizeof( protinfo ) );
Info_SetValueForKeyf( protinfo, "b", sizeof( protinfo ), "%d", Q_buildnum( ));
Info_SetValueForKey( protinfo, "o", Q_buildos(), sizeof( protinfo ) );
Info_SetValueForKey( protinfo, "a", Q_buildarch(), sizeof( protinfo ) );
}
Info_SetValueForKeyf( protinfo, "d", sizeof( protinfo ), "%d", input_devices );
Info_SetValueForKey( protinfo, "v", XASH_VERSION, sizeof( protinfo ) );
Info_SetValueForKeyf( protinfo, "b", sizeof( protinfo ), "%d", Q_buildnum( ));
Info_SetValueForKey( protinfo, "o", Q_buildos(), sizeof( protinfo ) );
Info_SetValueForKey( protinfo, "a", Q_buildarch(), sizeof( protinfo ) );
}
if( cls.legacymode == PROTO_GOLDSRC )
{
byte send_buf[1024];
byte send_buf[MAX_PRINT_MSG];
byte steam_cert[512];
string new_name;
const char *name;
size_t steam_cert_len;
sizebuf_t send;
protinfo[0] = 0;
steam_cert_len = CL_GenerateSteamTicket( steam_cert, sizeof( steam_cert ));
memset( steam_cert, 0, sizeof( steam_cert ));
Info_SetValueForKey( protinfo, "prot", "3", sizeof( protinfo )); // steam auth type
Info_SetValueForKeyf( protinfo, "unique", sizeof( protinfo ), "%i", 0xffffffff );
Info_SetValueForKey( protinfo, "raw", "steam", sizeof( protinfo ));
CL_GetCDKey( protinfo, sizeof( protinfo ));
Info_SetValueForKey( protinfo, "cdkey", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", sizeof( protinfo ));
// remove keys set for legacy protocol
Info_RemoveKey( cls.userinfo, "cl_maxpacket" );
Info_RemoveKey( cls.userinfo, "cl_maxpayload" );
name = Info_ValueForKey( cls.userinfo, "name" );
if( Q_strnicmp( name, "[Xash3D]", 8 ))
{
Q_snprintf( new_name, sizeof( new_name ), "[Xash3D]%s", name );
Info_SetValueForKey( cls.userinfo, "name", new_name, sizeof( cls.userinfo ));
}
Info_SetValueForStarKey( cls.userinfo, "*hltv", "0", sizeof( cls.userinfo ));
MSG_Init( &send, "GoldSrcConnect", send_buf, sizeof( send_buf ));
MSG_WriteLong( &send, NET_HEADER_OUTOFBANDPACKET );
MSG_WriteStringf( &send, "connect %i %i \"%s\" \"%s\"\n",
PROTOCOL_GOLDSRC_VERSION, cls.challenge, protinfo, cls.userinfo );
MSG_SeekToBit( &send, -8, SEEK_CUR ); // rewrite null terminator
MSG_WriteBytes( &send, steam_cert, steam_cert_len );
if( MSG_CheckOverflow( &send ))
Con_Printf( S_ERROR "%s: %s overflow!\n", __func__, MSG_GetName( &send ) );
MSG_WriteBytes( &send, steam_cert, sizeof( steam_cert ));
NET_SendPacket( NS_CLIENT, MSG_GetNumBytesWritten( &send ), MSG_GetData( &send ), adr );
Con_Printf( "Trying to connect with GoldSrc 48 protocol\n" );
}
else if( cls.legacymode == PROTO_LEGACY )
{
// reset nickname from cvar value
Info_SetValueForKey( cls.userinfo, "name", name.string, sizeof( cls.userinfo ));
// set related userinfo keys
if( cl_dlmax.value >= 40000 || cl_dlmax.value < 100 )
Info_SetValueForKey( cls.userinfo, "cl_maxpacket", "1400", sizeof( cls.userinfo ) );
@@ -1211,19 +1109,15 @@ static void CL_SendConnectPacket( void )
Netchan_OutOfBandPrint( NS_CLIENT, adr, "connect %i %i %i \"%s\" %d \"%s\"\n",
PROTOCOL_LEGACY_VERSION, Q_atoi( qport ), cls.challenge, cls.userinfo, NET_LEGACY_EXT_SPLIT, protinfo );
Con_Printf( "Trying to connect with legacy protocol\n" );
Con_Printf( "Trying to connect by legacy protocol\n" );
}
else
{
int extensions = NET_EXT_SPLITSIZE;
// reset nickname from cvar value
Info_SetValueForKey( cls.userinfo, "name", name.string, sizeof( cls.userinfo ));
if( cl_dlmax.value > FRAGMENT_MAX_SIZE || cl_dlmax.value < FRAGMENT_MIN_SIZE )
Cvar_SetValue( "cl_dlmax", FRAGMENT_DEFAULT_SIZE );
// remove keys set for legacy protocol
Info_RemoveKey( cls.userinfo, "cl_maxpacket" );
Info_RemoveKey( cls.userinfo, "cl_maxpayload" );
@@ -1232,7 +1126,7 @@ static void CL_SendConnectPacket( void )
Info_SetValueForKeyf( protinfo, "ext", sizeof( protinfo ), "%d", extensions);
Netchan_OutOfBandPrint( NS_CLIENT, adr, "connect %i %i \"%s\" \"%s\"\n", PROTOCOL_VERSION, cls.challenge, protinfo, cls.userinfo );
Con_Printf( "Trying to connect with modern protocol\n" );
Con_Printf( "Trying to connect by modern protocol\n" );
}
cls.timestart = Sys_DoubleTime();
@@ -1254,14 +1148,6 @@ static int CL_GetTestFragmentSize( void )
return FRAGMENT_MIN_SIZE;
}
static void CL_SendGetChallenge( netadr_t to, connprotocol_t proto )
{
if( proto == PROTO_GOLDSRC )
Netchan_OutOfBandPrint( NS_CLIENT, to, "getchallenge steam\n" );
else
Netchan_OutOfBandPrint( NS_CLIENT, to, "getchallenge\n" );
}
/*
=================
CL_CheckForResend
@@ -1275,7 +1161,7 @@ static void CL_CheckForResend( void )
net_gai_state_t res;
float resendTime;
qboolean bandwidthTest;
if( cls.internetservers_wait )
CL_SendMasterServerScanRequest();
@@ -1301,7 +1187,7 @@ static void CL_CheckForResend( void )
else if( cl_resend.value > CL_MAX_RESEND_TIME )
Cvar_SetValue( "cl_resend", CL_MAX_RESEND_TIME );
bandwidthTest = cls.legacymode == PROTO_CURRENT && cl_test_bandwidth.value && cls.connect_retry <= CL_TEST_RETRIES;
bandwidthTest = !cls.legacymode && cl_test_bandwidth.value && cls.connect_retry <= CL_TEST_RETRIES;
resendTime = bandwidthTest ? 1.0f : cl_resend.value;
if(( host.realtime - cls.connect_time ) < resendTime )
@@ -1336,7 +1222,7 @@ static void CL_CheckForResend( void )
// too many fails use default connection method
Con_Printf( "Bandwidth test failed, fallback to default connecting method\n" );
Con_Printf( "Connecting to %s... (retry #%i)\n", cls.servername, cls.connect_retry + 1 );
CL_SendGetChallenge( adr, cls.legacymode );
Netchan_OutOfBandPrint( NS_CLIENT, adr, "getchallenge\n" );
Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE );
cls.connect_time = host.realtime;
cls.connect_retry++;
@@ -1356,7 +1242,7 @@ static void CL_CheckForResend( void )
if( bandwidthTest )
Netchan_OutOfBandPrint( NS_CLIENT, adr, "bandwidth %i %i\n", PROTOCOL_VERSION, cls.max_fragment_size );
else
CL_SendGetChallenge( adr, cls.legacymode );
Netchan_OutOfBandPrint( NS_CLIENT, adr, "getchallenge\n" );
}
static resource_t *CL_AddResource( resourcetype_t type, const char *name, int size, qboolean bFatalIfMissing, int index )
@@ -1434,16 +1320,16 @@ static void CL_Connect_f( void )
{
const char *s = Cmd_Argv( 2 );
if( !Q_stricmp( s, "current" ) || !Q_strcmp( s, "49" ))
if( !Q_strcmp( s, "current" ) || !Q_strcmp( s, "49" ))
proto = PROTO_CURRENT;
else if( !Q_stricmp( s, "legacy" ) || !Q_strcmp( s, "48" ))
else if( !Q_strcmp( s, "legacy" ) || !Q_strcmp( s, "48" ))
proto = PROTO_LEGACY;
else if( !Q_stricmp( s, "goldsrc" ) || !Q_strcmp( s, "gs" ))
else if( !Q_strcmp( s, "goldsrc" ))
proto = PROTO_GOLDSRC;
else
{
// quake protocol only used for demos
Con_Printf( "Unknown protocol. Supported are: 49 (current), 48 (legacy), gs (goldsrc)\n" );
Con_Printf( "Unknown protocol. Supported are: current, legacy, goldsrc\n" );
return;
}
}
@@ -1591,7 +1477,7 @@ CL_SendDisconnectMessage
Sends a disconnect message to the server
=====================
*/
static void CL_SendDisconnectMessage( connprotocol_t proto )
static void CL_SendDisconnectMessage( void )
{
sizebuf_t buf;
byte data[32];
@@ -1600,9 +1486,7 @@ static void CL_SendDisconnectMessage( connprotocol_t proto )
MSG_Init( &buf, "LastMessage", data, sizeof( data ));
MSG_BeginClientCmd( &buf, clc_stringcmd );
if( proto == PROTO_GOLDSRC )
MSG_WriteString( &buf, "dropclient\n" );
else MSG_WriteString( &buf, "disconnect" );
MSG_WriteString( &buf, "disconnect" );
if( !cls.netchan.remote_address.type )
cls.netchan.remote_address.type = NA_LOOPBACK;
@@ -1642,24 +1526,26 @@ static void CL_Reconnect( qboolean setup_netchan )
{
uint flags = 0;
switch( cls.legacymode )
if( cls.legacymode == PROTO_GOLDSRC )
{
case PROTO_GOLDSRC:
SetBits( flags, NETCHAN_USE_MUNGE | NETCHAN_USE_BZIP2 | NETCHAN_GOLDSRC );
break;
case PROTO_LEGACY:
if( FBitSet( Q_atoi( Cmd_Argv( 1 )), NET_LEGACY_EXT_SPLIT ))
}
else if( cls.legacymode == PROTO_LEGACY )
{
unsigned int extensions = Q_atoi( Cmd_Argv( 1 ) );
if( FBitSet( extensions, NET_LEGACY_EXT_SPLIT ))
{
SetBits( flags, NETCHAN_USE_LEGACY_SPLIT );
Con_Reportf( "^2NET_EXT_SPLIT enabled^7 (packet sizes is %d/%d)\n", (int)cl_dlmax.value, 65536 );
}
break;
default:
}
else
{
cls.extensions = Q_atoi( Info_ValueForKey( Cmd_Argv( 1 ), "ext" ));
if( FBitSet( cls.extensions, NET_EXT_SPLITSIZE ))
Con_Reportf( "^2NET_EXT_SPLITSIZE enabled^7 (packet size is %d)\n", (int)cl_dlmax.value );
break;
}
Netchan_Setup( NS_CLIENT, &cls.netchan, net_from, Cvar_VariableInteger( "net_qport" ), NULL, CL_GetFragmentSize, flags );
@@ -1697,6 +1583,8 @@ This is also called on Host_Error, so it shouldn't cause any errors
*/
void CL_Disconnect( void )
{
cls.legacymode = PROTO_CURRENT;
if( cls.state == ca_disconnected )
return;
@@ -1707,7 +1595,7 @@ void CL_Disconnect( void )
CL_Stop_f();
// send a disconnect message to the server
CL_SendDisconnectMessage( cls.legacymode );
CL_SendDisconnectMessage();
CL_ClearState ();
S_StopBackgroundTrack ();
@@ -1723,7 +1611,6 @@ void CL_Disconnect( void )
cls.set_lastdemo = false;
cls.connect_retry = 0;
cls.signon = 0;
cls.legacymode = PROTO_CURRENT;
// back to menu in non-developer mode
if( host_developer.value || cls.key_dest == key_menu )
@@ -1751,7 +1638,7 @@ void CL_Crashed( void )
CL_Stop_f(); // stop any demos
// send a disconnect message to the server
CL_SendDisconnectMessage( cls.legacymode );
CL_SendDisconnectMessage();
Host_WriteOpenGLConfig();
Host_WriteConfig(); // write config
@@ -1815,7 +1702,7 @@ static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, u
Q_snprintf( temp, sizeof( temp ), "%d", Q_buildnum() );
Info_SetValueForKey( info, "buildnum", temp, remaining );
Q_snprintf( temp, sizeof( temp ), "%x", *key );
Info_SetValueForKey( info, "key", temp, remaining );
@@ -2249,14 +2136,6 @@ static void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
Cbuf_AddText( args );
Cbuf_AddText( "\n" );
}
else if( c[0] == 'l' )
{
char *s = args + 1;
Con_Printf( S_CYAN "r:" S_DEFAULT " %s", s );
if( !COM_CheckStringEmpty( s ) || s[Q_strlen( s ) - 1] != '\n' )
Con_Printf( "\n" );
}
else if( !Q_strcmp( c, "print" ))
{
// print command from somewhere
@@ -2290,7 +2169,7 @@ static void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
{
// too many fails use default connection method
Con_Printf( "hi-speed connection is failed, use default method\n" );
CL_SendGetChallenge( from, cls.legacymode );
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
Cvar_SetValue( "cl_dlmax", FRAGMENT_DEFAULT_SIZE );
cls.connect_time = host.realtime;
return;
@@ -2312,7 +2191,7 @@ static void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
// packet was sucessfully delivered, adjust the fragment size and get challenge
Con_DPrintf( "CRC %x is matched, get challenge, fragment size %d\n", crcValue, cls.max_fragment_size );
CL_SendGetChallenge( from, cls.legacymode );
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
Cvar_SetValue( "cl_dlmax", cls.max_fragment_size );
cls.connect_time = host.realtime;
}
@@ -2322,7 +2201,7 @@ static void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
{
// too many fails use default connection method
Con_Printf( "hi-speed connection is failed, use default method\n" );
CL_SendGetChallenge( from, cls.legacymode );
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE );
cls.connect_time = host.realtime;
return;
@@ -2392,8 +2271,6 @@ static void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
// in case we're in console or it's classic mainui which doesn't support messageboxes
if( !UI_IsVisible() || !UI_ShowMessageBox( formatted_msg ))
Msg( "%s\n", formatted_msg );
CL_Disconnect_f();
}
else if( !Q_strcmp( c, "updatemsg" ))
{
@@ -2785,11 +2662,10 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
Con_Printf( S_ERROR "server failed to transmit file '%s'\n", CL_CleanFileName( filename ));
}
if( cls.legacymode == PROTO_LEGACY )
if( cls.legacymode )
{
if( host.downloadcount > 0 )
host.downloadcount--;
if( !host.downloadcount )
{
MSG_WriteByte( &cls.netchan.message, clc_stringcmd );
@@ -2934,26 +2810,17 @@ tell server about changed userinfo
*/
void CL_UpdateInfo( const char *key, const char *value )
{
switch( cls.legacymode )
if( !cls.legacymode )
{
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", key, value );
}
else
{
case PROTO_LEGACY:
if( cls.state != ca_active )
break;
return;
MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
break;
case PROTO_GOLDSRC:
if( !Q_stricmp( key, "name" ) && Q_strnicmp( value, "[Xash3D]", 8 ))
{
// always prepend [Xash3D] on GoldSrc protocol :)
CL_ServerCommand( true, "setinfo \"%s\" \"[Xash3D]%s\"\n", key, value );
break;
}
// intentional fallthrough
default:
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", key, value );
break;
}
}
@@ -3232,9 +3099,6 @@ static void CL_InitLocal( void )
cl.resourcesneeded.pNext = cl.resourcesneeded.pPrev = &cl.resourcesneeded;
cl.resourcesonhand.pNext = cl.resourcesonhand.pPrev = &cl.resourcesonhand;
Cvar_RegisterVariable( &cl_ticket_generator );
Cvar_RegisterVariable( &showpause );
Cvar_RegisterVariable( &mp_decals );
Cvar_RegisterVariable( &dev_overview );
Cvar_RegisterVariable( &cl_resend );

View File

@@ -63,9 +63,9 @@ static byte netcolors[NETGRAPH_NET_COLORS+NETGRAPH_LERP_HEIGHT][4] =
// other will be generated through NetGraph_InitColors()
};
static const byte sendcolor[4] = { 88, 29, 130, 255 };
static const byte holdcolor[4] = { 255, 0, 0, 200 };
static const byte extrap_base_color[4] = { 255, 255, 255, 255 };
static byte sendcolor[4] = { 88, 29, 130, 255 };
static byte holdcolor[4] = { 255, 0, 0, 200 };
static byte extrap_base_color[4] = { 255, 255, 255, 255 };
static netbandwidthgraph_t netstat_graph[NET_TIMINGS];
static float packet_loss;
static float packet_choke;
@@ -79,7 +79,7 @@ NetGraph_DrawRect
NetGraph_FillRGBA shortcut
==========
*/
static void NetGraph_DrawRect( const wrect_t *rect, const byte colors[4] )
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
{
ref.dllFuncs.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad

View File

@@ -156,7 +156,7 @@ void CL_ParseRestoreSoundPacket( sizebuf_t *msg )
char sentenceName[32];
if( flags & SND_SEQUENCE )
Q_snprintf( sentenceName, sizeof( sentenceName ), "!#%i", sound + MAX_SOUNDS_NONSENTENCE );
Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound + MAX_SOUNDS_NONSENTENCE );
else Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
handle = S_RegisterSound( sentenceName );
@@ -181,14 +181,14 @@ CL_ParseServerTime
==================
*/
void CL_ParseServerTime( sizebuf_t *msg, connprotocol_t proto )
void CL_ParseServerTime( sizebuf_t *msg )
{
double dt;
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat( msg );
if( proto == PROTO_QUAKE )
if( cls.legacymode == PROTO_QUAKE )
return; // don't mess the time
if( cl.maxclients == 1 )
@@ -264,7 +264,7 @@ CL_ParseParticles
==================
*/
void CL_ParseParticles( sizebuf_t *msg, connprotocol_t proto )
void CL_ParseParticles( sizebuf_t *msg )
{
vec3_t org, dir;
int i, count, color;
@@ -277,12 +277,8 @@ void CL_ParseParticles( sizebuf_t *msg, connprotocol_t proto )
count = MSG_ReadByte( msg );
color = MSG_ReadByte( msg );
if( count == 255 )
count = 1024;
if( proto == PROTO_GOLDSRC )
life = 0.0f;
else life = MSG_ReadByte( msg ) * 0.125f;
if( count == 255 ) count = 1024;
life = MSG_ReadByte( msg ) * 0.125f;
if( life != 0.0f && count == 1 )
{
@@ -308,7 +304,7 @@ CL_ParseStaticEntity
static client entity
==================
*/
static void CL_ParseStaticEntity( sizebuf_t *msg )
void CL_ParseStaticEntity( sizebuf_t *msg )
{
int i, newnum;
entity_state_t from, to;
@@ -791,9 +787,7 @@ void CL_ParseResourceRequest( sizebuf_t *msg )
MSG_WriteBytes( &sbuf, cl.resourcelist[i].rgucMD5_hash, 16 );
}
// a1ba: useless check? MSG_BeginClientCmd and MSG_WriteShort will always
// write to the buffer
// if( MSG_GetNumBytesWritten( &sbuf ) > 0 )
if( MSG_GetNumBytesWritten( &sbuf ) > 0 )
{
Netchan_CreateFragments( &cls.netchan, &sbuf );
Netchan_FragSend( &cls.netchan );
@@ -856,7 +850,7 @@ void CL_ParseServerData( sizebuf_t *msg, connprotocol_t proto )
char gamefolder[MAX_QPATH];
string mapfile;
qboolean background;
int i, required_version;
int i;
uint32_t mapCRC;
HPAK_CheckSize( hpk_custom_file.string );
@@ -864,15 +858,12 @@ void CL_ParseServerData( sizebuf_t *msg, connprotocol_t proto )
switch( proto )
{
case PROTO_LEGACY:
required_version = PROTOCOL_LEGACY_VERSION;
Con_Reportf( "Legacy serverdata packet received.\n" );
break;
case PROTO_GOLDSRC:
required_version = PROTOCOL_GOLDSRC_VERSION;
Con_Reportf( "GoldSrc serverdata packet received.\n" );
break;
default:
required_version = PROTOCOL_VERSION;
Con_Reportf( "Serverdata packet received.\n" );
break;
}
@@ -891,34 +882,34 @@ void CL_ParseServerData( sizebuf_t *msg, connprotocol_t proto )
// parse protocol version number
i = MSG_ReadLong( msg );
if( i != required_version ) // GoldSrc protocol version is 48, same as Xash3D 48
Host_Error( "Server use invalid protocol (%i should be %i)\n", i, required_version );
if( proto == PROTO_LEGACY || proto == PROTO_GOLDSRC ) // GoldSrc protocol version is 48, same as Xash3D 48
{
if( i != PROTOCOL_LEGACY_VERSION )
Host_Error( "Server use invalid protocol (%i should be %i)\n", i, PROTOCOL_LEGACY_VERSION );
}
else
{
if( i != PROTOCOL_VERSION )
Host_Error( "Server use invalid protocol (%i should be %i)\n", i, PROTOCOL_VERSION );
}
cl.servercount = MSG_ReadLong( msg );
cl.checksum = MSG_ReadLong( msg );
if( proto == PROTO_GOLDSRC )
{
byte clientdllmd5[16];
const char *s;
byte unused;
MSG_ReadBytes( msg, clientdllmd5, sizeof( clientdllmd5 ));
cl.maxclients = MSG_ReadByte( msg );
cl.playernum = MSG_ReadByte( msg );
COM_UnMunge3((byte *)&cl.checksum, sizeof( cl.checksum ), ( 0xff - cl.playernum ) & 0xff );
MSG_SeekToBit( msg, sizeof( uint8_t ) << 3, SEEK_CUR ); // quake leftover, coop flag
unused = MSG_ReadByte( msg ); // coop flag
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
Con_Printf( "Remote host: %s\n", MSG_ReadString( msg ));
Q_strncpy( clgame.mapname, COM_FileWithoutPath( MSG_ReadString( msg )), sizeof( clgame.mapname ));
COM_StripExtension( clgame.mapname );
s = MSG_ReadString( msg );
if( COM_CheckStringEmpty( s ))
Con_Printf( "Server map cycle: %s\n", s ); // VALVEWHY?
if( MSG_ReadByte( msg ))
Con_Printf( "Uh, server says it's VAC2 secured.\n" );
MSG_ReadString( msg ); // hostname
Q_strncpy( clgame.mapname, MSG_ReadString( msg ), sizeof( clgame.mapname ));
MSG_ReadString( msg ); // mapcycle?????
unused = MSG_ReadByte( msg ); // vac secure
background = false;
clgame.maxEntities = GI->max_edicts + (( cl.maxclients - 1 ) * 15 );
@@ -947,7 +938,7 @@ void CL_ParseServerData( sizebuf_t *msg, connprotocol_t proto )
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
Host_ValidateEngineFeatures( MSG_ReadDword( msg ));
if( proto != PROTO_LEGACY )
if( proto == PROTO_LEGACY )
{
// receive the player hulls
for( i = 0; i < MAX_MAP_HULLS * 3; i++ )
@@ -1232,6 +1223,9 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto )
Delta_InitClient (); // finalize client delta's
if( proto == PROTO_GOLDSRC )
MSG_StartBitWriting( msg );
while( 1 )
{
cl_entity_t *ent;
@@ -1269,6 +1263,7 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto )
if( proto == PROTO_GOLDSRC )
{
int type = MSG_ReadUBitLong( msg, 2 );
int bits = MSG_GetNumBitsWritten( msg );
int delta_type;
if( player ) delta_type = DT_ENTITY_STATE_PLAYER_T;
@@ -1276,7 +1271,6 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto )
else delta_type = DT_ENTITY_STATE_T;
Delta_ReadGSFields( msg, delta_type, &ent->prevstate, &ent->baseline, 1.0f );
ent->baseline.entityType = type;
}
else MSG_ReadDeltaEntity( msg, &nullstate, &ent->baseline, newnum, player, 1.0f );
@@ -1301,6 +1295,9 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto )
}
}
}
if( proto == PROTO_GOLDSRC )
MSG_EndBitWriting( msg );
}
/*
@@ -1411,14 +1408,14 @@ CL_RegisterUserMessage
register new user message or update existing
================
*/
void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto )
void CL_RegisterUserMessage( sizebuf_t *msg )
{
char *pszName;
char *pszName;
int svc_num, size, bits;
svc_num = MSG_ReadByte( msg );
if( proto == PROTO_LEGACY || proto == PROTO_GOLDSRC )
if( cls.legacymode )
{
size = MSG_ReadByte( msg );
bits = 8;
@@ -1429,16 +1426,7 @@ void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto )
bits = 16;
}
if( proto == PROTO_GOLDSRC )
{
static char szName[17];
MSG_ReadBytes( msg, szName, sizeof( szName ) - 1 );
szName[16] = 0;
pszName = szName;
}
else pszName = MSG_ReadString( msg );
pszName = MSG_ReadString( msg );
// important stuff
if( size == ( BIT( bits ) - 1 ) )
@@ -1595,7 +1583,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
}
}
static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
static void CL_SendConsistencyInfo( sizebuf_t *msg )
{
qboolean user_changed_diskfile;
vec3_t mins, maxs;
@@ -1603,24 +1591,16 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
CRC32_t crcFile;
byte md5[16];
consistency_t *pc;
int i, pos;
int i;
if( !cl.need_force_consistency_response )
return;
cl.need_force_consistency_response = false;
MSG_BeginClientCmd( msg, clc_fileconsistency );
pos = MSG_GetNumBytesWritten( msg );
if( proto == PROTO_GOLDSRC )
{
MSG_WriteShort( msg, 0 );
MSG_StartBitWriting( msg );
}
for( i = 0; i < cl.num_consistency; i++ )
{
qboolean have_file = true;
pc = &cl.consistency_list[i];
user_changed_diskfile = false;
@@ -1631,10 +1611,7 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
Q_snprintf( filename, sizeof( filename ), DEFAULT_SOUNDPATH "%s", pc->filename );
else Q_strncpy( filename, pc->filename, sizeof( filename ));
COM_FixSlashes( filename );
have_file = FS_FileExists( filename, false );
if( Q_strstr( filename, "models/" ) && have_file )
if( Q_strstr( filename, "models/" ))
{
CRC32_Init( &crcFile );
CRC32_File( &crcFile, filename );
@@ -1653,37 +1630,12 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
MSG_WriteUBitLong( msg, 0, 32 );
else MSG_WriteUBitLong( msg, pc->value, 32 );
break;
case force_model_specifybounds_if_avail:
if( have_file )
{
if( !Mod_GetStudioBounds( filename, mins, maxs ))
Host_Error( "unable to find %s\n", filename );
if( user_changed_diskfile )
{
VectorSet( mins, -9999.9f, -9999.9f, -9999.9f );
VectorSet( maxs, 9999.9f, 9999.9f, 9999.9f );
}
}
else
{
VectorSet( mins, -1.0f, -1.0f, -1.0f );
VectorCopy( mins, maxs );
}
MSG_WriteBytes( msg, mins, 12 );
MSG_WriteBytes( msg, maxs, 12 );
break;
case force_model_samebounds:
case force_model_specifybounds:
if( !Mod_GetStudioBounds( filename, mins, maxs ))
Host_Error( "unable to find %s\n", filename );
if( user_changed_diskfile )
{
VectorSet( mins, -9999.9f, -9999.9f, -9999.9f );
VectorSet( maxs, 9999.9f, 9999.9f, 9999.9f );
}
ClearBounds( maxs, mins ); // g-cont. especially swapped
MSG_WriteBytes( msg, mins, 12 );
MSG_WriteBytes( msg, maxs, 12 );
break;
@@ -1694,17 +1646,6 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
}
MSG_WriteOneBit( msg, 0 );
if( proto == PROTO_GOLDSRC )
{
int len;
MSG_EndBitWriting( msg );
len = MSG_GetNumBytesWritten( msg ) - pos - 2;
*(short *)&msg->pData[pos] = len;
COM_Munge( &msg->pData[pos + 2], len, cl.servercount );
}
}
/*
@@ -1762,7 +1703,7 @@ void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto )
}
if( !cls.demoplayback )
CL_SendConsistencyInfo( msg, proto );
CL_SendConsistencyInfo( msg );
// All done precaching.
cl.worldmodel = CL_ModelHandle( 1 ); // get world pointer
@@ -1880,11 +1821,7 @@ static void CL_ParseConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
pc->value = 0;
if( pResource->type == t_model && memcmp( nullbuffer, pResource->rguc_reserved, 32 ))
{
if( proto == PROTO_GOLDSRC )
COM_UnMunge( pResource->rguc_reserved, sizeof( pResource->rguc_reserved ), cl.servercount );
pc->check_type = pResource->rguc_reserved[0];
}
skip_crc_change = pResource;
lastcheck = delta;
@@ -1948,29 +1885,15 @@ CL_ParseVoiceData
==================
*/
void CL_ParseVoiceData( sizebuf_t *msg, connprotocol_t proto )
void CL_ParseVoiceData( sizebuf_t *msg )
{
int size, idx, frames;
byte received[8192];
idx = MSG_ReadByte( msg ) + 1;
if( proto == PROTO_GOLDSRC )
{
size = MSG_ReadShort( msg );
MSG_SeekToBit( msg, size << 3, SEEK_CUR ); // skip the entire buf, not supported yet
#if 0 // shall we notify client.dll if nothing can be heard?
// must notify through as both local player and normal client
if( idx == cl.playernum + 1 )
Voice_StatusAck( &voice.local, VOICE_LOOPBACK_INDEX );
Voice_StatusAck( &voice.players_status[idx], idx );
#endif
return;
}
frames = MSG_ReadByte( msg );
size = MSG_ReadShort( msg );
size = Q_min( size, sizeof( received ));
@@ -2159,7 +2082,7 @@ and sent it back to the server
*/
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto )
{
const char *cvarName, *response = NULL;
const char *cvarName, *response;
convar_t *cvar;
int requestID;
@@ -2167,51 +2090,37 @@ void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t
requestID = MSG_ReadLong( msg );
cvarName = MSG_ReadString( msg );
cvar = Cvar_FindVar( cvarName );
if( proto == PROTO_GOLDSRC )
if( cvar )
{
if( !Q_stricmp( cvarName, "sv_version" ))
response = "1.1.2.2/Stdio,48,10211";
}
if( !response )
{
cvar = Cvar_FindVar( cvarName );
if( cvar )
{
if( cvar->flags & FCVAR_PRIVILEGED )
response = "CVAR is privileged";
else if( cvar->flags & FCVAR_SERVER )
response = "CVAR is server-only";
else if( cvar->flags & FCVAR_PROTECTED )
response = "CVAR is protected";
else
response = cvar->string;
}
else if( proto == PROTO_LEGACY )
{
response = "Not Found";
}
if( cvar->flags & FCVAR_PRIVILEGED )
response = "CVAR is privileged";
else if( cvar->flags & FCVAR_SERVER )
response = "CVAR is server-only";
else if( cvar->flags & FCVAR_PROTECTED )
response = "CVAR is protected";
else
{
response = "Bad CVAR request";
}
response = cvar->string;
}
else if( proto == PROTO_LEGACY )
{
response = "Not Found";
}
else
{
response = "Bad CVAR request";
}
if( ext )
{
int clc_msg = proto == PROTO_GOLDSRC ? clc_goldsrc_requestcvarvalue2 : clc_requestcvarvalue2;
MSG_BeginClientCmd( &cls.netchan.message, clc_msg );
MSG_BeginClientCmd( &cls.netchan.message, clc_requestcvarvalue2 );
MSG_WriteLong( &cls.netchan.message, requestID );
MSG_WriteString( &cls.netchan.message, cvarName );
}
else
{
int clc_msg = proto == PROTO_GOLDSRC ? clc_goldsrc_requestcvarvalue : clc_requestcvarvalue;
MSG_BeginClientCmd( &cls.netchan.message, clc_msg );
MSG_BeginClientCmd( &cls.netchan.message, clc_requestcvarvalue );
}
MSG_WriteString( &cls.netchan.message, response );
}
@@ -2309,7 +2218,7 @@ CL_ParseUserMessage
handles all user messages
==============
*/
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num, connprotocol_t proto )
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
{
byte pbuf[MAX_USERMSG_LENGTH];
int i, iSize;
@@ -2349,7 +2258,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num, connprotocol_t proto )
// message with variable sizes receive an actual size as first byte
if( iSize == -1 )
{
if( proto == PROTO_GOLDSRC || proto == PROTO_LEGACY )
if( cls.legacymode )
iSize = MSG_ReadByte( msg );
else iSize = MSG_ReadWord( msg );
}
@@ -2397,54 +2306,6 @@ ACTION MESSAGES
=====================================================================
*/
/*
============
CL_ParseCommonDLLMessage
parse a message which structure is enforced by DLL compatibility
it should always be the same regardless of protocol used
============
*/
qboolean CL_ParseCommonDLLMessage( sizebuf_t *msg, connprotocol_t proto, int svc_num, int startoffset )
{
int param1, param2;
switch( svc_num )
{
case svc_temp_entity:
CL_ParseTempEntity( msg, proto ); // need protocol because message header differs
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - startoffset;
break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_cdtrack:
param1 = MSG_ReadByte( msg );
param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum
param2 = MSG_ReadByte( msg );
param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum
S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false );
break;
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_director:
CL_ParseDirector( msg );
break;
default:
return false;
}
return true;
}
/*
=====================
CL_ParseServerMessage
@@ -2455,7 +2316,7 @@ dispatch messages
void CL_ParseServerMessage( sizebuf_t *msg )
{
size_t bufStart, playerbytes;
int cmd;
int cmd, param1, param2;
int old_background;
const char *s;
@@ -2480,9 +2341,6 @@ void CL_ParseServerMessage( sizebuf_t *msg )
// record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart );
if( CL_ParseCommonDLLMessage( msg, PROTO_CURRENT, cmd, bufStart ))
continue;
// other commands
switch( cmd )
{
@@ -2546,7 +2404,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_time:
CL_ParseServerTime( msg, PROTO_CURRENT );
CL_ParseServerTime( msg );
break;
case svc_print:
Con_Printf( "%s", MSG_ReadString( msg ));
@@ -2594,7 +2452,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
CL_UpdateUserPings( msg );
break;
case svc_particle:
CL_ParseParticles( msg, PROTO_CURRENT );
CL_ParseParticles( msg );
break;
case svc_restoresound:
CL_ParseRestoreSoundPacket( msg );
@@ -2610,6 +2468,10 @@ void CL_ParseServerMessage( sizebuf_t *msg )
case svc_spawnbaseline:
CL_ParseBaseline( msg, PROTO_CURRENT );
break;
case svc_temp_entity:
CL_ParseTempEntity( msg, PROTO_CURRENT );
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_setpause:
cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
break;
@@ -2619,23 +2481,42 @@ void CL_ParseServerMessage( sizebuf_t *msg )
case svc_centerprint:
CL_CenterPrint( MSG_ReadString( msg ), 0.25f );
break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_finale:
CL_ParseFinaleCutscene( msg, 2 );
break;
case svc_cdtrack:
param1 = MSG_ReadByte( msg );
param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum
param2 = MSG_ReadByte( msg );
param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum
S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false );
break;
case svc_restore:
CL_ParseRestore( msg );
break;
case svc_cutscene:
CL_ParseFinaleCutscene( msg, 3 );
break;
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_bspdecal:
CL_ParseStaticDecal( msg );
break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_addangle:
CL_ParseAddAngle( msg );
break;
case svc_usermessage:
CL_RegisterUserMessage( msg, PROTO_CURRENT );
CL_RegisterUserMessage( msg );
break;
case svc_packetentities:
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_CURRENT );
@@ -2675,11 +2556,14 @@ void CL_ParseServerMessage( sizebuf_t *msg )
case svc_hltv:
CL_ParseHLTV( msg );
break;
case svc_director:
CL_ParseDirector( msg );
break;
case svc_voiceinit:
CL_ParseVoiceInit( msg );
break;
case svc_voicedata:
CL_ParseVoiceData( msg, PROTO_CURRENT );
CL_ParseVoiceData( msg );
cl.frames[cl.parsecountmod].graphdata.voicebytes += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_resourcelocation:
@@ -2695,7 +2579,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
CL_ParseExec( msg );
break;
default:
CL_ParseUserMessage( msg, cmd, PROTO_CURRENT );
CL_ParseUserMessage( msg, cmd );
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
break;
}

View File

@@ -137,7 +137,12 @@ static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
if( FBitSet( flags, SND_SENTENCE ))
{
char sentenceName[32];
//if( FBitSet( flags, SND_SEQUENCE ))
//Q_snprintf( sentenceName, sizeof( sentenceName ), "!#%i", sound + MAX_SOUNDS );
//else
Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
handle = S_RegisterSound( sentenceName );
}
else handle = cl.sound_index[sound]; // see precached sound
@@ -315,7 +320,7 @@ dispatch messages
void CL_ParseLegacyServerMessage( sizebuf_t *msg )
{
size_t bufStart, playerbytes;
int cmd;
int cmd, param1, param2;
int old_background;
const char *s;
@@ -340,9 +345,6 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
// record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart );
if( CL_ParseCommonDLLMessage( msg, PROTO_LEGACY, cmd, bufStart ))
continue;
// other commands
switch( cmd )
{
@@ -419,7 +421,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
break;
case svc_time:
CL_ParseServerTime( msg, PROTO_LEGACY );
CL_ParseServerTime( msg );
break;
case svc_print:
Con_Printf( "%s", MSG_ReadString( msg ));
@@ -466,10 +468,11 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
CL_UpdateUserPings( msg );
break;
case svc_particle:
CL_ParseParticles( msg, PROTO_LEGACY );
CL_ParseParticles( msg );
break;
case svc_restoresound:
Con_Printf( S_ERROR "%s: svc_restoresound: implement me!\n", __func__ );
CL_ParseRestoreSoundPacket( msg );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_spawnstatic:
CL_LegacyParseStaticEntity( msg );
@@ -481,6 +484,10 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
case svc_spawnbaseline:
CL_ParseBaseline( msg, PROTO_LEGACY );
break;
case svc_temp_entity:
CL_ParseTempEntity( msg, PROTO_LEGACY );
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_setpause:
cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
break;
@@ -490,26 +497,45 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
case svc_centerprint:
CL_CenterPrint( MSG_ReadString( msg ), 0.25f );
break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_legacy_modelindex:
CL_LegacyPrecacheModel( msg );
break;
case svc_legacy_soundindex:
CL_LegacyPrecacheSound( msg );
break;
case svc_cdtrack:
param1 = MSG_ReadByte( msg );
param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum
param2 = MSG_ReadByte( msg );
param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum
S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false );
break;
case svc_restore:
CL_ParseRestore( msg );
break;
case svc_legacy_eventindex:
CL_LegacyPrecacheEvent(msg);
break;
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_bspdecal:
CL_ParseStaticDecal( msg );
break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_addangle:
CL_ParseAddAngle( msg );
break;
case svc_usermessage:
CL_RegisterUserMessage( msg, PROTO_LEGACY );
CL_RegisterUserMessage( msg );
break;
case svc_packetentities:
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_LEGACY );
@@ -564,6 +590,9 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
case svc_hltv:
CL_ParseHLTV( msg );
break;
case svc_director:
CL_ParseDirector( msg );
break;
case svc_resourcelocation:
CL_ParseResLocation( msg );
break;
@@ -574,7 +603,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
CL_ParseCvarValue( msg, true, PROTO_LEGACY );
break;
default:
CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
CL_ParseUserMessage( msg, cmd );
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
break;
}
@@ -586,7 +615,7 @@ void CL_LegacyPrecache_f( void )
int spawncount, i;
model_t *mod;
if( cls.legacymode != PROTO_LEGACY )
if( !cls.legacymode )
return;
spawncount = Q_atoi( Cmd_Argv( 1 ));

View File

@@ -28,18 +28,7 @@ static void CL_ParseExtraInfo( sizebuf_t *msg )
string clientfallback;
Q_strncpy( clientfallback, MSG_ReadString( msg ), sizeof( clientfallback ));
if( COM_CheckStringEmpty( clientfallback ))
Con_Reportf( S_ERROR "%s: TODO: add fallback directory %s!\n", __func__ );
if( MSG_ReadByte( msg ))
{
Cvar_FullSet( "sv_cheats", "1", FCVAR_READ_ONLY | FCVAR_SERVER );
}
else
{
Cvar_SetCheatState();
Cvar_FullSet( "sv_cheats", "0", FCVAR_READ_ONLY | FCVAR_SERVER );
}
Cvar_FullSet( "sv_cheats", MSG_ReadByte( msg ) ? "1" : "0", FCVAR_READ_ONLY | FCVAR_SERVER );
}
static void CL_ParseNewMovevars( sizebuf_t *msg )
@@ -82,13 +71,29 @@ static void CL_ParseNewMovevars( sizebuf_t *msg )
if( Q_strcmp( clgame.oldmovevars.skyName, clgame.movevars.skyName ) && cl.video_prepped )
R_SetupSky( clgame.movevars.skyName );
clgame.oldmovevars = clgame.movevars;
memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t ));
clgame.entities->curstate.scale = clgame.movevars.waveHeight;
// keep features an actual!
clgame.oldmovevars.features = clgame.movevars.features = host.features;
}
static void CL_ParseNewUserMsg( sizebuf_t *msg )
{
int svc_num, size;
char s[16];
svc_num = MSG_ReadByte( msg );
size = MSG_ReadByte( msg );
MSG_ReadBytes( msg, s, sizeof( s ));
s[15] = 0;
if( size == 255 )
size = -1;
CL_LinkUserMessage( s, svc_num, size );
}
typedef struct delta_header_t
{
qboolean remove : 1;
@@ -100,8 +105,11 @@ typedef struct delta_header_t
static int CL_ParseDeltaHeader( sizebuf_t *msg, qboolean delta, int oldnum, struct delta_header_t *hdr )
{
int entnum = oldnum;
memset( hdr, 0, sizeof( *hdr ));
int entnum;
hdr->remove = hdr->custom = hdr->instanced = false;
hdr->instanced_baseline_index = hdr->offset = 0;
entnum = oldnum;
if( !delta )
{
@@ -113,7 +121,7 @@ static int CL_ParseDeltaHeader( sizebuf_t *msg, qboolean delta, int oldnum, stru
else if( MSG_ReadOneBit( msg ) == 0 )
entnum += MSG_ReadUBitLong( msg, 6 );
else
entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
entnum += MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
}
else
{
@@ -131,6 +139,9 @@ static int CL_ParseDeltaHeader( sizebuf_t *msg, qboolean delta, int oldnum, stru
{
hdr->custom = MSG_ReadOneBit( msg );
hdr->instanced = false;
hdr->instanced_baseline_index = 0;
// do we got instanced baselines in svc_spawnbaselines?
if( cl.instanced_baseline_count )
{
@@ -139,6 +150,7 @@ static int CL_ParseDeltaHeader( sizebuf_t *msg, qboolean delta, int oldnum, stru
hdr->instanced_baseline_index = MSG_ReadUBitLong( msg, 6 );
}
hdr->offset = 0;
if( !delta && !hdr->instanced )
{
if( MSG_ReadOneBit( msg ))
@@ -175,6 +187,7 @@ static void CL_FlushEntityPacketGS( frame_t *frame, sizebuf_t *msg )
if( MSG_ReadWord( msg ) != 0 )
{
MSG_SeekToBit( msg, -16, SEEK_CUR );
num = CL_ParseDeltaHeader( msg, false, num, &hdr );
}
else break;
@@ -187,15 +200,16 @@ static void CL_FlushEntityPacketGS( frame_t *frame, sizebuf_t *msg )
Delta_ReadGSFields( msg, CL_GetEntityDelta( &hdr, num ), &from, &to, cl.mtime[0] );
}
MSG_EndBitWriting( msg );
}
static void CL_DeltaEntityGS( const delta_header_t *hdr, sizebuf_t *msg, frame_t *frame, int newnum, const entity_state_t *from )
static void CL_DeltaEntityGS( const delta_header_t *hdr, sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *from, qboolean has_update )
{
cl_entity_t *ent;
entity_state_t *to;
qboolean newent = from == NULL;
int pack = frame->num_entities;
qboolean has_update = msg != NULL;
// alloc next slot to store update
to = &cls.packet_entities[cls.next_client_entities % cls.num_client_entities];
@@ -212,8 +226,6 @@ static void CL_DeltaEntityGS( const delta_header_t *hdr, sizebuf_t *msg, frame_t
{
if( !newent )
CL_KillDeadBeams( ent );
else
Con_Printf( S_WARN "%s: entity remove on non-delta update (%d)\n", __func__, newnum );
return;
}
@@ -249,13 +261,13 @@ static void CL_DeltaEntityGS( const delta_header_t *hdr, sizebuf_t *msg, frame_t
frame->num_entities++;
}
static void CL_CopyPacketEntity( frame_t *frame, int num, const entity_state_t *from )
static void CL_CopyPacketEntity( frame_t *frame, int num, entity_state_t *from )
{
delta_header_t fakehdr =
{
.custom = FBitSet( from->entityType, ENTITY_BEAM ) == ENTITY_BEAM,
};
CL_DeltaEntityGS( &fakehdr, NULL, frame, num, from );
CL_DeltaEntityGS( &fakehdr, NULL, frame, num, from, false );
}
static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
@@ -278,6 +290,8 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
frame->num_entities = 0;
frame->valid = true;
MSG_StartBitWriting( msg );
if( delta )
{
uint oldpacket = MSG_ReadByte( msg );
@@ -285,9 +299,7 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
if( !CL_ValidateDeltaPacket( oldpacket, oldframe ))
{
MSG_StartBitWriting( msg );
CL_FlushEntityPacketGS( frame, msg );
MSG_EndBitWriting( msg );
return playerbytes;
}
}
@@ -300,8 +312,6 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
cl.validsequence = cls.netchan.incoming_sequence;
MSG_StartBitWriting( msg );
oldent = NULL;
oldindex = 0;
oldnum = CL_UpdateOldEntNum( oldindex, oldframe, &oldent );
@@ -328,9 +338,6 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
while( oldnum < newnum )
{
if( !delta )
Con_Printf( S_WARN "%s: old frame copy on non-delta update (%d < %d)\n", __func__, oldnum, newnum );
// one or more entities from the old packet are unchanged
CL_CopyPacketEntity( frame, oldnum, oldent );
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
@@ -340,17 +347,14 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
if( oldnum == newnum )
{
if( !delta )
Con_Printf( S_WARN "%s: delta entity on non-delta update (%d)\n", __func__, oldnum );
// from delta
CL_DeltaEntityGS( &hdr, msg, frame, newnum, oldent );
CL_DeltaEntityGS( &hdr, msg, frame, newnum, oldent, true );
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
}
else if( oldnum > newnum )
{
// from baseline
CL_DeltaEntityGS( &hdr, msg, frame, newnum, NULL );
CL_DeltaEntityGS( &hdr, msg, frame, newnum, NULL, true );
}
if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufstart;
@@ -378,10 +382,13 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
CL_ProcessPacket( frame );
CL_SetSolidEntities();
// first update, received world, remove loading plaque
// first update is the final signon stage where we actually receive an entity (i.e., the world at least)
if( cls.signon == ( SIGNONS - 1 ))
{
// we are done with signon sequence.
cls.signon = SIGNONS;
// Clear loading plaque.
CL_SignonReply( PROTO_GOLDSRC );
}
@@ -452,9 +459,7 @@ static void CL_ParseSoundPacketGS( sizebuf_t *msg )
chan = MSG_ReadUBitLong( msg, 3 );
entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
if( FBitSet( flags, SND_LEGACY_LARGE_INDEX ))
sound = MSG_ReadWord( msg );
else sound = MSG_ReadByte( msg );
sound = MSG_ReadUBitLong( msg, FBitSet( flags, SND_SEQUENCE ) ? 16 : 8 );
MSG_ReadGSBitVec3Coord( msg, pos );
if( FBitSet( flags, SND_PITCH ))
@@ -463,12 +468,14 @@ static void CL_ParseSoundPacketGS( sizebuf_t *msg )
MSG_EndBitWriting( msg );
ClearBits( flags, SND_LEGACY_LARGE_INDEX );
if( FBitSet( flags, SND_SENTENCE ))
{
char sentenceName[32];
Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
if( FBitSet( flags, SND_SEQUENCE ))
Q_snprintf( sentenceName, sizeof( sentenceName ), "!#%i", sound + MAX_SOUNDS_NONSENTENCE );
else Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
handle = S_RegisterSound( sentenceName );
}
else handle = cl.sound_index[sound]; // see precached sound
@@ -521,7 +528,8 @@ dispatch messages
void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
{
size_t bufStart, playerbytes;
int cmd, param1;
int cmd, param1, param2;
int old_background;
const char *s;
// parse the message
@@ -545,9 +553,6 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
// record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart );
if( CL_ParseCommonDLLMessage( msg, PROTO_GOLDSRC, cmd, bufStart ))
continue;
// other commands
switch( cmd )
{
@@ -555,16 +560,9 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
Host_Error( "svc_bad\n" );
break;
case svc_nop:
case svc_spawnstatic:
case svc_goldsrc_damage:
case svc_goldsrc_killedmonster:
case svc_goldsrc_foundsecret:
// this does nothing
break;
case svc_disconnect:
s = MSG_ReadString( msg );
if( COM_CheckStringEmpty( s ))
Con_Printf( "Server issued disconnect. Reason: %s\n", s );
CL_Drop ();
Host_AbortCurrentFrame ();
break;
@@ -574,11 +572,6 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
MSG_EndBitWriting( msg );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_goldsrc_version:
param1 = MSG_ReadLong( msg );
if( param1 != PROTOCOL_GOLDSRC_VERSION )
Host_Error( "Server use invalid protocol (%i should be %i)\n", param1, PROTOCOL_GOLDSRC_VERSION );
break;
case svc_setview:
CL_ParseViewEntity( msg );
break;
@@ -587,19 +580,13 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_time:
CL_ParseServerTime( msg, PROTO_GOLDSRC );
CL_ParseServerTime( msg );
break;
case svc_print:
Con_Printf( "%s", MSG_ReadString( msg ));
break;
case svc_stufftext:
s = MSG_ReadString( msg );
if( cl_trace_stufftext.value )
{
size_t len = Q_strlen( s );
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
}
#ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
@@ -613,6 +600,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
case svc_goldsrc_serverinfo:
Cbuf_Execute(); // make sure any stuffed commands are done
CL_ParseServerData( msg, PROTO_GOLDSRC );
Delta_InitMeta();
break;
case svc_lightstyle:
CL_ParseLightStyle( msg, PROTO_GOLDSRC );
@@ -629,18 +617,16 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
MSG_EndBitWriting( msg );
cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_goldsrc_stopsound:
param1 = MSG_ReadWord( msg );
S_StopSound( param1 >> 3, param1 & 7, NULL );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_pings:
MSG_StartBitWriting( msg );
CL_UpdateUserPings( msg );
MSG_EndBitWriting( msg );
break;
case svc_particle:
CL_ParseParticles( msg, PROTO_GOLDSRC );
CL_ParseParticles( msg );
break;
case svc_spawnstatic:
CL_ParseStaticEntity( msg );
break;
case svc_event_reliable:
MSG_StartBitWriting( msg );
@@ -649,12 +635,14 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_spawnbaseline:
MSG_StartBitWriting( msg );
CL_ParseBaseline( msg, PROTO_GOLDSRC );
MSG_EndBitWriting( msg );
break;
case svc_temp_entity:
CL_ParseTempEntity( msg, PROTO_GOLDSRC );
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_setpause:
cl.paused = ( MSG_ReadByte( msg ) != 0 );
cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
break;
case svc_signonnum:
CL_ParseSignon( msg, PROTO_GOLDSRC );
@@ -665,25 +653,39 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
case svc_goldsrc_spawnstaticsound:
CL_ParseSpawnStaticSound( msg );
break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_finale:
CL_ParseFinaleCutscene( msg, 2 );
break;
case svc_cdtrack:
param1 = MSG_ReadByte( msg );
param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum
param2 = MSG_ReadByte( msg );
param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum
S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false );
break;
case svc_restore:
CL_ParseRestore( msg );
break;
case svc_cutscene:
CL_ParseFinaleCutscene( msg, 3 );
break;
case svc_goldsrc_decalname:
param1 = MSG_ReadByte( msg );
s = MSG_ReadString( msg );
Q_strncpy( host.draw_decals[param1], s, sizeof( host.draw_decals[param1] ));
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_addangle:
CL_ParseAddAngle( msg );
break;
case svc_goldsrc_newusermsg:
CL_RegisterUserMessage( msg, PROTO_GOLDSRC );
CL_ParseNewUserMsg( msg );
break;
case svc_packetentities:
playerbytes = CL_ParsePacketEntitiesGS( msg, false );
@@ -725,11 +727,14 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
case svc_hltv:
CL_ParseHLTV( msg );
break;
case svc_director:
CL_ParseDirector( msg );
break;
case svc_voiceinit:
CL_ParseVoiceInit( msg );
break;
case svc_voicedata:
CL_ParseVoiceData( msg, PROTO_GOLDSRC );
CL_ParseVoiceData( msg );
cl.frames[cl.parsecountmod].graphdata.voicebytes += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_resourcelocation:
@@ -738,23 +743,17 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
case svc_goldsrc_sendextrainfo:
CL_ParseExtraInfo( msg );
break;
case svc_goldsrc_timescale:
// we can set sys_timescale to anything we want but in GoldSrc it's locked for
// HLTV and demoplayback. Do we really want to have it then if both are out of scope?
Con_Reportf( S_ERROR "%s: svc_goldsrc_timescale: implement me!\n", __func__ );
MSG_ReadFloat( msg );
break;
case svc_goldsrc_sendcvarvalue:
case svc_querycvarvalue:
CL_ParseCvarValue( msg, false, PROTO_GOLDSRC );
break;
case svc_goldsrc_sendcvarvalue2:
case svc_querycvarvalue2:
CL_ParseCvarValue( msg, true, PROTO_GOLDSRC );
break;
case svc_exec:
CL_ParseExec( msg );
break;
default:
CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
CL_ParseUserMessage( msg, cmd );
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
break;
}

View File

@@ -59,7 +59,7 @@ void GAME_EXPORT CL_PopPMStates( void )
CL_IsPredicted
===============
*/
static qboolean CL_IsPredicted( void )
qboolean CL_IsPredicted( void )
{
if( cl_nopred.value || cl.intermission )
return false;

View File

@@ -950,7 +950,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
break;
case svc_time:
Cbuf_AddText( "\n" ); // new frame was started
CL_ParseServerTime( msg, PROTO_QUAKE );
CL_ParseServerTime( msg );
break;
case svc_print:
str = MSG_ReadString( msg );

View File

@@ -35,17 +35,17 @@ TEMPENTS MANAGEMENT
#define SHARD_VOLUME 12.0f // on shard ever n^3 units
#define MAX_MUZZLEFLASH 3
static TEMPENTITY *cl_active_tents;
static TEMPENTITY *cl_free_tents;
static TEMPENTITY *cl_tempents = NULL; // entities pool
TEMPENTITY *cl_active_tents;
TEMPENTITY *cl_free_tents;
TEMPENTITY *cl_tempents = NULL; // entities pool
static model_t *cl_sprite_muzzleflash[MAX_MUZZLEFLASH]; // muzzle flashes
static model_t *cl_sprite_ricochet = NULL;
static model_t *cl_sprite_glow = NULL;
model_t *cl_sprite_dot = NULL;
model_t *cl_sprite_shell = NULL;
model_t *cl_sprite_muzzleflash[MAX_MUZZLEFLASH]; // muzzle flashes
model_t *cl_sprite_dot = NULL;
model_t *cl_sprite_ricochet = NULL;
model_t *cl_sprite_shell = NULL;
model_t *cl_sprite_glow = NULL;
static const char *const cl_default_sprites[] =
const char *cl_default_sprites[] =
{
// built-in sprites
"sprites/muzzleflash1.spr",
@@ -169,28 +169,6 @@ void CL_AddClientResources( void )
#endif
}
/*
================
CL_ClearTempEnts
================
*/
static void CL_ClearTempEnts( void )
{
int i;
if( !cl_tempents ) return;
for( i = 0; i < GI->max_tents - 1; i++ )
{
cl_tempents[i].next = &cl_tempents[i+1];
cl_tempents[i].entity.trivial_accept = INVALID_HANDLE;
}
cl_tempents[GI->max_tents-1].next = NULL;
cl_free_tents = cl_tempents;
cl_active_tents = NULL;
}
/*
================
@@ -207,6 +185,29 @@ void CL_InitTempEnts( void )
CL_LoadClientSprites ();
}
/*
================
CL_ClearTempEnts
================
*/
void CL_ClearTempEnts( void )
{
int i;
if( !cl_tempents ) return;
for( i = 0; i < GI->max_tents - 1; i++ )
{
cl_tempents[i].next = &cl_tempents[i+1];
cl_tempents[i].entity.trivial_accept = INVALID_HANDLE;
}
cl_tempents[GI->max_tents-1].next = NULL;
cl_free_tents = cl_tempents;
cl_active_tents = NULL;
}
/*
================
CL_FreeTempEnts
@@ -443,16 +444,11 @@ alloc normal\low priority tempentity
*/
TEMPENTITY *CL_TempEntAlloc( const vec3_t org, model_t *pmodel )
{
static float cl_lasttimewarn;
TEMPENTITY *pTemp;
if( !cl_free_tents )
{
if( cl_lasttimewarn < host.realtime )
{
Con_DPrintf( "Overflow %d temporary ents!\n", GI->max_tents );
cl_lasttimewarn = host.realtime + 1.0f;
}
Con_DPrintf( "Overflow %d temporary ents!\n", GI->max_tents );
return NULL;
}
@@ -1920,16 +1916,16 @@ void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto )
else iSize = MSG_ReadWord( msg );
// this will probably be fatal anyway
if( iSize > sizeof( msg_data ))
if( iSize > sizeof( pbuf ))
Con_Printf( S_ERROR "%s: Temp buffer overflow!\n", __func__ );
// parse user message into buffer
MSG_ReadBytes( msg, msg_data, iSize );
MSG_ReadBytes( msg, pbuf, iSize );
// init a safe tempbuffer
MSG_Init( &buf, "TempEntity", msg_data, iSize );
MSG_Init( pbuf, "TempEntity", pbuf, iSize );
pbuf = &buf;
pbuf = pbuf;
}
else
{

View File

@@ -77,6 +77,7 @@ void R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_t noise, int
void R_FireField( float *org, int radius, int modelIndex, int count, int flags, float life );
void R_PlayerSprites( int client, int modelIndex, int count, int size );
void R_Sprite_WallPuff( struct tempent_s *pTemp, float scale );
void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b );
void R_RicochetSound( const vec3_t pos );
struct dlight_s *CL_AllocDlight( int key );
struct dlight_s *CL_AllocElight( int key );

View File

@@ -129,6 +129,7 @@ typedef struct
// misc local info
qboolean repredicting; // repredicting in progress
qboolean thirdperson;
qboolean apply_effects; // local player will not added but we should apply their effects: flashlight etc
float idealpitch;
int viewmodel;
@@ -653,7 +654,6 @@ extern gameui_static_t gameui;
//
// cvars
//
extern convar_t showpause;
extern convar_t mp_decals;
extern convar_t cl_logomaxdim;
extern convar_t cl_allow_download;
@@ -868,14 +868,15 @@ void CL_UpdateUserinfo( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseResource( sizebuf_t *msg );
void CL_ParseClientData( sizebuf_t *msg, connprotocol_t proto );
void CL_UpdateUserPings( sizebuf_t *msg );
void CL_ParseParticles( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseParticles( sizebuf_t *msg );
void CL_ParseRestoreSoundPacket( sizebuf_t *msg );
void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseSignon( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseRestore( sizebuf_t *msg );
void CL_ParseStaticEntity( sizebuf_t *msg );
void CL_ParseStaticDecal( sizebuf_t *msg );
void CL_ParseAddAngle( sizebuf_t *msg );
void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto );
void CL_RegisterUserMessage( sizebuf_t *msg );
void CL_ParseResourceList( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseMovevars( sizebuf_t *msg );
void CL_ParseResourceRequest( sizebuf_t *msg );
@@ -886,18 +887,17 @@ void CL_ParseFileTransferFailed( sizebuf_t *msg );
void CL_ParseHLTV( sizebuf_t *msg );
void CL_ParseDirector( sizebuf_t *msg );
void CL_ParseVoiceInit( sizebuf_t *msg );
void CL_ParseVoiceData( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseVoiceData( sizebuf_t *msg );
void CL_ParseResLocation( sizebuf_t *msg );
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto );
void CL_ParseServerMessage( sizebuf_t *msg );
qboolean CL_ParseCommonDLLMessage( sizebuf_t *msg, connprotocol_t proto, int svc_num, int startoffset );
void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto );
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
qboolean CL_RequestMissingResources( void );
void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseViewEntity( sizebuf_t *msg );
void CL_ParseServerTime( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num, connprotocol_t proto );
void CL_ParseServerTime( sizebuf_t *msg );
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
void CL_ParseTextMessage( sizebuf_t *msg );
void CL_ParseExec( sizebuf_t *msg );
@@ -956,6 +956,7 @@ void CL_SetSolidPlayers( int playernum );
void CL_InitClientMove( void );
void CL_PredictMovement( qboolean repredicting );
void CL_CheckPredictionError( void );
qboolean CL_IsPredicted( void );
int CL_WaterEntity( const float *rgflPos );
cl_entity_t *CL_GetWaterEntity( const float *rgflPos );
pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags );
@@ -1030,6 +1031,7 @@ void CL_InitParticles( void );
void CL_ClearParticles( void );
void CL_FreeParticles( void );
void CL_InitTempEnts( void );
void CL_ClearTempEnts( void );
void CL_FreeTempEnts( void );
void CL_TempEntUpdate( void );
void CL_InitViewBeams( void );

View File

@@ -569,9 +569,10 @@ IN_EngineAppendMove
Called from cl_main.c after generating command in client
================
*/
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
void IN_EngineAppendMove( float frametime, void *cmd1, qboolean active )
{
float forward, side, pitch, yaw;
usercmd_t *cmd = cmd1;
if( clgame.dllFuncs.pfnLookEvent )
return;

View File

@@ -25,7 +25,6 @@ INPUT
*/
#include "keydefs.h"
#include "usercmd.h"
//
// input.c
@@ -44,7 +43,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate );
uint IN_CollectInputDevices( void );
void IN_LockInputDevices( qboolean lock );
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active );
void IN_EngineAppendMove( float frametime, void *cmd, qboolean active );
extern convar_t m_yaw;
extern convar_t m_pitch;

View File

@@ -1894,7 +1894,7 @@ S_VoiceRecordStart_f
*/
static void S_VoiceRecordStart_f( void )
{
if( cls.state != ca_active )
if( cls.state != ca_active || cls.legacymode )
return;
Voice_RecordStart();

View File

@@ -248,12 +248,6 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
const char *p;
int len;
// HACKHACK: some modders send strings like "/fvox/_period four"
// which should get parsed as "_period four" said by fvox
// it might be incorrect but ignore first slash here for now
if( psz[0] == '/' )
psz++;
// search / backwards
p = Q_strrchr( psz, '/' );
@@ -601,8 +595,8 @@ static void Test_VOX_GetDirectory( void )
{
"", "", "vox/",
"bark bark", "bark bark", "vox/",
"barney/meow", "meow", "barney/",
"/fvox/_period", "_period", "fvox/",
"barney/meow", "meow", "barney/"
};
int i;

View File

@@ -396,9 +396,6 @@ void Voice_RecordStart( void )
{
Voice_RecordStop();
if( !voice.initialized )
return;
if( voice_inputfromfile.value )
{
voice.input_file = FS_LoadSound( "voice_input.wav", NULL, 0 );
@@ -418,7 +415,7 @@ void Voice_RecordStart( void )
}
}
if( !Voice_IsRecording( ) && voice.device_opened )
if( !Voice_IsRecording() )
voice.is_recording = VoiceCapture_Activate( true );
if( Voice_IsRecording() )
@@ -630,8 +627,7 @@ qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
{
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
{
if( COM_CheckStringEmpty( pszCodecName ))
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
// reset saved codec name, we won't enable voice for this connection
voice_codec_init[0] = 0;

View File

@@ -25,7 +25,7 @@ typedef enum
T_COUNT
} cvartype_t;
static const char *const cvartypes[] = { NULL, "BOOL", "NUMBER", "LIST", "STRING" };
const char *cvartypes[] = { NULL, "BOOL", "NUMBER", "LIST", "STRING" };
typedef struct parserstate_s
{

View File

@@ -24,27 +24,18 @@ GNU General Public License for more details.
typedef struct
{
byte *const data;
const int maxsize;
int cursize;
byte *data;
int cursize;
int maxsize;
} cmdbuf_t;
static qboolean cmd_wait;
static byte cmd_text_buf[MAX_CMD_BUFFER];
static byte filteredcmd_text_buf[MAX_CMD_BUFFER];
static cmdbuf_t cmd_text =
{
.data = cmd_text_buf,
.maxsize = ARRAYSIZE( cmd_text_buf ),
};
static cmdbuf_t filteredcmd_text =
{
.data = filteredcmd_text_buf,
.maxsize = ARRAYSIZE( filteredcmd_text_buf ),
};
static cmdalias_t *cmd_alias;
static uint cmd_condition;
static int cmd_condlevel;
qboolean cmd_wait;
cmdbuf_t cmd_text, filteredcmd_text;
byte cmd_text_buf[MAX_CMD_BUFFER];
byte filteredcmd_text_buf[MAX_CMD_BUFFER];
cmdalias_t *cmd_alias;
uint cmd_condition;
int cmd_condlevel;
static qboolean cmd_currentCommandIsPrivileged;
static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPrivileged );
@@ -57,6 +48,20 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
=============================================================================
*/
/*
============
Cbuf_Init
============
*/
static void Cbuf_Init( void )
{
cmd_text.data = cmd_text_buf;
filteredcmd_text.data = filteredcmd_text_buf;
filteredcmd_text.maxsize = cmd_text.maxsize = MAX_CMD_BUFFER;
filteredcmd_text.cursize = cmd_text.cursize = 0;
}
/*
============
Cbuf_Clear
@@ -1382,6 +1387,8 @@ Cmd_Init
*/
void Cmd_Init( void )
{
Cbuf_Init();
cmd_functions = NULL;
cmd_condition = 0;
cmd_alias = NULL;

View File

@@ -23,7 +23,7 @@ GNU General Public License for more details.
#include "client.h"
#include "library.h"
static const char *const file_exts[] =
static const char *file_exts[] =
{
// ban text files that don't make sense as resource
"cfg", "lst", "ini", "log",
@@ -759,6 +759,25 @@ void GAME_EXPORT COM_FreeFile( void *buffer )
free( buffer );
}
/*
=============
COM_NormalizeAngles
=============
*/
void COM_NormalizeAngles( vec3_t angles )
{
int i;
for( i = 0; i < 3; i++ )
{
if( angles[i] > 180.0f )
angles[i] -= 360.0f;
else if( angles[i] < -180.0f )
angles[i] += 360.0f;
}
}
/*
=============
pfnGetModelType
@@ -824,7 +843,7 @@ int GAME_EXPORT COM_CompareFileTime( const char *filename1, const char *filename
if( ft1 == -1 || ft2 == -1 )
return bRet;
*iCompare = ft1 < ft2 ? -1 : ( ft1 > ft2 ? 1 : 0 );
*iCompare = Host_CompareFileTime( ft1, ft2 );
bRet = 1;
}
@@ -879,40 +898,18 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
char lwrfilename[4096];
const char *first, *last;
const char *ext;
size_t len;
int i;
if( !COM_CheckString( filename ))
return false;
ext = COM_FileExtension( filename );
len = Q_strlen( filename );
ext = COM_FileExtension( lwrfilename );
// only allow extensionless files that start with !MD5
if( !Q_strncmp( filename, "!MD5", 4 ))
{
if( COM_CheckStringEmpty( ext ))
return false;
len = Q_strlen( filename );
if( len != 36 )
return false;
for( i = 4; i < len; i++ )
{
if(( filename[i] >= '0' && filename[i] <= '9' ) ||
( filename[i] >= 'A' && filename[i] <= 'F' ))
continue;
return false;
}
if( !Q_strncmp( filename, "!MD5", 4 ) && ext[0] == 0 )
return true;
}
Q_strnlwr( filename, lwrfilename, sizeof( lwrfilename ));
ext = COM_FileExtension( lwrfilename );
if( Q_strpbrk( lwrfilename, "\\:~" ) || Q_strstr( lwrfilename, ".." ) )
return false;
@@ -1045,13 +1042,28 @@ void GAME_EXPORT pfnResetTutorMessageDecayData( void )
void Test_RunCommon( void )
{
Msg( "Checking COM_IsSafeFileToDownload...\n" );
char *file = (char *)"q asdf \"qwerty\" \"f \\\"f\" meowmeow\n// comment \"stuff ignored\"\nbark";
int len;
char buf[5];
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD5AAB5E8B307672DA86FBD10AC302BC732" ), true );
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD56f1ffd8c96bd64c9c27955309f6ecfe6" ), false );
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD5AAB5E8B307672DA86FBD10AC302B.exe" ), false );
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD5/../../valve/resource/GameMenu.res" ), false );
TASSERT_EQi( COM_IsSafeFileToDownload( "not-a-virus-trust-me.bat" ), false );
TASSERT_EQi( COM_IsSafeFileToDownload( "a-texture.png" ), true );
Msg( "Checking COM_ParseFile...\n" );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "q" ) && len == 1);
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "asdf" ) && len == 4);
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "qwer" ) && len == -1);
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "f \"f" ) && len == 4);
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "meow" ) && len == -1);
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "bark" ) && len == 4);
}
#endif

View File

@@ -168,7 +168,6 @@ extern convar_t sys_timescale;
extern convar_t cl_filterstuffcmd;
extern convar_t rcon_password;
extern convar_t hpk_custom_file;
extern convar_t con_gamemaps;
#define Mod_AllowMaterials() ( host_allow_materials.value != 0.0f && !FBitSet( host.features, ENGINE_DISABLE_HDTEXTURES ))
@@ -529,6 +528,7 @@ typedef void( *pfnChangeGame )( const char *progname );
qboolean Host_IsQuakeCompatible( void );
void EXPORT Host_Shutdown( void );
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
int Host_CompareFileTime( int ft1, int ft2 );
void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
void Host_AbortCurrentFrame( void ) NORETURN;
void Host_WriteServerConfig( const char *name );
@@ -769,25 +769,13 @@ void UI_ShowConnectionWarning( void );
void Cmd_Null_f( void );
void Rcon_Print( host_redirect_t *rd, const char *pMsg );
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename );
void COM_FreeFile( void *buffer );
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
char *va( const char *format, ... ) _format( 1 );
qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer );
static inline void COM_NormalizeAngles( vec3_t angles )
{
int i;
for( i = 0; i < 3; i++ )
{
if( angles[i] > 180.0f )
angles[i] -= 360.0f;
else if( angles[i] < -180.0f )
angles[i] += 360.0f;
}
}
#if !XASH_DEDICATED
connprotocol_t CL_Protocol( void );
#else

View File

@@ -18,6 +18,8 @@ GNU General Public License for more details.
#include "const.h"
#include "kbutton.h"
extern convar_t con_gamemaps;
#define CON_MAXCMDS 4096 // auto-complete intermediate list
typedef struct autocomplete_list_s
@@ -1010,7 +1012,7 @@ int GAME_EXPORT Cmd_CheckMapsList( int fRefresh )
return Cmd_CheckMapsList_R( fRefresh, true );
}
static const autocomplete_list_t cmd_list[] =
autocomplete_list_t cmd_list[] =
{
{ "map_background", 1, Cmd_GetMapList },
{ "changelevel2", 1, Cmd_GetMapList },
@@ -1073,7 +1075,7 @@ for various cmds
*/
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
{
const autocomplete_list_t *list;
autocomplete_list_t *list;
for( list = cmd_list; list->name; list++ )
{

View File

@@ -18,17 +18,17 @@ GNU General Public License for more details.
#include "base_cmd.h"
#include "eiface.h" // ARRAYSIZE
static convar_t *cvar_vars = NULL; // head of list
convar_t *cvar_vars = NULL; // head of list
CVAR_DEFINE_AUTO( cmd_scripting, "0", FCVAR_ARCHIVE|FCVAR_PRIVILEGED, "enable simple condition checking and variable operations" );
#ifdef HACKS_RELATED_HLMODS
typedef struct cvar_filter_quirks_s
{
const char *gamedir; // gamedir to enable for
const char *cvars; // list of cvars should be excluded from filter
} cvar_filter_quirks_t;
#ifdef HACKS_RELATED_HLMODS
static const cvar_filter_quirks_t cvar_filter_quirks[] =
static cvar_filter_quirks_t cvar_filter_quirks[] =
{
// EXAMPLE:
//{
@@ -44,9 +44,9 @@ static const cvar_filter_quirks_t cvar_filter_quirks[] =
"cl_dodmusic" // Day of Defeat Beta 1.3 cvar
},
};
#endif
static const cvar_filter_quirks_t *cvar_active_filter_quirks = NULL;
static cvar_filter_quirks_t *cvar_active_filter_quirks = NULL;
#endif
CVAR_DEFINE_AUTO( cl_filterstuffcmd, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "filter commands coming from server" );
@@ -618,7 +618,7 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
return Cvar_Get( var_name, value, FCVAR_USER_CREATED, NULL );
}
else
{
{
if( !Cmd_CurrentCommandIsPrivileged( ))
{
if( FBitSet( var->flags, FCVAR_PRIVILEGED ))
@@ -974,6 +974,7 @@ static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
if( cl_filterstuffcmd.value <= 0.0f )
return true;
#ifdef HACKS_RELATED_HLMODS
// check if game-specific filter exceptions should be applied
// TODO: for cmd exceptions, make generic function
if( cvar_active_filter_quirks )
@@ -1004,6 +1005,7 @@ static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
}
}
}
#endif
if( FBitSet( v->flags, FCVAR_FILTERABLE ))
return false;

View File

@@ -40,7 +40,7 @@ GNU General Public License for more details.
#include "render_api.h" // decallist_t
#include "tests.h"
static pfnChangeGame pChangeGame = NULL;
pfnChangeGame pChangeGame = NULL;
host_parm_t host; // host parms
#ifdef XASH_ENGINE_TESTS
@@ -49,8 +49,8 @@ struct tests_stats_s tests_stats;
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" );
CVAR_DEFINE_AUTO( sys_ticrate, "100", FCVAR_SERVER, "framerate in dedicated mode" );
static CVAR_DEFINE_AUTO( sys_ticrate, "100", FCVAR_SERVER, "framerate in dedicated mode" );
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" );
static CVAR_DEFINE_AUTO( host_gameloaded, "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" );
static CVAR_DEFINE_AUTO( host_clientloaded, "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
@@ -69,14 +69,14 @@ typedef struct feature_message_s
const char *arg;
} feature_message_t;
static const feature_message_t bugcomp_features[] =
static feature_message_t bugcomp_features[] =
{
{ BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" },
{ BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG, "GoldSrc Message Rewrite Facility", "gsmrf" },
{ BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE, "spatialize sounds with zero attenuation", "sp_attn_none" },
};
static const feature_message_t engine_features[] =
static feature_message_t engine_features[] =
{
{ ENGINE_WRITE_LARGE_COORD, "Big World Support" },
{ ENGINE_QUAKE_COMPATIBLE, "Quake Compatibility" },
@@ -200,6 +200,19 @@ static void Sys_PrintUsage( const char *exename )
Sys_Quit();
}
int Host_CompareFileTime( int ft1, int ft2 )
{
if( ft1 < ft2 )
{
return -1;
}
else if( ft1 > ft2 )
{
return 1;
}
return 0;
}
void Host_ShutdownServer( void )
{
SV_Shutdown( "Server was killed\n" );
@@ -210,7 +223,7 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures
================
*/
static void Host_PrintFeatures( uint32_t flags, const char *s, const feature_message_t *features, size_t size )
static void Host_PrintFeatures( uint32_t flags, const char *s, feature_message_t *features, size_t size )
{
size_t i;
@@ -233,20 +246,8 @@ void Host_ValidateEngineFeatures( uint32_t features )
uint32_t mask = ENGINE_FEATURES_MASK;
#if !XASH_DEDICATED
if( !Host_IsDedicated( ))
{
switch( cls.legacymode )
{
case PROTO_CURRENT:
break;
case PROTO_LEGACY:
mask = ENGINE_LEGACY_FEATURES_MASK;
break;
default:
mask = 0;
break;
}
}
if( !Host_IsDedicated( ) && cls.legacymode )
mask = ENGINE_LEGACY_FEATURES_MASK;
#endif
// don't allow unsupported bits
@@ -1071,9 +1072,6 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
Host_RunTests( 0 );
#endif
#if XASH_DEDICATED
Platform_SetupSigtermHandling();
#endif
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED );
FS_Init( basedir );

View File

@@ -198,7 +198,7 @@ static mlumpinfo_t srclumps[HEADER_LUMPS] =
{ LUMP_MODELS, 1, MAX_MAP_MODELS, sizeof( dmodel_t ), -1, "models", CHECK_OVERFLOW, (const void **)&srcmodel.submodels, &srcmodel.numsubmodels },
};
static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
static mlumpinfo_t extlumps[EXTRA_LUMPS] =
{
{ LUMP_LIGHTVECS, 0, MAX_MAP_LIGHTING, sizeof( byte ), -1, "deluxmaps", USE_EXTRAHEADER, (const void **)&srcmodel.deluxdata, &srcmodel.deluxdatasize },
{ LUMP_FACEINFO, 0, MAX_MAP_FACEINFO, sizeof( dfaceinfo_t ), -1, "faceinfos", CHECK_OVERFLOW|USE_EXTRAHEADER, (const void **)&srcmodel.faceinfo, &srcmodel.numfaceinfo },
@@ -347,7 +347,7 @@ Mod_LoadLump
generic loader
=================
*/
static void Mod_LoadLump( const byte *in, const mlumpinfo_t *info, mlumpstat_t *stat, int flags )
static void Mod_LoadLump( const byte *in, mlumpinfo_t *info, mlumpstat_t *stat, int flags )
{
int version = ((dheader_t *)in)->version;
size_t numelems, real_entrysize;

View File

@@ -17,13 +17,15 @@ GNU General Public License for more details.
#include "protocol.h"
#include "net_buffer.h"
#include "xash3d_mathlib.h"
//#define DEBUG_NET_MESSAGES_SEND
//#define DEBUG_NET_MESSAGES_READ
// precalculated bit masks for WriteUBitLong.
// Using these tables instead of doing the calculations
// gives a 33% speedup in WriteUBitLong.
static uint32_t BitWriteMasks[32][33];
static uint32_t ExtraMasks[32];
const char *const svc_strings[svc_lastmsg+1] =
const char *svc_strings[svc_lastmsg+1] =
{
"svc_bad",
"svc_nop",
@@ -87,7 +89,7 @@ const char *const svc_strings[svc_lastmsg+1] =
"svc_exec",
};
const char *const svc_legacy_strings[svc_lastmsg+1] =
const char *svc_legacy_strings[svc_lastmsg+1] =
{
[svc_legacy_changing] = "svc_legacy_changing",
[svc_legacy_ambientsound] = "svc_legacy_ambientsound",
@@ -98,7 +100,7 @@ const char *const svc_legacy_strings[svc_lastmsg+1] =
[svc_legacy_chokecount] = "svc_legacy_chokecount",
};
const char *const svc_goldsrc_strings[svc_lastmsg+1] =
const char *svc_goldsrc_strings[svc_lastmsg+1] =
{
[svc_goldsrc_version] = "svc_goldsrc_version",
[svc_goldsrc_serverinfo] = "svc_goldsrc_serverinfo",
@@ -117,7 +119,7 @@ const char *const svc_goldsrc_strings[svc_lastmsg+1] =
[svc_goldsrc_sendcvarvalue2] = "svc_goldsrc_sendcvarvalue2",
};
const char *const svc_quake_strings[svc_lastmsg+1] =
const char *svc_quake_strings[svc_lastmsg+1] =
{
[svc_updatestat] = "svc_quake_updatestat",
[svc_version] = "svc_quake_version",
@@ -211,23 +213,25 @@ void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits )
// do we have a valid # of bits to encode with?
Assert( numbits >= 1 && numbits <= 32 );
if( sb->iAlternateSign )
if( data < 0 )
{
MSG_WriteOneBit( sb, data < 0 ? 1 : 0 );
MSG_WriteUBitLong( sb, (uint)abs( data ), numbits - 1 );
if( sb->iAlternateSign )
MSG_WriteOneBit( sb, 1 );
MSG_WriteUBitLong( sb, (uint)( 0x80000000 + data ), numbits - 1 );
if( !sb->iAlternateSign )
MSG_WriteOneBit( sb, 1 );
}
else
{
if( data < 0 )
{
MSG_WriteUBitLong( sb, (uint)( 0x80000000 + data ), numbits - 1 );
MSG_WriteOneBit( sb, 1 );
}
else
{
MSG_WriteUBitLong( sb, (uint)data, numbits - 1 );
if( sb->iAlternateSign )
MSG_WriteOneBit( sb, 0 );
MSG_WriteUBitLong( sb, (uint)data, numbits - 1 );
if( !sb->iAlternateSign )
MSG_WriteOneBit( sb, 0 );
}
}
}
@@ -321,30 +325,28 @@ void MSG_WriteVec3Angles( sizebuf_t *sb, const float *fa )
void MSG_WriteCmdExt( sizebuf_t *sb, int cmd, netsrc_t type, const char *name )
{
if( unlikely( net_send_debug.value ))
#ifdef DEBUG_NET_MESSAGES_SEND
if( name != NULL )
{
if( name != NULL )
// get custom name
Con_Printf( "^1sv^7 write: %s\n", name );
}
else if( type == NS_SERVER )
{
if( cmd >= 0 && cmd <= svc_lastmsg )
{
// get custom name
Con_Printf( "^1sv^7 (%d) write: %s\n", sb->iCurBit, name );
}
else if( type == NS_SERVER )
{
if( cmd >= 0 && cmd <= svc_lastmsg )
{
// get engine message name
Con_Printf( "^1sv^7 (%d) write: %s\n", sb->iCurBit, svc_strings[cmd] );
}
}
else if( type == NS_CLIENT )
{
if( cmd >= 0 && cmd <= clc_lastmsg )
{
Con_Printf( "^1cl^7 (%d) write: %s\n", sb->iCurBit, clc_strings[cmd] );
}
// get engine message name
Con_Printf( "^1sv^7 write: %s\n", svc_strings[cmd] );
}
}
else if( type == NS_CLIENT )
{
if( cmd >= 0 && cmd <= clc_lastmsg )
{
Con_Printf( "^1cl^7 write: %s\n", clc_strings[cmd] );
}
}
#endif
MSG_WriteUBitLong( sb, cmd, sizeof( uint8_t ) << 3 );
}
@@ -570,18 +572,16 @@ int MSG_ReadCmd( sizebuf_t *sb, netsrc_t type )
{
int cmd = MSG_ReadUBitLong( sb, sizeof( uint8_t ) << 3 );
if( unlikely( net_recv_debug.value ))
#ifdef DEBUG_NET_MESSAGES_READ
if( type == NS_SERVER )
{
if( type == NS_SERVER )
{
Con_Printf( "^1cl^7 read: %s\n", CL_MsgInfo( cmd ));
}
else if( cmd >= 0 && cmd <= clc_lastmsg )
{
Con_Printf( "^1sv^7 read: %s\n", clc_strings[cmd] );
}
Con_Printf( "^1cl^7 read: %s\n", CL_MsgInfo( cmd ));
}
else if( cmd >= 0 && cmd <= clc_lastmsg )
{
Con_Printf( "^1sv^7 read: %s\n", clc_strings[cmd] );
}
#endif
return cmd;
}

View File

@@ -184,8 +184,7 @@ static inline void MSG_EndBitWriting( sizebuf_t *sb )
}
// we have native bit ops here, just pad to closest byte
if(( sb->iCurBit & 7 ) != 0 )
MSG_SeekToBit( sb, 8 - ( sb->iCurBit & 7 ), SEEK_CUR );
MSG_SeekToBit( sb, MSG_GetNumBytesWritten( sb ) << 3, SEEK_SET );
}
static inline void MSG_StartBitWriting( sizebuf_t *sb )

View File

@@ -87,12 +87,10 @@ such as during the connection stage while waiting for the client to load,
then a packet only needs to be delivered if there is something in the
unacknowledged reliable
*/
CVAR_DEFINE_AUTO( net_showpackets, "0", FCVAR_PRIVILEGED, "show network packets" );
CVAR_DEFINE_AUTO( net_showpackets, "0", 0, "show network packets" );
static CVAR_DEFINE_AUTO( net_chokeloop, "0", 0, "apply bandwidth choke to loopback packets" );
static CVAR_DEFINE_AUTO( net_showdrop, "0", 0, "show packets that are dropped" );
static CVAR_DEFINE_AUTO( net_qport, "0", FCVAR_READ_ONLY, "current quake netport" );
CVAR_DEFINE_AUTO( net_send_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for outgoing messages" );
CVAR_DEFINE_AUTO( net_recv_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for incoming messages" );
int net_drop;
netadr_t net_from;
@@ -100,58 +98,12 @@ sizebuf_t net_message;
static poolhandle_t net_mempool;
byte net_message_buffer[NET_MAX_MESSAGE];
static const char *const ns_strings[NS_COUNT] =
const char *ns_strings[NS_COUNT] =
{
"Client",
"Server",
};
#if !XASH_DEDICATED
void bz_internal_error( int errcode );
void bz_internal_error( int errcode )
{
Con_Printf( S_ERROR "bzip2/libbzip2: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, %s.\n"
"Please report it at: https://gitlab.com/bzip2/bzip2/-/issues\n"
"If this happened when you were using some program which uses\n"
"libbzip2 as a component, you should also report this bug to\n"
"the author(s) of that program.\n"
"Please make an effort to report this bug;\n"
"timely and accurate bug reports eventually lead to higher\n"
"quality software. Thanks.\n\n",
errcode, BZ2_bzlibVersion( ));
if (errcode == 1007) {
Con_Printf(
"\n*** A special note about internal error number 1007 ***\n"
"\n"
"Experience suggests that a common cause of i.e. 1007\n"
"is unreliable memory or other hardware. The 1007 assertion\n"
"just happens to cross-check the results of huge numbers of\n"
"memory reads/writes, and so acts (unintendedly) as a stress\n"
"test of your memory system.\n"
"\n"
"I suggest the following: try compressing the file again,\n"
"possibly monitoring progress in detail with the -vv flag.\n"
"\n"
"* If the error cannot be reproduced, and/or happens at different\n"
" points in compression, you may have a flaky memory system.\n"
" Try a memory-test program. I have used Memtest86\n"
" (www.memtest86.com). At the time of writing it is free (GPLd).\n"
" Memtest86 tests memory much more thorougly than your BIOSs\n"
" power-on test, and may find failures that the BIOS doesn't.\n"
"\n"
"* If the error can be repeatably reproduced, this is a bug in\n"
" bzip2, and I would very much like to hear about it. Please\n"
" let me know, and, ideally, save a copy of the file causing the\n"
" problem -- without which I will be unable to investigate it.\n"
"\n"
);
}
Sys_Error( "bzip2/libbzip2: internal error number %d\n", errcode );
}
#endif // XASH_DEDICATED
/*
=================================
@@ -267,8 +219,6 @@ void Netchan_Init( void )
Cvar_RegisterVariable( &net_chokeloop );
Cvar_RegisterVariable( &net_showdrop );
Cvar_RegisterVariable( &net_qport );
Cvar_RegisterVariable( &net_send_debug );
Cvar_RegisterVariable( &net_recv_debug );
Cvar_FullSet( net_qport.name, buf, net_qport.flags );
net_mempool = Mem_AllocPool( "Network Pool" );
@@ -746,29 +696,21 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
if( chan->use_bz2 && memcmp( MSG_GetData( msg ), "BZ2", 4 ))
{
#if !XASH_DEDICATED
byte pbOut[0x10000];
uint uSourceSize = MSG_GetNumBytesWritten( msg );
uint uCompressedSize = MSG_GetNumBytesWritten( msg ) - 4;
if( !BZ2_bzBuffToBuffCompress( pbOut, &uCompressedSize, MSG_GetData( msg ), uSourceSize, 9, 0, 30 ))
if( !BZ2_bzBuffToBuffCompress( pbOut, &uCompressedSize, MSG_GetData( msg ), MSG_GetNumBytesWritten( msg ), 9, 0, 30 ))
{
if( uCompressedSize < uSourceSize )
{
Con_Reportf( "Compressing split packet with BZip2 (%d -> %d bytes)\n", uSourceSize, uCompressedSize );
memcpy( msg->pData, "BZ2", 4 );
memcpy( msg->pData + 4, pbOut, uCompressedSize );
MSG_SeekToBit( msg, uCompressedSize << 3, SEEK_SET );
}
Con_Reportf( "Compressing split packet with BZip2 (%d -> %d bytes)\n", MSG_GetNumBytesWritten( msg ), uCompressedSize );
memcpy( msg->pData, "BZ2", 4 );
memcpy( msg->pData + 4, pbOut, uCompressedSize );
MSG_SeekToBit( msg, uCompressedSize << 3, SEEK_SET );
}
#else
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
#endif
}
else if( !chan->use_bz2 && !LZSS_IsCompressed( MSG_GetData( msg )))
{
uint uCompressedSize = 0;
uint uSourceSize = MSG_GetNumBytesWritten( msg );
byte *pbOut = LZSS_Compress( msg->pData, uSourceSize, &uCompressedSize );
uint uCompressedSize = 0;
uint uSourceSize = MSG_GetNumBytesWritten( msg );
byte *pbOut = LZSS_Compress( msg->pData, uSourceSize, &uCompressedSize );
if( pbOut && uCompressedSize > 0 && uCompressedSize < uSourceSize )
{
@@ -1017,7 +959,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
Con_Printf( S_WARN "Unable to transfer %s due to path length overflow\n", filename );
return 0;
}
if(( filesize = FS_FileSize( filename, false )) <= 0 )
{
Con_Printf( S_WARN "Unable to open %s for transfer\n", filename );
@@ -1177,16 +1119,12 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l
if( chan->use_bz2 && !memcmp( MSG_GetData( msg ), "BZ2", 4 ) )
{
#if !XASH_DEDICATED
byte buf[0x10000];
uint uDecompressedLen = sizeof( buf );
BZ2_bzBuffToBuffDecompress( buf, &uDecompressedLen, MSG_GetData( msg ) + 4, MSG_GetNumBytesWritten( msg ) - 4, 1, 0 );
memcpy( msg->pData, buf, uDecompressedLen );
size = uDecompressedLen;
#else
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
#endif
}
else if( !chan->use_bz2 && LZSS_IsCompressed( MSG_GetData( msg )))
{
@@ -1325,19 +1263,18 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
p = n;
}
if( chan->gs_netchan && chan->use_bz2 && !Q_stricmp( compressor, "bz2" ))
if( chan->gs_netchan && chan->use_bz2 )
{
#if !XASH_DEDICATED
byte *uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
if( !Q_stricmp( compressor, "bz2" ))
{
byte *uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
Con_DPrintf( "Decompressing file %s (%d -> %d bytes)\n", filename, nsize, uncompressedSize );
BZ2_bzBuffToBuffDecompress( uncompressedBuffer, &uncompressedSize, buffer, nsize, 1, 0 );
Mem_Free( buffer );
nsize = uncompressedSize;
buffer = uncompressedBuffer;
#else
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
#endif
Con_DPrintf( "Decompressing file %s (%d -> %d bytes)\n", filename, nsize, uncompressedSize );
BZ2_bzBuffToBuffDecompress( uncompressedBuffer, &uncompressedSize, buffer, nsize, 1, 0 );
Mem_Free( buffer );
nsize = uncompressedSize;
buffer = uncompressedBuffer;
}
}
else if( LZSS_IsCompressed( buffer ))
{

View File

@@ -376,74 +376,13 @@ static delta_info_t dt_info[] =
[DT_ENTITY_STATE_T] = { "entity_state_t", ent_fields, NUM_FIELDS( ent_fields ) },
[DT_ENTITY_STATE_PLAYER_T] = { "entity_state_player_t", ent_fields, NUM_FIELDS( ent_fields ) },
[DT_CUSTOM_ENTITY_STATE_T] = { "custom_entity_state_t", ent_fields, NUM_FIELDS( ent_fields ) },
[DT_GOLDSRC_DELTA_T] = { "goldsrc_delta_t", meta_fields, NUM_FIELDS( meta_fields ) },
#if XASH_ENGINE_TESTS
[DT_DELTA_TEST_STRUCT_T] = { "delta_test_struct_t", test_fields, NUM_FIELDS( test_fields ) },
#endif
[DT_STRUCT_COUNT] = { NULL },
};
// meta description is special, it cannot be overriden
static const delta_info_t dt_goldsrc_meta =
{
.pName = "goldsrc_delta_t",
.pInfo = meta_fields,
.maxFields = NUM_FIELDS( meta_fields ),
.numFields = NUM_FIELDS( meta_fields ),
.pFields = (delta_t[NUM_FIELDS( meta_fields )])
{
{
DESC_DEF( fieldType ),
.flags = DT_INTEGER,
.multiplier = 1.0f,
.post_multiplier = 1.0f,
.bits = 32,
},
{
DESC_DEF( fieldName ),
.flags = DT_STRING,
.multiplier = 1.0f,
.post_multiplier = 1.0f,
.bits = 1,
},
{
DESC_DEF( fieldOffset ),
.flags = DT_INTEGER,
.multiplier = 1.0f,
.post_multiplier = 1.0f,
.bits = 16,
},
{
DESC_DEF( fieldSize ),
.flags = DT_INTEGER,
.multiplier = 1.0f,
.post_multiplier = 1.0f,
.bits = 8,
},
{
DESC_DEF( significant_bits ),
.flags = DT_INTEGER,
.multiplier = 1.0f,
.post_multiplier = 1.0f,
.bits = 8,
},
{
DESC_DEF( premultiply ),
.flags = DT_FLOAT,
.multiplier = 4000.0f,
.post_multiplier = 1.0f,
.bits = 32,
},
{
DESC_DEF( postmultiply ),
.flags = DT_FLOAT,
.multiplier = 4000.0f,
.post_multiplier = 1.0f,
.bits = 32,
},
},
.bInitialized = true
};
static delta_info_t *Delta_FindStruct( const char *name )
{
int i;
@@ -681,6 +620,64 @@ void Delta_ParseTableField( sizebuf_t *msg )
Delta_AddField( dt, pName, flags, bits, mul, post_mul );
}
void Delta_InitMeta( void )
{
delta_info_t *dt = Delta_FindStructByIndex( DT_GOLDSRC_DELTA_T );
if( dt->bInitialized )
return;
Delta_AddField( dt, "fieldType", DT_INTEGER, 32, 1.0f, 1.0f );
Delta_AddField( dt, "fieldName", DT_STRING, 1, 1.0f, 1.0f );
Delta_AddField( dt, "fieldOffset", DT_INTEGER, 16, 1.0f, 1.0f );
Delta_AddField( dt, "fieldSize", DT_INTEGER, 8, 1.0f, 1.0f );
Delta_AddField( dt, "significant_bits", DT_INTEGER, 8, 1.0f, 1.0f );
Delta_AddField( dt, "premultiply", DT_FLOAT, 32, 4000.0f, 1.0f );
Delta_AddField( dt, "postmultiply", DT_FLOAT, 32, 4000.0f, 1.0f );
dt->numFields = dt->maxFields;
dt->bInitialized = true;
}
void Delta_ParseTableField_GS( sizebuf_t *msg )
{
const char *s = MSG_ReadString( msg );
delta_info_t *dt = Delta_FindStruct( s );
goldsrc_delta_t null = { 0 };
int i, num_fields;
// delta encoders it's already initialized on this machine (local game)
if( delta_init )
{
Delta_Shutdown();
Delta_InitMeta();
}
if( !dt )
Host_Error( "%s: not initialized", __func__ );
num_fields = MSG_ReadShort( msg );
if( num_fields > dt->maxFields )
Host_Error( "%s: numFields > maxFields", __func__ );
MSG_StartBitWriting( msg );
for( i = 0; i < num_fields; i++ )
{
goldsrc_delta_t to;
Delta_ReadGSFields( msg, DT_GOLDSRC_DELTA_T, &null, &to, 0.0f );
// patch our DT_SIGNED flag
if( FBitSet( to.fieldType, DT_SIGNED_GS ))
SetBits( to.fieldType, DT_SIGNED );
Delta_AddField( dt, to.fieldName, to.fieldType, to.significant_bits, to.premultiply, to.postmultiply );
}
MSG_EndBitWriting( msg );
}
static qboolean Delta_ParseField( char **delta_script, const delta_field_t *pInfo, delta_t *pField, qboolean bPost )
{
string token;
@@ -1322,6 +1319,7 @@ static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, const void *f
Delta_WriteField_( msg, pField, from, to, timebase );
return true;
return true;
}
/*
@@ -1484,8 +1482,9 @@ static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, const void *fr
return true;
}
static void Delta_ParseGSFields( sizebuf_t *msg, const delta_info_t *dt, const void *from, void *to, double timebase )
void Delta_ReadGSFields( sizebuf_t *msg, int index, void *from, void *to, double timebase )
{
delta_info_t *dt = Delta_FindStructByIndex( index );
uint8_t bits[8] = { 0 };
delta_t *pField;
byte c;
@@ -1507,13 +1506,7 @@ static void Delta_ParseGSFields( sizebuf_t *msg, const delta_info_t *dt, const v
}
}
void Delta_ReadGSFields( sizebuf_t *msg, int index, const void *from, void *to, double timebase )
{
const delta_info_t *dt = Delta_FindStructByIndex( index );
Delta_ParseGSFields( msg, dt, from, to, timebase );
}
void Delta_WriteGSFields( sizebuf_t *msg, int index, const void *from, const void *to, double timebase )
void Delta_WriteGSFields( sizebuf_t *msg, int index, void *from, void *to, double timebase )
{
delta_info_t *dt = Delta_FindStructByIndex( index );
delta_t *pField;
@@ -2111,44 +2104,6 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity
return true;
}
void Delta_ParseTableField_GS( sizebuf_t *msg )
{
const char *s = MSG_ReadString( msg );
delta_info_t *dt = Delta_FindStruct( s );
goldsrc_delta_t null = { 0 };
int i, num_fields;
// delta encoders it's already initialized on this machine (local game)
if( delta_init )
Delta_Shutdown();
if( !dt )
Host_Error( "%s: not initialized", __func__ );
num_fields = MSG_ReadShort( msg );
if( num_fields > dt->maxFields )
Host_Error( "%s: numFields > maxFields", __func__ );
MSG_StartBitWriting( msg );
for( i = 0; i < num_fields; i++ )
{
goldsrc_delta_t to;
Delta_ParseGSFields( msg, &dt_goldsrc_meta, &null, &to, 0.0f );
// patch our DT_SIGNED flag
if( FBitSet( to.fieldType, DT_SIGNED_GS ))
{
ClearBits( to.fieldType, DT_SIGNED_GS );
SetBits( to.fieldType, DT_SIGNED );
}
Delta_AddField( dt, to.fieldName, to.fieldType, to.significant_bits, to.premultiply, to.postmultiply );
}
MSG_EndBitWriting( msg );
}
/*
==================
Delta_WriteDescriptionToClient

View File

@@ -43,6 +43,7 @@ enum
DT_ENTITY_STATE_T,
DT_ENTITY_STATE_PLAYER_T,
DT_CUSTOM_ENTITY_STATE_T,
DT_GOLDSRC_DELTA_T,
#if XASH_ENGINE_TESTS
DT_DELTA_TEST_STRUCT_T,
#endif
@@ -103,6 +104,7 @@ typedef struct
//
void Delta_Init( void );
void Delta_InitClient( void );
void Delta_InitMeta( void );
void Delta_Shutdown( void );
void Delta_AddEncoder( char *name, pfnDeltaEncode encodeFunc );
int Delta_FindField( delta_t *pFields, const char *fieldname );
@@ -137,7 +139,7 @@ void MSG_ReadWeaponData( sizebuf_t *msg, const struct weapon_data_s *from, struc
void MSG_WriteDeltaEntity( const struct entity_state_s *from, const struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs );
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase );
int Delta_TestBaseline( const struct entity_state_s *from, const struct entity_state_s *to, qboolean player, double timebase );
void Delta_ReadGSFields( sizebuf_t *msg, int index, const void *from, void *to, double timebase );
void Delta_WriteGSFields( sizebuf_t *msg, int index, const void *from, const void *to, double timebase );
void Delta_ReadGSFields( sizebuf_t *msg, int index, void *from, void *to, double timebase );
void Delta_WriteGSFields( sizebuf_t *msg, int index, void *from, void *to, double timebase );
#endif//NET_ENCODE_H

View File

@@ -39,11 +39,10 @@ static const struct in6_addr in6addr_any;
#define MAX_LOOPBACK 4
#define MASK_LOOPBACK (MAX_LOOPBACK - 1)
#define MAX_ROUTEABLE_PACKET 1400
#define SPLITPACKET_MIN_SIZE 508 // RFC 791: 576(min ip packet) - 60 (ip header) - 8 (udp header)
#define SPLITPACKET_MAX_SIZE 64000
#define NET_MAX_FRAGMENTS ( NET_MAX_FRAGMENT / (SPLITPACKET_MIN_SIZE - sizeof( SPLITPACKET )))
#define NET_MAX_GOLDSRC_FRAGMENTS 5 // magic number
#define MAX_ROUTEABLE_PACKET 1400
#define SPLITPACKET_MIN_SIZE 508 // RFC 791: 576(min ip packet) - 60 (ip header) - 8 (udp header)
#define SPLITPACKET_MAX_SIZE 64000
#define NET_MAX_FRAGMENTS ( NET_MAX_FRAGMENT / (SPLITPACKET_MIN_SIZE - sizeof( SPLITPACKET )))
// ff02:1
static const uint8_t k_ipv6Bytes_LinkLocalAllNodes[16] =
@@ -146,7 +145,7 @@ static void NET_ClearLagData( qboolean bClient, qboolean bServer );
NET_ErrorString
====================
*/
static const char *NET_ErrorString( void )
static char *NET_ErrorString( void )
{
#if XASH_WIN32
int err = WSANOTINITIALISED;
@@ -1366,7 +1365,6 @@ static qboolean NET_GetLong( byte *pData, int size, size_t *outSize, int splitsi
short packet_id;
size_t header_size = proto == PROTO_GOLDSRC ? sizeof( SPLITPACKETGS ) : sizeof( SPLITPACKET );
int body_size = splitsize - header_size;
int max_splits;
if( body_size < 0 )
return false;
@@ -1385,8 +1383,6 @@ static qboolean NET_GetLong( byte *pData, int size, size_t *outSize, int splitsi
packet_id = pHeader->packet_id;
packet_count = ( packet_id & 0xF );
packet_number = ( packet_id >> 4 );
max_splits = NET_MAX_GOLDSRC_FRAGMENTS;
}
else
{
@@ -1396,11 +1392,9 @@ static qboolean NET_GetLong( byte *pData, int size, size_t *outSize, int splitsi
packet_id = pHeader->packet_id;
packet_count = ( packet_id & 0xFF );
packet_number = ( packet_id >> 8 );
max_splits = ARRAYSIZE( net.split_flags );
}
if( packet_number >= max_splits || packet_count > max_splits )
if( packet_number >= NET_MAX_FRAGMENTS || packet_count > NET_MAX_FRAGMENTS )
{
Con_Printf( S_ERROR "malformed packet number (%i/%i)\n", packet_number + 1, packet_count );
return false;
@@ -1413,7 +1407,7 @@ static qboolean NET_GetLong( byte *pData, int size, size_t *outSize, int splitsi
net.split.total_size = 0;
// clear part's sequence
for( i = 0; i < ARRAYSIZE( net.split_flags ); i++ )
for( i = 0; i < NET_MAX_FRAGMENTS; i++ )
net.split_flags[i] = -1;
if( net_showpackets.value == 4.0f )

View File

@@ -50,10 +50,8 @@ typedef enum
#include "netadr.h"
extern convar_t net_showpackets;
extern convar_t net_clockwindow;
extern convar_t net_send_debug;
extern convar_t net_recv_debug;
extern convar_t net_showpackets;
extern convar_t net_clockwindow;
void NET_Init( void );
void NET_Shutdown( void );

95
engine/common/pm_debug.c Normal file
View File

@@ -0,0 +1,95 @@
/*
pm_debug.c - player move debugging code
Copyright (C) 2017 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "xash3d_mathlib.h"
#include "pm_local.h"
#if !XASH_DEDICATED
#include "client.h" // CL_Particle
#endif
// expand debugging BBOX particle hulls by this many units.
#define BOX_GAP 0.0f
/*
===============
PM_ParticleLine
draw line from particles
================
*/
void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel )
{
#if !XASH_DEDICATED
float len, curdist;
vec3_t diff, pos;
// determine distance
VectorSubtract( end, start, diff );
len = VectorNormalizeLength( diff );
curdist = 0;
while( curdist <= len )
{
VectorMA( start, curdist, diff, pos );
CL_Particle( pos, pcolor, life, 0, zvel );
curdist += 2.0f;
}
#endif // XASH_DEDICATED
}
/*
================
PM_DrawRectangle
================
*/
static void PM_DrawRectangle( const vec3_t tl, const vec3_t bl, const vec3_t tr, const vec3_t br, int pcolor, float life )
{
PM_ParticleLine( tl, bl, pcolor, life, 0 );
PM_ParticleLine( bl, br, pcolor, life, 0 );
PM_ParticleLine( br, tr, pcolor, life, 0 );
PM_ParticleLine( tr, tl, pcolor, life, 0 );
}
/*
================
PM_DrawBBox
================
*/
void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int pcolor, float life )
{
#if !XASH_DEDICATED
vec3_t p[8], tmp;
float gap = BOX_GAP;
int i;
for( i = 0; i < 8; i++ )
{
tmp[0] = (i & 1) ? mins[0] - gap : maxs[0] + gap;
tmp[1] = (i & 2) ? mins[1] - gap : maxs[1] + gap ;
tmp[2] = (i & 4) ? mins[2] - gap : maxs[2] + gap ;
VectorAdd( tmp, origin, tmp );
VectorCopy( tmp, p[i] );
}
for( i = 0; i < 6; i++ )
{
PM_DrawRectangle( p[boxpnt[i][1]], p[boxpnt[i][0]], p[boxpnt[i][2]], p[boxpnt[i][3]], pcolor, life );
}
#endif // XASH_DEDICATED
}

View File

@@ -20,10 +20,17 @@ GNU General Public License for more details.
typedef int (*pfnIgnore)( physent_t *pe ); // custom trace filter
//
// pm_debug.c
//
void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel );
void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int pcolor, float life );
//
// pm_trace.c
//
void Pmove_Init( void );
void PM_ClearPhysEnts( playermove_t *pmove );
void PM_InitBoxHull( void );
hull_t *PM_HullForBsp( physent_t *pe, playermove_t *pmove, float *offset );
qboolean PM_RecursiveHullCheck( hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace );
@@ -39,29 +46,7 @@ struct msurface_s *PM_TraceSurfacePmove( playermove_t *pmove, int ground, float
const char *PM_TraceTexture( playermove_t *pmove, int ground, float *vstart, float *vend );
int PM_PointContentsPmove( playermove_t *pmove, const float *p, int *truecontents );
void PM_StuckTouch( playermove_t *pmove, int hitent, pmtrace_t *tr );
static inline void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent )
{
out->allsolid = in->allsolid;
out->startsolid = in->startsolid;
out->inopen = in->inopen;
out->inwater = in->inwater;
out->fraction = in->fraction;
out->plane.dist = in->plane.dist;
out->hitgroup = in->hitgroup;
out->ent = ent;
VectorCopy( in->endpos, out->endpos );
VectorCopy( in->plane.normal, out->plane.normal );
}
static inline void PM_ClearPhysEnts( playermove_t *pmove )
{
pmove->nummoveent = 0;
pmove->numphysent = 0;
pmove->numvisent = 0;
pmove->numtouch = 0;
}
void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent );
static inline void PM_InitTrace( trace_t *trace, const vec3_t end )
{

View File

@@ -55,6 +55,14 @@ void Pmove_Init( void )
memcpy( host.player_maxs, pm_hullmaxs, sizeof( pm_hullmaxs ));
}
void PM_ClearPhysEnts( playermove_t *pmove )
{
pmove->nummoveent = 0;
pmove->numphysent = 0;
pmove->numvisent = 0;
pmove->numtouch = 0;
}
/*
===================
PM_InitBoxHull
@@ -109,6 +117,21 @@ static hull_t *PM_HullForBox( const vec3_t mins, const vec3_t maxs )
return &pm_boxhull;
}
void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent )
{
out->allsolid = in->allsolid;
out->startsolid = in->startsolid;
out->inopen = in->inopen;
out->inwater = in->inwater;
out->fraction = in->fraction;
out->plane.dist = in->plane.dist;
out->hitgroup = in->hitgroup;
out->ent = ent;
VectorCopy( in->endpos, out->endpos );
VectorCopy( in->plane.normal, out->plane.normal );
}
/*
==================
PM_HullPointContents

View File

@@ -93,7 +93,7 @@ GNU General Public License for more details.
#define clc_voicedata 8
#define clc_requestcvarvalue 9
#define clc_requestcvarvalue2 10
#define clc_lastmsg 11 // end client messages (11 is GoldSrc message)
#define clc_lastmsg 10 // end client messages
#define MAX_VISIBLE_PACKET_BITS 11 // 2048 visible entities per frame (hl1 has 256)
#define MAX_VISIBLE_PACKET (1<<MAX_VISIBLE_PACKET_BITS)
@@ -277,11 +277,11 @@ GNU General Public License for more details.
#define SU_ARMOR (1<<13)
#define SU_WEAPON (1<<14)
extern const char *const svc_strings[svc_lastmsg+1];
extern const char *const svc_legacy_strings[svc_lastmsg+1];
extern const char *const svc_quake_strings[svc_lastmsg+1];
extern const char *const svc_goldsrc_strings[svc_lastmsg+1];
extern const char *const clc_strings[clc_lastmsg+1];
extern const char *svc_strings[svc_lastmsg+1];
extern const char *svc_legacy_strings[svc_lastmsg+1];
extern const char *svc_quake_strings[svc_lastmsg+1];
extern const char *svc_goldsrc_strings[svc_lastmsg+1];
extern const char *clc_strings[clc_lastmsg+1];
// FWGS extensions
#define NET_EXT_SPLITSIZE (1U<<0) // set splitsize by cl_dlmax
@@ -341,16 +341,13 @@ extern const char *const clc_strings[clc_lastmsg+1];
#define clc_goldsrc_hltv clc_requestcvarvalue // 9
#define clc_goldsrc_requestcvarvalue clc_requestcvarvalue2 // 10
#define clc_goldsrc_requestcvarvalue2 11
#define clc_goldsrc_lastmsg 11
#define clc_goldsrc_lastmsg 12
#define S2C_REJECT_BADPASSWORD '8'
#define S2C_REJECT '9'
#define S2C_CHALLENGE "A00000000"
#define S2C_CONNECTION "B"
#define A2C_PRINT 'l'
#define MAX_GOLDSRC_BACKUP_CMDS 8
#define MAX_GOLDSRC_TOTAL_CMDS 16
#define MAX_GOLDSRC_MODEL_BITS 10
#define MAX_GOLDSRC_RESOURCE_BITS 12
#define MAX_GOLDSRC_ENTITY_BITS 11

View File

@@ -21,7 +21,7 @@ enum soundlst_type_e
SoundList_List
};
static const char *const soundlst_groups[SoundList_Groups] =
static const char *soundlst_groups[SoundList_Groups] =
{
"BouncePlayerShell",
"BounceWeaponShell",
@@ -46,7 +46,7 @@ typedef struct soundlst_s
int max; // the string count if type is group
} soundlst_t;
static soundlst_t soundlst[SoundList_Groups];
soundlst_t soundlst[SoundList_Groups];
static void SoundList_Print_f( void );
static void SoundList_Free( soundlst_t *lst )

View File

@@ -41,7 +41,6 @@ void Test_RunIPFilter( void );
void Test_RunGamma( void );
void Test_RunDelta( void );
void Test_RunBuffer( void );
void Test_RunMunge( void );
#define TEST_LIST_0 \
Test_RunLibCommon(); \

View File

@@ -20,6 +20,47 @@ GNU General Public License for more details.
#include "xash3d_mathlib.h"
#include "studio.h"
/*
==================
World_MoveBounds
==================
*/
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs )
{
int i;
for( i = 0; i < 3; i++ )
{
if( end[i] > start[i] )
{
boxmins[i] = start[i] + mins[i] - 1.0f;
boxmaxs[i] = end[i] + maxs[i] + 1.0f;
}
else
{
boxmins[i] = end[i] + mins[i] - 1.0f;
boxmaxs[i] = start[i] + maxs[i] + 1.0f;
}
}
}
trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch )
{
if( trace->allsolid || trace->startsolid || trace->fraction < cliptrace->fraction )
{
trace->ent = touch;
if( cliptrace->startsolid )
{
*cliptrace = *trace;
cliptrace->startsolid = true;
}
else *cliptrace = *trace;
}
return *cliptrace;
}
/*
==================
World_TransformAABB
@@ -66,3 +107,31 @@ void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t m
}
}
}
/*
==================
RankForContents
Used for determine contents priority
==================
*/
int RankForContents( int contents )
{
switch( contents )
{
case CONTENTS_EMPTY: return 0;
case CONTENTS_WATER: return 1;
case CONTENTS_TRANSLUCENT: return 2;
case CONTENTS_CURRENT_0: return 3;
case CONTENTS_CURRENT_90: return 4;
case CONTENTS_CURRENT_180: return 5;
case CONTENTS_CURRENT_270: return 6;
case CONTENTS_CURRENT_UP: return 7;
case CONTENTS_CURRENT_DOWN: return 8;
case CONTENTS_SLIME: return 9;
case CONTENTS_LAVA: return 10;
case CONTENTS_SKY: return 11;
case CONTENTS_SOLID: return 12;
default: return 13; // any user contents has more priority than default
}
}

View File

@@ -36,71 +36,10 @@ ENTITY AREA CHECKING
#include "lightstyle.h"
// trace common
static inline void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs )
{
int i;
for( i = 0; i < 3; i++ )
{
if( end[i] > start[i] )
{
boxmins[i] = start[i] + mins[i] - 1.0f;
boxmaxs[i] = end[i] + maxs[i] + 1.0f;
}
else
{
boxmins[i] = end[i] + mins[i] - 1.0f;
boxmaxs[i] = start[i] + maxs[i] + 1.0f;
}
}
}
static inline trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch )
{
if( trace->allsolid || trace->startsolid || trace->fraction < cliptrace->fraction )
{
trace->ent = touch;
if( cliptrace->startsolid )
{
*cliptrace = *trace;
cliptrace->startsolid = true;
}
else *cliptrace = *trace;
}
return *cliptrace;
}
/*
==================
RankForContents
Used for determine contents priority
==================
*/
static inline int RankForContents( int contents )
{
switch( contents )
{
case CONTENTS_EMPTY: return 0;
case CONTENTS_WATER: return 1;
case CONTENTS_TRANSLUCENT: return 2;
case CONTENTS_CURRENT_0: return 3;
case CONTENTS_CURRENT_90: return 4;
case CONTENTS_CURRENT_180: return 5;
case CONTENTS_CURRENT_270: return 6;
case CONTENTS_CURRENT_UP: return 7;
case CONTENTS_CURRENT_DOWN: return 8;
case CONTENTS_SLIME: return 9;
case CONTENTS_LAVA: return 10;
case CONTENTS_SKY: return 11;
case CONTENTS_SOLID: return 12;
default: return 13; // any user contents has more priority than default
}
}
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs );
void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t maxs, vec3_t outmins, vec3_t outmaxs );
trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch );
int RankForContents( int contents );
#define check_angles( x ) ( (int)x == 90 || (int)x == 180 || (int)x == 270 || (int)x == -90 || (int)x == -180 || (int)x == -270 )

View File

@@ -64,7 +64,6 @@ typedef enum
force_exactfile, // File on client must exactly match server's file
force_model_samebounds, // For model files only, the geometry must fit in the same bbox
force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox
force_model_specifybounds_if_avail,
} FORCE_TYPE;
// Returned by TraceLine

View File

@@ -51,7 +51,6 @@ void IOS_LaunchDialog( void );
#if XASH_POSIX
void Posix_Daemonize( void );
void Posix_SetupSigtermHandling( void );
#endif
#if XASH_SDL
@@ -157,13 +156,6 @@ static inline qboolean Sys_DebuggerPresent( void )
#endif
}
static inline void Platform_SetupSigtermHandling( void )
{
#if XASH_POSIX
Posix_SetupSigtermHandling( );
#endif
}
/*
==============================================================================

View File

@@ -18,7 +18,6 @@ GNU General Public License for more details.
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include "platform/platform.h"
#include "menu_int.h"
@@ -146,21 +145,6 @@ void Posix_Daemonize( void )
}
static void Posix_SigtermCallback( int signal )
{
Sys_Quit();
}
void Posix_SetupSigtermHandling( void )
{
#if !XASH_PSVITA
struct sigaction act = { 0 };
act.sa_handler = Posix_SigtermCallback;
act.sa_flags = 0;
sigaction( SIGTERM, &act, NULL );
#endif
}
#if XASH_TIMER == TIMER_POSIX
double Platform_DoubleTime( void )
{

View File

@@ -19,7 +19,7 @@ GNU General Public License for more details.
#include "net_encode.h"
#include "net_api.h"
const char *const clc_strings[clc_lastmsg+1] =
const char *clc_strings[clc_lastmsg+1] =
{
"clc_bad",
"clc_nop",
@@ -27,12 +27,11 @@ const char *const clc_strings[clc_lastmsg+1] =
"clc_stringcmd",
"clc_delta",
"clc_resourcelist",
"clc_legacy_userinfo",
"clc_unused6",
"clc_fileconsistency",
"clc_voicedata",
"clc_cvarvalue/clc_goldsrc_hltv",
"clc_cvarvalue2/clc_goldsrc_requestcvarvalue",
"clc_goldsrc_requestcvarvalue2",
"clc_cvarvalue",
"clc_cvarvalue2",
};
typedef struct ucmd_s
@@ -1343,8 +1342,9 @@ otherwise see code SV_UpdateMovevars()
*/
void SV_FullUpdateMovevars( sv_client_t *cl, sizebuf_t *msg )
{
const movevars_t nullmovevars = { 0 };
movevars_t nullmovevars;
memset( &nullmovevars, 0, sizeof( nullmovevars ));
MSG_WriteDeltaMovevars( msg, &nullmovevars, &svgame.movevars );
}
@@ -3036,7 +3036,7 @@ static qboolean SV_EntGetVars_f( sv_client_t *cl )
return true;
}
static const ucmd_t ucmds[] =
ucmd_t ucmds[] =
{
{ "new", SV_New_f },
{ "god", SV_Godmode_f },
@@ -3056,7 +3056,7 @@ static const ucmd_t ucmds[] =
{ NULL, NULL }
};
static const ucmd_t enttoolscmds[] =
ucmd_t enttoolscmds[] =
{
{ "ent_list", SV_EntList_f },
{ "ent_info", SV_EntInfo_f },
@@ -3073,7 +3073,7 @@ SV_ExecuteUserCommand
*/
static void SV_ExecuteClientCommand( sv_client_t *cl, const char *s )
{
const ucmd_t *u;
ucmd_t *u;
Cmd_TokenizeString( s );

View File

@@ -16,6 +16,8 @@ GNU General Public License for more details.
#include "common.h"
#include "server.h"
extern convar_t con_gamemaps;
/*
=================
SV_ClientPrintf

View File

@@ -25,8 +25,8 @@ typedef struct
byte sended[MAX_EDICTS_BYTES];
} sv_ents_t;
static int c_fullsend; // just a debug counter
static int c_notsend;
int c_fullsend; // just a debug counter
int c_notsend;
/*
=======================

View File

@@ -24,6 +24,8 @@ GNU General Public License for more details.
#include "render_api.h" // modelstate_t
#include "ref_common.h" // decals
#define ENTVARS_COUNT ARRAYSIZE( gEntvarsDescription )
// GameAPI functions declarations
static int GAME_EXPORT pfnModelIndex( const char *m );
@@ -81,7 +83,7 @@ EntvarsDescription
entavrs table for FindEntityByString
=============
*/
static const TYPEDESCRIPTION gEntvarsDescription[] =
static TYPEDESCRIPTION gEntvarsDescription[] =
{
DEFINE_ENTITY_FIELD( classname, FIELD_STRING ),
DEFINE_ENTITY_FIELD( globalname, FIELD_STRING ),
@@ -98,6 +100,20 @@ static const TYPEDESCRIPTION gEntvarsDescription[] =
DEFINE_ENTITY_FIELD( noise3, FIELD_SOUNDNAME ),
};
/*
=============
SV_GetEntvarsDescription
entavrs table for FindEntityByString
=============
*/
static TYPEDESCRIPTION *SV_GetEntvarsDescirption( int number )
{
if( number < 0 || number >= ENTVARS_COUNT )
return NULL;
return &gEntvarsDescription[number];
}
/*
=============
SV_SysError
@@ -1490,8 +1506,8 @@ SV_FindEntityByString
*/
static edict_t *GAME_EXPORT SV_FindEntityByString( edict_t *pStartEdict, const char *pszField, const char *pszValue )
{
int i = 0, e = 0;
const TYPEDESCRIPTION *desc = NULL;
int index = 0, e = 0;
TYPEDESCRIPTION *desc = NULL;
edict_t *ed;
const char *t;
@@ -1500,13 +1516,10 @@ static edict_t *GAME_EXPORT SV_FindEntityByString( edict_t *pStartEdict, const c
if( pStartEdict ) e = NUM_FOR_EDICT( pStartEdict );
for( i = 0; i < ARRAYSIZE( gEntvarsDescription ); i++ )
while(( desc = SV_GetEntvarsDescirption( index++ )) != NULL )
{
if( !Q_strcmp( pszField, gEntvarsDescription[i].fieldName ))
{
desc = &gEntvarsDescription[i];
if( !Q_strcmp( pszField, desc->fieldName ))
break;
}
}
if( desc == NULL )

View File

@@ -1028,8 +1028,6 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba
if( !SV_InitGame( ))
return false;
Delta_Init(); // re-initialize delta
// unlock sv_cheats in local game
ClearBits( sv_cheats.flags, FCVAR_READ_ONLY );

View File

@@ -82,7 +82,7 @@ typedef struct
float time;
} SAVE_LIGHTSTYLE;
static void (__cdecl *pfnSaveGameComment)( char *buffer, int max_length ) = NULL;
void (__cdecl *pfnSaveGameComment)( char *buffer, int max_length ) = NULL;
static TYPEDESCRIPTION gGameHeader[] =
{
@@ -218,7 +218,7 @@ static TYPEDESCRIPTION gTempEntvars[] =
DEFINE_ENTITY_GLOBAL_FIELD( globalname, FIELD_STRING ),
};
static const struct
struct
{
const char *mapname;
const char *titlename;
@@ -2185,19 +2185,6 @@ qboolean SV_SaveGame( const char *pName )
return SaveGameSlot( savename, comment );
}
static int SV_CompareFileTime( int ft1, int ft2 )
{
if( ft1 < ft2 )
{
return -1;
}
else if( ft1 > ft2 )
{
return 1;
}
return 0;
}
/*
==================
SV_GetLatestSave
@@ -2223,7 +2210,7 @@ const char *SV_GetLatestSave( void )
if( ft > 0 )
{
// should we use the matched?
if( !found || SV_CompareFileTime( newest, ft ) < 0 )
if( !found || Host_CompareFileTime( newest, ft ) < 0 )
{
Q_strncpy( savename, t->filenames[i], sizeof( savename ));
newest = ft;

View File

@@ -80,24 +80,14 @@ def configure(conf):
conf.env.HAVE_SDL2 = True
else:
conf.load('sdl2')
if conf.options.SDL3:
if not conf.env.HAVE_SDL3:
conf.fatal('SDL3 not available! If you want to build dedicated server, specify --dedicated')
conf.define('XASH_SDL', 3)
else:
if not conf.env.HAVE_SDL2:
conf.fatal('SDL2 not available! If you want to build dedicated server, specify --dedicated')
conf.define('XASH_SDL', 2)
if not conf.env.HAVE_SDL2:
conf.fatal('SDL2 not available! If you want to build dedicated server, specify --dedicated')
conf.define('XASH_SDL', 2)
if conf.env.DEST_OS == 'haiku':
conf.env.LIB_HAIKU = ['network']
conf.env.LIBPATH_HAIKU = ['/boot/system/lib']
if conf.env.DEST_OS == 'wasi':
conf.options.NO_ASYNC_RESOLVE = True
conf.env.append_unique('CFLAGS', '-mllvm')
conf.env.append_unique('CFLAGS', '-wasm-enable-sjlj')
if conf.options.STATIC:
conf.env.STATIC = True
conf.define('XASH_NO_LIBDL',1)
@@ -182,8 +172,8 @@ def build(bld):
source += bld.path.ant_glob(['platform/misc/lib_static.c'])
is_cxx_link = True
if bld.env.HAVE_SDL2 or bld.env.HAVE_SDL3:
libs.append('SDL3' if bld.env.HAVE_SDL3 else 'SDL2')
if bld.env.HAVE_SDL2:
libs.append('SDL2')
source += bld.path.ant_glob(['platform/sdl/*.c'])
if bld.env.MAGX:
@@ -232,8 +222,7 @@ def build(bld):
'client/*.c',
'client/vgui/*.c',
'client/avi/*.c'])
is_cxx_link = True
libs += ['opus', 'bzip2', 'MultiEmulator']
libs += ['opus', 'bzip2']
includes = ['server', 'client', 'client/vgui' ]

View File

@@ -119,8 +119,6 @@ const char *Q_PlatformStringByID( const int platform )
return "nswitch";
case PLATFORM_PSVITA:
return "psvita";
case PLATFORM_WASI:
return "wasi";
}
assert( 0 );
@@ -206,8 +204,6 @@ const char *Q_ArchitectureStringByID( const int arch, const uint abi, const int
return is64 ? "riscv64d" : "riscv32d";
}
break;
case ARCHITECTURE_WASM:
return is64 ? "wasm64" : "wasm32";
}
assert( 0 );

View File

@@ -85,8 +85,6 @@ Then you can use another oneliner to query all variables:
#undef XASH_X86
#undef XASH_NSWITCH
#undef XASH_PSVITA
#undef XASH_WASI
#undef XASH_WASM
//================================================================
//
@@ -128,8 +126,6 @@ Then you can use another oneliner to query all variables:
#define XASH_NSWITCH 1
#elif defined __vita__
#define XASH_PSVITA 1
#elif defined __wasi__
#define XASH_WASI 1
#else
#error
#endif
@@ -238,11 +234,6 @@ Then you can use another oneliner to query all variables:
#else
#error "Unknown RISC-V float ABI"
#endif
#elif defined __wasm__
#if defined __wasm64__
#define XASH_64BIT 1
#endif
#define XASH_WASM 1
#else
#error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug"
#endif

View File

@@ -41,7 +41,6 @@ GNU General Public License for more details.
#define PLATFORM_IRIX 12
#define PLATFORM_NSWITCH 13
#define PLATFORM_PSVITA 14
#define PLATFORM_WASI 15
#if XASH_WIN32
#define XASH_PLATFORM PLATFORM_WIN32
@@ -71,8 +70,6 @@ GNU General Public License for more details.
#define XASH_PLATFORM PLATFORM_NSWITCH
#elif XASH_PSVITA
#define XASH_PLATFORM PLATFORM_PSVITA
#elif XASH_WASI
#define XASH_PLATFORM PLATFORM_WASI
#else
#error
#endif
@@ -90,7 +87,6 @@ GNU General Public License for more details.
#define ARCHITECTURE_E2K 7
#define ARCHITECTURE_RISCV 8
#define ARCHITECTURE_PPC 9
#define ARCHITECTURE_WASM 10
#if XASH_AMD64
#define XASH_ARCHITECTURE ARCHITECTURE_AMD64
@@ -108,8 +104,6 @@ GNU General Public License for more details.
#define XASH_ARCHITECTURE ARCHITECTURE_RISCV
#elif XASH_PPC
#define XASH_ARCHITECTURE ARCHITECTURE_PPC
#elif XASH_WASM
#define XASH_ARCHITECTURE ARCHITECTURE_WASM
#else
#error
#endif

View File

@@ -19,6 +19,8 @@ GNU General Public License for more details.
#include <stdlib.h>
#define NUM_BYTES 256
#define CRC32_INIT_VALUE 0xFFFFFFFFUL
#define CRC32_XOR_VALUE 0xFFFFFFFFUL
static const uint32_t crc32table[NUM_BYTES] =
{
@@ -88,6 +90,16 @@ static const uint32_t crc32table[NUM_BYTES] =
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
void GAME_EXPORT CRC32_Init( uint32_t *pulCRC )
{
*pulCRC = CRC32_INIT_VALUE;
}
uint32_t GAME_EXPORT CRC32_Final( uint32_t pulCRC )
{
return pulCRC ^ CRC32_XOR_VALUE;
}
void GAME_EXPORT CRC32_ProcessByte( uint32_t *pulCRC, byte ch )
{
uint32_t ulCrc = *pulCRC;
@@ -173,6 +185,24 @@ byte CRC32_BlockSequence( byte *base, int length, int sequence )
void MD5Transform( uint buf[4], const uint in[16] );
/*
==================
MD5Init
Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants.
==================
*/
void MD5Init( MD5Context_t *ctx )
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
===================
MD5Update
@@ -375,33 +405,6 @@ void MD5Transform( uint buf[4], const uint in[16] )
buf[3] += d;
}
/*
============
COM_Hex2Char
============
*/
static char COM_Hex2Char( uint8_t hex )
{
if( hex >= 0x0 && hex <= 0x9 )
hex += '0';
else if( hex >= 0xA && hex <= 0xF )
hex += '7';
return (char)hex;
}
/*
============
COM_Hex2String
============
*/
static void COM_Hex2String( uint8_t hex, char *str )
{
*str++ = COM_Hex2Char( hex >> 4 );
*str++ = COM_Hex2Char( hex & 0x0F );
*str = '\0';
}
/*
=================
MD5_Print

View File

@@ -26,41 +26,12 @@ typedef struct
uint in[16];
} MD5Context_t;
#define CRC32_INIT_VALUE 0xFFFFFFFFUL
#define CRC32_XOR_VALUE 0xFFFFFFFFUL
static inline void CRC32_Init( uint32_t *pulCRC )
{
*pulCRC = CRC32_INIT_VALUE;
}
static inline uint32_t CRC32_Final( uint32_t pulCRC )
{
return pulCRC ^ CRC32_XOR_VALUE;
}
void CRC32_Init( uint32_t *pulCRC );
byte CRC32_BlockSequence( byte *base, int length, int sequence );
void CRC32_ProcessBuffer( uint32_t *pulCRC, const void *pBuffer, int nBuffer );
void CRC32_ProcessByte( uint32_t *pulCRC, byte ch );
/*
==================
MD5Init
Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants.
==================
*/
static inline void MD5Init( MD5Context_t *ctx )
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
uint32_t CRC32_Final( uint32_t pulCRC );
void MD5Init( MD5Context_t *ctx );
void MD5Update( MD5Context_t *ctx, const byte *buf, uint len );
void MD5Final( byte digest[16], MD5Context_t *ctx );
uint COM_HashKey( const char *string, uint hashSize );

View File

@@ -702,6 +702,33 @@ void COM_PathSlashFix( char *path )
}
}
/*
============
COM_Hex2Char
============
*/
char COM_Hex2Char( uint8_t hex )
{
if( hex >= 0x0 && hex <= 0x9 )
hex += '0';
else if( hex >= 0xA && hex <= 0xF )
hex += '7';
return (char)hex;
}
/*
============
COM_Hex2String
============
*/
void COM_Hex2String( uint8_t hex, char *str )
{
*str++ = COM_Hex2Char( hex >> 4 );
*str++ = COM_Hex2Char( hex & 0x0F );
*str = '\0';
}
/*
==============
COM_IsSingleChar

View File

@@ -94,6 +94,8 @@ void COM_StripExtension( char *path );
void COM_RemoveLineFeed( char *str, size_t bufsize );
void COM_FixSlashes( char *pname );
void COM_PathSlashFix( char *path );
char COM_Hex2Char( uint8_t hex );
void COM_Hex2String( uint8_t hex, char *str );
// return 0 on empty or null string, 1 otherwise
#define COM_CheckString( string ) ( ( !string || !*string ) ? 0 : 1 )
#define COM_CheckStringEmpty( string ) ( ( !*string ) ? 0 : 1 )

View File

@@ -24,7 +24,6 @@ static struct
{ PLATFORM_IRIX, "irix" },
{ PLATFORM_NSWITCH, "nswitch" },
{ PLATFORM_PSVITA, "psvita" },
{ PLATFORM_WASI, "wasi" },
};
static struct
@@ -41,10 +40,6 @@ static struct
{ ARCHITECTURE_E2K, 0, -1, -1, "e2k" },
{ ARCHITECTURE_JS, 0, -1, -1, "javascript" },
// all possible WebAssembly names
{ ARCHITECTURE_WASM, 0, -1, true, "wasm64" },
{ ARCHITECTURE_WASM, 0, -1, false, "wasm32" },
// all possible MIPS names
{ ARCHITECTURE_MIPS, 0, ENDIANNESS_BIG, true, "mips64" },
{ ARCHITECTURE_MIPS, 0, ENDIANNESS_BIG, false, "mips" },

View File

@@ -1,34 +0,0 @@
#include "crtlib.h"
int main( void )
{
char *file = (char *)"q asdf \"qwerty\" \"f \\\"f\" meowmeow\n// comment \"stuff ignored\"\nbark";
int len;
char buf[5];
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
if( !( !Q_strcmp( buf, "q" ) && len == 1 ))
return 1;
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
if( !( !Q_strcmp( buf, "asdf" ) && len == 4 ))
return 2;
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
if( !( !Q_strcmp( buf, "qwer" ) && len == -1 ))
return 3;
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
if( !( !Q_strcmp( buf, "f \"f" ) && len == 4 ))
return 4;
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
if( !( !Q_strcmp( buf, "meow" ) && len == -1 ))
return 5;
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
if( !( !Q_strcmp( buf, "bark" ) && len == 4 ))
return 6;
return 0;
}

View File

@@ -123,7 +123,6 @@ def build(bld):
'filebase': 'tests/test_filebase.c',
'efp': 'tests/test_efp.c',
'atoi': 'tests/test_atoi.c',
'parsefile': 'tests/test_parsefile.c',
}
for i in tests:

View File

@@ -32,7 +32,7 @@ Limitations:
*/
#include "gl_local.h"
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
#include "gl2_shim.h"
#define MAX_SHADERLEN 4096
@@ -1328,7 +1328,7 @@ static void APIENTRY GL2_LoadMatrixf( const GLfloat *m )
gl2wrap_matrix.update = 0xFFFFFFFFFFFFFFFF;
}
#if XASH_GLES
#ifdef XASH_GLES
static void ( APIENTRY *_pglDepthRangef)( GLfloat zFar, GLfloat zNear );
static void APIENTRY GL2_DepthRange( GLdouble zFar, GLdouble zNear )
{

View File

@@ -620,18 +620,14 @@ was there. This is used to test for texture thrashing.
*/
void R_ShowTextures( void )
{
float w, h;
int start, k;
int base_w, base_h;
rgba_t color = { 255, 255, 255, 255 };
int charHeight;
gl_texture_t *image;
float x, y, w, h;
int total, start, end;
int i, j, k, base_w, base_h;
rgba_t color = { 192, 192, 192, 255 };
int charHeight, numTries = 0;
static qboolean showHelp = true;
float time; //nc add
float time_cubemap; //nc add
float cbm_cos, cbm_sin; //nc add
int per_page; //nc add
qboolean empty_page;
int skipped_empty_pages;
string shortname;
if( !r_showtextures->value )
return;
@@ -642,156 +638,85 @@ void R_ShowTextures( void )
showHelp = false;
}
GL_SetRenderMode( kRenderNormal );
pglClear( GL_COLOR_BUFFER_BIT );
pglFinish();
w = 200;
h = 200;
base_w = 8; // textures view by horizontal
base_h = 6; // textures view by vertical
time = gp_cl->time * 0.5f;
time -= floor( time );
time_cubemap = gp_cl->time * 0.25f;
time_cubemap -= floor( time_cubemap );
time_cubemap *= 6.2831853f;
SinCos( time_cubemap, &cbm_sin, &cbm_cos );
rebuild_page:
total = base_w * base_h;
start = total * (r_showtextures->value - 1);
end = total * r_showtextures->value;
if( end > MAX_TEXTURES ) end = MAX_TEXTURES;
w = gpGlobals->width / base_w;
h = gpGlobals->height / base_h;
gEngfuncs.Con_DrawStringLen( NULL, NULL, &charHeight );
base_w = gpGlobals->width / w;
base_h = gpGlobals->height / ( h + charHeight * 2 );
per_page = base_w * base_h;
start = per_page * ( r_showtextures->value - 1 ) + 1; // skip empty null texture
GL_SetRenderMode( kRenderTransTexture ); // nc changed from normal to trans, Con_DrawString does this anyway
empty_page = true;
skipped_empty_pages = 0;
while( empty_page )
for( i = j = 0; i < MAX_TEXTURES; i++ )
{
for( k = 0; k < per_page; k++ )
{
const gl_texture_t *image;
int i;
i = k + start;
if( i >= MAX_TEXTURES )
{
empty_page = false;
break;
}
image = R_GetTexture( i );
if( pglIsTexture( image->texnum ))
{
empty_page = false;
break;
}
}
if( empty_page )
{
start += per_page;
skipped_empty_pages++;
}
image = R_GetTexture( i );
if( j == start ) break; // found start
if( pglIsTexture( image->texnum )) j++;
}
if( skipped_empty_pages > 0 )
if( i == MAX_TEXTURES && r_showtextures->value != 1 )
{
char text[MAX_VA_STRING];
Q_snprintf( text, sizeof( text ), "%s: skipped %d empty texture pages", __func__, skipped_empty_pages );
gEngfuncs.CL_CenterPrint( text, 0.25f );
// bad case, rewind to one and try again
gEngfuncs.Cvar_SetValue( "r_showtextures", Q_max( 1, r_showtextures->value - 1 ));
if( ++numTries < 2 ) goto rebuild_page; // to prevent infinite loop
}
for( k = 0; k < per_page; k++ )
for( k = 0; i < MAX_TEXTURES; i++ )
{
const gl_texture_t *image;
int textlen, i;
char text[MAX_VA_STRING];
string shortname;
float x, y;
i = k + start;
if ( i >= MAX_TEXTURES )
break;
if( j == end ) break; // page is full
image = R_GetTexture( i );
if( !pglIsTexture( image->texnum ))
continue;
x = k % base_w * gpGlobals->width / base_w;
y = k / base_w * gpGlobals->height / base_h;
x = k % base_w * w;
y = k / base_w * h;
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
GL_Bind( XASH_TEXTURE0, image->texnum );
GL_Bind( XASH_TEXTURE0, i ); // NOTE: don't use image->texnum here, because skybox has a 'wrong' indexes
if( FBitSet( image->flags, TF_DEPTHMAP ) && !FBitSet( image->flags, TF_NOCOMPARE ))
pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE );
pglBegin( GL_QUADS );
#if XASH_NANOGL
#undef pglTexCoord3f
#define pglTexCoord3f( s, t, u ) pglTexCoord2f( s, t ) // not really correct but it requires nanogl rework
#endif // XASH_GLES
if( image->target == GL_TEXTURE_CUBE_MAP_ARB )
{
pglTexCoord3f( 0.75 * cbm_cos - cbm_sin, 0.75 * cbm_sin + cbm_cos, 1.0 );
pglVertex2f( x, y );
pglTexCoord3f( 0.75 * cbm_cos + cbm_sin, 0.75 * cbm_sin - cbm_cos, 1.0 );
pglVertex2f( x + w, y );
pglTexCoord3f( 0.75 * cbm_cos + cbm_sin, 0.75 * cbm_sin - cbm_cos, -1.0 );
pglVertex2f( x + w, y + h );
pglTexCoord3f( 0.75 * cbm_cos - cbm_sin, 0.75 * cbm_sin + cbm_cos, -1.0 );
pglVertex2f( x, y + h );
}
else if( image->target == GL_TEXTURE_RECTANGLE_EXT )
{
pglTexCoord2f( 0, 0 );
pglVertex2f( x, y );
pglTexCoord2f( 0, 0 );
pglVertex2f( x, y );
if( image->target == GL_TEXTURE_RECTANGLE_EXT )
pglTexCoord2f( image->width, 0 );
pglVertex2f( x + w, y );
else pglTexCoord2f( 1, 0 );
pglVertex2f( x + w, y );
if( image->target == GL_TEXTURE_RECTANGLE_EXT )
pglTexCoord2f( image->width, image->height );
pglVertex2f( x + w, y + h );
else pglTexCoord2f( 1, 1 );
pglVertex2f( x + w, y + h );
if( image->target == GL_TEXTURE_RECTANGLE_EXT )
pglTexCoord2f( 0, image->height );
pglVertex2f( x, y + h );
}
else
{
pglTexCoord3f( 0, 0, time );
pglVertex2f( x, y );
pglTexCoord3f( 1, 0, time );
pglVertex2f( x + w, y );
pglTexCoord3f( 1, 1, time );
pglVertex2f( x + w, y + h );
pglTexCoord3f( 0, 1, time);
pglVertex2f( x, y + h );
}
else pglTexCoord2f( 0, 1 );
pglVertex2f( x, y + h );
pglEnd();
if( FBitSet( image->flags, TF_DEPTHMAP ) && !FBitSet( image->flags, TF_NOCOMPARE ))
pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB );
COM_FileBase( image->name, shortname, sizeof( shortname ));
gEngfuncs.Con_DrawStringLen( shortname, &textlen, NULL );
if( textlen > w )
if( Q_strlen( shortname ) > 18 )
{
// cutoff too long names, it looks ugly
shortname[16] = '.';
shortname[17] = '.';
shortname[18] = '\0';
}
gEngfuncs.Con_DrawString( x + 1, y + h, shortname, color );
if( image->target == GL_TEXTURE_3D || image->target == GL_TEXTURE_2D_ARRAY_EXT )
Q_snprintf( text, sizeof( text ), "%ix%ix%i %s", image->width, image->height, image->depth, GL_TargetToString( image->target ));
else
Q_snprintf( text, sizeof( text ), "%ix%i %s", image->width, image->height, GL_TargetToString( image->target ));
gEngfuncs.Con_DrawString( x + 1, y + h + charHeight, text, color );
Q_strncpy( text, Q_memprint( image->size ), sizeof( text ));
gEngfuncs.Con_DrawStringLen( text, &textlen, NULL );
gEngfuncs.Con_DrawString(( x + w ) - textlen - 1, y + h + charHeight, text, color );
gEngfuncs.Con_DrawString( x + 1, y + h - charHeight, shortname, color );
j++, k++;
}
gEngfuncs.CL_DrawCenterPrint ();

View File

@@ -18,7 +18,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "gl_export.h"
#if XASH_GL4ES
#ifdef XASH_GL4ES
#include "gl4es/include/gl4esinit.h"
#endif
@@ -420,7 +420,7 @@ static void GAME_EXPORT R_OverrideTextureSourceSize( unsigned int texnum, uint s
static void* GAME_EXPORT R_GetProcAddress( const char *name )
{
#if XASH_GL4ES
#ifdef XASH_GL4ES
return gl4es_GetProcAddress( name );
#else // TODO: other wrappers
return gEngfuncs.GL_GetProcAddress( name );

View File

@@ -20,20 +20,20 @@ GNU General Public License for more details.
#endif
#ifndef APIENTRY_LINKAGE
#define APIENTRY_LINKAGE extern
#define APIENTRY_LINKAGE extern
#endif
#if XASH_NANOGL || XASH_WES || XASH_REGAL
#define XASH_GLES 1
#define XASH_GL_STATIC 1
#define REF_GL_KEEP_MANGLED_FUNCTIONS 1
#elif XASH_GLES3COMPAT
#ifdef SOFTFP_LINK
#undef APIENTRY
#define APIENTRY __attribute__((pcs("aapcs")))
#endif // SOFTFP_LINK
#define XASH_GLES 1
#endif // XASH_GLES3COMPAT
#if defined XASH_NANOGL || defined XASH_WES || defined XASH_REGAL
#define XASH_GLES
#define XASH_GL_STATIC
#define REF_GL_KEEP_MANGLED_FUNCTIONS
#elif defined XASH_GLES3COMPAT
#ifdef SOFTFP_LINK
#undef APIENTRY
#define APIENTRY __attribute__((pcs("aapcs")))
#endif
#define XASH_GLES
#endif
typedef uint GLenum;
typedef byte GLboolean;
@@ -897,16 +897,16 @@ typedef float GLmatrix[16];
#define WGL_SAMPLES_ARB 0x2042
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#if XASH_GL_STATIC && !REF_GL_KEEP_MANGLED_FUNCTIONS
#define GL_FUNCTION( name ) name
#elif XASH_GL_STATIC && REF_GL_KEEP_MANGLED_FUNCTIONS
#define GL_FUNCTION( name ) APIENTRY p##name
#if defined( XASH_GL_STATIC ) && !defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
#define GL_FUNCTION( name ) name
#elif defined( XASH_GL_STATIC ) && defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
#define GL_FUNCTION( name ) APIENTRY p##name
#else
#define GL_FUNCTION( name ) (APIENTRY *p##name)
#define GL_FUNCTION( name ) (APIENTRY *p##name)
#endif
// helper opengl functions
@@ -1387,11 +1387,11 @@ APIENTRY_LINKAGE void GL_FUNCTION( glFlushMappedBufferRange )(GLenum target, GLs
APIENTRY_LINKAGE void *GL_FUNCTION( glMapBufferRange )(GLenum target, GLsizei offset, GLsizei length, GLbitfield access);
APIENTRY_LINKAGE void GL_FUNCTION( glDrawRangeElementsBaseVertex )( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLuint vertex );
#if !XASH_GL_STATIC || ( !XASH_GLES && !XASH_GL4ES )
#if !defined( XASH_GL_STATIC ) || (!defined( XASH_GLES ) && !defined( XASH_GL4ES ))
APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
#endif /* !XASH_GLES && !XASH_GL4ES */
#if XASH_GL_STATIC && !REF_GL_KEEP_MANGLED_FUNCTIONS
#if defined( XASH_GL_STATIC ) && !defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
#define pglGetError glGetError
#define pglGetString glGetString
#define pglAccum glAccum
@@ -1857,7 +1857,7 @@ APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsi
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
#endif//GL_EXPORT_H

View File

@@ -55,7 +55,7 @@ gl_texture_t *R_GetTexture( GLenum texnum )
GL_TargetToString
=================
*/
const char *GL_TargetToString( GLenum target )
static const char *GL_TargetToString( GLenum target )
{
switch( target )
{
@@ -632,7 +632,7 @@ static void GL_SetTextureTarget( gl_texture_t *tex, rgbdata_t *pic )
pic->numMips = Q_max( 1, pic->numMips );
// trying to determine texture type
#if !XASH_GLES
#ifndef XASH_GLES
if( pic->width > 1 && pic->height <= 1 )
tex->target = GL_TEXTURE_1D;
else
@@ -1094,7 +1094,7 @@ static void GL_TextureImageCompressed( gl_texture_t *tex, GLint side, GLint leve
Assert( tex != NULL );
#if !XASH_GLES
#ifndef XASH_GLES
if( tex->target == GL_TEXTURE_1D )
{
if( subImage ) pglCompressedTexSubImage1DARB( tex->target, level, 0, width, tex->format, size, data );

View File

@@ -354,7 +354,6 @@ void R_DrawModelHull( void );
//
void R_SetTextureParameters( void );
gl_texture_t *R_GetTexture( GLenum texnum );
const char *GL_TargetToString( GLenum target );
#define GL_LoadTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, true )
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
@@ -678,6 +677,8 @@ typedef struct
typedef struct
{
int width, height;
int activeTMU;
GLint currentTextures[MAX_TEXTURE_UNITS];
GLint currentTexturesIndex[MAX_TEXTURE_UNITS];

View File

@@ -47,12 +47,11 @@ glconfig_t glConfig;
glstate_t glState;
glwstate_t glw_state;
#if XASH_GL_STATIC
#define GL_CALL( x ) #x, NULL
#ifdef XASH_GL_STATIC
#define GL_CALL( x ) #x, NULL
#else
#define GL_CALL( x ) #x, (void**)&p##x
#define GL_CALL( x ) #x, (void**)&p##x
#endif
static dllfunc_t opengl_110funcs[] =
{
{ GL_CALL( glClearColor ) },
@@ -230,7 +229,7 @@ static dllfunc_t vbofuncs[] =
{ GL_CALL( glDeleteBuffersARB ) },
{ GL_CALL( glGenBuffersARB ) },
{ GL_CALL( glIsBufferARB ) },
#if !XASH_GLES
#ifndef XASH_GLES
{ GL_CALL( glMapBufferARB ) },
{ GL_CALL( glUnmapBufferARB ) },
#endif
@@ -261,12 +260,13 @@ static dllfunc_t drawrangeelementsextfuncs[] =
// mangling in gl2shim???
// still need resolve some ext dynamicly, and mangling beginend wrappers will help only with LTO
// anyway this will not work with gl-wes/nanogl, we do not link to libGLESv2, so skip this now
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
static dllfunc_t mapbufferrangefuncs[] =
{
{ GL_CALL( glMapBufferRange ) },
{ GL_CALL( glFlushMappedBufferRange ) },
#if XASH_GLES
#ifdef XASH_GLES
{ GL_CALL( glUnmapBufferARB ) },
#endif
{ NULL, NULL }
@@ -284,6 +284,7 @@ static dllfunc_t bufferstoragefuncs[] =
{ NULL, NULL }
};
static dllfunc_t shaderobjectsfuncs[] =
{
{ GL_CALL( glDeleteObjectARB ) },
@@ -439,7 +440,7 @@ static dllfunc_t multitexturefuncs_es2[] =
{ NULL , NULL }
};
#endif // !XASH_GL_STATIC
#endif
/*
========================
@@ -547,7 +548,7 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
return false;
}
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
// clear exports
for( func = funcs; func && func->name; func++ )
*func->func = NULL;
@@ -560,7 +561,7 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
string name;
char *end;
size_t i = 0;
#if XASH_GLES
#ifdef XASH_GLES
const char *suffixes[] = { "", "EXT", "OES" };
#else
const char *suffixes[] = { "", "EXT" };
@@ -771,23 +772,24 @@ static void R_RenderInfo_f( void )
glConfig.alpha_bits, glConfig.depth_bits, glConfig.stencil_bits );
}
#if XASH_GLES
#ifdef XASH_GLES
static void GL_InitExtensionsGLES( void )
{
int extid;
// intialize wrapper type
#if XASH_NANOGL
#ifdef XASH_NANOGL
glConfig.context = CONTEXT_TYPE_GLES_1_X;
glConfig.wrapper = GLES_WRAPPER_NANOGL;
#elif XASH_WES
#elif defined( XASH_WES )
glConfig.context = CONTEXT_TYPE_GLES_2_X;
glConfig.wrapper = GLES_WRAPPER_WES;
#elif XASH_GLES3COMPAT
#elif defined( XASH_GLES3COMPAT )
glConfig.context = CONTEXT_TYPE_GLES_2_X;
glConfig.wrapper = GLES_WRAPPER_NONE;
#else
#error "unknown gles wrapper"
#error "unknown gles wrapper"
#endif
glConfig.hardware_type = GLHW_GENERIC;
@@ -802,7 +804,7 @@ static void GL_InitExtensionsGLES( void )
case GL_ARB_MULTITEXTURE:
if( !GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 ) && glConfig.wrapper == GLES_WRAPPER_NONE )
{
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
if( !GL_CheckExtension( "multitexture_es1", multitexturefuncs_es, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 )
&& !GL_CheckExtension( "multitexture_es2", multitexturefuncs_es2, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 2.0 ))
break;
@@ -837,7 +839,7 @@ static void GL_InitExtensionsGLES( void )
case GL_ARB_TEXTURE_NPOT_EXT:
GL_CheckExtension( "GL_OES_texture_npot", NULL, "gl_texture_npot", extid, 0 );
break;
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
case GL_SHADER_OBJECTS_EXT:
GL_CheckExtension( "ES2 Shaders", shaderobjectsfuncs_gles, "gl_shaderobjects", extid, 2.0 );
break;
@@ -884,7 +886,7 @@ static void GL_InitExtensionsGLES( void )
GL_SetExtension( extid, false );
}
}
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
GL2_ShimInit();
#endif
}
@@ -977,7 +979,7 @@ static void GL_InitExtensionsBigGL( void )
GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT, 2.0 );
GL_CheckExtension( "GL_ARB_texture_multisample", multisampletexfuncs, "gl_texture_multisample", GL_TEXTURE_MULTISAMPLE, 0 );
GL_CheckExtension( "GL_ARB_texture_compression_bptc", NULL, "gl_texture_bptc_compression", GL_ARB_TEXTURE_COMPRESSION_BPTC, 0 );
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
if( glConfig.context == CONTEXT_TYPE_GL_CORE )
GL_CheckExtension( "shader_objects", shaderobjectsfuncs_gles, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT, 2.0 );
else
@@ -1015,7 +1017,7 @@ static void GL_InitExtensionsBigGL( void )
if( GL_CheckExtension( "glDrawRangeElementsEXT", drawrangeelementsextfuncs,
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ))
{
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
pglDrawRangeElements = pglDrawRangeElementsEXT;
#endif
}
@@ -1031,7 +1033,7 @@ static void GL_InitExtensionsBigGL( void )
// init our immediate mode override
VGL_ShimInit();
#endif
#if !XASH_GLES && !XASH_GL_STATIC
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
if( gEngfuncs.Sys_CheckParm( "-gl2shim" ))
GL2_ShimInit();
#endif
@@ -1074,7 +1076,7 @@ void GL_InitExtensions( void )
glConfig.version_major = major;
glConfig.version_minor = minor;
}
#if !XASH_GL_STATIC
#ifndef XASH_GL_STATIC
if( !glConfig.extensions_string )
{
int n = 0;
@@ -1104,7 +1106,7 @@ void GL_InitExtensions( void )
#endif
gEngfuncs.Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string );
#if XASH_GLES
#ifdef XASH_GLES
GL_InitExtensionsGLES();
#else
GL_InitExtensionsBigGL();
@@ -1112,7 +1114,7 @@ void GL_InitExtensions( void )
pglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.max_2d_texture_size );
if( glConfig.max_2d_texture_size <= 0 ) glConfig.max_2d_texture_size = 256;
#if !XASH_GL4ES
#ifndef XASH_GL4ES
// enable gldebug if allowed
if( GL_Support( GL_DEBUG_OUTPUT ))
{
@@ -1233,7 +1235,7 @@ static void R_CheckVBO( void )
if( glConfig.max_texture_units < 3 )
disable = true;
#if XASH_MOBILE_PLATFORM
#ifdef XASH_MOBILE_PLATFORM
// VideoCore4 drivers have a problem with mixing VBO and client arrays
// Disable it, as there is no suitable workaround here
if( Q_stristr( glConfig.renderer_string, "VideoCore IV" ) || Q_stristr( glConfig.renderer_string, "vc4" ) )
@@ -1321,13 +1323,13 @@ void R_Shutdown( void )
GL_RemoveCommands();
R_ShutdownImages();
#if !XASH_GLES && !XASH_GL_STATIC
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
GL2_ShimShutdown();
#endif
Mem_FreePool( &r_temppool );
#if XASH_GL4ES
#ifdef XASH_GL4ES
close_gl4es();
#endif // XASH_GL4ES
@@ -1386,18 +1388,17 @@ void GL_SetupAttributes( int safegl )
int context_flags = 0; // REFTODO!!!!!
int samples = 0;
#if XASH_GLES
#ifdef XASH_GLES
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_ES );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_EGL, 1 );
#if XASH_NANOGL
#ifdef XASH_NANOGL
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 1 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 1 );
#else // !XASH_NANOGL
#else
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 2 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 0 );
#endif
#elif XASH_GL4ES
#elif defined XASH_GL4ES
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_ES );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_EGL, 1 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 2 );
@@ -1519,7 +1520,7 @@ void GL_SetupAttributes( int safegl )
void wes_init( const char *gles2 );
int nanoGL_Init( void );
#if XASH_GL4ES
#ifdef XASH_GL4ES
static void GL4ES_GetMainFBSize( int *width, int *height )
{
*width = gpGlobals->width;
@@ -1533,12 +1534,12 @@ static void *GL4ES_GetProcAddress( const char *name )
return NULL;
return gEngfuncs.GL_GetProcAddress( name );
}
#endif // XASH_GL4ES
#endif
void GL_OnContextCreated( void )
{
int colorBits[3];
#if XASH_NANOGL
#ifdef XASH_NANOGL
nanoGL_Init();
#endif
@@ -1556,11 +1557,10 @@ void GL_OnContextCreated( void )
gEngfuncs.GL_GetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, &glConfig.version_major );
gEngfuncs.GL_GetAttribute( REF_GL_CONTEXT_MINOR_VERSION, &glConfig.version_minor );
#if XASH_WES
#ifdef XASH_WES
wes_init( "" );
#endif // XASH_WES
#if XASH_GL4ES
#endif
#ifdef XASH_GL4ES
set_getprocaddress( GL4ES_GetProcAddress );
set_getmainfbsize( GL4ES_GetMainFBSize );
initialize_gl4es();
@@ -1569,5 +1569,5 @@ void GL_OnContextCreated( void )
pglHint( GL_BEGINEND_HINT_GL4ES, 1 );
// dxt unpacked to 16-bit looks ugly
pglHint( GL_AVOID16BITS_HINT_GL4ES, 1 );
#endif // XASH_GL4ES
#endif
}

View File

@@ -1240,7 +1240,7 @@ dynamic:
R_SetCacheState( fa );
#if XASH_WES
#ifdef XASH_WES
GL_Bind( XASH_TEXTURE1, tr.lightmapTextures[fa->lightmaptexturenum] );
pglTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
#else
@@ -1249,7 +1249,7 @@ dynamic:
pglTexSubImage2D( GL_TEXTURE_2D, 0, fa->light_s, fa->light_t, smax, tmax, GL_RGBA, GL_UNSIGNED_BYTE, temp );
#if XASH_WES
#ifdef XASH_WES
GL_SelectTexture( XASH_TEXTURE0 );
#endif
}

View File

@@ -33,9 +33,9 @@ typedef struct
} player_model_t;
// never gonna change, just shut up const warning
CVAR_DEFINE_AUTO( r_shadows, "0", 0, "draw ugly shadows" );
cvar_t r_shadows = { (char *)"r_shadows", (char *)"0", 0 };
static const vec3_t hullcolor[8] =
static vec3_t hullcolor[8] =
{
{ 1.0f, 1.0f, 1.0f },
{ 1.0f, 0.5f, 0.5f },
@@ -154,7 +154,8 @@ void R_StudioInit( void )
Matrix3x4_LoadIdentity( g_studio.rotationmatrix );
gEngfuncs.Cvar_RegisterVariable( &r_shadows );
// g-cont. cvar disabled by Valve
// gEngfuncs.Cvar_RegisterVariable( &r_shadows );
g_studio.interpolate = true;
g_studio.framecount = 0;

View File

@@ -46,27 +46,27 @@ def build(bld):
'ref_gl': {
'enable': bld.env.GL,
'libs': ['GL'] if bld.env.GL_STATIC else [],
'defines': ['XASH_GL_STATIC=1'] if bld.env.GL_STATIC else [],
'defines': ['XASH_GL_STATIC'] if bld.env.GL_STATIC else [],
},
'ref_gles1': {
'enable': bld.env.NANOGL,
'libs': ['DL', 'nanogl', 'LOG'],
'defines': ['XASH_NANOGL=1'],
'defines': ['XASH_NANOGL'],
},
'ref_gles2': {
'enable': bld.env.GLWES,
'libs': ['DL', 'gl-wes-v2', 'LOG'],
'defines': ['XASH_WES=1'],
'defines': ['XASH_WES'],
},
'ref_gl4es': {
'enable': bld.env.GL4ES,
'libs': ['DL', 'gl4es', 'LOG'],
'defines': ['XASH_GL_STATIC=1', 'XASH_GL4ES=1'],
'defines': ['XASH_GL_STATIC', 'XASH_GL4ES'],
},
'ref_gles3compat': {
'enable': bld.env.GLES3COMPAT,
'libs': [],
'defines': ['XASH_GLES3COMPAT=1'],
'defines': ['XASH_GLES3COMPAT'],
},
}

View File

@@ -32,9 +32,9 @@ typedef struct
model_t *model;
} player_model_t;
CVAR_DEFINE_AUTO( r_shadows, "0", 0, "draw ugly shadows" );
cvar_t r_shadows = { (char *)"r_shadows", (char *)"0", 0 };
static const vec3_t hullcolor[8] =
static vec3_t hullcolor[8] =
{
{ 1.0f, 1.0f, 1.0f },
{ 1.0f, 0.5f, 0.5f },

Some files were not shown because too many files have changed in this diff Show More