diff --git a/src/autosegs.h b/src/autosegs.h index 1226791476..b873602ed2 100644 --- a/src/autosegs.h +++ b/src/autosegs.h @@ -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 TAutoSegIteratorNoArrow { diff --git a/src/autostart.cpp b/src/autostart.cpp index c4d4ccbc45..5bdfa3c6eb 100644 --- a/src/autostart.cpp +++ b/src/autostart.cpp @@ -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 diff --git a/src/autozend.cpp b/src/autozend.cpp index 04d8b01132..84903eee66 100644 --- a/src/autozend.cpp +++ b/src/autozend.cpp @@ -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 diff --git a/src/doomstat.cpp b/src/doomstat.cpp index 0fe988a92f..ccc82a9081 100644 --- a/src/doomstat.cpp +++ b/src/doomstat.cpp @@ -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 diff --git a/src/g_game.cpp b/src/g_game.cpp index bf9a4a1d23..a8791b8fd6 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -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'; diff --git a/src/g_hub.cpp b/src/g_hub.cpp index 7eee1f932e..162aacd164 100644 --- a/src/g_hub.cpp +++ b/src/g_hub.cpp @@ -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; } } } diff --git a/src/g_level.cpp b/src/g_level.cpp index 5c6fbb8ea3..3c40a57d1d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -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 wadclusterinfos; TArray wadlevelinfos; -TArray 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()); } } } diff --git a/src/g_level.h b/src/g_level.h index cd303f1130..8132663253 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -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); diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 9dfeac3629..dc0b0fb060 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -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 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; + } + } } } } diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index cb77e40d19..43b0600231 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -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); diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index cc25a3b185..644e250853 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -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) diff --git a/src/g_skill.cpp b/src/g_skill.cpp index ce9a7e50f3..2b1f5c9712 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -41,6 +41,7 @@ #include "templates.h" #include "v_font.h" +TArray AllSkills; //========================================================================== // diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index bbef3a1c2e..6475495085 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -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); }