From 782b8a3b92ffabfd2a996e536de78c142e82e66f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Sep 2006 10:43:51 +0000 Subject: [PATCH] - Fixed: The sky scrolling calculations caused an integer multiplication overflow. - Fixed: Voodoo dolls should not start ENTER scripts. - Fixed: ActorDamage must not parse the enclosing parentheses as part of the expression. That will produce an error if a flag set or clear command immediately follows. - Fixed: P_DamageMobj ignored MF2_NODMGTHRUST if the damaging object had no owner. - Added a 'font' parameter to A_Print. - Changed A_CustomMeleeAttack to take one damage parameter only. Since expressions can be used this value is not used as a factor for a random value but as a direct damage value instead. - Fixed: AActor::SetState must check whether a called action function resulted in the actor's destruction. A_Jump constructs to a 0-length terminating state will hang if this isn't checked. SVN r329 (trunk) --- docs/rh-log.txt | 16 +++++++ src/p_acs.cpp | 32 +------------- src/p_interaction.cpp | 2 +- src/p_map.cpp | 1 - src/p_mobj.cpp | 4 ++ src/r_anim.cpp | 2 +- src/thingdef.cpp | 6 +-- src/thingdef_codeptr.cpp | 37 +++++++++++----- src/v_font.cpp | 67 ++++++++++++++++------------- src/v_font.h | 1 + wadsrc/decorate/strife/beggars.txt | 2 +- wadsrc/decorate/strife/peasants.txt | 2 +- 12 files changed, 93 insertions(+), 79 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 680044865..98be689d6 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,19 @@ +September 17, 2006 (Changes by Graf Zahl) +- Fixed: The sky scrolling calculations caused an integer multiplication overflow. +- Fixed: Voodoo dolls should not start ENTER scripts. +- Fixed: ActorDamage must not parse the enclosing parentheses as part of the + expression. That will produce an error if a flag set or clear command immediately + follows. +- Fixed: P_DamageMobj ignored MF2_NODMGTHRUST if the damaging object had no + owner. +- Added a 'font' parameter to A_Print. +- Changed A_CustomMeleeAttack to take one damage parameter only. Since expressions + can be used this value is not used as a factor for a random value but as + a direct damage value instead. +- Fixed: AActor::SetState must check whether a called action function resulted + in the actor's destruction. A_Jump constructs to a 0-length terminating + state will hang if this isn't checked. + September 13, 2006 - Moved the vid_fps display to the upper-right of the screen. - The stat display can now show multiple stats at once. diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 3cd345433..af418402c 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2043,38 +2043,10 @@ showme: void DLevelScript::DoSetFont (int fontnum) { const char *fontname = FBehavior::StaticLookupString (fontnum); - activefont = FFont::FindFont (fontname); + activefont = V_GetFont (fontname); if (activefont == NULL) { - int num = Wads.CheckNumForName (fontname); - if (num != -1) - { - char head[3]; - { - FWadLump lump = Wads.OpenLumpNum (num); - lump.Read (head, 3); - } - if (head[0] == 'F' && head[1] == 'O' && head[2] == 'N') - { - activefont = new FSingleLumpFont (fontname, num); - } - } - if (activefont == NULL) - { - num = TexMan.CheckForTexture (fontname, FTexture::TEX_Any); - if (num <= 0) - { - num = TexMan.AddPatch(fontname); - } - if (num > 0) - { - activefont = new FSingleLumpFont (fontname, -1); - } - else - { - activefont = SmallFont; - } - } + activefont = SmallFont; } if (screen != NULL) { diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index d8ebedc3e..51014ac18 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -909,7 +909,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage // (i.e. Guantlets/Chainsaw) if (inflictor && inflictor != target // [RH] Not if hurting own self && !(target->flags & MF_NOCLIP) - && (!source || !source->player || !(inflictor->flags2 & MF2_NODMGTHRUST))) + && !(inflictor->flags2 & MF2_NODMGTHRUST)) { int kickback; diff --git a/src/p_map.cpp b/src/p_map.cpp index 44717f3c3..bed94d82e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1426,7 +1426,6 @@ AActor *P_CheckOnmobj (AActor *thing) oldz = thing->z; P_FakeZMovement (thing); good = P_TestMobjZ (thing, false); - thing->z = oldz; return good ? NULL : onmobj; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 998aa7153..b37ba323d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -563,6 +563,9 @@ bool AActor::SetState (FState *newstate) CallingState = newstate; newstate->GetAction() (this); + + // Check whether the called action function resulted in destroying the actor + if (ObjectFlags & OF_MassDestruction) return false; } newstate = newstate->GetNextState(); } while (tics == 0); @@ -3437,6 +3440,7 @@ void P_SpawnPlayer (mapthing2_t *mthing, bool startenterscripts) { // Move the voodoo doll's inventory to the new player. mobj->ObtainInventory (oldactor); + FBehavior::StaticStopMyScripts (oldactor); // cancel all ENTER/RESPAWN scripts for the voodoo doll } // [GRB] Reset skin diff --git a/src/r_anim.cpp b/src/r_anim.cpp index 05ca83524..574d4cacf 100644 --- a/src/r_anim.cpp +++ b/src/r_anim.cpp @@ -802,7 +802,7 @@ void R_UpdateAnimations (DWORD mstime) } // Scroll the sky - double ms = mstime * FRACUNIT; + double ms = (double)mstime * FRACUNIT; sky1pos = fixed_t(fmod (ms * level.skyspeed1, double(TexMan[sky1texture]->GetWidth() << FRACBITS))); sky2pos = fixed_t(fmod (ms * level.skyspeed2, double(TexMan[sky2texture]->GetWidth() << FRACBITS))); } diff --git a/src/thingdef.cpp b/src/thingdef.cpp index 49d5db458..0573ed9ba 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -685,7 +685,7 @@ AFuncDesc AFTable[]= FUNC(A_SpawnItem, "Mxxyx" ) FUNC(A_ThrowGrenade, "Mxxxy" ) FUNC(A_SelectWeapon, "M") - FUNC(A_Print, "T") + FUNC(A_Print, "Txt") FUNC(A_SetTranslucent, "Xx") FUNC(A_FadeIn, "x") FUNC(A_FadeOut, "x") @@ -712,7 +712,7 @@ AFuncDesc AFTable[]= FUNC(A_GiveToTarget, "Mx" ) FUNC(A_TakeFromTarget, "Mx" ) FUNC(A_CountdownArg, "X") - FUNC(A_CustomMeleeAttack, "XXXsty" ) + FUNC(A_CustomMeleeAttack, "Xsty" ) FUNC(A_Burst, "M") FUNC(A_RadiusThrust, "xxy") {"A_Explode", A_ExplodeParms, "xxy" }, @@ -2414,8 +2414,8 @@ static void ActorDamage (AActor *defaults, Baggage &bag) if (SC_CheckString ("(")) { - SC_UnGet(); defaults->Damage = 0x40000000 | ParseExpression (false); + SC_MustGetStringName(")"); } else { diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index 509023bf6..146933e92 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -64,13 +64,13 @@ #include "a_sharedglobal.h" #include "a_doomglobal.h" #include "thingdef.h" +#include "v_video.h" static FRandom pr_camissile ("CustomActorfire"); static FRandom pr_camelee ("CustomMelee"); static FRandom pr_cabullet ("CustomBullet"); static FRandom pr_cajump ("CustomJump"); -static FRandom pr_custommelee ("CustomMelee2"); static FRandom pr_cwbullet ("CustomWpBullet"); static FRandom pr_cwjump ("CustomWpJump"); static FRandom pr_cwpunch ("CustomWpPunch"); @@ -750,15 +750,13 @@ void A_CustomBulletAttack (AActor *self) //========================================================================== void A_CustomMeleeAttack (AActor *self) { - int index=CheckIndex(6); + int index=CheckIndex(4); if (index<0) return; - int Multiplier = EvalExpressionI (StateParameters[index], self); - int Modulus = EvalExpressionI (StateParameters[index+1], self); - int Adder = EvalExpressionI (StateParameters[index+2], self); - int MeleeSound=StateParameters[index+3]; - ENamedName DamageType = (ENamedName)StateParameters[index+4]; - bool bleed = EvalExpressionN (StateParameters[index+5], self); + int damage = EvalExpressionI (StateParameters[index], self); + int MeleeSound=StateParameters[index+1]; + ENamedName DamageType = (ENamedName)StateParameters[index+2]; + bool bleed = EvalExpressionN (StateParameters[index+3], self); int mod; // This needs to be redesigned once the customizable damage type system is working @@ -773,7 +771,6 @@ void A_CustomMeleeAttack (AActor *self) A_FaceTarget (self); if (self->CheckMeleeRange ()) { - int damage = ((pr_custommelee()%Modulus)*Multiplier)+Adder; if (MeleeSound) S_SoundID (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM); P_DamageMobj (self->target, self, self, damage, MOD_HIT); if (bleed) P_TraceBleed (damage, self->target, self); @@ -1367,15 +1364,35 @@ void A_SelectWeapon(AActor * actor) // A_Print // //=========================================================================== +EXTERN_CVAR(Float, con_midtime) + void A_Print(AActor * actor) { - int index=CheckIndex(1, NULL); + int index=CheckIndex(3, NULL); if (index<0) return; if (actor->CheckLocalView (consoleplayer) || (actor->target!=NULL && actor->target->CheckLocalView (consoleplayer))) { + float time = EvalExpressionF (StateParameters[index+1], actor); + FName fontname = (ENamedName)StateParameters[index+2]; + FFont * oldfont = screen->Font; + float saved = con_midtime; + + + if (fontname != NAME_None) + { + FFont * font = V_GetFont(fontname); + if (font != NULL) screen->SetFont(font); + } + if (time > 0) + { + con_midtime = time; + } + C_MidPrint(FName((ENamedName)StateParameters[index]).GetChars()); + screen->SetFont(oldfont); + con_midtime = saved; } } diff --git a/src/v_font.cpp b/src/v_font.cpp index b8f1a85e4..ec8686d33 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -164,6 +164,39 @@ static TArray TranslationLookup; // CODE -------------------------------------------------------------------- +FFont * V_GetFont(const char *name) +{ + FFont *font = FFont::FindFont (name); + if (font == NULL) + { + int lump = Wads.CheckNumForName (name); + if (lump != -1) + { + char head[3]; + { + FWadLump lumpy = Wads.OpenLumpNum (lump); + lumpy.Read (head, 3); + } + if (head[0] == 'F' && head[1] == 'O' && head[2] == 'N') + { + font = new FSingleLumpFont (name, lump); + } + } + if (font == NULL) + { + int picnum = TexMan.CheckForTexture (name, FTexture::TEX_Any); + if (picnum <= 0) + { + picnum = TexMan.AddPatch (name); + } + if (picnum > 0) + { + font = new FSingleLumpFont (name, -1); + } + } + } + return font; +} //========================================================================== // // SerializeFFontPtr @@ -181,39 +214,11 @@ FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font) char *name = NULL; arc << name; - font = FFont::FindFont (name); + font = V_GetFont(name); if (font == NULL) { - int lump = Wads.CheckNumForName (name); - if (lump != -1) - { - char head[3]; - { - FWadLump lumpy = Wads.OpenLumpNum (lump); - lumpy.Read (head, 3); - } - if (head[0] == 'F' && head[1] == 'O' && head[2] == 'N') - { - font = new FSingleLumpFont (name, lump); - } - } - if (font == NULL) - { - int picnum = TexMan.CheckForTexture (name, FTexture::TEX_Any); - if (picnum <= 0) - { - picnum = TexMan.AddPatch (name); - } - if (picnum > 0) - { - font = new FSingleLumpFont (name, -1); - } - } - if (font == NULL) - { - Printf ("Could not load font %s\n", name); - font = SmallFont; - } + Printf ("Could not load font %s\n", name); + font = SmallFont; } delete[] name; } diff --git a/src/v_font.h b/src/v_font.h index cebf4dac1..5e9540521 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -152,5 +152,6 @@ extern FFont *SmallFont, *SmallFont2, *BigFont, *ConFont; void V_InitCustomFonts (); void V_InitFontColors (); EColorRange V_FindFontColor (FName name); +FFont * V_GetFont(const char *); #endif //__V_FONT_H__ diff --git a/wadsrc/decorate/strife/beggars.txt b/wadsrc/decorate/strife/beggars.txt index d730780e8..45347d9f1 100644 --- a/wadsrc/decorate/strife/beggars.txt +++ b/wadsrc/decorate/strife/beggars.txt @@ -30,7 +30,7 @@ ACTOR Beggar : StrifeHumanoid Loop Melee: BEGR D 8 - BEGR D 8 A_CustomMeleeAttack(2, 5, 2) + BEGR D 8 A_CustomMeleeAttack(2*random(1,5)+2) BEGR E 1 A_Chase BEGR D 8 A_SentinelRefire Loop diff --git a/wadsrc/decorate/strife/peasants.txt b/wadsrc/decorate/strife/peasants.txt index 463a30cea..c29862aed 100644 --- a/wadsrc/decorate/strife/peasants.txt +++ b/wadsrc/decorate/strife/peasants.txt @@ -29,7 +29,7 @@ ACTOR Peasant : StrifeHumanoid Loop Melee: PEAS E 10 A_FaceTarget - PEAS F 8 A_CustomMeleeAttack(2, 5, 2) + PEAS F 8 A_CustomMeleeAttack(2*random(1,5)+2) PEAS E 8 Goto See Pain: