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

1
.gitignore vendored
View file

@ -67,3 +67,4 @@ Icon
*.json *.json
*.html *.html
*.settings *.settings
*.sarif

View file

@ -1,23 +1,32 @@
language: cpp
dist: trusty
compiler:
- clang
addons: addons:
apt: apt:
packages: packages:
- lib32stdc++6 - libc6-dev-i386
- lib32z1-dev - linux-libc-dev
- libc6-dev-i386 - gcc-multilib
- linux-libc-dev - g++-multilib
- gcc-multilib
- g++-multilib
language: cpp
compiler:
- clang
os: os:
- linux - linux
- osx - osx
before_script: before_script:
- wget https://yapb.ru/ci/scripts/gitrev.sh && chmod a+x ./gitrev.sh && ./gitrev.sh - sed -i.bak "s/unspecified_hash/$(git rev-parse HEAD 2>/dev/null)/g;s/unspecified_author/$(git log --pretty="%ae" -1 2>/dev/null)/g;s/0000/$(git rev-list HEAD --count 2>/dev/null)/g" include/resource.h && rm include/resource.h.bak
script: script:
- cd project && CC=clang && make all - cd project && CC=clang && make all
after_success: after_success:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl --ftp-create-dirs -T ./release/yapb.so -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/release/yapb.so && curl --ftp-create-dirs -T ./debug/yapb.so -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/debug/yapb.so && curl -X GET "https://yapb.ru/agent/packager.php?key=$PACKAGER_KEY&os=linux"; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl --ftp-create-dirs -T ./release/yapb.dylib -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/release/yapb.dylib && curl --ftp-create-dirs -T ./debug/yapb.dylib -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/debug/yapb.dylib && curl -X GET "https://yapb.ru/agent/packager.php?key=$PACKAGER_KEY&os=osx"; fi - curl -F "key=$CI_KEY" -F "mode=build" -F "type=release" -F "lib=@./release/yapb.so" https://yapb.ru/agent/ci.php
- curl -F "key=$CI_KEY" -F "mode=build" -F "type=debug" -F "lib=@./debug/yapb.so" https://yapb.ru/agent/ci.php
- fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
- curl -F "key=$CI_KEY" -F "mode=build" -F "type=release" -F "lib=@./release/yapb.dylib" https://yapb.ru/agent/ci.php
- curl -F "key=$CI_KEY" -F "mode=build" -F "type=debug" -F "lib=@./debug/yapb.dylib" https://yapb.ru/agent/ci.php
- fi

View file

@ -4,84 +4,82 @@
// //
// This software is licensed under the BSD-style license. // This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit: // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license // https://yapb.ru/license
// //
#pragma once #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: protected:
unsigned long int m_textSize; unsigned long int m_csize;
unsigned long int m_codeSize;
uint8 m_textBuffer[N + F - 1]; uint8 m_buffer[MAXBUF + PADDING - 1];
int m_matchPosition; int m_matchPos;
int m_matchLength; int m_matchLen;
int m_left[N + 1]; int m_left[MAXBUF + 1];
int m_right[N + 257]; int m_right[MAXBUF + 257];
int m_parent[N + 1]; int m_parent[MAXBUF + 1];
private: private:
void InitTree (void) void initTrees (void) {
{ for (int i = MAXBUF + 1; i <= MAXBUF + 256; i++) {
for (int i = N + 1; i <= N + 256; i++)
m_right[i] = NIL; m_right[i] = NIL;
}
for (int j = 0; j < N; j++) for (int j = 0; j < MAXBUF; j++) {
m_parent[j] = NIL; m_parent[j] = NIL;
}
} }
void InsertNode (int node) void insert (int node) {
{
int i; int i;
int compare = 1; int compare = 1;
uint8 *key = &m_textBuffer[node]; uint8 *key = &m_buffer[node];
int temp = N + 1 + key[0]; int temp = MAXBUF + 1 + key[0];
m_right[node] = m_left[node] = NIL; m_right[node] = m_left[node] = NIL;
m_matchLength = 0; m_matchLen = 0;
for (;;) for (;;) {
{ if (compare >= 0) {
if (compare >= 0) if (m_right[temp] != NIL) {
{
if (m_right[temp] != NIL)
temp = m_right[temp]; temp = m_right[temp];
else }
{ else {
m_right[temp] = node; m_right[temp] = node;
m_parent[node] = temp; m_parent[node] = temp;
return; return;
} }
} }
else else {
{ if (m_left[temp] != NIL) {
if (m_left[temp] != NIL)
temp = m_left[temp]; temp = m_left[temp];
else }
{ else {
m_left[temp] = node; m_left[temp] = node;
m_parent[node] = temp; m_parent[node] = temp;
return; return;
} }
} }
for (i = 1; i < F; i++) for (i = 1; i < PADDING; i++) {
if ((compare = key[i] - m_textBuffer[temp + i]) != 0) if ((compare = key[i] - m_buffer[temp + i]) != 0) {
break; break;
}
}
if (i > m_matchLength) if (i > m_matchLen) {
{ m_matchPos = temp;
m_matchPosition = temp;
if ((m_matchLen = i) >= PADDING) {
if ((m_matchLength = i) >= F)
break; break;
}
} }
} }
@ -91,37 +89,35 @@ private:
m_parent[m_left[temp]] = node; m_parent[m_left[temp]] = node;
m_parent[m_right[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; m_right[m_parent[temp]] = node;
else }
else {
m_left[m_parent[temp]] = node; m_left[m_parent[temp]] = node;
}
m_parent[temp] = NIL; m_parent[temp] = NIL;
} }
void erase (int node) {
void DeleteNode (int node)
{
int temp; int temp;
if (m_parent[node] == NIL) if (m_parent[node] == NIL) {
return; // not in tree return; // not in tree
}
if (m_right[node] == NIL) if (m_right[node] == NIL) {
temp = m_left[node]; temp = m_left[node];
}
else if (m_left[node] == NIL) else if (m_left[node] == NIL) {
temp = m_right[node]; temp = m_right[node];
}
else else {
{
temp = m_left[node]; temp = m_left[node];
if (m_right[temp] != NIL) if (m_right[temp] != NIL) {
{ do {
do
temp = m_right[temp]; temp = m_right[temp];
while (m_right[temp] != NIL); } while (m_right[temp] != NIL);
m_right[m_parent[temp]] = m_left[temp]; m_right[m_parent[temp]] = m_left[temp];
m_parent[m_left[temp]] = m_parent[temp]; m_parent[m_left[temp]] = m_parent[temp];
@ -132,240 +128,208 @@ private:
m_right[temp] = m_right[node]; m_right[temp] = m_right[node];
m_parent[m_right[node]] = temp; m_parent[m_right[node]] = temp;
} }
m_parent[temp] = m_parent[node]; 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; m_right[m_parent[node]] = temp;
else }
else {
m_left[m_parent[node]] = temp; m_left[m_parent[node]] = temp;
}
m_parent[node] = NIL; m_parent[node] = NIL;
} }
public: public:
Compressor (void) Compress (void) : m_csize (0), m_matchPos (0), m_matchLen (0) {
{
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_right, 0, sizeof (m_right));
memset (m_left, 0, sizeof (m_left)); memset (m_left, 0, sizeof (m_left));
memset (m_parent, 0, sizeof (m_parent)); memset (m_parent, 0, sizeof (m_parent));
memset (m_buffer, 0, sizeof (m_buffer));
} }
~Compressor (void) ~Compress (void) = default;
{
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;
int encode_ (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) {
File fp (fileName, "wb"); File fp (fileName, "wb");
if (!fp.IsValid ()) if (!fp.isValid ()) {
return -1; 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); cb[0] = 0;
InitTree (); cbp = mask = 1;
ptr = 0;
node = MAXBUF - PADDING;
codeBuffer[0] = 0; for (i = ptr; i < node; i++)
codeBufferPtr = mask = 1; m_buffer[i] = ' ';
strPtr = 0;
node = N - F;
for (i = strPtr; i < node; i++) for (length = 0; (length < PADDING) && (bp < bufferSize); length++) {
m_textBuffer[i] = ' '; bit = buffer[bp++];
m_buffer[node + length] = bit;
for (length = 0; (length < F) && (bufferPtr < bufferSize); length++)
{
bit = buffer[bufferPtr++];
m_textBuffer[node + length] = bit;
} }
if ((m_textSize = length) == 0) if (length == 0) {
return -1; return -1;
}
for (i = 1; i <= F; i++) for (i = 1; i <= PADDING; i++) {
InsertNode (node - i); insert (node - i);
InsertNode (node); }
insert (node);
do do {
{ if (m_matchLen > length) {
if (m_matchLength > length) m_matchLen = length;
m_matchLength = length;
if (m_matchLength <= THRESHOLD)
{
m_matchLength = 1;
codeBuffer[0] |= mask;
codeBuffer[codeBufferPtr++] = m_textBuffer[node];
} }
else if (m_matchLen <= THRESHOLD) {
{ m_matchLen = 1;
codeBuffer[codeBufferPtr++] = (uint8) m_matchPosition;
codeBuffer[codeBufferPtr++] = (uint8) (((m_matchPosition >> 4) & 0xf0) | (m_matchLength - (THRESHOLD + 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) if ((mask <<= 1) == 0) {
{ for (i = 0; i < cbp; i++) {
for (i = 0; i < codeBufferPtr; i++) fp.putch (cb[i]);
fp.PutChar (codeBuffer[i]); }
m_csize += cbp;
m_codeSize += codeBufferPtr; cb[0] = 0;
codeBuffer[0] = 0; cbp = mask = 1;
codeBufferPtr = mask = 1;
} }
lastMatchLength = m_matchLength; last = m_matchLen;
for (i = 0; (i < lastMatchLength) && (bufferPtr < bufferSize); i++) for (i = 0; (i < last) && (bp < bufferSize); i++) {
{ bit = buffer[bp++];
bit = buffer[bufferPtr++]; erase (ptr);
DeleteNode (strPtr);
m_textBuffer[strPtr] = bit; m_buffer[ptr] = bit;
if (strPtr < F - 1) if (ptr < PADDING - 1) {
m_textBuffer[strPtr + N] = bit; m_buffer[ptr + MAXBUF] = bit;
}
strPtr = (strPtr + 1) & (N - 1); ptr = (ptr + 1) & (MAXBUF - 1);
node = (node + 1) & (N - 1); node = (node + 1) & (MAXBUF - 1);
InsertNode (node); insert (node);
} }
while (i++ < lastMatchLength) while (i++ < last) {
{ erase (ptr);
DeleteNode (strPtr);
strPtr = (strPtr + 1) & (N - 1); ptr = (ptr + 1) & (MAXBUF - 1);
node = (node + 1) & (N - 1); node = (node + 1) & (MAXBUF - 1);
if (length--) if (length--) {
InsertNode (node); insert (node);
}
} }
} while (length > 0); } while (length > 0);
if (codeBufferPtr > 1) if (cbp > 1) {
{ for (i = 0; i < cbp; i++) {
for (i = 0; i < codeBufferPtr; i++) fp.putch (cb[i]);
fp.PutChar (codeBuffer[i]); }
m_csize += cbp;
m_codeSize += codeBufferPtr;
} }
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; int i, j, k, node;
unsigned int flags; unsigned int flags;
int bufferPtr = 0; int bp = 0;
uint8 bit; uint8 bit;
File fp (fileName, "rb"); File fp (fileName, "rb");
if (!fp.IsValid ()) if (!fp.isValid ()) {
return -1; return -1;
}
fp.seek (headerSize, SEEK_SET);
fp.Seek (headerSize, SEEK_SET); node = MAXBUF - PADDING;
node = N - F;
for (i = 0; i < node; i++)
m_textBuffer[i] = ' ';
for (i = 0; i < node; i++) {
m_buffer[i] = ' ';
}
flags = 0; flags = 0;
for (;;) for (;;) {
{ if (((flags >>= 1) & 256) == 0) {
if (((flags >>= 1) & 256) == 0) int read = fp.getch ();
{
int read = fp.GetChar ();
if (read == EOF) if (read == EOF) {
break; break;
}
bit = static_cast <uint8> (read); bit = static_cast <uint8> (read);
flags = bit | 0xff00; 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; 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); i |= ((j & 0xf0) << 4);
j = (j & 0x0f) + THRESHOLD; j = (j & 0x0f) + THRESHOLD;
for (k = 0; k <= j; k++) for (k = 0; k <= j; k++) {
{ bit = m_buffer[(i + k) & (MAXBUF - 1)];
bit = m_textBuffer[(i + k) & (N - 1)]; buffer[bp++] = bit;
buffer[bufferPtr++] = bit;
if (bufferPtr > bufferSize) if (bp > bufferSize) {
return -1; return -1;
}
m_textBuffer[node++] = bit; m_buffer[node++] = bit;
node &= (N - 1); node &= (MAXBUF - 1);
} }
} }
} }
fp.Close (); fp.close ();
return bufferPtr; return bp;
} }
// external decoder // external decoder
static int Uncompress (const char *fileName, int headerSize, uint8 *buffer, int bufferSize) static int decode (const char *fileName, int headerSize, uint8 *buffer, int bufferSize) {
{ static Compress compressor;
static Compressor compressor = Compressor (); return compressor.decode_ (fileName, headerSize, buffer, bufferSize);
return compressor.InternalDecode (fileName, headerSize, buffer, bufferSize);
} }
// external encoder // external encoder
static int Compress(const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) static int encode (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) {
{ static Compress compressor;
static Compressor compressor = Compressor (); return compressor.encode_ (fileName, header, headerSize, buffer, bufferSize);
return compressor.InternalEncode (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. // This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit: // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license // https://yapb.ru/license
//
// Purpose: Engine & Game interfaces.
// //
#pragma once #pragma once
// line draw // line draw
enum DrawLineType enum DrawLineType {
{
DRAW_SIMPLE, DRAW_SIMPLE,
DRAW_ARROW, DRAW_ARROW,
DRAW_NUM DRAW_NUM
}; };
// trace ignore // trace ignore
enum TraceIgnore enum TraceIgnore {
{
TRACE_IGNORE_NONE = 0, TRACE_IGNORE_NONE = 0,
TRACE_IGNORE_GLASS = (1 << 0), TRACE_IGNORE_GLASS = (1 << 0),
TRACE_IGNORE_MONSTERS = (1 << 1), TRACE_IGNORE_MONSTERS = (1 << 1),
@ -29,8 +25,7 @@ enum TraceIgnore
}; };
// variable type // variable type
enum VarType enum VarType {
{
VT_NORMAL = 0, VT_NORMAL = 0,
VT_READONLY, VT_READONLY,
VT_PASSWORD, VT_PASSWORD,
@ -39,8 +34,7 @@ enum VarType
}; };
// netmessage functions // netmessage functions
enum NetMsgId enum NetMsgId {
{
NETMSG_UNDEFINED = -1, NETMSG_UNDEFINED = -1,
NETMSG_VGUI = 1, NETMSG_VGUI = 1,
NETMSG_SHOWMENU = 2, NETMSG_SHOWMENU = 2,
@ -55,7 +49,7 @@ enum NetMsgId
NETMSG_SCREENFADE = 11, NETMSG_SCREENFADE = 11,
NETMSG_HLTV = 12, NETMSG_HLTV = 12,
NETMSG_TEXTMSG = 13, NETMSG_TEXTMSG = 13,
NETMSG_SCOREINFO = 14, NETMSG_TEAMINFO = 14,
NETMSG_BARTIME = 15, NETMSG_BARTIME = 15,
NETMSG_SENDAUDIO = 17, NETMSG_SENDAUDIO = 17,
NETMSG_SAYTEXT = 18, NETMSG_SAYTEXT = 18,
@ -64,8 +58,7 @@ enum NetMsgId
}; };
// variable reg pair // variable reg pair
struct VarPair struct VarPair {
{
VarType type; VarType type;
cvar_t reg; cvar_t reg;
class ConVar *self; class ConVar *self;
@ -74,25 +67,32 @@ struct VarPair
const char *regVal; const char *regVal;
}; };
// translation pair
struct TranslatorPair
{
const char *original;
const char *translated;
};
// network message block // network message block
struct MessageBlock struct MessageBlock {
{
int bot; int bot;
int state; int state;
int msg; int msg;
int regMsgs[NETMSG_NUM]; 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) // provides utility functions to not call original engine (less call-cost)
class Engine : public Singleton <Engine> class Engine : public Singleton <Engine> {
{
private: private:
int m_drawModels[DRAW_NUM]; int m_drawModels[DRAW_NUM];
@ -105,217 +105,293 @@ private:
edict_t *m_localEntity; edict_t *m_localEntity;
Array <VarPair> m_cvars; Array <VarPair> m_cvars;
Array <TranslatorPair> m_language; HashMap <String, String, LangComprarer> m_language;
MessageBlock m_msgBlock; MessageBlock m_msgBlock;
bool m_precached;
public: public:
Engine (void); Engine (void);
~Engine (void); ~Engine (void);
// public functions
public: public:
// precaches internal stuff // precaches internal stuff
void Precache (edict_t *startEntity); void precache (void);
// initialize levels
void levelInitialize (void);
// prints data to servers console // prints data to servers console
void Printf (const char *fmt, ...); void print (const char *fmt, ...);
// prints chat message to all players // prints chat message to all players
void ChatPrintf (const char *fmt, ...); void chatPrint (const char *fmt, ...);
// prints center message to all players // prints center message to all players
void CenterPrintf (const char *fmt, ...); void centerPrint (const char *fmt, ...);
// prints message to client console // prints message to client console
void ClientPrintf (edict_t *ent, const char *fmt, ...); void clientPrint (edict_t *ent, const char *fmt, ...);
// display world line // 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 // 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 // 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 // get's the wave length
float GetWaveLength (const char *fileName); float getWaveLen (const char *fileName);
// we are on dedicated server ? // we are on dedicated server ?
bool IsDedicatedServer (void); bool isDedicated (void);
// get stripped down mod name // get stripped down mod name
const char *GetModName (void); const char *getModName (void);
// get the valid mapname // get the valid mapname
const char *GetMapName (void); const char *getMapName (void);
// get the "any" entity origin // get the "any" entity origin
Vector GetAbsOrigin (edict_t *ent); Vector getAbsPos (edict_t *ent);
// send server command // send server command
void IssueCmd (const char *fmt, ...); void execCmd (const char *fmt, ...);
// registers a server command // 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 // play's sound to client
void EmitSound (edict_t *ent, const char *sound); void playSound (edict_t *ent, const char *sound);
// sends bot command // sends bot command
void IssueBotCommand (edict_t *ent, const char *fmt, ...); void execBotCmd (edict_t *ent, const char *fmt, ...);
// adds cvar to registration stack // 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 // sends local registration stack for engine registration
void PushRegisteredConVarsToEngine (bool gameVars = false); void pushRegStackToEngine (bool gameVars = false);
// translates bot message into needed language // translates bot message into needed language
char *TraslateMessage (const char *input); const char *translate (const char *input);
// cleanup translator resources
void TerminateTranslator (void);
// do actual network message processing // do actual network message processing
void ProcessMessageCapture (void *ptr); void processMessages (void *ptr);
// public inlines // public inlines
public: public:
// get the current time on server // get the current time on server
FORCEINLINE float Time (void) inline float timebase (void) {
{
return g_pGlobals->time; return g_pGlobals->time;
} }
// get "maxplayers" limit on server // get "maxplayers" limit on server
FORCEINLINE int MaxClients (void) inline int maxClients (void) {
{
return g_pGlobals->maxClients; return g_pGlobals->maxClients;
} }
// get the fakeclient command interface // get the fakeclient command interface
inline bool IsBotCommand (void) inline bool isBotCmd (void) {
{
return m_isBotCommand; return m_isBotCommand;
} }
// gets custom engine args for client command // gets custom engine args for client command
inline const char *GetOverrideArgs (void) inline const char *botArgs (void) {
{ if (strncmp ("say ", m_arguments, 4) == 0) {
if (strncmp ("say ", m_arguments, 4) == 0)
return &m_arguments[4]; 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[9];
}
return m_arguments; return m_arguments;
} }
// gets custom engine argv for client command // gets custom engine argv for client command
inline const char *GetOverrideArgv (int num) inline const char *botArgv (int num) {
{ return getField (m_arguments, static_cast <size_t> (num));
return ExtractSingleField (m_arguments, num);
} }
// gets custom engine argc for client command // gets custom engine argc for client command
inline int GetOverrideArgc (void) inline int botArgc (void) {
{
return m_argumentCount; return m_argumentCount;
} }
// gets edict pointer out of entity index // 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); return static_cast <edict_t *> (m_startEntity + index);
}; };
// gets edict index out of it's pointer // 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); return static_cast <int> (ent - m_startEntity);
}; };
// verify entity isn't null // verify entity isn't null
FORCEINLINE bool IsNullEntity (const edict_t *ent) inline bool isNullEntity (const edict_t *ent) {
{ return !ent || !indexOfEntity (ent) || ent->free;
return !ent || !IndexOfEntity (ent); }
// get the wroldspawn entity
inline edict_t *getStartEntity (void) {
return m_startEntity;
} }
// gets the player team // gets the player team
FORCEINLINE int GetTeam (edict_t *ent) inline int getTeam (edict_t *ent) {
{
extern Client g_clients[MAX_ENGINE_PLAYERS]; 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 // adds translation pair from config
inline void PushTranslationPair (const TranslatorPair &lang) inline void addTranslation (const String &original, const String &translated) {
{ m_language.put (original, translated);
m_language.Push (lang);
} }
// resets the message capture mechanism // resets the message capture mechanism
inline void ResetMessageCapture (void) inline void resetMessages (void) {
{
m_msgBlock.msg = NETMSG_UNDEFINED; m_msgBlock.msg = NETMSG_UNDEFINED;
m_msgBlock.state = 0; m_msgBlock.state = 0;
m_msgBlock.bot = 0; m_msgBlock.bot = 0;
}; };
// sets the currently executed message // sets the currently executed message
inline void SetOngoingMessageId (int message) inline void setCurrentMessageId (int message) {
{
m_msgBlock.msg = message; m_msgBlock.msg = message;
} }
// set the bot entity that receive this message // set the bot entity that receive this message
inline void SetOngoingMessageReceiver (int id) inline void setCurrentMessageOwner (int id) {
{
m_msgBlock.bot = id; m_msgBlock.bot = id;
} }
// find registered message id // find registered message id
FORCEINLINE int FindMessageId (int type) inline int getMessageId (int type) {
{
return m_msgBlock.regMsgs[type]; return m_msgBlock.regMsgs[type];
} }
// assigns message id for message 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; m_msgBlock.regMsgs[type] = id;
} }
// tries to set needed message id // tries to set needed message id
FORCEINLINE void TryCaptureMessage (int type, int msgId) inline void captureMessage (int type, int msgId) {
{ if (type == m_msgBlock.regMsgs[msgId]) {
if (type == m_msgBlock.regMsgs[msgId]) setCurrentMessageId (msgId);
SetOngoingMessageId (msgId); }
}
// sets the precache to uninitialize
inline void setUnprecached (void) {
m_precached = false;
} }
// static utility functions // static utility functions
private: private:
const char *ExtractSingleField (const char *string, int id); const char *getField (const char *string, size_t id);
}; };
// simplify access for console variables // simplify access for console variables
class ConVar class ConVar {
{
public: public:
cvar_t *m_eptr; cvar_t *m_eptr;
public: 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; } inline bool boolean (void) const {
FORCEINLINE int GetInt (void) { return static_cast <int> (m_eptr->value); } return m_eptr->value > 0.0f;
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); } inline int integer (void) const {
FORCEINLINE void SetInt (int val) { SetFloat (static_cast <float> (val)); } return static_cast <int> (m_eptr->value);
FORCEINLINE void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); } }
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. * Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * 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. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#ifndef EIFACE_H #ifndef EIFACE_H
#define EIFACE_H #define EIFACE_H
@ -19,18 +19,17 @@
#include <stdio.h> #include <stdio.h>
#define FCVAR_ARCHIVE (1 << 0) // set to cause it to be saved to vars.rc #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_USERINFO (1 << 1) // changes the client's info string
#define FCVAR_SERVER (1 << 2) // notifies players when changed #define FCVAR_SERVER (1 << 2) // notifies players when changed
#define FCVAR_EXTDLL (1 << 3) // defined by external DLL #define FCVAR_EXTDLL (1 << 3) // defined by external DLL
#define FCVAR_CLIENTDLL (1 << 4) // defined by the client 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_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_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_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_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 *name;
char *string; char *string;
int flags; int flags;
@ -50,337 +49,323 @@ struct cvar_t
#ifdef _WIN32 #ifdef _WIN32
#define DLLEXPORT __stdcall #define DLLEXPORT __stdcall
#else #else
#define DLLEXPORT /* */ #define DLLEXPORT /* */
#endif #endif
typedef enum typedef enum {
{
at_notice, at_notice,
at_console, // same as at_notice, but forces a ConPrintf, not a message box 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_aiconsole, // same as at_console, but only shown if developer level is 2!
at_warning, at_warning,
at_error, at_error,
at_logged // Server print to console ( only in multiplayer games ). at_logged // Server print to console ( only in multiplayer games ).
} ALERT_TYPE; } ALERT_TYPE;
// 4-22-98 JOHN: added for use in pfnClientPrintf // 4-22-98 JOHN: added for use in pfnClientPrintf
typedef enum typedef enum { print_console, print_center, print_chat } PRINT_TYPE;
{
print_console,
print_center,
print_chat
} PRINT_TYPE;
// For integrity checking of content on clients // For integrity checking of content on clients
typedef enum typedef enum {
{ force_exactfile, // File on client must exactly match server's file
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_samebounds, // For model files only, the geometry must fit in the same bbox force_model_specifybounds // For model files only, the geometry must fit in the specified bbox
force_model_specifybounds // For model files only, the geometry must fit in the specified bbox
} FORCE_TYPE; } FORCE_TYPE;
// Returned by TraceLine // Returned by TraceLine
typedef struct typedef struct {
{ int fAllSolid; // if true, plane is not valid
int fAllSolid; // if true, plane is not valid int fStartSolid; // if true, the initial point was in a solid area
int fStartSolid; // if true, the initial point was in a solid area
int fInOpen; int fInOpen;
int fInWater; int fInWater;
float flFraction; // time completed, 1.0 = didn't hit anything float flFraction; // time completed, 1.0 = didn't hit anything
vec3_t vecEndPos; // final position vec3_t vecEndPos; // final position
float flPlaneDist; float flPlaneDist;
vec3_t vecPlaneNormal; // surface normal at impact vec3_t vecPlaneNormal; // surface normal at impact
edict_t *pHit; // entity the surface is on edict_t *pHit; // entity the surface is on
int iHitgroup; // 0 == generic, non zero is specific body part int iHitgroup; // 0 == generic, non zero is specific body part
} TraceResult; } TraceResult;
typedef uint32 CRC32_t; typedef uint32 CRC32_t;
// Engine hands this to DLLs for functionality callbacks // Engine hands this to DLLs for functionality callbacks
typedef struct enginefuncs_s typedef struct enginefuncs_s {
{ int (*pfnPrecacheModel) (char *s);
int (*pfnPrecacheModel) (char *s); int (*pfnPrecacheSound) (char *s);
int (*pfnPrecacheSound) (char *s); void (*pfnSetModel) (edict_t *e, const char *m);
void (*pfnSetModel) (edict_t *e, const char *m); int (*pfnModelIndex) (const char *m);
int (*pfnModelIndex) (const char *m); int (*pfnModelFrames) (int modelIndex);
int (*pfnModelFrames) (int modelIndex); void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax);
void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax); void (*pfnChangeLevel) (char *s1, char *s2);
void (*pfnChangeLevel) (char *s1, char *s2); void (*pfnGetSpawnParms) (edict_t *ent);
void (*pfnGetSpawnParms) (edict_t *ent); void (*pfnSaveSpawnParms) (edict_t *ent);
void (*pfnSaveSpawnParms) (edict_t *ent); float (*pfnVecToYaw) (const float *rgflVector);
float (*pfnVecToYaw) (const float *rgflVector); void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut);
void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut); void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType);
void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); void (*pfnChangeYaw) (edict_t *ent);
void (*pfnChangeYaw) (edict_t *ent); void (*pfnChangePitch) (edict_t *ent);
void (*pfnChangePitch) (edict_t *ent); edict_t *(*pfnFindEntityByString) (edict_t *pentEdictStartSearchAfter, const char *pszField, const char *pszValue);
edict_t *(*pfnFindEntityByString) (edict_t *pentEdictStartSearchAfter, const char *pszField, const char *pszValue); int (*pfnGetEntityIllum) (edict_t *pEnt);
int (*pfnGetEntityIllum) (edict_t *pEnt); edict_t *(*pfnFindEntityInSphere) (edict_t *pentEdictStartSearchAfter, const float *org, float rad);
edict_t *(*pfnFindEntityInSphere) (edict_t *pentEdictStartSearchAfter, const float *org, float rad); edict_t *(*pfnFindClientInPVS) (edict_t *ent);
edict_t *(*pfnFindClientInPVS) (edict_t *ent); edict_t *(*pfnEntitiesInPVS) (edict_t *pplayer);
edict_t *(*pfnEntitiesInPVS) (edict_t *pplayer); void (*pfnMakeVectors) (const float *rgflVector);
void (*pfnMakeVectors) (const float *rgflVector); void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up);
void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up); edict_t *(*pfnCreateEntity) (void);
edict_t *(*pfnCreateEntity) (void); void (*pfnRemoveEntity) (edict_t *e);
void (*pfnRemoveEntity) (edict_t *e); edict_t *(*pfnCreateNamedEntity) (int className);
edict_t *(*pfnCreateNamedEntity) (int className); void (*pfnMakeStatic) (edict_t *ent);
void (*pfnMakeStatic) (edict_t *ent); int (*pfnEntIsOnFloor) (edict_t *e);
int (*pfnEntIsOnFloor) (edict_t *e); int (*pfnDropToFloor) (edict_t *e);
int (*pfnDropToFloor) (edict_t *e); int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int mode);
int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int mode); void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin);
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 (*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 (*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 (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); void (*pfnTraceToss) (edict_t *pent, edict_t *pentToIgnore, 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);
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 (*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);
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); 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 (*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 (*pfnGetAimVector) (edict_t *ent, float speed, float *rgflReturn);
void (*pfnServerCommand) (char *str); void (*pfnServerCommand) (char *str);
void (*pfnServerExecute) (void); void (*pfnServerExecute) (void);
void (*pfnClientCommand) (edict_t *ent, char const *szFmt, ...); void (*pfnClientCommand) (edict_t *ent, char const *szFmt, ...);
void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count); void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count);
void (*pfnLightStyle) (int style, char *val); void (*pfnLightStyle) (int style, char *val);
int (*pfnDecalIndex) (const char *name); int (*pfnDecalIndex) (const char *name);
int (*pfnPointContents) (const float *rgflVector); int (*pfnPointContents) (const float *rgflVector);
void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
void (*pfnMessageEnd) (void); void (*pfnMessageEnd) (void);
void (*pfnWriteByte) (int value); void (*pfnWriteByte) (int value);
void (*pfnWriteChar) (int value); void (*pfnWriteChar) (int value);
void (*pfnWriteShort) (int value); void (*pfnWriteShort) (int value);
void (*pfnWriteLong) (int value); void (*pfnWriteLong) (int value);
void (*pfnWriteAngle) (float flValue); void (*pfnWriteAngle) (float flValue);
void (*pfnWriteCoord) (float flValue); void (*pfnWriteCoord) (float flValue);
void (*pfnWriteString) (const char *sz); void (*pfnWriteString) (const char *sz);
void (*pfnWriteEntity) (int value); void (*pfnWriteEntity) (int value);
void (*pfnCVarRegister) (cvar_t *pCvar); void (*pfnCVarRegister) (cvar_t *pCvar);
float (*pfnCVarGetFloat) (const char *szVarName); float (*pfnCVarGetFloat) (const char *szVarName);
const char *(*pfnCVarGetString) (const char *szVarName); const char *(*pfnCVarGetString) (const char *szVarName);
void (*pfnCVarSetFloat) (const char *szVarName, float flValue); void (*pfnCVarSetFloat) (const char *szVarName, float flValue);
void (*pfnCVarSetString) (const char *szVarName, const char *szValue); void (*pfnCVarSetString) (const char *szVarName, const char *szValue);
void (*pfnAlertMessage) (ALERT_TYPE atype, char *szFmt, ...); void (*pfnAlertMessage) (ALERT_TYPE atype, char *szFmt, ...);
void (*pfnEngineFprintf) (void *pfile, char *szFmt, ...); void (*pfnEngineFprintf) (void *pfile, char *szFmt, ...);
void *(*pfnPvAllocEntPrivateData) (edict_t *ent, int32 cb); void *(*pfnPvAllocEntPrivateData) (edict_t *ent, int32 cb);
void *(*pfnPvEntPrivateData) (edict_t *ent); void *(*pfnPvEntPrivateData) (edict_t *ent);
void (*pfnFreeEntPrivateData) (edict_t *ent); void (*pfnFreeEntPrivateData) (edict_t *ent);
const char *(*pfnSzFromIndex) (int stingPtr); const char *(*pfnSzFromIndex) (int stingPtr);
int (*pfnAllostring) (const char *szValue); int (*pfnAllocString) (const char *szValue);
struct entvars_s *(*pfnGetVarsOfEnt) (edict_t *ent); struct entvars_s *(*pfnGetVarsOfEnt) (edict_t *ent);
edict_t *(*pfnPEntityOfEntOffset) (int iEntOffset); edict_t *(*pfnPEntityOfEntOffset) (int iEntOffset);
int (*pfnEntOffsetOfPEntity) (const edict_t *ent); int (*pfnEntOffsetOfPEntity) (const edict_t *ent);
int (*pfnIndexOfEdict) (const edict_t *ent); int (*pfnIndexOfEdict) (const edict_t *ent);
edict_t *(*pfnPEntityOfEntIndex) (int entIndex); edict_t *(*pfnPEntityOfEntIndex) (int entIndex);
edict_t *(*pfnFindEntityByVars) (struct entvars_s *pvars); edict_t *(*pfnFindEntityByVars) (struct entvars_s *pvars);
void *(*pfnGetModelPtr) (edict_t *ent); void *(*pfnGetModelPtr) (edict_t *ent);
int (*pfnRegUserMsg) (const char *pszName, int iSize); int (*pfnRegUserMsg) (const char *pszName, int iSize);
void (*pfnAnimationAutomove) (const edict_t *ent, float flTime); void (*pfnAnimationAutomove) (const edict_t *ent, float flTime);
void (*pfnGetBonePosition) (const edict_t *ent, int iBone, float *rgflOrigin, float *rgflAngles); void (*pfnGetBonePosition) (const edict_t *ent, int iBone, float *rgflOrigin, float *rgflAngles);
uint32 (*pfnFunctionFromName) (const char *pName); uint32 (*pfnFunctionFromName) (const char *pName);
const char *(*pfnNameForFunction) (uint32 function); 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 (*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); void (*pfnServerPrint) (const char *szMsg);
const char *(*pfnCmd_Args) (void); // these 3 added const char *(*pfnCmd_Args) (void); // these 3 added
const char *(*pfnCmd_Argv) (int argc); // so game DLL can easily const char *(*pfnCmd_Argv) (int argc); // so game DLL can easily
int (*pfnCmd_Argc) (void); // access client 'cmd' strings int (*pfnCmd_Argc) (void); // access client 'cmd' strings
void (*pfnGetAttachment) (const edict_t *ent, int iAttachment, float *rgflOrigin, float *rgflAngles); void (*pfnGetAttachment) (const edict_t *ent, int iAttachment, float *rgflOrigin, float *rgflAngles);
void (*pfnCRC32_Init) (CRC32_t *pulCRC); void (*pfnCRC32_Init) (CRC32_t *pulCRC);
void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len); void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len);
void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, uint8 ch); void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, uint8 ch);
CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC); CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC);
int32 (*pfnRandomLong) (int32 lLow, int32 lHigh); int32 (*pfnRandomLong) (int32 lLow, int32 lHigh);
float (*pfnRandomFloat) (float flLow, float flHigh); float (*pfnRandomFloat) (float flLow, float flHigh);
void (*pfnSetView) (const edict_t *client, const edict_t *pViewent); void (*pfnSetView) (const edict_t *client, const edict_t *pViewent);
float (*pfnTime) (void); float (*pfnTime) (void);
void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw); void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw);
uint8 *(*pfnLoadFileForMe) (char const *szFilename, int *pLength); uint8 *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
void (*pfnFreeFile) (void *buffer); void (*pfnFreeFile) (void *buffer);
void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection
int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare); int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare);
void (*pfnGetGameDir) (char *szGetGameDir); void (*pfnGetGameDir) (char *szGetGameDir);
void (*pfnCvar_RegisterVariable) (cvar_t *variable); void (*pfnCvar_RegisterVariable) (cvar_t *variable);
void (*pfnFadeClientVolume) (const edict_t *ent, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); void (*pfnFadeClientVolume) (const edict_t *ent, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
void (*pfnSetClientMaxspeed) (const edict_t *ent, float fNewMaxspeed); void (*pfnSetClientMaxspeed) (const edict_t *ent, float fNewMaxspeed);
edict_t *(*pfnCreateFakeClient) (const char *netname); // returns nullptr if fake client can't be created 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); void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, uint16 buttons, uint8 impulse, uint8 msec);
int (*pfnNumberOfEntities) (void); int (*pfnNumberOfEntities) (void);
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in nullptr gets the serverinfo char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in nullptr gets the serverinfo
char *(*pfnInfoKeyValue) (char *infobuffer, char const *key); char *(*pfnInfoKeyValue) (char *infobuffer, char const *key);
void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value); void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value);
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value); void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value);
int (*pfnIsMapValid) (char *szFilename); int (*pfnIsMapValid) (char *szFilename);
void (*pfnStaticDecal) (const float *origin, int decalIndex, int entityIndex, int modelIndex); void (*pfnStaticDecal) (const float *origin, int decalIndex, int entityIndex, int modelIndex);
int (*pfnPrecacheGeneric) (char *s); 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 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); 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? int (*pfnIsDedicatedServer) (void); // is this a dedicated server?
cvar_t *(*pfnCVarGetPointer) (const char *szVarName); 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 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 (*pfnInfo_RemoveKey) (char *s, const char *key);
const char *(*pfnGetPhysicsKeyValue) (const edict_t *client, 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); const char *(*pfnGetPhysicsInfoString) (const edict_t *client);
uint16 (*pfnPrecacheEvent) (int type, const char *psz); 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); 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 *(*pfnSetFatPVS) (float *org);
uint8 *(*pfnSetFatPAS) (float *org); uint8 *(*pfnSetFatPAS) (float *org);
int (*pfnCheckVisibility) (const edict_t *entity, uint8 *pset); int (*pfnCheckVisibility) (const edict_t *entity, uint8 *pset);
void (*pfnDeltaSetField) (struct delta_s *pFields, const char *fieldname); void (*pfnDeltaSetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaUnsetField) (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)); void (*pfnDeltaAddEncoder) (char *name, void (*conditionalencode) (struct delta_s *pFields, const uint8 *from, const uint8 *to));
int (*pfnGetCurrentPlayer) (void); int (*pfnGetCurrentPlayer) (void);
int (*pfnCanSkipPlayer) (const edict_t *player); int (*pfnCanSkipPlayer) (const edict_t *player);
int (*pfnDeltaFindField) (struct delta_s *pFields, const char *fieldname); int (*pfnDeltaFindField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaSetFieldByIndex) (struct delta_s *pFields, int fieldNumber); void (*pfnDeltaSetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
void (*pfnDeltaUnsetFieldByIndex) (struct delta_s *pFields, int fieldNumber); void (*pfnDeltaUnsetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
void (*pfnSetGroupMask) (int mask, int op); void (*pfnSetGroupMask) (int mask, int op);
int (*pfnCreateInstancedBaseline) (int classname, struct entity_state_s *baseline); int (*pfnCreateInstancedBaseline) (int classname, struct entity_state_s *baseline);
void (*pfnCvar_DirectSet) (struct cvar_t *var, char *value); void (*pfnCvar_DirectSet) (struct cvar_t *var, char *value);
void (*pfnForceUnmodified) (FORCE_TYPE type, float *mins, float *maxs, const char *szFilename); void (*pfnForceUnmodified) (FORCE_TYPE type, float *mins, float *maxs, const char *szFilename);
void (*pfnGetPlayerStats) (const edict_t *client, int *ping, int *packet_loss); void (*pfnGetPlayerStats) (const edict_t *client, int *ping, int *packet_loss);
void (*pfnAddServerCommand) (char *cmd_name, void (*function) (void)); void (*pfnAddServerCommand) (char *cmd_name, void (*function) (void));
int (*pfnVoice_GetClientListening) (int iReceiver, int iSender); int (*pfnVoice_GetClientListening) (int iReceiver, int iSender);
int (*pfnVoice_SetClientListening) (int iReceiver, int iSender, int bListen); int (*pfnVoice_SetClientListening) (int iReceiver, int iSender, int bListen);
const char *(*pfnGetPlayerAuthId) (edict_t *e); const char *(*pfnGetPlayerAuthId) (edict_t *e);
struct sequenceEntry_s *(*pfnSequenceGet) (const char *fileName, const char *entryName); struct sequenceEntry_s *(*pfnSequenceGet) (const char *fileName, const char *entryName);
struct sentenceEntry_s *(*pfnSequencePickSentence) (const char *groupName, int pickMethod, int *picked); 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); unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath);
int (*pfnIsCareerMatch) (void); int (*pfnIsCareerMatch) (void);
int (*pfnGetLocalizedStringLength) (const char *label); int (*pfnGetLocalizedStringLength) (const char *label);
void (*pfnRegisterTutorMessageShown) (int mid); void (*pfnRegisterTutorMessageShown) (int mid);
int (*pfnGetTimesTutorMessageShown) (int mid); int (*pfnGetTimesTutorMessageShown) (int mid);
void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength); void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength);
void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength); void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength);
void (*pfnResetTutorMessageDecayData) (void); void (*pfnResetTutorMessageDecayData) (void);
void (*pfnQueryClientCVarValue) (const edict_t *player, const char *cvarName); void (*pfnQueryClientCVarValue) (const edict_t *player, const char *cvarName);
void (*pfnQueryClientCVarValue2) (const edict_t *player, const char *cvarName, int requestID); void (*pfnQueryClientCVarValue2) (const edict_t *player, const char *cvarName, int requestID);
int (*pfnCheckParm)(const char *pchCmdLineToken, char **ppnext); int (*pfnCheckParm) (const char *pchCmdLineToken, char **ppnext);
} enginefuncs_t; } enginefuncs_t;
// Passed to pfnKeyValue // Passed to pfnKeyValue
typedef struct KeyValueData_s typedef struct KeyValueData_s {
{
char *szClassName; // in: entity classname char *szClassName; // in: entity classname
char const *szKeyName; // in: name of key char const *szKeyName; // in: name of key
char *szValue; // in: value of key char *szValue; // in: value of key
int32 fHandled; // out: DLL sets to true if key-value pair was understood int32 fHandled; // out: DLL sets to true if key-value pair was understood
} KeyValueData; } KeyValueData;
#define ARRAYSIZE_HLSDK(p) (int) (sizeof(p)/sizeof(p[0]))
typedef struct customization_s customization_t; typedef struct customization_s customization_t;
typedef struct typedef struct {
{
// Initialize/shutdown the game (one-time call after loading of game .dll ) // Initialize/shutdown the game (one-time call after loading of game .dll )
void (*pfnGameInit) (void); void (*pfnGameInit) (void);
int (*pfnSpawn) (edict_t *pent); int (*pfnSpawn) (edict_t *pent);
void (*pfnThink) (edict_t *pent); void (*pfnThink) (edict_t *pent);
void (*pfnUse) (edict_t *pentUsed, edict_t *pentOther); void (*pfnUse) (edict_t *pentUsed, edict_t *pentOther);
void (*pfnTouch) (edict_t *pentTouched, edict_t *pentOther); void (*pfnTouch) (edict_t *pentTouched, edict_t *pentOther);
void (*pfnBlocked) (edict_t *pentBlocked, edict_t *pentOther); void (*pfnBlocked) (edict_t *pentBlocked, edict_t *pentOther);
void (*pfnKeyValue) (edict_t *pentKeyvalue, KeyValueData *pkvd); void (*pfnKeyValue) (edict_t *pentKeyvalue, KeyValueData *pkvd);
void (*pfnSave) (edict_t *pent, struct SAVERESTOREDATA *pSaveData); void (*pfnSave) (edict_t *pent, struct SAVERESTOREDATA *pSaveData);
int (*pfnRestore) (edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity); int (*pfnRestore) (edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity);
void (*pfnSetAbsBox) (edict_t *pent); void (*pfnSetAbsBox) (edict_t *pent);
void (*pfnSaveWriteFields) (SAVERESTOREDATA *, const char *, void *, struct TYPEDESCRIPTION *, int); void (*pfnSaveWriteFields) (SAVERESTOREDATA *, const char *, void *, struct TYPEDESCRIPTION *, int);
void (*pfnSaveReadFields) (SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int); void (*pfnSaveReadFields) (SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int);
void (*pfnSaveGlobalState) (SAVERESTOREDATA *); void (*pfnSaveGlobalState) (SAVERESTOREDATA *);
void (*pfnRestoreGlobalState) (SAVERESTOREDATA *); void (*pfnRestoreGlobalState) (SAVERESTOREDATA *);
void (*pfnResetGlobalState) (void); 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 (*pfnClientDisconnect) (edict_t *ent);
void (*pfnClientKill) (edict_t *ent); void (*pfnClientKill) (edict_t *ent);
void (*pfnClientPutInServer) (edict_t *ent); void (*pfnClientPutInServer) (edict_t *ent);
void (*pfnClientCommand) (edict_t *ent); void (*pfnClientCommand) (edict_t *ent);
void (*pfnClientUserInfoChanged) (edict_t *ent, char *infobuffer); void (*pfnClientUserInfoChanged) (edict_t *ent, char *infobuffer);
void (*pfnServerActivate) (edict_t *edictList, int edictCount, int clientMax); void (*pfnServerActivate) (edict_t *edictList, int edictCount, int clientMax);
void (*pfnServerDeactivate) (void); void (*pfnServerDeactivate) (void);
void (*pfnPlayerPreThink) (edict_t *ent); void (*pfnPlayerPreThink) (edict_t *ent);
void (*pfnPlayerPostThink) (edict_t *ent); void (*pfnPlayerPostThink) (edict_t *ent);
void (*pfnStartFrame) (void); void (*pfnStartFrame) (void);
void (*pfnParmsNewLevel) (void); void (*pfnParmsNewLevel) (void);
void (*pfnParmsChangeLevel) (void); void (*pfnParmsChangeLevel) (void);
// Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
const char *(*pfnGetGameDescription) (void); const char *(*pfnGetGameDescription) (void);
// Notify dll about a player customization. // 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 // Spectator funcs
void (*pfnSpectatorConnect) (edict_t *ent); void (*pfnSpectatorConnect) (edict_t *ent);
void (*pfnSpectatorDisconnect) (edict_t *ent); void (*pfnSpectatorDisconnect) (edict_t *ent);
void (*pfnSpectatorThink) (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. // 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_Move) (struct playermove_s *ppmove, int server);
void (*pfnPM_Init) (struct playermove_s *ppmove); void (*pfnPM_Init) (struct playermove_s *ppmove);
char (*pfnPM_FindTextureType) (char *name); char (*pfnPM_FindTextureType) (char *name);
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, uint8 **pvs, uint8 **pas); 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); 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); 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 (*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); void (*pfnRegisterEncoders) (void);
int (*pfnGetWeaponData) (struct edict_s *player, struct weapon_data_s *info); 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 (*pfnCmdStart) (const edict_t *player, const struct c *cmd, unsigned int random_seed);
void (*pfnCmdEnd) (const edict_t *player); 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 // 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. // 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 // 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. // 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 // 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 ) // 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 game .dll should return 1 if lag compensation should be allowed ( could also just set
// the sv_unlag cvar. // the sv_unlag cvar.
// Most games right now should return 0, until client-side weapon prediction code is written // Most games right now should return 0, until client-side weapon prediction code is written
// and tested for them. // and tested for them.
int (*pfnAllowLagCompensation) (void); int (*pfnAllowLagCompensation) (void);
} gamefuncs_t; } gamefuncs_t;
// Current version. // Current version.
#define NEWGAMEDLLFUNCS_VERSION 1 #define NEWGAMEDLLFUNCS_VERSION 1
typedef struct typedef struct {
{ // Called right before the object's memory is freed.
// Called right before the object's memory is freed.
// Calls its destructor. // Calls its destructor.
void (*pfnOnFreeEntPrivateData) (edict_t *pEnt); void (*pfnOnFreeEntPrivateData) (edict_t *pEnt);
void (*pfnGameShutdown) (void); void (*pfnGameShutdown) (void);
int (*pfnShouldCollide) (edict_t *pentTouched, edict_t *pentOther); int (*pfnShouldCollide) (edict_t *pentTouched, edict_t *pentOther);
void (*pfnCvarValue) (const edict_t *pEnt, 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); void (*pfnCvarValue2) (const edict_t *pEnt, int requestID, const char *cvarName, const char *value);
} newgamefuncs_t; } 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. * Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * 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. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#ifndef EXTDLL_H #ifndef EXTDLL_H
#define EXTDLL_H #define EXTDLL_H
#ifdef _MSC_VER #ifdef _MSC_VER
/* disable deprecation warnings concerning unsafe CRT functions */ /* disable deprecation warnings concerning unsafe CRT functions */
#if !defined _CRT_SECURE_NO_DEPRECATE #if !defined _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#define _WINSOCK_DEPRECATED_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif #endif
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -32,72 +32,70 @@
#define NOIME #define NOIME
#include "windows.h" #include "windows.h"
#include "winsock2.h" #include "winsock2.h"
#else // _WIN32 #else // _WIN32
#define FALSE 0 #define FALSE 0
#define TRUE (!FALSE) #define TRUE (!FALSE)
#define MAX_PATH PATH_MAX #define MAX_PATH PATH_MAX
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#ifndef min #ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b))
#endif #endif
#ifndef max #ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b))
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) #define _vsnprintf(a, b, c, d) vsnprintf (a, b, c, d)
#endif #endif
#endif //_WIN32 #endif //_WIN32
#include "stdio.h" #include "stdio.h"
#include "stdlib.h" #include "stdlib.h"
#include "math.h"
typedef int func_t; // typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h; typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h typedef float vec_t; // needed before including progdefs.h
#include "corelib.h" #include "corelib.h"
#define vec3_t Vector typedef cr::classes::Vector vec3_t;
using namespace cr::types;
#include "const.h" #include "const.h"
#include "progdefs.h" #include "progdefs.h"
#define MAX_ENT_LEAFS 48 #define MAX_ENT_LEAFS 48
struct edict_s struct edict_s {
{
int free; int free;
int serialnumber; int serialnumber;
link_t area; // linked to a division node or leaf link_t area; // linked to a division node or leaf
int headnode; // -1 to use normal leaf check int headnode; // -1 to use normal leaf check
int num_leafs; int num_leafs;
short leafnums[MAX_ENT_LEAFS]; short leafnums[MAX_ENT_LEAFS];
float freetime; // sv.time when the object was freed float freetime; // sv.time when the object was freed
void *pvPrivateData; // Alloced and freed by engine, used by DLLs void *pvPrivateData; // Alloced and freed by engine, used by DLLs
entvars_t v; // C exported fields from progs entvars_t v; // C exported fields from progs
}; };
#include "eiface.h" #include "eiface.h"
#define MAX_WEAPON_SLOTS 5 // hud item selection slots #define MAX_WEAPON_SLOTS 5 // hud item selection slots
#define MAX_ITEM_TYPES 6 // 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_WEAPONS (1 << 0)
#define HIDEHUD_FLASHLIGHT ( 1 << 1 ) #define HIDEHUD_FLASHLIGHT (1 << 1)
#define HIDEHUD_ALL ( 1 << 2 ) #define HIDEHUD_ALL (1 << 2)
#define HIDEHUD_HEALTH ( 1 << 3 ) #define HIDEHUD_HEALTH (1 << 3)
#define MAX_AMMO_TYPES 32 // ??? #define MAX_AMMO_TYPES 32 // ???
#define MAX_AMMO_SLOTS 32 // not really slots #define MAX_AMMO_SLOTS 32 // not really slots
#define HUD_PRINTNOTIFY 1 #define HUD_PRINTNOTIFY 1
#define HUD_PRINTCONSOLE 2 #define HUD_PRINTCONSOLE 2
#define HUD_PRINTTALK 3 #define HUD_PRINTTALK 3
#define HUD_PRINTCENTER 4 #define HUD_PRINTCENTER 4
#define WEAPON_SUIT 31 #define WEAPON_SUIT 31
#define __USE_GNU 1
#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" #define META_INTERFACE_VERSION "5:13"
typedef enum typedef enum { PT_NEVER = 0, PT_STARTUP, PT_CHANGELEVEL, PT_ANYTIME, PT_ANYPAUSE } PLUG_LOADTIME;
{
PT_NEVER = 0,
PT_STARTUP,
PT_CHANGELEVEL,
PT_ANYTIME,
PT_ANYPAUSE
} PLUG_LOADTIME;
typedef struct {
typedef struct
{
char const *ifvers; char const *ifvers;
char const *name; char const *name;
char const *version; char const *version;
@ -41,33 +32,13 @@ extern plugin_info_t Plugin_info;
typedef plugin_info_t *plid_t; 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 typedef enum { MRES_UNSET = 0, MRES_IGNORED, MRES_HANDLED, MRES_OVERRIDE, MRES_SUPERCEDE } META_RES;
{
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 typedef struct meta_globals_s {
{
MRES_UNSET = 0,
MRES_IGNORED,
MRES_HANDLED,
MRES_OVERRIDE,
MRES_SUPERCEDE
} META_RES;
typedef struct meta_globals_s
{
META_RES mres; META_RES mres;
META_RES prev_mres; META_RES prev_mres;
META_RES status; META_RES status;
@ -77,16 +48,23 @@ typedef struct meta_globals_s
extern meta_globals_t *gpMetaGlobals; extern meta_globals_t *gpMetaGlobals;
#define SET_META_RESULT(result) gpMetaGlobals->mres=result #define SET_META_RESULT(result) gpMetaGlobals->mres = result
#define RETURN_META(result) { gpMetaGlobals->mres=result; return; } #define RETURN_META(result) \
#define RETURN_META_VALUE(result, value) { gpMetaGlobals->mres=result; return(value); } { \
#define META_RESULT_STATUS gpMetaGlobals->status 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_PREVIOUS gpMetaGlobals->prev_mres
#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret #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;
GETENTITYAPI_FN pfnGetEntityAPI_Post; GETENTITYAPI_FN pfnGetEntityAPI_Post;
GETENTITYAPI2_FN pfnGetEntityAPI2; GETENTITYAPI2_FN pfnGetEntityAPI2;
@ -100,45 +78,34 @@ typedef struct
#include "util.h" #include "util.h"
// max buffer size for printed messages // max buffer size for printed messages
#define MAX_LOGMSG_LEN 1024 #define MAX_LOGMSG_LEN 1024
// for getgameinfo: // for getgameinfo:
typedef enum typedef enum { GINFO_NAME = 0, GINFO_DESC, GINFO_GAMEDIR, GINFO_DLL_FULLPATH, GINFO_DLL_FILENAME, GINFO_REALDLL_FULLPATH } ginfo_t;
{
GINFO_NAME = 0,
GINFO_DESC,
GINFO_GAMEDIR,
GINFO_DLL_FULLPATH,
GINFO_DLL_FILENAME,
GINFO_REALDLL_FULLPATH
} ginfo_t;
// Meta Utility Function table type. // Meta Utility Function table type.
typedef struct meta_util_funcs_s typedef struct meta_util_funcs_s {
{ void (*pfnLogConsole) (plid_t plid, const char *szFormat, ...);
void (*pfnLogConsole) (plid_t plid, const char *szFormat, ...); void (*pfnLogMessage) (plid_t plid, const char *szFormat, ...);
void (*pfnLogMessage) (plid_t plid, const char *szFormat, ...); void (*pfnLogError) (plid_t plid, const char *szFormat, ...);
void (*pfnLogError) (plid_t plid, const char *szFormat, ...); void (*pfnLogDeveloper) (plid_t plid, const char *szFormat, ...);
void (*pfnLogDeveloper) (plid_t plid, const char *szFormat, ...); void (*pfnCenterSay) (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 (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, const char *szFormat, ...); void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, const char *szFormat, va_list ap);
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 (*pfnCallGameEntity) (plid_t plid, const char *entStr, entvars_t *pev); int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size);
int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size);
const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size); const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size);
const char *(*pfnGetPluginPath) (plid_t plid); const char *(*pfnGetPluginPath) (plid_t plid);
const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag); const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag);
int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle); 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 (*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); 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); const char *(*pfnIsQueryingClienCVar_t) (plid_t plid, const edict_t *player);
int (*pfnMakeRequestID) (plid_t plid); int (*pfnMakeRequestID) (plid_t plid);
void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, gamefuncs_t **pdll, newgamefuncs_t **pnewdll); void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, gamefuncs_t **pdll, newgamefuncs_t **pnewdll);
} mutil_funcs_t; } mutil_funcs_t;
typedef struct {
typedef struct
{
gamefuncs_t *dllapi_table; gamefuncs_t *dllapi_table;
newgamefuncs_t *newapi_table; newgamefuncs_t *newapi_table;
} gamedll_funcs_t; } gamedll_funcs_t;
@ -148,85 +115,85 @@ extern mutil_funcs_t *gpMetaUtilFuncs;
extern meta_globals_t *gpMetaGlobals; extern meta_globals_t *gpMetaGlobals;
extern metamod_funcs_t gMetaFunctionTable; 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_GameDLLInit MDLL_FUNC->pfnGameInit
#define MDLL_Spawn MDLL_FUNC->pfnSpawn #define MDLL_Spawn MDLL_FUNC->pfnSpawn
#define MDLL_Think MDLL_FUNC->pfnThink #define MDLL_Think MDLL_FUNC->pfnThink
#define MDLL_Use MDLL_FUNC->pfnUse #define MDLL_Use MDLL_FUNC->pfnUse
#define MDLL_Touch MDLL_FUNC->pfnTouch #define MDLL_Touch MDLL_FUNC->pfnTouch
#define MDLL_Blocked MDLL_FUNC->pfnBlocked #define MDLL_Blocked MDLL_FUNC->pfnBlocked
#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue #define MDLL_KeyValue MDLL_FUNC->pfnKeyValue
#define MDLL_Save MDLL_FUNC->pfnSave #define MDLL_Save MDLL_FUNC->pfnSave
#define MDLL_Restore MDLL_FUNC->pfnRestore #define MDLL_Restore MDLL_FUNC->pfnRestore
#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox #define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox
#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields #define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields
#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields #define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields
#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState #define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState
#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState #define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState
#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState #define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState
#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect #define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect
#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect #define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect
#define MDLL_ClientKill MDLL_FUNC->pfnClientKill #define MDLL_ClientKill MDLL_FUNC->pfnClientKill
#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer #define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer
#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand #define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand
#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged #define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged
#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate #define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate
#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate #define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate
#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink #define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink
#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink #define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink
#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame #define MDLL_StartFrame MDLL_FUNC->pfnStartFrame
#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel #define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel
#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel #define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel
#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription #define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription
#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization #define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization
#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect #define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect
#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect #define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect
#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink #define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink
#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error #define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error
#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move #define MDLL_PM_Move MDLL_FUNC->pfnPM_Move
#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init #define MDLL_PM_Init MDLL_FUNC->pfnPM_Init
#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType #define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType
#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility #define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility
#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData #define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData
#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack #define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack
#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline #define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline
#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders #define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders
#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData #define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData
#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart #define MDLL_CmdStart MDLL_FUNC->pfnCmdStart
#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd #define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd
#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket #define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket
#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds #define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds
#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines #define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines
#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile #define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile
#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation #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_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData
#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown #define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown
#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide #define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide
#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue #define MNEW_CvarValue MNEW_FUNC->pfnCvarValue
#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2 #define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2
// convenience macros for metautil functions // convenience macros for metautil functions
#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole) #define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole)
#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage) #define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage)
#define LOG_MMERROR (*gpMetaUtilFuncs->pfnLogError) #define LOG_MMERROR (*gpMetaUtilFuncs->pfnLogError)
#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper) #define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper)
#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay) #define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay)
#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms) #define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms)
#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs) #define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs)
#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity) #define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity)
#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID) #define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID)
#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName) #define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName)
#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath) #define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath)
#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo) #define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo)
#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin) #define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin)
#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin) #define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin)
#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle) #define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle)
#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClienCVar_t) #define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClienCVar_t)
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID) #define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID)
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables) #define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
#endif #endif

View file

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

View file

@ -1,117 +1,50 @@
/*** /***
* *
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved. * Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * 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. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#ifndef SDKUTIL_H #ifndef SDKUTIL_H
#define 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; extern globalvars_t *g_pGlobals;
extern enginefuncs_t g_engfuncs;
#define DLL_GLOBAL
extern DLL_GLOBAL const Vector g_vZero;
// Use this instead of ALLOC_STRING on constant strings // Use this instead of ALLOC_STRING on constant strings
#define STRING(offset) (const char *)(g_pGlobals->pStringBase + (int)offset) #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))))
static inline edict_t *FIND_ENTITY_BY_CLASSNAME (edict_t *entStart, const char *pszName) // form fwgs-hlsdk
{ static inline int MAKE_STRING (const char *val) {
return FIND_ENTITY_BY_STRING (entStart, "classname", pszName); 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) #define ENGINE_STR(str) (const_cast <char *> (STRING (g_engfuncs.pfnAllocString (str))))
{
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);
}
// Dot products for view cone checking // Dot products for view cone checking
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees #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_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_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_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks
// Misc useful typedef enum { ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS;
static inline BOOL FStrEq (const char *sz1, const char *sz2) 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;
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 typedef struct hudtextparms_s {
{ 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
{
float x; float x;
float y; float y;
int effect; int effect;
@ -124,124 +57,87 @@ typedef struct hudtextparms_s
int channel; int channel;
} hudtextparms_t; } 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 SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements
#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 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 LFO_SQUARE 1
#define SND_STOP (1 << 5) // duplicated in protocol.h stop sound #define LFO_TRIANGLE 2
#define SND_CHANGE_VOL (1 << 6) // duplicated in protocol.h change sound vol #define LFO_RANDOM 3
#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
// func_rotating // func_rotating
#define SF_BRUSH_ROTATE_Y_AXIS 0 #define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1 #define SF_BRUSH_ROTATE_INSTANT 1
#define SF_BRUSH_ROTATE_BACKWARDS 2 #define SF_BRUSH_ROTATE_BACKWARDS 2
#define SF_BRUSH_ROTATE_Z_AXIS 4 #define SF_BRUSH_ROTATE_Z_AXIS 4
#define SF_BRUSH_ROTATE_X_AXIS 8 #define SF_BRUSH_ROTATE_X_AXIS 8
#define SF_PENDULUM_AUTO_RETURN 16 #define SF_PENDULUM_AUTO_RETURN 16
#define SF_PENDULUM_PASSABLE 32 #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_MEDIUMRADIUS 256
#define SF_BRUSH_ROTATE_LARGERADIUS 512 #define SF_BRUSH_ROTATE_LARGERADIUS 512
#define PUSH_BLOCK_ONLY_X 1 #define PUSH_BLOCK_ONLY_X 1
#define PUSH_BLOCK_ONLY_Y 2 #define PUSH_BLOCK_ONLY_Y 2
#define VEC_HULL_MIN Vector(-16, -16, -36) #define VEC_HULL_MIN Vector (-16, -16, -36)
#define VEC_HULL_MAX 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_MIN Vector (-16, -16, 0)
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 ) #define VEC_HUMAN_HULL_MAX Vector (16, 16, 72)
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 ) #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_MIN Vector (-16, -16, -18)
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18) #define VEC_DUCK_HULL_MAX Vector (16, 16, 18)
#define VEC_DUCK_VIEW Vector( 0, 0, 12 ) #define VEC_DUCK_VIEW Vector (0, 0, 12)
#define SVC_TEMPENTITY 23 #define SVC_TEMPENTITY 23
#define SVC_CENTERPRINT 26 #define SVC_CENTERPRINT 26
#define SVC_INTERMISSION 30 #define SVC_INTERMISSION 30
#define SVC_CDTRACK 32 #define SVC_CDTRACK 32
#define SVC_WEAPONANIM 35 #define SVC_WEAPONANIM 35
#define SVC_ROOMTYPE 37 #define SVC_ROOMTYPE 37
#define SVC_DIRECTOR 51 #define SVC_DIRECTOR 51
// triggers // triggers
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to 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_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger #define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
// func breakable // func breakable
#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger #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_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_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_CROWBAR 256 // instant break if hit with crowbar
// func_pushable (it's also func_breakable, so don't collide with those flags) // 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_NOMESSAGE 1
#define SPAWNFLAG_NOTOUCH 1 #define SPAWNFLAG_NOTOUCH 1
#define SPAWNFLAG_DROIDONLY 4 #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_PLAYER_ONLY 1
#define TELE_SILENT 2 #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 #endif

View file

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

View file

@ -4,39 +4,39 @@
// //
// This software is licensed under the BSD-style license. // This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit: // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license // https://yapb.ru/license
// //
#pragma once #pragma once
// detects the build platform // detects the build platform
#if defined (__linux__) || defined (__debian__) || defined (__linux) #if defined(__linux__)
#define PLATFORM_LINUX 1 #define PLATFORM_LINUX
#elif defined (__APPLE__) #elif defined(__APPLE__)
#define PLATFORM_OSX 1 #define PLATFORM_OSX
#elif defined (_WIN32) #elif defined(_WIN32)
#define PLATFORM_WIN32 1 #define PLATFORM_WIN32
#endif #endif
// by default sse has everyone
#define PLATFORM_HAS_SSE2
// detects the compiler // detects the compiler
#if defined (_MSC_VER) #if defined(_MSC_VER)
#define COMPILER_VISUALC _MSC_VER #define CXX_MSVC
#elif defined (__MINGW32_MAJOR_VERSION) #elif defined(__clang__)
#define COMPILER_MINGW32 __MINGW32_MAJOR_VERSION #define CXX_CLANG
#endif #endif
// configure export macros // configure export macros
#if defined (COMPILER_VISUALC) || defined (COMPILER_MINGW32) #if defined(PLATFORM_WIN32)
#define SHARED_LIBRARAY_EXPORT extern "C" __declspec (dllexport) #define SHARED_LIBRARAY_EXPORT extern "C" __declspec (dllexport)
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX) #elif defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
#define SHARED_LIBRARAY_EXPORT extern "C" __attribute__((visibility("default"))) #define SHARED_LIBRARAY_EXPORT extern "C" __attribute__ ((visibility ("default")))
#else #else
#error "Can't configure export macros. Compiler unrecognized." #error "Can't configure export macros. Compiler unrecognized."
#endif #endif
// enable sse intrinsics
#define ENABLE_SSE_INTRINSICS 1
// operating system specific macros, functions and typedefs // operating system specific macros, functions and typedefs
#ifdef PLATFORM_WIN32 #ifdef PLATFORM_WIN32
@ -49,108 +49,46 @@
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH) #define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
#define DLL_RETENTRY return TRUE #define DLL_RETENTRY return TRUE
#if defined (COMPILER_VISUALC) #if defined(CXX_MSVC) && !defined (_M_X64)
#define DLL_GIVEFNPTRSTODLL extern "C" void STD_CALL #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 #define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STD_CALL
#endif #endif
// specify export parameter // specify export parameter
#if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000) #if defined(CXX_MSVC) || defined (CXX_CLANG)
#pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1") #if !defined (_M_X64)
#pragma comment (linker, "/SECTION:.data,RW") #pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#endif
#pragma comment(linker, "/SECTION:.data,RW")
#endif #endif
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX) #elif defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
#include <unistd.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.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 <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_DETACHING TRUE
#define DLL_RETENTRY return #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 /* */ #define STD_CALL /* */
#if defined (__ANDROID__) // android is a linux with a special cases
#define PLATFORM_ANDROID 1 // @todo: sse should be working ok on x86 android?
#undef ENABLE_SSE_INTRINSICS #if defined(__ANDROID__)
#define PLATFORM_ANDROID
#undef PLATFORM_HAS_SSE2
#endif #endif
#else #else
#error "Platform unrecognized." #error "Platform unrecognized."
#endif #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. // This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit: // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license // https://yapb.ru/license
// //
#pragma once #pragma once
// general product information // general product information
#define PRODUCT_NAME "Yet Another POD-Bot" #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_AUTHOR "YaPB Dev Team"
#define PRODUCT_URL "https://yapb.jeefo.net/" #define PRODUCT_URL "https://yapb.ru/"
#define PRODUCT_EMAIL "dmitry@jeefo.net" #define PRODUCT_EMAIL "d@entix.io"
#define PRODUCT_LOGTAG "YAPB" #define PRODUCT_LOGTAG "YAPB"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot" #define PRODUCT_END_YEAR "2018"
#define PRODUCT_COPYRIGHT "Copyright © 1999-2017, by " PRODUCT_AUTHOR #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_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_ORIGINAL_NAME "yapb.dll"
#define PRODUCT_INTERNAL_NAME "skybot" #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_HASH "unspecified_hash"
#define PRODUCT_GIT_COMMIT_AUTHOR "unspecified_author" #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

