- Duke: replaced the game type macros with inline functions.

This commit is contained in:
Christoph Oelckers 2020-10-11 11:39:51 +02:00
parent 9cc1268839
commit fc82b3bc8a
11 changed files with 36 additions and 36 deletions

View file

@ -208,6 +208,11 @@ inline bool isPlutoPak()
return g_gameType & GAMEFLAG_PLUTOPAK; return g_gameType & GAMEFLAG_PLUTOPAK;
} }
inline bool isShareware()
{
return g_gameType & GAMEFLAG_SHAREWARE;
}
TArray<GrpEntry> GrpScan(); TArray<GrpEntry> GrpScan();
void S_PauseSound(bool notmusic, bool notsfx); void S_PauseSound(bool notmusic, bool notsfx);
void S_ResumeSound(bool notsfx); void S_ResumeSound(bool notsfx);

View file

@ -222,12 +222,12 @@ public:
if (soundanm == 2 && clock >= 280 && clock < 395) if (soundanm == 2 && clock >= 280 && clock < 395)
{ {
soundanm = 3; soundanm = 3;
if (PLUTOPAK) S_PlaySound(FLY_BY, CHAN_AUTO, CHANF_UI); if (isPlutoPak()) S_PlaySound(FLY_BY, CHAN_AUTO, CHANF_UI);
} }
else if (soundanm == 3 && clock >= 395) else if (soundanm == 3 && clock >= 395)
{ {
soundanm = 4; soundanm = 4;
if (PLUTOPAK) S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); if (isPlutoPak()) S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI);
} }
double scale = clamp(clock - 120, 0, 60) / 64.; double scale = clamp(clock - 120, 0, 60) / 64.;
@ -250,7 +250,7 @@ public:
DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
} }
if (PLUTOPAK) if (isPlutoPak())
{ {
scale = (410 - clamp(clock, 280, 395)) / 16.; scale = (410 - clamp(clock, 280, 395)) / 16.;
if (scale > 0. && clock > 280) if (scale > 0. && clock > 280)
@ -295,7 +295,7 @@ void Logo_d(const CompletionFunc &completion)
int job = 0; int job = 0;
if (!userConfig.nologo) if (!userConfig.nologo)
{ {
if (VOLUMEALL) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } }; if (!isShareware()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
else jobs[job++] = { Create<DScreenJob>(), []() { S_PlaySpecialMusic(MUS_INTRO); } }; else jobs[job++] = { Create<DScreenJob>(), []() { S_PlaySpecialMusic(MUS_INTRO); } };
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr }; if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr };
} }
@ -469,7 +469,7 @@ public:
break; break;
case 6: case 6:
if (PLUTOPAK) if (isPlutoPak())
{ {
if (clock > waittime) skiprequest = true; if (clock > waittime) skiprequest = true;
} }
@ -637,8 +637,8 @@ static void bonussequence_d(int num, JobDesc *jobs, int &job)
{ {
jobs[job++] = { PlayVideo("cineov3.anm", cineov3sound, framespeed_10), nullptr }; jobs[job++] = { PlayVideo("cineov3.anm", cineov3sound, framespeed_10), nullptr };
jobs[job++] = { Create<DBlackScreen>(200), []() { FX_StopAllSounds(); } }; jobs[job++] = { Create<DBlackScreen>(200), []() { FX_StopAllSounds(); } };
jobs[job++] = { Create<DEpisode3End>(), []() { if (!PLUTOPAK) S_PlaySound(ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI); } }; jobs[job++] = { Create<DEpisode3End>(), []() { if (!isPlutoPak()) S_PlaySound(ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI); } };
if (!PLUTOPAK) jobs[job++] = { Create<DImageScreen>(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup), if (!isPlutoPak()) jobs[job++] = { Create<DImageScreen>(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup),
DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff), []() { FX_StopAllSounds(); } }; DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff), []() { FX_StopAllSounds(); } };
} }
break; break;
@ -711,7 +711,7 @@ public:
twod->ClearScreen(); twod->ClearScreen();
DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, TAG_DONE); DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, TAG_DONE);
if (PLUTOPAK) if (isPlutoPak())
DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+2, true), 260, 36, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, TAG_DONE); DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+2, true), 260, 36, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, TAG_DONE);
GameText(160, 58 + 2, GStrings("Multiplayer Totals"), 0, 0); GameText(160, 58 + 2, GStrings("Multiplayer Totals"), 0, 0);

View file

