helloworld

This commit is contained in:
jeefo 2014-07-30 14:17:46 +04:00
commit 3a4164ec5d
30 changed files with 30901 additions and 0 deletions

360
include/compress.h Normal file
View file

@ -0,0 +1,360 @@
//
// Copyright (c) 2014, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Version: $Id:$
//
#ifndef COMPRESS_INCLUDED
#define COMPRESS_INCLUDED
const int N = 4096, F = 18, THRESHOLD = 2, NIL = N;
class Compressor
{
protected:
unsigned long int m_textSize;
unsigned long int m_codeSize;
byte m_textBuffer[N + F - 1];
int m_matchPosition;
int m_matchLength;
int m_left[N + 1];
int m_right[N + 257];
int m_parent[N + 1];
private:
void InitTree (void)
{
for (int i = N + 1; i <= N + 256; i++)
m_right[i] = NIL;
for (int j = 0; j < N; j++)
m_parent[j] = NIL;
}
void InsertNode (int node)
{
int i;
int compare = 1;
byte *key = &m_textBuffer[node];
int temp = N + 1 + key[0];
m_right[node] = m_left[node] = NIL;
m_matchLength = 0;
for (;;)
{
if (compare >= 0)
{
if (m_right[temp] != NIL)
temp = m_right[temp];
else
{
m_right[temp] = node;
m_parent[node] = temp;
return;
}
}
else
{
if (m_left[temp] != NIL)
temp = m_left[temp];
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)
break;
if (i > m_matchLength)
{
m_matchPosition = temp;
if ((m_matchLength = i) >= F)
break;
}
}
m_parent[node] = m_parent[temp];
m_left[node] = m_left[temp];
m_right[node] = m_right[temp];
m_parent[m_left[temp]] = node;
m_parent[m_right[temp]] = node;
if (m_right[m_parent[temp]] == temp)
m_right[m_parent[temp]] = node;
else
m_left[m_parent[temp]] = node;
m_parent[temp] = NIL;
}
void DeleteNode (int node)
{
int temp;
if (m_parent[node] == NIL)
return; // not in tree
if (m_right[node] == NIL)
temp = m_left[node];
else if (m_left[node] == NIL)
temp = m_right[node];
else
{
temp = m_left[node];
if (m_right[temp] != NIL)
{
do
temp = m_right[temp];
while (m_right[temp] != NIL);
m_right[m_parent[temp]] = m_left[temp];
m_parent[m_left[temp]] = m_parent[temp];
m_left[temp] = m_left[node];
m_parent[m_left[node]] = temp;
}
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)
m_right[m_parent[node]] = temp;
else
m_left[m_parent[node]] = temp;
m_parent[node] = NIL;
}
public:
Compressor (void)
{
m_textSize = 0;
m_codeSize = 0;
}
~Compressor (void)
{
m_textSize = 0;
m_codeSize = 0;
}
int InternalEncode (char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize)
{
int i, bit, length, node, strPtr, lastMatchLength, codeBufferPtr, bufferPtr = 0;
byte codeBuffer[17], mask;
File fp (fileName, "wb");
if (!fp.IsValid ())
return -1;
fp.Write (header, headerSize, 1);
InitTree ();
codeBuffer[0] = 0;
codeBufferPtr = mask = 1;
strPtr = 0;
node = N - F;
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;
}
if ((m_textSize = 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++] = (unsigned char) m_matchPosition;
codeBuffer[codeBufferPtr++] = (unsigned char) (((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;
}
lastMatchLength = m_matchLength;
for (i = 0; (i < lastMatchLength) && (bufferPtr < bufferSize); i++)
{
bit = buffer[bufferPtr++];
DeleteNode (strPtr);
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);
}
while (i++ < lastMatchLength)
{
DeleteNode (strPtr);
strPtr = (strPtr + 1) & (N - 1);
node = (node + 1) & (N - 1);
if (length--)
InsertNode (node);
}
} while (length > 0);
if (codeBufferPtr > 1)
{
for (i = 0; i < codeBufferPtr; i++)
fp.PutChar (codeBuffer[i]);
m_codeSize += codeBufferPtr;
}
fp.Close ();
return m_codeSize;
}
int InternalDecode (char *fileName, int headerSize, byte *buffer, int bufferSize)
{
int i, j, k, node, bit;
unsigned int flags;
int bufferPtr = 0;
File fp (fileName, "rb");
if (!fp.IsValid ())
return -1;
fp.Seek (headerSize, SEEK_SET);
node = N - F;
for (i = 0; i < node; i++)
m_textBuffer[i] = ' ';
flags = 0;
for (;;)
{
if (((flags >>= 1) & 256) == 0)
{
if ((bit = fp.GetChar ()) == EOF)
break;
flags = bit | 0xff00;
}
if (flags & 1)
{
if ((bit = fp.GetChar ()) == EOF)
break;
buffer[bufferPtr++] = bit;
if (bufferPtr > bufferSize)
return -1;
m_textBuffer[node++] = bit;
node &= (N - 1);
}
else
{
if ((i = fp.GetChar ()) == EOF)
break;
if ((j = fp.GetChar ()) == EOF)
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;
if (bufferPtr > bufferSize)
return -1;
m_textBuffer[node++] = bit;
node &= (N - 1);
}
}
}
fp.Close ();
return bufferPtr;
}
// external decoder
static int Uncompress (char *fileName, int headerSize, byte *buffer, int bufferSize)
{
static Compressor compressor = Compressor ();
return compressor.InternalDecode (fileName, headerSize, buffer, bufferSize);
}
// external encoder
static int Compress(char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize)
{
static Compressor compressor = Compressor ();
return compressor.InternalEncode (fileName, header, headerSize, buffer, bufferSize);
}
};
#endif // COMPRESS_INCLUDED

1678
include/core.h Normal file

File diff suppressed because it is too large Load diff

4168
include/corelib.h Normal file

File diff suppressed because it is too large Load diff

228
include/engine/archtypes.h Normal file
View file

@ -0,0 +1,228 @@
/***
*
* 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 ARCHTYPES_H
#define ARCHTYPES_H
#ifdef _WIN32
#pragma once
#endif
#include <string.h>
// detects the build platform
#if defined (__linux__) || defined (__debian__) || defined (__linux)
#define __linux__ 1
#endif
// for when we care about how many bits we use
typedef signed char int8;
typedef signed short int16;
typedef signed long int32;
#ifdef _WIN32
#ifdef _MSC_VER
typedef signed __int64 int64;
#endif
#elif defined __linux__
typedef long long int64;
#endif
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
#ifdef _WIN32
#ifdef _MSC_VER
typedef unsigned __int64 uint64;
#endif
#elif defined __linux__
typedef unsigned long long uint64;
#endif
typedef float float32;
typedef double float64;
// for when we don't care about how many bits we use
typedef unsigned int uint;
// This can be used to ensure the size of pointers to members when declaring
// a pointer type for a class that has only been forward declared
#ifdef _MSC_VER
#define SINGLE_INHERITANCE __single_inheritance
#define MULTIPLE_INHERITANCE __multiple_inheritance
#else
#define SINGLE_INHERITANCE
#define MULTIPLE_INHERITANCE
#endif
// need these for the limits
#include <limits.h>
#include <float.h>
// Maximum and minimum representable values
#define INT8_MAX SCHAR_MAX
#define INT16_MAX SHRT_MAX
#define INT32_MAX LONG_MAX
#define INT64_MAX (((int64)~0) >> 1)
#define INT8_MIN SCHAR_MIN
#define INT16_MIN SHRT_MIN
#define INT32_MIN LONG_MIN
#define INT64_MIN (((int64)1) << 63)
#define UINT8_MAX ((uint8)~0)
#define UINT16_MAX ((uint16)~0)
#define UINT32_MAX ((uint32)~0)
#define UINT64_MAX ((uint64)~0)
#define UINT8_MIN 0
#define UINT16_MIN 0
#define UINT32_MIN 0
#define UINT64_MIN 0
#ifndef UINT_MIN
#define UINT_MIN UINT32_MIN
#endif
#define FLOAT32_MAX FLT_MAX
#define FLOAT64_MAX DBL_MAX
#define FLOAT32_MIN FLT_MIN
#define FLOAT64_MIN DBL_MIN
// portability / compiler settings
#if defined(_WIN32) && !defined(WINDED)
#if defined(_M_IX86)
#define __i386__ 1
#endif
#elif __linux__
typedef unsigned int DWORD;
typedef unsigned short WORD;
typedef void *HINSTANCE;
#define _MAX_PATH PATH_MAX
#endif // defined(_WIN32) && !defined(WINDED)
// Defines MAX_PATH
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
// Used to step into the debugger
#define DebuggerBreak() __asm { int 3 }
// C functions for external declarations that call the appropriate C++ methods
#ifndef EXPORT
#ifdef _WIN32
#define EXPORT __declspec( dllexport )
#else
#define EXPORT /* */
#endif
#endif
#if defined __i386__ && !defined __linux__
#define id386 1
#else
#define id386 0
#endif // __i386__
#ifdef _WIN32
// Used for dll exporting and importing
#define DLL_EXPORT extern "C" __declspec( dllexport )
#define DLL_IMPORT extern "C" __declspec( dllimport )
// Can't use extern "C" when DLL exporting a class
#define DLL_CLASS_EXPORT __declspec( dllexport )
#define DLL_CLASS_IMPORT __declspec( dllimport )
// Can't use extern "C" when DLL exporting a global
#define DLL_GLOBAL_EXPORT extern __declspec( dllexport )
#define DLL_GLOBAL_IMPORT extern __declspec( dllimport )
#elif defined __linux__ || defined (__APPLE__)
// Used for dll exporting and importing
#define DLL_EXPORT extern "C"
#define DLL_IMPORT extern "C"
// Can't use extern "C" when DLL exporting a class
#define DLL_CLASS_EXPORT
#define DLL_CLASS_IMPORT
// Can't use extern "C" when DLL exporting a global
#define DLL_GLOBAL_EXPORT extern
#define DLL_GLOBAL_IMPORT extern
#else
#error "Unsupported Platform."
#endif
#ifndef _WIN32
#define FAKEFUNC (void *) 0
#else
#define FAKEFUNC __noop
#endif
// Used for standard calling conventions
#ifdef _WIN32
#define STDCALL __stdcall
#define FASTCALL __fastcall
#ifndef FORCEINLINE
#define FORCEINLINE __forceinline
#endif
#else
#define STDCALL
#define FASTCALL
#define FORCEINLINE inline
#endif
// Force a function call site -not- to inlined. (useful for profiling)
#define DONT_INLINE(a) (((int)(a)+1)?(a):(a))
// Pass hints to the compiler to prevent it from generating unnessecary / stupid code
// in certain situations. Several compilers other than MSVC also have an equivilent
// construct.
//
// Essentially the 'Hint' is that the condition specified is assumed to be true at
// that point in the compilation. If '0' is passed, then the compiler assumes that
// any subsequent code in the same 'basic block' is unreachable, and thus usually
// removed.
#ifdef _MSC_VER
#define HINT(THE_HINT) __assume((THE_HINT))
#else
#define HINT(THE_HINT) 0
#endif
// Marks the codepath from here until the next branch entry point as unreachable,
// and asserts if any attempt is made to execute it.
#define UNREACHABLE() { ASSERT(0); HINT(0); }
// In cases where no default is present or appropriate, this causes MSVC to generate
// as little code as possible, and throw an assertion in debug.
#define NO_DEFAULT default: UNREACHABLE();
#ifdef _WIN32
// Alloca defined for this platform
#define stackalloc( _size ) _alloca( _size )
#define stackfree( _p ) 0
#elif __linux__
// Alloca defined for this platform
#define stackalloc( _size ) alloca( _size )
#define stackfree( _p ) 0
#endif
#endif

774
include/engine/const.h Normal file
View file

