- gutted cache1d. The old file system is gone, excepr for klistpath, which still gets used in a few places.

- consolidated the 3 identical S_OpenAudio implementations. The replacement code is disabled for the time being because it needs a rewrite. The replacement logic is uses is a bit too volatile.
- removed the old GRP scan code.
This commit is contained in:
Christoph Oelckers 2019-11-01 22:17:15 +01:00
parent 2d7c0e26d2
commit cfca8060ba
47 changed files with 664 additions and 3837 deletions

View file

@ -771,6 +771,7 @@ set (PCH_SOURCES
common/inputstate.cpp
common/searchpaths.cpp
common/initfs.cpp
common/openaudio.cpp
common/2d/v_2ddrawer.cpp
common/2d/v_draw.cpp

View file

@ -1254,8 +1254,6 @@ int app_main()
I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
}
ScanINIFiles();
initprintf("Initializing OSD...\n");
OSD_SetVersion("Blood", 10, 0);
@ -1298,8 +1296,6 @@ int app_main()
ThrowError("TILES###.ART files not found");
}
LoadExtraArts();
levelLoadDefaults();
loaddefinitionsfile(BLOODWIDESCREENDEF);
@ -2119,96 +2115,6 @@ int loaddefinitions_game(const char *fileName, int32_t firstPass)
return 0;
}
INICHAIN *pINIChain;
INICHAIN const*pINISelected;
int nINICount = 0;
const char *pzCrypticArts[] = {
"CPART07.AR_", "CPART15.AR_"
};
INIDESCRIPTION gINIDescription[] = {
{ "BLOOD: One Unit Whole Blood", "BLOOD.INI", NULL, 0 },
{ "Cryptic passage", "CRYPTIC.INI", pzCrypticArts, ARRAY_SSIZE(pzCrypticArts) },
};
bool AddINIFile(const char *pzFile, bool bForce = false)
{
char *pzFN;
struct Bstat st;
static INICHAIN *pINIIter = NULL;
if (!bForce)
{
if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename
if (Bstat(pzFN, &st))
{
Bfree(pzFN);
return false;
} // failed to stat the file
Bfree(pzFN);
IniFile *pTempIni = new IniFile(pzFile);
if (!pTempIni->FindSection("Episode1"))
{
delete pTempIni;
return false;
}
delete pTempIni;
}
if (!pINIChain)
pINIIter = pINIChain = new INICHAIN;
else
pINIIter = pINIIter->pNext = new INICHAIN;
pINIIter->pNext = NULL;
pINIIter->pDescription = NULL;
Bstrncpy(pINIIter->zName, pzFile, BMAX_PATH);
for (int i = 0; i < ARRAY_SSIZE(gINIDescription); i++)
{
if (!Bstrncasecmp(pINIIter->zName, gINIDescription[i].pzFilename, BMAX_PATH))
{
pINIIter->pDescription = &gINIDescription[i];
break;
}
}
return true;
}
void ScanINIFiles(void)
{
nINICount = 0;
BUILDVFS_FIND_REC *pINIList = klistpath("/", "*.ini", BUILDVFS_FIND_FILE);
pINIChain = NULL;
if (bINIOverride || !pINIList)
{
AddINIFile(BloodIniFile, true);
}
for (auto pIter = pINIList; pIter; pIter = pIter->next)
{
AddINIFile(pIter->name);
}
klistfree(pINIList);
pINISelected = pINIChain;
for (auto pIter = pINIChain; pIter; pIter = pIter->pNext)
{
if (!Bstrncasecmp(BloodIniFile, pIter->zName, BMAX_PATH))
{
pINISelected = pIter;
break;
}
}
}
void LoadExtraArts(void)
{
if (!pINISelected->pDescription)
return;
for (int i = 0; i < pINISelected->pDescription->nArts; i++)
{
TileFiles.LoadArtFile(pINISelected->pDescription->pzArts[i]);
}
}
bool DemoRecordStatus(void) {
return gDemo.at0;
}

View file

