Skip to content

Commit

Permalink
- improved the secret hint management for Blood.
Browse files Browse the repository at this point in the history
This now uses sprite and sector indices directly instead of encoding them into a larger number. Sprite secrets will use a $t prefix instead of $s now.
  • Loading branch information
coelckers committed Mar 20, 2022
1 parent 3114059 commit 26179c5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
26 changes: 21 additions & 5 deletions source/core/secrets.cpp
Expand Up @@ -11,6 +11,7 @@
#include "v_video.h"
#include "v_text.h"
#include "c_cvars.h"
#include "secrets.h"

// Unlike in GZDoom we have to maintain this list here, because we got different game frontents that all store this info differently.
// So the games will have to report the credited secrets so that this code can keep track of how to display them.
Expand All @@ -31,12 +32,21 @@ static void PrintSecretString(const char *string, bool thislevel)
{
if (*string == '$')
{
unsigned secnum = UINT_MAX;
if (string[1] == 'S' || string[1] == 's')
{
auto secnum = (unsigned)strtoull(string+2, (char**)&string, 10);
if (*string == ';') string++;
colstr = discovered_secrets.Find(secnum) == discovered_secrets.Size() ? TEXTCOLOR_RED : TEXTCOLOR_GREEN;
secnum = (unsigned)strtoull(string+2, (char**)&string, 10);
}
else if (string[1] == 'T' || string[1] == 't')
{
secnum = (unsigned)strtoull(string + 2, (char**)&string, 10) + 0x100000 * Secret_Sprite;
}
else if (string[1] == 'W' || string[1] == 'w')
{
secnum = (unsigned)strtoull(string + 2, (char**)&string, 10) + 0x100000 * Secret_Wall;
}
if (*string == ';') string++;
if (secnum != UINT_MAX) colstr = discovered_secrets.Find(secnum) == discovered_secrets.Size() ? TEXTCOLOR_RED : TEXTCOLOR_GREEN;
}
auto brok = V_BreakLines(NewConsoleFont, screen->GetWidth()*95/100, string);

Expand Down Expand Up @@ -127,12 +137,18 @@ void SECRET_SetMapName(const char *filename, const char *_maptitle)
maptitle = _maptitle;
}

bool SECRET_Trigger(int num)
bool SECRET_Trigger(int nnum, int type)
{
int num = nnum + type * 0x100000;
if (discovered_secrets.Find(num) == discovered_secrets.Size())
{
discovered_secrets.Push(num);
if (secret_notify) Printf(PRINT_NONOTIFY, "Secret #%d found\n", num);
if (secret_notify)
{
if (type == Secret_Sector) Printf(PRINT_NONOTIFY, "Secret sector #%d found\n", nnum);
else if (type == Secret_Sprite) Printf(PRINT_NONOTIFY, "Secret sprite #%d found\n", nnum);
else if (type == Secret_Wall) Printf(PRINT_NONOTIFY, "Secret wall #%d found\n", nnum);
}
return true;
}
return false;
Expand Down
9 changes: 8 additions & 1 deletion source/core/secrets.h
@@ -1,9 +1,16 @@
#pragma once
#include "files.h"

enum ESecretType
{
Secret_Sector = 0,
Secret_Sprite,
Secret_Wall
};

class FSerializer;
void SECRET_Serialize(FSerializer &arc);
void SECRET_SetMapName(const char *filename, const char *maptitle);
bool SECRET_Trigger(int num);
bool SECRET_Trigger(int num, int type = Secret_Sector);


9 changes: 5 additions & 4 deletions source/games/blood/src/eventq.cpp
Expand Up @@ -391,10 +391,11 @@ void evSend(EventObject& eob, int rxId, COMMAND_ID command)
case kChannelSecretFound:
{
int nIndex = -1;
if (eob.isActor() && eob.actor()) nIndex = eob.actor()->GetIndex() + 3 * 65536; // the hint system needs the sprite index.
else if (eob.isSector()) nIndex = eob.rawindex() + 6 * 65536;
else if (eob.isWall()) nIndex = eob.rawindex();
if (SECRET_Trigger(nIndex)) // if the hint system knows this secret it's a retrigger - skip that.
int nType = -1;
if (eob.isActor() && eob.actor()) nIndex = eob.actor()->GetIndex(), nType = Secret_Sprite;
else if (eob.isSector()) nIndex = eob.rawindex(), nType = Secret_Sector;
else if (eob.isWall()) nIndex = eob.rawindex(), nType = Secret_Wall;
if (SECRET_Trigger(nIndex, nType)) // if the hint system knows this secret it's a retrigger - skip that.
{
if (command >= kCmdNumberic)
{
Expand Down

0 comments on commit 26179c5

Please sign in to comment.