From 0c5d9f8cbee8123a474a5c13de0658456d1692a6 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 18 Jan 2017 22:21:08 +0000 Subject: [PATCH] Initial work on standalone (non-Duke3D) binary support. git-svn-id: https://svn.eduke32.com/eduke32@6009 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile.common | 5 +++++ polymer/eduke32/source/cheats.c | 11 +++++++---- polymer/eduke32/source/cheats.h | 3 ++- polymer/eduke32/source/common.c | 27 ++++++++++++++++++++++++--- polymer/eduke32/source/game.c | 6 ++++-- polymer/eduke32/source/grpscan.c | 8 ++++++++ polymer/eduke32/source/menus.c | 2 ++ 7 files changed, 52 insertions(+), 10 deletions(-) diff --git a/polymer/eduke32/Makefile.common b/polymer/eduke32/Makefile.common index 405ee5d81..e1b7821cc 100644 --- a/polymer/eduke32/Makefile.common +++ b/polymer/eduke32/Makefile.common @@ -171,6 +171,8 @@ APPLE_FRAMEWORKS ?=/Library/Frameworks # LINKED_GTK - enables compile-time linkage to GTK # APPNAME ?= EDuke32 +APPBASENAME ?= eduke32 +STANDALONE ?= 0 POLYMER = 1 USE_OPENGL = 1 NOASM = 0 @@ -670,6 +672,9 @@ ifneq (0,$(DMALLOC)) LIBS+= -ldmalloc COMPILERFLAGS+= -DDMALLOC endif +ifneq (0,$(STANDALONE)) + COMPILERFLAGS+= -DEDUKE32_STANDALONE +endif COMPILERFLAGS+= -DAPPNAME=\"$(APPNAME)\" diff --git a/polymer/eduke32/source/cheats.c b/polymer/eduke32/source/cheats.c index 18822a8f9..a64d60b60 100644 --- a/polymer/eduke32/source/cheats.c +++ b/polymer/eduke32/source/cheats.c @@ -25,8 +25,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "cheats.h" // KEEPINSYNC game.h: enum cheatindex_t -char CheatStrings [][MAXCHEATLEN] = +char CheatStrings [NUMCHEATS][MAXCHEATLEN] = { +#ifndef EDUKE32_STANDALONE "cornholio", // 0 "stuff", // 1 "scotty###", // 2 @@ -54,9 +55,10 @@ char CheatStrings [][MAXCHEATLEN] = "debug", // 24 "", // 25 "cgs", // 26 +#endif }; -const uint32_t CheatFunctionFlags [] = +const uint32_t CheatFunctionFlags [NUMCHEATS] = { 1 << CHEATFUNC_GOD, 1 << CHEATFUNC_GIVEEVERYTHING, @@ -89,7 +91,7 @@ const uint32_t CheatFunctionFlags [] = // KEEPINSYNC game.h: enum CheatCodeFunctions // KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[] -const uint8_t CheatFunctionIDs [] = +const uint8_t CheatFunctionIDs[NUMCHEATS] = { CHEAT_CASHMAN, CHEAT_CORNHOLIO, @@ -116,6 +118,7 @@ const uint8_t CheatFunctionIDs [] = char const * const g_NAMMattCheatQuote = "Matt Saettler. matts@saettler.com"; +#ifndef EDUKE32_STANDALONE void G_SetupCheats(void) { // KEEPINSYNC: NAM_WW2GI_CHEATS @@ -189,7 +192,7 @@ void G_SetupCheats(void) Bstrcpy(g_gametypeNames[2], "GruntMatch (No Spawn)"); } } - +#endif static void doinvcheat(DukePlayer_t * const pPlayer, int32_t invidx, int32_t defaultnum, int32_t event) { diff --git a/polymer/eduke32/source/cheats.h b/polymer/eduke32/source/cheats.h index 32e9d1bbd..15a82e96a 100644 --- a/polymer/eduke32/source/cheats.h +++ b/polymer/eduke32/source/cheats.h @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. extern void G_DoCheats(void); extern void G_SetupCheats(void); -extern char CheatStrings [][MAXCHEATLEN]; extern char const * const g_NAMMattCheatQuote; // Cheats @@ -62,6 +61,8 @@ enum cheatindex_t NUMCHEATS, }; +extern char CheatStrings[NUMCHEATS][MAXCHEATLEN]; + // KEEPINSYNC game.c: uint8_t CheatFunctionIDs[] // KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[] enum CheatCodeFunctions diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index 80153b645..ff7e72788 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -34,10 +34,12 @@ const char *g_gameNamePtr = NULL; // grp/con handling +static const char *defaultconfilename = "GAME.CON"; +#ifndef EDUKE32_STANDALONE static const char *defaultgamegrp[GAMECOUNT] = { "DUKE3D.GRP", "NAM.GRP", "NAPALM.GRP", "WW2GI.GRP" }; static const char *defaultdeffilename[GAMECOUNT] = { "duke3d.def", "nam.def", "napalm.def", "ww2gi.def" }; -static const char *defaultconfilename = "GAME.CON"; static const char *defaultgameconfilename[GAMECOUNT] = { "EDUKE.CON", "NAM.CON", "NAPALM.CON", "WW2GI.CON" }; +#endif // g_grpNamePtr can ONLY point to a malloc'd block (length BMAX_PATH) char *g_grpNamePtr = NULL; @@ -58,6 +60,7 @@ void clearScriptNamePtr(void) const char *G_DefaultGrpFile(void) { +#ifndef EDUKE32_STANDALONE if (DUKE) return defaultgamegrp[GAME_DUKE]; else if (NAPALM) @@ -68,9 +71,13 @@ const char *G_DefaultGrpFile(void) return defaultgamegrp[GAME_NAM]; return defaultgamegrp[0]; +#else + return "(none)"; +#endif } const char *G_DefaultDefFile(void) { +#ifndef EDUKE32_STANDALONE if (DUKE) return defaultdeffilename[GAME_DUKE]; else if (WW2GI) @@ -91,9 +98,13 @@ const char *G_DefaultDefFile(void) } return defaultdeffilename[0]; +#else + return "(none)"; +#endif } const char *G_DefaultConFile(void) { +#ifndef EDUKE32_STANDALONE if (DUKE && testkopen(defaultgameconfilename[GAME_DUKE],0)) return defaultgameconfilename[GAME_DUKE]; else if (WW2GI && testkopen(defaultgameconfilename[GAME_WW2GI],0)) @@ -118,7 +129,7 @@ const char *G_DefaultConFile(void) else return defaultgameconfilename[GAME_NAM]; } - +#endif return defaultconfilename; } @@ -301,7 +312,7 @@ void G_ExtInit(void) { Bsnprintf(cwd,sizeof(cwd),"%s/" #if defined(_WIN32) - "EDuke32 Settings" + APPNAME " Settings" #elif defined(GEKKO) "apps/eduke32" #else @@ -321,6 +332,7 @@ void G_ExtInit(void) } // JBF 20031220: Because it's annoying renaming GRP files whenever I want to test different game data +#ifndef EDUKE32_STANDALONE if (g_grpNamePtr == NULL) { const char *cp = getenv("DUKE3DGRP"); @@ -331,6 +343,7 @@ void G_ExtInit(void) initprintf("Using \"%s\" as main GRP file\n", g_grpNamePtr); } } +#endif } void G_ScanGroups(void) @@ -447,6 +460,7 @@ void G_LoadGroups(int32_t autoload) if (g_modDir[0] != '/') G_LoadGroupsInDir(g_modDir); +#ifndef EDUKE32_STANDALONE if (g_defNamePtr == NULL) { const char *tmpptr = getenv("DUKE3DDEF"); @@ -457,6 +471,7 @@ void G_LoadGroups(int32_t autoload) initprintf("Using \"%s\" as definitions file\n", g_defNamePtr); } } +#endif loaddefinitions_game(G_DefFile(), TRUE); @@ -508,6 +523,7 @@ static int G_ReadRegistryValue(char const * const SubKey, char const * const Val static void G_LoadAddon(void) { +#ifndef EDUKE32_STANDALONE int32_t crc = 0; // compiler-happy switch (g_addonNum) @@ -529,8 +545,10 @@ static void G_LoadAddon(void) if (grp) g_selectedGrp = grp; +#endif } +#ifndef EDUKE32_STANDALONE #ifndef EDUKE32_TOUCH_DEVICES #if defined EDUKE32_OSX || defined __linux__ || defined EDUKE32_BSD static void G_AddSteamPaths(const char *basepath) @@ -734,9 +752,11 @@ static void G_ParseSteamKeyValuesForPaths(const char *vdf) } #endif #endif +#endif void G_AddSearchPaths(void) { +#ifndef EDUKE32_STANDALONE #ifndef EDUKE32_TOUCH_DEVICES #if defined __linux__ || defined EDUKE32_BSD char buf[BMAX_PATH]; @@ -870,6 +890,7 @@ void G_AddSearchPaths(void) } #endif #endif +#endif } void G_CleanupSearchPaths(void) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index f8e994f20..6129d5869 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -6214,11 +6214,12 @@ int app_main(int argc, char const * const * argv) G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad); // flushlogwindow = 1; - G_SetupCheats(); - if (!g_useCwd) G_CleanupSearchPaths(); +#ifndef EDUKE32_STANDALONE + G_SetupCheats(); + if (SHAREWARE) g_Shareware = 1; else @@ -6231,6 +6232,7 @@ int app_main(int argc, char const * const * argv) kclose(kFile); } } +#endif // gotta set the proper title after we compile the CONs if this is the full version diff --git a/polymer/eduke32/source/grpscan.c b/polymer/eduke32/source/grpscan.c index 7fb9c7013..a310356d1 100644 --- a/polymer/eduke32/source/grpscan.c +++ b/polymer/eduke32/source/grpscan.c @@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "common_game.h" #include "grpscan.h" +#ifndef EDUKE32_STANDALONE static void process_vaca13(int32_t crcval); static void process_vacapp15(int32_t crcval); @@ -65,6 +66,7 @@ static internalgrpinfo_t const internalgrpfiles[] = { "NAPALM", NAPALM_CRC, 44365728, GAMEFLAG_NAM|GAMEFLAG_NAPALM, 0, NULL, NULL}, { "WWII GI", WW2GI_CRC, 77939508, GAMEFLAG_WW2GI, 0, NULL, NULL}, }; +#endif struct grpfile_t *foundgrps = NULL; struct grpinfo_t *listgrps = NULL; @@ -76,6 +78,7 @@ static void LoadList(const char * 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); @@ -97,6 +100,7 @@ static void LoadList(const char * filename) scriptfile_addsymbolvalue("NAM_CRC", NAM_CRC); scriptfile_addsymbolvalue("NAPALM_CRC", NAPALM_CRC); scriptfile_addsymbolvalue("WW2GI_CRC", WW2GI_CRC); +#endif while (!scriptfile_eof(script)) { @@ -197,6 +201,7 @@ static void LoadList(const char * filename) 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)); @@ -215,6 +220,7 @@ static void LoadGameList(void) fg->next = listgrps; listgrps = fg; } +#endif CACHE1D_FIND_REC * const srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE); @@ -505,6 +511,7 @@ void FreeGroups(void) FreeGameList(); } +#ifndef EDUKE32_STANDALONE static void process_vaca13(int32_t crcval) { krename(crcval, 0, "ADDREE.VOC"); @@ -646,3 +653,4 @@ static void process_vacapp15(int32_t crcval) initgroupfile("VACATION.PRG"); } +#endif diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index ccd6a3b22..38212026c 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2196,6 +2196,7 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) case MENU_CREDITS: case MENU_CREDITS2: case MENU_CREDITS3: +#ifndef EDUKE32_STANDALONE if (!VOLUMEALL || !PLUTOPAK) { switch (cm) @@ -2317,6 +2318,7 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) } } break; +#endif case MENU_CREDITS4: // JBF 20031220 l = 7;