From e2a6353182943bd583f64c01b11f0b66a4476e73 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Sep 2022 00:18:09 +0200 Subject: [PATCH] - eliminated AngleDiff. --- source/CMakeLists.txt | 1 - source/games/exhumed/all.cpp | 1 - source/games/exhumed/src/anubis.cpp | 4 +- source/games/exhumed/src/engine.h | 10 ----- source/games/exhumed/src/lavadude.cpp | 4 +- source/games/exhumed/src/lion.cpp | 8 ++-- source/games/exhumed/src/mummy.cpp | 4 +- source/games/exhumed/src/player.cpp | 8 +--- source/games/exhumed/src/scorp.cpp | 4 +- source/games/exhumed/src/set.cpp | 6 +-- source/games/exhumed/src/spider.cpp | 4 +- source/games/exhumed/src/trigdat.cpp | 65 --------------------------- 12 files changed, 19 insertions(+), 100 deletions(-) delete mode 100644 source/games/exhumed/src/trigdat.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d646a4635..448147b65 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -902,7 +902,6 @@ set( NOT_COMPILED_SOURCE_FILES games/exhumed/src/spider.cpp games/exhumed/src/status.cpp games/exhumed/src/switch.cpp - games/exhumed/src/trigdat.cpp games/exhumed/src/view.cpp games/exhumed/src/wasp.cpp diff --git a/source/games/exhumed/all.cpp b/source/games/exhumed/all.cpp index 9df6c0d08..490af75ba 100644 --- a/source/games/exhumed/all.cpp +++ b/source/games/exhumed/all.cpp @@ -43,7 +43,6 @@ #include "src/spider.cpp" #include "src/status.cpp" #include "src/switch.cpp" -#include "src/trigdat.cpp" #include "src/view.cpp" #include "src/wasp.cpp" // This includes the VM so it is last diff --git a/source/games/exhumed/src/anubis.cpp b/source/games/exhumed/src/anubis.cpp index df94997f1..136c39c82 100644 --- a/source/games/exhumed/src/anubis.cpp +++ b/source/games/exhumed/src/anubis.cpp @@ -177,8 +177,8 @@ void AIAnubis::Tick(RunListEvent* ev) { if (move.actor() == pTarget) { - auto nAngDiff = AngleDiff(ap->spr.angle, VecToAngle(pTarget->spr.pos - ap->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(ap->spr.angle, VecToAngle(pTarget->spr.pos - ap->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { ap->nAction = 2; ap->nFrame = 0; diff --git a/source/games/exhumed/src/engine.h b/source/games/exhumed/src/engine.h index 946ec2647..3cde828d1 100644 --- a/source/games/exhumed/src/engine.h +++ b/source/games/exhumed/src/engine.h @@ -121,15 +121,5 @@ DAngle RandomAngle9(); DAngle RandomAngle(); double RandomFloat(double range); -// record - -// save - -// trigdat - - -int AngleDiff(DAngle a, DAngle b); -int AngleDelta(int a, int b, int c); - END_PS_NS diff --git a/source/games/exhumed/src/lavadude.cpp b/source/games/exhumed/src/lavadude.cpp index a69592bfa..daa984e77 100644 --- a/source/games/exhumed/src/lavadude.cpp +++ b/source/games/exhumed/src/lavadude.cpp @@ -305,8 +305,8 @@ void AILavaDude::Tick(RunListEvent* ev) { if (coll.actor() == pTarget) { - auto nAngDiff = AngleDiff(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { pActor->nAction = 2; pActor->nFrame = 0; diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index b9fcb3d61..155e6dfe6 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -302,8 +302,8 @@ void AILion::Tick(RunListEvent* ev) } else { - auto nAngDiff = AngleDiff(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { pActor->nAction = 3; } @@ -427,8 +427,8 @@ void AILion::Tick(RunListEvent* ev) { if (nMov.actor() == pTarget) { - auto nAngDiff = AngleDiff(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { pActor->nAction = 3; pActor->nFrame = 0; diff --git a/source/games/exhumed/src/mummy.cpp b/source/games/exhumed/src/mummy.cpp index cc0a3c5a0..f67c03d1c 100644 --- a/source/games/exhumed/src/mummy.cpp +++ b/source/games/exhumed/src/mummy.cpp @@ -266,8 +266,8 @@ void AIMummy::Tick(RunListEvent* ev) { if (nMov.actor() == pTarget) { - auto nAngDiff = AngleDiff(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { pActor->nAction = 2; pActor->nFrame = 0; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 761768cff..f9f400002 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -738,13 +738,9 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort { if ((sect->hitag == 45) && bTouchFloor) { - int nDiff = AngleDiff(nNormal, pPlayerActor->spr.angle + DAngle180); + auto nDiff = absangle(nNormal, pPlayerActor->spr.angle + DAngle180); - if (nDiff < 0) { - nDiff = -nDiff; - } - - if (nDiff <= 256) + if (nDiff <= DAngle45) { PlayerList[nPlayer].pPlayerPushSect = sect; diff --git a/source/games/exhumed/src/scorp.cpp b/source/games/exhumed/src/scorp.cpp index 18d71dab1..267dbdb7f 100644 --- a/source/games/exhumed/src/scorp.cpp +++ b/source/games/exhumed/src/scorp.cpp @@ -244,8 +244,8 @@ void AIScorp::Tick(RunListEvent* ev) { if (pTarget == nMov.actor()) { - auto nAngDiff = AngleDiff(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { pActor->nAction = 2; pActor->nFrame = 0; diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index 1dd32c59a..df33ec7ec 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -424,9 +424,9 @@ void AISet::Tick(RunListEvent* ev) { if (pTarget == nMov.actor()) { - auto nAngDiff = AngleDiff(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); - if (nAngDiff < 64) - { + auto nAngDiff = absangle(pActor->spr.angle, VecToAngle(pTarget->spr.pos - pActor->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) + { pActor->nAction = 4; pActor->nFrame = 0; } diff --git a/source/games/exhumed/src/spider.cpp b/source/games/exhumed/src/spider.cpp index 25d03dee1..b37cc1dfe 100644 --- a/source/games/exhumed/src/spider.cpp +++ b/source/games/exhumed/src/spider.cpp @@ -305,8 +305,8 @@ void AISpider::Tick(RunListEvent* ev) { if (nMov.actor() == pTarget) { - auto nAngDiff = AngleDiff(spp->spr.angle, VecToAngle(pTarget->spr.pos - spp->spr.pos)); - if (nAngDiff < 64) + auto nAngDiff = absangle(spp->spr.angle, VecToAngle(pTarget->spr.pos - spp->spr.pos)); + if (nAngDiff < DAngle22_5 / 2) { spp->nAction = 2; spp->nFrame = 0; diff --git a/source/games/exhumed/src/trigdat.cpp b/source/games/exhumed/src/trigdat.cpp deleted file mode 100644 index 5a718489a..000000000 --- a/source/games/exhumed/src/trigdat.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010-2019 EDuke32 developers and contributors -Copyright (C) 2019 sirlemonhead, Nuke.YKT -This file is part of PCExhumed. -PCExhumed is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- -#include "ns.h" -#include "engine.h" -#ifndef __WATCOMC__ -#include -#include -#else -#include -#endif - -BEGIN_PS_NS - -// 100% done -int AngleDiff(DAngle a, DAngle b) -{ - int diff = (b - a).Normalized360().Buildang(); - - if (diff > 1024) { - diff = 2048 - diff; - } - return diff; -} - -int AngleDelta(int a, int b, int c) -{ - int diff = b - a; - - if (diff >= 0) - { - if (diff > 1024) { - diff = -(2048 - diff); - } - } - else if (diff < -1024) - { - diff += 2048; - } - - if (abs(diff) > c) - { - if (diff < 0) { - return -diff; - } - - diff = c; - } - return diff; -} -END_PS_NS