From d5c3693fd928a9cc1ceaf1b58d6da66976b98877 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 29 Mar 2008 22:59:41 +0000 Subject: [PATCH] - Added SnowKate709's A_DamageMaster/A_DamageChildren patch. - Added a SFX_TRANSFERAMBUSHFLAG for A_SpawnItemEx. - Added "Shaded" as a valid parameter for DECORATE's RenderStyle. - Added Karate Chris's patch for a MAPINFO option making Strife conversations not halt the game. - Extended the $limit fix that $alias and $random definitions can have their own $limit now. - Fixed: When resolving a linked sound the limit of the current sound was ignored and the one of the referenced sound being used. This was particularly noticable when using the chaingun in a group of Zombiemen. - Added a namespc parameter to FWadCollection::CheckNumForFullName which is used when a normal lump name has to be looked up and changed all CheckNumForFullName/CheckNumForName combinations in the source to use the extended version of CheckNumForFullName only to have consistent behavior for lump name lookup. SVN r865 (trunk) --- docs/rh-log.txt | 17 ++++++++ src/codepointers.h | 2 + src/g_level.cpp | 2 + src/g_level.h | 2 + src/g_shared/sbarinfo_parser.cpp | 5 +-- src/p_conversation.cpp | 12 +++--- src/r_things.cpp | 6 +-- src/s_advsound.cpp | 9 +++-- src/s_sound.cpp | 26 +++++++----- src/sc_man.cpp | 4 +- src/textures/texturemanager.cpp | 5 +-- src/thingdef/thingdef_codeptr.cpp | 67 ++++++++++++++++++++++++++++++- src/thingdef/thingdef_main.cpp | 25 +++--------- src/v_font.cpp | 11 ++--- src/w_wad.cpp | 4 +- src/w_wad.h | 2 +- wadsrc/decorate/constants.txt | 1 + wadsrc/decorate/nativeclasses.txt | 2 + 18 files changed, 138 insertions(+), 64 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index ba1b33b72..be6638080 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,20 @@ +March 29, 2008 (Changes by Graf Zahl) +- Added SnowKate709's A_DamageMaster/A_DamageChildren patch. +- Added a SFX_TRANSFERAMBUSHFLAG for A_SpawnItemEx. +- Added "Shaded" as a valid parameter for DECORATE's RenderStyle. +- Added Karate Chris's patch for a MAPINFO option making Strife conversations + not halt the game. +- Extended the $limit fix that $alias and $random definitions can have their + own $limit now. +- Fixed: When resolving a linked sound the limit of the current sound was + ignored and the one of the referenced sound being used. This was particularly + noticable when using the chaingun in a group of Zombiemen. +- Added a namespc parameter to FWadCollection::CheckNumForFullName which is + used when a normal lump name has to be looked up and changed all + CheckNumForFullName/CheckNumForName combinations in the source to use + the extended version of CheckNumForFullName only to have consistent + behavior for lump name lookup. + March 28, 2008 - Moved sound sample rate, buffer size, and buffer count to the advanced sound options menu. Removed opl_enable from the menu. diff --git a/src/codepointers.h b/src/codepointers.h index e9ce9e793..25270f613 100644 --- a/src/codepointers.h +++ b/src/codepointers.h @@ -108,3 +108,5 @@ ACTOR(DropFire) ACTOR(ClearTarget) ACTOR(LookEx) ACTOR(JumpIfTargetInLOS) +ACTOR(DamageMaster) +ACTOR(DamageChildren) diff --git a/src/g_level.cpp b/src/g_level.cpp index 0cfaa3e0d..1b7710af0 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -310,6 +310,7 @@ static const char *MapInfoMapLevel[] = "checkswitchrange", "nocheckswitchrange", "translator", + "unfreezesingleplayerconversations", NULL }; @@ -460,6 +461,7 @@ MapHandlers[] = { MITYPE_SETFLAG, LEVEL_CHECKSWITCHRANGE, 0 }, { MITYPE_CLRFLAG, LEVEL_CHECKSWITCHRANGE, 0 }, { MITYPE_STRING, lioffset(translator), 0 }, + { MITYPE_SETFLAG, LEVEL_CONV_SINGLE_UNFREEZE, 0 }, }; static const char *MapInfoClusterLevel[] = diff --git a/src/g_level.h b/src/g_level.h index 8608ecdb7..7d8dd1864 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -117,6 +117,8 @@ #define LEVEL_FORCETEAMPLAYON UCONST64(0x4000000000000) #define LEVEL_FORCETEAMPLAYOFF UCONST64(0x8000000000000) +#define LEVEL_CONV_SINGLE_UNFREEZE UCONST64(0x10000000000000) + struct acsdefered_s; diff --git a/src/g_shared/sbarinfo_parser.cpp b/src/g_shared/sbarinfo_parser.cpp index f6feaa1e8..27cde16cb 100644 --- a/src/g_shared/sbarinfo_parser.cpp +++ b/src/g_shared/sbarinfo_parser.cpp @@ -137,10 +137,7 @@ void SBarInfo::ParseSBarInfo(int lump) if(sc.TokenType == TK_Include) { sc.MustGetToken(TK_StringConst); - int lump = Wads.CheckNumForFullName(sc.String); //zip/pk3 - //Do a normal wad lookup. - if (lump == -1 && sc.StringLen <= 8 && !strchr(sc.String, '/')) - lump = Wads.CheckNumForName(sc.String); + int lump = Wads.CheckNumForFullName(sc.String, true); if (lump == -1) sc.ScriptError("Lump '%s' not found", sc.String); ParseSBarInfo(lump); diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index e7aaedd2a..28be4e88a 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -639,7 +639,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang int i, j; // [CW] If an NPC is talking to a PC already, then don't let - // anyone else talk to NPC. + // anyone else talk to the NPC. for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || pc->player == &players[i]) @@ -826,8 +826,8 @@ static void DrawConversationMenu () return; } - // [CW] Pausing the game in a multiplayer game is a bad idea. - if (ConversationPauseTic < gametic && !multiplayer) + // [CW] Freeze the game depending on MAPINFO options. + if (ConversationPauseTic < gametic && !multiplayer && !(level.flags & LEVEL_CONV_SINGLE_UNFREEZE)) { menuactive = MENU_On; } @@ -1037,9 +1037,9 @@ static void PickConversationReply () Net_WriteByte (DEM_CONVERSATION); Net_WriteByte (CONV_NPCANGLE); - // [CW] Set these to NULL because we're not talking to them - // anymore. However, this can interfere with slideshows so - // we don't set them to NULL in that case. + // [CW] Set these to NULL because we're not using to them + // anymore. However, this can interfere with slideshows + // so we don't set them to NULL in that case. if (gameaction != ga_slideshow) { Net_WriteByte (DEM_CONVERSATION); diff --git a/src/r_things.cpp b/src/r_things.cpp index b3a85b089..0eb53ef9a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -573,8 +573,7 @@ void R_InitSkins (void) int lump = Wads.CheckNumForName (sc.String, skins[i].namespc); if (lump == -1) { - lump = Wads.CheckNumForFullName (sc.String); - if (lump == -1) lump = Wads.CheckNumForName (sc.String, ns_sounds); + lump = Wads.CheckNumForFullName (sc.String, true, ns_sounds); } if (lump != -1) { @@ -607,8 +606,7 @@ void R_InitSkins (void) sndlumps[j] = Wads.CheckNumForName (sc.String, skins[i].namespc); if (sndlumps[j] == -1) { // Replacement not found, try finding it in the global namespace - sndlumps[j] = Wads.CheckNumForFullName (sc.String); - if (sndlumps[j] == -1) sndlumps[j] = Wads.CheckNumForName (sc.String, ns_sounds); + sndlumps[j] = Wads.CheckNumForFullName (sc.String, true, ns_sounds); } } } diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 055f318a9..8fc923cc5 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -493,8 +493,7 @@ int S_FindSoundTentative (const char *name) int S_AddSound (const char *logicalname, const char *lumpname, FScanner *sc) { - int lump = Wads.CheckNumForFullName (lumpname); - if (lump == -1) lump = Wads.CheckNumForName (lumpname, ns_sounds); + int lump = Wads.CheckNumForFullName (lumpname, true, ns_sounds); return S_AddSound (logicalname, lump); } @@ -536,6 +535,7 @@ static int S_AddSound (const char *logicalname, int lumpnum, FScanner *sc) sfx->bRandomHeader = false; sfx->link = sfxinfo_t::NO_LINK; sfx->bTentative = false; + if (sfx->NearLimit < 0) sfx->NearLimit = 2; //sfx->PitchMask = CurrentPitchMask; } else @@ -560,7 +560,7 @@ int S_AddPlayerSound (const char *pclass, int gender, int refid, if (lumpname) { - lump = Wads.CheckNumForFullName (lumpname); + lump = Wads.CheckNumForFullName (lumpname, true, ns_sounds); if (lump == -1) lump = Wads.CheckNumForName (lumpname, ns_sounds); } @@ -1104,6 +1104,7 @@ static void S_AddSNDINFO (int lump) sfxfrom = S_sfx[sfxfrom].link; } S_sfx[sfxfrom].link = S_FindSoundTentative (sc.String); + S_sfx[sfxfrom].NearLimit = -1; // Aliases must use the original sound's limit. } break; @@ -1233,6 +1234,7 @@ static void S_AddSNDINFO (int lump) if (list.Size() == 1) { // Only one sound: treat as $alias S_sfx[random.SfxHead].link = list[0]; + S_sfx[random.SfxHead].NearLimit = -1; } else if (list.Size() > 1) { // Only add non-empty random lists @@ -1241,6 +1243,7 @@ static void S_AddSNDINFO (int lump) S_sfx[random.SfxHead].bRandomHeader = true; S_rnd[S_sfx[random.SfxHead].link].Sounds = new WORD[random.NumSounds]; memcpy (S_rnd[S_sfx[random.SfxHead].link].Sounds, &list[0], sizeof(WORD)*random.NumSounds); + S_sfx[random.SfxHead].NearLimit = -1; } } break; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index c1616139c..c5d6c67bf 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -95,7 +95,7 @@ extern float S_GetMusicVolume (const char *music); static fixed_t P_AproxDistance2(fixed_t *listener, fixed_t x, fixed_t y); static void S_StartSound(fixed_t *pt, AActor *mover, int channel, int sound_id, float volume, float attenuation); -static bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3]); +static bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3], int NearLimit); static void S_ActivatePlayList(bool goBack); static void CalcPosVel(fixed_t *pt, AActor *mover, int constz, float pos[3], float vel[3]); @@ -684,20 +684,27 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, if (volume <= 0) return; + // When resolving a link we do not want to get the NearLimit of + // the referenced sound so some additional checks are required + int NearLimit = sfx->NearLimit; + // Resolve player sounds, random sounds, and aliases while (sfx->link != sfxinfo_t::NO_LINK) { if (sfx->bPlayerReserve) { sound_id = S_FindSkinnedSound (mover, sound_id); + NearLimit = sfx[sound_id].NearLimit; } else if (sfx->bRandomHeader) { sound_id = S_PickReplacement (sound_id); + if (NearLimit < 0) NearLimit = sfx[sound_id].NearLimit; } else { sound_id = sfx->link; + if (NearLimit < 0) NearLimit = sfx[sound_id].NearLimit; } sfx = &S_sfx[sound_id]; } @@ -708,7 +715,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, // If this sound doesn't like playing near itself, don't play it if // that's what would happen. - if (sfx->NearLimit && pt != NULL && S_CheckSoundLimit(sfx, pos)) + if (NearLimit > 0 && pt != NULL && S_CheckSoundLimit(sfx, pos, NearLimit)) return; // Make sure the sound is loaded. @@ -935,12 +942,12 @@ bool S_CheckSingular(int sound_id) // //========================================================================== -bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3]) +bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3], int NearLimit) { FSoundChan *chan; int count; - for (chan = Channels, count = 0; chan != NULL && count < sfx->NearLimit; chan = chan->NextChan) + for (chan = Channels, count = 0; chan != NULL && count < NearLimit; chan = chan->NextChan) { if (chan->SfxInfo == sfx) { @@ -953,7 +960,7 @@ bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3]) } } } - return count >= sfx->NearLimit; + return count >= NearLimit; } //========================================================================== @@ -1315,13 +1322,10 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) if (!FileExists (musicname)) { - if ((lumpnum = Wads.CheckNumForName (musicname, ns_music)) == -1) + if ((lumpnum = Wads.CheckNumForFullName (musicname, true, ns_music)) == -1) { - if ((lumpnum = Wads.CheckNumForFullName (musicname)) == -1) - { - Printf ("Music \"%s\" not found\n", musicname); - return false; - } + Printf ("Music \"%s\" not found\n", musicname); + return false; } if (!Wads.IsUncompressedFile(lumpnum)) { diff --git a/src/sc_man.cpp b/src/sc_man.cpp index cfaeaf24c..31d474587 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -164,10 +164,10 @@ FScanner &FScanner::operator=(const FScanner &other) void FScanner::Open (const char *name) { - int lump = Wads.CheckNumForFullName(name); + int lump = Wads.CheckNumForFullName(name, true); if (lump == -1) { - lump = Wads.GetNumForName(name); + I_Error("Could not find script lump '%s'\n", name); } OpenLumpNum(lump, name); } diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 4c2499bbc..f90a852a2 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -530,8 +530,7 @@ void FTextureManager::LoadHiresTex(int wadnum) FName texname = sc.String; sc.MustGetString(); - int lumpnum = Wads.CheckNumForFullName(sc.String); - if (lumpnum < 0) lumpnum = Wads.CheckNumForName(sc.String, ns_graphics); + int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics); if (tlist.Size() == 0) { @@ -572,7 +571,7 @@ void FTextureManager::LoadHiresTex(int wadnum) sc.GetString(); memcpy(src, sc.String, 8); - int lumpnum = Wads.CheckNumForFullName(sc.String); + int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics); if (lumpnum < 0) lumpnum = Wads.CheckNumForName(sc.String, ns_graphics); sc.GetString(); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index bd453d4b2..99f6f5cf1 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1477,7 +1477,9 @@ enum SIX_Flags SIXF_ABSOLUTEMOMENTUM=8, SIXF_SETMASTER=16, SIXF_NOCHECKPOSITION=32, - SIXF_TELEFRAG=64 + SIXF_TELEFRAG=64, + // 128 is used by Skulltag! + SIXF_TRANSFERAMBUSHFLAG=256, }; void A_SpawnItemEx(AActor * self) @@ -1547,6 +1549,7 @@ void A_SpawnItemEx(AActor * self) mo->momz=zmom; mo->angle=Angle; if (flags & SIXF_TELEFRAG) P_TeleportMove(mo, mo->x, mo->y, mo->z, true); + if (flags & SIXF_TRANSFERAMBUSHFLAG) mo->flags = (mo->flags&~MF_AMBUSH) | (self->flags & MF_AMBUSH); } } @@ -2171,4 +2174,66 @@ void A_JumpIfTargetInLOS(AActor * self) DoJump(self, CallingState, StateParameters[index]); } +//=========================================================================== +// +// A_DamageMaster (int amount) +// Damages the master of this child by the specified amount. Negative values heal. +// +//=========================================================================== +void A_DamageMaster(AActor * self) +{ + int index = CheckIndex(2); + if (index<0) return; + + int amount = EvalExpressionI (StateParameters[index], self); + ENamedName DamageType = (ENamedName)StateParameters[index+1]; + + if (self->master != NULL) + { + if (amount > 0) + { + P_DamageMobj(self->master, self, self, amount, DamageType, DMG_NO_ARMOR); + } + else if (amount < 0) + { + amount = -amount; + P_GiveBody(self->master, amount); + } + } +} + +//=========================================================================== +// +// A_DamageChildren (amount) +// Damages the children of this master by the specified amount. Negative values heal. +// +//=========================================================================== +void A_DamageChildren(AActor * self) +{ + TThinkerIterator it; + AActor * mo; + + int index = CheckIndex(2); + if (index<0) return; + + int amount = EvalExpressionI (StateParameters[index], self); + ENamedName DamageType = (ENamedName)StateParameters[index+3]; + + while ( (mo = it.Next()) ) + { + if (mo->master == self) + { + if (amount > 0) + { + P_DamageMobj(mo, self, self, amount, DamageType, DMG_NO_ARMOR); + } + else if (amount < 0) + { + amount = -amount; + P_GiveBody(mo, amount); + } + } + } +} + // [KS] *** End of my modifications *** diff --git a/src/thingdef/thingdef_main.cpp b/src/thingdef/thingdef_main.cpp index 395d06e50..d19bd4c25 100644 --- a/src/thingdef/thingdef_main.cpp +++ b/src/thingdef/thingdef_main.cpp @@ -66,8 +66,6 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def); static void ParseDecorate (FScanner &sc) { - int lump; - // Get actor class name. for(;;) { @@ -79,26 +77,13 @@ static void ParseDecorate (FScanner &sc) switch (sc.TokenType) { case TK_Include: + { sc.MustGetString(); - // This is not using SC_Open because it can print a more useful error message when done here - lump = Wads.CheckNumForFullName(sc.String); - - // Try a normal WAD name lookup only if it's a proper name without path separator and - // not longer than 8 characters. - if (lump == -1 && sc.StringLen <= 8 && !strchr(sc.String, '/')) - { - lump = Wads.CheckNumForName(sc.String); - } - if (lump == -1) - { - sc.ScriptError("Lump '%s' not found", sc.String); - } - else - { - FScanner newscanner(lump, sc.String); - ParseDecorate(newscanner); - } + FScanner newscanner; + newscanner.Open(sc.String); + ParseDecorate(newscanner); break; + } case TK_Class: ParseClass (sc); diff --git a/src/v_font.cpp b/src/v_font.cpp index 34a83f1c3..4db45c3c1 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -216,17 +216,14 @@ FFont *V_GetFont(const char *name) if (font == NULL) { int lump = -1; - FString fullname; - - if (strlen(name) > 8) + + lump = Wads.CheckNumForFullName(name, true); + if (lump < 0 && strlen(name) > 8) { + FString fullname; fullname.Format("%s.fon", name); lump = Wads.CheckNumForFullName(fullname); } - else - { - lump = Wads.CheckNumForName (name); - } if (lump != -1) { diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 7c53db2b7..544e5944d 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -916,7 +916,7 @@ int FWadCollection::GetNumForName (const char *name, int space) // //========================================================================== -int FWadCollection::CheckNumForFullName (const char *name, bool trynormal) +int FWadCollection::CheckNumForFullName (const char *name, bool trynormal, int namespc) { WORD i; @@ -936,7 +936,7 @@ int FWadCollection::CheckNumForFullName (const char *name, bool trynormal) if (trynormal && strlen(name) <= 8 && !strpbrk(name, "./")) { - return CheckNumForName(name, ns_global); + return CheckNumForName(name, namespc); } return -1; } diff --git a/src/w_wad.h b/src/w_wad.h index 0273a318a..e4f351128 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -181,7 +181,7 @@ public: inline int GetNumForName (const BYTE *name) { return GetNumForName ((const char *)name); } inline int GetNumForName (const BYTE *name, int ns) { return GetNumForName ((const char *)name, ns); } - int CheckNumForFullName (const char *name, bool trynormal = false); + int CheckNumForFullName (const char *name, bool trynormal = false, int namespc = ns_global); int CheckNumForFullName (const char *name, int wadfile); int GetNumForFullName (const char *name); diff --git a/wadsrc/decorate/constants.txt b/wadsrc/decorate/constants.txt index 1b7c894b5..91caf723c 100644 --- a/wadsrc/decorate/constants.txt +++ b/wadsrc/decorate/constants.txt @@ -13,6 +13,7 @@ const int SXF_ABSOLUTEMOMENTUM=8; const int SXF_SETMASTER=16; const int SXF_NOCHECKPOSITION = 32; const int SXF_TELEFRAG=64; +const int SXF_TRANSFERAMBUSHFLAG=128; // Flags for A_Chase const int CHF_FASTCHASE = 1; diff --git a/wadsrc/decorate/nativeclasses.txt b/wadsrc/decorate/nativeclasses.txt index 3984a4504..2a46114c0 100644 --- a/wadsrc/decorate/nativeclasses.txt +++ b/wadsrc/decorate/nativeclasses.txt @@ -174,6 +174,8 @@ class Actor extends Thinker action native A_LookEx(optional eval int flags, optional eval float minseedist, optional eval float maxseedist, optional eval float maxheardist, optional eval float fov, optional state label); action native A_ClearTarget(); action native A_JumpIfTargetInLOS (state label, optional eval float fov); + action native A_DamageMaster(int amount, optional name damagetype); + action native A_DamageChildren(int amount, optional name damagetype); action native A_SelectWeapon(class whichweapon); action native A_Punch(); }