void MSG_WriteCoord (sizebuf_t *sb, float f)
{
- MSG_WriteShort (sb, (int)(f*8));
+ if (dpprotocol)
+ MSG_WriteFloat(sb, f);
+ else
+ MSG_WriteShort (sb, (int)(f*8.0f + 0.5f));
+}
+
+void MSG_WritePreciseAngle (sizebuf_t *sb, float f)
+{
+ MSG_WriteShort (sb, (int)(f*(65536.0f/360.0f) + 0.5f) & 65535);
}
+// LordHavoc: round to nearest value, rather than rounding down, fixes crosshair problem
void MSG_WriteAngle (sizebuf_t *sb, float f)
{
- MSG_WriteByte (sb, ((int)f*256/360) & 255);
+ MSG_WriteByte (sb, (int)(f*(256.0f/360.0f) + 0.5f) & 255);
}
//
return string;
}
+float MSG_ReadCoord (void)
+{
+ if (dpprotocol)
+ return MSG_ReadFloat();
+ else
+ return MSG_ReadShort() * (1.0f/8.0f);
+}
+
/*
float MSG_ReadCoord (void)
{
{
return MSG_ReadChar() * (360.0f/256.0f);
}
-*/
+float MSG_ReadPreciseAngle (void)
+{
+ return MSG_ReadShort() * (360.0f/65536);
+}
+*/
//===========================================================================
int dirlen;
} dpackheader_t;
-// LordHavoc: was 2048
+// LordHavoc: was 2048, increased to 16384 and changed info[MAX_PACK_FILES] to a temporary malloc to avoid stack overflows
#define MAX_FILES_IN_PACK 16384
char com_cachedir[MAX_OSPATH];
int numpackfiles;
pack_t *pack;
int packhandle;
- dpackfile_t info[MAX_FILES_IN_PACK];
+ // LordHavoc: changed from stack array to temporary malloc, allowing huge pack directories
+ dpackfile_t *info;
unsigned short crc;
if (Sys_FileOpenRead (packfile, &packhandle) == -1)
newfiles = Hunk_AllocName (numpackfiles * sizeof(packfile_t), "packfile");
+ info = malloc(sizeof(*info)*MAX_FILES_IN_PACK);
Sys_FileSeek (packhandle, header.dirofs);
Sys_FileRead (packhandle, (void *)info, header.dirlen);
newfiles[i].filepos = LittleLong(info[i].filepos);
newfiles[i].filelen = LittleLong(info[i].filelen);
}
+ free(info);
pack = Hunk_Alloc (sizeof (pack_t));
strcpy (pack->filename, packfile);