2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-27 23:25:45 +03:00

[api] Added MSG_* funcs

[rehlsdk] Added missing platform.h
Bump minor version
This commit is contained in:
s1lent 2019-04-30 22:02:23 +07:00
parent f6822e30ea
commit 998f17263e
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
6 changed files with 313 additions and 60 deletions

View File

@ -1,3 +1,3 @@
majorVersion=3
minorVersion=4
minorVersion=6
maintenanceVersion=0

View File

@ -83,7 +83,7 @@ task publishPrepareFiles {
copy {
from 'rehlds/public'
into 'publish/publishRoot/hlsdk/public'
exclude '**/rehlds/*', '**/tier0/*'
exclude '**/rehlds/*'
}
copy {
from 'rehlds/public/rehlds'

View File

@ -531,10 +531,8 @@ void MSG_WriteBits(uint32 data, int numbits)
#endif //defined(REHLDS_FIXES)
NOXREF qboolean MSG_IsBitWriting(void)
qboolean MSG_IsBitWriting(void)
{
NOXREFCHECK;
return bfwrite.pbuf != 0;
}
@ -622,10 +620,8 @@ int MSG_CurrentBit(void)
return nbits;
}
NOXREF qboolean MSG_IsBitReading(void)
qboolean MSG_IsBitReading(void)
{
NOXREFCHECK;
return bfread.pbuf != 0;
}
@ -758,10 +754,8 @@ uint32 MSG_ReadBits(int numbits)
return result;
}
NOXREF uint32 MSG_PeekBits(int numbits)
uint32 MSG_PeekBits(int numbits)
{
NOXREFCHECK;
bf_read_t savebf = bfread;
uint32 r = MSG_ReadBits(numbits);
bfread = savebf;
@ -782,10 +776,8 @@ int MSG_ReadSBits(int numbits)
return result;
}
NOXREF char *MSG_ReadBitString(void)
char *MSG_ReadBitString(void)
{
NOXREFCHECK;
static char buf[8192];
char *p = &buf[0];
@ -825,10 +817,8 @@ int MSG_ReadBitData(void *dest, int length)
return length;
}
NOXREF float MSG_ReadBitCoord(void)
float MSG_ReadBitCoord(void)
{
NOXREFCHECK;
float value = 0;
int intval = MSG_ReadOneBit();
@ -878,10 +868,8 @@ void MSG_WriteBitCoord(const float f)
}
}
NOXREF void MSG_ReadBitVec3Coord(vec3_t fa)
void MSG_ReadBitVec3Coord(vec3_t fa)
{
NOXREFCHECK;
int xflag = MSG_ReadOneBit();
int yflag = MSG_ReadOneBit();
int zflag = MSG_ReadOneBit();
@ -912,10 +900,8 @@ void MSG_WriteBitVec3Coord(const vec3_t fa)
MSG_WriteBitCoord(fa[2]);
}
NOXREF float MSG_ReadCoord(void)
float MSG_ReadCoord(void)
{
NOXREFCHECK;
return (float)(MSG_ReadShort() * (1.0 / 8));
}
@ -924,10 +910,8 @@ void MSG_WriteCoord(sizebuf_t *sb, const float f)
MSG_WriteShort(sb, (int)(f * 8.0));
}
NOXREF void MSG_ReadVec3Coord(sizebuf_t *sb, vec3_t fa)
void MSG_ReadVec3Coord(sizebuf_t *sb, vec3_t fa)
{
NOXREFCHECK;
if (MSG_IsBitReading())
{
MSG_ReadBitVec3Coord(fa);
@ -940,10 +924,8 @@ NOXREF void MSG_ReadVec3Coord(sizebuf_t *sb, vec3_t fa)
}
}
NOXREF void MSG_WriteVec3Coord(sizebuf_t *sb, const vec3_t fa)
void MSG_WriteVec3Coord(sizebuf_t *sb, const vec3_t fa)
{
NOXREFCHECK;
MSG_StartBitWriting(sb);
MSG_WriteBitVec3Coord(fa);
MSG_EndBitWriting(sb);
@ -1047,10 +1029,8 @@ int MSG_ReadLong(void)
return c;
}
NOXREF float MSG_ReadFloat(void)
float MSG_ReadFloat(void)
{
NOXREFCHECK;
float f;
if (msg_readcount + 4 <= net_message.cursize)
@ -1109,10 +1089,8 @@ char *MSG_ReadStringLine(void)
return string;
}
NOXREF float MSG_ReadAngle(void)
float MSG_ReadAngle(void)
{
NOXREFCHECK;
int c = MSG_ReadChar();
#ifdef REHLDS_FIXES
if (c == -1) // FIXED: Added check for wrong value, but just return 0 instead of -1 * (360.0 / 256)
@ -1123,10 +1101,8 @@ NOXREF float MSG_ReadAngle(void)
return (float)(c * (360.0 / 256));
}
NOXREF float MSG_ReadHiresAngle(void)
float MSG_ReadHiresAngle(void)
{
NOXREFCHECK;
int c = MSG_ReadShort();
#ifdef REHLDS_FIXES
if (c == -1) // FIXED: Added check for wrong value, but just return 0 instead of -1 * (360.0 / 65536)

View File

@ -117,7 +117,7 @@ void MSG_WriteUsercmd(sizebuf_t *buf, usercmd_t *to, usercmd_t *from);
void COM_BitOpsInit(void);
void MSG_WriteOneBit(int nValue);
void MSG_StartBitWriting(sizebuf_t *buf);
NOXREF qboolean MSG_IsBitWriting(void);
qboolean MSG_IsBitWriting(void);
void MSG_EndBitWriting(sizebuf_t *buf);
void MSG_WriteBits(uint32 data, int numbits);
void MSG_WriteSBits(int data, int numbits);
@ -126,35 +126,35 @@ void MSG_WriteBitData(void *src, int length);
void MSG_WriteBitAngle(float fAngle, int numbits);
float MSG_ReadBitAngle(int numbits);
int MSG_CurrentBit(void);
NOXREF qboolean MSG_IsBitReading(void);
qboolean MSG_IsBitReading(void);
void MSG_StartBitReading(sizebuf_t *buf);
void MSG_EndBitReading(sizebuf_t *buf);
int MSG_ReadOneBit(void);
uint32 MSG_ReadBits(int numbits);
NOXREF uint32 MSG_PeekBits(int numbits);
uint32 MSG_PeekBits(int numbits);
int MSG_ReadSBits(int numbits);
NOXREF char *MSG_ReadBitString(void);
char *MSG_ReadBitString(void);
int MSG_ReadBitData(void *dest, int length);
NOXREF float MSG_ReadBitCoord(void);
float MSG_ReadBitCoord(void);
void MSG_WriteBitCoord(const float f);
NOXREF void MSG_ReadBitVec3Coord(vec3_t fa);
void MSG_ReadBitVec3Coord(vec3_t fa);
void MSG_WriteBitVec3Coord(const vec3_t fa);
NOXREF float MSG_ReadCoord(void);
float MSG_ReadCoord(void);
void MSG_WriteCoord(sizebuf_t *sb, const float f);
NOXREF void MSG_ReadVec3Coord(sizebuf_t *sb, vec3_t fa);
NOXREF void MSG_WriteVec3Coord(sizebuf_t *sb, const vec3_t fa);
void MSG_ReadVec3Coord(sizebuf_t *sb, vec3_t fa);
void MSG_WriteVec3Coord(sizebuf_t *sb, const vec3_t fa);
void MSG_BeginReading(void);
int MSG_ReadChar(void);
int MSG_ReadByte(void);
int MSG_ReadShort(void);
NOXREF int MSG_ReadWord(void);
int MSG_ReadLong(void);
NOXREF float MSG_ReadFloat(void);
float MSG_ReadFloat(void);
int MSG_ReadBuf(int iSize, void *pbuf);
char *MSG_ReadString(void);
char *MSG_ReadStringLine(void);
NOXREF float MSG_ReadAngle(void);
NOXREF float MSG_ReadHiresAngle(void);
float MSG_ReadAngle(void);
float MSG_ReadHiresAngle(void);
void MSG_ReadUsercmd(usercmd_t *to, usercmd_t *from);
void SZ_Alloc(const char *name, sizebuf_t *buf, int startsize);

View File

@ -37,7 +37,7 @@
#include "pr_dlls.h"
#define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 5
#define REHLDS_API_VERSION_MINOR 6
//Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -301,6 +301,55 @@ struct RehldsFuncs_t {
void(*RemoveExtDll)(void *hModule);
void(*RemoveCvarListener)(const char *var_name, cvar_callback_t func);
ENTITYINIT(*GetEntityInit)(char *pszClassName);
// Read functions
int(*MSG_ReadChar)();
int(*MSG_ReadByte)();
int(*MSG_ReadLong)();
float(*MSG_ReadFloat)();
char*(*MSG_ReadString)();
char*(*MSG_ReadStringLine)();
float(*MSG_ReadAngle)();
float(*MSG_ReadHiresAngle)();
void(*MSG_ReadUsercmd)(usercmd_t *to, usercmd_t *from);
float(*MSG_ReadCoord)();
void(*MSG_ReadVec3Coord)(sizebuf_t *sb, vec3_t fa);
// Read bit functions
bool(*MSG_IsBitReading)();
void(*MSG_StartBitReading)(sizebuf_t *buf);
void(*MSG_EndBitReading)(sizebuf_t *buf);
uint32(*MSG_PeekBits)(int numbits);
int(*MSG_ReadOneBit)();
uint32(*MSG_ReadBits)(int numbits);
int(*MSG_ReadSBits)(int numbits);
float(*MSG_ReadBitCoord)();
void(*MSG_ReadBitVec3Coord)(vec_t *fa);
float(*MSG_ReadBitAngle)(int numbits);
int(*MSG_ReadBitData)(void *dest, int length);
char*(*MSG_ReadBitString)();
int(*MSG_CurrentBit)();
// Write functions
void(*MSG_WriteLong)(sizebuf_t *sb, int c);
void(*MSG_WriteFloat)(sizebuf_t *sb, float f);
void(*MSG_WriteAngle)(sizebuf_t *sb, float f);
void(*MSG_WriteHiresAngle)(sizebuf_t *sb, float f);
void(*MSG_WriteUsercmd)(sizebuf_t *sb, usercmd_t *to, usercmd_t *from);
void(*MSG_WriteCoord)(sizebuf_t *sb, float f);
void(*MSG_WriteVec3Coord)(sizebuf_t *sb, const vec3_t fa);
// Write bit functions
bool(*MSG_IsBitWriting)();
void(*MSG_WriteOneBit)(int nValue);
void(*MSG_WriteSBits)(uint32 data, int numbits);
void(*MSG_WriteBitCoord)(float f);
void(*MSG_WriteBitAngle)(float fAngle, int numbits);
void(*MSG_WriteBitData)(void *src, int length);
void(*MSG_WriteBitString)(const char *p);
void(*SZ_Write)(sizebuf_t *buf, const void *data, int length);
void(*SZ_Print)(sizebuf_t *buf, const char *data);
void(*SZ_Clear)(sizebuf_t *buf);
};
class IRehldsApi {

View File

@ -85,24 +85,126 @@ DLL_FUNCTIONS* EXT_FUNC GetEntityInterface_api() {
return &gEntityInterface;
}
void EXT_FUNC MSG_StartBitWriting_api(sizebuf_t *buf) {
MSG_StartBitWriting(buf);
//
// Read functions API
//
int EXT_FUNC MSG_ReadChar_api() {
return MSG_ReadChar();
}
void EXT_FUNC MSG_WriteBits_api(uint32 data, int numbits) {
MSG_WriteBits(data, numbits);
int EXT_FUNC MSG_ReadByte_api() {
return MSG_ReadByte();
}
int EXT_FUNC MSG_ReadShort_api() {
return MSG_ReadShort();
}
int EXT_FUNC MSG_ReadLong_api() {
return MSG_ReadLong();
}
float EXT_FUNC MSG_ReadFloat_api() {
return MSG_ReadFloat();
}
char* EXT_FUNC MSG_ReadString_api() {
return MSG_ReadString();
}
char* EXT_FUNC MSG_ReadStringLine_api() {
return MSG_ReadStringLine();
}
int EXT_FUNC MSG_ReadBuf_api(int iSize, void *pbuf) {
return MSG_ReadBuf(iSize, pbuf);
}
void EXT_FUNC MSG_WriteBuf_api(sizebuf_t *sb, int iSize, void *buf) {
MSG_WriteBuf(sb, iSize, buf);
float EXT_FUNC MSG_ReadAngle_api() {
return MSG_ReadAngle();
}
float EXT_FUNC MSG_ReadHiresAngle_api() {
return MSG_ReadHiresAngle();
}
void EXT_FUNC MSG_ReadUsercmd_api(usercmd_t *to, usercmd_t *from) {
MSG_ReadUsercmd(to, from);
}
float EXT_FUNC MSG_ReadCoord_api() {
return MSG_ReadCoord();
}
void EXT_FUNC MSG_ReadVec3Coord_api(sizebuf_t *sb, vec3_t fa) {
MSG_ReadVec3Coord(sb, fa);
}
//
// Read bit functions API
//
bool EXT_FUNC MSG_IsBitReading_api() {
return MSG_IsBitReading() ? true : false;
}
void EXT_FUNC MSG_StartBitReading_api(sizebuf_t *buf) {
MSG_StartBitReading(buf);
}
void EXT_FUNC MSG_EndBitReading_api(sizebuf_t *buf) {
MSG_EndBitReading(buf);
}
uint32 EXT_FUNC MSG_PeekBits_api(int numbits) {
return MSG_PeekBits(numbits);
}
int EXT_FUNC MSG_ReadOneBit_api() {
return MSG_ReadOneBit();
}
uint32 EXT_FUNC MSG_ReadBits_api(int numbits) {
return MSG_ReadBits(numbits);
}
int EXT_FUNC MSG_ReadSBits_api(int numbits) {
return MSG_ReadSBits(numbits);
}
float EXT_FUNC MSG_ReadBitCoord_api() {
return MSG_ReadBitCoord();
}
void EXT_FUNC MSG_ReadBitVec3Coord_api(vec_t *fa) {
MSG_ReadBitVec3Coord(fa);
}
float EXT_FUNC MSG_ReadBitAngle_api(int numbits) {
return MSG_ReadBitAngle(numbits);
}
int EXT_FUNC MSG_ReadBitData_api(void *dest, int length) {
return MSG_ReadBitData(dest, length);
}
char* EXT_FUNC MSG_ReadBitString_api() {
return MSG_ReadBitString();
}
int EXT_FUNC MSG_CurrentBit_api() {
return MSG_CurrentBit();
}
//
// Write functions API
//
void EXT_FUNC MSG_WriteChar_api(sizebuf_t *sb, int c) {
MSG_WriteChar(sb, c);
}
void EXT_FUNC MSG_WriteByte_api(sizebuf_t *sb, int c) {
@ -113,16 +215,101 @@ void EXT_FUNC MSG_WriteShort_api(sizebuf_t *sb, int c) {
MSG_WriteShort(sb, c);
}
void EXT_FUNC MSG_WriteLong_api(sizebuf_t *sb, int c) {
MSG_WriteLong(sb, c);
}
void EXT_FUNC MSG_WriteFloat_api(sizebuf_t *sb, float f) {
MSG_WriteFloat(sb, f);
}
void EXT_FUNC MSG_WriteString_api(sizebuf_t *sb, const char *s) {
MSG_WriteString(sb, s);
}
void EXT_FUNC MSG_WriteBuf_api(sizebuf_t *sb, int iSize, void *buf) {
MSG_WriteBuf(sb, iSize, buf);
}
void EXT_FUNC MSG_WriteAngle_api(sizebuf_t *sb, float f) {
MSG_WriteAngle(sb, f);
}
void EXT_FUNC MSG_WriteHiresAngle_api(sizebuf_t *sb, float f) {
MSG_WriteHiresAngle(sb, f);
}
void EXT_FUNC MSG_WriteUsercmd_api(sizebuf_t *sb, usercmd_t *to, usercmd_t *from) {
MSG_WriteUsercmd(sb, to, from);
}
void EXT_FUNC MSG_WriteCoord_api(sizebuf_t *sb, float f) {
MSG_WriteCoord(sb, f);
}
void EXT_FUNC MSG_WriteVec3Coord_api(sizebuf_t *sb, const vec3_t fa) {
MSG_WriteVec3Coord(sb, fa);
}
//
// Write bit functions API
//
bool EXT_FUNC MSG_IsBitWriting_api() {
return MSG_IsBitWriting() ? true : false;
}
void EXT_FUNC MSG_StartBitWriting_api(sizebuf_t *buf) {
MSG_StartBitWriting(buf);
}
void EXT_FUNC MSG_EndBitWriting_api(sizebuf_t *buf) {
MSG_EndBitWriting(buf);
}
void EXT_FUNC MSG_WriteOneBit_api(int nValue) {
MSG_WriteOneBit(nValue);
}
void EXT_FUNC MSG_WriteBits_api(uint32 data, int numbits) {
MSG_WriteBits(data, numbits);
}
void EXT_FUNC MSG_WriteSBits_api(uint32 data, int numbits) {
MSG_WriteSBits(data, numbits);
}
void EXT_FUNC MSG_WriteBitCoord_api(float f) {
MSG_WriteBitCoord(f);
}
void EXT_FUNC MSG_WriteBitVec3Coord_api(const vec3_t fa) {
MSG_WriteBitVec3Coord(fa);
}
void EXT_FUNC MSG_EndBitWriting_api(sizebuf_t *buf) {
MSG_EndBitWriting(buf);
void EXT_FUNC MSG_WriteBitAngle_api(float fAngle, int numbits) {
MSG_WriteBitAngle(fAngle, numbits);
}
void EXT_FUNC MSG_WriteBitData_api(void *src, int length) {
MSG_WriteBitData(src, length);
}
void EXT_FUNC MSG_WriteBitString_api(const char *p) {
MSG_WriteBitString(p);
}
void EXT_FUNC SZ_Write_api(sizebuf_t *buf, const void *data, int length) {
SZ_Write(buf, data, length);
}
void EXT_FUNC SZ_Print_api(sizebuf_t *buf, const char *data) {
SZ_Print(buf, data);
}
void EXT_FUNC SZ_Clear_api(sizebuf_t *buf) {
SZ_Clear(buf);
}
cvar_t* EXT_FUNC GetCvarVars_api() {
@ -316,7 +503,48 @@ RehldsFuncs_t g_RehldsApiFuncs =
&AddCvarListener_api,
&RemoveExtDll_api,
&RemoveCvarListener_api,
&GetEntityInit
&GetEntityInit,
&MSG_ReadChar_api,
&MSG_ReadByte_api,
&MSG_ReadLong_api,
&MSG_ReadFloat_api,
&MSG_ReadString_api,
&MSG_ReadStringLine_api,
&MSG_ReadAngle_api,
&MSG_ReadHiresAngle_api,
&MSG_ReadUsercmd_api,
&MSG_ReadCoord_api,
&MSG_ReadVec3Coord_api,
&MSG_IsBitReading_api,
&MSG_StartBitReading_api,
&MSG_EndBitReading_api,
&MSG_PeekBits_api,
&MSG_ReadOneBit_api,
&MSG_ReadBits_api,
&MSG_ReadSBits_api,
&MSG_ReadBitCoord_api,
&MSG_ReadBitVec3Coord_api,
&MSG_ReadBitAngle_api,
&MSG_ReadBitData_api,
&MSG_ReadBitString_api,
&MSG_CurrentBit_api,
&MSG_WriteLong_api,
&MSG_WriteFloat_api,
&MSG_WriteAngle_api,
&MSG_WriteHiresAngle_api,
&MSG_WriteUsercmd_api,
&MSG_WriteCoord_api,
&MSG_WriteVec3Coord_api,
&MSG_IsBitWriting_api,
&MSG_WriteOneBit_api,
&MSG_WriteSBits_api,
&MSG_WriteBitCoord_api,
&MSG_WriteBitAngle_api,
&MSG_WriteBitData_api,
&MSG_WriteBitString_api,
&SZ_Write_api,
&SZ_Print_api,
&SZ_Clear_api,
};
bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin)