The handling for grp, con, and def filenames has been massively cleaned up and factored into common.c. A new header, common_game.h, was created because common.h was placed in build/include (see r2542) and we need a common header for things that strictly should not be in the engine. RTS file names were also improved but some of the patterned changes were already made in r2420, and they were not factored because they are strictly part of the game, not the editor.

NAM and Napalm can now share their con, def, and rts files if the one for their respective game is not present because the con and rts files are identical.

Also, decapitalize two string literals missed in r2540.

git-svn-id: https://svn.eduke32.com/eduke32@2726 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2012-06-03 16:09:33 +00:00
parent 19d9d0a71e
commit 67ed6945fd
18 changed files with 350 additions and 236 deletions

View file

@ -6,6 +6,8 @@
#include "duke3d.h"
#include "game.h"
#undef GetTime
#include "common.h"
#include "common_game.h"
#include "build.h"
#include "compat.h"
#include "baselayer.h"
@ -416,7 +418,7 @@ int startwin_run(void)
settings.channels = ud.config.NumChannels;
settings.forcesetup = ud.config.ForceSetup;
// settings.game = gametype;
strncpy(settings.selectedgrp, defaultduke3dgrp, BMAX_PATH);
strncpy(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
[startwin setupRunMode];
@ -437,7 +439,8 @@ int startwin_run(void)
ud.config.NumBits = settings.bitspersample;
ud.config.NumChannels = settings.channels;
ud.config.ForceSetup = settings.forcesetup;
strncpy(defaultduke3dgrp, settings.selectedgrp, BMAX_PATH);
clearGrpNamePtr();
g_grpNamePtr = dup_filename(settings.selectedgrp);
// gametype = settings.game;
}

View file

@ -798,7 +798,8 @@ int32_t md_loadmodel(const char *fn);
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
extern char defsfilename[BMAX_PATH];
extern char *G_DefaultDefFile(void);
extern char *G_DefFile(void);
extern char *g_defNamePtr;
extern char **g_defModules;

View file

@ -619,7 +619,7 @@ int32_t app_main(int32_t argc, const char **argv)
Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman");
initcrc();
if (!loaddefinitionsfile(g_defNamePtr))
if (!loaddefinitionsfile(G_DefFile()))
initprintf("Definitions file loaded.\n");
for (i=0; i < g_defModulesNum; ++i)

View file

@ -264,7 +264,7 @@ static int32_t defsparser(scriptfile *script)
}
case T_INCLUDEDEFAULT:
{
defsparser_include(defsfilename, script, cmdtokptr);
defsparser_include(G_DefaultDefFile(), script, cmdtokptr);
break;
}
case T_DEFINE:

View file

