SW: Some GRP/def infrastructure.

git-svn-id: https://svn.eduke32.com/eduke32@5217 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-05-19 22:07:18 +00:00
parent 0fc284d5bf
commit 6b89b482b3
6 changed files with 88 additions and 28 deletions

View file

@ -3,6 +3,43 @@
#include "common_game.h"
static const char *defaultgrpfilename = "sw.grp";
static const char *defaultdeffilename = "sw.def";
// g_grpNamePtr can ONLY point to a malloc'd block (length BMAX_PATH)
char *g_grpNamePtr = NULL;
void clearGrpNamePtr(void)
{
if (g_grpNamePtr != NULL)
Bfree(g_grpNamePtr);
// g_grpNamePtr assumed to be assigned to right after
}
const char *G_DefaultGrpFile(void)
{
return defaultgrpfilename;
}
const char *G_GrpFile(void)
{
if (g_grpNamePtr == NULL)
return G_DefaultGrpFile();
else
return g_grpNamePtr;
}
const char *G_DefaultDefFile(void)
{
return defaultdeffilename;
}
const char *G_DefFile(void)
{
if (g_defNamePtr == NULL)
return G_DefaultDefFile();
else
return g_defNamePtr;
}
#define NUMPSKYMULTIS 1
EDUKE32_STATIC_ASSERT(NUMPSKYMULTIS <= MAXPSKYMULTIS);
EDUKE32_STATIC_ASSERT(PSKYOFF_MAX <= MAXPSKYTILES);

View file

