mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Rest of support for qflight/qfvis. bspfile.c and quakefs.c will need cleaning up, compare to previous cvs versions...
This commit is contained in:
parent
a3af2d9fa9
commit
cfedb80d1d
4 changed files with 432 additions and 26 deletions
16
configure.ac
16
configure.ac
|
@ -1900,6 +1900,16 @@ QF_DEPS(QFCC,
|
|||
[$(top_builddir)/libs/gamecode/engine/libQFgamecode.la $(top_builddir)/libs/util/libQFutil.la],
|
||||
[$(WIN32_LIBS)],
|
||||
)
|
||||
QF_DEPS(QFLIGHT,
|
||||
[-I$(top_srcdir)/tools/qflight/include],
|
||||
[$(top_builddir)/libs/gamecode/engine/libQFgamecode.la $(top_builddir)/libs/util/libQFutil.la],
|
||||
[$(WIN32_LIBS)],
|
||||
)
|
||||
QF_DEPS(QFVIS,
|
||||
[-I$(top_srcdir)/tools/qfvis/include],
|
||||
[$(top_builddir)/libs/gamecode/engine/libQFgamecode.la $(top_builddir)/libs/util/libQFutil.la],
|
||||
[$(WIN32_LIBS)],
|
||||
)
|
||||
QF_DEPS(QFPROGS,
|
||||
[-I$(top_srcdir)/tools/qfprogs/include],
|
||||
[$(top_builddir)/libs/gamecode/engine/libQFgamecode.la $(top_builddir)/libs/util/libQFutil.la],
|
||||
|
@ -1995,9 +2005,15 @@ AC_OUTPUT(
|
|||
tools/qfdefs/Makefile
|
||||
tools/qfdefs/include/Makefile
|
||||
tools/qfdefs/source/Makefile
|
||||
tools/qflight/Makefile
|
||||
tools/qflight/include/Makefile
|
||||
tools/qflight/source/Makefile
|
||||
tools/qfprogs/Makefile
|
||||
tools/qfprogs/include/Makefile
|
||||
tools/qfprogs/source/Makefile
|
||||
tools/qfvis/Makefile
|
||||
tools/qfvis/include/Makefile
|
||||
tools/qfvis/source/Makefile
|
||||
tools/qwaq/Makefile
|
||||
tools/qwaq/progs.src
|
||||
tools/wav/Makefile
|
||||
|
|
|
@ -26,11 +26,12 @@ libQFutil_la_LDFLAGS= -version-info 1:0:0
|
|||
libQFutil_la_LIBADD= libasm.la $(Z_LIBS) $(DL_LIBS)
|
||||
libQFutil_la_DEPENDENCIES= libasm.la
|
||||
libQFutil_la_SOURCES= \
|
||||
buildnum.c cbuf.c checksum.c cmd.c crc.c cvar.c dstring.c exp.c fendian.c \
|
||||
getopt.c getopt1.c gib_buffer.c gib_builtin.c gib_function.c gib_parse.c \
|
||||
gib_process.c gib_vars.c hash.c idparse.c info.c link.c mathlib.c mdfour.c \
|
||||
msg.c ops.c pakfile.c pcx.c plugin.c qargs.c qendian.c qfplist.c quakefs.c \
|
||||
quakeio.c sizebuf.c string.c sys.c tga.c va.c ver_check.c wad.c zone.c \
|
||||
bspfile.c buildnum.c cbuf.c checksum.c cmd.c crc.c cvar.c dstring.c \
|
||||
exp.c fendian.c getopt.c getopt1.c gib_buffer.c gib_builtin.c \
|
||||
gib_function.c gib_parse.c gib_process.c gib_vars.c hash.c idparse.c \
|
||||
info.c link.c mathlib.c mdfour.c msg.c ops.c pakfile.c pcx.c plugin.c \
|
||||
qargs.c qendian.c qfplist.c quakefs.c quakeio.c sizebuf.c string.c \
|
||||
sys.c tga.c va.c ver_check.c wad.c zone.c \
|
||||
$(fnmatch)
|
||||
|
||||
EXTRA_DIST= $(asm_src) $(fnmatch_src)
|
||||
|
|
337
libs/util/bspfile.c
Normal file
337
libs/util/bspfile.c
Normal file
|
@ -0,0 +1,337 @@
|
|||
/*
|
||||
bspfile.c
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/bspfile.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/vfile.h"
|
||||
#include "QF/vfs.h"
|
||||
|
||||
int nummodels;
|
||||
dmodel_t dmodels[MAX_MAP_MODELS];
|
||||
|
||||
int visdatasize;
|
||||
byte dvisdata[MAX_MAP_VISIBILITY];
|
||||
|
||||
int lightdatasize;
|
||||
byte dlightdata[MAX_MAP_LIGHTING];
|
||||
|
||||
int texdatasize;
|
||||
byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
|
||||
|
||||
int entdatasize;
|
||||
char dentdata[MAX_MAP_ENTSTRING];
|
||||
|
||||
int numleafs;
|
||||
dleaf_t dleafs[MAX_MAP_LEAFS];
|
||||
|
||||
int numplanes;
|
||||
dplane_t dplanes[MAX_MAP_PLANES];
|
||||
|
||||
int numvertexes;
|
||||
dvertex_t dvertexes[MAX_MAP_VERTS];
|
||||
|
||||
int numnodes;
|
||||
dnode_t dnodes[MAX_MAP_NODES];
|
||||
|
||||
int numtexinfo;
|
||||
texinfo_t texinfo[MAX_MAP_TEXINFO];
|
||||
|
||||
int numfaces;
|
||||
dface_t dfaces[MAX_MAP_FACES];
|
||||
|
||||
int numclipnodes;
|
||||
dclipnode_t dclipnodes[MAX_MAP_CLIPNODES];
|
||||
|
||||
int numedges;
|
||||
dedge_t dedges[MAX_MAP_EDGES];
|
||||
|
||||
int nummarksurfaces;
|
||||
unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES];
|
||||
|
||||
int numsurfedges;
|
||||
int dsurfedges[MAX_MAP_SURFEDGES];
|
||||
|
||||
dheader_t *header;
|
||||
dheader_t outheader;
|
||||
VFile *wadfile;
|
||||
|
||||
|
||||
/*
|
||||
SwapBSPFile
|
||||
|
||||
Byte swaps all data in a bsp file.
|
||||
*/
|
||||
void
|
||||
SwapBSPFile (qboolean todisk)
|
||||
{
|
||||
int c, i, j;
|
||||
dmiptexlump_t *mtl;
|
||||
dmodel_t *d;
|
||||
|
||||
// models
|
||||
for (i = 0; i < nummodels; i++) {
|
||||
d = &dmodels[i];
|
||||
|
||||
for (j = 0; j < MAX_MAP_HULLS; j++)
|
||||
d->headnode[j] = LittleLong (d->headnode[j]);
|
||||
|
||||
d->visleafs = LittleLong (d->visleafs);
|
||||
d->firstface = LittleLong (d->firstface);
|
||||
d->numfaces = LittleLong (d->numfaces);
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
d->mins[j] = LittleFloat (d->mins[j]);
|
||||
d->maxs[j] = LittleFloat (d->maxs[j]);
|
||||
d->origin[j] = LittleFloat (d->origin[j]);
|
||||
}
|
||||
}
|
||||
|
||||
// vertexes
|
||||
for (i = 0; i < numvertexes ; i++) {
|
||||
for (j = 0; j < 3; j++)
|
||||
dvertexes[i].point[j] = LittleFloat (dvertexes[i].point[j]);
|
||||
}
|
||||
|
||||
// planes
|
||||
for (i = 0; i < numplanes; i++) {
|
||||
for (j = 0; j < 3; j++)
|
||||
dplanes[i].normal[j] = LittleFloat (dplanes[i].normal[j]);
|
||||
dplanes[i].dist = LittleFloat (dplanes[i].dist);
|
||||
dplanes[i].type = LittleLong (dplanes[i].type);
|
||||
}
|
||||
|
||||
// texinfos
|
||||
for (i = 0; i < numtexinfo; i++) {
|
||||
for (j = 0; j < 8; j++)
|
||||
texinfo[i].vecs[0][j] = LittleFloat (texinfo[i].vecs[0][j]);
|
||||
texinfo[i].miptex = LittleLong (texinfo[i].miptex);
|
||||
texinfo[i].flags = LittleLong (texinfo[i].flags);
|
||||
}
|
||||
|
||||
// faces
|
||||
for (i = 0; i < numfaces; i++) {
|
||||
dfaces[i].texinfo = LittleShort (dfaces[i].texinfo);
|
||||
dfaces[i].planenum = LittleShort (dfaces[i].planenum);
|
||||
dfaces[i].side = LittleShort (dfaces[i].side);
|
||||
dfaces[i].lightofs = LittleLong (dfaces[i].lightofs);
|
||||
dfaces[i].firstedge = LittleLong (dfaces[i].firstedge);
|
||||
dfaces[i].numedges = LittleShort (dfaces[i].numedges);
|
||||
}
|
||||
|
||||
// nodes
|
||||
for (i = 0; i < numnodes; i++) {
|
||||
dnodes[i].planenum = LittleLong (dnodes[i].planenum);
|
||||
for (j = 0; j < 3; j++) {
|
||||
dnodes[i].mins[j] = LittleShort (dnodes[i].mins[j]);
|
||||
dnodes[i].maxs[j] = LittleShort (dnodes[i].maxs[j]);
|
||||
}
|
||||
dnodes[i].children[0] = LittleShort (dnodes[i].children[0]);
|
||||
dnodes[i].children[1] = LittleShort (dnodes[i].children[1]);
|
||||
dnodes[i].firstface = LittleShort (dnodes[i].firstface);
|
||||
dnodes[i].numfaces = LittleShort (dnodes[i].numfaces);
|
||||
}
|
||||
|
||||
// leafs
|
||||
for (i = 0; i < numleafs; i++) {
|
||||
dleafs[i].contents = LittleLong (dleafs[i].contents);
|
||||
for (j = 0; j < 3; j++) {
|
||||
dleafs[i].mins[j] = LittleShort (dleafs[i].mins[j]);
|
||||
dleafs[i].maxs[j] = LittleShort (dleafs[i].maxs[j]);
|
||||
}
|
||||
|
||||
dleafs[i].firstmarksurface = LittleShort (dleafs[i].firstmarksurface);
|
||||
dleafs[i].nummarksurfaces = LittleShort (dleafs[i].nummarksurfaces);
|
||||
dleafs[i].visofs = LittleLong (dleafs[i].visofs);
|
||||
}
|
||||
|
||||
// clipnodes
|
||||
for (i = 0; i < numclipnodes; i++) {
|
||||
dclipnodes[i].planenum = LittleLong (dclipnodes[i].planenum);
|
||||
dclipnodes[i].children[0] = LittleShort (dclipnodes[i].children[0]);
|
||||
dclipnodes[i].children[1] = LittleShort (dclipnodes[i].children[1]);
|
||||
}
|
||||
|
||||
// miptex
|
||||
if (texdatasize) {
|
||||
mtl = (dmiptexlump_t *) dtexdata;
|
||||
if (todisk)
|
||||
c = mtl->nummiptex;
|
||||
else
|
||||
c = LittleLong (mtl->nummiptex);
|
||||
mtl->nummiptex = LittleLong (mtl->nummiptex);
|
||||
for (i = 0; i < c; i++)
|
||||
mtl->dataofs[i] = LittleLong (mtl->dataofs[i]);
|
||||
}
|
||||
|
||||
// marksurfaces
|
||||
for (i = 0; i < nummarksurfaces; i++)
|
||||
dmarksurfaces[i] = LittleShort (dmarksurfaces[i]);
|
||||
|
||||
// surfedges
|
||||
for (i = 0; i < numsurfedges; i++)
|
||||
dsurfedges[i] = LittleLong (dsurfedges[i]);
|
||||
|
||||
// edges
|
||||
for (i = 0; i < numedges; i++) {
|
||||
dedges[i].v[0] = LittleShort (dedges[i].v[0]);
|
||||
dedges[i].v[1] = LittleShort (dedges[i].v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AddLump (int lumpnum, void *data, int len)
|
||||
{
|
||||
lump_t *lump;
|
||||
|
||||
lump = &header->lumps[lumpnum];
|
||||
|
||||
lump->fileofs = LittleLong (Qtell (wadfile));
|
||||
lump->filelen = LittleLong (len);
|
||||
Qwrite (wadfile, data, (len + 3) &~3);
|
||||
}
|
||||
|
||||
int
|
||||
CopyLump (int lump, void *dest, int size)
|
||||
{
|
||||
int length, ofs;
|
||||
|
||||
length = header->lumps[lump].filelen;
|
||||
ofs = header->lumps[lump].fileofs;
|
||||
|
||||
if (length % size)
|
||||
Sys_Error ("LoadBSPFile: odd lump size");
|
||||
|
||||
memcpy (dest, (byte *) header + ofs, length);
|
||||
|
||||
return length / size;
|
||||
}
|
||||
|
||||
extern int LoadFile (const char *filename, void **bufferptr);
|
||||
|
||||
void
|
||||
LoadBSPFile (const char *filename)
|
||||
{
|
||||
int i;
|
||||
|
||||
// load the file header
|
||||
LoadFile (filename, (void *) &header);
|
||||
|
||||
// swap the header
|
||||
for (i = 0; i < sizeof (dheader_t) / 4; i++)
|
||||
((int *) header)[i] = LittleLong (((int *) header)[i]);
|
||||
|
||||
if (header->version != BSPVERSION)
|
||||
Sys_Error ("%s is version %i, not %i", filename, i, BSPVERSION);
|
||||
|
||||
nummodels = CopyLump (LUMP_MODELS, dmodels, sizeof (dmodel_t));
|
||||
numvertexes = CopyLump (LUMP_VERTEXES, dvertexes, sizeof (dvertex_t));
|
||||
numplanes = CopyLump (LUMP_PLANES, dplanes, sizeof (dplane_t));
|
||||
numleafs = CopyLump (LUMP_LEAFS, dleafs, sizeof (dleaf_t));
|
||||
numnodes = CopyLump (LUMP_NODES, dnodes, sizeof (dnode_t));
|
||||
numtexinfo = CopyLump (LUMP_TEXINFO, texinfo, sizeof (texinfo_t));
|
||||
numclipnodes = CopyLump (LUMP_CLIPNODES, dclipnodes, sizeof (dclipnode_t));
|
||||
numfaces = CopyLump (LUMP_FACES, dfaces, sizeof (dface_t));
|
||||
nummarksurfaces = CopyLump (LUMP_MARKSURFACES, dmarksurfaces,
|
||||
sizeof (dmarksurfaces[0]));
|
||||
numsurfedges = CopyLump (LUMP_SURFEDGES, dsurfedges,
|
||||
sizeof (dsurfedges[0]));
|
||||
numedges = CopyLump (LUMP_EDGES, dedges, sizeof (dedge_t));
|
||||
|
||||
texdatasize = CopyLump (LUMP_TEXTURES, dtexdata, 1);
|
||||
visdatasize = CopyLump (LUMP_VISIBILITY, dvisdata, 1);
|
||||
lightdatasize = CopyLump (LUMP_LIGHTING, dlightdata, 1);
|
||||
entdatasize = CopyLump (LUMP_ENTITIES, dentdata, 1);
|
||||
|
||||
free (header);
|
||||
|
||||
SwapBSPFile (false);
|
||||
}
|
||||
|
||||
/*
|
||||
WriteBSPFile
|
||||
|
||||
Swaps the bsp file in place, so it should not be referenced again
|
||||
*/
|
||||
void
|
||||
WriteBSPFile (const char *filename)
|
||||
{
|
||||
header = &outheader;
|
||||
memset (header, 0, sizeof (dheader_t));
|
||||
|
||||
SwapBSPFile (true);
|
||||
|
||||
header->version = LittleLong (BSPVERSION);
|
||||
|
||||
wadfile = Qopen (filename, "wb");
|
||||
if (!wadfile)
|
||||
Sys_Error ("Error opening %s", filename);
|
||||
|
||||
Qwrite (wadfile, header, sizeof (dheader_t)); // overwritten later
|
||||
|
||||
AddLump (LUMP_PLANES, dplanes, numplanes * sizeof (dplane_t));
|
||||
AddLump (LUMP_LEAFS, dleafs, numleafs * sizeof (dleaf_t));
|
||||
AddLump (LUMP_VERTEXES, dvertexes, numvertexes * sizeof (dvertex_t));
|
||||
AddLump (LUMP_NODES, dnodes, numnodes * sizeof (dnode_t));
|
||||
AddLump (LUMP_TEXINFO, texinfo, numtexinfo * sizeof (texinfo_t));
|
||||
AddLump (LUMP_FACES, dfaces, numfaces * sizeof (dface_t));
|
||||
AddLump (LUMP_CLIPNODES, dclipnodes, numclipnodes * sizeof (dclipnode_t));
|
||||
AddLump (LUMP_MARKSURFACES, dmarksurfaces, nummarksurfaces
|
||||
* sizeof (dmarksurfaces[0]));
|
||||
AddLump (LUMP_SURFEDGES, dsurfedges, numsurfedges
|
||||
* sizeof (dsurfedges[0]));
|
||||
AddLump (LUMP_EDGES, dedges, numedges * sizeof (dedge_t));
|
||||
AddLump (LUMP_MODELS, dmodels, nummodels * sizeof (dmodel_t));
|
||||
|
||||
AddLump (LUMP_LIGHTING, dlightdata, lightdatasize);
|
||||
AddLump (LUMP_VISIBILITY, dvisdata, visdatasize);
|
||||
AddLump (LUMP_ENTITIES, dentdata, entdatasize);
|
||||
AddLump (LUMP_TEXTURES, dtexdata, texdatasize);
|
||||
|
||||
Qseek (wadfile, 0, SEEK_SET);
|
||||
Qwrite (wadfile, header, sizeof (dheader_t));
|
||||
Qclose (wadfile);
|
||||
}
|
|
@ -42,9 +42,10 @@ static const char rcsid[] =
|
|||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_FNMATCH_H
|
||||
# define model_t sunmodel_t
|
||||
|
@ -82,7 +83,7 @@ static const char rcsid[] =
|
|||
#include "compat.h"
|
||||
|
||||
#ifndef HAVE_FNMATCH_PROTO
|
||||
int fnmatch (const char *__pattern, const char *__string, int __flags);
|
||||
int fnmatch (const char *__pattern, const char *__string, int __flags);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -108,20 +109,17 @@ int fnmatch (const char *__pattern, const char *__string, int __flags);
|
|||
mirrored into the cache directory, then opened there.
|
||||
*/
|
||||
|
||||
/*
|
||||
QUAKE FILESYSTEM
|
||||
*/
|
||||
|
||||
char gamedirfile[MAX_OSPATH];
|
||||
// QUAKE FILESYSTEM
|
||||
|
||||
cvar_t *fs_userpath;
|
||||
cvar_t *fs_sharepath;
|
||||
cvar_t *fs_basegame;
|
||||
cvar_t *fs_skinbase;
|
||||
|
||||
int com_filesize;
|
||||
char gamedirfile[MAX_OSPATH];
|
||||
|
||||
char com_gamedir[MAX_OSPATH];
|
||||
int com_filesize;
|
||||
|
||||
searchpath_t *com_searchpaths;
|
||||
searchpath_t *com_base_searchpaths; // without gamedirs
|
||||
|
@ -130,8 +128,7 @@ searchpath_t *com_base_searchpaths; // without gamedirs
|
|||
void
|
||||
COM_FileBase (const char *in, char *out)
|
||||
{
|
||||
const char *slash, *dot;
|
||||
const char *s;
|
||||
const char *slash, *dot, *s;
|
||||
|
||||
slash = in;
|
||||
dot = NULL;
|
||||
|
@ -158,8 +155,7 @@ COM_FileBase (const char *in, char *out)
|
|||
int
|
||||
COM_filelength (VFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
int end, pos;
|
||||
|
||||
pos = Qtell (f);
|
||||
Qseek (f, 0, SEEK_END);
|
||||
|
@ -169,7 +165,6 @@ COM_filelength (VFile *f)
|
|||
return end;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
COM_FileOpenRead (char *path, VFile **hndl)
|
||||
{
|
||||
|
@ -185,6 +180,65 @@ COM_FileOpenRead (char *path, VFile **hndl)
|
|||
return COM_filelength (f);
|
||||
}
|
||||
|
||||
VFile *
|
||||
COM_SafeOpenRead (const char *filename)
|
||||
{
|
||||
VFile *f;
|
||||
|
||||
f = Qopen (filename, "rb");
|
||||
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s: %s", filename, strerror (errno));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
VFile *
|
||||
COM_SafeOpenWrite (const char *filename)
|
||||
{
|
||||
VFile *f;
|
||||
|
||||
f = Qopen (filename, "wb");
|
||||
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s: %s", filename, strerror (errno));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void
|
||||
COM_SafeRead (VFile *f, void *buffer, int count)
|
||||
{
|
||||
if (Qread (f, buffer, count) != (size_t) count)
|
||||
Sys_Error ("File read failure");
|
||||
}
|
||||
|
||||
void
|
||||
COM_SafeWrite (VFile *f, const void *buffer, int count)
|
||||
{
|
||||
if (Qwrite (f, buffer, count) != (size_t) count)
|
||||
Sys_Error ("File read failure");
|
||||
}
|
||||
|
||||
int
|
||||
LoadFile (const char *filename, void **bufferptr)
|
||||
{
|
||||
int length;
|
||||
void *buffer;
|
||||
VFile *f;
|
||||
|
||||
f = COM_SafeOpenRead (filename);
|
||||
length = COM_filelength (f);
|
||||
buffer = malloc (length + 1);
|
||||
SYS_CHECKMEM (buffer);
|
||||
((char *) buffer)[length] = 0;
|
||||
COM_SafeRead (f, buffer, length);
|
||||
Qclose (f);
|
||||
|
||||
*bufferptr = buffer;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
COM_Path_f (void)
|
||||
|
@ -211,8 +265,8 @@ COM_Path_f (void)
|
|||
void
|
||||
COM_WriteFile (const char *filename, void *data, int len)
|
||||
{
|
||||
VFile *f;
|
||||
char name[MAX_OSPATH];
|
||||
VFile *f;
|
||||
|
||||
snprintf (name, sizeof (name), "%s/%s", com_gamedir, filename);
|
||||
|
||||
|
@ -237,9 +291,9 @@ COM_WriteFile (const char *filename, void *data, int len)
|
|||
void
|
||||
COM_WriteBuffers (const char *filename, int count, ...)
|
||||
{
|
||||
VFile *f;
|
||||
char name[MAX_OSPATH];
|
||||
va_list args;
|
||||
VFile *f;
|
||||
|
||||
va_start (args, count);
|
||||
|
||||
|
@ -296,13 +350,12 @@ COM_CreatePath (const char *path)
|
|||
void
|
||||
COM_CopyFile (char *netpath, char *cachepath)
|
||||
{
|
||||
VFile *in, *out;
|
||||
int remaining, count;
|
||||
char buf[4096];
|
||||
VFile *in, *out;
|
||||
|
||||
remaining = COM_FileOpenRead (netpath, &in);
|
||||
COM_CreatePath (cachepath); // create directories up to the cache
|
||||
// file
|
||||
COM_CreatePath (cachepath); // create directories up to the cache file
|
||||
out = Qopen (cachepath, "wb");
|
||||
if (!out)
|
||||
Sys_Error ("Error opening %s", cachepath);
|
||||
|
@ -324,9 +377,8 @@ COM_CopyFile (char *netpath, char *cachepath)
|
|||
VFile *
|
||||
COM_OpenRead (const char *path, int offs, int len, int zip)
|
||||
{
|
||||
unsigned char id[2], len_bytes[4];
|
||||
int fd = open (path, O_RDONLY);
|
||||
unsigned char id[2];
|
||||
unsigned char len_bytes[4];
|
||||
|
||||
if (fd == -1) {
|
||||
Sys_Error ("Couldn't open %s", path);
|
||||
|
@ -365,8 +417,8 @@ COM_OpenRead (const char *path, int offs, int len, int zip)
|
|||
char *
|
||||
COM_CompressPath (const char *pth)
|
||||
{
|
||||
char *path= malloc (strlen (pth) + 1);
|
||||
char *p, *d;
|
||||
char *path= malloc (strlen (pth) + 1);
|
||||
|
||||
for (d = path; *pth; d++, pth++) {
|
||||
if (*pth == '\\')
|
||||
|
|
Loading…
Reference in a new issue