View file

@ -4,27 +4,21 @@
# #
# This software is licensed under the BSD-style license. # This software is licensed under the BSD-style license.
# Additional exceptions apply. For full license details, see LICENSE.txt or visit: # Additional exceptions apply. For full license details, see LICENSE.txt or visit:
# https://yapb.jeefo.net/license # https://yapb.ru/license
# #
PROJECT = yapb PROJECT = yapb
SOURCES = ../source SOURCES = ../source
OBJECTS = $(wildcard $(SOURCES)/*.cpp) OBJECTS = $(wildcard $(SOURCES)/*.cpp)
COMPILER_FLAGS = -std=c++11 -m32 -Wall -Werror -Wextra -fno-exceptions -fno-rtti COMPILER_FLAGS = -mtune=generic -std=c++11 -m32 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -DPOSIX
LINKER_FLAGS = -m32 -lm -ldl LINKER_FLAGS = -m32
ifeq "$(SSE_VERSION)" ""
COMPILER_SSE_VERSION = 2
else
COMPILER_SSE_VERSION = $(SSE_VERSION)
endif
ifeq "$(DEBUG)" "true" ifeq "$(DEBUG)" "true"
COMPILER_FLAGS += -D_DEBUG -DDEBUG -g3 COMPILER_FLAGS += -D_DEBUG -DDEBUG -g3
BINARY_DIR = debug BINARY_DIR = debug
else else
COMPILER_FLAGS += -DNDEBUG -pipe -O2 -msse$(COMPILER_SSE_VERSION) -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden COMPILER_FLAGS += -DNDEBUG -pipe -O3 -msse2 -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden -nostdinc++
BINARY_DIR = release BINARY_DIR = release
endif endif
@ -37,12 +31,12 @@ endif
ifeq "$(OSX)" "true" ifeq "$(OSX)" "true"
LIBRARY_EXT = dylib LIBRARY_EXT = dylib
COMPILER_FLAGS += -DOSX -D_OSX -DPOSIX COMPILER_FLAGS += -DOSX -D_OSX -mmacosx-version-min=10.9
LINKER_FLAGS += -dynamiclib -lstdc++ -mmacosx-version-min=10.12 -arch i386 LINKER_FLAGS += -dynamiclib -lstdc++ -mmacosx-version-min=10.9 -arch i386
else else
LIBRARY_EXT = so LIBRARY_EXT = so
COMPILER_FLAGS += -DLINUX -D_LINUX -DPOSIX COMPILER_FLAGS += -DLINUX -D_LINUX
LINKER_FLAGS += -shared -lsupc++ LINKER_FLAGS += -shared
endif endif
BINARY_OUTPUT = $(PROJECT).$(LIBRARY_EXT) BINARY_OUTPUT = $(PROJECT).$(LIBRARY_EXT)
@ -54,13 +48,11 @@ ifeq ($(findstring clang,$(COMPILER)),clang)
else ifeq ($(findstring gcc,$(COMPILER)),gcc) else ifeq ($(findstring gcc,$(COMPILER)),gcc)
ifneq "$(OSX)" "false" ifneq "$(OSX)" "false"
LINKER_FLAGS += -static-libgcc LINKER_FLAGS += -static-libgcc
COMPILER_FLAGS += -funroll-all-loops COMPILER_FLAGS += -funroll-all-loops -Wno-implicit-fallthrough
endif endif
else ifeq ($(findstring icpc,$(COMPILER)),icpc) else ifeq ($(findstring icc,$(COMPILER)),icc)
COMPILER_FLAGS += -funroll-all-loops -no-prec-div -no-inline-min-size -no-inline-max-size -wd11076 -wd11074 COMPILER_FLAGS += -funroll-all-loops -no-prec-div -no-inline-min-size -no-inline-max-size -wd11076 -wd11074
LINKER_FLAGS += -static-intel -no-intel-extensions LINKER_FLAGS += -cxxlib-nostd -static-intel -no-intel-extensions
else
$(error Compiler unrecognized. Specify CC.)
endif endif
OBJECTS_BIN := $(OBJECTS:%.cpp=$(BINARY_DIR)/%.o) OBJECTS_BIN := $(OBJECTS:%.cpp=$(BINARY_DIR)/%.o)

View file

@ -27,7 +27,7 @@ FILETYPE 0x2
VALUE "LegalCopyright", PRODUCT_COPYRIGHT "\0" VALUE "LegalCopyright", PRODUCT_COPYRIGHT "\0"
VALUE "LegalTrademarks", PRODUCT_LEGAL "\0" VALUE "LegalTrademarks", PRODUCT_LEGAL "\0"
VALUE "ProductName", PRODUCT_NAME "\0" VALUE "ProductName", PRODUCT_NAME "\0"
VALUE "ProductVersion", PRODUCT_COMMENTS "\0" VALUE "ProductVersion", PRODUCT_VERSION "\0"
VALUE "InternalName", PRODUCT_INTERNAL_NAME "\0" VALUE "InternalName", PRODUCT_INTERNAL_NAME "\0"
} }
} }

View file

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.25029.0 VisualStudioVersion = 15.0.28016.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yapb", "yapb.vcxproj", "{C232645A-3B99-48F4-A1F3-F20CF0A9568B}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yapb", "yapb.vcxproj", "{C232645A-3B99-48F4-A1F3-F20CF0A9568B}"
EndProject EndProject
@ -19,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03C7A0BC-CD53-4141-879D-E7347565D90C}
EndGlobalSection
EndGlobal EndGlobal

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -12,12 +12,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\include\compress.h" /> <ClInclude Include="..\include\compress.h" />
<ClInclude Include="..\include\core.h" /> <ClInclude Include="..\include\yapb.h" />
<ClInclude Include="..\include\corelib.h" /> <ClInclude Include="..\include\corelib.h" />
<ClInclude Include="..\include\engine.h" /> <ClInclude Include="..\include\engine.h" />
<ClInclude Include="..\include\engine\const.h" /> <ClInclude Include="..\include\engine\const.h" />
<ClInclude Include="..\include\engine\eiface.h" /> <ClInclude Include="..\include\engine\eiface.h" />
<ClInclude Include="..\include\engine\enginecallback.h" />
<ClInclude Include="..\include\engine\extdll.h" /> <ClInclude Include="..\include\engine\extdll.h" />
<ClInclude Include="..\include\engine\meta_api.h" /> <ClInclude Include="..\include\engine\meta_api.h" />
<ClInclude Include="..\include\engine\progdefs.h" /> <ClInclude Include="..\include\engine\progdefs.h" />
@ -53,14 +52,14 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140_xp</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v140_xp</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">

View file

@ -18,9 +18,6 @@
<ClInclude Include="..\include\compress.h"> <ClInclude Include="..\include\compress.h">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\include\core.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\corelib.h"> <ClInclude Include="..\include\corelib.h">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
@ -54,8 +51,8 @@
<ClInclude Include="..\include\engine.h"> <ClInclude Include="..\include\engine.h">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\include\engine\enginecallback.h"> <ClInclude Include="..\include\yapb.h">
<Filter>include\engine</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -80,15 +77,15 @@
<ClCompile Include="..\source\manager.cpp"> <ClCompile Include="..\source\manager.cpp">
<Filter>source</Filter> <Filter>source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\source\basecode.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\combat.cpp"> <ClCompile Include="..\source\combat.cpp">
<Filter>source</Filter> <Filter>source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\source\engine.cpp"> <ClCompile Include="..\source\engine.cpp">
<Filter>source</Filter> <Filter>source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\source\basecode.cpp">
<Filter>source</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="yapb.rc"> <ResourceCompile Include="yapb.rc">

File diff suppressed because it is too large Load diff

View file

@ -4,142 +4,141 @@
// //
// This software is licensed under the BSD-style license. // This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit: // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license // https://yapb.ru/license
// //
#include <core.h> #include <yapb.h>
ConVar yb_chat ("yb_chat", "1"); ConVar yb_chat ("yb_chat", "1");
void StripTags (char *buffer) void stripClanTags (char *buffer) {
{
// this function strips 'clan' tags specified below in given string buffer // this function strips 'clan' tags specified below in given string buffer
const char *tagOpen[] = {"-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")"}; if (isEmptyStr (buffer)) {
const char *tagClose[] = {"=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "("}; return;
}
size_t nameLength = strlen (buffer);
int index, fieldStart, fieldStop, i; if (nameLength < 4) {
int length = strlen (buffer); // get length of string return;
}
// foreach known tag... constexpr const char *open[] = { "-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")" };
for (index = 0; index < ARRAYSIZE_HLSDK (tagOpen); index++) constexpr const char *close[] = { "=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "(" };
{
fieldStart = strstr (buffer, tagOpen[index]) - buffer; // look for a tag start // for each known tag...
for (size_t i = 0; i < cr::arrsize (open); i++) {
size_t start = strstr (buffer, open[i]) - buffer; // look for a tag start
// have we found a tag start? // have we found a tag start?
if (fieldStart >= 0 && fieldStart < 32) if (start < 32) {
{ size_t stop = strstr (buffer, close[i]) - buffer; // look for a tag stop
fieldStop = strstr (buffer, tagClose[index]) - buffer; // look for a tag stop
// have we found a tag stop? // have we found a tag stop?
if (fieldStop > fieldStart && fieldStop < 32) if (stop > start && stop < 32) {
{ size_t tag = strlen (close[i]);
int tagLength = strlen (tagClose[index]); size_t j = start;
for (i = fieldStart; i < length - (fieldStop + tagLength - fieldStart); i++) for (; j < nameLength - (stop + tag - start); j++) {
buffer[i] = buffer[i + (fieldStop + tagLength - fieldStart)]; // overwrite the buffer with the stripped string buffer[j] = buffer[j + (stop + tag - start)]; // overwrite the buffer with the stripped string
}
buffer[i] = 0x0; // terminate the string buffer[j] = '\0'; // terminate the string
} }
} }
} }
// have we stripped too much (all the stuff)? // have we stripped too much (all the stuff)?
if (buffer[0] != '\0') if (isEmptyStr (buffer)) {
{ String::trimChars (buffer);
String::TrimExternalBuffer (buffer); // if so, string is just a tag return;
}
String::trimChars (buffer); // if so, string is just a tag
int tagLength = 0; // strip just the tag part...
for (size_t i = 0; i < cr::arrsize (open); i++) {
size_t start = strstr (buffer, open[i]) - buffer; // look for a tag start
// strip just the tag part... // have we found a tag start?
for (index = 0; index < ARRAYSIZE_HLSDK (tagOpen); index++) if (start < 32) {
{ size_t tag = strlen (open[i]);
fieldStart = strstr (buffer, tagOpen[index]) - buffer; // look for a tag start size_t j = start;
// have we found a tag start? for (; j < nameLength - tag; j++) {
if (fieldStart >= 0 && fieldStart < 32) buffer[j] = buffer[j + tag]; // overwrite the buffer with the stripped string
{ }
tagLength = strlen (tagOpen[index]); buffer[j] = '\0'; // terminate the string
start = strstr (buffer, close[i]) - buffer; // look for a tag stop
for (i = fieldStart; i < length - tagLength; i++) // have we found a tag stop ?
buffer[i] = buffer[i + tagLength]; // overwrite the buffer with the stripped string if (start < 32) {
tag = strlen (close[i]);
j = start;
buffer[i] = 0x0; // terminate the string for (; j < nameLength - tag; j++) {
buffer[j] = buffer[j + tag]; // overwrite the buffer with the stripped string
fieldStart = strstr (buffer, tagClose[index]) - buffer; // look for a tag stop
// have we found a tag stop ?
if (fieldStart >= 0 && fieldStart < 32)
{
tagLength = strlen (tagClose[index]);
for (i = fieldStart; i < length - tagLength; i++)
buffer[i] = buffer[i + tagLength]; // overwrite the buffer with the stripped string
buffer[i] = 0; // terminate the string
} }
buffer[j] = 0; // terminate the string
} }
} }
} }
String::TrimExternalBuffer (buffer); // to finish, strip eventual blanks after and before the tag marks String::trimChars (buffer); // to finish, strip eventual blanks after and before the tag marks
} }
char *HumanizeName (char *name) char *humanizeName (char *name) {
{
// this function humanize player name (i.e. trim clan and switch to lower case (sometimes)) // this function humanize player name (i.e. trim clan and switch to lower case (sometimes))
static char outputName[64]; // create return name buffer static char outputName[64]; // create return name buffer
strncpy (outputName, name, SIZEOF_CHAR (outputName)); // copy name to new buffer strncpy (outputName, name, cr::bufsize (outputName)); // copy name to new buffer
// drop tag marks, 80 percent of time // drop tag marks, 80 percent of time
if (Random.Int (1, 100) < 80) if (rng.getInt (1, 100) < 80) {
StripTags (outputName); stripClanTags (outputName);
else }
String::TrimExternalBuffer (outputName); else {
String::trimChars (outputName);
}
// sometimes switch name to lower characters // sometimes switch name to lower characters
// note: since we're using russian names written in english, we reduce this shit to 6 percent // note: since we're using russian names written in english, we reduce this shit to 6 percent
if (Random.Int (1, 100) <= 6) if (rng.getInt (1, 100) <= 6) {
{ for (size_t i = 0; i < strlen (outputName); i++) {
for (int i = 0; i < static_cast <int> (strlen (outputName)); i++)
outputName[i] = static_cast <char> (tolower (static_cast <int> (outputName[i]))); // to lower case outputName[i] = static_cast <char> (tolower (static_cast <int> (outputName[i]))); // to lower case
}
} }
return &outputName[0]; // return terminated string return &outputName[0]; // return terminated string
} }
void HumanizeChat (char *buffer) void addChatErrors (char *buffer) {
{
// this function humanize chat string to be more handwritten // this function humanize chat string to be more handwritten
int length = strlen (buffer); // get length of string size_t length = strlen (buffer); // get length of string
int i = 0; size_t i = 0;
// sometimes switch text to lowercase // sometimes switch text to lowercase
// note: since we're using russian chat written in english, we reduce this shit to 4 percent // note: since we're using russian chat written in English, we reduce this shit to 4 percent
if (Random.Int (1, 100) <= 4) if (rng.getInt (1, 100) <= 4) {
{ for (i = 0; i < length; i++) {
for (i = 0; i < length; i++) buffer[i] = static_cast <char> (tolower (static_cast <int> (buffer[i]))); // switch to lowercase
buffer[i] = static_cast <char> (tolower (static_cast <int> (buffer[i])));; // switch to lowercase }
} }
if (length > 15) if (length > 15) {
{ size_t percentile = length / 2;
// "length / 2" percent of time drop a character // "length / 2" percent of time drop a character
if (Random.Int (1, 100) < (length / 2)) if (rng.getInt (1u, 100u) < percentile) {
{ size_t pos = rng.getInt (length / 8, length - length / 8); // chose random position in string
int pos = Random.Int ((length / 8), length - (length / 8)); // chose random position in string
for (i = pos; i < length - 1; i++) for (i = pos; i < length - 1; i++) {
buffer[i] = buffer[i + 1]; // overwrite the buffer with stripped string buffer[i] = buffer[i + 1]; // overwrite the buffer with stripped string
}
buffer[i] = 0x0; // terminate string; buffer[i] = '\0'; // terminate string;
length--; // update new string length length--; // update new string length
} }
// "length" / 4 precent of time swap character // "length" / 4 precent of time swap character
if (Random.Int (1, 100) < (length / 4)) if (rng.getInt (1u, 100u) < percentile / 2) {
{ size_t pos = rng.getInt (length / 8, 3 * length / 8); // choose random position in string
int pos = Random.Int ((length / 8), ((3 * length) / 8)); // choose random position in string
char ch = buffer[pos]; // swap characters char ch = buffer[pos]; // swap characters
buffer[pos] = buffer[pos + 1]; buffer[pos] = buffer[pos + 1];
@ -149,304 +148,286 @@ void HumanizeChat (char *buffer)
buffer[length] = 0; // terminate string buffer[length] = 0; // terminate string
} }
void Bot::PrepareChatMessage (char *text) void Bot::prepareChatMessage (char *text) {
{
// this function parses messages from the botchat, replaces keywords and converts names into a more human style // this function parses messages from the botchat, replaces keywords and converts names into a more human style
if (!yb_chat.GetBool () || IsNullString (text)) if (!yb_chat.boolean () || isEmptyStr (text)) {
return; return;
}
#define ASSIGN_TALK_ENTITY() if (!engine.IsNullEntity (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings)) m_tempStrings.clear ();
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
char *textStart = text; char *textStart = text;
char *pattern = text; char *pattern = text;
edict_t *talkEntity = nullptr; edict_t *talkEntity = nullptr;
while (pattern != nullptr) auto getHumanizedName = [] (edict_t *ent) {
{ if (!engine.isNullEntity (ent)) {
return const_cast <const char *> (humanizeName (const_cast <char *> (STRING (ent->v.netname))));
}
return "unknown";
};
while (pattern != nullptr) {
// all replacement placeholders start with a % // all replacement placeholders start with a %
pattern = strstr (textStart, "%"); pattern = strchr (textStart, '%');
if (pattern != nullptr) if (pattern != nullptr) {
{ size_t length = pattern - textStart;
int length = pattern - textStart;
if (length > 0)
strncpy (m_tempStrings, textStart, length);
if (length > 0) {
m_tempStrings = String (textStart, length);
}
pattern++; pattern++;
// player with most frags? // player with most frags?
if (*pattern == 'f') if (*pattern == 'f') {
{
int highestFrags = -9000; // just pick some start value int highestFrags = -9000; // just pick some start value
int index = 0; int index = 0;
for (int i = 0; i < engine.MaxClients (); i++) for (int i = 0; i < engine.maxClients (); i++) {
{
const Client &client = g_clients[i]; const Client &client = g_clients[i];
if (!(client.flags & CF_USED) || client.ent == GetEntity ()) if (!(client.flags & CF_USED) || client.ent == ent ()) {
continue; continue;
}
int frags = static_cast <int> (client.ent->v.frags); int frags = static_cast <int> (client.ent->v.frags);
if (frags > highestFrags) if (frags > highestFrags) {
{
highestFrags = frags; highestFrags = frags;
index = i; index = i;
} }
} }
talkEntity = g_clients[index].ent; talkEntity = g_clients[index].ent;
m_tempStrings += getHumanizedName (talkEntity);
ASSIGN_TALK_ENTITY ();
} }
// mapname? // mapname?
else if (*pattern == 'm') else if (*pattern == 'm') {
strncat (m_tempStrings, engine.GetMapName (), SIZEOF_CHAR (m_tempStrings)); m_tempStrings += engine.getMapName ();
}
// roundtime? // roundtime?
else if (*pattern == 'r') else if (*pattern == 'r') {
{ int time = static_cast <int> (g_timeRoundEnd - engine.timebase ());
int time = static_cast <int> (g_timeRoundEnd - engine.Time ()); m_tempStrings.formatAppend ("%02d:%02d", time / 60, time % 60);
strncat (m_tempStrings, FormatBuffer ("%02d:%02d", time / 60, time % 60), SIZEOF_CHAR (m_tempStrings));
} }
// chat reply? // chat reply?
else if (*pattern == 's') else if (*pattern == 's') {
{ talkEntity = engine.entityOfIndex (m_sayTextBuffer.entityIndex);
talkEntity = engine.EntityOfIndex (m_sayTextBuffer.entityIndex); m_tempStrings += getHumanizedName (talkEntity);
ASSIGN_TALK_ENTITY ();
} }
// teammate alive? // teammate alive?
else if (*pattern == 't') else if (*pattern == 't') {
{
int i; int i;
for (i = 0; i < engine.MaxClients (); i++) for (i = 0; i < engine.maxClients (); i++) {
{
const Client &client = g_clients[i]; const Client &client = g_clients[i];
if (!(client.flags & CF_USED) || !(client.flags & CF_ALIVE) || client.team != m_team || client.ent == GetEntity ()) if (!(client.flags & CF_USED) || !(client.flags & CF_ALIVE) || client.team != m_team || client.ent == ent ()) {
continue; continue;
}
break; break;
} }
if (i < engine.MaxClients ()) if (i < engine.maxClients ()) {
{ if (isPlayer (pev->dmg_inflictor) && m_team == engine.getTeam (pev->dmg_inflictor)) {
if (!engine.IsNullEntity (pev->dmg_inflictor) && m_team == engine.GetTeam (pev->dmg_inflictor))
talkEntity = pev->dmg_inflictor; talkEntity = pev->dmg_inflictor;
else }
else {
talkEntity = g_clients[i].ent; talkEntity = g_clients[i].ent;
}
ASSIGN_TALK_ENTITY (); m_tempStrings += getHumanizedName (talkEntity);
} }
else // no teammates alive... else // no teammates alive...
{ {
for (i = 0; i < engine.MaxClients (); i++) for (i = 0; i < engine.maxClients (); i++) {
{
const Client &client = g_clients[i]; const Client &client = g_clients[i];
if (!(client.flags & CF_USED) || client.team != m_team || client.ent == GetEntity ()) if (!(client.flags & CF_USED) || client.team != m_team || client.ent == ent ()) {
continue; continue;
}
break; break;
} }
if (i < engine.MaxClients ()) if (i < engine.maxClients ()) {
{
talkEntity = g_clients[i].ent; talkEntity = g_clients[i].ent;
m_tempStrings += getHumanizedName (talkEntity);
ASSIGN_TALK_ENTITY ();
} }
} }
} }
else if (*pattern == 'e') else if (*pattern == 'e') {
{
int i; int i;
for (i = 0; i < engine.MaxClients (); i++) for (i = 0; i < engine.maxClients (); i++) {
{
const Client &client = g_clients[i]; const Client &client = g_clients[i];
if (!(client.flags & CF_USED) || !(client.flags & CF_ALIVE) || client.team == m_team || client.ent == GetEntity ()) if (!(client.flags & CF_USED) || !(client.flags & CF_ALIVE) || client.team == m_team || client.ent == ent ()) {
continue; continue;
}
break; break;
} }
if (i < engine.MaxClients ()) if (i < engine.maxClients ()) {
{
talkEntity = g_clients[i].ent; talkEntity = g_clients[i].ent;
ASSIGN_TALK_ENTITY (); m_tempStrings += getHumanizedName (talkEntity);
} }
else // no teammates alive...
{ // no teammates alive ?
for (i = 0; i < engine.MaxClients (); i++) else {
{ for (i = 0; i < engine.maxClients (); i++) {
const Client &client = g_clients[i]; const Client &client = g_clients[i];
if (!(client.flags & CF_USED) || client.team == m_team || client.ent == GetEntity ()) if (!(client.flags & CF_USED) || client.team == m_team || client.ent == ent ()) {
continue; continue;
}
break; break;
} }
if (i < engine.MaxClients ()) if (i < engine.maxClients ()) {
{
talkEntity = g_clients[i].ent; talkEntity = g_clients[i].ent;
ASSIGN_TALK_ENTITY (); m_tempStrings += getHumanizedName (talkEntity);
} }
} }
} }
else if (*pattern == 'd') else if (*pattern == 'd') {
{ if (g_gameFlags & GAME_CZERO) {
if (g_gameFlags & GAME_CZERO) if (rng.getInt (1, 100) < 30) {
{ m_tempStrings += "CZ";
if (Random.Int (1, 100) < 30) }
strcat (m_tempStrings, "CZ"); else {
else m_tempStrings += "Condition Zero";
strcat (m_tempStrings, "Condition Zero"); }
} }
else if ((g_gameFlags & GAME_CSTRIKE16) || (g_gameFlags & GAME_LEGACY)) else if ((g_gameFlags & GAME_CSTRIKE16) || (g_gameFlags & GAME_LEGACY)) {
{ if (rng.getInt (1, 100) < 30) {
if (Random.Int (1, 100) < 30) m_tempStrings += "CS";
strcat (m_tempStrings, "CS"); }
else else {
strcat (m_tempStrings, "Counter-Strike"); m_tempStrings += "Counter-Strike";
}
} }
} }
else if (*pattern == 'v') else if (*pattern == 'v') {
{
talkEntity = m_lastVictim; talkEntity = m_lastVictim;
ASSIGN_TALK_ENTITY (); m_tempStrings += getHumanizedName (talkEntity);
} }
pattern++; pattern++;
textStart = pattern; textStart = pattern;
} }
} }
if (textStart != nullptr) if (textStart != nullptr) {
{
// let the bots make some mistakes... // let the bots make some mistakes...
char tempString[160]; char tempString[160];
strncpy (tempString, textStart, SIZEOF_CHAR (tempString)); strncpy (tempString, textStart, cr::bufsize (tempString));
HumanizeChat (tempString); addChatErrors (tempString);
strncat (m_tempStrings, tempString, SIZEOF_CHAR (m_tempStrings)); m_tempStrings += tempString;
} }
} }
bool CheckKeywords (char *tempMessage, char *reply) bool checkForKeywords (char *message, char *reply) {
{ // this function checks is string contain keyword, and generates reply to it
// this function checks is string contain keyword, and generates relpy to it
if (!yb_chat.GetBool () || IsNullString (tempMessage)) if (!yb_chat.boolean () || isEmptyStr (message)) {
return false; return false;
}
for (auto &factory : g_replyFactory) {
for (auto &keyword : factory.keywords) {
FOR_EACH_AE (g_replyFactory, i)
{
FOR_EACH_AE (g_replyFactory[i].keywords, j)
{
// check is keyword has occurred in message // check is keyword has occurred in message
if (strstr (tempMessage, g_replyFactory[i].keywords[j].GetBuffer ()) != nullptr) if (strstr (message, keyword.chars ()) != nullptr) {
{ StringArray &replies = factory.usedReplies;
Array <String> &replies = g_replyFactory[i].usedReplies;
if (replies.GetElementNumber () >= g_replyFactory[i].replies.GetElementNumber () / 2) if (replies.length () >= factory.replies.length () / 2) {
replies.RemoveAll (); replies.clear ();
bool replyUsed = false;
const char *generatedReply = g_replyFactory[i].replies.GetRandomElement ();
// don't say this twice
FOR_EACH_AE (replies, k)
{
if (strstr (replies[k].GetBuffer (), generatedReply) != nullptr)
replyUsed = true;
} }
else if (!replies.empty ()) {
bool replyUsed = false;
const String &choosenReply = factory.replies.random ();
// reply not used, so use it // don't say this twice
if (!replyUsed) for (auto &used : replies) {
{ if (used.contains (choosenReply)) {
strcpy (reply, generatedReply); // update final buffer replyUsed = true;
replies.Push (generatedReply); //add to ignore list break;
}
}
return true; // reply not used, so use it
if (!replyUsed) {
strcpy (reply, choosenReply.chars ()); // update final buffer
replies.push (choosenReply); // add to ignore list
return true;
}
} }
} }
} }
} }
// didn't find a keyword? 70% of the time use some universal reply // didn't find a keyword? 70% of the time use some universal reply
if (Random.Int (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ()) if (rng.getInt (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].empty ()) {
{ strcpy (reply, g_chatFactory[CHAT_NOKW].random ().chars ());
strcpy (reply, g_chatFactory[CHAT_NOKW].GetRandomElement ().GetBuffer ());
return true; return true;
} }
return false; return false;
} }
bool Bot::ParseChat (char *reply) bool Bot::processChatKeywords (char *reply) {
{
// this function parse chat buffer, and prepare buffer to keyword searching // this function parse chat buffer, and prepare buffer to keyword searching
char tempMessage[512]; char tempMessage[512];
strcpy (tempMessage, m_sayTextBuffer.sayText); // copy to safe place size_t maxLength = cr::bufsize (tempMessage);
strncpy (tempMessage, m_sayTextBuffer.sayText.chars (), maxLength); // copy to safe place
// text to uppercase for keyword parsing // text to uppercase for keyword parsing
for (int i = 0; i < static_cast <int> (strlen (tempMessage)); i++) for (size_t i = 0; i < maxLength; i++) {
tempMessage[i] = static_cast <char> (tolower (static_cast <int> (tempMessage[i]))); tempMessage[i] = static_cast <char> (toupper (static_cast <int> (tempMessage[i])));
}
return CheckKeywords (tempMessage, reply); return checkForKeywords (tempMessage, reply);
} }
bool Bot::RepliesToPlayer (void) bool Bot::isReplyingToChat (void) {
{
// this function sends reply to a player // this function sends reply to a player
if (m_sayTextBuffer.entityIndex != -1 && !IsNullString (m_sayTextBuffer.sayText)) if (m_sayTextBuffer.entityIndex != -1 && !m_sayTextBuffer.sayText.empty ()) {
{
char text[256]; char text[256];
// check is time to chat is good // check is time to chat is good
if (m_sayTextBuffer.timeNextChat < engine.Time ()) if (m_sayTextBuffer.timeNextChat < engine.timebase ()) {
{ if (rng.getInt (1, 100) < m_sayTextBuffer.chatProbability + rng.getInt (15, 35) && processChatKeywords (reinterpret_cast <char *> (&text))) {
if (Random.Int (1, 100) < m_sayTextBuffer.chatProbability + Random.Int (2, 10) && ParseChat (reinterpret_cast <char *> (&text))) prepareChatMessage (text);
{ pushMsgQueue (GAME_MSG_SAY_CMD);
PrepareChatMessage (text);
PushMessageQueue (GAME_MSG_SAY_CMD);
m_sayTextBuffer.entityIndex = -1; m_sayTextBuffer.entityIndex = -1;
m_sayTextBuffer.sayText[0] = 0x0; m_sayTextBuffer.timeNextChat = engine.timebase () + m_sayTextBuffer.chatDelay;
m_sayTextBuffer.timeNextChat = engine.Time () + m_sayTextBuffer.chatDelay; m_sayTextBuffer.sayText.clear ();
return true; return true;
} }
m_sayTextBuffer.entityIndex = -1; m_sayTextBuffer.entityIndex = -1;
m_sayTextBuffer.sayText[0] = 0x0; m_sayTextBuffer.sayText.clear ();
} }
} }
return false; return false;
} }
void Bot::SayText (const char *text) void Bot::say (const char *text) {
{
// this function prints saytext message to all players // this function prints saytext message to all players
if (IsNullString (text)) if (isEmptyStr (text)) {
return; return;
}
engine.IssueBotCommand (GetEntity (), "say \"%s\"", text); engine.execBotCmd (ent (), "say \"%s\"", text);
} }
void Bot::TeamSayText (const char *text) void Bot::sayTeam (const char *text) {
{
// this function prints saytext message only for teammates // this function prints saytext message only for teammates
if (IsNullString (text)) if (isEmptyStr (text)) {
return; return;
}
engine.IssueBotCommand (GetEntity (), "say_team \"%s\"", text); engine.execBotCmd (ent (), "say_team \"%s\"", text);
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,10 +4,10 @@
// //
// This software is licensed under the BSD-style license. // This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit: // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://yapb.jeefo.net/license // https://yapb.ru/license
// //
#include <core.h> #include <yapb.h>
bool g_canSayBombPlanted = true; bool g_canSayBombPlanted = true;
bool g_roundEnded = true; bool g_roundEnded = true;
@ -27,25 +27,23 @@ float g_timeRoundMid = 0.0f;
float g_timeNextBombUpdate = 0.0f; float g_timeNextBombUpdate = 0.0f;
float g_timeBombPlanted = 0.0f; float g_timeBombPlanted = 0.0f;
float g_timePerSecondUpdate = 0.0f; float g_timePerSecondUpdate = 0.0f;
float g_lastRadioTime[2] = {0.0f, 0.0f}; float g_lastRadioTime[MAX_TEAM_COUNT] = { 0.0f, };
float g_autoPathDistance = 250.0f; float g_autoPathDistance = 250.0f;
int g_lastRadio[2]; int g_lastRadio[MAX_TEAM_COUNT];
int g_storeAddbotVars[4]; int g_storeAddbotVars[4];
int g_radioSelect[MAX_ENGINE_PLAYERS]; int g_radioSelect[MAX_ENGINE_PLAYERS];
int g_gameFlags = 0; int g_gameFlags = 0;
int g_numWaypoints = 0; int g_mapFlags = 0;
int g_mapType = 0;
int g_highestDamageCT = 1; int g_highestDamageCT = 1;
int g_highestDamageT = 1; int g_highestDamageT = 1;
int g_highestKills = 1; int g_highestKills = 1;
Array <Array <String> > g_chatFactory; Array<StringArray> g_chatFactory;
Array <Array <ChatterItem> > g_chatterFactory; Array<Array<ChatterItem>> g_chatterFactory;
Array <BotName> g_botNames; Array<BotName> g_botNames;
Array <KeywordFactory> g_replyFactory; Array<KeywordFactory> g_replyFactory;
RandomSequenceOfUnique Random;
Library *g_gameLib = nullptr; Library *g_gameLib = nullptr;
meta_globals_t *gpMetaGlobals = nullptr; meta_globals_t *gpMetaGlobals = nullptr;
@ -63,31 +61,15 @@ globalvars_t *g_pGlobals = nullptr;
Experience *g_experienceData = nullptr; Experience *g_experienceData = nullptr;
// default tables for personality weapon preferences, overridden by weapons.cfg // default tables for personality weapon preferences, overridden by weapons.cfg
int g_normalWeaponPrefs[NUM_WEAPONS] = int g_normalWeaponPrefs[NUM_WEAPONS] = {0, 2, 1, 4, 5, 6, 3, 12, 10, 24, 25, 13, 11, 8, 7, 22, 23, 18, 21, 17, 19, 15, 17, 9, 14, 16};
{0, 2, 1, 4, 5, 6, 3, 12, 10, 24, 25, 13, 11, 8, 7, 22, 23, 18, 21, 17, 19, 15, 17, 9, 14, 16}; int g_rusherWeaponPrefs[NUM_WEAPONS] = {0, 2, 1, 4, 5, 6, 3, 24, 19, 22, 23, 20, 21, 10, 12, 13, 7, 8, 11, 9, 18, 17, 19, 25, 15, 16};
int g_carefulWeaponPrefs[NUM_WEAPONS] = {0, 2, 1, 4, 25, 6, 3, 7, 8, 12, 10, 13, 11, 9, 24, 18, 14, 17, 16, 15, 19, 20, 21, 22, 23, 5};
int g_rusherWeaponPrefs[NUM_WEAPONS] = int g_grenadeBuyPrecent[NUM_WEAPONS - 23] = {95, 85, 60};
{0, 2, 1, 4, 5, 6, 3, 24, 19, 22, 23, 20, 21, 10, 12, 13, 7, 8, 11, 9, 18, 17, 19, 25, 15, 16}; int g_botBuyEconomyTable[NUM_WEAPONS - 15] = {1900, 2100, 2100, 4000, 6000, 7000, 16000, 1200, 800, 1000, 3000};
int *g_weaponPrefs[] = {g_normalWeaponPrefs, g_rusherWeaponPrefs, g_carefulWeaponPrefs};
int g_carefulWeaponPrefs[NUM_WEAPONS] =
{0, 2, 1, 4, 25, 6, 3, 7, 8, 12, 10, 13, 11, 9, 24, 18, 14, 17, 16, 15, 19, 20, 21, 22, 23, 5};
int g_grenadeBuyPrecent[NUM_WEAPONS - 23] =
{95, 85, 60};
int g_botBuyEconomyTable[NUM_WEAPONS - 15] =
{1900, 2100, 2100, 4000, 6000, 7000, 16000, 1200, 800, 1000, 3000};
int *g_weaponPrefs[] =
{
g_normalWeaponPrefs,
g_rusherWeaponPrefs,
g_carefulWeaponPrefs
};
// metamod plugin information // metamod plugin information
plugin_info_t Plugin_info = plugin_info_t Plugin_info = {
{
META_INTERFACE_VERSION, // interface version META_INTERFACE_VERSION, // interface version
PRODUCT_NAME, // plugin name PRODUCT_NAME, // plugin name
PRODUCT_VERSION, // plugin version PRODUCT_VERSION, // plugin version
@ -99,304 +81,291 @@ plugin_info_t Plugin_info =
PT_ANYTIME, // when unloadable PT_ANYTIME, // when unloadable
}; };
// table with all available actions for the bots (filtered in & out in Bot::SetConditions) some of them have subactions included // table with all available actions for the bots (filtered in & out in Bot::setConditions) some of them have subactions included
TaskItem g_taskFilters[] = Task g_taskFilters[TASK_MAX] = {
{ { TASK_NORMAL, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
{TASK_NORMAL, 0, -1, 0.0f, true}, { TASK_PAUSE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_PAUSE, 0, -1, 0.0f, false}, { TASK_MOVETOPOSITION, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
{TASK_MOVETOPOSITION, 0, -1, 0.0f, true}, { TASK_FOLLOWUSER, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
{TASK_FOLLOWUSER, 0, -1, 0.0f, true}, { TASK_PICKUPITEM, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
{TASK_WAITFORGO, 0, -1, 0.0f, true}, { TASK_CAMP, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
{TASK_PICKUPITEM, 0, -1, 0.0f, true}, { TASK_PLANTBOMB, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_CAMP, 0, -1, 0.0f, true}, { TASK_DEFUSEBOMB, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_PLANTBOMB, 0, -1, 0.0f, false}, { TASK_ATTACK, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_DEFUSEBOMB, 0, -1, 0.0f, false}, { TASK_HUNTENEMY, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_ATTACK, 0, -1, 0.0f, false}, { TASK_SEEKCOVER, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_HUNTENEMY, 0, -1, 0.0f, false}, { TASK_THROWHEGRENADE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_SEEKCOVER, 0, -1, 0.0f, false}, { TASK_THROWFLASHBANG, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_THROWHEGRENADE, 0, -1, 0.0f, false}, { TASK_THROWSMOKE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_THROWFLASHBANG, 0, -1, 0.0f, false}, { TASK_DOUBLEJUMP, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_THROWSMOKE, 0, -1, 0.0f, false}, { TASK_ESCAPEFROMBOMB, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_DOUBLEJUMP, 0, -1, 0.0f, false}, { TASK_SHOOTBREAKABLE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_ESCAPEFROMBOMB, 0, -1, 0.0f, false}, { TASK_HIDE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_SHOOTBREAKABLE, 0, -1, 0.0f, false}, { TASK_BLINDED, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
{TASK_HIDE, 0, -1, 0.0f, false}, { TASK_SPRAY, 0, INVALID_WAYPOINT_INDEX, 0.0f, false }
{TASK_BLINDED, 0, -1, 0.0f, false},
{TASK_SPRAY, 0, -1, 0.0f, false}
}; };
// weapons and their specifications // weapons and their specifications
WeaponSelect g_weaponSelect[NUM_WEAPONS + 1] = WeaponSelect g_weaponSelect[NUM_WEAPONS + 1] = {
{ { WEAPON_KNIFE, "weapon_knife", "knife.mdl", 0, 0, -1, -1, 0, 0, 0, 0, 0, true },
{WEAPON_KNIFE, "weapon_knife", "knife.mdl", 0, 0, -1, -1, 0, 0, 0, 0, 0, true }, { WEAPON_USP, "weapon_usp", "usp.mdl", 500, 1, -1, -1, 1, 1, 2, 2, 0, false },
{WEAPON_USP, "weapon_usp", "usp.mdl", 500, 1, -1, -1, 1, 1, 2, 2, 0, false}, { WEAPON_GLOCK, "weapon_glock18", "glock18.mdl", 400, 1, -1, -1, 1, 2, 1, 1, 0, false },
{WEAPON_GLOCK, "weapon_glock18", "glock18.mdl", 400, 1, -1, -1, 1, 2, 1, 1, 0, false}, { WEAPON_DEAGLE, "weapon_deagle", "deagle.mdl", 650, 1, 2, 2, 1, 3, 4, 4, 2, false },
{WEAPON_DEAGLE, "weapon_deagle", "deagle.mdl", 650, 1, 2, 2, 1, 3, 4, 4, 2, false}, { WEAPON_P228, "weapon_p228", "p228.mdl", 600, 1, 2, 2, 1, 4, 3, 3, 0 , false },
{WEAPON_P228, "weapon_p228", "p228.mdl", 600, 1, 2, 2, 1, 4, 3, 3, 0, false}, { WEAPON_ELITE, "weapon_elite", "elite.mdl", 800, 1, 0, 0, 1, 5, 5, 5, 0, false },
{WEAPON_ELITE, "weapon_elite", "elite.mdl", 1000, 1, 0, 0, 1, 5, 5, 5, 0, false}, { WEAPON_FIVESEVEN, "weapon_fiveseven", "fiveseven.mdl", 750, 1, 1, 1, 1, 6, 5, 5, 0, false },
{WEAPON_FIVESEVEN, "weapon_fiveseven", "fiveseven.mdl", 750, 1, 1, 1, 1, 6, 5, 5, 0, false}, { WEAPON_M3, "weapon_m3", "m3.mdl", 1700, 1, 2, -1, 2, 1, 1, 1, 0, false },
{WEAPON_M3, "weapon_m3", "m3.mdl", 1700, 1, 2, -1, 2, 1, 1, 1, 0, false}, { WEAPON_XM1014, "weapon_xm1014", "xm1014.mdl", 3000, 1, 2, -1, 2, 2, 2, 2, 0, false },
{WEAPON_XM1014, "weapon_xm1014", "xm1014.mdl", 3000, 1, 2, -1, 2, 2, 2, 2, 0, false}, { WEAPON_MP5, "weapon_mp5navy", "mp5.mdl", 1500, 1, 2, 1, 3, 1, 2, 2, 0, true },
{WEAPON_MP5, "weapon_mp5navy", "mp5.mdl", 1500, 1, 2, 1, 3, 1, 2, 2, 0, true }, { WEAPON_TMP, "weapon_tmp", "tmp.mdl", 1250, 1, 1, 1, 3, 2, 1, 1, 0, true },
{WEAPON_TMP, "weapon_tmp", "tmp.mdl", 1250, 1, 1, 1, 3, 2, 1, 1, 0, true }, { WEAPON_P90, "weapon_p90", "p90.mdl", 2350, 1, 2, 1, 3, 3, 4, 4, 0, true },
{WEAPON_P90, "weapon_p90", "p90.mdl", 2350, 1, 2, 1, 3, 3, 4, 4, 0, true }, { WEAPON_MAC10, "weapon_mac10", "mac10.mdl", 1400, 1, 0, 0, 3, 4, 1, 1, 0, true },
{WEAPON_MAC10, "weapon_mac10", "mac10.mdl", 1400, 1, 0, 0, 3, 4, 1, 1, 0, true }, { WEAPON_UMP45, "weapon_ump45", "ump45.mdl", 1700, 1, 2, 2, 3, 5, 3, 3, 0, true },
{WEAPON_UMP45, "weapon_ump45", "ump45.mdl", 1700, 1, 2, 2, 3, 5, 3, 3, 0, true }, { WEAPON_AK47, "weapon_ak47", "ak47.mdl", 2500, 1, 0, 0, 4, 1, 2, 2, 2, true },
{WEAPON_AK47, "weapon_ak47", "ak47.mdl", 2500, 1, 0, 0, 4, 1, 2, 2, 2, true }, { WEAPON_SG552, "weapon_sg552", "sg552.mdl", 3500, 1, 0, -1, 4, 2, 4, 4, 2, true },
{WEAPON_SG552, "weapon_sg552", "sg552.mdl", 3500, 1, 0, -1, 4, 2, 4, 4, 2, true }, { WEAPON_M4A1, "weapon_m4a1", "m4a1.mdl", 3100, 1, 1, 1, 4, 3, 3, 3, 2, true },
{WEAPON_M4A1, "weapon_m4a1", "m4a1.mdl", 3100, 1, 1, 1, 4, 3, 3, 3, 2, true }, { WEAPON_GALIL, "weapon_galil", "galil.mdl", 2000, 1, 0, 0, 4, -1, 1, 1, 2, true },
{WEAPON_GALIL, "weapon_galil", "galil.mdl", 2000, 1, 0, 0, 4, -1, 1, 1, 2, true }, { WEAPON_FAMAS, "weapon_famas", "famas.mdl", 2250, 1, 1, 1, 4, -1, 1, 1, 2, true },
{WEAPON_FAMAS, "weapon_famas", "famas.mdl", 2250, 1, 1, 1, 4, -1, 1, 1, 2, true }, { WEAPON_AUG, "weapon_aug", "aug.mdl", 3500, 1, 1, 1, 4, 4, 4, 4, 2, true },
{WEAPON_AUG, "weapon_aug", "aug.mdl", 3500, 1, 1, 1, 4, 4, 4, 4, 2, true }, { WEAPON_SCOUT, "weapon_scout", "scout.mdl", 2750, 1, 2, 0, 4, 5, 3, 2, 3, false },
{WEAPON_SCOUT, "weapon_scout", "scout.mdl", 2750, 1, 2, 0, 4, 5, 3, 2, 3, false}, { WEAPON_AWP, "weapon_awp", "awp.mdl", 4750, 1, 2, 0, 4, 6, 5, 6, 3, false },
{WEAPON_AWP, "weapon_awp", "awp.mdl", 4750, 1, 2, 0, 4, 6, 5, 6, 3, false}, { WEAPON_G3SG1, "weapon_g3sg1", "g3sg1.mdl", 5000, 1, 0, 2, 4, 7, 6, 6, 3, false },
{WEAPON_G3SG1, "weapon_g3sg1", "g3sg1.mdl", 5000, 1, 0, 2, 4, 7, 6, 6, 3, false}, { WEAPON_SG550, "weapon_sg550", "sg550.mdl", 4200, 1, 1, 1, 4, 8, 5, 5, 3, false },
{WEAPON_SG550, "weapon_sg550", "sg550.mdl", 4200, 1, 1, 1, 4, 8, 5, 5, 3, false}, { WEAPON_M249, "weapon_m249", "m249.mdl", 5750, 1, 2, 1, 5, 1, 1, 1, 2, true },
{WEAPON_M249, "weapon_m249", "m249.mdl", 5750, 1, 2, 1, 5, 1, 1, 1, 2, true }, { WEAPON_SHIELD, "weapon_shield", "shield.mdl", 2200, 0, 1, 1, 8, -1, 8, 8, 0, false },
{WEAPON_SHIELD, "weapon_shield", "shield.mdl", 2200, 0, 1, 1, 8, -1, 8, 8, 0, false}, { 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, false }
{0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, false}
}; };
void SetupBotMenus (void) void setupBotMenus (void) {
{
int counter = 0; int counter = 0;
auto buildKeys = [](int numKeys) {
int keys = 0;
for (int i = 0; i < numKeys; i++) {
keys |= (1 << i);
}
keys |= (1 << 9);
return keys;
};
// bots main menu // bots main menu
g_menus[counter] = g_menus[counter] = {
{ BOT_MENU_MAIN, buildKeys (4),
BOT_MENU_MAIN, 0x2ff, "\\yMain Menu\\w\n\n"
"\\yMain Menu\\w\v\v" "1. Control Bots\n"
"1. Control Bots\v" "2. Features\n\n"
"2. Features\v\v" "3. Fill Server\n"
"3. Fill Server\v" "4. End Round\n\n"
"4. End Round\v\v"
"0. Exit" "0. Exit"
}; };
// bots features menu // bots features menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_FEATURES, buildKeys (5),
BOT_MENU_FEATURES, 0x25f, "\\yBots Features\\w\n\n"
"\\yBots Features\\w\v\v" "1. Weapon Mode Menu\n"
"1. Weapon Mode Menu\v" "2. Waypoint Menu\n"
"2. Waypoint Menu\v" "3. Select Personality\n\n"
"3. Select Personality\v\v" "4. Toggle Debug Mode\n"
"4. Toggle Debug Mode\v" "5. Command Menu\n\n"
"5. Command Menu\v\v"
"0. Exit" "0. Exit"
}; };
// bot control menu // bot control menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_CONTROL, buildKeys (5),
BOT_MENU_CONTROL, 0x2ff, "\\yBots Control Menu\\w\n\n"
"\\yBots Control Menu\\w\v\v" "1. Add a Bot, Quick\n"
"1. Add a Bot, Quick\v" "2. Add a Bot, Specified\n\n"
"2. Add a Bot, Specified\v\v" "3. Remove Random Bot\n"
"3. Remove Random Bot\v" "4. Remove All Bots\n\n"
"4. Remove All Bots\v\v" "5. Remove Bot Menu\n\n"
"5. Remove Bot Menu\v\v"
"0. Exit" "0. Exit"
}; };
// weapon mode select menu // weapon mode select menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WEAPON_MODE, buildKeys (7),
BOT_MENU_WEAPON_MODE, 0x27f, "\\yBots Weapon Mode\\w\n\n"
"\\yBots Weapon Mode\\w\v\v" "1. Knives only\n"
"1. Knives only\v" "2. Pistols only\n"
"2. Pistols only\v" "3. Shotguns only\n"
"3. Shotguns only\v" "4. Machine Guns only\n"
"4. Machine Guns only\v" "5. Rifles only\n"
"5. Rifles only\v" "6. Sniper Weapons only\n"
"6. Sniper Weapons only\v" "7. All Weapons\n\n"
"7. All Weapons\v\v"
"0. Exit" "0. Exit"
}; };
// personality select menu // personality select menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_PERSONALITY, buildKeys (4),
BOT_MENU_PERSONALITY, 0x20f, "\\yBots Personality\\w\n\n"
"\\yBots Personality\\w\v\v" "1. Random\n"
"1. Random\v" "2. Normal\n"
"2. Normal\v" "3. Aggressive\n"
"3. Aggressive\v" "4. Careful\n\n"
"4. Careful\v\v"
"0. Exit" "0. Exit"
}; };
// difficulty select menu // difficulty select menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_DIFFICULTY, buildKeys (5),
BOT_MENU_DIFFICULTY, 0x23f, "\\yBots Difficulty Level\\w\n\n"
"\\yBots Difficulty Level\\w\v\v" "1. Newbie\n"
"1. Newbie\v" "2. Average\n"
"2. Average\v" "3. Normal\n"
"3. Normal\v" "4. Professional\n"
"4. Professional\v" "5. Godlike\n\n"
"5. Godlike\v\v"
"0. Exit" "0. Exit"
}; };
// team select menu // team select menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_TEAM_SELECT, buildKeys (5),
BOT_MENU_TEAM_SELECT, 0x213, "\\ySelect a team\\w\n\n"
"\\ySelect a team\\w\v\v" "1. Terrorist Force\n"
"1. Terrorist Force\v" "2. Counter-Terrorist Force\n\n"
"2. Counter-Terrorist Force\v\v" "5. Auto-select\n\n"
"5. Auto-select\v\v"
"0. Exit" "0. Exit"
}; };
// terrorist model select menu // terrorist model select menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_TERRORIST_SELECT, buildKeys (5),
BOT_MENU_TERRORIST_SELECT, 0x21f, "\\ySelect an appearance\\w\n\n"
"\\ySelect an appearance\\w\v\v" "1. Phoenix Connexion\n"
"1. Phoenix Connexion\v" "2. L337 Krew\n"
"2. L337 Krew\v" "3. Arctic Avengers\n"
"3. Arctic Avengers\v" "4. Guerilla Warfare\n\n"
"4. Guerilla Warfare\v\v" "5. Auto-select\n\n"
"5. Auto-select\v\v"
"0. Exit" "0. Exit"
}; };
// counter-terrorist model select menu // counter-terrorist model select menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_CT_SELECT, buildKeys (5),
BOT_MENU_CT_SELECT, 0x21f, "\\ySelect an appearance\\w\n\n"
"\\ySelect an appearance\\w\v\v" "1. Seal Team 6 (DEVGRU)\n"
"1. Seal Team 6 (DEVGRU)\v" "2. German GSG-9\n"
"2. German GSG-9\v" "3. UK SAS\n"
"3. UK SAS\v" "4. French GIGN\n\n"
"4. French GIGN\v\v" "5. Auto-select\n\n"
"5. Auto-select\v\v"
"0. Exit" "0. Exit"
}; };
// command menu // command menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_COMMANDS, buildKeys (4),
BOT_MENU_COMMANDS, 0x23f, "\\yBot Command Menu\\w\n\n"
"\\yBot Command Menu\\w\v\v" "1. Make Double Jump\n"
"1. Make Double Jump\v" "2. Finish Double Jump\n\n"
"2. Finish Double Jump\v\v" "3. Drop the C4 Bomb\n"
"3. Drop the C4 Bomb\v" "4. Drop the Weapon\n\n"
"4. Drop the Weapon\v\v"
"0. Exit" "0. Exit"
}; };
// main waypoint menu // main waypoint menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_MAIN_PAGE1, buildKeys (9),
BOT_MENU_WAYPOINT_MAIN_PAGE1, 0x3ff, "\\yWaypoint Operations (Page 1)\\w\n\n"
"\\yWaypoint Operations (Page 1)\\w\v\v" "1. Show/Hide waypoints\n"
"1. Show/Hide waypoints\v" "2. Cache waypoint\n"
"2. Cache waypoint\v" "3. Create path\n"
"3. Create path\v" "4. Delete path\n"
"4. Delete path\v" "5. Add waypoint\n"
"5. Add waypoint\v" "6. Delete waypoint\n"
"6. Delete waypoint\v" "7. Set Autopath Distance\n"
"7. Set Autopath Distance\v" "8. Set Radius\n\n"
"8. Set Radius\v\v" "9. Next...\n\n"
"9. Next...\v\v"
"0. Exit" "0. Exit"
}; };
// main waypoint menu (page 2) // main waypoint menu (page 2)
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_MAIN_PAGE2, buildKeys (9),
BOT_MENU_WAYPOINT_MAIN_PAGE2, 0x3ff, "\\yWaypoint Operations (Page 2)\\w\n\n"
"\\yWaypoint Operations (Page 2)\\w\v\v" "1. Waypoint stats\n"
"1. Waypoint stats\v" "2. Autowaypoint on/off\n"
"2. Autowaypoint on/off\v" "3. Set flags\n"
"3. Set flags\v" "4. Save waypoints\n"
"4. Save waypoints\v" "5. Save without checking\n"
"5. Save without checking\v" "6. Load waypoints\n"
"6. Load waypoints\v" "7. Check waypoints\n"
"7. Check waypoints\v" "8. Noclip cheat on/off\n\n"
"8. Noclip cheat on/off\v\v" "9. Previous...\n\n"
"9. Previous...\v\v"
"0. Exit" "0. Exit"
}; };
// select waypoint radius menu // select waypoint radius menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_RADIUS, buildKeys (9),
BOT_MENU_WAYPOINT_RADIUS, 0x3ff, "\\yWaypoint Radius\\w\n\n"
"\\yWaypoint Radius\\w\v\v" "1. SetRadius 0\n"
"1. SetRadius 0\v" "2. SetRadius 8\n"
"2. SetRadius 8\v" "3. SetRadius 16\n"
"3. SetRadius 16\v" "4. SetRadius 32\n"
"4. SetRadius 32\v" "5. SetRadius 48\n"
"5. SetRadius 48\v" "6. SetRadius 64\n"
"6. SetRadius 64\v" "7. SetRadius 80\n"
"7. SetRadius 80\v" "8. SetRadius 96\n"
"8. SetRadius 96\v" "9. SetRadius 128\n\n"
"9. SetRadius 128\v\v"
"0. Exit" "0. Exit"
}; };
// waypoint add menu // waypoint add menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_TYPE, buildKeys (9),
BOT_MENU_WAYPOINT_TYPE, 0x3ff, "\\yWaypoint Type\\w\n\n"
"\\yWaypoint Type\\w\v\v" "1. Normal\n"
"1. Normal\v" "\\r2. Terrorist Important\n"
"\\r2. Terrorist Important\v" "3. Counter-Terrorist Important\n"
"3. Counter-Terrorist Important\v" "\\w4. Block with hostage / Ladder\n"
"\\w4. Block with hostage / Ladder\v" "\\y5. Rescue Zone\n"
"\\y5. Rescue Zone\v" "\\w6. Camping\n"
"\\w6. Camping\v" "7. Camp End\n"
"7. Camp End\v" "\\r8. Map Goal\n"
"\\r8. Map Goal\v" "\\w9. Jump\n\n"
"\\w9. Jump\v\v"
"0. Exit" "0. Exit"
}; };
// set waypoint flag menu // set waypoint flag menu
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_FLAG, buildKeys (5),
BOT_MENU_WAYPOINT_FLAG, 0x2ff, "\\yToggle Waypoint Flags\\w\n\n"
"\\yToggle Waypoint Flags\\w\v\v" "1. Block with Hostage\n"
"1. Block with Hostage\v" "2. Terrorists Specific\n"
"2. Terrorists Specific\v" "3. CTs Specific\n"
"3. CTs Specific\v" "4. Use Elevator\n"
"4. Use Elevator\v" "5. Sniper Point (\\yFor Camp Points Only!\\w)\n\n"
"5. Sniper Point (\\yFor Camp Points Only!\\w)\v\v"
"0. Exit" "0. Exit"
}; };
// auto-path max distance // auto-path max distance
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_AUTOPATH, buildKeys (7),
BOT_MENU_WAYPOINT_AUTOPATH, "\\yAutoPath Distance\\w\n\n"
0x27f, "1. Distance 0\n"
"\\yAutoPath Distance\\w\v\v" "2. Distance 100\n"
"1. Distance 0\v" "3. Distance 130\n"
"2. Distance 100\v" "4. Distance 160\n"
"3. Distance 130\v" "5. Distance 190\n"
"4. Distance 160\v" "6. Distance 220\n"
"5. Distance 190\v" "7. Distance 250 (Default)\n\n"
"6. Distance 220\v"
"7. Distance 250 (Default)\v\v"
"0. Exit" "0. Exit"
}; };
// path connections // path connections
g_menus[++counter] = g_menus[++counter] = {
{ BOT_MENU_WAYPOINT_PATH, buildKeys (3),
BOT_MENU_WAYPOINT_PATH, "\\yCreate Path (Choose Direction)\\w\n\n"
0x207, "1. Outgoing Path\n"
"\\yCreate Path (Choose Direction)\\w\v\v" "2. Incoming Path\n"
"1. Outgoing Path\v" "3. Bidirectional (Both Ways)\n\n"
"2. Incoming Path\v"
"3. Bidirectional (Both Ways)\v\v"
"0. Exit" "0. Exit"
}; };
const String &empty = ""; const String &empty = "";
// kick menus // kick menus
@ -407,4 +376,4 @@ void SetupBotMenus (void)
} }
// bot menus // bot menus
MenuText g_menus[BOT_MENU_TOTAL_MENUS]; MenuText g_menus[BOT_MENU_TOTAL_MENUS];

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff