- Some data restructuring in MAPINFO branch:

* removed support for custom cluster properties
  * Changed how G_MaybeLookupLevelName works and made it return an FString.
  * removed 64 character limit on level names.



SVN r1379 (newmapinfo)
This commit is contained in:
Christoph Oelckers 2009-01-30 12:07:45 +00:00
parent e7141238ba
commit 2c793bce0a
13 changed files with 131 additions and 148 deletions

View file

@ -42,14 +42,12 @@
#define GREG_SECTION "__DATA,greg"
#define MREG_SECTION "__DATA,mreg"
#define MREG_SECTION "__DATA,yreg"
#define MREG_SECTION "__DATA,zreg"
#else
#define AREG_SECTION "areg"
#define CREG_SECTION "creg"
#define GREG_SECTION "greg"
#define MREG_SECTION "mreg"
#define GREG_SECTION "yreg"
#define MREG_SECTION "zreg"
#endif
#endif
@ -76,10 +74,6 @@ extern REGINFO MRegTail;
extern REGINFO YRegHead;
extern REGINFO YRegTail;
// List of MAPINFO cluster options
extern REGINFO ZRegHead;
extern REGINFO ZRegTail;
template<class T, REGINFO *_head, REGINFO *_tail>
class TAutoSegIteratorNoArrow
{

View file

@ -46,7 +46,7 @@
#if defined(_MSC_VER)
#pragma comment(linker, "/merge:.areg=.data /merge:.creg=.data /merge:.greg=.data /merge:.mreg=.data /merge:.yreg=.data /merge:.zreg=.data")
#pragma comment(linker, "/merge:.areg=.data /merge:.creg=.data /merge:.greg=.data /merge:.mreg=.data /merge:.yreg=.data")
#pragma data_seg(".areg$a")
void *ARegHead = 0;
@ -63,9 +63,6 @@ void *MRegHead = 0;
#pragma data_seg(".yreg$a")
void *YRegHead = 0;
#pragma data_seg(".zreg$a")
void *ZRegHead = 0;
#pragma data_seg()
// We want visual styles support under XP
@ -94,7 +91,6 @@ void *CRegHead __attribute__((section(CREG_SECTION))) = 0;
void *GRegHead __attribute__((section(GREG_SECTION))) = 0;
void *MRegHead __attribute__((section(MREG_SECTION))) = 0;
void *YRegHead __attribute__((section(YREG_SECTION))) = 0;
void *ZRegHead __attribute__((section(ZREG_SECTION))) = 0;
#elif

View file

@ -52,9 +52,6 @@ void *MRegTail = 0;
#pragma data_seg(".yreg$z")
void *YRegTail = 0;
#pragma data_seg(".zreg$z")
void *ZRegTail = 0;
#pragma data_seg()
@ -66,7 +63,6 @@ void *CRegTail __attribute__((section(CREG_SECTION))) = 0;
void *GRegTail __attribute__((section(GREG_SECTION))) = 0;
void *MRegTail __attribute__((section(MREG_SECTION))) = 0;
void *YRegTail __attribute__((section(YREG_SECTION))) = 0;
void *ZRegTail __attribute__((section(ZREG_SECTION))) = 0;
#elif

View file

@ -60,7 +60,7 @@ CUSTOM_CVAR (String, language, "auto", CVAR_ARCHIVE)
{
SetLanguageIDs ();
GStrings.LoadStrings (false);
G_MaybeLookupLevelName (NULL);
level.LevelName = level.info->LookupLevelName();
}
// [RH] Network arbitrator

View file

@ -1980,7 +1980,7 @@ static void PutSaveComment (FILE *file)
// Get level name
//strcpy (comment, level.level_name);
mysnprintf(comment, countof(comment), "%s - %s", level.mapname, level.level_name);
mysnprintf(comment, countof(comment), "%s - %s", level.mapname, level.LevelName.GetChars());
len = (WORD)strlen (comment);
comment[len] = '\n';

View file

@ -131,13 +131,12 @@ void G_LeavingHub(int mode, cluster_info_t * cluster, wbstartstruct_t * wbs)
{
if (cluster->flags & CLUSTER_LOOKUPNAME)
{
strncpy(level.level_name, GStrings(cluster->ClusterName), 64);
level.LevelName = GStrings(cluster->ClusterName);
}
else
{
strncpy(level.level_name, cluster->ClusterName, 64);
level.LevelName = cluster->ClusterName;
}
level.level_name[63]=0;
}
}
}

View file

@ -96,7 +96,6 @@ EXTERN_CVAR (Int, disableautosave)
#define PCLS_ID MAKE_ID('p','c','L','s')
static void SetEndSequence (char *nextmap, int type);
static void InitPlayerClasses ();
void G_VerifySkill();
static FRandom pr_classchoice ("RandomPlayerClassChoice");
@ -140,7 +139,6 @@ FLevelLocals level; // info about current level
TArray<cluster_info_t> wadclusterinfos;
TArray<level_info_t> wadlevelinfos;
TArray<FSkillInfo> AllSkills;
static level_info_t TheDefaultLevelInfo;
static cluster_info_t TheDefaultClusterInfo;
@ -383,6 +381,28 @@ void G_DoNewGame (void)
gameaction = ga_nothing;
}
// Initializes player classes in case they are random.
// This gets called at the start of a new game, and the classes
// chosen here are used for the remainder of a single-player
// or coop game. These are ignored for deathmatch.
static void InitPlayerClasses ()
{
if (!savegamerestore)
{
for (int i = 0; i < MAXPLAYERS; ++i)
{
SinglePlayerClass[i] = players[i].userinfo.PlayerClass;
if (SinglePlayerClass[i] < 0 || !playeringame[i])
{
SinglePlayerClass[i] = (pr_classchoice()) % PlayerClasses.Size ();
}
players[i].cls = NULL;
players[i].CurrentPlayerClass = SinglePlayerClass[i];
}
}
}
void G_InitNew (const char *mapname, bool bTitleLevel)
{
EGameSpeed oldSpeed;
@ -877,7 +897,7 @@ void G_DoLoadLevel (int position, bool autosave)
"\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
"\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"
TEXTCOLOR_BOLD "%s - %s\n\n",
level.mapname, level.level_name);
level.mapname, level.LevelName.GetChars());
if (wipegamestate == GS_LEVEL)
wipegamestate = GS_FORCEWIPE;
@ -1257,9 +1277,7 @@ void G_InitLevelLocals ()
level.Music = info->Music;
level.musicorder = info->musicorder;
strncpy(level.level_name, info->LevelName, 63);
level.level_name[63] = 0;
G_MaybeLookupLevelName (NULL);
level.LevelName = level.info->LookupLevelName();
strncpy (level.nextmap, info->nextmap, 8);
level.nextmap[8] = 0;
strncpy (level.secretmap, info->secretmap, 8);
@ -1274,7 +1292,7 @@ void G_InitLevelLocals ()
{
level.partime = level.cluster = 0;
level.sucktime = 0;
strcpy(level.level_name, "Unnamed");
level.LevelName = "Unnamed";
level.nextmap[0] =
level.secretmap[0] = 0;
level.Music = "";
@ -1393,62 +1411,6 @@ cluster_info_t *FindClusterInfo (int cluster)
return &TheDefaultClusterInfo;
}
const char *G_MaybeLookupLevelName (level_info_t *ininfo)
{
level_info_t *info;
if (ininfo == NULL)
{
info = level.info;
}
else
{
info = ininfo;
}
if (info != NULL && info->flags & LEVEL_LOOKUPLEVELNAME)
{
const char *thename;
const char *lookedup;
lookedup = GStrings[info->LevelName];
if (lookedup == NULL)
{
thename = info->LevelName;
}
else
{
char checkstring[32];
// Strip out the header from the localized string
if (info->mapname[0] == 'E' && info->mapname[2] == 'M')
{
mysnprintf (checkstring, countof(checkstring), "%s: ", info->mapname);
}
else if (info->mapname[0] == 'M' && info->mapname[1] == 'A' && info->mapname[2] == 'P')
{
mysnprintf (checkstring, countof(checkstring), "%d: ", atoi(info->mapname + 3));
}
thename = strstr (lookedup, checkstring);
if (thename == NULL)
{
thename = lookedup;
}
else
{
thename += strlen (checkstring);
}
}
if (ininfo == NULL)
{
strncpy(level.level_name, thename, 63);
level.level_name[63] = 0;
}
return thename;
}
return info != NULL ? (const char*)(info->LevelName) : NULL;
}
void G_AirControlChanged ()
{
if (level.aircontrol <= 256)
@ -1913,30 +1875,6 @@ void FLevelLocals::AddScroller (DScroller *scroller, int secnum)
}
}
// Initializes player classes in case they are random.
// This gets called at the start of a new game, and the classes
// chosen here are used for the remainder of a single-player
// or coop game. These are ignored for deathmatch.
static void InitPlayerClasses ()
{
if (!savegamerestore)
{
for (int i = 0; i < MAXPLAYERS; ++i)
{
SinglePlayerClass[i] = players[i].userinfo.PlayerClass;
if (SinglePlayerClass[i] < 0 || !playeringame[i])
{
SinglePlayerClass[i] = (pr_classchoice()) % PlayerClasses.Size ();
}
players[i].cls = NULL;
players[i].CurrentPlayerClass = SinglePlayerClass[i];
}
}
}
//==========================================================================
//
// Lists all currently defined maps
@ -1951,7 +1889,7 @@ CCMD(listmaps)
if (P_CheckMapData(info->mapname))
{
Printf("%s: '%s'\n", info->mapname, G_MaybeLookupLevelName(info));
Printf("%s: '%s'\n", info->mapname, info->LookupLevelName().GetChars());
}
}
}