@ -42,7 +42,7 @@ struct INICHAIN {
};
extern INICHAIN *pINIChain;
extern INICHAIN const*pINISelected;
enum INPUT_MODE {
kInputGame = 0,
@ -77,7 +77,6 @@ void PreloadCache(void);
void StartLevel(GAMEOPTIONS *gameOptions);
void ProcessFrame(void);
void ScanINIFiles(void);
void LoadExtraArts(void);
bool DemoRecordStatus(void);
bool VanillaMode(void);
bool fileExistsRFF(int id, const char* ext);

View file

@ -34,19 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "palette.h"
#include "gamecvars.h"
#ifdef _WIN32
# define NEED_SHLWAPI_H
# include "windows_inc.h"
# include "win32/winbits.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif
# ifndef KEY_WOW64_32KEY
# define KEY_WOW64_32KEY 0x0200
# endif
#elif defined __APPLE__
# include "osxbits.h"
#endif
#include "common.h"
#include "common_game.h"
@ -73,114 +60,5 @@ void G_SetupGlobalPsky(void)
}
//////////
#ifdef FORMAT_UPGRADE_ELIGIBLE
static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char const searchfirst)
{
#ifdef HAVE_FLAC
{
Bstrcpy(fn_suffix, ".flac");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
#ifdef HAVE_VORBIS
{
Bstrcpy(fn_suffix, ".ogg");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
return FileReader();
}
static FileReader S_TryExtensionReplacements(char * const testfn, char const searchfirst, uint8_t const ismusic)
{
char * extension = Bstrrchr(testfn, '.');
char * const fn_end = Bstrchr(testfn, '\0');
// ex: grabbag.voc --> grabbag_voc.*
if (extension != NULL)
{
*extension = '_';
auto fp = S_TryFormats(testfn, fn_end, searchfirst);
if (fp.isOpen())
return fp;
}
else
{
extension = fn_end;
}
// ex: grabbag.mid --> grabbag.*
if (ismusic)
{
auto fp = S_TryFormats(testfn, extension, searchfirst);
if (fp.isOpen())
return fp;
}
return FileReader();
}
FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
{
auto origfp = kopenFileReader(fn, searchfirst);
char const* const origparent = origfp.isOpen() ? kfileparent(origfp) : NULL;
uint32_t const parentlength = origparent != NULL ? Bstrlen(origparent) : 0;
auto testfn = (char *)Xmalloc(Bstrlen(fn) + 12 + parentlength); // "music/" + overestimation of parent minus extension + ".flac" + '\0'
// look in ./
// ex: ./grabbag.mid
Bstrcpy(testfn, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
// look in ./music/<file's parent GRP name>/
// ex: ./music/duke3d/grabbag.mid
// ex: ./music/nwinter/grabbag.mid
if (origparent != NULL)
{
char const * const parentextension = Bstrrchr(origparent, '.');
uint32_t const namelength = parentextension != NULL ? (unsigned)(parentextension - origparent) : parentlength;
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
// look in ./music/
// ex: ./music/grabbag.mid
{
Bsprintf(testfn, "music/%s", fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
Bfree(testfn);
return origfp;
}
#endif
END_BLD_NS

View file

@ -528,9 +528,6 @@ static inline int gameHandleEvents(void)
return handleevents();
}
# define FORMAT_UPGRADE_ELIGIBLE
extern FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic);
#pragma pack(push,1)
#if 0

View file

@ -226,7 +226,7 @@ void levelLoadDefaults(void)
{
char buffer[64];
char buffer2[16];
levelInitINI(pINISelected->zName);
levelInitINI(G_ConFile()); // This doubles for the INI in the global code.
memset(gEpisodeInfo, 0, sizeof(gEpisodeInfo));
strncpy(gEpisodeInfo[MUS_INTRO/kMaxLevels].at28[MUS_INTRO%kMaxLevels].atd0, "PESTIS", BMAX_PATH);
int i;
@ -275,7 +275,6 @@ void levelLoadDefaults(void)
void levelAddUserMap(const char *pzMap)
{
char buffer[BMAX_PATH];
//strcpy(buffer, g_modDir);
strncpy(buffer, pzMap, BMAX_PATH);
ChangeExtension(buffer, ".DEF");

View file

@ -524,7 +524,6 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
// OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
//
// OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
//#ifdef DEBUGGINGAIDS
// OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer);
//#endif

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "sound.h"
#include "renderlayer.h"
#include "al_midi.h"
#include "openaudio.h"
BEGIN_BLD_NS

View file

@ -15,55 +15,15 @@
#include "vfs.h"
extern char *kpzbuf;
extern int32_t kpzbufsiz;
extern int32_t kpzbufload(const char *);
void cacheInitBuffer(int32_t dacachesize);
void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *newlockptr);
void cacheAgeEntries(void);
using buildvfs_kfd = int32_t;
#define buildvfs_kfd_invalid (-1)
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
char *listsearchpath(int32_t initp);
int32_t addsearchpath_user(const char *p, int32_t user);
#define addsearchpath(a) addsearchpath_user(a, 0)
int32_t removesearchpath(const char *p);
void removesearchpaths_withuser(int32_t usermask);
int32_t findfrompath(const char *fn, char **where);
buildvfs_kfd openfrompath(const char *fn, int32_t flags, int32_t mode);
buildvfs_FILE fopenfrompath(const char *fn, const char *mode);
extern char g_modDir[BMAX_PATH];
extern int32_t numgroupfiles;
int initgroupfile(const char *filename);
void uninitgroupfile(void);
buildvfs_kfd kopen4load(const char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group
buildvfs_kfd kopen4loadfrommod(const char *filename, char searchfirst);
int32_t kread(buildvfs_kfd handle, void *buffer, int32_t leng);
#define kread_and_test(handle, buffer, leng) EDUKE32_PREDICT_FALSE(kread((handle), (buffer), (leng)) != (leng))
int32_t klseek(buildvfs_kfd handle, int32_t offset, int32_t whence);
#define klseek_and_test(handle, offset, whence) EDUKE32_PREDICT_FALSE(klseek((handle), (offset), (whence)) < 0)
int32_t kfilelength(buildvfs_kfd handle);
int32_t ktell(buildvfs_kfd handle);
void kclose(buildvfs_kfd handle);
void krename(int32_t crcval, int32_t filenum, const char *newname);
char const * kfileparent(int32_t handle);
extern int32_t kpzbufloadfil(buildvfs_kfd);
#ifdef WITHKPLIB
int32_t cache1d_file_fromzip(buildvfs_kfd fil);
#endif
typedef struct
{
intptr_t *hand;
int32_t leng;
uint8_t * lock;
} cactype;
enum {
CACHE1D_FIND_FILE = 1,
@ -95,101 +55,64 @@ int32_t klistaddentry(CACHE1D_FIND_REC **rec, const char *name, int32_t type, in
void klistfree(CACHE1D_FIND_REC *rec);
CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type);
extern int32_t lz4CompressionLevel;
int32_t kdfread_LZ4(void *buffer, int dasizeof, int count, buildvfs_kfd fil);
int32_t kdfread_LZ4(void* buffer, int dasizeof, int count, FileReader& fil);
void dfwrite_LZ4(const void *buffer, int dasizeof, int count, buildvfs_FILE fil);
// compression disabled pending a better process for saving. Per-block compression as done here was not that great.
int32_t kdfread_LZ4(void* buffer, int dasizeof, int count, buildvfs_kfd fil) = delete;
class KFileReaderInterface : public FileReaderInterface
inline int32_t kdfread_LZ4(void* buffer, int dasizeof, int count, FileReader& fil)
{
buildvfs_kfd khandle = buildvfs_kfd_invalid;
public:
return fil.Read(buffer, dasizeof * count);
}
KFileReaderInterface(int handle)
{
khandle = handle;
Length = 0;
if (khandle != buildvfs_kfd_invalid)
{
klseek(khandle, 0, SEEK_END);
Length = ktell(khandle);
klseek(khandle, 0, SEEK_SET);
}
}
~KFileReaderInterface()
{
if (khandle != buildvfs_kfd_invalid)
{
kclose(khandle);
}
}
virtual long Tell() const
{
return ktell(khandle);
}
virtual long Seek(long offset, int origin)
{
return klseek(khandle, offset, origin);
}
virtual long Read(void* buffer, long len)
{
return kread(khandle, buffer, (int32_t)len);
}
virtual char* Gets(char* strbuf, int len)
{
// Not supported by the underlying system, so we do not need it anyway.
// Gross hack alert: Abuse this function to return the container's name until we have a better resource management in place.
// Right now there is no way to cleanly pass this through and this function is the most convenient workaround.
return (char*)kfileparent(khandle);
}
inline void dfwrite_LZ4(const void* buffer, int dasizeof, int count, buildvfs_FILE fil)
{
fwrite(buffer, dasizeof, count, fil);
}
};
FileReader openFromBaseResource(const char* name);
#include "filesystem/filesystem.h"
// Wrappers for the handle based API to get rid of the direct calls without any actual changes to the implementation.
// These are now getting redirected to the file system so that the implementation here can be gutted without making changes to the calling code.
inline FileReader kopenFileReader(const char* name, int where)
{
int handle = where == 0 ? kopen4loadfrommod(name, 0) : kopen4load(name, where);
if (handle != buildvfs_kfd_invalid) return FileReader(new KFileReaderInterface(handle));
return openFromBaseResource(name);
auto lump = fileSystem.FindFile(name);
if (lump < 0) return FileReader();
else return fileSystem.OpenFileReader(lump);
}
// This is only here to mark a file as not being part of the game assets (e.g. savegames)
// These should be handled differently (e.g read from a userdata directory or similar things.)
inline FileReader fopenFileReader(const char* name, int where)
{
return kopenFileReader(name, 0);
FileReader fr;
fr.OpenFile(name);
return fr;
}
inline bool testkopen(const char* name, int where)
{
int handle = where == 0 ? kopen4loadfrommod(name, 0) : kopen4load(name, where);
if (handle != buildvfs_kfd_invalid) kclose(handle);
return handle != buildvfs_kfd_invalid;
// todo: if backed by a single file, we must actually open it to make sure.
return fileSystem.FindFile(name) >= 0;
}
inline TArray<uint8_t> kloadfile(const char* name, int where)
{
auto fr = kopenFileReader(name, where);
return fr.isOpen() ? fr.Read() : TArray <uint8_t>();
auto lump = fileSystem.FindFile(name);
if (lump < 0) return TArray<uint8_t>();
return fileSystem.GetFileData(lump);
}
inline int32_t kfilesize(const char* name, int where)
{
int handle = where == 0 ? kopen4loadfrommod(name, 0) : kopen4load(name, where);
if (handle != buildvfs_kfd_invalid)
{
auto fs = kfilelength(handle);
kclose(handle);
return fs;
}
return -1;
auto lump = fileSystem.FindFile(name);
if (lump < 0) return -1;
return fileSystem.FileLength(lump);
}
inline char const* kfileparent(FileReader &fr)
// checks from path and in ZIPs, returns 1 if NOT found
inline int32_t check_file_exist(const char* fn)
{
// This is by no means a good implementation. Its only advantage is that it can be done without hacking in something more invasive.
return fr.Gets(nullptr, 0);
return fileSystem.FindFile(fn) >= 0;
}
#endif // cache1d_h_

View file

@ -77,8 +77,6 @@ int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens);
int32_t G_CheckCmdSwitch(int32_t argc, char const * const * argv, const char *str);
int32_t check_file_exist(const char *fn); // findfrompath with pathsearchmode=1 / search in zips
void fnlist_clearnames(fnlist_t *fnl);
int32_t fnlist_getnames(fnlist_t *fnl, const char *dirname, const char *pattern,
int32_t dirflags, int32_t fileflags);

File diff suppressed because it is too large Load diff

View file

@ -71,36 +71,6 @@ int32_t G_CheckCmdSwitch(int32_t argc, char const * const * argv, const char *st
return 0;
}
// checks from path and in ZIPs, returns 1 if NOT found
int32_t check_file_exist(const char *fn)
{
#ifdef USE_PHYSFS
return !PHYSFS_exists(fn);
#else
int32_t opsm = pathsearchmode;
char *tfn;
pathsearchmode = 1;
if (findfrompath(fn,&tfn) < 0)
{
char buf[BMAX_PATH];
Bstrcpy(buf,fn);
kzfindfilestart(buf);
if (!kzfindfile(buf))
{
initprintf("Error: file \"%s\" does not exist\n",fn);
pathsearchmode = opsm;
return 1;
}
}
else Xfree(tfn);
pathsearchmode = opsm;
return 0;
#endif
}
//// FILE NAME / DIRECTORY LISTS ////
void fnlist_clearnames(fnlist_t *fnl)

View file

@ -1808,10 +1808,6 @@ static int32_t defsparser(scriptfile *script)
int32_t basepal=-1, pal=-1;
char *fn = NULL;
char *highpalend;
#ifdef POLYMER
buildvfs_kfd fd;
char *highpaldata;
#endif
static const tokenlist highpaltokens[] =
{
{ "basepal", T_BASEPAL },

View file

@ -7619,11 +7619,11 @@ static int32_t engineLoadTables(void)
}
#endif
// TABLES.DAT format:
//kread(fil,sintable,2048*2);
//kread(fil,radarang,640*2);
//kread(fil,textfont,1024);
//kread(fil,smalltextfont,1024);
//kread(fil,britable,1024);
//fr.Read(sintable,2048*2);
//fr.Read(radarang,640*2);
//fr.Read(textfont,1024);
//fr.Read(smalltextfont,1024);
//fr.Read(britable,1024);
calcbritable();
@ -8262,7 +8262,6 @@ void engineUnInit(void)
basepaltable[0] = palette;
DO_FREE_AND_NULL(kpzbuf);
kpzbufsiz = 0;
uninitsystem();
@ -9476,7 +9475,7 @@ static FORCE_INLINE int32_t have_maptext(void)
return (mapversion >= 10);
}
static void enginePrepareLoadBoard(buildvfs_kfd fil, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum)
static void enginePrepareLoadBoard(FileReader & fr, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum)
{
initspritelists();
@ -9496,11 +9495,11 @@ static void enginePrepareLoadBoard(buildvfs_kfd fil, vec3_t *dapos, int16_t *daa
if (!have_maptext())
{
kread(fil,&dapos->x,4); dapos->x = B_LITTLE32(dapos->x);
kread(fil,&dapos->y,4); dapos->y = B_LITTLE32(dapos->y);
kread(fil,&dapos->z,4); dapos->z = B_LITTLE32(dapos->z);
kread(fil,daang,2); *daang = B_LITTLE16(*daang) & 2047;
kread(fil,dacursectnum,2); *dacursectnum = B_LITTLE16(*dacursectnum);
fr.Read(&dapos->x,4); dapos->x = B_LITTLE32(dapos->x);
fr.Read(&dapos->y,4); dapos->y = B_LITTLE32(dapos->y);
fr.Read(&dapos->z,4); dapos->z = B_LITTLE32(dapos->z);
fr.Read(daang,2); *daang = B_LITTLE16(*daang) & 2047;
fr.Read(dacursectnum,2); *dacursectnum = B_LITTLE16(*dacursectnum);
}
}
@ -9636,10 +9635,6 @@ static void check_sprite(int32_t i)
}
}
#ifdef NEW_MAP_FORMAT
// Returns the number of sprites, or <0 on error.
LUNATIC_CB int32_t (*loadboard_maptext)(buildvfs_kfd fil, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
#endif
#include "md4.h"
@ -9663,13 +9658,12 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t
flags &= 3;
buildvfs_kfd fil;
if ((fil = kopen4load(filename,flags)) == buildvfs_kfd_invalid)
FileReader fr = kopenFileReader(filename, 0);
if (!fr.isOpen())
{ mapversion = 7; return -1; }
if (kread(fil, &mapversion, 4) != 4)
if (fr.Read(&mapversion, 4) != 4)
{
kclose(fil);
return -2;
}
@ -9700,53 +9694,29 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t
if (!ok)
{
kclose(fil);
return -2;
}
}
enginePrepareLoadBoard(fil, dapos, daang, dacursectnum);
enginePrepareLoadBoard(fr, dapos, daang, dacursectnum);
#ifdef NEW_MAP_FORMAT
if (have_maptext())
{
int32_t ret = klseek(fil, 0, SEEK_SET);
if (ret == 0)
ret = loadboard_maptext(fil, dapos, daang, dacursectnum);
if (ret < 0)
{
kclose(fil);
return ret;
}
numsprites = ret;
goto skip_reading_mapbin;
}
#endif
////////// Read sectors //////////
kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors);
fr.Read(&numsectors,2); numsectors = B_LITTLE16(numsectors);
if ((unsigned)numsectors >= MYMAXSECTORS() + 1)
{
error:
numsectors = 0;
numwalls = 0;
numsprites = 0;
kclose(fil);
return -3;
}
kread(fil, sector, sizeof(sectortypev7)*numsectors);
fr.Read(sector, sizeof(sectortypev7)*numsectors);
for (i=numsectors-1; i>=0; i--)
{
#ifdef NEW_MAP_FORMAT
Bmemmove(&sector[i], &(((sectortypev7 *)sector)[i]), sizeof(sectortypevx));
inplace_vx_from_v7_sector(&sector[i]);
#endif
sector[i].wallptr = B_LITTLE16(sector[i].wallptr);
sector[i].wallnum = B_LITTLE16(sector[i].wallnum);
sector[i].ceilingz = B_LITTLE32(sector[i].ceilingz);
@ -9760,25 +9730,18 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t
sector[i].lotag = B_LITTLE16(sector[i].lotag);
sector[i].hitag = B_LITTLE16(sector[i].hitag);
sector[i].extra = B_LITTLE16(sector[i].extra);
#ifdef NEW_MAP_FORMAT
inplace_vx_tweak_sector(&sector[i], mapversion==9);
#endif
}
////////// Read walls //////////
kread(fil,&numwalls,2); numwalls = B_LITTLE16(numwalls);
fr.Read(&numwalls,2); numwalls = B_LITTLE16(numwalls);
if ((unsigned)numwalls >= MYMAXWALLS()+1) goto error;
kread(fil, wall, sizeof(walltypev7)*numwalls);
fr.Read( wall, sizeof(walltypev7)*numwalls);
for (i=numwalls-1; i>=0; i--)
{
#ifdef NEW_MAP_FORMAT
Bmemmove(&wall[i], &(((walltypev7 *)wall)[i]), sizeof(walltypevx));
inplace_vx_from_v7_wall(&wall[i]);
#endif
wall[i].x = B_LITTLE32(wall[i].x);
wall[i].y = B_LITTLE32(wall[i].y);
wall[i].point2 = B_LITTLE16(wall[i].point2);
@ -9790,31 +9753,23 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t
wall[i].lotag = B_LITTLE16(wall[i].lotag);
wall[i].hitag = B_LITTLE16(wall[i].hitag);
wall[i].extra = B_LITTLE16(wall[i].extra);
#ifdef NEW_MAP_FORMAT
inplace_vx_tweak_wall(&wall[i], mapversion==9);
#endif
}
////////// Read sprites //////////
kread(fil,&numsprites,2); numsprites = B_LITTLE16(numsprites);
fr.Read(&numsprites,2); numsprites = B_LITTLE16(numsprites);
if ((unsigned)numsprites >= MYMAXSPRITES()+1) goto error;
kread(fil, sprite, sizeof(spritetype)*numsprites);
fr.Read( sprite, sizeof(spritetype)*numsprites);
#ifdef NEW_MAP_FORMAT
skip_reading_mapbin:
#endif
klseek(fil, 0, SEEK_SET);
int32_t boardsize = kfilelength(fil);
fr.Seek(0, FileReader::SeekSet);
int32_t boardsize = fr.GetLength();
uint8_t *fullboard = (uint8_t*)Xmalloc(boardsize);
kread(fil, fullboard, boardsize);
fr.Read( fullboard, boardsize);
md4once(fullboard, boardsize, g_loadedMapHack.md4);
Xfree(fullboard);
kclose(fil);
// Done reading file.
if (!have_maptext())
@ -9856,13 +9811,14 @@ skip_reading_mapbin:
if ((myflags&8)==0)
{
#if 0 // No, no! This is absolutely unacceptable. I won't support mods that require this kind of access.
char fn[BMAX_PATH];
Bstrcpy(fn, filename);
append_ext_UNSAFE(fn, ".cfg");
OSD_Exec(fn);
#endif
system_getcvars();
// Per-map ART
@ -9894,23 +9850,23 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
struct walltypev6 v6wall;
struct spritetypev6 v6spr;
buildvfs_kfd fil;
if ((fil = kopen4load(filename,fromwhere)) == buildvfs_kfd_invalid)
FileReader fr = kopenFileReader(filename, fromwhere);
if (!fr.isOpen())
{ mapversion = 5L; return -1; }
kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion);
if (mapversion != 5L && mapversion != 6L) { kclose(fil); return -2; }
fr.Read(&mapversion,4); mapversion = B_LITTLE32(mapversion);
if (mapversion != 5L && mapversion != 6L) { return -2; }
enginePrepareLoadBoard(fil, dapos, daang, dacursectnum);
enginePrepareLoadBoard(fr, dapos, daang, dacursectnum);
kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors);
if (numsectors > MAXSECTORS) { kclose(fil); return -1; }
fr.Read(&numsectors,2); numsectors = B_LITTLE16(numsectors);
if (numsectors > MAXSECTORS) { return -1; }
for (i=0; i<numsectors; i++)
{
switch (mapversion)
{
case 5:
kread(fil,&v5sect,sizeof(struct sectortypev5));
fr.Read(&v5sect,sizeof(struct sectortypev5));
v5sect.wallptr = B_LITTLE16(v5sect.wallptr);
v5sect.wallnum = B_LITTLE16(v5sect.wallnum);
v5sect.ceilingpicnum = B_LITTLE16(v5sect.ceilingpicnum);
@ -9924,7 +9880,7 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
v5sect.extra = B_LITTLE16(v5sect.extra);
break;
case 6:
kread(fil,&v6sect,sizeof(struct sectortypev6));
fr.Read(&v6sect,sizeof(struct sectortypev6));
v6sect.wallptr = B_LITTLE16(v6sect.wallptr);
v6sect.wallnum = B_LITTLE16(v6sect.wallnum);
v6sect.ceilingpicnum = B_LITTLE16(v6sect.ceilingpicnum);
@ -9950,14 +9906,14 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
}
}
kread(fil,&numwalls,2); numwalls = B_LITTLE16(numwalls);
if (numwalls > MAXWALLS) { kclose(fil); return -1; }
fr.Read(&numwalls,2); numwalls = B_LITTLE16(numwalls);
if (numwalls > MAXWALLS) { return -1; }
for (i=0; i<numwalls; i++)
{
switch (mapversion)
{
case 5:
kread(fil,&v5wall,sizeof(struct walltypev5));
fr.Read(&v5wall,sizeof(struct walltypev5));
v5wall.x = B_LITTLE32(v5wall.x);
v5wall.y = B_LITTLE32(v5wall.y);
v5wall.point2 = B_LITTLE16(v5wall.point2);
@ -9973,7 +9929,7 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
v5wall.extra = B_LITTLE16(v5wall.extra);
break;
case 6:
kread(fil,&v6wall,sizeof(struct walltypev6));
fr.Read(&v6wall,sizeof(struct walltypev6));
v6wall.x = B_LITTLE32(v6wall.x);
v6wall.y = B_LITTLE32(v6wall.y);
v6wall.point2 = B_LITTLE16(v6wall.point2);
@ -9999,14 +9955,14 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
}
}
kread(fil,&numsprites,2); numsprites = B_LITTLE16(numsprites);
if (numsprites > MAXSPRITES) { kclose(fil); return -1; }
fr.Read(&numsprites,2); numsprites = B_LITTLE16(numsprites);
if (numsprites > MAXSPRITES) { return -1; }
for (i=0; i<numsprites; i++)
{
switch (mapversion)
{
case 5:
kread(fil,&v5spr,sizeof(struct spritetypev5));
fr.Read(&v5spr,sizeof(struct spritetypev5));
v5spr.x = B_LITTLE32(v5spr.x);
v5spr.y = B_LITTLE32(v5spr.y);
v5spr.z = B_LITTLE32(v5spr.z);
@ -10023,7 +9979,7 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
v5spr.extra = B_LITTLE16(v5spr.extra);
break;
case 6:
kread(fil,&v6spr,sizeof(struct spritetypev6));
fr.Read(&v6spr,sizeof(struct spritetypev6));
v6spr.x = B_LITTLE32(v6spr.x);
v6spr.y = B_LITTLE32(v6spr.y);
v6spr.z = B_LITTLE32(v6spr.z);
@ -10055,7 +10011,6 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos,
check_sprite(i);
}
kclose(fil);
// Done reading file.
return engineFinishLoadBoard(dapos, dacursectnum, numsprites, 0);

View file

@ -250,7 +250,7 @@ void paletteLoadFromDisk(void)
int32_t lamedukep = 0;
if (numshades >= 256)
{
static char const * const seekfail = "Warning: klseek() failed in loadpalette()!\n";
static char const * const seekfail = "Warning: seek failed in loadpalette()!\n";
uint16_t temp;
if (read_and_test(fil, &temp, 2))

View file

@ -485,41 +485,8 @@ int main(int argc, char *argv[])
return r;
}
static std::unique_ptr<FResourceFile> demolition_pk3;
// The resourge manager in cache1d is far too broken to add some arbitrary file without some adjustment.
// For now, keep this file here, until the resource management can be redone in a more workable fashion.
extern FString progdir;
extern FString LumpFilter;
void InitBaseRes()
{
if (!demolition_pk3)
{
// If we get here for the first time, load the engine-internal data.
FString baseres = progdir + "demolition.pk3";
demolition_pk3.reset(FResourceFile::OpenResourceFile(baseres, true, true));
if (!demolition_pk3)
{
I_Error("Engine resources (%s) not found", baseres.GetChars());
}
}
}
FileReader openFromBaseResource(const char* fn)
{
InitBaseRes();
auto lump = demolition_pk3->FindLump(fn);
if (lump) return lump->NewReader();
// Also look in game filtered directories.
FStringf filtername("filter/%s/%s", LumpFilter.GetChars(), fn);
lump = demolition_pk3->FindLump(filtername);
if (lump) return lump->NewReader();
return FileReader(nullptr);
}
#if SDL_MAJOR_VERSION != 1
int32_t videoSetVsync(int32_t newSync)

View file

@ -511,7 +511,6 @@ CUSTOM_CVAR(String, rtsname, "", CVAR_ARCHIVE | CVAR_USERINFO)
/* Baselayer CVARs. Some are pointless, some not worth bothering before the backend is swappewd out, the only relevant one was r_voxels.
static osdcvardata_t cvars_engine[] =
{
{ "lz4compressionlevel","adjust LZ4 compression level used for savegames",(void *) &lz4CompressionLevel, CVAR_INT, 1, 32 },
{ "r_usenewaspect","enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 },
{ "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",
(void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 },

373
source/common/initfs.cpp Normal file
View file

@ -0,0 +1,373 @@
/*
** initfs.cpp
**
**---------------------------------------------------------------------------
** Copyright 1999-2016 Randy Heit
** Copyright 2002-2019 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
**
*/
#include "filesystem/filesystem.h"
#include "filesystem/resourcefile.h"
#include "cmdlib.h"
#include "zstring.h"
#include "gamecontrol.h"
#include "gameconfigfile.h"
#include "printf.h"
#include "m_argv.h"
#include "../platform/win32/i_findfile.h" // This is a temporary direct path. Needs to be fixed when stuff gets cleaned up.
#ifndef PATH_MAX
#define PATH_MAX 260
#endif
//==========================================================================
//
// BaseFileSearch
//
// If a file does not exist at <file>, looks for it in the directories
// specified in the config file. Returns the path to the file, if found,
// or nullptr if it could not be found.
//
//==========================================================================
FString BaseFileSearch (const char *file, const char *ext, bool lookfirstinprogdir)
{
FString wad;
if (file == nullptr || *file == '\0')
{
return nullptr;
}
if (lookfirstinprogdir)
{
wad.Format("%s%s%s", progdir.GetChars(), progdir.Back() == '/' ? "" : "/", file);
if (DirEntryExists (wad))
{
return wad;
}
}
if (DirEntryExists (file))
{
wad.Format("%s", file);
return wad;
}
if (GameConfig != nullptr && GameConfig->SetSection ("FileSearch.Directories"))
{
const char *key;
const char *value;
while (GameConfig->NextInSection (key, value))
{
if (stricmp (key, "Path") == 0)
{
FString dir;
dir = NicePath(value);
if (dir.IsNotEmpty())
{
wad.Format("%s%s%s", dir.GetChars(), dir.Back() == '/' ? "" : "/", file);
if (DirEntryExists (wad))
{
return wad;
}
}
}
}
}
// Retry, this time with a default extension
if (ext != nullptr)
{
FString tmp = file;
DefaultExtension (tmp, ext);
return BaseFileSearch (tmp, nullptr, lookfirstinprogdir);
}
return nullptr;
}
//==========================================================================
//
// D_AddFile
//
//==========================================================================
bool D_AddFile (TArray<FString> &wadfiles, const char *file, bool check = true, int position = -1)
{
if (file == NULL || *file == '\0')
{
return false;
}
if (check && !DirEntryExists (file))
{
const char *f = BaseFileSearch (file, ".wad", false);
if (f == NULL)
{
Printf ("Can't find '%s'\n", file);
return false;
}
file = f;
}
FString f = file;
f.Substitute("\\", "/");
if (position == -1) wadfiles.Push(f);
else wadfiles.Insert(position, f);
return true;
}
//==========================================================================
//
// D_AddWildFile
//
//==========================================================================
void D_AddWildFile (TArray<FString> &wadfiles, const char *value)
{
if (value == NULL || *value == '\0')
{
return;
}
const char *wadfile = BaseFileSearch (value, ".wad", false);
if (wadfile != NULL)
{
D_AddFile (wadfiles, wadfile);
}
else
{ // Try pattern matching
findstate_t findstate;
char path[260];
char *sep;
void *handle = I_FindFirst (value, &findstate);
strcpy (path, value);
sep = strrchr (path, '/');
if (sep == NULL)
{
sep = strrchr (path, '\\');
#ifdef _WIN32
if (sep == NULL && path[1] == ':')
{
sep = path + 1;
}
#endif
}
if (handle != ((void *)-1))
{
do
{
if (!(I_FindAttr(&findstate) & FA_DIREC))
{
if (sep == NULL)
{
D_AddFile (wadfiles, I_FindName (&findstate));
}
else
{
strcpy (sep+1, I_FindName (&findstate));
D_AddFile (wadfiles, path, false );
}
}
} while (I_FindNext (handle, &findstate) == 0);
}
I_FindClose (handle);
}
}
//==========================================================================
//
// D_AddConfigWads
//
// Adds all files in the specified config file section.
//
//==========================================================================
void D_AddConfigWads (TArray<FString> &wadfiles, const char *section)
{
if (GameConfig->SetSection (section))
{
const char *key;
const char *value;
FConfigFile::Position pos;
while (GameConfig->NextInSection (key, value))
{
if (stricmp (key, "Path") == 0)
{
// D_AddWildFile resets GameConfig's position, so remember it
GameConfig->GetPosition (pos);
D_AddWildFile (wadfiles, ExpandEnvVars(value));
// Reset GameConfig's position to get next wad
GameConfig->SetPosition (pos);
}
}
}
}
//==========================================================================
//
// D_AddDirectory
//
// Add all .wad files in a directory. Does not descend into subdirectories.
//
//==========================================================================
static void D_AddDirectory (TArray<FString> &wadfiles, const char *dir)
{
char curdir[PATH_MAX];
if (getcwd (curdir, PATH_MAX))
{
char skindir[PATH_MAX];
findstate_t findstate;
void *handle;
size_t stuffstart;
stuffstart = strlen (dir);
memcpy (skindir, dir, stuffstart*sizeof(*dir));
skindir[stuffstart] = 0;
if (skindir[stuffstart-1] == '/')
{
skindir[--stuffstart] = 0;
}
if (!chdir (skindir))
{
skindir[stuffstart++] = '/';
int savedstart = stuffstart;
const char* validexts[] = { "*.grp", "*.zip", "*.pk3", "*.pk4", "*.7z", "*.pk7" };
for (auto ext : validexts)
{
stuffstart = savedstart;
if ((handle = I_FindFirst(ext, &findstate)) != (void*)-1)
{
do
{
if (!(I_FindAttr(&findstate) & FA_DIREC))
{
strcpy(skindir + stuffstart, I_FindName(&findstate));
D_AddFile(wadfiles, skindir);
}
} while (I_FindNext(handle, &findstate) == 0);
I_FindClose(handle);
}
}
}
chdir (curdir);
}
}
void InitFileSystem(TArray<GrpEntry>& groups)
{
TArray<int> dependencies;
TArray<FString> Files;
// First comes the engine's own stuff.
FString baseres = progdir + "demolition.pk3";
D_AddFile(Files, baseres);
bool insertdirectoriesafter = Args->CheckParm("-insertdirafter");
int i = groups.Size()-1;
for (auto &grp : groups)
{
// Add all dependencies, plus the directory of the base dependency.
// Directories of addon content are not added if they differ from the main directory.
// Also, the directory is inserted after the base dependency, allowing the addons to override directory content.
// This can be overridden via command line switch if needed.
if (!grp.FileInfo.loaddirectory)
D_AddFile(Files, grp.FileName);
auto fn = grp.FileName;
fn.Substitute("\\", "/");
auto index = fn.LastIndexOf("/");
fn.Truncate(index+1); // right after the last slash.
for (auto& fname : grp.FileInfo.loadfiles)
{
FString newname = fn + fname;
D_AddFile(Files, newname);
}
// Add the game's main directory in the proper spot.
if ((i == (insertdirectoriesafter ? 0 : dependencies.Size() - 1)) || grp.FileInfo.loaddirectory)
{
// Build's original 'file system' loads all GRPs before the first external directory.
// Do this only if explicitly requested because this severely limits the usability of GRP files.
if (insertdirectoriesafter && i == 0) for (auto& file : *userConfig.AddFilesPre)
{
D_AddFile(Files, file);
}
D_AddFile(Files, fn);
}
i--;
}
if (!insertdirectoriesafter) for (auto& file : *userConfig.AddFilesPre)
{
D_AddFile(Files, file);
}
for (auto& file : *userConfig.AddFiles)
{
D_AddFile(Files, file);
}
// Finally, if the last entry in the chain is a directory, it's being considered the mod directory, and all GRPs inside need to be loaded, too.
if (userConfig.AddFiles->NumArgs() > 0)
{
auto fn = (*userConfig.AddFiles)[userConfig.AddFiles->NumArgs() - 1];
bool isdir = false;
if (DirEntryExists(fn, &isdir) && isdir)
{
// Insert the GRPs before this entry itself.
FString lastfn;
Files.Pop(lastfn);
D_AddDirectory(Files, fn);
Files.Push(lastfn);
}
}
TArray<FString> todelete;
fileSystem.InitMultipleFiles(Files, todelete);
FILE* f = fopen("filesystem.dir", "wb");
for (int i = 0; i < fileSystem.GetNumEntries(); i++)
{
auto fd = fileSystem.GetFileAt(i);
fprintf(f, "%.50s %60s %d\n", fd->FullName(), fileSystem.GetResourceFileFullName(fileSystem.GetFileContainer(i)), fd->Size());
}
fclose(f);
}

119
source/common/openaudio.cpp Normal file
View file

@ -0,0 +1,119 @@
#include "cache1d.h"
#include "openaudio.h"
#include "gamecvars.h"
//////////
#if 0 // disabled pending a rewrite from the ground up.
static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char const searchfirst)
{
#ifdef HAVE_FLAC
{
Bstrcpy(fn_suffix, ".flac");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
#ifdef HAVE_VORBIS
{
Bstrcpy(fn_suffix, ".ogg");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
return FileReader();
}
static FileReader S_TryExtensionReplacements(char * const testfn, char const searchfirst, uint8_t const ismusic)
{
char * extension = Bstrrchr(testfn, '.');
char * const fn_end = Bstrchr(testfn, '\0');
// ex: grabbag.voc --> grabbag_voc.*
if (extension != NULL)
{
*extension = '_';
auto fp = S_TryFormats(testfn, fn_end, searchfirst);
if (fp.isOpen())
return fp;
}
else
{
extension = fn_end;
}
// ex: grabbag.mid --> grabbag.*
if (ismusic)
{
auto fp = S_TryFormats(testfn, extension, searchfirst);
if (fp.isOpen())
return fp;
}
return FileReader();
}
#endif
FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
{
auto origfp = kopenFileReader(fn, searchfirst);
if (!snd_tryformats) return origfp;
return origfp;
#if 0 // this needs to be redone
char const* const origparent = origfp.isOpen() ? kfileparent(origfp) : NULL;
uint32_t const parentlength = origparent != NULL ? Bstrlen(origparent) : 0;
auto testfn = (char *)Xmalloc(Bstrlen(fn) + 12 + parentlength); // "music/" + overestimation of parent minus extension + ".flac" + '\0'
// look in ./
// ex: ./grabbag.mid
Bstrcpy(testfn, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
// look in ./music/<file's parent GRP name>/
// ex: ./music/duke3d/grabbag.mid
// ex: ./music/nwinter/grabbag.mid
if (origparent != NULL)
{
char const * const parentextension = Bstrrchr(origparent, '.');
uint32_t const namelength = parentextension != NULL ? (unsigned)(parentextension - origparent) : parentlength;
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
// look in ./music/
// ex: ./music/grabbag.mid
{
Bsprintf(testfn, "music/%s", fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
Bfree(testfn);
return origfp;
#endif
}

View file

@ -0,0 +1,4 @@
#pragma once
// This really, really needs to be redone in its entirety, the audio lookup code is hideous.
extern FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic);

View file

@ -1114,3 +1114,71 @@ const char* G_ConFile(void)
}
#if 0
// Should this be added to the game data collector?
bool AddINIFile(const char* pzFile, bool bForce = false)
{
char* pzFN;
struct Bstat st;
static INICHAIN* pINIIter = NULL;
if (!bForce)
{
if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename
if (Bstat(pzFN, &st))
{
Bfree(pzFN);
return false;
} // failed to stat the file
Bfree(pzFN);
IniFile* pTempIni = new IniFile(pzFile);
if (!pTempIni->FindSection("Episode1"))
{
delete pTempIni;
return false;
}
delete pTempIni;
}
if (!pINIChain)
pINIIter = pINIChain = new INICHAIN;
else
pINIIter = pINIIter->pNext = new INICHAIN;
pINIIter->pNext = NULL;
pINIIter->pDescription = NULL;
Bstrncpy(pINIIter->zName, pzFile, BMAX_PATH);
for (int i = 0; i < ARRAY_SSIZE(gINIDescription); i++)
{
if (!Bstrncasecmp(pINIIter->zName, gINIDescription[i].pzFilename, BMAX_PATH))
{
pINIIter->pDescription = &gINIDescription[i];
break;
}
}
return true;
}
void ScanINIFiles(void)
{
nINICount = 0;
BUILDVFS_FIND_REC* pINIList = klistpath("/", "*.ini", BUILDVFS_FIND_FILE);
pINIChain = NULL;
if (bINIOverride || !pINIList)
{
AddINIFile(BloodIniFile, true);
}
for (auto pIter = pINIList; pIter; pIter = pIter->next)
{
AddINIFile(pIter->name);
}
klistfree(pINIList);
pINISelected = pINIChain;
for (auto pIter = pINIChain; pIter; pIter = pIter->pNext)
{
if (!Bstrncasecmp(BloodIniFile, pIter->zName, BMAX_PATH))
{
pINISelected = pIter;
break;
}
}
#endif

View file

@ -46,7 +46,6 @@ set( PCH_SOURCES
src/gameexec.cpp
src/gamevars.cpp
src/global.cpp
src/grpscan.cpp
src/menus.cpp
src/namesdyn.cpp
src/network.cpp

View file

@ -10,7 +10,6 @@
#include "palette.h"
#include "gamecvars.h"
#include "cmdlib.h"
#include "grpscan.h"
#include "rts.h"
#include "gamecontrol.h"
@ -140,116 +139,5 @@ void G_LoadLookups(void)
}
}
//////////
#ifdef FORMAT_UPGRADE_ELIGIBLE
static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char const searchfirst)
{
#ifdef HAVE_FLAC
{
Bstrcpy(fn_suffix, ".flac");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
#ifdef HAVE_VORBIS
{
Bstrcpy(fn_suffix, ".ogg");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
return FileReader();
}
static FileReader S_TryExtensionReplacements(char * const testfn, char const searchfirst, uint8_t const ismusic)
{
char * extension = Bstrrchr(testfn, '.');
char * const fn_end = Bstrchr(testfn, '\0');
// ex: grabbag.voc --> grabbag_voc.*
if (extension != NULL)
{
*extension = '_';
auto fp = S_TryFormats(testfn, fn_end, searchfirst);
if (fp.isOpen())
return fp;
}
else
{
extension = fn_end;
}
// ex: grabbag.mid --> grabbag.*
if (ismusic)
{
auto fp = S_TryFormats(testfn, extension, searchfirst);
if (fp.isOpen())
return fp;
}
return FileReader();
}
FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
{
auto origfp = kopenFileReader(fn, searchfirst);
if (!snd_tryformats) return origfp;
char const* const origparent = origfp.isOpen() ? kfileparent(origfp) : NULL;
uint32_t const parentlength = origparent != NULL ? Bstrlen(origparent) : 0;
auto testfn = (char *)Xmalloc(Bstrlen(fn) + 12 + parentlength); // "music/" + overestimation of parent minus extension + ".flac" + '\0'
// look in ./
// ex: ./grabbag.mid
Bstrcpy(testfn, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
// look in ./music/<file's parent GRP name>/
// ex: ./music/duke3d/grabbag.mid
// ex: ./music/nwinter/grabbag.mid
if (origparent != NULL)
{
char const * const parentextension = Bstrrchr(origparent, '.');
uint32_t const namelength = parentextension != NULL ? (unsigned)(parentextension - origparent) : parentlength;
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
// look in ./music/
// ex: ./music/grabbag.mid
{
Bsprintf(testfn, "music/%s", fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
Bfree(testfn);
return origfp;
}
#endif
END_DUKE_NS

View file

@ -8,7 +8,6 @@
#define EDUKE32_COMMON_GAME_H_
#include "collections.h"
#include "grpscan.h"
#include "gamecontrol.h"
#include "vfs.h"
@ -67,8 +66,5 @@ extern void G_LoadLookups(void);
//////////
# define FORMAT_UPGRADE_ELIGIBLE
extern FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic);
END_DUKE_NS
#endif

View file

@ -4687,20 +4687,6 @@ void G_HandleLocalKeys(void)
Demo_PrepareWarp();
}
#if 0
// Enter a game from within a demo.
if (KB_KeyPressed(sc_Return) && ud.multimode==1)
{
KB_ClearKeyDown(sc_Return);
g_demo_cnt = g_demo_goalCnt = ud.reccnt = ud.pause_on = ud.recstat = ud.m_recstat = 0;
// XXX: probably redundant; this stuff needs an API anyway:
kclose(g_demo_recFilePtr); g_demo_recFilePtr = buildvfs_kfd_invalid;
myplayer.gm = MODE_GAME;
ready2send=1; // TODO: research this weird variable
screenpeek=myconnectindex;
// g_demo_paused=0;
}
#endif
}
if (SHIFTS_IS_PRESSED || ALT_IS_PRESSED || WIN_IS_PRESSED)
@ -5734,9 +5720,7 @@ void G_Shutdown(void)
KB_Shutdown();
engineUnInit();
G_Cleanup();
FreeGroups();
OSD_Cleanup();
uninitgroupfile();
Bfflush(NULL);
}

View file

@ -1904,7 +1904,7 @@ static int C_CountCaseStatements()
static void C_Include(const char *confile)
{
auto fp = kopenFileReader(confile,g_loadFromGroupOnly);
auto fp = kopenFileReader(confile,0);
if (!fp.isOpen())
{
@ -1956,16 +1956,6 @@ static void C_Include(const char *confile)
}
#endif // !defined LUNATIC
#ifdef _WIN32
static void check_filename_case(const char *fn)
{
// WTF?!?
testkopen(fn, g_loadFromGroupOnly);
}
#else
static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); }
#endif
void G_DoGameStartup(const int32_t *params)
{
auto &p0 = *g_player[0].ps;
@ -2039,7 +2029,6 @@ void C_DefineMusic(int volumeNum, int levelNum, const char *fileName)
Xfree(pMapInfo->musicfn);
pMapInfo->musicfn = dup_filename(fileName);
check_filename_case(pMapInfo->musicfn);
}
void C_DefineVolumeFlags(int32_t vol, int32_t flags)
@ -5593,8 +5582,6 @@ repeatcase:
}
g_sounds[k].filename[i] = '\0';
check_filename_case(g_sounds[k].filename);
C_GetNextValue(LABEL_DEFINE);
g_sounds[k].ps = g_scriptPtr[-1];
C_GetNextValue(LABEL_DEFINE);
@ -6095,7 +6082,7 @@ void C_Compile(const char *fileName)
Gv_Init();
C_InitProjectiles();
auto kFile = kopenFileReader(fileName,g_loadFromGroupOnly);
auto kFile = kopenFileReader(fileName,0);
if (!kFile.isOpen())
{

View file

@ -1,689 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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 the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "baselayer.h"
#include "cache1d.h"
#include "common_game.h"
#include "compat.h"
#include "crc32_.h"
#include "duke3d.h"
#include "grpscan.h"
#include "scriptfile.h"
#include "vfs.h"
BEGIN_DUKE_NS
#ifndef EDUKE32_STANDALONE
static void process_vaca13(int32_t crcval);
static void process_vacapp15(int32_t crcval);
// custom GRP support for the startup window, file format reflects the structure below
#define GAMELISTFILE "games.list"
// name crc size flags dependency scriptname postprocessing
static internalgrpinfo_t const internalgrpfiles[] =
{
{ "Duke Nukem 3D", DUKE13_CRC, 26524524, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D (South Korean Censored)", DUKEKR_CRC, 26385383, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D: Atomic Edition", DUKE15_CRC, 44356548, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D: Atomic Edition (WT)", DUKEWT_CRC, 44356548, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D: Plutonium Pak", DUKEPP_CRC, 44348015, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D Shareware 0.99", DUKE099_CRC, 9690241, GAMEFLAG_DUKE|GAMEFLAG_DUKEBETA, 0, NULL, NULL},
{ "Duke Nukem 3D Shareware 1.0", DUKE10_CRC, 10429258, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
{ "Duke Nukem 3D Shareware 1.1", DUKE11_CRC, 10442980, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
{ "Duke Nukem 3D Shareware 1.3D", DUKESW_CRC, 11035779, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
{ "Duke Nukem 3D Mac Demo", DUKEMD_CRC, 10444391, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
{ "Duke Nukem 3D MacUser Demo", DUKEMD2_CRC, 10628573, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL },
{ "Duke it out in D.C. (1.3D)", DUKEDC13_CRC, 7926624, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE13_CRC, NULL, NULL},
{ "Duke it out in D.C.", DUKEDCPP_CRC, 8225517, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, NULL},
{ "Duke it out in D.C.", DUKEDC_CRC, 8410183, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, NULL},
{ "Duke it out in D.C.", (int32_t) 0x39A692BF, 8410187, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "DUKEDC.CON", NULL},
{ "Duke Caribbean: Life's a Beach (1.3D)", VACA13_CRC, 23559381, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE13_CRC, NULL, process_vaca13},
{ "Duke Caribbean: Life's a Beach (PPak)", VACAPP_CRC, 22551333, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKEPP_CRC, NULL, process_vacapp15},
{ "Duke Caribbean: Life's a Beach", VACA15_CRC, 22521880, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, process_vacapp15},
{ "Duke Caribbean: Life's a Beach", DUKECB_CRC, 22213819, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, NULL},
{ "Duke Caribbean: Life's a Beach", (int32_t) 0x65B5F690, 22397273, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "VACATION.CON", NULL},
{ "Duke: Nuclear Winter", DUKENW_CRC, 16169365, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "NWINTER.CON", NULL},
{ "Duke: Nuclear Winter Demo", (int32_t) 0xC7EFBFA9, 10965909, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "NWINTER.CON", NULL},
{ "Duke!ZONE II (1.3D)", DZ2_13_CRC, 26135388, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE13_CRC, "DZ-GAME.CON", NULL},
{ "Duke!ZONE II", DZ2_PP_CRC, 44100411, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "DZ-GAME.CON", NULL},
{ "Duke!ZONE II", (int32_t) 0x1E9516F1, 3186656, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "DZ-GAME.CON", NULL},
{ "NAM", NAM_CRC, 43448927, GAMEFLAG_NAM, 0, NULL, NULL},
{ "NAPALM", NAPALM_CRC, 44365728, GAMEFLAG_NAM|GAMEFLAG_NAPALM, 0, NULL, NULL},
{ "WWII GI", WW2GI_CRC, 77939508, GAMEFLAG_WW2GI, 0, NULL, NULL},
{ "Platoon Leader", PLATOONL_CRC, 37852572, GAMEFLAG_WW2GI|GAMEFLAG_ADDON, WW2GI_CRC, "PLATOONL.DEF", NULL},
};
#endif
struct grpfile_t *foundgrps = NULL;
struct grpinfo_t *listgrps = NULL;
static void LoadList(const char * filename)
{
scriptfile *script = scriptfile_fromfile(filename);
if (!script)
return;
#ifndef EDUKE32_STANDALONE
scriptfile_addsymbolvalue("GAMEFLAG_DUKE", GAMEFLAG_DUKE);
scriptfile_addsymbolvalue("GAMEFLAG_ADDON", GAMEFLAG_DUKE|GAMEFLAG_ADDON);
scriptfile_addsymbolvalue("GAMEFLAG_NAM", GAMEFLAG_NAM);
scriptfile_addsymbolvalue("GAMEFLAG_NAPALM", GAMEFLAG_NAM|GAMEFLAG_NAPALM);
scriptfile_addsymbolvalue("GAMEFLAG_WW2GI", GAMEFLAG_NAM|GAMEFLAG_WW2GI);
scriptfile_addsymbolvalue("DUKE15_CRC", DUKE15_CRC);
scriptfile_addsymbolvalue("DUKEPP_CRC", DUKEPP_CRC);
scriptfile_addsymbolvalue("DUKE13_CRC", DUKE13_CRC);
scriptfile_addsymbolvalue("DUKEDC13_CRC", DUKEDC13_CRC);
scriptfile_addsymbolvalue("DUKEDCPP_CRC", DUKEDCPP_CRC);
scriptfile_addsymbolvalue("DUKEDC_CRC", DUKEDC_CRC);
scriptfile_addsymbolvalue("VACA13_CRC", VACA13_CRC);
scriptfile_addsymbolvalue("VACAPP_CRC", VACAPP_CRC);
scriptfile_addsymbolvalue("VACA15_CRC", VACA15_CRC);
scriptfile_addsymbolvalue("DUKECB_CRC", DUKECB_CRC);
scriptfile_addsymbolvalue("DUKENW_CRC", DUKENW_CRC);
scriptfile_addsymbolvalue("DZ2_13_CRC", DZ2_13_CRC);
scriptfile_addsymbolvalue("DZ2_PP_CRC", DZ2_PP_CRC);
scriptfile_addsymbolvalue("NAM_CRC", NAM_CRC);
scriptfile_addsymbolvalue("NAPALM_CRC", NAPALM_CRC);
scriptfile_addsymbolvalue("WW2GI_CRC", WW2GI_CRC);
#endif
while (!scriptfile_eof(script))
{
enum
{
T_GRPINFO,
T_GAMENAME,
T_CRC,
T_SIZE,
T_DEPCRC,
T_SCRIPTNAME,
T_DEFNAME,
T_FLAGS,
T_RTSNAME,
};
static const tokenlist profiletokens[] =
{
{ "grpinfo", T_GRPINFO },
};
int32_t token = getatoken(script,profiletokens,ARRAY_SIZE(profiletokens));
switch (token)
{
case T_GRPINFO:
{
int32_t gsize = 0, gcrcval = 0, gflags = GAMEFLAG_DUKE, gdepcrc = DUKE15_CRC;
char *gname = NULL, *gscript = NULL, *gdef = NULL;
char *grts = NULL;
char *grpend = NULL;
static const tokenlist grpinfotokens[] =
{
{ "name", T_GAMENAME },
{ "scriptname", T_SCRIPTNAME },
{ "defname", T_DEFNAME },
{ "rtsname", T_RTSNAME },
{ "crc", T_CRC },
{ "dependency", T_DEPCRC },
{ "size", T_SIZE },
{ "flags", T_FLAGS },
};
if (scriptfile_getbraces(script,&grpend)) break;
while (script->textptr < grpend)
{
int32_t token = getatoken(script,grpinfotokens,ARRAY_SIZE(grpinfotokens));
switch (token)
{
case T_GAMENAME:
scriptfile_getstring(script,&gname); break;
case T_SCRIPTNAME:
scriptfile_getstring(script,&gscript); break;
case T_DEFNAME:
scriptfile_getstring(script,&gdef); break;
case T_RTSNAME:
scriptfile_getstring(script,&grts); break;
case T_FLAGS:
scriptfile_getsymbol(script,&gflags); gflags &= GAMEFLAGMASK; break;
case T_DEPCRC:
scriptfile_getsymbol(script,&gdepcrc); break;
case T_CRC:
scriptfile_getsymbol(script,&gcrcval); break;
case T_SIZE:
scriptfile_getnumber(script,&gsize); break;
default:
break;
}
grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
fg->next = listgrps;
listgrps = fg;
if (gname)
fg->name = Xstrdup(gname);
fg->size = gsize;
fg->crcval = gcrcval;
fg->dependency = gdepcrc;
fg->game = gflags;
if (gscript)
fg->scriptname = dup_filename(gscript);
if (gdef)
fg->defname = dup_filename(gdef);
if (grts)
fg->rtsname = dup_filename(grts);
}
break;
}
default:
break;
}
}
scriptfile_close(script);
scriptfile_clearsymbols();
}
static void LoadGameList(void)
{
#ifndef EDUKE32_STANDALONE
for (size_t i = 0; i < ARRAY_SIZE(internalgrpfiles); i++)
{
grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
fg->name = Xstrdup(internalgrpfiles[i].name);
fg->crcval = internalgrpfiles[i].crcval;
fg->size = internalgrpfiles[i].size;
fg->game = internalgrpfiles[i].game;
fg->dependency = internalgrpfiles[i].dependency;
if (internalgrpfiles[i].scriptname)
fg->scriptname = dup_filename(internalgrpfiles[i].scriptname);
fg->postprocessing = internalgrpfiles[i].postprocessing;
fg->next = listgrps;
listgrps = fg;
}
#endif
#ifdef USE_PHYSFS
auto const base = PHYSFS_getBaseDir();
#else
static char const base[] = "/";
#endif
CACHE1D_FIND_REC * const srch = klistpath(base, "*.grpinfo", CACHE1D_FIND_FILE);
for (CACHE1D_FIND_REC *sidx = srch; sidx; sidx = sidx->next)
LoadList(sidx->name);
klistfree(srch);
}
static void FreeGameList(void)
{
while (listgrps)
{
Xfree(listgrps->name);
Xfree(listgrps->scriptname);
Xfree(listgrps->defname);
Xfree(listgrps->rtsname);
grpinfo_t * const fg = listgrps->next;
Xfree(listgrps);
listgrps = fg;
}
}
#define GRPCACHEFILE "grpfiles.cache"
static struct grpcache
{
struct grpcache *next;
int32_t size;
int32_t mtime;
int32_t crcval;
char name[BMAX_PATH];
}
*grpcache = NULL, *usedgrpcache = NULL;
static int32_t LoadGroupsCache(void)
{
struct grpcache *fg;
int32_t fsize, fmtime, fcrcval;
char *fname;
scriptfile *script;
script = scriptfile_fromfile(GRPCACHEFILE);
if (!script) return -1;
while (!scriptfile_eof(script))
{
if (scriptfile_getstring(script, &fname)) break; // filename
if (scriptfile_getnumber(script, &fsize)) break; // filesize
if (scriptfile_getnumber(script, &fmtime)) break; // modification time
if (scriptfile_getnumber(script, &fcrcval)) break; // crc checksum
fg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
fg->next = grpcache;
grpcache = fg;
Bstrncpy(fg->name, fname, BMAX_PATH);
fg->size = fsize;
fg->mtime = fmtime;
fg->crcval = fcrcval;
}
scriptfile_close(script);
return 0;
}
static void FreeGroupsCache(void)
{
while (grpcache)
{
struct grpcache * const fg = grpcache->next;
Xfree(grpcache);
grpcache = fg;
}
}
static void RemoveGroup(grpfile_t *igrp)
{
for (grpfile_t *prev = NULL, *grp = foundgrps; grp; grp=grp->next)
{
if (grp == igrp)
{
if (grp == foundgrps)
foundgrps = grp->next;
else
prev->next = grp->next;
Xfree((char *)grp->filename);
Xfree(grp);
return;
}
prev = grp;
}
}
grpfile_t * FindGroup(int32_t crcval)
{
grpfile_t *grp;
for (grp = foundgrps; grp; grp=grp->next)
{
if (grp->type->crcval == crcval)
return grp;
}
return NULL;
}
#ifndef USE_PHYSFS
static grpinfo_t const * FindGrpInfo(int32_t crcval, int32_t size)
{
grpinfo_t *grpinfo;
for (grpinfo = listgrps; grpinfo; grpinfo=grpinfo->next)
{
if (grpinfo->crcval == crcval && grpinfo->size == size)
return grpinfo;
}
return NULL;
}
static void ProcessGroups(CACHE1D_FIND_REC *srch)
{
CACHE1D_FIND_REC *sidx;
struct grpcache *fg, *fgg;
char *fn;
struct Bstat st;
static constexpr int ReadSize = 65536;
auto buf = (uint8_t *)Xmalloc(ReadSize);
for (sidx = srch; sidx; sidx = sidx->next)
{
for (fg = grpcache; fg; fg = fg->next)
{
if (!Bstrcmp(fg->name, sidx->name)) break;
}
if (fg)
{
if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename
if (Bstat(fn, &st))
{
Xfree(fn);
continue;
} // failed to stat the file
Xfree(fn);
if (fg->size == (int32_t)st.st_size && fg->mtime == (int32_t)st.st_mtime)
{
grpinfo_t const * const grptype = FindGrpInfo(fg->crcval, fg->size);
if (grptype)
{
grpfile_t * const grp = (grpfile_t *)Xcalloc(1, sizeof(grpfile_t));
grp->filename = Xstrdup(sidx->name);
grp->type = grptype;
grp->next = foundgrps;
foundgrps = grp;
}
fgg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
strcpy(fgg->name, fg->name);
fgg->size = fg->size;
fgg->mtime = fg->mtime;
fgg->crcval = fg->crcval;
fgg->next = usedgrpcache;
usedgrpcache = fgg;
continue;
}
}
{
int32_t b, fh;
int32_t crcval = 0;
fh = openfrompath(sidx->name, BO_RDONLY|BO_BINARY, BS_IREAD);
if (fh < 0) continue;
if (Bfstat(fh, &st)) continue;
initprintf(" Checksumming %s...", sidx->name);
do
{
b = read(fh, buf, ReadSize);
if (b > 0) crcval = Bcrc32((uint8_t *)buf, b, crcval);
}
while (b == ReadSize);
close(fh);
initprintf(" Done\n");
grpinfo_t const * const grptype = FindGrpInfo(crcval, st.st_size);
if (grptype)
{
grpfile_t * const grp = (grpfile_t *)Xcalloc(1, sizeof(grpfile_t));
grp->filename = Xstrdup(sidx->name);
grp->type = grptype;
grp->next = foundgrps;
foundgrps = grp;
}
fgg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
Bstrncpy(fgg->name, sidx->name, BMAX_PATH);
fgg->size = st.st_size;
fgg->mtime = st.st_mtime;
fgg->crcval = crcval;
fgg->next = usedgrpcache;
usedgrpcache = fgg;
}
}
Xfree(buf);
}
#endif
int32_t ScanGroups(void)
{
#ifndef USE_PHYSFS
struct grpcache *fg, *fgg;
initprintf("Searching for game data...\n");
LoadGameList();
LoadGroupsCache();
static char const *extensions[] =
{
"*.grp",
"*.ssi",
"*.dat",
};
for (char const *extension : extensions)
{
CACHE1D_FIND_REC *srch = klistpath("/", extension, CACHE1D_FIND_FILE);
ProcessGroups(srch);
klistfree(srch);
}
FreeGroupsCache();
for (grpfile_t *grp = foundgrps; grp; grp=grp->next)
{
if (grp->type->dependency)
{
if (FindGroup(grp->type->dependency) == NULL) // couldn't find dependency
{
//initprintf("removing %s\n", grp->name);
RemoveGroup(grp);
grp = foundgrps;
// start from the beginning so we can remove anything that depended on this grp
continue;
}
}
}
if (usedgrpcache)
{
int32_t i = 0;
buildvfs_FILE fp = buildvfs_fopen_write(GRPCACHEFILE);
if (fp)
{
for (fg = usedgrpcache; fg; fg=fgg)
{
fgg = fg->next;
fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
Xfree(fg);
i++;
}
buildvfs_fclose(fp);
}
// initprintf("Found %d recognized GRP %s.\n",i,i>1?"files":"file");
return 0;
}
initprintf("Found no recognized game data!\n");
#endif
return 0;
}
void FreeGroups(void)
{
while (foundgrps)
{
Xfree((char *)foundgrps->filename);
grpfile_t * const fg = foundgrps->next;
Xfree(foundgrps);
foundgrps = fg;
}
FreeGameList();
}
#ifndef EDUKE32_STANDALONE
static void process_vaca13(int32_t crcval)
{
krename(crcval, 0, "ADDREE.VOC");
krename(crcval, 1, "BALLBOOM.VOC");
krename(crcval, 2, "BARMUSIC.VOC");
krename(crcval, 3, "BCHBALL.VOC");
krename(crcval, 4, "BOING.VOC");
krename(crcval, 5, "CHACHA.VOC");
krename(crcval, 6, "CHAINDRV.VOC");
krename(crcval, 7, "CHEAP01.VOC");
krename(crcval, 8, "CHEER.VOC");
krename(crcval, 9, "CHNSQRT.VOC");
krename(crcval, 10, "COCOANUT.VOC");
krename(crcval, 11, "CRUSH2.VOC");
krename(crcval, 12, "DEFLATE2.VOC");
krename(crcval, 13, "DRAGHURT.VOC");
krename(crcval, 14, "DRAGROAM.VOC");
krename(crcval, 15, "DRAGSHOT.VOC");
krename(crcval, 16, "DUKE01.VOC");
krename(crcval, 17, "ELEV1.VOC");
krename(crcval, 18, "GMEOVR05.VOC");
krename(crcval, 19, "GULLDIE.VOC");
krename(crcval, 20, "GULLHURT.VOC");
krename(crcval, 21, "GULLROAM.VOC");
krename(crcval, 22, "GULLSHIT.VOC");
krename(crcval, 23, "HELP04.VOC");
krename(crcval, 24, "ICECONCH.VOC");
krename(crcval, 25, "IDLEBOAT.VOC");
krename(crcval, 26, "KICKHEAD.VOC");
krename(crcval, 27, "LANI05.VOC");
krename(crcval, 28, "LANI08.VOC");
krename(crcval, 29, "LANIDUK2.VOC");
krename(crcval, 30, "MUSCLE01.VOC");
krename(crcval, 31, "MUSCLE04.VOC");
krename(crcval, 32, "MUZAK.VOC");
krename(crcval, 33, "PINEFALL.VOC");
krename(crcval, 34, "POINT07.VOC");
krename(crcval, 35, "POINT08.VOC");
krename(crcval, 36, "RADIO.VOC");
krename(crcval, 37, "RUIN01.VOC");
krename(crcval, 38, "SCREAM.VOC");
krename(crcval, 39, "SCREAM04.VOC");
krename(crcval, 40, "SCREAM9.VOC");
krename(crcval, 41, "SHIPHORN.VOC");
krename(crcval, 42, "SNGLGULL.VOC");
krename(crcval, 43, "SQRT4.VOC");
krename(crcval, 44, "SQUIRT1.VOC");
krename(crcval, 45, "SSCOOL1.VOC");
krename(crcval, 46, "SSCOOL2.VOC");
krename(crcval, 47, "SSCOOL3.VOC");
krename(crcval, 48, "SSDIE1.VOC");
krename(crcval, 49, "SSDIE2.VOC");
krename(crcval, 50, "SSNORM01.VOC");
krename(crcval, 51, "SSNORM02.VOC");
krename(crcval, 52, "SSNORM03.VOC");
krename(crcval, 53, "SSNORM04.VOC");
krename(crcval, 54, "SSNORM05.VOC");
krename(crcval, 55, "SSNORM06.VOC");
krename(crcval, 56, "SSNORM07.VOC");
krename(crcval, 57, "SSNORM08.VOC");
krename(crcval, 58, "SSNORM10.VOC");
krename(crcval, 59, "SSNORM11.VOC");
krename(crcval, 60, "SSNORM12.VOC");
krename(crcval, 61, "SSNORM13.VOC");
krename(crcval, 62, "SSNORM14.VOC");
krename(crcval, 63, "SSNORM15.VOC");
krename(crcval, 64, "SSNORM16.VOC");
krename(crcval, 65, "SSNORM17.VOC");
krename(crcval, 66, "SSNORM18.VOC");
krename(crcval, 67, "SSNORM19.VOC");
krename(crcval, 68, "SSNORM20.VOC");
krename(crcval, 69, "SSTAUNT1.VOC");
krename(crcval, 70, "SSTAUNT2.VOC");
krename(crcval, 71, "SSTAUNT3.VOC");
krename(crcval, 72, "SSTAUNT4.VOC");
krename(crcval, 73, "SSTAUNT5.VOC");
krename(crcval, 74, "SSTAUNT6.VOC");
krename(crcval, 75, "SSTAUNT7.VOC");
krename(crcval, 76, "SSTAUNT8.VOC");
krename(crcval, 77, "SURF.VOC");
krename(crcval, 78, "TAN01.VOC");
krename(crcval, 79, "TAN04.VOC");
krename(crcval, 80, "VINESNAP.VOC");
krename(crcval, 81, "VOODRUMS.VOC");
krename(crcval, 82, "WIND54.VOC");
krename(crcval, 83, "DOOMSDAY.MID");
krename(crcval, 84, "DUKE-O.MID");
krename(crcval, 85, "IRIEPRTY.MID");
krename(crcval, 86, "JUNGVEIN.MID");
krename(crcval, 87, "PRTYCRUZ.MID");
krename(crcval, 88, "SOL-MAN1.MID");
krename(crcval, 90, "CINEOV3.ANM");
krename(crcval, 91, "DUKETEAM.ANM");
krename(crcval, 92, "BEACHBAB.CON");
krename(crcval, 93, "BEACHBAL.CON");
krename(crcval, 94, "BEACHBTH.CON");
krename(crcval, 95, "DEFS.CON");
krename(crcval, 96, "DRAGON.CON");
krename(crcval, 97, "GAME.CON");
krename(crcval, 98, "SEAGULL.CON");
krename(crcval, 99, "SOUNDS.CON");
krename(crcval, 100, "USER.CON");
krename(crcval, 101, "DEMO1.DMO");
krename(crcval, 102, "DEMO2.DMO");
krename(crcval, 103, "DEMO3.DMO");
krename(crcval, 104, "VACA1.MAP");
krename(crcval, 105, "VACA2.MAP");
krename(crcval, 106, "VACA3.MAP");
krename(crcval, 107, "VACA4.MAP");
krename(crcval, 108, "VACA5.MAP");
krename(crcval, 109, "VACA6.MAP");
krename(crcval, 110, "VACA7.MAP");
krename(crcval, 111, "VACADM1.MAP");
krename(crcval, 112, "VACADM2.MAP");
krename(crcval, 113, "VACADM3.MAP");
krename(crcval, 114, "VACADM4.MAP");
krename(crcval, 115, "VACASL.MAP");
krename(crcval, 120, "TILES000.ART");
krename(crcval, 121, "TILES001.ART");
krename(crcval, 122, "TILES003.ART");
krename(crcval, 123, "TILES005.ART");
krename(crcval, 124, "TILES006.ART");
krename(crcval, 125, "TILES007.ART");
krename(crcval, 126, "TILES008.ART");
krename(crcval, 127, "TILES009.ART");
krename(crcval, 128, "TILES010.ART");
krename(crcval, 129, "TILES012.ART");
krename(crcval, 130, "TILES014.ART");
}
static void process_vacapp15(int32_t crcval)
{
krename(crcval, 5, "DEFS.CON");
krename(crcval, 6, "GAME.CON");
krename(crcval, 7, "USER.CON");
krename(crcval, 8, "DEMO1.DMO");
krename(crcval, 9, "DEMO2.DMO");
krename(crcval, 10, "DEMO3.DMO");
initgroupfile("VACATION.PRG");
}
#endif
END_DUKE_NS

View file

@ -1,104 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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 the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#ifndef grpscan_h_
#define grpscan_h_
BEGIN_DUKE_NS
#define MAXLISTNAMELEN 32
// List of internally-known GRP files
#define DUKE13_CRC (int32_t)0xBBC9CE44
#define DUKEKR_CRC (int32_t)0xAA4F6A40
#define DUKE15_CRC (int32_t)0xFD3DCFF1
#define DUKEPP_CRC (int32_t)0xF514A6AC
#define DUKEWT_CRC (int32_t)0x982AFE4A
#define DUKE099_CRC (int32_t)0x02F18900
#define DUKE10_CRC (int32_t)0xA28AA589
#define DUKE11_CRC (int32_t)0x912E1E8D
#define DUKESW_CRC (int32_t)0x983AD923
#define DUKEMD_CRC (int32_t)0xC5F71561
#define DUKEMD2_CRC (int32_t)0x73A15EE7
#define DUKEDC13_CRC (int32_t)0xA9242158
#define DUKEDCPP_CRC (int32_t)0xB79D997F
#define DUKEDC_CRC (int32_t)0xA8CF80DA
#define VACA13_CRC (int32_t)0x4A2DBB62
#define VACAPP_CRC (int32_t)0x2F4FCCEE
#define VACA15_CRC (int32_t)0xB62B42FD
#define DUKECB_CRC (int32_t)0x18F01C5B
#define DUKENW_CRC (int32_t)0xF1CAE8E4
#define DZ2_13_CRC (int32_t)0x82C1B47F
#define DZ2_PP_CRC (int32_t)0x7FB6117C
#define NAM_CRC (int32_t)0x75C1F07B
#define NAPALM_CRC (int32_t)0x3DE1589A
#define WW2GI_CRC (int32_t)0x907B82BF
#define PLATOONL_CRC (int32_t)0xD1ED8C0C
enum addon_t {
ADDON_NONE,
ADDON_DUKEDC,
ADDON_NWINTER,
ADDON_CARIBBEAN,
NUMADDONS
};
typedef struct internalgrpinfo_t {
char const *name;
int32_t const crcval;
int32_t const size;
int32_t const game;
int32_t const dependency;
char const *scriptname;
void(*postprocessing)(int32_t);
} internalgrpinfo_t;
typedef struct grpinfo_t {
char *name;
int32_t crcval;
int32_t size;
int32_t game;
int32_t dependency;
char *scriptname;
char *defname;
char *rtsname;
void (*postprocessing)(int32_t);
struct grpinfo_t *next;
} grpinfo_t;
typedef struct grpfile_t {
char *filename;
struct grpinfo_t const *type;
struct grpfile_t *next;
} grpfile_t;
extern grpfile_t *foundgrps;
extern grpinfo_t *listgrps;
extern grpfile_t * FindGroup(int32_t crcval);
int32_t ScanGroups(void);
void FreeGroups(void);
END_DUKE_NS
#endif

View file

@ -720,16 +720,6 @@ static int osdcmd_lua(osdcmdptr_t parm)
}
#endif
static int osdcmd_initgroupfile(osdcmdptr_t parm)
{
if (parm->numparms != 1)
return OSDCMD_SHOWHELP;
initgroupfile(parm->parms[0]);
return OSDCMD_OK;
}
static int osdcmd_cmenu(osdcmdptr_t parm)
{
if (parm->numparms != 1)
@ -1216,7 +1206,6 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
#ifdef DEBUGGINGAIDS
OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer);
#endif

View file

@ -1017,7 +1017,7 @@ static int32_t readspecdata(const dataspec_t *spec, FileReader *fil, uint8_t **d
OSD_Printf("rsd: spec=%s, idx=%d:\n", (char *)sptr->ptr, (int32_t)(spec-sptr));
if (ksiz!=siz)
OSD_Printf(" kread returned %d, expected %d.\n", ksiz, siz);
OSD_Printf(" file read returned %d, expected %d.\n", ksiz, siz);
else
OSD_Printf(" sp->ptr and cmpstrbuf not identical!\n");
@ -2268,67 +2268,6 @@ static uint8_t *dosaveplayer2(buildvfs_FILE fil, uint8_t *mem)
return mem;
}
#ifdef LUNATIC
char *g_elSavecode = NULL;
static int32_t El_ReadSaveCode(buildvfs_kfd fil)
{
// Read Lua code to restore gamevar values from the savegame.
// It will be run from Lua with its state creation later on.
char header[12];
int32_t slen;
if (kread(fil, header, 12) != 12)
{
OSD_Printf("doloadplayer2: failed reading Lunatic gamevar header.\n");
return -100;
}
if (Bmemcmp(header, "\0\1LunaGVAR\3\4", 12))
{
OSD_Printf("doloadplayer2: Lunatic gamevar header doesn't match.\n");
return -101;
}
if (kread(fil, &slen, sizeof(slen)) != sizeof(slen))
{
OSD_Printf("doloadplayer2: failed reading Lunatic gamevar string size.\n");
return -102;
}
slen = B_LITTLE32(slen);
if (slen < 0)
{
OSD_Printf("doloadplayer2: invalid Lunatic gamevar string size %d.\n", slen);
return -103;
}
if (slen > 0)
{
char *svcode = (char *)Xmalloc(slen+1);
if (kdfread_LZ4(svcode, 1, slen, fil) != slen) // cnt and sz swapped
{
OSD_Printf("doloadplayer2: failed reading Lunatic gamevar restoration code.\n");
Xfree(svcode);
return -104;
}
svcode[slen] = 0;
g_elSavecode = svcode;
}
return 0;
}
void El_FreeSaveCode(void)
{
// Free Lunatic gamevar savegame restoration Lua code.
Xfree(g_elSavecode);
g_elSavecode = NULL;
}
#endif
static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr)
{

View file

@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h"
#include "renderlayer.h" // for win_gethwnd()
#include "al_midi.h"
#include "openaudio.h"
#include <atomic>
#include "vfs.h"
@ -134,16 +135,12 @@ void S_MusicStartup(void)
}
MUSIC_SetVolume(mus_volume);
auto const fil = kopen4load("d3dtimbr.tmb", 0);
auto fr = kopenFileReader("d3dtimbr.tmb", 0);
if (fil != buildvfs_kfd_invalid)
if (fr.isOpen())
{
int l = kfilelength(fil);
auto tmb = (uint8_t *)Xmalloc(l);
kread(fil, tmb, l);
AL_RegisterTimbreBank(tmb);
Xfree(tmb);
kclose(fil);
auto tmb = fr.Read();
AL_RegisterTimbreBank(tmb.Data());
}
}
@ -470,7 +467,7 @@ int32_t S_LoadSound(int num)
auto &snd = g_sounds[num];
auto fp = S_OpenAudio(snd.filename, g_loadFromGroupOnly, 0);
auto fp = S_OpenAudio(snd.filename, 0, 0);
if (!fp.isOpen())
{

View file

@ -43,7 +43,6 @@ set( PCH_SOURCES
src/gamedef.cpp
src/gameexec.cpp
src/global.cpp
src/grpscan.cpp
src/menus.cpp
src/namesdyn.cpp
src/net.cpp

View file

@ -8,7 +8,6 @@
#include "baselayer.h"
#include "palette.h"
#include "cmdlib.h"
#include "grpscan.h"
#include "gamecvars.h"
#include "rts.h"
#include "gamecontrol.h"
@ -183,116 +182,5 @@ void G_LoadLookups(void)
}
}
//////////
#ifdef FORMAT_UPGRADE_ELIGIBLE
static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char const searchfirst)
{
#ifdef HAVE_FLAC
{
Bstrcpy(fn_suffix, ".flac");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
#ifdef HAVE_VORBIS
{
Bstrcpy(fn_suffix, ".ogg");
auto fp = kopenFileReader(testfn, searchfirst);
if (fp.isOpen())
return fp;
}
#endif
return FileReader();
}
static FileReader S_TryExtensionReplacements(char * const testfn, char const searchfirst, uint8_t const ismusic)
{
char * extension = Bstrrchr(testfn, '.');
char * const fn_end = Bstrchr(testfn, '\0');
// ex: grabbag.voc --> grabbag_voc.*
if (extension != NULL)
{
*extension = '_';
auto fp = S_TryFormats(testfn, fn_end, searchfirst);
if (fp.isOpen())
return fp;
}
else
{
extension = fn_end;
}
// ex: grabbag.mid --> grabbag.*
if (ismusic)
{
auto fp = S_TryFormats(testfn, extension, searchfirst);
if (fp.isOpen())
return fp;
}
return FileReader();
}
FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
{
auto origfp = kopenFileReader(fn, searchfirst);
char const * const origparent = origfp.isOpen() ? kfileparent(origfp) : NULL;
uint32_t const origparentlength = origparent != NULL ? Bstrlen(origparent) : 0;
char * const testfn = (char *)Xmalloc(Bstrlen(fn) + 12 + origparentlength); // "music/" + overestimation of parent minus extension + ".flac" + '\0'
// look in ./
// ex: ./grabbag.mid
{
Bstrcpy(testfn, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
// look in ./music/<file's parent GRP name>/
// ex: ./music/duke3d/grabbag.mid
// ex: ./music/nwinter/grabbag.mid
if (origparent != NULL)
{
char const * const origparentextension = Bstrrchr(origparent, '.');
uint32_t namelength = origparentextension != NULL ? (unsigned)(origparentextension - origparent) : origparentlength;
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
// look in ./music/
// ex: ./music/grabbag.mid
{
Bsprintf(testfn, "music/%s", fn);
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen())
{
Bfree(testfn);
return fp;
}
}
Bfree(testfn);
return origfp;
}
#endif
END_RR_NS

View file

@ -8,7 +8,6 @@
#define EDUKE32_COMMON_GAME_H_
#include "collections.h"
#include "grpscan.h"
#include "gamecontrol.h"
BEGIN_RR_NS
@ -70,9 +69,6 @@ extern void G_LoadLookups(void);
//////////
# define FORMAT_UPGRADE_ELIGIBLE
extern FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic);
END_RR_NS
#endif

View file

@ -6203,21 +6203,6 @@ void G_HandleLocalKeys(void)
Demo_PrepareWarp();
}
#if 0
// Enter a game from within a demo.
if (KB_KeyPressed(sc_Return) && ud.multimode==1)
{
KB_ClearKeyDown(sc_Return);
g_demo_cnt = g_demo_goalCnt = ud.reccnt = ud.pause_on = ud.recstat = ud.m_recstat = 0;
// XXX: probably redundant; this stuff needs an API anyway:
kclose(g_demo_recFilePtr); g_demo_recFilePtr = -1;
g_player[myconnectindex].ps->gm = MODE_GAME;
ready2send=1; // TODO: research this weird variable
screenpeek=myconnectindex;
// g_demo_paused=0;
}
#endif
}
if (SHIFTS_IS_PRESSED || ALT_IS_PRESSED || WIN_IS_PRESSED)
@ -7099,9 +7084,7 @@ void G_Shutdown(void)
G_SetFog(0);
engineUnInit();
G_Cleanup();
FreeGroups();
OSD_Cleanup();
uninitgroupfile();
Bfflush(NULL);
}

View file

@ -778,7 +778,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
static void C_Include(const char *confile)
{
auto fp = kopenFileReader(confile,g_loadFromGroupOnly);
auto fp = kopenFileReader(confile,0);
if (!fp.isOpen())
{
@ -829,16 +829,6 @@ static void C_Include(const char *confile)
Bfree(mptr);
}
#ifdef _WIN32
static void check_filename_case(const char *fn)
{
// WTF?!?
testkopen(fn, g_loadFromGroupOnly);
}
#else
static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); }
#endif
void G_DoGameStartup(const int32_t *params)
{
int j = 0;
@ -898,7 +888,6 @@ void C_DefineMusic(int volumeNum, int levelNum, const char *fileName)
Bfree(pMapInfo->musicfn);
pMapInfo->musicfn = dup_filename(fileName);
check_filename_case(pMapInfo->musicfn);
}
void C_DefineVolumeFlags(int32_t vol, int32_t flags)
@ -2160,8 +2149,6 @@ static int32_t C_ParseCommand(int32_t loop)
}
g_sounds[k].filename[i] = '\0';
check_filename_case(g_sounds[k].filename);
C_GetNextValue(LABEL_DEFINE);
g_sounds[k].ps = *(g_scriptPtr-1);
C_GetNextValue(LABEL_DEFINE);
@ -2375,7 +2362,7 @@ void C_Compile(const char *fileName)
C_InitHashes();
auto kFile = kopenFileReader(fileName,g_loadFromGroupOnly);
auto kFile = kopenFileReader(fileName,0);
if (!kFile.isOpen())
{

View file

@ -1,544 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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 the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "compat.h"
#include "baselayer.h"
#include "scriptfile.h"
#include "cache1d.h"
#include "crc32_.h"
#include "duke3d.h"
#include "common_game.h"
#include "grpscan.h"
BEGIN_RR_NS
//static void process_vaca13(int32_t crcval);
static void process_vacapp15(int32_t crcval);
// custom GRP support for the startup window, file format reflects the structure below
#define GAMELISTFILE "games.list"
// name crc size flags dependency scriptname postprocessing
static internalgrpinfo_t const internalgrpfiles[] =
{
//{ "Duke Nukem 3D", DUKE13_CRC, 26524524, GAMEFLAG_DUKE, 0, NULL, NULL},
//{ "Duke Nukem 3D (South Korean Censored)", DUKEKR_CRC, 26385383, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D: Atomic Edition", DUKE15_CRC, 44356548, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D: Atomic Edition (WT)", DUKEWT_CRC, 44356548, GAMEFLAG_DUKE, 0, NULL, NULL},
{ "Duke Nukem 3D: Plutonium Pak", DUKEPP_CRC, 44348015, GAMEFLAG_DUKE, 0, NULL, NULL},
//{ "Duke Nukem 3D Shareware 0.99", DUKE099_CRC, 9690241, GAMEFLAG_DUKE|GAMEFLAG_DUKEBETA, 0, NULL, NULL},
//{ "Duke Nukem 3D Shareware 1.0", DUKE10_CRC, 10429258, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
//{ "Duke Nukem 3D Shareware 1.1", DUKE11_CRC, 10442980, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
//{ "Duke Nukem 3D Shareware 1.3D", DUKESW_CRC, 11035779, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
//{ "Duke Nukem 3D Mac Demo", DUKEMD_CRC, 10444391, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL},
//{ "Duke Nukem 3D MacUser Demo", DUKEMD2_CRC, 10628573, GAMEFLAG_DUKE|GAMEFLAG_SHAREWARE, 0, NULL, NULL },
//{ "Duke it out in D.C. (1.3D)", DUKEDC13_CRC, 7926624, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE13_CRC, NULL, NULL},
{ "Duke it out in D.C.", DUKEDCPP_CRC, 8225517, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, NULL},
{ "Duke it out in D.C.", DUKEDC_CRC, 8410183, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, NULL},
{ "Duke it out in D.C.", (int32_t) 0x39A692BF, 8410187, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "DUKEDC.CON", NULL},
//{ "Duke Caribbean: Life's a Beach (1.3D)", VACA13_CRC, 23559381, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE13_CRC, NULL, process_vaca13},
{ "Duke Caribbean: Life's a Beach (PPak)", VACAPP_CRC, 22551333, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKEPP_CRC, NULL, process_vacapp15},
{ "Duke Caribbean: Life's a Beach", VACA15_CRC, 22521880, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, process_vacapp15},
{ "Duke Caribbean: Life's a Beach", DUKECB_CRC, 22213819, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, NULL, NULL},
{ "Duke Caribbean: Life's a Beach", (int32_t) 0x65B5F690, 22397273, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "VACATION.CON", NULL},
{ "Duke: Nuclear Winter", DUKENW_CRC, 16169365, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "NWINTER.CON", NULL},
{ "Duke: Nuclear Winter Demo", (int32_t) 0xC7EFBFA9, 10965909, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "NWINTER.CON", NULL},
// { "Duke!ZONE II (1.3D)", DZ2_13_CRC, 26135388, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE13_CRC, "DZ-GAME.CON", NULL},
{ "Duke!ZONE II", DZ2_PP_CRC, 44100411, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "DZ-GAME.CON", NULL},
{ "Duke!ZONE II", (int32_t) 0x1E9516F1, 3186656, GAMEFLAG_DUKE|GAMEFLAG_ADDON, DUKE15_CRC, "DZ-GAME.CON", NULL},
{ "NAM", NAM_CRC, 43448927, GAMEFLAG_NAM, 0, NULL, NULL},
{ "NAPALM", NAPALM_CRC, 44365728, GAMEFLAG_NAM|GAMEFLAG_NAPALM, 0, NULL, NULL},
//{ "WWII GI", WW2GI_CRC, 77939508, GAMEFLAG_WW2GI, 0, NULL, NULL},
//{ "Platoon Leader", PLATOONL_CRC, 37852572, GAMEFLAG_WW2GI|GAMEFLAG_ADDON, WW2GI_CRC, "PLATOONL.DEF", NULL},
{ "Redneck Rampage", RR_CRC, 141174222, GAMEFLAG_RR, 0, NULL, NULL },
{ "Redneck Rampage: Rides Again", RRRA_CRC, 191798609, GAMEFLAG_RR|GAMEFLAG_RRRA, 0, NULL, NULL },
};
struct grpfile_t *foundgrps = NULL;
struct grpinfo_t *listgrps = NULL;
static void LoadList(const char * filename)
{
scriptfile *script = scriptfile_fromfile(filename);
if (!script)
return;
scriptfile_addsymbolvalue("GAMEFLAG_DUKE", GAMEFLAG_DUKE);
scriptfile_addsymbolvalue("GAMEFLAG_ADDON", GAMEFLAG_DUKE|GAMEFLAG_ADDON);
scriptfile_addsymbolvalue("GAMEFLAG_NAM", GAMEFLAG_NAM);
scriptfile_addsymbolvalue("GAMEFLAG_NAPALM", GAMEFLAG_NAM|GAMEFLAG_NAPALM);
scriptfile_addsymbolvalue("GAMEFLAG_RR", GAMEFLAG_RR);
scriptfile_addsymbolvalue("GAMEFLAG_RRRA", GAMEFLAG_RR|GAMEFLAG_RRRA);
scriptfile_addsymbolvalue("DUKE15_CRC", DUKE15_CRC);
scriptfile_addsymbolvalue("DUKEPP_CRC", DUKEPP_CRC);
scriptfile_addsymbolvalue("DUKE13_CRC", DUKE13_CRC);
scriptfile_addsymbolvalue("DUKEDC13_CRC", DUKEDC13_CRC);
scriptfile_addsymbolvalue("DUKEDCPP_CRC", DUKEDCPP_CRC);
scriptfile_addsymbolvalue("DUKEDC_CRC", DUKEDC_CRC);
scriptfile_addsymbolvalue("VACA13_CRC", VACA13_CRC);
scriptfile_addsymbolvalue("VACAPP_CRC", VACAPP_CRC);
scriptfile_addsymbolvalue("VACA15_CRC", VACA15_CRC);
scriptfile_addsymbolvalue("DUKECB_CRC", DUKECB_CRC);
scriptfile_addsymbolvalue("DUKENW_CRC", DUKENW_CRC);
scriptfile_addsymbolvalue("DZ2_13_CRC", DZ2_13_CRC);
scriptfile_addsymbolvalue("DZ2_PP_CRC", DZ2_PP_CRC);
scriptfile_addsymbolvalue("NAM_CRC", NAM_CRC);
scriptfile_addsymbolvalue("NAPALM_CRC", NAPALM_CRC);
scriptfile_addsymbolvalue("WW2GI_CRC", WW2GI_CRC);
while (!scriptfile_eof(script))
{
enum
{
T_GRPINFO,
T_GAMENAME,
T_CRC,
T_SIZE,
T_DEPCRC,
T_SCRIPTNAME,
T_DEFNAME,
T_FLAGS,
T_RTSNAME,
};
static const tokenlist profiletokens[] =
{
{ "grpinfo", T_GRPINFO },
};
int32_t token = getatoken(script,profiletokens,ARRAY_SIZE(profiletokens));
switch (token)
{
case T_GRPINFO:
{
int32_t gsize = 0, gcrcval = 0, gflags = GAMEFLAG_DUKE, gdepcrc = DUKE15_CRC;
char *gname = NULL, *gscript = NULL, *gdef = NULL;
char *grts = NULL;
char *grpend = NULL;
static const tokenlist grpinfotokens[] =
{
{ "name", T_GAMENAME },
{ "scriptname", T_SCRIPTNAME },
{ "defname", T_DEFNAME },
{ "rtsname", T_RTSNAME },
{ "crc", T_CRC },
{ "dependency", T_DEPCRC },
{ "size", T_SIZE },
{ "flags", T_FLAGS },
};
if (scriptfile_getbraces(script,&grpend)) break;
while (script->textptr < grpend)
{
int32_t token = getatoken(script,grpinfotokens,ARRAY_SIZE(grpinfotokens));
switch (token)
{
case T_GAMENAME:
scriptfile_getstring(script,&gname); break;
case T_SCRIPTNAME:
scriptfile_getstring(script,&gscript); break;
case T_DEFNAME:
scriptfile_getstring(script,&gdef); break;
case T_RTSNAME:
scriptfile_getstring(script,&grts); break;
case T_FLAGS:
scriptfile_getsymbol(script,&gflags); gflags &= GAMEFLAGMASK; break;
case T_DEPCRC:
scriptfile_getsymbol(script,&gdepcrc); break;
case T_CRC:
scriptfile_getsymbol(script,&gcrcval); break;
case T_SIZE:
scriptfile_getnumber(script,&gsize); break;
default:
break;
}
grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
fg->next = listgrps;
listgrps = fg;
if (gname)
fg->name = Xstrdup(gname);
fg->size = gsize;
fg->crcval = gcrcval;
fg->dependency = gdepcrc;
fg->game = gflags;
if (gscript)
fg->scriptname = dup_filename(gscript);
if (gdef)
fg->defname = dup_filename(gdef);
if (grts)
fg->rtsname = dup_filename(grts);
}
break;
}
default:
break;
}
}
scriptfile_close(script);
scriptfile_clearsymbols();
}
static void LoadGameList(void)
{
for (size_t i = 0; i < ARRAY_SIZE(internalgrpfiles); i++)
{
grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
fg->name = Xstrdup(internalgrpfiles[i].name);
fg->crcval = internalgrpfiles[i].crcval;
fg->size = internalgrpfiles[i].size;
fg->game = internalgrpfiles[i].game;
fg->dependency = internalgrpfiles[i].dependency;
if (internalgrpfiles[i].scriptname)
fg->scriptname = dup_filename(internalgrpfiles[i].scriptname);
fg->postprocessing = internalgrpfiles[i].postprocessing;
fg->next = listgrps;
listgrps = fg;
}
CACHE1D_FIND_REC * const srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE);
for (CACHE1D_FIND_REC *sidx = srch; sidx; sidx = sidx->next)
LoadList(sidx->name);
klistfree(srch);
}
static void FreeGameList(void)
{
while (listgrps)
{
Bfree(listgrps->name);
Bfree(listgrps->scriptname);
Bfree(listgrps->defname);
Bfree(listgrps->rtsname);
grpinfo_t * const fg = listgrps->next;
Bfree(listgrps);
listgrps = fg;
}
}
#define GRPCACHEFILE "grpfiles.cache"
static struct grpcache
{
struct grpcache *next;
int32_t size;
int32_t mtime;
int32_t crcval;
char name[BMAX_PATH];
}
*grpcache = NULL, *usedgrpcache = NULL;
static int32_t LoadGroupsCache(void)
{
struct grpcache *fg;
int32_t fsize, fmtime, fcrcval;
char *fname;
scriptfile *script;
script = scriptfile_fromfile(GRPCACHEFILE);
if (!script) return -1;
while (!scriptfile_eof(script))
{
if (scriptfile_getstring(script, &fname)) break; // filename
if (scriptfile_getnumber(script, &fsize)) break; // filesize
if (scriptfile_getnumber(script, &fmtime)) break; // modification time
if (scriptfile_getnumber(script, &fcrcval)) break; // crc checksum
fg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
fg->next = grpcache;
grpcache = fg;
Bstrncpy(fg->name, fname, BMAX_PATH);
fg->size = fsize;
fg->mtime = fmtime;
fg->crcval = fcrcval;
}
scriptfile_close(script);
return 0;
}
static void FreeGroupsCache(void)
{
while (grpcache)
{
struct grpcache * const fg = grpcache->next;
Bfree(grpcache);
grpcache = fg;
}
}
static void RemoveGroup(grpfile_t *igrp)
{
for (grpfile_t *prev = NULL, *grp = foundgrps; grp; grp=grp->next)
{
if (grp == igrp)
{
if (grp == foundgrps)
foundgrps = grp->next;
else
prev->next = grp->next;
Bfree((char *)grp->filename);
Bfree(grp);
return;
}
prev = grp;
}
}
grpfile_t * FindGroup(int32_t crcval)
{
grpfile_t *grp;
for (grp = foundgrps; grp; grp=grp->next)
{
if (grp->type->crcval == crcval)
return grp;
}
return NULL;
}
static grpinfo_t const * FindGrpInfo(int32_t crcval, int32_t size)
{
grpinfo_t *grpinfo;
for (grpinfo = listgrps; grpinfo; grpinfo=grpinfo->next)
{
if (grpinfo->crcval == crcval && grpinfo->size == size)
return grpinfo;
}
return NULL;
}
static void ProcessGroups(CACHE1D_FIND_REC *srch)
{
CACHE1D_FIND_REC *sidx;
struct grpcache *fg, *fgg;
char *fn;
struct Bstat st;
#define BUFFER_SIZE (1024 * 1024 * 8)
uint8_t *buf = (uint8_t *)Xmalloc(BUFFER_SIZE);
for (sidx = srch; sidx; sidx = sidx->next)
{
for (fg = grpcache; fg; fg = fg->next)
{
if (!Bstrcmp(fg->name, sidx->name)) break;
}
if (fg)
{
if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename
if (Bstat(fn, &st))
{
Bfree(fn);
continue;
} // failed to stat the file
Bfree(fn);
if (fg->size == (int32_t)st.st_size && fg->mtime == (int32_t)st.st_mtime)
{
grpinfo_t const * const grptype = FindGrpInfo(fg->crcval, fg->size);
if (grptype)
{
grpfile_t * const grp = (grpfile_t *)Xcalloc(1, sizeof(grpfile_t));
grp->filename = Xstrdup(sidx->name);
grp->type = grptype;
grp->next = foundgrps;
foundgrps = grp;
}
fgg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
strcpy(fgg->name, fg->name);
fgg->size = fg->size;
fgg->mtime = fg->mtime;
fgg->crcval = fg->crcval;
fgg->next = usedgrpcache;
usedgrpcache = fgg;
continue;
}
}
{
int32_t b, fh;
int32_t crcval = 0;
fh = openfrompath(sidx->name, BO_RDONLY|BO_BINARY, BS_IREAD);
if (fh < 0) continue;
if (Bfstat(fh, &st)) continue;
initprintf(" Checksumming %s...", sidx->name);
do
{
b = read(fh, buf, BUFFER_SIZE);
if (b > 0) crcval = Bcrc32((uint8_t *)buf, b, crcval);
}
while (b == BUFFER_SIZE);
close(fh);
initprintf(" Done\n");
grpinfo_t const * const grptype = FindGrpInfo(crcval, st.st_size);
if (grptype)
{
grpfile_t * const grp = (grpfile_t *)Xcalloc(1, sizeof(grpfile_t));
grp->filename = Xstrdup(sidx->name);
grp->type = grptype;
grp->next = foundgrps;
foundgrps = grp;
}
fgg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
Bstrncpy(fgg->name, sidx->name, BMAX_PATH);
fgg->size = st.st_size;
fgg->mtime = st.st_mtime;
fgg->crcval = crcval;
fgg->next = usedgrpcache;
usedgrpcache = fgg;
}
}
Bfree(buf);
}
int32_t ScanGroups(void)
{
struct grpcache *fg, *fgg;
initprintf("Searching for game data...\n");
LoadGameList();
LoadGroupsCache();
static char const *extensions[] =
{
"*.grp",
"*.ssi",
"*.dat",
};
for (char const *extension : extensions)
{
CACHE1D_FIND_REC *srch = klistpath("/", extension, CACHE1D_FIND_FILE);
ProcessGroups(srch);
klistfree(srch);
}
FreeGroupsCache();
for (grpfile_t *grp = foundgrps; grp; grp=grp->next)
{
if (grp->type->dependency)
{
if (FindGroup(grp->type->dependency) == NULL) // couldn't find dependency
{
//initprintf("removing %s\n", grp->name);
RemoveGroup(grp);
grp = foundgrps;
// start from the beginning so we can remove anything that depended on this grp
continue;
}
}
}
if (usedgrpcache)
{
int32_t i = 0;
FILE *fp;
fp = fopen(GRPCACHEFILE, "wt");
if (fp)
{
for (fg = usedgrpcache; fg; fg=fgg)
{
fgg = fg->next;
fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
Bfree(fg);
i++;
}
fclose(fp);
}
// initprintf("Found %d recognized GRP %s.\n",i,i>1?"files":"file");
return 0;
}
initprintf("Found no recognized game data!\n");
return 0;
}
void FreeGroups(void)
{
while (foundgrps)
{
Bfree((char *)foundgrps->filename);
grpfile_t * const fg = foundgrps->next;
Bfree(foundgrps);
foundgrps = fg;
}
FreeGameList();
}
static void process_vacapp15(int32_t crcval)
{
krename(crcval, 5, "DEFS.CON");
krename(crcval, 6, "GAME.CON");
krename(crcval, 7, "USER.CON");
krename(crcval, 8, "DEMO1.DMO");
krename(crcval, 9, "DEMO2.DMO");
krename(crcval, 10, "DEMO3.DMO");
initgroupfile("VACATION.PRG");
}
END_RR_NS

View file

@ -1,106 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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 the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#ifndef grpscan_h_
#define grpscan_h_
BEGIN_RR_NS
#define MAXLISTNAMELEN 32
// List of internally-known GRP files
#define DUKE13_CRC (int32_t)0xBBC9CE44
#define DUKEKR_CRC (int32_t)0xAA4F6A40
#define DUKE15_CRC (int32_t)0xFD3DCFF1
#define DUKEPP_CRC (int32_t)0xF514A6AC
#define DUKEWT_CRC (int32_t)0x982AFE4A
#define DUKE099_CRC (int32_t)0x02F18900
#define DUKE10_CRC (int32_t)0xA28AA589
#define DUKE11_CRC (int32_t)0x912E1E8D
#define DUKESW_CRC (int32_t)0x983AD923
#define DUKEMD_CRC (int32_t)0xC5F71561
#define DUKEMD2_CRC (int32_t)0x73A15EE7
#define DUKEDC13_CRC (int32_t)0xA9242158
#define DUKEDCPP_CRC (int32_t)0xB79D997F
#define DUKEDC_CRC (int32_t)0xA8CF80DA
#define VACA13_CRC (int32_t)0x4A2DBB62
#define VACAPP_CRC (int32_t)0x2F4FCCEE
#define VACA15_CRC (int32_t)0xB62B42FD
#define DUKECB_CRC (int32_t)0x18F01C5B
#define DUKENW_CRC (int32_t)0xF1CAE8E4
#define DZ2_13_CRC (int32_t)0x82C1B47F
#define DZ2_PP_CRC (int32_t)0x7FB6117C
#define NAM_CRC (int32_t)0x75C1F07B
#define NAPALM_CRC (int32_t)0x3DE1589A
#define WW2GI_CRC (int32_t)0x907B82BF
#define PLATOONL_CRC (int32_t)0xD1ED8C0C
#define RR_CRC (int32_t)0x19D9BC79
#define RRRA_CRC (int32_t)0x958018C6
enum addon_t {
ADDON_NONE,
ADDON_DUKEDC,
ADDON_NWINTER,
ADDON_CARIBBEAN,
NUMADDONS
};
typedef struct internalgrpinfo_t {
char const *name;
int32_t const crcval;
int32_t const size;
int32_t const game;
int32_t const dependency;
char const *scriptname;
void(*postprocessing)(int32_t);
} internalgrpinfo_t;
typedef struct grpinfo_t {
char *name;
int32_t crcval;
int32_t size;
int32_t game;
int32_t dependency;
char *scriptname;
char *defname;
char *rtsname;
void (*postprocessing)(int32_t);
struct grpinfo_t *next;
} grpinfo_t;
typedef struct grpfile_t {
char *filename;
struct grpinfo_t const *type;
struct grpfile_t *next;
} grpfile_t;
extern grpfile_t *foundgrps;
extern grpinfo_t *listgrps;
extern grpfile_t * FindGroup(int32_t crcval);
int32_t ScanGroups(void);
void FreeGroups(void);
END_RR_NS
#endif

View file

@ -6085,8 +6085,6 @@ static void Menu_Run(Menu_t *cm, const vec2_t origin)
if (dir == object->findhigh[i] && object->currentList == i)
status |= MT_Selected;
// pal = dir->source==CACHE1D_SOURCE_ZIP ? 8 : 2
Menu_Run_AbbreviateNameIntoBuffer(dir->name, USERMAPENTRYLENGTH);
const int32_t thisx = object->format[i]->pos.x;

View file

@ -575,16 +575,6 @@ static int osdcmd_spawn(osdcmdptr_t parm)
return OSDCMD_OK;
}
static int osdcmd_initgroupfile(osdcmdptr_t parm)
{
if (parm->numparms != 1)
return OSDCMD_SHOWHELP;
initgroupfile(parm->parms[0]);
return OSDCMD_OK;
}
static int osdcmd_cmenu(osdcmdptr_t parm)
{
if (parm->numparms != 1)
@ -996,7 +986,6 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
#ifdef DEBUGGINGAIDS
OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer);
#endif

View file

@ -725,7 +725,7 @@ static int32_t readspecdata(const dataspec_t *spec, FileReader *fil, uint8_t **d
OSD_Printf("rsd: spec=%s, idx=%d:\n", (char *)sptr->ptr, (int32_t)(spec-sptr));
if (ksiz!=siz)
OSD_Printf(" kread returned %d, expected %d.\n", ksiz, siz);
OSD_Printf(" file read returned %d, expected %d.\n", ksiz, siz);
else
OSD_Printf(" sp->ptr and cmpstrbuf not identical!\n");

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h"
#include "renderlayer.h" // for win_gethwnd()
#include "openaudio.h"
#include <atomic>
BEGIN_RR_NS
@ -432,7 +433,7 @@ int32_t S_LoadSound(int num)
auto &snd = g_sounds[num];
auto fp = S_OpenAudio(snd.filename, g_loadFromGroupOnly, 0);
auto fp = S_OpenAudio(snd.filename, 0, 0);
if (!fp.isOpen())
{

View file

@ -51,7 +51,6 @@ set( PCH_SOURCES
src/game.cpp
src/girlninj.cpp
src/goro.cpp
src/grpscan.cpp
src/hornet.cpp
src/interp.cpp
src/interpsh.cpp

View file

@ -677,7 +677,6 @@ TerminateGame(void)
if (CleanExit)
DosScreen();
uninitgroupfile();
}
void
@ -779,7 +778,6 @@ void MultiSharewareCheck(void)
engineUnInit();
UnInitSound();
timerUninit();
uninitgroupfile();
Bexit(0);
}
}
@ -1859,8 +1857,8 @@ TenScreen(void)
if ((fin = k open4load("ten.pal", 0)) != -1)
{
kread(fin, pal, PAL_SIZE);
kclose(fin);
k read(fin, pal, PAL_SIZE);
k close(fin);
}
// palette to black
@ -1912,24 +1910,10 @@ TitleLevel(void)
tempbuf[i] = i;
palookup[0] = tempbuf;
//GetPaletteFromVESA(pal);
//memcpy(backup_pal, pal, PAL_SIZE);
videoClearViewableArea(0L);
videoNextPage();
// if ((fin = k open4load("title.pal", 0)) != -1)
// {
// kread(fin, pal, PAL_SIZE);
// kclose(fin);
// SetPaletteToVESA(pal);
// }
// clearview(0);
// nextpage();
//FadeOut(0, 0);
ready2send = 0;
ready2send = 0;
totalclock = 0;
ototalclock = 0;
@ -3101,28 +3085,6 @@ void swexit(int exitval)
void DosScreen(void)
{
#if 0
#ifdef SW_SHAREWARE
#define DOS_SCREEN_NAME "SHADSW.BIN"
#else
#define DOS_SCREEN_NAME "SWREG.BIN"
#endif
#define DOS_SCREEN_SIZE (4000-(80*2))
#define DOS_SCREEN_PTR ((void *)(0xB8000))
int i;
char buffer[DOS_SCREEN_SIZE];
fin = k open4load(DOS_SCREEN_NAME,0);
if (fin == -1)
return;
kread(fin, buffer, sizeof(buffer));
memcpy(DOS_SCREEN_PTR, buffer, DOS_SCREEN_SIZE);
kclose(fin);
move_cursor(23,0);
_displaycursor(_GCURSORON);
#endif
}
#if 0 //PLOCK_VERSION

View file

@ -1,217 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2007 Jonathon Fowler <jf@jonof.id.au>
This file is part of JFShadowWarrior
Shadow Warrior 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 the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "build.h"
#include "baselayer.h"
#include "scriptfile.h"
#include "cache1d.h"
#include "crc32_.h"
#include "grpscan.h"
BEGIN_SW_NS
internalgrpfile grpfiles[numgrpfiles] =
{
{ "Registered Version", 0x7545319Fu, 47536148 },
{ "Shareware Version", 0x08A7FA1Fu, 26056769 },
{ "Wanton Destruction (Addon)", 0xA9AAA7B7u, 48698128 },
};
grpfile *foundgrps = NULL;
#define GRPCACHEFILE "grpfiles.cache"
static struct grpcache
{
struct grpcache *next;
char name[BMAX_PATH+1];
int size;
int mtime;
unsigned int crcval;
} *grpcache = NULL, *usedgrpcache = NULL;
static int LoadGroupsCache(void)
{
struct grpcache *fg;
int fsize, fmtime, fcrcval;
char *fname;
scriptfile *script;
script = scriptfile_fromfile(GRPCACHEFILE);
if (!script) return -1;
while (!scriptfile_eof(script))
{
if (scriptfile_getstring(script, &fname)) break; // filename
if (scriptfile_getnumber(script, &fsize)) break; // filesize
if (scriptfile_getnumber(script, &fmtime)) break; // modification time
if (scriptfile_getnumber(script, &fcrcval)) break; // crc checksum
fg = (struct grpcache*)calloc(1, sizeof(struct grpcache));
fg->next = grpcache;
grpcache = fg;
strncpy(fg->name, fname, BMAX_PATH);
fg->size = fsize;
fg->mtime = fmtime;
fg->crcval = fcrcval;
}
scriptfile_close(script);
return 0;
}
static void FreeGroupsCache(void)
{
struct grpcache *fg;
while (grpcache)
{
fg = grpcache->next;
free(grpcache);
grpcache = fg;
}
}
int ScanGroups(void)
{
CACHE1D_FIND_REC *srch, *sidx;
struct grpcache *fg, *fgg;
struct grpfile *grp;
char *fn;
struct Bstat st;
buildputs("Scanning for GRP files...\n");
LoadGroupsCache();
srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE);
for (sidx = srch; sidx; sidx = sidx->next)
{
for (fg = grpcache; fg; fg = fg->next)
{
if (!Bstrcmp(fg->name, sidx->name)) break;
}
if (fg)
{
if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename
if (Bstat(fn, &st)) { free(fn); continue; } // failed to stat the file
free(fn);
if (fg->size == st.st_size && fg->mtime == st.st_mtime)
{
grp = (struct grpfile *)calloc(1, sizeof(struct grpfile));
grp->name = strdup(sidx->name);
grp->crcval = fg->crcval;
grp->size = fg->size;
grp->next = foundgrps;
foundgrps = grp;
fgg = (struct grpcache *)calloc(1, sizeof(struct grpcache));
strcpy(fgg->name, fg->name);
fgg->size = fg->size;
fgg->mtime = fg->mtime;
fgg->crcval = fg->crcval;
fgg->next = usedgrpcache;
usedgrpcache = fgg;
continue;
}
}
{
int b, fh;
unsigned int crcval = 0;
unsigned char buf[16*512];
fh = openfrompath(sidx->name, BO_RDONLY|BO_BINARY, BS_IREAD);
if (fh < 0) continue;
if (fstat(fh, &st)) continue;
buildprintf(" Checksumming %s...", sidx->name);
do
{
b = read(fh, buf, sizeof(buf));
if (b > 0) crcval = Bcrc32(buf, b, crcval);
}
while (b == sizeof(buf));
close(fh);
buildputs(" Done\n");
grp = (struct grpfile *)calloc(1, sizeof(struct grpfile));
grp->name = strdup(sidx->name);
grp->crcval = crcval;
grp->size = st.st_size;
grp->next = foundgrps;
foundgrps = grp;
fgg = (struct grpcache *)calloc(1, sizeof(struct grpcache));
strncpy(fgg->name, sidx->name, BMAX_PATH);
fgg->size = st.st_size;
fgg->mtime = st.st_mtime;
fgg->crcval = crcval;
fgg->next = usedgrpcache;
usedgrpcache = fgg;
}
}
klistfree(srch);
FreeGroupsCache();
if (usedgrpcache)
{
FILE *fp;
fp = fopen(GRPCACHEFILE, "wt");
if (fp)
{
for (fg = usedgrpcache; fg; fg=fgg)
{
fgg = fg->next;
fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
free(fg);
}
fclose(fp);
}
}
return 0;
}
void FreeGroups(void)
{
struct grpfile *fg;
while (foundgrps)
{
fg = foundgrps->next;
free(foundgrps->name);
free(foundgrps);
foundgrps = fg;
}
}
END_SW_NS

View file

@ -1,53 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2007 Jonathon Fowler <jf@jonof.id.au>
This file is part of JFShadowWarrior
Shadow Warrior 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 the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#ifndef grpscan_h__
#define grpscan_h__
BEGIN_SW_NS
// List of internally-known GRP files
#define numgrpfiles 3
struct internalgrpfile
{
const char *name;
unsigned int crcval;
int size;
};
struct grpfile
{
char *name;
unsigned int crcval;
int size;
struct grpfile *next;
};
extern internalgrpfile grpfiles[numgrpfiles];
extern grpfile *foundgrps;
int ScanGroups(void);
void FreeGroups(void);
END_SW_NS
#endif

View file

@ -268,8 +268,6 @@ grpinfo
name "NAM"
size 43448927
crc NAM_CRC
defname "nam.def" //, "napalm.def"
//scriptname "nam.con", "napalm.con"
flags GAMEFLAG_NAM
dependency 0
gamefilter "Nam.Nam"
@ -280,8 +278,6 @@ grpinfo
name "NAPALM"
size 44365728
crc NAPALM_CRC
defname "napalm.def" //, "nam.def"
//scriptname "napalm.con", "nam.con"
flags GAMEFLAG_NAM|GAMEFLAG_NAPALM
dependency 0
gamefilter "Nam.Napalm"
@ -292,8 +288,6 @@ grpinfo
name "WWII GI"
size 77939508
crc WW2GI_CRC
defname "ww2gi.def"
//scriptname "ww2gi.con"
flags GAMEFLAG_WW2GI
dependency 0
gamefilter "WW2GI.WW2GI"
@ -335,13 +329,12 @@ grpinfo
grpinfo
{
name "Redneck Rampage: Suckin' Grits on Route 66"
crc 0x30C49F26 // tests carnival.map
size 234898
loaddirectory "CARNIVAL.MAP"
loaddirectory
scriptname "GAME66.CON"
mustcontain "TILESA66.ART", "TILESB66.ART", "CARNIVAL.MAP", "TRUCKSTP.MAP", "GAME66.CON"
flags GAMEFLAG_RR|GAMEFLAG_ADDON
dependency RR_CRC
loadart "TILESA66.ART", "TILESB66.ART"
loadart "TILESA66.ART", "TILESB66.ART" // replaces TILES009 and TILES023.
gamefilter "Redneck.Route66"
}
@ -361,13 +354,12 @@ grpinfo
grpinfo
{
name "BLOOD: Cryptic Passage"
crc 0x2144DF1C // tests CP01.MAP
size 327015
loaddirectory "CP01.MAP"
loaddirectory
scriptname "CRYPTIC.INI"
mustcontain "CRYPTIC.INI", "CP01.MAP", "CP02.MAP"
flags GAMEFLAG_BLOOD|GAMEFLAG_ADDON
dependency BLOOD_CRC
loadart "CPART07.AR_", "CPART15.AR_"
loadart "CPART07.AR_", "CPART15.AR_" // some versions have these file names, some have the real ones instead so these must be listed but cannot be used for checking.
gamefilter "Blood.Cryptic"
}