From 29380f70b37ca57cf0b3e67f810d5536ec9fdcc2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Jun 2008 16:56:53 +0000 Subject: [PATCH] - Added an option to consider intermission screens gameplay for purposes of capturing the mouse. - Changed: Telefragging should not thrust the victim if it isn't in precisely the same position as the killer. - fixed: A_SpawnItemEx must call P_TeleportMove before checking the spawned object's position. SVN r1014 (trunk) --- docs/rh-log.txt | 8 ++++++ src/gameconfigfile.h | 1 + src/namedef.h | 2 +- src/p_interaction.cpp | 3 +- src/p_local.h | 8 ++++-- src/p_map.cpp | 7 +++-- src/sdl/i_input.cpp | 22 ++++++++++++++- src/thingdef/thingdef_codeptr.cpp | 47 ++++++++++++++++++------------- src/win32/i_input.cpp | 23 ++++++++++++++- 9 files changed, 92 insertions(+), 29 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 92efe60d3..a404734ba 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +June 2, 2008 (Changes by Graf Zahl) +- Added an option to consider intermission screens gameplay for purposes of + capturing the mouse. +- Changed: Telefragging should not thrust the victim if it isn't in precisely the + same position as the killer. +- fixed: A_SpawnItemEx must call P_TeleportMove before checking the spawned + object's position. + June 1, 2008 (Changes by Graf Zahl) - Fixed: Ouch state was far to easy to achieve. - Made all the basic texture classes local to their implementation. diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index cd5e30abe..a3f7d578c 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -34,6 +34,7 @@ #ifndef __GAMECONFIGFILE_H__ #define __GAMECONFIGFILE_H__ +#include "doomtype.h" #include "configfile.h" class DArgs; diff --git a/src/namedef.h b/src/namedef.h index ad235754f..da2961e75 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -367,4 +367,4 @@ xx(light) xx(lightabsolute) xx(nofakecontrast) -xx(Renderstyle) \ No newline at end of file +xx(Renderstyle) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 5c55efd65..f0da1d0e5 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -982,7 +982,8 @@ 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) - && !(inflictor->flags2 & MF2_NODMGTHRUST)) + && !(inflictor->flags2 & MF2_NODMGTHRUST) + && !(flags & DMG_THRUSTLESS)) { int kickback; diff --git a/src/p_local.h b/src/p_local.h index 9abd5270d..f53e0be66 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -441,8 +441,12 @@ bool P_GiveBody (AActor *actor, int num); void P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison); void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPainSound); -#define DMG_NO_ARMOR 1 -#define DMG_INFLICTOR_IS_PUFF 2 +enum EDmgFlags +{ + DMG_NO_ARMOR = 1, + DMG_INFLICTOR_IS_PUFF = 2, + DMG_THRUSTLESS = 4, +}; // ===== PO_MAN ===== diff --git a/src/p_map.cpp b/src/p_map.cpp index 3e0ced12e..ec1f8804b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -247,7 +247,8 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr spechit.Clear (); - bool StompAlwaysFrags = thing->player || (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag; + bool StompAlwaysFrags = thing->player || (thing->flags2 & MF2_TELESTOMP) || + (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag; FBoundingBox box(x, y, thing->radius); FBlockLinesIterator it(box); @@ -291,9 +292,9 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // monsters don't stomp things except on boss level // [RH] Some Heretic/Hexen monsters can telestomp - if (StompAlwaysFrags || (thing->flags2 & MF2_TELESTOMP)) + if (StompAlwaysFrags) { - P_DamageMobj (th, thing, thing, 1000000, NAME_Telefrag); + P_DamageMobj (th, thing, thing, 1000000, NAME_Telefrag, DMG_THRUSTLESS); continue; } return false; diff --git a/src/sdl/i_input.cpp b/src/sdl/i_input.cpp index 2adfd6f09..097a45e2c 100644 --- a/src/sdl/i_input.cpp +++ b/src/sdl/i_input.cpp @@ -280,13 +280,33 @@ static void MouseRead () } } +CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +{ + if (self < 0) self = 0; + else if (self > 2) self = 2; +} + +static bool inGame() +{ + switch (mouse_capturemode) + { + default: + case 0: + return gamestate == GS_LEVEL; + case 1: + return gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_FINALE; + case 2: + return true; + } +} + static void I_CheckNativeMouse () { bool focus = (SDL_GetAppState() & (SDL_APPINPUTFOCUS|SDL_APPACTIVE)) == (SDL_APPINPUTFOCUS|SDL_APPACTIVE); bool fs = (SDL_GetVideoSurface ()->flags & SDL_FULLSCREEN) != 0; - bool wantNative = !focus || !use_mouse || (!fs && (GUICapture || paused || demoplayback || gamestate != GS_LEVEL)); + bool wantNative = !focus || !use_mouse || (!fs && (GUICapture || paused || demoplayback || !inGame())); if (wantNative != NativeMouse) { diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index e02732205..0aef41b20 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1350,14 +1350,27 @@ void A_TakeFromTarget(AActor * self) // Common code for A_SpawnItem and A_SpawnItemEx // //=========================================================================== +enum SIX_Flags +{ + SIXF_TRANSFERTRANSLATION=1, + SIXF_ABSOLUTEPOSITION=2, + SIXF_ABSOLUTEANGLE=4, + SIXF_ABSOLUTEMOMENTUM=8, + SIXF_SETMASTER=16, + SIXF_NOCHECKPOSITION=32, + SIXF_TELEFRAG=64, + // 128 is used by Skulltag! + SIXF_TRANSFERAMBUSHFLAG=256, +}; -static void InitSpawnedItem(AActor *self, AActor *mo, INTBOOL transfer_translation, INTBOOL setmaster, INTBOOL nocheckpos) + +static void InitSpawnedItem(AActor *self, AActor *mo, int flags) { if (mo) { AActor * originator = self; - if (transfer_translation && !(mo->flags2 & MF2_DONTTRANSLATE)) + if ((flags & SIXF_TRANSFERTRANSLATION) && !(mo->flags2 & MF2_DONTTRANSLATE)) { mo->Translation = self->Translation; } @@ -1365,9 +1378,16 @@ static void InitSpawnedItem(AActor *self, AActor *mo, INTBOOL transfer_translati mo->angle=self->angle; while (originator && isMissile(originator)) originator = originator->target; + if (flags & SIXF_TELEFRAG) + { + P_TeleportMove(mo, mo->x, mo->y, mo->z, true); + // This is needed to ensure consistent behavior. + // Otherwise it will only spawn if nothing gets telefragged + flags |= SIXF_NOCHECKPOSITION; + } if (mo->flags3&MF3_ISMONSTER) { - if (!nocheckpos && !P_TestMobjLocation(mo)) + if (!(flags&SIXF_NOCHECKPOSITION) && !P_TestMobjLocation(mo)) { // The monster is blocked so don't spawn it at all! if (mo->CountsAsKill()) level.total_monsters--; @@ -1381,7 +1401,7 @@ static void InitSpawnedItem(AActor *self, AActor *mo, INTBOOL transfer_translati { // If this is a monster transfer all friendliness information mo->CopyFriendliness(originator, true); - if (setmaster) mo->master = originator; // don't let it attack you (optional)! + if (flags&SIXF_SETMASTER) mo->master = originator; // don't let it attack you (optional)! } else if (originator->player) { @@ -1459,7 +1479,8 @@ void A_SpawnItem(AActor * self) self->y + FixedMul(distance, finesine[self->angle>>ANGLETOFINESHIFT]), self->z - self->floorclip + zheight, ALLOW_REPLACE); - InitSpawnedItem(self, mo, transfer_translation, useammo, false); + int flags = (transfer_translation? SIXF_TRANSFERTRANSLATION:0) + (useammo? SIXF_SETMASTER:0); + InitSpawnedItem(self, mo, flags); } //=========================================================================== @@ -1469,19 +1490,6 @@ void A_SpawnItem(AActor * self) // Enhanced spawning function // //=========================================================================== -enum SIX_Flags -{ - SIXF_TRANSFERTRANSLATION=1, - SIXF_ABSOLUTEPOSITION=2, - SIXF_ABSOLUTEANGLE=4, - SIXF_ABSOLUTEMOMENTUM=8, - SIXF_SETMASTER=16, - SIXF_NOCHECKPOSITION=32, - SIXF_TELEFRAG=64, - // 128 is used by Skulltag! - SIXF_TRANSFERAMBUSHFLAG=256, -}; - void A_SpawnItemEx(AActor * self) { FState * CallingState; @@ -1541,14 +1549,13 @@ void A_SpawnItemEx(AActor * self) } AActor * mo = Spawn( missile, x, y, self->z + self->floorclip + zofs, ALLOW_REPLACE); - InitSpawnedItem(self, mo, (flags & SIXF_TRANSFERTRANSLATION), (flags&SIXF_SETMASTER), (flags&SIXF_NOCHECKPOSITION)); + InitSpawnedItem(self, mo, flags); if (mo) { mo->momx=xmom; mo->momy=ymom; 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); } } diff --git a/src/win32/i_input.cpp b/src/win32/i_input.cpp index cd03fb1b1..4b7736c9f 100644 --- a/src/win32/i_input.cpp +++ b/src/win32/i_input.cpp @@ -415,10 +415,31 @@ static void I_CheckGUICapture () } } +CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +{ + if (self < 0) self = 0; + else if (self > 2) self = 2; +} + +static bool inGame() +{ + switch (mouse_capturemode) + { + default: + case 0: + return gamestate == GS_LEVEL; + case 1: + return gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_FINALE; + case 2: + return true; + } +} + void I_CheckNativeMouse (bool preferNative) { bool wantNative = !HaveFocus || - ((!screen || !screen->IsFullscreen()) && (gamestate != GS_LEVEL || GUICapture || paused || preferNative || !use_mouse || demoplayback)); + ((!screen || !screen->IsFullscreen()) && + (!inGame() || GUICapture || paused || preferNative || !use_mouse || demoplayback)); //Printf ("%d %d %d\n", wantNative, preferNative, NativeMouse);