@ -2391,7 +2391,7 @@ static void greenslime(int i)
int sect = s->sectnum; int sect = s->sectnum;
int j; int j;
// #ifndef VOLUMEONE // #ifndef isShareware()
if (ud.multimode < 2) if (ud.multimode < 2)
{ {
if (actor_tog == 1) if (actor_tog == 1)

View file

@ -95,7 +95,7 @@ static const char *cheatGod(int myconnectindex, int state)
static const char* cheatUnlock() static const char* cheatUnlock()
{ {
if (VOLUMEONE) return nullptr; if (isShareware()) return nullptr;
for (int i = numsectors - 1; i >= 0; i--) //Unlock for (int i = numsectors - 1; i >= 0; i--) //Unlock
{ {
int j = sector[i].lotag; int j = sector[i].lotag;
@ -221,7 +221,7 @@ const char* GameInterface::GenericCheat(int player, int cheat)
static bool cheatWeapons(int player) static bool cheatWeapons(int player)
{ {
int weaponLimit = (VOLUMEONE) ? SHRINKER_WEAPON : MAX_WEAPONS; int weaponLimit = (isShareware()) ? SHRINKER_WEAPON : MAX_WEAPONS;
for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ ) for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ )
{ {
@ -493,7 +493,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
case GIVE_AMMO: case GIVE_AMMO:
{ {
int maxw = VOLUMEONE ? SHRINKER_WEAPON : MAX_WEAPONS; int maxw = isShareware() ? SHRINKER_WEAPON : MAX_WEAPONS;
for (int i = maxw; i >= PISTOL_WEAPON; i--) for (int i = maxw; i >= PISTOL_WEAPON; i--)
addammo(i, &ps[player], max_ammo_amount[i]); addammo(i, &ps[player], max_ammo_amount[i]);
break; break;

View file

@ -422,8 +422,3 @@ enum gamemode_t {
MODE_GAME = 0x00000004, MODE_GAME = 0x00000004,
MODE_EOL = 0x00000008, MODE_EOL = 0x00000008,
}; };
#define VOLUMEALL ((g_gameType & GAMEFLAG_SHAREWARE) == 0)
#define PLUTOPAK ((g_gameType & GAMEFLAG_PLUTOPAK) != 0)
#define VOLUMEONE ((g_gameType & GAMEFLAG_SHAREWARE) != 0)

View file

@ -98,14 +98,14 @@ template <class func>
void runtwoscreens(func completion) void runtwoscreens(func completion)
{ {
// shareware and TEN screens // shareware and TEN screens
if (!VOLUMEALL && !isRR()) if (!isShareware() && !isRR())
showtwoscreens(completion); showtwoscreens(completion);
else completion(false); else completion(false);
} }
static void endthegame(bool) static void endthegame(bool)
{ {
endoomName = isRR() ? "redneck.bin" : VOLUMEALL ? "duke3d.bin" : "dukesw.bin"; endoomName = isRR() ? "redneck.bin" : !isShareware() ? "duke3d.bin" : "dukesw.bin";
ST_Endoom(); ST_Endoom();
} }

View file

@ -50,7 +50,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
BEGIN_DUKE_NS BEGIN_DUKE_NS
#define VERSIONCHECK 41 enum { VERSIONCHECK = 41 };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1916,7 +1916,7 @@ int ConCompiler::parsecommand()
camerashitable = parseone(); camerashitable = parseone();
numfreezebounces = parseone(); numfreezebounces = parseone();
freezerhurtowner = parseone(); freezerhurtowner = parseone();
if (PLUTOPAK || isRR()) if (isPlutoPak() || isRR())
{ {
spriteqamount = clamp(parseone(), 0, 1024); spriteqamount = clamp(parseone(), 0, 1024);
lasermode = parseone(); lasermode = parseone();

View file

@ -1735,7 +1735,7 @@ int ParseState::parse(void)
// JBF 20030805: As I understand it, if xrepeat becomes 0 it basically kills the // JBF 20030805: As I understand it, if xrepeat becomes 0 it basically kills the
// sprite, which is why the "sizeto 0 41" calls in 1.3d became "sizeto 4 41" in // sprite, which is why the "sizeto 0 41" calls in 1.3d became "sizeto 4 41" in
// 1.4, so instead of patching the CONs I'll surruptitiously patch the code here // 1.4, so instead of patching the CONs I'll surruptitiously patch the code here
//if (!PLUTOPAK && *insptr == 0) *insptr = 4; //if (!isPlutoPak() && *insptr == 0) *insptr = 4;
j = ((*insptr) - g_sp->xrepeat) << 1; j = ((*insptr) - g_sp->xrepeat) << 1;
g_sp->xrepeat += ksgn(j); g_sp->xrepeat += ksgn(j);

View file

@ -1133,7 +1133,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
switch (p->curr_weapon) switch (p->curr_weapon)
{ {
case SHRINKER_WEAPON: case SHRINKER_WEAPON:
j = PLUTOPAK ? GROW_WEAPON : p->curr_weapon; j = isPlutoPak() ? GROW_WEAPON : p->curr_weapon;
break; break;
case GROW_WEAPON: case GROW_WEAPON:
j = SHRINKER_WEAPON; j = SHRINKER_WEAPON;
@ -1155,7 +1155,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
j = (weap == WeaponSel_Prev ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice j = (weap == WeaponSel_Prev ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice
i = 0; i = 0;
while ((k >= 0 && k < 10) || (PLUTOPAK && k == GROW_WEAPON && (p->subweapon & (1 << GROW_WEAPON)) != 0) while ((k >= 0 && k < 10) || (isPlutoPak() && k == GROW_WEAPON && (p->subweapon & (1 << GROW_WEAPON)) != 0)
|| (isWorldTour() && k == FLAMETHROWER_WEAPON && (p->subweapon & (1 << FLAMETHROWER_WEAPON)) != 0)) || (isWorldTour() && k == FLAMETHROWER_WEAPON && (p->subweapon & (1 << FLAMETHROWER_WEAPON)) != 0))
{ {
if (k == FLAMETHROWER_WEAPON) //Twentieth Anniversary World Tour if (k == FLAMETHROWER_WEAPON) //Twentieth Anniversary World Tour
@ -1174,7 +1174,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
{ {
k += j; k += j;
// JBF 20040116: so we don't select grower with v1.3d // JBF 20040116: so we don't select grower with v1.3d
if (PLUTOPAK && k == SHRINKER_WEAPON && (p->subweapon & (1 << GROW_WEAPON))) // JBF: activates grower if (isPlutoPak() && k == SHRINKER_WEAPON && (p->subweapon & (1 << GROW_WEAPON))) // JBF: activates grower
k = GROW_WEAPON; // if enabled k = GROW_WEAPON; // if enabled
if (isWorldTour() && k == FREEZE_WEAPON && (p->subweapon & (1 << FLAMETHROWER_WEAPON)) != 0) if (isWorldTour() && k == FREEZE_WEAPON && (p->subweapon & (1 << FLAMETHROWER_WEAPON)) != 0)
k = FLAMETHROWER_WEAPON; k = FLAMETHROWER_WEAPON;
@ -1185,7 +1185,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
if (p->gotweapon[k] && p->ammo_amount[k] > 0) if (p->gotweapon[k] && p->ammo_amount[k] > 0)
{ {
if (PLUTOPAK) // JBF 20040116: so we don't select grower with v1.3d if (isPlutoPak()) // JBF 20040116: so we don't select grower with v1.3d
if (k == SHRINKER_WEAPON && (p->subweapon & (1 << GROW_WEAPON))) if (k == SHRINKER_WEAPON && (p->subweapon & (1 << GROW_WEAPON)))
k = GROW_WEAPON; k = GROW_WEAPON;
if (isWorldTour() && k == FREEZE_WEAPON && (p->subweapon & (1 << FLAMETHROWER_WEAPON)) != 0) if (isWorldTour() && k == FREEZE_WEAPON && (p->subweapon & (1 << FLAMETHROWER_WEAPON)) != 0)
@ -1194,13 +1194,13 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
j = k; j = k;
break; break;
} }
else if (PLUTOPAK && k == GROW_WEAPON && p->ammo_amount[GROW_WEAPON] == 0 && p->gotweapon[SHRINKER_WEAPON] && p->ammo_amount[SHRINKER_WEAPON] > 0) // JBF 20040116: added PLUTOPAK so we don't select grower with v1.3d else if (isPlutoPak() && k == GROW_WEAPON && p->ammo_amount[GROW_WEAPON] == 0 && p->gotweapon[SHRINKER_WEAPON] && p->ammo_amount[SHRINKER_WEAPON] > 0) // JBF 20040116: added isPlutoPak() so we don't select grower with v1.3d
{ {
j = SHRINKER_WEAPON; j = SHRINKER_WEAPON;
p->subweapon &= ~(1 << GROW_WEAPON); p->subweapon &= ~(1 << GROW_WEAPON);
break; break;
} }
else if (PLUTOPAK && k == SHRINKER_WEAPON && p->ammo_amount[SHRINKER_WEAPON] == 0 && p->gotweapon[SHRINKER_WEAPON] && p->ammo_amount[GROW_WEAPON] > 0) // JBF 20040116: added PLUTOPAK so we don't select grower with v1.3d else if (isPlutoPak() && k == SHRINKER_WEAPON && p->ammo_amount[SHRINKER_WEAPON] == 0 && p->gotweapon[SHRINKER_WEAPON] && p->ammo_amount[GROW_WEAPON] > 0) // JBF 20040116: added isPlutoPak() so we don't select grower with v1.3d
{ {
j = GROW_WEAPON; j = GROW_WEAPON;
p->subweapon |= (1 << GROW_WEAPON); p->subweapon |= (1 << GROW_WEAPON);
@ -1274,7 +1274,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
p->subweapon &= ~(1 << FLAMETHROWER_WEAPON); p->subweapon &= ~(1 << FLAMETHROWER_WEAPON);
} }
if (j == SHRINKER_WEAPON && PLUTOPAK) // JBF 20040116: so we don't select the grower with v1.3d if (j == SHRINKER_WEAPON && isPlutoPak()) // JBF 20040116: so we don't select the grower with v1.3d
{ {
if (p->curr_weapon != GROW_WEAPON && p->curr_weapon != SHRINKER_WEAPON) if (p->curr_weapon != GROW_WEAPON && p->curr_weapon != SHRINKER_WEAPON)
{ {

View file

@ -859,12 +859,12 @@ void newgame(MapRecord* map, int sk, func completion)
static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode) static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode)
{ {
int16_t lbang; int16_t lbang;
if (VOLUMEONE && (mi->flags & MI_USERMAP)) if (isShareware() && (mi->flags & MI_USERMAP))
{ {
I_Error("Cannot load user maps with shareware version!\n"); I_Error("Cannot load user maps with shareware version!\n");
} }
engineLoadBoard(mi->fileName, VOLUMEONE, &p->pos, &lbang, &p->cursectnum); engineLoadBoard(mi->fileName, isShareware(), &p->pos, &lbang, &p->cursectnum);
currentLevel = mi; currentLevel = mi;
SECRET_SetMapName(mi->DisplayName(), mi->name); SECRET_SetMapName(mi->DisplayName(), mi->name);
@ -953,7 +953,7 @@ void enterlevel(MapRecord *mi, int gamemode)
S_PlayLevelMusic(mi); S_PlayLevelMusic(mi);
} }
if (VOLUMEONE && mi->levelNumber == 0 && ud.recstat != 2) FTA(QUOTE_F1HELP, &ps[myconnectindex]); if (isShareware() && mi->levelNumber == 0 && ud.recstat != 2) FTA(QUOTE_F1HELP, &ps[myconnectindex]);
for (int i = connecthead; i >= 0; i = connectpoint2[i]) for (int i = connecthead; i >= 0; i = connectpoint2[i])
{ {
@ -1084,7 +1084,7 @@ void exitlevel(MapRecord *nextlevel)
{ {
if (ud.multimode < 2) if (ud.multimode < 2)
{ {
if (!VOLUMEALL) if (isShareware())
doorders([](bool) { gameaction = ga_startup; }); doorders([](bool) { gameaction = ga_startup; });
else gameaction = ga_startup; else gameaction = ga_startup;
return; return;

View file

@ -119,8 +119,8 @@ public:
FString format; FString format;
FGameTexture* img; FGameTexture* img;
double imgScale; double imgScale;
double baseScale = (scale * numberFont.mFont->GetHeight()) * (isNamWW2GI() ? 0.65 : !PLUTOPAK ? 0.75 : 0.7); double baseScale = (scale * numberFont.mFont->GetHeight()) * (isNamWW2GI() ? 0.65 : !isPlutoPak() ? 0.75 : 0.7);
double texty = -numberFont.mFont->GetHeight() + (isNamWW2GI() ? 2.5 : !PLUTOPAK ? 3.5 : 4.5); double texty = -numberFont.mFont->GetHeight() + (isNamWW2GI() ? 2.5 : !isPlutoPak() ? 3.5 : 4.5);
// //
// Health // Health
@ -303,7 +303,7 @@ public:
void DrawWeaponNum(int index, double x, double y, int num1, int num2, int shade, int numdigits) void DrawWeaponNum(int index, double x, double y, int num1, int num2, int shade, int numdigits)
{ {
/* /*
if (VOLUMEONE && (ind > HANDBOMB_WEAPON || ind < 0)) if (isShareware() && (ind > HANDBOMB_WEAPON || ind < 0))
{ {
minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX); minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX);
return; return;