@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "names.h"
#include "common.h"
#include "common_game.h"
#include "mapster32.h"
#include "keys.h"
@ -67,12 +68,6 @@ static char levelname[BMAX_PATH];
// static char *startwin_labeltext = "Starting Mapster32...";
static char setupfilename[BMAX_PATH] = "mapster32.cfg";
char defsfilename[BMAX_PATH] = "duke3d.def";
static char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp";
// g_defNamePtr can ONLY point to one of: defsfilename, malloc'd block (all
// length BMAX_PATH)
char *g_defNamePtr = defsfilename;
int32_t fixmaponsave_sprites = 1;
static int32_t fixmaponsave_walls = 0;
static int32_t lastsave = -180*60;
@ -82,32 +77,6 @@ static int32_t spnoclip=1;
static char *default_tiles_cfg = "tiles.cfg";
static int32_t pathsearchmode_oninit;
// Sound in Mapster32
static char defaultgamecon[2][BMAX_PATH] = { "eduke.con", "game.con" };
static void clearDefNamePtr(void)
{
if (g_defNamePtr != defsfilename)
Bfree(g_defNamePtr);
// g_defNamePtr assumed to be assigned to right after
}
char * defaultgameconfile(void)
{
int32_t script; // scriptfile *script;
script = kopen4load(defaultgamecon[0],0); // script = scriptfile_fromfile(defaultgamecon[0]);
if (script >= 0)
return defaultgamecon[0];
return defaultgamecon[1];
}
static const char *gamecon = "\0";
static int32_t g_skipDefaultCons = 0;
static int32_t g_skipDefaultDefs = 0; // primarily for NAM/WWII GI appeasement
char **g_scriptModules = NULL;
int32_t g_scriptModulesNum = 0;
char **g_defModules = NULL;
@ -8598,7 +8567,8 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
if (argc > i+1)
{
Bstrncpyz(defaultduke3dgrp, argv[i+1], sizeof(defaultduke3dgrp));
clearGrpNamePtr();
g_grpNamePtr = dup_filename(argv[i+1]);
COPYARG(i);
COPYARG(i+1);
i++;
@ -8606,15 +8576,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nam"))
{
Bstrcpy(defaultduke3dgrp, "nam.grp");
Bstrcpy(defsfilename, "nam.def");
Bstrcpy(defaultgamecon[0], "nam.con");
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"namesfile"))
{
g_namesFileName = argv[i+1];
@ -8665,11 +8626,23 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nam"))
{
g_gameType = GAMEFLAG_NAM;
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"napalm"))
{
g_gameType = GAMEFLAG_NAM|GAMEFLAG_NAPALM;
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"ww2gi"))
{
Bstrcpy(defaultduke3dgrp, "ww2gi.grp");
Bstrcpy(defaultgamecon[0], "ww2gi.con");
Bstrcpy(defsfilename, "ww2gi.def");
g_gameType = GAMEFLAG_WW2GI;
COPYARG(i);
i++;
continue;
@ -8732,7 +8705,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
clearDefNamePtr();
g_defNamePtr = dup_filename(c);
g_skipDefaultDefs = 1;
COPYARG(i);
initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
}
@ -8754,11 +8726,12 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
case 'x':
case 'X':
c++;
if (!*c) break;
gamecon = c;
g_skipDefaultCons = 1;
COPYARG(i);
initprintf("Using CON file \"%s\".\n",gamecon);
if (*c)
{
clearScriptNamePtr();
g_scriptNamePtr = dup_filename(c);
initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
}
break;
}
}
@ -8778,16 +8751,15 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
COPYARG(i);
clearDefNamePtr();
g_defNamePtr = dup_filename(argv[i++]);
g_skipDefaultDefs = 1;
initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
continue;
}
else if (!Bstrcasecmp(k,".con"))
{
COPYARG(i);
gamecon = argv[i++];
g_skipDefaultCons = 1;
initprintf("Using CON file \"%s\".\n",gamecon);
clearScriptNamePtr();
g_scriptNamePtr = dup_filename(argv[i++]);
initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
continue;
}
}
@ -9680,7 +9652,7 @@ int32_t parsegroupfiles(scriptfile *script)
break;
case T_INCLUDEDEFAULT:
{
parsegroupfiles_include(defsfilename, script, cmdtokptr);
parsegroupfiles_include(G_DefaultDefFile(), script, cmdtokptr);
break;
}
break;
@ -10120,7 +10092,7 @@ static int32_t parseconsounds(scriptfile *script)
}
case T_INCLUDEDEFAULT:
{
parseconsounds_include(defaultgameconfile(), script, cmdtokptr);
parseconsounds_include(G_DefaultConFile(), script, cmdtokptr);
break;
}
case T_DEFINE:
@ -10367,41 +10339,45 @@ int32_t ExtInit(void)
}
{
const char *grpNamePtr = defaultduke3dgrp;
// JBF 20031220: Because it's annoying renaming GRP files whenever I want to test different game data
if (getenv("DUKE3DGRP"))
// (CODEDUP game.c)
if (g_grpNamePtr == NULL)
{
grpNamePtr = getenv("DUKE3DGRP");
initprintf("Using \"%s\" as main GRP file\n", grpNamePtr);
const char *cp = getenv("DUKE3DGRP");
if (cp)
{
clearGrpNamePtr();
g_grpNamePtr = dup_filename(cp);
initprintf("Using \"%s\" as main GRP file\n", g_grpNamePtr);
}
}
i = initgroupfile(grpNamePtr);
const char *grpfile = G_GrpFile();
i = initgroupfile(grpfile);
if (!NoAutoLoad)
{
G_LoadGroupsInDir("autoload");
if (i != -1)
G_DoAutoload(grpNamePtr);
G_DoAutoload(grpfile);
}
}
// (CODEDUP game.c)
if (g_defNamePtr == NULL)
{
const char *tmpptr = getenv("DUKE3DDEF");
if (tmpptr)
{
clearDefNamePtr();
g_defNamePtr = dup_filename(tmpptr);
g_skipDefaultDefs = 1;
initprintf("Using \"%s\" as definitions file\n", g_defNamePtr);
}
}
if (g_skipDefaultDefs == 0)
if (g_defNamePtr != defsfilename)
Bstrcpy(g_defNamePtr, defsfilename); // it MAY have changed, with NAM/WWII GI
loadgroupfiles(g_defNamePtr); // the defs are actually loaded in app_main in build.c
loadgroupfiles(G_DefFile()); // the defs are actually loaded in app_main in build.c
{
struct strllist *s;
@ -11156,10 +11132,7 @@ void ExtCheckKeys(void)
{
g_numsounds = 0;
if (g_skipDefaultCons == 0)
loadconsounds(defaultgameconfile());
else
loadconsounds(gamecon);
loadconsounds(G_ConFile());
if (g_numsounds > 0)
{

View file

@ -3,13 +3,143 @@
//
#include "compat.h"
#include "build.h"
#include "scriptfile.h"
#include "cache1d.h"
#include "kplib.h"
#include "baselayer.h"
#include "common.h"
#include "common_game.h"
int32_t g_gameType = 0;
// grp/con/def handling
char *defaultgamegrp[GAMECOUNT] = { "DUKE3D.GRP", "NAM.GRP", "NAPALM.GRP", "WW2GI.GRP" };
char *defaultdeffilename[GAMECOUNT] = { "duke3d.def", "nam.def", "napalm.def", "ww2gi.def" };
char *defaultconfilename = "GAME.CON";
char *defaultgameconfilename[GAMECOUNT] = { "EDUKE.CON", "NAM.CON", "NAPALM.CON", "WW2GI.CON" };
// g_grpNamePtr can ONLY point to a malloc'd block (length BMAX_PATH)
char *g_grpNamePtr = NULL;
// g_defNamePtr can ONLY point to a malloc'd block (length BMAX_PATH)
char *g_defNamePtr = NULL;
// g_scriptNamePtr can ONLY point to a malloc'd block (length BMAX_PATH)
char *g_scriptNamePtr = NULL;
void clearGrpNamePtr(void)
{
if (g_grpNamePtr != NULL)
Bfree(g_grpNamePtr);
// g_grpNamePtr assumed to be assigned to right after
}
void clearDefNamePtr(void)
{
if (g_defNamePtr != NULL)
Bfree(g_defNamePtr);
// g_defNamePtr assumed to be assigned to right after
}
void clearScriptNamePtr(void)
{
if (g_scriptNamePtr != NULL)
Bfree(g_scriptNamePtr);
// g_scriptNamePtr assumed to be assigned to right after
}
char *G_DefaultGrpFile(void)
{
if (DUKE)
return defaultgamegrp[GAME_DUKE];
// order is important for the following three because GAMEFLAG_NAM overlaps all
else if (NAPALM)
return defaultgamegrp[GAME_NAPALM];
else if (WW2GI)
return defaultgamegrp[GAME_WW2GI];
else if (NAM)
return defaultgamegrp[GAME_NAM];
return defaultgamegrp[0];
}
char *G_DefaultDefFile(void)
{
if (DUKE)
return defaultdeffilename[GAME_DUKE];
else if (WW2GI)
return defaultdeffilename[GAME_WW2GI];
else if (NAPALM)
{
if ((kopen4load(defaultdeffilename[GAME_NAPALM],0) < 0) && (kopen4load(defaultdeffilename[GAME_NAM],0) >= 0))
return defaultdeffilename[GAME_NAM]; // NAM/Napalm Sharing
else
return defaultdeffilename[GAME_NAPALM];
}
else if (NAM)
{
if ((kopen4load(defaultdeffilename[GAME_NAM],0) < 0) && (kopen4load(defaultdeffilename[GAME_NAPALM],0) >= 0))
return defaultdeffilename[GAME_NAPALM]; // NAM/Napalm Sharing
else
return defaultdeffilename[GAME_NAM];
}
return defaultdeffilename[0];
}
char *G_DefaultConFile(void)
{
if (DUKE && (kopen4load(defaultgameconfilename[GAME_DUKE],0) >= 0))
return defaultgameconfilename[GAME_DUKE];
else if (WW2GI && (kopen4load(defaultgameconfilename[GAME_WW2GI],0) >= 0))
return defaultgameconfilename[GAME_WW2GI];
else if (NAPALM)
{
if (kopen4load(defaultgameconfilename[GAME_NAPALM],0) < 0)
{
if (kopen4load(defaultgameconfilename[GAME_NAM],0) >= 0)
return defaultgameconfilename[GAME_NAM]; // NAM/Napalm Sharing
}
else
return defaultgameconfilename[GAME_NAPALM];
}
else if (NAM)
{
if (kopen4load(defaultgameconfilename[GAME_NAM],0) < 0)
{
if (kopen4load(defaultgameconfilename[GAME_NAPALM],0) >= 0)
return defaultgameconfilename[GAME_NAPALM]; // NAM/Napalm Sharing
}
else
return defaultgameconfilename[GAME_NAM];
}
return defaultconfilename;
}
char *G_GrpFile(void)
{
if (g_grpNamePtr == NULL)
return G_DefaultGrpFile();
else
return g_grpNamePtr;
}
char *G_DefFile(void)
{
if (g_defNamePtr == NULL)
return G_DefaultDefFile();
else
return g_defNamePtr;
}
char *G_ConFile(void)
{
if (g_scriptNamePtr == NULL)
return G_DefaultConFile();
else
return g_scriptNamePtr;
}
//////////
struct strllist *CommandPaths, *CommandGrps;

View file

@ -0,0 +1,48 @@
//
// Definitions of common game-only data structures/functions
// (and declarations of data appearing in both)
// for EDuke32 and Mapster32
//
#ifndef EDUKE32_COMMON_GAME_H_
#define EDUKE32_COMMON_GAME_H_
#define GAMEFLAG_DUKE 0x00000001
#define GAMEFLAG_NAM 0x00000002
#define GAMEFLAG_NAPALM 0x00000004
#define GAMEFLAG_WW2GI 0x00000008
extern int32_t g_gameType;
#define DUKE (g_gameType & GAMEFLAG_DUKE)
#define NAM (g_gameType & GAMEFLAG_NAM)
#define NAPALM (g_gameType & GAMEFLAG_NAPALM)
#define WW2GI (g_gameType & GAMEFLAG_WW2GI)
enum Games_t {
GAME_DUKE = 0,
GAME_NAM,
GAME_NAPALM,
GAME_WW2GI,
GAMECOUNT
};
extern char *defaultgamegrp[GAMECOUNT];
extern char *defaultdeffilename[GAMECOUNT];
extern char *defaultconfilename;
extern char *defaultgameconfilename[GAMECOUNT];
extern char *g_grpNamePtr;
extern char *g_scriptNamePtr;
extern char *G_DefaultGrpFile(void);
extern char *G_GrpFile(void);
extern char *G_DefaultConFile(void);
extern char *G_ConFile(void);
extern void clearGrpNamePtr(void);
extern void clearDefNamePtr(void);
extern void clearScriptNamePtr(void);
#endif

View file

@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "baselayer.h"
#include "duke3d.h"
#include "game.h"
#include "common_game.h"
#include "scriplib.h"
#include "osd.h"
#include "osdcmds.h"
@ -267,7 +268,7 @@ void CONFIG_SetDefaults(void)
ud.config.CheckForUpdates = 1;
if (g_rtsNamePtr == NULL)
Bstrcpy(ud.rtsname, defaultrtsfilename);
Bstrcpy(ud.rtsname, G_DefaultRtsFile());
Bstrcpy(szPlayerName, "Duke");
Bstrcpy(ud.ridecule[0], "An inspiration for birth control.");
@ -686,7 +687,7 @@ int32_t CONFIG_ReadSetup(void)
}
// #endif
if (!Bstrcmp(defaultduke3dgrp,"duke3d.grp"))
if (g_grpNamePtr != NULL && !Bstrcmp(g_grpNamePtr,defaultgamegrp[0]))
SCRIPT_GetString(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr[0]);
if (!NAM)

View file

@ -52,17 +52,10 @@ extern "C" {
#define VERSION "2.0.0devel"
#define HEAD2 APPNAME" "VERSION
#define GAME_DUKE 0
#define GAME_NAM 1
#define GAME_WW2 2
#define VOLUMEALL (g_Shareware == 0)
#define PLUTOPAK (g_scriptVersion == 14)
#define VOLUMEONE (g_Shareware == 1)
#define NAM (g_gameType & GAME_NAM)
#define WW2GI (g_gameType & GAME_WW2)
// increase by 3, because atomic GRP adds 1, and Shareware adds 2
#define BYTEVERSION_JF 243
@ -106,6 +99,7 @@ extern "C" {
// so that debugging with valgrind --smc-check=none is possible:
//#define DEBUG_VALGRIND_NO_SMC
#include "common_game.h"
#include "namesdyn.h"
#include "function.h"
#include "macros.h"

View file

@ -52,6 +52,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "anim.h"
#include "demo.h"
#include "common.h"
#include "common_game.h"
#ifdef LUNATIC
# include "lunatic.h"
@ -106,9 +107,6 @@ uint8_t *basepaltable[BASEPALCOUNT] = { palette, water_pal, slime_pal, dre_alms,
int8_t g_noFloorPal[MAXPALOOKUPS]; // 1 if sprite pal should not be taken over from floor pal
static int32_t g_skipDefaultCons = 0;
static int32_t g_skipDefaultDefs = 0; // primarily for NAM/WWII GI appeasement
int32_t voting = -1;
int32_t vote_map = -1, vote_episode = -1;
@ -116,47 +114,14 @@ static int32_t g_Debug = 0;
static int32_t g_noLogoAnim = 0;
static int32_t g_noLogo = 0;
char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp";
char defsfilename[BMAX_PATH] = "duke3d.def";
static char defaultconfilename[2][BMAX_PATH] = { "EDUKE.CON", "GAME.CON" };
const char *defaultrtsfilename = "DUKE.RTS";
const char *defaultrtsfilename[GAMECOUNT] = { "DUKE.RTS", "NAM.RTS", "NAPALM.RTS", "WW2GI.RTS" };
// g_grpNamePtr can ONLY point to one of: defaultduke3dgrp, malloc'd block (all
// length BMAX_PATH)
char *g_grpNamePtr = defaultduke3dgrp;
// g_defNamePtr can ONLY point to one of: defsfilename, malloc'd block (all
// length BMAX_PATH)
char *g_defNamePtr = defsfilename;
// g_scriptNamePtr can ONLY point to defaultconfilename[0] OR to malloc'd block
// (all length BMAX_PATH)
static char *g_scriptNamePtr = defaultconfilename[0];
// g_gameNamePtr can point to one of: grpfiles[].name (string literal), string
// literal, malloc'd block (XXX: possible leak)
const char *g_gameNamePtr = NULL;
// g_rtsNamePtr can point to an argv[] element
const char *g_rtsNamePtr = NULL;
void clearGrpNamePtr(void)
{
if (g_grpNamePtr != defaultduke3dgrp)
Bfree(g_grpNamePtr);
// g_grpNamePtr assumed to be assigned to right after
}
void clearDefNamePtr(void)
{
if (g_defNamePtr != defsfilename)
Bfree(g_defNamePtr);
// g_defNamePtr assumed to be assigned to right after
}
static void clearScriptNamePtr(void)
{
if (g_scriptNamePtr != defaultconfilename[0])
Bfree(g_scriptNamePtr);
// g_scriptNamePtr assumed to be assigned to right after
}
char **g_scriptModules = NULL;
int32_t g_scriptModulesNum = 0;
char **g_defModules = NULL;
@ -174,7 +139,6 @@ El_State g_ElState;
extern int32_t lastvisinc;
int32_t g_Shareware = 0;
int32_t g_gameType = 0;
#define MAXUSERQUOTES 6
int32_t quotebot, quotebotgoal;
@ -239,16 +203,28 @@ int32_t kopen4loadfrommod(const char *filename, char searchfirst)
return r;
}
char *defaultconfile(void)
const char *G_DefaultRtsFile(void)
{
int32_t i;
if (DUKE)
return defaultrtsfilename[GAME_DUKE];
else if (WW2GI)
return defaultrtsfilename[GAME_WW2GI];
else if (NAPALM)
{
if ((kopen4load(defaultrtsfilename[GAME_NAPALM],0) < 0) && (kopen4load(defaultrtsfilename[GAME_NAM],0) >= 0))
return defaultrtsfilename[GAME_NAM]; // NAM/Napalm Sharing
else
return defaultrtsfilename[GAME_NAPALM];
}
else if (NAM)
{
if ((kopen4load(defaultrtsfilename[GAME_NAM],0) < 0) && (kopen4load(defaultrtsfilename[GAME_NAPALM],0) >= 0))
return defaultrtsfilename[GAME_NAPALM]; // NAM/Napalm Sharing
else
return defaultrtsfilename[GAME_NAM];
}
i = kopen4load(defaultconfilename[0],0);
if (i >= 0)
return defaultconfilename[0];
return defaultconfilename[1];
return defaultrtsfilename[0];
}
enum gametokens
@ -8158,7 +8134,8 @@ static void G_ShowParameterHelp(void)
"-mh [file.def]\tInclude an additional definitions module\n"
"-mx [file.con]\tInclude an additional CON script module\n"
"-m\t\tDisable monsters\n"
"-nam\t\tRun in NAM/NAPALM compatibility mode\n"
"-nam\t\tRun in NAM compatibility mode\n"
"-napalm\t\tRun in Napalm compatibility mode\n"
"-rts [file.rts]\tLoad a custom Remote Ridicule sound bank\n"
"-r\t\tRecord demo\n"
"-s#\t\tSet skill level (1-4)\n"
@ -8172,7 +8149,7 @@ static void G_ShowParameterHelp(void)
#endif
"-u#########\tUser's favorite weapon order (default: 3425689071)\n"
"-v#\t\tWarp to volume #, see -l\n"
"-ww2gi\t\tRun in WW2GI compatibility mode\n"
"-ww2gi\t\tRun in WWII GI compatibility mode\n"
"-x[game.con]\tLoad custom CON script\n"
"-#\t\tLoad and run a game from slot # (0-9)\n"
// "\n-?/--help\tDisplay this help message and exit\n"
@ -8390,7 +8367,7 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload)
}
case T_INCLUDEDEFAULT:
{
parsedefinitions_game_include(defsfilename, script, cmdtokptr, preload);
parsedefinitions_game_include(G_DefaultDefFile(), script, cmdtokptr, preload);
break;
}
case T_NOAUTOLOAD:
@ -8747,7 +8724,8 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
if (argc > i+1)
{
Bstrcpy(defaultduke3dgrp,argv[i+1]);
clearGrpNamePtr();
g_grpNamePtr = dup_filename(argv[i+1]);
i++;
}
i++;
@ -8755,21 +8733,19 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
}
if (!Bstrcasecmp(c+1,"nam"))
{
Bstrcpy(defaultduke3dgrp, "nam.grp");
Bstrcpy(defsfilename, "nam.def");
// Bstrcpy(g_defNamePtr, "nam.def");
Bstrcpy(defaultconfilename[0], "nam.con");
g_gameType = GAME_NAM;
g_gameType = GAMEFLAG_NAM;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"napalm"))
{
g_gameType = GAMEFLAG_NAM|GAMEFLAG_NAPALM;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"ww2gi"))
{
Bstrcpy(defaultduke3dgrp, "ww2gi.grp");
Bstrcpy(defsfilename, "ww2gi.def");
// Bstrcpy(g_defNamePtr, "ww2gi.def");
Bstrcpy(defaultconfilename[0], "ww2gi.con");
g_gameType = GAME_WW2;
g_gameType = GAMEFLAG_WW2GI;
i++;
continue;
}
@ -9039,7 +9015,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
clearDefNamePtr();
g_defNamePtr = dup_filename(c);
g_skipDefaultDefs = 1;
initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
}
break;
@ -9164,7 +9139,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
clearScriptNamePtr();
g_scriptNamePtr = dup_filename(c);
g_skipDefaultCons = 1;
initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
}
break;
@ -9212,7 +9186,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
clearScriptNamePtr();
g_scriptNamePtr = dup_filename(argv[i++]);
g_skipDefaultCons = 1;
initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
continue;
}
@ -9220,7 +9193,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
{
clearDefNamePtr();
g_defNamePtr = dup_filename(argv[i++]);
g_skipDefaultDefs = 1;
initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
continue;
}
@ -9515,27 +9487,16 @@ static void G_CompileScripts(void)
labelcode = (int32_t *)&sector[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
if (g_scriptNamePtr != NULL)
Bcorrectfilename(g_scriptNamePtr,0);
// if we compile for a V7 engine wall[] should be used for label names since it's bigger
pathsearchmode = 1;
if (g_skipDefaultCons == 0)
{
const char *cp = defaultconfile();
if (cp != g_scriptNamePtr)
Bsprintf(g_scriptNamePtr, "%s", cp);
}
C_Compile(g_scriptNamePtr);
C_Compile(G_ConFile());
if (g_loadFromGroupOnly) // g_loadFromGroupOnly is true only when compiling fails and internal defaults are utilized
{
if (g_skipDefaultCons == 0)
{
const char *cp = defaultconfile();
if (cp != g_scriptNamePtr)
Bsprintf(g_scriptNamePtr, "%s", cp);
}
C_Compile(g_scriptNamePtr);
}
C_Compile(G_ConFile());
if ((uint32_t)g_numLabels > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why
G_GameExit("Error: too many labels defined!");
@ -10073,6 +10034,8 @@ int32_t app_main(int32_t argc, const char **argv)
i = CONFIG_ReadSetup();
// CODEDUP astub.c
if (g_grpNamePtr == NULL)
{
const char *cp = getenv("DUKE3DGRP");
if (cp)
@ -10145,7 +10108,7 @@ int32_t app_main(int32_t argc, const char **argv)
ScanGroups();
{
// try and identify the 'defaultduke3dgrp' in the set of GRPs.
// 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;
@ -10156,7 +10119,7 @@ int32_t app_main(int32_t argc, const char **argv)
if (i == NUMGRPFILES) continue; // unrecognised grp file
fg->game = grpfiles[i].game;
if (!first) first = fg;
if (!Bstrcasecmp(fg->name, defaultduke3dgrp))
if (!Bstrcasecmp(fg->name, G_DefaultGrpFile()))
{
g_gameType = grpfiles[i].game;
g_gameNamePtr = grpfiles[i].name;
@ -10165,7 +10128,11 @@ int32_t app_main(int32_t argc, const char **argv)
}
if (!fg && first)
{
Bstrcpy(defaultduke3dgrp, first->name);
if (g_grpNamePtr == NULL)
{
clearGrpNamePtr();
g_grpNamePtr = dup_filename(first->name);
}
g_gameType = first->game;
g_gameNamePtr = grpfiles[0].name;
}
@ -10187,15 +10154,8 @@ int32_t app_main(int32_t argc, const char **argv)
if (WW2GI || NAM)
{
// overwrite the default GRP and CON so that if the user chooses
// something different, they get what they asked for
Bstrcpy(defaultduke3dgrp, WW2GI ? "ww2gi.grp" : "nam.grp");
Bstrcpy(defsfilename, WW2GI ? "ww2gi.def" : "nam.def");
// Bstrcpy(g_defNamePtr, WW2GI ? "ww2gi.def" : "nam.def");
Bstrcpy(defaultconfilename[0], WW2GI ? "ww2gi.con" : "nam.con");
Bstrcpy(GametypeNames[0],"GRUNTMATCH (SPAWN)");
Bstrcpy(GametypeNames[2],"GRUNTMATCH (NO SPAWN)");
Bstrcpy(GametypeNames[0],"GruntMatch (Spawn)");
Bstrcpy(GametypeNames[2],"GruntMatch (No Spawn)");
}
if (g_modDir[0] != '/')
@ -10302,40 +10262,40 @@ CLEAN_DIRECTORY:
}
#endif
if ((i = initgroupfile(g_grpNamePtr)) == -1)
initprintf("Warning: could not find main data file \"%s\"!\n",g_grpNamePtr);
{
const char *grpfile = G_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", g_grpNamePtr);
initprintf("Using \"%s\" as main game data file.\n", grpfile);
if (!g_noAutoLoad && !ud.config.NoAutoLoad)
{
G_LoadGroupsInDir("autoload");
if (i != -1)
G_DoAutoload(g_grpNamePtr);
G_DoAutoload(grpfile);
}
}
if (g_modDir[0] != '/')
G_LoadGroupsInDir(g_modDir);
// CODEDUP astub.c
if (g_defNamePtr == NULL)
{
const char *tmpptr = getenv("DUKE3DDEF");
if (tmpptr)
{
clearDefNamePtr();
g_defNamePtr = dup_filename(tmpptr);
g_skipDefaultDefs = 1;
initprintf("Using \"%s\" as definitions file\n", g_defNamePtr);
}
}
if (g_skipDefaultDefs == 0)
if (g_defNamePtr != defsfilename)
Bstrcpy(g_defNamePtr, defsfilename); // it MAY have changed, with NAM/WWII GI
flushlogwindow = 0;
loaddefinitions_game(g_defNamePtr, TRUE);
loaddefinitions_game(G_DefFile(), TRUE);
// flushlogwindow = 1;
{
@ -10417,10 +10377,13 @@ CLEAN_DIRECTORY:
if (quitevent) return 4;
if (!loaddefinitionsfile(g_defNamePtr))
{
initprintf("Definitions file \"%s\" loaded.\n",g_defNamePtr);
loaddefinitions_game(g_defNamePtr, FALSE);
char *defsfile = G_DefFile();
if (!loaddefinitionsfile(defsfile))
{
initprintf("Definitions file \"%s\" loaded.\n",defsfile);
loaddefinitions_game(defsfile, FALSE);
}
}
for (i=0; i < g_defModulesNum; ++i)
@ -10449,18 +10412,15 @@ CLEAN_DIRECTORY:
playerswhenstarted = ud.multimode;
ud.last_level = 0;
// the point of this block is to avoid overwriting the default in the cfg while asserting our selection
if (g_rtsNamePtr == NULL &&
(!Bstrcasecmp(ud.rtsname,defaultrtsfilename) ||
!Bstrcasecmp(ud.rtsname,"WW2GI.RTS") ||
!Bstrcasecmp(ud.rtsname,"NAM.RTS")))
(!Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_DUKE]) ||
!Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_WW2GI]) ||
!Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_NAM]) ||
!Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_NAPALM])))
{
// ud.last_level is used as a flag here to reset the string to default after load
if (WW2GI)
ud.last_level = (Bstrcpy(ud.rtsname, "WW2GI.RTS") == ud.rtsname);
else if (NAM)
ud.last_level = (Bstrcpy(ud.rtsname, "NAM.RTS") == ud.rtsname);
else
ud.last_level = (Bstrcpy(ud.rtsname, defaultrtsfilename) == ud.rtsname);
ud.last_level = (Bstrcpy(ud.rtsname, G_DefaultRtsFile()) == ud.rtsname);
}
RTS_Init(ud.rtsname);
@ -10469,7 +10429,7 @@ CLEAN_DIRECTORY:
initprintf("Using RTS file \"%s\".\n",ud.rtsname);
if (ud.last_level)
Bstrcpy(ud.rtsname, defaultrtsfilename);
Bstrcpy(ud.rtsname, defaultrtsfilename[0]);
ud.last_level = -1;

