mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Restructure the GRP scanning functionality. Outwardly, this allows GRP selections with special handling (the add-ons and NAM) to function properly when the Windows or GTK startup windows do not run, namely with the OS X startup window, and using the -gamegrp command line parameter on any other platform, or on all of the both under dedicated server mode,
git-svn-id: https://svn.eduke32.com/eduke32@5103 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5c5019d9d8
commit
fe17d41b14
11 changed files with 177 additions and 306 deletions
|
@ -19,15 +19,10 @@
|
|||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
struct grpfile *p;
|
||||
|
||||
list = [[NSMutableArray alloc] init];
|
||||
|
||||
for (p = foundgrps; p; p=p->next) {
|
||||
struct grpfile const * const group = GetInternalGroup(p->crcval);
|
||||
if (group == NULL)
|
||||
continue;
|
||||
[list addObject:[[GrpFile alloc] initWithGrpfile:p andName:[NSString stringWithCString:group->name encoding:NSUTF8StringEncoding]]];
|
||||
for (grpfile_t const *p = foundgrps; p; p=p->next) {
|
||||
[list addObject:[[GrpFile alloc] initWithGrpfile:p]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,14 @@
|
|||
|
||||
@interface GrpFile : NSObject
|
||||
{
|
||||
NSString *name;
|
||||
struct grpfile *fg;
|
||||
NSString *namestring;
|
||||
NSString *grpnamestring;
|
||||
grpfile_t const *fg;
|
||||
}
|
||||
- (id)initWithGrpfile:(struct grpfile *)grpfile andName:(NSString*)aName;
|
||||
- (id)initWithGrpfile:(grpfile_t const *)grpfile;
|
||||
- (void)dealloc;
|
||||
- (NSString *)name;
|
||||
- (NSString *)grpname;
|
||||
- (struct grpfile *)entryptr;
|
||||
- (grpfile_t const *)entryptr;
|
||||
@end
|
||||
|
||||
|
|
|
@ -10,30 +10,33 @@
|
|||
#include "GrpFile.game.h"
|
||||
|
||||
@implementation GrpFile
|
||||
- (id)initWithGrpfile:(struct grpfile *)grpfile andName:(NSString*)aName
|
||||
- (id)initWithGrpfile:(grpfile_t const *)grpfile
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
fg = grpfile;
|
||||
name = aName;
|
||||
[aName retain];
|
||||
namestring = [NSString stringWithCString:fg->type->name encoding:NSUTF8StringEncoding];
|
||||
[namestring retain];
|
||||
grpnamestring = [NSString stringWithCString:fg->filename encoding:NSUTF8StringEncoding];
|
||||
[grpnamestring retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
[name release];
|
||||
[namestring release];
|
||||
[grpnamestring release];
|
||||
[super dealloc];
|
||||
}
|
||||
- (NSString *)name
|
||||
{
|
||||
return name;
|
||||
return namestring;
|
||||
}
|
||||
- (NSString *)grpname
|
||||
{
|
||||
return [NSString stringWithCString:(fg->name) encoding:NSUTF8StringEncoding];
|
||||
return grpnamestring;
|
||||
}
|
||||
- (struct grpfile *)entryptr
|
||||
- (grpfile_t const *)entryptr
|
||||
{
|
||||
return fg;
|
||||
}
|
||||
|
|
|
@ -22,12 +22,11 @@
|
|||
#include "common.h"
|
||||
#include "common_game.h"
|
||||
|
||||
struct grpfile_t const *g_selectedGrp;
|
||||
|
||||
int32_t g_gameType = GAMEFLAG_DUKE;
|
||||
|
||||
int32_t g_dependencyCRC = 0;
|
||||
int32_t g_groupCRC;
|
||||
int32_t g_usingAddon = 0;
|
||||
void (*g_postprocessing)(int32_t);
|
||||
|
||||
// g_gameNamePtr can point to one of: grpfiles[].name (string literal), string
|
||||
// literal, malloc'd block (XXX: possible leak)
|
||||
|
@ -374,40 +373,46 @@ void G_ScanGroups(void)
|
|||
{
|
||||
ScanGroups();
|
||||
|
||||
// try and identify the 'defaultgamegrp' in the set of GRPs.
|
||||
// if it is found, set up the environment accordingly for the game it represents.
|
||||
// if it is not found, choose the first GRP from the list
|
||||
struct grpfile *fg, *first = NULL;
|
||||
g_selectedGrp = NULL;
|
||||
|
||||
for (fg = foundgrps; fg; fg=fg->next)
|
||||
char const * const currentGrp = G_GrpFile();
|
||||
|
||||
for (grpfile_t const *fg = foundgrps; fg; fg=fg->next)
|
||||
{
|
||||
struct grpfile *grp;
|
||||
for (grp = listgrps; grp; grp=grp->next)
|
||||
if (fg->crcval == grp->crcval) break;
|
||||
|
||||
if (grp == NULL)
|
||||
continue;
|
||||
|
||||
fg->game = grp->game;
|
||||
if (!first) first = fg;
|
||||
if (!Bstrcasecmp(fg->name, G_DefaultGrpFile()))
|
||||
if (!Bstrcasecmp(fg->filename, currentGrp))
|
||||
{
|
||||
g_gameType = grp->game;
|
||||
g_gameNamePtr = grp->name;
|
||||
g_selectedGrp = fg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fg && first)
|
||||
{
|
||||
if (g_grpNamePtr == NULL)
|
||||
{
|
||||
clearGrpNamePtr();
|
||||
g_grpNamePtr = dup_filename(first->name);
|
||||
}
|
||||
g_gameType = first->game;
|
||||
g_gameNamePtr = listgrps->name;
|
||||
}
|
||||
else if (!fg) g_gameNamePtr = NULL;
|
||||
}
|
||||
|
||||
static int32_t G_TryLoadingGrp(char const * const grpfile)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if ((i = initgroupfile(grpfile)) == -1)
|
||||
initprintf("Warning: could not find main data file \"%s\"!\n", grpfile);
|
||||
else
|
||||
initprintf("Using \"%s\" as main game data file.\n", grpfile);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int32_t G_LoadGrpDependencyChain(grpfile_t const * const grp)
|
||||
{
|
||||
if (!grp)
|
||||
return -1;
|
||||
|
||||
if (grp->type->dependency)
|
||||
G_LoadGrpDependencyChain(FindGroup(grp->type->dependency));
|
||||
|
||||
int32_t const i = G_TryLoadingGrp(grp->filename);
|
||||
|
||||
if (grp->type->postprocessing)
|
||||
grp->type->postprocessing(grp->type->crcval);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void G_LoadGroups(int32_t autoload)
|
||||
|
@ -440,28 +445,32 @@ void G_LoadGroups(int32_t autoload)
|
|||
if (g_usingAddon)
|
||||
G_LoadAddon();
|
||||
|
||||
const char *grpfile;
|
||||
int32_t i;
|
||||
const char *grpfile = G_GrpFile();
|
||||
|
||||
if (g_dependencyCRC)
|
||||
if ((i = G_LoadGrpDependencyChain(g_selectedGrp)) != -1)
|
||||
{
|
||||
struct grpfile *grp = FindGroup(g_dependencyCRC);
|
||||
if (grp)
|
||||
grpfile = g_selectedGrp->filename;
|
||||
|
||||
clearGrpNamePtr();
|
||||
g_grpNamePtr = dup_filename(grpfile);
|
||||
|
||||
grpinfo_t const * const type = g_selectedGrp->type;
|
||||
|
||||
g_gameType = type->game;
|
||||
g_gameNamePtr = type->name;
|
||||
|
||||
if (type->scriptname && g_scriptNamePtr == NULL)
|
||||
g_scriptNamePtr = dup_filename(type->scriptname);
|
||||
|
||||
if (type->defname && g_defNamePtr == NULL)
|
||||
g_defNamePtr = dup_filename(type->defname);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((i = initgroupfile(grp->name)) == -1)
|
||||
initprintf("Warning: could not find main data file \"%s\"!\n", grp->name);
|
||||
else
|
||||
initprintf("Using \"%s\" as main game data file.\n", grp->name);
|
||||
grpfile = G_GrpFile();
|
||||
i = G_TryLoadingGrp(grpfile);
|
||||
}
|
||||
}
|
||||
|
||||
if ((i = initgroupfile(grpfile)) == -1)
|
||||
initprintf("Warning: could not find main data file \"%s\"!\n", grpfile);
|
||||
else
|
||||
initprintf("Using \"%s\" as main game data file.\n", grpfile);
|
||||
|
||||
if (g_postprocessing)
|
||||
g_postprocessing(g_groupCRC);
|
||||
|
||||
if (autoload)
|
||||
{
|
||||
|
@ -560,7 +569,6 @@ const char * G_GetInstallPath(int32_t insttype)
|
|||
|
||||
static void G_LoadAddon(void)
|
||||
{
|
||||
struct grpfile * grp;
|
||||
int32_t crc = 0; // compiler-happy
|
||||
|
||||
switch (g_usingAddon)
|
||||
|
@ -578,30 +586,10 @@ static void G_LoadAddon(void)
|
|||
|
||||
if (!crc) return;
|
||||
|
||||
grp = FindGroup(crc);
|
||||
grpfile_t const * const grp = FindGroup(crc);
|
||||
|
||||
if (grp && FindGroup(DUKE15_CRC))
|
||||
{
|
||||
clearGrpNamePtr();
|
||||
g_grpNamePtr = dup_filename(FindGroup(DUKE15_CRC)->name);
|
||||
|
||||
G_AddGroup(grp->name);
|
||||
|
||||
for (grp = listgrps; grp; grp=grp->next)
|
||||
if (crc == grp->crcval) break;
|
||||
|
||||
if (grp != NULL && grp->scriptname)
|
||||
{
|
||||
clearScriptNamePtr();
|
||||
g_scriptNamePtr = dup_filename(grp->scriptname);
|
||||
}
|
||||
|
||||
if (grp != NULL && grp->defname)
|
||||
{
|
||||
clearDefNamePtr();
|
||||
g_defNamePtr = dup_filename(grp->defname);
|
||||
}
|
||||
}
|
||||
if (grp)
|
||||
g_selectedGrp = grp;
|
||||
}
|
||||
|
||||
#if defined EDUKE32_OSX || defined __linux__ || defined EDUKE32_BSD
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef EDUKE32_COMMON_GAME_H_
|
||||
#define EDUKE32_COMMON_GAME_H_
|
||||
|
||||
#include "grpscan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -23,12 +25,11 @@ extern int32_t usecwd;
|
|||
#define GAMEFLAGMASK 0x0000007F // flags allowed from grpinfo
|
||||
#define GAMEFLAG_NWINTER 0x00000080
|
||||
|
||||
extern struct grpfile_t const *g_selectedGrp;
|
||||
|
||||
extern int32_t g_gameType;
|
||||
|
||||
extern int32_t g_usingAddon;
|
||||
extern int32_t g_dependencyCRC;
|
||||
extern int32_t g_groupCRC;
|
||||
extern void (*g_postprocessing)(int32_t);
|
||||
|
||||
#define DUKE (g_gameType & GAMEFLAG_DUKE)
|
||||
#define NAM (g_gameType & GAMEFLAG_NAM)
|
||||
|
|
|
@ -11553,16 +11553,16 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
flushlogwindow = 0;
|
||||
G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad);
|
||||
// flushlogwindow = 1;
|
||||
|
||||
if (WW2GI || NAM)
|
||||
{
|
||||
Bstrcpy(GametypeNames[0],"GruntMatch (Spawn)");
|
||||
Bstrcpy(GametypeNames[2],"GruntMatch (No Spawn)");
|
||||
}
|
||||
|
||||
flushlogwindow = 0;
|
||||
G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad);
|
||||
// flushlogwindow = 1;
|
||||
|
||||
if (!usecwd)
|
||||
G_CleanupSearchPaths();
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ 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 defname postprocessing
|
||||
struct grpfile internalgrpfiles[] =
|
||||
static grpinfo_t const internalgrpfiles[] =
|
||||
{
|
||||
{ "Duke Nukem 3D", DUKE13_CRC, 26524524, GAMEFLAG_DUKE, 0, NULL, NULL, NULL, NULL },
|
||||
{ "Duke Nukem 3D (South Korean Censored)", DUKEKR_CRC, 26385383, GAMEFLAG_DUKE, 0, NULL, NULL, NULL, NULL },
|
||||
|
@ -61,24 +61,11 @@ struct grpfile internalgrpfiles[] =
|
|||
{ "WWII GI", WW2GI_CRC, 77939508, GAMEFLAG_WW2GI|GAMEFLAG_NAM, 0, NULL, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
struct grpfile const * GetInternalGroup(int32_t crcval)
|
||||
{
|
||||
for (size_t i = 0; i < ARRAY_SIZE(internalgrpfiles); i++)
|
||||
if (crcval == internalgrpfiles[i].crcval)
|
||||
return &internalgrpfiles[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct grpfile *foundgrps = NULL;
|
||||
struct grpfile *listgrps = NULL;
|
||||
struct grpfile_t *foundgrps = NULL;
|
||||
struct grpinfo_t *listgrps = NULL;
|
||||
|
||||
static void LoadList(const char * filename)
|
||||
{
|
||||
struct grpfile *fg;
|
||||
|
||||
char *grpend = NULL;
|
||||
|
||||
scriptfile *script = scriptfile_fromfile(filename);
|
||||
|
||||
if (!script)
|
||||
|
@ -130,6 +117,7 @@ static void LoadList(const char * filename)
|
|||
{
|
||||
int32_t gsize = 0, gcrcval = 0, gflags = GAMEFLAG_DUKE, gdepcrc = DUKE15_CRC;
|
||||
char *gname = NULL, *gscript = NULL, *gdef = NULL;
|
||||
char *grpend = NULL;
|
||||
|
||||
static const tokenlist grpinfotokens[] =
|
||||
{
|
||||
|
@ -170,7 +158,7 @@ static void LoadList(const char * filename)
|
|||
break;
|
||||
}
|
||||
|
||||
fg = (struct grpfile *)Xcalloc(1, sizeof(struct grpfile));
|
||||
grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
|
||||
fg->next = listgrps;
|
||||
listgrps = fg;
|
||||
|
||||
|
@ -202,12 +190,9 @@ static void LoadList(const char * filename)
|
|||
|
||||
static void LoadGameList(void)
|
||||
{
|
||||
struct grpfile *fg;
|
||||
CACHE1D_FIND_REC *srch, *sidx;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(internalgrpfiles); i++)
|
||||
{
|
||||
fg = (struct grpfile *)Xcalloc(1, sizeof(struct grpfile));
|
||||
grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
|
||||
|
||||
fg->name = Xstrdup(internalgrpfiles[i].name);
|
||||
fg->crcval = internalgrpfiles[i].crcval;
|
||||
|
@ -227,21 +212,18 @@ static void LoadGameList(void)
|
|||
listgrps = fg;
|
||||
}
|
||||
|
||||
srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE);
|
||||
CACHE1D_FIND_REC * const srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE);
|
||||
|
||||
for (sidx = srch; sidx; sidx = sidx->next)
|
||||
LoadList(srch->name);
|
||||
for (CACHE1D_FIND_REC *sidx = srch; sidx; sidx = sidx->next)
|
||||
LoadList(sidx->name);
|
||||
|
||||
klistfree(srch);
|
||||
}
|
||||
|
||||
static void FreeGameList(void)
|
||||
{
|
||||
struct grpfile *fg;
|
||||
|
||||
while (listgrps)
|
||||
{
|
||||
fg = listgrps->next;
|
||||
Bfree(listgrps->name);
|
||||
|
||||
if (listgrps->scriptname)
|
||||
|
@ -250,6 +232,7 @@ static void FreeGameList(void)
|
|||
if (listgrps->defname)
|
||||
Bfree(listgrps->defname);
|
||||
|
||||
grpinfo_t * const fg = listgrps->next;
|
||||
Bfree(listgrps);
|
||||
listgrps = fg;
|
||||
}
|
||||
|
@ -302,68 +285,65 @@ static int32_t LoadGroupsCache(void)
|
|||
|
||||
static void FreeGroupsCache(void)
|
||||
{
|
||||
struct grpcache *fg;
|
||||
|
||||
while (grpcache)
|
||||
{
|
||||
fg = grpcache->next;
|
||||
struct grpcache * const fg = grpcache->next;
|
||||
Bfree(grpcache);
|
||||
grpcache = fg;
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveGroup(int32_t crcval)
|
||||
static void RemoveGroup(grpfile_t *igrp)
|
||||
{
|
||||
struct grpfile *grp;
|
||||
|
||||
for (grp = foundgrps; grp; grp=grp->next)
|
||||
for (grpfile_t *prev = NULL, *grp = foundgrps; grp; grp=grp->next)
|
||||
{
|
||||
if (grp->crcval == crcval)
|
||||
if (grp == igrp)
|
||||
{
|
||||
if (grp == foundgrps)
|
||||
foundgrps = grp->next;
|
||||
else
|
||||
{
|
||||
struct grpfile *fg;
|
||||
prev->next = grp->next;
|
||||
|
||||
for (fg = foundgrps; fg; fg=fg->next)
|
||||
{
|
||||
if (fg->next == grp)
|
||||
{
|
||||
fg->next = grp->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bfree((char *)grp->name);
|
||||
Bfree((char *)grp->filename);
|
||||
Bfree(grp);
|
||||
|
||||
RemoveGroup(crcval);
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
prev = grp;
|
||||
}
|
||||
}
|
||||
|
||||
struct grpfile * FindGroup(int32_t crcval)
|
||||
grpfile_t * FindGroup(int32_t crcval)
|
||||
{
|
||||
struct grpfile *grp;
|
||||
grpfile_t *grp;
|
||||
|
||||
for (grp = foundgrps; grp; grp=grp->next)
|
||||
{
|
||||
if (grp->crcval == crcval)
|
||||
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;
|
||||
struct grpfile *grp;
|
||||
char *fn;
|
||||
struct Bstat st;
|
||||
|
||||
|
@ -388,12 +368,15 @@ static void ProcessGroups(CACHE1D_FIND_REC *srch)
|
|||
Bfree(fn);
|
||||
if (fg->size == (int32_t)st.st_size && fg->mtime == (int32_t)st.st_mtime)
|
||||
{
|
||||
grp = (struct grpfile *)Xcalloc(1, sizeof(struct grpfile));
|
||||
grp->name = Xstrdup(sidx->name);
|
||||
grp->crcval = fg->crcval;
|
||||
grp->size = fg->size;
|
||||
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);
|
||||
|
@ -424,12 +407,15 @@ static void ProcessGroups(CACHE1D_FIND_REC *srch)
|
|||
close(fh);
|
||||
initprintf(" Done\n");
|
||||
|
||||
grp = (struct grpfile *)Xcalloc(1, sizeof(struct grpfile));
|
||||
grp->name = Xstrdup(sidx->name);
|
||||
grp->crcval = crcval;
|
||||
grp->size = st.st_size;
|
||||
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);
|
||||
|
@ -448,7 +434,6 @@ int32_t ScanGroups(void)
|
|||
{
|
||||
CACHE1D_FIND_REC *srch;
|
||||
struct grpcache *fg, *fgg;
|
||||
struct grpfile *grp;
|
||||
|
||||
initprintf("Searching for game data...\n");
|
||||
|
||||
|
@ -465,39 +450,19 @@ int32_t ScanGroups(void)
|
|||
|
||||
FreeGroupsCache();
|
||||
|
||||
for (grp = foundgrps; grp; /*grp=grp->next*/)
|
||||
for (grpfile_t *grp = foundgrps; grp; grp=grp->next)
|
||||
{
|
||||
struct grpfile *igrp;
|
||||
for (igrp = listgrps; igrp; igrp=igrp->next)
|
||||
if (grp->crcval == igrp->crcval) break;
|
||||
|
||||
if (igrp == NULL)
|
||||
if (grp->type->dependency)
|
||||
{
|
||||
grp = grp->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (igrp->dependency)
|
||||
{
|
||||
struct grpfile *depgrp;
|
||||
|
||||
//initprintf("found grp with dep\n");
|
||||
for (depgrp = foundgrps; depgrp; depgrp=depgrp->next)
|
||||
if (depgrp->crcval == igrp->dependency) break;
|
||||
|
||||
if (depgrp == NULL || depgrp->crcval != igrp->dependency) // couldn't find dependency
|
||||
if (FindGroup(grp->type->dependency) == NULL) // couldn't find dependency
|
||||
{
|
||||
//initprintf("removing %s\n", grp->name);
|
||||
RemoveGroup(igrp->crcval);
|
||||
RemoveGroup(grp);
|
||||
grp = foundgrps;
|
||||
// start from the beginning so we can remove anything that depended on this grp
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (igrp->game && !grp->game)
|
||||
grp->game = igrp->game;
|
||||
|
||||
grp=grp->next;
|
||||
}
|
||||
|
||||
if (usedgrpcache)
|
||||
|
@ -529,12 +494,10 @@ int32_t ScanGroups(void)
|
|||
|
||||
void FreeGroups(void)
|
||||
{
|
||||
struct grpfile *fg;
|
||||
|
||||
while (foundgrps)
|
||||
{
|
||||
fg = foundgrps->next;
|
||||
Bfree((char *)foundgrps->name);
|
||||
Bfree((char *)foundgrps->filename);
|
||||
grpfile_t * const fg = foundgrps->next;
|
||||
Bfree(foundgrps);
|
||||
foundgrps = fg;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ enum addon_t {
|
|||
NUMADDONS
|
||||
};
|
||||
|
||||
typedef struct grpfile {
|
||||
typedef struct grpinfo_t {
|
||||
char *name;
|
||||
int32_t crcval;
|
||||
int32_t size;
|
||||
|
@ -68,16 +68,20 @@ typedef struct grpfile {
|
|||
char *scriptname;
|
||||
char *defname;
|
||||
void (*postprocessing)(int32_t);
|
||||
struct grpfile *next;
|
||||
} grpfile_type;
|
||||
struct grpinfo_t *next;
|
||||
} grpinfo_t;
|
||||
|
||||
extern struct grpfile internalgrpfiles[];
|
||||
extern struct grpfile *foundgrps;
|
||||
extern struct grpfile *listgrps;
|
||||
typedef struct grpfile_t {
|
||||
char *filename;
|
||||
struct grpinfo_t const *type;
|
||||
struct grpfile_t *next;
|
||||
} grpfile_t;
|
||||
|
||||
extern struct grpfile const * GetInternalGroup(int32_t crcval);
|
||||
extern grpfile_t *foundgrps;
|
||||
extern grpinfo_t *listgrps;
|
||||
|
||||
extern grpfile_t * FindGroup(int32_t crcval);
|
||||
|
||||
extern struct grpfile * FindGroup(int32_t crcval);
|
||||
int32_t ScanGroups(void);
|
||||
void FreeGroups(void);
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ static struct
|
|||
|
||||
static struct
|
||||
{
|
||||
grpfile_t const * grp;
|
||||
int32_t fullscreen;
|
||||
#ifdef POLYMER
|
||||
int32_t polymer;
|
||||
|
@ -115,10 +116,7 @@ static struct
|
|||
int32_t forcesetup;
|
||||
int32_t autoload;
|
||||
int32_t usemouse, usejoy;
|
||||
int32_t game;
|
||||
int32_t crcval;
|
||||
char *custommoddir;
|
||||
char selectedgrp[BMAX_PATH];
|
||||
} settings;
|
||||
|
||||
static int32_t retval = -1, mode = TAB_MESSAGES;
|
||||
|
@ -235,15 +233,13 @@ static void on_gamelist_selection_changed(GtkTreeSelection *selection, gpointer
|
|||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
struct grpfile *fg;
|
||||
UNREFERENCED_PARAMETER(user_data);
|
||||
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter))
|
||||
{
|
||||
grpfile_t const *fg;
|
||||
gtk_tree_model_get(model, &iter, 2, (gpointer)&fg, -1);
|
||||
strcpy(settings.selectedgrp, fg->name);
|
||||
settings.game = fg->game;
|
||||
settings.crcval = fg->crcval;
|
||||
settings.grp = fg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,7 +433,6 @@ static void PopulateForm(unsigned char pgs)
|
|||
|
||||
if ((pgs == ALL) || (pgs == POPULATE_GAME))
|
||||
{
|
||||
struct grpfile *fg;
|
||||
GtkListStore *list;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeView *gamelist;
|
||||
|
@ -446,18 +441,11 @@ static void PopulateForm(unsigned char pgs)
|
|||
list = GTK_LIST_STORE(gtk_tree_view_get_model(gamelist));
|
||||
gtk_list_store_clear(list);
|
||||
|
||||
for (fg = foundgrps; fg; fg=fg->next)
|
||||
for (grpfile_t const * fg = foundgrps; fg; fg=fg->next)
|
||||
{
|
||||
struct grpfile *grp;
|
||||
for (grp = listgrps; grp; grp=grp->next)
|
||||
if (fg->crcval == grp->crcval) break;
|
||||
|
||||
if (grp == NULL)
|
||||
continue;
|
||||
|
||||
gtk_list_store_append(list, &iter);
|
||||
gtk_list_store_set(list, &iter, 0, grp->name, 1, fg->name, 2, (gpointer)fg, -1);
|
||||
if (!Bstrcasecmp(fg->name, settings.selectedgrp))
|
||||
gtk_list_store_set(list, &iter, 0, fg->type->name, 1, fg->filename, 2, (gpointer)fg, -1);
|
||||
if (settings.grp == fg)
|
||||
{
|
||||
GtkTreeSelection *sel = gtk_tree_view_get_selection(gamelist);
|
||||
g_signal_handlers_block_by_func(sel, (gpointer)on_gamelist_selection_changed, NULL);
|
||||
|
@ -890,8 +878,7 @@ int32_t startwin_run(void)
|
|||
settings.usejoy = ud.config.UseJoystick;
|
||||
settings.custommoddir = g_modDir;
|
||||
settings.forcesetup = ud.config.ForceSetup;
|
||||
settings.game = g_gameType;
|
||||
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
|
||||
settings.grp = g_selectedGrp;
|
||||
if (ud.config.NoAutoLoad) settings.autoload = FALSE;
|
||||
else settings.autoload = TRUE;
|
||||
#ifdef POLYMER
|
||||
|
@ -915,37 +902,14 @@ int32_t startwin_run(void)
|
|||
ud.config.UseMouse = settings.usemouse;
|
||||
ud.config.UseJoystick = settings.usejoy;
|
||||
ud.config.ForceSetup = settings.forcesetup;
|
||||
g_selectedGrp = settings.grp;
|
||||
|
||||
clearGrpNamePtr();
|
||||
g_grpNamePtr = dup_filename(settings.selectedgrp);
|
||||
|
||||
g_gameType = settings.game;
|
||||
if (settings.custommoddir != NULL)
|
||||
Bstrcpy(g_modDir, settings.custommoddir);
|
||||
else Bsprintf(g_modDir, "/");
|
||||
|
||||
if (settings.autoload) ud.config.NoAutoLoad = FALSE;
|
||||
else ud.config.NoAutoLoad = TRUE;
|
||||
|
||||
{
|
||||
struct grpfile *grp;
|
||||
for (grp = listgrps; grp; grp=grp->next)
|
||||
if (settings.crcval == grp->crcval) break;
|
||||
|
||||
if (grp)
|
||||
{
|
||||
g_gameNamePtr = grp->name;
|
||||
g_dependencyCRC = grp->dependency;
|
||||
g_groupCRC = grp->crcval;
|
||||
g_postprocessing = grp->postprocessing;
|
||||
|
||||
if (grp->scriptname && g_scriptNamePtr == NULL)
|
||||
g_scriptNamePtr = dup_filename(grp->scriptname);
|
||||
|
||||
if (grp->defname && g_defNamePtr == NULL)
|
||||
g_defNamePtr = dup_filename(grp->defname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
static id nsapp;
|
||||
|
||||
static struct {
|
||||
grpfile_t const * grp;
|
||||
int fullscreen;
|
||||
int xdim3d, ydim3d, bpp3d;
|
||||
int forcesetup;
|
||||
char selectedgrp[BMAX_PATH+1];
|
||||
int game;
|
||||
int samplerate, bitspersample, channels;
|
||||
} settings;
|
||||
|
||||
|
@ -218,11 +217,7 @@ static struct soundQuality_t {
|
|||
|
||||
int row = [[gameList documentView] selectedRow];
|
||||
if (row >= 0) {
|
||||
struct grpfile *p = [[gamelistsrc grpAtIndex:row] entryptr];
|
||||
if (p) {
|
||||
strcpy(settings.selectedgrp, p->name);
|
||||
settings.game = p->game;
|
||||
}
|
||||
settings.grp = [[gamelistsrc grpAtIndex:row] entryptr];
|
||||
}
|
||||
|
||||
settings.forcesetup = [alwaysShowButton state] == NSOnState;
|
||||
|
@ -248,7 +243,7 @@ static struct soundQuality_t {
|
|||
[[gameList documentView] setDataSource:gamelistsrc];
|
||||
[[gameList documentView] deselectAll:nil];
|
||||
|
||||
int row = [gamelistsrc findIndexForGrpname:[NSString stringWithCString:settings.selectedgrp encoding:NSUTF8StringEncoding]];
|
||||
int row = [gamelistsrc findIndexForGrpname:[NSString stringWithCString:settings.grp->filename encoding:NSUTF8StringEncoding]];
|
||||
if (row >= 0) {
|
||||
[[gameList documentView] scrollRowToVisible:row];
|
||||
#if defined(MAC_OS_X_VERSION_10_3) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3)
|
||||
|
@ -422,8 +417,7 @@ int startwin_run(void)
|
|||
settings.bitspersample = ud.config.NumBits;
|
||||
settings.channels = ud.config.NumChannels;
|
||||
settings.forcesetup = ud.config.ForceSetup;
|
||||
// settings.game = gametype;
|
||||
strncpy(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
|
||||
settings.grp = g_selectedGrp;
|
||||
|
||||
[startwin setupRunMode];
|
||||
|
||||
|
@ -444,9 +438,7 @@ int startwin_run(void)
|
|||
ud.config.NumBits = settings.bitspersample;
|
||||
ud.config.NumChannels = settings.channels;
|
||||
ud.config.ForceSetup = settings.forcesetup;
|
||||
clearGrpNamePtr();
|
||||
g_grpNamePtr = dup_filename(settings.selectedgrp);
|
||||
// gametype = settings.game;
|
||||
g_selectedGrp = settings.grp;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -56,14 +56,12 @@ static struct audioenumdrv *wavedevs = NULL;
|
|||
|
||||
static struct
|
||||
{
|
||||
struct grpfile_t const * grp;
|
||||
int32_t flags; // bitfield
|
||||
int32_t xdim, ydim, bpp;
|
||||
int32_t forcesetup;
|
||||
int32_t usemouse, usejoy;
|
||||
int32_t game;
|
||||
int32_t crcval; // for finding the grp in the list again
|
||||
char *gamedir;
|
||||
char selectedgrp[BMAX_PATH];
|
||||
}
|
||||
settings;
|
||||
|
||||
|
@ -249,29 +247,19 @@ static void PopulateForm(int32_t pgs)
|
|||
|
||||
if (pgs & POPULATE_GAME)
|
||||
{
|
||||
struct grpfile *fg;
|
||||
int32_t j;
|
||||
char buf[1024];
|
||||
|
||||
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);
|
||||
|
||||
for (fg = foundgrps; fg; fg=fg->next)
|
||||
for (grpfile_t const * fg = foundgrps; fg; fg=fg->next)
|
||||
{
|
||||
struct grpfile *grp;
|
||||
for (grp = listgrps; grp; grp=grp->next)
|
||||
if (fg->crcval == grp->crcval) break;
|
||||
|
||||
if (grp == NULL)
|
||||
continue;
|
||||
|
||||
Bsprintf(buf, "%s\t%s", grp->name, fg->name);
|
||||
Bsprintf(buf, "%s\t%s", fg->type->name, fg->filename);
|
||||
j = ListBox_AddString(hwnd, buf);
|
||||
(void)ListBox_SetItemData(hwnd, j, (LPARAM)fg);
|
||||
if (!Bstrcasecmp(fg->name, settings.selectedgrp))
|
||||
if (settings.grp == fg)
|
||||
{
|
||||
(void)ListBox_SetCurSel(hwnd, j);
|
||||
settings.game = fg->game;
|
||||
settings.crcval = fg->crcval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -377,9 +365,7 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
|
|||
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
|
||||
if (i != CB_ERR)
|
||||
{
|
||||
strcpy(settings.selectedgrp, ((struct grpfile *)i)->name);
|
||||
settings.game = ((struct grpfile *)i)->game;
|
||||
settings.crcval = ((struct grpfile *)i)->crcval;
|
||||
settings.grp = (grpfile_t const *)i;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -746,9 +732,7 @@ int32_t startwin_run(void)
|
|||
settings.forcesetup = ud.config.ForceSetup;
|
||||
settings.usemouse = ud.config.UseMouse;
|
||||
settings.usejoy = ud.config.UseJoystick;
|
||||
settings.game = g_gameType;
|
||||
// settings.crcval = 0;
|
||||
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
|
||||
settings.grp = g_selectedGrp;
|
||||
settings.gamedir = g_modDir;
|
||||
PopulateForm(-1);
|
||||
|
||||
|
@ -786,35 +770,11 @@ int32_t startwin_run(void)
|
|||
ud.config.ForceSetup = settings.forcesetup;
|
||||
ud.config.UseMouse = settings.usemouse;
|
||||
ud.config.UseJoystick = settings.usejoy;
|
||||
|
||||
clearGrpNamePtr();
|
||||
g_grpNamePtr = dup_filename(settings.selectedgrp);
|
||||
|
||||
g_gameType = settings.game;
|
||||
g_selectedGrp = settings.grp;
|
||||
|
||||
if (g_noSetup == 0 && settings.gamedir != NULL)
|
||||
Bstrcpy(g_modDir,settings.gamedir);
|
||||
else Bsprintf(g_modDir,"/");
|
||||
|
||||
{
|
||||
struct grpfile *grp;
|
||||
for (grp = listgrps; grp; grp=grp->next)
|
||||
if (settings.crcval == grp->crcval) break;
|
||||
|
||||
if (grp)
|
||||
{
|
||||
g_gameNamePtr = grp->name;
|
||||
g_dependencyCRC = grp->dependency;
|
||||
g_groupCRC = grp->crcval;
|
||||
g_postprocessing = grp->postprocessing;
|
||||
|
||||
if (grp->scriptname && g_scriptNamePtr == NULL)
|
||||
g_scriptNamePtr = dup_filename(grp->scriptname);
|
||||
|
||||
if (grp->defname && g_defNamePtr == NULL)
|
||||
g_defNamePtr = dup_filename(grp->defname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wavedevs)
|
||||
|
|
Loading…
Reference in a new issue