@ -132,6 +132,12 @@ extern "C" {
#define MACRO10 "ITTAIIIUUU!!!"
extern char *g_grpNamePtr;
const char *G_DefaultGrpFile(void);
const char *G_GrpFile(void);
void clearGrpNamePtr(void);
void SW_InitMultiPsky(void);

View file

@ -89,6 +89,7 @@ Things required to make savegames work:
#include "text.h"
#include "music.h"
#include "common.h"
#include "common_game.h"
#include "crc32.h"
@ -929,7 +930,6 @@ void COVERsetbrightness(int bright, unsigned char *pal)
static int firstnet = 0; // JBF
int nextvoxid = 0; // JBF
static const char *deffile = "sw.def";
extern int startwin_run(void);
@ -951,7 +951,7 @@ InitGame(int32_t argc, const char **argv)
exit(1);
}
//initgroupfile("sw.grp"); // JBF: moving this close to start of program to detect shareware
//initgroupfile(G_GrpFile()); // JBF: moving this close to start of program to detect shareware
InitSetup();
InitAutoNet();
@ -1063,7 +1063,12 @@ InitGame(int32_t argc, const char **argv)
if (!SW_SHAREWARE)
LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information
if (!loaddefinitionsfile(deffile)) buildputs("Definitions file loaded.\n");
if (!loaddefinitionsfile(G_DefFile())) buildputs("Definitions file loaded.\n");
for (i=0; i < g_defModulesNum; ++i)
Bfree(g_defModules[i]);
Bfree(g_defModules);
g_defModules = NULL;
DemoModeMenuInit = TRUE;
// precache as much stuff as you can
@ -3446,7 +3451,6 @@ void CommandLineHelp(const char **argv)
#endif
}
char *grpfile = "sw.grp";
int32_t app_main(int32_t argc, const char **argv)
{
int i;
@ -3567,13 +3571,15 @@ int32_t app_main(int32_t argc, const char **argv)
}
OSD_SetLogFile("sw.log");
if (g_grpNamePtr == NULL)
{
char *newgrp;
newgrp = getenv("SWGRP");
if (newgrp)
const char *cp = getenv("SWGRP");
if (cp)
{
grpfile = newgrp;
buildprintf("Using alternative GRP file: %s\n", newgrp);
clearGrpNamePtr();
g_grpNamePtr = dup_filename(cp);
initprintf("Using \"%s\" as main GRP file\n", g_grpNamePtr);
}
}
@ -3598,7 +3604,7 @@ int32_t app_main(int32_t argc, const char **argv)
}
#endif
initgroupfile(grpfile);
initgroupfile(G_GrpFile());
if (!DetectShareware())
{
if (SW_SHAREWARE) buildputs("Detected shareware GRP\n");
@ -4088,10 +4094,12 @@ int32_t app_main(int32_t argc, const char **argv)
else if (Bstrncasecmp(arg, "h", 1) == 0 && !SW_SHAREWARE)
{
if (strlen(arg) > 1)
{
deffile = (arg+1);
buildprintf("Using DEF file %s.\n", arg+1);
G_AddDef(arg+1);
}
else if (Bstrncasecmp(arg, "mh", 1) == 0 && !SW_SHAREWARE)
{
if (strlen(arg) > 1)
G_AddDefModule(arg+1);
}
}

View file

@ -36,6 +36,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "tags.h"
#include "pal.h"
#include "common.h"
#include "common_game.h"
#define M_RED 102
@ -76,7 +77,6 @@ SWBOOL bSpinBobVoxels = TRUE; // Do twizzly stuff to voxels
SWBOOL bAutoSize = TRUE; // Autosizing on/off
int nextvoxid = 0;
char *defsfilename = "sw.def";
// Globals used to hold current sprite type being searched for.
short FindPicNum = 0;
@ -607,7 +607,7 @@ ExtInit(void)
void InitPalette(void);
int i, fil;
initgroupfile("sw.grp");
initgroupfile(G_GrpFile());
if ((fil = open("setup.dat", O_BINARY | O_RDWR, S_IREAD)) != -1)
{
read(fil, &option[0], NUMOPTIONS);
@ -655,7 +655,6 @@ int
ExtInit(void)
{
int rv = 0;
char *swgrp = "sw.grp";
#ifndef BUILD_DEV_VER
char ch;
@ -729,12 +728,17 @@ ExtInit(void)
}
}
if (getenv("SWGRP"))
if (g_grpNamePtr == NULL)
{
swgrp = getenv("SWGRP");
buildprintf("Using %s as main GRP file\n", swgrp);
const char *cp = getenv("SWGRP");
if (cp)
{
clearGrpNamePtr();
g_grpNamePtr = dup_filename(cp);
initprintf("Using \"%s\" as main GRP file\n", g_grpNamePtr);
}
initgroupfile(swgrp);
}
initgroupfile(G_GrpFile());
/*
if ((fil = open("setup.dat", O_BINARY | O_RDWR, S_IREAD)) != -1)
{

View file

@ -21,9 +21,13 @@
#include "types.h"
#include "build.h"
#include "baselayer.h"
#include "grpscan.h"
#include "common.h"
#include "common_game.h"
#define TAB_CONFIG 0
#define TAB_GAME 1
#define TAB_MESSAGES 2
@ -715,7 +719,6 @@ int startwin_idle(void *s)
}
extern int32_t ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, ForceSetup, UseMouse, UseJoystick;
extern char *grpfile; // game.c
int startwin_run(void)
{
@ -733,7 +736,7 @@ int startwin_run(void)
settings.forcesetup = ForceSetup;
settings.usemouse = UseMouse;
settings.usejoy = UseJoystick;
strncpy(settings.selectedgrp, grpfile, BMAX_PATH);
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
PopulateForm(-1);
gtk_main();
@ -748,7 +751,7 @@ int startwin_run(void)
ForceSetup = settings.forcesetup;
UseMouse = settings.usemouse;
UseJoystick = settings.usejoy;
grpfile = settings.selectedgrp;
g_grpNamePtr = dup_filename(settings.selectedgrp);
}
return retval;

View file

@ -5,6 +5,9 @@
#include "build.h"
#include "renderlayer.h"
#include "common.h"
#include "common_game.h"
#include "gamedefs.h"
#include "config.h"
@ -600,8 +603,6 @@ int startwin_idle(void *v)
return 0;
}
extern char *grpfile; // game.c
int startwin_run(void)
{
MSG msg;
@ -624,7 +625,7 @@ int startwin_run(void)
settings.forcesetup = ForceSetup;
settings.usemouse = UseMouse;
settings.usejoy = UseJoystick;
strncpy(settings.selectedgrp, grpfile, BMAX_PATH);
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
PopulateForm(-1);
while (done < 0)
@ -655,7 +656,8 @@ int startwin_run(void)
ForceSetup = settings.forcesetup;
UseMouse = settings.usemouse;
UseJoystick = settings.usejoy;
grpfile = settings.selectedgrp;
clearGrpNamePtr();
g_grpNamePtr = dup_filename(settings.selectedgrp);
}
FreeGroups();