From 969cc1f6f9c2e3920ff2360b835318d154d34566 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Mar 2008 14:18:27 +0000 Subject: [PATCH] - Expanded the args for MAPINFO special actions to 32 bit integers as in the rest of the game. - Fixed: The specialaction list was not copied properly when transferred from the defaultinfo. - Fixed: The defaultinfo for MAPINFO wasn't cleared fully after MAPINFO parsing was completed. - Made Doom-format linedef translators a map property so that it's easier to define replacements or extensions. SVN r843 (trunk) --- docs/rh-log.txt | 10 ++++++++ src/g_level.cpp | 38 ++++++++++++++++++++++-------- src/g_level.h | 3 ++- src/gi.cpp | 33 +++++++++++++++++--------- src/gi.h | 1 + src/p_setup.cpp | 5 ++++ src/xlat/parse_xlat.cpp | 52 ++++++++++++++++------------------------- 7 files changed, 88 insertions(+), 54 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f42d1c18c1..a96587d970 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,13 @@ +March 23, 2008 (Changes by Graf Zahl) +- Expanded the args for MAPINFO special actions to 32 bit integers as in + the rest of the game. +- Fixed: The specialaction list was not copied properly when transferred + from the defaultinfo. +- Fixed: The defaultinfo for MAPINFO wasn't cleared fully after MAPINFO + parsing was completed. +- Made Doom-format linedef translators a map property so that it's easier + to define replacements or extensions. + March 22, 2008 - Changed MIDI playback to not bother playing super short songs that don't contain enough music to fill the initial output buffers. diff --git a/src/g_level.cpp b/src/g_level.cpp index 37e4f54de1..0cfaa3e0d4 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -309,6 +309,7 @@ static const char *MapInfoMapLevel[] = "teamplayoff", "checkswitchrange", "nocheckswitchrange", + "translator", NULL }; @@ -458,6 +459,7 @@ MapHandlers[] = { MITYPE_SCFLAGS, LEVEL_FORCETEAMPLAYOFF, ~LEVEL_FORCETEAMPLAYON }, { MITYPE_SETFLAG, LEVEL_CHECKSWITCHRANGE, 0 }, { MITYPE_CLRFLAG, LEVEL_CHECKSWITCHRANGE, 0 }, + { MITYPE_STRING, lioffset(translator), 0 }, }; static const char *MapInfoClusterLevel[] = @@ -605,6 +607,20 @@ void G_ParseMapInfo () } } +static FSpecialAction *CopySpecialActions(FSpecialAction *spec) +{ + FSpecialAction **pSpec = &spec; + + while (*pSpec) + { + FSpecialAction *newspec = new FSpecialAction; + *newspec = **pSpec; + *pSpec = newspec; + pSpec = &newspec->Next; + } + return spec; +} + static void G_DoParseMapInfo (int lump) { level_info_t defaultinfo; @@ -624,8 +640,7 @@ static void G_DoParseMapInfo (int lump) switch (sc.MustMatchString (MapInfoTopLevel)) { case MITL_DEFAULTMAP: - if (defaultinfo.music != NULL) delete [] defaultinfo.music; - if (defaultinfo.intermusic != NULL) delete [] defaultinfo.intermusic; + ClearLevelInfoStrings(&defaultinfo); SetLevelDefaults (&defaultinfo); ParseMapInfoLower (sc, MapHandlers, MapInfoMapLevel, &defaultinfo, NULL, defaultinfo.flags); break; @@ -668,6 +683,11 @@ static void G_DoParseMapInfo (int lump) { levelinfo->intermusic = copystring (levelinfo->intermusic); } + if (levelinfo->translator != NULL) + { + levelinfo->translator = copystring (levelinfo->translator); + } + levelinfo->specialactions = CopySpecialActions(levelinfo->specialactions); if (HexenHack) { levelinfo->WallHorizLight = levelinfo->WallVertLight = 0; @@ -773,14 +793,7 @@ static void G_DoParseMapInfo (int lump) } } - if (defaultinfo.music != NULL) - { - delete [] defaultinfo.music; - } - if (defaultinfo.intermusic != NULL) - { - delete [] defaultinfo.intermusic; - } + ClearLevelInfoStrings(&defaultinfo); } static void ClearLevelInfoStrings(level_info_t *linfo) @@ -800,6 +813,11 @@ static void ClearLevelInfoStrings(level_info_t *linfo) delete[] linfo->level_name; linfo->level_name = NULL; } + if (linfo->translator != NULL) + { + delete[] linfo->translator; + linfo->translator = NULL; + } for (FSpecialAction *spac = linfo->specialactions; spac != NULL; ) { FSpecialAction *next = spac->Next; diff --git a/src/g_level.h b/src/g_level.h index 69c3e0ac0d..8608ecdb74 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -124,7 +124,7 @@ struct FSpecialAction { FName Type; // this is initialized before the actors... BYTE Action; - WORD Args[5]; // must allow 16 bit tags for 666 & 667! + int Args[5]; // must allow 16 bit tags for 666 & 667! FSpecialAction *Next; }; @@ -163,6 +163,7 @@ struct level_info_s int airsupply; DWORD compatflags; DWORD compatmask; + char *translator; // for converting Doom-format linedef and sector types. // Redirection: If any player is carrying the specified item, then // you go to the RedirectMap instead of this one. diff --git a/src/gi.cpp b/src/gi.cpp index 7bca0ede96..72231f79ca 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -94,7 +94,8 @@ gameinfo_t HexenGameInfo = GAME_Hexen, 150, "F_SKY", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/heretic.txt", // not really correct but this was used before. }; gameinfo_t HexenDKGameInfo = @@ -122,7 +123,8 @@ gameinfo_t HexenDKGameInfo = GAME_Hexen, 150, "F_SKY", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/heretic.txt", // not really correct but this was used before. }; gameinfo_t HereticGameInfo = @@ -150,7 +152,8 @@ gameinfo_t HereticGameInfo = GAME_Heretic, 150, "F_SKY1", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/heretic.txt", }; gameinfo_t HereticSWGameInfo = @@ -178,7 +181,8 @@ gameinfo_t HereticSWGameInfo = GAME_Heretic, 150, "F_SKY1", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/heretic.txt", }; gameinfo_t SharewareGameInfo = @@ -206,7 +210,8 @@ gameinfo_t SharewareGameInfo = GAME_Doom, 100, "F_SKY1", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/doom.txt", }; gameinfo_t RegisteredGameInfo = @@ -234,7 +239,8 @@ gameinfo_t RegisteredGameInfo = GAME_Doom, 100, "F_SKY1", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/doom.txt", }; gameinfo_t RetailGameInfo = @@ -262,7 +268,8 @@ gameinfo_t RetailGameInfo = GAME_Doom, 100, "F_SKY1", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/doom.txt", }; gameinfo_t CommercialGameInfo = @@ -290,7 +297,8 @@ gameinfo_t CommercialGameInfo = GAME_Doom, 100, "F_SKY1", - 24*FRACUNIT + 24*FRACUNIT, + "xlat/doom.txt", }; gameinfo_t StrifeGameInfo = @@ -318,7 +326,8 @@ gameinfo_t StrifeGameInfo = GAME_Strife, 150, "F_SKY001", - 16*FRACUNIT + 16*FRACUNIT, + "xlat/strife.txt", }; gameinfo_t StrifeTeaserGameInfo = @@ -346,7 +355,8 @@ gameinfo_t StrifeTeaserGameInfo = GAME_Strife, 150, "F_SKY001", - 16*FRACUNIT + 16*FRACUNIT, + "xlat/strife.txt", }; gameinfo_t StrifeTeaser2GameInfo = @@ -374,5 +384,6 @@ gameinfo_t StrifeTeaser2GameInfo = GAME_Strife, 150, "F_SKY001", - 16*FRACUNIT + 16*FRACUNIT, + "xlat/strife.txt", }; diff --git a/src/gi.h b/src/gi.h index 49ab57be3f..101074641a 100644 --- a/src/gi.h +++ b/src/gi.h @@ -113,6 +113,7 @@ typedef struct int defKickback; char SkyFlatName[9]; fixed_t StepHeight; + const char *translator; } gameinfo_t; extern gameinfo_t gameinfo; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index b0c1146dea..4268d9062a 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -63,6 +63,7 @@ extern void P_SpawnMapThing (mapthing2_t *mthing, int position); extern bool P_LoadBuildMap (BYTE *mapdata, size_t len, mapthing2_t **things, int *numthings); +extern void P_LoadTranslator(const char *lump); extern void P_TranslateLineDef (line_t *ld, maplinedef_t *mld); extern void P_TranslateTeleportThings (void); extern int P_TranslateSectorSpecial (int); @@ -3605,6 +3606,10 @@ void P_SetupLevel (char *lumpname, int position) { level.flags &= ~LEVEL_LAXMONSTERACTIVATION; } + + // We need translators only for Doom format maps. + // If none has been defined in a map use the game's default. + P_LoadTranslator(level.info->translator != NULL? (const char *)level.info->translator : gameinfo.translator); } FBehavior::StaticLoadDefaultModules (); diff --git a/src/xlat/parse_xlat.cpp b/src/xlat/parse_xlat.cpp index a15f248803..d414ccb419 100644 --- a/src/xlat/parse_xlat.cpp +++ b/src/xlat/parse_xlat.cpp @@ -44,6 +44,7 @@ #include "xlat_parser.h" #include "xlat.h" +static FString LastTranslator; TAutoGrowArray SimpleLineTranslations; FBoomTranslator Boomish[MAX_BOOMISH]; int NumBoomish; @@ -462,39 +463,26 @@ void ParseXlatLump(const char *lumpname, void *pParser, XlatParseContext *contex // //========================================================================== -void ParseXlat(const char *lumpname) +void P_LoadTranslator(const char *lumpname) { - void *pParser = XlatParseAlloc(malloc); - - XlatParseContext context; - - ParseXlatLump(lumpname, pParser, &context); - XlatToken tok; - tok.val=0; - XlatParse(pParser, 0, tok, &context); - XlatParseFree(pParser, free); -} - -//========================================================================== -// -// -// -//========================================================================== - -AT_GAME_SET(Translators) -{ - if (gameinfo.gametype == GAME_Doom) + // Only read the lump if it differs from the previous one. + if (LastTranslator.CompareNoCase(lumpname)) { - ParseXlat("xlat/doom.txt"); - } - else if (gameinfo.gametype == GAME_Strife) - { - ParseXlat("xlat/strife.txt"); - } - else - { - ParseXlat("xlat/heretic.txt"); + // Clear the old data before parsing the lump. + SimpleLineTranslations.Clear(); + NumBoomish = 0; + SectorTranslations.Clear(); + SectorMasks.Clear(); + + void *pParser = XlatParseAlloc(malloc); + + XlatParseContext context; + + ParseXlatLump(lumpname, pParser, &context); + XlatToken tok; + tok.val=0; + XlatParse(pParser, 0, tok, &context); + XlatParseFree(pParser, free); + LastTranslator = lumpname; } } - -