2
0
mirror of https://github.com/rehlds/revoice.git synced 2024-12-29 08:05:29 +03:00

Update ReHLDS API 3.x

This commit is contained in:
Adidasman 2016-12-13 05:54:47 +06:00
parent c8311da7da
commit 08dd8df4b4
46 changed files with 519 additions and 326 deletions

View File

@ -71,6 +71,9 @@
#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time #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 #define FL_DORMANT (1<<31) // Entity is dormant, no updates to client
// SV_EmitSound2 flags
#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS
#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker
// Engine edict->spawnflags // Engine edict->spawnflags
#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file #define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file

View File

@ -32,13 +32,10 @@
#pragma once #pragma once
#endif #endif
/* <31b2a> ../common/kbutton.h:7 */
typedef struct kbutton_s typedef struct kbutton_s
{ {
int down[2]; int down[2];
int state; int state;
} kbutton_t; } kbutton_t;
#endif // KBUTTON_H #endif // KBUTTON_H

View File

@ -1,37 +1,47 @@
/*** /*
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
* *
* This product contains software technology licensed from Id * This program is distributed in the hope that it will be useful, but
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * WITHOUT ANY WARRANTY; without even the implied warranty of
* All Rights Reserved. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* *
* Use, distribution, and modification of this source code and/or resulting * You should have received a copy of the GNU General Public License
* object code is restricted to non-commercial enhancements to products from * along with this program; if not, write to the Free Software Foundation,
* Valve LLC. All other use, distribution, or modification is prohibited * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* without written permission from Valve LLC.
* *
****/ * 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.
*
*/
#ifndef MATHLIB_H
#define MATHLIB_H
#ifdef _WIN32
#pragma once #pragma once
#endif
/* <42b7f> ../common/mathlib.h:3 */
typedef float vec_t; typedef float vec_t;
/* <42b91> ../common/mathlib.h:6 */ #if !defined DID_VEC3_T_DEFINE && !defined vec3_t
#ifndef DID_VEC3_T_DEFINE
#define DID_VEC3_T_DEFINE #define DID_VEC3_T_DEFINE
typedef vec_t vec3_t[3]; typedef vec_t vec3_t[3];
#endif #endif
/* <80013> ../common/mathlib.h:8 */
typedef vec_t vec4_t[4]; typedef vec_t vec4_t[4];
typedef int fixed16_t;
/* <42bac> ../common/mathlib.h:18 */
typedef int fixed16_t; /* size: 4 */
/* <42bb7> ../common/mathlib.h:60 */
typedef union DLONG_u typedef union DLONG_u
{ {
int i[2]; int i[2];
@ -41,6 +51,50 @@ typedef union DLONG_u
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#ifdef __cplusplus
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#ifdef clamp
#undef clamp
#endif
template <typename T>
inline T min(T a, T b) {
return (a < b) ? a : b;
}
template <typename T>
inline T max(T a, T b) {
return (a < b) ? b : a;
}
template <typename T>
inline T clamp(T a, T min, T max) {
return (a > max) ? max : (a < min) ? min : a;
}
template <typename T>
inline T bswap(T s) {
switch (sizeof(T)) {
#ifdef _WIN32
case 2: {auto res = _byteswap_ushort(*(uint16 *)&s); return *(T *)&res;}
case 4: {auto res = _byteswap_ulong(*(uint32 *)(&s)); return *(T *)&res;}
case 8: {auto res = _byteswap_uint64(*(uint64 *)&s); return *(T *)&res;}
#else
case 2: {auto res = _bswap16(*(uint16 *)&s); return *(T *)&res;}
case 4: {auto res = _bswap(*(uint32 *)&s); return *(T *)&res;}
case 8: {auto res = _bswap64(*(uint64 *)&s); return *(T *)&res;}
#endif
default: return s;
}
}
#else // __cplusplus
#ifndef max #ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b))
#endif #endif
@ -50,3 +104,6 @@ typedef union DLONG_u
#endif #endif
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
#endif // __cplusplus
#endif // MATHLIB_H

View File

@ -12,7 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// netadr.h
#ifndef NETADR_H #ifndef NETADR_H
#define NETADR_H #define NETADR_H
#ifdef _WIN32 #ifdef _WIN32
@ -31,10 +31,10 @@ typedef enum
typedef struct netadr_s typedef struct netadr_s
{ {
netadrtype_t type; netadrtype_t type;
unsigned char ip[4]; unsigned char ip[4];
unsigned char ipx[10]; unsigned char ipx[10];
unsigned short port; unsigned short port;
} netadr_t; } netadr_t;
#endif // NETADR_H #endif // NETADR_H

View File

@ -25,15 +25,19 @@
#define MAX_LIGHTSTYLE_INDEX_BITS 6 #define MAX_LIGHTSTYLE_INDEX_BITS 6
#define MAX_LIGHTSTYLES (1<<MAX_LIGHTSTYLE_INDEX_BITS) #define MAX_LIGHTSTYLES (1<<MAX_LIGHTSTYLE_INDEX_BITS)
// Resource counts; // Resource counts
#define MAX_MODEL_INDEX_BITS 9 // sent as a short #define MAX_MODEL_INDEX_BITS 9 // sent as a short
#define MAX_MODELS (1<<MAX_MODEL_INDEX_BITS) #define MAX_MODELS (1<<MAX_MODEL_INDEX_BITS)
#define MAX_SOUND_INDEX_BITS 9 #define MAX_SOUND_INDEX_BITS 9
#define MAX_SOUNDS (1<<MAX_SOUND_INDEX_BITS) #define MAX_SOUNDS (1<<MAX_SOUND_INDEX_BITS)
#define MAX_SOUNDS_HASHLOOKUP_SIZE (MAX_SOUNDS * 2 - 1)
#define MAX_GENERIC_INDEX_BITS 9 #define MAX_GENERIC_INDEX_BITS 9
#define MAX_GENERIC (1<<MAX_GENERIC_INDEX_BITS) #define MAX_GENERIC (1<<MAX_GENERIC_INDEX_BITS)
#define MAX_DECAL_INDEX_BITS 9 #define MAX_DECAL_INDEX_BITS 9
#define MAX_BASE_DECALS (1<<MAX_DECAL_INDEX_BITS) #define MAX_BASE_DECALS (1<<MAX_DECAL_INDEX_BITS)
#define MAX_EVENTS 256
#define MAX_PACKET_ENTITIES 256 // 256 visible entities per frame
#endif // QLIMITS_H #endif // QLIMITS_H

View File

@ -27,18 +27,15 @@
*/ */
#pragma once #pragma once
/* <19039> ../common/quakedef.h:29 */ typedef int BOOL;
typedef int BOOL; /* size: 4 */
// user message // user message
#define MAX_USER_MSG_DATA 192 #define MAX_USER_MSG_DATA 192
/* <627f> ../common/quakedef.h:137 */
//moved to com_model.h //moved to com_model.h
//typedef struct cache_user_s //typedef struct cache_user_s
//{ //{
// void *data; // void *data;
//} cache_user_t; //} cache_user_t;
/* <4313b> ../common/quakedef.h:162 */
typedef int (*pfnUserMsgHook)(const char *, int, void *); typedef int (*pfnUserMsgHook)(const char *, int, void *);

View File

@ -27,8 +27,6 @@
*/ */
#pragma once #pragma once
/* <430ee> ../common/vmodes.h:40 */
typedef struct rect_s typedef struct rect_s
{ {
int left, right, top, bottom; int left, right, top, bottom;

View File

@ -27,46 +27,47 @@
*/ */
#pragma once #pragma once
#define BSPVERSION 30 // header
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
#define HLBSP_VERSION 30 // half-life regular version
#define MAX_MAP_HULLS 4 #define MAX_MAP_HULLS 4
#define CONTENTS_ORIGIN -7 // removed at csg time #define CONTENTS_ORIGIN -7 // removed at csg time
#define CONTENTS_CLIP -8 // changed to contents_solid #define CONTENTS_CLIP -8 // changed to contents_solid
#define CONTENTS_CURRENT_0 -9 #define CONTENTS_CURRENT_0 -9
#define CONTENTS_CURRENT_90 -10 #define CONTENTS_CURRENT_90 -10
#define CONTENTS_CURRENT_180 -11 #define CONTENTS_CURRENT_180 -11
#define CONTENTS_CURRENT_270 -12 #define CONTENTS_CURRENT_270 -12
#define CONTENTS_CURRENT_UP -13 #define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14 #define CONTENTS_CURRENT_DOWN -14
#define CONTENTS_TRANSLUCENT -15 #define CONTENTS_TRANSLUCENT -15
#define LUMP_ENTITIES 0 #define LUMP_ENTITIES 0
#define LUMP_PLANES 1 #define LUMP_PLANES 1
#define LUMP_TEXTURES 2 #define LUMP_TEXTURES 2
#define LUMP_VERTEXES 3 #define LUMP_VERTEXES 3
#define LUMP_VISIBILITY 4 #define LUMP_VISIBILITY 4
#define LUMP_NODES 5 #define LUMP_NODES 5
#define LUMP_TEXINFO 6 #define LUMP_TEXINFO 6
#define LUMP_FACES 7 #define LUMP_FACES 7
#define LUMP_LIGHTING 8 #define LUMP_LIGHTING 8
#define LUMP_CLIPNODES 9 #define LUMP_CLIPNODES 9
#define LUMP_LEAFS 10 #define LUMP_LEAFS 10
#define LUMP_MARKSURFACES 11 #define LUMP_MARKSURFACES 11
#define LUMP_EDGES 12 #define LUMP_EDGES 12
#define LUMP_SURFEDGES 13 #define LUMP_SURFEDGES 13
#define LUMP_MODELS 14 #define LUMP_MODELS 14
#define HEADER_LUMPS 15 #define HEADER_LUMPS 15
/* <a1fc> ../engine/bspfile.h:41 */ typedef struct lump_s
typedef struct lump_s
{ {
int fileofs; int fileofs;
int filelen; int filelen;
} lump_t; } lump_t;
/* <a22c> ../engine/bspfile.h:64 */
typedef struct dmodel_s typedef struct dmodel_s
{ {
float mins[3], maxs[3]; float mins[3], maxs[3];
@ -76,21 +77,18 @@ typedef struct dmodel_s
int firstface, numfaces; int firstface, numfaces;
} dmodel_t; } dmodel_t;
/* <a2c2> ../engine/bspfile.h:73 */
typedef struct dheader_s typedef struct dheader_s
{ {
int version; int version;
lump_t lumps[15]; lump_t lumps[15];
} dheader_t; } dheader_t;
/* <485b2> ../engine/bspfile.h:79 */
typedef struct dmiptexlump_s typedef struct dmiptexlump_s
{ {
int _nummiptex; int _nummiptex;
int dataofs[4]; int dataofs[4];
} dmiptexlump_t; } dmiptexlump_t;
/* <1ce18> ../engine/bspfile.h:86 */
typedef struct miptex_s typedef struct miptex_s
{ {
char name[16]; char name[16];
@ -99,13 +97,11 @@ typedef struct miptex_s
unsigned offsets[4]; unsigned offsets[4];
} miptex_t; } miptex_t;
/* <48652> ../engine/bspfile.h:94 */
typedef struct dvertex_s typedef struct dvertex_s
{ {
float point[3]; float point[3];
} dvertex_t; } dvertex_t;
/* <48674> ../engine/bspfile.h:110 */
typedef struct dplane_s typedef struct dplane_s
{ {
float normal[3]; float normal[3];
@ -113,7 +109,6 @@ typedef struct dplane_s
int type; int type;
} dplane_t; } dplane_t;
/* <486b2> ../engine/bspfile.h:132 */
typedef struct dnode_s typedef struct dnode_s
{ {
int planenum; int planenum;
@ -124,14 +119,12 @@ typedef struct dnode_s
unsigned short numfaces; unsigned short numfaces;
} dnode_t; } dnode_t;
/* <a332> ../engine/bspfile.h:142 */
typedef struct dclipnode_s typedef struct dclipnode_s
{ {
int planenum; int planenum;
short children[2]; // negative numbers are contents short children[2]; // negative numbers are contents
} dclipnode_t; } dclipnode_t;
/* <4876a> ../engine/bspfile.h:149 */
typedef struct texinfo_s typedef struct texinfo_s
{ {
float vecs[2][4]; float vecs[2][4];
@ -139,13 +132,11 @@ typedef struct texinfo_s
int flags; int flags;
} texinfo_t; } texinfo_t;
/* <487c2> ../engine/bspfile.h:159 */
typedef struct dedge_s typedef struct dedge_s
{ {
unsigned short v[2]; unsigned short v[2];
} dedge_t; } dedge_t;
/* <487f2> ../engine/bspfile.h:165 */
typedef struct dface_s typedef struct dface_s
{ {
short planenum; short planenum;

View File

@ -29,10 +29,7 @@
#include "archtypes.h" #include "archtypes.h"
/* <8f1> ../engine/cmd.h:65 */
typedef void(*xcommand_t)(void); typedef void(*xcommand_t)(void);
/* <904> ../engine/cmd.h:71 */
typedef struct cmd_function_s typedef struct cmd_function_s
{ {
struct cmd_function_s *next; struct cmd_function_s *next;
@ -41,7 +38,6 @@ typedef struct cmd_function_s
int flags; int flags;
} cmd_function_t; } cmd_function_t;
/* <95a> ../engine/cmd.h:80 */
typedef enum cmd_source_s typedef enum cmd_source_s
{ {
src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state. src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state.

View File

@ -47,7 +47,6 @@
#define COM_COPY_CHUNK_SIZE 1024 #define COM_COPY_CHUNK_SIZE 1024
#define COM_MAX_CMD_LINE 256 #define COM_MAX_CMD_LINE 256
/* <6ae> ../common/common.h:82 */
typedef struct sizebuf_s typedef struct sizebuf_s
{ {
const char *buffername; const char *buffername;
@ -57,7 +56,6 @@ typedef struct sizebuf_s
int cursize; int cursize;
} sizebuf_t; } sizebuf_t;
/* <270aa> ../common/common.h:297 */
typedef struct downloadtime_s typedef struct downloadtime_s
{ {
qboolean bUsed; qboolean bUsed;
@ -65,7 +63,6 @@ typedef struct downloadtime_s
int nBytesRemaining; int nBytesRemaining;
} downloadtime_t; } downloadtime_t;
/* <19fa2> ../common/common.h:303 */
typedef struct incomingtransfer_s typedef struct incomingtransfer_s
{ {
qboolean doneregistering; qboolean doneregistering;

View File

@ -28,19 +28,16 @@
#pragma once #pragma once
/* <82286> ../engine/d_local.h:20 */
typedef struct surfcache_s typedef struct surfcache_s
{ {
struct surfcache_s *next; struct surfcache_s *next;
struct surfcache_s **owner; struct surfcache_s **owner;
int lightadj[4]; int lightadj[4];
int dlight; int dlight;
int size; int size;
unsigned width; unsigned width;
unsigned height; unsigned height;
float mipscale; float mipscale;
struct texture_s *texture; struct texture_s *texture;
unsigned char data[4]; unsigned char data[4];
} surfcache_t; } surfcache_t;

View File

@ -48,13 +48,24 @@ public:
virtual void callOriginal(t_args... args) = 0; virtual void callOriginal(t_args... args) = 0;
}; };
// Specifies priorities for hooks call order in the chain.
// For equal priorities first registered hook will be called first.
enum HookChainPriority
{
HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks.
HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority.
HC_PRIORITY_DEFAULT = 128, // Default hook call priority.
HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority.
HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks.
};
// Hook chain registry(for hooks [un]registration) // Hook chain registry(for hooks [un]registration)
template<typename t_ret, typename ...t_args> template<typename t_ret, typename ...t_args>
class IHookChainRegistry { class IHookChainRegistry {
public: public:
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...); typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
virtual void registerHook(hookfunc_t hook) = 0; virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0; virtual void unregisterHook(hookfunc_t hook) = 0;
}; };
@ -64,6 +75,6 @@ class IVoidHookChainRegistry {
public: public:
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...); typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
virtual void registerHook(hookfunc_t hook) = 0; virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0; virtual void unregisterHook(hookfunc_t hook) = 0;
}; };

View File

@ -33,14 +33,21 @@
#include "bspfile.h" #include "bspfile.h"
#include "crc.h" #include "crc.h"
#include "com_model.h" #include "com_model.h"
#include "commonmacros.h"
#define SURF_PLANEBACK 2 // header
#define SURF_DRAWSKY 4 #define ALIAS_MODEL_VERSION 0x006
#define IDPOLYHEADER MAKEID('I', 'D', 'P', 'O') // little-endian "IDPO"
#define MAX_LBM_HEIGHT 480
#define MAX_ALIAS_MODEL_VERTS 2000
#define SURF_PLANEBACK 2
#define SURF_DRAWSKY 4
#define SURF_DRAWSPRITE 8 #define SURF_DRAWSPRITE 8
#define SURF_DRAWTURB 0x10 #define SURF_DRAWTURB 0x10
#define SURF_DRAWTILED 0x20 #define SURF_DRAWTILED 0x20
#define SURF_DRAWBACKGROUND 0x40 #define SURF_DRAWBACKGROUND 0x40
#define ALIAS_MODEL_VERSION 0x006
#define MAX_MODEL_NAME 64 #define MAX_MODEL_NAME 64
#define MIPLEVELS 4 #define MIPLEVELS 4
@ -48,13 +55,11 @@
#define MAXLIGHTMAPS 4 #define MAXLIGHTMAPS 4
#define MAX_KNOWN_MODELS 1024 #define MAX_KNOWN_MODELS 1024
/* <6816> ../engine/model.h:27 */
typedef struct mvertex_s typedef struct mvertex_s
{ {
vec3_t position; vec3_t position;
} mvertex_t; } mvertex_t;
/* <6838> ../engine/model.h:39 */
typedef struct mplane_s typedef struct mplane_s
{ {
vec3_t normal; // surface normal vec3_t normal; // surface normal
@ -64,27 +69,36 @@ typedef struct mplane_s
byte pad[2]; byte pad[2];
} mplane_t; } mplane_t;
/* <68a6> ../engine/model.h:48 */
typedef struct texture_s typedef struct texture_s
{ {
char name[16]; char name[16];
unsigned width, height; unsigned width, height;
#ifndef SWDS
int gl_texturenum;
struct msurface_s * texturechain;
#endif
int anim_total; // total tenths in sequence ( 0 = no) int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frame 1 use these struct texture_s *alternate_anims; // bmodels in frame 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored unsigned offsets[MIPLEVELS]; // four mip maps stored
#ifdef SWDS
unsigned paloffset; unsigned paloffset;
#else
byte *pPal;
#endif
} texture_t; } texture_t;
/* <6950> ../engine/model.h:71 */
typedef struct medge_s typedef struct medge_s
{ {
unsigned short v[2]; unsigned short v[2];
unsigned int cachededgeoffset; unsigned int cachededgeoffset;
} medge_t; } medge_t;
/* <697e> ../engine/model.h:78 */
typedef struct mtexinfo_s typedef struct mtexinfo_s
{ {
float vecs[2][4]; // [s/t] unit vectors in world space. float vecs[2][4]; // [s/t] unit vectors in world space.
@ -96,13 +110,10 @@ typedef struct mtexinfo_s
} mtexinfo_t; } mtexinfo_t;
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision #define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
/* <69d0> ../engine/model.h:91 */
typedef struct msurface_s msurface_t; typedef struct msurface_s msurface_t;
/* <1db66> ../engine/model.h:92 */
typedef struct decal_s decal_t; typedef struct decal_s decal_t;
// JAY: Compress this as much as possible // JAY: Compress this as much as possible
/* <1db71> ../engine/model.h:96 */
struct decal_s struct decal_s
{ {
decal_t *pnext; // linked list for each surface decal_t *pnext; // linked list for each surface
@ -116,7 +127,6 @@ struct decal_s
short entityIndex; // Entity this is attached to short entityIndex; // Entity this is attached to
}; };
/* <69db> ../engine/model.h:118 */
struct msurface_s struct msurface_s
{ {
int visframe; // should be drawn when node is crossed int visframe; // should be drawn when node is crossed
@ -148,7 +158,6 @@ struct msurface_s
decal_t *pdecals; decal_t *pdecals;
}; };
/* <6b6c> ../engine/model.h:149 */
typedef struct mnode_s typedef struct mnode_s
{ {
// common with leaf // common with leaf
@ -167,7 +176,6 @@ typedef struct mnode_s
unsigned short numsurfaces; unsigned short numsurfaces;
} mnode_t; } mnode_t;
/* <1dcd4> ../engine/model.h:169 */
typedef struct mleaf_s typedef struct mleaf_s
{ {
// common with node // common with node
@ -188,7 +196,6 @@ typedef struct mleaf_s
byte ambient_sound_level[NUM_AMBIENTS]; byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t; } mleaf_t;
/* <1ddbe> ../engine/model.h:190 */
typedef struct hull_s typedef struct hull_s
{ {
dclipnode_t *clipnodes; dclipnode_t *clipnodes;
@ -198,7 +205,6 @@ typedef struct hull_s
vec3_t clip_mins, clip_maxs; vec3_t clip_mins, clip_maxs;
} hull_t; } hull_t;
/* <4b3fe> ../engine/model.h:210 */
typedef struct mspriteframe_t typedef struct mspriteframe_t
{ {
int width; int width;
@ -208,7 +214,6 @@ typedef struct mspriteframe_t
byte pixels[4]; byte pixels[4];
} mspriteframe_s; } mspriteframe_s;
/* <4b485> ../engine/model.h:219 */
typedef struct mspritegroup_s typedef struct mspritegroup_s
{ {
int numframes; int numframes;
@ -216,14 +221,12 @@ typedef struct mspritegroup_s
mspriteframe_t *frames[1]; mspriteframe_t *frames[1];
} mspritegroup_t; } mspritegroup_t;
/* <4b4df> ../engine/model.h:226 */
typedef struct mspriteframedesc_s typedef struct mspriteframedesc_s
{ {
spriteframetype_t type; spriteframetype_t type;
mspriteframe_t *frameptr; mspriteframe_t *frameptr;
} mspriteframedesc_t; } mspriteframedesc_t;
/* <4b50f> ../engine/model.h:232 */
typedef struct msprite_s typedef struct msprite_s
{ {
short int type; short int type;
@ -236,7 +239,6 @@ typedef struct msprite_s
mspriteframedesc_t frames[1]; mspriteframedesc_t frames[1];
} msprite_t; } msprite_t;
/* <4b5b5> ../engine/model.h:255 */
typedef struct maliasframedesc_s typedef struct maliasframedesc_s
{ {
aliasframetype_t type; aliasframetype_t type;
@ -245,7 +247,6 @@ typedef struct maliasframedesc_s
char name[16]; char name[16];
} maliasframedesc_t; } maliasframedesc_t;
/* <4b615> ../engine/model.h:264 */
typedef struct maliasskindesc_s typedef struct maliasskindesc_s
{ {
aliasskintype_t type; aliasskintype_t type;
@ -253,14 +254,12 @@ typedef struct maliasskindesc_s
int skin; int skin;
} maliasskindesc_t; } maliasskindesc_t;
/* <4b658> ../engine/model.h:271 */
typedef struct maliasgroupframedesc_s typedef struct maliasgroupframedesc_s
{ {
trivertx_t bboxmin, bboxmax; trivertx_t bboxmin, bboxmax;
int frame; int frame;
} maliasgroupframedesc_t; } maliasgroupframedesc_t;
/* <4b69b> ../engine/model.h:278 */
typedef struct maliasgroup_s typedef struct maliasgroup_s
{ {
int numframes; int numframes;
@ -268,7 +267,6 @@ typedef struct maliasgroup_s
maliasgroupframedesc_t frames[1]; maliasgroupframedesc_t frames[1];
} maliasgroup_t; } maliasgroup_t;
/* <4b6ee> ../engine/model.h:285 */
typedef struct maliasskingroup_s typedef struct maliasskingroup_s
{ {
int numskins; int numskins;
@ -276,14 +274,12 @@ typedef struct maliasskingroup_s
maliasskindesc_t skindescs[1]; maliasskindesc_t skindescs[1];
} maliasskingroup_t; } maliasskingroup_t;
/* <4b741> ../engine/model.h:293 */
typedef struct mtriangle_s typedef struct mtriangle_s
{ {
int facesfront; int facesfront;
int vertindex[3]; int vertindex[3];
} mtriangle_t; } mtriangle_t;
/* <4b779> ../engine/model.h:298 */
typedef struct aliashdr_s typedef struct aliashdr_s
{ {
int model; int model;
@ -294,21 +290,19 @@ typedef struct aliashdr_s
maliasframedesc_t frames[1]; maliasframedesc_t frames[1];
} aliashdr_t; } aliashdr_t;
/* <1de30> ../engine/model.h:315 */
typedef enum modtype_e typedef enum modtype_e
{ {
mod_bad = -1,
mod_brush, mod_brush,
mod_sprite, mod_sprite,
mod_alias, mod_alias,
mod_studio, mod_studio,
} modtype_t; } modtype_t;
/* <1de5e> ../engine/model.h:331 */
typedef struct model_s typedef struct model_s
{ {
char name[MAX_MODEL_NAME]; char name[MAX_MODEL_NAME];
//TODO: qboolean? seriously?
int needload; // bmodels and sprites don't cache normally int needload; // bmodels and sprites don't cache normally
modtype_t type; modtype_t type;

View File

@ -32,30 +32,24 @@
#pragma once #pragma once
#endif #endif
/* <67f6> ../engine/modelgen.h:37 */
typedef enum synctype_e typedef enum synctype_e
{ {
ST_SYNC = 0, ST_SYNC = 0,
ST_RAND = 1, ST_RAND = 1,
} synctype_t; } synctype_t;
/* <4abae> ../engine/modelgen.h:40 */
typedef enum aliasframetype_s typedef enum aliasframetype_s
{ {
ALIAS_SINGLE = 0, ALIAS_SINGLE = 0,
ALIAS_GROUP = 1, ALIAS_GROUP = 1,
} aliasframetype_t; } aliasframetype_t;
/* 203 */
/* <4abce> ../engine/modelgen.h:42 */
typedef enum aliasskintype_s typedef enum aliasskintype_s
{ {
ALIAS_SKIN_SINGLE = 0, ALIAS_SKIN_SINGLE = 0,
ALIAS_SKIN_GROUP = 1, ALIAS_SKIN_GROUP = 1,
} aliasskintype_t; } aliasskintype_t;
/* <4abee> ../engine/modelgen.h:44 */
typedef struct mdl_s typedef struct mdl_s
{ {
int ident; int ident;
@ -75,7 +69,6 @@ typedef struct mdl_s
float size; float size;
} mdl_t; } mdl_t;
/* <4acd4> ../engine/modelgen.h:64 */
typedef struct stvert_s typedef struct stvert_s
{ {
int onseam; int onseam;
@ -83,59 +76,50 @@ typedef struct stvert_s
int t; int t;
} stvert_t; } stvert_t;
/* <4ad0e> ../engine/modelgen.h:70 */
typedef struct dtriangle_s typedef struct dtriangle_s
{ {
int facesfront; int facesfront;
int vertindex[3]; int vertindex[3];
} dtriangle_t; } dtriangle_t;
/* <4ad42> ../engine/modelgen.h:80 */
typedef struct trivertx_s typedef struct trivertx_s
{ {
byte v[3]; byte v[3];
byte lightnormalindex; byte lightnormalindex;
} trivertx_t; } trivertx_t;
/* <4ad80> ../engine/modelgen.h:85 */
typedef struct daliasframe_s typedef struct daliasframe_s
{ {
trivertx_t bboxmin, bboxmax; trivertx_t bboxmin, bboxmax;
char name[16]; char name[16];
} daliasframe_t; } daliasframe_t;
/* <4adbe> ../engine/modelgen.h:91 */
typedef struct daliasgroup_s typedef struct daliasgroup_s
{ {
int numframes; int numframes;
trivertx_t bboxmin, bboxmax; trivertx_t bboxmin, bboxmax;
} daliasgroup_t; } daliasgroup_t;
/* <4adfc> ../engine/modelgen.h:97 */
typedef struct daliasskingroup_s typedef struct daliasskingroup_s
{ {
int numskins; int numskins;
} daliasskingroup_t; } daliasskingroup_t;
/* <4ae1e> ../engine/modelgen.h:101 */
typedef struct daliasinterval_s typedef struct daliasinterval_s
{ {
float interval; float interval;
} daliasinterval_t; } daliasinterval_t;
/* <4ae40> ../engine/modelgen.h:105 */
typedef struct daliasskininterval_s typedef struct daliasskininterval_s
{ {
float interval; float interval;
} daliasskininterval_t; } daliasskininterval_t;
/* <4ae62> ../engine/modelgen.h:109 */
typedef struct daliasframetype_s typedef struct daliasframetype_s
{ {
aliasframetype_t type; aliasframetype_t type;
} daliasframetype_t; } daliasframetype_t;
/* <4ae84> ../engine/modelgen.h:113 */
typedef struct daliasskintype_s typedef struct daliasskintype_s
{ {
aliasskintype_t type; aliasskintype_t type;

View File

@ -103,6 +103,7 @@
#define HIDDEN #define HIDDEN
#define NOINLINE __declspec(noinline) #define NOINLINE __declspec(noinline)
#define ALIGN16 __declspec(align(16)) #define ALIGN16 __declspec(align(16))
#define NORETURN __declspec(noreturn)
#define FORCE_STACK_ALIGN #define FORCE_STACK_ALIGN
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); } //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); }
@ -123,6 +124,11 @@
VirtualFree(ptr, 0, MEM_RELEASE); VirtualFree(ptr, 0, MEM_RELEASE);
} }
#else // _WIN32 #else // _WIN32
#ifdef __FUNCTION__
#undef __FUNCTION__
#endif
#define __FUNCTION__ __func__
#ifndef PAGESIZE #ifndef PAGESIZE
#define PAGESIZE 4096 #define PAGESIZE 4096
#endif #endif
@ -143,6 +149,7 @@
#define HIDDEN __attribute__((visibility("hidden"))) #define HIDDEN __attribute__((visibility("hidden")))
#define NOINLINE __attribute__((noinline)) #define NOINLINE __attribute__((noinline))
#define ALIGN16 __attribute__((aligned(16))) #define ALIGN16 __attribute__((aligned(16)))
#define NORETURN __attribute__((noreturn))
#define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer)) #define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer))
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); } //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); }
@ -166,8 +173,6 @@
#define WSAENOPROTOOPT ENOPROTOOPT #define WSAENOPROTOOPT ENOPROTOOPT
inline unsigned long _byteswap_ulong(unsigned long val) { return _bswap(val); }
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif #endif
@ -186,6 +191,4 @@
#define EXT_FUNC FORCE_STACK_ALIGN #define EXT_FUNC FORCE_STACK_ALIGN
extern void __declspec(noreturn) rehlds_syserror(const char* fmt, ...);
#endif // _OSCONFIG_H #endif // _OSCONFIG_H

View File

@ -34,8 +34,8 @@
#include "interface.h" #include "interface.h"
#include "model.h" #include "model.h"
#define REHLDS_API_VERSION_MAJOR 2 #define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 4 #define REHLDS_API_VERSION_MINOR 0
//Steam_NotifyClientConnect hook //Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect; typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -78,8 +78,8 @@ typedef IHookChain<qboolean, IGameClient*> IRehldsHook_Steam_NotifyBotConnect;
typedef IHookChainRegistry<qboolean, IGameClient*> IRehldsHookRegistry_Steam_NotifyBotConnect; typedef IHookChainRegistry<qboolean, IGameClient*> IRehldsHookRegistry_Steam_NotifyBotConnect;
//SerializeSteamId //SerializeSteamId
typedef IVoidHookChain<USERID_t*> IRehldsHook_SerializeSteamId; typedef IVoidHookChain<USERID_t*, USERID_t*> IRehldsHook_SerializeSteamId;
typedef IVoidHookChainRegistry<USERID_t*> IRehldsHookRegistry_SerializeSteamId; typedef IVoidHookChainRegistry<USERID_t*, USERID_t*> IRehldsHookRegistry_SerializeSteamId;
//SV_CompareUserID hook //SV_CompareUserID hook
typedef IHookChain<qboolean, USERID_t*, USERID_t*> IRehldsHook_SV_CompareUserID; typedef IHookChain<qboolean, USERID_t*, USERID_t*> IRehldsHook_SV_CompareUserID;
@ -122,8 +122,8 @@ typedef IVoidHookChain<IGameClient *, struct packet_entities_s *, sizebuf_t *> I
typedef IVoidHookChainRegistry<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHookRegistry_SV_EmitEvents; typedef IVoidHookChainRegistry<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHookRegistry_SV_EmitEvents;
//EV_PlayReliableEvent hook //EV_PlayReliableEvent hook
typedef IVoidHookChain<IGameClient *, int, short unsigned int, float, struct event_args_s *> IRehldsHook_EV_PlayReliableEvent; typedef IVoidHookChain<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHook_EV_PlayReliableEvent;
typedef IVoidHookChainRegistry<IGameClient *, int, short unsigned int, float, struct event_args_s *> IRehldsHookRegistry_EV_PlayReliableEvent; typedef IVoidHookChainRegistry<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHookRegistry_EV_PlayReliableEvent;
//SV_StartSound hook //SV_StartSound hook
typedef IVoidHookChain<int , edict_t *, int, const char *, int, float, int, int> IRehldsHook_SV_StartSound; typedef IVoidHookChain<int , edict_t *, int, const char *, int, float, int, int> IRehldsHook_SV_StartSound;
@ -157,6 +157,38 @@ typedef IVoidHookChainRegistry<int> IRehldsHookRegistry_SV_ActivateServer;
typedef IVoidHookChain<sizebuf_t *> IRehldsHook_SV_WriteVoiceCodec; typedef IVoidHookChain<sizebuf_t *> IRehldsHook_SV_WriteVoiceCodec;
typedef IVoidHookChainRegistry<sizebuf_t *> IRehldsHookRegistry_SV_WriteVoiceCodec; typedef IVoidHookChainRegistry<sizebuf_t *> IRehldsHookRegistry_SV_WriteVoiceCodec;
//Steam_GSGetSteamID hook
typedef IHookChain<uint64> IRehldsHook_Steam_GSGetSteamID;
typedef IHookChainRegistry<uint64> IRehldsHookRegistry_Steam_GSGetSteamID;
//SV_TransferConsistencyInfo hook
typedef IHookChain<int> IRehldsHook_SV_TransferConsistencyInfo;
typedef IHookChainRegistry<int> IRehldsHookRegistry_SV_TransferConsistencyInfo;
//Steam_GSBUpdateUserData hook
typedef IHookChain<bool, uint64, const char *, uint32> IRehldsHook_Steam_GSBUpdateUserData;
typedef IHookChainRegistry<bool, uint64, const char *, uint32> IRehldsHookRegistry_Steam_GSBUpdateUserData;
//Cvar_DirectSet hook
typedef IVoidHookChain<struct cvar_s *, const char *> IRehldsHook_Cvar_DirectSet;
typedef IVoidHookChainRegistry<struct cvar_s *, const char *> IRehldsHookRegistry_Cvar_DirectSet;
//SV_EstablishTimeBase hook
typedef IVoidHookChain<IGameClient *, struct usercmd_s *, int, int, int> IRehldsHook_SV_EstablishTimeBase;
typedef IVoidHookChainRegistry<IGameClient *, struct usercmd_s *, int, int, int> IRehldsHookRegistry_SV_EstablishTimeBase;
//SV_Spawn_f hook
typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
//SV_CreatePacketEntities hook
typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
//SV_EmitSound2 hook
typedef IHookChain<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHook_SV_EmitSound2;
typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHookRegistry_SV_EmitSound2;
class IRehldsHookchains { class IRehldsHookchains {
public: public:
virtual ~IRehldsHookchains() { } virtual ~IRehldsHookchains() { }
@ -191,6 +223,14 @@ public:
virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0; virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0;
virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0; virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0;
virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0; virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0;
virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0;
virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0;
virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0;
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0;
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {
@ -217,7 +257,7 @@ struct RehldsFuncs_t {
cmd_source_t*(*GetCmdSource)(); cmd_source_t*(*GetCmdSource)();
void(*Log)(const char* prefix, const char* msg); void(*Log)(const char* prefix, const char* msg);
DLL_FUNCTIONS *(*GetEntityInterface)(); DLL_FUNCTIONS *(*GetEntityInterface)();
void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, short unsigned int eventindex, float delay, struct event_args_s *pargs); void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs);
int(*SV_LookupSoundIndex)(const char *sample); int(*SV_LookupSoundIndex)(const char *sample);
void(*MSG_StartBitWriting)(sizebuf_t *buf); void(*MSG_StartBitWriting)(sizebuf_t *buf);
void(*MSG_WriteBits)(uint32 data, int numbits); void(*MSG_WriteBits)(uint32 data, int numbits);
@ -235,6 +275,13 @@ struct RehldsFuncs_t {
void(*MSG_WriteString)(sizebuf_t *sb, const char *s); void(*MSG_WriteString)(sizebuf_t *sb, const char *s);
void*(*GetPluginApi)(const char *name); void*(*GetPluginApi)(const char *name);
void(*RegisterPluginApi)(const char *name, void *impl); void(*RegisterPluginApi)(const char *name, void *impl);
qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist);
qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key);
void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
void(*SV_UpdateUserInfo)(IGameClient *pGameClient);
bool(*StripUnprintableAndSpace)(char *pch);
}; };
class IRehldsApi { class IRehldsApi {

View File

@ -71,6 +71,7 @@ public:
virtual void SetLastVoiceTime(double time) = 0; virtual void SetLastVoiceTime(double time) = 0;
virtual double GetLastVoiceTime() = 0; virtual double GetLastVoiceTime() = 0;
virtual bool GetLoopback() = 0; virtual bool GetLoopback() = 0;
virtual struct usercmd_s *GetLastCmd() = 0;
// this must be the last virtual function in class // this must be the last virtual function in class
#ifdef REHLDS_SELF #ifdef REHLDS_SELF
@ -123,4 +124,9 @@ public:
virtual int GetDecalNameNum() = 0; virtual int GetDecalNameNum() = 0;
virtual double GetTime() = 0; virtual double GetTime() = 0;
virtual void SetResourcesNum(int num) = 0;
virtual struct resource_s *GetResource(int index) = 0;
virtual void SetName(const char* name) = 0;
virtual class ISteamGameServer *GetSteamGameServer() = 0;
virtual struct netadr_s *GetNetFrom() = 0;
}; };

View File

@ -33,11 +33,10 @@
#endif #endif
#include "modelgen.h" #include "modelgen.h"
#include "commonmacros.h"
#define SPRITE_VERSION 2 // Half-Life sprites
#define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I') #define IDSPRITEHEADER MAKEID('I', 'D', 'S', 'P') // little-endian "IDSP"
#define SPRITE_VERSION 2
typedef enum spriteframetype_e typedef enum spriteframetype_e
{ {
@ -46,7 +45,6 @@ typedef enum spriteframetype_e
SPR_ANGLED SPR_ANGLED
} spriteframetype_t; } spriteframetype_t;
/* <4aea6> ../engine/spritegn.h:50 */
typedef struct dsprite_s typedef struct dsprite_s
{ {
int ident; int ident;
@ -61,7 +59,6 @@ typedef struct dsprite_s
synctype_t synctype; synctype_t synctype;
} dsprite_t; } dsprite_t;
/* <4af46> ../engine/spritegn.h:74 */
typedef struct dspriteframe_s typedef struct dspriteframe_s
{ {
int origin[2]; int origin[2];
@ -69,19 +66,16 @@ typedef struct dspriteframe_s
int height; int height;
} dspriteframe_t; } dspriteframe_t;
/* <4af84> ../engine/spritegn.h:80 */
typedef struct dspritegroup_s typedef struct dspritegroup_s
{ {
int numframes; int numframes;
} dspritegroup_t; } dspritegroup_t;
/* <4afa6> ../engine/spritegn.h:84 */
typedef struct dspriteinterval_s typedef struct dspriteinterval_s
{ {
float interval; float interval;
} dspriteinterval_t; } dspriteinterval_t;
/* <4afe8> ../engine/spritegn.h:90 */
typedef struct dspriteframetype_s typedef struct dspriteframetype_s
{ {
spriteframetype_t type; spriteframetype_t type;

View File

@ -44,7 +44,7 @@ private:
// this was a root node // this was a root node
unsigned int rootId = GetRoodNodeId(node->key); unsigned int rootId = GetRoodNodeId(node->key);
if (m_RootNodes[rootId] != node) { if (m_RootNodes[rootId] != node) {
util_syserror("%s: invlid root node", __FUNCTION__); Sys_Error(__FUNCTION__ ": invalid root node");
return; return;
} }

View File

@ -310,10 +310,13 @@ typedef struct
} mstudiotrivert_t; } mstudiotrivert_t;
#endif #endif
#define STUDIO_DYNAMIC_LIGHT 0x0100 // dynamically get lighting from floor or ceil (flying monsters)
#define STUDIO_TRACE_HITBOX 0x0200 // always use hitbox trace instead of bbox
// lighting options // lighting options
#define STUDIO_NF_FLATSHADE 0x0001 #define STUDIO_NF_FLATSHADE 0x0001
#define STUDIO_NF_CHROME 0x0002 #define STUDIO_NF_CHROME 0x0002
#define STUDIO_NF_FULLBRIGHT 0x0004 #define STUDIO_NF_FULLBRIGHT 0x0004
#define STUDIO_NF_NOMIPS 0x0008 #define STUDIO_NF_NOMIPS 0x0008
#define STUDIO_NF_ALPHA 0x0010 #define STUDIO_NF_ALPHA 0x0010
#define STUDIO_NF_ADDITIVE 0x0020 #define STUDIO_NF_ADDITIVE 0x0020

View File

@ -35,6 +35,7 @@
#define SSSE3_FLAG (1<<9) #define SSSE3_FLAG (1<<9)
#define SSE4_1_FLAG (1<<19) #define SSE4_1_FLAG (1<<19)
#define SSE4_2_FLAG (1<<20) #define SSE4_2_FLAG (1<<20)
#define POPCNT_FLAG (1<<23)
#define AVX_FLAG (1<<28) #define AVX_FLAG (1<<28)
#define AVX2_FLAG (1<<5) #define AVX2_FLAG (1<<5)
@ -56,6 +57,7 @@ void Sys_CheckCpuInstructionsSupport(void)
cpuinfo.ssse3 = (cpuid_data[2] & SSSE3_FLAG) ? 1 : 0; cpuinfo.ssse3 = (cpuid_data[2] & SSSE3_FLAG) ? 1 : 0;
cpuinfo.sse4_1 = (cpuid_data[2] & SSE4_1_FLAG) ? 1 : 0; cpuinfo.sse4_1 = (cpuid_data[2] & SSE4_1_FLAG) ? 1 : 0;
cpuinfo.sse4_2 = (cpuid_data[2] & SSE4_2_FLAG) ? 1 : 0; cpuinfo.sse4_2 = (cpuid_data[2] & SSE4_2_FLAG) ? 1 : 0;
cpuinfo.popcnt = (cpuid_data[2] & POPCNT_FLAG) ? 1 : 0;
cpuinfo.avx = (cpuid_data[2] & AVX_FLAG) ? 1 : 0; cpuinfo.avx = (cpuid_data[2] & AVX_FLAG) ? 1 : 0;
#if defined ASMLIB_H #if defined ASMLIB_H

View File

@ -31,7 +31,7 @@
typedef struct cpuinfo_s typedef struct cpuinfo_s
{ {
uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2; uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2, popcnt;
} cpuinfo_t; } cpuinfo_t;
extern cpuinfo_t cpuinfo; extern cpuinfo_t cpuinfo;

View File

@ -38,7 +38,6 @@ enum AUTH_IDTYPE
AUTH_IDTYPE_LOCAL = 3 AUTH_IDTYPE_LOCAL = 3
}; };
/* <2e915> ../engine/userid.h:22 */
typedef struct USERID_s typedef struct USERID_s
{ {
int idtype; int idtype;

View File

@ -0,0 +1,30 @@
#ifndef COMMONMACROS_H
#define COMMONMACROS_H
#pragma once
// -------------------------------------------------------
//
// commonmacros.h
//
// This should contain ONLY general purpose macros that are
// appropriate for use in engine/launcher/all tools
//
// -------------------------------------------------------
#include "osconfig.h"
// Makes a 4-byte "packed ID" int out of 4 characters
#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) )
// Compares a string with a 4-byte packed ID constant
#define STRING_MATCHES_ID( p, id ) ( (*((int *)(p)) == (id) ) ? true : false )
#define ID_TO_STRING( id, p ) ( (p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF) )
#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
// 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))
#endif // COMMONMACROS_H

View File

@ -1,30 +1,38 @@
#include "precompiled.h" #include "precompiled.h"
CSteamP2PCodec::CSteamP2PCodec(VoiceEncoder_Silk* backend) { CSteamP2PCodec::CSteamP2PCodec(VoiceEncoder_Silk* backend)
{
m_BackendCodec = backend; m_BackendCodec = backend;
} }
bool CSteamP2PCodec::Init(int quality) { bool CSteamP2PCodec::Init(int quality)
{
return m_BackendCodec->Init(quality); return m_BackendCodec->Init(quality);
} }
void CSteamP2PCodec::Release() { void CSteamP2PCodec::Release()
{
m_BackendCodec->Release(); m_BackendCodec->Release();
delete this; delete this;
} }
bool CSteamP2PCodec::ResetState() { bool CSteamP2PCodec::ResetState()
{
return m_BackendCodec->ResetState(); return m_BackendCodec->ResetState();
} }
int CSteamP2PCodec::StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const { int CSteamP2PCodec::StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const
{
const char* maxReadPos = pCompressed + compressedBytes; const char* maxReadPos = pCompressed + compressedBytes;
const char* readPos = pCompressed; const char* readPos = pCompressed;
while (readPos < maxReadPos) {
while (readPos < maxReadPos)
{
uint8 opcode = *(uint8*)readPos; uint8 opcode = *(uint8*)readPos;
readPos++; readPos++;
switch (opcode) { switch (opcode)
{
case 0xB: //Set sampling rate case 0xB: //Set sampling rate
if (readPos + 2 > maxReadPos) { if (readPos + 2 > maxReadPos) {
return 0; return 0;
@ -37,6 +45,7 @@ int CSteamP2PCodec::StreamDecode(const char *pCompressed, int compressedBytes, c
if (readPos + 2 > maxReadPos) { if (readPos + 2 > maxReadPos) {
return 0; return 0;
} }
uint16 len = *(uint16*)readPos; uint16 len = *(uint16*)readPos;
readPos += 2; readPos += 2;
@ -56,8 +65,10 @@ int CSteamP2PCodec::StreamDecode(const char *pCompressed, int compressedBytes, c
return 0; // no voice payload in the stream return 0; // no voice payload in the stream
} }
int CSteamP2PCodec::StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const { int CSteamP2PCodec::StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const
{
char* writePos = pCompressed; char* writePos = pCompressed;
if (maxCompressedBytes < 10) { // no room if (maxCompressedBytes < 10) { // no room
return 0; return 0;
} }
@ -80,13 +91,15 @@ int CSteamP2PCodec::StreamEncode(const char *pUncompressedBytes, int nSamples, c
return writePos - pCompressed; return writePos - pCompressed;
} }
int CSteamP2PCodec::Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) { int CSteamP2PCodec::Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes)
{
if (compressedBytes < 12) { if (compressedBytes < 12) {
return 0; return 0;
} }
uint32 computedChecksum = crc32(pCompressed, compressedBytes - 4); uint32 computedChecksum = crc32(pCompressed, compressedBytes - 4);
uint32 wireChecksum = *(uint32*)(pCompressed + compressedBytes - 4); uint32 wireChecksum = *(uint32*)(pCompressed + compressedBytes - 4);
if (computedChecksum != wireChecksum) { if (computedChecksum != wireChecksum) {
return 0; return 0;
} }
@ -94,7 +107,8 @@ int CSteamP2PCodec::Decompress(const char *pCompressed, int compressedBytes, cha
return StreamDecode(pCompressed + 8, compressedBytes - 12, pUncompressed, maxUncompressedBytes); return StreamDecode(pCompressed + 8, compressedBytes - 12, pUncompressed, maxUncompressedBytes);
} }
int CSteamP2PCodec::Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) { int CSteamP2PCodec::Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal)
{
if (maxCompressedBytes < 12) { //no room if (maxCompressedBytes < 12) { //no room
return 0; return 0;
} }
@ -110,6 +124,7 @@ int CSteamP2PCodec::Compress(const char *pUncompressedBytes, int nSamples, char
if (encodeRes <= 0) { if (encodeRes <= 0) {
return 0; return 0;
} }
writePos += encodeRes; writePos += encodeRes;
uint32 cksum = crc32(pCompressed, writePos - pCompressed); uint32 cksum = crc32(pCompressed, writePos - pCompressed);

View File

@ -17,6 +17,7 @@ public:
private: private:
int StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const; int StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const;
int StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const; int StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const;
private: private:
VoiceEncoder_Silk* m_BackendCodec; VoiceEncoder_Silk* m_BackendCodec;
}; };

View File

@ -1,14 +1,15 @@
#include "precompiled.h" #include "precompiled.h"
VoiceEncoder_Silk::VoiceEncoder_Silk() { VoiceEncoder_Silk::VoiceEncoder_Silk()
{
m_pEncoder = NULL; m_pEncoder = NULL;
m_pDecoder = NULL; m_pDecoder = NULL;
m_targetRate_bps = 25000; m_targetRate_bps = 25000;
m_packetLoss_perc = 0; m_packetLoss_perc = 0;
} }
VoiceEncoder_Silk::~VoiceEncoder_Silk() { VoiceEncoder_Silk::~VoiceEncoder_Silk()
{
if (m_pEncoder) { if (m_pEncoder) {
free(m_pEncoder); free(m_pEncoder);
m_pEncoder = NULL; m_pEncoder = NULL;
@ -20,7 +21,8 @@ VoiceEncoder_Silk::~VoiceEncoder_Silk() {
} }
} }
bool VoiceEncoder_Silk::Init(int quality) { bool VoiceEncoder_Silk::Init(int quality)
{
m_targetRate_bps = 25000; m_targetRate_bps = 25000;
m_packetLoss_perc = 0; m_packetLoss_perc = 0;
@ -37,11 +39,13 @@ bool VoiceEncoder_Silk::Init(int quality) {
return true; return true;
} }
void VoiceEncoder_Silk::Release() { void VoiceEncoder_Silk::Release()
{
delete this; delete this;
} }
bool VoiceEncoder_Silk::ResetState() { bool VoiceEncoder_Silk::ResetState()
{
if (m_pEncoder) if (m_pEncoder)
SKP_Silk_SDK_InitEncoder(m_pEncoder, &this->m_encControl); SKP_Silk_SDK_InitEncoder(m_pEncoder, &this->m_encControl);
@ -49,10 +53,12 @@ bool VoiceEncoder_Silk::ResetState() {
SKP_Silk_SDK_InitDecoder(m_pDecoder); SKP_Silk_SDK_InitDecoder(m_pDecoder);
m_bufOverflowBytes.Clear(); m_bufOverflowBytes.Clear();
return true; return true;
} }
int VoiceEncoder_Silk::Compress(const char *pUncompressedIn, int nSamplesIn, char *pCompressed, int maxCompressedBytes, bool bFinal) { int VoiceEncoder_Silk::Compress(const char *pUncompressedIn, int nSamplesIn, char *pCompressed, int maxCompressedBytes, bool bFinal)
{
signed int nSamplesToUse; // edi@4 signed int nSamplesToUse; // edi@4
const __int16 *psRead; // ecx@4 const __int16 *psRead; // ecx@4
int nSamples; // edi@5 int nSamples; // edi@5
@ -122,10 +128,11 @@ int VoiceEncoder_Silk::Compress(const char *pUncompressedIn, int nSamplesIn, cha
m_bufOverflowBytes.Put(&pUncompressedIn[2 * (nSamplesIn - nSamplesRemaining)], 2 * nSamplesRemaining); m_bufOverflowBytes.Put(&pUncompressedIn[2 * (nSamplesIn - nSamplesRemaining)], 2 * nSamplesRemaining);
} }
if (bFinal) { if (bFinal)
{
ResetState(); ResetState();
if (pWritePosMax > pWritePos + 2)
{ if (pWritePosMax > pWritePos + 2) {
uint16 * pWriteEndFlag = (uint16*)pWritePos; uint16 * pWriteEndFlag = (uint16*)pWritePos;
pWritePos += sizeof(uint16); pWritePos += sizeof(uint16);
*pWriteEndFlag = 0xFFFF; *pWriteEndFlag = 0xFFFF;
@ -147,6 +154,7 @@ int VoiceEncoder_Silk::Decompress(const char *pCompressed, int compressedBytes,
m_decControl.API_sampleRate = outSampleRate; m_decControl.API_sampleRate = outSampleRate;
int nSamplesPerFrame = outSampleRate / 50; int nSamplesPerFrame = outSampleRate / 50;
if (compressedBytes <= 0) { if (compressedBytes <= 0) {
return 0; return 0;
} }
@ -157,7 +165,8 @@ int VoiceEncoder_Silk::Decompress(const char *pCompressed, int compressedBytes,
pWritePos = pUncompressed; pWritePos = pUncompressed;
pWritePosMax = &pUncompressed[maxUncompressedBytes]; pWritePosMax = &pUncompressed[maxUncompressedBytes];
while (pReadPos < pReadPosMax) { while (pReadPos < pReadPosMax)
{
if (pReadPosMax - pReadPos < 2) { if (pReadPosMax - pReadPos < 2) {
break; break;
} }
@ -174,11 +183,14 @@ int VoiceEncoder_Silk::Decompress(const char *pCompressed, int compressedBytes,
//DTX (discontinued transmission) //DTX (discontinued transmission)
int numEmptySamples = nSamplesPerFrame; int numEmptySamples = nSamplesPerFrame;
short nSamples = (pWritePosMax - pWritePos) / 2; short nSamples = (pWritePosMax - pWritePos) / 2;
if (nSamples < numEmptySamples) { if (nSamples < numEmptySamples) {
break; break;
} }
memset(pWritePos, 0, numEmptySamples * 2); memset(pWritePos, 0, numEmptySamples * 2);
pWritePos += numEmptySamples * 2; pWritePos += numEmptySamples * 2;
continue; continue;
} }
@ -189,9 +201,11 @@ int VoiceEncoder_Silk::Decompress(const char *pCompressed, int compressedBytes,
do { do {
short nSamples = (pWritePosMax - pWritePos) / 2; short nSamples = (pWritePosMax - pWritePos) / 2;
int decodeRes = SKP_Silk_SDK_Decode(m_pDecoder, &m_decControl, 0, (const unsigned char*)pReadPos, nPayloadSize, (__int16 *)pWritePos, &nSamples); int decodeRes = SKP_Silk_SDK_Decode(m_pDecoder, &m_decControl, 0, (const unsigned char*)pReadPos, nPayloadSize, (__int16 *)pWritePos, &nSamples);
if (SKP_SILK_NO_ERROR != decodeRes) { if (SKP_SILK_NO_ERROR != decodeRes) {
return (pWritePos - pUncompressed) / 2; return (pWritePos - pUncompressed) / 2;
} }
pWritePos += nSamples * sizeof(int16); pWritePos += nSamples * sizeof(int16);
} while (m_decControl.moreInternalDecoderFrames); } while (m_decControl.moreInternalDecoderFrames);
pReadPos += nPayloadSize; pReadPos += nPayloadSize;

View File

@ -6,15 +6,15 @@
class VoiceEncoder_Silk : public IVoiceCodec { class VoiceEncoder_Silk : public IVoiceCodec {
private: private:
void * m_pEncoder; /* 4 4 */ void * m_pEncoder; /* 4 4 */
//int m_API_fs_Hz; /* 8 4 */ //int m_API_fs_Hz; /* 8 4 */
int m_targetRate_bps; /* 12 4 */ int m_targetRate_bps; /* 12 4 */
int m_packetLoss_perc; /* 16 4 */ int m_packetLoss_perc; /* 16 4 */
SKP_SILK_SDK_EncControlStruct m_encControl; /* 20 32 */ SKP_SILK_SDK_EncControlStruct m_encControl; /* 20 32 */
CUtlBuffer m_bufOverflowBytes; /* 52 24 */ CUtlBuffer m_bufOverflowBytes; /* 52 24 */
void * m_pDecoder; /* 76 4 */ void * m_pDecoder; /* 76 4 */
SKP_SILK_SDK_DecControlStruct m_decControl; /* 80 20 */ SKP_SILK_SDK_DecControlStruct m_decControl; /* 80 20 */
public: public:
VoiceEncoder_Silk(); VoiceEncoder_Silk();

View File

@ -35,21 +35,21 @@ bool VoiceEncoder_Speex::Init(int quality, int &rawFrameSize, int &encodedFrameS
rawFrameSize = 320; rawFrameSize = 320;
switch (quality) { switch (quality) {
case 2: case 2:
m_Quality = 2; m_Quality = 2;
break; break;
case 3: case 3:
m_Quality = 4; m_Quality = 4;
break; break;
case 4: case 4:
m_Quality = 6; m_Quality = 6;
break; break;
case 5: case 5:
m_Quality = 8; m_Quality = 8;
break; break;
default: default:
m_Quality = 0; m_Quality = 0;
break; break;
} }
encodedFrameSize = ENCODED_FRAME_SIZE[m_Quality]; encodedFrameSize = ENCODED_FRAME_SIZE[m_Quality];
@ -123,14 +123,12 @@ bool VoiceEncoder_Speex::InitStates()
/* <ff6> ../engine/voice_codecs/speex/VoiceEncoder_Speex.cpp:193 */ /* <ff6> ../engine/voice_codecs/speex/VoiceEncoder_Speex.cpp:193 */
void VoiceEncoder_Speex::TermStates() void VoiceEncoder_Speex::TermStates()
{ {
if (m_EncoderState != NULL) if (m_EncoderState != NULL) {
{
speex_encoder_destroy(m_EncoderState); speex_encoder_destroy(m_EncoderState);
m_EncoderState = NULL; m_EncoderState = NULL;
} }
if (m_DecoderState != NULL) if (m_DecoderState != NULL) {
{
speex_encoder_destroy(m_DecoderState); speex_encoder_destroy(m_DecoderState);
m_DecoderState = NULL; m_DecoderState = NULL;
} }

View File

@ -31,8 +31,7 @@
#include "precompiled.h" #include "precompiled.h"
static DLL_FUNCTIONS gFunctionTable = static DLL_FUNCTIONS gFunctionTable = {
{
NULL, // pfnGameInit NULL, // pfnGameInit
NULL, // pfnSpawn NULL, // pfnSpawn
NULL, // pfnThink NULL, // pfnThink
@ -120,7 +119,8 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(TRUE); return(TRUE);
} }
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion) { C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
{
if (!pNewFunctionTable) { if (!pNewFunctionTable) {
UTIL_LogPrintf("GetNewDLLFunctions called with null pNewFunctionTable"); UTIL_LogPrintf("GetNewDLLFunctions called with null pNewFunctionTable");
return(FALSE); return(FALSE);

View File

@ -31,8 +31,7 @@
#include "precompiled.h" #include "precompiled.h"
enginefuncs_t meta_engfuncs = enginefuncs_t meta_engfuncs = {
{
NULL, // pfnPrecacheModel() NULL, // pfnPrecacheModel()
NULL, // pfnPrecacheSound() NULL, // pfnPrecacheSound()
NULL, // pfnSetModel() NULL, // pfnSetModel()

View File

@ -28,7 +28,7 @@
//! Holds engine functionality callbacks //! Holds engine functionality callbacks
enginefuncs_t g_engfuncs; enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals; globalvars_t *gpGlobals;
// Receive engine function table from engine. // Receive engine function table from engine.
// This appears to be the _first_ DLL routine called by the engine, so we // This appears to be the _first_ DLL routine called by the engine, so we

View File

@ -34,6 +34,7 @@
* version. * version.
* *
*/ */
#include "precompiled.h" #include "precompiled.h"
// Must provide at least one of these.. // Must provide at least one of these..
@ -73,9 +74,11 @@ mutil_funcs_t *gpMetaUtilFuncs; // metamod utility functions
C_DLLEXPORT int Meta_Query(char * /*ifvers */, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs) C_DLLEXPORT int Meta_Query(char * /*ifvers */, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
{ {
// Give metamod our plugin_info struct // Give metamod our plugin_info struct
*pPlugInfo=&Plugin_info; *pPlugInfo = &Plugin_info;
// Get metamod utility function table. // Get metamod utility function table.
gpMetaUtilFuncs=pMetaUtilFuncs; gpMetaUtilFuncs = pMetaUtilFuncs;
return(TRUE); return(TRUE);
} }
@ -90,13 +93,16 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */, META_FUNCTIONS *pFunctionTa
LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals"); LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals");
return(FALSE); return(FALSE);
} }
gpMetaGlobals=pMGlobals;
gpMetaGlobals = pMGlobals;
if(!pFunctionTable) { if(!pFunctionTable) {
LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable"); LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable");
return(FALSE); return(FALSE);
} }
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS)); memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
gpGamedllFuncs=pGamedllFuncs; gpGamedllFuncs = pGamedllFuncs;
return Revoice_Load() ? (TRUE) : (FALSE); return Revoice_Load() ? (TRUE) : (FALSE);
} }
@ -109,7 +115,8 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME /* now */, PL_UNLOAD_REASON /* reason
return(TRUE); return(TRUE);
} }
bool Revoice_Load() { bool Revoice_Load()
{
if (!Revoice_Utils_Init()) if (!Revoice_Utils_Init())
return false; return false;
@ -125,6 +132,7 @@ bool Revoice_Load() {
return false; return false;
Revoice_Init_Players(); Revoice_Init_Players();
if (!Revoice_Main_Init()) { if (!Revoice_Main_Init()) {
LCPrintf(true, "Initialization failed\n"); LCPrintf(true, "Initialization failed\n");
return false; return false;

View File

@ -13,7 +13,7 @@
#include <dllapi.h> #include <dllapi.h>
#include <meta_api.h> #include <meta_api.h>
#include <h_export.h> #include <h_export.h>
#include "sdk_util.h" // UTIL_LogPrintf, etc #include "sdk_util.h" // UTIL_LogPrintf, etc
#include "revoice_shared.h" #include "revoice_shared.h"
#include "revoice_cfg.h" #include "revoice_cfg.h"

View File

@ -2,16 +2,18 @@
CRevoiceConfig* g_RevoiceConfig; CRevoiceConfig* g_RevoiceConfig;
bool Revoice_Cfg_LoadDefault() { bool Revoice_Cfg_LoadDefault()
{
CRevoiceConfig* cfg = CRevoiceConfig::load(REVOICE_CFG_FILE); CRevoiceConfig* cfg = CRevoiceConfig::load(REVOICE_CFG_FILE);
if (!cfg) if (!cfg)
return false; return false;
if (g_RevoiceConfig) { if (g_RevoiceConfig)
delete g_RevoiceConfig; delete g_RevoiceConfig;
}
g_RevoiceConfig = cfg; g_RevoiceConfig = cfg;
return true; return true;
} }
@ -21,11 +23,16 @@ CRevoiceConfig* CRevoiceConfig::load(const char* fname)
char gamedir[MAX_PATH]; char gamedir[MAX_PATH];
sprintf(namebuf, "./%s", fname); sprintf(namebuf, "./%s", fname);
FILE *fl = fopen(namebuf, "r"); FILE *fl = fopen(namebuf, "r");
if (fl == NULL) {
if (fl == NULL)
{
g_engfuncs.pfnGetGameDir(gamedir); g_engfuncs.pfnGetGameDir(gamedir);
sprintf(namebuf, "./%s/%s", gamedir, fname); sprintf(namebuf, "./%s/%s", gamedir, fname);
fl = fopen(namebuf, "r"); fl = fopen(namebuf, "r");
if (fl == NULL) { if (fl == NULL) {
LCPrintf(true, "Failed to load config: can't find %s in server root or gamedir\n", fname); LCPrintf(true, "Failed to load config: can't find %s in server root or gamedir\n", fname);
return NULL; return NULL;
@ -36,13 +43,17 @@ CRevoiceConfig* CRevoiceConfig::load(const char* fname)
int cline = 0; int cline = 0;
CRevoiceConfig* cfg = createDefault(); CRevoiceConfig* cfg = createDefault();
while (fgets(linebuf, sizeof(linebuf), fl)) { while (fgets(linebuf, sizeof(linebuf), fl))
{
cline++; cline++;
char* l = trimbuf(linebuf); char* l = trimbuf(linebuf);
if (l[0] == '\0' || l[0] == '#') if (l[0] == '\0' || l[0] == '#')
continue; continue;
char* valSeparator = strchr(l, '='); char* valSeparator = strchr(l, '=');
if (valSeparator == NULL) { if (valSeparator == NULL) {
LCPrintf(true, "Config line parsing failed: missed '=' on line %d\n", cline); LCPrintf(true, "Config line parsing failed: missed '=' on line %d\n", cline);
} }
@ -51,6 +62,7 @@ CRevoiceConfig* CRevoiceConfig::load(const char* fname)
char* param = trimbuf(l); char* param = trimbuf(l);
char* value = trimbuf(valSeparator); char* value = trimbuf(valSeparator);
if (!cfg->parseCfgParam(param, value)) { if (!cfg->parseCfgParam(param, value)) {
LCPrintf(true, "Config line parsing failed: unknown parameter '%s' at line %d\n", param, cline); LCPrintf(true, "Config line parsing failed: unknown parameter '%s' at line %d\n", param, cline);
} }
@ -74,43 +86,44 @@ CRevoiceConfig* CRevoiceConfig::createDefault()
bool CRevoiceConfig::parseCfgParam(const char* param, const char* value) bool CRevoiceConfig::parseCfgParam(const char* param, const char* value)
{ {
#define REV_CFG_PARSE_INT(paramName, field, _type, minVal, maxVal) \ #define REV_CFG_PARSE_INT(paramName, field, _type, minVal, maxVal) \
if (!strcasecmp(paramName, param)) { \ if (!strcasecmp(paramName, param)) { \
int i = atoi(value); \ int i = atoi(value); \
if (i < minVal || i > maxVal) { \ if (i < minVal || i > maxVal) { \
LCPrintf(true, "Invalid %s value '%s'\n", param, value); \ LCPrintf(true, "Invalid %s value '%s'\n", param, value); \
return false; \ return false; \
} \ } \
field = (_type) i; \ field = (_type) i; \
return true; \ return true; \
} }
#define REV_CFG_PARSE_IP(paramName, field) \ #define REV_CFG_PARSE_IP(paramName, field) \
if (!strcasecmp(paramName, param)) { \ if (!strcasecmp(paramName, param)) { \
field = inet_addr(value); \ field = inet_addr(value); \
return true; \ return true; \
} }
#define REV_CFG_PARSE_BOOL(paramName, field) \ #define REV_CFG_PARSE_BOOL(paramName, field) \
if (!strcasecmp(paramName, param)) { \ if (!strcasecmp(paramName, param)) { \
int i = atoi(value); \ int i = atoi(value); \
if (i < 0 || i > 1) { \ if (i < 0 || i > 1) { \
LCPrintf(true, "Invalid %s value '%s'\n", param, value); \ LCPrintf(true, "Invalid %s value '%s'\n", param, value); \
return false; \ return false; \
} \ } \
field = i ? true : false; \ field = i ? true : false; \
return true; \ return true; \
} }
#define REV_CFG_PARSE_STR(paramName, field) \ #define REV_CFG_PARSE_STR(paramName, field) \
if (!strcasecmp(paramName, param)) { \ if (!strcasecmp(paramName, param)) { \
strncpy(field, value, ARRAYSIZE(field) - 1); \ strncpy(field, value, ARRAYSIZE(field) - 1); \
field[ARRAYSIZE(field) - 1] = 0; \ field[ARRAYSIZE(field) - 1] = 0; \
return true; \ return true; \
} }
REV_CFG_PARSE_INT("LoggingMode", m_LogMode, int, rl_none, (rl_console|rl_logfile)); REV_CFG_PARSE_INT("LoggingMode", m_LogMode, int, rl_none, (rl_console | rl_logfile));
LCPrintf(true, " Config line parsing failed: unknown parameter '%s'\n", param); LCPrintf(true, " Config line parsing failed: unknown parameter '%s'\n", param);
return false; return false;
} }

View File

@ -1,17 +1,18 @@
#include "precompiled.h" #include "precompiled.h"
cvar_t* pcv_sv_voiceenable = NULL; cvar_t* pcv_sv_voiceenable = NULL;
void SV_DropClient_hook(IRehldsHook_SV_DropClient* chain, IGameClient* cl, bool crash, const char* msg) { void SV_DropClient_hook(IRehldsHook_SV_DropClient* chain, IGameClient* cl, bool crash, const char* msg)
{
CRevoicePlayer* plr = GetPlayerByClientPtr(cl); CRevoicePlayer* plr = GetPlayerByClientPtr(cl);
plr->OnDisconnected(); plr->OnDisconnected();
chain->callNext(cl, crash, msg); chain->callNext(cl, crash, msg);
} }
void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, const char *cvarValue) { void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, const char *cvarValue)
{
CRevoicePlayer* plr = GetPlayerByEdict(pEnt); CRevoicePlayer* plr = GetPlayerByEdict(pEnt);
if (plr->GetRequestId() != requestID) { if (plr->GetRequestId() != requestID) {
@ -19,26 +20,31 @@ void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, con
} }
const char* lastSeparator = strrchr(cvarValue, ','); const char* lastSeparator = strrchr(cvarValue, ',');
int buildNumber = 0;
if (lastSeparator) {
buildNumber = atoi(lastSeparator + 1);
}
if (buildNumber > 4554) { if (lastSeparator)
plr->SetCodecType(vct_silk); {
int buildNumber = atoi(lastSeparator + 1);
if (buildNumber > 4554) {
plr->SetCodecType(vct_silk);
}
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
int TranscodeVoice(const char* srcBuf, int srcBufLen, IVoiceCodec* srcCodec, IVoiceCodec* dstCodec, char* dstBuf, int dstBufSize) { int TranscodeVoice(const char* srcBuf, int srcBufLen, IVoiceCodec* srcCodec, IVoiceCodec* dstCodec, char* dstBuf, int dstBufSize)
{
char decodedBuf[32768]; char decodedBuf[32768];
int numDecodedSamples = srcCodec->Decompress(srcBuf, srcBufLen, decodedBuf, sizeof(decodedBuf)); int numDecodedSamples = srcCodec->Decompress(srcBuf, srcBufLen, decodedBuf, sizeof(decodedBuf));
if (numDecodedSamples <= 0) { if (numDecodedSamples <= 0) {
return 0; return 0;
} }
int compressedSize = dstCodec->Compress(decodedBuf, numDecodedSamples, dstBuf, dstBufSize, false); int compressedSize = dstCodec->Compress(decodedBuf, numDecodedSamples, dstBuf, dstBufSize, false);
if (compressedSize <= 0) { if (compressedSize <= 0) {
return 0; return 0;
} }
@ -59,7 +65,8 @@ int TranscodeVoice(const char* srcBuf, int srcBufLen, IVoiceCodec* srcCodec, IVo
return compressedSize; return compressedSize;
} }
void SV_ParseVoiceData_emu(IGameClient* cl) { void SV_ParseVoiceData_emu(IGameClient* cl)
{
char chReceived[4096]; char chReceived[4096];
unsigned int nDataLength = g_RehldsFuncs->MSG_ReadShort(); unsigned int nDataLength = g_RehldsFuncs->MSG_ReadShort();
@ -82,7 +89,8 @@ void SV_ParseVoiceData_emu(IGameClient* cl) {
char* speexData; int speexDataLen; char* speexData; int speexDataLen;
char* silkData; int silkDataLen; char* silkData; int silkDataLen;
switch (srcPlayer->GetCodecType()) { switch (srcPlayer->GetCodecType())
{
case vct_silk: case vct_silk:
{ {
if (nDataLength > MAX_SILK_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_SILK_VOICE_RATE) if (nDataLength > MAX_SILK_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_SILK_VOICE_RATE)
@ -109,7 +117,8 @@ void SV_ParseVoiceData_emu(IGameClient* cl) {
int maxclients = g_RehldsSvs->GetMaxClients(); int maxclients = g_RehldsSvs->GetMaxClients();
for (int i = 0; i < maxclients; i++) { for (int i = 0; i < maxclients; i++)
{
CRevoicePlayer* dstPlayer = &g_Players[i]; CRevoicePlayer* dstPlayer = &g_Players[i];
IGameClient* dstClient = dstPlayer->GetClient(); IGameClient* dstClient = dstPlayer->GetClient();
@ -121,7 +130,8 @@ void SV_ParseVoiceData_emu(IGameClient* cl) {
char* sendBuf; int nSendLen; char* sendBuf; int nSendLen;
switch (dstPlayer->GetCodecType()) { switch (dstPlayer->GetCodecType())
{
case vct_silk: case vct_silk:
sendBuf = silkData; nSendLen = silkDataLen; sendBuf = silkData; nSendLen = silkDataLen;
break; break;
@ -151,7 +161,8 @@ void SV_ParseVoiceData_emu(IGameClient* cl) {
} }
} }
void Rehlds_HandleNetCommand(IRehldsHook_HandleNetCommand* chain, IGameClient* cl, int8 opcode) { void Rehlds_HandleNetCommand(IRehldsHook_HandleNetCommand* chain, IGameClient* cl, int8 opcode)
{
if (opcode == 8) { //clc_voicedata if (opcode == 8) { //clc_voicedata
SV_ParseVoiceData_emu(cl); SV_ParseVoiceData_emu(cl);
return; return;
@ -163,38 +174,43 @@ void Rehlds_HandleNetCommand(IRehldsHook_HandleNetCommand* chain, IGameClient* c
qboolean mm_ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) { qboolean mm_ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) {
CRevoicePlayer* plr = GetPlayerByEdict(pEntity); CRevoicePlayer* plr = GetPlayerByEdict(pEntity);
plr->OnConnected(); plr->OnConnected();
RETURN_META_VALUE(MRES_IGNORED, TRUE); RETURN_META_VALUE(MRES_IGNORED, TRUE);
} }
void SV_WriteVoiceCodec_hooked(IRehldsHook_SV_WriteVoiceCodec* chain, sizebuf_t* sb) { void SV_WriteVoiceCodec_hooked(IRehldsHook_SV_WriteVoiceCodec* chain, sizebuf_t* sb)
{
IGameClient* cl = g_RehldsFuncs->GetHostClient(); IGameClient* cl = g_RehldsFuncs->GetHostClient();
CRevoicePlayer* plr = GetPlayerByClientPtr(cl); CRevoicePlayer* plr = GetPlayerByClientPtr(cl);
switch (plr->GetCodecType()) { switch (plr->GetCodecType())
case vct_silk: {
g_RehldsFuncs->MSG_WriteByte(sb, svc_voiceinit); //svc_voiceinit case vct_silk:
g_RehldsFuncs->MSG_WriteString(sb, ""); //codec id g_RehldsFuncs->MSG_WriteByte(sb, svc_voiceinit); //svc_voiceinit
g_RehldsFuncs->MSG_WriteByte(sb, 0); //quality g_RehldsFuncs->MSG_WriteString(sb, ""); //codec id
break; g_RehldsFuncs->MSG_WriteByte(sb, 0); //quality
break;
case vct_speex: case vct_speex:
g_RehldsFuncs->MSG_WriteByte(sb, svc_voiceinit); //svc_voiceinit g_RehldsFuncs->MSG_WriteByte(sb, svc_voiceinit); //svc_voiceinit
g_RehldsFuncs->MSG_WriteString(sb, "voice_speex"); //codec id g_RehldsFuncs->MSG_WriteString(sb, "voice_speex"); //codec id
g_RehldsFuncs->MSG_WriteByte(sb, 5); //quality g_RehldsFuncs->MSG_WriteByte(sb, 5); //quality
break; break;
default: default:
LCPrintf(true, "SV_WriteVoiceCodec() called on client(%d) with unknown voice codec\n", cl->GetId()); LCPrintf(true, "SV_WriteVoiceCodec() called on client(%d) with unknown voice codec\n", cl->GetId());
break; break;
} }
} }
bool Revoice_Main_Init() { bool Revoice_Main_Init()
g_RehldsHookchains->SV_DropClient()->registerHook(SV_DropClient_hook); {
g_RehldsHookchains->HandleNetCommand()->registerHook(Rehlds_HandleNetCommand); g_RehldsHookchains->SV_DropClient()->registerHook(SV_DropClient_hook, HC_PRIORITY_DEFAULT + 1);
g_RehldsHookchains->SV_WriteVoiceCodec()->registerHook(SV_WriteVoiceCodec_hooked); g_RehldsHookchains->HandleNetCommand()->registerHook(Rehlds_HandleNetCommand, HC_PRIORITY_DEFAULT + 1);
g_RehldsHookchains->SV_WriteVoiceCodec()->registerHook(SV_WriteVoiceCodec_hooked, HC_PRIORITY_DEFAULT + 1);
pcv_sv_voiceenable = g_engfuncs.pfnCVarGetPointer("sv_voiceenable"); pcv_sv_voiceenable = g_engfuncs.pfnCVarGetPointer("sv_voiceenable");
return true; return true;

View File

@ -2,7 +2,8 @@
CRevoicePlayer g_Players[MAX_PLAYERS]; CRevoicePlayer g_Players[MAX_PLAYERS];
CRevoicePlayer::CRevoicePlayer() { CRevoicePlayer::CRevoicePlayer()
{
m_CodecType = vct_none; m_CodecType = vct_none;
m_SpeexCodec = new VoiceCodec_Frame(new VoiceEncoder_Speex()); m_SpeexCodec = new VoiceCodec_Frame(new VoiceEncoder_Speex());
m_SilkCodec = new CSteamP2PCodec(new VoiceEncoder_Silk()); m_SilkCodec = new CSteamP2PCodec(new VoiceEncoder_Silk());
@ -15,7 +16,8 @@ CRevoicePlayer::CRevoicePlayer() {
m_Connected = false; m_Connected = false;
} }
void CRevoicePlayer::Initialize(IGameClient* cl) { void CRevoicePlayer::Initialize(IGameClient* cl)
{
m_RehldsClient = cl; m_RehldsClient = cl;
} }
@ -67,18 +69,20 @@ void Revoice_Init_Players()
} }
} }
CRevoicePlayer* GetPlayerByClientPtr(IGameClient* cl) { CRevoicePlayer* GetPlayerByClientPtr(IGameClient* cl)
return &g_Players[cl->GetId()]; {
return &g_Players[ cl->GetId() ];
} }
CRevoicePlayer* GetPlayerByEdict(const edict_t* ed) CRevoicePlayer* GetPlayerByEdict(const edict_t* ed)
{ {
int clientId = g_engfuncs.pfnIndexOfEdict(ed) - 1; int clientId = g_engfuncs.pfnIndexOfEdict(ed) - 1;
if (clientId < 0 || clientId >= g_RehldsSvs->GetMaxClients()) { if (clientId < 0 || clientId >= g_RehldsSvs->GetMaxClients()) {
util_syserror("Invalid player edict id=%d\n", clientId); util_syserror("Invalid player edict id=%d\n", clientId);
} }
return &g_Players[clientId]; return &g_Players[ clientId ];
} }
void CRevoicePlayer::SetLastVoiceTime(double time) void CRevoicePlayer::SetLastVoiceTime(double time)
@ -93,15 +97,16 @@ void CRevoicePlayer::UpdateVoiceRate(double delta)
{ {
switch (m_CodecType) switch (m_CodecType)
{ {
case vct_silk: case vct_silk:
m_VoiceRate -= int(delta * MAX_SILK_VOICE_RATE) + MAX_SILK_DATA_LEN; m_VoiceRate -= int(delta * MAX_SILK_VOICE_RATE) + MAX_SILK_DATA_LEN;
break; break;
case vct_speex: case vct_speex:
m_VoiceRate -= int(delta * MAX_SPEEX_VOICE_RATE) + MAX_SPEEX_DATA_LEN; m_VoiceRate -= int(delta * MAX_SPEEX_VOICE_RATE) + MAX_SPEEX_DATA_LEN;
break; break;
default:
break; default:
break;
} }
if (m_VoiceRate < 0) if (m_VoiceRate < 0)

View File

@ -31,11 +31,11 @@ public:
int GetRequestId() const { return m_RequestId; } int GetRequestId() const { return m_RequestId; }
bool IsConnected() const { return m_Connected; } bool IsConnected() const { return m_Connected; }
void SetCodecType(revoice_codec_type codecType) { m_CodecType = codecType; }; void SetCodecType(revoice_codec_type codecType) { m_CodecType = codecType; };
revoice_codec_type GetCodecType() const { return m_CodecType; } revoice_codec_type GetCodecType() const { return m_CodecType; }
CSteamP2PCodec* GetSilkCodec() const { return m_SilkCodec; } CSteamP2PCodec* GetSilkCodec() const { return m_SilkCodec; }
VoiceCodec_Frame* GetSpeexCodec() const { return m_SpeexCodec; } VoiceCodec_Frame* GetSpeexCodec() const { return m_SpeexCodec; }
IGameClient* GetClient() const { return m_RehldsClient; } IGameClient* GetClient() const { return m_RehldsClient; }
}; };
extern CRevoicePlayer g_Players[MAX_PLAYERS]; extern CRevoicePlayer g_Players[MAX_PLAYERS];

View File

@ -14,6 +14,7 @@ bool Revoice_RehldsApi_TryInit(CSysModule* engineModule, char* failureReason)
} }
CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule); CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule);
if (!ifaceFactory) { if (!ifaceFactory) {
sprintf(failureReason, "Failed to locate interface factory in engine module\n"); sprintf(failureReason, "Failed to locate interface factory in engine module\n");
return false; return false;
@ -21,6 +22,7 @@ bool Revoice_RehldsApi_TryInit(CSysModule* engineModule, char* failureReason)
int retCode = 0; int retCode = 0;
g_RehldsApi = (IRehldsApi*)ifaceFactory(VREHLDS_HLDS_API_VERSION, &retCode); g_RehldsApi = (IRehldsApi*)ifaceFactory(VREHLDS_HLDS_API_VERSION, &retCode);
if (!g_RehldsApi) { if (!g_RehldsApi) {
sprintf(failureReason, "Failed to locate retrieve rehlds api interface from engine module, return code is %d\n", retCode); sprintf(failureReason, "Failed to locate retrieve rehlds api interface from engine module, return code is %d\n", retCode);
return false; return false;
@ -47,7 +49,6 @@ bool Revoice_RehldsApi_TryInit(CSysModule* engineModule, char* failureReason)
return true; return true;
} }
bool Revoice_RehldsApi_Init() { bool Revoice_RehldsApi_Init() {
char failReason[2048]; char failReason[2048];

View File

@ -2,7 +2,8 @@
IReunionApi* g_ReunionApi; IReunionApi* g_ReunionApi;
bool Revoice_ReunionApi_Init() { bool Revoice_ReunionApi_Init()
{
g_ReunionApi = (IReunionApi *)g_RehldsFuncs->GetPluginApi("reunion"); g_ReunionApi = (IReunionApi *)g_RehldsFuncs->GetPluginApi("reunion");
if (g_ReunionApi == NULL) { if (g_ReunionApi == NULL) {

View File

@ -53,4 +53,3 @@ extern uint32 crc32(const void* buf, unsigned int bufLen);
extern bool Revoice_Load(); extern bool Revoice_Load();
extern bool Revoice_Utils_Init(); extern bool Revoice_Utils_Init();
extern void util_syserror(const char* fmt, ...); extern void util_syserror(const char* fmt, ...);

View File

@ -6,9 +6,10 @@ cvar_t* pcv_revoice_version;
cvar_t* pcv_mp_logecho; cvar_t* pcv_mp_logecho;
char logstring[2048]; char logstring[2048];
void LCPrintf(bool critical, const char *fmt, ...) { void LCPrintf(bool critical, const char *fmt, ...)
va_list argptr; {
const int prefixlen = 11; //sizeof(LOG_PREFIX) - 1; va_list argptr;
const int prefixlen = 11; //sizeof(LOG_PREFIX) - 1;
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(logstring + prefixlen, sizeof(logstring) - prefixlen, fmt, argptr); vsnprintf(logstring + prefixlen, sizeof(logstring) - prefixlen, fmt, argptr);
@ -30,38 +31,47 @@ void LCPrintf(bool critical, const char *fmt, ...) {
ALERT(at_logged, logstring); ALERT(at_logged, logstring);
} }
bool Revoice_Utils_Init() { bool Revoice_Utils_Init()
{
g_engfuncs.pfnCvar_RegisterVariable(&cv_revoice_version); g_engfuncs.pfnCvar_RegisterVariable(&cv_revoice_version);
pcv_revoice_version = g_engfuncs.pfnCVarGetPointer(cv_revoice_version.name); pcv_revoice_version = g_engfuncs.pfnCVarGetPointer(cv_revoice_version.name);
pcv_mp_logecho = g_engfuncs.pfnCVarGetPointer("mp_logecho"); pcv_mp_logecho = g_engfuncs.pfnCVarGetPointer("mp_logecho");
strcpy(logstring, LOG_PREFIX); strcpy(logstring, LOG_PREFIX);
return true; return true;
} }
char* trimbuf(char *str) { char* trimbuf(char *str)
{
char *ibuf = str; char *ibuf = str;
int i = 0; int i = 0;
if (str == NULL) return NULL; if (str == NULL) return NULL;
for (ibuf = str; *ibuf && (byte)(*ibuf) < (byte)0x80 && isspace(*ibuf); ++ibuf) for (ibuf = str; *ibuf && (byte)(*ibuf) < (byte)0x80 && isspace(*ibuf); ++ibuf)
; ;
i = strlen(ibuf); i = strlen(ibuf);
if (str != ibuf) if (str != ibuf)
memmove(str, ibuf, i); memmove(str, ibuf, i);
str[i] = 0; str[i] = 0;
while (--i >= 0) { while (--i >= 0) {
if (!isspace(ibuf[i])) if (!isspace(ibuf[i]))
break; break;
} }
ibuf[++i] = 0; ibuf[++i] = 0;
return str; return str;
} }
uint32 crc32(const void* buf, unsigned int bufLen) { uint32 crc32(const void* buf, unsigned int bufLen)
{
CRC32_t hCrc; CRC32_t hCrc;
g_engfuncs.pfnCRC32_Init(&hCrc); g_engfuncs.pfnCRC32_Init(&hCrc);
g_engfuncs.pfnCRC32_ProcessBuffer(&hCrc, (void*)buf, bufLen); g_engfuncs.pfnCRC32_ProcessBuffer(&hCrc, (void*)buf, bufLen);
@ -73,11 +83,13 @@ void util_syserror(const char* fmt, ...)
{ {
va_list argptr; va_list argptr;
char buf[4096]; char buf[4096];
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(buf, ARRAYSIZE(buf) - 1, fmt, argptr); vsnprintf(buf, ARRAYSIZE(buf) - 1, fmt, argptr);
buf[ARRAYSIZE(buf) - 1] = 0; buf[ARRAYSIZE(buf) - 1] = 0;
va_end(argptr); va_end(argptr);
LCPrintf(true, "ERROR: %s", buf); LCPrintf(true, "ERROR: %s", buf);
*(int *)0 = 0; *(int *)0 = 0;
} }

View File

@ -16,6 +16,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== util.cpp ======================================================== ===== util.cpp ========================================================
@ -23,6 +24,7 @@
Utility code. Really not optional after all. Utility code. Really not optional after all.
*/ */
#include "precompiled.h" #include "precompiled.h"
//========================================================= //=========================================================

View File

@ -71,8 +71,7 @@ int VoiceCodec_Frame::Compress(const char *pUncompressedBytes, int nSamples, cha
} }
// If it must get the last data, just pad with zeros.. // If it must get the last data, just pad with zeros..
if (bFinal && m_nEncodeBufferSamples && (maxCompressedBytes - nCompressedBytes) >= m_nEncodedBytes) if (bFinal && m_nEncodeBufferSamples && (maxCompressedBytes - nCompressedBytes) >= m_nEncodedBytes) {
{
memset(&m_EncodeBuffer[m_nEncodeBufferSamples], 0, (m_nRawSamples - m_nEncodeBufferSamples) * BYTES_PER_SAMPLE); memset(&m_EncodeBuffer[m_nEncodeBufferSamples], 0, (m_nRawSamples - m_nEncodeBufferSamples) * BYTES_PER_SAMPLE);
m_pFrameEncoder->EncodeFrame((const char*)m_EncodeBuffer, &pCompressed[nCompressedBytes]); m_pFrameEncoder->EncodeFrame((const char*)m_EncodeBuffer, &pCompressed[nCompressedBytes]);
nCompressedBytes += m_nEncodedBytes; nCompressedBytes += m_nEncodedBytes;

View File

@ -26,4 +26,4 @@ protected:
int m_nRawSamples; int m_nRawSamples;
int m_nEncodedBytes; int m_nEncodedBytes;
};/* size: 2072, cachelines: 33, members: 7 */ }; /* size: 2072, cachelines: 33, members: 7 */