mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-12-01 16:51:18 +00:00
maps: move entity add null terminate to sv_init
This commit is contained in:
parent
7e53c83c88
commit
fb85150702
4 changed files with 31 additions and 16 deletions
|
@ -1495,7 +1495,7 @@ Mod_LoadModel_MD3(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
{
|
{
|
||||||
const md3_shader_t *md3_shader = (md3_shader_t*)((byte*)buffer + meshofs + LittleLong(md3_mesh->ofs_shaders)) + j;
|
const md3_shader_t *md3_shader = (md3_shader_t*)((byte*)buffer + meshofs + LittleLong(md3_mesh->ofs_shaders)) + j;
|
||||||
|
|
||||||
strncpy(skin, md3_shader->name, Q_min(sizeof(md3_shader->name), MAX_SKINNAME) - 1);
|
memcpy(skin, md3_shader->name, Q_min(sizeof(md3_shader->name), MAX_SKINNAME));
|
||||||
skin += MAX_SKINNAME;
|
skin += MAX_SKINNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ typedef struct
|
||||||
int numclusters;
|
int numclusters;
|
||||||
int numvisibility;
|
int numvisibility;
|
||||||
|
|
||||||
char *map_entitystring;
|
const char *map_entitystring;
|
||||||
int numentitychars;
|
int numentitychars;
|
||||||
|
|
||||||
int extradatasize;
|
int extradatasize;
|
||||||
|
@ -1651,7 +1651,7 @@ CMod_LoadAreaPortals(const char *name, const dareaportal_t **map_areaportals, qb
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CMod_LoadEntityString(const char *name, char **map_entitystring, int *numentitychars,
|
CMod_LoadEntityString(const char *name, const char **map_entitystring, int *numentitychars,
|
||||||
const byte *cmod_base, const lump_t *l)
|
const byte *cmod_base, const lump_t *l)
|
||||||
{
|
{
|
||||||
if (sv_entfile->value)
|
if (sv_entfile->value)
|
||||||
|
@ -1688,14 +1688,15 @@ CMod_LoadEntityString(const char *name, char **map_entitystring, int *numentityc
|
||||||
|
|
||||||
if (buffer != NULL && bufLen > 1)
|
if (buffer != NULL && bufLen > 1)
|
||||||
{
|
{
|
||||||
Com_Printf (".ent file %s loaded.\n", entname);
|
char *entity;
|
||||||
*numentitychars = bufLen;
|
*numentitychars = bufLen;
|
||||||
|
|
||||||
*map_entitystring = Hunk_Alloc(bufLen + 1);
|
entity = Hunk_Alloc(bufLen);
|
||||||
|
memcpy(entity, buffer, bufLen);
|
||||||
memcpy(*map_entitystring, buffer, bufLen);
|
|
||||||
(*map_entitystring)[bufLen] = 0; /* jit entity bug - null terminate the entity string! */
|
|
||||||
FS_FreeFile(buffer);
|
FS_FreeFile(buffer);
|
||||||
|
|
||||||
|
Com_Printf (".ent file %s loaded.\n", entname);
|
||||||
|
*map_entitystring = entity;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (bufLen != -1)
|
else if (bufLen != -1)
|
||||||
|
@ -1713,9 +1714,7 @@ CMod_LoadEntityString(const char *name, char **map_entitystring, int *numentityc
|
||||||
Com_Error(ERR_DROP, "%s: Map has too small entity lump", __func__);
|
Com_Error(ERR_DROP, "%s: Map has too small entity lump", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
*map_entitystring = Hunk_Alloc(l->filelen + 1);
|
*map_entitystring = (const char *)cmod_base + l->fileofs;
|
||||||
memcpy(*map_entitystring, cmod_base + l->fileofs, l->filelen);
|
|
||||||
(*map_entitystring)[l->filelen] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1974,9 +1973,10 @@ CM_NumInlineModels(void)
|
||||||
return cmod->numcmodels;
|
return cmod->numcmodels;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
CM_EntityString(void)
|
CM_EntityString(int *size)
|
||||||
{
|
{
|
||||||
|
*size = cmod->numentitychars;
|
||||||
return cmod->map_entitystring;
|
return cmod->map_entitystring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,7 @@ void CM_ModFreeAll(void);
|
||||||
|
|
||||||
int CM_NumClusters(void);
|
int CM_NumClusters(void);
|
||||||
int CM_NumInlineModels(void);
|
int CM_NumInlineModels(void);
|
||||||
char *CM_EntityString(void);
|
const char *CM_EntityString(int *size);
|
||||||
|
|
||||||
/* creates a clipping hull for an arbitrary box */
|
/* creates a clipping hull for an arbitrary box */
|
||||||
int CM_HeadnodeForBox(vec3_t mins, vec3_t maxs);
|
int CM_HeadnodeForBox(vec3_t mins, vec3_t maxs);
|
||||||
|
|
|
@ -194,8 +194,10 @@ static void
|
||||||
SV_SpawnServer(char *server, char *spawnpoint, server_state_t serverstate,
|
SV_SpawnServer(char *server, char *spawnpoint, server_state_t serverstate,
|
||||||
qboolean attractloop, qboolean loadgame, qboolean isautosave)
|
qboolean attractloop, qboolean loadgame, qboolean isautosave)
|
||||||
{
|
{
|
||||||
int i;
|
const char *entity_orig;
|
||||||
unsigned checksum;
|
unsigned checksum;
|
||||||
|
char *entity;
|
||||||
|
int i, entitysize;
|
||||||
|
|
||||||
if (attractloop)
|
if (attractloop)
|
||||||
{
|
{
|
||||||
|
@ -286,8 +288,21 @@ SV_SpawnServer(char *server, char *spawnpoint, server_state_t serverstate,
|
||||||
sv.state = ss_loading;
|
sv.state = ss_loading;
|
||||||
Com_SetServerState(sv.state);
|
Com_SetServerState(sv.state);
|
||||||
|
|
||||||
|
/* copy original entities string */
|
||||||
|
entity_orig = CM_EntityString(&entitysize);
|
||||||
|
if (entitysize < 0)
|
||||||
|
{
|
||||||
|
entitysize = 0;
|
||||||
|
}
|
||||||
|
entity = malloc(entitysize + 1);
|
||||||
|
if (entitysize)
|
||||||
|
{
|
||||||
|
memcpy(entity, entity_orig, entitysize);
|
||||||
|
}
|
||||||
|
entity[entitysize] = 0; /* jit entity bug - null terminate the entity string! */
|
||||||
/* load and spawn all other entities */
|
/* load and spawn all other entities */
|
||||||
ge->SpawnEntities(sv.name, CM_EntityString(), spawnpoint);
|
ge->SpawnEntities(sv.name, entity, spawnpoint);
|
||||||
|
free(entity);
|
||||||
|
|
||||||
/* run two frames to allow everything to settle */
|
/* run two frames to allow everything to settle */
|
||||||
ge->RunFrame();
|
ge->RunFrame();
|
||||||
|
|
Loading…
Reference in a new issue