From 5336f1085c327ca06f5f549448c5cc594a4fe7b2 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 11 Jan 2015 10:30:30 +0200 Subject: [PATCH 01/16] Fixed incorrect value that I_FPSTime() may return when OS X thread-based timer implementation is used --- src/posix/cocoa/i_timer.cpp | 42 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/posix/cocoa/i_timer.cpp b/src/posix/cocoa/i_timer.cpp index 319cdd2b8..b08a43139 100644 --- a/src/posix/cocoa/i_timer.cpp +++ b/src/posix/cocoa/i_timer.cpp @@ -32,6 +32,7 @@ */ #include +#include #include #include #include @@ -43,34 +44,23 @@ #include "templates.h" -static timeval s_startTicks; - - -unsigned int I_MSTime() +namespace { - timeval now; - gettimeofday(&now, NULL); - const uint32_t ticks = - (now.tv_sec - s_startTicks.tv_sec ) * 1000 - + (now.tv_usec - s_startTicks.tv_usec) / 1000; +timeval s_gameStartTicks; +timeval s_systemBootTicks; - return ticks; -} - -unsigned int I_FPSTime() +unsigned int GetMillisecondsSince(const timeval& time) { timeval now; gettimeofday(&now, NULL); return static_cast( - (now.tv_sec) * 1000 + (now.tv_usec) / 1000); + (now.tv_sec - time.tv_sec ) * 1000 + + (now.tv_usec - time.tv_usec) / 1000); } -namespace -{ - bool s_isTicFrozen; timespec GetNextTickTime() @@ -185,6 +175,17 @@ void FreezeTimeThreaded(bool frozen) } // unnamed namespace +unsigned int I_MSTime() +{ + return GetMillisecondsSince(s_gameStartTicks); +} + +unsigned int I_FPSTime() +{ + return GetMillisecondsSince(s_systemBootTicks); +} + + fixed_t I_GetTimeFrac(uint32* ms) { const uint32_t now = I_MSTime(); @@ -205,7 +206,12 @@ void I_InitTimer() assert(!s_timerInitialized); s_timerInitialized = true; - gettimeofday(&s_startTicks, NULL); + gettimeofday(&s_gameStartTicks, NULL); + + int mib[2] = { CTL_KERN, KERN_BOOTTIME }; + size_t len = sizeof s_systemBootTicks; + + sysctl(mib, 2, &s_systemBootTicks, &len, NULL, 0); pthread_cond_init (&s_timerEvent, NULL); pthread_mutex_init(&s_timerMutex, NULL); From 7ae3678abc322f6a951916b8ccb5cf18bae33a00 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 11 Jan 2015 11:43:43 +0200 Subject: [PATCH 02/16] Extended check for embedded WADs with one special case Added loading of embedded WAD file if `myfile.wad` is placed in `myfile` directory inside `myfile.zip` This helps with an unpleasant and very annoying fashion to zip a folder instead of just .wad and .txt files. Recent examples include Monster Hunter Ltd.: http://www.doomworld.com/idgames/?id=17601 and http://www.doomworld.com/idgames/?id=17625 Hell Awakened 2 Episode 1: http://www.doomworld.com/idgames/?id=17795 Bauhaus: http://www.doomworld.com/idgames/?id=17954 --- src/resourcefiles/resourcefile.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index 8a4f07fd7..24b3ad3d6 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -150,11 +150,22 @@ void FResourceLump::LumpNameSetup(const char *iname) // //========================================================================== +static bool IsWadInFolder(const char* const fullName) +{ + // Checks a special case when was put in + // directory inside + + const FString baseName = ExtractFileBase(fullName); + const FString fileName = baseName + '/' + baseName + ".wad"; + + return 0 == fileName.CompareNoCase(fullName); +} + void FResourceLump::CheckEmbedded() { // Checks for embedded archives const char *c = strstr(FullName, ".wad"); - if (c && strlen(c) == 4 && !strchr(FullName, '/')) + if (c && strlen(c) == 4 && (!strchr(FullName, '/') || IsWadInFolder(FullName))) { // Mark all embedded WADs Flags |= LUMPF_EMBEDDED; From 9df56216b32617509d79c212ddfce8df290d74c7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 12 Jan 2015 11:28:40 +0200 Subject: [PATCH 03/16] Reworked check for embedded WADs put inside directory within archive Any WAD from directory named the same as archive are treated as embedded Fixed the issue with archive filename that wasn't taken into account --- src/resourcefiles/resourcefile.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index 24b3ad3d6..15a4337b1 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -150,22 +150,28 @@ void FResourceLump::LumpNameSetup(const char *iname) // //========================================================================== -static bool IsWadInFolder(const char* const fullName) +static bool IsWadInFolder(const FResourceFile* const archive, const char* const resPath) { - // Checks a special case when was put in - // directory inside + // Checks a special case when was put in + // directory inside - const FString baseName = ExtractFileBase(fullName); - const FString fileName = baseName + '/' + baseName + ".wad"; + if (NULL == archive) + { + return false; + } - return 0 == fileName.CompareNoCase(fullName); + const FString dirName = ExtractFileBase(archive->Filename); + const FString fileName = ExtractFileBase(resPath, true); + const FString filePath = dirName + '/' + fileName; + + return 0 == filePath.CompareNoCase(resPath); } void FResourceLump::CheckEmbedded() { // Checks for embedded archives const char *c = strstr(FullName, ".wad"); - if (c && strlen(c) == 4 && (!strchr(FullName, '/') || IsWadInFolder(FullName))) + if (c && strlen(c) == 4 && (!strchr(FullName, '/') || IsWadInFolder(Owner, FullName))) { // Mark all embedded WADs Flags |= LUMPF_EMBEDDED; From db25322b4c479a4b729918c06caa26bf7008aaf8 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Tue, 13 Jan 2015 21:01:00 +1300 Subject: [PATCH 04/16] P_SpawnPuff MF4_RANDOMIZE behaviour - Doom's BulletPuff random spawn tics behaviour was lost at some point. --- src/p_mobj.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 09f84663a..fea80f868 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4959,6 +4959,13 @@ AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t puff = Spawn (pufftype, x, y, z, ALLOW_REPLACE); if (puff == NULL) return NULL; + if ((puff->flags4 & MF4_RANDOMIZE) && puff->tics > 0) + { + puff->tics -= pr_spawnpuff() & 3; + if (puff->tics < 1) + puff->tics = 1; + } + //Moved puff creation and target/master/tracer setting to here. if (puff && vict) { From 1c2a6e8457237bdbe355ad402c2fa11b6a470927 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 16 Jan 2015 13:12:18 -0500 Subject: [PATCH 05/16] - Fixed: fullscreenoffset coordinates were determined by translated (offsets) coordinates instead of input coordinates. --- src/g_shared/sbarinfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 7a11a2865..8ffedb5a4 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -1280,8 +1280,8 @@ public: // We can't use DTA_HUDRules since it forces a width and height. // Translation: No high res. - bool xright = rx < 0; - bool ybot = ry < 0; + bool xright = *x < 0; + bool ybot = *y < 0; w = (forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth); h = (forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight); From 4bae3f99762ac7c1d602fdcc95142e10809d28ea Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 16 Jan 2015 18:58:23 -0500 Subject: [PATCH 06/16] - Fixed: SDLVideo::CreateFrameBuffer cleared "retry" too soon resulting in infinite recursion if the code was used. --- src/posix/sdl/sdlvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 7a04ce901..309002456 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -286,7 +286,6 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree } SDLFB *fb = new SDLFB (width, height, fullscreen); - retry = 0; // If we could not create the framebuffer, try again with slightly // different parameters in this order: @@ -327,6 +326,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree ++retry; fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); } + retry = 0; fb->SetFlash (flashColor, flashAmount); From 845bcdf14c0beda51d6bfd0c9db062c287e35d8b Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 16 Jan 2015 19:13:51 -0500 Subject: [PATCH 07/16] - Attempt to disable all comparison operators on FString since unless we decide otherwise, it's a programming error to use them (caused implicit conversion to const char* and then the built in comparision was called). --- src/zstring.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/zstring.h b/src/zstring.h index 0104020fa..82c38142c 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -296,6 +296,16 @@ protected: static FNullStringData NullString; friend struct FStringData; + +private: + // Prevent these from being called as current practices are to use Compare. + // Without this FStrings will be accidentally compared against char* ptrs. + bool operator == (const FString &illegal) const; + bool operator != (const FString &illegal) const; + bool operator < (const FString &illegal) const; + bool operator > (const FString &illegal) const; + bool operator <= (const FString &illegal) const; + bool operator >= (const FString &illegal) const; }; namespace StringFormat From 105a62cc20f878e86ad3b348888d327aea330d5b Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 19 Jan 2015 14:54:20 -0600 Subject: [PATCH 08/16] - Added pointer field to A_ChangeVelocity. - Defaults to AAPTR_DEFAULT, otherwise known as the calling actor. --- src/thingdef/thingdef_codeptr.cpp | 27 ++++++++++++++++++--------- wadsrc/static/actors/actor.txt | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 300ee7556..d522f284a 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4029,12 +4029,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) ACTION_PARAM_FIXED(y, 1); ACTION_PARAM_FIXED(z, 2); ACTION_PARAM_INT(flags, 3); + ACTION_PARAM_INT(ptr, 4); - INTBOOL was_moving = self->velx | self->vely | self->velz; + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } + + INTBOOL was_moving = ref->velx | ref->vely | ref->velz; fixed_t vx = x, vy = y, vz = z; - fixed_t sina = finesine[self->angle >> ANGLETOFINESHIFT]; - fixed_t cosa = finecosine[self->angle >> ANGLETOFINESHIFT]; + fixed_t sina = finesine[ref->angle >> ANGLETOFINESHIFT]; + fixed_t cosa = finecosine[ref->angle >> ANGLETOFINESHIFT]; if (flags & 1) // relative axes - make x, y relative to actor's current angle { @@ -4043,15 +4052,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) } if (flags & 2) // discard old velocity - replace old velocity with new velocity { - self->velx = vx; - self->vely = vy; - self->velz = vz; + ref->velx = vx; + ref->vely = vy; + ref->velz = vz; } else // add new velocity to old velocity { - self->velx += vx; - self->vely += vy; - self->velz += vz; + ref->velx += vx; + ref->vely += vy; + ref->velz += vz; } if (was_moving) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index b2fa80c30..44ba7f9b6 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -293,7 +293,7 @@ ACTOR Actor native //: Thinker action native A_SetPitch(float pitch, int flags = 0); action native A_SetRoll(float roll, int flags = 0); action native A_ScaleVelocity(float scale); - action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0); + action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_SetArg(int pos, int value); action native A_SetUserVar(name varname, int value); action native A_SetUserArray(name varname, int index, int value); From 67312b907b22bee6abc794fc19e954820171a649 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 Jan 2015 10:25:58 +0100 Subject: [PATCH 09/16] - fixed: AInventory::AbsorbDamage may only be called for positive damage values, otherwise it ends up adding armor points. --- src/p_interaction.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 36a68281e..7bf19a03b 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1278,7 +1278,10 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL) { int newdam = damage; - player->mo->Inventory->AbsorbDamage(damage, mod, newdam); + if (damage > 0) + { + player->mo->Inventory->AbsorbDamage(damage, mod, newdam); + } if (damage < TELEFRAG_DAMAGE) { // if we are telefragging don't let the damage value go below that magic value. Some further checks would fail otherwise. From fa411af1daab62980d2b77cc73c3fd0723962e6d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 18 Jan 2015 09:21:59 -0600 Subject: [PATCH 10/16] - Fixed: Reflected projectiles were always changing their angles to 0. --- src/p_mobj.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index fea80f868..bb33a88c4 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1970,6 +1970,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { //int dir; //angle_t delta; + angle = R_PointToAngle2(BlockingMobj->x, BlockingMobj->y, mo->x, mo->y); bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle)); // Change angle for deflection/reflection @@ -1989,7 +1990,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) //dest->x - source->x FVector3 velocity(origin->x - mo->x, origin->y - mo->y, (origin->z + (origin->height/2)) - mo->z); velocity.Resize(speed); - angle = mo->angle >> ANGLETOFINESHIFT; + angle = mo->angle >>= ANGLETOFINESHIFT; mo->velx = (fixed_t)(velocity.X); mo->vely = (fixed_t)(velocity.Y); mo->velz = (fixed_t)(velocity.Z); @@ -2001,6 +2002,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } else { + mo->angle = angle; angle >>= ANGLETOFINESHIFT; mo->velx = FixedMul(mo->Speed >> 1, finecosine[angle]); From 4fd87a1ce911065f7d82405843318de99457784c Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 20 Jan 2015 22:54:30 -0600 Subject: [PATCH 11/16] - Redid A_SetHealth. - This function will not take the actor's health below 1, and any attempts to do so will simply set it to 1 in its place. --- src/thingdef/thingdef_codeptr.cpp | 39 ++++++++++++++++++++++++++++++- wadsrc/static/actors/actor.txt | 1 + 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 300ee7556..53b5f7f05 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5656,7 +5656,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SwapTeleFog) // // A_SetFloatBobPhase // -// Changes the FloatBobPhase of the +// Changes the FloatBobPhase of the actor. //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetFloatBobPhase) @@ -5669,6 +5669,43 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetFloatBobPhase) self->FloatBobPhase = bob; } +//=========================================================================== +// A_SetHealth +// +// Changes the health of the actor. +// Takes a pointer as well. +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetHealth) +{ + ACTION_PARAM_START(2); + ACTION_PARAM_INT(health, 0); + ACTION_PARAM_INT(ptr, 1); + + AActor *mobj = COPY_AAPTR(self, ptr); + + if (!mobj) + { + return; + } + + player_t *player = mobj->player; + if (player) + { + if (health <= 0) + player->mo->health = mobj->health = player->health = 1; //Copied from the buddha cheat. + else + player->mo->health = mobj->health = player->health = health; + } + else if (mobj) + { + if (health <= 0) + mobj->health = 1; + else + mobj->health = health; + } +} + //=========================================================================== // // A_SetRipperLevel(int level) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index b2fa80c30..5fda5c590 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -327,6 +327,7 @@ ACTOR Actor native //: Thinker action native A_SetTeleFog(name oldpos, name newpos); action native A_SwapTeleFog(); action native A_SetFloatBobPhase(int bob); + action native A_SetHealth(int health, int ptr = AAPTR_DEFAULT); action native A_SetRipperLevel(int level); action native A_SetRipMin(int min); action native A_SetRipMax(int max); From 73bdd06cebd094c8b4329830132ec5a036a2869f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Jan 2015 14:10:55 +0100 Subject: [PATCH 12/16] - removed bogus angle modification from reflection code. --- src/p_mobj.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index bb33a88c4..ef23ca0ba 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1990,15 +1990,9 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) //dest->x - source->x FVector3 velocity(origin->x - mo->x, origin->y - mo->y, (origin->z + (origin->height/2)) - mo->z); velocity.Resize(speed); - angle = mo->angle >>= ANGLETOFINESHIFT; mo->velx = (fixed_t)(velocity.X); mo->vely = (fixed_t)(velocity.Y); mo->velz = (fixed_t)(velocity.Z); - /* - mo->velx = FixedMul(mo->Speed, finecosine[angle]); - mo->vely = FixedMul(mo->Speed, finesine[angle]); - mo->velz = -mo->velz; - */ } else { From 7157db89b73db5f6edd2e42ad68a52964e48243c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Jan 2015 14:13:25 +0100 Subject: [PATCH 13/16] - fixed: A_VileAttack didn't check for MF7_DONTTHRUST. This is a fixed version of Major Cookes pull request. --- src/g_doom/a_archvile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index 8fce33324..f24ff146e 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -151,5 +151,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0); } - target->velz = Scale(thrust, 1000, target->Mass); + if (!(target->flags7 & MF7_DONTTHRUST)) + target->velz = Scale(thrust, 1000, target->Mass); } From 19b43d47528536c97542f6ae277617b43bf234d8 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 23 Jan 2015 09:26:34 -0600 Subject: [PATCH 14/16] - Added A_ResetHealth(ptr). Defaults to AAPTR_DEFAULT (the action caller). - Added pointers to the following functions, all of them set to AAPTR_DEFAULT: - A_SetAngle - A_SetPitch - A_SetScale - A_SetSpeed - A_ScaleVelocity --- src/thingdef/thingdef_codeptr.cpp | 113 +++++++++++++++++++++++++----- wadsrc/static/actors/actor.txt | 11 +-- 2 files changed, 100 insertions(+), 24 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 926799b7a..32bc9d315 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2504,12 +2504,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeTo) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetScale) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(3); ACTION_PARAM_FIXED(scalex, 0); ACTION_PARAM_FIXED(scaley, 1); + ACTION_PARAM_INT(ptr, 2); - self->scaleX = scalex; - self->scaleY = scaley ? scaley : scalex; + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } + + ref->scaleX = scalex; + ref->scaleY = scaley ? scaley : scalex; } //=========================================================================== @@ -3934,10 +3943,19 @@ enum DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(3); ACTION_PARAM_ANGLE(angle, 0); - ACTION_PARAM_INT(flags, 1) - self->SetAngle(angle, !!(flags & SPF_INTERPOLATE)); + ACTION_PARAM_INT(flags, 1); + ACTION_PARAM_INT(ptr, 2); + + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } + ref->SetAngle(angle, !!(flags & SPF_INTERPOLATE)); } //=========================================================================== @@ -3950,18 +3968,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(3); ACTION_PARAM_ANGLE(pitch, 0); ACTION_PARAM_INT(flags, 1); + ACTION_PARAM_INT(ptr, 2); - if (self->player != NULL || (flags & SPF_FORCECLAMP)) + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } + + if (ref->player != NULL || (flags & SPF_FORCECLAMP)) { // clamp the pitch we set int min, max; - if (self->player != NULL) + if (ref->player != NULL) { - min = self->player->MinPitch; - max = self->player->MaxPitch; + min = ref->player->MinPitch; + max = ref->player->MaxPitch; } else { @@ -3970,7 +3997,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) } pitch = clamp(pitch, min, max); } - self->SetPitch(pitch, !!(flags & SPF_INTERPOLATE)); + ref->SetPitch(pitch, !!(flags & SPF_INTERPOLATE)); } //=========================================================================== @@ -3999,20 +4026,29 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRoll) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) { - ACTION_PARAM_START(1); + ACTION_PARAM_START(2); ACTION_PARAM_FIXED(scale, 0); + ACTION_PARAM_INT(ptr, 1); + + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } INTBOOL was_moving = self->velx | self->vely | self->velz; - self->velx = FixedMul(self->velx, scale); - self->vely = FixedMul(self->vely, scale); - self->velz = FixedMul(self->velz, scale); + ref->velx = FixedMul(ref->velx, scale); + ref->vely = FixedMul(ref->vely, scale); + ref->velz = FixedMul(ref->velz, scale); // If the actor was previously moving but now is not, and is a player, // update its player variables. (See A_Stop.) if (was_moving) { - CheckStopped(self); + CheckStopped(ref); } } @@ -5073,10 +5109,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropItem) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpeed) { - ACTION_PARAM_START(1); + ACTION_PARAM_START(2); ACTION_PARAM_FIXED(speed, 0); + ACTION_PARAM_INT(ptr, 1); + + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } - self->Speed = speed; + ref->Speed = speed; } static bool DoCheckSpecies(AActor *mo, FName species, bool exclude) @@ -5715,6 +5760,36 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetHealth) } } +//=========================================================================== +// A_ResetHealth +// +// Resets the health of the actor to default, except if their dead. +// Takes a pointer. +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ResetHealth) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_INT(ptr, 0); + + AActor *mobj = COPY_AAPTR(self, ptr); + + if (!mobj) + { + return; + } + + player_t *player = mobj->player; + if (player && (player->mo->health > 0)) + { + player->health = player->mo->health = player->mo->GetDefault()->health; //Copied from the resurrect cheat. + } + else if (mobj && (mobj->health > 0)) + { + mobj->health = mobj->GetDefault()->health; + } +} + //=========================================================================== // // A_SetRipperLevel(int level) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index ded3a0b93..f3c567c71 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -231,7 +231,7 @@ ACTOR Actor native //: Thinker action native A_FadeIn(float reduce = 0.1, int flags = 0); action native A_FadeOut(float reduce = 0.1, int flags = 1); //bool remove == true action native A_FadeTo(float target, float amount = 0.1, int flags = 0); - action native A_SetScale(float scalex, float scaley = 0); + action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT); action native A_SetMass(int mass); action native A_SpawnDebris(class spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1); action native A_CheckSight(state label); @@ -289,10 +289,10 @@ ACTOR Actor native //: Thinker action native A_DropWeaponPieces(class p1, class p2, class p3); action native A_PigPain (); action native A_MonsterRefire(int chance, state label); - action native A_SetAngle(float angle = 0, int flags = 0); - action native A_SetPitch(float pitch, int flags = 0); + action native A_SetAngle(float angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + action native A_SetPitch(float pitch, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_SetRoll(float roll, int flags = 0); - action native A_ScaleVelocity(float scale); + action native A_ScaleVelocity(float scale, int ptr = AAPTR_DEFAULT); action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_SetArg(int pos, int value); action native A_SetUserVar(name varname, int value); @@ -302,7 +302,7 @@ ACTOR Actor native //: Thinker action native A_SetTics(int tics); action native A_SetDamageType(name damagetype); action native A_DropItem(class item, int dropamount = -1, int chance = 256); - action native A_SetSpeed(float speed); + action native A_SetSpeed(float speed, int ptr = AAPTR_DEFAULT); action native A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None"); action native A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None"); action native A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None"); @@ -328,6 +328,7 @@ ACTOR Actor native //: Thinker action native A_SwapTeleFog(); action native A_SetFloatBobPhase(int bob); action native A_SetHealth(int health, int ptr = AAPTR_DEFAULT); + action native A_ResetHealth(int ptr = AAPTR_DEFAULT); action native A_SetRipperLevel(int level); action native A_SetRipMin(int min); action native A_SetRipMax(int max); From 301c061ec3520ba592fe9b3c75b5f6c10f0a5145 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 23 Jan 2015 10:24:23 -0600 Subject: [PATCH 15/16] - Added pointer for A_SetRoll. --- src/thingdef/thingdef_codeptr.cpp | 13 +++++++++++-- wadsrc/static/actors/actor.txt | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 32bc9d315..324500f7c 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4010,10 +4010,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRoll) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(3); ACTION_PARAM_ANGLE(roll, 0); ACTION_PARAM_INT(flags, 1); - self->SetRoll(roll, !!(flags & SPF_INTERPOLATE)); + ACTION_PARAM_INT(ptr, 2); + + AActor *ref = COPY_AAPTR(self, ptr); + + if (!ref) + { + ACTION_SET_RESULT(false); + return; + } + ref->SetRoll(roll, !!(flags & SPF_INTERPOLATE)); } //=========================================================================== diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index f3c567c71..f0e68d9a5 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -291,7 +291,7 @@ ACTOR Actor native //: Thinker action native A_MonsterRefire(int chance, state label); action native A_SetAngle(float angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_SetPitch(float pitch, int flags = 0, int ptr = AAPTR_DEFAULT); - action native A_SetRoll(float roll, int flags = 0); + action native A_SetRoll(float roll, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_ScaleVelocity(float scale, int ptr = AAPTR_DEFAULT); action native A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_SetArg(int pos, int value); From d1cca79c3178afb4dc4ef087cb60e4c1a8ec79a8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Jan 2015 20:29:38 +0100 Subject: [PATCH 16/16] - Use SpawnHealth() when calling A_ResetHealth. --- src/thingdef/thingdef_codeptr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 324500f7c..be3921877 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5795,7 +5795,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ResetHealth) } else if (mobj && (mobj->health > 0)) { - mobj->health = mobj->GetDefault()->health; + mobj->health = mobj->SpawnHealth(); } }