mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
make a LoadBSPMem function so bsp files can be read from already loaded
images
This commit is contained in:
parent
7fe0962bac
commit
0a0f8d0cfa
2 changed files with 16 additions and 6 deletions
|
@ -279,6 +279,7 @@ typedef struct bsp_s {
|
|||
int *surfedges;
|
||||
} bsp_t;
|
||||
|
||||
bsp_t *LoadBSPMem (void *mem, int size);
|
||||
bsp_t *LoadBSPFile (QFile *file, int size);
|
||||
void WriteBSPFile (bsp_t *bsp, QFile *file);
|
||||
bsp_t *BSP_New (void);
|
||||
|
|
|
@ -176,14 +176,11 @@ swap_bsp (bsp_t *bsp, int todisk)
|
|||
}
|
||||
|
||||
bsp_t *
|
||||
LoadBSPFile (QFile *file, int size)
|
||||
LoadBSPMem (void *mem, int size)
|
||||
{
|
||||
dheader_t *header;
|
||||
dheader_t *header = mem;
|
||||
bsp_t *bsp;
|
||||
|
||||
header = malloc (size);
|
||||
Qread (file, header, size);
|
||||
|
||||
if (LittleLong (header->version) != BSPVERSION)
|
||||
Sys_Error ("version %i, not %i", LittleLong (header->version),
|
||||
BSPVERSION);
|
||||
|
@ -232,12 +229,24 @@ do { \
|
|||
SET_LUMP (LUMP_ENTITIES, entdata);
|
||||
SET_LUMP (LUMP_TEXTURES, texdata);
|
||||
|
||||
free (header);
|
||||
|
||||
swap_bsp (bsp, 0);
|
||||
return bsp;
|
||||
}
|
||||
|
||||
bsp_t *
|
||||
LoadBSPFile (QFile *file, int size)
|
||||
{
|
||||
void *buf;
|
||||
bsp_t *bsp;
|
||||
|
||||
buf = malloc (size);
|
||||
Qread (file, buf, size);
|
||||
bsp = LoadBSPMem (buf, size);
|
||||
free (buf);
|
||||
return bsp;
|
||||
}
|
||||
|
||||
/*
|
||||
WriteBSPFile
|
||||
|
||||
|
|
Loading…
Reference in a new issue