Renamed qcommon/files.c to qcommon/filesystem.c.

Added qcommon/filesystem.h for filesystem structs/prototypes.
Added update version to console (e.g. KMQuake2 v0.20u8).
This commit is contained in:
Knightmare66 2021-04-11 21:07:08 -04:00
parent 26b6cd5797
commit c18c245fe2
10 changed files with 188 additions and 122 deletions

View file

@ -242,7 +242,7 @@ QUAKE2_OBJS = \
$(BUILDDIR)/client/common.o \
$(BUILDDIR)/client/crc.o \
$(BUILDDIR)/client/cvar.o \
$(BUILDDIR)/client/files.o \
$(BUILDDIR)/client/filesystem.o \
$(BUILDDIR)/client/md4.o \
$(BUILDDIR)/client/net_chan.o \
$(BUILDDIR)/client/wildcard.o \
@ -487,7 +487,7 @@ $(BUILDDIR)/client/crc.o : $(COMMON_DIR)/crc.c
$(BUILDDIR)/client/cvar.o : $(COMMON_DIR)/cvar.c
$(DO_CC)
$(BUILDDIR)/client/files.o : $(COMMON_DIR)/files.c
$(BUILDDIR)/client/filesystem.o : $(COMMON_DIR)/filesystem.c
$(DO_CC)
$(BUILDDIR)/client/md4.o : $(COMMON_DIR)/md4.c
@ -657,7 +657,7 @@ Q2DED_OBJS = \
$(BUILDDIR)/ded/common.o \
$(BUILDDIR)/ded/crc.o \
$(BUILDDIR)/ded/cvar.o \
$(BUILDDIR)/ded/files.o \
$(BUILDDIR)/ded/filesystem.o \
$(BUILDDIR)/ded/md4.o \
$(BUILDDIR)/ded/net_chan.o \
$(BUILDDIR)/ded/wildcard.o \
@ -702,7 +702,7 @@ $(BUILDDIR)/ded/crc.o : $(COMMON_DIR)/crc.c
$(BUILDDIR)/ded/cvar.o : $(COMMON_DIR)/cvar.c
$(DO_DED_CC)
$(BUILDDIR)/ded/files.o : $(COMMON_DIR)/files.c
$(BUILDDIR)/ded/filesystem.o : $(COMMON_DIR)/filesystem.c
$(DO_DED_CC)
$(BUILDDIR)/ded/md4.o : $(COMMON_DIR)/md4.c

View file

@ -954,9 +954,9 @@ void Con_DrawConsole (float frac, qboolean trans)
// changed to "KMQuake2 vx.xx"
#ifdef ERASER_COMPAT_BUILD
Com_sprintf (version, sizeof(version), S_COLOR_BOLD S_COLOR_SHADOW S_COLOR_ALT"KMQuake2 v%4.2f (Eraser compatible)", VERSION);
Com_sprintf (version, sizeof(version), S_COLOR_BOLD S_COLOR_SHADOW S_COLOR_ALT"KMQuake2 v%4.2fu%d (Eraser compatible)", VERSION, VERSION_UPDATE);
#else // ERASER_COMPAT_BUILD
Com_sprintf (version, sizeof(version), S_COLOR_BOLD S_COLOR_SHADOW S_COLOR_ALT"KMQuake2 v%4.2f", VERSION);
Com_sprintf (version, sizeof(version), S_COLOR_BOLD S_COLOR_SHADOW S_COLOR_ALT"KMQuake2 v%4.2fu%d", VERSION, VERSION_UPDATE);
#endif // NEW_ENTITY_STATE_MEMBERS
Con_DrawString ((int)(conLeft+conWidth)-FONT_SIZE*(stringLen((const char *)&version))-3, y-(int)(1.25*FONT_SIZE), version, FONT_CONSOLE, 255);

View file

@ -324,7 +324,7 @@ qboolean Pickup_Powerup (edict_t *ent, edict_t *other)
if ((coop->value) && (ent->item->flags & IT_STAY_COOP) && (quantity > 0))
return false;
//Can only pickup one flashlight
// Can only pickup one flashlight
if (!strcmp(ent->classname, "item_flashlight") && quantity >= 1)
return false;
@ -352,7 +352,7 @@ qboolean Pickup_Powerup (edict_t *ent, edict_t *other)
other->client->pers.inventory[ITEM_INDEX(ent->item)]++;
//Knightmare- set cell usage for flashlight
// Knightmare- set cell usage for flashlight
if (!strcmp(ent->classname, "item_flashlight"))
{
if (ent->count)

View file

@ -1145,7 +1145,7 @@ void TossClientWeapon (edict_t *self)
{
gitem_t *item;
edict_t *drop;
qboolean quad;
qboolean quad, doubled, quadfire;
float spread;
if (!deathmatch->value)
@ -1162,10 +1162,16 @@ void TossClientWeapon (edict_t *self)
if (item && (strcmp (item->pickup_name, "Homing Rocket Launcher") == 0))
item = FindItem("Rocket Launcher");
if (!((int)(dmflags->value) & DF_QUAD_DROP))
if (!((int)(dmflags->value) & DF_QUAD_DROP)) {
quad = false;
else
doubled = false;
quadfire = false;
}
else {
quad = (self->client->quad_framenum > (level.framenum + 10));
doubled = (self->client->double_framenum > (level.framenum + 10));
quadfire = (self->client->quadfire_framenum > (level.framenum + 10));
}
if (item && quad)
spread = 22.5;
@ -1191,6 +1197,30 @@ void TossClientWeapon (edict_t *self)
drop->nextthink = level.time + (self->client->quad_framenum - level.framenum) * FRAMETIME;
drop->think = G_FreeEdict;
}
if (doubled)
{
self->client->v_angle[YAW] += spread;
drop = Drop_Item (self, FindItemByClassname ("item_double"));
self->client->v_angle[YAW] -= spread;
drop->spawnflags |= DROPPED_PLAYER_ITEM;
drop->touch = Touch_Item;
drop->nextthink = level.time + (self->client->double_framenum - level.framenum) * FRAMETIME;
drop->think = G_FreeEdict;
}
if (quadfire)
{
self->client->v_angle[YAW] += spread;
drop = Drop_Item (self, FindItemByClassname ("item_quadfire"));
self->client->v_angle[YAW] -= spread;
drop->spawnflags |= DROPPED_PLAYER_ITEM;
drop->touch = Touch_Item;
drop->nextthink = level.time + (self->client->quadfire_framenum - level.framenum) * FRAMETIME;
drop->think = G_FreeEdict;
}
}

View file

@ -245,7 +245,7 @@ SOURCE=..\..\qcommon\cvar.c
# End Source File
# Begin Source File
SOURCE=..\..\qcommon\files.c
SOURCE=..\..\qcommon\filesystem.c
# End Source File
# Begin Source File
@ -586,6 +586,10 @@ SOURCE=..\..\client\console.h
# End Source File
# Begin Source File
SOURCE=..\..\qcommon\filesystem.h
# End Source File
# Begin Source File
SOURCE=..\..\game\game.h
# End Source File
# Begin Source File

View file

@ -372,7 +372,7 @@
>
</File>
<File
RelativePath="..\..\qcommon\files.c"
RelativePath="..\..\qcommon\filesystem.c"
>
</File>
<File
@ -713,6 +713,10 @@
RelativePath="..\..\client\console.h"
>
</File>
<File
RelativePath="..\..\qcommon\filesystem.h"
>
</File>
<File
RelativePath="..\..\game\game.h"
>

View file

@ -580,7 +580,7 @@
>
</File>
<File
RelativePath="..\..\qcommon\files.c"
RelativePath="..\..\qcommon\filesystem.c"
>
</File>
<File
@ -886,11 +886,11 @@
Filter="h;hpp;hxx;hm;inl;fi;fd"
>
<File
RelativePath="..\..\client\anorms.h"
RelativePath="..\..\renderer\anorms.h"
>
</File>
<File
RelativePath="..\..\renderer\anorms.h"
RelativePath="..\..\client\anorms.h"
>
</File>
<File
@ -921,6 +921,10 @@
RelativePath="..\..\client\console.h"
>
</File>
<File
RelativePath="..\..\qcommon\filesystem.h"
>
</File>
<File
RelativePath="..\..\game\game.h"
>

View file

@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// filesystem.c -- game filesystem and PAK/PK3 file loading
#include "qcommon.h"
#if defined (_MSC_VER) && (_MSC_VER <= 1200) // use older version of zlib for MSVC6
#include "../include/zlibpng_vc6/unzip.h"
#include "../include/zlibpng_vc6/zip.h"
#else
#include "../include/zlibpng/unzip.h"
#include "../include/zlibpng/zip.h"
#endif
#include "filesystem.h"
#ifdef _WIN32
#include "../win32/winquake.h"
@ -36,7 +32,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// enables faster binary pak searck, still experimental
#define BINARY_PACK_SEARCH
#pragma warning (disable : 4715)
/*
@ -67,108 +62,17 @@ executing. This is a precacution against having a malicious server
instruct clients to write files over areas they shouldn't.
*/
#define BASEDIRNAME "baseq2"
#define MAX_HANDLES 32
#define MAX_READ 0x10000
#define MAX_WRITE 0x10000
#define MAX_FIND_FILES 0x04000
#define USE_SAVEGAMEDIR // whether to use new fs_savegamedir/fs_downloaddir paths
//
// in memory
//
//
// Berserk's pk3 file support
//
typedef struct {
char name[MAX_QPATH];
unsigned int hash; // To speed up searching
int size;
int offset; // This is ignored in PK3 files
qboolean ignore; // Whether this file should be ignored
} fsPackFile_t;
typedef struct {
char name[MAX_QPATH];
fsMode_t mode;
FILE *file; // Only one of file or
unzFile *zip; // zip will be used
zipFile *writeZip; // Only used for writing to zip file
fsPackFile_t *pakFile; // Only used for seek/tell in .pak files
} fsHandle_t;
typedef struct fsLink_s {
char *from;
int length;
char *to;
struct fsLink_s *next;
} fsLink_t;
typedef struct {
char name[MAX_OSPATH];
FILE *pak;
unzFile *pk3;
int numFiles;
fsPackFile_t *files;
unsigned int contentFlags;
qboolean isProtectedPak; // from Yamagi Q2
} fsPack_t;
typedef struct fsSearchPath_s {
char path[MAX_OSPATH]; // Only one of path or
fsPack_t *pack; // pack will be used
struct fsSearchPath_s *next;
} fsSearchPath_t;
fsHandle_t fs_handles[MAX_HANDLES];
fsLink_t *fs_links;
fsSearchPath_t *fs_searchPaths;
fsSearchPath_t *fs_baseSearchPaths;
char fs_gamedir[MAX_OSPATH];
char fs_savegamedir[MAX_OSPATH];
char fs_downloaddir[MAX_OSPATH];
static char fs_currentGame[MAX_QPATH];
static char fs_fileInPath[MAX_OSPATH];
static qboolean fs_fileInPack;
int file_from_protected_pak; // This is set by FS_FOpenFile, from Yamagi Q2
int file_from_pak = 0; // This is set by FS_FOpenFile
int file_from_pk3 = 0; // This is set by FS_FOpenFile
char last_pk3_name[MAX_QPATH]; // This is set by FS_FOpenFile
cvar_t *fs_homepath;
cvar_t *fs_basedir;
cvar_t *fs_cddir;
cvar_t *fs_basegamedir;
cvar_t *fs_basegamedir2;
cvar_t *fs_basegamedir3; // So we can mount Rogue, Xatrix, and Zaero assets at once
cvar_t *fs_gamedirvar;
cvar_t *fs_debug;
cvar_t *fs_roguegame;
#ifdef _WIN32
cvar_t *win_use_profile_dir; // whether to use user profile dir for savegames, configs, screenshots, etc
#endif
void CDAudio_Stop (void);
void Com_FileExtension (const char *path, char *dst, int dstSize);
/*
=================
Com_FilePath
FS_FilePath
Returns the path up to, but not including the last /
=================
*/
void Com_FilePath (const char *path, char *dst, int dstSize)
void FS_FilePath (const char *path, char *dst, int dstSize)
{
const char *s, *last;
@ -433,8 +337,6 @@ FS_FileForHandle
Returns a FILE * for a fileHandle_t
=================
*/
fsHandle_t *FS_GetFileByHandle (fileHandle_t f);
FILE *FS_FileForHandle (fileHandle_t f)
{
fsHandle_t *handle;
@ -678,7 +580,7 @@ int FS_FOpenFileRead (fsHandle_t *handle)
if (!Q_stricmp(pack->files[i].name, handle->name))
{
// Found it!
Com_FilePath(pack->name, fs_fileInPath, sizeof(fs_fileInPath));
FS_FilePath (pack->name, fs_fileInPath, sizeof(fs_fileInPath));
fs_fileInPack = true;
// if (fs_debug->value)
@ -1320,7 +1222,7 @@ char **FS_FindFiles (const char *path, const char *extension, int *num)
continue;
// check path
COM_FilePath (pak->files[i].name, dir, sizeof(dir));
FS_FilePath (pak->files[i].name, dir, sizeof(dir));
if ( Q_stricmp((char *)path, dir) )
continue;

121
qcommon/filesystem.h Normal file
View file

@ -0,0 +1,121 @@
/*
===========================================================================
Copyright (C) 1997-2001 Id Software, Inc.
This file is part of Quake 2 source code.
Quake 2 source code 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.
Quake 2 source code 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 Quake 2 source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#if defined (_MSC_VER) && (_MSC_VER <= 1200) // use older version of zlib for MSVC6
#include "../include/zlibpng_vc6/unzip.h"
#include "../include/zlibpng_vc6/zip.h"
#else
#include "../include/zlibpng/unzip.h"
#include "../include/zlibpng/zip.h"
#endif
#define BASEDIRNAME "baseq2"
#define MAX_HANDLES 32
#define MAX_READ 0x10000
#define MAX_WRITE 0x10000
#define MAX_FIND_FILES 0x04000
#define USE_SAVEGAMEDIR // whether to use new fs_savegamedir/fs_downloaddir paths
//
// in memory
//
//
// Berserk's pk3 file support
//
typedef struct {
char name[MAX_QPATH];
unsigned int hash; // To speed up searching
int size;
int offset; // This is ignored in PK3 files
qboolean ignore; // Whether this file should be ignored
} fsPackFile_t;
typedef struct {
char name[MAX_QPATH];
fsMode_t mode;
FILE *file; // Only one of file or
unzFile *zip; // zip will be used
zipFile *writeZip; // Only used for writing to zip file
fsPackFile_t *pakFile; // Only used for seek/tell in .pak files
} fsHandle_t;
typedef struct fsLink_s {
char *from;
int length;
char *to;
struct fsLink_s *next;
} fsLink_t;
typedef struct {
char name[MAX_OSPATH];
FILE *pak;
unzFile *pk3;
int numFiles;
fsPackFile_t *files;
unsigned int contentFlags;
qboolean isProtectedPak; // from Yamagi Q2
} fsPack_t;
typedef struct fsSearchPath_s {
char path[MAX_OSPATH]; // Only one of path or
fsPack_t *pack; // pack will be used
struct fsSearchPath_s *next;
} fsSearchPath_t;
fsHandle_t fs_handles[MAX_HANDLES];
fsLink_t *fs_links;
fsSearchPath_t *fs_searchPaths;
fsSearchPath_t *fs_baseSearchPaths;
char fs_gamedir[MAX_OSPATH];
char fs_savegamedir[MAX_OSPATH];
char fs_downloaddir[MAX_OSPATH];
static char fs_currentGame[MAX_QPATH];
static char fs_fileInPath[MAX_OSPATH];
static qboolean fs_fileInPack;
int file_from_protected_pak; // This is set by FS_FOpenFile, from Yamagi Q2
int file_from_pak = 0; // This is set by FS_FOpenFile
int file_from_pk3 = 0; // This is set by FS_FOpenFile
char last_pk3_name[MAX_QPATH]; // This is set by FS_FOpenFile
cvar_t *fs_homepath;
cvar_t *fs_basedir;
cvar_t *fs_cddir;
cvar_t *fs_basegamedir;
cvar_t *fs_basegamedir2;
cvar_t *fs_basegamedir3; // So we can mount Rogue, Xatrix, and Zaero assets at once
cvar_t *fs_gamedirvar;
cvar_t *fs_debug;
cvar_t *fs_roguegame;
#ifdef _WIN32
cvar_t *win_use_profile_dir; // whether to use user profile dir for savegames, configs, screenshots, etc
#endif
fsHandle_t *FS_GetFileByHandle (fileHandle_t f);

View file

@ -26,7 +26,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../game/q_shared.h"
#define VERSION 0.20 // was 3.21
#define VERSION 0.20 // was 3.21
#define VERSION_UPDATE 8
#define BASEDIRNAME "baseq2"