mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
K_InitBrightmapsPwad: Also use guaranteed null-terminated data copy ala K_InitTerrain
This commit is contained in:
parent
496cc2fa0b
commit
2d95c177ea
1 changed files with 13 additions and 4 deletions
|
|
@ -86,7 +86,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
|
static boolean K_BRIGHTLumpParser(char *data, size_t size)
|
||||||
|
|
||||||
Parses inputted lump data as a BRIGHT lump.
|
Parses inputted lump data as a BRIGHT lump.
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN
|
||||||
Return:-
|
Return:-
|
||||||
false if any errors occured, otherwise true.
|
false if any errors occured, otherwise true.
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
|
static boolean K_BRIGHTLumpParser(char *data, size_t size)
|
||||||
{
|
{
|
||||||
char *tkn = M_GetToken((char *)data);
|
char *tkn = M_GetToken((char *)data);
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
@ -188,6 +188,7 @@ void K_InitBrightmapsPwad(INT32 wadNum)
|
||||||
{
|
{
|
||||||
lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum];
|
lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum];
|
||||||
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
|
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
|
||||||
|
char *datacopy;
|
||||||
|
|
||||||
size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
||||||
char *name = malloc(nameLength + 1);
|
char *name = malloc(nameLength + 1);
|
||||||
|
|
@ -198,10 +199,18 @@ void K_InitBrightmapsPwad(INT32 wadNum)
|
||||||
size = W_LumpLengthPwad(wadNum, lumpNum);
|
size = W_LumpLengthPwad(wadNum, lumpNum);
|
||||||
|
|
||||||
CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name);
|
CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name);
|
||||||
K_BRIGHTLumpParser(data, size);
|
|
||||||
|
datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL);
|
||||||
|
memmove(datacopy,data,size);
|
||||||
|
datacopy[size] = '\0';
|
||||||
|
|
||||||
|
Z_Free(data);
|
||||||
|
|
||||||
|
K_BRIGHTLumpParser(datacopy, size);
|
||||||
|
|
||||||
|
Z_Free(datacopy);
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
Z_Free(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
|
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue