mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-23 12:22:26 +00:00
models: merge md5 mesh and anim on load
Merge content with use zero as separator of content sections. Fixes: https://github.com/yquake2/yquake2remaster/issues/4
This commit is contained in:
parent
8d0261c6a0
commit
f57ef011b5
3 changed files with 31 additions and 1 deletions
|
@ -1439,7 +1439,35 @@ Mod_LoadFileWithoutExt(const char *namewe, void **buffer, const char* ext)
|
||||||
filesize = ri.FS_LoadFile(newname, buffer);
|
filesize = ri.FS_LoadFile(newname, buffer);
|
||||||
if (filesize > 0)
|
if (filesize > 0)
|
||||||
{
|
{
|
||||||
return filesize;
|
int fullsize, filesize_anim;
|
||||||
|
char *final_buffer = NULL;
|
||||||
|
void *anim_buffer = NULL;
|
||||||
|
|
||||||
|
Q_strlcpy(newname, namewe, sizeof(newname));
|
||||||
|
Q_strlcat(newname, ".md5anim", sizeof(newname));
|
||||||
|
filesize_anim = ri.FS_LoadFile(newname, &anim_buffer);
|
||||||
|
|
||||||
|
if (filesize_anim <= 0)
|
||||||
|
{
|
||||||
|
return filesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
fullsize = filesize + filesize_anim + 1;
|
||||||
|
|
||||||
|
/* allocate new buffer, ERR_FATAL on alloc fail */
|
||||||
|
final_buffer = ri.FS_AllocFile(fullsize);
|
||||||
|
|
||||||
|
/* copy combined information */
|
||||||
|
memcpy(final_buffer, *buffer, filesize);
|
||||||
|
final_buffer[filesize] = 0;
|
||||||
|
memcpy(final_buffer + filesize + 1, anim_buffer, filesize_anim);
|
||||||
|
|
||||||
|
/* Remove old buffers */
|
||||||
|
ri.FS_FreeFile(anim_buffer);
|
||||||
|
ri.FS_FreeFile(*buffer);
|
||||||
|
|
||||||
|
*buffer = final_buffer;
|
||||||
|
return fullsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check Heretic2 model */
|
/* Check Heretic2 model */
|
||||||
|
|
|
@ -233,6 +233,7 @@ typedef struct
|
||||||
// NULL can be passed for buf to just determine existance
|
// NULL can be passed for buf to just determine existance
|
||||||
int (IMPORT *FS_LoadFile) (const char *name, void **buf);
|
int (IMPORT *FS_LoadFile) (const char *name, void **buf);
|
||||||
void (IMPORT *FS_FreeFile) (void *buf);
|
void (IMPORT *FS_FreeFile) (void *buf);
|
||||||
|
void *(IMPORT *FS_AllocFile) (int size);
|
||||||
|
|
||||||
// gamedir will be the current directory that generated
|
// gamedir will be the current directory that generated
|
||||||
// files should be stored to, ie: "f:\quake\id1"
|
// files should be stored to, ie: "f:\quake\id1"
|
||||||
|
|
|
@ -438,6 +438,7 @@ VID_LoadRenderer(void)
|
||||||
ri.FS_FreeFile = FS_FreeFile;
|
ri.FS_FreeFile = FS_FreeFile;
|
||||||
ri.FS_Gamedir = FS_Gamedir;
|
ri.FS_Gamedir = FS_Gamedir;
|
||||||
ri.FS_LoadFile = FS_LoadFile;
|
ri.FS_LoadFile = FS_LoadFile;
|
||||||
|
ri.FS_AllocFile = Z_Malloc;
|
||||||
ri.GLimp_InitGraphics = GLimp_InitGraphics;
|
ri.GLimp_InitGraphics = GLimp_InitGraphics;
|
||||||
ri.GLimp_GetDesktopMode = GLimp_GetDesktopMode;
|
ri.GLimp_GetDesktopMode = GLimp_GetDesktopMode;
|
||||||
ri.Sys_Error = Com_Error;
|
ri.Sys_Error = Com_Error;
|
||||||
|
|
Loading…
Reference in a new issue