@ -0,0 +1,774 @@
/***
*
* 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
//
// Constants shared by the engine and dlls
// This header file included by engine files and DLL files.
// Most came from server.h
// edict->flags
#define FL_FLY (1 << 0) // Changes the SV_Movestep() behavior to not need to be on ground
#define FL_SWIM (1 << 1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water)
#define FL_CONVEYOR (1 << 2)
#define FL_CLIENT (1 << 3)
#define FL_INWATER (1 << 4)
#define FL_MONSTER (1 << 5)
#define FL_GODMODE (1 << 6)
#define FL_NOTARGET (1 << 7)
#define FL_SKIPLOCALHOST (1 << 8) // Don't send entity to local host, it's predicting this entity itself
#define FL_ONGROUND (1 << 9) // At rest / on the ground
#define FL_PARTIALGROUND (1 << 10) // not all corners are valid
#define FL_WATERJUMP (1 << 11) // player jumping out of water
#define FL_FROZEN (1 << 12) // Player is frozen for 3rd person camera
#define FL_FAKECLIENT (1 << 13) // JAC: fake client, simulated server side; don't send network messages to them
#define FL_DUCKING (1 << 14) // Player flag -- Player is fully crouched
#define FL_FLOAT (1 << 15) // Apply floating force to this entity when in water
#define FL_GRAPHED (1 << 16) // worldgraph has this ent listed as something that blocks a connection
// UNDONE: Do we need these?
#define FL_IMMUNE_WATER (1 << 17)
#define FL_IMMUNE_SLIME (1 << 18)
#define FL_IMMUNE_LAVA (1 << 19)
#define FL_PROXY (1 << 20) // This is a spectator proxy
#define FL_ALWAYSTHINK (1 << 21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path)
#define FL_BASEVELOCITY (1 << 22) // Base velocity has been applied this frame (used to convert base velocity into momentum)
#define FL_MONSTERCLIP (1 << 23) // Only collide in with monsters who have FL_MONSTERCLIP set
#define FL_ONTRAIN (1 << 24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
#define FL_WORLDBRUSH (1 << 25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something)
#define FL_SPECTATOR (1 << 26) // This client is a spectator, don't run touch functions, etc.
#define FL_CUSTOMENTITY (1 << 29) // This is a custom entity
#define FL_KILLME (1 << 30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
#define FL_DORMANT (1 << 31) // Entity is dormant, no updates to client
// Goes into globalvars_t.trace_flags
#define FTRACE_SIMPLEBOX (1 << 0) // Traceline with a simple box
// walkmove modes
#define WALKMOVE_NORMAL 0 // normal walkmove
#define WALKMOVE_WORLDONLY 1 // doesn't hit ANY entities, no matter what the solid type
#define WALKMOVE_CHECKONLY 2 // move, but don't touch triggers
// edict->movetype values
#define MOVETYPE_NONE 0 // never moves
#define MOVETYPE_WALK 3 // Player only - moving on the ground
#define MOVETYPE_STEP 4 // gravity, special edge handling -- monsters use this
#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff
#define MOVETYPE_TOSS 6 // gravity/collisions
#define MOVETYPE_PUSH 7 // no clip to world, push and crush
#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity
#define MOVETYPE_FLYMISSILE 9 // extra size to monsters
#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces
#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
#define MOVETYPE_FOLLOW 12 // track movement of aiment
#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision)
// edict->solid values
// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves
// SOLID only effects OTHER entities colliding with this one when they move - UGH!
#define SOLID_NOT 0 // no interaction with other objects
#define SOLID_TRIGGER 1 // touch on edge, but not blocking
#define SOLID_BBOX 2 // touch on edge, block
#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
#define SOLID_BSP 4 // bsp clip, touch on edge, block
// edict->deadflag values
#define DEAD_NO 0 // alive
#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground
#define DEAD_DEAD 2 // dead. lying still.
#define DEAD_RESPAWNABLE 3
#define DEAD_DISCARDBODY 4
#define DAMAGE_NO 0
#define DAMAGE_YES 1
#define DAMAGE_AIM 2
// entity effects
#define EF_BRIGHTFIELD 1 // swirling cloud of particles
#define EF_MUZZLEFLASH 2 // single frame ELIGHT on entity attachment 0
#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin
#define EF_DIMLIGHT 8 // player flashlight
#define EF_INVLIGHT 16 // get lighting from ceiling
#define EF_NOINTERP 32 // don't interpolate the next frame
#define EF_LIGHT 64 // rocket flare glow sprite
#define EF_NODRAW 128 // don't draw entity
// entity flags
#define EFLAG_SLERP 1 // do studio interpolation of this entity
//
// temp entity events
//
#define TE_BEAMPOINTS 0 // beam effect between two points
// coord coord coord (start position)
// coord coord coord (end position)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_BEAMENTPOINT 1 // beam effect between point and entity
// short (start entity)
// coord coord coord (end position)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_GUNSHOT 2 // particle effect plus ricochet sound
// coord coord coord (position)
#define TE_EXPLOSION 3 // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps
// coord coord coord (position)
// short (sprite index)
// byte (scale in 0.1's)
// byte (framerate)
// byte (flags)
//
// The Explosion effect has some flags to control performance/aesthetic features:
#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion
#define TE_EXPLFLAG_NOADDITIVE 1 // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite)
#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights
#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)
#define TE_SMOKE 5 // alphablend sprite, move vertically 30 pps
// coord coord coord (position)
// short (sprite index)
// byte (scale in 0.1's)
// byte (framerate)
#define TE_TRACER 6 // tracer effect from point to point
// coord, coord, coord (start)
// coord, coord, coord (end)
#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters
// coord, coord, coord (start)
// coord, coord, coord (end)
// byte (life in 0.1's)
// byte (width in 0.1's)
// byte (amplitude in 0.01's)
// short (sprite model index)
#define TE_BEAMENTS 8
// short (start entity)
// short (end entity)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite
// coord coord coord (position)
#define TE_LAVASPLASH 10 // Quake1 lava splash
// coord coord coord (position)
#define TE_TELEPORT 11 // Quake1 teleport splash
// coord coord coord (position)
#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound
// coord coord coord (position)
// byte (starting color)
// byte (num colors)
#define TE_BSPDECAL 13 // Decal from the .BSP file
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// short (texture index of precached decal texture name)
// short (entity index)
// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity)
#define TE_IMPLOSION 14 // tracers moving toward a point
// coord, coord, coord (position)
// byte (radius)
// byte (count)
// byte (life in 0.1's)
#define TE_SPRITETRAIL 15 // line of moving glow sprites with gravity, fadeout, and collisions
// coord, coord, coord (start)
// coord, coord, coord (end)
// short (sprite index)
// byte (count)
// byte (life in 0.1's)
// byte (scale in 0.1's)
// byte (velocity along Vector in 10's)
// byte (randomness of velocity in 10's)
#define TE_BEAM 16 // obsolete
#define TE_SPRITE 17 // additive sprite, plays 1 cycle
// coord, coord, coord (position)
// short (sprite index)
// byte (scale in 0.1's)
// byte (brightness)
#define TE_BEAMSPRITE 18 // A beam with a sprite at the end
// coord, coord, coord (start position)
// coord, coord, coord (end position)
// short (beam sprite index)
// short (end sprite index)
#define TE_BEAMTORUS 19 // screen aligned beam ring, expands to max radius over lifetime
// coord coord coord (center position)
// coord coord coord (axis and radius)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_BEAMDISK 20 // disk that expands to max radius over lifetime
// coord coord coord (center position)
// coord coord coord (axis and radius)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_BEAMCYLINDER 21 // cylinder that expands to max radius over lifetime
// coord coord coord (center position)
// coord coord coord (axis and radius)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_BEAMFOLLOW 22 // create a line of decaying beam segments until entity stops moving
// short (entity:attachment to follow)
// short (sprite index)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte,byte,byte (color)
// byte (brightness)
#define TE_GLOWSPRITE 23
// coord, coord, coord (pos) short (model index) byte (scale / 10)
#define TE_BEAMRING 24 // connect a beam ring to two entities
// short (start entity)
// short (end entity)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)
#define TE_STREAK_SPLASH 25 // oriented shower of tracers
// coord coord coord (start position)
// coord coord coord (direction Vector)
// byte (color)
// short (count)
// short (base speed)
// short (ramdon velocity)
#define TE_BEAMHOSE 26 // obsolete
#define TE_DLIGHT 27 // dynamic light, effect world, minor entity effect
// coord, coord, coord (pos)
// byte (radius in 10's)
// byte byte byte (color)
// byte (brightness)
// byte (life in 10's)
// byte (decay rate in 10's)
#define TE_ELIGHT 28 // point entity light, no world effect
// short (entity:attachment to follow)
// coord coord coord (initial position)
// coord (radius)
// byte byte byte (color)
// byte (life in 0.1's)
// coord (decay rate)
#define TE_TEXTMESSAGE 29
// 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)
// 4 bytes r,g,b,a color1 (text color)
// 4 bytes r,g,b,a color2 (effect color)
// ushort 8.8 fadein time
// ushort 8.8 fadeout time
// ushort 8.8 hold time
// optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2)
// string text message (512 chars max sz string)
#define TE_LINE 30
// coord, coord, coord startpos
// coord, coord, coord endpos
// short life in 0.1 s
// 3 bytes r, g, b
#define TE_BOX 31
// coord, coord, coord boxmins
// coord, coord, coord boxmaxs
// short life in 0.1 s
// 3 bytes r, g, b
#define TE_KILLBEAM 99 // kill all beams attached to entity
// short (entity)
#define TE_LARGEFUNNEL 100
// coord coord coord (funnel position)
// short (sprite index)
// short (flags)
#define TE_BLOODSTREAM 101 // particle spray
// coord coord coord (start position)
// coord coord coord (spray Vector)
// byte (color)
// byte (speed)
#define TE_SHOWLINE 102 // line of particles every 5 units, dies in 30 seconds
// coord coord coord (start position)
// coord coord coord (end position)
#define TE_BLOOD 103 // particle spray
// coord coord coord (start position)
// coord coord coord (spray Vector)
// byte (color)
// byte (speed)
#define TE_DECAL 104 // Decal applied to a brush entity (not the world)
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name)
// short (entity index)
#define TE_FIZZ 105 // create alpha sprites inside of entity, float upwards
// short (entity)
// short (sprite index)
// byte (density)
#define TE_MODEL 106 // create a moving model that bounces and makes a sound when it hits
// coord, coord, coord (position)
// coord, coord, coord (velocity)
// angle (initial yaw)
// short (model index)
// byte (bounce sound type)
// byte (life in 0.1's)
#define TE_EXPLODEMODEL 107 // spherical shower of models, picks from set
// coord, coord, coord (origin)
// coord (velocity)
// short (model index)
// short (count)
// byte (life in 0.1's)
#define TE_BREAKMODEL 108 // box of models or sprites
// coord, coord, coord (position)
// coord, coord, coord (size)
// coord, coord, coord (velocity)
// byte (random velocity in 10's)
// short (sprite or model index)
// byte (count)
// byte (life in 0.1 secs)
// byte (flags)
#define TE_GUNSHOTDECAL 109 // decal and ricochet sound
// coord, coord, coord (position)
// short (entity index???)
// byte (decal???)
#define TE_SPRITE_SPRAY 110 // spay of alpha sprites
// coord, coord, coord (position)
// coord, coord, coord (velocity)
// short (sprite index)
// byte (count)
// byte (speed)
// byte (noise)
#define TE_ARMOR_RICOCHET 111 // quick spark sprite, client ricochet sound.
// coord, coord, coord (position)
// byte (scale in 0.1's)
#define TE_PLAYERDECAL 112 // ???
// byte (playerindex)
// coord, coord, coord (position)
// short (entity???)
// byte (decal number???)
// [optional] short (model index???)
#define TE_BUBBLES 113 // create alpha sprites inside of box, float upwards
// coord, coord, coord (min start position)
// coord, coord, coord (max start position)
// coord (float height)
// short (model index)
// byte (count)
// coord (speed)
#define TE_BUBBLETRAIL 114 // create alpha sprites along a line, float upwards
// coord, coord, coord (min start position)
// coord, coord, coord (max start position)
// coord (float height)
// short (model index)
// byte (count)
// coord (speed)
#define TE_BLOODSPRITE 115 // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent)
// coord, coord, coord (position)
// short (sprite1 index)
// short (sprite2 index)
// byte (color)
// byte (scale)
#define TE_WORLDDECAL 116 // Decal applied to the world brush
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name)
#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name - 256)
#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name - 256)
// short (entity index)
#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent)
// coord, coord, coord (position)
// coord, coord, coord (velocity)
// short (modelindex)
// byte (life)
// byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client).
#define TE_SPRAY 120 // Throws a shower of sprites or models
// coord, coord, coord (position)
// coord, coord, coord (direction)
// short (modelindex)
// byte (count)
// byte (speed)
// byte (noise)
// byte (rendermode)
#define TE_PLAYERSPRITES 121 // sprites emit from a player's bounding box (ONLY use for players!)
// byte (playernum)
// short (sprite modelindex)
// byte (count)
// byte (variance) (0 = no variance in size) (10 = 10% variance in size)
#define TE_PARTICLEBURST 122 // very similar to lavasplash.
// coord (origin)
// short (radius)
// byte (particle color)
// byte (duration * 10) (will be randomized a bit)
#define TE_FIREFIELD 123 // makes a field of fire.
// coord (origin)
// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius)
// short (modelindex)
// byte (count)
// byte (flags)
// byte (duration (in seconds) * 10) (will be randomized a bit)
//
// to keep network traffic low, this message has associated flags that fit into a byte:
#define TEFIRE_FLAG_ALLFLOAT 1 // all sprites will drift upwards as they animate
#define TEFIRE_FLAG_SOMEFLOAT 2 // some of the sprites will drift upwards. (50% chance)
#define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration.
#define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque
#define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube.
#define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent)
// byte (entity index of player)
// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset )
// short (model index)
// short (life * 10 );
#define TE_KILLPLAYERATTACHMENTS 125 // will expire all TENTS attached to a player.
// byte (entity index of player)
#define TE_MULTIGUNSHOT 126 // much more compact shotgun message
// This message is used to make a client approximate a 'spray' of gunfire.
// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is
// a good candidate for MULTIGUNSHOT use. (shotguns)
//
// NOTE: This effect makes the client do traces for each bullet, these client traces ignore
// entities that have studio models.Traces are 4096 long.
//
// coord (origin)
// coord (origin)
// coord (origin)
// coord (direction)
// coord (direction)
// coord (direction)
// coord (x noise * 100)
// coord (y noise * 100)
// byte (count)
// byte (bullethole decal texture index)
#define TE_USERTRACER 127 // larger message than the standard tracer, but allows some customization.
// coord (origin)
// coord (origin)
// coord (origin)
// coord (velocity)
// coord (velocity)
// coord (velocity)
// byte ( life * 10 )
// 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
#define MSG_INIT 3 // write to the init string
#define MSG_PVS 4 // Ents in PVS of org
#define MSG_PAS 5 // Ents in PAS of org
#define MSG_PVS_R 6 // Reliable to PVS
#define MSG_PAS_R 7 // Reliable to PAS
#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped )
#define MSG_SPEC 9 // Sends to all spectator proxies
// contents of a spot in the world
#define CONTENTS_EMPTY -1
#define CONTENTS_SOLID -2
#define CONTENTS_WATER -3
#define CONTENTS_SLIME -4
#define CONTENTS_LAVA -5
#define CONTENTS_SKY -6
#define CONTENTS_LADDER -16
#define CONTENT_FLYFIELD -17
#define CONTENT_GRAVITY_FLYFIELD -18
#define CONTENT_FOG -19
#define CONTENT_EMPTY -1
#define CONTENT_SOLID -2
#define CONTENT_WATER -3
#define CONTENT_SLIME -4
#define CONTENT_LAVA -5
#define CONTENT_SKY -6
// channels
#define CHAN_AUTO 0
#define CHAN_WEAPON 1
#define CHAN_VOICE 2
#define CHAN_ITEM 3
#define CHAN_BODY 4
#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area
#define CHAN_STATIC 6 // allocate channel from the static area
#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network
#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END).
// attenuation values
#define ATTN_NONE 0
#define ATTN_NORM (float)0.8
#define ATTN_IDLE (float)2
#define ATTN_STATIC (float)1.25
// pitch values
#define PITCH_NORM 100 // non-pitch shifted
#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high
#define PITCH_HIGH 120
// volume values
#define VOL_NORM 1.0
// plats
#define PLAT_LOW_TRIGGER 1
// Trains
#define SF_TRAIN_WAIT_RETRIGGER 1
#define SF_TRAIN_START_ON 4 // Train is initially moving
#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains
// buttons
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15)
// Break Model Defines
#define BREAK_TYPEMASK 0x4F
#define BREAK_GLASS 0x01
#define BREAK_METAL 0x02
#define BREAK_FLESH 0x04
#define BREAK_WOOD 0x08
#define BREAK_SMOKE 0x10
#define BREAK_TRANS 0x20
#define BREAK_CONCRETE 0x40
#define BREAK_2 0x80
// Colliding temp entity sounds
#define BOUNCE_GLASS BREAK_GLASS
#define BOUNCE_METAL BREAK_METAL
#define BOUNCE_FLESH BREAK_FLESH
#define BOUNCE_WOOD BREAK_WOOD
#define BOUNCE_SHRAP 0x10
#define BOUNCE_SHELL 0x20
#define BOUNCE_CONCRETE BREAK_CONCRETE
#define BOUNCE_SHOTSHELL 0x80
// Temp entity bounce sound types
#define TE_BOUNCE_NULL 0
#define TE_BOUNCE_SHELL 1
#define TE_BOUNCE_SHOTSHELL 2
// Rendering constants
enum
{
kRenderNormal, // src
kRenderTransColor, // c*a+dest*(1-a)
kRenderTransTexture, // src*a+dest*(1-a)
kRenderGlow, // src*a+dest -- No Z buffer checks
kRenderTransAlpha, // src*srca+dest*(1-srca)
kRenderTransAdd, // src*a+dest
};
enum
{
kRenderFxNone = 0,
kRenderFxPulseSlow,
kRenderFxPulseFast,
kRenderFxPulseSlowWide,
kRenderFxPulseFastWide,
kRenderFxFadeSlow,
kRenderFxFadeFast,
kRenderFxSolidSlow,
kRenderFxSolidFast,
kRenderFxStrobeSlow,
kRenderFxStrobeFast,
kRenderFxStrobeFaster,
kRenderFxFlickerSlow,
kRenderFxFlickerFast,
kRenderFxNoDissipation,
kRenderFxDistort, // Distort/scale/translate flicker
kRenderFxHologram, // kRenderFxDistort + distance fade
kRenderFxDeadPlayer, // kRenderAmt is the player index
kRenderFxExplode, // Scale up really big!
kRenderFxGlowShell, // Glowing Shell
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
};
typedef int func_t;
typedef int string_t;
typedef unsigned char byte;
typedef unsigned short word;
#define _DEF_BYTE_
#undef true
#undef false
#ifndef __cplusplus
typedef enum
{ false, true } int;
#else
#endif
typedef struct
{
byte r, g, b;
} color24;
typedef struct
{
unsigned r, g, b, a;
} colorVec;
#ifdef _WIN32
#pragma pack(push,2)
#endif
typedef struct
{
unsigned short r, g, b, a;
} PackedColorVec;
#ifdef _WIN32
#pragma pack(pop)
#endif
typedef struct link_s
{
struct link_s *prev, *next;
} link_t;
typedef struct edict_s edict_t;
typedef struct
{
vec3_t normal;
float dist;
} plane_t;
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;
float fraction; // time completed, 1.0 = didn't hit anything
vec3_t endpos; // final position
plane_t plane; // surface normal at impact
edict_t *ent; // entity the surface is on
int hitgroup; // 0 == generic, non zero is specific body part
} trace_t;
#endif

47
include/engine/dllapi.h Normal file
View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
*
* This file is part of Metamod.
*
* Metamod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* Metamod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Metamod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
// Simplified version by Wei Mingzhi
#ifndef DLLAPI_H
#define DLLAPI_H
#undef DLLEXPORT
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#elif defined(linux) || defined (__APPLE__)
#define DLLEXPORT /* */
#define WINAPI /* */
#endif /* linux */
#define C_DLLEXPORT extern "C" DLLEXPORT
#endif /* DLLAPI_H */

398
include/engine/eiface.h Normal file
View file

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

View file

@ -0,0 +1,145 @@
/***
*
* 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 = NULL, edict_t *ed = NULL)
{
(*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) : NULL);
#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

122
include/engine/extdll.h Normal file
View file

@ -0,0 +1,122 @@
/***
*
* 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 DLL_DEBUG
#define DEBUG 1
#endif
#ifdef _WIN32
#pragma warning (disable : 4244) // int or float down-conversion
#pragma warning (disable : 4305) // int or float data truncation
#pragma warning (disable : 4201) // nameless struct/union
#pragma warning (disable : 4514) // unreferenced inline function removed
#pragma warning (disable : 4100) // unreferenced formal parameter
#pragma warning (disable : 4715) // not all control paths return a value
#pragma warning (disable : 4996) // function was declared deprecated
#pragma warning (disable : 4702) // unreachable code
#pragma warning (disable : 4706) // assignment within conditional expression
/* (dz): disable deprecation warnings concerning unsafe CRT functions */
#if !defined _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOWINRES
#define NOSERVICE
#define NOMCX
#define NOIME
#include "windows.h"
#include "winsock2.h"
#else // _WIN32
#define FALSE 0
#define TRUE (!FALSE)
typedef unsigned long ULONG;
typedef unsigned char BYTE;
typedef int BOOL;
#define MAX_PATH PATH_MAX
#include <limits.h>
#include <stdarg.h>
#ifndef min
#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)
#endif
#endif //_WIN32
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include <archtypes.h>
typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h
#include "corelib.h"
#define vec3_t Vector
#include "const.h"
#include "progdefs.h"
#define MAX_ENT_LEAFS 48
struct edict_s
{
int free;
int serialnumber;
link_t area; // linked to a division node or leaf
int headnode; // -1 to use normal leaf check
int num_leafs;
short leafnums[MAX_ENT_LEAFS];
float freetime; // sv.time when the object was freed
void *pvPrivateData; // Alloced and freed by engine, used by DLLs
entvars_t v; // C exported fields from progs
};
#include "eiface.h"
#define MAX_WEAPON_SLOTS 5 // hud item selection slots
#define MAX_ITEM_TYPES 6 // hud item selection slots
#define MAX_ITEMS 5 // hard coded item types
#define HIDEHUD_WEAPONS ( 1 << 0 )
#define HIDEHUD_FLASHLIGHT ( 1 << 1 )
#define HIDEHUD_ALL ( 1 << 2 )
#define HIDEHUD_HEALTH ( 1 << 3 )
#define MAX_AMMO_TYPES 32 // ???
#define MAX_AMMO_SLOTS 32 // not really slots
#define HUD_PRINTNOTIFY 1
#define HUD_PRINTCONSOLE 2
#define HUD_PRINTTALK 3
#define HUD_PRINTCENTER 4
#define WEAPON_SUIT 31
#define __USE_GNU 1
#endif //EXTDLL_H

265
include/engine/meta_api.h Normal file
View file

