From 3d7934f1a10957a21b0d3d859c0280446e17fe0a Mon Sep 17 00:00:00 2001 From: ChillyDoom Date: Mon, 9 Feb 2015 20:16:57 +0000 Subject: [PATCH 1/8] - Fixed: Part of Net_CheckLastReceived treated Net_Arbitrator as a node number rather than a player number. --- src/d_net.cpp | 16 ++++++++-------- src/d_net.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4483f3cf9..9ab4b6179 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -107,7 +107,7 @@ int resendcount[MAXNETNODES]; unsigned int lastrecvtime[MAXPLAYERS]; // [RH] Used for pings unsigned int currrecvtime[MAXPLAYERS]; -unsigned int lastglobalrecvtime; // Identify the last time a packet was recieved. +unsigned int lastglobalrecvtime; // Identify the last time a packet was received. bool hadlate; int netdelay[MAXNETNODES][BACKUPTICS]; // Used for storing network delay times. int lastaverage; @@ -1861,7 +1861,7 @@ void TryRunTics (void) if (counts == 0 && !doWait) { // Check possible stall conditions - Net_CheckLastRecieved(counts); + Net_CheckLastReceived(counts); if (realtics >= 1) { C_Ticker(); @@ -1897,7 +1897,7 @@ void TryRunTics (void) I_Error ("TryRunTics: lowtic < gametic"); // Check possible stall conditions - Net_CheckLastRecieved (counts); + Net_CheckLastReceived (counts); // don't stay in here forever -- give the menu a chance to work if (I_GetTime (false) - entertic >= 1) @@ -1945,9 +1945,9 @@ void TryRunTics (void) } } -void Net_CheckLastRecieved (int counts) +void Net_CheckLastReceived (int counts) { - // [Ed850] Check to see the last time a packet was recieved. + // [Ed850] Check to see the last time a packet was received. // If it's longer then 3 seconds, a node has likely stalled. if (I_GetTime(false) - lastglobalrecvtime >= TICRATE * 3) { @@ -1974,11 +1974,11 @@ void Net_CheckLastRecieved (int counts) } else { //Send a resend request to the Arbitrator, as it's obvious we are stuck here. - if (debugfile && !players[playerfornode[Net_Arbitrator]].waiting) + if (debugfile && !players[Net_Arbitrator].waiting) fprintf(debugfile, "Arbitrator is slow (%i to %i)\n", - nettics[Net_Arbitrator], gametic + counts); + nettics[nodeforplayer[Net_Arbitrator]], gametic + counts); //Send resend request to the Arbitrator. Also mark the Arbitrator as waiting to display it in the hud. - remoteresend[Net_Arbitrator] = players[playerfornode[Net_Arbitrator]].waiting = hadlate = true; + remoteresend[nodeforplayer[Net_Arbitrator]] = players[Net_Arbitrator].waiting = hadlate = true; } } } diff --git a/src/d_net.h b/src/d_net.h index 07921a301..f9c4f6106 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -115,7 +115,7 @@ void D_QuitNetGame (void); void TryRunTics (void); //Use for checking to see if the netgame has stalled -void Net_CheckLastRecieved(int); +void Net_CheckLastReceived(int); // [RH] Functions for making and using special "ticcmds" void Net_NewMakeTic (); From 7db035abba4909703a89fa3082d7cd16e94ad0fe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Feb 2015 16:27:28 +0100 Subject: [PATCH 2/8] - undid NOGRAVITY for all floatbobbing items. I have no idea why this was ever deemed proper - but it clearly breaks some Hexen maps and it not even remotely mimics the original behavior. Even now, it's not the same but since the items fall down they at least end up where they are supposed to be. --- wadsrc/static/actors/heretic/hereticammo.txt | 1 - wadsrc/static/actors/heretic/hereticarmor.txt | 2 -- wadsrc/static/actors/heretic/hereticartifacts.txt | 4 ---- wadsrc/static/actors/hexen/blastradius.txt | 1 - wadsrc/static/actors/hexen/boostarmor.txt | 1 - wadsrc/static/actors/hexen/clericholy.txt | 1 - wadsrc/static/actors/hexen/fighterquietus.txt | 1 - wadsrc/static/actors/hexen/flechette.txt | 1 - wadsrc/static/actors/hexen/healingradius.txt | 1 - wadsrc/static/actors/hexen/magestaff.txt | 1 - wadsrc/static/actors/hexen/mana.txt | 3 --- wadsrc/static/actors/hexen/speedboots.txt | 1 - wadsrc/static/actors/hexen/summon.txt | 1 - wadsrc/static/actors/hexen/teleportother.txt | 1 - wadsrc/static/actors/raven/artiegg.txt | 2 -- wadsrc/static/actors/raven/artitele.txt | 1 - wadsrc/static/actors/raven/ravenartifacts.txt | 6 ------ wadsrc/static/actors/raven/ravenhealth.txt | 1 - 18 files changed, 30 deletions(-) diff --git a/wadsrc/static/actors/heretic/hereticammo.txt b/wadsrc/static/actors/heretic/hereticammo.txt index 8f02cce0a..96a20352b 100644 --- a/wadsrc/static/actors/heretic/hereticammo.txt +++ b/wadsrc/static/actors/heretic/hereticammo.txt @@ -221,7 +221,6 @@ ACTOR BagOfHolding : BackpackItem 8 Inventory.PickupMessage "$TXT_ITEMBAGOFHOLDING" +COUNTITEM +FLOATBOB - +NOGRAVITY States { Spawn: diff --git a/wadsrc/static/actors/heretic/hereticarmor.txt b/wadsrc/static/actors/heretic/hereticarmor.txt index 40ca671da..e027f4f47 100644 --- a/wadsrc/static/actors/heretic/hereticarmor.txt +++ b/wadsrc/static/actors/heretic/hereticarmor.txt @@ -6,7 +6,6 @@ Actor SilverShield : BasicArmorPickup 85 Game Heretic SpawnID 68 +FLOATBOB - +NOGRAVITY Inventory.Pickupmessage "$TXT_ITEMSHIELD1" Inventory.Icon "SHLDA0" Armor.Savepercent 50 @@ -26,7 +25,6 @@ Actor EnchantedShield : BasicArmorPickup 31 Game Heretic SpawnID 69 +FLOATBOB - +NOGRAVITY Inventory.Pickupmessage "$TXT_ITEMSHIELD2" Inventory.Icon "SHD2A0" Armor.Savepercent 75 diff --git a/wadsrc/static/actors/heretic/hereticartifacts.txt b/wadsrc/static/actors/heretic/hereticartifacts.txt index 404e5ba39..67d3946b9 100644 --- a/wadsrc/static/actors/heretic/hereticartifacts.txt +++ b/wadsrc/static/actors/heretic/hereticartifacts.txt @@ -7,7 +7,6 @@ ACTOR SuperMap : MapRevealer 35 +COUNTITEM +INVENTORY.ALWAYSPICKUP +FLOATBOB - +NOGRAVITY Inventory.MaxAmount 0 Inventory.PickupMessage "$TXT_ITEMSUPERMAP" States @@ -27,7 +26,6 @@ ACTOR ArtiInvisibility : PowerupGiver 75 SpawnID 135 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH RenderStyle Translucent Alpha 0.4 @@ -53,7 +51,6 @@ ACTOR ArtiTomeOfPower : PowerupGiver 86 native SpawnID 134 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.Icon "ARTIPWBK" Powerup.Type Weaponlevel2 @@ -97,7 +94,6 @@ ACTOR ArtiTimeBomb : Inventory 34 native SpawnID 72 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/blastradius.txt b/wadsrc/static/actors/hexen/blastradius.txt index 28af3e698..ad98d7ecc 100644 --- a/wadsrc/static/actors/hexen/blastradius.txt +++ b/wadsrc/static/actors/hexen/blastradius.txt @@ -4,7 +4,6 @@ ACTOR ArtiBlastRadius : CustomInventory 10110 Game Hexen SpawnID 74 +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" +INVBAR +FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/boostarmor.txt b/wadsrc/static/actors/hexen/boostarmor.txt index 8aa6b6eeb..607c8d66a 100644 --- a/wadsrc/static/actors/hexen/boostarmor.txt +++ b/wadsrc/static/actors/hexen/boostarmor.txt @@ -7,7 +7,6 @@ ACTOR ArtiBoostArmor : Inventory 8041 native SpawnID 22 +COUNTITEM +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" +INVBAR +FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/clericholy.txt b/wadsrc/static/actors/hexen/clericholy.txt index cebc44610..e97be8b17 100644 --- a/wadsrc/static/actors/hexen/clericholy.txt +++ b/wadsrc/static/actors/hexen/clericholy.txt @@ -8,7 +8,6 @@ ACTOR ClericWeaponPiece : WeaponPiece Inventory.ForbiddenTo FighterPlayer, MagePlayer WeaponPiece.Weapon CWeapWraithverge +FLOATBOB - +NOGRAVITY } // Cleric Weapon Piece 1 ---------------------------------------------------- diff --git a/wadsrc/static/actors/hexen/fighterquietus.txt b/wadsrc/static/actors/hexen/fighterquietus.txt index b5ecd22e4..a77e851d8 100644 --- a/wadsrc/static/actors/hexen/fighterquietus.txt +++ b/wadsrc/static/actors/hexen/fighterquietus.txt @@ -8,7 +8,6 @@ ACTOR FighterWeaponPiece : WeaponPiece Inventory.ForbiddenTo ClericPlayer, MagePlayer WeaponPiece.Weapon FWeapQuietus +FLOATBOB - +NOGRAVITY } // Fighter Weapon Piece 1 --------------------------------------------------- diff --git a/wadsrc/static/actors/hexen/flechette.txt b/wadsrc/static/actors/hexen/flechette.txt index 74c7a0a6a..6e12bff53 100644 --- a/wadsrc/static/actors/hexen/flechette.txt +++ b/wadsrc/static/actors/hexen/flechette.txt @@ -99,7 +99,6 @@ ACTOR ArtiPoisonBag : Inventory 8000 native Game Hexen SpawnID 72 +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" +INVBAR +FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/healingradius.txt b/wadsrc/static/actors/hexen/healingradius.txt index 97efc0449..e0556915b 100644 --- a/wadsrc/static/actors/hexen/healingradius.txt +++ b/wadsrc/static/actors/hexen/healingradius.txt @@ -6,7 +6,6 @@ ACTOR ArtiHealingRadius : Inventory 10120 native Game Hexen +COUNTITEM +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH diff --git a/wadsrc/static/actors/hexen/magestaff.txt b/wadsrc/static/actors/hexen/magestaff.txt index a8584aae7..aa75ed446 100644 --- a/wadsrc/static/actors/hexen/magestaff.txt +++ b/wadsrc/static/actors/hexen/magestaff.txt @@ -8,7 +8,6 @@ ACTOR MageWeaponPiece : WeaponPiece Inventory.ForbiddenTo FighterPlayer, ClericPlayer WeaponPiece.Weapon MWeapBloodscourge +FLOATBOB - +NOGRAVITY } // Mage Weapon Piece 1 ------------------------------------------------------ diff --git a/wadsrc/static/actors/hexen/mana.txt b/wadsrc/static/actors/hexen/mana.txt index 97bc419c8..a2e6ee4bc 100644 --- a/wadsrc/static/actors/hexen/mana.txt +++ b/wadsrc/static/actors/hexen/mana.txt @@ -11,7 +11,6 @@ ACTOR Mana1 : Ammo 122 Radius 8 Height 8 +FLOATBOB - +NOGRAVITY Inventory.Icon "MAN1I0" Inventory.PickupMessage "$TXT_MANA_1" States @@ -35,7 +34,6 @@ ACTOR Mana2 : Ammo 124 Radius 8 Height 8 +FLOATBOB - +NOGRAVITY Inventory.Icon "MAN2G0" Inventory.PickupMessage "$TXT_MANA_2" States @@ -55,7 +53,6 @@ ACTOR Mana3 : CustomInventory 8004 Radius 8 Height 8 +FLOATBOB - +NOGRAVITY Inventory.PickupMessage "$TXT_MANA_BOTH" States { diff --git a/wadsrc/static/actors/hexen/speedboots.txt b/wadsrc/static/actors/hexen/speedboots.txt index c22699b62..5fd6703b8 100644 --- a/wadsrc/static/actors/hexen/speedboots.txt +++ b/wadsrc/static/actors/hexen/speedboots.txt @@ -5,7 +5,6 @@ ACTOR ArtiSpeedBoots : PowerupGiver 8002 Game Hexen SpawnID 13 +FLOATBOB - +NOGRAVITY +COUNTITEM +INVENTORY.PICKUPFLASH Inventory.Icon ARTISPED diff --git a/wadsrc/static/actors/hexen/summon.txt b/wadsrc/static/actors/hexen/summon.txt index 28c3c3267..a4b3b8584 100644 --- a/wadsrc/static/actors/hexen/summon.txt +++ b/wadsrc/static/actors/hexen/summon.txt @@ -7,7 +7,6 @@ ACTOR ArtiDarkServant : Inventory 86 native SpawnID 16 +COUNTITEM +FLOATBOB - +NOGRAVITY Inventory.RespawnTics 4230 Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" diff --git a/wadsrc/static/actors/hexen/teleportother.txt b/wadsrc/static/actors/hexen/teleportother.txt index 49b20a0bd..77a05f6af 100644 --- a/wadsrc/static/actors/hexen/teleportother.txt +++ b/wadsrc/static/actors/hexen/teleportother.txt @@ -7,7 +7,6 @@ ACTOR ArtiTeleportOther : Inventory 10040 native SpawnID 17 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/raven/artiegg.txt b/wadsrc/static/actors/raven/artiegg.txt index 2a9c6867e..d94f00151 100644 --- a/wadsrc/static/actors/raven/artiegg.txt +++ b/wadsrc/static/actors/raven/artiegg.txt @@ -31,7 +31,6 @@ ACTOR ArtiEgg : CustomInventory 30 SpawnID 14 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND @@ -86,7 +85,6 @@ ACTOR ArtiPork : CustomInventory 30 SpawnID 14 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/raven/artitele.txt b/wadsrc/static/actors/raven/artitele.txt index b0eedf1cd..79811fd53 100644 --- a/wadsrc/static/actors/raven/artitele.txt +++ b/wadsrc/static/actors/raven/artitele.txt @@ -7,7 +7,6 @@ ACTOR ArtiTeleport : Inventory 36 native SpawnID 18 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/raven/ravenartifacts.txt b/wadsrc/static/actors/raven/ravenartifacts.txt index 4f31ad5fb..c02c19c3b 100644 --- a/wadsrc/static/actors/raven/ravenartifacts.txt +++ b/wadsrc/static/actors/raven/ravenartifacts.txt @@ -8,7 +8,6 @@ ACTOR ArtiHealth : HealthPickup 82 Health 25 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND Inventory.Icon ARTIPTN2 @@ -33,7 +32,6 @@ ACTOR ArtiSuperHealth : HealthPickup 32 Health 100 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND Inventory.Icon ARTISPHL @@ -57,7 +55,6 @@ ACTOR ArtiFly : PowerupGiver 83 SpawnID 15 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.INTERHUBSTRIP Inventory.RespawnTics 4230 @@ -81,7 +78,6 @@ ACTOR ArtiInvulnerability : PowerupGiver 84 SpawnID 133 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.RespawnTics 4230 Inventory.Icon ARTIINVU @@ -105,7 +101,6 @@ ACTOR ArtiInvulnerability2 : PowerupGiver 84 SpawnID 133 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.RespawnTics 4230 Inventory.Icon ARTIDEFN @@ -128,7 +123,6 @@ ACTOR ArtiTorch : PowerupGiver 33 SpawnID 73 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.Icon ARTITRCH Inventory.PickupMessage "$TXT_ARTITORCH" diff --git a/wadsrc/static/actors/raven/ravenhealth.txt b/wadsrc/static/actors/raven/ravenhealth.txt index 45cbe59b9..af951be1b 100644 --- a/wadsrc/static/actors/raven/ravenhealth.txt +++ b/wadsrc/static/actors/raven/ravenhealth.txt @@ -3,7 +3,6 @@ ACTOR CrystalVial : Health 81 Game Raven SpawnID 23 +FLOATBOB - +NOGRAVITY Inventory.Amount 10 Inventory.PickupMessage "$TXT_ITEMHEALTH" States From c2e155bb9f044f81942820f0e9d055ea3e983452 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Feb 2015 16:29:08 +0100 Subject: [PATCH 3/8] - with floatbobbing items no longer having no gravity, we don't need the corresponding compatibility setting anymore. --- wadsrc/static/compatibility.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index d2bb85fd2..bd90342f2 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -198,14 +198,6 @@ E2B5D1400279335811C1C1C0B437D9C8 // Deathknights of the Dark Citadel, map54 clearlineflags 1069 0x200 } -CBDE77E3ACB4B166D53C1812E5C72F54 // Hexen IWAD map04 -{ - setthingz 49 0 - setthingz 50 0 - setthingz 51 0 - setthingz 52 0 -} - 3F249EDD62A3A08F53A6C53CB4C7ABE5 // Artica 3 map01 { clearlinespecial 66 From 93c12cf2595ac473061f83486139907d7c2c7bb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Feb 2015 18:57:06 +0100 Subject: [PATCH 4/8] - addressed the problem that prompted setting NOGRAVITY for all floatbobbing items for real: Hexen uses the spawn height value from the mapthing_t structure to offset the item when floatbobbing. With proper gravity handling enabled this method doesn't really work so as a workaround ZDoom will now enable a hidden compatibility option when playing any map with a Hexen format MAPINFO so that any positive value in this field will make P_ZMovement revert to the original method of setting the items height (excluding the floatbob offset, of course.) This also removes some code from P_NightmareRespawn that originate from the original Hexen method for floatbobbing which aren't needed anymore --- src/compatibility.cpp | 6 ++++++ src/doomdef.h | 1 + src/p_mobj.cpp | 24 +++++++++++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 4ddc670e9..da4ab4945 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -109,6 +109,7 @@ static FCompatOption Options[] = { "rebuildnodes", BCOMPATF_REBUILDNODES, SLOT_BCOMPAT }, { "linkfrozenprops", BCOMPATF_LINKFROZENPROPS, SLOT_BCOMPAT }, { "disablepushwindowcheck", BCOMPATF_NOWINDOWCHECK, SLOT_BCOMPAT }, + { "floatbob", BCOMPATF_FLOATBOB, SLOT_BCOMPAT }, // list copied from g_mapinfo.cpp { "shorttex", COMPATF_SHORTTEX, SLOT_COMPAT }, @@ -434,6 +435,11 @@ void CheckCompatibility(MapData *map) // Reset i_compatflags compatflags.Callback(); compatflags2.Callback(); + // Set floatbob compatibility for all maps with an original Hexen MAPINFO. + if (level.flags2 & LEVEL2_HEXENHACK) + { + ib_compatflags |= BCOMPATF_FLOATBOB; + } } //========================================================================== diff --git a/src/doomdef.h b/src/doomdef.h index 767f97661..c8aa66c17 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -354,6 +354,7 @@ enum BCOMPATF_REBUILDNODES = 1 << 5, // Force node rebuild BCOMPATF_LINKFROZENPROPS = 1 << 6, // Clearing PROP_TOTALLYFROZEN or PROP_FROZEN also clears the other BCOMPATF_NOWINDOWCHECK = 1 << 7, // Disable the window check in CheckForPushSpecial() + BCOMPATF_FLOATBOB = 1 << 8, // Use Hexen's original method of preventing floatbobbing items from falling down }; // phares 3/20/98: diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b27c79d91..2235c7820 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2314,6 +2314,16 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) } } + // Hexen compatibility handling for floatbobbing. Ugh... + // Hexen yanked all items to the floor, except those being spawned at map start in the air. + // Those were kept at their original height. + // Do this only if the item was actually spawned by the map above ground to avoid problems. + if (mo->special1 > 0 && (mo->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) + { + mo->z = mo->floorz + mo->special1; + } + + // // adjust height // @@ -2616,8 +2626,6 @@ void P_NightmareRespawn (AActor *mobj) z = ONCEILINGZ; else if (info->flags2 & MF2_SPAWNFLOAT) z = FLOATRANDZ; - else if (info->flags2 & MF2_FLOATBOB) - z = mobj->SpawnPoint[2]; else z = ONFLOORZ; @@ -4869,7 +4877,13 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) mobj = AActor::StaticSpawn (i, x, y, z, NO_REPLACE, true); if (z == ONFLOORZ) + { mobj->z += mthing->z; + if ((mobj->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) + { + mobj->special1 = mthing->z; + } + } else if (z == ONCEILINGZ) mobj->z -= mthing->z; @@ -4882,7 +4896,11 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) else if (mthing->gravity > 0) mobj->gravity = FixedMul(mobj->gravity, mthing->gravity); else mobj->flags &= ~MF_NOGRAVITY; - P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); + // For Hexen floatbob 'compatibility' we do not really want to alter the floorz. + if (mobj->special1 == 0 || !(mobj->flags2 & MF2_FLOATBOB) || !(ib_compatflags & BCOMPATF_FLOATBOB)) + { + P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); + } if (!(mobj->flags2 & MF2_ARGSDEFINED)) { From fa2e2a852891e2f8743582414e6027153bbcc2ed Mon Sep 17 00:00:00 2001 From: Alexey Khokholov Date: Sat, 14 Feb 2015 00:01:54 +0900 Subject: [PATCH 5/8] Update nukedopl3.cpp --- src/oplsynth/nukedopl3.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/oplsynth/nukedopl3.cpp b/src/oplsynth/nukedopl3.cpp index a520f68e1..4d143f4a5 100644 --- a/src/oplsynth/nukedopl3.cpp +++ b/src/oplsynth/nukedopl3.cpp @@ -98,8 +98,7 @@ Bit16s envelope_calcsin0(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u out = 0; Bit16u neg = 0; - if (phase & 0x200 && (phase & 0x1ff)) { - phase--; + if (phase & 0x200) { neg = ~0; } if (phase & 0x100) { @@ -154,8 +153,7 @@ Bit16s envelope_calcsin4(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u out = 0; Bit16u neg = 0; - if ((phase & 0x300) == 0x100 && (phase & 0xff)) { - phase--; + if ((phase & 0x300) == 0x100) { neg = ~0; } if (phase & 0x200) { @@ -188,8 +186,7 @@ Bit16s envelope_calcsin5(Bit16u phase, Bit16u envelope) { Bit16s envelope_calcsin6(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u neg = 0; - if (phase & 0x200 && (phase & 0x1ff)) { - phase--; + if (phase & 0x200) { neg = ~0; } return envelope_calcexp(envelope << 3) ^ neg; @@ -199,8 +196,7 @@ Bit16s envelope_calcsin7(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u out = 0; Bit16u neg = 0; - if (phase & 0x200 && (phase & 0x1ff)) { - phase--; + if (phase & 0x200) { neg = ~0; phase = (phase & 0x1ff) ^ 0x1ff; } @@ -976,4 +972,4 @@ NukedOPL3::NukedOPL3(bool stereo) { OPLEmul *NukedOPL3Create(bool stereo) { return new NukedOPL3(stereo); -} \ No newline at end of file +} From 7050d03222a239cf70ead2dad6d93180e1d278f7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sat, 14 Feb 2015 15:58:39 -0600 Subject: [PATCH 6/8] Added A_QuakeEx(intensity x, y, z, duration, damrad, tremrad, sound, flags) - Unlocks the full potential of using quakes, including the Z axis. Each intensity applies to X/Y/Z planes whenever a player is experiencing it. - Flags: - QF_RELATIVE - Adjusts the quaking of the camera to go in the direction its aiming (X: forward/backward. Y: Left/right.) - Plans for including pitch will be implemented in the future for the Z axis with relativity. --- src/g_shared/a_quake.cpp | 86 +++++++++++++++++++++++++----- src/g_shared/a_sharedglobal.h | 14 +++-- src/p_spec.h | 3 +- src/r_utility.cpp | 32 +++++++++-- src/thingdef/thingdef_codeptr.cpp | 22 ++++++++ wadsrc/static/actors/actor.txt | 1 + wadsrc/static/actors/constants.txt | 5 ++ 7 files changed, 143 insertions(+), 20 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index c3a227b36..462deafb6 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -33,8 +33,8 @@ DEarthquake::DEarthquake() // //========================================================================== -DEarthquake::DEarthquake (AActor *center, int intensity, int duration, - int damrad, int tremrad, FSoundID quakesound) +DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int intensityZ, int duration, + int damrad, int tremrad, FSoundID quakesound, int flags) : DThinker(STAT_EARTHQUAKE) { m_QuakeSFX = quakesound; @@ -42,8 +42,12 @@ DEarthquake::DEarthquake (AActor *center, int intensity, int duration, // Radii are specified in tile units (64 pixels) m_DamageRadius = damrad << (FRACBITS); m_TremorRadius = tremrad << (FRACBITS); - m_Intensity = intensity; + m_Intensity = intensityX; m_Countdown = duration; + m_Flags = flags; + m_iX = intensityX; + m_iY = intensityY; + m_iZ = intensityZ; } //========================================================================== @@ -54,10 +58,10 @@ DEarthquake::DEarthquake (AActor *center, int intensity, int duration, void DEarthquake::Serialize (FArchive &arc) { - Super::Serialize (arc); + Super::Serialize (arc); //[MC] m_Intensity is unused now but I don't want to break compatibility... arc << m_Spot << m_Intensity << m_Countdown << m_TremorRadius << m_DamageRadius - << m_QuakeSFX; + << m_QuakeSFX << m_Flags << m_iX << m_iY << m_iZ; } //========================================================================== @@ -126,9 +130,10 @@ void DEarthquake::Tick () // //========================================================================== -int DEarthquake::StaticGetQuakeIntensity (AActor *victim) +int DEarthquake::StaticGetQuakeIntensity (AActor *victim, int selector) { int intensity = 0; + int quakeIntensity = 0; TThinkerIterator iterator (STAT_EARTHQUAKE); DEarthquake *quake; @@ -145,32 +150,84 @@ int DEarthquake::StaticGetQuakeIntensity (AActor *victim) victim->y - quake->m_Spot->y); if (dist < quake->m_TremorRadius) { - if (intensity < quake->m_Intensity) - intensity = quake->m_Intensity; + switch (selector) + { + default: + case 0: + quakeIntensity = quake->m_iX; + break; + case 1: + quakeIntensity = quake->m_iY; + break; + case 2: + quakeIntensity = quake->m_iZ; + break; + + } + + if (intensity < quakeIntensity) + intensity = quakeIntensity; } } } return intensity; } +//========================================================================== +// +// DEarthquake::StaticGetQuakeIntensity +// +// Searches for all quakes near the victim and returns their combined +// intensity. +// +//========================================================================== + +int DEarthquake::StaticGetQuakeFlags(AActor *victim) +{ + int flags = 0; + TThinkerIterator iterator(STAT_EARTHQUAKE); + DEarthquake *quake; + + if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) + { + return 0; + } + + while ((quake = iterator.Next()) != NULL) + { + if (quake->m_Spot != NULL) + { + fixed_t dist = P_AproxDistance(victim->x - quake->m_Spot->x, + victim->y - quake->m_Spot->y); + if (dist < quake->m_TremorRadius) + { + if (!(flags & QF_RELATIVE) && (quake->m_Flags & QF_RELATIVE)) + flags += QF_RELATIVE; + } + } + } + return flags; +} //========================================================================== // // P_StartQuake // //========================================================================== -bool P_StartQuake (AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) +bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags) { AActor *center; bool res = false; - intensity = clamp (intensity, 1, 9); + if (intensityX) intensityX = clamp(intensityX, 1, 9); + if (intensityY) intensityY = clamp(intensityY, 1, 9); + if (intensityZ) intensityZ = clamp(intensityZ, 1, 9); if (tid == 0) { if (activator != NULL) { - new DEarthquake(activator, intensity, duration, damrad, tremrad, quakesfx); + new DEarthquake(activator, intensityX, intensityY, intensityZ, duration, damrad, tremrad, quakesfx, flags); return true; } } @@ -180,9 +237,14 @@ bool P_StartQuake (AActor *activator, int tid, int intensity, int duration, int while ( (center = iterator.Next ()) ) { res = true; - new DEarthquake (center, intensity, duration, damrad, tremrad, quakesfx); + new DEarthquake(center, intensityX, intensityY, intensityZ, duration, damrad, tremrad, quakesfx, flags); } } return res; } + +bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) +{ //Maintains original behavior by passing 0 to intensityZ, and flags. + return P_StartQuakeXYZ(activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0); +} diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index a898433f0..a186fa010 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -131,23 +131,31 @@ protected: DFlashFader (); }; +enum +{ + QF_RELATIVE = 1, +}; + class DEarthquake : public DThinker { DECLARE_CLASS (DEarthquake, DThinker) HAS_OBJECT_POINTERS public: - DEarthquake (AActor *center, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); + DEarthquake(AActor *center, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags); void Serialize (FArchive &arc); void Tick (); - TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; int m_Intensity; int m_Countdown; FSoundID m_QuakeSFX; + int m_Flags; + int m_iX, m_iY, m_iZ; - static int StaticGetQuakeIntensity (AActor *viewer); + static int StaticGetQuakeFlags(AActor *viewer); + static int StaticGetQuakeIntensity (AActor *viewer, int selector); + private: DEarthquake (); diff --git a/src/p_spec.h b/src/p_spec.h index 0d7ef4cff..2edfe6390 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -929,6 +929,7 @@ void P_DoDeferedScripts (void); // // [RH] p_quake.c // -bool P_StartQuake (AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); +bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags); +bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); #endif diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 585e3dcf3..f809a6800 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -875,13 +875,37 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensity = DEarthquake::StaticGetQuakeIntensity (camera); - if (intensity != 0) + int intensityX = DEarthquake::StaticGetQuakeIntensity(camera, 0); + int intensityY = DEarthquake::StaticGetQuakeIntensity(camera, 1); + int intensityZ = DEarthquake::StaticGetQuakeIntensity(camera, 2); + int quakeflags = DEarthquake::StaticGetQuakeFlags(camera); + if (intensityX || intensityY || intensityZ) { fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); - viewx += quakefactor * ((pr_torchflicker() % (intensity<<2)) - (intensity<<1)); - viewy += quakefactor * ((pr_torchflicker() % (intensity<<2)) - (intensity<<1)); + if ((quakeflags & QF_RELATIVE) && (intensityX != intensityY)) + { + if (intensityX) + { + int ang = (camera->angle) >> ANGLETOFINESHIFT; + int tflicker = pr_torchflicker(); + viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); + viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); + } + if (intensityY) + { + int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; + int tflicker = pr_torchflicker(); + viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); + viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); + } + } + else + { + if (intensityX) viewx += quakefactor * ((pr_torchflicker() % (intensityX << 2)) - (intensityX << 1)); + if (intensityY) viewy += quakefactor * ((pr_torchflicker() % (intensityY << 2)) - (intensityY << 1)); + } + if (intensityZ) viewz += quakefactor * ((pr_torchflicker() % (intensityZ << 2)) - (intensityZ << 1)); } } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index fc157c92b..280f09fd6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4403,6 +4403,28 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Quake) P_StartQuake(self, 0, intensity, duration, damrad, tremrad, sound); } +//=========================================================================== +// +// A_QuakeEx +// +// Extended version of A_Quake. Takes individual axis into account and can +// take a flag. +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_QuakeEx) +{ + ACTION_PARAM_START(8); + ACTION_PARAM_INT(intensityX, 0); + ACTION_PARAM_INT(intensityY, 1); + ACTION_PARAM_INT(intensityZ, 2); + ACTION_PARAM_INT(duration, 3); + ACTION_PARAM_INT(damrad, 4); + ACTION_PARAM_INT(tremrad, 5); + ACTION_PARAM_SOUND(sound, 6); + ACTION_PARAM_INT(flags, 7); + P_StartQuakeXYZ(self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags); +} + //=========================================================================== // // A_Weave diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index c03c86596..e8906af3f 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -299,6 +299,7 @@ ACTOR Actor native //: Thinker action native A_SetUserArray(name varname, int index, int value); action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0); action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake"); + action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0); action native A_SetTics(int tics); action native A_SetDamageType(name damagetype); action native A_DropItem(class item, int dropamount = -1, int chance = 256); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 1604b5c83..b3fd26ecb 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -457,6 +457,11 @@ enum FAF_NODISTFACTOR = 8, }; +// Flags for A_QuakeEx +enum +{ + QF_RELATIVE = 1, +}; // This is only here to provide one global variable for testing. native int testglobalvar; From 0f4bca86073ff316d920f6f6d6f7ecd2b767d3c0 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sat, 14 Feb 2015 16:51:05 -0600 Subject: [PATCH 7/8] - Added SXF_TRANSFERROLL. --- src/thingdef/thingdef_codeptr.cpp | 6 ++++++ wadsrc/static/actors/constants.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index fc157c92b..117207302 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1875,6 +1875,7 @@ enum SIX_Flags SIXF_NOPOINTERS = 0x00400000, SIXF_ORIGINATOR = 0x00800000, SIXF_TRANSFERSPRITEFRAME = 0x01000000, + SIXF_TRANSFERROLL = 0x02000000, }; static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) @@ -2027,6 +2028,11 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) mo->frame = self->frame; } + if (flags & SIXF_TRANSFERROLL) + { + mo->roll = self->roll; + } + return true; } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 1604b5c83..aedd01284 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -73,6 +73,7 @@ const int SXF_SETTRACER = 1 << 21; const int SXF_NOPOINTERS = 1 << 22; const int SXF_ORIGINATOR = 1 << 23; const int SXF_TRANSFERSPRITEFRAME = 1 << 24; +const int SXF_TRANSFERROLL = 1 << 25; // Flags for A_Chase const int CHF_FASTCHASE = 1; From e377c2c4f867dbcbb701ba97384277ff9b3d1869 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 18 Feb 2015 14:48:52 -0600 Subject: [PATCH 8/8] Change XYZ Quaking from Major Cooke - Relative quakes are different from other quakes; all quakes affecting the camera do not become relative if one of them is relative. - Use a single function call to get quake visual parameters instead of four. - Thrust things in a psuedo-ellipse if they're inside a damaging quake whose IntensityX != IntensityY. - Don't break old savegames. --- src/g_shared/a_quake.cpp | 113 +++++++++++++++------------------- src/g_shared/a_sharedglobal.h | 7 +-- src/r_utility.cpp | 69 +++++++++++++-------- src/version.h | 2 +- 4 files changed, 96 insertions(+), 95 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 462deafb6..874ecbb51 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -42,12 +42,11 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in // Radii are specified in tile units (64 pixels) m_DamageRadius = damrad << (FRACBITS); m_TremorRadius = tremrad << (FRACBITS); - m_Intensity = intensityX; + m_IntensityX = intensityX; + m_IntensityY = intensityY; + m_IntensityZ = intensityZ; m_Countdown = duration; m_Flags = flags; - m_iX = intensityX; - m_iY = intensityY; - m_iZ = intensityZ; } //========================================================================== @@ -58,10 +57,20 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in void DEarthquake::Serialize (FArchive &arc) { - Super::Serialize (arc); //[MC] m_Intensity is unused now but I don't want to break compatibility... - arc << m_Spot << m_Intensity << m_Countdown + Super::Serialize (arc); + arc << m_Spot << m_IntensityX << m_Countdown << m_TremorRadius << m_DamageRadius - << m_QuakeSFX << m_Flags << m_iX << m_iY << m_iZ; + << m_QuakeSFX; + if (SaveVersion < 4519) + { + m_IntensityY = m_IntensityX; + m_IntensityZ = 0; + m_Flags = 0; + } + else + { + arc << m_IntensityY << m_IntensityZ << m_Flags; + } } //========================================================================== @@ -106,7 +115,18 @@ void DEarthquake::Tick () } // Thrust player around angle_t an = victim->angle + ANGLE_1*pr_quake(); - P_ThrustMobj (victim, an, m_Intensity << (FRACBITS-1)); + if (m_IntensityX == m_IntensityY) + { // Thrust in a circle + P_ThrustMobj (victim, an, m_IntensityX << (FRACBITS-1)); + } + else + { // Thrust in an ellipse + an >>= ANGLETOFINESHIFT; + // So this is actually completely wrong, but it ought to be good + // enough. Otherwise, I'd have to use tangents and square roots. + victim->velx += FixedMul(m_IntensityX << (FRACBITS-1), finecosine[an]); + victim->vely += FixedMul(m_IntensityY << (FRACBITS-1), finesine[an]); + } } } } @@ -130,18 +150,20 @@ void DEarthquake::Tick () // //========================================================================== -int DEarthquake::StaticGetQuakeIntensity (AActor *victim, int selector) +int DEarthquake::StaticGetQuakeIntensities(AActor *victim, + int &x, int &y, int &z, int &relx, int &rely, int &relz) { - int intensity = 0; - int quakeIntensity = 0; - TThinkerIterator iterator (STAT_EARTHQUAKE); - DEarthquake *quake; - if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { return 0; } + x = y = z = relx = rely = 0; + + TThinkerIterator iterator(STAT_EARTHQUAKE); + DEarthquake *quake; + int count = 0; + while ( (quake = iterator.Next()) != NULL) { if (quake->m_Spot != NULL) @@ -150,64 +172,25 @@ int DEarthquake::StaticGetQuakeIntensity (AActor *victim, int selector) victim->y - quake->m_Spot->y); if (dist < quake->m_TremorRadius) { - switch (selector) + ++count; + if (quake->m_Flags & QF_RELATIVE) { - default: - case 0: - quakeIntensity = quake->m_iX; - break; - case 1: - quakeIntensity = quake->m_iY; - break; - case 2: - quakeIntensity = quake->m_iZ; - break; - + relx = MAX(relx, quake->m_IntensityX); + rely = MAX(rely, quake->m_IntensityY); + relz = MAX(relz, quake->m_IntensityZ); + } + else + { + x = MAX(x, quake->m_IntensityX); + y = MAX(y, quake->m_IntensityY); + z = MAX(z, quake->m_IntensityZ); } - - if (intensity < quakeIntensity) - intensity = quakeIntensity; } } } - return intensity; + return count; } -//========================================================================== -// -// DEarthquake::StaticGetQuakeIntensity -// -// Searches for all quakes near the victim and returns their combined -// intensity. -// -//========================================================================== - -int DEarthquake::StaticGetQuakeFlags(AActor *victim) -{ - int flags = 0; - TThinkerIterator iterator(STAT_EARTHQUAKE); - DEarthquake *quake; - - if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) - { - return 0; - } - - while ((quake = iterator.Next()) != NULL) - { - if (quake->m_Spot != NULL) - { - fixed_t dist = P_AproxDistance(victim->x - quake->m_Spot->x, - victim->y - quake->m_Spot->y); - if (dist < quake->m_TremorRadius) - { - if (!(flags & QF_RELATIVE) && (quake->m_Flags & QF_RELATIVE)) - flags += QF_RELATIVE; - } - } - } - return flags; -} //========================================================================== // // P_StartQuake diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index a186fa010..e153f7070 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -147,15 +147,12 @@ public: void Tick (); TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; - int m_Intensity; int m_Countdown; FSoundID m_QuakeSFX; int m_Flags; - int m_iX, m_iY, m_iZ; + int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeFlags(AActor *viewer); - static int StaticGetQuakeIntensity (AActor *viewer, int selector); - + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index f809a6800..a65c90d93 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -764,6 +764,23 @@ bool R_GetViewInterpolationStatus() return NoInterpolateView; } +//========================================================================== +// +// QuakePower +// +//========================================================================== + +static fixed_t QuakePower(fixed_t factor, int intensity) +{ + if (intensity == 0) + { + return 0; + } + else + { + return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + } +} //========================================================================== // @@ -875,37 +892,41 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX = DEarthquake::StaticGetQuakeIntensity(camera, 0); - int intensityY = DEarthquake::StaticGetQuakeIntensity(camera, 1); - int intensityZ = DEarthquake::StaticGetQuakeIntensity(camera, 2); - int quakeflags = DEarthquake::StaticGetQuakeFlags(camera); - if (intensityX || intensityY || intensityZ) + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + if (DEarthquake::StaticGetQuakeIntensities(camera, + intensityX, intensityY, intensityZ, + relIntensityX, relIntensityY, relIntensityZ) > 0) { fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); - if ((quakeflags & QF_RELATIVE) && (intensityX != intensityY)) + if (relIntensityX != 0) { - if (intensityX) - { - int ang = (camera->angle) >> ANGLETOFINESHIFT; - int tflicker = pr_torchflicker(); - viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); - viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); - } - if (intensityY) - { - int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - int tflicker = pr_torchflicker(); - viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); - viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); - } + int ang = (camera->angle) >> ANGLETOFINESHIFT; + fixed_t power = QuakePower(quakefactor, relIntensityX); + viewx += FixedMul(finecosine[ang], power); + viewy += FixedMul(finesine[ang], power); } - else + if (relIntensityY != 0) { - if (intensityX) viewx += quakefactor * ((pr_torchflicker() % (intensityX << 2)) - (intensityX << 1)); - if (intensityY) viewy += quakefactor * ((pr_torchflicker() % (intensityY << 2)) - (intensityY << 1)); + int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; + fixed_t power = QuakePower(quakefactor, relIntensityY); + viewx += FixedMul(finecosine[ang], power); + viewy += FixedMul(finesine[ang], power); + } + if (intensityX != 0) + { + viewx += QuakePower(quakefactor, intensityX); + } + if (intensityY != 0) + { + viewy += QuakePower(quakefactor, intensityY); + } + // FIXME: Relative Z is not relative + intensityZ = MAX(intensityZ, relIntensityZ); + if (intensityZ != 0) + { + viewz += QuakePower(quakefactor, intensityZ); } - if (intensityZ) viewz += quakefactor * ((pr_torchflicker() % (intensityZ << 2)) - (intensityZ << 1)); } } diff --git a/src/version.h b/src/version.h index 09b830438..2be4787ee 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4518 +#define SAVEVER 4519 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)