View file

@ -45,18 +45,13 @@ class FScanner;
#if defined(_MSC_VER)
#pragma data_seg(".yreg$u")
#pragma data_seg(".zreg$u")
#pragma data_seg()
#define MSVC_YSEG __declspec(allocate(".yreg$u"))
#define GCC_YSEG
#define MSVC_ZSEG __declspec(allocate(".zreg$u"))
#define GCC_ZSEG
#else
#define MSVC_YSEG
#define GCC_YSEG __attribute__((section(YREG_SECTION)))
#define MSVC_ZSEG
#define GCC_ZSEG __attribute__((section(ZREG_SECTION)))
#endif
@ -195,13 +190,6 @@ struct FMapInfoParser
MSVC_YSEG FMapOptInfo *mapopt_##name GCC_YSEG = &MapOpt_##name; \
static void MapOptHandler_##name(FMapInfoParser &parse, level_info_t *info)
#define DEFINE_CLUSTER_OPTION(name, old) \
static void MapOptHandler_##name(FScanner &sc, cluster_info_t *info); \
static FClusterOptInfo ClusterOpt_##name = \
{ #name, ClusterOptHandler_##name, old }; \
MSVC_ZSEG FClusterOptInfo *clusteropt_##name GCC_ZSEG = &ClusterOpt_##name; \
static void ClusterOptHandler_##name(FScanner &sc, cluster_info_t *info)
struct FMapOptInfo
{
@ -210,14 +198,6 @@ struct FMapOptInfo
bool old;
};
struct FClusterOptInfo
{
const char *name;
void (*handler) (FScanner &sc, cluster_info_t *levelinfo);
bool old;
};
#define NUM_WORLDVARS 256
#define NUM_GLOBALVARS 64
@ -391,6 +371,7 @@ struct level_info_t
level_info_t() { Reset(); }
void Reset();
FString LookupLevelName ();
};
@ -417,7 +398,7 @@ struct FLevelLocals
int clusterflags;
int levelnum;
int lumpnum;
char level_name[64];
FString LevelName;
char mapname[256]; // the server name (base1, etc)
char nextmap[9]; // go here when fraglimit is hit
char secretmap[9]; // map to go to when used secret exit
@ -573,8 +554,6 @@ void G_InitLevelLocals (void);
void G_AirControlChanged ();
const char *G_MaybeLookupLevelName (level_info_t *level);
cluster_info_t *FindClusterInfo (int cluster);
level_info_t *FindLevelInfo (const char *mapname);
level_info_t *FindLevelByNum (int num);

View file

