diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 7a6748fdc..06bcf6b58 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 2b710b5a0..9c7ca796a 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2509,6 +2509,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) { diff --git a/src/d_net.cpp b/src/d_net.cpp index b08c79c5f..71d99a966 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -951,7 +951,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; @@ -1810,6 +1810,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 @@ -1934,7 +1935,7 @@ void TryRunTics (void) C_Ticker (); M_Ticker (); I_GetTime (true); - G_Ticker (); + if (!pauseext) G_Ticker(); gametic++; NetUpdate (); // check for new console commands diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index e3db71ff3..83d0d4695 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. diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index cd9f41628..24898baab 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1418,6 +1418,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; @@ -1438,7 +1440,27 @@ 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) + { + if (!titem->CallTryPickup(toucher)) // The object no longer can exist + { + titem->Destroy(); + } + } + } + } + } return res; } diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 5c3f913c9..1331151ff 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -127,7 +127,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/menu/optionmenu.cpp b/src/menu/optionmenu.cpp index eff53fc49..9a7715265 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) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index d0e1c2859..920ff4330 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2742,7 +2742,14 @@ void A_Chase(VMFrameStack *stack, 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; @@ -2765,28 +2772,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 @@ -2797,20 +2804,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) @@ -2828,7 +2848,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) ) @@ -2837,19 +2861,19 @@ 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) @@ -2857,8 +2881,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget) PARAM_ACTION_PROLOGUE; PARAM_ANGLE_OPT(max_turn) { max_turn = 0; } PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; } + PARAM_ANGLE_OPT(ang_offset) { max_turn = 0; } + PARAM_ANGLE_OPT(pitch_offset) { max_turn = 0; } + PARAM_INT_OPT(flags) { max_turn = 0; } - A_FaceTarget(self, max_turn, max_pitch); + A_FaceTarget(self, max_turn, max_pitch, ang_offset, pitch_offset, flags); return 0; } @@ -2867,8 +2894,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMaster) PARAM_ACTION_PROLOGUE; PARAM_ANGLE_OPT(max_turn) { max_turn = 0; } PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; } + PARAM_ANGLE_OPT(ang_offset) { max_turn = 0; } + PARAM_ANGLE_OPT(pitch_offset) { max_turn = 0; } + PARAM_INT_OPT(flags) { max_turn = 0; } - A_FaceMaster(self, max_turn, max_pitch); + A_FaceMaster(self, max_turn, max_pitch, ang_offset, pitch_offset, flags); return 0; } @@ -2877,8 +2907,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTracer) PARAM_ACTION_PROLOGUE; PARAM_ANGLE_OPT(max_turn) { max_turn = 0; } PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; } + PARAM_ANGLE_OPT(ang_offset) { max_turn = 0; } + PARAM_ANGLE_OPT(pitch_offset) { max_turn = 0; } + PARAM_INT_OPT(flags) { max_turn = 0; } - A_FaceTracer(self, max_turn, max_pitch); + A_FaceTracer(self, max_turn, max_pitch, ang_offset, pitch_offset, flags); return 0; } diff --git a/src/p_enemy.h b/src/p_enemy.h index facf16a3b..27abdaebf 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -72,8 +72,8 @@ DECLARE_ACTION(A_FreezeDeathChunks) void A_BossDeath(AActor *self); void A_Chase(VMFrameStack *stack, 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/src/p_mobj.cpp b/src/p_mobj.cpp index b434b314b..d9323537f 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -681,6 +681,7 @@ void AActor::RemoveInventory (AInventory *item) *invp = item->Inventory; item->DetachFromOwner (); item->Owner = NULL; + item->Inventory = NULL; break; } } @@ -2063,8 +2064,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 @@ -2091,12 +2090,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 @@ -3040,11 +3048,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) @@ -3067,15 +3072,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; } diff --git a/src/po_man.cpp b/src/po_man.cpp index c6e273a0f..bb9b3ca46 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) diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 25e19ff21..75d663266 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 9b1d326ae..d99caeca9 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 ff700eff4..d60494d1a 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 e3f9906b6..6255c8a96 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); } diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index 384290782..55a6f5f06 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; } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 5de2dd413..d161fef6d 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -323,6 +323,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),}; diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index c68098d38..61ce5e27a 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -50,9 +50,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 0b792fa13..89a547617 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -446,3 +446,13 @@ enum FTF_REMOVE = 1 << 0, FTF_CLAMP = 1 << 1, }; + +// Flags for A_Face* +enum +{ + FAF_BOTTOM = 1, + FAF_MIDDLE = 2, + FAF_TOP = 4, + FAF_NODISTFACTOR = 8, +}; +