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:
parent
faa45c6331
commit
5f6a1638d6
32 changed files with 13626 additions and 17110 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -67,3 +67,4 @@ Icon
|
|||
*.json
|
||||
*.html
|
||||
*.settings
|
||||
*.sarif
|
||||
|
|
|
|||
27
.travis.yml
27
.travis.yml
|
|
@ -1,23 +1,32 @@
|
|||
language: cpp
|
||||
dist: trusty
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- lib32stdc++6
|
||||
- lib32z1-dev
|
||||
- libc6-dev-i386
|
||||
- linux-libc-dev
|
||||
- gcc-multilib
|
||||
- g++-multilib
|
||||
language: cpp
|
||||
compiler:
|
||||
- clang
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
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:
|
||||
- cd project && CC=clang && make all
|
||||
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" == "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
|
||||
|
||||
after_success:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||
- 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
|
||||
|
|
|
|||
|
|
@ -4,86 +4,84 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
const int N = 4096, F = 18, THRESHOLD = 2, NIL = N;
|
||||
static constexpr int MAXBUF = 4096, PADDING = 18, THRESHOLD = 2, NIL = MAXBUF;
|
||||
|
||||
class Compressor
|
||||
{
|
||||
class Compress {
|
||||
protected:
|
||||
unsigned long int m_textSize;
|
||||
unsigned long int m_codeSize;
|
||||
unsigned long int m_csize;
|
||||
|
||||
uint8 m_textBuffer[N + F - 1];
|
||||
int m_matchPosition;
|
||||
int m_matchLength;
|
||||
uint8 m_buffer[MAXBUF + PADDING - 1];
|
||||
int m_matchPos;
|
||||
int m_matchLen;
|
||||
|
||||
int m_left[N + 1];
|
||||
int m_right[N + 257];
|
||||
int m_parent[N + 1];
|
||||
int m_left[MAXBUF + 1];
|
||||
int m_right[MAXBUF + 257];
|
||||
int m_parent[MAXBUF + 1];
|
||||
|
||||
private:
|
||||
void InitTree (void)
|
||||
{
|
||||
for (int i = N + 1; i <= N + 256; i++)
|
||||
void initTrees (void) {
|
||||
for (int i = MAXBUF + 1; i <= MAXBUF + 256; i++) {
|
||||
m_right[i] = NIL;
|
||||
|
||||
for (int j = 0; j < N; j++)
|
||||
m_parent[j] = NIL;
|
||||
}
|
||||
|
||||
void InsertNode (int node)
|
||||
{
|
||||
for (int j = 0; j < MAXBUF; j++) {
|
||||
m_parent[j] = NIL;
|
||||
}
|
||||
}
|
||||
|
||||
void insert (int node) {
|
||||
int i;
|
||||
|
||||
int compare = 1;
|
||||
|
||||
uint8 *key = &m_textBuffer[node];
|
||||
int temp = N + 1 + key[0];
|
||||
uint8 *key = &m_buffer[node];
|
||||
int temp = MAXBUF + 1 + key[0];
|
||||
|
||||
m_right[node] = m_left[node] = NIL;
|
||||
m_matchLength = 0;
|
||||
m_matchLen = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (compare >= 0)
|
||||
{
|
||||
if (m_right[temp] != NIL)
|
||||
for (;;) {
|
||||
if (compare >= 0) {
|
||||
if (m_right[temp] != NIL) {
|
||||
temp = m_right[temp];
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
m_right[temp] = node;
|
||||
m_parent[node] = temp;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_left[temp] != NIL)
|
||||
else {
|
||||
if (m_left[temp] != NIL) {
|
||||
temp = m_left[temp];
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
m_left[temp] = node;
|
||||
m_parent[node] = temp;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i < F; i++)
|
||||
if ((compare = key[i] - m_textBuffer[temp + i]) != 0)
|
||||
for (i = 1; i < PADDING; i++) {
|
||||
if ((compare = key[i] - m_buffer[temp + i]) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > m_matchLength)
|
||||
{
|
||||
m_matchPosition = temp;
|
||||
if (i > m_matchLen) {
|
||||
m_matchPos = temp;
|
||||
|
||||
if ((m_matchLength = i) >= F)
|
||||
if ((m_matchLen = i) >= PADDING) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_parent[node] = m_parent[temp];
|
||||
m_left[node] = m_left[temp];
|
||||
|
|
@ -91,37 +89,35 @@ private:
|
|||
m_parent[m_left[temp]] = node;
|
||||
m_parent[m_right[temp]] = node;
|
||||
|
||||
if (m_right[m_parent[temp]] == temp)
|
||||
if (m_right[m_parent[temp]] == temp) {
|
||||
m_right[m_parent[temp]] = node;
|
||||
else
|
||||
}
|
||||
else {
|
||||
m_left[m_parent[temp]] = node;
|
||||
|
||||
}
|
||||
m_parent[temp] = NIL;
|
||||
}
|
||||
|
||||
|
||||
void DeleteNode (int node)
|
||||
{
|
||||
void erase (int node) {
|
||||
int temp;
|
||||
|
||||
if (m_parent[node] == NIL)
|
||||
if (m_parent[node] == NIL) {
|
||||
return; // not in tree
|
||||
}
|
||||
|
||||
if (m_right[node] == NIL)
|
||||
if (m_right[node] == NIL) {
|
||||
temp = m_left[node];
|
||||
|
||||
else if (m_left[node] == NIL)
|
||||
}
|
||||
else if (m_left[node] == NIL) {
|
||||
temp = m_right[node];
|
||||
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
temp = m_left[node];
|
||||
|
||||
if (m_right[temp] != NIL)
|
||||
{
|
||||
do
|
||||
if (m_right[temp] != NIL) {
|
||||
do {
|
||||
temp = m_right[temp];
|
||||
while (m_right[temp] != NIL);
|
||||
} while (m_right[temp] != NIL);
|
||||
|
||||
m_right[m_parent[temp]] = m_left[temp];
|
||||
m_parent[m_left[temp]] = m_parent[temp];
|
||||
|
|
@ -132,240 +128,208 @@ private:
|
|||
m_right[temp] = m_right[node];
|
||||
m_parent[m_right[node]] = temp;
|
||||
}
|
||||
|
||||
m_parent[temp] = m_parent[node];
|
||||
|
||||
if (m_right[m_parent[node]] == node)
|
||||
if (m_right[m_parent[node]] == node) {
|
||||
m_right[m_parent[node]] = temp;
|
||||
else
|
||||
}
|
||||
else {
|
||||
m_left[m_parent[node]] = temp;
|
||||
|
||||
}
|
||||
m_parent[node] = NIL;
|
||||
}
|
||||
|
||||
public:
|
||||
Compressor (void)
|
||||
{
|
||||
m_textSize = 0;
|
||||
m_codeSize = 0;
|
||||
|
||||
m_matchPosition = 0;
|
||||
m_matchLength = 0;
|
||||
|
||||
memset (m_textBuffer, 0, sizeof (m_textBuffer));
|
||||
Compress (void) : m_csize (0), m_matchPos (0), m_matchLen (0) {
|
||||
memset (m_right, 0, sizeof (m_right));
|
||||
memset (m_left, 0, sizeof (m_left));
|
||||
memset (m_parent, 0, sizeof (m_parent));
|
||||
memset (m_buffer, 0, sizeof (m_buffer));
|
||||
}
|
||||
|
||||
~Compressor (void)
|
||||
{
|
||||
m_textSize = 0;
|
||||
m_codeSize = 0;
|
||||
|
||||
m_matchPosition = 0;
|
||||
m_matchLength = 0;
|
||||
|
||||
memset (m_textBuffer, 0, sizeof (m_textBuffer));
|
||||
memset (m_right, 0, sizeof (m_right));
|
||||
memset (m_left, 0, sizeof (m_left));
|
||||
memset (m_parent, 0, sizeof (m_parent));
|
||||
}
|
||||
|
||||
int InternalEncode (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize)
|
||||
{
|
||||
int i, length, node, strPtr, lastMatchLength, codeBufferPtr, bufferPtr = 0;
|
||||
uint8 codeBuffer[17], mask;
|
||||
~Compress (void) = default;
|
||||
|
||||
int encode_ (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) {
|
||||
File fp (fileName, "wb");
|
||||
|
||||
if (!fp.IsValid ())
|
||||
if (!fp.isValid ()) {
|
||||
return -1;
|
||||
}
|
||||
int i, length, node, ptr, last, cbp, bp = 0;
|
||||
uint8 cb[17] = {0, }, mask, bit;
|
||||
|
||||
uint8 bit;
|
||||
fp.write (header, headerSize, 1);
|
||||
initTrees ();
|
||||
|
||||
fp.Write (header, headerSize, 1);
|
||||
InitTree ();
|
||||
cb[0] = 0;
|
||||
cbp = mask = 1;
|
||||
ptr = 0;
|
||||
node = MAXBUF - PADDING;
|
||||
|
||||
codeBuffer[0] = 0;
|
||||
codeBufferPtr = mask = 1;
|
||||
strPtr = 0;
|
||||
node = N - F;
|
||||
for (i = ptr; i < node; i++)
|
||||
m_buffer[i] = ' ';
|
||||
|
||||
for (i = strPtr; i < node; i++)
|
||||
m_textBuffer[i] = ' ';
|
||||
|
||||
for (length = 0; (length < F) && (bufferPtr < bufferSize); length++)
|
||||
{
|
||||
bit = buffer[bufferPtr++];
|
||||
m_textBuffer[node + length] = bit;
|
||||
for (length = 0; (length < PADDING) && (bp < bufferSize); length++) {
|
||||
bit = buffer[bp++];
|
||||
m_buffer[node + length] = bit;
|
||||
}
|
||||
|
||||
if ((m_textSize = length) == 0)
|
||||
if (length == 0) {
|
||||
return -1;
|
||||
|
||||
for (i = 1; i <= F; i++)
|
||||
InsertNode (node - i);
|
||||
InsertNode (node);
|
||||
|
||||
do
|
||||
{
|
||||
if (m_matchLength > length)
|
||||
m_matchLength = length;
|
||||
|
||||
if (m_matchLength <= THRESHOLD)
|
||||
{
|
||||
m_matchLength = 1;
|
||||
codeBuffer[0] |= mask;
|
||||
codeBuffer[codeBufferPtr++] = m_textBuffer[node];
|
||||
}
|
||||
else
|
||||
{
|
||||
codeBuffer[codeBufferPtr++] = (uint8) m_matchPosition;
|
||||
codeBuffer[codeBufferPtr++] = (uint8) (((m_matchPosition >> 4) & 0xf0) | (m_matchLength - (THRESHOLD + 1)));
|
||||
}
|
||||
|
||||
if ((mask <<= 1) == 0)
|
||||
{
|
||||
for (i = 0; i < codeBufferPtr; i++)
|
||||
fp.PutChar (codeBuffer[i]);
|
||||
|
||||
m_codeSize += codeBufferPtr;
|
||||
codeBuffer[0] = 0;
|
||||
codeBufferPtr = mask = 1;
|
||||
for (i = 1; i <= PADDING; i++) {
|
||||
insert (node - i);
|
||||
}
|
||||
lastMatchLength = m_matchLength;
|
||||
insert (node);
|
||||
|
||||
for (i = 0; (i < lastMatchLength) && (bufferPtr < bufferSize); i++)
|
||||
{
|
||||
bit = buffer[bufferPtr++];
|
||||
DeleteNode (strPtr);
|
||||
do {
|
||||
if (m_matchLen > length) {
|
||||
m_matchLen = length;
|
||||
}
|
||||
if (m_matchLen <= THRESHOLD) {
|
||||
m_matchLen = 1;
|
||||
|
||||
m_textBuffer[strPtr] = bit;
|
||||
|
||||
if (strPtr < F - 1)
|
||||
m_textBuffer[strPtr + N] = bit;
|
||||
|
||||
strPtr = (strPtr + 1) & (N - 1);
|
||||
node = (node + 1) & (N - 1);
|
||||
InsertNode (node);
|
||||
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)));
|
||||
}
|
||||
|
||||
while (i++ < lastMatchLength)
|
||||
{
|
||||
DeleteNode (strPtr);
|
||||
if ((mask <<= 1) == 0) {
|
||||
for (i = 0; i < cbp; i++) {
|
||||
fp.putch (cb[i]);
|
||||
}
|
||||
m_csize += cbp;
|
||||
cb[0] = 0;
|
||||
cbp = mask = 1;
|
||||
}
|
||||
last = m_matchLen;
|
||||
|
||||
strPtr = (strPtr + 1) & (N - 1);
|
||||
node = (node + 1) & (N - 1);
|
||||
for (i = 0; (i < last) && (bp < bufferSize); i++) {
|
||||
bit = buffer[bp++];
|
||||
erase (ptr);
|
||||
|
||||
if (length--)
|
||||
InsertNode (node);
|
||||
m_buffer[ptr] = bit;
|
||||
|
||||
if (ptr < PADDING - 1) {
|
||||
m_buffer[ptr + MAXBUF] = bit;
|
||||
}
|
||||
ptr = (ptr + 1) & (MAXBUF - 1);
|
||||
node = (node + 1) & (MAXBUF - 1);
|
||||
insert (node);
|
||||
}
|
||||
|
||||
while (i++ < last) {
|
||||
erase (ptr);
|
||||
|
||||
ptr = (ptr + 1) & (MAXBUF - 1);
|
||||
node = (node + 1) & (MAXBUF - 1);
|
||||
|
||||
if (length--) {
|
||||
insert (node);
|
||||
}
|
||||
}
|
||||
} while (length > 0);
|
||||
|
||||
if (codeBufferPtr > 1)
|
||||
{
|
||||
for (i = 0; i < codeBufferPtr; i++)
|
||||
fp.PutChar (codeBuffer[i]);
|
||||
|
||||
m_codeSize += codeBufferPtr;
|
||||
if (cbp > 1) {
|
||||
for (i = 0; i < cbp; i++) {
|
||||
fp.putch (cb[i]);
|
||||
}
|
||||
fp.Close ();
|
||||
m_csize += cbp;
|
||||
}
|
||||
fp.close ();
|
||||
|
||||
return m_codeSize;
|
||||
return m_csize;
|
||||
}
|
||||
|
||||
int InternalDecode (const char *fileName, int headerSize, uint8 *buffer, int bufferSize)
|
||||
{
|
||||
int decode_ (const char *fileName, int headerSize, uint8 *buffer, int bufferSize) {
|
||||
int i, j, k, node;
|
||||
unsigned int flags;
|
||||
int bufferPtr = 0;
|
||||
int bp = 0;
|
||||
|
||||
uint8 bit;
|
||||
|
||||
File fp (fileName, "rb");
|
||||
|
||||
if (!fp.IsValid ())
|
||||
if (!fp.isValid ()) {
|
||||
return -1;
|
||||
}
|
||||
fp.seek (headerSize, SEEK_SET);
|
||||
|
||||
fp.Seek (headerSize, SEEK_SET);
|
||||
|
||||
node = N - F;
|
||||
for (i = 0; i < node; i++)
|
||||
m_textBuffer[i] = ' ';
|
||||
node = MAXBUF - PADDING;
|
||||
|
||||
for (i = 0; i < node; i++) {
|
||||
m_buffer[i] = ' ';
|
||||
}
|
||||
flags = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (((flags >>= 1) & 256) == 0)
|
||||
{
|
||||
int read = fp.GetChar ();
|
||||
for (;;) {
|
||||
if (((flags >>= 1) & 256) == 0) {
|
||||
int read = fp.getch ();
|
||||
|
||||
if (read == EOF)
|
||||
if (read == EOF) {
|
||||
break;
|
||||
|
||||
}
|
||||
bit = static_cast <uint8> (read);
|
||||
|
||||
flags = bit | 0xff00;
|
||||
}
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
int read = fp.GetChar ();
|
||||
if (flags & 1) {
|
||||
int read = fp.getch ();
|
||||
|
||||
if (read == EOF)
|
||||
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;
|
||||
bit = static_cast <uint8> (read);
|
||||
buffer[bp++] = bit;
|
||||
|
||||
if ((j = fp.GetChar ()) == EOF)
|
||||
if (bp > bufferSize) {
|
||||
return -1;
|
||||
}
|
||||
m_buffer[node++] = bit;
|
||||
node &= (MAXBUF - 1);
|
||||
}
|
||||
else {
|
||||
if ((i = fp.getch ()) == EOF) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((j = fp.getch ()) == EOF) {
|
||||
break;
|
||||
}
|
||||
|
||||
i |= ((j & 0xf0) << 4);
|
||||
j = (j & 0x0f) + THRESHOLD;
|
||||
|
||||
for (k = 0; k <= j; k++)
|
||||
{
|
||||
bit = m_textBuffer[(i + k) & (N - 1)];
|
||||
buffer[bufferPtr++] = bit;
|
||||
for (k = 0; k <= j; k++) {
|
||||
bit = m_buffer[(i + k) & (MAXBUF - 1)];
|
||||
buffer[bp++] = bit;
|
||||
|
||||
if (bufferPtr > bufferSize)
|
||||
if (bp > bufferSize) {
|
||||
return -1;
|
||||
}
|
||||
m_buffer[node++] = bit;
|
||||
node &= (MAXBUF - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
fp.close ();
|
||||
|
||||
m_textBuffer[node++] = bit;
|
||||
node &= (N - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
fp.Close ();
|
||||
|
||||
return bufferPtr;
|
||||
return bp;
|
||||
}
|
||||
|
||||
// external decoder
|
||||
static int Uncompress (const char *fileName, int headerSize, uint8 *buffer, int bufferSize)
|
||||
{
|
||||
static Compressor compressor = Compressor ();
|
||||
return compressor.InternalDecode (fileName, headerSize, buffer, bufferSize);
|
||||
static int decode (const char *fileName, int headerSize, uint8 *buffer, int bufferSize) {
|
||||
static Compress compressor;
|
||||
return compressor.decode_ (fileName, headerSize, buffer, bufferSize);
|
||||
}
|
||||
|
||||
// external encoder
|
||||
static int Compress(const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize)
|
||||
{
|
||||
static Compressor compressor = Compressor ();
|
||||
return compressor.InternalEncode (fileName, header, headerSize, buffer, bufferSize);
|
||||
static int encode (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize) {
|
||||
static Compress compressor;
|
||||
return compressor.encode_ (fileName, header, headerSize, buffer, bufferSize);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
5057
include/corelib.h
5057
include/corelib.h
File diff suppressed because it is too large
Load diff
292
include/engine.h
292
include/engine.h
|
|
@ -4,24 +4,20 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
//
|
||||
// Purpose: Engine & Game interfaces.
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// line draw
|
||||
enum DrawLineType
|
||||
{
|
||||
enum DrawLineType {
|
||||
DRAW_SIMPLE,
|
||||
DRAW_ARROW,
|
||||
DRAW_NUM
|
||||
};
|
||||
|
||||
// trace ignore
|
||||
enum TraceIgnore
|
||||
{
|
||||
enum TraceIgnore {
|
||||
TRACE_IGNORE_NONE = 0,
|
||||
TRACE_IGNORE_GLASS = (1 << 0),
|
||||
TRACE_IGNORE_MONSTERS = (1 << 1),
|
||||
|
|
@ -29,8 +25,7 @@ enum TraceIgnore
|
|||
};
|
||||
|
||||
// variable type
|
||||
enum VarType
|
||||
{
|
||||
enum VarType {
|
||||
VT_NORMAL = 0,
|
||||
VT_READONLY,
|
||||
VT_PASSWORD,
|
||||
|
|
@ -39,8 +34,7 @@ enum VarType
|
|||
};
|
||||
|
||||
// netmessage functions
|
||||
enum NetMsgId
|
||||
{
|
||||
enum NetMsgId {
|
||||
NETMSG_UNDEFINED = -1,
|
||||
NETMSG_VGUI = 1,
|
||||
NETMSG_SHOWMENU = 2,
|
||||
|
|
@ -55,7 +49,7 @@ enum NetMsgId
|
|||
NETMSG_SCREENFADE = 11,
|
||||
NETMSG_HLTV = 12,
|
||||
NETMSG_TEXTMSG = 13,
|
||||
NETMSG_SCOREINFO = 14,
|
||||
NETMSG_TEAMINFO = 14,
|
||||
NETMSG_BARTIME = 15,
|
||||
NETMSG_SENDAUDIO = 17,
|
||||
NETMSG_SAYTEXT = 18,
|
||||
|
|
@ -64,8 +58,7 @@ enum NetMsgId
|
|||
};
|
||||
|
||||
// variable reg pair
|
||||
struct VarPair
|
||||
{
|
||||
struct VarPair {
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
class ConVar *self;
|
||||
|
|
@ -74,25 +67,32 @@ struct VarPair
|
|||
const char *regVal;
|
||||
};
|
||||
|
||||
// translation pair
|
||||
struct TranslatorPair
|
||||
{
|
||||
const char *original;
|
||||
const char *translated;
|
||||
};
|
||||
|
||||
// network message block
|
||||
struct MessageBlock
|
||||
{
|
||||
struct MessageBlock {
|
||||
int bot;
|
||||
int state;
|
||||
int msg;
|
||||
int regMsgs[NETMSG_NUM];
|
||||
};
|
||||
|
||||
// compare language
|
||||
struct LangComprarer {
|
||||
size_t operator () (const String &key) const {
|
||||
char *str = const_cast <char *> (key.chars ());
|
||||
size_t hash = key.length ();
|
||||
|
||||
while (*str++) {
|
||||
if (!isalpha (*str)) {
|
||||
continue;
|
||||
}
|
||||
hash = ((*str << 5) + hash) + *str;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
||||
// provides utility functions to not call original engine (less call-cost)
|
||||
class Engine : public Singleton <Engine>
|
||||
{
|
||||
class Engine : public Singleton <Engine> {
|
||||
private:
|
||||
int m_drawModels[DRAW_NUM];
|
||||
|
||||
|
|
@ -105,217 +105,293 @@ private:
|
|||
edict_t *m_localEntity;
|
||||
|
||||
Array <VarPair> m_cvars;
|
||||
Array <TranslatorPair> m_language;
|
||||
HashMap <String, String, LangComprarer> m_language;
|
||||
|
||||
MessageBlock m_msgBlock;
|
||||
bool m_precached;
|
||||
|
||||
public:
|
||||
Engine (void);
|
||||
|
||||
~Engine (void);
|
||||
|
||||
// public functions
|
||||
public:
|
||||
|
||||
// precaches internal stuff
|
||||
void Precache (edict_t *startEntity);
|
||||
void precache (void);
|
||||
|
||||
// initialize levels
|
||||
void levelInitialize (void);
|
||||
|
||||
// prints data to servers console
|
||||
void Printf (const char *fmt, ...);
|
||||
void print (const char *fmt, ...);
|
||||
|
||||
// prints chat message to all players
|
||||
void ChatPrintf (const char *fmt, ...);
|
||||
void chatPrint (const char *fmt, ...);
|
||||
|
||||
// prints center message to all players
|
||||
void CenterPrintf (const char *fmt, ...);
|
||||
void centerPrint (const char *fmt, ...);
|
||||
|
||||
// prints message to client console
|
||||
void ClientPrintf (edict_t *ent, const char *fmt, ...);
|
||||
void clientPrint (edict_t *ent, const char *fmt, ...);
|
||||
|
||||
// display world line
|
||||
void DrawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life, DrawLineType type = DRAW_SIMPLE);
|
||||
void drawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life, DrawLineType type = DRAW_SIMPLE);
|
||||
|
||||
// test line
|
||||
void TestLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
void testLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
|
||||
// test line
|
||||
void TestHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
void testHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
|
||||
// get's the wave length
|
||||
float GetWaveLength (const char *fileName);
|
||||
float getWaveLen (const char *fileName);
|
||||
|
||||
// we are on dedicated server ?
|
||||
bool IsDedicatedServer (void);
|
||||
bool isDedicated (void);
|
||||
|
||||
// get stripped down mod name
|
||||
const char *GetModName (void);
|
||||
const char *getModName (void);
|
||||
|
||||
// get the valid mapname
|
||||
const char *GetMapName (void);
|
||||
const char *getMapName (void);
|
||||
|
||||
// get the "any" entity origin
|
||||
Vector GetAbsOrigin (edict_t *ent);
|
||||
Vector getAbsPos (edict_t *ent);
|
||||
|
||||
// send server command
|
||||
void IssueCmd (const char *fmt, ...);
|
||||
void execCmd (const char *fmt, ...);
|
||||
|
||||
// registers a server command
|
||||
void RegisterCmd (const char *command, void func (void));
|
||||
void registerCmd (const char *command, void func (void));
|
||||
|
||||
// play's sound to client
|
||||
void EmitSound (edict_t *ent, const char *sound);
|
||||
void playSound (edict_t *ent, const char *sound);
|
||||
|
||||
// sends bot command
|
||||
void IssueBotCommand (edict_t *ent, const char *fmt, ...);
|
||||
void execBotCmd (edict_t *ent, const char *fmt, ...);
|
||||
|
||||
// adds cvar to registration stack
|
||||
void PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, const char *regVal, ConVar *self);
|
||||
void pushVarToRegStack (const char *variable, const char *value, VarType varType, bool regMissing, const char *regVal, ConVar *self);
|
||||
|
||||
// sends local registration stack for engine registration
|
||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||
void pushRegStackToEngine (bool gameVars = false);
|
||||
|
||||
// translates bot message into needed language
|
||||
char *TraslateMessage (const char *input);
|
||||
|
||||
// cleanup translator resources
|
||||
void TerminateTranslator (void);
|
||||
const char *translate (const char *input);
|
||||
|
||||
// do actual network message processing
|
||||
void ProcessMessageCapture (void *ptr);
|
||||
void processMessages (void *ptr);
|
||||
|
||||
// public inlines
|
||||
public:
|
||||
|
||||
// get the current time on server
|
||||
FORCEINLINE float Time (void)
|
||||
{
|
||||
inline float timebase (void) {
|
||||
return g_pGlobals->time;
|
||||
}
|
||||
|
||||
// get "maxplayers" limit on server
|
||||
FORCEINLINE int MaxClients (void)
|
||||
{
|
||||
inline int maxClients (void) {
|
||||
return g_pGlobals->maxClients;
|
||||
}
|
||||
|
||||
// get the fakeclient command interface
|
||||
inline bool IsBotCommand (void)
|
||||
{
|
||||
inline bool isBotCmd (void) {
|
||||
return m_isBotCommand;
|
||||
}
|
||||
|
||||
// gets custom engine args for client command
|
||||
inline const char *GetOverrideArgs (void)
|
||||
{
|
||||
if (strncmp ("say ", m_arguments, 4) == 0)
|
||||
inline const char *botArgs (void) {
|
||||
if (strncmp ("say ", m_arguments, 4) == 0) {
|
||||
return &m_arguments[4];
|
||||
else if (strncmp ("say_team ", m_arguments, 9) == 0)
|
||||
}
|
||||
else if (strncmp ("say_team ", m_arguments, 9) == 0) {
|
||||
return &m_arguments[9];
|
||||
|
||||
}
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
// gets custom engine argv for client command
|
||||
inline const char *GetOverrideArgv (int num)
|
||||
{
|
||||
return ExtractSingleField (m_arguments, num);
|
||||
inline const char *botArgv (int num) {
|
||||
return getField (m_arguments, static_cast <size_t> (num));
|
||||
}
|
||||
|
||||
// gets custom engine argc for client command
|
||||
inline int GetOverrideArgc (void)
|
||||
{
|
||||
inline int botArgc (void) {
|
||||
return m_argumentCount;
|
||||
}
|
||||
|
||||
// gets edict pointer out of entity index
|
||||
FORCEINLINE edict_t *EntityOfIndex (const int index)
|
||||
{
|
||||
inline edict_t *entityOfIndex (const int index) {
|
||||
return static_cast <edict_t *> (m_startEntity + index);
|
||||
};
|
||||
|
||||
// gets edict index out of it's pointer
|
||||
FORCEINLINE int IndexOfEntity (const edict_t *ent)
|
||||
{
|
||||
inline int indexOfEntity (const edict_t *ent) {
|
||||
return static_cast <int> (ent - m_startEntity);
|
||||
};
|
||||
|
||||
// verify entity isn't null
|
||||
FORCEINLINE bool IsNullEntity (const edict_t *ent)
|
||||
{
|
||||
return !ent || !IndexOfEntity (ent);
|
||||
inline bool isNullEntity (const edict_t *ent) {
|
||||
return !ent || !indexOfEntity (ent) || ent->free;
|
||||
}
|
||||
|
||||
// get the wroldspawn entity
|
||||
inline edict_t *getStartEntity (void) {
|
||||
return m_startEntity;
|
||||
}
|
||||
|
||||
// gets the player team
|
||||
FORCEINLINE int GetTeam (edict_t *ent)
|
||||
{
|
||||
inline int getTeam (edict_t *ent) {
|
||||
extern Client g_clients[MAX_ENGINE_PLAYERS];
|
||||
return g_clients[IndexOfEntity (ent) - 1].team;
|
||||
return g_clients[indexOfEntity (ent) - 1].team;
|
||||
}
|
||||
|
||||
// adds translation pair from config
|
||||
inline void PushTranslationPair (const TranslatorPair &lang)
|
||||
{
|
||||
m_language.Push (lang);
|
||||
inline void addTranslation (const String &original, const String &translated) {
|
||||
m_language.put (original, translated);
|
||||
}
|
||||
|
||||
// resets the message capture mechanism
|
||||
inline void ResetMessageCapture (void)
|
||||
{
|
||||
inline void resetMessages (void) {
|
||||
m_msgBlock.msg = NETMSG_UNDEFINED;
|
||||
m_msgBlock.state = 0;
|
||||
m_msgBlock.bot = 0;
|
||||
};
|
||||
|
||||
// sets the currently executed message
|
||||
inline void SetOngoingMessageId (int message)
|
||||
{
|
||||
inline void setCurrentMessageId (int message) {
|
||||
m_msgBlock.msg = message;
|
||||
}
|
||||
|
||||
// set the bot entity that receive this message
|
||||
inline void SetOngoingMessageReceiver (int id)
|
||||
{
|
||||
inline void setCurrentMessageOwner (int id) {
|
||||
m_msgBlock.bot = id;
|
||||
}
|
||||
|
||||
// find registered message id
|
||||
FORCEINLINE int FindMessageId (int type)
|
||||
{
|
||||
inline int getMessageId (int type) {
|
||||
return m_msgBlock.regMsgs[type];
|
||||
}
|
||||
|
||||
// assigns message id for message type
|
||||
inline void AssignMessageId (int type, int id)
|
||||
{
|
||||
inline void setMessageId (int type, int id) {
|
||||
m_msgBlock.regMsgs[type] = id;
|
||||
}
|
||||
|
||||
// tries to set needed message id
|
||||
FORCEINLINE void TryCaptureMessage (int type, int msgId)
|
||||
{
|
||||
if (type == m_msgBlock.regMsgs[msgId])
|
||||
SetOngoingMessageId (msgId);
|
||||
inline void captureMessage (int type, int msgId) {
|
||||
if (type == m_msgBlock.regMsgs[msgId]) {
|
||||
setCurrentMessageId (msgId);
|
||||
}
|
||||
}
|
||||
|
||||
// sets the precache to uninitialize
|
||||
inline void setUnprecached (void) {
|
||||
m_precached = false;
|
||||
}
|
||||
|
||||
// static utility functions
|
||||
private:
|
||||
const char *ExtractSingleField (const char *string, int id);
|
||||
const char *getField (const char *string, size_t id);
|
||||
};
|
||||
|
||||
// simplify access for console variables
|
||||
class ConVar
|
||||
{
|
||||
class ConVar {
|
||||
public:
|
||||
cvar_t *m_eptr;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false, const char *regVal = nullptr);
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false, const char *regVal = nullptr) : m_eptr (nullptr) {
|
||||
Engine::ref ().pushVarToRegStack (name, initval, type, regMissing, regVal, this);
|
||||
}
|
||||
|
||||
FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; }
|
||||
FORCEINLINE int GetInt (void) { return static_cast <int> (m_eptr->value); }
|
||||
FORCEINLINE float GetFloat (void) { return m_eptr->value; }
|
||||
FORCEINLINE const char *GetString (void) { return m_eptr->string; }
|
||||
FORCEINLINE void SetFloat (float val) { g_engfuncs.pfnCVarSetFloat (m_eptr->name, val); }
|
||||
FORCEINLINE void SetInt (int val) { SetFloat (static_cast <float> (val)); }
|
||||
FORCEINLINE void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); }
|
||||
inline bool boolean (void) const {
|
||||
return m_eptr->value > 0.0f;
|
||||
}
|
||||
|
||||
inline int integer (void) const {
|
||||
return static_cast <int> (m_eptr->value);
|
||||
}
|
||||
|
||||
inline float flt (void) const {
|
||||
return m_eptr->value;
|
||||
}
|
||||
|
||||
inline const char *str (void) const {
|
||||
return m_eptr->string;
|
||||
}
|
||||
|
||||
inline void set (float val) const {
|
||||
g_engfuncs.pfnCVarSetFloat (m_eptr->name, val);
|
||||
}
|
||||
|
||||
inline void set (int val) const {
|
||||
set (static_cast <float> (val));
|
||||
}
|
||||
|
||||
inline void set (const char *val) const {
|
||||
g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val));
|
||||
}
|
||||
};
|
||||
|
||||
class MessageWriter {
|
||||
private:
|
||||
bool m_autoDestruct { false };
|
||||
|
||||
public:
|
||||
MessageWriter (void) = default;
|
||||
|
||||
MessageWriter (int dest, int type, const Vector &pos = Vector::null (), edict_t *to = nullptr) {
|
||||
start (dest, type, pos, to);
|
||||
m_autoDestruct = true;
|
||||
}
|
||||
|
||||
virtual ~MessageWriter (void) {
|
||||
if (m_autoDestruct) {
|
||||
end ();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
MessageWriter &start (int dest, int type, const Vector &pos = Vector::null (), edict_t *to = nullptr) {
|
||||
g_engfuncs.pfnMessageBegin (dest, type, pos, to);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void end (void) {
|
||||
g_engfuncs.pfnMessageEnd ();
|
||||
}
|
||||
|
||||
MessageWriter &writeByte (int val) {
|
||||
g_engfuncs.pfnWriteByte (val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessageWriter &writeChar (int val) {
|
||||
g_engfuncs.pfnWriteChar (val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessageWriter &writeShort (int val) {
|
||||
g_engfuncs.pfnWriteShort (val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessageWriter &writeCoord (float val) {
|
||||
g_engfuncs.pfnWriteCoord (val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessageWriter &writeString (const char *val) {
|
||||
g_engfuncs.pfnWriteString (val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
static inline uint16 fu16 (float value, float scale) {
|
||||
return cr::clamp <uint16> (static_cast <uint16> (value * scale), 0, 0xffff);
|
||||
}
|
||||
|
||||
static inline short fs16 (float value, float scale) {
|
||||
return cr::clamp <short> (static_cast <short> (value * scale), -32767, 32767);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
#ifndef CONST_H
|
||||
#define CONST_H
|
||||
//
|
||||
|
|
@ -155,7 +155,6 @@
|
|||
#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound
|
||||
#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles
|
||||
|
||||
|
||||
#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound
|
||||
// coord coord coord (position)
|
||||
|
||||
|
|
@ -333,8 +332,8 @@
|
|||
// short 1.2.13 x (-1 = center)
|
||||
// short 1.2.13 y (-1 = center)
|
||||
// byte Effect 0 = fade in/fade out
|
||||
// 1 is flickery credits
|
||||
// 2 is write out (training room)
|
||||
// 1 is flickery credits
|
||||
// 2 is write out (training room)
|
||||
|
||||
// 4 bytes r,g,b,a color1 (text color)
|
||||
// 4 bytes r,g,b,a color2 (effect color)
|
||||
|
|
@ -556,8 +555,6 @@
|
|||
// byte ( color ) this is an index into an array of color vectors in the engine. (0 - )
|
||||
// byte ( length * 10 )
|
||||
|
||||
|
||||
|
||||
#define MSG_BROADCAST 0 // unreliable to all
|
||||
#define MSG_ONE 1 // reliable to one (msg_entity)
|
||||
#define MSG_ALL 2 // reliable to all
|
||||
|
|
@ -671,8 +668,7 @@
|
|||
#define TE_BOUNCE_SHOTSHELL 2
|
||||
|
||||
// Rendering constants
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
kRenderNormal, // src
|
||||
kRenderTransColor, // c*a+dest*(1-a)
|
||||
kRenderTransTexture, // src*a+dest*(1-a)
|
||||
|
|
@ -681,8 +677,7 @@ enum
|
|||
kRenderTransAdd // src*a+dest
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
kRenderFxNone = 0,
|
||||
kRenderFxPulseSlow,
|
||||
kRenderFxPulseFast,
|
||||
|
|
@ -706,25 +701,21 @@ enum
|
|||
kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!)
|
||||
};
|
||||
|
||||
|
||||
typedef int func_t;
|
||||
typedef int string_t;
|
||||
|
||||
typedef struct link_s
|
||||
{
|
||||
typedef struct link_s {
|
||||
struct link_s *prev, *next;
|
||||
} link_t;
|
||||
|
||||
typedef struct edict_s edict_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
} plane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int allsolid; // if true, plane is not valid
|
||||
int startsolid; // if true, the initial point was in a solid area
|
||||
int inopen, inwater;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
#ifndef EIFACE_H
|
||||
#define EIFACE_H
|
||||
|
||||
|
|
@ -29,8 +29,7 @@
|
|||
#define FCVAR_PRINTABLEONLY (1 << 7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
|
||||
#define FCVAR_UNLOGGED (1 << 8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
|
||||
|
||||
struct cvar_t
|
||||
{
|
||||
struct cvar_t {
|
||||
char *name;
|
||||
char *string;
|
||||
int flags;
|
||||
|
|
@ -53,8 +52,7 @@ struct cvar_t
|
|||
#define DLLEXPORT /* */
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
at_notice,
|
||||
at_console, // same as at_notice, but forces a ConPrintf, not a message box
|
||||
at_aiconsole, // same as at_console, but only shown if developer level is 2!
|
||||
|
|
@ -64,24 +62,17 @@ typedef enum
|
|||
} ALERT_TYPE;
|
||||
|
||||
// 4-22-98 JOHN: added for use in pfnClientPrintf
|
||||
typedef enum
|
||||
{
|
||||
print_console,
|
||||
print_center,
|
||||
print_chat
|
||||
} PRINT_TYPE;
|
||||
typedef enum { print_console, print_center, print_chat } PRINT_TYPE;
|
||||
|
||||
// For integrity checking of content on clients
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
force_exactfile, // File on client must exactly match server's file
|
||||
force_model_samebounds, // For model files only, the geometry must fit in the same bbox
|
||||
force_model_specifybounds // For model files only, the geometry must fit in the specified bbox
|
||||
} FORCE_TYPE;
|
||||
|
||||
// Returned by TraceLine
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int fAllSolid; // if true, plane is not valid
|
||||
int fStartSolid; // if true, the initial point was in a solid area
|
||||
int fInOpen;
|
||||
|
|
@ -98,8 +89,7 @@ typedef uint32 CRC32_t;
|
|||
|
||||
// Engine hands this to DLLs for functionality callbacks
|
||||
|
||||
typedef struct enginefuncs_s
|
||||
{
|
||||
typedef struct enginefuncs_s {
|
||||
int (*pfnPrecacheModel) (char *s);
|
||||
int (*pfnPrecacheSound) (char *s);
|
||||
void (*pfnSetModel) (edict_t *e, const char *m);
|
||||
|
|
@ -167,7 +157,7 @@ typedef struct enginefuncs_s
|
|||
void *(*pfnPvEntPrivateData) (edict_t *ent);
|
||||
void (*pfnFreeEntPrivateData) (edict_t *ent);
|
||||
const char *(*pfnSzFromIndex) (int stingPtr);
|
||||
int (*pfnAllostring) (const char *szValue);
|
||||
int (*pfnAllocString) (const char *szValue);
|
||||
struct entvars_s *(*pfnGetVarsOfEnt) (edict_t *ent);
|
||||
edict_t *(*pfnPEntityOfEntOffset) (int iEntOffset);
|
||||
int (*pfnEntOffsetOfPEntity) (const edict_t *ent);
|
||||
|
|
@ -264,25 +254,21 @@ typedef struct enginefuncs_s
|
|||
|
||||
void (*pfnQueryClientCVarValue) (const edict_t *player, const char *cvarName);
|
||||
void (*pfnQueryClientCVarValue2) (const edict_t *player, const char *cvarName, int requestID);
|
||||
int (*pfnCheckParm)(const char *pchCmdLineToken, char **ppnext);
|
||||
int (*pfnCheckParm) (const char *pchCmdLineToken, char **ppnext);
|
||||
|
||||
} enginefuncs_t;
|
||||
|
||||
// Passed to pfnKeyValue
|
||||
typedef struct KeyValueData_s
|
||||
{
|
||||
typedef struct KeyValueData_s {
|
||||
char *szClassName; // in: entity classname
|
||||
char const *szKeyName; // in: name of key
|
||||
char *szValue; // in: value of key
|
||||
int32 fHandled; // out: DLL sets to true if key-value pair was understood
|
||||
} KeyValueData;
|
||||
|
||||
|
||||
#define ARRAYSIZE_HLSDK(p) (int) (sizeof(p)/sizeof(p[0]))
|
||||
typedef struct customization_s customization_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
// Initialize/shutdown the game (one-time call after loading of game .dll )
|
||||
void (*pfnGameInit) (void);
|
||||
int (*pfnSpawn) (edict_t *pent);
|
||||
|
|
@ -340,7 +326,7 @@ typedef struct
|
|||
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, uint8 **pvs, uint8 **pas);
|
||||
void (*pfnUpdateClientData) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
|
||||
int (*pfnAddToFullPack) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, uint8 *pSet);
|
||||
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, float* player_mins, float* player_maxs);
|
||||
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, float *player_mins, float *player_maxs);
|
||||
void (*pfnRegisterEncoders) (void);
|
||||
int (*pfnGetWeaponData) (struct edict_s *player, struct weapon_data_s *info);
|
||||
|
||||
|
|
@ -371,8 +357,7 @@ typedef struct
|
|||
// Current version.
|
||||
#define NEWGAMEDLLFUNCS_VERSION 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
// Called right before the object's memory is freed.
|
||||
// Calls its destructor.
|
||||
void (*pfnOnFreeEntPrivateData) (edict_t *pEnt);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef EXTDLL_H
|
||||
#define EXTDLL_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* disable deprecation warnings concerning unsafe CRT functions */
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
#endif
|
||||
/* disable deprecation warnings concerning unsafe CRT functions */
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
@ -39,17 +39,16 @@
|
|||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define _vsnprintf(a, b, c, d) vsnprintf (a, b, c, d)
|
||||
#endif
|
||||
#endif //_WIN32
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
typedef int func_t; //
|
||||
typedef int string_t; // from engine's pr_comp.h;
|
||||
|
|
@ -57,15 +56,15 @@ typedef float vec_t; // needed before including progdefs.h
|
|||
|
||||
#include "corelib.h"
|
||||
|
||||
#define vec3_t Vector
|
||||
typedef cr::classes::Vector vec3_t;
|
||||
using namespace cr::types;
|
||||
|
||||
#include "const.h"
|
||||
#include "progdefs.h"
|
||||
|
||||
#define MAX_ENT_LEAFS 48
|
||||
|
||||
struct edict_s
|
||||
{
|
||||
struct edict_s {
|
||||
int free;
|
||||
int serialnumber;
|
||||
link_t area; // linked to a division node or leaf
|
||||
|
|
@ -84,10 +83,10 @@ struct edict_s
|
|||
|
||||
#define MAX_ITEMS 5 // hard coded item types
|
||||
|
||||
#define HIDEHUD_WEAPONS ( 1 << 0 )
|
||||
#define HIDEHUD_FLASHLIGHT ( 1 << 1 )
|
||||
#define HIDEHUD_ALL ( 1 << 2 )
|
||||
#define HIDEHUD_HEALTH ( 1 << 3 )
|
||||
#define HIDEHUD_WEAPONS (1 << 0)
|
||||
#define HIDEHUD_FLASHLIGHT (1 << 1)
|
||||
#define HIDEHUD_ALL (1 << 2)
|
||||
#define HIDEHUD_HEALTH (1 << 3)
|
||||
|
||||
#define MAX_AMMO_TYPES 32 // ???
|
||||
#define MAX_AMMO_SLOTS 32 // not really slots
|
||||
|
|
@ -98,6 +97,5 @@ struct edict_s
|
|||
#define HUD_PRINTCENTER 4
|
||||
|
||||
#define WEAPON_SUIT 31
|
||||
#define __USE_GNU 1
|
||||
|
||||
#endif //EXTDLL_H
|
||||
#endif // EXTDLL_H
|
||||
|
|
|
|||
|
|
@ -15,18 +15,9 @@ typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int
|
|||
|
||||
#define META_INTERFACE_VERSION "5:13"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PT_NEVER = 0,
|
||||
PT_STARTUP,
|
||||
PT_CHANGELEVEL,
|
||||
PT_ANYTIME,
|
||||
PT_ANYPAUSE
|
||||
} PLUG_LOADTIME;
|
||||
typedef enum { PT_NEVER = 0, PT_STARTUP, PT_CHANGELEVEL, PT_ANYTIME, PT_ANYPAUSE } PLUG_LOADTIME;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
char const *ifvers;
|
||||
char const *name;
|
||||
char const *version;
|
||||
|
|
@ -43,31 +34,11 @@ typedef plugin_info_t *plid_t;
|
|||
|
||||
#define PLID &Plugin_info
|
||||
|
||||
typedef enum { PNL_NULL = 0, PNL_INI_DELETED, PNL_FILE_NEWER, PNL_COMMAND, PNL_CMD_FORCED, PNL_DELAYED, PNL_PLUGIN, PNL_PLG_FORCED, PNL_RELOAD } PL_UNLOAD_REASON;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PNL_NULL = 0,
|
||||
PNL_INI_DELETED,
|
||||
PNL_FILE_NEWER,
|
||||
PNL_COMMAND,
|
||||
PNL_CMD_FORCED,
|
||||
PNL_DELAYED,
|
||||
PNL_PLUGIN,
|
||||
PNL_PLG_FORCED,
|
||||
PNL_RELOAD
|
||||
} PL_UNLOAD_REASON;
|
||||
typedef enum { MRES_UNSET = 0, MRES_IGNORED, MRES_HANDLED, MRES_OVERRIDE, MRES_SUPERCEDE } META_RES;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MRES_UNSET = 0,
|
||||
MRES_IGNORED,
|
||||
MRES_HANDLED,
|
||||
MRES_OVERRIDE,
|
||||
MRES_SUPERCEDE
|
||||
} META_RES;
|
||||
|
||||
typedef struct meta_globals_s
|
||||
{
|
||||
typedef struct meta_globals_s {
|
||||
META_RES mres;
|
||||
META_RES prev_mres;
|
||||
META_RES status;
|
||||
|
|
@ -77,16 +48,23 @@ typedef struct meta_globals_s
|
|||
|
||||
extern meta_globals_t *gpMetaGlobals;
|
||||
|
||||
#define SET_META_RESULT(result) gpMetaGlobals->mres=result
|
||||
#define RETURN_META(result) { gpMetaGlobals->mres=result; return; }
|
||||
#define RETURN_META_VALUE(result, value) { gpMetaGlobals->mres=result; return(value); }
|
||||
#define SET_META_RESULT(result) gpMetaGlobals->mres = result
|
||||
#define RETURN_META(result) \
|
||||
{ \
|
||||
gpMetaGlobals->mres = result; \
|
||||
return; \
|
||||
}
|
||||
#define RETURN_META_VALUE(result, value) \
|
||||
{ \
|
||||
gpMetaGlobals->mres = result; \
|
||||
return (value); \
|
||||
}
|
||||
#define META_RESULT_STATUS gpMetaGlobals->status
|
||||
#define META_RESULT_PREVIOUS gpMetaGlobals->prev_mres
|
||||
#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret
|
||||
#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
GETENTITYAPI_FN pfnGetEntityAPI;
|
||||
GETENTITYAPI_FN pfnGetEntityAPI_Post;
|
||||
GETENTITYAPI2_FN pfnGetEntityAPI2;
|
||||
|
|
@ -103,19 +81,10 @@ typedef struct
|
|||
#define MAX_LOGMSG_LEN 1024
|
||||
|
||||
// for getgameinfo:
|
||||
typedef enum
|
||||
{
|
||||
GINFO_NAME = 0,
|
||||
GINFO_DESC,
|
||||
GINFO_GAMEDIR,
|
||||
GINFO_DLL_FULLPATH,
|
||||
GINFO_DLL_FILENAME,
|
||||
GINFO_REALDLL_FULLPATH
|
||||
} ginfo_t;
|
||||
typedef enum { GINFO_NAME = 0, GINFO_DESC, GINFO_GAMEDIR, GINFO_DLL_FULLPATH, GINFO_DLL_FILENAME, GINFO_REALDLL_FULLPATH } ginfo_t;
|
||||
|
||||
// Meta Utility Function table type.
|
||||
typedef struct meta_util_funcs_s
|
||||
{
|
||||
typedef struct meta_util_funcs_s {
|
||||
void (*pfnLogConsole) (plid_t plid, const char *szFormat, ...);
|
||||
void (*pfnLogMessage) (plid_t plid, const char *szFormat, ...);
|
||||
void (*pfnLogError) (plid_t plid, const char *szFormat, ...);
|
||||
|
|
@ -136,9 +105,7 @@ typedef struct meta_util_funcs_s
|
|||
void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, gamefuncs_t **pdll, newgamefuncs_t **pnewdll);
|
||||
} mutil_funcs_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
gamefuncs_t *dllapi_table;
|
||||
newgamefuncs_t *newapi_table;
|
||||
} gamedll_funcs_t;
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
#ifndef PROGDEFS_H
|
||||
#define PROGDEFS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
float time;
|
||||
float frametime;
|
||||
float force_retouch;
|
||||
|
|
@ -53,9 +52,7 @@ typedef struct
|
|||
vec3_t vecLandmarkOffset;
|
||||
} globalvars_t;
|
||||
|
||||
|
||||
typedef struct entvars_s
|
||||
{
|
||||
typedef struct entvars_s {
|
||||
string_t classname;
|
||||
string_t globalname;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,85 +1,38 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
*
|
||||
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This source code contains proprietary and confidential information of
|
||||
* Valve LLC and its suppliers. Access to this code is restricted to
|
||||
* persons who have executed a written SDK license with Valve. Any access,
|
||||
* use or distribution of this code by or to any unlicensed person is illegal.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef SDKUTIL_H
|
||||
#define SDKUTIL_H
|
||||
|
||||
#ifndef ENGINECALLBACK_H
|
||||
#include "enginecallback.h"
|
||||
#endif
|
||||
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent); // implementation later in this file
|
||||
|
||||
extern globalvars_t *g_pGlobals;
|
||||
|
||||
#define DLL_GLOBAL
|
||||
|
||||
extern DLL_GLOBAL const Vector g_vZero;
|
||||
extern enginefuncs_t g_engfuncs;
|
||||
|
||||
// Use this instead of ALLOC_STRING on constant strings
|
||||
#define STRING(offset) (const char *)(g_pGlobals->pStringBase + (int)offset)
|
||||
#define MAKE_STRING(str) ((int)str - (int)STRING(0))
|
||||
#define ENGINE_STR(str) (const_cast <char *> (STRING (ALLOC_STRING (str))))
|
||||
|
||||
static inline edict_t *FIND_ENTITY_BY_CLASSNAME (edict_t *entStart, const char *pszName)
|
||||
{
|
||||
return FIND_ENTITY_BY_STRING (entStart, "classname", pszName);
|
||||
// form fwgs-hlsdk
|
||||
static inline int MAKE_STRING (const char *val) {
|
||||
long long ptrdiff = val - STRING (0);
|
||||
|
||||
if (ptrdiff > INT_MAX || ptrdiff < INT_MIN) {
|
||||
return g_engfuncs.pfnAllocString (val);
|
||||
}
|
||||
return static_cast <int> (ptrdiff);
|
||||
}
|
||||
|
||||
static inline edict_t *FIND_ENTITY_BY_TARGETNAME (edict_t *entStart, const char *pszName)
|
||||
{
|
||||
return FIND_ENTITY_BY_STRING (entStart, "targetname", pszName);
|
||||
}
|
||||
|
||||
// for doing a reverse lookup. Say you have a door, and want to find its button.
|
||||
static inline edict_t *FIND_ENTITY_BY_TARGET (edict_t *entStart, const char *pszName)
|
||||
{
|
||||
return FIND_ENTITY_BY_STRING (entStart, "target", pszName);
|
||||
}
|
||||
|
||||
// Keeps clutter down a bit, when using a float as a bit-Vector
|
||||
#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
|
||||
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
|
||||
|
||||
// Makes these more explicit, and easier to find
|
||||
#define FILE_GLOBAL static
|
||||
|
||||
// Until we figure out why "const" gives the compiler problems, we'll just have to use
|
||||
// this bogus "empty" define to mark things as constant.
|
||||
#define CONSTANT
|
||||
|
||||
// More explicit than "int"
|
||||
typedef int EOFFSET;
|
||||
|
||||
// In case it's not alread defined
|
||||
#ifndef BOOL
|
||||
typedef int BOOL;
|
||||
#endif
|
||||
|
||||
// In case this ever changes
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926
|
||||
#endif
|
||||
|
||||
short FixedSigned16 (float value, float scale);
|
||||
uint16 FixedUnsigned16 (float value, float scale);
|
||||
|
||||
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent)
|
||||
{
|
||||
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ent->pContainingEntity);
|
||||
}
|
||||
#define ENGINE_STR(str) (const_cast <char *> (STRING (g_engfuncs.pfnAllocString (str))))
|
||||
|
||||
// Dot products for view cone checking
|
||||
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
|
||||
|
|
@ -87,31 +40,11 @@ static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrig
|
|||
#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks
|
||||
#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks
|
||||
|
||||
// Misc useful
|
||||
static inline BOOL FStrEq (const char *sz1, const char *sz2)
|
||||
{
|
||||
return (strcmp (sz1, sz2) == 0);
|
||||
}
|
||||
static inline BOOL FClassnameIs (edict_t *pent, const char *szClassname)
|
||||
{
|
||||
return FStrEq (STRING (pent->v.classname), szClassname);
|
||||
}
|
||||
static inline BOOL FClassnameIs (entvars_t *pev, const char *szClassname)
|
||||
{
|
||||
return FStrEq (STRING (pev->classname), szClassname);
|
||||
}
|
||||
typedef enum { ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS;
|
||||
typedef enum { ignore_glass = 1, dont_ignore_glass = 0 } IGNORE_GLASS;
|
||||
typedef enum { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 } HULL;
|
||||
|
||||
typedef enum
|
||||
{ ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS;
|
||||
typedef enum
|
||||
{ ignore_glass = 1, dont_ignore_glass = 0 } IGNORE_GLASS;
|
||||
typedef enum
|
||||
{ point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 } HULL;
|
||||
typedef int (*tMenuCallback) (edict_t *, int);
|
||||
|
||||
|
||||
typedef struct hudtextparms_s
|
||||
{
|
||||
typedef struct hudtextparms_s {
|
||||
float x;
|
||||
float y;
|
||||
int effect;
|
||||
|
|
@ -124,7 +57,6 @@ typedef struct hudtextparms_s
|
|||
int channel;
|
||||
} hudtextparms_t;
|
||||
|
||||
|
||||
#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation
|
||||
#define AMBIENT_SOUND_EVERYWHERE 1
|
||||
#define AMBIENT_SOUND_SMALLRADIUS 2
|
||||
|
|
@ -160,17 +92,17 @@ typedef struct hudtextparms_s
|
|||
#define PUSH_BLOCK_ONLY_X 1
|
||||
#define PUSH_BLOCK_ONLY_Y 2
|
||||
|
||||
#define VEC_HULL_MIN Vector(-16, -16, -36)
|
||||
#define VEC_HULL_MAX Vector( 16, 16, 36)
|
||||
#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 )
|
||||
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 )
|
||||
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 )
|
||||
#define VEC_HULL_MIN Vector (-16, -16, -36)
|
||||
#define VEC_HULL_MAX Vector (16, 16, 36)
|
||||
#define VEC_HUMAN_HULL_MIN Vector (-16, -16, 0)
|
||||
#define VEC_HUMAN_HULL_MAX Vector (16, 16, 72)
|
||||
#define VEC_HUMAN_HULL_DUCK Vector (16, 16, 36)
|
||||
|
||||
#define VEC_VIEW Vector( 0, 0, 28 )
|
||||
#define VEC_VIEW Vector (0, 0, 28)
|
||||
|
||||
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 )
|
||||
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
|
||||
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
|
||||
#define VEC_DUCK_HULL_MIN Vector (-16, -16, -18)
|
||||
#define VEC_DUCK_HULL_MAX Vector (16, 16, 18)
|
||||
#define VEC_DUCK_VIEW Vector (0, 0, 12)
|
||||
|
||||
#define SVC_TEMPENTITY 23
|
||||
#define SVC_CENTERPRINT 26
|
||||
|
|
@ -207,41 +139,5 @@ typedef struct hudtextparms_s
|
|||
|
||||
#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
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
|
@ -27,10 +27,9 @@ extern float g_timeRoundEnd;
|
|||
extern float g_timeRoundMid;
|
||||
extern float g_timeRoundStart;
|
||||
extern float g_timePerSecondUpdate;
|
||||
extern float g_lastRadioTime[2];
|
||||
extern float g_lastRadioTime[MAX_TEAM_COUNT];
|
||||
|
||||
extern int g_mapType;
|
||||
extern int g_numWaypoints;
|
||||
extern int g_mapFlags;
|
||||
extern int g_gameFlags;
|
||||
|
||||
extern int g_highestDamageCT;
|
||||
|
|
@ -43,22 +42,21 @@ extern int g_carefulWeaponPrefs[NUM_WEAPONS];
|
|||
extern int g_grenadeBuyPrecent[NUM_WEAPONS - 23];
|
||||
extern int g_botBuyEconomyTable[NUM_WEAPONS - 15];
|
||||
extern int g_radioSelect[MAX_ENGINE_PLAYERS];
|
||||
extern int g_lastRadio[2];
|
||||
extern int g_lastRadio[MAX_TEAM_COUNT];
|
||||
extern int g_storeAddbotVars[4];
|
||||
extern int *g_weaponPrefs[];
|
||||
|
||||
extern Array <Array <String> > g_chatFactory;
|
||||
extern Array <Array <ChatterItem> > g_chatterFactory;
|
||||
extern Array <BotName> g_botNames;
|
||||
extern Array <KeywordFactory> g_replyFactory;
|
||||
extern RandomSequenceOfUnique Random;
|
||||
extern Array<StringArray> g_chatFactory;
|
||||
extern Array<Array<ChatterItem>> g_chatterFactory;
|
||||
extern Array<BotName> g_botNames;
|
||||
extern Array<KeywordFactory> g_replyFactory;
|
||||
|
||||
extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1];
|
||||
extern WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
|
||||
|
||||
extern Client g_clients[MAX_ENGINE_PLAYERS];
|
||||
extern MenuText g_menus[BOT_MENU_TOTAL_MENUS];
|
||||
extern TaskItem g_taskFilters[];
|
||||
extern Task g_taskFilters[TASK_MAX];
|
||||
|
||||
extern Experience *g_experienceData;
|
||||
|
||||
|
|
@ -67,10 +65,9 @@ extern Library *g_gameLib;
|
|||
|
||||
extern gamefuncs_t g_functionTable;
|
||||
|
||||
static inline bool IsNullString (const char *input)
|
||||
{
|
||||
if (input == nullptr)
|
||||
static inline bool isEmptyStr (const char *input) {
|
||||
if (input == nullptr) {
|
||||
return true;
|
||||
|
||||
}
|
||||
return *input == '\0';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,39 +4,39 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// detects the build platform
|
||||
#if defined (__linux__) || defined (__debian__) || defined (__linux)
|
||||
#define PLATFORM_LINUX 1
|
||||
#elif defined (__APPLE__)
|
||||
#define PLATFORM_OSX 1
|
||||
#elif defined (_WIN32)
|
||||
#define PLATFORM_WIN32 1
|
||||
#if defined(__linux__)
|
||||
#define PLATFORM_LINUX
|
||||
#elif defined(__APPLE__)
|
||||
#define PLATFORM_OSX
|
||||
#elif defined(_WIN32)
|
||||
#define PLATFORM_WIN32
|
||||
#endif
|
||||
|
||||
// by default sse has everyone
|
||||
#define PLATFORM_HAS_SSE2
|
||||
|
||||
// detects the compiler
|
||||
#if defined (_MSC_VER)
|
||||
#define COMPILER_VISUALC _MSC_VER
|
||||
#elif defined (__MINGW32_MAJOR_VERSION)
|
||||
#define COMPILER_MINGW32 __MINGW32_MAJOR_VERSION
|
||||
#if defined(_MSC_VER)
|
||||
#define CXX_MSVC
|
||||
#elif defined(__clang__)
|
||||
#define CXX_CLANG
|
||||
#endif
|
||||
|
||||
// configure export macros
|
||||
#if defined (COMPILER_VISUALC) || defined (COMPILER_MINGW32)
|
||||
#if defined(PLATFORM_WIN32)
|
||||
#define SHARED_LIBRARAY_EXPORT extern "C" __declspec (dllexport)
|
||||
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
|
||||
#define SHARED_LIBRARAY_EXPORT extern "C" __attribute__((visibility("default")))
|
||||
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
|
||||
#define SHARED_LIBRARAY_EXPORT extern "C" __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#error "Can't configure export macros. Compiler unrecognized."
|
||||
#endif
|
||||
|
||||
// enable sse intrinsics
|
||||
#define ENABLE_SSE_INTRINSICS 1
|
||||
|
||||
// operating system specific macros, functions and typedefs
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
|
|
@ -49,108 +49,46 @@
|
|||
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
|
||||
#define DLL_RETENTRY return TRUE
|
||||
|
||||
#if defined (COMPILER_VISUALC)
|
||||
#if defined(CXX_MSVC) && !defined (_M_X64)
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void STD_CALL
|
||||
#elif defined (COMPILER_MINGW32)
|
||||
#elif defined(CXX_CLANG) || defined (_M_X64)
|
||||
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STD_CALL
|
||||
#endif
|
||||
|
||||
// specify export parameter
|
||||
#if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000)
|
||||
#pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
|
||||
#pragma comment (linker, "/SECTION:.data,RW")
|
||||
#if defined(CXX_MSVC) || defined (CXX_CLANG)
|
||||
#if !defined (_M_X64)
|
||||
#pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
|
||||
#endif
|
||||
#pragma comment(linker, "/SECTION:.data,RW")
|
||||
#endif
|
||||
|
||||
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
|
||||
|
||||
#include <unistd.h>
|
||||
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define DLL_ENTRYPOINT __attribute__((destructor)) void _fini (void)
|
||||
#define DLL_ENTRYPOINT __attribute__ ((destructor)) void _fini (void)
|
||||
#define DLL_DETACHING TRUE
|
||||
#define DLL_RETENTRY return
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__ ((visibility ("default")))
|
||||
|
||||
#define STD_CALL /* */
|
||||
|
||||
#if defined (__ANDROID__)
|
||||
#define PLATFORM_ANDROID 1
|
||||
#undef ENABLE_SSE_INTRINSICS
|
||||
// android is a linux with a special cases
|
||||
// @todo: sse should be working ok on x86 android?
|
||||
#if defined(__ANDROID__)
|
||||
#define PLATFORM_ANDROID
|
||||
#undef PLATFORM_HAS_SSE2
|
||||
#endif
|
||||
#else
|
||||
#error "Platform unrecognized."
|
||||
#endif
|
||||
|
||||
// library wrapper
|
||||
class Library
|
||||
{
|
||||
private:
|
||||
void *m_ptr;
|
||||
|
||||
public:
|
||||
|
||||
Library (const char *fileName)
|
||||
{
|
||||
m_ptr = nullptr;
|
||||
|
||||
if (fileName == nullptr)
|
||||
return;
|
||||
|
||||
LoadLib (fileName);
|
||||
}
|
||||
|
||||
~Library (void)
|
||||
{
|
||||
if (!IsLoaded ())
|
||||
return;
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
FreeLibrary ((HMODULE) m_ptr);
|
||||
#else
|
||||
dlclose (m_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
inline void *LoadLib (const char *fileName)
|
||||
{
|
||||
#ifdef PLATFORM_WIN32
|
||||
m_ptr = LoadLibrary (fileName);
|
||||
#else
|
||||
m_ptr = dlopen (fileName, RTLD_NOW);
|
||||
#endif
|
||||
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
template <typename R> R GetFuncAddr (const char *function)
|
||||
{
|
||||
if (!IsLoaded ())
|
||||
return nullptr;
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
return reinterpret_cast <R> (GetProcAddress (static_cast <HMODULE> (m_ptr), function));
|
||||
#else
|
||||
return reinterpret_cast <R> (dlsym (m_ptr, function));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename R> R GetHandle (void)
|
||||
{
|
||||
return (R) m_ptr;
|
||||
}
|
||||
|
||||
inline bool IsLoaded (void) const
|
||||
{
|
||||
return m_ptr != nullptr;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,27 +4,30 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// general product information
|
||||
#define PRODUCT_NAME "Yet Another POD-Bot"
|
||||
#define PRODUCT_VERSION "2.8"
|
||||
#define PRODUCT_VERSION "2.9"
|
||||
#define PRODUCT_AUTHOR "YaPB Dev Team"
|
||||
#define PRODUCT_URL "https://yapb.jeefo.net/"
|
||||
#define PRODUCT_EMAIL "dmitry@jeefo.net"
|
||||
#define PRODUCT_URL "https://yapb.ru/"
|
||||
#define PRODUCT_EMAIL "d@entix.io"
|
||||
#define PRODUCT_LOGTAG "YAPB"
|
||||
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot"
|
||||
#define PRODUCT_COPYRIGHT "Copyright © 1999-2017, by " PRODUCT_AUTHOR
|
||||
#define PRODUCT_END_YEAR "2018"
|
||||
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot (" PRODUCT_COMMENTS ")"
|
||||
#define PRODUCT_COPYRIGHT "Copyright © 1999-" PRODUCT_END_YEAR ", by " PRODUCT_AUTHOR
|
||||
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
|
||||
#define PRODUCT_ORIGINAL_NAME "yapb.dll"
|
||||
#define PRODUCT_INTERNAL_NAME "skybot"
|
||||
#define PRODUCT_VERSION_DWORD_INTERNAL 2,8
|
||||
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL,0
|
||||
#define PRODUCT_SUPPORT_VERSION "1.0 - CZ"
|
||||
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
|
||||
#define PRODUCT_DATE __DATE__
|
||||
#define PRODUCT_GIT_HASH "unspecified_hash"
|
||||
#define PRODUCT_GIT_COMMIT_AUTHOR "unspecified_author"
|
||||
#define PRODUCT_GIT_COMMIT_ID 0000
|
||||
#define PRODUCT_VERSION_DWORD_INTERNAL 2, 9
|
||||
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL, PRODUCT_GIT_COMMIT_ID
|
||||
#define PRODUCT_SUPPORT_VERSION "Beta 6.6 - Condition Zero"
|
||||
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
|
||||
#define PRODUCT_DATE __DATE__
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -4,27 +4,21 @@
|
|||
#
|
||||
# This software is licensed under the BSD-style license.
|
||||
# Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
# https://yapb.jeefo.net/license
|
||||
# https://yapb.ru/license
|
||||
#
|
||||
|
||||
PROJECT = yapb
|
||||
SOURCES = ../source
|
||||
OBJECTS = $(wildcard $(SOURCES)/*.cpp)
|
||||
|
||||
COMPILER_FLAGS = -std=c++11 -m32 -Wall -Werror -Wextra -fno-exceptions -fno-rtti
|
||||
LINKER_FLAGS = -m32 -lm -ldl
|
||||
|
||||
ifeq "$(SSE_VERSION)" ""
|
||||
COMPILER_SSE_VERSION = 2
|
||||
else
|
||||
COMPILER_SSE_VERSION = $(SSE_VERSION)
|
||||
endif
|
||||
COMPILER_FLAGS = -mtune=generic -std=c++11 -m32 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -DPOSIX
|
||||
LINKER_FLAGS = -m32
|
||||
|
||||
ifeq "$(DEBUG)" "true"
|
||||
COMPILER_FLAGS += -D_DEBUG -DDEBUG -g3
|
||||
BINARY_DIR = debug
|
||||
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
|
||||
endif
|
||||
|
||||
|
|
@ -37,12 +31,12 @@ endif
|
|||
|
||||
ifeq "$(OSX)" "true"
|
||||
LIBRARY_EXT = dylib
|
||||
COMPILER_FLAGS += -DOSX -D_OSX -DPOSIX
|
||||
LINKER_FLAGS += -dynamiclib -lstdc++ -mmacosx-version-min=10.12 -arch i386
|
||||
COMPILER_FLAGS += -DOSX -D_OSX -mmacosx-version-min=10.9
|
||||
LINKER_FLAGS += -dynamiclib -lstdc++ -mmacosx-version-min=10.9 -arch i386
|
||||
else
|
||||
LIBRARY_EXT = so
|
||||
COMPILER_FLAGS += -DLINUX -D_LINUX -DPOSIX
|
||||
LINKER_FLAGS += -shared -lsupc++
|
||||
COMPILER_FLAGS += -DLINUX -D_LINUX
|
||||
LINKER_FLAGS += -shared
|
||||
endif
|
||||
|
||||
BINARY_OUTPUT = $(PROJECT).$(LIBRARY_EXT)
|
||||
|
|
@ -54,13 +48,11 @@ ifeq ($(findstring clang,$(COMPILER)),clang)
|
|||
else ifeq ($(findstring gcc,$(COMPILER)),gcc)
|
||||
ifneq "$(OSX)" "false"
|
||||
LINKER_FLAGS += -static-libgcc
|
||||
COMPILER_FLAGS += -funroll-all-loops
|
||||
COMPILER_FLAGS += -funroll-all-loops -Wno-implicit-fallthrough
|
||||
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
|
||||
LINKER_FLAGS += -static-intel -no-intel-extensions
|
||||
else
|
||||
$(error Compiler unrecognized. Specify CC.)
|
||||
LINKER_FLAGS += -cxxlib-nostd -static-intel -no-intel-extensions
|
||||
endif
|
||||
|
||||
OBJECTS_BIN := $(OBJECTS:%.cpp=$(BINARY_DIR)/%.o)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ FILETYPE 0x2
|
|||
VALUE "LegalCopyright", PRODUCT_COPYRIGHT "\0"
|
||||
VALUE "LegalTrademarks", PRODUCT_LEGAL "\0"
|
||||
VALUE "ProductName", PRODUCT_NAME "\0"
|
||||
VALUE "ProductVersion", PRODUCT_COMMENTS "\0"
|
||||
VALUE "ProductVersion", PRODUCT_VERSION "\0"
|
||||
VALUE "InternalName", PRODUCT_INTERNAL_NAME "\0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25029.0
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28016.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yapb", "yapb.vcxproj", "{C232645A-3B99-48F4-A1F3-F20CF0A9568B}"
|
||||
EndProject
|
||||
|
|
@ -19,4 +19,7 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {03C7A0BC-CD53-4141-879D-E7347565D90C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?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">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
|
|
@ -12,12 +12,11 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\compress.h" />
|
||||
<ClInclude Include="..\include\core.h" />
|
||||
<ClInclude Include="..\include\yapb.h" />
|
||||
<ClInclude Include="..\include\corelib.h" />
|
||||
<ClInclude Include="..\include\engine.h" />
|
||||
<ClInclude Include="..\include\engine\const.h" />
|
||||
<ClInclude Include="..\include\engine\eiface.h" />
|
||||
<ClInclude Include="..\include\engine\enginecallback.h" />
|
||||
<ClInclude Include="..\include\engine\extdll.h" />
|
||||
<ClInclude Include="..\include\engine\meta_api.h" />
|
||||
<ClInclude Include="..\include\engine\progdefs.h" />
|
||||
|
|
@ -53,14 +52,14 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@
|
|||
<ClInclude Include="..\include\compress.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\core.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\corelib.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -54,8 +51,8 @@
|
|||
<ClInclude Include="..\include\engine.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\engine\enginecallback.h">
|
||||
<Filter>include\engine</Filter>
|
||||
<ClInclude Include="..\include\yapb.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
@ -80,15 +77,15 @@
|
|||
<ClCompile Include="..\source\manager.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\basecode.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\combat.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\engine.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\basecode.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="yapb.rc">
|
||||
|
|
|
|||
6087
source/basecode.cpp
6087
source/basecode.cpp
File diff suppressed because it is too large
Load diff
|
|
@ -4,142 +4,141 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#include <core.h>
|
||||
#include <yapb.h>
|
||||
|
||||
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
|
||||
|
||||
const char *tagOpen[] = {"-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")"};
|
||||
const char *tagClose[] = {"=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "("};
|
||||
if (isEmptyStr (buffer)) {
|
||||
return;
|
||||
}
|
||||
size_t nameLength = strlen (buffer);
|
||||
|
||||
int index, fieldStart, fieldStop, i;
|
||||
int length = strlen (buffer); // get length of string
|
||||
if (nameLength < 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
// foreach known tag...
|
||||
for (index = 0; index < ARRAYSIZE_HLSDK (tagOpen); index++)
|
||||
{
|
||||
fieldStart = strstr (buffer, tagOpen[index]) - buffer; // look for a tag start
|
||||
constexpr const char *open[] = { "-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")" };
|
||||
constexpr const char *close[] = { "=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "(" };
|
||||
|
||||
// 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?
|
||||
if (fieldStart >= 0 && fieldStart < 32)
|
||||
{
|
||||
fieldStop = strstr (buffer, tagClose[index]) - buffer; // look for a tag stop
|
||||
if (start < 32) {
|
||||
size_t stop = strstr (buffer, close[i]) - buffer; // look for a tag stop
|
||||
|
||||
// have we found a tag stop?
|
||||
if (fieldStop > fieldStart && fieldStop < 32)
|
||||
{
|
||||
int tagLength = strlen (tagClose[index]);
|
||||
if (stop > start && stop < 32) {
|
||||
size_t tag = strlen (close[i]);
|
||||
size_t j = start;
|
||||
|
||||
for (i = fieldStart; i < length - (fieldStop + tagLength - fieldStart); i++)
|
||||
buffer[i] = buffer[i + (fieldStop + tagLength - fieldStart)]; // overwrite the buffer with the stripped string
|
||||
|
||||
buffer[i] = 0x0; // terminate the string
|
||||
for (; j < nameLength - (stop + tag - start); j++) {
|
||||
buffer[j] = buffer[j + (stop + tag - start)]; // overwrite the buffer with the stripped string
|
||||
}
|
||||
buffer[j] = '\0'; // terminate the string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// have we stripped too much (all the stuff)?
|
||||
if (buffer[0] != '\0')
|
||||
{
|
||||
String::TrimExternalBuffer (buffer); // if so, string is just a tag
|
||||
|
||||
int tagLength = 0;
|
||||
if (isEmptyStr (buffer)) {
|
||||
String::trimChars (buffer);
|
||||
return;
|
||||
}
|
||||
String::trimChars (buffer); // if so, string is just a tag
|
||||
|
||||
// strip just the tag part...
|
||||
for (index = 0; index < ARRAYSIZE_HLSDK (tagOpen); index++)
|
||||
{
|
||||
fieldStart = strstr (buffer, tagOpen[index]) - buffer; // look for a tag start
|
||||
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?
|
||||
if (fieldStart >= 0 && fieldStart < 32)
|
||||
{
|
||||
tagLength = strlen (tagOpen[index]);
|
||||
if (start < 32) {
|
||||
size_t tag = strlen (open[i]);
|
||||
size_t j = start;
|
||||
|
||||
for (i = fieldStart; i < length - tagLength; i++)
|
||||
buffer[i] = buffer[i + tagLength]; // overwrite the buffer with the stripped string
|
||||
|
||||
buffer[i] = 0x0; // terminate the string
|
||||
|
||||
fieldStart = strstr (buffer, tagClose[index]) - buffer; // look for a tag stop
|
||||
for (; j < nameLength - tag; j++) {
|
||||
buffer[j] = buffer[j + tag]; // overwrite the buffer with the stripped string
|
||||
}
|
||||
buffer[j] = '\0'; // terminate the string
|
||||
start = strstr (buffer, close[i]) - buffer; // look for a tag stop
|
||||
|
||||
// have we found a tag stop ?
|
||||
if (fieldStart >= 0 && fieldStart < 32)
|
||||
{
|
||||
tagLength = strlen (tagClose[index]);
|
||||
if (start < 32) {
|
||||
tag = strlen (close[i]);
|
||||
j = start;
|
||||
|
||||
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
|
||||
for (; j < nameLength - tag; j++) {
|
||||
buffer[j] = buffer[j + tag]; // overwrite the buffer with the stripped 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))
|
||||
|
||||
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
|
||||
if (Random.Int (1, 100) < 80)
|
||||
StripTags (outputName);
|
||||
else
|
||||
String::TrimExternalBuffer (outputName);
|
||||
if (rng.getInt (1, 100) < 80) {
|
||||
stripClanTags (outputName);
|
||||
}
|
||||
else {
|
||||
String::trimChars (outputName);
|
||||
}
|
||||
|
||||
// sometimes switch name to lower characters
|
||||
// note: since we're using russian names written in english, we reduce this shit to 6 percent
|
||||
if (Random.Int (1, 100) <= 6)
|
||||
{
|
||||
for (int i = 0; i < static_cast <int> (strlen (outputName)); i++)
|
||||
if (rng.getInt (1, 100) <= 6) {
|
||||
for (size_t i = 0; i < strlen (outputName); i++) {
|
||||
outputName[i] = static_cast <char> (tolower (static_cast <int> (outputName[i]))); // to lower case
|
||||
}
|
||||
}
|
||||
return &outputName[0]; // return terminated string
|
||||
}
|
||||
|
||||
void HumanizeChat (char *buffer)
|
||||
{
|
||||
void addChatErrors (char *buffer) {
|
||||
// this function humanize chat string to be more handwritten
|
||||
|
||||
int length = strlen (buffer); // get length of string
|
||||
int i = 0;
|
||||
size_t length = strlen (buffer); // get length of string
|
||||
size_t i = 0;
|
||||
|
||||
// sometimes switch text to lowercase
|
||||
// note: since we're using russian chat written in english, we reduce this shit to 4 percent
|
||||
if (Random.Int (1, 100) <= 4)
|
||||
{
|
||||
for (i = 0; i < length; i++)
|
||||
buffer[i] = static_cast <char> (tolower (static_cast <int> (buffer[i])));; // switch to lowercase
|
||||
// note: since we're using russian chat written in English, we reduce this shit to 4 percent
|
||||
if (rng.getInt (1, 100) <= 4) {
|
||||
for (i = 0; i < length; i++) {
|
||||
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
|
||||
if (Random.Int (1, 100) < (length / 2))
|
||||
{
|
||||
int pos = Random.Int ((length / 8), length - (length / 8)); // chose random position in string
|
||||
if (rng.getInt (1u, 100u) < percentile) {
|
||||
size_t pos = rng.getInt (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] = 0x0; // terminate string;
|
||||
}
|
||||
buffer[i] = '\0'; // terminate string;
|
||||
length--; // update new string length
|
||||
}
|
||||
|
||||
// "length" / 4 precent of time swap character
|
||||
if (Random.Int (1, 100) < (length / 4))
|
||||
{
|
||||
int pos = Random.Int ((length / 8), ((3 * length) / 8)); // choose random position in string
|
||||
if (rng.getInt (1u, 100u) < percentile / 2) {
|
||||
size_t pos = rng.getInt (length / 8, 3 * length / 8); // choose random position in string
|
||||
char ch = buffer[pos]; // swap characters
|
||||
|
||||
buffer[pos] = buffer[pos + 1];
|
||||
|
|
@ -149,304 +148,286 @@ void HumanizeChat (char *buffer)
|
|||
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
|
||||
|
||||
if (!yb_chat.GetBool () || IsNullString (text))
|
||||
if (!yb_chat.boolean () || isEmptyStr (text)) {
|
||||
return;
|
||||
|
||||
#define ASSIGN_TALK_ENTITY() if (!engine.IsNullEntity (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings))
|
||||
|
||||
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
|
||||
}
|
||||
m_tempStrings.clear ();
|
||||
|
||||
char *textStart = text;
|
||||
char *pattern = text;
|
||||
|
||||
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 %
|
||||
pattern = strstr (textStart, "%");
|
||||
pattern = strchr (textStart, '%');
|
||||
|
||||
if (pattern != nullptr)
|
||||
{
|
||||
int length = pattern - textStart;
|
||||
|
||||
if (length > 0)
|
||||
strncpy (m_tempStrings, textStart, length);
|
||||
if (pattern != nullptr) {
|
||||
size_t length = pattern - textStart;
|
||||
|
||||
if (length > 0) {
|
||||
m_tempStrings = String (textStart, length);
|
||||
}
|
||||
pattern++;
|
||||
|
||||
// player with most frags?
|
||||
if (*pattern == 'f')
|
||||
{
|
||||
if (*pattern == 'f') {
|
||||
int highestFrags = -9000; // just pick some start value
|
||||
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];
|
||||
|
||||
if (!(client.flags & CF_USED) || client.ent == GetEntity ())
|
||||
if (!(client.flags & CF_USED) || client.ent == ent ()) {
|
||||
continue;
|
||||
|
||||
}
|
||||
int frags = static_cast <int> (client.ent->v.frags);
|
||||
|
||||
if (frags > highestFrags)
|
||||
{
|
||||
if (frags > highestFrags) {
|
||||
highestFrags = frags;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
talkEntity = g_clients[index].ent;
|
||||
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
// mapname?
|
||||
else if (*pattern == 'm')
|
||||
strncat (m_tempStrings, engine.GetMapName (), SIZEOF_CHAR (m_tempStrings));
|
||||
else if (*pattern == 'm') {
|
||||
m_tempStrings += engine.getMapName ();
|
||||
}
|
||||
// roundtime?
|
||||
else if (*pattern == 'r')
|
||||
{
|
||||
int time = static_cast <int> (g_timeRoundEnd - engine.Time ());
|
||||
strncat (m_tempStrings, FormatBuffer ("%02d:%02d", time / 60, time % 60), SIZEOF_CHAR (m_tempStrings));
|
||||
else if (*pattern == 'r') {
|
||||
int time = static_cast <int> (g_timeRoundEnd - engine.timebase ());
|
||||
m_tempStrings.formatAppend ("%02d:%02d", time / 60, time % 60);
|
||||
}
|
||||
// chat reply?
|
||||
else if (*pattern == 's')
|
||||
{
|
||||
talkEntity = engine.EntityOfIndex (m_sayTextBuffer.entityIndex);
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
else if (*pattern == 's') {
|
||||
talkEntity = engine.entityOfIndex (m_sayTextBuffer.entityIndex);
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
// teammate alive?
|
||||
else if (*pattern == 't')
|
||||
{
|
||||
else if (*pattern == 't') {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
for (i = 0; i < engine.maxClients (); 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;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
if (!engine.IsNullEntity (pev->dmg_inflictor) && m_team == engine.GetTeam (pev->dmg_inflictor))
|
||||
if (i < engine.maxClients ()) {
|
||||
if (isPlayer (pev->dmg_inflictor) && m_team == engine.getTeam (pev->dmg_inflictor)) {
|
||||
talkEntity = pev->dmg_inflictor;
|
||||
else
|
||||
}
|
||||
else {
|
||||
talkEntity = g_clients[i].ent;
|
||||
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
}
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
else // no teammates alive...
|
||||
{
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
for (i = 0; i < engine.maxClients (); 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;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
if (i < engine.maxClients ()) {
|
||||
talkEntity = g_clients[i].ent;
|
||||
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*pattern == 'e')
|
||||
{
|
||||
else if (*pattern == 'e') {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
for (i = 0; i < engine.maxClients (); 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;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
if (i < engine.maxClients ()) {
|
||||
talkEntity = g_clients[i].ent;
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
else // no teammates alive...
|
||||
{
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
|
||||
// no teammates alive ?
|
||||
else {
|
||||
for (i = 0; i < engine.maxClients (); 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;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
if (i < engine.maxClients ()) {
|
||||
talkEntity = g_clients[i].ent;
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*pattern == 'd')
|
||||
{
|
||||
if (g_gameFlags & GAME_CZERO)
|
||||
{
|
||||
if (Random.Int (1, 100) < 30)
|
||||
strcat (m_tempStrings, "CZ");
|
||||
else
|
||||
strcat (m_tempStrings, "Condition Zero");
|
||||
else if (*pattern == 'd') {
|
||||
if (g_gameFlags & GAME_CZERO) {
|
||||
if (rng.getInt (1, 100) < 30) {
|
||||
m_tempStrings += "CZ";
|
||||
}
|
||||
else if ((g_gameFlags & GAME_CSTRIKE16) || (g_gameFlags & GAME_LEGACY))
|
||||
{
|
||||
if (Random.Int (1, 100) < 30)
|
||||
strcat (m_tempStrings, "CS");
|
||||
else
|
||||
strcat (m_tempStrings, "Counter-Strike");
|
||||
else {
|
||||
m_tempStrings += "Condition Zero";
|
||||
}
|
||||
}
|
||||
else if (*pattern == 'v')
|
||||
{
|
||||
else if ((g_gameFlags & GAME_CSTRIKE16) || (g_gameFlags & GAME_LEGACY)) {
|
||||
if (rng.getInt (1, 100) < 30) {
|
||||
m_tempStrings += "CS";
|
||||
}
|
||||
else {
|
||||
m_tempStrings += "Counter-Strike";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*pattern == 'v') {
|
||||
talkEntity = m_lastVictim;
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
m_tempStrings += getHumanizedName (talkEntity);
|
||||
}
|
||||
pattern++;
|
||||
textStart = pattern;
|
||||
}
|
||||
}
|
||||
|
||||
if (textStart != nullptr)
|
||||
{
|
||||
if (textStart != nullptr) {
|
||||
// let the bots make some mistakes...
|
||||
char tempString[160];
|
||||
strncpy (tempString, textStart, SIZEOF_CHAR (tempString));
|
||||
strncpy (tempString, textStart, cr::bufsize (tempString));
|
||||
|
||||
HumanizeChat (tempString);
|
||||
strncat (m_tempStrings, tempString, SIZEOF_CHAR (m_tempStrings));
|
||||
addChatErrors (tempString);
|
||||
m_tempStrings += tempString;
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckKeywords (char *tempMessage, char *reply)
|
||||
{
|
||||
// this function checks is string contain keyword, and generates relpy to it
|
||||
bool checkForKeywords (char *message, char *reply) {
|
||||
// this function checks is string contain keyword, and generates reply to it
|
||||
|
||||
if (!yb_chat.GetBool () || IsNullString (tempMessage))
|
||||
if (!yb_chat.boolean () || isEmptyStr (message)) {
|
||||
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
|
||||
if (strstr (tempMessage, g_replyFactory[i].keywords[j].GetBuffer ()) != nullptr)
|
||||
{
|
||||
Array <String> &replies = g_replyFactory[i].usedReplies;
|
||||
|
||||
if (replies.GetElementNumber () >= g_replyFactory[i].replies.GetElementNumber () / 2)
|
||||
replies.RemoveAll ();
|
||||
if (strstr (message, keyword.chars ()) != nullptr) {
|
||||
StringArray &replies = factory.usedReplies;
|
||||
|
||||
if (replies.length () >= factory.replies.length () / 2) {
|
||||
replies.clear ();
|
||||
}
|
||||
else if (!replies.empty ()) {
|
||||
bool replyUsed = false;
|
||||
const char *generatedReply = g_replyFactory[i].replies.GetRandomElement ();
|
||||
const String &choosenReply = factory.replies.random ();
|
||||
|
||||
// don't say this twice
|
||||
FOR_EACH_AE (replies, k)
|
||||
{
|
||||
if (strstr (replies[k].GetBuffer (), generatedReply) != nullptr)
|
||||
for (auto &used : replies) {
|
||||
if (used.contains (choosenReply)) {
|
||||
replyUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// reply not used, so use it
|
||||
if (!replyUsed)
|
||||
{
|
||||
strcpy (reply, generatedReply); // update final buffer
|
||||
replies.Push (generatedReply); //add to ignore list
|
||||
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
|
||||
if (Random.Int (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ())
|
||||
{
|
||||
strcpy (reply, g_chatFactory[CHAT_NOKW].GetRandomElement ().GetBuffer ());
|
||||
if (rng.getInt (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].empty ()) {
|
||||
strcpy (reply, g_chatFactory[CHAT_NOKW].random ().chars ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bot::ParseChat (char *reply)
|
||||
{
|
||||
bool Bot::processChatKeywords (char *reply) {
|
||||
// this function parse chat buffer, and prepare buffer to keyword searching
|
||||
|
||||
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
|
||||
for (int i = 0; i < static_cast <int> (strlen (tempMessage)); i++)
|
||||
tempMessage[i] = static_cast <char> (tolower (static_cast <int> (tempMessage[i])));
|
||||
|
||||
return CheckKeywords (tempMessage, reply);
|
||||
for (size_t i = 0; i < maxLength; i++) {
|
||||
tempMessage[i] = static_cast <char> (toupper (static_cast <int> (tempMessage[i])));
|
||||
}
|
||||
return checkForKeywords (tempMessage, reply);
|
||||
}
|
||||
|
||||
bool Bot::RepliesToPlayer (void)
|
||||
{
|
||||
bool Bot::isReplyingToChat (void) {
|
||||
// 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];
|
||||
|
||||
// check is time to chat is good
|
||||
if (m_sayTextBuffer.timeNextChat < engine.Time ())
|
||||
{
|
||||
if (Random.Int (1, 100) < m_sayTextBuffer.chatProbability + Random.Int (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
|
||||
{
|
||||
PrepareChatMessage (text);
|
||||
PushMessageQueue (GAME_MSG_SAY_CMD);
|
||||
if (m_sayTextBuffer.timeNextChat < engine.timebase ()) {
|
||||
if (rng.getInt (1, 100) < m_sayTextBuffer.chatProbability + rng.getInt (15, 35) && processChatKeywords (reinterpret_cast <char *> (&text))) {
|
||||
prepareChatMessage (text);
|
||||
pushMsgQueue (GAME_MSG_SAY_CMD);
|
||||
|
||||
|
||||
m_sayTextBuffer.entityIndex = -1;
|
||||
m_sayTextBuffer.sayText[0] = 0x0;
|
||||
m_sayTextBuffer.timeNextChat = engine.Time () + m_sayTextBuffer.chatDelay;
|
||||
m_sayTextBuffer.timeNextChat = engine.timebase () + m_sayTextBuffer.chatDelay;
|
||||
m_sayTextBuffer.sayText.clear ();
|
||||
|
||||
return true;
|
||||
}
|
||||
m_sayTextBuffer.entityIndex = -1;
|
||||
m_sayTextBuffer.sayText[0] = 0x0;
|
||||
m_sayTextBuffer.sayText.clear ();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bot::SayText (const char *text)
|
||||
{
|
||||
void Bot::say (const char *text) {
|
||||
// this function prints saytext message to all players
|
||||
|
||||
if (IsNullString (text))
|
||||
if (isEmptyStr (text)) {
|
||||
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
|
||||
|
||||
if (IsNullString (text))
|
||||
if (isEmptyStr (text)) {
|
||||
return;
|
||||
|
||||
engine.IssueBotCommand (GetEntity (), "say_team \"%s\"", text);
|
||||
}
|
||||
engine.execBotCmd (ent (), "say_team \"%s\"", text);
|
||||
}
|
||||
|
|
|
|||
1465
source/combat.cpp
1465
source/combat.cpp
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -4,10 +4,10 @@
|
|||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.jeefo.net/license
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#include <core.h>
|
||||
#include <yapb.h>
|
||||
|
||||
bool g_canSayBombPlanted = true;
|
||||
bool g_roundEnded = true;
|
||||
|
|
@ -27,25 +27,23 @@ float g_timeRoundMid = 0.0f;
|
|||
float g_timeNextBombUpdate = 0.0f;
|
||||
float g_timeBombPlanted = 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;
|
||||
|
||||
int g_lastRadio[2];
|
||||
int g_lastRadio[MAX_TEAM_COUNT];
|
||||
int g_storeAddbotVars[4];
|
||||
int g_radioSelect[MAX_ENGINE_PLAYERS];
|
||||
int g_gameFlags = 0;
|
||||
int g_numWaypoints = 0;
|
||||
int g_mapType = 0;
|
||||
int g_mapFlags = 0;
|
||||
|
||||
int g_highestDamageCT = 1;
|
||||
int g_highestDamageT = 1;
|
||||
int g_highestKills = 1;
|
||||
|
||||
Array <Array <String> > g_chatFactory;
|
||||
Array <Array <ChatterItem> > g_chatterFactory;
|
||||
Array <BotName> g_botNames;
|
||||
Array <KeywordFactory> g_replyFactory;
|
||||
RandomSequenceOfUnique Random;
|
||||
Array<StringArray> g_chatFactory;
|
||||
Array<Array<ChatterItem>> g_chatterFactory;
|
||||
Array<BotName> g_botNames;
|
||||
Array<KeywordFactory> g_replyFactory;
|
||||
Library *g_gameLib = nullptr;
|
||||
|
||||
meta_globals_t *gpMetaGlobals = nullptr;
|
||||
|
|
@ -63,31 +61,15 @@ globalvars_t *g_pGlobals = nullptr;
|
|||
Experience *g_experienceData = nullptr;
|
||||
|
||||
// default tables for personality weapon preferences, overridden by weapons.cfg
|
||||
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};
|
||||
|
||||
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_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
|
||||
};
|
||||
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};
|
||||
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_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
|
||||
plugin_info_t Plugin_info =
|
||||
{
|
||||
plugin_info_t Plugin_info = {
|
||||
META_INTERFACE_VERSION, // interface version
|
||||
PRODUCT_NAME, // plugin name
|
||||
PRODUCT_VERSION, // plugin version
|
||||
|
|
@ -99,304 +81,291 @@ plugin_info_t Plugin_info =
|
|||
PT_ANYTIME, // when unloadable
|
||||
};
|
||||
|
||||
// table with all available actions for the bots (filtered in & out in Bot::SetConditions) some of them have subactions included
|
||||
TaskItem g_taskFilters[] =
|
||||
{
|
||||
{TASK_NORMAL, 0, -1, 0.0f, true},
|
||||
{TASK_PAUSE, 0, -1, 0.0f, false},
|
||||
{TASK_MOVETOPOSITION, 0, -1, 0.0f, true},
|
||||
{TASK_FOLLOWUSER, 0, -1, 0.0f, true},
|
||||
{TASK_WAITFORGO, 0, -1, 0.0f, true},
|
||||
{TASK_PICKUPITEM, 0, -1, 0.0f, true},
|
||||
{TASK_CAMP, 0, -1, 0.0f, true},
|
||||
{TASK_PLANTBOMB, 0, -1, 0.0f, false},
|
||||
{TASK_DEFUSEBOMB, 0, -1, 0.0f, false},
|
||||
{TASK_ATTACK, 0, -1, 0.0f, false},
|
||||
{TASK_HUNTENEMY, 0, -1, 0.0f, false},
|
||||
{TASK_SEEKCOVER, 0, -1, 0.0f, false},
|
||||
{TASK_THROWHEGRENADE, 0, -1, 0.0f, false},
|
||||
{TASK_THROWFLASHBANG, 0, -1, 0.0f, false},
|
||||
{TASK_THROWSMOKE, 0, -1, 0.0f, false},
|
||||
{TASK_DOUBLEJUMP, 0, -1, 0.0f, false},
|
||||
{TASK_ESCAPEFROMBOMB, 0, -1, 0.0f, false},
|
||||
{TASK_SHOOTBREAKABLE, 0, -1, 0.0f, false},
|
||||
{TASK_HIDE, 0, -1, 0.0f, false},
|
||||
{TASK_BLINDED, 0, -1, 0.0f, false},
|
||||
{TASK_SPRAY, 0, -1, 0.0f, false}
|
||||
// table with all available actions for the bots (filtered in & out in Bot::setConditions) some of them have subactions included
|
||||
Task g_taskFilters[TASK_MAX] = {
|
||||
{ TASK_NORMAL, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
|
||||
{ TASK_PAUSE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_MOVETOPOSITION, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
|
||||
{ TASK_FOLLOWUSER, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
|
||||
{ TASK_PICKUPITEM, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
|
||||
{ TASK_CAMP, 0, INVALID_WAYPOINT_INDEX, 0.0f, true },
|
||||
{ TASK_PLANTBOMB, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_DEFUSEBOMB, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_ATTACK, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_HUNTENEMY, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_SEEKCOVER, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_THROWHEGRENADE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_THROWFLASHBANG, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_THROWSMOKE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_DOUBLEJUMP, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_ESCAPEFROMBOMB, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_SHOOTBREAKABLE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_HIDE, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_BLINDED, 0, INVALID_WAYPOINT_INDEX, 0.0f, false },
|
||||
{ TASK_SPRAY, 0, INVALID_WAYPOINT_INDEX, 0.0f, false }
|
||||
};
|
||||
|
||||
// weapons and their specifications
|
||||
WeaponSelect g_weaponSelect[NUM_WEAPONS + 1] =
|
||||
{
|
||||
{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_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_P228, "weapon_p228", "p228.mdl", 600, 1, 2, 2, 1, 4, 3, 3, 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_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_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_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_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_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_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_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_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_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_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}
|
||||
WeaponSelect g_weaponSelect[NUM_WEAPONS + 1] = {
|
||||
{ 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_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_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_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_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_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_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_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_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_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_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_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_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 },
|
||||
{ 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, false }
|
||||
};
|
||||
|
||||
void SetupBotMenus (void)
|
||||
{
|
||||
void setupBotMenus (void) {
|
||||
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
|
||||
g_menus[counter] =
|
||||
{
|
||||
BOT_MENU_MAIN, 0x2ff,
|
||||
"\\yMain Menu\\w\v\v"
|
||||
"1. Control Bots\v"
|
||||
"2. Features\v\v"
|
||||
"3. Fill Server\v"
|
||||
"4. End Round\v\v"
|
||||
g_menus[counter] = {
|
||||
BOT_MENU_MAIN, buildKeys (4),
|
||||
"\\yMain Menu\\w\n\n"
|
||||
"1. Control Bots\n"
|
||||
"2. Features\n\n"
|
||||
"3. Fill Server\n"
|
||||
"4. End Round\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// bots features menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_FEATURES, 0x25f,
|
||||
"\\yBots Features\\w\v\v"
|
||||
"1. Weapon Mode Menu\v"
|
||||
"2. Waypoint Menu\v"
|
||||
"3. Select Personality\v\v"
|
||||
"4. Toggle Debug Mode\v"
|
||||
"5. Command Menu\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_FEATURES, buildKeys (5),
|
||||
"\\yBots Features\\w\n\n"
|
||||
"1. Weapon Mode Menu\n"
|
||||
"2. Waypoint Menu\n"
|
||||
"3. Select Personality\n\n"
|
||||
"4. Toggle Debug Mode\n"
|
||||
"5. Command Menu\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// bot control menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_CONTROL, 0x2ff,
|
||||
"\\yBots Control Menu\\w\v\v"
|
||||
"1. Add a Bot, Quick\v"
|
||||
"2. Add a Bot, Specified\v\v"
|
||||
"3. Remove Random Bot\v"
|
||||
"4. Remove All Bots\v\v"
|
||||
"5. Remove Bot Menu\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_CONTROL, buildKeys (5),
|
||||
"\\yBots Control Menu\\w\n\n"
|
||||
"1. Add a Bot, Quick\n"
|
||||
"2. Add a Bot, Specified\n\n"
|
||||
"3. Remove Random Bot\n"
|
||||
"4. Remove All Bots\n\n"
|
||||
"5. Remove Bot Menu\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// weapon mode select menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WEAPON_MODE, 0x27f,
|
||||
"\\yBots Weapon Mode\\w\v\v"
|
||||
"1. Knives only\v"
|
||||
"2. Pistols only\v"
|
||||
"3. Shotguns only\v"
|
||||
"4. Machine Guns only\v"
|
||||
"5. Rifles only\v"
|
||||
"6. Sniper Weapons only\v"
|
||||
"7. All Weapons\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WEAPON_MODE, buildKeys (7),
|
||||
"\\yBots Weapon Mode\\w\n\n"
|
||||
"1. Knives only\n"
|
||||
"2. Pistols only\n"
|
||||
"3. Shotguns only\n"
|
||||
"4. Machine Guns only\n"
|
||||
"5. Rifles only\n"
|
||||
"6. Sniper Weapons only\n"
|
||||
"7. All Weapons\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// personality select menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_PERSONALITY, 0x20f,
|
||||
"\\yBots Personality\\w\v\v"
|
||||
"1. Random\v"
|
||||
"2. Normal\v"
|
||||
"3. Aggressive\v"
|
||||
"4. Careful\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_PERSONALITY, buildKeys (4),
|
||||
"\\yBots Personality\\w\n\n"
|
||||
"1. Random\n"
|
||||
"2. Normal\n"
|
||||
"3. Aggressive\n"
|
||||
"4. Careful\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// difficulty select menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_DIFFICULTY, 0x23f,
|
||||
"\\yBots Difficulty Level\\w\v\v"
|
||||
"1. Newbie\v"
|
||||
"2. Average\v"
|
||||
"3. Normal\v"
|
||||
"4. Professional\v"
|
||||
"5. Godlike\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_DIFFICULTY, buildKeys (5),
|
||||
"\\yBots Difficulty Level\\w\n\n"
|
||||
"1. Newbie\n"
|
||||
"2. Average\n"
|
||||
"3. Normal\n"
|
||||
"4. Professional\n"
|
||||
"5. Godlike\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// team select menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_TEAM_SELECT, 0x213,
|
||||
"\\ySelect a team\\w\v\v"
|
||||
"1. Terrorist Force\v"
|
||||
"2. Counter-Terrorist Force\v\v"
|
||||
"5. Auto-select\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_TEAM_SELECT, buildKeys (5),
|
||||
"\\ySelect a team\\w\n\n"
|
||||
"1. Terrorist Force\n"
|
||||
"2. Counter-Terrorist Force\n\n"
|
||||
"5. Auto-select\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// terrorist model select menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_TERRORIST_SELECT, 0x21f,
|
||||
"\\ySelect an appearance\\w\v\v"
|
||||
"1. Phoenix Connexion\v"
|
||||
"2. L337 Krew\v"
|
||||
"3. Arctic Avengers\v"
|
||||
"4. Guerilla Warfare\v\v"
|
||||
"5. Auto-select\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_TERRORIST_SELECT, buildKeys (5),
|
||||
"\\ySelect an appearance\\w\n\n"
|
||||
"1. Phoenix Connexion\n"
|
||||
"2. L337 Krew\n"
|
||||
"3. Arctic Avengers\n"
|
||||
"4. Guerilla Warfare\n\n"
|
||||
"5. Auto-select\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// counter-terrorist model select menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_CT_SELECT, 0x21f,
|
||||
"\\ySelect an appearance\\w\v\v"
|
||||
"1. Seal Team 6 (DEVGRU)\v"
|
||||
"2. German GSG-9\v"
|
||||
"3. UK SAS\v"
|
||||
"4. French GIGN\v\v"
|
||||
"5. Auto-select\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_CT_SELECT, buildKeys (5),
|
||||
"\\ySelect an appearance\\w\n\n"
|
||||
"1. Seal Team 6 (DEVGRU)\n"
|
||||
"2. German GSG-9\n"
|
||||
"3. UK SAS\n"
|
||||
"4. French GIGN\n\n"
|
||||
"5. Auto-select\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// command menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_COMMANDS, 0x23f,
|
||||
"\\yBot Command Menu\\w\v\v"
|
||||
"1. Make Double Jump\v"
|
||||
"2. Finish Double Jump\v\v"
|
||||
"3. Drop the C4 Bomb\v"
|
||||
"4. Drop the Weapon\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_COMMANDS, buildKeys (4),
|
||||
"\\yBot Command Menu\\w\n\n"
|
||||
"1. Make Double Jump\n"
|
||||
"2. Finish Double Jump\n\n"
|
||||
"3. Drop the C4 Bomb\n"
|
||||
"4. Drop the Weapon\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// main waypoint menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_MAIN_PAGE1, 0x3ff,
|
||||
"\\yWaypoint Operations (Page 1)\\w\v\v"
|
||||
"1. Show/Hide waypoints\v"
|
||||
"2. Cache waypoint\v"
|
||||
"3. Create path\v"
|
||||
"4. Delete path\v"
|
||||
"5. Add waypoint\v"
|
||||
"6. Delete waypoint\v"
|
||||
"7. Set Autopath Distance\v"
|
||||
"8. Set Radius\v\v"
|
||||
"9. Next...\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_MAIN_PAGE1, buildKeys (9),
|
||||
"\\yWaypoint Operations (Page 1)\\w\n\n"
|
||||
"1. Show/Hide waypoints\n"
|
||||
"2. Cache waypoint\n"
|
||||
"3. Create path\n"
|
||||
"4. Delete path\n"
|
||||
"5. Add waypoint\n"
|
||||
"6. Delete waypoint\n"
|
||||
"7. Set Autopath Distance\n"
|
||||
"8. Set Radius\n\n"
|
||||
"9. Next...\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// main waypoint menu (page 2)
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_MAIN_PAGE2, 0x3ff,
|
||||
"\\yWaypoint Operations (Page 2)\\w\v\v"
|
||||
"1. Waypoint stats\v"
|
||||
"2. Autowaypoint on/off\v"
|
||||
"3. Set flags\v"
|
||||
"4. Save waypoints\v"
|
||||
"5. Save without checking\v"
|
||||
"6. Load waypoints\v"
|
||||
"7. Check waypoints\v"
|
||||
"8. Noclip cheat on/off\v\v"
|
||||
"9. Previous...\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_MAIN_PAGE2, buildKeys (9),
|
||||
"\\yWaypoint Operations (Page 2)\\w\n\n"
|
||||
"1. Waypoint stats\n"
|
||||
"2. Autowaypoint on/off\n"
|
||||
"3. Set flags\n"
|
||||
"4. Save waypoints\n"
|
||||
"5. Save without checking\n"
|
||||
"6. Load waypoints\n"
|
||||
"7. Check waypoints\n"
|
||||
"8. Noclip cheat on/off\n\n"
|
||||
"9. Previous...\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// select waypoint radius menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_RADIUS, 0x3ff,
|
||||
"\\yWaypoint Radius\\w\v\v"
|
||||
"1. SetRadius 0\v"
|
||||
"2. SetRadius 8\v"
|
||||
"3. SetRadius 16\v"
|
||||
"4. SetRadius 32\v"
|
||||
"5. SetRadius 48\v"
|
||||
"6. SetRadius 64\v"
|
||||
"7. SetRadius 80\v"
|
||||
"8. SetRadius 96\v"
|
||||
"9. SetRadius 128\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_RADIUS, buildKeys (9),
|
||||
"\\yWaypoint Radius\\w\n\n"
|
||||
"1. SetRadius 0\n"
|
||||
"2. SetRadius 8\n"
|
||||
"3. SetRadius 16\n"
|
||||
"4. SetRadius 32\n"
|
||||
"5. SetRadius 48\n"
|
||||
"6. SetRadius 64\n"
|
||||
"7. SetRadius 80\n"
|
||||
"8. SetRadius 96\n"
|
||||
"9. SetRadius 128\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// waypoint add menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_TYPE, 0x3ff,
|
||||
"\\yWaypoint Type\\w\v\v"
|
||||
"1. Normal\v"
|
||||
"\\r2. Terrorist Important\v"
|
||||
"3. Counter-Terrorist Important\v"
|
||||
"\\w4. Block with hostage / Ladder\v"
|
||||
"\\y5. Rescue Zone\v"
|
||||
"\\w6. Camping\v"
|
||||
"7. Camp End\v"
|
||||
"\\r8. Map Goal\v"
|
||||
"\\w9. Jump\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_TYPE, buildKeys (9),
|
||||
"\\yWaypoint Type\\w\n\n"
|
||||
"1. Normal\n"
|
||||
"\\r2. Terrorist Important\n"
|
||||
"3. Counter-Terrorist Important\n"
|
||||
"\\w4. Block with hostage / Ladder\n"
|
||||
"\\y5. Rescue Zone\n"
|
||||
"\\w6. Camping\n"
|
||||
"7. Camp End\n"
|
||||
"\\r8. Map Goal\n"
|
||||
"\\w9. Jump\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// set waypoint flag menu
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_FLAG, 0x2ff,
|
||||
"\\yToggle Waypoint Flags\\w\v\v"
|
||||
"1. Block with Hostage\v"
|
||||
"2. Terrorists Specific\v"
|
||||
"3. CTs Specific\v"
|
||||
"4. Use Elevator\v"
|
||||
"5. Sniper Point (\\yFor Camp Points Only!\\w)\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_FLAG, buildKeys (5),
|
||||
"\\yToggle Waypoint Flags\\w\n\n"
|
||||
"1. Block with Hostage\n"
|
||||
"2. Terrorists Specific\n"
|
||||
"3. CTs Specific\n"
|
||||
"4. Use Elevator\n"
|
||||
"5. Sniper Point (\\yFor Camp Points Only!\\w)\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// auto-path max distance
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_AUTOPATH,
|
||||
0x27f,
|
||||
"\\yAutoPath Distance\\w\v\v"
|
||||
"1. Distance 0\v"
|
||||
"2. Distance 100\v"
|
||||
"3. Distance 130\v"
|
||||
"4. Distance 160\v"
|
||||
"5. Distance 190\v"
|
||||
"6. Distance 220\v"
|
||||
"7. Distance 250 (Default)\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_AUTOPATH, buildKeys (7),
|
||||
"\\yAutoPath Distance\\w\n\n"
|
||||
"1. Distance 0\n"
|
||||
"2. Distance 100\n"
|
||||
"3. Distance 130\n"
|
||||
"4. Distance 160\n"
|
||||
"5. Distance 190\n"
|
||||
"6. Distance 220\n"
|
||||
"7. Distance 250 (Default)\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
// path connections
|
||||
g_menus[++counter] =
|
||||
{
|
||||
BOT_MENU_WAYPOINT_PATH,
|
||||
0x207,
|
||||
"\\yCreate Path (Choose Direction)\\w\v\v"
|
||||
"1. Outgoing Path\v"
|
||||
"2. Incoming Path\v"
|
||||
"3. Bidirectional (Both Ways)\v\v"
|
||||
g_menus[++counter] = {
|
||||
BOT_MENU_WAYPOINT_PATH, buildKeys (3),
|
||||
"\\yCreate Path (Choose Direction)\\w\n\n"
|
||||
"1. Outgoing Path\n"
|
||||
"2. Incoming Path\n"
|
||||
"3. Bidirectional (Both Ways)\n\n"
|
||||
"0. Exit"
|
||||
};
|
||||
|
||||
const String &empty = "";
|
||||
|
||||
// kick menus
|
||||
|
|
|
|||
3112
source/interface.cpp
3112
source/interface.cpp
File diff suppressed because it is too large
Load diff
1625
source/manager.cpp
1625
source/manager.cpp
File diff suppressed because it is too large
Load diff
3219
source/navigate.cpp
3219
source/navigate.cpp
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2519
source/waypoint.cpp
2519
source/waypoint.cpp
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue