From f3159af211f6aa052863f57a6761eb6c22c1b984 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 19 Jan 2017 18:48:21 -0500 Subject: [PATCH 01/16] - fixed: Remove ccmd should check if an object is actually an inventory object before attempting to check its owner. (Ooops!) --- src/d_net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index d9eca7a43..6e1d4436e 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2110,7 +2110,7 @@ static int RemoveClass(const PClass *cls) continue; } // [SP] Don't remove owned inventory objects. - if (static_cast(actor)->Owner != NULL) + if (actor->IsKindOf(RUNTIME_CLASS(AInventory)) && static_cast(actor)->Owner != NULL) { continue; } From f5421491ec05a7e7a8b355581fcace2e3e530e65 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 10:51:21 +0100 Subject: [PATCH 02/16] - wrapped the entire DSBarInfo class in a container and completely decoupled it from DBaseStatusBar. The idea is, when status bars are moved to ZScript that only this small wrapper class needs to be dealt with and the implementation can be left alone. SBARINFO is far too complex to be scriptified, but having it inherit directly from DBaseStatusBar and access its member variables severely limits the options of dealing with the status bar code. This way, it only accesses some globally visible functions in DBaseStatusBar and no variables. - renamed the global ST_X and ST_Y variables because it is far too confusing and error-prone to have the same names inside and outside DBaseStatusBar. --- src/am_map.cpp | 6 +- src/ct_chat.cpp | 4 +- src/d_main.cpp | 6 +- src/g_shared/sbar.h | 11 +- src/g_shared/sbarinfo.cpp | 211 +++++++++++++++++++++-------- src/g_shared/sbarinfo.h | 23 ++++ src/g_shared/sbarinfo_commands.cpp | 4 +- src/g_shared/shared_sbar.cpp | 26 ++-- src/hu_scores.cpp | 2 +- src/r_utility.cpp | 4 +- src/st_stuff.h | 4 +- src/v_draw.cpp | 4 +- 12 files changed, 213 insertions(+), 92 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index a20998526..f7f140f4d 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1059,7 +1059,7 @@ static void AM_findMinMaxBoundaries () static void AM_calcMinMaxMtoF() { double a = SCREENWIDTH / max_w; - double b = ::ST_Y / max_h; + double b = gST_Y / max_h; min_scale_mtof = a < b ? a : b; max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS); @@ -1417,7 +1417,7 @@ void AM_NewResolution() else if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); f_w = screen->GetWidth(); - f_h = ST_Y; + f_h = gST_Y; AM_activateNewScale(); } @@ -3066,7 +3066,7 @@ void AM_Drawer () // and view size adjustments. f_x = f_y = 0; f_w = screen->GetWidth (); - f_h = ST_Y; + f_h = gST_Y; f_p = screen->GetPitch (); AM_clearFB(AMColors[AMColors.Background]); diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index 971c94a38..9d54a5991 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -241,13 +241,13 @@ void CT_Drawer (void) { screen_width = SCREENWIDTH; screen_height = SCREENHEIGHT; - st_y = ST_Y; + st_y = gST_Y; } else { screen_width = SCREENWIDTH / active_con_scaletext(); screen_height = SCREENHEIGHT / active_con_scaletext(); - st_y = ST_Y / active_con_scaletext(); + st_y = gST_Y / active_con_scaletext(); } y += ((SCREENHEIGHT == viewheight && viewactive) || gamestate != GS_LEVEL) ? screen_height : st_y; diff --git a/src/d_main.cpp b/src/d_main.cpp index 887923260..971e0ece0 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -787,13 +787,13 @@ void D_Display () screen->DrawBlendingRect(); if (automapactive) { - int saved_ST_Y = ST_Y; + int saved_ST_Y = gST_Y; if (hud_althud && viewheight == SCREENHEIGHT) { - ST_Y = viewheight; + gST_Y = viewheight; } AM_Drawer (); - ST_Y = saved_ST_Y; + gST_Y = saved_ST_Y; } if (!automapactive || viewactive) { diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index 414d2a730..16e230790 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -307,6 +307,7 @@ enum class DBaseStatusBar : public DObject { + friend class DSBarInfo; DECLARE_CLASS (DBaseStatusBar, DObject) HAS_OBJECT_POINTERS public: @@ -342,8 +343,6 @@ public: DBaseStatusBar (int reltop, int hres=320, int vres=200); void OnDestroy() override; - void SetScaled (bool scale, bool force=false); - void AttachMessage (DHUDMessage *msg, uint32 id=0, int layer=HUDMSGLayer_Default); DHUDMessage *DetachMessage (DHUDMessage *msg); DHUDMessage *DetachMessage (uint32 id); @@ -357,6 +356,7 @@ public: // do not make this a DObject Serialize function because it's not used like one! void SerializeMessages(FSerializer &arc); + virtual void SetScaled(bool scale, bool force = false); virtual void Tick (); virtual void Draw (EHudState state); void DrawBottomStuff (EHudState state); @@ -375,6 +375,13 @@ public: virtual void SetMugShotState (const char *state_name, bool wait_till_done=false, bool reset=false); void DrawLog(); + void GetCoords(int &x, int &y) + { + x = ST_X; + y = ST_Y; + } + + protected: void DrawPowerups (); diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index fe22c3b9c..dadfc0a11 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -970,17 +970,16 @@ inline void adjustRelCenter(bool relX, bool relY, const double &x, const double outY = y; } -class DSBarInfo : public DBaseStatusBar +class DSBarInfo { - DECLARE_CLASS(DSBarInfo, DBaseStatusBar) - HAS_OBJECT_POINTERS public: - DSBarInfo (SBarInfo *script=NULL) : DBaseStatusBar(script->height, script->resW, script->resH), + DSBarInfo (DBaseStatusBar *wrapper, SBarInfo *script=NULL) : ammo1(NULL), ammo2(NULL), ammocount1(0), ammocount2(0), armor(NULL), - pendingPopup(POP_None), currentPopup(POP_None), lastHud(-1), + pendingPopup(DBaseStatusBar::POP_None), currentPopup(DBaseStatusBar::POP_None), lastHud(-1), scalingWasForced(false), lastInventoryBar(NULL), lastPopup(NULL) { this->script = script; + this->wrapper = wrapper; static const char *InventoryBarLumps[] = { @@ -1001,8 +1000,6 @@ public: } invBarOffset = script->Images.Size(); Images.Init(&patchnames[0], patchnames.Size()); - - CompleteBorder = script->completeBorder; } ~DSBarInfo () @@ -1010,9 +1007,18 @@ public: Images.Uninit(); } - void ScreenSizeChanged() override + void _SetScaled(bool scaled) + { + Scaled = scaled; + } + + void _AttachToPlayer(player_t *player) + { + CPlayer = player; + } + + void _ScreenSizeChanged() { - Super::ScreenSizeChanged(); if (uiscale > 0) { script->cleanX = uiscale; @@ -1024,13 +1030,13 @@ public: } } - void Draw (EHudState state) override + void _Draw (EHudState state) { - DBaseStatusBar::Draw(state); if (script->cleanX <= 0) { // Calculate cleanX and cleanY - ScreenSizeChanged(); + wrapper->ScreenSizeChanged(); } + wrapper->GetCoords(ST_X, ST_Y); int hud = STBAR_NORMAL; if(state == HUD_StatusBar) { @@ -1059,13 +1065,13 @@ public: else if(!Scaled) { scalingWasForced = true; - SetScaled(true, true); + wrapper->SetScaled(true, true); setsizeneeded = true; } } //prepare ammo counts - GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2); + wrapper->GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2); armor = CPlayer->mo->FindInventory(NAME_BasicArmor); if(state != HUD_AltHud) @@ -1078,12 +1084,12 @@ public: if(scalingWasForced) { scalingWasForced = false; - SetScaled(false); + wrapper->SetScaled(false); setsizeneeded = true; } } - if(currentPopup != POP_None && !script->huds[hud]->FullScreenOffsets()) + if(currentPopup != DBaseStatusBar::POP_None && !script->huds[hud]->FullScreenOffsets()) script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), 1.); else script->huds[hud]->Draw(NULL, this, 0, 0, 1.); @@ -1105,14 +1111,14 @@ public: } // Handle popups - if(currentPopup != POP_None) + if(currentPopup != DBaseStatusBar::POP_None) { int popbar = 0; - if(currentPopup == POP_Log) + if(currentPopup == DBaseStatusBar::POP_Log) popbar = STBAR_POPUPLOG; - else if(currentPopup == POP_Keys) + else if(currentPopup == DBaseStatusBar::POP_Keys) popbar = STBAR_POPUPKEYS; - else if(currentPopup == POP_Status) + else if(currentPopup == DBaseStatusBar::POP_Status) popbar = STBAR_POPUPSTATUS; if(script->huds[popbar] != lastPopup) { @@ -1129,40 +1135,33 @@ public: hud_scale = oldhud_scale; } - void NewGame () override + void _NewGame () { - if (CPlayer != NULL) - { - AttachToPlayer (CPlayer); - - // Reset the huds - script->ResetHuds(); - lastHud = -1; // Reset - } + // Reset the huds + script->ResetHuds(); + lastHud = -1; // Reset } - bool MustDrawLog (EHudState state) override + bool _MustDrawLog (EHudState state) { return script->huds[STBAR_POPUPLOG]->NumCommands() == 0; } - void SetMugShotState (const char *state_name, bool wait_till_done, bool reset) override + void _SetMugShotState (const char *state_name, bool wait_till_done, bool reset) { script->MugShot.SetState(state_name, wait_till_done, reset); } - void Tick () override + void _Tick () { - DBaseStatusBar::Tick(); - script->MugShot.Tick(CPlayer); - if(currentPopup != POP_None) + if(currentPopup != DBaseStatusBar::POP_None) { script->popups[currentPopup-1].tick(); if(script->popups[currentPopup-1].opened == false && script->popups[currentPopup-1].isDoneMoving()) { currentPopup = pendingPopup; - if(currentPopup != POP_None) + if(currentPopup != DBaseStatusBar::POP_None) script->popups[currentPopup-1].open(); } @@ -1175,30 +1174,29 @@ public: lastInventoryBar->Tick(NULL, this, false); } - void ReceivedWeapon(AWeapon *weapon) override + void _ReceivedWeapon(AWeapon *weapon) { script->MugShot.Grin(); } // void DSBarInfo::FlashItem(const PClass *itemtype) - Is defined with CommandDrawSelectedInventory - void FlashItem(const PClass *itemtype) override; + void _FlashItem(const PClass *itemtype); - void ShowPop(int popnum) override + void _ShowPop(int popnum) { - DBaseStatusBar::ShowPop(popnum); if(popnum != currentPopup) { pendingPopup = popnum; } else - pendingPopup = POP_None; - if(currentPopup != POP_None) + pendingPopup = DBaseStatusBar::POP_None; + if(currentPopup != DBaseStatusBar::POP_None) script->popups[currentPopup-1].close(); else { currentPopup = pendingPopup; - pendingPopup = POP_None; - if(currentPopup != POP_None) + pendingPopup = DBaseStatusBar::POP_None; + if(currentPopup != DBaseStatusBar::POP_None) script->popups[currentPopup-1].open(); } } @@ -1519,6 +1517,10 @@ public: AInventory *armor; FImageCollection Images; unsigned int invBarOffset; + player_t *CPlayer = nullptr; + DBaseStatusBar *wrapper; + bool Scaled; + int ST_X, ST_Y; private: SBarInfo *script; @@ -1530,20 +1532,6 @@ private: SBarInfoMainBlock *lastPopup; }; -IMPLEMENT_CLASS(DSBarInfo, false, true) - -IMPLEMENT_POINTERS_START(DSBarInfo) - IMPLEMENT_POINTER(ammo1) - IMPLEMENT_POINTER(ammo2) - IMPLEMENT_POINTER(armor) -IMPLEMENT_POINTERS_END - -DBaseStatusBar *CreateCustomStatusBar (int script) -{ - if(SBarInfoScript[script] == NULL) - I_FatalError("Tried to create a status bar with no script!"); - return new DSBarInfo(SBarInfoScript[script]); -} void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { @@ -1562,7 +1550,7 @@ void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statu else if(!statusBar->Scaled) { rescale = true; - statusBar->SetScaled(true, true); + statusBar->wrapper->SetScaled(true, true); } } @@ -1573,8 +1561,111 @@ void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statu if(FullScreenOffsets()) hud_scale = false; else - statusBar->SetScaled(false); + statusBar->wrapper->SetScaled(false); } } #include "sbarinfo_commands.cpp" + + +//========================================================================== +// +// SBarinfoWrapper +// +// This class abstracts SBARINFO from the rest of the engine. +// The idea is, when status bars are moved to ZScript that only +// this small wrapper class needs to be dealt with and the implementation +// can be left alone. +// +//========================================================================== + + +DSBarInfoWrapper::DSBarInfoWrapper(SBarInfo *script) + : DBaseStatusBar(script->height, script->resW, script->resH) +{ + core = new DSBarInfo(this, script); + core->_SetScaled(Scaled); + CompleteBorder = script->completeBorder; +} + +void DSBarInfoWrapper::OnDestroy() +{ + if (core != nullptr) delete core; + Super::OnDestroy(); +} + +void DSBarInfoWrapper::SetScaled(bool scale, bool force) +{ + Super::SetScaled(scale, force); + core->_SetScaled(scale); +} + +void DSBarInfoWrapper::AttachToPlayer(player_t *player) +{ + Super::AttachToPlayer(player); + core->_AttachToPlayer(player); +} + +void DSBarInfoWrapper::ScreenSizeChanged() +{ + Super::ScreenSizeChanged(); + core->_ScreenSizeChanged(); +} + +void DSBarInfoWrapper::Draw(EHudState state) +{ + Super::Draw(state); + core->_Draw(state); +} + +void DSBarInfoWrapper::NewGame() +{ + Super::NewGame(); + if (CPlayer != NULL) + { + AttachToPlayer(CPlayer); + core->_NewGame(); + } +} + +bool DSBarInfoWrapper::MustDrawLog(EHudState state) +{ + return core->_MustDrawLog(state); +} + +void DSBarInfoWrapper::SetMugShotState(const char *state_name, bool wait_till_done, bool reset) +{ + core->_SetMugShotState(state_name, wait_till_done, reset); +} + +void DSBarInfoWrapper::Tick() +{ + DBaseStatusBar::Tick(); + core->_Tick(); +} + +void DSBarInfoWrapper::ReceivedWeapon(AWeapon *weapon) +{ + core->_ReceivedWeapon(weapon); +} + +void DSBarInfoWrapper::FlashItem(const PClass *itemtype) +{ + core->_FlashItem(itemtype); +} + +void DSBarInfoWrapper::ShowPop(int popnum) +{ + DBaseStatusBar::ShowPop(popnum); //DBaseStatusBar supercall + core->_ShowPop(popnum); +} + +IMPLEMENT_CLASS(DSBarInfoWrapper, false, false) + +DBaseStatusBar *CreateCustomStatusBar(int script) +{ + if (SBarInfoScript[script] == NULL) + I_FatalError("Tried to create a status bar with no script!"); + return new DSBarInfoWrapper(SBarInfoScript[script]); +} + diff --git a/src/g_shared/sbarinfo.h b/src/g_shared/sbarinfo.h index f5dcb4abd..c7a970792 100644 --- a/src/g_shared/sbarinfo.h +++ b/src/g_shared/sbarinfo.h @@ -129,4 +129,27 @@ struct SBarInfo #define SCRIPT_DEFAULT 1 extern SBarInfo *SBarInfoScript[2]; +class DSBarInfoWrapper : public DBaseStatusBar +{ + DSBarInfo *core; + DECLARE_CLASS(DSBarInfoWrapper, DBaseStatusBar) +public: + DSBarInfoWrapper() : DBaseStatusBar(10, 10, 10) { core = nullptr; } + DSBarInfoWrapper(SBarInfo *script); + void OnDestroy() override; + void SetScaled(bool scale, bool force); + void AttachToPlayer(player_t *player) override; + + void ScreenSizeChanged() override; + void Draw(EHudState state) override; + void NewGame() override; + bool MustDrawLog(EHudState state) override; + void SetMugShotState(const char *state_name, bool wait_till_done, bool reset) override; + void Tick() override; + void ReceivedWeapon(AWeapon *weapon) override; + void FlashItem(const PClass *itemtype) override; + void ShowPop(int popnum) override; +}; + + #endif //__SBarInfo_SBAR_H__ diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 8cb90a350..5e12bf9d0 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -1818,7 +1818,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra int CommandDrawSelectedInventory::artiflashTick = 0; double CommandDrawSelectedInventory::itemflashFade = 0.75; -void DSBarInfo::FlashItem(const PClass *itemtype) +void DSBarInfo::_FlashItem(const PClass *itemtype) { CommandDrawSelectedInventory::Flash(); } @@ -2190,7 +2190,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand AInventory *item; unsigned int i = 0; // If the player has no artifacts, don't draw the bar - statusBar->CPlayer->mo->InvFirst = statusBar->ValidateInvFirst(size); + statusBar->CPlayer->mo->InvFirst = statusBar->wrapper->ValidateInvFirst(size); if(statusBar->CPlayer->mo->InvFirst != NULL || alwaysShow) { for(item = statusBar->CPlayer->mo->InvFirst, i = 0; item != NULL && i < size; item = item->NextInv(), ++i) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 8719a7833..363a17bd8 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -86,7 +86,7 @@ DBaseStatusBar *StatusBar; extern int setblocks; -int ST_X, ST_Y; +int gST_X, gST_Y; int SB_state = 3; FTexture *CrosshairImage; @@ -292,7 +292,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) { ST_X = (SCREENWIDTH - HorizontalResolution) / 2; ST_Y = SCREENHEIGHT - RelTop; - ::ST_Y = ST_Y; + gST_Y = ST_Y; if (RelTop > 0) { Displacement = double((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))/RelTop; @@ -309,16 +309,16 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); if (!AspectTallerThanWide(aspect)) { // Normal resolution - ::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); + gST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); } else { // 5:4 resolution - ::ST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2 + gST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2 + (SCREENHEIGHT - SCREENHEIGHT * AspectMultiplier(aspect) / 48) / 2; } Displacement = 0; } - ::ST_X = ST_X; + gST_X = ST_X; ST_SetNeedRefresh(); } @@ -1047,7 +1047,7 @@ void DBaseStatusBar::RefreshBackground () const float ratio = ActiveRatio (SCREENWIDTH, SCREENHEIGHT); x = (ratio < 1.5f || !Scaled) ? ST_X : SCREENWIDTH*(48-AspectMultiplier(ratio))/(48*2); - y = x == ST_X && x > 0 ? ST_Y : ::ST_Y; + y = x == ST_X && x > 0 ? ST_Y : gST_Y; if(!CompleteBorder) { @@ -1255,21 +1255,21 @@ void DBaseStatusBar::Draw (EHudState state) vwidth = SCREENWIDTH; vheight = SCREENHEIGHT; xpos = vwidth - 80; - y = ::ST_Y - height; + y = gST_Y - height; } else if (active_con_scaletext() > 1) { vwidth = SCREENWIDTH / active_con_scaletext(); vheight = SCREENHEIGHT / active_con_scaletext(); xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = ::ST_Y/4 - height; + y = gST_Y/4 - height; } else { vwidth = SCREENWIDTH/2; vheight = SCREENHEIGHT/2; xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = ::ST_Y/2 - height; + y = gST_Y/2 - height; } if (gameinfo.gametype == GAME_Strife) @@ -1325,7 +1325,7 @@ void DBaseStatusBar::Draw (EHudState state) } // Draw map name - y = ::ST_Y - height; + y = gST_Y - height; if (gameinfo.gametype == GAME_Heretic && SCREENWIDTH > 320 && !Scaled) { y -= 8; @@ -1476,7 +1476,7 @@ void DBaseStatusBar::SetMugShotState(const char *stateName, bool waitTillDone, b void DBaseStatusBar::DrawBottomStuff (EHudState state) { - DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? ::ST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); } //--------------------------------------------------------------------------- @@ -1498,9 +1498,9 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) DrawPowerups (); if (automapactive && !viewactive) { - DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? ::ST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); } - DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? ::ST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); DrawConsistancy (); DrawWaiting (); if (ShowLog && MustDrawLog(state)) DrawLog (); diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 1164eaf1c..2b752bda4 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -252,7 +252,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER lineheight = MAX(height, maxiconheight * CleanYfac); ypadding = (lineheight - height + 1) / 2; - bottom = ST_Y; + bottom = gST_Y; y = MAX(48*CleanYfac, (bottom - MAXPLAYERS * (height + CleanYfac + 1)) / 2); HU_DrawTimeRemaining (bottom - height); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 2cc422beb..d2358d8b3 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -273,13 +273,13 @@ void R_ExecuteSetViewSize () setsizeneeded = false; V_SetBorderNeedRefresh(); - R_SetWindow (setblocks, SCREENWIDTH, SCREENHEIGHT, ST_Y); + R_SetWindow (setblocks, SCREENWIDTH, SCREENHEIGHT, gST_Y); // Handle resize, e.g. smaller view windows with border and/or status bar. viewwindowx = (screen->GetWidth() - viewwidth) >> 1; // Same with base row offset. - viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (ST_Y - viewheight) >> 1; + viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (gST_Y - viewheight) >> 1; } //========================================================================== diff --git a/src/st_stuff.h b/src/st_stuff.h index b895cc620..c95c6e801 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -26,8 +26,8 @@ struct event_t; -extern int ST_X; -extern int ST_Y; +extern int gST_X; +extern int gST_Y; bool ST_Responder(event_t* ev); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index fce5f50b4..3d4954ed2 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1662,10 +1662,10 @@ static void V_DrawViewBorder (void) V_DrawBorder (0, 0, SCREENWIDTH, viewwindowy); V_DrawBorder (0, viewwindowy, viewwindowx, viewheight + viewwindowy); V_DrawBorder (viewwindowx + viewwidth, viewwindowy, SCREENWIDTH, viewheight + viewwindowy); - V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, ST_Y); + V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, gST_Y); V_DrawFrame (viewwindowx, viewwindowy, viewwidth, viewheight); - V_MarkRect (0, 0, SCREENWIDTH, ST_Y); + V_MarkRect (0, 0, SCREENWIDTH, gST_Y); } //========================================================================== From 02cfdbc29c016616f1dd3c47314c248b8b15cd77 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 11:59:12 +0100 Subject: [PATCH 03/16] - fixed: A_ClearRefire was copied to the wrong script class. --- wadsrc/static/zscript/inventory/stateprovider.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wadsrc/static/zscript/inventory/stateprovider.txt b/wadsrc/static/zscript/inventory/stateprovider.txt index 3f4f1fcda..6f52f6696 100644 --- a/wadsrc/static/zscript/inventory/stateprovider.txt +++ b/wadsrc/static/zscript/inventory/stateprovider.txt @@ -25,12 +25,6 @@ class CustomInventory : StateProvider // //--------------------------------------------------------------------------- - action void A_ClearReFire() - { - if (NULL != player) player.refire = 0; - } - - // This is only here, because these functions were originally exported on Inventory, despite only working for weapons, so this is here to satisfy some potential old mods having called it through CustomInventory. deprecated action void A_GunFlash(statelabel flash = null, int flags = 0) {} deprecated action void A_Lower() {} @@ -81,4 +75,9 @@ class CustomInventory : StateProvider return useok; } + action void A_ClearReFire() + { + if (NULL != player) player.refire = 0; + } + } From 314e49f791c4837b60a12ce0ef4f4208ad272bfa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 12:39:51 +0100 Subject: [PATCH 04/16] - let A_SpawnProjectile, A_FireProjectile, A_SpawnItem(Ex) and A_ThrowGrenade return the spawned actors to the calling code. - fixed the return type checks in CallStateChain. These made some bogus assumptions about what return prototypes to support and would have skipped any multi-return function whose first argument was actually usable. --- src/p_actionfunctions.cpp | 105 +++++++++++------- src/scripting/vm/vm.h | 1 - wadsrc/static/zscript/actor.txt | 8 +- .../zscript/inventory/stateprovider.txt | 2 +- 4 files changed, 69 insertions(+), 47 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 65f7be9a1..8b5916207 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -160,27 +160,23 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) // we don't care about), we pretend they return true, // thanks to the values set just above. - if (proto->ReturnTypes.Size() == 1) - { - if (proto->ReturnTypes[0] == TypeState) - { // Function returns a state - wantret = &ret[0]; - retval = false; // this is a jump function which never affects the success state. - } - else if (proto->ReturnTypes[0] == TypeSInt32 || proto->ReturnTypes[0] == TypeBool) - { // Function returns an int or bool - wantret = &ret[1]; - } - numret = 1; + if (proto->ReturnTypes.Size() >= 2 && + proto->ReturnTypes[0] == TypeState && + (proto->ReturnTypes[1] == TypeSInt32 || proto->ReturnTypes[0] == TypeUInt32 || proto->ReturnTypes[1] == TypeBool)) + { // Function returns a state and an int or bool + wantret = &ret[0]; + numret = 2; } - else if (proto->ReturnTypes.Size() == 2) - { - if (proto->ReturnTypes[0] == TypeState && - (proto->ReturnTypes[1] == TypeSInt32 || proto->ReturnTypes[1] == TypeBool)) - { // Function returns a state and an int or bool - wantret = &ret[0]; - numret = 2; - } + else if (proto->ReturnTypes.Size() == 1 && proto->ReturnTypes[0] == TypeState) + { // Function returns a state + wantret = &ret[0]; + retval = false; // this is a jump function which never affects the success state. + } + else if (proto->ReturnTypes.Size() >= 1 && + (proto->ReturnTypes[0] == TypeSInt32 || proto->ReturnTypes[0] == TypeUInt32 || proto->ReturnTypes[0] == TypeBool)) + { // Function returns an int or bool + wantret = &ret[1]; + numret = 1; } try { @@ -1464,7 +1460,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProjectile) int aimmode = flags & CMF_AIMMODE; AActor * targ; - AActor * missile; + AActor * missile = nullptr; if (ref != NULL || aimmode == 2) { @@ -1576,7 +1572,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProjectile) if (self->SeeState != NULL && (self->health > 0 || !(self->flags3 & MF3_ISMONSTER))) self->SetState(self->SeeState); } - return 0; + ACTION_RETURN_OBJECT(missile); } //========================================================================== @@ -1990,7 +1986,7 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_FireProjectile) PARAM_ANGLE_DEF (pitch); if (!self->player) - return 0; + ACTION_RETURN_OBJECT(nullptr); player_t *player = self->player; AWeapon *weapon = player->ReadyWeapon; @@ -2000,7 +1996,7 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_FireProjectile) if (useammo && ACTION_CALL_FROM_PSPRITE() && weapon) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) - return 0; // out of ammo + ACTION_RETURN_OBJECT(nullptr); // out of ammo } if (ti) @@ -2032,8 +2028,9 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_FireProjectile) misl->VelFromAngle(misl->VelXYToSpeed()); } } + ACTION_RETURN_OBJECT(misl); } - return 0; + ACTION_RETURN_OBJECT(nullptr); } @@ -2861,17 +2858,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnItem) PARAM_FLOAT_DEF (distance) PARAM_FLOAT_DEF (zheight) PARAM_BOOL_DEF (useammo) - PARAM_BOOL_DEF (transfer_translation) + PARAM_BOOL_DEF (transfer_translation); + + if (numret > 1) ret[1].SetPointer(nullptr, ATAG_OBJECT); if (missile == NULL) { - ACTION_RETURN_BOOL(false); + if (numret > 0) ret[0].SetInt(false); + return MIN(numret, 2); } // Don't spawn monsters if this actor has been massacred if (self->DamageType == NAME_Massacre && (GetDefaultByType(missile)->flags3 & MF3_ISMONSTER)) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } if (ACTION_CALL_FROM_PSPRITE()) @@ -2881,18 +2882,24 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnItem) if (weapon == NULL) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } } AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->Angles.Yaw, -self->Floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE); int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0); - ACTION_RETURN_BOOL(InitSpawnedItem(self, mo, flags)); // for an inventory item's use state + bool res = InitSpawnedItem(self, mo, flags); // for an inventory item's use state + if (numret > 0) ret[0].SetInt(res); + if (numret > 1) ret[1].SetPointer(mo, ATAG_OBJECT); + return MIN(numret, 2); + } //=========================================================================== @@ -2917,18 +2924,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnItemEx) PARAM_INT_DEF (chance) PARAM_INT_DEF (tid) + if (numret > 1) ret[1].SetPointer(nullptr, ATAG_OBJECT); + if (missile == NULL) { - ACTION_RETURN_BOOL(false); + if (numret > 0) ret[0].SetInt(false); + return MIN(numret, 2); } if (chance > 0 && pr_spawnitemex() < chance) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } // Don't spawn monsters if this actor has been massacred if (self->DamageType == NAME_Massacre && (GetDefaultByType(missile)->flags3 & MF3_ISMONSTER)) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } DVector2 pos; @@ -2976,7 +2988,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnItemEx) } mo->Angles.Yaw = angle; } - ACTION_RETURN_BOOL(res); // for an inventory item's use state + if (numret > 0) ret[0].SetInt(res); + if (numret > 1) ret[1].SetPointer(mo, ATAG_OBJECT); + return MIN(numret, 2); } //=========================================================================== @@ -2995,9 +3009,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrowGrenade) PARAM_FLOAT_DEF (zvel) PARAM_BOOL_DEF (useammo) + if (numret > 1) ret[1].SetPointer(nullptr, ATAG_OBJECT); + if (missile == NULL) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(false); + return MIN(numret, 2); } if (ACTION_CALL_FROM_PSPRITE()) { @@ -3006,11 +3023,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrowGrenade) if (weapon == NULL) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) { - ACTION_RETURN_BOOL(true); + if (numret > 0) ret[0].SetInt(true); + return MIN(numret, 2); } } @@ -3049,13 +3068,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrowGrenade) bo->Vel.Z = xy_velz + z_velz; bo->target = self; - P_CheckMissileSpawn (bo, self->radius); + if (!P_CheckMissileSpawn(bo, self->radius)) bo = nullptr; + + if (numret > 0) ret[0].SetInt(true); + if (numret > 1) ret[1].SetPointer(bo, ATAG_OBJECT); + return MIN(numret, 2); } else { - ACTION_RETURN_BOOL(false); + if (numret > 0) ret[0].SetInt(false); + return MIN(numret, 2); } - ACTION_RETURN_BOOL(true); } diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index a9fdf3abe..060fa0a76 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -1148,7 +1148,6 @@ struct AFuncDesc class AActor; - #define ACTION_RETURN_STATE(v) do { FState *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_STATE); return 1; } return 0; } while(0) #define ACTION_RETURN_POINTER(v) do { void *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_GENERIC); return 1; } return 0; } while(0) #define ACTION_RETURN_OBJECT(v) do { auto state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_OBJECT); return 1; } return 0; } while(0) diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 7df019fc3..24afe68e9 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -756,14 +756,14 @@ class Actor : Thinker native deprecated native void A_StopSoundEx(name slot); native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); native action state A_Jump(int chance, statelabel label, ...); - native void A_SpawnProjectile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); + native Actor A_SpawnProjectile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); native void A_CustomBulletAttack(double spread_xy, double spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", double range = 0, int flags = 0, int ptr = AAPTR_TARGET, class missile = null, double Spawnheight = 32, double Spawnofs_xy = 0); native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = 0, color color2 = 0, int flags = 0, int aim = 0, double maxdiff = 0, class pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class spawnclass = null, double spawnofs_z = 0, int spiraloffset = 270, int limit = 0, double veleffect = 3); native bool A_SetInventory(class itemtype, int amount, int ptr = AAPTR_DEFAULT, bool beyondMax = false); native bool A_GiveInventory(class itemtype, int amount = 0, int giveto = AAPTR_DEFAULT); native bool A_TakeInventory(class itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT); - action native bool A_SpawnItem(class itemtype = "Unknown", double distance = 0, double zheight = 0, bool useammo = true, bool transfer_translation = false); - native bool A_SpawnItemEx(class itemtype, double xofs = 0, double yofs = 0, double zofs = 0, double xvel = 0, double yvel = 0, double zvel = 0, double angle = 0, int flags = 0, int failchance = 0, int tid=0); + action native bool, Actor A_SpawnItem(class itemtype = "Unknown", double distance = 0, double zheight = 0, bool useammo = true, bool transfer_translation = false); + native bool, Actor A_SpawnItemEx(class itemtype, double xofs = 0, double yofs = 0, double zofs = 0, double xvel = 0, double yvel = 0, double zvel = 0, double angle = 0, int flags = 0, int failchance = 0, int tid=0); native void A_Print(string whattoprint, double time = 0, name fontname = "none"); native void A_PrintBold(string whattoprint, double time = 0, name fontname = "none"); native void A_Log(string whattoprint, bool local = false); @@ -785,7 +785,7 @@ class Actor : Thinker native native void A_RaiseChildren(bool copy = 0); native void A_RaiseSiblings(bool copy = 0); deprecated native void A_BasicAttack(int meleedamage, sound meleesound, class missiletype, double missileheight); - action native bool A_ThrowGrenade(class itemtype, double zheight = 0, double xyvel = 0, double zvel = 0, bool useammo = true); + action native bool, Actor A_ThrowGrenade(class itemtype, double zheight = 0, double xyvel = 0, double zvel = 0, bool useammo = true); native void A_Weave(int xspeed, int yspeed, double xdist, double ydist); diff --git a/wadsrc/static/zscript/inventory/stateprovider.txt b/wadsrc/static/zscript/inventory/stateprovider.txt index 6f52f6696..dc261eaa9 100644 --- a/wadsrc/static/zscript/inventory/stateprovider.txt +++ b/wadsrc/static/zscript/inventory/stateprovider.txt @@ -4,7 +4,7 @@ class StateProvider : Inventory native action native state A_JumpIfNoAmmo(statelabel label); action native void A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class pufftype = "BulletPuff", double range = 0, double lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = 0, sound MissSound = ""); action native void A_FireBullets(double spread_xy, double spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, double range = 0, class missile = null, double Spawnheight = 32, double Spawnofs_xy = 0); - action native void A_FireProjectile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0); + action native Actor A_FireProjectile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0); action native void A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = 0, color color2 = 0, int flags = 0, double maxdiff = 0, class pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class spawnclass = "none", double spawnofs_z = 0, int spiraloffset = 270, int limit = 0); action native void A_WeaponReady(int flags = 0); From 6168d3ee7c8b0a8572c0edf03a098b48252822f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 14:46:35 +0100 Subject: [PATCH 05/16] - fixed: The BurningBarrel has been replaced with something blue in Freedoom so adjust the light for that. --- wadsrc_lights/static/filter/doom.freedoom/gldefs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc_lights/static/filter/doom.freedoom/gldefs.txt b/wadsrc_lights/static/filter/doom.freedoom/gldefs.txt index 1bb7c2b84..457ae8a00 100644 --- a/wadsrc_lights/static/filter/doom.freedoom/gldefs.txt +++ b/wadsrc_lights/static/filter/doom.freedoom/gldefs.txt @@ -479,7 +479,7 @@ object ShortBlueTorch // Burning barrel flickerlight2 FIREBARREL { - color 1.0 0.9 0.4 + color 0.6 0.6 0.9 size 72 secondarySize 81 interval 0.1 From 302cb41403ceba4f34c8f0cd3f431916e9d13a33 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 17:20:50 +0100 Subject: [PATCH 06/16] - fixed typo in MorphMonster definition. --- src/g_shared/a_morph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index c8220af5a..0c95c77b8 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -443,7 +443,7 @@ bool P_MorphMonster (AActor *actor, PClassActor *spawntype, int duration, int st DEFINE_ACTION_FUNCTION(AActor, MorphMonster) { PARAM_SELF_PROLOGUE(AActor); - PARAM_CLASS(spawntype, APlayerPawn); + PARAM_CLASS(spawntype, AActor); PARAM_INT(duration); PARAM_INT(style); PARAM_CLASS_DEF(enter_flash, AActor); From 4fa5055548d017fe1e964df7e07afa3b759ee23c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 17:23:13 +0100 Subject: [PATCH 07/16] - fixed: With some functions moved to Weapon, Dehacked needs to check Weapon, not StateProvider to find its code pointers. --- src/d_dehacked.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index b9d9b876d..312333676 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -790,7 +790,7 @@ void SetDehParams(FState *state, int codepointer) // Let's identify the codepointer we're dealing with. PFunction *sym; - sym = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(FName(MBFCodePointers[codepointer].name), true)); + sym = dyn_cast(RUNTIME_CLASS(AWeapon)->Symbols.FindSymbol(FName(MBFCodePointers[codepointer].name), true)); if (sym == NULL) return; if (codepointer < 0 || (unsigned)codepointer >= countof(MBFCodePointerFactories)) @@ -2108,7 +2108,7 @@ static int PatchCodePtrs (int dummy) // This skips the action table and goes directly to the internal symbol table // DEH compatible functions are easy to recognize. - PFunction *sym = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(symname, true)); + PFunction *sym = dyn_cast(RUNTIME_CLASS(AWeapon)->Symbols.FindSymbol(symname, true)); if (sym == NULL) { Printf(TEXTCOLOR_RED "Frame %d: Unknown code pointer '%s'\n", frame, Line2); @@ -2717,11 +2717,11 @@ static bool LoadDehSupp () } else { - // all relevant code pointers are either defined in AStateProvider + // all relevant code pointers are either defined in AWeapon // or AActor so this will find all of them. FString name = "A_"; name << sc.String; - PFunction *sym = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(name, true)); + PFunction *sym = dyn_cast(RUNTIME_CLASS(AWeapon)->Symbols.FindSymbol(name, true)); if (sym == NULL) { sc.ScriptError("Unknown code pointer '%s'", sc.String); @@ -3093,7 +3093,7 @@ void FinishDehPatch () { if (AmmoPerAttacks[j].ptr == nullptr) { - auto p = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(AmmoPerAttacks[j].func, true)); + auto p = dyn_cast(RUNTIME_CLASS(AWeapon)->Symbols.FindSymbol(AmmoPerAttacks[j].func, true)); if (p != nullptr) AmmoPerAttacks[j].ptr = p->Variants[0].Implementation; } if (state->ActionFunc == AmmoPerAttacks[j].ptr) From e993f9304bb6c691d7026136f58bf9892af51217 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 20 Jan 2017 14:56:03 +0100 Subject: [PATCH 08/16] - Fixed GCC/Clang compile error. --- src/g_shared/sbarinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/sbarinfo.h b/src/g_shared/sbarinfo.h index c7a970792..638bfb96a 100644 --- a/src/g_shared/sbarinfo.h +++ b/src/g_shared/sbarinfo.h @@ -42,7 +42,7 @@ #define NUMPOPUPS 3 class FScanner; - +class DSBarInfo; class SBarInfoMainBlock; //Popups! From 7adc34932fb7b32a0ab07ef3a7db6a33ffce29c8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 19:55:57 +0100 Subject: [PATCH 09/16] - fixed: The state parameter for CallStateChain was checked for the wrong type. --- src/p_actionfunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 8b5916207..7a4e92eb2 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -223,7 +223,7 @@ DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain) { PARAM_SELF_PROLOGUE(AStateProvider); PARAM_OBJECT(affectee, AActor); - PARAM_STATE(state); + PARAM_POINTER(state, FState); ACTION_RETURN_BOOL(self->CallStateChain(affectee, state)); } From 23a7fd40aa0230827b8ee4ac4790ea83ecd6fd08 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 20:04:57 +0100 Subject: [PATCH 10/16] - fixed: The script wrapper for AActor::TakeInventory erroneously called RemoveInventory, not TakeInventory. --- src/p_mobj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c3bbcf076..0cdd197a8 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -920,11 +920,11 @@ bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate DEFINE_ACTION_FUNCTION(AActor, TakeInventory) { PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(item, AInventory); + PARAM_CLASS_NOT_NULL(item, AInventory); PARAM_INT(amount); PARAM_BOOL_DEF(fromdecorate); PARAM_BOOL_DEF(notakeinfinite); - self->RemoveInventory(item); + self->TakeInventory(item, amount, fromdecorate, notakeinfinite); return 0; } From 06898bf8fb4b17d14aed94454f3846a27a3ffbdf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 20:19:38 +0100 Subject: [PATCH 11/16] - copied A_ClearRefire to the proper place for good now. --- wadsrc/static/zscript/inventory/stateprovider.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wadsrc/static/zscript/inventory/stateprovider.txt b/wadsrc/static/zscript/inventory/stateprovider.txt index dc261eaa9..043af1d50 100644 --- a/wadsrc/static/zscript/inventory/stateprovider.txt +++ b/wadsrc/static/zscript/inventory/stateprovider.txt @@ -11,6 +11,11 @@ class StateProvider : Inventory native action native void A_ReFire(statelabel flash = null); action native state A_CheckForReload(int counter, statelabel label, bool dontincrement = false); action native void A_ResetReloadCounter(); + + action void A_ClearReFire() + { + if (NULL != player) player.refire = 0; + } } class CustomInventory : StateProvider @@ -74,10 +79,4 @@ class CustomInventory : StateProvider } return useok; } - - action void A_ClearReFire() - { - if (NULL != player) player.refire = 0; - } - } From 36e1d71f2b9d44256715fe5f4ea7f3f993e35603 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 22:45:09 +0100 Subject: [PATCH 12/16] - fix spelling error. --- src/g_shared/sbar.h | 2 +- src/g_shared/shared_sbar.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index 16e230790..fa6c53abb 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -409,7 +409,7 @@ public: int ST_X, ST_Y; int RelTop; - int HorizontalResolution, VirticalResolution; + int HorizontalResolution, VerticalResolution; bool Scaled; bool Centering; bool FixedOrigin; diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 363a17bd8..0f01edb27 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -248,7 +248,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres) CPlayer = NULL; ShowLog = false; HorizontalResolution = hres; - VirticalResolution = vres; + VerticalResolution = vres; SetScaled (st_scale); } @@ -282,7 +282,7 @@ void DBaseStatusBar::OnDestroy () //--------------------------------------------------------------------------- //[BL] Added force argument to have forcescaled mean forcescaled. -// - Also, if the VirticalResolution is something other than the default (200) +// - Also, if the VerticalResolution is something other than the default (200) // We should always obey the value of scale. void DBaseStatusBar::SetScaled (bool scale, bool force) { @@ -295,7 +295,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) gST_Y = ST_Y; if (RelTop > 0) { - Displacement = double((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))/RelTop; + Displacement = double((ST_Y * VerticalResolution / SCREENHEIGHT) - (VerticalResolution - RelTop))/RelTop; } else { @@ -305,15 +305,15 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) else { ST_X = 0; - ST_Y = VirticalResolution - RelTop; + ST_Y = VerticalResolution - RelTop; float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); if (!AspectTallerThanWide(aspect)) { // Normal resolution - gST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); + gST_Y = Scale (ST_Y, SCREENHEIGHT, VerticalResolution); } else { // 5:4 resolution - gST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2 + gST_Y = Scale(ST_Y - VerticalResolution/2, SCREENHEIGHT*3, Scale(VerticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2 + (SCREENHEIGHT - SCREENHEIGHT * AspectMultiplier(aspect) / 48) / 2; } Displacement = 0; From 355570198de0f66b41b5bb61ff517f7d60985a4c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jan 2017 22:59:31 +0100 Subject: [PATCH 13/16] - moved statusbar code to a separate directory before starting work on it. --- src/CMakeLists.txt | 16 ++++++++-------- src/{g_shared => g_statusbar}/sbar.h | 0 src/{g_shared => g_statusbar}/sbar_mugshot.cpp | 0 src/{g_shared => g_statusbar}/sbarinfo.cpp | 0 src/{g_shared => g_statusbar}/sbarinfo.h | 0 .../sbarinfo_commands.cpp | 0 src/{g_shared => g_statusbar}/shared_sbar.cpp | 0 src/{g_strife => g_statusbar}/strife_sbar.cpp | 0 8 files changed, 8 insertions(+), 8 deletions(-) rename src/{g_shared => g_statusbar}/sbar.h (100%) rename src/{g_shared => g_statusbar}/sbar_mugshot.cpp (100%) rename src/{g_shared => g_statusbar}/sbarinfo.cpp (100%) rename src/{g_shared => g_statusbar}/sbarinfo.h (100%) rename src/{g_shared => g_statusbar}/sbarinfo_commands.cpp (100%) rename src/{g_shared => g_statusbar}/shared_sbar.cpp (100%) rename src/{g_strife => g_statusbar}/strife_sbar.cpp (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad0f28267..2668356cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -773,8 +773,8 @@ file( GLOB HEADER_FILES ${EXTRA_HEADER_DIRS} fragglescript/*.h g_shared/*.h + g_statusbar/*.h g_inventory/*.h - g_strife/*.h intermission/*.h menu/*.h oplsynth/*.h @@ -818,7 +818,7 @@ set( NOT_COMPILED_SOURCE_FILES ${OTHER_SYSTEM_SOURCES} sc_man_scanner.h sc_man_scanner.re - g_shared/sbarinfo_commands.cpp + g_statusbar/sbarinfo_commands.cpp xlat/xlat_parser.y xlat_parser.c xlat_parser.h @@ -1148,7 +1148,6 @@ set (PCH_SOURCES g_inventory/a_keys.cpp g_inventory/a_pickups.cpp g_inventory/a_weapons.cpp - g_strife/strife_sbar.cpp g_shared/a_action.cpp g_shared/a_decals.cpp g_shared/a_flashfader.cpp @@ -1157,10 +1156,11 @@ set (PCH_SOURCES g_shared/a_quake.cpp g_shared/a_specialspot.cpp g_shared/hudmessages.cpp - g_shared/sbarinfo.cpp - g_shared/sbar_mugshot.cpp g_shared/shared_hud.cpp - g_shared/shared_sbar.cpp + g_statusbar/sbarinfo.cpp + g_statusbar/sbar_mugshot.cpp + g_statusbar/shared_sbar.cpp + g_statusbar/strife_sbar.cpp resourcefiles/ancientzip.cpp resourcefiles/file_7z.cpp resourcefiles/file_grp.cpp @@ -1274,7 +1274,7 @@ endif() target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) include_directories( . - g_strife + g_statusbar g_shared g_inventory oplsynth @@ -1403,7 +1403,6 @@ source_group("External\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/m source_group("External\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/.+") source_group("External\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+") source_group("FraggleScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/fragglescript/.+") -source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+") source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") source_group("Inventory" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_inventory/.+") source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") @@ -1440,6 +1439,7 @@ source_group("Scripting\\Code Generation" REGULAR_EXPRESSION "^${CMAKE_CURRENT_S source_group("Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/vm/.+") source_group("Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/.+") source_group("Shared Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_shared/.+") +source_group("Statusbar" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_statusbar/.+") source_group("Versioning" FILES version.h win32/zdoom.rc) source_group("Xlat" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/xlat/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h) source_group("Source Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h sc_man_scanner.re) diff --git a/src/g_shared/sbar.h b/src/g_statusbar/sbar.h similarity index 100% rename from src/g_shared/sbar.h rename to src/g_statusbar/sbar.h diff --git a/src/g_shared/sbar_mugshot.cpp b/src/g_statusbar/sbar_mugshot.cpp similarity index 100% rename from src/g_shared/sbar_mugshot.cpp rename to src/g_statusbar/sbar_mugshot.cpp diff --git a/src/g_shared/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp similarity index 100% rename from src/g_shared/sbarinfo.cpp rename to src/g_statusbar/sbarinfo.cpp diff --git a/src/g_shared/sbarinfo.h b/src/g_statusbar/sbarinfo.h similarity index 100% rename from src/g_shared/sbarinfo.h rename to src/g_statusbar/sbarinfo.h diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp similarity index 100% rename from src/g_shared/sbarinfo_commands.cpp rename to src/g_statusbar/sbarinfo_commands.cpp diff --git a/src/g_shared/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp similarity index 100% rename from src/g_shared/shared_sbar.cpp rename to src/g_statusbar/shared_sbar.cpp diff --git a/src/g_strife/strife_sbar.cpp b/src/g_statusbar/strife_sbar.cpp similarity index 100% rename from src/g_strife/strife_sbar.cpp rename to src/g_statusbar/strife_sbar.cpp From 74f4171947199fa324873131f3635f0692971464 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jan 2017 00:29:19 +0100 Subject: [PATCH 14/16] - removed several unused draw functions from DBaseStatusBar. --- src/g_statusbar/sbar.h | 8 +- src/g_statusbar/shared_sbar.cpp | 252 -------------------------------- 2 files changed, 1 insertion(+), 259 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index fa6c53abb..f50128fa8 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -385,20 +385,14 @@ public: protected: void DrawPowerups (); - void UpdateRect (int x, int y, int width, int height) const; void DrawImage (FTexture *image, int x, int y, FRemapTable *translation=NULL) const; void DrawDimImage (FTexture *image, int x, int y, bool dimmed) const; - void DrawPartialImage (FTexture *image, int wx, int ww) const; void DrINumber (signed int val, int x, int y, int imgBase=imgINumbers) const; - void DrBNumber (signed int val, int x, int y, int w=3) const; - void DrSmallNumber (int val, int x, int y) const; void DrINumberOuter (signed int val, int x, int y, bool center=false, int w=9) const; - void DrBNumberOuter (signed int val, int x, int y, int w=3) const; void DrBNumberOuterFont (signed int val, int x, int y, int w=3) const; - void DrSmallNumberOuter (int val, int x, int y, bool center) const; - + void RefreshBackground () const; void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 0f01edb27..c299eca38 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -576,28 +576,6 @@ void DBaseStatusBar::DrawDimImage (FTexture *img, } } -//--------------------------------------------------------------------------- -// -// PROC DrawPartialImage -// -// Draws a portion of an image with the status bar's upper-left corner as -// the origin. The image should be the same size as the status bar. -// Used for Doom's status bar. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrawPartialImage (FTexture *img, int wx, int ww) const -{ - if (img != NULL) - { - screen->DrawTexture (img, ST_X, ST_Y, - DTA_WindowLeft, wx, - DTA_WindowRight, wx + ww, - DTA_Bottom320x200, Scaled, - TAG_DONE); - } -} - //--------------------------------------------------------------------------- // // PROC DrINumber @@ -638,97 +616,6 @@ void DBaseStatusBar::DrINumber (signed int val, int x, int y, int imgBase) const DrawImage (Images[imgBase+val], x+18, y); } -//--------------------------------------------------------------------------- -// -// PROC DrBNumber -// -// Draws an x digit number using the big font. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrBNumber (signed int val, int x, int y, int size) const -{ - bool neg; - int i, w; - int power; - FTexture *pic; - - pic = Images[imgBNumbers]; - w = (pic != NULL) ? pic->GetWidth() : 0; - - if (val == 0) - { - if (pic != NULL) - { - DrawImage (pic, x - w, y); - } - return; - } - - if ( (neg = val < 0) ) - { - val = -val; - size--; - } - for (i = size-1, power = 10; i > 0; i--) - { - power *= 10; - } - if (val >= power) - { - val = power - 1; - } - while (val != 0 && size--) - { - x -= w; - pic = Images[imgBNumbers + val % 10]; - val /= 10; - if (pic != NULL) - { - DrawImage (pic, x, y); - } - } - if (neg) - { - pic = Images[imgBNEGATIVE]; - if (pic != NULL) - { - DrawImage (pic, x - w, y); - } - } -} - -//--------------------------------------------------------------------------- -// -// PROC DrSmallNumber -// -// Draws a small three digit number. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrSmallNumber (int val, int x, int y) const -{ - int digit = 0; - - if (val > 999) - { - val = 999; - } - if (val > 99) - { - digit = val / 100; - DrawImage (Images[imgSmNumbers + digit], x, y); - val -= digit * 100; - } - if (val > 9 || digit) - { - digit = val / 10; - DrawImage (Images[imgSmNumbers + digit], x+4, y); - val -= digit * 10; - } - DrawImage (Images[imgSmNumbers + val], x+8, y); -} - //--------------------------------------------------------------------------- // // PROC DrINumberOuter @@ -793,112 +680,6 @@ void DBaseStatusBar::DrINumberOuter (signed int val, int x, int y, bool center, } } -//--------------------------------------------------------------------------- -// -// PROC DrBNumberOuter -// -// Draws a three digit number using the big font outside the status bar. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrBNumberOuter (signed int val, int x, int y, int size) const -{ - int xpos; - int w; - bool negative = false; - FTexture *pic; - - pic = Images[imgBNumbers+3]; - if (pic != NULL) - { - w = pic->GetWidth(); - } - else - { - w = 0; - } - - xpos = x + w/2 + (size-1)*w; - - if (val == 0) - { - pic = Images[imgBNumbers]; - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - pic->GetWidth()/2 + 2, y + 2, - DTA_HUDRules, HUD_Normal, - DTA_AlphaF, HR_SHADOW, - DTA_FillColor, 0, - TAG_DONE); - screen->DrawTexture (pic, xpos - pic->GetWidth()/2, y, - DTA_HUDRules, HUD_Normal, - TAG_DONE); - } - return; - } - else if (val < 0) - { - negative = true; - val = -val; - } - - int oval = val; - int oxpos = xpos; - - // Draw shadow first - while (val != 0) - { - pic = Images[val % 10 + imgBNumbers]; - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - pic->GetWidth()/2 + 2, y + 2, - DTA_HUDRules, HUD_Normal, - DTA_AlphaF, HR_SHADOW, - DTA_FillColor, 0, - TAG_DONE); - } - val /= 10; - xpos -= w; - } - if (negative) - { - pic = Images[imgBNEGATIVE]; - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - pic->GetWidth()/2 + 2, y + 2, - DTA_HUDRules, HUD_Normal, - DTA_AlphaF, HR_SHADOW, - DTA_FillColor, 0, - TAG_DONE); - } - } - - // Then draw the real thing - val = oval; - xpos = oxpos; - while (val != 0) - { - pic = Images[val % 10 + imgBNumbers]; - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - pic->GetWidth()/2, y, - DTA_HUDRules, HUD_Normal, - TAG_DONE); - } - val /= 10; - xpos -= w; - } - if (negative) - { - pic = Images[imgBNEGATIVE]; - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - pic->GetWidth()/2, y, - DTA_HUDRules, HUD_Normal, - TAG_DONE); - } - } -} //--------------------------------------------------------------------------- // @@ -1001,39 +782,6 @@ void DBaseStatusBar::DrBNumberOuterFont (signed int val, int x, int y, int size) } } -//--------------------------------------------------------------------------- -// -// PROC DrSmallNumberOuter -// -// Draws a small three digit number outside the status bar. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrSmallNumberOuter (int val, int x, int y, bool center) const -{ - int digit = 0; - - if (val > 999) - { - val = 999; - } - if (val > 99) - { - digit = val / 100; - screen->DrawTexture (Images[imgSmNumbers + digit], x, y, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - val -= digit * 100; - } - if (val > 9 || digit) - { - digit = val / 10; - screen->DrawTexture (Images[imgSmNumbers + digit], x+4, y, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - val -= digit * 10; - } - screen->DrawTexture (Images[imgSmNumbers + val], x+8, y, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); -} //--------------------------------------------------------------------------- // From 274727e8aedd6bd1292214d33cee06e979e05041 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jan 2017 00:41:59 +0100 Subject: [PATCH 15/16] - moved the draw functions which are exclusively used by the Strife status bar into strife_sbar.cpp to get them out of the way. They are not expected to survive anyway. --- src/g_statusbar/sbar.h | 5 - src/g_statusbar/shared_sbar.cpp | 206 -------------------------------- src/g_statusbar/strife_sbar.cpp | 173 +++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 211 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index f50128fa8..cf17a5354 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -388,11 +388,6 @@ protected: void DrawImage (FTexture *image, int x, int y, FRemapTable *translation=NULL) const; void DrawDimImage (FTexture *image, int x, int y, bool dimmed) const; - void DrINumber (signed int val, int x, int y, int imgBase=imgINumbers) const; - - void DrINumberOuter (signed int val, int x, int y, bool center=false, int w=9) const; - void DrBNumberOuterFont (signed int val, int x, int y, int w=3) const; - void RefreshBackground () const; void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index c299eca38..81655d2ab 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -576,212 +576,6 @@ void DBaseStatusBar::DrawDimImage (FTexture *img, } } -//--------------------------------------------------------------------------- -// -// PROC DrINumber -// -// Draws a three digit number. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrINumber (signed int val, int x, int y, int imgBase) const -{ - int oldval; - - if (val > 999) - val = 999; - oldval = val; - if (val < 0) - { - if (val < -9) - { - DrawImage (Images[imgLAME], x+1, y+1); - return; - } - val = -val; - DrawImage (Images[imgBase+val], x+18, y); - DrawImage (Images[imgNEGATIVE], x+9, y); - return; - } - if (val > 99) - { - DrawImage (Images[imgBase+val/100], x, y); - } - val = val % 100; - if (val > 9 || oldval > 99) - { - DrawImage (Images[imgBase+val/10], x+9, y); - } - val = val % 10; - DrawImage (Images[imgBase+val], x+18, y); -} - -//--------------------------------------------------------------------------- -// -// PROC DrINumberOuter -// -// Draws a number outside the status bar, possibly scaled. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrINumberOuter (signed int val, int x, int y, bool center, int w) const -{ - bool negative = false; - - x += w*2; - if (val < 0) - { - negative = true; - val = -val; - } - else if (val == 0) - { - screen->DrawTexture (Images[imgINumbers], x + 1, y + 1, - DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - screen->DrawTexture (Images[imgINumbers], x, y, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - return; - } - - int oval = val; - int ox = x; - - // First the shadow - while (val != 0) - { - screen->DrawTexture (Images[imgINumbers + val % 10], x + 1, y + 1, - DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - x -= w; - val /= 10; - } - if (negative) - { - screen->DrawTexture (Images[imgNEGATIVE], x + 1, y + 1, - DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - } - - // Then the real deal - val = oval; - x = ox; - while (val != 0) - { - screen->DrawTexture (Images[imgINumbers + val % 10], x, y, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - x -= w; - val /= 10; - } - if (negative) - { - screen->DrawTexture (Images[imgNEGATIVE], x, y, - DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); - } -} - - -//--------------------------------------------------------------------------- -// -// PROC DrBNumberOuter -// -// Draws a three digit number using the real big font outside the status bar. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrBNumberOuterFont (signed int val, int x, int y, int size) const -{ - int xpos; - int w, v; - bool negative = false; - FTexture *pic; - - w = 0; - BigFont->GetChar ('0', &w); - - if (w > 1) - { - w--; - } - xpos = x + w/2 + (size-1)*w; - - if (val == 0) - { - pic = BigFont->GetChar ('0', &v); - screen->DrawTexture (pic, xpos - v/2 + 2, y + 2, - DTA_HUDRules, HUD_Normal, - DTA_AlphaF, HR_SHADOW, - DTA_FillColor, 0, - DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED), - TAG_DONE); - screen->DrawTexture (pic, xpos - v/2, y, - DTA_HUDRules, HUD_Normal, - DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED), - TAG_DONE); - return; - } - else if (val < 0) - { - negative = true; - val = -val; - } - - int oval = val; - int oxpos = xpos; - - // First the shadow - while (val != 0) - { - pic = BigFont->GetChar ('0' + val % 10, &v); - screen->DrawTexture (pic, xpos - v/2 + 2, y + 2, - DTA_HUDRules, HUD_Normal, - DTA_AlphaF, HR_SHADOW, - DTA_FillColor, 0, - DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED), - TAG_DONE); - val /= 10; - xpos -= w; - } - if (negative) - { - pic = BigFont->GetChar ('-', &v); - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - v/2 + 2, y + 2, - DTA_HUDRules, HUD_Normal, - DTA_AlphaF, HR_SHADOW, - DTA_FillColor, 0, - DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED), - TAG_DONE); - } - } - - // Then the foreground number - val = oval; - xpos = oxpos; - while (val != 0) - { - pic = BigFont->GetChar ('0' + val % 10, &v); - screen->DrawTexture (pic, xpos - v/2, y, - DTA_HUDRules, HUD_Normal, - DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED), - TAG_DONE); - val /= 10; - xpos -= w; - } - if (negative) - { - pic = BigFont->GetChar ('-', &v); - if (pic != NULL) - { - screen->DrawTexture (pic, xpos - v/2, y, - DTA_HUDRules, HUD_Normal, - DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED), - TAG_DONE); - } - } -} - //--------------------------------------------------------------------------- // diff --git a/src/g_statusbar/strife_sbar.cpp b/src/g_statusbar/strife_sbar.cpp index af06b7474..43624c2fa 100644 --- a/src/g_statusbar/strife_sbar.cpp +++ b/src/g_statusbar/strife_sbar.cpp @@ -845,8 +845,181 @@ private: int CurrentPop, PendingPop, PopHeight, PopHeightChange; int KeyPopPos, KeyPopScroll; double ItemFlash; + + void DrINumberOuter(signed int val, int x, int y, bool center = false, int w = 9) const; + void DrBNumberOuterFont(signed int val, int x, int y, int w = 3) const; + }; +//--------------------------------------------------------------------------- +// +// PROC DrINumberOuter +// +// Draws a number outside the status bar, possibly scaled. +// +//--------------------------------------------------------------------------- + +void DStrifeStatusBar::DrINumberOuter(signed int val, int x, int y, bool center, int w) const +{ + bool negative = false; + + x += w * 2; + if (val < 0) + { + negative = true; + val = -val; + } + else if (val == 0) + { + screen->DrawTexture(Images[imgINumbers], x + 1, y + 1, + DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW, + DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); + screen->DrawTexture(Images[imgINumbers], x, y, + DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); + return; + } + + int oval = val; + int ox = x; + + // First the shadow + while (val != 0) + { + screen->DrawTexture(Images[imgINumbers + val % 10], x + 1, y + 1, + DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW, + DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); + x -= w; + val /= 10; + } + if (negative) + { + screen->DrawTexture(Images[imgNEGATIVE], x + 1, y + 1, + DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW, + DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); + } + + // Then the real deal + val = oval; + x = ox; + while (val != 0) + { + screen->DrawTexture(Images[imgINumbers + val % 10], x, y, + DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); + x -= w; + val /= 10; + } + if (negative) + { + screen->DrawTexture(Images[imgNEGATIVE], x, y, + DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE); + } +} + + +//--------------------------------------------------------------------------- +// +// PROC DrBNumberOuter +// +// Draws a three digit number using the real big font outside the status bar. +// +//--------------------------------------------------------------------------- + +void DStrifeStatusBar::DrBNumberOuterFont(signed int val, int x, int y, int size) const +{ + int xpos; + int w, v; + bool negative = false; + FTexture *pic; + + w = 0; + BigFont->GetChar('0', &w); + + if (w > 1) + { + w--; + } + xpos = x + w / 2 + (size - 1)*w; + + if (val == 0) + { + pic = BigFont->GetChar('0', &v); + screen->DrawTexture(pic, xpos - v / 2 + 2, y + 2, + DTA_HUDRules, HUD_Normal, + DTA_AlphaF, HR_SHADOW, + DTA_FillColor, 0, + DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED), + TAG_DONE); + screen->DrawTexture(pic, xpos - v / 2, y, + DTA_HUDRules, HUD_Normal, + DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED), + TAG_DONE); + return; + } + else if (val < 0) + { + negative = true; + val = -val; + } + + int oval = val; + int oxpos = xpos; + + // First the shadow + while (val != 0) + { + pic = BigFont->GetChar('0' + val % 10, &v); + screen->DrawTexture(pic, xpos - v / 2 + 2, y + 2, + DTA_HUDRules, HUD_Normal, + DTA_AlphaF, HR_SHADOW, + DTA_FillColor, 0, + DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED), + TAG_DONE); + val /= 10; + xpos -= w; + } + if (negative) + { + pic = BigFont->GetChar('-', &v); + if (pic != NULL) + { + screen->DrawTexture(pic, xpos - v / 2 + 2, y + 2, + DTA_HUDRules, HUD_Normal, + DTA_AlphaF, HR_SHADOW, + DTA_FillColor, 0, + DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED), + TAG_DONE); + } + } + + // Then the foreground number + val = oval; + xpos = oxpos; + while (val != 0) + { + pic = BigFont->GetChar('0' + val % 10, &v); + screen->DrawTexture(pic, xpos - v / 2, y, + DTA_HUDRules, HUD_Normal, + DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED), + TAG_DONE); + val /= 10; + xpos -= w; + } + if (negative) + { + pic = BigFont->GetChar('-', &v); + if (pic != NULL) + { + screen->DrawTexture(pic, xpos - v / 2, y, + DTA_HUDRules, HUD_Normal, + DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED), + TAG_DONE); + } + } +} + + + + IMPLEMENT_CLASS(DStrifeStatusBar, false, false); DBaseStatusBar *CreateStrifeStatusBar () From 7e114c1127bdc618d2d3b367d6c9e4b5907b6682 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jan 2017 00:49:54 +0100 Subject: [PATCH 16/16] - moved some more code out of the way. --- src/g_statusbar/sbar.h | 4 +-- src/g_statusbar/shared_sbar.cpp | 42 ------------------------------- src/g_statusbar/strife_sbar.cpp | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index cf17a5354..3c911e693 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -385,9 +385,7 @@ public: protected: void DrawPowerups (); - void DrawImage (FTexture *image, int x, int y, FRemapTable *translation=NULL) const; - void DrawDimImage (FTexture *image, int x, int y, bool dimmed) const; - + void RefreshBackground () const; void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 81655d2ab..a0c825df5 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -535,48 +535,6 @@ void DBaseStatusBar::ShowPlayerName () 1.5f, 0.92f, 0, 0, color, 2.f, 0.35f), MAKE_ID('P','N','A','M')); } -//--------------------------------------------------------------------------- -// -// PROC DrawImage -// -// Draws an image with the status bar's upper-left corner as the origin. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrawImage (FTexture *img, - int x, int y, FRemapTable *translation) const -{ - if (img != NULL) - { - screen->DrawTexture (img, x + ST_X, y + ST_Y, - DTA_Translation, translation, - DTA_Bottom320x200, Scaled, - TAG_DONE); - } -} - -//--------------------------------------------------------------------------- -// -// PROC DrawImage -// -// Draws an optionally dimmed image with the status bar's upper-left corner -// as the origin. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrawDimImage (FTexture *img, - int x, int y, bool dimmed) const -{ - if (img != NULL) - { - screen->DrawTexture (img, x + ST_X, y + ST_Y, - DTA_ColorOverlay, dimmed ? DIM_OVERLAY : 0, - DTA_Bottom320x200, Scaled, - TAG_DONE); - } -} - - //--------------------------------------------------------------------------- // // RefreshBackground diff --git a/src/g_statusbar/strife_sbar.cpp b/src/g_statusbar/strife_sbar.cpp index 43624c2fa..d2511c42d 100644 --- a/src/g_statusbar/strife_sbar.cpp +++ b/src/g_statusbar/strife_sbar.cpp @@ -848,6 +848,8 @@ private: void DrINumberOuter(signed int val, int x, int y, bool center = false, int w = 9) const; void DrBNumberOuterFont(signed int val, int x, int y, int w = 3) const; + void DrawDimImage(FTexture *image, int x, int y, bool dimmed) const; + void DrawImage(FTexture *image, int x, int y, FRemapTable *translation = NULL) const; }; @@ -1017,6 +1019,48 @@ void DStrifeStatusBar::DrBNumberOuterFont(signed int val, int x, int y, int size } } +//--------------------------------------------------------------------------- +// +// PROC DrawImage +// +// Draws an image with the status bar's upper-left corner as the origin. +// +//--------------------------------------------------------------------------- + +void DStrifeStatusBar::DrawImage(FTexture *img, + int x, int y, FRemapTable *translation) const +{ + if (img != NULL) + { + screen->DrawTexture(img, x + ST_X, y + ST_Y, + DTA_Translation, translation, + DTA_Bottom320x200, Scaled, + TAG_DONE); + } +} + +//--------------------------------------------------------------------------- +// +// PROC DrawImage +// +// Draws an optionally dimmed image with the status bar's upper-left corner +// as the origin. +// +//--------------------------------------------------------------------------- + +void DStrifeStatusBar::DrawDimImage(FTexture *img, + int x, int y, bool dimmed) const +{ + if (img != NULL) + { + screen->DrawTexture(img, x + ST_X, y + ST_Y, + DTA_ColorOverlay, dimmed ? DIM_OVERLAY : 0, + DTA_Bottom320x200, Scaled, + TAG_DONE); + } +} + +