Some small cleanups to entity file support.

- Fix some compiler warning about wrong format strings.
- Comply to code style.
- Remove unnecessary comments.
This commit is contained in:
Yamagi Burmeister 2018-10-07 09:43:19 +02:00
parent d036868600
commit 9525dc35a8
3 changed files with 17 additions and 25 deletions

View file

@ -1612,58 +1612,51 @@ CMod_LoadVisibility(lump_t *l)
void
CMod_LoadEntityString(lump_t *l, char *name)
{
/*
* Port from Knightmare's kmquake2: support for .ent files.
*/
if (sv_entfile->value)
{
char s[MAX_QPATH];
char *buffer = NULL;
int nameLen, bufLen;
char s[MAX_QPATH];
char *buffer = NULL;
int nameLen, bufLen;
nameLen = strlen(name);
strcpy(s, name);
s[nameLen-3] = 'e'; s[nameLen-2] = 'n'; s[nameLen-1] = 't';
bufLen = FS_LoadFile (s, (void **)&buffer);
bufLen = FS_LoadFile(s, (void **)&buffer);
if (buffer != NULL && bufLen > 1)
{
if (bufLen + 1 > sizeof(map_entitystring)) /* jit fix */
if (bufLen + 1 > sizeof(map_entitystring))
{
Com_Printf ("CMod_LoadEntityString: .ent file %s too large: %i > %i.\n", s, bufLen, sizeof(map_entitystring));
FS_FreeFile (buffer);
Com_Printf("CMod_LoadEntityString: .ent file %s too large: %i > %lu.\n", s, bufLen, sizeof(map_entitystring));
FS_FreeFile(buffer);
}
else
{
Com_Printf ("CMod_LoadEntityString: .ent file %s loaded.\n", s);
numentitychars = bufLen;
memcpy (map_entitystring, 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);
return;
}
}
/* If the .ent file is too small, don't load. */
else if (bufLen != -1)
{
Com_Printf ("CMod_LoadEntityString: .ent file %s too small.\n", s);
FS_FreeFile (buffer);
/* If the .ent file is too small, don't load. */
Com_Printf("CMod_LoadEntityString: .ent file %s too small.\n", s);
FS_FreeFile(buffer);
}
/* Fall back to bsp entity string if no .ent file loaded */
}
/*
* End of the kmquake2 .ent file support port.
*/
numentitychars = l->filelen;
/* if (l->filelen > MAX_MAP_ENTSTRING) */
if (l->filelen + 1 > sizeof(map_entitystring)) /* jit fix */
if (l->filelen + 1 > sizeof(map_entitystring))
{
Com_Error(ERR_DROP, "Map has too large entity lump");
}
memcpy(map_entitystring, cmod_base + l->fileofs, l->filelen);
map_entitystring[l->filelen] = 0; /* jit entity bug - null terminate the entity string! */
map_entitystring[l->filelen] = 0;
}
/*

View file

@ -720,7 +720,7 @@ extern cvar_t *dedicated;
extern cvar_t *host_speeds;
extern cvar_t *log_stats;
/* Ported from kmquake2: .ent file support - whether to use .ent file or not */
/* External entity files. */
extern cvar_t *sv_entfile;
/* Hack for portable client */

View file

@ -49,7 +49,7 @@ cvar_t *maxclients; /* rename sv_maxclients */
cvar_t *sv_showclamp;
cvar_t *hostname;
cvar_t *public_server; /* should heartbeats be sent */
cvar_t *sv_entfile; /* From kmquake2: whether to use .ent file */
cvar_t *sv_entfile; /* External entity files. */
void Master_Shutdown(void);
void SV_ConnectionlessPacket(void);
@ -610,7 +610,6 @@ SV_Init(void)
public_server = Cvar_Get("public", "0", 0);
/* From kmquake2: whether to use .ent file. */
sv_entfile = Cvar_Get("sv_entfile", "1", CVAR_ARCHIVE);
SZ_Init(&net_message, net_message_buffer, sizeof(net_message_buffer));