2016-03-01 15:47:10 +00:00
|
|
|
/*
|
|
|
|
** g_hub.cpp
|
|
|
|
**
|
|
|
|
** Intermission stats for hubs
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2005 Christoph Oelckers
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "g_hub.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "m_png.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "wi_stuff.h"
|
2016-09-21 10:19:13 +00:00
|
|
|
#include "serializer.h"
|
2017-01-08 17:45:30 +00:00
|
|
|
#include "g_levellocals.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Player is leaving the current level
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
struct FHubInfo
|
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
int levelnum;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2020-08-30 13:34:53 +00:00
|
|
|
int totalkills;
|
2016-03-01 15:47:10 +00:00
|
|
|
int maxkills;
|
|
|
|
int maxitems;
|
|
|
|
int maxsecret;
|
|
|
|
int maxfrags;
|
|
|
|
|
|
|
|
wbplayerstruct_t plyr[MAXPLAYERS];
|
|
|
|
|
|
|
|
FHubInfo &operator=(const wbstartstruct_t &wbs)
|
|
|
|
{
|
2020-08-30 13:34:53 +00:00
|
|
|
levelnum = wbs.finished_ep;
|
|
|
|
totalkills = wbs.totalkills;
|
|
|
|
maxkills = wbs.maxkills;
|
|
|
|
maxsecret = wbs.maxsecret;
|
|
|
|
maxitems = wbs.maxitems;
|
|
|
|
maxfrags = wbs.maxfrags;
|
2016-03-01 15:47:10 +00:00
|
|
|
memcpy(plyr, wbs.plyr, sizeof(plyr));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static TArray<FHubInfo> hubdata;
|
|
|
|
|
2019-01-29 01:08:53 +00:00
|
|
|
void G_LeavingHub(FLevelLocals *Level, int mode, cluster_info_t * cluster, wbstartstruct_t * wbs)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
unsigned int i, j;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (cluster->flags & CLUSTER_HUB)
|
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
for (i = 0; i < hubdata.Size(); i++)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 01:08:53 +00:00
|
|
|
if (hubdata[i].levelnum == Level->levelnum)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
hubdata[i] = *wbs;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-09-21 10:19:13 +00:00
|
|
|
if (i == hubdata.Size())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
hubdata[hubdata.Reserve(1)] = *wbs;
|
|
|
|
}
|
|
|
|
|
2019-01-29 01:08:53 +00:00
|
|
|
hubdata[i].levelnum = Level->levelnum;
|
2016-03-01 15:47:10 +00:00
|
|
|
if (!multiplayer && !deathmatch)
|
|
|
|
{
|
|
|
|
// The player counters don't work in hubs
|
2019-01-29 01:08:53 +00:00
|
|
|
hubdata[i].plyr[0].skills = Level->killed_monsters;
|
|
|
|
hubdata[i].plyr[0].sitems = Level->found_items;
|
|
|
|
hubdata[i].plyr[0].ssecret = Level->found_secrets;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
if (mode != FINISH_SameHub)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2020-08-30 13:34:53 +00:00
|
|
|
wbs->totalkills = Level->killed_monsters;
|
2016-09-21 10:19:13 +00:00
|
|
|
wbs->maxkills = wbs->maxitems = wbs->maxsecret = 0;
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
wbs->plyr[i].sitems = wbs->plyr[i].skills = wbs->plyr[i].ssecret = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
for (i = 0; i < hubdata.Size(); i++)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
wbs->maxkills += hubdata[i].maxkills;
|
|
|
|
wbs->maxitems += hubdata[i].maxitems;
|
|
|
|
wbs->maxsecret += hubdata[i].maxsecret;
|
2016-09-21 10:19:13 +00:00
|
|
|
for (j = 0; j < MAXPLAYERS; j++)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
wbs->plyr[j].sitems += hubdata[i].plyr[j].sitems;
|
|
|
|
wbs->plyr[j].skills += hubdata[i].plyr[j].skills;
|
|
|
|
wbs->plyr[j].ssecret += hubdata[i].plyr[j].ssecret;
|
|
|
|
}
|
|
|
|
}
|
2016-09-21 10:19:13 +00:00
|
|
|
if (cluster->ClusterName.IsNotEmpty())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (cluster->flags & CLUSTER_LOOKUPNAME)
|
|
|
|
{
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
wbs->thisname = GStrings(cluster->ClusterName);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
wbs->thisname = cluster->ClusterName;
|
2019-08-02 07:11:40 +00:00
|
|
|
wbs->thisauthor = "";
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
wbs->LName0.SetInvalid(); // The level's own name was just invalidated, and so was its name patch.
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-21 10:19:13 +00:00
|
|
|
if (mode != FINISH_SameHub) hubdata.Clear();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Serialize intermission info for hubs
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
FSerializer &Serialize(FSerializer &arc, const char *key, wbplayerstruct_t &h, wbplayerstruct_t *def)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
if (arc.BeginObject(key))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-02-23 23:28:33 +00:00
|
|
|
arc("kills", h.skills)
|
2016-09-21 10:19:13 +00:00
|
|
|
("items", h.sitems)
|
|
|
|
("secrets", h.ssecret)
|
|
|
|
("time", h.stime)
|
|
|
|
("fragcount", h.fragcount)
|
|
|
|
.Array("frags", h.frags, MAXPLAYERS)
|
|
|
|
.EndObject();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-09-21 10:19:13 +00:00
|
|
|
return arc;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
FSerializer &Serialize(FSerializer &arc, const char *key, FHubInfo &h, FHubInfo *def)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
if (arc.BeginObject(key))
|
|
|
|
{
|
|
|
|
arc("levelnum", h.levelnum)
|
2020-08-30 13:34:53 +00:00
|
|
|
("totalkills", h.totalkills)
|
2016-09-21 10:19:13 +00:00
|
|
|
("maxkills", h.maxkills)
|
|
|
|
("maxitems", h.maxitems)
|
|
|
|
("maxsecret", h.maxsecret)
|
|
|
|
("maxfrags", h.maxfrags)
|
|
|
|
.Array("players", h.plyr, MAXPLAYERS)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
void G_SerializeHub(FSerializer &arc)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
arc("hubinfo", hubdata);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void G_ClearHubInfo()
|
|
|
|
{
|
|
|
|
hubdata.Clear();
|
2019-01-29 01:08:53 +00:00
|
|
|
}
|