@ -0,0 +1,265 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef META_API_H
#define META_API_H
typedef int (*GameAPI_t) (gamefuncs_t *, int);
typedef int (*GameAPI2_t) (gamefuncs_t *, int *);
typedef int (*NewAPI2_t) (gamefuncs_t *, int *);
typedef int (*EngineAPI_t) (enginefuncs_t *, int *);
typedef int (*GETENTITYAPI_FN) (gamefuncs_t *pFunctionTable, int interfaceVersion);
typedef int (*GETENTITYAPI2_FN) (gamefuncs_t *pFunctionTable, int *interfaceVersion);
typedef int (*GETNEWDLLFUNCTIONS_FN) (newgamefuncs_t *pFunctionTable, int *interfaceVersion);
typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
C_DLLEXPORT int GetEntityAPI (gamefuncs_t *pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetEntityAPI2 (gamefuncs_t *pFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions (newgamefuncs_t *pNewFunctionTable, int *interfaceVersion);
#define META_INTERFACE_VERSION "5:13"
typedef enum
{
PT_NEVER = 0,
PT_STARTUP,
PT_CHANGELEVEL,
PT_ANYTIME,
PT_ANYPAUSE,
} PLUG_LOADTIME;
typedef struct
{
char *ifvers;
char *name;
char *version;
char *date;
char *author;
char *url;
char *logtag;
PLUG_LOADTIME loadable;
PLUG_LOADTIME unloadable;
} plugin_info_t;
extern plugin_info_t Plugin_info;
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
{
MRES_UNSET = 0,
MRES_IGNORED,
MRES_HANDLED,
MRES_OVERRIDE,
MRES_SUPERCEDE,
} META_RES;
typedef struct meta_globals_s
{
META_RES mres;
META_RES prev_mres;
META_RES status;
void *orig_ret;
void *override_ret;
} meta_globals_t;
extern meta_globals_t *gpMetaGlobals;
#define SET_META_RESULT(result) gpMetaGlobals->mres=result
#define RETURN_META(result) { gpMetaGlobals->mres=result; return; }
#define RETURN_META_VALUE(result, value) { gpMetaGlobals->mres=result; return(value); }
#define META_RESULT_STATUS gpMetaGlobals->status
#define 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
{
GETENTITYAPI_FN pfnGetEntityAPI;
GETENTITYAPI_FN pfnGetEntityAPI_Post;
GETENTITYAPI2_FN pfnGetEntityAPI2;
GETENTITYAPI2_FN pfnGetEntityAPI2_Post;
GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions;
GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions_Post;
GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions;
GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions_Post;
} metamod_funcs_t;
#include "util.h"
// max buffer size for printed messages
#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;
// Meta Utility Function table type.
typedef struct meta_util_funcs_s
{
void (*pfnLogConsole) (plid_t plid, const char *szFormat, ...);
void (*pfnLogMessage) (plid_t plid, const char *szFormat, ...);
void (*pfnLogError) (plid_t plid, const char *szFormat, ...);
void (*pfnLogDeveloper) (plid_t plid, const char *szFormat, ...);
void (*pfnCenterSay) (plid_t plid, const char *szFormat, ...);
void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, const char *szFormat, ...);
void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, const char *szFormat, va_list ap);
int (*pfnCallGameEntity) (plid_t plid, const char *entStr, entvars_t *pev);
int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size);
const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size);
const char *(*pfnGetPluginPath) (plid_t plid);
const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag);
int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle);
int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
const char *(*pfnIsQueryingClienCVar_t) (plid_t plid, const edict_t *player);
int (*pfnMakeRequestID) (plid_t plid);
void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, gamefuncs_t **pdll, newgamefuncs_t **pnewdll);
} mutil_funcs_t;
typedef struct
{
gamefuncs_t *dllapi_table;
newgamefuncs_t *newapi_table;
} gamedll_funcs_t;
extern gamedll_funcs_t *gpGamedllFuncs;
extern mutil_funcs_t *gpMetaUtilFuncs;
extern meta_globals_t *gpMetaGlobals;
extern metamod_funcs_t gMetaFunctionTable;
C_DLLEXPORT void Meta_Init (void);
typedef void (*META_INIT_FN) (void);
C_DLLEXPORT int Meta_Query (char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);
typedef int (*META_QUERY_FN) (char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);
C_DLLEXPORT int Meta_Attach (PLUG_LOADTIME now, metamod_funcs_t *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, metamod_funcs_t *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
C_DLLEXPORT int Meta_Detach (PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
C_DLLEXPORT int GetEntityAPI_Post (gamefuncs_t *pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetEntityAPI2_Post (gamefuncs_t *pFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions_Post (newgamefuncs_t *pNewFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetEngineFunctions (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
C_DLLEXPORT int GetEngineFunctions_Post (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
#define MDLL_FUNC gpGamedllFuncs->dllapi_table
#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
#define MDLL_Spawn MDLL_FUNC->pfnSpawn
#define MDLL_Think MDLL_FUNC->pfnThink
#define MDLL_Use MDLL_FUNC->pfnUse
#define MDLL_Touch MDLL_FUNC->pfnTouch
#define MDLL_Blocked MDLL_FUNC->pfnBlocked
#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue
#define MDLL_Save MDLL_FUNC->pfnSave
#define MDLL_Restore MDLL_FUNC->pfnRestore
#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox
#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields
#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields
#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState
#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState
#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState
#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect
#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect
#define MDLL_ClientKill MDLL_FUNC->pfnClientKill
#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer
#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand
#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged
#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate
#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate
#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink
#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink
#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame
#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel
#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel
#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription
#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization
#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect
#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect
#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink
#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error
#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move
#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init
#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType
#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility
#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData
#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack
#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline
#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders
#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData
#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart
#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd
#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket
#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds
#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines
#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile
#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation
#define MNEW_FUNC gpGamedllFuncs->newapi_table
#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData
#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown
#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide
#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue
#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2
// convenience macros for metautil functions
#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole)
#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage)
#define LOG_MMERROR (*gpMetaUtilFuncs->pfnLogError)
#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper)
#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay)
#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms)
#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs)
#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity)
#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID)
#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName)
#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath)
#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo)
#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin)
#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin)
#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle)
#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClienCVar_t)
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID)
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
uint16 FixedUnsigned16 (float fValue, float fScale);
short FixedSigned16 (float fValue, float fScale);
#endif

14
include/engine/mutil.h Normal file
View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef MUTIL_H
#define MUTIL_H
#include "plinfo.h"
#include "sdk_util.h"
#endif /* MUTIL_H */

11
include/engine/plinfo.h Normal file
View file

@ -0,0 +1,11 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef PLINFO_H
#define PLINFO_H
#endif

222
include/engine/progdefs.h Normal file
View file

@ -0,0 +1,222 @@
/***
*
* 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
{
float time;
float frametime;
float force_retouch;
string_t mapname;
string_t startspot;
float deathmatch;
float coop;
float teamplay;
float serverflags;
float found_secrets;
vec3_t v_forward;
vec3_t v_up;
vec3_t v_right;
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
edict_t *trace_ent;
float trace_inopen;
float trace_inwater;
int trace_hitgroup;
int trace_flags;
int msg_entity;
int cdAudioTrack;
int maxClients;
int maxEntities;
const char *pStringBase;
void *pSaveData;
vec3_t vecLandmarkOffset;
} globalvars_t;
typedef struct entvars_s
{
string_t classname;
string_t globalname;
vec3_t origin;
vec3_t oldorigin;
vec3_t velocity;
vec3_t basevelocity;
vec3_t clbasevelocity; // Base velocity that was passed in to server physics so
// client can predict conveyors correctly. Server zeroes it, so we need to store here, too.
vec3_t movedir;
vec3_t angles; // Model angles
vec3_t avelocity; // angle velocity (degrees per second)
vec3_t punchangle; // auto-decaying view angle adjustment
vec3_t v_angle; // Viewing angle (player only)
// For parametric entities
vec3_t endpos;
vec3_t startpos;
float impacttime;
float starttime;
int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity
float idealpitch;
float pitch_speed;
float ideal_yaw;
float yaw_speed;
int modelindex;
string_t model;
int viewmodel; // player's viewmodel
int weaponmodel; // what other players see
vec3_t absmin; // BB max translated to world coord
vec3_t absmax; // BB max translated to world coord
vec3_t mins; // local BB min
vec3_t maxs; // local BB max
vec3_t size; // maxs - mins
float ltime;
float nextthink;
int movetype;
int solid;
int skin;
int body; // sub-model selection for studiomodels
int effects;
float gravity; // % of "normal" gravity
float friction; // inverse elasticity of MOVETYPE_BOUNCE
int light_level;
int sequence; // animation sequence
int gaitsequence; // movement animation sequence for player (0 for none)
float frame; // % playback position in animation sequences (0..255)
float animtime; // world time when frame was set
float framerate; // animation playback rate (-8x to 8x)
byte controller[4]; // bone controller setting (0..255)
byte blending[2]; // blending amount between sub-sequences (0..255)
float scale; // sprite rendering scale (0..255)
int rendermode;
float renderamt;
vec3_t rendercolor;
int renderfx;
float health;
float frags;
int weapons; // bit mask for available weapons
float takedamage;
int deadflag;
vec3_t view_ofs; // eye position
int button;
int impulse;
edict_t *chain; // Entity pointer when linked into a linked list
edict_t *dmg_inflictor;
edict_t *enemy;
edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW
edict_t *owner;
edict_t *groundentity;
int spawnflags;
int flags;
int colormap; // lowbyte topcolor, highbyte bottomcolor
int team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
int waterlevel;
int watertype;
string_t target;
string_t targetname;
string_t netname;
string_t message;
float dmg_take;
float dmg_save;
float dmg;
float dmgtime;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
float speed;
float air_finished;
float pain_finished;
float radsuit_finished;
edict_t *pContainingEntity;
int playerclass;
float maxspeed;
float fov;
int weaponanim;
int pushmsec;
int bInDuck;
int flTimeStepSound;
int flSwimTime;
int flDuckTime;
int iStepLeft;
float flFallVelocity;
int gamestate;
int oldbuttons;
int groupinfo;
// For mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
vec3_t vuser1;
vec3_t vuser2;
vec3_t vuser3;
vec3_t vuser4;
edict_t *euser1;
edict_t *euser2;
edict_t *euser3;
edict_t *euser4;
} entvars_t;
#endif

23
include/engine/sdk_util.h Normal file
View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef SDK_UTIL_H
#define SDK_UTIL_H
#ifdef DEBUG
#undef DEBUG
#endif
#include <util.h>
short FixedSigned16 (float value, float scale);
unsigned short FixedUnsigned16 (float value, float scale);
#endif

346
include/engine/util.h Normal file
View file

@ -0,0 +1,346 @@
/***
*
* 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;
// 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);
}
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))
// Pointer operators
#define PTR_TO_BYTE(in) *(byte *) (in)
#define PTR_TO_FLT(in) *(float *) (in)
#define PTR_TO_INT(in) *(int *) (in)
#define PTR_TO_STR(in) (char *) (in)
// 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
#define M_PI 3.1415926
//
// Conversion among the three types of "entity", including identity-conversions.
//
static inline edict_t *ENT (const entvars_t *pev)
{
return pev->pContainingEntity;
}
static inline edict_t *ENT (edict_t *pent)
{
return pent;
}
static inline edict_t *ENT (EOFFSET eoffset)
{
return (*g_engfuncs.pfnPEntityOfEntOffset) (eoffset);
}
static inline EOFFSET OFFSET (EOFFSET eoffset)
{
return eoffset;
}
static inline EOFFSET OFFSET (const edict_t *pent)
{
#if _DEBUG
if (!pent)
ALERT (at_error, "Bad ent in OFFSET()\n");
#endif
return (*g_engfuncs.pfnEntOffsetOfPEntity) (pent);
}
static inline EOFFSET OFFSET (entvars_t *pev)
{
#if _DEBUG
if (!pev)
ALERT (at_error, "Bad pev in OFFSET()\n");
#endif
return OFFSET (ENT (pev));
}
static inline entvars_t *VARS (entvars_t *pev)
{
return pev;
}
static inline entvars_t *VARS (edict_t *pent)
{
if (!pent)
return NULL;
return &pent->v;
}
static inline entvars_t *VARS (EOFFSET eoffset)
{
return VARS (ENT (eoffset));
}
static inline int ENTINDEX (edict_t *ent)
{
return (*g_engfuncs.pfnIndexOfEdict) (ent);
}
static inline edict_t *INDEXENT (int iEdictNum)
{
return (*g_engfuncs.pfnPEntityOfEntIndex) (iEdictNum);
}
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 (ent));
}
// Testing the three types of "entity" for nullity
#define eoNullEntity 0
static inline BOOL FNullEnt (EOFFSET eoffset)
{
return eoffset == 0;
}
static inline BOOL FNullEnt (entvars_t *pev)
{
return pev == NULL || FNullEnt (OFFSET (pev));
}
static inline int FNullEnt (const edict_t *pent)
{
return !pent || !(*g_engfuncs.pfnEntOffsetOfPEntity) (pent);
}
// Testing strings for nullity
#define iStringNull 0
static inline BOOL FStringNull (int stingPtr)
{
return stingPtr == iStringNull;
}
#define cchMapNameMost 32
#define SAFE_FUNCTION_CALL(pfn,args) try { pfn args; } catch (...) { }
// Dot products for view cone checking
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks
#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks
#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks
// 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 (VARS (pent)->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 int (*tMenuCallback) (edict_t *, int);
typedef struct hudtextparms_s
{
float x;
float y;
int effect;
byte r1, g1, b1, a1;
byte r2, g2, b2, a2;
float fadeinTime;
float fadeoutTime;
float holdTime;
float fxTime;
int channel;
} hudtextparms_t;
extern Vector GetEntityOrigin (entvars_t *pevBModel);
#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation
#define AMBIENT_SOUND_EVERYWHERE 1
#define AMBIENT_SOUND_SMALLRADIUS 2
#define AMBIENT_SOUND_MEDIUMRADIUS 4
#define AMBIENT_SOUND_LARGERADIUS 8
#define AMBIENT_SOUND_START_SILENT 16
#define AMBIENT_SOUND_NOT_LOOPING 32
#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements
#define SND_SPAWNING (1 << 8) // duplicated in protocol.h we're spawing, used in some cases for ambients
#define SND_STOP (1 << 5) // duplicated in protocol.h stop sound
#define SND_CHANGE_VOL (1 << 6) // duplicated in protocol.h change sound vol
#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch
#define LFO_SQUARE 1
#define LFO_TRIANGLE 2
#define LFO_RANDOM 3
// func_rotating
#define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1
#define SF_BRUSH_ROTATE_BACKWARDS 2
#define SF_BRUSH_ROTATE_Z_AXIS 4
#define SF_BRUSH_ROTATE_X_AXIS 8
#define SF_PENDULUM_AUTO_RETURN 16
#define SF_PENDULUM_PASSABLE 32
#define SF_BRUSH_ROTATE_SMALLRADIUS 128
#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256
#define SF_BRUSH_ROTATE_LARGERADIUS 512
#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_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 SVC_TEMPENTITY 23
#define SVC_INTERMISSION 30
#define SVC_CDTRACK 32
#define SVC_WEAPONANIM 35
#define SVC_ROOMTYPE 37
#define SVC_DIRECTOR 51
// triggers
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
// func breakable
#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger
#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass)
#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it
#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar
// func_pushable (it's also func_breakable, so don't collide with those flags)
#define SF_PUSH_BREAKABLE 128
#define SF_LIGHT_START_OFF 1
#define SPAWNFLAG_NOMESSAGE 1
#define SPAWNFLAG_NOTOUCH 1
#define SPAWNFLAG_DROIDONLY 4
#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons)
#define TELE_PLAYER_ONLY 1
#define TELE_SILENT 2
#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);
}
/// ///
// Bot Additions //
/// ///
// removes linker warning when using msvcrt library
#if defined ( _MSC_VER )
#define stricmp _stricmp
#define unlink _unlink
#define mkdir _mkdir
#endif
// 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

101
include/globals.h Normal file
View file

@ -0,0 +1,101 @@
//
// Copyright (c) 2014, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Version: $Id:$
//
#ifndef GLOBALS_INCLUDED
#define GLOBALS_INCLUDED
extern bool g_canSayBombPlanted;
extern bool g_bombPlanted;
extern bool g_bombSayString;
extern bool g_roundEnded;
extern bool g_radioInsteadVoice;
extern bool g_waypointOn;
extern bool g_waypointsChanged;
extern bool g_autoWaypoint;
extern bool g_botsCanPause;
extern bool g_editNoclip;
extern bool g_isMetamod;
extern bool g_isFakeCommand;
extern bool g_sendAudioFinished;
extern bool g_isCommencing;
extern bool g_leaderChoosen[2];
extern float g_autoPathDistance;
extern float g_timeBombPlanted;
extern float g_timeNextBombUpdate;
extern float g_lastChatTime;
extern float g_timeRoundEnd;
extern float g_timeRoundMid;
extern float g_timeNextBombUpdate;
extern float g_timeRoundStart;
extern float g_lastRadioTime[2];
extern int g_mapType;
extern int g_numWaypoints;
extern int g_gameVersion;
extern int g_fakeArgc;
extern int g_killHistory;
extern int g_normalWeaponPrefs[NUM_WEAPONS];
extern int g_rusherWeaponPrefs[NUM_WEAPONS];
extern int g_carefulWeaponPrefs[NUM_WEAPONS];
extern int g_grenadeBuyPrecent[NUM_WEAPONS - 23];
extern int g_botBuyEconomyTable[NUM_WEAPONS - 15];
extern int g_radioSelect[32];
extern int g_lastRadio[2];
extern int g_storeAddbotVars[4];
extern int *g_weaponPrefs[];
extern short g_modelIndexLaser;
extern short g_modelIndexArrow;
extern char g_fakeArgv[256];
extern Array <Array <String> > g_chatFactory;
extern Array <Array <ChatterItem> > g_chatterFactory;
extern Array <BotName> g_botNames;
extern Array <KeywordFactory> g_replyFactory;
extern RandGen g_randGen;
extern FireDelay g_fireDelay[NUM_WEAPONS + 1];
extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1];
extern WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
extern Client g_clients[32];
extern MenuText g_menus[21];
extern SkillDefinition g_skillTab[6];
extern TaskItem g_taskFilters[];
extern Experience *g_experienceData;
extern edict_t *g_hostEntity;
extern edict_t *g_worldEdict;
extern Library *g_gameLib;
extern gamefuncs_t g_functionTable;
extern EntityAPI_t g_entityAPI;
extern FuncPointers_t g_funcPointers;
extern NewEntityAPI_t g_getNewEntityAPI;
extern BlendAPI_t g_serverBlendingAPI;
#endif // GLOBALS_INCLUDED

64
include/resource.h Normal file
View file

@ -0,0 +1,64 @@
//
// Copyright (c) 2014, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Version: $Id:$
//
#ifndef RESOURCE_INCLUDED
#define RESOURCE_INCLUDED
// general product information
#define PRODUCT_NAME "YaPB"
#define PRODUCT_VERSION "2.6"
#define PRODUCT_AUTHOR "YaPB Dev Team"
#define PRODUCT_URL "http://yapb.jeefo.net/"
#define PRODUCT_EMAIL "yapb@jeefo.net"
#define PRODUCT_LOGTAG "YAPB"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike 1.6 Bot"
#define PRODUCT_COPYRIGHT "Copyright © 2014, 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 "podbot"
#define PRODUCT_VERSION_DWORD 2,6,0 // major version, minor version, WIP (or Update) version, BUILD number (generated with RES file)
#define PRODUCT_SUPPORT_VERSION "1.4 - CZ"
#define PRODUCT_DATE __DATE__
// product optimization type (we're not using crt builds anymore)
#ifndef PRODUCT_OPT_TYPE
#if defined (_DEBUG)
# if defined (_AFXDLL)
# define PRODUCT_OPT_TYPE "Debug Build (CRT)"
# else
# define PRODUCT_OPT_TYPE "Debug Build"
# endif
#elif defined (NDEBUG)
# if defined (_AFXDLL)
# define PRODUCT_OPT_TYPE "Optimized Build (CRT)"
# else
# define PRODUCT_OPT_TYPE "Optimized Build"
# endif
#else
# define PRODUCT_OPT_TYPE "Default Release"
#endif
#endif
#endif // RESOURCE_INCLUDED

71
project/makefile Normal file
View file

@ -0,0 +1,71 @@
#
# Copyright (c) 2014, by Yet Another POD-Bot Development Team.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# $Id$
#
MODNAME = yapb
SYSTEM = ../source
OBJ = ${SYSTEM}/basecode.o \
${SYSTEM}/botmanager.o \
${SYSTEM}/chatlib.o \
${SYSTEM}/combat.o \
${SYSTEM}/globals.o \
${SYSTEM}/interface.o \
${SYSTEM}/navigate.o \
${SYSTEM}/netmsg.o \
${SYSTEM}/support.o \
${SYSTEM}/waypoint.o \
CCOPT = -w -O3 -m32 -s -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe -fvisibility-inlines-hidden -fvisibility=hidden
CCDEBUG = -ggdb -w -DDEBUG=1 -fpermissive
CFLAGS = $(CCOPT) -I../include/engine -I../include
#CFLAGS = $(CCDEBUG) -I../include/engine -I../include
BASEFLAGS = -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp
CPPFLAGS = ${BASEFLAGS} ${CFLAGS}
OS := $(shell uname -s)
ifeq "$(OS)" "Darwin"
CPP=clang
SUFFIX=dylib
LINK=-m32 -dynamiclib -mmacosx-version-min=10.5
CPPLIB=-ldl -lm -lstdc++
else
CPP=gcc
SUFFIX=so
LINK=-m32 -shared -static-libgcc
CPPLIB=-ldl -lm -lsupc++
endif
BINARY=${MODNAME}.${SUFFIX}
${MODNAME}: ${OBJ}
${CPP} ${LINK} ${OBJ} ${CPPLIB} -o ${BINARY}
clean:
-rm -f ${SYSTEM}/*.o
-rm -f ${BINARY}
%.o: %.cpp
${CPP} ${CPPFLAGS} -c $< -o $@

40
project/yapb.sln Normal file
View file

@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yapb", "yapb.vcxproj", "{C232645A-3B99-48F4-A1F3-F20CF0A9568B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_Mmgr|Any CPU = Debug_Mmgr|Any CPU
Debug_Mmgr|Mixed Platforms = Debug_Mmgr|Mixed Platforms
Debug_Mmgr|Win32 = Debug_Mmgr|Win32
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug_Mmgr|Any CPU.ActiveCfg = Debug_Mmgr|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug_Mmgr|Mixed Platforms.ActiveCfg = Debug_Mmgr|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug_Mmgr|Mixed Platforms.Build.0 = Debug_Mmgr|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug_Mmgr|Win32.ActiveCfg = Debug_Mmgr|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug_Mmgr|Win32.Build.0 = Debug_Mmgr|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug|Win32.ActiveCfg = Debug|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Debug|Win32.Build.0 = Debug|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Release|Any CPU.ActiveCfg = Release|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Release|Mixed Platforms.Build.0 = Release|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Release|Win32.ActiveCfg = Release|Win32
{C232645A-3B99-48F4-A1F3-F20CF0A9568B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

331
project/yapb.vcxproj Normal file
View file

@ -0,0 +1,331 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug_Mmgr|Win32">
<Configuration>Debug_Mmgr</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\compress.h" />
<ClInclude Include="..\include\core.h" />
<ClInclude Include="..\include\corelib.h" />
<ClInclude Include="..\include\engine\archtypes.h" />
<ClInclude Include="..\include\engine\const.h" />
<ClInclude Include="..\include\engine\dllapi.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\mutil.h" />
<ClInclude Include="..\include\engine\plinfo.h" />
<ClInclude Include="..\include\engine\progdefs.h" />
<ClInclude Include="..\include\engine\sdk_util.h" />
<ClInclude Include="..\include\engine\util.h" />
<ClInclude Include="..\include\globals.h" />
<ClInclude Include="..\include\resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\basecode.cpp" />
<ClCompile Include="..\source\botmanager.cpp" />
<ClCompile Include="..\source\chatlib.cpp" />
<ClCompile Include="..\source\combat.cpp" />
<ClCompile Include="..\source\globals.cpp" />
<ClCompile Include="..\source\interface.cpp" />
<ClCompile Include="..\source\navigate.cpp" />
<ClCompile Include="..\source\netmsg.cpp" />
<ClCompile Include="..\source\support.cpp" />
<ClCompile Include="..\source\waypoint.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="yapb.rc" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C232645A-3B99-48F4-A1F3-F20CF0A9568B}</ProjectGuid>
<RootNamespace>yapb</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Mmgr|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>Intel C++ Compiler XE 14.0</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>Intel C++ Compiler XE 14.0</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>Intel C++ Compiler XE 14.0</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Mmgr|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.21005.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\debug\</OutDir>
<IntDir>.\debug\inf\</IntDir>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
<LinkIncremental>true</LinkIncremental>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\release\</OutDir>
<IntDir>.\release\inf\</IntDir>
<IgnoreImportLibrary>false</IgnoreImportLibrary>
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Mmgr|Win32'">
<OutDir>$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
<LinkIncremental>true</LinkIncremental>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent>
<Command>..\..\tool\buildup\release\buildup.exe yapb.rc</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command />
</CustomBuildStep>
<Midl>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
<TypeLibraryName>.\debug/yapb.tlb</TypeLibraryName>
<HeaderFileName />
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader />
<PrecompiledHeaderFile>core.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\debug\inf\yapb.pch</PrecompiledHeaderOutputFile>
<ExpandAttributedSource>false</ExpandAttributedSource>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<AssemblerListingLocation>.\debug\asm\</AssemblerListingLocation>
<ObjectFileName>.\debug\obj\</ObjectFileName>
<ProgramDataBaseFileName>.\debug\inf</ProgramDataBaseFileName>
<BrowseInformation />
<BrowseInformationFile />
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<PreLinkEvent>
<Command />
</PreLinkEvent>
<Link>
<OutputFile>.\debug\yapb.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<ProgramDatabaseFile>.\debug\inf\yapb.pdb</ProgramDatabaseFile>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>.\debug\inf\yapb.map</MapFileName>
<MapExports>true</MapExports>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
<NoEntryPoint>false</NoEntryPoint>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention />
<ImportLibrary>.\debug\inf\yapb.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy "$(TargetPath)" "d:\steam\SteamApps\common\Half-Life\cstrike\addons\yapb\dlls" /y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
<Command>..\..\tool\buildup\release\buildup.exe yapb.rc</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command />
</CustomBuildStep>
<Midl>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
<TypeLibraryName>.\Release/yapb.tlb</TypeLibraryName>
<HeaderFileName />
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StructMemberAlignment>8Bytes</StructMemberAlignment>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>false</FunctionLevelLinking>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>core.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\release\asm\</AssemblerListingLocation>
<ObjectFileName>.\release\obj\</ObjectFileName>
<ProgramDataBaseFileName>.\release\inf\</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAs>CompileAsCpp</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InterproceduralOptimization>SingleFile</InterproceduralOptimization>
<FlushDenormalResultsToZero>true</FlushDenormalResultsToZero>
<Parallelization>false</Parallelization>
<Optimization>MaxSpeedHighLevel</Optimization>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
<ResourceOutputFileName>$(IntDir)%(Filename).res</ResourceOutputFileName>
</ResourceCompile>
<PreLinkEvent>
<Command />
</PreLinkEvent>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Link>
<OutputFile>.\release\yapb.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DelayLoadDLLs>user32.dll;ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>false</GenerateDebugInformation>
<GenerateMapFile>false</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<SetChecksum>false</SetChecksum>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention />
<TurnOffAssemblyGeneration>true</TurnOffAssemblyGeneration>
<ImportLibrary>.\release\inf\yapb.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
<MinimumRequiredVersion />
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy "$(TargetPath)" "d:\steam\SteamApps\common\Half-Life\cstrike\addons\yapb\dlls" /y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Mmgr|Win32'">
<PreBuildEvent>
<Command>..\..\tool\buildup\release\buildup.exe yapb.rc</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command />
</CustomBuildStep>
<Midl>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
<TypeLibraryName>.\debug/yapb.tlb</TypeLibraryName>
<HeaderFileName />
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;MEMORY_TEST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader />
<PrecompiledHeaderFile>core.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\debug_mmgr\inf\yapb.pch</PrecompiledHeaderOutputFile>
<ExpandAttributedSource>false</ExpandAttributedSource>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<AssemblerListingLocation>.\debug_mmgr\asm\</AssemblerListingLocation>
<ObjectFileName>.\debug_mmgr\obj\</ObjectFileName>
<ProgramDataBaseFileName>.\debug_mmgr\inf</ProgramDataBaseFileName>
<BrowseInformation />
<BrowseInformationFile />
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<PreLinkEvent>
<Command />
</PreLinkEvent>
<Link>
<OutputFile>.\debug_mmgr\yapb.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<ProgramDatabaseFile>.\debug_mmgr\inf\yapb.pdb</ProgramDatabaseFile>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>.\debug_mmgr\inf\yapb.map</MapFileName>
<MapExports>true</MapExports>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
<NoEntryPoint>false</NoEntryPoint>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention />
<ImportLibrary>.\debug_mmgr\inf\yapb.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>copy "$(TargetPath)" "d:\game\steam\steamapps\dmitryzhukov\counter-strike\cstrike\addons\yapb\dlls\" /y
copy "$(TargetPath)" "d:\game\steam\steamapps\dmitryzhukov\condition zero\czero\addons\yapb\dlls\" /y
copy "$(TargetPath)" "d:\game\steam\steamapps\dmitryzhukov\dedicated server\cstrike\addons\yapb\dlls\" /y
copy "$(TargetPath)" "d:\hlds\cs1\cstrike\addons\yapb\dlls\" /y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

6459
source/basecode.cpp Normal file

File diff suppressed because it is too large Load diff

1226
source/botmanager.cpp Normal file

File diff suppressed because it is too large Load diff

468
source/chatlib.cpp Normal file
View file

@ -0,0 +1,468 @@
//
// Copyright (c) 2014, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Version: $Id:$
//
#include <core.h>
ConVar yb_chat ("yb_chat", "1");
void StripTags (char *buffer)
{
// this function strips 'clan' tags specified below in given string buffer
// first three tags for Enhanced POD-Bot (e[POD], 3[POD], E[POD])
char *tagOpen[] = {"e[P", "3[P", "E[P", "-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+"};
char *tagClose[] = {"]", "]", "]", "=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+"};
int index, fieldStart, fieldStop, i;
int length = strlen (buffer); // get length of string
// foreach known tag...
for (index = 0; index < ARRAYSIZE_HLSDK (tagOpen); index++)
{
fieldStart = strstr (buffer, tagOpen[index]) - 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
// have we found a tag stop?
if ((fieldStop > fieldStart) && (fieldStop < 32))
{
int tagLength = strlen (tagClose[index]);
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
}
}
}
// have we stripped too much (all the stuff)?
if (buffer[0] != '\0')
{
strtrim (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
// have we found a tag start?
if (fieldStart >= 0 && fieldStart < 32)
{
fieldStop = fieldStart + strlen (tagOpen[index]); // set the tag stop
int tagLength = strlen (tagOpen[index]);
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
// have we found a tag stop ?
if (fieldStart >= 0 && fieldStart < 32)
{
fieldStop = fieldStart + strlen (tagClose[index]); // set the tag
int tagLength = strlen (tagClose[index]);
for (i = fieldStart; i < length - tagLength; i++)
buffer[i] = buffer[i + tagLength]; // overwrite the buffer with the stripped string
buffer[i] = 0; // terminate the string
}
}
}
}
strtrim (buffer); // to finish, strip eventual blanks after and before the tag marks
}
char *HumanizeName (char *name)
{
// this function humanize player name (i.e. trim clan and switch to lower case (sometimes))
static char outputName[256]; // create return name buffer
strcpy (outputName, name); // copy name to new buffer
// drop tag marks, 80 percent of time
if (g_randGen.Long (1, 100) < 80)
StripTags (outputName);
else
strtrim (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 (g_randGen.Long (1, 100) <= 6)
{
for (int i = 0; i < static_cast <int> (strlen (outputName)); i++)
outputName[i] = tolower (outputName[i]); // to lower case
}
return &outputName[0]; // return terminated string
}
void HumanizeChat (char *buffer)
{
// this function humanize chat string to be more handwritten
int length = strlen (buffer); // get length of string
int 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 (g_randGen.Long (1, 100) <= 4)
{
for (i = 0; i < length; i++)
buffer[i] = tolower (buffer[i]); // switch to lowercase
}
if (length > 15)
{
// "length / 2" percent of time drop a character
if (g_randGen.Long (1, 100) < (length / 2))
{
int pos = g_randGen.Long ((length / 8), length - (length / 8)); // chose random position in string
for (i = pos; i < length - 1; i++)
buffer[i] = buffer[i + 1]; // overwrite the buffer with stripped string
buffer[i] = 0x0; // terminate string;
length--; // update new string length
}
// "length" / 4 precent of time swap character
if (g_randGen.Long (1, 100) < (length / 4))
{
int pos = g_randGen.Long ((length / 8), ((3 * length) / 8)); // choose random position in string
char ch = buffer[pos]; // swap characters
buffer[pos] = buffer[pos + 1];
buffer[pos + 1] = ch;
}
}
buffer[length] = 0; // terminate string
}
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))
return;
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
char *textStart = text;
char *pattern = text;
edict_t *talkEntity = NULL;
while (pattern != NULL)
{
// all replacement placeholders start with a %
pattern = strstr (textStart, "%");
if (pattern != NULL)
{
int length = pattern - textStart;
if (length > 0)
strncpy (m_tempStrings, textStart, length);
pattern++;
// player with most frags?
if (*pattern == 'f')
{
int highestFrags = -9000; // just pick some start value
int index = 0;
for (int i = 0; i < GetMaxClients (); i++)
{
if (!(g_clients[i].flags & CF_USED) || g_clients[i].ent == GetEntity ())
continue;
int frags = static_cast <int> (g_clients[i].ent->v.frags);
if (frags > highestFrags)
{
highestFrags = frags;
index = i;
}
}
talkEntity = g_clients[index].ent;
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
// mapname?
else if (*pattern == 'm')
strcat (m_tempStrings, GetMapName ());
// roundtime?
else if (*pattern == 'r')
{
int time = static_cast <int> (g_timeRoundEnd - GetWorldTime ());
strcat (m_tempStrings, FormatBuffer ("%02d:%02d", time / 60, time % 60));
}
// chat reply?
else if (*pattern == 's')
{
talkEntity = INDEXENT (m_sayTextBuffer.entityIndex);
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
// teammate alive?
else if (*pattern == 't')
{
int team = GetTeam (GetEntity ());
int i;
for (i = 0; i < GetMaxClients (); i++)
{
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || (g_clients[i].team != team) || (g_clients[i].ent == GetEntity ()))
continue;
break;
}
if (i < GetMaxClients ())
{
if (!FNullEnt (pev->dmg_inflictor) && (GetTeam (GetEntity ()) == GetTeam (pev->dmg_inflictor)))
talkEntity = pev->dmg_inflictor;
else
talkEntity = g_clients[i].ent;
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
else // no teammates alive...
{
for (i = 0; i < GetMaxClients (); i++)
{
if (!(g_clients[i].flags & CF_USED) || (g_clients[i].team != team) || (g_clients[i].ent == GetEntity ()))
continue;
break;
}
if (i < GetMaxClients ())
{
talkEntity = g_clients[i].ent;
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
}
}
else if (*pattern == 'e')
{
int team = GetTeam (GetEntity ());
int i;
for (i = 0; i < GetMaxClients (); i++)
{
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || (g_clients[i].team == team) || (g_clients[i].ent == GetEntity ()))
continue;
break;
}
if (i < GetMaxClients ())
{
talkEntity = g_clients[i].ent;
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
else // no teammates alive...
{
for (i = 0; i < GetMaxClients (); i++)
{
if (!(g_clients[i].flags & CF_USED) || (g_clients[i].team == team) || (g_clients[i].ent == GetEntity ()))
continue;
break;
}
if (i < GetMaxClients ())
{
talkEntity = g_clients[i].ent;
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
}
}
else if (*pattern == 'd')
{
if (g_gameVersion == CSV_CZERO)
{
if (g_randGen.Long (1, 100) < 30)
strcat (m_tempStrings, "CZ");
else if (g_randGen.Long (1, 100) < 80)
strcat (m_tempStrings, "KoHTpa K3");
else
strcat (m_tempStrings, "Condition Zero");
}
else if ((g_gameVersion == CSV_STEAM) || (g_gameVersion == CSV_OLD))
{
if (g_randGen.Long (1, 100) < 30)
strcat (m_tempStrings, "CS");
else if (g_randGen.Long (1, 100) < 80)
strcat (m_tempStrings, "KoHTpa");
else
strcat (m_tempStrings, "Counter-Strike");
}
}
else if (*pattern == 'v')
{
talkEntity = m_lastVictim;
if (!FNullEnt (talkEntity))
strcat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))));
}
pattern++;
textStart = pattern;
}
}
// let the bots make some mistakes...
char tempString[160];
strncpy (tempString, textStart, 159);
HumanizeChat (tempString);
strcat (m_tempStrings, tempString);
}
bool CheckKeywords (char *tempMessage, char *reply)
{
// this function checks is string contain keyword, and generates relpy to it
if (!yb_chat.GetBool () || IsNullString (tempMessage))
return false;
IterateArray (g_replyFactory, i)
{
IterateArray (g_replyFactory[i].keywords, j)
{
// check is keyword has occurred in message
if (strstr (tempMessage, g_replyFactory[i].keywords[j].GetBuffer ()) != NULL)
{
Array <String> &replies = g_replyFactory[i].usedReplies;
if (replies.GetElementNumber () >= g_replyFactory[i].replies.GetElementNumber () / 2)
replies.RemoveAll ();
bool replyUsed = false;
const char *generatedReply = g_replyFactory[i].replies.GetRandomElement ();
// don't say this twice
IterateArray (replies, k)
{
if (strstr (replies[k].GetBuffer (), generatedReply) != NULL)
replyUsed = true;
}
// reply not used, so use it
if (!replyUsed)
{
strcpy (reply, generatedReply); // update final buffer
replies.Push (generatedReply); //add to ignore list
return true;
}
}
}
}
// didn't find a keyword? 70% of the time use some universal reply
if (g_randGen.Long (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ())
{
strcpy (reply, g_chatFactory[CHAT_NOKW].GetRandomElement ().GetBuffer ());
return true;
}
return false;
}
bool Bot::ParseChat (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
// text to uppercase for keyword parsing
for (int i = 0; i < static_cast <int> (strlen (tempMessage)); i++)
tempMessage[i] = toupper (tempMessage[i]);
return CheckKeywords (tempMessage, reply);
}
bool Bot::RepliesToPlayer (void)
{
// this function sends reply to a player
if (m_sayTextBuffer.entityIndex != -1 && !IsNullString (m_sayTextBuffer.sayText))
{
char text[256];
// check is time to chat is good
if (m_sayTextBuffer.timeNextChat < GetWorldTime ())
{
if (g_randGen.Long (1, 100) < m_sayTextBuffer.chatProbability + g_randGen.Long (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
{
PrepareChatMessage (text);
PushMessageQueue (GSM_SAY);
m_sayTextBuffer.entityIndex = -1;
m_sayTextBuffer.sayText[0] = 0x0;
m_sayTextBuffer.timeNextChat = GetWorldTime () + m_sayTextBuffer.chatDelay;
return true;
}
m_sayTextBuffer.entityIndex = -1;
m_sayTextBuffer.sayText[0] = 0x0;
}
}
return false;
}
void Bot::SayText (const char *text)
{
// this function prints saytext message to all players
if (IsNullString (text))
return;
FakeClientCommand (GetEntity (), "say \"%s\"", text);
}
void Bot::TeamSayText (const char *text)
{
// this function prints saytext message only for teammates
if (IsNullString (text))
return;
FakeClientCommand (GetEntity (), "say_team \"%s\"", text);
}

1539
source/combat.cpp Normal file

File diff suppressed because it is too large Load diff

489
source/globals.cpp Normal file
View file

@ -0,0 +1,489 @@
//
// Copyright (c) 2014, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Version: $Id:$
//
#include <core.h>
bool g_canSayBombPlanted = true;
bool g_isMetamod = false;
bool g_radioInsteadVoice = false;
bool g_roundEnded = true;
bool g_botsCanPause = false;
bool g_sendAudioFinished = true;
bool g_bombPlanted = false;
bool g_bombSayString = false;
bool g_isCommencing = false;
bool g_editNoclip = false;
bool g_isFakeCommand = false;
bool g_waypointOn = false;
bool g_waypointsChanged = true;
bool g_autoWaypoint = false;
bool g_bLearnJumpWaypoint = false;
bool g_leaderChoosen[2] = {false, false};
float g_lastChatTime = 0.0;
float g_timeRoundStart = 0.0;
float g_timeRoundEnd = 0.0;
float g_timeRoundMid = 0.0;
float g_timeNextBombUpdate = 0.0;
float g_timeBombPlanted = 0.0;
float g_lastRadioTime[2] = {0.0, 0.0};
float g_autoPathDistance = 250.0;
int g_lastRadio[2];
int g_storeAddbotVars[4];
int g_radioSelect[32];
int g_fakeArgc = 0;
int g_gameVersion = CSV_STEAM;
int g_numWaypoints = 0;
int g_mapType = 0;
int g_killHistory = 0;
short g_modelIndexLaser = 0;
short g_modelIndexArrow = 0;
char g_fakeArgv[256];
Array <Array <String> > g_chatFactory;
Array <Array <ChatterItem> > g_chatterFactory;
Array <BotName> g_botNames;
Array <KeywordFactory> g_replyFactory;
RandGen g_randGen;
Library *g_gameLib = NULL;
meta_globals_t *gpMetaGlobals = NULL;
gamedll_funcs_t *gpGamedllFuncs = NULL;
mutil_funcs_t *gpMetaUtilFuncs = NULL;
gamefuncs_t g_functionTable;
EntityAPI_t g_entityAPI = NULL;
NewEntityAPI_t g_getNewEntityAPI = NULL;
BlendAPI_t g_serverBlendingAPI = NULL;
FuncPointers_t g_funcPointers = NULL;
enginefuncs_t g_engfuncs;
Client g_clients[32];
WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
edict_t *g_worldEdict = NULL;
edict_t *g_hostEntity = NULL;
globalvars_t *g_pGlobals = NULL;
Experience *g_experienceData = NULL;
// 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};
SkillDefinition g_skillTab[6] =
{
{0.8, 1.0, 45.0, 65.0, 2.0, 3.0, 40.0, 40.0, 50.0, 0, 0, 0, 50},
{0.6, 0.8, 40.0, 60.0, 3.0, 4.0, 30.0, 30.0, 42.0, 10, 0, 0, 40},
{0.4, 0.6, 35.0, 55.0, 4.0, 6.0, 20.0, 20.0, 32.0, 30, 0, 50, 35},
{0.2, 0.3, 30.0, 50.0, 6.0, 8.0, 10.0, 10.0, 18.0, 0, 30, 80, 30},
{0.1, 0.2, 25.0, 40.0, 8.0, 10.0, 5.0, 5.0, 10.0, 80, 50, 100, 23},
{0.0, 0.1, 20.0, 30.0, 9.0, 12.0, 0.0, 5.0, 0.0, 100, 100, 100, 20}
};
int *g_weaponPrefs[] =
{
g_normalWeaponPrefs,
g_rusherWeaponPrefs,
g_carefulWeaponPrefs
};
// metamod engine & dllapi function tables
metamod_funcs_t gMetaFunctionTable =
{
NULL, // pfnEntityAPI_t ()
NULL, // pfnEntityAPI_t_Post ()
GetEntityAPI2, // pfnEntityAPI_t2 ()
GetEntityAPI2_Post, // pfnEntityAPI_t2_Post ()
NULL, // pfnGetNewDLLFunctions ()
NULL, // pfnGetNewDLLFunctions_Post ()
GetEngineFunctions, // pfnGetEngineFunctions ()
NULL, // pfnGetEngineFunctions_Post ()
};
// metamod plugin information
plugin_info_t Plugin_info =
{
META_INTERFACE_VERSION, // interface version
PRODUCT_NAME, // plugin name
PRODUCT_VERSION, // plugin version
PRODUCT_DATE, // date of creation
PRODUCT_AUTHOR, // plugin author
PRODUCT_URL, // plugin URL
PRODUCT_LOGTAG, // plugin logtag
PT_CHANGELEVEL, // when loadable
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.0, true},
{TASK_PAUSE, 0, -1, 0.0, false},
{TASK_MOVETOPOSITION, 0, -1, 0.0, true},
{TASK_FOLLOWUSER, 0, -1,0.0, true},
{TASK_WAITFORGO, 0, -1, 0.0, true},
{TASK_PICKUPITEM, 0, -1, 0.0, true},
{TASK_CAMP, 0, -1, 0.0, true},
{TASK_PLANTBOMB, 0, -1, 0.0, false},
{TASK_DEFUSEBOMB, 0, -1, 0.0, false},
{TASK_ATTACK, 0, -1, 0.0, false},
{TASK_HUNTENEMY, 0, -1, 0.0, false},
{TASK_SEEKCOVER, 0, -1, 0.0, false},
{TASK_THROWHEGRENADE, 0, -1, 0.0, false},
{TASK_THROWFLASHBANG, 0, -1, 0.0, false},
{TASK_THROWSMOKE, 0, -1, 0.0, false},
{TASK_DOUBLEJUMP, 0, -1, 0.0, false},
{TASK_ESCAPEFROMBOMB, 0, -1, 0.0, false},
{TASK_SHOOTBREAKABLE, 0, -1, 0.0, false},
{TASK_HIDE, 0, -1, 0.0, false},
{TASK_BLINDED, 0, -1, 0.0, false},
{TASK_SPRAY, 0, -1, 0.0, 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, false, true },
{WEAPON_USP, "weapon_usp", "usp.mdl", 500, 1, -1, -1, 1, 1, 2, 2, false, false},
{WEAPON_GLOCK, "weapon_glock18", "glock18.mdl", 400, 1, -1, -1, 1, 2, 1, 1, false, false},
{WEAPON_DEAGLE, "weapon_deagle", "deagle.mdl", 650, 1, 2, 2, 1, 3, 4, 4, true, false},
{WEAPON_P228, "weapon_p228", "p228.mdl", 600, 1, 2, 2, 1, 4, 3, 3, false, false},
{WEAPON_ELITE, "weapon_elite", "elite.mdl", 1000, 1, 0, 0, 1, 5, 5, 5, false, false},
{WEAPON_FIVESEVEN, "weapon_fiveseven", "fiveseven.mdl", 750, 1, 1, 1, 1, 6, 5, 5, false, false},
{WEAPON_M3, "weapon_m3", "m3.mdl", 1700, 1, 2, -1, 2, 1, 1, 1, false, false},
{WEAPON_XM1014, "weapon_xm1014", "xm1014.mdl", 3000, 1, 2, -1, 2, 2, 2, 2, false, false},
{WEAPON_MP5, "weapon_mp5navy", "mp5.mdl", 1500, 1, 2, 1, 3, 1, 2, 2, false, true },
{WEAPON_TMP, "weapon_tmp", "tmp.mdl", 1250, 1, 1, 1, 3, 2, 1, 1, false, true },
{WEAPON_P90, "weapon_p90", "p90.mdl", 2350, 1, 2, 1, 3, 3, 4, 4, false, true },
{WEAPON_MAC10, "weapon_mac10", "mac10.mdl", 1400, 1, 0, 0, 3, 4, 1, 1, false, true },
{WEAPON_UMP45, "weapon_ump45", "ump45.mdl", 1700, 1, 2, 2, 3, 5, 3, 3, false, true },
{WEAPON_AK47, "weapon_ak47", "ak47.mdl", 2500, 1, 0, 0, 4, 1, 2, 2, true, true },
{WEAPON_SG552, "weapon_sg552", "sg552.mdl", 3500, 1, 0, -1, 4, 2, 4, 4, true, true },
{WEAPON_M4A1, "weapon_m4a1", "m4a1.mdl", 3100, 1, 1, 1, 4, 3, 3, 3, true, true },
{WEAPON_GALIL, "weapon_galil", "galil.mdl", 2000, 1, 0, 0, 4, -1, 1, 1, true, true },
{WEAPON_FAMAS, "weapon_famas", "famas.mdl", 2250, 1, 1, 1, 4, -1, 1, 1, true, true },
{WEAPON_AUG, "weapon_aug", "aug.mdl", 3500, 1, 1, 1, 4, 4, 4, 4, true, true },
{WEAPON_SCOUT, "weapon_scout", "scout.mdl", 2750, 1, 2, 0, 4, 5, 3, 2, true, false},
{WEAPON_AWP, "weapon_awp", "awp.mdl", 4750, 1, 2, 0, 4, 6, 5, 6, true, false},
{WEAPON_G3SG1, "weapon_g3sg1", "g3sg1.mdl", 5000, 1, 0, 2, 4, 7, 6, 6, true, false},
{WEAPON_SG550, "weapon_sg550", "sg550.mdl", 4200, 1, 1, 1, 4, 8, 5, 5, true, false},
{WEAPON_M249, "weapon_m249", "m249.mdl", 5750, 1, 2, 1, 5, 1, 1, 1, true, true },
{WEAPON_SHIELD, "weapon_shield", "shield.mdl", 2200, 0, 1, 1, 8, -1, 8, 8, false, false},
{0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, false, false}
};
// weapon firing delay based on skill (min and max delay for each weapon)
FireDelay g_fireDelay[NUM_WEAPONS + 1] =
{
{WEAPON_KNIFE, 255, 256, 0.10, {0.0, 0.2, 0.3, 0.4, 0.6, 0.8}, {0.1, 0.3, 0.5, 0.7, 1.0, 1.2}, 0.0, {0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0}},
{WEAPON_USP, 3, 853, 0.15, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_GLOCK, 5, 853, 0.15, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_DEAGLE, 2, 640, 0.20, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_P228, 4, 853, 0.14, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_ELITE, 3, 640, 0.20, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_FIVESEVEN, 4, 731, 0.14, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_M3, 8, 365, 0.86, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_XM1014, 7, 512, 0.15, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_MP5, 4, 731, 0.10, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_TMP, 3, 731, 0.05, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_P90, 4, 731, 0.10, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_MAC10, 3, 731, 0.06, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_UMP45, 4, 731, 0.15, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_AK47, 2, 512, 0.09, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_SG552, 3, 512, 0.11, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_M4A1, 3, 512, 0.08, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_GALIL, 4, 512, 0.09, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_FAMAS, 4, 512, 0.10, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_AUG, 3, 512, 0.11, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_SCOUT, 10, 256, 0.18, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_AWP, 10, 170, 0.22, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_G3SG1, 4, 256, 0.25, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_SG550, 4, 256, 0.25, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_M249, 3, 640, 0.10, {0.0, 0.1, 0.2, 0.3, 0.4, 0.6}, {0.1, 0.2, 0.3, 0.4, 0.5, 0.7}, 0.2, {0.0, 0.0, 0.1, 0.1, 0.2}, {0.1, 0.1, 0.2, 0.2, 0.4}},
{WEAPON_SHIELD, 0, 256, 0.00, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 0.0, {0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0}},
{0, 0, 256, 0.00, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 0.0, {0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0}}
};
// bot menus
MenuText g_menus[21] =
{
// main menu
{
0x2ff,
"\\yYaPB Main Menu\\w\v\v"
"1. YaPB Control\v"
"2. Features\v\v"
"3. Fill Server\v"
"4. End Round\v\v"
"0. Exit"
},
// bot features menu
{
0x25f,
"\\yYaPB 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"
"0. Exit"
},
// bot control menu
{
0x2ff,
"\\yYaPB 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"
"0. Exit"
},
// weapon mode select menu
{
0x27f,
"\\yYaPB 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"
"0. Exit"
},
// personality select menu
{
0x20f,
"\\yYaPB Personality\\w\v\v"
"1. Random\v"
"2. Normal\v"
"3. Aggressive\v"
"4. Careful\v\v"
"0. Exit"
},
// skill select menu
{
0x23f,
"\\yYaPB Skill Level\\w\v\v"
"1. Stupid (0-20)\v"
"2. Newbie (20-40)\v"
"3. Average (40-60)\v"
"4. Advanced (60-80)\v"
"5. Professional (80-99)\v"
"6. Godlike (100)\v\v"
"0. Exit"
},
// team select menu
{
0x213,
"\\ySelect a team\\w\v\v"
"1. Terrorist Force\v"
"2. Counter-Terrorist Force\v\v"
"5. Auto-select\v\v"
"0. Exit"
},
// terrorist model select menu
{
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"
"0. Exit"
},
// counter-terrirust model select menu
{
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"
"0. Exit"
},
// main waypoint menu
{
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"
"0. Exit"
},
// main waypoint menu (page 2)
{
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"
"0. Exit"
},
// select waypoint radius menu
{
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"
"0. Exit"
},
// waypoint add menu
{
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"
"0. Exit"
},
// set waypoint flag menu
{
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"
"0. Exit"
},
// kickmenu #1
{
0x0,
NULL,
},
// kickmenu #2
{
0x0,
NULL,
},
// kickmenu #3
{
0x0,
NULL,
},
// kickmenu #4
{
0x0,
NULL,
},
// command menu
{
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"
"0. Exit"
},
// auto-path max distance
{
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"
"0. Exit"
},
// path connections
{
0x207,
"\\yCreate Path (Choose Direction)\\w\v\v"
"1. Outgoing Path\v"
"2. Incoming Path\v"
"3. Bidirectional (Both Ways)\v\v"
"0. Exit"
}
};

3540
source/interface.cpp Normal file

File diff suppressed because it is too large Load diff

2936
source/navigate.cpp Normal file

File diff suppressed because it is too large Load diff

481
source/netmsg.cpp Normal file
View file

@ -0,0 +1,481 @@
//
// Copyright (c) 2014, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Version: $Id:$
//
#include <core.h>
NetworkMsg::NetworkMsg (void)
{
m_message = NETMSG_UNDEFINED;
m_state = 0;
m_bot = NULL;
for (int i = 0; i < NETMSG_BOTVOICE; i++)
m_registerdMessages[i] = -1;
}
void NetworkMsg::HandleMessageIfRequired (int messageType, int requiredType)
{
if (messageType == m_registerdMessages[requiredType])
SetMessage (requiredType);
}
void NetworkMsg::Execute (void *p)
{
if (m_message == NETMSG_UNDEFINED)
return; // no message or not for bot, return
// some needed variables
static byte r, g, b;
static byte enabled;
static int damageArmor, damageTaken, damageBits;
static int killerIndex, victimIndex, playerIndex;
static int index, numPlayers;
static int state, id, clip;
static Vector damageOrigin;
static WeaponProperty weaponProp;
// now starts of netmessage execution
switch (m_message)
{
case NETMSG_VGUI:
// this message is sent when a VGUI menu is displayed.
if (m_state == 0)
{
switch (PTR_TO_INT (p))
{
case VMS_TEAM:
m_bot->m_startAction = GSM_TEAM_SELECT;
break;
case VMS_TF:
case VMS_CT:
m_bot->m_startAction = GSM_CLASS_SELECT;
break;
}
}
break;
case NETMSG_SHOWMENU:
// this message is sent when a text menu is displayed.
if (m_state < 3) // ignore first 3 fields of message
break;
if (strcmp (PTR_TO_STR (p), "#Team_Select") == 0) // team select menu?
m_bot->m_startAction = GSM_TEAM_SELECT;
else if (strcmp (PTR_TO_STR (p), "#Team_Select_Spect") == 0) // team select menu?
m_bot->m_startAction = GSM_TEAM_SELECT;
else if (strcmp (PTR_TO_STR (p), "#IG_Team_Select_Spect") == 0) // team select menu?
m_bot->m_startAction = GSM_TEAM_SELECT;
else if (strcmp (PTR_TO_STR (p), "#IG_Team_Select") == 0) // team select menu?
m_bot->m_startAction = GSM_TEAM_SELECT;
else if (strcmp (PTR_TO_STR (p), "#IG_VIP_Team_Select") == 0) // team select menu?
m_bot->m_startAction = GSM_TEAM_SELECT;
else if (strcmp (PTR_TO_STR (p), "#IG_VIP_Team_Select_Spect") == 0) // team select menu?
m_bot->m_startAction = GSM_TEAM_SELECT;
else if (strcmp (PTR_TO_STR (p), "#Terrorist_Select") == 0) // T model select?
m_bot->m_startAction = GSM_CLASS_SELECT;
else if (strcmp (PTR_TO_STR (p), "#CT_Select") == 0) // CT model select menu?
m_bot->m_startAction = GSM_CLASS_SELECT;
break;
case NETMSG_WEAPONLIST:
// this message is sent when a client joins the game. All of the weapons are sent with the weapon ID and information about what ammo is used.
switch (m_state)
{
case 0:
strcpy (weaponProp.className, PTR_TO_STR (p));
break;
case 1:
weaponProp.ammo1 = PTR_TO_INT (p); // ammo index 1
break;
case 2:
weaponProp.ammo1Max = PTR_TO_INT (p); // max ammo 1
break;
case 5:
weaponProp.slotID = PTR_TO_INT (p); // slot for this weapon
break;
case 6:
weaponProp.position = PTR_TO_INT (p); // position in slot
break;
case 7:
weaponProp.id = PTR_TO_INT (p); // weapon ID
break;
case 8:
weaponProp.flags = PTR_TO_INT (p); // flags for weapon (WTF???)
g_weaponDefs[weaponProp.id] = weaponProp; // store away this weapon with it's ammo information...
break;
}
break;
case NETMSG_CURWEAPON:
// this message is sent when a weapon is selected (either by the bot chosing a weapon or by the server auto assigning the bot a weapon). In CS it's also called when Ammo is increased/decreased
switch (m_state)
{
case 0:
state = PTR_TO_INT (p); // state of the current weapon (WTF???)
break;
case 1:
id = PTR_TO_INT (p); // weapon ID of current weapon
break;
case 2:
clip = PTR_TO_INT (p); // ammo currently in the clip for this weapon
if (id <= 31)
{
if (state != 0)
m_bot->m_currentWeapon = id;
// ammo amount decreased ? must have fired a bullet...
if (id == m_bot->m_currentWeapon && m_bot->m_ammoInClip[id] > clip)
{
// time fired with in burst firing time ?
if (m_bot->m_timeLastFired + 1.0 > GetWorldTime ())
m_bot->m_burstShotsFired++;
m_bot->m_timeLastFired = GetWorldTime (); // remember the last bullet time
}
m_bot->m_ammoInClip[id] = clip;
}
break;
}
break;
case NETMSG_AMMOX:
// this message is sent whenever ammo amounts are adjusted (up or down). NOTE: Logging reveals that CS uses it very unreliable!
switch (m_state)
{
case 0:
index = PTR_TO_INT (p); // ammo index (for type of ammo)
break;
case 1:
m_bot->m_ammo[index] = PTR_TO_INT (p); // store it away
break;
}
break;
case NETMSG_AMMOPICKUP:
// this message is sent when the bot picks up some ammo (AmmoX messages are also sent so this message is probably
// not really necessary except it allows the HUD to draw pictures of ammo that have been picked up. The bots
// don't really need pictures since they don't have any eyes anyway.
switch (m_state)
{
case 0:
index = PTR_TO_INT (p);
break;
case 1:
m_bot->m_ammo[index] = PTR_TO_INT (p);
break;
}
break;
case NETMSG_DAMAGE:
// this message gets sent when the bots are getting damaged.
switch (m_state)
{
case 0:
damageArmor = PTR_TO_INT (p);
break;
case 1:
damageTaken = PTR_TO_INT (p);
break;
case 2:
damageBits = PTR_TO_INT (p);
if (m_bot && damageArmor > 0 || damageTaken > 0)
m_bot->TakeDamage (m_bot->pev->dmg_inflictor, damageTaken, damageArmor, damageBits);
break;
}
break;
case NETMSG_MONEY:
// this message gets sent when the bots money amount changes
if (m_state == 0)
m_bot->m_moneyAmount = PTR_TO_INT (p); // amount of money
break;
case NETMSG_STATUSICON:
switch (m_state)
{
case 0:
enabled = PTR_TO_BYTE (p);
break;
case 1:
if (strcmp (PTR_TO_STR (p), "defuser") == 0)
m_bot->m_hasDefuser = (enabled != 0);
else if (strcmp (PTR_TO_STR (p), "buyzone") == 0)
{
m_bot->m_inBuyZone = (enabled != 0);
// try to equip in buyzone
m_bot->EquipInBuyzone (0);
}
else if (strcmp (PTR_TO_STR (p), "vipsafety") == 0)
m_bot->m_inVIPZone = (enabled != 0);
else if (strcmp (PTR_TO_STR (p), "c4") == 0)
m_bot->m_inBombZone = (enabled == 2);
break;
}
break;
case NETMSG_DEATH: // this message sends on death
switch (m_state)
{
case 0:
killerIndex = PTR_TO_INT (p);
break;
case 1:
victimIndex = PTR_TO_INT (p);
break;
case 2:
if (killerIndex != 0 && killerIndex != victimIndex)
{
edict_t *killer = INDEXENT (killerIndex);
edict_t *victim = INDEXENT (victimIndex);
if (FNullEnt (killer) || FNullEnt (victim))
break;
// need to send congrats on well placed shot
for (int i = 0; i < GetMaxClients (); i++)
{
Bot *bot = g_botManager->GetBot (i);
if (bot != NULL && IsAlive (bot->GetEntity ()) && killer != bot->GetEntity () && bot->EntityIsVisible (victim->v.origin) && GetTeam (killer) == GetTeam (bot->GetEntity ()) && GetTeam (killer) != GetTeam (victim))
{
if (killer == g_hostEntity)
bot->HandleChatterMessage ("#Bot_NiceShotCommander");
else
bot->HandleChatterMessage ("#Bot_NiceShotPall");
break;
}
}
// notice nearby to victim teammates, that attacker is near
for (int i = 0; i < GetMaxClients (); i++)
{
Bot *bot = g_botManager->GetBot (i);
if (bot != NULL && IsAlive (bot->GetEntity ()) && GetTeam (bot->GetEntity ()) == GetTeam (victim) && IsVisible (killer->v.origin, bot->GetEntity ()) && FNullEnt (bot->m_enemy) && GetTeam (killer) != GetTeam (victim))
{
bot->m_actualReactionTime = 0.0;
bot->m_seeEnemyTime = GetWorldTime ();
bot->m_enemy = killer;
bot->m_lastEnemy = killer;
bot->m_lastEnemyOrigin = killer->v.origin;
}
}
Bot *bot = g_botManager->GetBot (killer);
// is this message about a bot who killed somebody?
if (bot != NULL)
bot->m_lastVictim = victim;
else // did a human kill a bot on his team?
{
Bot *bot = g_botManager->GetBot (victim);
if (bot != NULL)
{
if (GetTeam (killer) == GetTeam (victim))
bot->m_voteKickIndex = killerIndex;
bot->m_notKilled = false;
}
}
}
break;
}
break;
case NETMSG_SCREENFADE: // this message gets sent when the Screen fades (Flashbang)
switch (m_state)
{
case 3:
r = PTR_TO_BYTE (p);
break;
case 4:
g = PTR_TO_BYTE (p);
break;
case 5:
b = PTR_TO_BYTE (p);
break;
case 6:
m_bot->TakeBlinded (Vector (r, g, b), PTR_TO_BYTE (p));
break;
}
break;
case NETMSG_HLTV: // round restart in steam cs
switch (m_state)
{
case 0:
numPlayers = PTR_TO_INT (p);
break;
case 1:
if (numPlayers == 0 && PTR_TO_INT (p) == 0)
RoundInit ();
break;
}
break;
case NETMSG_RESETHUD:
#if 0
if (m_bot != NULL)
m_bot->NewRound ();
#endif
break;
case NETMSG_TEXTMSG:
if (m_state == 1)
{
if (FStrEq (PTR_TO_STR (p), "#CTs_Win") ||
FStrEq (PTR_TO_STR (p), "#Bomb_Defused") ||
FStrEq (PTR_TO_STR (p), "#Terrorists_Win") ||
FStrEq (PTR_TO_STR (p), "#Round_Draw") ||
FStrEq (PTR_TO_STR (p), "#All_Hostages_Rescued") ||
FStrEq (PTR_TO_STR (p), "#Target_Saved") ||
FStrEq (PTR_TO_STR (p), "#Hostages_Not_Rescued") ||
FStrEq (PTR_TO_STR (p), "#Terrorists_Not_Escaped") ||
FStrEq (PTR_TO_STR (p), "#VIP_Not_Escaped") ||
FStrEq (PTR_TO_STR (p), "#Escaping_Terrorists_Neutralized") ||
FStrEq (PTR_TO_STR (p), "#VIP_Assassinated") ||
FStrEq (PTR_TO_STR (p), "#VIP_Escaped") ||
FStrEq (PTR_TO_STR (p), "#Terrorists_Escaped") ||
FStrEq (PTR_TO_STR (p), "#CTs_PreventEscape") ||
FStrEq (PTR_TO_STR (p), "#Target_Bombed") ||
FStrEq (PTR_TO_STR (p), "#Game_Commencing") ||
FStrEq (PTR_TO_STR (p), "#Game_will_restart_in"))
{
g_roundEnded = true;
if (FStrEq (PTR_TO_STR (p), "#Game_Commencing"))
g_isCommencing = true;
if (FStrEq (PTR_TO_STR (p), "#CTs_Win"))
g_botManager->SetLastWinner (TEAM_CF); // update last winner for economics
if (FStrEq (PTR_TO_STR (p), "#Terrorists_Win"))
g_botManager->SetLastWinner (TEAM_TF); // update last winner for economics
g_waypoint->SetBombPosition (true);
}
else if (!g_bombPlanted && FStrEq (PTR_TO_STR (p), "#Bomb_Planted"))
{
g_bombPlanted = g_bombSayString = true;
g_timeBombPlanted = GetWorldTime ();
for (int i = 0; i < GetMaxClients (); i++)
{
Bot *bot = g_botManager->GetBot (i);
if (bot != NULL && IsAlive (bot->GetEntity ()))
{
bot->DeleteSearchNodes ();
bot->ResetTasks ();
if (g_randGen.Long (0, 100) < 85 && GetTeam (bot->GetEntity ()) == TEAM_CF)
bot->ChatterMessage (Chatter_WhereIsTheBomb);
}
}
g_waypoint->SetBombPosition ();
}
else if (m_bot != NULL && FStrEq (PTR_TO_STR (p), "#Switch_To_BurstFire"))
m_bot->m_weaponBurstMode = BM_ON;
else if (m_bot != NULL && FStrEq (PTR_TO_STR (p), "#Switch_To_SemiAuto"))
m_bot->m_weaponBurstMode = BM_OFF;
}
break;
case NETMSG_SCOREINFO:
switch (m_state)
{
case 0:
playerIndex = PTR_TO_INT (p);
break;
case 4:
if (playerIndex >= 0 && playerIndex <= GetMaxClients ())
{
if (PTR_TO_INT (p) == 1)
g_clients[playerIndex - 1].realTeam = TEAM_TF;
else if (PTR_TO_INT (p) == 2)
g_clients[playerIndex - 1].realTeam = TEAM_CF;
if (yb_csdm_mode.GetInt () == 2)
g_clients[playerIndex - 1].team = playerIndex;
else
g_clients[playerIndex - 1].team = g_clients[playerIndex - 1].realTeam;
}
break;
}
break;
case NETMSG_BARTIME:
if (m_state == 0)
{
if (PTR_TO_INT (p) > 0)
m_bot->m_hasProgressBar = true; // the progress bar on a hud
else if (PTR_TO_INT (p) == 0)
m_bot->m_hasProgressBar = false; // no progress bar or disappeared
}
break;
default:
AddLogEntry (true, LL_FATAL, "Network message handler error. Call to unrecognized message id (%d).\n", m_message);
}
m_state++; // and finally update network message state
}

1744
source/support.cpp Normal file

File diff suppressed because it is too large Load diff

2611
source/waypoint.cpp Normal file

File diff suppressed because it is too large Load diff