Skip to content

Commit

Permalink
camplete garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvensson committed Jan 19, 2025
1 parent 2946642 commit 5383dd2
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/bspfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#define MAX_MAP_HULLS 4

#define MAX_MAP_MODELS 512
#define MAX_MAP_MODELS 4096
#define MAX_MAP_BRUSHES 4096
#define MAX_MAP_ENTITIES 1024
#define MAX_MAP_ENTSTRING 65536
Expand Down
23 changes: 16 additions & 7 deletions src/cl_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,16 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits) {
#endif

to->flags = bits;
if (bits & U_MODEL)
if (bits & U_MODEL) {
to->modelindex = MSG_ReadByte();
#ifdef FTE_PEXT_MODELDBL
if (morebits & U_FTE_MODELDBL) {
to->modelindex += 256;
}
} else if (morebits & U_FTE_MODELDBL) {
to->modelindex = MSG_ReadShort();
#endif
}

if (bits & U_FRAME)
to->frame = MSG_ReadByte ();
Expand Down Expand Up @@ -591,11 +599,6 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits) {
to->number += 1024;
}
#endif
#ifdef FTE_PEXT_MODELDBL
if (morebits & U_FTE_MODELDBL) {
to->modelindex += 256;
}
#endif
#endif
}

Expand Down Expand Up @@ -999,7 +1002,13 @@ void CL_LinkPacketEntities(void)

if (!(model = cl.model_precache[state->modelindex]))
{
Host_Error ("CL_LinkPacketEntities: bad modelindex");
for (i = 0; i < 4096; i++)
{
if (!cl.model_precache[i])
continue;
Con_Printf("m[%d]: %s\n", i, cl.model_precache[i]->name);
}
Host_Error ("CL_LinkPacketEntities: bad modelindex (%d)", state->modelindex);
}

ent.model = model;
Expand Down
6 changes: 3 additions & 3 deletions src/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,9 +1677,9 @@ static void CL_ReadPackets(void)
{
if (curtime - cls.netchan.last_received > (cl_timeout.value > 0 ? cl_timeout.value : 60))
{
Com_Printf("\nServer connection timed out.\n");
Host_EndGame();
return;
//Com_Printf("\nServer connection timed out.\n");
//Host_EndGame();
//return;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ typedef struct {
char map[MAX_STYLESTRING];
} lightstyle_t;

#define MAX_STATIC_ENTITIES 512 // torches, etc
#define MAX_STATIC_ENTITIES 2048 // torches, etc
#define MAX_DEMOS 8
#define MAX_DEMONAME 16

Expand Down Expand Up @@ -800,7 +800,7 @@ typedef struct visentity_s {
qbool draw[visent_max];
} visentity_t;

#define MAX_STANDARD_ENTITIES 512
#define MAX_STANDARD_ENTITIES 2048

typedef struct visentlist_s {
visentity_t list[MAX_STANDARD_ENTITIES];
Expand Down
38 changes: 33 additions & 5 deletions src/cmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,9 @@ crosses a waterline.
=============================================================================
*/

static int fatbytes;
static byte fatpvs[MAX_MAP_LEAFS/8];
static int fatbytes = 0;
static byte *fatpvs = NULL;
static size_t fatpvs_capacity;
static vec3_t fatpvs_org;

static void AddToFatPVS_r (cnode_t *node)
Expand Down Expand Up @@ -498,11 +499,23 @@ Calculates a PVS that is the inclusive or of all leafs within 8 pixels of the
given point.
=============
*/
#define VIS_ALIGN 16 // vis buffer size alignment (in bytes)
#define VIS_ALIGN_MASK (VIS_ALIGN - 1) // alignment - 1, to simplify alignment code
byte *CM_FatPVS (vec3_t org)
{
VectorCopy (org, fatpvs_org);

fatbytes = (visleafs+31)>>3;
fatbytes = (visleafs+7)>>3; // ericw -- was +31, assumed to be a bug/typo
fatbytes = (fatbytes + VIS_ALIGN_MASK) & ~VIS_ALIGN_MASK; // round up
if (fatpvs == NULL || fatbytes > fatpvs_capacity)
{
fatpvs_capacity = fatbytes;
fatpvs = (byte *) realloc (fatpvs, fatpvs_capacity);
if (!fatpvs)
Sys_Error ("SV_FatPVS: realloc() failed on %d bytes", fatpvs_capacity);
}

//fatbytes = (visleafs+31)>>3;
memset (fatpvs, 0, fatbytes);
AddToFatPVS_r (map_nodes);
return fatpvs;
Expand Down Expand Up @@ -1071,14 +1084,24 @@ static void CM_LoadPlanes(byte *buffer, size_t length)
/*
** DecompressVis
*/
#define VIS_ALIGN 16 // vis buffer size alignment (in bytes)
#define VIS_ALIGN_MASK (VIS_ALIGN - 1) // alignment - 1, to simplify alignment code

static byte *DecompressVis(byte *in)
{
static byte decompressed[MAX_MAP_LEAFS / 8];
static byte *decompressed = NULL;
static size_t decompressed_capacity = 0;
int c, row;
byte *out;
byte *out, *outend;

row = (visleafs + 7) >> 3;
if (decompressed == NULL || row > decompressed_capacity)
{
decompressed_capacity = (row + VIS_ALIGN_MASK) & ~VIS_ALIGN_MASK;
decompressed = (byte *) Q_realloc (decompressed, decompressed_capacity);
}
out = decompressed;
outend = decompressed + row;

if (!in) { // no vis info, so make all visible
while (row) {
Expand All @@ -1097,6 +1120,11 @@ static byte *DecompressVis(byte *in)
c = in[1];
in += 2;
while (c) {
if (out == outend)
{
Con_Printf("Mod_DecompressVis: output overrun on model\n");
return decompressed;
}
*out++ = 0;
c--;
}
Expand Down
5 changes: 5 additions & 0 deletions src/com_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
bits |= U_MODEL;
#ifdef FTE_PEXT_ENTITYDBL
if (to->modelindex > 255) {
if (to->modelindex > 512) {
bits &= ~U_MODEL;
}
evenmorebits |= U_FTE_MODELDBL;
required_extensions |= FTE_PEXT_MODELDBL;
}
Expand Down Expand Up @@ -408,6 +411,8 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *

if (bits & U_MODEL)
MSG_WriteByte (msg, to->modelindex & 255);
else if (evenmorebits & U_FTE_MODELDBL)
MSG_WriteShort(msg, to->modelindex);
if (bits & U_FRAME)
MSG_WriteByte (msg, to->frame);
if (bits & U_COLORMAP)
Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef enum
#define MAX_EDICTS 2048 // can't encode more than this, see SV_WriteDelta
#define MAX_EDICTS_SAFE 512 // lower limit, to make sure no client limits exceeded
#define MAX_LIGHTSTYLES 64
#define MAX_MODELS 512 // can't encode more than this, see SV_WriteDelta
#define MAX_MODELS 4096 // can't encode more than this, see SV_WriteDelta
#define MAX_VWEP_MODELS 32 // could be increased to 256
#define MAX_SOUNDS 256 // so they cannot be blindly increased

Expand Down
6 changes: 4 additions & 2 deletions src/glsl/draw_world.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ void main()
texColor = vec4(mix(texColor.rgb, texColor.rgb + lumaColor.rgb, min(1, Flags & EZQ_SURFACE_HAS_LUMA)), texColor.a);
#endif
texColor = applyColorTinting(texColor);
frag_colour = vec4(lmColor.rgb * alpha, alpha) * texColor;
frag_colour = vec4(lmColor.rgb, 1) * texColor;
#if defined(DRAW_LUMA_TEXTURES) && defined(DRAW_LUMA_TEXTURES_FB)
lumaColor = applyColorTinting(lumaColor);
frag_colour = vec4(mix(frag_colour.rgb, frag_colour.rgb + lumaColor.rgb, min(1, Flags & EZQ_SURFACE_HAS_LUMA)), frag_colour.a);
frag_colour = vec4(mix(frag_colour.rgb, lumaColor.rgb * alpha, min(1, Flags & EZQ_SURFACE_HAS_FB) * lumaColor.a), frag_colour.a);
frag_colour = vec4(mix(frag_colour.rgb, lumaColor.rgb, min(1, Flags & EZQ_SURFACE_HAS_FB) * lumaColor.a), frag_colour.a);
#elif !defined(DRAW_LUMA_TEXTURES) && defined(DRAW_LUMA_TEXTURES_FB)
// GL_DECAL
lumaColor = applyColorTinting(lumaColor);
Expand All @@ -255,5 +255,7 @@ void main()
#ifdef DRAW_FOG
frag_colour = applyFog(frag_colour, gl_FragCoord.z / gl_FragCoord.w);
#endif

frag_colour *= alpha;
}
}
17 changes: 16 additions & 1 deletion src/r_brushmodel_surfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,20 +369,35 @@ void R_DrawWorld(void)
}
R_TraceLeaveNamedRegion();
}
#define VIS_ALIGN 16 // vis buffer size alignment (in bytes)
#define VIS_ALIGN_MASK (VIS_ALIGN - 1) // alignment - 1, to simplify alignment code

void R_MarkLeaves(void)
{
byte *vis;
mnode_t *node;
int i;
byte solid[MAX_MAP_LEAFS / 8];
static byte *solid;
static size_t solid_capacity;
extern cvar_t r_novis;
int solidbytes;

if (!r_novis.value && r_oldviewleaf == r_viewleaf && r_oldviewleaf2 == r_viewleaf2) {
// watervis hack
return;
}

solidbytes = (cl.worldmodel->numleafs+7)>>3; // ericw -- was +31, assumed to be a bug/typo
solidbytes = (solidbytes + VIS_ALIGN_MASK) & ~VIS_ALIGN_MASK; // round up
if (solid == NULL || solidbytes > solid_capacity)
{
solid_capacity = solidbytes;
solid = (byte *) realloc (solid, solid_capacity);
if (!solid)
Sys_Error ("SV_FatPVS: realloc() failed on %d bytes", solid_capacity);
}


r_visframecount++;
r_oldviewleaf = r_viewleaf;

Expand Down
14 changes: 12 additions & 2 deletions src/r_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void Mod_AddModelFlags(model_t *mod);

byte mod_novis[MAX_MAP_LEAFS/8];

#define MAX_MOD_KNOWN 512
#define MAX_MOD_KNOWN 4096
model_t mod_known[MAX_MOD_KNOWN];
int mod_numknown;

Expand Down Expand Up @@ -94,13 +94,23 @@ mleaf_t *Mod_PointInLeaf(vec3_t p, model_t *model)
return NULL; // never reached
}

#define VIS_ALIGN 16 // vis buffer size alignment (in bytes)
#define VIS_ALIGN_MASK (VIS_ALIGN - 1) // alignment - 1, to simplify alignment code

byte *Mod_DecompressVis(byte *in, model_t *model)
{
static byte decompressed[MAX_MAP_LEAFS / 8];
static byte *decompressed;
static size_t decompressed_capacity;
int c, row;
byte *out;

row = (model->numleafs + 7) >> 3;
if (decompressed == NULL || row > decompressed_capacity)
{
decompressed_capacity = (row + VIS_ALIGN_MASK) & ~VIS_ALIGN_MASK;
decompressed = (byte *) Q_realloc (decompressed, decompressed_capacity);
}

out = decompressed;

if (!in) { // no vis info, so make all visible
Expand Down
4 changes: 2 additions & 2 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ typedef struct

qbool mvdrecording;

entity_state_t static_entities[512];
entity_state_t static_entities[2048];
int static_entity_count;
} server_t;

Expand Down Expand Up @@ -733,7 +733,7 @@ extern demo_t demo; // server demo struct
extern client_t *sv_client;
extern edict_t *sv_player;

#define MODEL_NAME_LEN 5
#define MODEL_NAME_LEN 6
extern char localmodels[MAX_MODELS][MODEL_NAME_LEN]; // inline model names for precache
//extern char localinfo[MAX_LOCALINFO_STRING+1];
extern ctxinfo_t _localinfo_;
Expand Down
2 changes: 1 addition & 1 deletion src/sv_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void SV_WriteDelta(client_t* client, entity_state_t *from, entity_state_t *to, s
bits |= U_MODEL;
#ifdef FTE_PEXT_ENTITYDBL
if (to->modelindex > 255) {
if (to->modelindex > 512) {
if (to->modelindex >= 512) {
bits &= ~U_MODEL;
}
evenmorebits |= U_FTE_MODELDBL;
Expand Down
2 changes: 1 addition & 1 deletion src/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server_static_t svs; // persistent server info
server_t sv; // local server
demo_t demo; // server demo struct

char localmodels[MAX_MODELS][5]; // inline model names for precache
char localmodels[MAX_MODELS][6]; // inline model names for precache

//char localinfo[MAX_LOCALINFO_STRING+1]; // local game info
ctxinfo_t _localinfo_;
Expand Down
7 changes: 4 additions & 3 deletions src/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ void SV_Error (char *error, ...)
vsnprintf (string, sizeof (string), error, argptr);
va_end (argptr);

SV_Shutdown (va ("SV_Error: %s\n", string));
//SV_Shutdown (va ("SV_Error: %s\n", string));
Con_Printf (va ("SV_Error: %s\n", string));

Host_EndGame();
Host_Error("SV_Error: %s", string);
//Host_EndGame();
//Host_Error("SV_Error: %s", string);
}

static void SV_FreeHeadDelayedPacket(client_t *cl) {
Expand Down
2 changes: 1 addition & 1 deletion src/sv_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ static void Cmd_Modellist_f (void)
maxclientsupportedmodels = 256;
#ifdef FTE_PEXT_MODELDBL
if (sv_client->fteprotocolextensions & FTE_PEXT_MODELDBL) {
maxclientsupportedmodels *= 2;
maxclientsupportedmodels = 4096;
}
#endif

Expand Down

0 comments on commit 5383dd2

Please sign in to comment.