@ -45,6 +45,7 @@
#include "p_setup.h"
#include "i_system.h"
#include "gi.h"
#include "gstrings.h"
int FindEndSequence (int type, const char *picname);
@ -122,6 +123,52 @@ void level_info_t::Reset()
}
//==========================================================================
//
//
//==========================================================================
FString level_info_t::LookupLevelName()
{
if (flags & LEVEL_LOOKUPLEVELNAME)
{
const char *thename;
const char *lookedup;
lookedup = GStrings[LevelName];
if (lookedup == NULL)
{
thename = LevelName;
}
else
{
char checkstring[32];
// Strip out the header from the localized string
if (mapname[0] == 'E' && mapname[2] == 'M')
{
mysnprintf (checkstring, countof(checkstring), "%s: ", mapname);
}
else if (mapname[0] == 'M' && mapname[1] == 'A' && mapname[2] == 'P')
{
mysnprintf (checkstring, countof(checkstring), "%d: ", atoi(mapname + 3));
}
thename = strstr (lookedup, checkstring);
if (thename == NULL)
{
thename = lookedup;
}
else
{
thename += strlen (checkstring);
}
}
return thename;
}
else return LevelName;
}
//==========================================================================
//
//
@ -347,6 +394,20 @@ void FMapInfoParser::ParseNextMap(char *mapname)
}
ParseCloseParen();
}
else
{
if (format_type == FMT_New)
{
// Unknown
sc.ScriptMessage("Unknown property '%s' found in endgame definition\n", sc.String);
SkipToNext();
}
else
{
sc.ScriptError("Unknown property '%s' found in endgame definition\n", sc.String);
}
}
}
useseq = true;
}
@ -993,17 +1054,34 @@ void FMapInfoParser::ParseMapDefinition(level_info_t &info)
break;
}
}
else if (!ParseCloseBrace())
{
// Unknown
sc.ScriptMessage("Unknown property '%s' found in map definition\n", sc.String);
SkipToNext();
}
else
{
break;
TAutoSegIterator<FMapOptInfo*, &YRegHead, &YRegTail> probe;
bool success = false;
while (++probe != NULL)
{
if (sc.Compare(probe->name))
{
probe->handler(*this, &info);
success = true;
break;
}
}
if (!success)
{
if (!ParseCloseBrace())
{
// Unknown
sc.ScriptMessage("Unknown property '%s' found in map definition\n", sc.String);
SkipToNext();
}
else
{
break;
}
}
}
}
}

View file

@ -875,7 +875,7 @@ void DrawHUD()
}
}
mysnprintf(printstr, countof(printstr), "%s: %s", level.mapname, level.level_name);
mysnprintf(printstr, countof(printstr), "%s: %s", level.mapname, level.LevelName.GetChars());
screen->DrawText(SmallFont, hudcolor_titl, 1, hudheight-fonth-1, printstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);

View file

@ -1242,11 +1242,11 @@ void DBaseStatusBar::Draw (EHudState state)
{
i = mysnprintf (line, countof(line), "%s: ", level.mapname);
}
line[i] = TEXTCOLOR_ESCAPE;
line[i+1] = CR_GREY + 'A';
strcpy (&line[i+2], level.level_name);
FString mapname;
mapname.Format("%c%c%s", TEXTCOLOR_ESCAPE, CR_GREY + 'A', level.LevelName.GetChars());
screen->DrawText (SmallFont, highlight,
(SCREENWIDTH - SmallFont->StringWidth (line)*CleanXfac)/2, y, line,
(SCREENWIDTH - SmallFont->StringWidth (mapname)*CleanXfac)/2, y, mapname,
DTA_CleanNoMove, true, TAG_DONE);
if (!deathmatch)

View file

@ -41,6 +41,7 @@
#include "templates.h"
#include "v_font.h"
TArray<FSkillInfo> AllSkills;
//==========================================================================
//

View file

@ -230,7 +230,7 @@ static FTexture* p; // Player graphic
static FTexture* lnames[2]; // Name graphics of each level (centered)
// [RH] Info to dynamically generate the level name graphics
static const char *lnametexts[2];
static FString lnametexts[2];
static FTexture *background;
@ -712,6 +712,7 @@ int WI_DrawName(int y, const char *levelname)
lumph = BigFont->GetHeight() * CleanYfac;
p = levelname;
if (!p) return 0;
l = strlen(p);
if (!l) return 0;
@ -1967,10 +1968,11 @@ void WI_loadData(void)
}
// Use the local level structure which can be overridden by hubs
lnametexts[0] = level.level_name;
lnametexts[0] = level.LevelName;
level_info_t *li = FindLevelInfo(wbs->next);
lnametexts[1] = li ? G_MaybeLookupLevelName(li) : NULL;
if (li) lnametexts[1] = li->LookupLevelName();
else lnametexts[1] = "";
WI_LoadBackground(false);
}