View file

@ -178,17 +178,19 @@ extern cactype cac[];
// this is checked against http://eduke32.com/VERSION
extern const char *s_buildDate;
extern char *g_grpNamePtr;
extern char *g_defNamePtr;
extern const char *g_gameNamePtr;
extern const char *g_rtsNamePtr;
extern char **g_scriptModules;
extern int32_t g_scriptModulesNum;
extern char CheatStrings[][MAXCHEATLEN];
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
extern char boardfilename[BMAX_PATH];
extern char defaultduke3dgrp[BMAX_PATH];
extern const char *defaultrtsfilename;
extern const char *defaultrtsfilename[GAMECOUNT];
extern const char *G_DefaultRtsFile(void);
extern char g_modDir[BMAX_PATH];
extern char g_modDir[BMAX_PATH];
extern char inputloc;
@ -209,7 +211,6 @@ extern int32_t g_cameraDistance;
extern int32_t g_crosshairSum;
extern int32_t g_doQuickSave;
extern int32_t g_forceWeaponChoice;
extern int32_t g_gameType;
extern int32_t g_levelTextTime;
extern int32_t g_noSetup;
extern int32_t g_quitDeadline;
@ -242,9 +243,6 @@ extern user_defs ud;
//extern int32_t g_yax_smoothratio;
void clearDefNamePtr(void);
void clearGrpNamePtr(void);
int32_t A_CheckInventorySprite(spritetype *s);
int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss);
int32_t A_Spawn(int32_t j,int32_t pn);
@ -255,7 +253,6 @@ int32_t G_PrintGameText(int32_t f,int32_t tile,int32_t x,int32_t y,const char *t
int32_t GetTime(void);
int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c);
int32_t kopen4loadfrommod(const char *filename,char searchfirst);
char * defaultconfile(void);
int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb);
int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits);
int32_t startwin_run(void);

