Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Sigil II #1129

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/crispy.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/crispy.h

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/crispy.h

File src/crispy.h does not conform to Custom style guidelines. (lines 100, 117)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
// Copyright(C) 2014-2017 Fabian Greffrath
Expand Down Expand Up @@ -97,6 +97,7 @@
boolean fliplevels;
boolean flipweapons;
boolean haved1e5;
boolean haved1e6;
boolean havee1m10;
boolean havemap33;
boolean havessg;
Expand All @@ -113,6 +114,7 @@
char *havenerve;
char *havemaster;
char *havesigil;
char *havesigil2;

const char *sdlversion;
const char *platform;
Expand Down
20 changes: 20 additions & 0 deletions src/doom/d_englsh.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/d_englsh.h

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/d_englsh.h

File src/doom/d_englsh.h does not conform to Custom style guidelines. (lines 210, 211, 212, 213, 214, 215, 216, 217, 218, 524, 525, 526, 527, 528, 529, 530, 531)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -207,6 +207,16 @@
#define HUSTR_E5M8 "E5M8: Halls of Perdition"
#define HUSTR_E5M9 "E5M9: Realm of Iblis"

#define HUSTR_E6M1 "E6M1: Cursed Darkness"
#define HUSTR_E6M2 "E6M2: Violent Hatred"
#define HUSTR_E6M3 "E6M3: Twilight Desolation"
#define HUSTR_E6M4 "E6M4: Fragments of Sanity"
#define HUSTR_E6M5 "E6M5: Wrathful Reckoning"
#define HUSTR_E6M6 "E6M6: Vengeance Unleashed"
#define HUSTR_E6M7 "E6M7: Descent Into Terror"
#define HUSTR_E6M8 "E6M8: Abyss of Despair"
#define HUSTR_E6M9 "E6M9: Shattered Homecoming"

#define HUSTR_1 "level 1: entryway"
#define HUSTR_2 "level 2: underhalls"
#define HUSTR_3 "level 3: the gantlet"
Expand Down Expand Up @@ -511,6 +521,16 @@
"\n"\
"Lock and load. Rip and tear."

#define E6TEXT \
"Satan erred in casting you to Hell's\n"\
"darker depths. His plan failed. He has\n"\
"tried for so long to destroy you, and he\n"\
"has lost every single time. His only\n"\
"option is to flood Earth with demons\n"\
"and hope you go down fighting.\n"\
"\n"\
"Prepare for HELLION!"

// after level 6, put this:

#define C1TEXT \
Expand Down
8 changes: 7 additions & 1 deletion src/doom/d_main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/d_main.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/d_main.c

File src/doom/d_main.c does not conform to Custom style guidelines. (lines 1996)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -1993,7 +1993,7 @@
gamevariant != freedoom &&
strncasecmp(M_BaseName(iwadfile), "rekkr", 5))
{
D_LoadSigilWad();
D_LoadSigilWads();
}

if (gamemission == doom2)
Expand Down Expand Up @@ -2132,6 +2132,12 @@
(W_CheckNumForName("e5m1") != -1) &&
(W_CheckNumForName("wilv40") != -1);

// [crispy] check for presence of a 6th episode
crispy->haved1e6 = (gameversion == exe_ultimate) &&
(W_CheckNumForName("m_epi6") != -1) &&
(W_CheckNumForName("e6m1") != -1) &&
(W_CheckNumForName("wilv50") != -1);

// [crispy] check for presence of E1M10
crispy->havee1m10 = (gamemode == retail) &&
(W_CheckNumForName("e1m10") != -1) &&
Expand Down
180 changes: 155 additions & 25 deletions src/doom/d_pwad.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/d_pwad.c

File src/doom/d_pwad.c does not conform to Custom style guidelines. (lines 36, 41, 74, 81, 84, 86, 89, 94, 113, 177, 188, 191, 192, 193, 194, 196, 197, 198, 199, 200, 201, 202, 212, 228, 260, 281)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
// Copyright(C) 2020 Fabian Greffrath
Expand Down Expand Up @@ -28,16 +28,17 @@
#include "m_misc.h"
#include "w_main.h"
#include "w_wad.h"
#include "w_merge.h" // [crispy] W_MergeFile()

extern char *iwadfile;

// [crispy] auto-load SIGIL.WAD (and SIGIL_SHREDS.WAD) if available
void D_LoadSigilWad (void)
static boolean LoadSigilWad (const char *iwaddir, boolean pwadtexture)

Check warning on line 36 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:36:16 [readability-function-cognitive-complexity]

function 'LoadSigilWad' has cognitive complexity of 27 (threshold 25)
{
int i, j;
char *sigil_shreds = NULL;
const char *sigil_basename;
char *dirname, *autoload_dir;
char *autoload_dir;

Check warning on line 41 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:41:8 [cppcoreguidelines-init-variables]

variable 'autoload_dir' is not initialized

const char *const sigil_wads[] = {
"SIGIL_v1_21.wad",
Expand All @@ -61,12 +62,6 @@
{"D_INTRO", "D_SIGTIT"},
};

const char *const texture_files[] = {
"PNAMES",
"TEXTURE1",
"TEXTURE2",
};

// [crispy] don't load SIGIL.WAD if another PWAD already provides E5M1
i = W_CheckNumForName("E5M1");
if (i != -1)
Expand All @@ -76,34 +71,27 @@
{
crispy->havesigil = (char *)-1;
}
return;
return false;
}

// [crispy] don't load SIGIL.WAD if SIGIL_COMPAT.WAD is already loaded
i = W_CheckNumForName("E3M1");
if (i != -1 && !strncasecmp(W_WadNameForLump(lumpinfo[i]), "SIGIL_COMPAT", 12))
{
return;
return false;
}

// [crispy] don't load SIGIL.WAD if another PWAD already modifies the texture files
for (i = 0; i < arrlen(texture_files); i++)
if (pwadtexture)
{
j = W_CheckNumForName(texture_files[i]);

if (j != -1 && !W_IsIWADLump(lumpinfo[j]))
{
return;
}
return false;
}

dirname = M_DirName(iwadfile);
sigil_shreds = M_StringJoin(dirname, DIR_SEPARATOR_S, "SIGIL_SHREDS.WAD", NULL);
sigil_shreds = M_StringJoin(iwaddir, DIR_SEPARATOR_S, "SIGIL_SHREDS.WAD", NULL);

// [crispy] load SIGIL.WAD
for (i = 0; i < arrlen(sigil_wads); i++)
{
crispy->havesigil = M_StringJoin(dirname, DIR_SEPARATOR_S, sigil_wads[i], NULL);
crispy->havesigil = M_StringJoin(iwaddir, DIR_SEPARATOR_S, sigil_wads[i], NULL);

if (M_FileExists(crispy->havesigil))
{
Expand All @@ -118,12 +106,11 @@
break;
}
}
free(dirname);

if (crispy->havesigil == NULL)
{
free(sigil_shreds);
return;
return false;
}

printf(" [Sigil] adding %s\n", crispy->havesigil);
Expand Down Expand Up @@ -183,8 +170,151 @@
}
}

// [crispy] regenerate the hashtable
W_GenerateHashTable();
return true;
}

// [crispy] auto-load Sigil II
static boolean LoadSigil2Wad (const char *iwaddir, boolean pwadtexture)
{
int i, j;

Check warning on line 179 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:179:5 [readability-isolate-declaration]

multiple declarations in a single statement reduces readability

Check warning on line 179 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:179:9 [cppcoreguidelines-init-variables]

variable 'i' is not initialized

Check warning on line 179 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:179:9 [readability-identifier-length]

variable name 'i' is too short, expected at least 3 characters

Check warning on line 179 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:179:12 [cppcoreguidelines-init-variables]

variable 'j' is not initialized

Check warning on line 179 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:179:12 [readability-identifier-length]

variable name 'j' is too short, expected at least 3 characters
const char *sigil2_basename;

Check warning on line 180 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:180:17 [cppcoreguidelines-init-variables]

variable 'sigil2_basename' is not initialized
char *autoload_dir;

Check warning on line 181 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:181:11 [cppcoreguidelines-init-variables]

variable 'autoload_dir' is not initialized

const char *const sigil2_wads[] = {
"SIGIL_II_MP3_V1_0.WAD",
"SIGIL_II_V1_0.WAD",
};

static const struct {
const char *name;
const char new_name[8];
} sigil2_lumps [] = {
ceski-1 marked this conversation as resolved.
Show resolved Hide resolved
{"CREDIT", "SG2CREDI"},
{"HELP1", "SG2HELP1"},
{"TITLEPIC", "SG2TITLE"},
{"SIGILEND", "SGL2END"},
{"DEHACKED", "SG2_DEH"},
{"DEMO1", "SG2DEMO1"},
{"DEMO2", "SG2DEMO2"},
{"DEMO3", "SG2DEMO3"},
{"DEMO4", "SG2DEMO4"},
{"D_INTER", "D_SG2INT"},
{"D_INTRO", "D_SG2TIT"},
};

// [crispy] don't load Sigil II if another PWAD already provides E6M1
i = W_CheckNumForName("E6M1");
if (i != -1)
{
// [crispy] indicate that SIGIL_II_*.WAD is already loaded as a PWAD
if (!strncasecmp(W_WadNameForLump(lumpinfo[i]), "SIGIL_II", 8))
{
crispy->havesigil2 = (char *)-1;

Check warning on line 212 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:212:34 [performance-no-int-to-ptr]

integer to pointer cast pessimizes optimization opportunities
}

return false;
}

// [crispy] don't load Sigil II if another PWAD already modifies the
// texture files
if (pwadtexture)
{
return false;
}

// [crispy] load Sigil II
for (i = 0; i < arrlen(sigil2_wads); i++)
{
crispy->havesigil2 = M_StringJoin(iwaddir, DIR_SEPARATOR_S,
sigil2_wads[i], NULL);

if (M_FileExists(crispy->havesigil2))
{
break;
}

free(crispy->havesigil2);
crispy->havesigil2 = D_FindWADByName(sigil2_wads[i]);

if (crispy->havesigil2)
{
break;
}
}

if (crispy->havesigil2 == NULL)
{
return false;
}

printf(" [Sigil II] adding %s\n", crispy->havesigil2);
W_MergeFile(crispy->havesigil2);
sigil2_basename = M_BaseName(crispy->havesigil2);

// [crispy] rename intrusive Sigil II graphics, demos and music lumps out
// of the way
for (i = 0; i < arrlen(sigil2_lumps); i++)
{
j = W_CheckNumForName(sigil2_lumps[i].name);

if (j != -1 && !strcasecmp(W_WadNameForLump(lumpinfo[j]), sigil2_basename))
{
memcpy(lumpinfo[j]->name, sigil2_lumps[i].new_name, 8);
}
}

// [crispy] load WAD and DEH files from autoload directories
if (!M_ParmExists("-noautoload"))
{
if ((autoload_dir = M_GetAutoloadDir(sigil2_basename, false)))
{
W_AutoLoadWADs(autoload_dir);
DEH_AutoLoadPatches(autoload_dir);
free(autoload_dir);
}
}

return true;
}

// [crispy] auto-load Sigil and Sigil II if available
void D_LoadSigilWads (void)
{
int i, j;
boolean sigilloaded, sigil2loaded;
boolean pwadtexture = false;
char *iwaddir;

const char *const texture_file[] = {
"PNAMES",
"TEXTURE1",
"TEXTURE2",
};

// [crispy] don't load Sigils if another PWAD already modifies the texture
// files
for (i = 0; i < arrlen(texture_file); i++)
{
j = W_CheckNumForName(texture_file[i]);

if (j != -1 && !W_IsIWADLump(lumpinfo[j]))
{
pwadtexture = true;
break;
}
}

iwaddir = M_DirName(iwadfile);
sigilloaded = LoadSigilWad(iwaddir, pwadtexture);
sigil2loaded = LoadSigil2Wad(iwaddir, pwadtexture);

if (sigilloaded || sigil2loaded)
{
// [crispy] regenerate the hashtable
W_GenerateHashTable();
}

free(iwaddir);
}

// [crispy] check if NERVE.WAD is already loaded as a PWAD
Expand Down
2 changes: 1 addition & 1 deletion src/doom/d_pwad.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef __D_PWAD__
#define __D_PWAD__

void D_LoadSigilWad(void);
void D_LoadSigilWads(void);
void D_LoadNerveWad(void);
void D_LoadMasterlevelsWad(void);

Expand Down
4 changes: 2 additions & 2 deletions src/doom/deh_bexpars.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/deh_bexpars.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/deh_bexpars.c

File src/doom/deh_bexpars.c does not conform to Custom style guidelines. (lines 46)
// Copyright(C) 2005-2014 Simon Howard
// Copyright(C) 2014 Fabian Greffrath
//
Expand All @@ -22,7 +22,7 @@
#include "deh_bexpars.h"
#include "deh_io.h"

int bex_pars[6][10] = {{0}};
int bex_pars[7][10] = {{0}};
int bex_cpars[32] = {0};

static void *DEH_BEXParsStart(deh_context_t *context, char *line)
Expand All @@ -43,7 +43,7 @@

if (sscanf(line, "par %32d %32d %32d", &episode, &map, &partime) == 3)
{
if (episode >= 1 && episode <= 5 && map >= 1 && map <= 9)
if (episode >= 1 && episode <= 6 && map >= 1 && map <= 9)
bex_pars[episode][map] = partime;
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/doom/deh_bexpars.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef DEH_BEXPARS_H
#define DEH_BEXPARS_H

extern int bex_pars[6][10];
extern int bex_pars[7][10];
extern int bex_cpars[32];

#endif /* #ifndef DEH_BEXPARS_H */
14 changes: 14 additions & 0 deletions src/doom/f_finale.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/f_finale.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/f_finale.c

File src/doom/f_finale.c does not conform to Custom style guidelines. (lines 79)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -76,6 +76,7 @@
{ doom, 3, 8, "MFLR8_4", E3TEXT},
{ doom, 4, 8, "MFLR8_3", E4TEXT},
{ doom, 5, 8, "FLOOR7_2", E5TEXT}, // [crispy] Sigil
{ doom, 6, 8, "FLOOR7_2", E6TEXT}, // [crispy] Sigil II

{ doom2, 1, 6, "SLIME16", C1TEXT},
{ doom2, 1, 11, "RROCK14", C2TEXT},
Expand Down Expand Up @@ -1018,6 +1019,19 @@
return;
}
break;
// [crispy] Sigil II
case 6:
lumpname = "SGL2END";
if (W_CheckNumForName(DEH_String(lumpname)) == -1)
{
lumpname = "SIGILEND";

if (W_CheckNumForName(DEH_String(lumpname)) == -1)
{
return;
}
}
break;
default:
return;
}
Expand Down
Loading
Loading