From 5c4bf981943b3375d190522914f14b0070e72c7a Mon Sep 17 00:00:00 2001 From: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:41:58 +1000 Subject: [PATCH 1/2] Interpolate angle for 2d map view --- source/blood/src/map2d.cpp | 8 ++++---- source/blood/src/map2d.h | 2 +- source/blood/src/view.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/source/blood/src/map2d.cpp b/source/blood/src/map2d.cpp index bded20302b..a37eb84f40 100644 --- a/source/blood/src/map2d.cpp +++ b/source/blood/src/map2d.cpp @@ -214,14 +214,14 @@ void CViewMap::Draw(void) viewResizeView(viewSize); } -void CViewMap::Process(spritetype *pSprite) +void CViewMap::Process(int nX, int nY, short nAng) { nZoom = gZoom; if (bFollowMode) { - x = pSprite->x; - y = pSprite->y; - angle = pSprite->ang; + x = nX; + y = nY; + angle = nAng; } else { diff --git a/source/blood/src/map2d.h b/source/blood/src/map2d.h index 74b8ec3bcb..fa924612cc 100644 --- a/source/blood/src/map2d.h +++ b/source/blood/src/map2d.h @@ -34,7 +34,7 @@ class CViewMap { CViewMap(); void Init(int, int, int, short, char); void Draw(void); - void Process(spritetype *pSprite); + void Process(int nX, int nY, short nAng); void SetPos(int *, int*); void FollowMode(char); }; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index bb58633325..96c68666c9 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -3899,7 +3899,35 @@ void viewDrawScreen(void) } if (gViewMode == 4) { - gViewMap.Process(gView->pSprite); + int cX = 0, cY = 0, nAng = 0; + if (gViewMap.bFollowMode) // calculate get current player position for 2d map for follow mode + { + cX = gView->pSprite->x, cY = gView->pSprite->y, nAng = gView->pSprite->ang; + if (!VanillaMode()) // interpolate angle for 2d map view + { + fix16_t cA = gView->q16ang; + if (gViewInterpolate) + { + if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0) + { + cX = interpolate(predictOld.at50, predict.at50, gInterpolate); + cY = interpolate(predictOld.at54, predict.at54, gInterpolate); + cA = interpolateangfix16(predictOld.at30, predict.at30, gInterpolate); + } + else + { + VIEW *pView = &gPrevView[gViewIndex]; + cX = interpolate(pView->at50, cX, gInterpolate); + cY = interpolate(pView->at54, cY, gInterpolate); + cA = interpolateangfix16(pView->at30, cA, gInterpolate); + } + } + if (gView == gMe && (numplayers <= 1 || gPrediction) && gView->pXSprite->health != 0) + cA = gViewAngle; + nAng = fix16_to_int(cA); + } + } + gViewMap.Process(cX, cY, nAng); } viewDrawInterface(delta); int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220; From b70038862a3e042d9191c75ca656c93667be91dc Mon Sep 17 00:00:00 2001 From: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com> Date: Thu, 3 Aug 2023 03:35:25 +1000 Subject: [PATCH 2/2] Fix edge case when actively editing multiple CGameMenuItemZEdit items --- source/blood/src/gamemenu.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blood/src/gamemenu.cpp b/source/blood/src/gamemenu.cpp index 81682b1289..9eca8fd5ce 100644 --- a/source/blood/src/gamemenu.cpp +++ b/source/blood/src/gamemenu.cpp @@ -1906,6 +1906,7 @@ void CGameMenuItemZEdit::Draw(void) bool CGameMenuItemZEdit::Event(CGameMenuEvent &event) { static char buffer[256]; + static CGameMenuItemZEdit *pGameMenuItemZEdit = NULL; // Hack if (event.at2 == sc_kpad_2 || event.at2 == sc_kpad_4 || event.at2 == sc_kpad_6 || event.at2 == sc_kpad_8) event.at0 = kMenuEventKey; @@ -1917,6 +1918,7 @@ bool CGameMenuItemZEdit::Event(CGameMenuEvent &event) strncpy(at20, buffer, at24); at20[at24-1] = 0; at30 = 0; + pGameMenuItemZEdit = NULL; return false; } return true; @@ -1934,6 +1936,13 @@ bool CGameMenuItemZEdit::Event(CGameMenuEvent &event) at30 = 0; return false; } + else // unselect previously edited item + { + if (!pGameMenuItemZEdit) + pGameMenuItemZEdit = this; + else if (pGameMenuItemZEdit != this) + pGameMenuItemZEdit->at30 = 0, pGameMenuItemZEdit = this; + } strncpy(buffer, at20, at24); buffer[at24-1] = 0; at30 = 1;