View file

@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "gameexec.h"
#include "savegame.h"
#include "common.h"
#include "common_game.h"
#include "osd.h"
@ -2529,7 +2530,7 @@ static int32_t C_ParseCommand(int32_t loop)
case CON_INCLUDEDEFAULT:
C_SkipComments();
C_Include(defaultconfile());
C_Include(G_DefaultConFile());
continue;
case CON_AI:
@ -5776,7 +5777,7 @@ void C_Compile(const char *filenam)
"version of Duke Nukem 3D: Atomic Edition immediately for only $5.99 through our partnership with GOG.com.\n\n"
"Not a typo; it's less than 6 bucks. Get Duke now?\n\n"
"(Clicking yes will bring you to our web store)",
g_grpNamePtr,g_grpNamePtr);
G_GrpFile(),G_GrpFile());
if (wm_ynbox("Important - Duke Nukem 3D not found - EDuke32","%s",tempbuf))
{
@ -5799,7 +5800,7 @@ void C_Compile(const char *filenam)
Bsprintf(tempbuf,"Duke Nukem 3D game data was not found. A valid copy of \"%s\" or other compatible data is needed to run EDuke32.\n"
"You can find \"%s\" in the 'DN3DINST' or 'ATOMINST' directory on your Duke Nukem 3D installation CD-ROM.\n\n"
"EDuke32 will now close.",
g_grpNamePtr,g_grpNamePtr);
G_GrpFile(),G_GrpFile());
G_GameExit(tempbuf);
#endif
}

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//-------------------------------------------------------------------------
#include "duke3d.h"
#include "common_game.h"
#include "gamevars.h"
#include "gamedef.h"
#include "osd.h"

