From 78b4cbdf6c4c7150a1689a78aa25dd4a39a5efc5 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Mon, 26 Jan 2015 02:20:54 +0100 Subject: [PATCH 01/12] - Fixed a very old issue with rotating polydoors. This happened when the polydoor was open. If a mobj blocked the poly door, such that the door could not move from its open position, the poly door could rotate a little bit more than needed, making the door partially closing when the door managed to close later. --- src/po_man.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/po_man.cpp b/src/po_man.cpp index c6e273a0f8..bb9b3ca46a 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -676,7 +676,7 @@ void DPolyDoor::Tick () break; case PODOOR_SWING: - if (poly->RotatePolyobj (m_Speed)) + if (m_Dist <= 0 || poly->RotatePolyobj (m_Speed)) { absSpeed = abs (m_Speed); if (m_Dist == -1) From 6bb0849984275b2605942a58be4cd9e78a74520c Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 30 Jan 2015 16:34:24 -0600 Subject: [PATCH 02/12] - Fixed: MIRRORREFLECT was broken after my last patch to fix the always 0 angle issue. Also simplified the speed change -- it's the same thing without having to recalculate the angle into it. - Also ensure that the check for AIMREFLECT happens no matter what. --- src/p_mobj.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index ef23ca0baa..b368a19705 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1968,8 +1968,6 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // Don't change the angle if there's THRUREFLECT on the monster. if (!(BlockingMobj->flags7 & MF7_THRUREFLECT)) { - //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 @@ -1996,12 +1994,21 @@ 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]); - mo->vely = FixedMul(mo->Speed >> 1, finesine[angle]); - mo->velz = -mo->velz / 2; + if (BlockingMobj->flags7 & MF7_MIRRORREFLECT && (tg || blockingtg)) + { + mo->angle += ANGLE_180; + mo->velx = -mo->velx / 2; + mo->vely = -mo->vely / 2; + mo->velz = -mo->velz / 2; + } + else + { + mo->angle = angle; + angle >>= ANGLETOFINESHIFT; + mo->velx = FixedMul(mo->Speed >> 1, finecosine[angle]); + mo->vely = FixedMul(mo->Speed >> 1, finesine[angle]); + mo->velz = -mo->velz / 2; + } } } else @@ -2932,11 +2939,8 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle) { if (flags2 & MF2_DONTREFLECT) return true; if (thing->flags7 & MF7_THRUREFLECT) return false; - - if (thing->flags7 & MF7_MIRRORREFLECT) - angle += ANGLE_180; // Change angle for reflection - else if (thing->flags4&MF4_SHIELDREFLECT) + if (thing->flags4&MF4_SHIELDREFLECT) { // Shield reflection (from the Centaur if (abs (angle - thing->angle)>>24 > 45) @@ -2959,15 +2963,23 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle) else angle -= ANG45; } - else if (thing->flags7 & MF7_AIMREFLECT) + else + { + angle += ANGLE_1 * ((pr_reflect() % 16) - 8); + } + //Always check for AIMREFLECT, no matter what else is checked above. + if (thing->flags7 & MF7_AIMREFLECT) { if (this->target != NULL) + { A_Face(this, this->target); + } else if (thing->target != NULL) + { A_Face(this, thing->target); + } } - else - angle += ANGLE_1 * ((pr_reflect()%16)-8); + return false; } From 53fd57d6b74b1dea15f8001b351e09d4ceea3960 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 30 Jan 2015 16:48:24 -0600 Subject: [PATCH 03/12] - Added ang_offset and pitch_offset to A_Face, along with 4 new flags: - ang_offset: the extra angle to apply to the actor after calculating the maximum turn. - pitch_offset: Just like ang_offset, with pitch instead. - FAF_BOTTOM: Aim straight for the actor's z coordinate, not with +32 units. - FAF_MIDDLE: Aims for the direct middle of the actor. - FAF_TOP: Aims for the very top of the actor. - FAF_NODISTFACTOR: Use the raw pitch offset without calculating it into the distance of the aimed actor. --- src/p_enemy.cpp | 77 +++++++++++++++++++++--------- src/p_enemy.h | 4 +- wadsrc/static/actors/actor.txt | 6 +-- wadsrc/static/actors/constants.txt | 9 ++++ 4 files changed, 69 insertions(+), 27 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index ef6136fdc0..17af5c26d5 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2721,7 +2721,14 @@ void A_Chase(AActor *self) // A_FaceTracer // //============================================================================= -void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch) +enum FAF_Flags +{ + FAF_BOTTOM = 1, + FAF_MIDDLE = 2, + FAF_TOP = 4, + FAF_NODISTFACTOR = 8, +}; +void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags) { if (!other) return; @@ -2744,28 +2751,28 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch) { if (self->angle - other_angle < ANGLE_180) { - self->angle -= max_turn; + self->angle -= max_turn + ang_offset; } else { - self->angle += max_turn; + self->angle += max_turn + ang_offset; } } else { if (other_angle - self->angle < ANGLE_180) { - self->angle += max_turn; + self->angle += max_turn + ang_offset; } else { - self->angle -= max_turn; + self->angle -= max_turn + ang_offset; } } } else { - self->angle = other_angle; + self->angle = other_angle + ang_offset; } // [DH] Now set pitch. In order to maintain compatibility, this can be @@ -2776,20 +2783,33 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch) // result is only used in a ratio. double dist_x = other->x - self->x; double dist_y = other->y - self->y; + // Positioning ala missile spawning, 32 units above foot level fixed_t source_z = self->z + 32*FRACUNIT + self->GetBobOffset(); fixed_t target_z = other->z + 32*FRACUNIT + other->GetBobOffset(); + // If the target z is above the target's head, reposition to the middle of - // its body. + // its body. if (target_z >= other->z + other->height) { - target_z = other->z + other->height / 2; + target_z = other->z + (other->height / 2); } + + //Note there is no +32*FRACUNIT on purpose. This is for customization sake. + //If one doesn't want this behavior, just don't use FAF_BOTTOM. + if (flags & FAF_BOTTOM) + target_z = other->z + other->GetBobOffset(); + if (flags & FAF_MIDDLE) + target_z = other->z + (other->height / 2) + other->GetBobOffset(); + if (flags & FAF_TOP) + target_z = other->z + (other->height) + other->GetBobOffset(); + if (!flags & FAF_NODISTFACTOR) + target_z += pitch_offset; + double dist_z = target_z - source_z; double dist = sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z); - int other_pitch = (int)rad2bam(asin(dist_z / dist)); - + if (max_pitch != 0) { if (self->pitch > other_pitch) @@ -2807,7 +2827,11 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch) { self->pitch = other_pitch; } + if (flags & FAF_NODISTFACTOR) + self->pitch += pitch_offset; } + + // This will never work well if the turn angle is limited. if (max_turn == 0 && (self->angle == other_angle) && other->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE) ) @@ -2816,46 +2840,55 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch) } } -void A_FaceTarget (AActor *self, angle_t max_turn, angle_t max_pitch) +void A_FaceTarget(AActor *self, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags) { - A_Face(self, self->target, max_turn, max_pitch); + A_Face(self, self->target, max_turn, max_pitch, ang_offset, pitch_offset, flags); } -void A_FaceMaster (AActor *self, angle_t max_turn, angle_t max_pitch) +void A_FaceMaster(AActor *self, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags) { - A_Face(self, self->master, max_turn, max_pitch); + A_Face(self, self->master, max_turn, max_pitch, ang_offset, pitch_offset, flags); } -void A_FaceTracer (AActor *self, angle_t max_turn, angle_t max_pitch) +void A_FaceTracer(AActor *self, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags) { - A_Face(self, self->tracer, max_turn, max_pitch); + A_Face(self, self->tracer, max_turn, max_pitch, ang_offset, pitch_offset, flags); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(5); ACTION_PARAM_ANGLE(max_turn, 0); ACTION_PARAM_ANGLE(max_pitch, 1); + ACTION_PARAM_ANGLE(ang_offset, 2); + ACTION_PARAM_ANGLE(pitch_offset, 3); + ACTION_PARAM_INT(flags, 4); - A_FaceTarget(self, max_turn, max_pitch); + A_FaceTarget(self, max_turn, max_pitch, ang_offset, pitch_offset, flags); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMaster) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(5); ACTION_PARAM_ANGLE(max_turn, 0); ACTION_PARAM_ANGLE(max_pitch, 1); + ACTION_PARAM_ANGLE(ang_offset, 2); + ACTION_PARAM_ANGLE(pitch_offset, 3); + ACTION_PARAM_INT(flags, 4); - A_FaceMaster(self, max_turn, max_pitch); + A_FaceMaster(self, max_turn, max_pitch, ang_offset, pitch_offset, flags); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTracer) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(5); ACTION_PARAM_ANGLE(max_turn, 0); ACTION_PARAM_ANGLE(max_pitch, 1); + ACTION_PARAM_ANGLE(ang_offset, 2); + ACTION_PARAM_ANGLE(pitch_offset, 3); + ACTION_PARAM_INT(flags, 4); - A_FaceTracer(self, max_turn, max_pitch); + A_FaceTracer(self, max_turn, max_pitch, ang_offset, pitch_offset, flags); } //=========================================================================== diff --git a/src/p_enemy.h b/src/p_enemy.h index f5cc387dd9..799b4c0ff7 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -72,8 +72,8 @@ DECLARE_ACTION(A_FreezeDeathChunks) DECLARE_ACTION(A_BossDeath) void A_Chase(AActor *self); -void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270); -void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270); +void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0); +void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0); bool A_RaiseMobj (AActor *, fixed_t speed); bool A_SinkMobj (AActor *, fixed_t speed); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index f0e68d9a59..c03c86596f 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -82,9 +82,9 @@ ACTOR Actor native //: Thinker action native A_XScream(); action native A_Look(); action native A_Chase(state melee = "*", state missile = "none", int flags = 0); - action native A_FaceTarget(float max_turn = 0, float max_pitch = 270); - action native A_FaceTracer(float max_turn = 0, float max_pitch = 270); - action native A_FaceMaster(float max_turn = 0, float max_pitch = 270); + action native A_FaceTarget(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0); + action native A_FaceTracer(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0); + action native A_FaceMaster(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0); action native A_PosAttack(); action native A_Scream(); action native A_SPosAttack(); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 074953afe4..b4bb4c5325 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -447,6 +447,15 @@ enum FTF_CLAMP = 1 << 1, }; +// Flags for A_Face* +enum +{ + FAF_BOTTOM = 1, + FAF_MIDDLE = 2, + FAF_TOP = 4, + FAF_NODISTFACTOR = 8, +}; + // This is only here to provide one global variable for testing. native int testglobalvar; From cce5066beaf4646b9d0d3a3ca6a2a6487fc60542 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 31 Jan 2015 13:14:30 +0200 Subject: [PATCH 04/12] Improved check for skins and maps in the same WAD The corresponding warning is shown for Doom I mods too. Good example of it is Hyena TC: http://www.doomworld.com/idgames/index.php?file=levels/doom/Ports/megawads/hyena.zip Reduced chance of false positive for the mentioned warning --- src/resourcefiles/file_wad.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index 384290782f..55a6f5f064 100644 --- a/src/resourcefiles/file_wad.cpp +++ b/src/resourcefiles/file_wad.cpp @@ -581,9 +581,18 @@ void FWadFile::SkinHack () namespc++; } } - if (lump->Name[0] == 'M' && - lump->Name[1] == 'A' && - lump->Name[2] == 'P') + if ((lump->Name[0] == 'M' && + lump->Name[1] == 'A' && + lump->Name[2] == 'P' && + lump->Name[3] >= '0' && lump->Name[3] <= '9' && + lump->Name[4] >= '0' && lump->Name[4] <= '9' && + lump->Name[5] >= '\0') + || + (lump->Name[0] == 'E' && + lump->Name[1] >= '0' && lump->Name[1] <= '9' && + lump->Name[2] == 'M' && + lump->Name[3] >= '0' && lump->Name[3] <= '9' && + lump->Name[4] >= '\0')) { hasmap = true; } From dc6b45804d22ea84d2f7a506c4bc2ac79d87a9be Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 31 Jan 2015 20:10:18 -0600 Subject: [PATCH 05/12] Don't lose the cursor when scrolling up in option menus - Fixed: If the menu cursor was on the topmost-displayed item, pressing up would not scroll the view up. The check for scrolling only tested if the newly selected item was the topmost one, since the menu code had assumed the only time the cursor would be on the topmost visible line was when it was the very first line of the menu. Using PgDn breaks this assumption. --- src/menu/optionmenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/menu/optionmenu.cpp b/src/menu/optionmenu.cpp index eff53fc496..9a77152659 100644 --- a/src/menu/optionmenu.cpp +++ b/src/menu/optionmenu.cpp @@ -196,9 +196,9 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller) --mDesc->mSelectedItem; if (mDesc->mScrollPos > 0 && - mDesc->mSelectedItem == mDesc->mScrollTop + mDesc->mScrollPos) + mDesc->mSelectedItem <= mDesc->mScrollTop + mDesc->mScrollPos) { - mDesc->mScrollPos--; + mDesc->mScrollPos = MAX(mDesc->mSelectedItem - mDesc->mScrollTop - 1, 0); } if (mDesc->mSelectedItem < 0) From 8e1b1aa20150d4fb3340ceedc8bf9a615cef249d Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 2 Feb 2015 19:36:08 -0500 Subject: [PATCH 06/12] - Defer SDL subsystem initialization since it seems to cause conflicts with GUI toolkits on some systems. --- src/posix/sdl/hardware.cpp | 10 ++++++++++ src/posix/sdl/i_joystick.cpp | 11 ++++++++--- src/posix/sdl/i_main.cpp | 3 +-- src/posix/sdl/i_timer.cpp | 5 ++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 25e19ff21a..75d6632664 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -66,10 +66,20 @@ void I_ShutdownGraphics () } if (Video) delete Video, Video = NULL; + + SDL_QuitSubSystem (SDL_INIT_VIDEO); } void I_InitGraphics () { + if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) + { + I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError()); + return; + } + + Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); + UCVarValue val; val.Bool = !!Args->CheckParm ("-devparm"); diff --git a/src/posix/sdl/i_joystick.cpp b/src/posix/sdl/i_joystick.cpp index 9b1d326aef..d99caeca9d 100644 --- a/src/posix/sdl/i_joystick.cpp +++ b/src/posix/sdl/i_joystick.cpp @@ -1,4 +1,4 @@ -#include +#include #include "doomdef.h" #include "templates.h" @@ -266,11 +266,16 @@ static SDLInputJoystickManager *JoystickManager; void I_StartupJoysticks() { - JoystickManager = new SDLInputJoystickManager(); + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) + JoystickManager = new SDLInputJoystickManager(); } void I_ShutdownJoysticks() { - delete JoystickManager; + if(JoystickManager) + { + delete JoystickManager; + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + } } void I_GetJoysticks(TArray &sticks) diff --git a/src/posix/sdl/i_main.cpp b/src/posix/sdl/i_main.cpp index ff700eff42..d60494d1a5 100644 --- a/src/posix/sdl/i_main.cpp +++ b/src/posix/sdl/i_main.cpp @@ -265,14 +265,13 @@ int main (int argc, char **argv) setlocale (LC_ALL, "C"); - if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1) + if (SDL_Init (0) < 0) { fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError()); return -1; } atterm (SDL_Quit); - printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); printf("\n"); try diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp index e3f9906b62..6255c8a96c 100644 --- a/src/posix/sdl/i_timer.cpp +++ b/src/posix/sdl/i_timer.cpp @@ -195,6 +195,9 @@ fixed_t I_GetTimeFrac (uint32 *ms) void I_InitTimer () { + if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0) + I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError()); + I_GetTime = I_GetTimeSelect; I_WaitForTic = I_WaitForTicSelect; I_FreezeTime = I_FreezeTimeSelect; @@ -202,5 +205,5 @@ void I_InitTimer () void I_ShutdownTimer () { - + SDL_QuitSubSystem(SDL_INIT_TIMER); } From de4097cc7bb7c84b7a1d241a9dab67eaa224fd94 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 14:52:52 +1300 Subject: [PATCH 07/12] Added INVENTORY.TRANSFER - INVENTORY.TRANSFER allows transferring all owned inventory to a new owner on pickup. --- src/g_shared/a_pickups.h | 2 +- src/p_mobj.cpp | 26 ++++++++++++++++++++++++++ src/thingdef/thingdef_data.cpp | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 8616393e71..df0c94b460 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -136,7 +136,7 @@ enum IF_NOSCREENFLASH = 1<<21, // No pickup flash on the player's screen IF_TOSSED = 1<<22, // Was spawned by P_DropItem (i.e. as a monster drop) IF_ALWAYSRESPAWN = 1<<23, // Always respawn, regardless of dmflag - + IF_TRANSFER = 1<<24, // All inventory items that the inventory item contains is also transfered to the pickuper }; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index ef23ca0baa..b8e45278ec 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -551,12 +551,17 @@ void AActor::AddInventory (AInventory *item) { // Is it attached to us? if (item->Owner == this) + { + Printf("Crantech: AddInventory->%s->Owner was Owner\n", item->GetClass()->TypeName.GetChars()); return; + } // No, then remove it from the other actor first item->Owner->RemoveInventory (item); + Printf("Crantech: AddInventory->%s->Owner was nonNULL\n", item->GetClass()->TypeName.GetChars()); } + TObjPtr Invstack = item->Inventory; item->Owner = this; item->Inventory = Inventory; Inventory = item; @@ -567,6 +572,26 @@ void AActor::AddInventory (AInventory *item) // run sometime in the future, so by the time it runs, the inventory // might not be in the same state as it was when DEM_INVUSE was sent. Inventory->InventoryID = InventoryID++; + + // If the flag exists, transfer all inventory accross that the old object had. + if ((item->ItemFlags & IF_TRANSFER)) + { + while (Invstack) + { + AInventory* titem = Invstack; + Invstack = titem->Inventory; + + Printf("Crantech: AddInventory->%s doing transfer of %s\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + bool success = titem->CallTryPickup(this); + if (!success) + { + Printf("Crantech: AddInventory->%s, %s is now being destroyed\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + titem->Destroy(); + } + //AddInventory(item->Inventory); // Adds current inventory item to present index + } + } + } //============================================================================ @@ -587,6 +612,7 @@ void AActor::RemoveInventory (AInventory *item) *invp = item->Inventory; item->DetachFromOwner (); item->Owner = NULL; + item->Inventory = NULL; break; } } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index fbe28fb5bf..e91c2ee657 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -324,6 +324,7 @@ static FFlagDef InventoryFlags[] = DEFINE_FLAG(IF, NOSCREENFLASH, AInventory, ItemFlags), DEFINE_FLAG(IF, TOSSED, AInventory, ItemFlags), DEFINE_FLAG(IF, ALWAYSRESPAWN, AInventory, ItemFlags), + DEFINE_FLAG(IF, TRANSFER, AInventory, ItemFlags), DEFINE_DEPRECATED_FLAG(PICKUPFLASH), DEFINE_DEPRECATED_FLAG(INTERHUBSTRIP),}; From 1e0a1466a3d873a0eeee2644eedcb32a5ebc9e42 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 20:13:54 +1300 Subject: [PATCH 08/12] Moved and rearranged transfer task - Some inventory pickup conditions weren't properly covered --- src/g_shared/a_pickups.cpp | 30 +++++++++++++++++++++++++++++- src/p_mobj.cpp | 25 ------------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 1aab998a9a..1bdc69fba1 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1372,6 +1372,8 @@ bool AInventory::TryPickupRestricted (AActor *&toucher) bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) { + TObjPtr Invstack = Inventory; // A pointer of the inventories item stack. + // unmorphed versions of a currently morphed actor cannot pick up anything. if (toucher->flags & MF_UNMORPHED) return false; @@ -1392,7 +1394,33 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) GoAwayAndDie(); } - if (res) GiveQuest(toucher); + if (res) + { + GiveQuest(toucher); + + // Transfer all inventory accross that the old object had, if requested. + if ((ItemFlags & IF_TRANSFER)) + { + while (Invstack) + { + AInventory* titem = Invstack; + Invstack = titem->Inventory; + if (titem->Owner == this) + { + Printf("Crantech: %s::CallTryPickup doing transfer of %s\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + if (!titem->CallTryPickup(toucher)) // The object no longer can exist + { + Printf("Crantech: %s::CallTryPickup, %s is now being destroyed\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + titem->Destroy(); + } + } + else + { + Printf("Crantech: %s::CallTryPickup, %s didn't belong to this object\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + } + } + } + } return res; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b8e45278ec..51c6407f91 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -551,17 +551,12 @@ void AActor::AddInventory (AInventory *item) { // Is it attached to us? if (item->Owner == this) - { - Printf("Crantech: AddInventory->%s->Owner was Owner\n", item->GetClass()->TypeName.GetChars()); return; - } // No, then remove it from the other actor first item->Owner->RemoveInventory (item); - Printf("Crantech: AddInventory->%s->Owner was nonNULL\n", item->GetClass()->TypeName.GetChars()); } - TObjPtr Invstack = item->Inventory; item->Owner = this; item->Inventory = Inventory; Inventory = item; @@ -572,26 +567,6 @@ void AActor::AddInventory (AInventory *item) // run sometime in the future, so by the time it runs, the inventory // might not be in the same state as it was when DEM_INVUSE was sent. Inventory->InventoryID = InventoryID++; - - // If the flag exists, transfer all inventory accross that the old object had. - if ((item->ItemFlags & IF_TRANSFER)) - { - while (Invstack) - { - AInventory* titem = Invstack; - Invstack = titem->Inventory; - - Printf("Crantech: AddInventory->%s doing transfer of %s\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); - bool success = titem->CallTryPickup(this); - if (!success) - { - Printf("Crantech: AddInventory->%s, %s is now being destroyed\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); - titem->Destroy(); - } - //AddInventory(item->Inventory); // Adds current inventory item to present index - } - } - } //============================================================================ From cbb066f1fb80973ed190179374d9d5cd884cfe4c Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 22:43:42 +1300 Subject: [PATCH 09/12] Keep gameticker running to let the thread sleep --- src/d_net.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 02ca8c0c4d..116c5ab82e 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -939,7 +939,7 @@ void NetUpdate (void) newtics = nowtime - gametime; gametime = nowtime; - if (newtics <= 0 || pauseext) // nothing new to update or window paused + if (newtics <= 0) // nothing new to update { GetPackets (); return; @@ -1795,6 +1795,7 @@ void TryRunTics (void) // If paused, do not eat more CPU time than we need, because it // will all be wasted anyway. + if (pauseext) r_NoInterpolate = true; bool doWait = cl_capfps || r_NoInterpolate /*|| netgame*/; // get real tics @@ -1919,7 +1920,7 @@ void TryRunTics (void) C_Ticker (); M_Ticker (); I_GetTime (true); - G_Ticker (); + if (!pauseext) G_Ticker(); gametic++; NetUpdate (); // check for new console commands From 5164b78c31a7fac96867456c5ff1581f75e8b720 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 22:44:51 +1300 Subject: [PATCH 10/12] Camera paths would hold indeterminate of the level --- src/g_shared/a_movingcamera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index e3db71ff33..83d0d46954 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -301,14 +301,14 @@ void APathFollower::Tick () bJustStepped = false; if (CurrNode->args[2]) { - HoldTime = gametic + CurrNode->args[2] * TICRATE / 8; + HoldTime = level.time + CurrNode->args[2] * TICRATE / 8; x = CurrNode->x; y = CurrNode->y; z = CurrNode->z; } } - if (HoldTime > gametic) + if (HoldTime > level.time) return; // Splines must have a previous node. From 291861bf524d43c18f12a34462ed8c36a4486565 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 23:53:34 +1300 Subject: [PATCH 11/12] Removed debug output --- src/g_shared/a_pickups.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 1bdc69fba1..2888ea2b69 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1407,17 +1407,11 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) Invstack = titem->Inventory; if (titem->Owner == this) { - Printf("Crantech: %s::CallTryPickup doing transfer of %s\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); if (!titem->CallTryPickup(toucher)) // The object no longer can exist { - Printf("Crantech: %s::CallTryPickup, %s is now being destroyed\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); titem->Destroy(); } } - else - { - Printf("Crantech: %s::CallTryPickup, %s didn't belong to this object\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); - } } } } From ec5817869592660af6837b9f4e20ed140972a2b2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Feb 2015 15:27:31 +0100 Subject: [PATCH 12/12] - replace all \0 characters in Dehacked patches with spaces. This is needed to make some old and broken patches in some WolfenDoom mods load. --- src/c_dispatch.cpp | 2 +- src/d_dehacked.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 7a6748fdc7..06bcf6b583 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -694,7 +694,7 @@ void C_DoCommand (const char *cmd, int keynum) } else { - Printf ("Unknown command \"%.*s\"\n", len, beg); + Printf ("Unknown command \"%.*s\"\n", (int)len, beg); } } } diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 41ad714720..8debb69a4b 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2455,6 +2455,12 @@ static bool DoDehPatch() Printf (PRINT_BOLD, "\"%s\" is an old and unsupported DeHackEd patch\n", PatchFile); return false; } + // fix for broken WolfenDoom patches which contain \0 characters in some places. + for (int i = 0; i < PatchSize; i++) + { + if (PatchFile[i] == 0) PatchFile[i] = ' '; + } + PatchPt = strchr (PatchFile, '\n'); while ((cont = GetLine()) == 1) {