extern void CL_Locs_Reload_f(void);
extern void CL_VM_Init (void);
+static const vec3_t defaultmins = {-4096, -4096, -4096};
+static const vec3_t defaultmaxs = {4096, 4096, 4096};
static void CL_SetupWorldModel(void)
{
// update the world model
// set up csqc world for collision culling
if (cl.worldmodel)
- {
- VectorCopy(cl.worldmodel->normalmins, cl.world.areagrid_mins);
- VectorCopy(cl.worldmodel->normalmaxs, cl.world.areagrid_maxs);
- }
+ World_SetSize(&cl.world, cl.worldmodel->normalmins, cl.worldmodel->normalmaxs);
else
- {
- VectorSet(cl.world.areagrid_mins, -4096, -4096, -4096);
- VectorSet(cl.world.areagrid_maxs, 4096, 4096, 4096);
- }
- World_Clear(&cl.world);
+ World_SetSize(&cl.world, defaultmins, defaultmaxs);
// load or reload .loc file for team chat messages
CL_Locs_Reload_f();
void CL_VM_CB_BeginIncreaseEdicts(void)
{
- int i;
- prvm_edict_t *ent;
-
// links don't survive the transition, so unlink everything
- for (i = 0, ent = prog->edicts;i < prog->max_edicts;i++, ent++)
- {
- if (!ent->priv.server->free)
- World_UnlinkEdict(prog->edicts + i);
- memset(&ent->priv.server->areagrid, 0, sizeof(ent->priv.server->areagrid));
- }
- World_Clear(&cl.world);
+ World_UnlinkAll(&cl.world);
}
void CL_VM_CB_EndIncreaseEdicts(void)
//
// clear world interaction links
//
- VectorCopy(sv.worldmodel->normalmins, sv.world.areagrid_mins);
- VectorCopy(sv.worldmodel->normalmaxs, sv.world.areagrid_maxs);
- World_Clear(&sv.world);
+ World_SetSize(&sv.world, sv.worldmodel->normalmins, sv.worldmodel->normalmaxs);
strlcpy(sv.sound_precache[0], "", sizeof(sv.sound_precache[0]));
static void SV_VM_CB_BeginIncreaseEdicts(void)
{
- int i;
- prvm_edict_t *ent;
-
// links don't survive the transition, so unlink everything
- for (i = 0, ent = prog->edicts;i < prog->max_edicts;i++, ent++)
- {
- if (!ent->priv.server->free)
- World_UnlinkEdict(prog->edicts + i);
- memset(&ent->priv.server->areagrid, 0, sizeof(ent->priv.server->areagrid));
- }
- World_Clear(&sv.world);
+ World_UnlinkAll(&sv.world);
}
static void SV_VM_CB_EndIncreaseEdicts(void)
/*
===============
-World_Clear
+World_SetSize
===============
*/
-void World_Clear(world_t *world)
+void World_SetSize(world_t *world, const vec3_t mins, const vec3_t maxs)
{
int i;
// the areagrid_marknumber is not allowed to be 0
World_ClearLink(&world->areagrid_outside);
for (i = 0;i < AREA_GRIDNODES;i++)
World_ClearLink(&world->areagrid[i]);
- Con_DPrintf("areagrid settings: divisions %ix%ix1 : box %f %f %f : %f %f %f size %f %f %f grid %f %f %f (mingrid %f)\n", AREA_GRID, AREA_GRID, world->areagrid_mins[0], world->areagrid_mins[1], world->areagrid_mins[2], world->areagrid_maxs[0], world->areagrid_maxs[1], world->areagrid_maxs[2], world->areagrid_size[0], world->areagrid_size[1], world->areagrid_size[2], 1.0f / world->areagrid_scale[0], 1.0f / world->areagrid_scale[1], 1.0f / world->areagrid_scale[2], sv_areagrid_mingridsize.value);
+ if (developer.integer >= 10)
+ Con_Printf("areagrid settings: divisions %ix%ix1 : box %f %f %f : %f %f %f size %f %f %f grid %f %f %f (mingrid %f)\n", AREA_GRID, AREA_GRID, world->areagrid_mins[0], world->areagrid_mins[1], world->areagrid_mins[2], world->areagrid_maxs[0], world->areagrid_maxs[1], world->areagrid_maxs[2], world->areagrid_size[0], world->areagrid_size[1], world->areagrid_size[2], 1.0f / world->areagrid_scale[0], 1.0f / world->areagrid_scale[1], 1.0f / world->areagrid_scale[2], sv_areagrid_mingridsize.value);
}
+/*
+===============
+World_UnlinkAll
+
+===============
+*/
+void World_UnlinkAll(world_t *world)
+{
+ int i;
+ link_t *grid;
+ // unlink all entities one by one
+ grid = &world->areagrid_outside;
+ while (grid->next != grid)
+ World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
+ for (i = 0, grid = world->areagrid;i < AREA_GRIDNODES;i++, grid++)
+ while (grid->next != grid)
+ World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
+}
/*
===============
void World_Init(void);
// called after the world model has been loaded, before linking any entities
-void World_Clear(world_t *world);
+void World_SetSize(world_t *world, const vec3_t mins, const vec3_t maxs);
+// unlinks all entities (used before reallocation of edicts)
+void World_UnlinkAll(world_t *world);
void World_PrintAreaStats(world_t *world, const char *worldname);