View file

@ -28,18 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "crc32.h"
#include "duke3d.h"
#include "common_game.h"
#include "grpscan.h"
struct grpfile grpfiles[NUMGRPFILES] =
{
{ "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAME_DUKE, NULL },
{ "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAME_DUKE, NULL },
{ "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAME_DUKE, NULL },
{ "Duke Nukem 3D Shareware", 0x983AD923, 11035779, GAME_DUKE, NULL },
{ "Duke Nukem 3D Mac Shareware", 0xC5F71561, 10444391, GAME_DUKE, NULL },
{ "NAM", 0x75C1F07B, 43448927, GAME_NAM, NULL },
{ "Napalm", 0x3DE1589A, 44365728, GAME_NAM, NULL },
{ "WW2GI", 0x907B82BF, 77939508, GAME_WW2|GAME_NAM, NULL },
{ "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEFLAG_DUKE, NULL },
{ "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEFLAG_DUKE, NULL },
{ "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEFLAG_DUKE, NULL },
{ "Duke Nukem 3D Shareware", 0x983AD923, 11035779, GAMEFLAG_DUKE, NULL },
{ "Duke Nukem 3D Mac Shareware", 0xC5F71561, 10444391, GAMEFLAG_DUKE, NULL },
{ "NAM", 0x75C1F07B, 43448927, GAMEFLAG_NAM, NULL },
{ "Napalm", 0x3DE1589A, 44365728, GAMEFLAG_NAM|GAMEFLAG_NAPALM, NULL },
{ "WWII GI", 0x907B82BF, 77939508, GAMEFLAG_WW2GI|GAMEFLAG_NAM, NULL },
};
struct grpfile *foundgrps = NULL;

View file

@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "demo.h"
#include "crc32.h"
#include "common.h"
#include "common_game.h"
#include <sys/stat.h>

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//-------------------------------------------------------------------------
#include "duke3d.h"
#include "common_game.h"
#include "osd.h"
#include "player.h"
#include "demo.h"

View file

@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "game.h"
#include "common.h"
#include "common_game.h"
#define RDR_POLYMOST 3 // sould be defined elsewhere
#define RDR_POLYMER 4 // sould be defined elsewhere
@ -886,7 +887,7 @@ int32_t startwin_run(void)
settings.custommoddir = g_modDir;
settings.forcesetup = ud.config.ForceSetup;
settings.game = g_gameType;
Bstrncpyz(settings.selectedgrp, g_grpNamePtr, BMAX_PATH);
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
if (ud.config.NoAutoLoad) settings.autoload = FALSE;
else settings.autoload = TRUE;
#ifdef POLYMER

View file

@ -46,6 +46,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "game.h"
#include "common.h"
#include "common_game.h"
#define TAB_CONFIG 0
// #define TAB_GAME 1
@ -738,7 +739,7 @@ int32_t startwin_run(void)
settings.usejoy = ud.config.UseJoystick;
settings.game = g_gameType;
// settings.crcval = 0;
Bstrncpyz(settings.selectedgrp, g_grpNamePtr, BMAX_PATH);
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
settings.gamedir = g_modDir;
PopulateForm(-1);