Egg TV: detect Prisons mode

This commit is contained in:
James R 2024-02-12 18:10:26 -08:00
parent aa4ff315b7
commit b275a14ec2
4 changed files with 25 additions and 5 deletions

View file

@ -2667,6 +2667,9 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
if (pdemoflags & DF_ENCORE) if (pdemoflags & DF_ENCORE)
pdemo->kartspeed |= DF_ENCORE; pdemo->kartspeed |= DF_ENCORE;
if (pdemoflags & DF_GRANDPRIX)
pdemo->gp = true;
// Read standings! // Read standings!
count = 0; count = 0;

View file

@ -89,6 +89,7 @@ struct menudemo_t {
INT16 gametype; INT16 gametype;
SINT8 kartspeed; // Add OR DF_ENCORE for encore mode, idk SINT8 kartspeed; // Add OR DF_ENCORE for encore mode, idk
UINT8 numlaps; UINT8 numlaps;
UINT8 gp;
struct { struct {
UINT8 ranking; UINT8 ranking;

View file

@ -237,7 +237,7 @@ EggTVData::Replay::Replay(Folder::Cache::ReplayRef& ref) : ref_(&ref)
if (info.gametype == GT_RACE) if (info.gametype == GT_RACE)
{ {
gametype_ = Gametype(GT_RACE, Gametype::Race { gametype_ = Gametype(GT_RACE, info.gp, Gametype::Race {
info.numlaps, info.numlaps,
kartspeed_cons_t[(info.kartspeed & ~(DF_ENCORE)) + 1].strvalue, kartspeed_cons_t[(info.kartspeed & ~(DF_ENCORE)) + 1].strvalue,
(info.kartspeed & DF_ENCORE) != 0, (info.kartspeed & DF_ENCORE) != 0,
@ -245,7 +245,7 @@ EggTVData::Replay::Replay(Folder::Cache::ReplayRef& ref) : ref_(&ref)
} }
else else
{ {
gametype_ = Gametype(info.gametype); gametype_ = Gametype(info.gametype, info.gp);
} }
for (const auto& data : info.standings) for (const auto& data : info.standings)

View file

@ -193,12 +193,12 @@ public:
}; };
explicit Gametype() {} explicit Gametype() {}
explicit Gametype(INT16 gt, Race race) : gametype_(get(gt)), var_(race) {} explicit Gametype(INT16 gt, bool gp) : gametype_(get(gt)), name_(get_name(gt, gp)) {}
explicit Gametype(INT16 gt) : gametype_(get(gt)) {} explicit Gametype(INT16 gt, bool gp, Race race) : Gametype(gt, gp) { var_ = race; }
bool valid() const { return gametype_; } bool valid() const { return gametype_; }
std::string_view name() const { return valid() ? gametype_->name : "<Unknown gametype>"; } std::string_view name() const { return name_; }
UINT32 rules() const { return valid() ? gametype_->rules : 0u; } UINT32 rules() const { return valid() ? gametype_->rules : 0u; }
bool ranks_time() const { return !ranks_points(); } bool ranks_time() const { return !ranks_points(); }
@ -208,8 +208,24 @@ public:
private: private:
const gametype_t* gametype_ = nullptr; const gametype_t* gametype_ = nullptr;
std::string_view name_;
std::variant<std::monostate, Race> var_; std::variant<std::monostate, Race> var_;
std::string_view get_name(INT16 gt, bool gp) const
{
if (!valid())
{
return "<Unknown gametype>";
}
if ((rules() & GTR_PRISONS) && gp)
{
return "Prison Break";
}
return gametype_->name;
}
static gametype_t* get(INT16 gt) { return gt >= 0 && gt < numgametypes ? gametypes[gt] : nullptr; } static gametype_t* get(INT16 gt) { return gt >= 0 && gt < numgametypes ? gametypes[gt] : nullptr; }
}; };