From 98e4a3035d69b3ab2b83a304f998f8689fc87ee0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Mar 2021 11:54:39 +0100 Subject: [PATCH 01/12] - updated the earcut.hpp triangulator. The old one wasn't triangulating the bathroom sector in DUKEDC2 properly, the bug got fixed upstream in the mean time. --- source/common/thirdparty/earcut.hpp | 81 ++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/source/common/thirdparty/earcut.hpp b/source/common/thirdparty/earcut.hpp index d6a2c9798..2c83e33bf 100644 --- a/source/common/thirdparty/earcut.hpp +++ b/source/common/thirdparty/earcut.hpp @@ -82,6 +82,7 @@ private: template Node* eliminateHoles(const Polygon& points, Node* outerNode); void eliminateHole(Node* hole, Node* outerNode); Node* findHoleBridge(Node* hole, Node* outerNode); + bool sectorContainsSector(const Node* m, const Node* p); void indexCurve(Node* start); Node* sortLinked(Node* list); int32_t zOrder(const double x_, const double y_); @@ -91,6 +92,8 @@ private: double area(const Node* p, const Node* q, const Node* r) const; bool equals(const Node* p1, const Node* p2); bool intersects(const Node* p1, const Node* q1, const Node* p2, const Node* q2); + bool onSegment(const Node* p, const Node* q, const Node* r); + int sign(double val); bool intersectsPolygon(const Node* a, const Node* b); bool locallyInside(const Node* a, const Node* b); bool middleInside(const Node* a, const Node* b); @@ -116,16 +119,18 @@ private: template T* construct(Args&&... args) { if (currentIndex >= blockSize) { - currentBlock = alloc.allocate(blockSize); + currentBlock = alloc_traits::allocate(alloc, blockSize); allocations.emplace_back(currentBlock); currentIndex = 0; } T* object = ¤tBlock[currentIndex++]; - alloc.construct(object, std::forward(args)...); + alloc_traits::construct(alloc, object, std::forward(args)...); return object; } void reset(std::size_t newBlockSize) { - for (auto allocation : allocations) alloc.deallocate(allocation, blockSize); + for (auto allocation : allocations) { + alloc_traits::deallocate(alloc, allocation, blockSize); + } allocations.clear(); blockSize = std::max(1, newBlockSize); currentBlock = nullptr; @@ -138,6 +143,7 @@ private: std::size_t blockSize = 1; std::vector allocations; Alloc alloc; + typedef typename std::allocator_traits alloc_traits; }; ObjectPool nodes; }; @@ -165,7 +171,7 @@ void Earcut::operator()(const Polygon& points) { indices.reserve(len + points[0].size()); Node* outerNode = linkedList(points[0], true); - if (!outerNode) return; + if (!outerNode || outerNode->prev == outerNode->next) return; if (points.size() > 1) outerNode = eliminateHoles(points, outerNode); @@ -244,8 +250,7 @@ Earcut::filterPoints(Node* start, Node* end) { do { again = false; - if (!p->steiner && (equals(p, p->next) /*|| area(p->prev, p, p->next) == 0*/)) - { + if (!p->steiner && (equals(p, p->next) || area(p->prev, p, p->next) == 0)) { removeNode(p); p = end = p->prev; @@ -304,7 +309,7 @@ void Earcut::earcutLinked(Node* ear, int pass) { // if this didn't work, try curing all small self-intersections locally else if (pass == 1) { - ear = cureLocalIntersections(ear); + ear = cureLocalIntersections(filterPoints(ear)); earcutLinked(ear, 2); // as a last resort, try splitting the remaining polygon into two @@ -401,7 +406,7 @@ Earcut::cureLocalIntersections(Node* start) { p = p->next; } while (p != start); - return p; + return filterPoints(p); } // try splitting polygon into two and triangulate them independently @@ -464,6 +469,9 @@ void Earcut::eliminateHole(Node* hole, Node* outerNode) { outerNode = findHoleBridge(hole, outerNode); if (outerNode) { Node* b = splitPolygon(outerNode, hole); + + // filter out colinear points around cuts + filterPoints(outerNode, outerNode->next); filterPoints(b, b->next); } } @@ -497,7 +505,7 @@ Earcut::findHoleBridge(Node* hole, Node* outerNode) { if (!m) return 0; - if (hx == qx) return m->prev; + if (hx == qx) return m; // hole touches outer segment; pick leftmost endpoint // look for points inside the triangle of hole Vertex, segment intersection and endpoint; // if there are no points found, we have a valid connection; @@ -507,28 +515,35 @@ Earcut::findHoleBridge(Node* hole, Node* outerNode) { double tanMin = std::numeric_limits::infinity(); double tanCur = 0; - p = m->next; + p = m; double mx = m->x; double my = m->y; - while (p != stop) { + do { if (hx >= p->x && p->x >= mx && hx != p->x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p->x, p->y)) { tanCur = std::abs(hy - p->y) / (hx - p->x); // tangential - if ((tanCur < tanMin || (tanCur == tanMin && p->x > m->x)) && locallyInside(p, hole)) { + if (locallyInside(p, hole) && + (tanCur < tanMin || (tanCur == tanMin && (p->x > m->x || sectorContainsSector(m, p))))) { m = p; tanMin = tanCur; } } p = p->next; - } + } while (p != stop); return m; } +// whether sector in vertex m contains sector in vertex p in the same coordinates +template +bool Earcut::sectorContainsSector(const Node* m, const Node* p) { + return area(m->prev, m, p->prev) < 0 && area(p->next, m, m->next) < 0; +} + // interlink polygon nodes in z-order template void Earcut::indexCurve(Node* start) { @@ -644,7 +659,8 @@ Earcut::getLeftmost(Node* start) { Node* p = start; Node* leftmost = start; do { - if (p->x < leftmost->x) leftmost = p; + if (p->x < leftmost->x || (p->x == leftmost->x && p->y < leftmost->y)) + leftmost = p; p = p->next; } while (p != start); @@ -662,8 +678,10 @@ bool Earcut::pointInTriangle(double ax, double ay, double bx, double by, doub // check if a diagonal between two polygon nodes is valid (lies in polygon interior) template bool Earcut::isValidDiagonal(Node* a, Node* b) { - return a->next->i != b->i && a->prev->i != b->i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); + return a->next->i != b->i && a->prev->i != b->i && !intersectsPolygon(a, b) && // dones't intersect other edges + ((locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible + (area(a->prev, a, b->prev) != 0.0 || area(a, b->prev, b) != 0.0)) || // does not create opposite-facing sectors + (equals(a, b) && area(a->prev, a, a->next) > 0 && area(b->prev, b, b->next) > 0)); // special zero-length case } // signed area of a triangle @@ -681,10 +699,33 @@ bool Earcut::equals(const Node* p1, const Node* p2) { // check if two segments intersect template bool Earcut::intersects(const Node* p1, const Node* q1, const Node* p2, const Node* q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return (area(p1, q1, p2) > 0) != (area(p1, q1, q2) > 0) && - (area(p2, q2, p1) > 0) != (area(p2, q2, q1) > 0); + int o1 = sign(area(p1, q1, p2)); + int o2 = sign(area(p1, q1, q2)); + int o3 = sign(area(p2, q2, p1)); + int o4 = sign(area(p2, q2, q1)); + + if (o1 != o2 && o3 != o4) return true; // general case + + if (o1 == 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if (o2 == 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if (o3 == 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if (o4 == 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; +} + +// for collinear points p, q, r, check if point q lies on segment pr +template +bool Earcut::onSegment(const Node* p, const Node* q, const Node* r) { + return q->x <= std::max(p->x, r->x) && + q->x >= std::min(p->x, r->x) && + q->y <= std::max(p->y, r->y) && + q->y >= std::min(p->y, r->y); +} + +template +int Earcut::sign(double val) { + return (0.0 < val) - (val < 0.0); } // check if a polygon diagonal intersects any polygon segments From a12f2778460ccc17a55e3eff1d8f8a2a66e7f140 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Mar 2021 12:07:15 +0100 Subject: [PATCH 02/12] - fixed uninitialized clear color variable. --- source/common/rendering/v_video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/rendering/v_video.h b/source/common/rendering/v_video.h index ae4b318d0..69ccdc3bc 100644 --- a/source/common/rendering/v_video.h +++ b/source/common/rendering/v_video.h @@ -147,7 +147,7 @@ public: IntRect mScreenViewport; IntRect mSceneViewport; IntRect mOutputLetterbox; - float mSceneClearColor[4]; + float mSceneClearColor[4]{ 0,0,0,255 }; public: DFrameBuffer (int width=1, int height=1); From 39fe9efaffc6652993fe2a4708ced8d770d2122a Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 31 Mar 2021 19:43:41 +1100 Subject: [PATCH 03/12] - PlayerAngle: Adjust how `settarget()` methods store angle for unsynchronised angle adjustments and adjust `processhelpers()` method accordingly. * Repairs angle issues raised in https://forum.zdoom.org/viewtopic.php?f=340&p=1185365. --- source/core/gameinput.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 357febc07..03c41067b 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -97,9 +97,9 @@ struct PlayerHorizon struct PlayerAngle { - binangle ang, oang; + binangle ang, oang, target; lookangle look_ang, olook_ang, rotscrnang, orotscrnang, spin; - double adjustment, target; + double adjustment; void backup() { @@ -172,12 +172,12 @@ struct PlayerAngle { if (!SyncInput() && !backup) { - target = (ang + getincanglebam(ang, buildang(value))).asbam(); - if (target == 0) target += 1; + target = buildang(value & 2047); + if (target.asbam() == 0) target = bamang(1); } else { - ang = buildang(value); + ang = buildang(value & 2047); if (backup) oang = ang; } } @@ -186,12 +186,12 @@ struct PlayerAngle { if (!SyncInput() && !backup) { - target = (ang + getincanglebam(ang, buildfang(value))).asbam(); - if (target == 0) target += 1; + target = buildfang(fmod(value, 2048)); + if (target.asbam() == 0) target = bamang(1); } else { - ang = buildfang(value); + ang = buildfang(fmod(value, 2048)); if (backup) oang = ang; } } @@ -200,8 +200,8 @@ struct PlayerAngle { if (!SyncInput() && !backup) { - target = (ang + getincanglebam(ang, value)).asbam(); - if (target == 0) target += 1; + target = value; + if (target.asbam() == 0) target = bamang(1); } else { @@ -212,14 +212,14 @@ struct PlayerAngle void processhelpers(double const scaleAdjust) { - if (target) + if (target.asbam()) { - ang += bamang(xs_CRoundToUInt(scaleAdjust * (target - ang.asbam()))); + ang += bamang(xs_CRoundToUInt(scaleAdjust * getincanglebam(ang, target).asbam())); - if (abs(ang.asbam() - target) < BAMUNIT) + if (getincanglebam(ang, target).asbam() < BAMUNIT) { - ang = bamang(target); - target = 0; + ang = target; + target = bamang(0); } } else if (adjustment) From bf2d8078a4418eed5386faf904ca075d2af587d5 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 31 Mar 2021 19:44:50 +1100 Subject: [PATCH 04/12] - PlayerHorizon: Replicate changes to `settarget()` and `processhelpers()` methods from 39fe9efaffc6652993fe2a4708ced8d770d2122a. --- source/core/binaryangle.h | 2 ++ source/core/gameinput.h | 48 +++++++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index 198abc6d7..acf5b82f2 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -398,6 +398,7 @@ class fixedhoriz friend constexpr fixedhoriz q16horiz(fixed_t v); friend constexpr fixedhoriz buildhoriz(int v); + friend constexpr fixedhoriz buildfhoriz(double v); friend fixedhoriz pitchhoriz(double v); friend fixedhoriz bamhoriz(int32_t v); @@ -496,6 +497,7 @@ public: inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); } inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); } +inline constexpr fixedhoriz buildfhoriz(double v) { return fixedhoriz(FloatToFixed(v)); } inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(PitchToHoriz(v)); } inline fixedhoriz bamhoriz(int32_t v) { return pitchhoriz(BAMToPitch(v)); } diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 03c41067b..652cac326 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -12,8 +12,8 @@ lookangle getincanglebam(binangle a, binangle na); struct PlayerHorizon { - fixedhoriz horiz, ohoriz, horizoff, ohorizoff; - double adjustment, target; + fixedhoriz horiz, ohoriz, horizoff, ohorizoff, target; + double adjustment; void backup() { @@ -44,30 +44,58 @@ struct PlayerHorizon adjustment = 0; } + void settarget(int value, bool backup = false) + { + if (!SyncInput() && !backup) + { + target = buildhoriz(value); + if (target.asq16() == 0) target = q16horiz(1); + } + else + { + horiz = buildhoriz(value); + if (backup) ohoriz = horiz; + } + } + void settarget(double value, bool backup = false) { if (!SyncInput() && !backup) { - target = value * FRACUNIT; - if (target == 0) target += 1; + target = buildfhoriz(value); + if (target.asq16() == 0) target = q16horiz(1); } else { - horiz = q16horiz(FloatToFixed(value)); + horiz = buildfhoriz(value); + if (backup) ohoriz = horiz; + } + } + + void settarget(fixedhoriz value, bool backup = false) + { + if (!SyncInput() && !backup) + { + target = value; + if (target.asq16() == 0) target = q16horiz(1); + } + else + { + horiz = value; if (backup) ohoriz = horiz; } } void processhelpers(double const scaleAdjust) { - if (target) + if (target.asq16()) { - horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz.asq16()))); + horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz).asq16())); - if (abs(horiz.asq16() - target) < FRACUNIT) + if (abs((horiz - target).asq16()) < FRACUNIT) { - horiz = q16horiz(target); - target = 0; + horiz = target; + target = q16horiz(0); } } else if (adjustment) From 16886895b0124912ab2587a9139af2bc98053679 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 31 Mar 2021 19:48:38 +1100 Subject: [PATCH 05/12] - Duke: `DoPlayer()`: Ensure `SB_CENTERVIEW` bit is cleared when setting a horiz target from CON. * Repairs horizon issues raised in https://forum.zdoom.org/viewtopic.php?f=340&p=1185365. --- source/games/duke/src/gameexec.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 55e450aaa..896b2602f 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -332,12 +332,19 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_HORIZ: - if (bSet) ps[iPlayer].horizon.settarget(lValue - 100); - else SetGameVarID((int)lVar2, ps[iPlayer].horizon.horiz.asbuild() + 100, sActor, sPlayer); + if (bSet) + { + if (ps[iPlayer].sync.actions & SB_CENTERVIEW) + { + ps[iPlayer].sync.actions &= ~SB_CENTERVIEW; + } + ps[iPlayer].horizon.settarget(lValue); + } + else SetGameVarID((int)lVar2, ps[iPlayer].horizon.horiz.asbuild(), sActor, sPlayer); break; case PLAYER_OHORIZ: - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].horizon.ohoriz.asbuild() + 100, sActor, sPlayer); + if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].horizon.ohoriz.asbuild(), sActor, sPlayer); break; case PLAYER_HORIZOFF: From 760c918e75eadae52f0817663960c5097de1a264 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 31 Mar 2021 20:07:36 +1100 Subject: [PATCH 06/12] - Duke: Remove unnecessary int casts from `gameexec.cpp`. * Incoming vars are already int and called functions only accept an int so really just no need at all. --- source/games/duke/src/gameexec.cpp | 524 ++++++++++++++--------------- 1 file changed, 262 insertions(+), 262 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 896b2602f..d041ce935 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -99,7 +99,7 @@ static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* { int lValue; - lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + lValue = GetGameVarID(lVar2, sActor, sPlayer); // most settings have been removed because they are either pointless, no longer existent or simply too dangerous to access. // Others have been made read-only. @@ -107,155 +107,155 @@ static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* { case USERDEFS_GOD: // redid this so that the script won't be able to disable user-set god mode. if (bSet) ud.god = (ud.god & ~2) | (lValue? 2:0); - else SetGameVarID((int)lVar2, !!ud.god, sActor, sPlayer); + else SetGameVarID(lVar2, !!ud.god, sActor, sPlayer); break; case USERDEFS_CASHMAN: if (bSet) ud.cashman = lValue; - else SetGameVarID((int)lVar2, ud.cashman, sActor, sPlayer); + else SetGameVarID(lVar2, ud.cashman, sActor, sPlayer); break; case USERDEFS_EOG: if (bSet) ud.eog = lValue; - else SetGameVarID((int)lVar2, ud.eog, sActor, sPlayer); + else SetGameVarID(lVar2, ud.eog, sActor, sPlayer); break; case USERDEFS_SHOWALLMAP: if (bSet) gFullMap = lValue; - else SetGameVarID((int)lVar2, gFullMap, sActor, sPlayer); + else SetGameVarID(lVar2, gFullMap, sActor, sPlayer); break; case USERDEFS_SHOWWEAPONS: // Read-only user state. - if (!bSet) SetGameVarID((int)lVar2, cl_showweapon, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, cl_showweapon, sActor, sPlayer); break; case USERDEFS_FROM_BONUS: if (bSet) ud.from_bonus = lValue; - else SetGameVarID((int)lVar2, ud.from_bonus, sActor, sPlayer); + else SetGameVarID(lVar2, ud.from_bonus, sActor, sPlayer); break; case USERDEFS_CAMERASPRITE: if (bSet) ud.cameraactor = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ud.cameraactor), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ud.cameraactor), sActor, sPlayer); break; case USERDEFS_LAST_CAMSPRITE: - if (!bSet) SetGameVarID((int)lVar2, -1, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, -1, sActor, sPlayer); break; case USERDEFS_LAST_LEVEL: if (bSet) ud.last_level = lValue; - else SetGameVarID((int)lVar2, ud.last_level, sActor, sPlayer); + else SetGameVarID(lVar2, ud.last_level, sActor, sPlayer); break; case USERDEFS_SECRETLEVEL: if (bSet) ud.secretlevel = lValue; - else SetGameVarID((int)lVar2, ud.secretlevel, sActor, sPlayer); + else SetGameVarID(lVar2, ud.secretlevel, sActor, sPlayer); break; case USERDEFS_CONST_VISIBILITY: if (bSet) ud.const_visibility = lValue; - else SetGameVarID((int)lVar2, ud.const_visibility, sActor, sPlayer); + else SetGameVarID(lVar2, ud.const_visibility, sActor, sPlayer); break; case USERDEFS_SHADOWS: if (bSet) ud.shadows = lValue; - else SetGameVarID((int)lVar2, ud.shadows, sActor, sPlayer); + else SetGameVarID(lVar2, ud.shadows, sActor, sPlayer); break; case USERDEFS_M_COOP: - if (!bSet) SetGameVarID((int)lVar2, ud.m_coop, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ud.m_coop, sActor, sPlayer); break; case USERDEFS_COOP: - if (!bSet) SetGameVarID((int)lVar2, ud.coop, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ud.coop, sActor, sPlayer); break; case USERDEFS_RESPAWN_MONSTERS: if (bSet) ud.respawn_monsters = lValue; - else SetGameVarID((int)lVar2, ud.respawn_monsters, sActor, sPlayer); + else SetGameVarID(lVar2, ud.respawn_monsters, sActor, sPlayer); break; case USERDEFS_RESPAWN_ITEMS: if (bSet) ud.respawn_items = lValue; - else SetGameVarID((int)lVar2, ud.respawn_items, sActor, sPlayer); + else SetGameVarID(lVar2, ud.respawn_items, sActor, sPlayer); break; case USERDEFS_RESPAWN_INVENTORY: if (bSet) ud.respawn_inventory = lValue; - else SetGameVarID((int)lVar2, ud.respawn_inventory, sActor, sPlayer); + else SetGameVarID(lVar2, ud.respawn_inventory, sActor, sPlayer); break; case USERDEFS_RECSTAT: - if (!bSet) SetGameVarID((int)lVar2, ud.recstat, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ud.recstat, sActor, sPlayer); break; case USERDEFS_MONSTERS_OFF: if (bSet) ud.monsters_off = lValue; - else SetGameVarID((int)lVar2, ud.monsters_off, sActor, sPlayer); + else SetGameVarID(lVar2, ud.monsters_off, sActor, sPlayer); break; case USERDEFS_BRIGHTNESS: if (bSet) ud.brightness = lValue; - else SetGameVarID((int)lVar2, ud.brightness, sActor, sPlayer); + else SetGameVarID(lVar2, ud.brightness, sActor, sPlayer); break; case USERDEFS_M_RESPAWN_ITEMS: if (bSet) ud.m_respawn_items = lValue; - else SetGameVarID((int)lVar2, ud.m_respawn_items, sActor, sPlayer); + else SetGameVarID(lVar2, ud.m_respawn_items, sActor, sPlayer); break; case USERDEFS_M_RESPAWN_MONSTERS: if (bSet) ud.m_respawn_monsters = lValue; - else SetGameVarID((int)lVar2, ud.m_respawn_monsters, sActor, sPlayer); + else SetGameVarID(lVar2, ud.m_respawn_monsters, sActor, sPlayer); break; case USERDEFS_M_RESPAWN_INVENTORY: if (bSet) ud.m_respawn_inventory = lValue; - else SetGameVarID((int)lVar2, ud.m_respawn_inventory, sActor, sPlayer); + else SetGameVarID(lVar2, ud.m_respawn_inventory, sActor, sPlayer); break; case USERDEFS_M_MONSTERS_OFF: if (bSet) ud.m_monsters_off = lValue; - else SetGameVarID((int)lVar2, ud.m_monsters_off, sActor, sPlayer); + else SetGameVarID(lVar2, ud.m_monsters_off, sActor, sPlayer); break; case USERDEFS_M_FFIRE: if (bSet) ud.m_ffire = lValue; - else SetGameVarID((int)lVar2, ud.m_ffire, sActor, sPlayer); + else SetGameVarID(lVar2, ud.m_ffire, sActor, sPlayer); break; case USERDEFS_FFIRE: if (bSet) ud.ffire = lValue; - else SetGameVarID((int)lVar2, ud.ffire, sActor, sPlayer); + else SetGameVarID(lVar2, ud.ffire, sActor, sPlayer); break; case USERDEFS_MULTIMODE: - if (!bSet) SetGameVarID((int)lVar2, ud.multimode, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ud.multimode, sActor, sPlayer); break; case USERDEFS_PLAYER_SKILL: if (bSet) ud.player_skill = lValue; - else SetGameVarID((int)lVar2, ud.player_skill, sActor, sPlayer); + else SetGameVarID(lVar2, ud.player_skill, sActor, sPlayer); break; case USERDEFS_LEVEL_NUMBER: - if (!bSet) SetGameVarID((int)lVar2, mapfromlevelnum(currentLevel->levelNumber), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, mapfromlevelnum(currentLevel->levelNumber), sActor, sPlayer); break; case USERDEFS_VOLUME_NUMBER: - if (!bSet) SetGameVarID((int)lVar2, volfromlevelnum(currentLevel->levelNumber), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, volfromlevelnum(currentLevel->levelNumber), sActor, sPlayer); break; case USERDEFS_MARKER: if (bSet) ud.marker = lValue; - else SetGameVarID((int)lVar2, ud.marker, sActor, sPlayer); + else SetGameVarID(lVar2, ud.marker, sActor, sPlayer); break; default: // This will also catch all deleted cases. // make sure that the return value is always defined. - if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, 0, sActor, sPlayer); break; } return; @@ -268,7 +268,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, int lValue; int lTemp; - lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + lValue = GetGameVarID(lVar2, sActor, sPlayer); if (lVar1 == g_iThisActorID) { @@ -277,7 +277,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, } else { - iPlayer = GetGameVarID((int)lVar1, sActor, sPlayer); + iPlayer = GetGameVarID(lVar1, sActor, sPlayer); } if (iPlayer < 0 || iPlayer >= MAXPLAYERS) @@ -286,49 +286,49 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, switch (lLabelID) { case PLAYER_ZOOM: - SetGameVarID((int)lVar2, 768, sActor, sPlayer); //return default for AM zoom. + SetGameVarID(lVar2, 768, sActor, sPlayer); //return default for AM zoom. break; case PLAYER_EXITX: if (bSet) ps[iPlayer].exitx = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].exitx, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].exitx, sActor, sPlayer); break; case PLAYER_EXITY: if (bSet) ps[iPlayer].exity = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].exity, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].exity, sActor, sPlayer); break; case PLAYER_LOOGIEX: if (bSet) ps[iPlayer].loogiex[lParm2] = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].loogiex[lParm2], sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].loogiex[lParm2], sActor, sPlayer); break; case PLAYER_LOOGIEY: if (bSet) ps[iPlayer].loogiey[lParm2] = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].loogiey[lParm2], sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].loogiey[lParm2], sActor, sPlayer); break; case PLAYER_NUMLOOGS: if (bSet) ps[iPlayer].numloogs = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].numloogs, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].numloogs, sActor, sPlayer); break; case PLAYER_LOOGCNT: if (bSet) ps[iPlayer].loogcnt = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].loogcnt, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].loogcnt, sActor, sPlayer); break; case PLAYER_POSX: // oh, my... :( Writing to these has been disabled until I know how to do it without the engine shitting all over itself. - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].posx, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].posx, sActor, sPlayer); break; case PLAYER_POSY: - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].posy, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].posy, sActor, sPlayer); break; case PLAYER_POSZ: - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].posz, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].posz, sActor, sPlayer); break; case PLAYER_HORIZ: @@ -340,582 +340,582 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, } ps[iPlayer].horizon.settarget(lValue); } - else SetGameVarID((int)lVar2, ps[iPlayer].horizon.horiz.asbuild(), sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].horizon.horiz.asbuild(), sActor, sPlayer); break; case PLAYER_OHORIZ: - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].horizon.ohoriz.asbuild(), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].horizon.ohoriz.asbuild(), sActor, sPlayer); break; case PLAYER_HORIZOFF: if (bSet) ps[iPlayer].horizon.horizoff = buildhoriz(lValue); - else SetGameVarID((int)lVar2, ps[iPlayer].horizon.horizoff.asbuild(), sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].horizon.horizoff.asbuild(), sActor, sPlayer); break; case PLAYER_OHORIZOFF: - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].horizon.ohorizoff.asbuild(), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].horizon.ohorizoff.asbuild(), sActor, sPlayer); break; case PLAYER_INVDISPTIME: if (bSet) ps[iPlayer].invdisptime = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].invdisptime, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].invdisptime, sActor, sPlayer); break; case PLAYER_BOBPOSX: if (bSet) ps[iPlayer].bobposx = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].bobposx, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].bobposx, sActor, sPlayer); break; case PLAYER_BOBPOSY: if (bSet) ps[iPlayer].bobposy = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].bobposy, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].bobposy, sActor, sPlayer); break; case PLAYER_OPOSX: if (bSet) ps[iPlayer].oposx = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].oposx, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].oposx, sActor, sPlayer); break; case PLAYER_OPOSY: if (bSet) ps[iPlayer].oposy = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].oposy, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].oposy, sActor, sPlayer); break; case PLAYER_OPOSZ: if (bSet) ps[iPlayer].oposz = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].oposz, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].oposz, sActor, sPlayer); break; case PLAYER_PYOFF: if (bSet) ps[iPlayer].pyoff = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].pyoff, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].pyoff, sActor, sPlayer); break; case PLAYER_OPYOFF: if (bSet) ps[iPlayer].opyoff = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].opyoff, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].opyoff, sActor, sPlayer); break; case PLAYER_POSXV: if (bSet) ps[iPlayer].posxv = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].posxv, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].posxv, sActor, sPlayer); break; case PLAYER_POSYV: if (bSet) ps[iPlayer].posyv = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].posyv, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].posyv, sActor, sPlayer); break; case PLAYER_POSZV: if (bSet) ps[iPlayer].poszv = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].poszv, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].poszv, sActor, sPlayer); break; case PLAYER_LAST_PISSED_TIME: if (bSet) ps[iPlayer].last_pissed_time = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].last_pissed_time, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].last_pissed_time, sActor, sPlayer); break; case PLAYER_TRUEFZ: if (bSet) ps[iPlayer].truefz = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].truefz, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].truefz, sActor, sPlayer); break; case PLAYER_TRUECZ: if (bSet) ps[iPlayer].truecz = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].truecz, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].truecz, sActor, sPlayer); break; case PLAYER_PLAYER_PAR: if (bSet) ps[iPlayer].player_par = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].player_par, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].player_par, sActor, sPlayer); break; case PLAYER_VISIBILITY: if (bSet) ps[iPlayer].visibility = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].visibility, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].visibility, sActor, sPlayer); break; case PLAYER_BOBCOUNTER: if (bSet) ps[iPlayer].bobcounter = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].bobcounter, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].bobcounter, sActor, sPlayer); break; case PLAYER_WEAPON_SWAY: if (bSet) ps[iPlayer].weapon_sway = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].weapon_sway, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].weapon_sway, sActor, sPlayer); break; case PLAYER_PALS_TIME: if (bSet) ps[iPlayer].pals.a = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].pals.a, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].pals.a, sActor, sPlayer); break; case PLAYER_RANDOMFLAMEX: if (bSet) ps[iPlayer].randomflamex = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].randomflamex, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].randomflamex, sActor, sPlayer); break; case PLAYER_CRACK_TIME: if (bSet) ps[iPlayer].crack_time = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].crack_time, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].crack_time, sActor, sPlayer); break; case PLAYER_AIM_MODE: // game has no business enforcing this in any way. - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].aim_mode, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].aim_mode, sActor, sPlayer); break; case PLAYER_ANG: if (bSet) ps[iPlayer].angle.settarget(lValue); - else SetGameVarID((int)lVar2, ps[iPlayer].angle.ang.asbuild(), sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].angle.ang.asbuild(), sActor, sPlayer); break; case PLAYER_OANG: - if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].angle.oang.asbuild(), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].angle.oang.asbuild(), sActor, sPlayer); break; case PLAYER_ANGVEL: // This no longer exists. - if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, 0, sActor, sPlayer); break; case PLAYER_CURSECTNUM: if (bSet) ps[iPlayer].cursectnum = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].cursectnum, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].cursectnum, sActor, sPlayer); break; case PLAYER_LOOK_ANG: if (bSet) ps[iPlayer].angle.look_ang = buildlook(lValue); - else SetGameVarID((int)lVar2, ps[iPlayer].angle.look_ang.asbuild(), sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].angle.look_ang.asbuild(), sActor, sPlayer); break; case PLAYER_LAST_EXTRA: if (bSet) ps[iPlayer].last_extra = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].last_extra, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].last_extra, sActor, sPlayer); break; case PLAYER_SUBWEAPON: if (bSet) ps[iPlayer].subweapon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].subweapon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].subweapon, sActor, sPlayer); break; case PLAYER_AMMO_AMOUNT: - lTemp = GetGameVarID((int)lParm2, sActor, sPlayer); + lTemp = GetGameVarID(lParm2, sActor, sPlayer); if (bSet) ps[iPlayer].ammo_amount[lTemp] = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].ammo_amount[lTemp], sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].ammo_amount[lTemp], sActor, sPlayer); break; case PLAYER_WACKEDBYACTOR: if (bSet) ps[iPlayer].wackedbyactor = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].wackedbyactor), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].wackedbyactor), sActor, sPlayer); break; case PLAYER_FRAG: if (bSet) ps[iPlayer].frag = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].frag, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].frag, sActor, sPlayer); break; case PLAYER_FRAGGEDSELF: if (bSet) ps[iPlayer].fraggedself = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].fraggedself, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].fraggedself, sActor, sPlayer); break; case PLAYER_CURR_WEAPON: if (bSet) ps[iPlayer].curr_weapon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].curr_weapon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].curr_weapon, sActor, sPlayer); break; case PLAYER_LAST_WEAPON: if (bSet) ps[iPlayer].last_weapon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].last_weapon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].last_weapon, sActor, sPlayer); break; case PLAYER_TIPINCS: if (bSet) ps[iPlayer].tipincs = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].tipincs, sActor, sPlayer); break; case PLAYER_WANTWEAPONFIRE: if (bSet) ps[iPlayer].wantweaponfire = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); break; case PLAYER_HOLODUKE_AMOUNT: if (bSet) ps[iPlayer].holoduke_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].holoduke_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].holoduke_amount, sActor, sPlayer); break; case PLAYER_NEWOWNER: if (bSet) ps[iPlayer].newOwner = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].newOwner), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].newOwner), sActor, sPlayer); break; case PLAYER_HURT_DELAY: if (bSet) ps[iPlayer].hurt_delay = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].hurt_delay, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].hurt_delay, sActor, sPlayer); break; case PLAYER_HBOMB_HOLD_DELAY: if (bSet) ps[iPlayer].hbomb_hold_delay = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].hbomb_hold_delay, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].hbomb_hold_delay, sActor, sPlayer); break; case PLAYER_JUMPING_COUNTER: if (bSet) ps[iPlayer].jumping_counter = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].jumping_counter, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].jumping_counter, sActor, sPlayer); break; case PLAYER_AIRLEFT: if (bSet) ps[iPlayer].airleft = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].airleft, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].airleft, sActor, sPlayer); break; case PLAYER_KNEE_INCS: if (bSet) ps[iPlayer].knee_incs = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); break; case PLAYER_ACCESS_INCS: if (bSet) ps[iPlayer].access_incs = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].access_incs, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].access_incs, sActor, sPlayer); break; case PLAYER_ACCESS_WALLNUM: if (bSet) ps[iPlayer].access_wallnum = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].access_wallnum, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].access_wallnum, sActor, sPlayer); break; case PLAYER_ACCESS_SPRITENUM: if (bSet) ps[iPlayer].access_spritenum = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].access_spritenum), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].access_spritenum), sActor, sPlayer); break; case PLAYER_KICKBACK_PIC: if (bSet) ps[iPlayer].kickback_pic = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].kickback_pic, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].kickback_pic, sActor, sPlayer); break; case PLAYER_GOT_ACCESS: if (bSet) ps[iPlayer].got_access = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].got_access, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].got_access, sActor, sPlayer); break; case PLAYER_WEAPON_ANG: if (bSet) ps[iPlayer].weapon_ang = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].weapon_ang, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].weapon_ang, sActor, sPlayer); break; case PLAYER_FIRSTAID_AMOUNT: if (bSet) ps[iPlayer].firstaid_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].firstaid_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].firstaid_amount, sActor, sPlayer); break; case PLAYER_SOMETHINGONPLAYER: if (bSet) ps[iPlayer].somethingonplayer = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].somethingonplayer), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].somethingonplayer), sActor, sPlayer); break; case PLAYER_ON_CRANE: if (bSet) ps[iPlayer].on_crane = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].on_crane), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].on_crane), sActor, sPlayer); break; case PLAYER_I: // This is dangerous!!! if (bSet) ps[iPlayer].i = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].i, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].i, sActor, sPlayer); break; case PLAYER_ONE_PARALLAX_SECTNUM: if (bSet) ps[iPlayer].one_parallax_sectnum = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); break; case PLAYER_OVER_SHOULDER_ON: if (bSet) ps[iPlayer].over_shoulder_on = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); break; case PLAYER_RANDOM_CLUB_FRAME: if (bSet) ps[iPlayer].random_club_frame = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].random_club_frame, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].random_club_frame, sActor, sPlayer); break; case PLAYER_FIST_INCS: if (bSet) ps[iPlayer].fist_incs = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); break; case PLAYER_ONE_EIGHTY_COUNT: if (bSet) ps[iPlayer].angle.spin = buildlook(lValue); - else SetGameVarID((int)lVar2, ps[iPlayer].angle.spin.asbuild(), sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].angle.spin.asbuild(), sActor, sPlayer); break; case PLAYER_CHEAT_PHASE: if (bSet) ps[iPlayer].cheat_phase = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].cheat_phase, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].cheat_phase, sActor, sPlayer); break; case PLAYER_DUMMYPLAYERSPRITE: if (bSet) ps[iPlayer].dummyplayersprite = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].dummyplayersprite), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].dummyplayersprite), sActor, sPlayer); break; case PLAYER_EXTRA_EXTRA8: if (bSet) ps[iPlayer].extra_extra8 = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].extra_extra8, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].extra_extra8, sActor, sPlayer); break; case PLAYER_QUICK_KICK: if (bSet) ps[iPlayer].quick_kick = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].quick_kick, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].quick_kick, sActor, sPlayer); break; case PLAYER_HEAT_AMOUNT: if (bSet) ps[iPlayer].heat_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].heat_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].heat_amount, sActor, sPlayer); break; case PLAYER_ACTORSQU: if (bSet) ps[iPlayer].actorsqu = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].actorsqu), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].actorsqu), sActor, sPlayer); break; case PLAYER_TIMEBEFOREEXIT: if (bSet) ps[iPlayer].timebeforeexit = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].timebeforeexit, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].timebeforeexit, sActor, sPlayer); break; case PLAYER_CUSTOMEXITSOUND: if (bSet) ps[iPlayer].customexitsound = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].customexitsound, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].customexitsound, sActor, sPlayer); break; case PLAYER_WEAPRECS: if (bSet) ps[iPlayer].weaprecs[lParm2] = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].weaprecs[lParm2], sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].weaprecs[lParm2], sActor, sPlayer); break; case PLAYER_WEAPRECCNT: if (bSet) ps[iPlayer].weapreccnt = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].weapreccnt, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].weapreccnt, sActor, sPlayer); break; case PLAYER_INTERFACE_TOGGLE_FLAG: if (bSet) ps[iPlayer].interface_toggle_flag = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].interface_toggle_flag, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].interface_toggle_flag, sActor, sPlayer); break; case PLAYER_ROTSCRNANG: if (bSet) ps[iPlayer].angle.rotscrnang = buildlook(lValue); - else SetGameVarID((int)lVar2, ps[iPlayer].angle.rotscrnang.asbuild(), sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].angle.rotscrnang.asbuild(), sActor, sPlayer); break; case PLAYER_DEAD_FLAG: if (bSet) ps[iPlayer].dead_flag = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].dead_flag, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].dead_flag, sActor, sPlayer); break; case PLAYER_SHOW_EMPTY_WEAPON: if (bSet) ps[iPlayer].show_empty_weapon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].show_empty_weapon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].show_empty_weapon, sActor, sPlayer); break; case PLAYER_SCUBA_AMOUNT: if (bSet) ps[iPlayer].scuba_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].scuba_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].scuba_amount, sActor, sPlayer); break; case PLAYER_JETPACK_AMOUNT: if (bSet) ps[iPlayer].jetpack_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].jetpack_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].jetpack_amount, sActor, sPlayer); break; case PLAYER_STEROIDS_AMOUNT: if (bSet) ps[iPlayer].steroids_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].steroids_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].steroids_amount, sActor, sPlayer); break; case PLAYER_SHIELD_AMOUNT: if (bSet) ps[iPlayer].shield_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].shield_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].shield_amount, sActor, sPlayer); break; case PLAYER_HOLODUKE_ON: if (bSet) ps[iPlayer].holoduke_on = ScriptIndexToActor(lValue); - else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].holoduke_on), sActor, sPlayer); + else SetGameVarID(lVar2, ActorToScriptIndex(ps[iPlayer].holoduke_on), sActor, sPlayer); break; case PLAYER_PYCOUNT: if (bSet) ps[iPlayer].pycount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].pycount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].pycount, sActor, sPlayer); break; case PLAYER_WEAPON_POS: if (bSet) ps[iPlayer].weapon_pos = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].weapon_pos, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].weapon_pos, sActor, sPlayer); break; case PLAYER_FRAG_PS: if (bSet) ps[iPlayer].frag_ps = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].frag_ps, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].frag_ps, sActor, sPlayer); break; case PLAYER_TRANSPORTER_HOLD: if (bSet) ps[iPlayer].transporter_hold = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].transporter_hold, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].transporter_hold, sActor, sPlayer); break; case PLAYER_LAST_FULL_WEAPON: if (bSet) ps[iPlayer].last_full_weapon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].last_full_weapon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].last_full_weapon, sActor, sPlayer); break; case PLAYER_FOOTPRINTSHADE: if (bSet) ps[iPlayer].footprintshade = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].footprintshade, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].footprintshade, sActor, sPlayer); break; case PLAYER_BOOT_AMOUNT: if (bSet) ps[iPlayer].boot_amount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].boot_amount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].boot_amount, sActor, sPlayer); break; case PLAYER_GM: - if (!bSet) SetGameVarID((int)lVar2, MODE_GAME, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, MODE_GAME, sActor, sPlayer); break; case PLAYER_ON_WARPING_SECTOR: if (bSet) ps[iPlayer].on_warping_sector = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].on_warping_sector, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].on_warping_sector, sActor, sPlayer); break; case PLAYER_FOOTPRINTCOUNT: if (bSet) ps[iPlayer].footprintcount = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].footprintcount, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].footprintcount, sActor, sPlayer); break; case PLAYER_HBOMB_ON: if (bSet) ps[iPlayer].hbomb_on = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].hbomb_on, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].hbomb_on, sActor, sPlayer); break; case PLAYER_JUMPING_TOGGLE: if (bSet) ps[iPlayer].jumping_toggle = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].jumping_toggle, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].jumping_toggle, sActor, sPlayer); break; case PLAYER_RAPID_FIRE_HOLD: if (bSet) ps[iPlayer].rapid_fire_hold = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].rapid_fire_hold, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].rapid_fire_hold, sActor, sPlayer); break; case PLAYER_ON_GROUND: if (bSet) ps[iPlayer].on_ground = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].on_ground, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].on_ground, sActor, sPlayer); break; case PLAYER_INVEN_ICON: if (bSet) ps[iPlayer].inven_icon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].inven_icon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].inven_icon, sActor, sPlayer); break; case PLAYER_BUTTONPALETTE: if (bSet) ps[iPlayer].buttonpalette = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].buttonpalette, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].buttonpalette, sActor, sPlayer); break; case PLAYER_JETPACK_ON: if (bSet) ps[iPlayer].jetpack_on = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].jetpack_on, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].jetpack_on, sActor, sPlayer); break; case PLAYER_SPRITEBRIDGE: if (bSet) ps[iPlayer].spritebridge = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].spritebridge, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].spritebridge, sActor, sPlayer); break; case PLAYER_LASTRANDOMSPOT: if (bSet) ps[iPlayer].lastrandomspot = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].lastrandomspot, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].lastrandomspot, sActor, sPlayer); break; case PLAYER_SCUBA_ON: if (bSet) ps[iPlayer].scuba_on = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].scuba_on, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].scuba_on, sActor, sPlayer); break; case PLAYER_FOOTPRINTPAL: if (bSet) ps[iPlayer].footprintpal = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].footprintpal, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].footprintpal, sActor, sPlayer); break; case PLAYER_HEAT_ON: if (bSet) ps[iPlayer].heat_on = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].heat_on, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].heat_on, sActor, sPlayer); break; case PLAYER_HOLSTER_WEAPON: if (bSet) ps[iPlayer].holster_weapon = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].holster_weapon, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].holster_weapon, sActor, sPlayer); break; case PLAYER_FALLING_COUNTER: if (bSet) ps[iPlayer].falling_counter = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].falling_counter, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].falling_counter, sActor, sPlayer); break; case PLAYER_GOTWEAPON: if (bSet) ps[iPlayer].gotweapon.Set(lParm2, lValue); - else SetGameVarID((int)lVar2, ps[iPlayer].gotweapon[lParm2], sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].gotweapon[lParm2], sActor, sPlayer); break; case PLAYER_REFRESH_INVENTORY: if (bSet) ps[iPlayer].refresh_inventory = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].refresh_inventory, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].refresh_inventory, sActor, sPlayer); break; case PLAYER_TOGGLE_KEY_FLAG: if (bSet) ps[iPlayer].toggle_key_flag = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].toggle_key_flag, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].toggle_key_flag, sActor, sPlayer); break; case PLAYER_KNUCKLE_INCS: if (bSet) ps[iPlayer].knuckle_incs = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].knuckle_incs, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].knuckle_incs, sActor, sPlayer); break; case PLAYER_WALKING_SND_TOGGLE: if (bSet) ps[iPlayer].walking_snd_toggle = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].walking_snd_toggle, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].walking_snd_toggle, sActor, sPlayer); break; case PLAYER_PALOOKUP: if (bSet) ps[iPlayer].palookup = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].palookup, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].palookup, sActor, sPlayer); break; case PLAYER_HARD_LANDING: if (bSet) ps[iPlayer].hard_landing = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].hard_landing, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].hard_landing, sActor, sPlayer); break; case PLAYER_MAX_SECRET_ROOMS: if (bSet) ps[iPlayer].max_secret_rooms = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].max_secret_rooms, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].max_secret_rooms, sActor, sPlayer); break; case PLAYER_SECRET_ROOMS: if (bSet) ps[iPlayer].secret_rooms = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].secret_rooms, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].secret_rooms, sActor, sPlayer); break; case PLAYER_MAX_ACTORS_KILLED: if (bSet) ps[iPlayer].max_actors_killed = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].max_actors_killed, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].max_actors_killed, sActor, sPlayer); break; case PLAYER_ACTORS_KILLED: if (bSet) ps[iPlayer].actors_killed = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); break; case PLAYER_RETURN_TO_CENTER: @@ -926,12 +926,12 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else { auto center = ps[iPlayer].sync.actions & SB_CENTERVIEW ? xs_CRoundToInt(ps[iPlayer].horizon.horiz.asq16() * (9. / gi->playerHorizMax())) : 0; - SetGameVarID((int)lVar2, center, sActor, sPlayer); + SetGameVarID(lVar2, center, sActor, sPlayer); } break; default: - if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, 0, sActor, sPlayer); break; } return; @@ -943,13 +943,13 @@ void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, s int iWall; int lValue; - lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + lValue = GetGameVarID(lVar2, sActor, sPlayer); - iWall = GetGameVarID((int)lVar1, sActor, sPlayer); + iWall = GetGameVarID(lVar1, sActor, sPlayer); if (iWall < 0 || iWall >= numwalls) { - if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, 0, sActor, sPlayer); return; } @@ -957,67 +957,67 @@ void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, s switch (lLabelID) { case WALL_X: - if (!bSet) SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, wall[iWall].x, sActor, sPlayer); break; case WALL_Y: - if (bSet) SetGameVarID((int)lVar2, wall[iWall].y, sActor, sPlayer); + if (bSet) SetGameVarID(lVar2, wall[iWall].y, sActor, sPlayer); break; case WALL_POINT2: - if (!bSet) SetGameVarID((int)lVar2, wall[iWall].point2, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, wall[iWall].point2, sActor, sPlayer); break; case WALL_NEXTWALL: - if (!bSet) SetGameVarID((int)lVar2, wall[iWall].nextwall, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, wall[iWall].nextwall, sActor, sPlayer); break; case WALL_NEXTSECTOR: - if (!bSet) SetGameVarID((int)lVar2, wall[iWall].nextsector, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, wall[iWall].nextsector, sActor, sPlayer); break; case WALL_CSTAT: if (bSet) wall[iWall].cstat = lValue; - else SetGameVarID((int)lVar2, wall[iWall].cstat, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].cstat, sActor, sPlayer); break; case WALL_PICNUM: if (bSet) wall[iWall].picnum = lValue; - else SetGameVarID((int)lVar2, wall[iWall].picnum, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].picnum, sActor, sPlayer); break; case WALL_OVERPICNUM: if (bSet) wall[iWall].overpicnum = lValue; - else SetGameVarID((int)lVar2, wall[iWall].overpicnum, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].overpicnum, sActor, sPlayer); break; case WALL_SHADE: if (bSet) wall[iWall].x = lValue; - else SetGameVarID((int)lVar2, wall[iWall].shade, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].shade, sActor, sPlayer); break; case WALL_PAL: if (bSet) wall[iWall].pal = lValue; - else SetGameVarID((int)lVar2, wall[iWall].pal, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].pal, sActor, sPlayer); break; case WALL_XREPEAT: if (bSet) wall[iWall].xrepeat = lValue; - else SetGameVarID((int)lVar2, wall[iWall].xrepeat, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].xrepeat, sActor, sPlayer); break; case WALL_YREPEAT: if (bSet) wall[iWall].yrepeat = lValue; - else SetGameVarID((int)lVar2, wall[iWall].yrepeat, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].yrepeat, sActor, sPlayer); break; case WALL_XPANNING: if (bSet) wall[iWall].xpan_ = lValue; - else SetGameVarID((int)lVar2, wall[iWall].xpan(), sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].xpan(), sActor, sPlayer); break; case WALL_YPANNING: if (bSet) wall[iWall].ypan_ = lValue; - else SetGameVarID((int)lVar2, wall[iWall].ypan(), sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].ypan(), sActor, sPlayer); break; case WALL_LOTAG: if (bSet) wall[iWall].lotag = lValue; - else SetGameVarID((int)lVar2, wall[iWall].lotag, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].lotag, sActor, sPlayer); break; case WALL_HITAG: if (bSet) wall[iWall].hitag = lValue; - else SetGameVarID((int)lVar2, wall[iWall].hitag, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].hitag, sActor, sPlayer); break; case WALL_EXTRA: if (bSet) wall[iWall].x = lValue; - else SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); + else SetGameVarID(lVar2, wall[iWall].x, sActor, sPlayer); break; default: break; @@ -1037,105 +1037,105 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, } else { - iSector = GetGameVarID((int)lVar1, sActor, sPlayer); + iSector = GetGameVarID(lVar1, sActor, sPlayer); } if (iSector < 0 || iSector >= numsectors) { - if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, 0, sActor, sPlayer); return; } - lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + lValue = GetGameVarID(lVar2, sActor, sPlayer); // All fields affecting map geometry have been made read-only! switch (lLabelID) { case SECTOR_WALLPTR: - if (!bSet) SetGameVarID((int)lVar2, sector[iSector].wallptr, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, sector[iSector].wallptr, sActor, sPlayer); break; case SECTOR_WALLNUM: - if (!bSet) SetGameVarID((int)lVar2, sector[iSector].wallnum, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, sector[iSector].wallnum, sActor, sPlayer); break; case SECTOR_CEILINGZ: if (bSet) sector[iSector].ceilingz = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingz, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingz, sActor, sPlayer); break; case SECTOR_FLOORZ: if (bSet) sector[iSector].floorz = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorz, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorz, sActor, sPlayer); break; case SECTOR_CEILINGSTAT: if (bSet) sector[iSector].ceilingstat = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingstat, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingstat, sActor, sPlayer); break; case SECTOR_FLOORSTAT: if (bSet) sector[iSector].floorstat = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorstat, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorstat, sActor, sPlayer); break; case SECTOR_CEILINGPICNUM: if (bSet) sector[iSector].ceilingpicnum = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingpicnum, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingpicnum, sActor, sPlayer); break; case SECTOR_CEILINGSLOPE: if (bSet) sector[iSector].ceilingheinum = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingheinum, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingheinum, sActor, sPlayer); break; case SECTOR_CEILINGSHADE: if (bSet) sector[iSector].ceilingshade = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingshade, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingshade, sActor, sPlayer); break; case SECTOR_CEILINGPAL: if (bSet) sector[iSector].ceilingpal = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingpal, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingpal, sActor, sPlayer); break; case SECTOR_CEILINGXPANNING: if (bSet) sector[iSector].ceilingxpan_ = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingxpan(), sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingxpan(), sActor, sPlayer); break; case SECTOR_CEILINGYPANNING: if (bSet) sector[iSector].ceilingypan_ = lValue; - else SetGameVarID((int)lVar2, sector[iSector].ceilingypan(), sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].ceilingypan(), sActor, sPlayer); break; case SECTOR_FLOORPICNUM: if (bSet) sector[iSector].floorpicnum = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorpicnum, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorpicnum, sActor, sPlayer); break; case SECTOR_FLOORSLOPE: if (bSet) sector[iSector].floorheinum = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorheinum, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorheinum, sActor, sPlayer); break; case SECTOR_FLOORSHADE: if (bSet) sector[iSector].floorshade = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorshade, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorshade, sActor, sPlayer); break; case SECTOR_FLOORPAL: if (bSet) sector[iSector].floorpal = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorpal, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorpal, sActor, sPlayer); break; case SECTOR_FLOORXPANNING: if (bSet) sector[iSector].floorxpan_ = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorxpan(), sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorxpan(), sActor, sPlayer); break; case SECTOR_FLOORYPANNING: if (bSet) sector[iSector].floorypan_ = lValue; - else SetGameVarID((int)lVar2, sector[iSector].floorypan(), sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].floorypan(), sActor, sPlayer); break; case SECTOR_VISIBILITY: if (bSet) sector[iSector].visibility = lValue; - else SetGameVarID((int)lVar2, sector[iSector].visibility, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].visibility, sActor, sPlayer); break; case SECTOR_LOTAG: if (bSet) sector[iSector].lotag = lValue; - else SetGameVarID((int)lVar2, sector[iSector].lotag, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].lotag, sActor, sPlayer); break; case SECTOR_HITAG: if (bSet) sector[iSector].hitag = lValue; - else SetGameVarID((int)lVar2, sector[iSector].hitag, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].hitag, sActor, sPlayer); break; case SECTOR_EXTRA: if (bSet) sector[iSector].extra = lValue; - else SetGameVarID((int)lVar2, sector[iSector].extra, sActor, sPlayer); + else SetGameVarID(lVar2, sector[iSector].extra, sActor, sPlayer); break; default: break; @@ -1148,7 +1148,7 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, int iActor; int lValue; - lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + lValue = GetGameVarID(lVar2, sActor, sPlayer); DDukeActor* act; if (lVar1 == g_iThisActorID) @@ -1158,14 +1158,14 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, } else { - iActor = GetGameVarID((int)lVar1, sActor, sPlayer); + iActor = GetGameVarID(lVar1, sActor, sPlayer); act = ScriptIndexToActor(iActor); } auto spr = &act->s; if (iActor < 0 || iActor >= MAXSPRITES || spr->statnum == MAXSTATUS) { - if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, 0, sActor, sPlayer); return; } @@ -1173,188 +1173,188 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, { case ACTOR_X: if (bSet) spr->x = lValue; - else SetGameVarID((int)lVar2, spr->x, sActor, sPlayer); + else SetGameVarID(lVar2, spr->x, sActor, sPlayer); break; case ACTOR_Y: if (bSet) spr->y = lValue; - else SetGameVarID((int)lVar2, spr->y, sActor, sPlayer); + else SetGameVarID(lVar2, spr->y, sActor, sPlayer); break; case ACTOR_Z: if (bSet) spr->z = lValue; - else SetGameVarID((int)lVar2, spr->z, sActor, sPlayer); + else SetGameVarID(lVar2, spr->z, sActor, sPlayer); break; case ACTOR_CSTAT: if (bSet) spr->cstat = lValue; - else SetGameVarID((int)lVar2, spr->cstat, sActor, sPlayer); + else SetGameVarID(lVar2, spr->cstat, sActor, sPlayer); break; case ACTOR_PICNUM: if (bSet) spr->picnum = lValue; - else SetGameVarID((int)lVar2, spr->picnum, sActor, sPlayer); + else SetGameVarID(lVar2, spr->picnum, sActor, sPlayer); break; case ACTOR_SHADE: if (bSet) spr->shade = lValue; - else SetGameVarID((int)lVar2, spr->shade, sActor, sPlayer); + else SetGameVarID(lVar2, spr->shade, sActor, sPlayer); break; case ACTOR_PAL: if (bSet) spr->pal = lValue; - else SetGameVarID((int)lVar2, spr->pal, sActor, sPlayer); + else SetGameVarID(lVar2, spr->pal, sActor, sPlayer); break; case ACTOR_CLIPDIST: if (bSet) spr->clipdist = lValue; - else SetGameVarID((int)lVar2, spr->clipdist, sActor, sPlayer); + else SetGameVarID(lVar2, spr->clipdist, sActor, sPlayer); break; case ACTOR_DETAIL: if (bSet) act->spriteextra = lValue; - else SetGameVarID((int)lVar2, act->spriteextra, sActor, sPlayer); + else SetGameVarID(lVar2, act->spriteextra, sActor, sPlayer); break; case ACTOR_XREPEAT: if (bSet) spr->xrepeat = lValue; - else SetGameVarID((int)lVar2, spr->xrepeat, sActor, sPlayer); + else SetGameVarID(lVar2, spr->xrepeat, sActor, sPlayer); break; case ACTOR_YREPEAT: if (bSet) spr->yrepeat = lValue; - else SetGameVarID((int)lVar2, spr->yrepeat, sActor, sPlayer); + else SetGameVarID(lVar2, spr->yrepeat, sActor, sPlayer); break; case ACTOR_XOFFSET: if (bSet) spr->xoffset = lValue; - else SetGameVarID((int)lVar2, spr->xoffset, sActor, sPlayer); + else SetGameVarID(lVar2, spr->xoffset, sActor, sPlayer); break; case ACTOR_YOFFSET: if (bSet) spr->yoffset = lValue; - else SetGameVarID((int)lVar2, spr->yoffset, sActor, sPlayer); + else SetGameVarID(lVar2, spr->yoffset, sActor, sPlayer); break; case ACTOR_SECTNUM: if (bSet) changespritesect(iActor, lValue); - else SetGameVarID((int)lVar2, spr->sectnum, sActor, sPlayer); + else SetGameVarID(lVar2, spr->sectnum, sActor, sPlayer); break; case ACTOR_STATNUM: if (bSet) changespritestat(iActor, lValue); - else SetGameVarID((int)lVar2, spr->statnum, sActor, sPlayer); + else SetGameVarID(lVar2, spr->statnum, sActor, sPlayer); break; case ACTOR_ANG: if (bSet) spr->ang = lValue; - else SetGameVarID((int)lVar2, spr->ang, sActor, sPlayer); + else SetGameVarID(lVar2, spr->ang, sActor, sPlayer); break; case ACTOR_OWNER: if (bSet) spr->owner = lValue; - else SetGameVarID((int)lVar2, spr->owner, sActor, sPlayer); + else SetGameVarID(lVar2, spr->owner, sActor, sPlayer); break; case ACTOR_XVEL: if (bSet) spr->xvel = lValue; - else SetGameVarID((int)lVar2, spr->xvel, sActor, sPlayer); + else SetGameVarID(lVar2, spr->xvel, sActor, sPlayer); break; case ACTOR_YVEL: if (bSet) spr->yvel = lValue; - else SetGameVarID((int)lVar2, spr->yvel, sActor, sPlayer); + else SetGameVarID(lVar2, spr->yvel, sActor, sPlayer); break; case ACTOR_ZVEL: if (bSet) spr->zvel = lValue; - else SetGameVarID((int)lVar2, spr->zvel, sActor, sPlayer); + else SetGameVarID(lVar2, spr->zvel, sActor, sPlayer); break; case ACTOR_LOTAG: if (bSet) spr->lotag = lValue; - else SetGameVarID((int)lVar2, spr->lotag, sActor, sPlayer); + else SetGameVarID(lVar2, spr->lotag, sActor, sPlayer); break; case ACTOR_HITAG: if (bSet) spr->hitag = lValue; - else SetGameVarID((int)lVar2, spr->hitag, sActor, sPlayer); + else SetGameVarID(lVar2, spr->hitag, sActor, sPlayer); break; case ACTOR_EXTRA: if (bSet) spr->extra = lValue; - else SetGameVarID((int)lVar2, spr->extra, sActor, sPlayer); + else SetGameVarID(lVar2, spr->extra, sActor, sPlayer); break; case ACTOR_HTCGG: if (bSet) act->cgg = lValue; - else SetGameVarID((int)lVar2, act->cgg, sActor, sPlayer); + else SetGameVarID(lVar2, act->cgg, sActor, sPlayer); break; case ACTOR_HTPICNUM: if (bSet) act->picnum = lValue; - else SetGameVarID((int)lVar2, act->picnum, sActor, sPlayer); + else SetGameVarID(lVar2, act->picnum, sActor, sPlayer); break; case ACTOR_HTANG: if (bSet) act->ang = lValue; - else SetGameVarID((int)lVar2, act->ang, sActor, sPlayer); + else SetGameVarID(lVar2, act->ang, sActor, sPlayer); break; case ACTOR_HTEXTRA: if (bSet) act->extra = lValue; - else SetGameVarID((int)lVar2, act->extra, sActor, sPlayer); + else SetGameVarID(lVar2, act->extra, sActor, sPlayer); break; case ACTOR_HTOWNER: if (bSet) act->owner = lValue; - else SetGameVarID((int)lVar2, act->owner, sActor, sPlayer); + else SetGameVarID(lVar2, act->owner, sActor, sPlayer); break; case ACTOR_HTMOVFLAG: if (bSet) act->movflag = lValue; - else SetGameVarID((int)lVar2, act->movflag, sActor, sPlayer); + else SetGameVarID(lVar2, act->movflag, sActor, sPlayer); break; case ACTOR_HTTEMPANG: if (bSet) act->tempang = lValue; - else SetGameVarID((int)lVar2, act->tempang, sActor, sPlayer); + else SetGameVarID(lVar2, act->tempang, sActor, sPlayer); break; case ACTOR_HTACTORSTAYPUT: if (bSet) act->actorstayput = lValue; - else SetGameVarID((int)lVar2, act->actorstayput, sActor, sPlayer); + else SetGameVarID(lVar2, act->actorstayput, sActor, sPlayer); break; case ACTOR_HTDISPICNUM: if (bSet) act->dispicnum = lValue; - else SetGameVarID((int)lVar2, act->dispicnum, sActor, sPlayer); + else SetGameVarID(lVar2, act->dispicnum, sActor, sPlayer); break; case ACTOR_HTTIMETOSLEEP: if (bSet) act->timetosleep = lValue; - else SetGameVarID((int)lVar2, act->timetosleep, sActor, sPlayer); + else SetGameVarID(lVar2, act->timetosleep, sActor, sPlayer); break; case ACTOR_HTFLOORZ: if (bSet) act->floorz = lValue; - else SetGameVarID((int)lVar2, act->floorz, sActor, sPlayer); + else SetGameVarID(lVar2, act->floorz, sActor, sPlayer); break; case ACTOR_HTCEILINGZ: if (bSet) act->ceilingz = lValue; - else SetGameVarID((int)lVar2, act->ceilingz, sActor, sPlayer); + else SetGameVarID(lVar2, act->ceilingz, sActor, sPlayer); break; case ACTOR_HTLASTVX: if (bSet) act->lastvx = lValue; - else SetGameVarID((int)lVar2, act->lastvx, sActor, sPlayer); + else SetGameVarID(lVar2, act->lastvx, sActor, sPlayer); break; case ACTOR_HTLASTVY: if (bSet) act->lastvy = lValue; - else SetGameVarID((int)lVar2, act->lastvy, sActor, sPlayer); + else SetGameVarID(lVar2, act->lastvy, sActor, sPlayer); break; case ACTOR_HTBPOSX: if (bSet) spr->ox = lValue; - else SetGameVarID((int)lVar2, spr->ox, sActor, sPlayer); + else SetGameVarID(lVar2, spr->ox, sActor, sPlayer); break; case ACTOR_HTBPOSY: if (bSet) spr->oy = lValue; - else SetGameVarID((int)lVar2, spr->oy, sActor, sPlayer); + else SetGameVarID(lVar2, spr->oy, sActor, sPlayer); break; case ACTOR_HTBPOSZ: if (bSet) spr->oz = lValue; - else SetGameVarID((int)lVar2, spr->oz, sActor, sPlayer); + else SetGameVarID(lVar2, spr->oz, sActor, sPlayer); break; case ACTOR_HTG_T0: if (bSet) act->temp_data[0] = lValue; - else SetGameVarID((int)lVar2, act->temp_data[0], sActor, sPlayer); + else SetGameVarID(lVar2, act->temp_data[0], sActor, sPlayer); break; case ACTOR_HTG_T1: if (bSet) act->temp_data[1] = lValue; - else SetGameVarID((int)lVar2, act->temp_data[1], sActor, sPlayer); + else SetGameVarID(lVar2, act->temp_data[1], sActor, sPlayer); break; case ACTOR_HTG_T2: if (bSet) act->temp_data[2] = lValue; - else SetGameVarID((int)lVar2, act->temp_data[2], sActor, sPlayer); + else SetGameVarID(lVar2, act->temp_data[2], sActor, sPlayer); break; case ACTOR_HTG_T3: if (bSet) act->temp_data[3] = lValue; - else SetGameVarID((int)lVar2, act->temp_data[3], sActor, sPlayer); + else SetGameVarID(lVar2, act->temp_data[3], sActor, sPlayer); break; case ACTOR_HTG_T4: if (bSet) act->temp_data[4] = lValue; - else SetGameVarID((int)lVar2, act->temp_data[4], sActor, sPlayer); + else SetGameVarID(lVar2, act->temp_data[4], sActor, sPlayer); break; case ACTOR_HTG_T5: if (bSet) act->temp_data[5] = lValue; - else SetGameVarID((int)lVar2, act->temp_data[5], sActor, sPlayer); + else SetGameVarID(lVar2, act->temp_data[5], sActor, sPlayer); break; default: @@ -1800,13 +1800,13 @@ int ParseState::parse(void) case concmd_stopsound: insptr++; if (S_CheckSoundPlaying(*insptr)) - S_StopSound((int)*insptr); + S_StopSound(*insptr); insptr++; break; case concmd_globalsound: insptr++; if (g_p == screenpeek || ud.coop == 1) - S_PlayActorSound((int)*insptr, ps[screenpeek].GetActor()); + S_PlayActorSound(*insptr, ps[screenpeek].GetActor()); insptr++; break; case concmd_smackbubba: @@ -2447,7 +2447,7 @@ int ParseState::parse(void) j = 0; } - parseifelse((int) j); + parseifelse( j); } break; From c630ad9110256db08ad54dce2f22b7997d994942 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 31 Mar 2021 20:35:10 +1100 Subject: [PATCH 07/12] Revert "- subjective fix to Duke 3D's RPG harsh recoil." This reverts commit 839a7bcbe4a02e2d38470ea7a114473d59580e91. Revert "- Duke: Restore RPG harsh recoil behind a CVAR." This reverts commit 88a49b0d2248243c687989e3a5a50f265a9fa089. # Conflicts: # source/core/gamecvars.cpp # source/core/gamecvars.h --- source/core/gamecvars.cpp | 1 - source/core/gamecvars.h | 1 - source/games/duke/src/player_d.cpp | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 2f974cdbc..7fea2c6f6 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -77,7 +77,6 @@ CVARD(Bool, cl_slopetilting, false, CVAR_ARCHIVE, "enable/disable slope tilting" CVARD(Int, cl_showweapon, 1, CVAR_ARCHIVE, "enable/disable show weapons") // only implemented in Blood CVARD(Bool, cl_sointerpolation, true, CVAR_ARCHIVE, "enable/disable sector object interpolation") // only implemented in SW CVARD(Bool, cl_syncinput, false, CVAR_ARCHIVE, "enable/disable synchronized input with game's ticrate") // only implemented in Duke -CVARD(Bool, cl_dukefixrpgrecoil, false, CVAR_ARCHIVE, "soften recoil of Duke 3D's RPG") CVARD(Bool, cl_smoothsway, false, CVAR_ARCHIVE, "move SW weapon left and right smoothly while bobbing") CVARD(Bool, cl_showmagamt, false, CVAR_ARCHIVE, "show the amount of rounds left in the magazine of your weapon on the modern HUD") CVARD(Bool, cl_nomeleeblur, false, CVAR_ARCHIVE, "enable/disable blur effect with melee weapons in SW") diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 8c92f76c3..fa2115037 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -22,7 +22,6 @@ EXTERN_CVAR(Int, cl_weaponswitch) EXTERN_CVAR(Float, crosshairscale) EXTERN_CVAR(Bool, cl_sointerpolation) EXTERN_CVAR(Bool, cl_syncinput) -EXTERN_CVAR(Bool, cl_dukefixrpgrecoil) EXTERN_CVAR(Bool, cl_smoothsway) EXTERN_CVAR(Bool, cl_showmagamt) EXTERN_CVAR(Bool, cl_nomeleeblur) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 6f23e1250..16de421c8 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2611,7 +2611,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) fi.shoot(pact, RPG); checkavailweapon(p); } - else if (p->kickback_pic == (cl_dukefixrpgrecoil ? 13 : 20)) + else if (p->kickback_pic == 20) p->okickback_pic = p->kickback_pic = 0; break; } From aa35b6a4793825b9b66c74a76c676e9185cb16f2 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 1 Apr 2021 08:32:07 +1100 Subject: [PATCH 08/12] - binaryangle.h: Fix constexpr issue on GCC builds following bf2d8078a4418eed5386faf904ca075d2af587d5. --- source/core/binaryangle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index acf5b82f2..373f5a02e 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -398,7 +398,7 @@ class fixedhoriz friend constexpr fixedhoriz q16horiz(fixed_t v); friend constexpr fixedhoriz buildhoriz(int v); - friend constexpr fixedhoriz buildfhoriz(double v); + friend fixedhoriz buildfhoriz(double v); friend fixedhoriz pitchhoriz(double v); friend fixedhoriz bamhoriz(int32_t v); @@ -497,7 +497,7 @@ public: inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); } inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); } -inline constexpr fixedhoriz buildfhoriz(double v) { return fixedhoriz(FloatToFixed(v)); } +inline fixedhoriz buildfhoriz(double v) { return fixedhoriz(FloatToFixed(v)); } inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(PitchToHoriz(v)); } inline fixedhoriz bamhoriz(int32_t v) { return pitchhoriz(BAMToPitch(v)); } From 029f8807df476c23812b956fb8ee8c11800f0cf0 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 1 Apr 2021 10:42:22 +1100 Subject: [PATCH 09/12] - Make `360. / 2048.` a constant expression and replace all uses throughout code. --- source/core/binaryangle.h | 1 + source/core/gameinput.cpp | 5 ++--- source/games/blood/src/qav.cpp | 2 +- source/games/blood/src/view.cpp | 2 +- source/games/duke/src/game_misc.cpp | 2 +- source/games/duke/src/input.cpp | 2 +- source/games/duke/src/sbar_r.cpp | 4 ++-- source/games/exhumed/src/movie.cpp | 2 +- source/games/sw/src/draw.cpp | 2 +- source/glbackend/glbackend.cpp | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index 373f5a02e..bec19e891 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -60,6 +60,7 @@ enum constexpr double BAngRadian = pi::pi() * (1. / 1024.); constexpr double BRadAngScale = 1. / BAngRadian; +constexpr double BAngToDegree = 360. / 2048.; //--------------------------------------------------------------------------- diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index a84df7574..a36edaa7a 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -154,8 +154,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn int const keymove = gi->playerKeyMove() << running; int const cntrlvelscale = g_gameType & GAMEFLAG_PSEXHUMED ? 8 : 1; float const mousevelscale = keymove / 160.f; - double const angtodegscale = 360. / 2048.; - double const hidspeed = ((running ? 1585. : 867.5) / GameTicRate) * angtodegscale; + double const hidspeed = ((running ? 1585. : 867.5) / GameTicRate) * BAngToDegree; // process mouse and initial controller input. if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe) @@ -199,7 +198,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn // allow Exhumed to use its legacy values given the drastic difference from the other games. if ((g_gameType & GAMEFLAG_PSEXHUMED) && cl_exhumedoldturn) { - preambleturn = turnamount = (running ? 12 : 8) * angtodegscale; + preambleturn = turnamount = (running ? 12 : 8) * BAngToDegree; } if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe)) diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index 9fd8d3566..607a73d40 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -46,7 +46,7 @@ void DrawFrame(double x, double y, TILE_FRAME *pTile, int stat, int shade, int p { auto tex = tileGetTexture(pTile->picnum); double scale = pTile->z/65536.; - double angle = pTile->angle * (360./2048); + double angle = pTile->angle * BAngToDegree; int renderstyle = (stat & RS_NOMASK)? STYLE_Normal : STYLE_Translucent; double alpha = (stat & RS_TRANS1)? glblend[0].def[!!(stat & RS_TRANS2)].alpha : 1.; int pin = (stat & kQavOrientationLeft)? -1 : (stat & RS_ALIGN_R)? 1:0; diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 2048fc333..6575d1298 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -882,7 +882,7 @@ FString GameInterface::GetCoordString() FString out; out.Format("pos= %d, %d, %d - angle = %2.3f", - gMe->pSprite->x, gMe->pSprite->y, gMe->pSprite->z, gMe->pSprite->ang * (360./2048)); + gMe->pSprite->x, gMe->pSprite->y, gMe->pSprite->z, gMe->pSprite->ang * BAngToDegree); return out; } diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index c806bad00..f5ea986d9 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -577,7 +577,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, else if (j > (65536 << 1)) j = (65536 << 1); DrawTexture(twod, tileGetTexture(i), xdim / 2. + spos.x / 4096., ydim / 2. + spos.y / 4096., DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(&pp), pspr->pal), DTA_CenterOffset, true, - DTA_Rotate, daang * (-360./2048), DTA_Color, shadeToLight(pspr->shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE); + DTA_Rotate, daang * -BAngToDegree, DTA_Color, shadeToLight(pspr->shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE); } } return true; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 4bf022212..d8cbaa751 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -755,7 +755,7 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I } input.fvel = xs_CRoundToInt(p->MotoSpeed); - input.avel *= (45. / 256.); + input.avel *= BAngToDegree; loc.avel += input.avel; } diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index ee23a90a4..c6035b13a 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -413,8 +413,8 @@ public: p->drunkang = 400; } - DrawRotated(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, p->drunkang * (-360. / 2048), 1, scale, scale, 0xffffffff, 0); - DrawRotated(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, p->eatang * (-360. / 2048), 1, scale, scale, 0xffffffff, 0); + DrawRotated(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, p->drunkang * -BAngToDegree, 1, scale, scale, 0xffffffff, 0); + DrawRotated(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, p->eatang * -BAngToDegree, 1, scale, scale, 0xffffffff, 0); if (p->drink_amt >= 0 && p->drink_amt <= 30) { diff --git a/source/games/exhumed/src/movie.cpp b/source/games/exhumed/src/movie.cpp index bb18ea182..d26b9ce52 100644 --- a/source/games/exhumed/src/movie.cpp +++ b/source/games/exhumed/src/movie.cpp @@ -250,7 +250,7 @@ public: { twod->ClearScreen(); DrawTexture(twod, decoder.animTex().GetFrame(), 160, 100, DTA_FullscreenScale, FSMode_Fit320x200, - DTA_CenterOffset, true, DTA_FlipY, true, DTA_ScaleX, z / 65536., DTA_ScaleY, z / 65536., DTA_Rotate, (-angle - 512) * (360. / 2048.), TAG_DONE); + DTA_CenterOffset, true, DTA_FlipY, true, DTA_ScaleX, z / 65536., DTA_ScaleY, z / 65536., DTA_Rotate, (-angle - 512) * BAngToDegree, TAG_DONE); } lastclock = clock; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 0110fb5e5..6763fd752 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1825,7 +1825,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double sc = MulScale(czoom * (spr->yrepeat), yxaspect, 16) / 32768.; if (spnum >= 0) { - DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * (-360. / 2048), + DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * -BAngToDegree, DTA_CenterOffsetRel, true, DTA_TranslationIndex, TRANSLATION(Translation_Remap, spr->pal), DTA_Color, shadeToLight(spr->shade), DTA_Alpha, (spr->cstat & 2) ? 0.33 : 1., TAG_DONE); } diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 8cc3d006d..b1abfbfce 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -557,7 +557,7 @@ void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dasha DTA_FlipX, !!(dastat & RS_XFLIPHUD), DTA_FlipY, !!(dastat & RS_YFLIPHUD), DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0, - DTA_Rotate, a * (-360./2048), + DTA_Rotate, a * -BAngToDegree, DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)), DTA_Alpha, alpha, TAG_DONE); From 4321efa21c375cb244f45e94f23840a7b7a83804 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 1 Apr 2021 12:25:57 +1100 Subject: [PATCH 10/12] - Re-arrange `swaddons[]` const char array so that `/gameroot` is picked up first following changes in f4b27bbd27b0f424c92278f56c0469c47125930e. * Since f4b27bbd27b0f424c92278f56c0469c47125930e, `D:/Program Files (x86)/Steam/steamapps/common/Shadow Warrior Classic/gameroot/addons/Sw.grp` was being picked up instead of `D:/Program Files (x86)/Steam/steamapps/common/Shadow Warrior Classic/gameroot/SW.GRP`. * Fixes #289. --- source/core/searchpaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index ca679c51f..f2f07e281 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -88,7 +88,7 @@ struct RegistryPathInfo }; static const char * gameroot[] = { "/gameroot", nullptr}; -static const char * swaddons[] = { "/gameroot", "/gameroot/addons", nullptr}; +static const char * swaddons[] = { "/gameroot/addons", "/gameroot", nullptr}; static const char * dukeaddons[] = { "/gameroot", "/gameroot/addons/dc", "/gameroot/addons/nw", "/gameroot/addons/vacation", nullptr}; static const char * dn3d[] = { "/Duke Nukem 3D", nullptr}; static const char * nam[] = { "/NAM", nullptr}; From c076310e346345a6dc186ddceb66913b3222b1dd Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 1 Apr 2021 13:46:16 +1100 Subject: [PATCH 11/12] - `InputState::ClearAllInput()`: Only clear `crouch_toggle` bool if outside of a level, and resend `SB_CROUCH` sync bit if inside a level and `crouch_toggle` is true. * Fixes #287. --- source/core/inputstate.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 98500826a..a87a24219 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -119,13 +119,26 @@ void InputState::ClearAllInput() { memset(KeyStatus, 0, sizeof(KeyStatus)); AnyKeyStatus = false; - ActionsToSend = 0; WeaponToSend = 0; dpad_lock = 0; lastCheck = 0; - crouch_toggle = false; + + if (gamestate != GS_LEVEL) + { + ActionsToSend = 0; + crouch_toggle = false; + gi->clearlocalinputstate(); // also clear game local input state. + } + else if (gamestate == GS_LEVEL && crouch_toggle) + { + ActionsToSend |= SB_CROUCH; + } + else + { + ActionsToSend = 0; + } + buttonMap.ResetButtonStates(); // this is important. If all input is cleared, the buttons must be cleared as well. - gi->clearlocalinputstate(); // also clear game local input state. resetTurnHeldAmt(); } From 612b8b3350b1cb9fc921866dee28f0c021d42385 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 1 Apr 2021 13:59:31 +1100 Subject: [PATCH 12/12] - Fix `Linux GCC 7` continuous integration target. --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 6da199d37..3c603963d 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -39,7 +39,7 @@ jobs: name: "Linux GCC 7", os: ubuntu-20.04, extra_options: "-DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7", - deps_cmdline: "sudo apt update && sudo apt install libsdl2-dev libvpx-dev libgtk2.0-dev", + deps_cmdline: "sudo apt update && sudo apt install libsdl2-dev libvpx-dev libgtk2.0-dev gcc-7 g++-7", build_type: "RelWithDebInfo" } - {