2.9 Update (#64)

* Fixed bots not camping in camp spots.
Fixed chatter/radio message cycling. (need feedback).
Fixed CTs unable to defuse bomb.
Fixed backward jump path generation in waypoint editor.
Fixed autoradius in waypoint editor.
Fixed autoradius menu non closeable.
Fixed bots version display on entering game.
Fixed memory leak in DLL-loader. (non metamod).
Fixed bots able to see through smoke.
Fixed team-detection on non-standard modes.
Fixed quota & autovacate management.
Fixed bunch of warnings from static analyzers.
Greatly imporoved grenade throwing.
Grealty reduced bot CPU usage.

* Fixed stack-corruption in memory-file reader.
Fixed A* pathfinder not working correctly.
Fixed 'Tried to write to uninitialized sizebuf_t error' on bot add/remove.
Minor tweaks to camping and bot enemy aiming

* Make clang happy.

* Fixed VIP-dection on some maps.
Fixed occupied waypoint checker.
Small refactoring of code with clang-format.

* Fixed clang compilation

* Fixed compilation.

* Debugging seek cover task.
Some more code cleanup.

* Fixed typos.

* Fixes to attack movement.
Revert Z component updates.

* Fixes for aiming at enemy.
Fixes for seek cover & enemy hunt tasks.
More refactoring.

* Making clang happy once again?
Tweaked grenade timers.

* Revised language comparer hasher

* Fixed build.

* Fixed build.

* Optimized headshot offsets.
Optimized aim errors and enemy searches.
Get rid of preprocessor macroses.
Added back yb_think_fps. Use with caution.

* Minor refactoring of code.

* Check if tracking entity is still alive.
Do not duck in crouch-goal waypoints.
Remove ancient hack with failed goals.

* Get rid of c++14 stuff.
Tweaked isOccupiedPoint.

* Changed pickup check radius.

* Fix compilation.

* Fixed bots ignore breakables.
Fixed A* pathfinder.
Fixed searching for optimal waypoints.
Fixed bot waypoint reachability functions.

* Get rid of new/delete calls in pathfinder.
Disallow access to yapb waypoint menu on hlds.
Minor refactoring.

* Updated linux/osx makefile

* Spaces -> Tabs in makefile.
Made G++ happy.

* Updated makefile.

* Fixed heap buffer overflow in config loader code.

* Lowered CPU usage a bit, by using "waypoint buckets" for searching closest node.
Do not traceline for doors on map, that have no doors.
Get rid stack-based containers.

* Remove win-only debug crap.

* Refactored string class.

* Fix OSX compiling.

* Minor refactoring of corelib to use cpp move-semantic.

* Use reference for active grenades searcher.

* Use system's atan2f () as it's eror rate is a bit lower.
Fixed bots continuously stays in throw smoke task.
Fixed bots reaching camp-goal jumping or stays they for some time.
Increased radius for searching targets for grenades.
Tweaked bot difficulty levels.
Improved sniper weapon handling. Trying to stand still while shooting.
Increase retreat level only if sniper weapon is low on ammo.
Fixed predict path enemy tracking timer is always true.
Allow bots to process their tasks while on freezetime, so on small maps they already aiming enemies when freezetime ends.
Fied bots endlessy trying to pickup weapons.
Reduce surpise timers when holding sniper weapons.
New aim-at-head position calculation.
Shoot delay timers are now based on bot's difficulty.
Prefer smoke grenades more than flashbangs.
Fixed kill-all bot command not killing one random bot for first time use.
Do not play with jump velocity, now using the same as in waypoints.
Tweaked shift move, so zero move speed not overriden with shift speed.
Radius waypoint searcher use waypoint bucket as well.
Increase reachability radius for dest waypoint, if it's  currenlty owned by other bot.
Partially fixed bots choice to use unreachable waypoints.

* Makes OSX clang happy?

* Support for compiling on llvm-win32, makefile to be done.
Increased default reachability time.

* Fixed build.

* Move level-initialization stuff from Spawn to ServerActivate, so bot will not check init-stuff every entity spawn. This should save few CPU cycles.

* Fixed active grenades list not working after changelevel.
Reworked items pickup code, so every bot is not firing sphere search every time, but instead we maintain our own list of intresting entities, so every bot is accessing this list. This should lower CPU usage more a little.

* Precache should be done in spawn...

* Do not use engfuncs in intresting entities.

* Fixed GCC-8.2 warnings.
Minor refactoring.

* Added some safety checks to intresting entities.
Get rid of stdc++ dependency for GCC & ICC under linux.

* Remove -g from release make.
Cosmetic changes.

* Re-enabled debug overlay.

* Remove test header...

* Some static-analyzer warnings fixed.
Support for X64 build for FWGS Xash3D Engine.

* Reduced time between selecting grenade and throwing it away.
Do not try to kill bots that already dead with kill command.
Several fixes from static-analyzers.

* Update CI.

* Fixed bot's not added after the changelevel on Xash3D engine.

* Revert commit that enables movement during freezetime. Everything goes bad, when there is no freezetime....

* Bots will try to  not strafe while in combat if seeing enemy only partially.
Do not use "shift" when considering stuck.

* Weapon price for Elite is 800$ since CS 1.6...

* Fixed bots at difficulty 0 can't shoot enemies.

* Cosmetic change.

* Fixed assert in ClientDisconnect when quitting game while meta unloaded yapb module.
Consider freed entities as invalid.

* Bigger distance for throwing he grenades.

* Faster version of atan2f().

* Removed accidentally left SSE header.

* Cosmetic changes to enums.

* Tweaked difficulty levels.
Bots on Android will have a difficulty level 2 by default.
Fixed LTO builds under linux.

* Do not consider Android CS as legacy.

* Get rid of system's math functions. Just for fun)

* Use SSE2 for sincos function.

* Fixed failed during load wayponts still allows to add bots, thus causing bot to crash.
Added ability to delete waypoint by number using "yb wp delete".
Enabled Link Time Optimization for Linux and OSX.

* Fixed CI Builds.
This commit is contained in:
jeefo 2018-10-28 19:26:36 +03:00 committed by GitHub
commit 5f6a1638d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 13626 additions and 17110 deletions

View file

@ -4,84 +4,82 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license
// https://yapb.ru/license
//
#pragma once
const int N = 4096, F = 18, THRESHOLD = 2, NIL = N;
static constexpr int MAXBUF = 4096, PADDING = 18, THRESHOLD = 2, NIL = MAXBUF;
class Compressor
{
class Compress {
protected:
unsigned long int m_textSize;
unsigned long int m_codeSize;
unsigned long int m_csize;
uint8 m_textBuffer[N + F - 1];
int m_matchPosition;
int m_matchLength;
uint8 m_buffer[MAXBUF + PADDING - 1];
int m_matchPos;
int m_matchLen;
int m_left[N + 1];
int m_right[N + 257];
int m_parent[N + 1];
int m_left[MAXBUF + 1];
int m_right[MAXBUF + 257];
int m_parent[MAXBUF + 1];
private:
void InitTree (void)
{
for (int i = N + 1; i <= N + 256; i++)
void initTrees (void) {
for (int i = MAXBUF + 1; i <= MAXBUF + 256; i++) {
m_right[i] = NIL;
}
for (int j = 0; j < N; j++)
for (int j = 0; j < MAXBUF; j++) {
m_parent[j] = NIL;
}
}
void InsertNode (int node)
{
void insert (int node) {
int i;
int compare = 1;
uint8 *key = &m_textBuffer[node];
int temp = N + 1 + key[0];
uint8 *key = &m_buffer[node];
int temp = MAXBUF + 1 + key[0];
m_right[node] = m_left[node] = NIL;
m_matchLength = 0;
m_matchLen = 0;
for (;;)
{
if (compare >= 0)
{
if (m_right[temp] != NIL)
for (;;) {
if (compare >= 0) {
if (m_right[temp] != NIL) {
temp = m_right[temp];
else
{
}
else {
m_right[temp] = node;
m_parent[node] = temp;
return;
}
}
else
{
if (m_left[temp] != NIL)
else {
if (m_left[temp] != NIL) {
temp = m_left[temp];
else
{
}
else {
m_left[temp] = node;
m_parent[node] = temp;
return;
}
}
for (i = 1; i < F; i++)
if ((compare = key[i] - m_textBuffer[temp + i]) != 0)
for (i = 1; i < PADDING; i++) {
if ((compare = key[i] - m_buffer[temp + i]) != 0) {
break;
}
}
if (i > m_matchLength)
{
m_matchPosition = temp;
if ((m_matchLength = i) >= F)
if (i > m_matchLen) {
m_matchPos = temp;
if ((m_matchLen = i) >= PADDING) {
break;
}
}
}
@ -91,37 +89,35 @@ private:
m_parent[m_left[temp]] = node;
m_parent[m_right[temp]] = node;
if (m_right[m_parent[temp]] == temp)
if (m_right[m_parent[temp]] == temp) {
m_right[m_parent[temp]] = node;
else
}
else {
m_left[m_parent[temp]] = node;
}
m_parent[temp] = NIL;
}
void DeleteNode (int node)
{
void erase (int node) {
int temp;
if (m_parent[node] == NIL)
if (m_parent[node] == NIL) {
return; // not in tree
}
if (m_right[node] == NIL)
if (m_right[node] == NIL) {
temp = m_left[node];
else if (m_left[node] == NIL)
}
else if (m_left[node] == NIL) {
temp = m_right[node];
else
{
}
else {
temp = m_left[node];
if (m_right[temp] != NIL)
{
do
if (m_right[temp] != NIL) {
do {
temp = m_right[temp];
while (m_right[temp] != NIL);
} while (m_right[temp] != NIL);
m_right[m_parent[temp]] = m_left[temp];
m_parent[m_left[temp]] = m_parent[temp];
@ -132,240 +128,208 @@ private:
m_right[temp] = m_right[node];
m_parent[m_right[node]] = temp;
}
m_parent[temp] = m_parent[node];
if (m_right[m_parent[node]] == node)
if (m_right[m_parent[node]] == node) {
m_right[m_parent[node]] = temp;
else
}
else {
m_left[m_parent[node]] = temp;
}
m_parent[node] = NIL;
}
public:
Compressor (void)
{
m_textSize = 0;
m_codeSize = 0;
m_matchPosition = 0;
m_matchLength = 0;
memset (m_textBuffer, 0, sizeof (m_textBuffer));
Compress (void) : m_csize (0), m_matchPos (0), m_matchLen (0) {
memset (m_right, 0, sizeof (m_right));
memset (m_left, 0, sizeof (m_left));
memset (m_parent, 0, sizeof (m_parent));
memset (m_buffer, 0, sizeof (m_buffer));
}
~Compressor (void)
{
m_textSize = 0;
m_codeSize = 0;
m_matchPosition = 0;
m_matchLength = 0;
memset (m_textBuffer, 0, sizeof (m_textBuffer));
memset (m_right, 0, sizeof (m_right));
memset (m_left, 0, sizeof (m_left));
memset (m_parent, 0, sizeof (m_parent));
}
int InternalEncode (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize)
{
int i, length, node, strPtr, lastMatchLength, codeBufferPtr, bufferPtr = 0;
uint8 codeBuffer[17], mask;
~Compress (void) = default;
int encode_ (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) {
File fp (fileName, "wb");
if (!fp.IsValid ())
if (!fp.isValid ()) {
return -1;
}
int i, length, node, ptr, last, cbp, bp = 0;
uint8 cb[17] = {0, }, mask, bit;
uint8 bit;
fp.write (header, headerSize, 1);
initTrees ();
fp.Write (header, headerSize, 1);
InitTree ();
cb[0] = 0;
cbp = mask = 1;
ptr = 0;
node = MAXBUF - PADDING;
codeBuffer[0] = 0;
codeBufferPtr = mask = 1;
strPtr = 0;
node = N - F;
for (i = ptr; i < node; i++)
m_buffer[i] = ' ';
for (i = strPtr; i < node; i++)
m_textBuffer[i] = ' ';
for (length = 0; (length < F) && (bufferPtr < bufferSize); length++)
{
bit = buffer[bufferPtr++];
m_textBuffer[node + length] = bit;
for (length = 0; (length < PADDING) && (bp < bufferSize); length++) {
bit = buffer[bp++];
m_buffer[node + length] = bit;
}
if ((m_textSize = length) == 0)
if (length == 0) {
return -1;
}
for (i = 1; i <= F; i++)
InsertNode (node - i);
InsertNode (node);
for (i = 1; i <= PADDING; i++) {
insert (node - i);
}
insert (node);
do
{
if (m_matchLength > length)
m_matchLength = length;
if (m_matchLength <= THRESHOLD)
{
m_matchLength = 1;
codeBuffer[0] |= mask;
codeBuffer[codeBufferPtr++] = m_textBuffer[node];
do {
if (m_matchLen > length) {
m_matchLen = length;
}
else
{
codeBuffer[codeBufferPtr++] = (uint8) m_matchPosition;
codeBuffer[codeBufferPtr++] = (uint8) (((m_matchPosition >> 4) & 0xf0) | (m_matchLength - (THRESHOLD + 1)));
if (m_matchLen <= THRESHOLD) {
m_matchLen = 1;
cb[0] |= mask;
cb[cbp++] = m_buffer[node];
}
else {
cb[cbp++] = (uint8) (m_matchPos & 0xff);
cb[cbp++] = (uint8) (((m_matchPos >> 4) & 0xf0) | (m_matchLen - (THRESHOLD + 1)));
}
if ((mask <<= 1) == 0)
{
for (i = 0; i < codeBufferPtr; i++)
fp.PutChar (codeBuffer[i]);
m_codeSize += codeBufferPtr;
codeBuffer[0] = 0;
codeBufferPtr = mask = 1;
if ((mask <<= 1) == 0) {
for (i = 0; i < cbp; i++) {
fp.putch (cb[i]);
}
m_csize += cbp;
cb[0] = 0;
cbp = mask = 1;
}
lastMatchLength = m_matchLength;
last = m_matchLen;
for (i = 0; (i < lastMatchLength) && (bufferPtr < bufferSize); i++)
{
bit = buffer[bufferPtr++];
DeleteNode (strPtr);
for (i = 0; (i < last) && (bp < bufferSize); i++) {
bit = buffer[bp++];
erase (ptr);
m_textBuffer[strPtr] = bit;
m_buffer[ptr] = bit;
if (strPtr < F - 1)
m_textBuffer[strPtr + N] = bit;
strPtr = (strPtr + 1) & (N - 1);
node = (node + 1) & (N - 1);
InsertNode (node);
if (ptr < PADDING - 1) {
m_buffer[ptr + MAXBUF] = bit;
}
ptr = (ptr + 1) & (MAXBUF - 1);
node = (node + 1) & (MAXBUF - 1);
insert (node);
}
while (i++ < lastMatchLength)
{
DeleteNode (strPtr);
while (i++ < last) {
erase (ptr);
strPtr = (strPtr + 1) & (N - 1);
node = (node + 1) & (N - 1);
ptr = (ptr + 1) & (MAXBUF - 1);
node = (node + 1) & (MAXBUF - 1);
if (length--)
InsertNode (node);
if (length--) {
insert (node);
}
}
} while (length > 0);
if (codeBufferPtr > 1)
{
for (i = 0; i < codeBufferPtr; i++)
fp.PutChar (codeBuffer[i]);
m_codeSize += codeBufferPtr;
if (cbp > 1) {
for (i = 0; i < cbp; i++) {
fp.putch (cb[i]);
}
m_csize += cbp;
}
fp.Close ();
fp.close ();
return m_codeSize;
return m_csize;
}
int InternalDecode (const char *fileName, int headerSize, uint8 *buffer, int bufferSize)
{
int decode_ (const char *fileName, int headerSize, uint8 *buffer, int bufferSize) {
int i, j, k, node;
unsigned int flags;
int bufferPtr = 0;
int bp = 0;
uint8 bit;
File fp (fileName, "rb");
if (!fp.IsValid ())
if (!fp.isValid ()) {
return -1;
}
fp.seek (headerSize, SEEK_SET);
fp.Seek (headerSize, SEEK_SET);
node = N - F;
for (i = 0; i < node; i++)
m_textBuffer[i] = ' ';
node = MAXBUF - PADDING;
for (i = 0; i < node; i++) {
m_buffer[i] = ' ';
}
flags = 0;
for (;;)
{
if (((flags >>= 1) & 256) == 0)
{
int read = fp.GetChar ();
for (;;) {
if (((flags >>= 1) & 256) == 0) {
int read = fp.getch ();
if (read == EOF)
if (read == EOF) {
break;
}
bit = static_cast <uint8> (read);
flags = bit | 0xff00;
}
if (flags & 1)
{
int read = fp.GetChar ();
if (read == EOF)
break;
bit = static_cast <uint8> (read);
buffer[bufferPtr++] = bit;
if (bufferPtr > bufferSize)
return -1;
m_textBuffer[node++] = bit;
node &= (N - 1);
}
else
{
if ((i = fp.GetChar ()) == EOF)
break;
if ((j = fp.GetChar ()) == EOF)
if (flags & 1) {
int read = fp.getch ();
if (read == EOF) {
break;
}
bit = static_cast <uint8> (read);
buffer[bp++] = bit;
if (bp > bufferSize) {
return -1;
}
m_buffer[node++] = bit;
node &= (MAXBUF - 1);
}
else {
if ((i = fp.getch ()) == EOF) {
break;
}
if ((j = fp.getch ()) == EOF) {
break;
}
i |= ((j & 0xf0) << 4);
j = (j & 0x0f) + THRESHOLD;
for (k = 0; k <= j; k++)
{
bit = m_textBuffer[(i + k) & (N - 1)];
buffer[bufferPtr++] = bit;
for (k = 0; k <= j; k++) {
bit = m_buffer[(i + k) & (MAXBUF - 1)];
buffer[bp++] = bit;
if (bufferPtr > bufferSize)
if (bp > bufferSize) {
return -1;
m_textBuffer[node++] = bit;
node &= (N - 1);
}
m_buffer[node++] = bit;
node &= (MAXBUF - 1);
}
}
}
fp.Close ();
fp.close ();
return bufferPtr;
return bp;
}
// external decoder
static int Uncompress (const char *fileName, int headerSize, uint8 *buffer, int bufferSize)
{
static Compressor compressor = Compressor ();
return compressor.InternalDecode (fileName, headerSize, buffer, bufferSize);
static int decode (const char *fileName, int headerSize, uint8 *buffer, int bufferSize) {
static Compress compressor;
return compressor.decode_ (fileName, headerSize, buffer, bufferSize);
}
// external encoder
static int Compress(const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize)
{
static Compressor compressor = Compressor ();
return compressor.InternalEncode (fileName, header, headerSize, buffer, bufferSize);
static int encode (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) {
static Compress compressor;
return compressor.encode_ (fileName, header, headerSize, buffer, bufferSize);
}
};

File diff suppressed because it is too large Load diff

View file

@ -4,24 +4,20 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license
//
// Purpose: Engine & Game interfaces.
// https://yapb.ru/license
//
#pragma once
// line draw
enum DrawLineType
{
enum DrawLineType {
DRAW_SIMPLE,
DRAW_ARROW,
DRAW_NUM
};
// trace ignore
enum TraceIgnore
{
enum TraceIgnore {
TRACE_IGNORE_NONE = 0,
TRACE_IGNORE_GLASS = (1 << 0),
TRACE_IGNORE_MONSTERS = (1 << 1),
@ -29,8 +25,7 @@ enum TraceIgnore
};
// variable type
enum VarType
{
enum VarType {
VT_NORMAL = 0,
VT_READONLY,
VT_PASSWORD,
@ -39,8 +34,7 @@ enum VarType
};
// netmessage functions
enum NetMsgId
{
enum NetMsgId {
NETMSG_UNDEFINED = -1,
NETMSG_VGUI = 1,
NETMSG_SHOWMENU = 2,
@ -55,7 +49,7 @@ enum NetMsgId
NETMSG_SCREENFADE = 11,
NETMSG_HLTV = 12,
NETMSG_TEXTMSG = 13,
NETMSG_SCOREINFO = 14,
NETMSG_TEAMINFO = 14,
NETMSG_BARTIME = 15,
NETMSG_SENDAUDIO = 17,
NETMSG_SAYTEXT = 18,
@ -64,8 +58,7 @@ enum NetMsgId
};
// variable reg pair
struct VarPair
{
struct VarPair {
VarType type;
cvar_t reg;
class ConVar *self;
@ -74,25 +67,32 @@ struct VarPair
const char *regVal;
};
// translation pair
struct TranslatorPair
{
const char *original;
const char *translated;
};
// network message block
struct MessageBlock
{
struct MessageBlock {
int bot;
int state;
int msg;
int regMsgs[NETMSG_NUM];
};
// compare language
struct LangComprarer {
size_t operator () (const String &key) const {
char *str = const_cast <char *> (key.chars ());
size_t hash = key.length ();
while (*str++) {
if (!isalpha (*str)) {
continue;
}
hash = ((*str << 5) + hash) + *str;
}
return hash;
}
};
// provides utility functions to not call original engine (less call-cost)
class Engine : public Singleton <Engine>
{
class Engine : public Singleton <Engine> {
private:
int m_drawModels[DRAW_NUM];
@ -105,217 +105,293 @@ private:
edict_t *m_localEntity;
Array <VarPair> m_cvars;
Array <TranslatorPair> m_language;
HashMap <String, String, LangComprarer> m_language;
MessageBlock m_msgBlock;
bool m_precached;
public:
Engine (void);
~Engine (void);
// public functions
public:
// precaches internal stuff
void Precache (edict_t *startEntity);
void precache (void);
// initialize levels
void levelInitialize (void);
// prints data to servers console
void Printf (const char *fmt, ...);
void print (const char *fmt, ...);
// prints chat message to all players
void ChatPrintf (const char *fmt, ...);
void chatPrint (const char *fmt, ...);
// prints center message to all players
void CenterPrintf (const char *fmt, ...);
void centerPrint (const char *fmt, ...);
// prints message to client console
void ClientPrintf (edict_t *ent, const char *fmt, ...);
void clientPrint (edict_t *ent, const char *fmt, ...);
// display world line
void DrawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life, DrawLineType type = DRAW_SIMPLE);
void drawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life, DrawLineType type = DRAW_SIMPLE);
// test line
void TestLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
void testLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
// test line
void TestHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
void testHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
// get's the wave length
float GetWaveLength (const char *fileName);
float getWaveLen (const char *fileName);
// we are on dedicated server ?
bool IsDedicatedServer (void);
bool isDedicated (void);
// get stripped down mod name
const char *GetModName (void);
const char *getModName (void);
// get the valid mapname
const char *GetMapName (void);
const char *getMapName (void);
// get the "any" entity origin
Vector GetAbsOrigin (edict_t *ent);
Vector getAbsPos (edict_t *ent);
// send server command
void IssueCmd (const char *fmt, ...);
void execCmd (const char *fmt, ...);
// registers a server command
void RegisterCmd (const char *command, void func (void));
void registerCmd (const char *command, void func (void));
// play's sound to client
void EmitSound (edict_t *ent, const char *sound);
void playSound (edict_t *ent, const char *sound);
// sends bot command
void IssueBotCommand (edict_t *ent, const char *fmt, ...);
void execBotCmd (edict_t *ent, const char *fmt, ...);
// adds cvar to registration stack
void PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, const char *regVal, ConVar *self);
void pushVarToRegStack (const char *variable, const char *value, VarType varType, bool regMissing, const char *regVal, ConVar *self);
// sends local registration stack for engine registration
void PushRegisteredConVarsToEngine (bool gameVars = false);
void pushRegStackToEngine (bool gameVars = false);
// translates bot message into needed language
char *TraslateMessage (const char *input);
// cleanup translator resources
void TerminateTranslator (void);
const char *translate (const char *input);
// do actual network message processing
void ProcessMessageCapture (void *ptr);
void processMessages (void *ptr);
// public inlines
public:
// get the current time on server
FORCEINLINE float Time (void)
{
inline float timebase (void) {
return g_pGlobals->time;
}
// get "maxplayers" limit on server
FORCEINLINE int MaxClients (void)
{
inline int maxClients (void) {
return g_pGlobals->maxClients;
}
// get the fakeclient command interface
inline bool IsBotCommand (void)
{
inline bool isBotCmd (void) {
return m_isBotCommand;
}
// gets custom engine args for client command
inline const char *GetOverrideArgs (void)
{
if (strncmp ("say ", m_arguments, 4) == 0)
inline const char *botArgs (void) {
if (strncmp ("say ", m_arguments, 4) == 0) {
return &m_arguments[4];
else if (strncmp ("say_team ", m_arguments, 9) == 0)
}
else if (strncmp ("say_team ", m_arguments, 9) == 0) {
return &m_arguments[9];
}
return m_arguments;
}
// gets custom engine argv for client command
inline const char *GetOverrideArgv (int num)
{
return ExtractSingleField (m_arguments, num);
inline const char *botArgv (int num) {
return getField (m_arguments, static_cast <size_t> (num));
}
// gets custom engine argc for client command
inline int GetOverrideArgc (void)
{
inline int botArgc (void) {
return m_argumentCount;
}
// gets edict pointer out of entity index
FORCEINLINE edict_t *EntityOfIndex (const int index)
{
inline edict_t *entityOfIndex (const int index) {
return static_cast <edict_t *> (m_startEntity + index);
};
// gets edict index out of it's pointer
FORCEINLINE int IndexOfEntity (const edict_t *ent)
{
inline int indexOfEntity (const edict_t *ent) {
return static_cast <int> (ent - m_startEntity);
};
// verify entity isn't null
FORCEINLINE bool IsNullEntity (const edict_t *ent)
{
return !ent || !IndexOfEntity (ent);
inline bool isNullEntity (const edict_t *ent) {
return !ent || !indexOfEntity (ent) || ent->free;
}
// get the wroldspawn entity
inline edict_t *getStartEntity (void) {
return m_startEntity;
}
// gets the player team
FORCEINLINE int GetTeam (edict_t *ent)
{
inline int getTeam (edict_t *ent) {
extern Client g_clients[MAX_ENGINE_PLAYERS];
return g_clients[IndexOfEntity (ent) - 1].team;
return g_clients[indexOfEntity (ent) - 1].team;
}
// adds translation pair from config
inline void PushTranslationPair (const TranslatorPair &lang)
{
m_language.Push (lang);
inline void addTranslation (const String &original, const String &translated) {
m_language.put (original, translated);
}
// resets the message capture mechanism
inline void ResetMessageCapture (void)
{
inline void resetMessages (void) {
m_msgBlock.msg = NETMSG_UNDEFINED;
m_msgBlock.state = 0;
m_msgBlock.bot = 0;
};
// sets the currently executed message
inline void SetOngoingMessageId (int message)
{
inline void setCurrentMessageId (int message) {
m_msgBlock.msg = message;
}
// set the bot entity that receive this message
inline void SetOngoingMessageReceiver (int id)
{
inline void setCurrentMessageOwner (int id) {
m_msgBlock.bot = id;
}
// find registered message id
FORCEINLINE int FindMessageId (int type)
{
inline int getMessageId (int type) {
return m_msgBlock.regMsgs[type];
}
// assigns message id for message type
inline void AssignMessageId (int type, int id)
{
inline void setMessageId (int type, int id) {
m_msgBlock.regMsgs[type] = id;
}
// tries to set needed message id
FORCEINLINE void TryCaptureMessage (int type, int msgId)
{
if (type == m_msgBlock.regMsgs[msgId])
SetOngoingMessageId (msgId);
inline void captureMessage (int type, int msgId) {
if (type == m_msgBlock.regMsgs[msgId]) {
setCurrentMessageId (msgId);
}
}
// sets the precache to uninitialize
inline void setUnprecached (void) {
m_precached = false;
}
// static utility functions
private:
const char *ExtractSingleField (const char *string, int id);
const char *getField (const char *string, size_t id);
};
// simplify access for console variables
class ConVar
{
class ConVar {
public:
cvar_t *m_eptr;
public:
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false, const char *regVal = nullptr);
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false, const char *regVal = nullptr) : m_eptr (nullptr) {
Engine::ref ().pushVarToRegStack (name, initval, type, regMissing, regVal, this);
}
FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; }
FORCEINLINE int GetInt (void) { return static_cast <int> (m_eptr->value); }
FORCEINLINE float GetFloat (void) { return m_eptr->value; }
FORCEINLINE const char *GetString (void) { return m_eptr->string; }
FORCEINLINE void SetFloat (float val) { g_engfuncs.pfnCVarSetFloat (m_eptr->name, val); }
FORCEINLINE void SetInt (int val) { SetFloat (static_cast <float> (val)); }
FORCEINLINE void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); }
inline bool boolean (void) const {
return m_eptr->value > 0.0f;
}
inline int integer (void) const {
return static_cast <int> (m_eptr->value);
}
inline float flt (void) const {
return m_eptr->value;
}
inline const char *str (void) const {
return m_eptr->string;
}
inline void set (float val) const {
g_engfuncs.pfnCVarSetFloat (m_eptr->name, val);
}
inline void set (int val) const {
set (static_cast <float> (val));
}
inline void set (const char *val) const {
g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val));
}
};
class MessageWriter {
private:
bool m_autoDestruct { false };
public:
MessageWriter (void) = default;
MessageWriter (int dest, int type, const Vector &pos = Vector::null (), edict_t *to = nullptr) {
start (dest, type, pos, to);
m_autoDestruct = true;
}
virtual ~MessageWriter (void) {
if (m_autoDestruct) {
end ();
}
}
public:
MessageWriter &start (int dest, int type, const Vector &pos = Vector::null (), edict_t *to = nullptr) {
g_engfuncs.pfnMessageBegin (dest, type, pos, to);
return *this;
}
void end (void) {
g_engfuncs.pfnMessageEnd ();
}
MessageWriter &writeByte (int val) {
g_engfuncs.pfnWriteByte (val);
return *this;
}
MessageWriter &writeChar (int val) {
g_engfuncs.pfnWriteChar (val);
return *this;
}
MessageWriter &writeShort (int val) {
g_engfuncs.pfnWriteShort (val);
return *this;
}
MessageWriter &writeCoord (float val) {
g_engfuncs.pfnWriteCoord (val);
return *this;
}
MessageWriter &writeString (const char *val) {
g_engfuncs.pfnWriteString (val);
return *this;
}
public:
static inline uint16 fu16 (float value, float scale) {
return cr::clamp <uint16> (static_cast <uint16> (value * scale), 0, 0xffff);
}
static inline short fs16 (float value, float scale) {
return cr::clamp <short> (static_cast <short> (value * scale), -32767, 32767);
}
};

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
/***
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef EIFACE_H
#define EIFACE_H
@ -19,18 +19,17 @@
#include <stdio.h>
#define FCVAR_ARCHIVE (1 << 0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1 << 1) // changes the client's info string
#define FCVAR_SERVER (1 << 2) // notifies players when changed
#define FCVAR_EXTDLL (1 << 3) // defined by external DLL
#define FCVAR_CLIENTDLL (1 << 4) // defined by the client dll
#define FCVAR_PROTECTED (1 << 5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1 << 6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1 << 7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1 << 8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_ARCHIVE (1 << 0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1 << 1) // changes the client's info string
#define FCVAR_SERVER (1 << 2) // notifies players when changed
#define FCVAR_EXTDLL (1 << 3) // defined by external DLL
#define FCVAR_CLIENTDLL (1 << 4) // defined by the client dll
#define FCVAR_PROTECTED (1 << 5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1 << 6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1 << 7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1 << 8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
struct cvar_t
{
struct cvar_t {
char *name;
char *string;
int flags;
@ -50,337 +49,323 @@ struct cvar_t
#ifdef _WIN32
#define DLLEXPORT __stdcall
#else
#define DLLEXPORT /* */
#define DLLEXPORT /* */
#endif
typedef enum
{
typedef enum {
at_notice,
at_console, // same as at_notice, but forces a ConPrintf, not a message box
at_aiconsole, // same as at_console, but only shown if developer level is 2!
at_console, // same as at_notice, but forces a ConPrintf, not a message box
at_aiconsole, // same as at_console, but only shown if developer level is 2!
at_warning,
at_error,
at_logged // Server print to console ( only in multiplayer games ).
at_logged // Server print to console ( only in multiplayer games ).
} ALERT_TYPE;
// 4-22-98 JOHN: added for use in pfnClientPrintf
typedef enum
{
print_console,
print_center,
print_chat
} PRINT_TYPE;
typedef enum { print_console, print_center, print_chat } PRINT_TYPE;
// For integrity checking of content on clients
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
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_TYPE;
// Returned by TraceLine
typedef struct
{
int fAllSolid; // if true, plane is not valid
int fStartSolid; // if true, the initial point was in a solid area
typedef struct {
int fAllSolid; // if true, plane is not valid
int fStartSolid; // if true, the initial point was in a solid area
int fInOpen;
int fInWater;
float flFraction; // time completed, 1.0 = didn't hit anything
vec3_t vecEndPos; // final position
float flFraction; // time completed, 1.0 = didn't hit anything
vec3_t vecEndPos; // final position
float flPlaneDist;
vec3_t vecPlaneNormal; // surface normal at impact
edict_t *pHit; // entity the surface is on
int iHitgroup; // 0 == generic, non zero is specific body part
vec3_t vecPlaneNormal; // surface normal at impact
edict_t *pHit; // entity the surface is on
int iHitgroup; // 0 == generic, non zero is specific body part
} TraceResult;
typedef uint32 CRC32_t;
// Engine hands this to DLLs for functionality callbacks
typedef struct enginefuncs_s
{
int (*pfnPrecacheModel) (char *s);
int (*pfnPrecacheSound) (char *s);
void (*pfnSetModel) (edict_t *e, const char *m);
int (*pfnModelIndex) (const char *m);
int (*pfnModelFrames) (int modelIndex);
void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax);
void (*pfnChangeLevel) (char *s1, char *s2);
void (*pfnGetSpawnParms) (edict_t *ent);
void (*pfnSaveSpawnParms) (edict_t *ent);
float (*pfnVecToYaw) (const float *rgflVector);
void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut);
void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType);
void (*pfnChangeYaw) (edict_t *ent);
void (*pfnChangePitch) (edict_t *ent);
edict_t *(*pfnFindEntityByString) (edict_t *pentEdictStartSearchAfter, const char *pszField, const char *pszValue);
int (*pfnGetEntityIllum) (edict_t *pEnt);
edict_t *(*pfnFindEntityInSphere) (edict_t *pentEdictStartSearchAfter, const float *org, float rad);
edict_t *(*pfnFindClientInPVS) (edict_t *ent);
edict_t *(*pfnEntitiesInPVS) (edict_t *pplayer);
void (*pfnMakeVectors) (const float *rgflVector);
void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up);
edict_t *(*pfnCreateEntity) (void);
void (*pfnRemoveEntity) (edict_t *e);
edict_t *(*pfnCreateNamedEntity) (int className);
void (*pfnMakeStatic) (edict_t *ent);
int (*pfnEntIsOnFloor) (edict_t *e);
int (*pfnDropToFloor) (edict_t *e);
int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int mode);
void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin);
void (*pfnEmitSound) (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch);
void (*pfnEmitAmbientSound) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch);
void (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnTraceToss) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr);
int (*pfnTraceMonsterHull) (edict_t *ent, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnTraceHull) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnTraceModel) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr);
typedef struct enginefuncs_s {
int (*pfnPrecacheModel) (char *s);
int (*pfnPrecacheSound) (char *s);
void (*pfnSetModel) (edict_t *e, const char *m);
int (*pfnModelIndex) (const char *m);
int (*pfnModelFrames) (int modelIndex);
void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax);
void (*pfnChangeLevel) (char *s1, char *s2);
void (*pfnGetSpawnParms) (edict_t *ent);
void (*pfnSaveSpawnParms) (edict_t *ent);
float (*pfnVecToYaw) (const float *rgflVector);
void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut);
void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType);
void (*pfnChangeYaw) (edict_t *ent);
void (*pfnChangePitch) (edict_t *ent);
edict_t *(*pfnFindEntityByString) (edict_t *pentEdictStartSearchAfter, const char *pszField, const char *pszValue);
int (*pfnGetEntityIllum) (edict_t *pEnt);
edict_t *(*pfnFindEntityInSphere) (edict_t *pentEdictStartSearchAfter, const float *org, float rad);
edict_t *(*pfnFindClientInPVS) (edict_t *ent);
edict_t *(*pfnEntitiesInPVS) (edict_t *pplayer);
void (*pfnMakeVectors) (const float *rgflVector);
void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up);
edict_t *(*pfnCreateEntity) (void);
void (*pfnRemoveEntity) (edict_t *e);
edict_t *(*pfnCreateNamedEntity) (int className);
void (*pfnMakeStatic) (edict_t *ent);
int (*pfnEntIsOnFloor) (edict_t *e);
int (*pfnDropToFloor) (edict_t *e);
int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int mode);
void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin);
void (*pfnEmitSound) (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch);
void (*pfnEmitAmbientSound) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch);
void (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnTraceToss) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr);
int (*pfnTraceMonsterHull) (edict_t *ent, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnTraceHull) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnTraceModel) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr);
const char *(*pfnTraceTexture) (edict_t *pTextureEntity, const float *v1, const float *v2);
void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnGetAimVector) (edict_t *ent, float speed, float *rgflReturn);
void (*pfnServerCommand) (char *str);
void (*pfnServerExecute) (void);
void (*pfnClientCommand) (edict_t *ent, char const *szFmt, ...);
void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count);
void (*pfnLightStyle) (int style, char *val);
int (*pfnDecalIndex) (const char *name);
int (*pfnPointContents) (const float *rgflVector);
void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
void (*pfnMessageEnd) (void);
void (*pfnWriteByte) (int value);
void (*pfnWriteChar) (int value);
void (*pfnWriteShort) (int value);
void (*pfnWriteLong) (int value);
void (*pfnWriteAngle) (float flValue);
void (*pfnWriteCoord) (float flValue);
void (*pfnWriteString) (const char *sz);
void (*pfnWriteEntity) (int value);
void (*pfnCVarRegister) (cvar_t *pCvar);
float (*pfnCVarGetFloat) (const char *szVarName);
void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr);
void (*pfnGetAimVector) (edict_t *ent, float speed, float *rgflReturn);
void (*pfnServerCommand) (char *str);
void (*pfnServerExecute) (void);
void (*pfnClientCommand) (edict_t *ent, char const *szFmt, ...);
void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count);
void (*pfnLightStyle) (int style, char *val);
int (*pfnDecalIndex) (const char *name);
int (*pfnPointContents) (const float *rgflVector);
void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
void (*pfnMessageEnd) (void);
void (*pfnWriteByte) (int value);
void (*pfnWriteChar) (int value);
void (*pfnWriteShort) (int value);
void (*pfnWriteLong) (int value);
void (*pfnWriteAngle) (float flValue);
void (*pfnWriteCoord) (float flValue);
void (*pfnWriteString) (const char *sz);
void (*pfnWriteEntity) (int value);
void (*pfnCVarRegister) (cvar_t *pCvar);
float (*pfnCVarGetFloat) (const char *szVarName);
const char *(*pfnCVarGetString) (const char *szVarName);
void (*pfnCVarSetFloat) (const char *szVarName, float flValue);
void (*pfnCVarSetString) (const char *szVarName, const char *szValue);
void (*pfnAlertMessage) (ALERT_TYPE atype, char *szFmt, ...);
void (*pfnEngineFprintf) (void *pfile, char *szFmt, ...);
void *(*pfnPvAllocEntPrivateData) (edict_t *ent, int32 cb);
void *(*pfnPvEntPrivateData) (edict_t *ent);
void (*pfnFreeEntPrivateData) (edict_t *ent);
void (*pfnCVarSetFloat) (const char *szVarName, float flValue);
void (*pfnCVarSetString) (const char *szVarName, const char *szValue);
void (*pfnAlertMessage) (ALERT_TYPE atype, char *szFmt, ...);
void (*pfnEngineFprintf) (void *pfile, char *szFmt, ...);
void *(*pfnPvAllocEntPrivateData) (edict_t *ent, int32 cb);
void *(*pfnPvEntPrivateData) (edict_t *ent);
void (*pfnFreeEntPrivateData) (edict_t *ent);
const char *(*pfnSzFromIndex) (int stingPtr);
int (*pfnAllostring) (const char *szValue);
int (*pfnAllocString) (const char *szValue);
struct entvars_s *(*pfnGetVarsOfEnt) (edict_t *ent);
edict_t *(*pfnPEntityOfEntOffset) (int iEntOffset);
int (*pfnEntOffsetOfPEntity) (const edict_t *ent);
int (*pfnIndexOfEdict) (const edict_t *ent);
edict_t *(*pfnPEntityOfEntIndex) (int entIndex);
edict_t *(*pfnFindEntityByVars) (struct entvars_s *pvars);
void *(*pfnGetModelPtr) (edict_t *ent);
int (*pfnRegUserMsg) (const char *pszName, int iSize);
void (*pfnAnimationAutomove) (const edict_t *ent, float flTime);
void (*pfnGetBonePosition) (const edict_t *ent, int iBone, float *rgflOrigin, float *rgflAngles);
uint32 (*pfnFunctionFromName) (const char *pName);
edict_t *(*pfnPEntityOfEntOffset) (int iEntOffset);
int (*pfnEntOffsetOfPEntity) (const edict_t *ent);
int (*pfnIndexOfEdict) (const edict_t *ent);
edict_t *(*pfnPEntityOfEntIndex) (int entIndex);
edict_t *(*pfnFindEntityByVars) (struct entvars_s *pvars);
void *(*pfnGetModelPtr) (edict_t *ent);
int (*pfnRegUserMsg) (const char *pszName, int iSize);
void (*pfnAnimationAutomove) (const edict_t *ent, float flTime);
void (*pfnGetBonePosition) (const edict_t *ent, int iBone, float *rgflOrigin, float *rgflAngles);
uint32 (*pfnFunctionFromName) (const char *pName);
const char *(*pfnNameForFunction) (uint32 function);
void (*pfnClientPrintf) (edict_t *ent, PRINT_TYPE ptype, const char *szMsg); // JOHN: engine callbacks so game DLL can print messages to individual clients
void (*pfnServerPrint) (const char *szMsg);
const char *(*pfnCmd_Args) (void); // these 3 added
const char *(*pfnCmd_Argv) (int argc); // so game DLL can easily
int (*pfnCmd_Argc) (void); // access client 'cmd' strings
void (*pfnGetAttachment) (const edict_t *ent, int iAttachment, float *rgflOrigin, float *rgflAngles);
void (*pfnCRC32_Init) (CRC32_t *pulCRC);
void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len);
void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, uint8 ch);
CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC);
int32 (*pfnRandomLong) (int32 lLow, int32 lHigh);
float (*pfnRandomFloat) (float flLow, float flHigh);
void (*pfnSetView) (const edict_t *client, const edict_t *pViewent);
float (*pfnTime) (void);
void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw);
uint8 *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
void (*pfnFreeFile) (void *buffer);
void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection
int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare);
void (*pfnGetGameDir) (char *szGetGameDir);
void (*pfnCvar_RegisterVariable) (cvar_t *variable);
void (*pfnFadeClientVolume) (const edict_t *ent, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
void (*pfnSetClientMaxspeed) (const edict_t *ent, float fNewMaxspeed);
edict_t *(*pfnCreateFakeClient) (const char *netname); // returns nullptr if fake client can't be created
void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, uint16 buttons, uint8 impulse, uint8 msec);
int (*pfnNumberOfEntities) (void);
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in nullptr gets the serverinfo
char *(*pfnInfoKeyValue) (char *infobuffer, char const *key);
void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value);
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value);
int (*pfnIsMapValid) (char *szFilename);
void (*pfnStaticDecal) (const float *origin, int decalIndex, int entityIndex, int modelIndex);
int (*pfnPrecacheGeneric) (char *s);
int (*pfnGetPlayerUserId) (edict_t *e); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients
void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
int (*pfnIsDedicatedServer) (void); // is this a dedicated server?
cvar_t *(*pfnCVarGetPointer) (const char *szVarName);
unsigned int (*pfnGetPlayerWONId) (edict_t *e); // returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients
void (*pfnInfo_RemoveKey) (char *s, const char *key);
void (*pfnClientPrintf) (edict_t *ent, PRINT_TYPE ptype, const char *szMsg); // JOHN: engine callbacks so game DLL can print messages to individual clients
void (*pfnServerPrint) (const char *szMsg);
const char *(*pfnCmd_Args) (void); // these 3 added
const char *(*pfnCmd_Argv) (int argc); // so game DLL can easily
int (*pfnCmd_Argc) (void); // access client 'cmd' strings
void (*pfnGetAttachment) (const edict_t *ent, int iAttachment, float *rgflOrigin, float *rgflAngles);
void (*pfnCRC32_Init) (CRC32_t *pulCRC);
void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len);
void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, uint8 ch);
CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC);
int32 (*pfnRandomLong) (int32 lLow, int32 lHigh);
float (*pfnRandomFloat) (float flLow, float flHigh);
void (*pfnSetView) (const edict_t *client, const edict_t *pViewent);
float (*pfnTime) (void);
void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw);
uint8 *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
void (*pfnFreeFile) (void *buffer);
void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection
int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare);
void (*pfnGetGameDir) (char *szGetGameDir);
void (*pfnCvar_RegisterVariable) (cvar_t *variable);
void (*pfnFadeClientVolume) (const edict_t *ent, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
void (*pfnSetClientMaxspeed) (const edict_t *ent, float fNewMaxspeed);
edict_t *(*pfnCreateFakeClient) (const char *netname); // returns nullptr if fake client can't be created
void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, uint16 buttons, uint8 impulse, uint8 msec);
int (*pfnNumberOfEntities) (void);
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in nullptr gets the serverinfo
char *(*pfnInfoKeyValue) (char *infobuffer, char const *key);
void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value);
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value);
int (*pfnIsMapValid) (char *szFilename);
void (*pfnStaticDecal) (const float *origin, int decalIndex, int entityIndex, int modelIndex);
int (*pfnPrecacheGeneric) (char *s);
int (*pfnGetPlayerUserId) (edict_t *e); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients
void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
int (*pfnIsDedicatedServer) (void); // is this a dedicated server?
cvar_t *(*pfnCVarGetPointer) (const char *szVarName);
unsigned int (*pfnGetPlayerWONId) (edict_t *e); // returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients
void (*pfnInfo_RemoveKey) (char *s, const char *key);
const char *(*pfnGetPhysicsKeyValue) (const edict_t *client, const char *key);
void (*pfnSetPhysicsKeyValue) (const edict_t *client, const char *key, const char *value);
void (*pfnSetPhysicsKeyValue) (const edict_t *client, const char *key, const char *value);
const char *(*pfnGetPhysicsInfoString) (const edict_t *client);
uint16 (*pfnPrecacheEvent) (int type, const char *psz);
void (*pfnPlaybackEvent) (int flags, const edict_t *pInvoker, uint16 evIndexOfEntity, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
uint8 *(*pfnSetFatPVS) (float *org);
uint8 *(*pfnSetFatPAS) (float *org);
int (*pfnCheckVisibility) (const edict_t *entity, uint8 *pset);
void (*pfnDeltaSetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaUnsetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaAddEncoder) (char *name, void (*conditionalencode) (struct delta_s *pFields, const uint8 *from, const uint8 *to));
int (*pfnGetCurrentPlayer) (void);
int (*pfnCanSkipPlayer) (const edict_t *player);
int (*pfnDeltaFindField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaSetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
void (*pfnDeltaUnsetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
void (*pfnSetGroupMask) (int mask, int op);
int (*pfnCreateInstancedBaseline) (int classname, struct entity_state_s *baseline);
void (*pfnCvar_DirectSet) (struct cvar_t *var, char *value);
void (*pfnForceUnmodified) (FORCE_TYPE type, float *mins, float *maxs, const char *szFilename);
void (*pfnGetPlayerStats) (const edict_t *client, int *ping, int *packet_loss);
void (*pfnAddServerCommand) (char *cmd_name, void (*function) (void));
int (*pfnCheckVisibility) (const edict_t *entity, uint8 *pset);
void (*pfnDeltaSetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaUnsetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaAddEncoder) (char *name, void (*conditionalencode) (struct delta_s *pFields, const uint8 *from, const uint8 *to));
int (*pfnGetCurrentPlayer) (void);
int (*pfnCanSkipPlayer) (const edict_t *player);
int (*pfnDeltaFindField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaSetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
void (*pfnDeltaUnsetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
void (*pfnSetGroupMask) (int mask, int op);
int (*pfnCreateInstancedBaseline) (int classname, struct entity_state_s *baseline);
void (*pfnCvar_DirectSet) (struct cvar_t *var, char *value);
void (*pfnForceUnmodified) (FORCE_TYPE type, float *mins, float *maxs, const char *szFilename);
void (*pfnGetPlayerStats) (const edict_t *client, int *ping, int *packet_loss);
void (*pfnAddServerCommand) (char *cmd_name, void (*function) (void));
int (*pfnVoice_GetClientListening) (int iReceiver, int iSender);
int (*pfnVoice_SetClientListening) (int iReceiver, int iSender, int bListen);
const char *(*pfnGetPlayerAuthId) (edict_t *e);
struct sequenceEntry_s *(*pfnSequenceGet) (const char *fileName, const char *entryName);
struct sentenceEntry_s *(*pfnSequencePickSentence) (const char *groupName, int pickMethod, int *picked);
int (*pfnGetFileSize) (char *szFilename);
int (*pfnGetFileSize) (char *szFilename);
unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath);
int (*pfnIsCareerMatch) (void);
int (*pfnGetLocalizedStringLength) (const char *label);
void (*pfnRegisterTutorMessageShown) (int mid);
int (*pfnGetTimesTutorMessageShown) (int mid);
void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength);
void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength);
void (*pfnResetTutorMessageDecayData) (void);
void (*pfnQueryClientCVarValue) (const edict_t *player, const char *cvarName);
void (*pfnQueryClientCVarValue2) (const edict_t *player, const char *cvarName, int requestID);
int (*pfnCheckParm)(const char *pchCmdLineToken, char **ppnext);
int (*pfnIsCareerMatch) (void);
int (*pfnGetLocalizedStringLength) (const char *label);
void (*pfnRegisterTutorMessageShown) (int mid);
int (*pfnGetTimesTutorMessageShown) (int mid);
void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength);
void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength);
void (*pfnResetTutorMessageDecayData) (void);
void (*pfnQueryClientCVarValue) (const edict_t *player, const char *cvarName);
void (*pfnQueryClientCVarValue2) (const edict_t *player, const char *cvarName, int requestID);
int (*pfnCheckParm) (const char *pchCmdLineToken, char **ppnext);
} enginefuncs_t;
// Passed to pfnKeyValue
typedef struct KeyValueData_s
{
typedef struct KeyValueData_s {
char *szClassName; // in: entity classname
char const *szKeyName; // in: name of key
char *szValue; // in: value of key
int32 fHandled; // out: DLL sets to true if key-value pair was understood
char const *szKeyName; // in: name of key
char *szValue; // in: value of key
int32 fHandled; // out: DLL sets to true if key-value pair was understood
} KeyValueData;
#define ARRAYSIZE_HLSDK(p) (int) (sizeof(p)/sizeof(p[0]))
typedef struct customization_s customization_t;
typedef struct
{
typedef struct {
// Initialize/shutdown the game (one-time call after loading of game .dll )
void (*pfnGameInit) (void);
int (*pfnSpawn) (edict_t *pent);
void (*pfnThink) (edict_t *pent);
void (*pfnUse) (edict_t *pentUsed, edict_t *pentOther);
void (*pfnTouch) (edict_t *pentTouched, edict_t *pentOther);
void (*pfnBlocked) (edict_t *pentBlocked, edict_t *pentOther);
void (*pfnKeyValue) (edict_t *pentKeyvalue, KeyValueData *pkvd);
void (*pfnSave) (edict_t *pent, struct SAVERESTOREDATA *pSaveData);
int (*pfnRestore) (edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity);
void (*pfnSetAbsBox) (edict_t *pent);
void (*pfnGameInit) (void);
int (*pfnSpawn) (edict_t *pent);
void (*pfnThink) (edict_t *pent);
void (*pfnUse) (edict_t *pentUsed, edict_t *pentOther);
void (*pfnTouch) (edict_t *pentTouched, edict_t *pentOther);
void (*pfnBlocked) (edict_t *pentBlocked, edict_t *pentOther);
void (*pfnKeyValue) (edict_t *pentKeyvalue, KeyValueData *pkvd);
void (*pfnSave) (edict_t *pent, struct SAVERESTOREDATA *pSaveData);
int (*pfnRestore) (edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity);
void (*pfnSetAbsBox) (edict_t *pent);
void (*pfnSaveWriteFields) (SAVERESTOREDATA *, const char *, void *, struct TYPEDESCRIPTION *, int);
void (*pfnSaveReadFields) (SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int);
void (*pfnSaveWriteFields) (SAVERESTOREDATA *, const char *, void *, struct TYPEDESCRIPTION *, int);
void (*pfnSaveReadFields) (SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int);
void (*pfnSaveGlobalState) (SAVERESTOREDATA *);
void (*pfnRestoreGlobalState) (SAVERESTOREDATA *);
void (*pfnResetGlobalState) (void);
void (*pfnSaveGlobalState) (SAVERESTOREDATA *);
void (*pfnRestoreGlobalState) (SAVERESTOREDATA *);
void (*pfnResetGlobalState) (void);
int (*pfnClientConnect) (edict_t *ent, const char *pszName, const char *pszAddress, char szRejectReason[128]);
int (*pfnClientConnect) (edict_t *ent, const char *pszName, const char *pszAddress, char szRejectReason[128]);
void (*pfnClientDisconnect) (edict_t *ent);
void (*pfnClientKill) (edict_t *ent);
void (*pfnClientPutInServer) (edict_t *ent);
void (*pfnClientCommand) (edict_t *ent);
void (*pfnClientUserInfoChanged) (edict_t *ent, char *infobuffer);
void (*pfnClientDisconnect) (edict_t *ent);
void (*pfnClientKill) (edict_t *ent);
void (*pfnClientPutInServer) (edict_t *ent);
void (*pfnClientCommand) (edict_t *ent);
void (*pfnClientUserInfoChanged) (edict_t *ent, char *infobuffer);
void (*pfnServerActivate) (edict_t *edictList, int edictCount, int clientMax);
void (*pfnServerDeactivate) (void);
void (*pfnServerActivate) (edict_t *edictList, int edictCount, int clientMax);
void (*pfnServerDeactivate) (void);
void (*pfnPlayerPreThink) (edict_t *ent);
void (*pfnPlayerPostThink) (edict_t *ent);
void (*pfnPlayerPreThink) (edict_t *ent);
void (*pfnPlayerPostThink) (edict_t *ent);
void (*pfnStartFrame) (void);
void (*pfnParmsNewLevel) (void);
void (*pfnParmsChangeLevel) (void);
void (*pfnStartFrame) (void);
void (*pfnParmsNewLevel) (void);
void (*pfnParmsChangeLevel) (void);
// Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
const char *(*pfnGetGameDescription) (void);
// Notify dll about a player customization.
void (*pfnPlayerCustomization) (edict_t *ent, struct customization_s *pCustom);
void (*pfnPlayerCustomization) (edict_t *ent, struct customization_s *pCustom);
// Spectator funcs
void (*pfnSpectatorConnect) (edict_t *ent);
void (*pfnSpectatorDisconnect) (edict_t *ent);
void (*pfnSpectatorThink) (edict_t *ent);
void (*pfnSpectatorConnect) (edict_t *ent);
void (*pfnSpectatorDisconnect) (edict_t *ent);
void (*pfnSpectatorThink) (edict_t *ent);
// Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint.
void (*pfnSys_Error) (const char *error_string);
void (*pfnSys_Error) (const char *error_string);
void (*pfnPM_Move) (struct playermove_s *ppmove, int server);
void (*pfnPM_Init) (struct playermove_s *ppmove);
char (*pfnPM_FindTextureType) (char *name);
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, uint8 **pvs, uint8 **pas);
void (*pfnUpdateClientData) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
int (*pfnAddToFullPack) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, uint8 *pSet);
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, float* player_mins, float* player_maxs);
void (*pfnRegisterEncoders) (void);
int (*pfnGetWeaponData) (struct edict_s *player, struct weapon_data_s *info);
void (*pfnPM_Move) (struct playermove_s *ppmove, int server);
void (*pfnPM_Init) (struct playermove_s *ppmove);
char (*pfnPM_FindTextureType) (char *name);
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, uint8 **pvs, uint8 **pas);
void (*pfnUpdateClientData) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
int (*pfnAddToFullPack) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, uint8 *pSet);
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, float *player_mins, float *player_maxs);
void (*pfnRegisterEncoders) (void);
int (*pfnGetWeaponData) (struct edict_s *player, struct weapon_data_s *info);
void (*pfnCmdStart) (const edict_t *player, const struct c *cmd, unsigned int random_seed);
void (*pfnCmdEnd) (const edict_t *player);
void (*pfnCmdStart) (const edict_t *player, const struct c *cmd, unsigned int random_seed);
void (*pfnCmdEnd) (const edict_t *player);
// Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
// size of the response_buffer, so you must zero it out if you choose not to respond.
int (*pfnConnectionlessPacket) (const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size);
int (*pfnConnectionlessPacket) (const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size);
// Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise
int (*pfnGetHullBounds) (int hullnumber, float *mins, float *maxs);
int (*pfnGetHullBounds) (int hullnumber, float *mins, float *maxs);
// Create baselines for certain "unplaced" items.
void (*pfnCreateInstancedBaselines) (void);
void (*pfnCreateInstancedBaselines) (void);
// One of the pfnForceUnmodified files failed the consistency check for the specified player
// Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters )
int (*pfnInconsistentFile) (const struct edict_s *player, const char *szFilename, char *disconnect_message);
int (*pfnInconsistentFile) (const struct edict_s *player, const char *szFilename, char *disconnect_message);
// The game .dll should return 1 if lag compensation should be allowed ( could also just set
// the sv_unlag cvar.
// Most games right now should return 0, until client-side weapon prediction code is written
// and tested for them.
int (*pfnAllowLagCompensation) (void);
int (*pfnAllowLagCompensation) (void);
} gamefuncs_t;
// Current version.
#define NEWGAMEDLLFUNCS_VERSION 1
#define NEWGAMEDLLFUNCS_VERSION 1
typedef struct
{
// Called right before the object's memory is freed.
typedef struct {
// Called right before the object's memory is freed.
// Calls its destructor.
void (*pfnOnFreeEntPrivateData) (edict_t *pEnt);
void (*pfnGameShutdown) (void);
int (*pfnShouldCollide) (edict_t *pentTouched, edict_t *pentOther);
void (*pfnOnFreeEntPrivateData) (edict_t *pEnt);
void (*pfnGameShutdown) (void);
int (*pfnShouldCollide) (edict_t *pentTouched, edict_t *pentOther);
void (*pfnCvarValue) (const edict_t *pEnt, const char *value);
void (*pfnCvarValue2) (const edict_t *pEnt, int requestID, const char *cvarName, const char *value);
void (*pfnCvarValue) (const edict_t *pEnt, const char *value);
void (*pfnCvarValue2) (const edict_t *pEnt, int requestID, const char *cvarName, const char *value);
} newgamefuncs_t;
#endif /* EIFACE_H */
#endif /* EIFACE_H */

View file

@ -1,145 +0,0 @@
/***
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef ENGINECALLBACK_H
#define ENGINECALLBACK_H
#pragma once
// Must be provided by user of this code
extern enginefuncs_t g_engfuncs;
// The actual engine callbacks
#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId)
#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel)
#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound)
#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric)
#define SET_MODEL (*g_engfuncs.pfnSetModel)
#define MODEL_INDEX (*g_engfuncs.pfnModelIndex)
#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames)
#define SET_SIZE (*g_engfuncs.pfnSetSize)
#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel)
#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue)
#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand)
#define SERVER_PRINT (*g_engfuncs.pfnServerPrint)
#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue)
#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms)
#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms)
#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw)
#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles)
#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin)
#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw)
#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch)
#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors)
#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity)
#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity)
#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity)
#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic)
#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor)
#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor)
#define WALK_MOVE (*g_engfuncs.pfnWalkMove)
#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin)
#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound)
#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg)
#define TRACE_LINE (*g_engfuncs.pfnTraceLine)
#define TRACE_TOSS (*g_engfuncs.pfnTraceToss)
#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull)
#define TRACE_HULL (*g_engfuncs.pfnTraceHull)
#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector)
#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand)
#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute)
#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand)
#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect)
#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle)
#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex)
#define POINT_CONTENTS (*g_engfuncs.pfnPointContents)
#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init)
#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer)
#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte)
#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final)
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin = nullptr, edict_t *ed = nullptr)
{
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ed);
}
#define MESSAGE_END (*g_engfuncs.pfnMessageEnd)
#define WRITE_BYTE (*g_engfuncs.pfnWriteByte)
#define WRITE_CHAR (*g_engfuncs.pfnWriteChar)
#define WRITE_SHORT (*g_engfuncs.pfnWriteShort)
#define WRITE_LONG (*g_engfuncs.pfnWriteLong)
#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle)
#define WRITE_COORD (*g_engfuncs.pfnWriteCoord)
#define WRITE_STRING (*g_engfuncs.pfnWriteString)
#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity)
#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister)
#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat)
#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString)
#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat)
#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString)
#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer)
#define ALERT (*g_engfuncs.pfnAlertMessage)
#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf)
#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData)
#define GET_PRIVATE(pent) (pent ? (pent->pvPrivateData) : nullptr);
#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData)
#define ALLOC_STRING (*g_engfuncs.pfnAllostring)
#define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString)
#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum)
#define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere)
#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS)
#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound)
#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr)
#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg)
#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition)
#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName)
#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction)
#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture)
#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf)
#define CMD_ARGS (*g_engfuncs.pfnCmd_Args)
#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc)
#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv)
#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment)
#define SET_VIEW (*g_engfuncs.pfnSetView)
#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle)
#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe)
#define FREE_FILE (*g_engfuncs.pfnFreeFile)
#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime)
#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir)
#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid)
#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities)
#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer)
#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent)
#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent)
#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS)
#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS)
#define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility)
#define DELTA_SET (*g_engfuncs.pfnDeltaSetField)
#define DELTA_UNSET (*g_engfuncs.pfnDeltaUnsetField)
#define DELTA_ADDENCODER (*g_engfuncs.pfnDeltaAddEncoder)
#define ENGINE_CURRENT_PLAYER (*g_engfuncs.pfnGetCurrentPlayer)
#define ENGINE_CANSKIP (*g_engfuncs.pfnCanSkipPlayer)
#define DELTA_FINDFIELD (*g_engfuncs.pfnDeltaFindField)
#define DELTA_SETBYINDEX (*g_engfuncs.pfnDeltaSetFieldByIndex)
#define DELTA_UNSETBYINDEX (*g_engfuncs.pfnDeltaUnsetFieldByIndex)
#define ENGINE_GETPHYSINFO (*g_engfuncs.pfnGetPhysicsInfoString)
#define ENGINE_SETGROUPMASK (*g_engfuncs.pfnSetGroupMask)
#define ENGINE_INSTANCE_BASELINE (*g_engfuncs.pfnCreateInstancedBaseline)
#define ENGINE_FORCE_UNMODIFIED (*g_engfuncs.pfnForceUnmodified)
#define PLAYER_CNX_STATS (*g_engfuncs.pfnGetPlayerStats)
#endif //ENGINECALLBACK_H

View file

@ -1,27 +1,27 @@
/***
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef EXTDLL_H
#define EXTDLL_H
#ifdef _MSC_VER
/* disable deprecation warnings concerning unsafe CRT functions */
#if !defined _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
/* disable deprecation warnings concerning unsafe CRT functions */
#if !defined _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#ifdef _WIN32
@ -32,72 +32,70 @@
#define NOIME
#include "windows.h"
#include "winsock2.h"
#else // _WIN32
#else // _WIN32
#define FALSE 0
#define TRUE (!FALSE)
#define MAX_PATH PATH_MAX
#include <limits.h>
#include <stdarg.h>
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define _vsnprintf(a, b, c, d) vsnprintf (a, b, c, d)
#endif
#endif //_WIN32
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h
typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h
#include "corelib.h"
#define vec3_t Vector
typedef cr::classes::Vector vec3_t;
using namespace cr::types;
#include "const.h"
#include "progdefs.h"
#define MAX_ENT_LEAFS 48
#define MAX_ENT_LEAFS 48
struct edict_s
{
struct edict_s {
int free;
int serialnumber;
link_t area; // linked to a division node or leaf
int headnode; // -1 to use normal leaf check
link_t area; // linked to a division node or leaf
int headnode; // -1 to use normal leaf check
int num_leafs;
short leafnums[MAX_ENT_LEAFS];
float freetime; // sv.time when the object was freed
void *pvPrivateData; // Alloced and freed by engine, used by DLLs
entvars_t v; // C exported fields from progs
float freetime; // sv.time when the object was freed
void *pvPrivateData; // Alloced and freed by engine, used by DLLs
entvars_t v; // C exported fields from progs
};
#include "eiface.h"
#define MAX_WEAPON_SLOTS 5 // hud item selection slots
#define MAX_ITEM_TYPES 6 // hud item selection slots
#define MAX_WEAPON_SLOTS 5 // hud item selection slots
#define MAX_ITEM_TYPES 6 // hud item selection slots
#define MAX_ITEMS 5 // hard coded item types
#define MAX_ITEMS 5 // hard coded item types
#define HIDEHUD_WEAPONS ( 1 << 0 )
#define HIDEHUD_FLASHLIGHT ( 1 << 1 )
#define HIDEHUD_ALL ( 1 << 2 )
#define HIDEHUD_HEALTH ( 1 << 3 )
#define HIDEHUD_WEAPONS (1 << 0)
#define HIDEHUD_FLASHLIGHT (1 << 1)
#define HIDEHUD_ALL (1 << 2)
#define HIDEHUD_HEALTH (1 << 3)
#define MAX_AMMO_TYPES 32 // ???
#define MAX_AMMO_SLOTS 32 // not really slots
#define MAX_AMMO_TYPES 32 // ???
#define MAX_AMMO_SLOTS 32 // not really slots
#define HUD_PRINTNOTIFY 1
#define HUD_PRINTCONSOLE 2
#define HUD_PRINTTALK 3
#define HUD_PRINTCENTER 4
#define HUD_PRINTNOTIFY 1
#define HUD_PRINTCONSOLE 2
#define HUD_PRINTTALK 3
#define HUD_PRINTCENTER 4
#define WEAPON_SUIT 31
#define __USE_GNU 1
#define WEAPON_SUIT 31
#endif //EXTDLL_H
#endif // EXTDLL_H

View file

@ -15,18 +15,9 @@ typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int
#define META_INTERFACE_VERSION "5:13"
typedef enum
{
PT_NEVER = 0,
PT_STARTUP,
PT_CHANGELEVEL,
PT_ANYTIME,
PT_ANYPAUSE
} PLUG_LOADTIME;
typedef enum { PT_NEVER = 0, PT_STARTUP, PT_CHANGELEVEL, PT_ANYTIME, PT_ANYPAUSE } PLUG_LOADTIME;
typedef struct
{
typedef struct {
char const *ifvers;
char const *name;
char const *version;
@ -41,33 +32,13 @@ extern plugin_info_t Plugin_info;
typedef plugin_info_t *plid_t;
#define PLID &Plugin_info
#define PLID &Plugin_info
typedef enum { PNL_NULL = 0, PNL_INI_DELETED, PNL_FILE_NEWER, PNL_COMMAND, PNL_CMD_FORCED, PNL_DELAYED, PNL_PLUGIN, PNL_PLG_FORCED, PNL_RELOAD } PL_UNLOAD_REASON;
typedef enum
{
PNL_NULL = 0,
PNL_INI_DELETED,
PNL_FILE_NEWER,
PNL_COMMAND,
PNL_CMD_FORCED,
PNL_DELAYED,
PNL_PLUGIN,
PNL_PLG_FORCED,
PNL_RELOAD
} PL_UNLOAD_REASON;
typedef enum { MRES_UNSET = 0, MRES_IGNORED, MRES_HANDLED, MRES_OVERRIDE, MRES_SUPERCEDE } META_RES;
typedef enum
{
MRES_UNSET = 0,
MRES_IGNORED,
MRES_HANDLED,
MRES_OVERRIDE,
MRES_SUPERCEDE
} META_RES;
typedef struct meta_globals_s
{
typedef struct meta_globals_s {
META_RES mres;
META_RES prev_mres;
META_RES status;
@ -77,16 +48,23 @@ typedef struct meta_globals_s
extern meta_globals_t *gpMetaGlobals;
#define SET_META_RESULT(result) gpMetaGlobals->mres=result
#define RETURN_META(result) { gpMetaGlobals->mres=result; return; }
#define RETURN_META_VALUE(result, value) { gpMetaGlobals->mres=result; return(value); }
#define META_RESULT_STATUS gpMetaGlobals->status
#define SET_META_RESULT(result) gpMetaGlobals->mres = result
#define RETURN_META(result) \
{ \
gpMetaGlobals->mres = result; \
return; \
}
#define RETURN_META_VALUE(result, value) \
{ \
gpMetaGlobals->mres = result; \
return (value); \
}
#define META_RESULT_STATUS gpMetaGlobals->status
#define META_RESULT_PREVIOUS gpMetaGlobals->prev_mres
#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret
#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret
#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret
typedef struct
{
typedef struct {
GETENTITYAPI_FN pfnGetEntityAPI;
GETENTITYAPI_FN pfnGetEntityAPI_Post;
GETENTITYAPI2_FN pfnGetEntityAPI2;
@ -100,45 +78,34 @@ typedef struct
#include "util.h"
// max buffer size for printed messages
#define MAX_LOGMSG_LEN 1024
#define MAX_LOGMSG_LEN 1024
// for getgameinfo:
typedef enum
{
GINFO_NAME = 0,
GINFO_DESC,
GINFO_GAMEDIR,
GINFO_DLL_FULLPATH,
GINFO_DLL_FILENAME,
GINFO_REALDLL_FULLPATH
} ginfo_t;
typedef enum { GINFO_NAME = 0, GINFO_DESC, GINFO_GAMEDIR, GINFO_DLL_FULLPATH, GINFO_DLL_FILENAME, GINFO_REALDLL_FULLPATH } ginfo_t;
// Meta Utility Function table type.
typedef struct meta_util_funcs_s
{
void (*pfnLogConsole) (plid_t plid, const char *szFormat, ...);
void (*pfnLogMessage) (plid_t plid, const char *szFormat, ...);
void (*pfnLogError) (plid_t plid, const char *szFormat, ...);
void (*pfnLogDeveloper) (plid_t plid, const char *szFormat, ...);
void (*pfnCenterSay) (plid_t plid, const char *szFormat, ...);
void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, const char *szFormat, ...);
void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, const char *szFormat, va_list ap);
int (*pfnCallGameEntity) (plid_t plid, const char *entStr, entvars_t *pev);
int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size);
typedef struct meta_util_funcs_s {
void (*pfnLogConsole) (plid_t plid, const char *szFormat, ...);
void (*pfnLogMessage) (plid_t plid, const char *szFormat, ...);
void (*pfnLogError) (plid_t plid, const char *szFormat, ...);
void (*pfnLogDeveloper) (plid_t plid, const char *szFormat, ...);
void (*pfnCenterSay) (plid_t plid, const char *szFormat, ...);
void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, const char *szFormat, ...);
void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, const char *szFormat, va_list ap);
int (*pfnCallGameEntity) (plid_t plid, const char *entStr, entvars_t *pev);
int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size);
const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size);
const char *(*pfnGetPluginPath) (plid_t plid);
const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag);
int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle);
int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
const char *(*pfnIsQueryingClienCVar_t) (plid_t plid, const edict_t *player);
int (*pfnMakeRequestID) (plid_t plid);
void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, gamefuncs_t **pdll, newgamefuncs_t **pnewdll);
int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle);
int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
const char *(*pfnIsQueryingClienCVar_t) (plid_t plid, const edict_t *player);
int (*pfnMakeRequestID) (plid_t plid);
void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, gamefuncs_t **pdll, newgamefuncs_t **pnewdll);
} mutil_funcs_t;
typedef struct
{
typedef struct {
gamefuncs_t *dllapi_table;
newgamefuncs_t *newapi_table;
} gamedll_funcs_t;
@ -148,85 +115,85 @@ extern mutil_funcs_t *gpMetaUtilFuncs;
extern meta_globals_t *gpMetaGlobals;
extern metamod_funcs_t gMetaFunctionTable;
#define MDLL_FUNC gpGamedllFuncs->dllapi_table
#define MDLL_FUNC gpGamedllFuncs->dllapi_table
#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
#define MDLL_Spawn MDLL_FUNC->pfnSpawn
#define MDLL_Think MDLL_FUNC->pfnThink
#define MDLL_Use MDLL_FUNC->pfnUse
#define MDLL_Touch MDLL_FUNC->pfnTouch
#define MDLL_Blocked MDLL_FUNC->pfnBlocked
#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue
#define MDLL_Save MDLL_FUNC->pfnSave
#define MDLL_Restore MDLL_FUNC->pfnRestore
#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox
#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields
#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields
#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState
#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState
#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState
#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect
#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect
#define MDLL_ClientKill MDLL_FUNC->pfnClientKill
#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer
#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand
#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged
#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate
#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate
#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink
#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink
#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame
#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel
#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel
#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription
#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization
#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect
#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect
#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink
#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error
#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move
#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init
#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType
#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility
#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData
#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack
#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline
#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders
#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData
#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart
#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd
#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket
#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds
#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines
#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile
#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation
#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
#define MDLL_Spawn MDLL_FUNC->pfnSpawn
#define MDLL_Think MDLL_FUNC->pfnThink
#define MDLL_Use MDLL_FUNC->pfnUse
#define MDLL_Touch MDLL_FUNC->pfnTouch
#define MDLL_Blocked MDLL_FUNC->pfnBlocked
#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue
#define MDLL_Save MDLL_FUNC->pfnSave
#define MDLL_Restore MDLL_FUNC->pfnRestore
#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox
#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields
#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields
#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState
#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState
#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState
#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect
#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect
#define MDLL_ClientKill MDLL_FUNC->pfnClientKill
#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer
#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand
#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged
#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate
#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate
#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink
#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink
#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame
#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel
#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel
#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription
#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization
#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect
#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect
#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink
#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error
#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move
#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init
#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType
#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility
#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData
#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack
#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline
#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders
#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData
#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart
#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd
#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket
#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds
#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines
#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile
#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation
#define MNEW_FUNC gpGamedllFuncs->newapi_table
#define MNEW_FUNC gpGamedllFuncs->newapi_table
#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData
#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown
#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide
#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue
#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2
#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData
#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown
#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide
#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue
#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2
// convenience macros for metautil functions
#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole)
#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage)
#define LOG_MMERROR (*gpMetaUtilFuncs->pfnLogError)
#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper)
#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay)
#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms)
#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs)
#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity)
#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID)
#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName)
#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath)
#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo)
#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin)
#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin)
#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle)
#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole)
#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage)
#define LOG_MMERROR (*gpMetaUtilFuncs->pfnLogError)
#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper)
#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay)
#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms)
#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs)
#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity)
#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID)
#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName)
#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath)
#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo)
#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin)
#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin)
#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle)
#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClienCVar_t)
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID)
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID)
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
#endif

View file

@ -1,25 +1,24 @@
/***
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef PROGDEFS_H
#define PROGDEFS_H
#ifdef _WIN32
#pragma once
#endif
typedef struct
{
typedef struct {
float time;
float frametime;
float force_retouch;
@ -53,9 +52,7 @@ typedef struct
vec3_t vecLandmarkOffset;
} globalvars_t;
typedef struct entvars_s
{
typedef struct entvars_s {
string_t classname;
string_t globalname;
@ -63,14 +60,14 @@ typedef struct entvars_s
vec3_t oldorigin;
vec3_t velocity;
vec3_t basevelocity;
vec3_t clbasevelocity; // Base velocity that was passed in to server physics so
vec3_t clbasevelocity; // Base velocity that was passed in to server physics so
// client can predict conveyors correctly. Server zeroes it, so we need to store here, too.
vec3_t movedir;
vec3_t angles; // Model angles
vec3_t avelocity; // angle velocity (degrees per second)
vec3_t punchangle; // auto-decaying view angle adjustment
vec3_t v_angle; // Viewing angle (player only)
vec3_t angles; // Model angles
vec3_t avelocity; // angle velocity (degrees per second)
vec3_t punchangle; // auto-decaying view angle adjustment
vec3_t v_angle; // Viewing angle (player only)
// For parametric entities
vec3_t endpos;
@ -78,7 +75,7 @@ typedef struct entvars_s
float impacttime;
float starttime;
int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity
int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity
float idealpitch;
float pitch_speed;
float ideal_yaw;
@ -87,14 +84,14 @@ typedef struct entvars_s
int modelindex;
string_t model;
int viewmodel; // player's viewmodel
int weaponmodel; // what other players see
int viewmodel; // player's viewmodel
int weaponmodel; // what other players see
vec3_t absmin; // BB max translated to world coord
vec3_t absmax; // BB max translated to world coord
vec3_t mins; // local BB min
vec3_t maxs; // local BB max
vec3_t size; // maxs - mins
vec3_t absmin; // BB max translated to world coord
vec3_t absmax; // BB max translated to world coord
vec3_t mins; // local BB min
vec3_t maxs; // local BB max
vec3_t size; // maxs - mins
float ltime;
float nextthink;
@ -103,23 +100,23 @@ typedef struct entvars_s
int solid;
int skin;
int body; // sub-model selection for studiomodels
int body; // sub-model selection for studiomodels
int effects;
float gravity; // % of "normal" gravity
float friction; // inverse elasticity of MOVETYPE_BOUNCE
float gravity; // % of "normal" gravity
float friction; // inverse elasticity of MOVETYPE_BOUNCE
int light_level;
int sequence; // animation sequence
int gaitsequence; // movement animation sequence for player (0 for none)
float frame; // % playback position in animation sequences (0..255)
float animtime; // world time when frame was set
float framerate; // animation playback rate (-8x to 8x)
uint8 controller[4]; // bone controller setting (0..255)
uint8 blending[2]; // blending amount between sub-sequences (0..255)
int sequence; // animation sequence
int gaitsequence; // movement animation sequence for player (0 for none)
float frame; // % playback position in animation sequences (0..255)
float animtime; // world time when frame was set
float framerate; // animation playback rate (-8x to 8x)
uint8 controller[4]; // bone controller setting (0..255)
uint8 blending[2]; // blending amount between sub-sequences (0..255)
float scale; // sprite rendering scale (0..255)
float scale; // sprite rendering scale (0..255)
int rendermode;
float renderamt;
@ -128,26 +125,26 @@ typedef struct entvars_s
float health;
float frags;
int weapons; // bit mask for available weapons
int weapons; // bit mask for available weapons
float takedamage;
int deadflag;
vec3_t view_ofs; // eye position
vec3_t view_ofs; // eye position
int button;
int impulse;
edict_t *chain; // Entity pointer when linked into a linked list
edict_t *chain; // Entity pointer when linked into a linked list
edict_t *dmg_inflictor;
edict_t *enemy;
edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW
edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW
edict_t *owner;
edict_t *groundentity;
int spawnflags;
int flags;
int colormap; // lowbyte topcolor, highbyte bottomcolor
int colormap; // lowbyte topcolor, highbyte bottomcolor
int team;
float max_health;

View file

@ -1,117 +1,50 @@
/***
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef SDKUTIL_H
#define SDKUTIL_H
#ifndef ENGINECALLBACK_H
#include "enginecallback.h"
#endif
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent); // implementation later in this file
extern globalvars_t *g_pGlobals;
#define DLL_GLOBAL
extern DLL_GLOBAL const Vector g_vZero;
extern enginefuncs_t g_engfuncs;
// Use this instead of ALLOC_STRING on constant strings
#define STRING(offset) (const char *)(g_pGlobals->pStringBase + (int)offset)
#define MAKE_STRING(str) ((int)str - (int)STRING(0))
#define ENGINE_STR(str) (const_cast <char *> (STRING (ALLOC_STRING (str))))
#define STRING(offset) (const char *)(g_pGlobals->pStringBase + (int)offset)
static inline edict_t *FIND_ENTITY_BY_CLASSNAME (edict_t *entStart, const char *pszName)
{
return FIND_ENTITY_BY_STRING (entStart, "classname", pszName);
// form fwgs-hlsdk
static inline int MAKE_STRING (const char *val) {
long long ptrdiff = val - STRING (0);
if (ptrdiff > INT_MAX || ptrdiff < INT_MIN) {
return g_engfuncs.pfnAllocString (val);
}
return static_cast <int> (ptrdiff);
}
static inline edict_t *FIND_ENTITY_BY_TARGETNAME (edict_t *entStart, const char *pszName)
{
return FIND_ENTITY_BY_STRING (entStart, "targetname", pszName);
}
// for doing a reverse lookup. Say you have a door, and want to find its button.
static inline edict_t *FIND_ENTITY_BY_TARGET (edict_t *entStart, const char *pszName)
{
return FIND_ENTITY_BY_STRING (entStart, "target", pszName);
}
// Keeps clutter down a bit, when using a float as a bit-Vector
#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
// Makes these more explicit, and easier to find
#define FILE_GLOBAL static
// Until we figure out why "const" gives the compiler problems, we'll just have to use
// this bogus "empty" define to mark things as constant.
#define CONSTANT
// More explicit than "int"
typedef int EOFFSET;
// In case it's not alread defined
#ifndef BOOL
typedef int BOOL;
#endif
// In case this ever changes
#ifndef M_PI
#define M_PI 3.1415926
#endif
short FixedSigned16 (float value, float scale);
uint16 FixedUnsigned16 (float value, float scale);
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent)
{
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ent->pContainingEntity);
}
#define ENGINE_STR(str) (const_cast <char *> (STRING (g_engfuncs.pfnAllocString (str))))
// Dot products for view cone checking
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks
#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks
#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks
#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks
#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks
// Misc useful
static inline BOOL FStrEq (const char *sz1, const char *sz2)
{
return (strcmp (sz1, sz2) == 0);
}
static inline BOOL FClassnameIs (edict_t *pent, const char *szClassname)
{
return FStrEq (STRING (pent->v.classname), szClassname);
}
static inline BOOL FClassnameIs (entvars_t *pev, const char *szClassname)
{
return FStrEq (STRING (pev->classname), szClassname);
}
typedef enum { ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS;
typedef enum { ignore_glass = 1, dont_ignore_glass = 0 } IGNORE_GLASS;
typedef enum { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 } HULL;
typedef enum
{ ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS;
typedef enum
{ ignore_glass = 1, dont_ignore_glass = 0 } IGNORE_GLASS;
typedef enum
{ point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 } HULL;
typedef int (*tMenuCallback) (edict_t *, int);
typedef struct hudtextparms_s
{
typedef struct hudtextparms_s {
float x;
float y;
int effect;
@ -124,124 +57,87 @@ typedef struct hudtextparms_s
int channel;
} hudtextparms_t;
#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation
#define AMBIENT_SOUND_EVERYWHERE 1
#define AMBIENT_SOUND_SMALLRADIUS 2
#define AMBIENT_SOUND_MEDIUMRADIUS 4
#define AMBIENT_SOUND_LARGERADIUS 8
#define AMBIENT_SOUND_START_SILENT 16
#define AMBIENT_SOUND_NOT_LOOPING 32
#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation
#define AMBIENT_SOUND_EVERYWHERE 1
#define AMBIENT_SOUND_SMALLRADIUS 2
#define AMBIENT_SOUND_MEDIUMRADIUS 4
#define AMBIENT_SOUND_LARGERADIUS 8
#define AMBIENT_SOUND_START_SILENT 16
#define AMBIENT_SOUND_NOT_LOOPING 32
#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements
#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements
#define SND_SPAWNING (1 << 8) // duplicated in protocol.h we're spawing, used in some cases for ambients
#define SND_STOP (1 << 5) // duplicated in protocol.h stop sound
#define SND_CHANGE_VOL (1 << 6) // duplicated in protocol.h change sound vol
#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch
#define SND_SPAWNING (1 << 8) // duplicated in protocol.h we're spawing, used in some cases for ambients
#define SND_STOP (1 << 5) // duplicated in protocol.h stop sound
#define SND_CHANGE_VOL (1 << 6) // duplicated in protocol.h change sound vol
#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch
#define LFO_SQUARE 1
#define LFO_TRIANGLE 2
#define LFO_RANDOM 3
#define LFO_SQUARE 1
#define LFO_TRIANGLE 2
#define LFO_RANDOM 3
// func_rotating
#define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1
#define SF_BRUSH_ROTATE_BACKWARDS 2
#define SF_BRUSH_ROTATE_Z_AXIS 4
#define SF_BRUSH_ROTATE_X_AXIS 8
#define SF_PENDULUM_AUTO_RETURN 16
#define SF_PENDULUM_PASSABLE 32
#define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1
#define SF_BRUSH_ROTATE_BACKWARDS 2
#define SF_BRUSH_ROTATE_Z_AXIS 4
#define SF_BRUSH_ROTATE_X_AXIS 8
#define SF_PENDULUM_AUTO_RETURN 16
#define SF_PENDULUM_PASSABLE 32
#define SF_BRUSH_ROTATE_SMALLRADIUS 128
#define SF_BRUSH_ROTATE_SMALLRADIUS 128
#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256
#define SF_BRUSH_ROTATE_LARGERADIUS 512
#define SF_BRUSH_ROTATE_LARGERADIUS 512
#define PUSH_BLOCK_ONLY_X 1
#define PUSH_BLOCK_ONLY_Y 2
#define PUSH_BLOCK_ONLY_X 1
#define PUSH_BLOCK_ONLY_Y 2
#define VEC_HULL_MIN Vector(-16, -16, -36)
#define VEC_HULL_MAX Vector( 16, 16, 36)
#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 )
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 )
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 )
#define VEC_HULL_MIN Vector (-16, -16, -36)
#define VEC_HULL_MAX Vector (16, 16, 36)
#define VEC_HUMAN_HULL_MIN Vector (-16, -16, 0)
#define VEC_HUMAN_HULL_MAX Vector (16, 16, 72)
#define VEC_HUMAN_HULL_DUCK Vector (16, 16, 36)
#define VEC_VIEW Vector( 0, 0, 28 )
#define VEC_VIEW Vector (0, 0, 28)
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 )
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
#define VEC_DUCK_HULL_MIN Vector (-16, -16, -18)
#define VEC_DUCK_HULL_MAX Vector (16, 16, 18)
#define VEC_DUCK_VIEW Vector (0, 0, 12)
#define SVC_TEMPENTITY 23
#define SVC_CENTERPRINT 26
#define SVC_INTERMISSION 30
#define SVC_CDTRACK 32
#define SVC_WEAPONANIM 35
#define SVC_ROOMTYPE 37
#define SVC_DIRECTOR 51
#define SVC_TEMPENTITY 23
#define SVC_CENTERPRINT 26
#define SVC_INTERMISSION 30
#define SVC_CDTRACK 32
#define SVC_WEAPONANIM 35
#define SVC_ROOMTYPE 37
#define SVC_DIRECTOR 51
// triggers
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
// func breakable
#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger
#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass)
#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it
#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar
#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger
#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass)
#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it
#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar
// func_pushable (it's also func_breakable, so don't collide with those flags)
#define SF_PUSH_BREAKABLE 128
#define SF_PUSH_BREAKABLE 128
#define SF_LIGHT_START_OFF 1
#define SF_LIGHT_START_OFF 1
#define SPAWNFLAG_NOMESSAGE 1
#define SPAWNFLAG_NOTOUCH 1
#define SPAWNFLAG_DROIDONLY 4
#define SPAWNFLAG_NOMESSAGE 1
#define SPAWNFLAG_NOTOUCH 1
#define SPAWNFLAG_DROIDONLY 4
#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons)
#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons)
#define TELE_PLAYER_ONLY 1
#define TELE_SILENT 2
#define TELE_PLAYER_ONLY 1
#define TELE_SILENT 2
#define SF_TRIG_PUSH_ONCE 1
#define SF_TRIG_PUSH_ONCE 1
// NOTE: use EMIT_SOUND_DYN to set the pitch of a sound. Pitch of 100
// is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100
// down to 1 is a lower pitch. 150 to 70 is the realistic range.
// EMIT_SOUND_DYN with pitch != 100 should be used sparingly, as it's not quite as
// fast as EMIT_SOUND (the pitchshift mixer is not native coded).
void EMIT_SOUND_DYN (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch);
static inline void EMIT_SOUND (edict_t *entity, int channel, const char *sample, float volume, float attenuation)
{
EMIT_SOUND_DYN (entity, channel, sample, volume, attenuation, 0, PITCH_NORM);
}
static inline void STOP_SOUND (edict_t *entity, int channel, const char *sample)
{
EMIT_SOUND_DYN (entity, channel, sample, 0, 0, SND_STOP, PITCH_NORM);
}
// macro to handle memory allocation fails
#define TerminateOnMalloc() \
AddLogEntry (true, LL_FATAL, "Memory Allocation Fail!\nFile: %s (Line: %d)", __FILE__, __LINE__) \
// internal assert function
#define InternalAssert(Expr) \
if (!(Expr)) \
{ \
AddLogEntry (true, LL_ERROR, "Assertion Fail! (Expression: %s, File: %s, Line: %d)", #Expr, __FILE__, __LINE__); \
} \
static inline void MakeVectors (const Vector &in)
{
in.BuildVectors (&g_pGlobals->v_forward, &g_pGlobals->v_right, &g_pGlobals->v_up);
}
#endif

View file

@ -4,18 +4,18 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license
// https://yapb.ru/license
//
#pragma once
extern bool g_canSayBombPlanted;
extern bool g_bombPlanted;
extern bool g_bombSayString;
extern bool g_bombSayString;
extern bool g_roundEnded;
extern bool g_waypointOn;
extern bool g_autoWaypoint;
extern bool g_botsCanPause;
extern bool g_botsCanPause;
extern bool g_editNoclip;
extern bool g_gameWelcomeSent;
@ -27,10 +27,9 @@ extern float g_timeRoundEnd;
extern float g_timeRoundMid;
extern float g_timeRoundStart;
extern float g_timePerSecondUpdate;
extern float g_lastRadioTime[2];
extern float g_lastRadioTime[MAX_TEAM_COUNT];
extern int g_mapType;
extern int g_numWaypoints;
extern int g_mapFlags;
extern int g_gameFlags;
extern int g_highestDamageCT;
@ -43,34 +42,32 @@ extern int g_carefulWeaponPrefs[NUM_WEAPONS];
extern int g_grenadeBuyPrecent[NUM_WEAPONS - 23];
extern int g_botBuyEconomyTable[NUM_WEAPONS - 15];
extern int g_radioSelect[MAX_ENGINE_PLAYERS];
extern int g_lastRadio[2];
extern int g_lastRadio[MAX_TEAM_COUNT];
extern int g_storeAddbotVars[4];
extern int *g_weaponPrefs[];
extern Array <Array <String> > g_chatFactory;
extern Array <Array <ChatterItem> > g_chatterFactory;
extern Array <BotName> g_botNames;
extern Array <KeywordFactory> g_replyFactory;
extern RandomSequenceOfUnique Random;
extern Array<StringArray> g_chatFactory;
extern Array<Array<ChatterItem>> g_chatterFactory;
extern Array<BotName> g_botNames;
extern Array<KeywordFactory> g_replyFactory;
extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1];
extern WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
extern Client g_clients[MAX_ENGINE_PLAYERS];
extern MenuText g_menus[BOT_MENU_TOTAL_MENUS];
extern TaskItem g_taskFilters[];
extern Task g_taskFilters[TASK_MAX];
extern Experience *g_experienceData;
extern edict_t *g_hostEntity;
extern edict_t *g_hostEntity;
extern Library *g_gameLib;
extern gamefuncs_t g_functionTable;
static inline bool IsNullString (const char *input)
{
if (input == nullptr)
static inline bool isEmptyStr (const char *input) {
if (input == nullptr) {
return true;
}
return *input == '\0';
}

View file

@ -4,39 +4,39 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license
// https://yapb.ru/license
//
#pragma once
// detects the build platform
#if defined (__linux__) || defined (__debian__) || defined (__linux)
#define PLATFORM_LINUX 1
#elif defined (__APPLE__)
#define PLATFORM_OSX 1
#elif defined (_WIN32)
#define PLATFORM_WIN32 1
#if defined(__linux__)
#define PLATFORM_LINUX
#elif defined(__APPLE__)
#define PLATFORM_OSX
#elif defined(_WIN32)
#define PLATFORM_WIN32
#endif
// by default sse has everyone
#define PLATFORM_HAS_SSE2
// detects the compiler
#if defined (_MSC_VER)
#define COMPILER_VISUALC _MSC_VER
#elif defined (__MINGW32_MAJOR_VERSION)
#define COMPILER_MINGW32 __MINGW32_MAJOR_VERSION
#if defined(_MSC_VER)
#define CXX_MSVC
#elif defined(__clang__)
#define CXX_CLANG
#endif
// configure export macros
#if defined (COMPILER_VISUALC) || defined (COMPILER_MINGW32)
#if defined(PLATFORM_WIN32)
#define SHARED_LIBRARAY_EXPORT extern "C" __declspec (dllexport)
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#define SHARED_LIBRARAY_EXPORT extern "C" __attribute__((visibility("default")))
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
#define SHARED_LIBRARAY_EXPORT extern "C" __attribute__ ((visibility ("default")))
#else
#error "Can't configure export macros. Compiler unrecognized."
#endif
// enable sse intrinsics
#define ENABLE_SSE_INTRINSICS 1
// operating system specific macros, functions and typedefs
#ifdef PLATFORM_WIN32
@ -49,108 +49,46 @@
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
#define DLL_RETENTRY return TRUE
#if defined (COMPILER_VISUALC)
#if defined(CXX_MSVC) && !defined (_M_X64)
#define DLL_GIVEFNPTRSTODLL extern "C" void STD_CALL
#elif defined (COMPILER_MINGW32)
#elif defined(CXX_CLANG) || defined (_M_X64)
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STD_CALL
#endif
// specify export parameter
#if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000)
#pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#pragma comment (linker, "/SECTION:.data,RW")
#if defined(CXX_MSVC) || defined (CXX_CLANG)
#if !defined (_M_X64)
#pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#endif
#pragma comment(linker, "/SECTION:.data,RW")
#endif
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#include <unistd.h>
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#define DLL_ENTRYPOINT __attribute__((destructor)) void _fini (void)
#define DLL_ENTRYPOINT __attribute__ ((destructor)) void _fini (void)
#define DLL_DETACHING TRUE
#define DLL_RETENTRY return
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__ ((visibility ("default")))
#define STD_CALL /* */
#if defined (__ANDROID__)
#define PLATFORM_ANDROID 1
#undef ENABLE_SSE_INTRINSICS
// android is a linux with a special cases
// @todo: sse should be working ok on x86 android?
#if defined(__ANDROID__)
#define PLATFORM_ANDROID
#undef PLATFORM_HAS_SSE2
#endif
#else
#error "Platform unrecognized."
#endif
// library wrapper
class Library
{
private:
void *m_ptr;
public:
Library (const char *fileName)
{
m_ptr = nullptr;
if (fileName == nullptr)
return;
LoadLib (fileName);
}
~Library (void)
{
if (!IsLoaded ())
return;
#ifdef PLATFORM_WIN32
FreeLibrary ((HMODULE) m_ptr);
#else
dlclose (m_ptr);
#endif
}
public:
inline void *LoadLib (const char *fileName)
{
#ifdef PLATFORM_WIN32
m_ptr = LoadLibrary (fileName);
#else
m_ptr = dlopen (fileName, RTLD_NOW);
#endif
return m_ptr;
}
template <typename R> R GetFuncAddr (const char *function)
{
if (!IsLoaded ())
return nullptr;
#ifdef PLATFORM_WIN32
return reinterpret_cast <R> (GetProcAddress (static_cast <HMODULE> (m_ptr), function));
#else
return reinterpret_cast <R> (dlsym (m_ptr, function));
#endif
}
template <typename R> R GetHandle (void)
{
return (R) m_ptr;
}
inline bool IsLoaded (void) const
{
return m_ptr != nullptr;
}
};

View file

@ -4,27 +4,30 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license
// https://yapb.ru/license
//
#pragma once
// general product information
#define PRODUCT_NAME "Yet Another POD-Bot"
#define PRODUCT_VERSION "2.8"
#define PRODUCT_VERSION "2.9"
#define PRODUCT_AUTHOR "YaPB Dev Team"
#define PRODUCT_URL "https://yapb.jeefo.net/"
#define PRODUCT_EMAIL "dmitry@jeefo.net"
#define PRODUCT_URL "https://yapb.ru/"
#define PRODUCT_EMAIL "d@entix.io"
#define PRODUCT_LOGTAG "YAPB"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot"
#define PRODUCT_COPYRIGHT "Copyright © 1999-2017, by " PRODUCT_AUTHOR
#define PRODUCT_END_YEAR "2018"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot (" PRODUCT_COMMENTS ")"
#define PRODUCT_COPYRIGHT "Copyright © 1999-" PRODUCT_END_YEAR ", by " PRODUCT_AUTHOR
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
#define PRODUCT_ORIGINAL_NAME "yapb.dll"
#define PRODUCT_INTERNAL_NAME "skybot"
#define PRODUCT_VERSION_DWORD_INTERNAL 2,8
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL,0
#define PRODUCT_SUPPORT_VERSION "1.0 - CZ"
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
#define PRODUCT_DATE __DATE__
#define PRODUCT_GIT_HASH "unspecified_hash"
#define PRODUCT_GIT_COMMIT_AUTHOR "unspecified_author"
#define PRODUCT_GIT_COMMIT_ID 0000
#define PRODUCT_VERSION_DWORD_INTERNAL 2, 9
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL, PRODUCT_GIT_COMMIT_ID
#define PRODUCT_SUPPORT_VERSION "Beta 6.6 - Condition Zero"
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
#define PRODUCT_DATE __DATE__

File diff suppressed because it is too large Load diff