mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-22 03:51:32 +00:00
c6c3d3f4e0
Quick hack preliminary d3d11 renderer. I'm not likely to touch this again for quite some time. Sys_Error works properly on android, with an error message shown. Should be less of a stab in the dark if you get errors. Seg faults are still instantly fatal. Not much I can reliably do about those - most of the juicy ones will likely occur within the gl drivers (even if its my fault) and java will still call in to it. Stereoscopic (quad-buffered) rendering is in the gl renderer. You'll likely need a quatro to use it despite it being a gl 1.0 feature. No idea about ati. See r_stereo_method for non-quad-buffered alternatives. Tweaked networking to not overflow so much. Needs testing against other qw clients. Fixed an issue with surface numbers > 32k on limit-breaking maps. Fixed a preparse issue resulting in QW clients dying with the ne_ruins map's progs. Support for the DP-variant of BSP2. The depricated RMQ variant is still supported. QTV proxy now uses ipv6 hybrid sockets where possible. Preliminary pext support. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4105 fc73d0e0-1445-4013-8a0c-d673dee63da5
173 lines
No EOL
3.1 KiB
C
173 lines
No EOL
3.1 KiB
C
#include "qtv.h"
|
|
|
|
void InitNetMsg(netmsg_t *b, void *buffer, int bufferlength)
|
|
{
|
|
b->data = buffer;
|
|
b->maxsize = bufferlength;
|
|
b->readpos = 0;
|
|
b->cursize = 0;
|
|
}
|
|
|
|
unsigned char ReadByte(netmsg_t *b)
|
|
{
|
|
if (b->readpos >= b->cursize)
|
|
{
|
|
b->readpos = b->cursize+1;
|
|
return 0;
|
|
}
|
|
return ((unsigned char *)b->data)[b->readpos++];
|
|
}
|
|
unsigned short ReadShort(netmsg_t *b)
|
|
{
|
|
int b1, b2;
|
|
b1 = ReadByte(b);
|
|
b2 = ReadByte(b);
|
|
|
|
return b1 | (b2<<8);
|
|
}
|
|
unsigned int ReadLong(netmsg_t *b)
|
|
{
|
|
int s1, s2;
|
|
s1 = ReadShort(b);
|
|
s2 = ReadShort(b);
|
|
|
|
return s1 | (s2<<16);
|
|
}
|
|
|
|
unsigned int BigLong(unsigned int val)
|
|
{
|
|
union {
|
|
unsigned int i;
|
|
unsigned char c[4];
|
|
} v;
|
|
|
|
v.i = val;
|
|
return (v.c[0]<<24) | (v.c[1] << 16) | (v.c[2] << 8) | (v.c[3] << 0);
|
|
}
|
|
|
|
unsigned int SwapLong(unsigned int val)
|
|
{
|
|
union {
|
|
unsigned int i;
|
|
unsigned char c[4];
|
|
} v;
|
|
unsigned char s;
|
|
|
|
v.i = val;
|
|
s = v.c[0];
|
|
v.c[0] = v.c[3];
|
|
v.c[3] = s;
|
|
s = v.c[1];
|
|
v.c[1] = v.c[2];
|
|
v.c[2] = s;
|
|
|
|
return v.i;
|
|
}
|
|
|
|
float ReadFloat(netmsg_t *b)
|
|
{
|
|
union {
|
|
unsigned int i;
|
|
float f;
|
|
} u;
|
|
|
|
u.i = ReadLong(b);
|
|
return u.f;
|
|
}
|
|
void ReadString(netmsg_t *b, char *string, int maxlen)
|
|
{
|
|
maxlen--; //for null terminator
|
|
while(maxlen)
|
|
{
|
|
*string = ReadByte(b);
|
|
if (!*string)
|
|
return;
|
|
string++;
|
|
maxlen--;
|
|
}
|
|
*string++ = '\0'; //add the null
|
|
|
|
printf("ReadString: buffer is too small\n");
|
|
while(ReadByte(b)) //finish reading the string, even if we will loose part of it
|
|
;
|
|
}
|
|
float ReadCoord(netmsg_t *b, unsigned int pext)
|
|
{
|
|
if (pext & PEXT_FLOATCOORDS)
|
|
return ReadFloat(b);
|
|
else
|
|
return ReadShort(b) / 8.0;
|
|
}
|
|
float ReadAngle(netmsg_t *b, unsigned int pext)
|
|
{
|
|
if (pext & PEXT_FLOATCOORDS)
|
|
return (ReadShort(b) * 360.0) / 0x10000;
|
|
else
|
|
return (ReadByte(b) * 360.0) / 0x100;
|
|
}
|
|
|
|
void WriteByte(netmsg_t *b, unsigned char c)
|
|
{
|
|
if (b->cursize>=b->maxsize)
|
|
return;
|
|
((unsigned char*)b->data)[b->cursize++] = c;
|
|
}
|
|
void WriteShort(netmsg_t *b, unsigned short l)
|
|
{
|
|
WriteByte(b, (l&0x00ff)>>0);
|
|
WriteByte(b, (l&0xff00)>>8);
|
|
}
|
|
void WriteLong(netmsg_t *b, unsigned int l)
|
|
{
|
|
WriteByte(b, (l&0x000000ff)>>0);
|
|
WriteByte(b, (l&0x0000ff00)>>8);
|
|
WriteByte(b, (l&0x00ff0000)>>16);
|
|
WriteByte(b, (l&0xff000000)>>24);
|
|
}
|
|
void WriteFloat(netmsg_t *b, float f)
|
|
{
|
|
union {
|
|
unsigned int i;
|
|
float f;
|
|
} u;
|
|
|
|
u.f = f;
|
|
WriteLong(b, u.i);
|
|
}
|
|
void WriteString2(netmsg_t *b, const char *str)
|
|
{ //no null terminator, convienience function.
|
|
while(*str)
|
|
WriteByte(b, *str++);
|
|
}
|
|
void WriteString(netmsg_t *b, const char *str)
|
|
{
|
|
while(*str)
|
|
WriteByte(b, *str++);
|
|
WriteByte(b, 0);
|
|
}
|
|
void WriteData(netmsg_t *b, const void *data, int length)
|
|
{
|
|
int i;
|
|
unsigned char *buf;
|
|
|
|
if (b->cursize + length > b->maxsize) //urm, that's just too big. :(
|
|
return;
|
|
buf = (unsigned char*)b->data+b->cursize;
|
|
for (i = 0; i < length; i++)
|
|
*buf++ = ((unsigned char*)data)[i];
|
|
b->cursize+=length;
|
|
}
|
|
void WriteCoordf(netmsg_t *b, unsigned int pext, float fl)
|
|
{
|
|
if (pext & PEXT_FLOATCOORDS)
|
|
WriteFloat(b, fl);
|
|
else
|
|
WriteShort(b, fl*8);
|
|
}
|
|
void WriteAnglef(netmsg_t *b, unsigned int pext, float fl)
|
|
{
|
|
if (pext & PEXT_FLOATCOORDS)
|
|
WriteShort(b, (fl/360)*0x10000);
|
|
else
|
|
WriteByte(b, (fl/360)*0x100);
|
|
} |