Skip to content

Commit

Permalink
IDMUS cheat support UMAPINFO
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro-Beirao committed Dec 7, 2024
1 parent 22a5e97 commit 8eb9abb
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 53 deletions.
10 changes: 5 additions & 5 deletions prboom2/src/dsda/mapinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,17 @@ int dsda_MusicIndexToLumpNum(int music_index) {
return lump;
}

void dsda_MapMusic(int* music_index, int* music_lump) {
if (dsda_DoomMapMusic(music_index, music_lump))
void dsda_MapMusic(int* music_index, int* music_lump, int episode, int map) {
if (dsda_DoomMapMusic(music_index, music_lump, episode, map))
return;

if (dsda_HexenMapMusic(music_index, music_lump))
if (dsda_HexenMapMusic(music_index, music_lump, episode, map))
return;

if (dsda_UMapMusic(music_index, music_lump))
if (dsda_UMapMusic(music_index, music_lump, episode, map))
return;

dsda_LegacyMapMusic(music_index, music_lump);
dsda_LegacyMapMusic(music_index, music_lump, episode, map);
}

void dsda_IntermissionMusic(int* music_index, int* music_lump) {
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda/mapinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void dsda_UpdateNextMapInfo(void);
int dsda_ResolveCLEV(int* episode, int* map);
int dsda_ResolveINIT(void);
int dsda_MusicIndexToLumpNum(int music_index);
void dsda_MapMusic(int* music_index, int* music_lump);
void dsda_MapMusic(int* music_index, int* music_lump, int episode, int map);
void dsda_IntermissionMusic(int* music_index, int* music_lump);
void dsda_InterMusic(int* music_index, int* music_lump);
void dsda_StartFinale(void);
Expand Down
15 changes: 12 additions & 3 deletions prboom2/src/dsda/mapinfo/doom.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,22 @@ int dsda_DoomMusicIndexToLumpNum(int* lump, int music_index) {
return false;
}

int dsda_DoomMapMusic(int* music_index, int* music_lump) {
int dsda_DoomMapMusic(int* music_index, int* music_lump, int episode, int map) {
int lump;
const doom_mapinfo_map_t* entry;
int level_num;

if (gamemode == commercial)
level_num = map;
else
level_num = map + episode * 10;

entry = dsda_DoomMapEntry(level_num);

if (!current_map || !current_map->music)
if (!entry || !entry->music)
return false;

lump = W_CheckNumForName(current_map->music);
lump = W_CheckNumForName(entry->music);

if (lump == LUMP_NOT_FOUND)
return false;
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda/mapinfo/doom.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void dsda_DoomUpdateNextMapInfo(void);
int dsda_DoomResolveCLEV(int* clev, int* episode, int* map);
int dsda_DoomResolveINIT(int* init);
int dsda_DoomMusicIndexToLumpNum(int* lump, int music_index);
int dsda_DoomMapMusic(int* music_index, int* music_lump);
int dsda_DoomMapMusic(int* music_index, int* music_lump, int episode, int map);
int dsda_DoomIntermissionMusic(int* music_index, int* music_lump);
int dsda_DoomInterMusic(int* music_index, int* music_lump);
int dsda_DoomStartFinale(void);
Expand Down
4 changes: 2 additions & 2 deletions prboom2/src/dsda/mapinfo/hexen.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ int dsda_HexenMusicIndexToLumpNum(int* lump, int music_index) {
return true;
}

int dsda_HexenMapMusic(int* music_index, int* music_lump) {
int dsda_HexenMapMusic(int* music_index, int* music_lump, int episode, int map) {
if (!hexen)
return false;

*music_lump = -1;
*music_index = gamemap;
*music_index = map;

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda/mapinfo/hexen.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void dsda_HexenUpdateNextMapInfo(void);
int dsda_HexenResolveCLEV(int* clev, int* episode, int* map);
int dsda_HexenResolveINIT(int* init);
int dsda_HexenMusicIndexToLumpNum(int* lump, int music_index);
int dsda_HexenMapMusic(int* music_index, int* music_lump);
int dsda_HexenMapMusic(int* music_index, int* music_lump, int episode, int map);
int dsda_HexenIntermissionMusic(int* music_index, int* music_lump);
int dsda_HexenInterMusic(int* music_index, int* music_lump);
int dsda_HexenStartFinale(void);
Expand Down
12 changes: 6 additions & 6 deletions prboom2/src/dsda/mapinfo/legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,14 @@ static inline int WRAP(int i, int w)
return i % w;
}

int dsda_LegacyMapMusic(int* music_index, int* music_lump) {
int dsda_LegacyMapMusic(int* music_index, int* music_lump, int episode, int map) {
*music_lump = -1;

if (idmusnum != -1)
*music_index = idmusnum; //jff 3/17/98 reload IDMUS music if not -1
else {
if (gamemode == commercial)
*music_index = mus_runnin + WRAP(gamemap - 1, DOOM_MUSINFO - mus_runnin);
*music_index = mus_runnin + WRAP(map - 1, DOOM_MUSINFO - mus_runnin);
else {
static const int spmus[] = {
mus_e3m4,
Expand All @@ -380,13 +380,13 @@ int dsda_LegacyMapMusic(int* music_index, int* music_lump) {

if (heretic)
*music_index = heretic_mus_e1m1 +
WRAP((gameepisode - 1) * 9 + gamemap - 1,
WRAP((episode - 1) * 9 + map - 1,
HERETIC_NUMMUSIC - heretic_mus_e1m1);
else if (gameepisode < 4)
else if (episode < 4)
*music_index = mus_e1m1 +
WRAP((gameepisode - 1) * 9 + gamemap - 1, mus_runnin - mus_e1m1);
WRAP((episode - 1) * 9 + map - 1, mus_runnin - mus_e1m1);
else
*music_index = spmus[WRAP(gamemap - 1, 9)];
*music_index = spmus[WRAP(map - 1, 9)];
}
}

Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda/mapinfo/legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void dsda_LegacyUpdateNextMapInfo(void);
int dsda_LegacyResolveCLEV(int* clev, int* episode, int* map);
int dsda_LegacyResolveINIT(int* init);
int dsda_LegacyMusicIndexToLumpNum(int* lump, int music_index);
int dsda_LegacyMapMusic(int* music_index, int* music_lump);
int dsda_LegacyMapMusic(int* music_index, int* music_lump, int episode, int map);
int dsda_LegacyIntermissionMusic(int* music_index, int* music_lump);
int dsda_LegacyInterMusic(int* music_index, int* music_lump);
int dsda_LegacyStartFinale(void);
Expand Down
11 changes: 5 additions & 6 deletions prboom2/src/dsda/mapinfo/u.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,15 @@ int dsda_UMusicIndexToLumpNum(int* lump, int music_index) {
return false;
}

int dsda_UMapMusic(int* music_index, int* music_lump) {
int dsda_UMapMusic(int* music_index, int* music_lump, int episode, int map) {
int lump;
struct MapEntry* entry = dsda_UMapEntry(episode, map);
int level_num;

if (!gamemapinfo)
return false;

if (!gamemapinfo->music[0])
if (!entry || !entry->music[0])
return false;

lump = W_CheckNumForName(gamemapinfo->music);
lump = W_CheckNumForName(entry->music);

if (lump == LUMP_NOT_FOUND)
return false;
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda/mapinfo/u.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void dsda_UUpdateNextMapInfo(void);
int dsda_UResolveCLEV(int* clev, int* episode, int* map);
int dsda_UResolveINIT(int* init);
int dsda_UMusicIndexToLumpNum(int* lump, int music_index);
int dsda_UMapMusic(int* music_index, int* music_lump);
int dsda_UMapMusic(int* music_index, int* music_lump, int episode, int map);
int dsda_UIntermissionMusic(int* music_index, int* music_lump);
int dsda_UInterMusic(int* music_index, int* music_lump);
int dsda_UStartFinale(void);
Expand Down
53 changes: 28 additions & 25 deletions prboom2/src/m_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "p_tick.h"
#include "m_cheat.h"
#include "s_sound.h"
#include "s_advsound.h"
#include "sounds.h"
#include "dstrings.h"
#include "r_main.h"
Expand Down Expand Up @@ -254,42 +255,44 @@ cheatseq_t cheat[] = {
static void cheat_mus(buf)
char buf[3];
{
int musnum;
int musnum, muslump;
int epsd, map;

//jff 3/20/98 note: this cheat allowed in netgame/demorecord

//jff 3/17/98 avoid musnum being negative and crashing
if (!isdigit(buf[0]) || !isdigit(buf[1]))
return;

if (gamemode == commercial)
{
epsd = 1; //jff was 0, but espd is 1-based
map = (buf[0] - '0') * 10 + buf[1] - '0';
}
else
{
epsd = buf[0] - '1';
map = buf[1] - '1';
}

dsda_AddMessage(s_STSTR_MUS);

if (gamemode == commercial)
{
musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
idmusnum = -1;
dsda_MapMusic(&musnum, &muslump, epsd, map);
idmusnum = musnum; //jff 3/17/98 remember idmus number for restore

//jff 4/11/98 prevent IDMUS00 in DOOMII and IDMUS36 or greater
if (musnum < mus_runnin || ((buf[0]-'0')*10 + buf[1]-'0') > 35)
dsda_AddMessage(s_STSTR_NOMUS);
else
{
S_ChangeMusic(musnum, 1);
idmusnum = musnum; //jff 3/17/98 remember idmus number for restore
}
}
if (muslump != -1)
{
S_ChangeMusInfoMusic(muslump, true);
}
else if (musnum != -1)
{
S_ChangeMusic(musnum, 1);
}
else
{
musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');

//jff 4/11/98 prevent IDMUS0x IDMUSx0 in DOOMI and greater than introa
if (buf[0] < '1' || buf[1] < '1' || ((buf[0]-'1')*9 + buf[1]-'1') > 31)
dsda_AddMessage(s_STSTR_NOMUS);
else
{
S_ChangeMusic(musnum, 1);
idmusnum = musnum; //jff 3/17/98 remember idmus number for restore
}
}
{
dsda_AddMessage(s_STSTR_NOMUS);
}
}

// 'choppers' invulnerability & chainsaw
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/s_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void S_Start(void)
// start new music for the level
mus_paused = 0;

dsda_MapMusic(&mnum, &muslump);
dsda_MapMusic(&mnum, &muslump, gameepisode, gamemap);

if (muslump >= 0)
{
Expand Down

0 comments on commit 8eb9abb

Please sign in to comment.