From 1cf4ce0d0877404c03c663eb7ceb2ec726b18b13 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 29 Apr 2022 16:40:57 +0200 Subject: [PATCH] Adapt code to use MSTimeF(). --- language.version | 4 ++-- zscript/compat/swwm_hdoom.zsc | 2 +- zscript/compat/swwm_shame.zsc | 2 +- zscript/hud/swwm_hud.zsc | 24 ++++++++++-------------- zscript/menu/swwm_achievementmenu.zsc | 4 ++-- zscript/menu/swwm_menus.zsc | 10 +++++----- zscript/menu/swwm_title.zsc | 2 +- zscript/swwm_handler.zsc | 15 ++++++--------- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/language.version b/language.version index 0bf5129e6..90039360a 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r50 \cu(Thu 28 Apr 21:55:02 CEST 2022)\c-"; -SWWM_SHORTVER="\cw1.3pre r50 \cu(2022-04-28 21:55:02)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r51 \cu(Fri 29 Apr 16:40:57 CEST 2022)\c-"; +SWWM_SHORTVER="\cw1.3pre r51 \cu(2022-04-29 16:40:57)\c-"; diff --git a/zscript/compat/swwm_hdoom.zsc b/zscript/compat/swwm_hdoom.zsc index a55f47df8..e833719bb 100644 --- a/zscript/compat/swwm_hdoom.zsc +++ b/zscript/compat/swwm_hdoom.zsc @@ -26,7 +26,7 @@ Class SWWMHDoomHandler : StaticEventHandler } if ( !detected ) return; - SetRandomSeed[hdscreen](Random[hdscreen]()+consoleplayer+MSTime()); + SetRandomSeed[hdscreen](Random[hdscreen]()+consoleplayer+int(MSTimeF())); Console.Printf( "\cx┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\c-\n" "\cx┃ \cfOh my, someone appears to be \cgH \ckO \cdR \cvN \chY \ct♥ \cx┃\c-\n" diff --git a/zscript/compat/swwm_shame.zsc b/zscript/compat/swwm_shame.zsc index 5a8a91018..f3d395885 100644 --- a/zscript/compat/swwm_shame.zsc +++ b/zscript/compat/swwm_shame.zsc @@ -39,7 +39,7 @@ Class SWWMBrutalHandler : StaticEventHandler } if ( !detected ) return; - SetRandomSeed[bdscreen](Random[bdscreen]()+consoleplayer+MSTime()); + SetRandomSeed[bdscreen](Random[bdscreen]()+consoleplayer+int(MSTimeF())); Console.Printf( "\cx┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\c-\n" "\cx┃ \cfIf you have "..whichshort.." on your autoload you really shouldn't. \cx┃\c-\n" diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index 341588082..62dbd90e5 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -63,7 +63,7 @@ Class SWWMStatusBar : BaseStatusBar int margin; double FracTic; double FrameTime; - int PrevFrame; + double PrevFrame; int chatopen; bool camhidden; int pausetime; @@ -1201,7 +1201,6 @@ Class SWWMStatusBar : BaseStatusBar override void Init() { - Super.Init(); StatusTex = TexMan.CheckForTexture("graphics/HUD/StatusBox.png",TexMan.Type_Any); DashTex = TexMan.CheckForTexture("graphics/HUD/DashBar.png",TexMan.Type_Any); FuelTex[0] = TexMan.CheckForTexture("graphics/HUD/FuelBar.png",TexMan.Type_Any); @@ -1243,7 +1242,7 @@ Class SWWMStatusBar : BaseStatusBar FuelInter = DynamicValueInterpolator.Create(120,.5,1,100); DashInter = DynamicValueInterpolator.Create(120,.5,1,40); hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); - PrevFrame = MSTime(); + PrevFrame = MSTimeF(); } static private string FormatDist( double dist ) @@ -2865,18 +2864,12 @@ Class SWWMStatusBar : BaseStatusBar override void Draw( int state, double TicFrac ) { Super.Draw(state,TicFrac); - int CurFrame = MSTime(); + double CurFrame = MSTimeF(); FrameTime = (CurFrame-PrevFrame)/1000.; - if ( (state != HUD_StatusBar) && (state != HUD_Fullscreen) ) - { - PrevFrame = CurFrame; - return; - } if ( !hnd ) hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); if ( !swwm_camhud && !(players[consoleplayer].Camera is 'PlayerPawn') ) camhidden = true; else camhidden = false; - BeginHUD(); if ( swwm_hudscale ) hs = CleanXFac_1; else hs = max(floor(Screen.GetWidth()/640.),1.); ss = (Screen.GetWidth()/hs,Screen.GetHeight()/hs); @@ -2902,10 +2895,13 @@ Class SWWMStatusBar : BaseStatusBar else { DrawTarget(); - DrawScore(); - DrawInventory(); - DrawStatus(); - DrawWeapon(); + if ( state != HUD_AltHUD ) // proper support for an alt hud will come someday + { + DrawScore(); + DrawInventory(); + DrawStatus(); + DrawWeapon(); + } if ( hnd ) hnd.DrawBossBar(self); DrawPickups(); double malph = DrawDeath(); diff --git a/zscript/menu/swwm_achievementmenu.zsc b/zscript/menu/swwm_achievementmenu.zsc index 30be7a23b..5515afed2 100644 --- a/zscript/menu/swwm_achievementmenu.zsc +++ b/zscript/menu/swwm_achievementmenu.zsc @@ -113,13 +113,13 @@ Class SWWMAchievementMenu : GenericMenu { str = StringTable.Localize("$SWWM_AC_COMPLETE1"); xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2; - Screen.DrawText(newsmallfont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTime()/3.6)),255,255,255)); + Screen.DrawText(newsmallfont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTimeF()/3.6)),255,255,255)); yy += newsmallfont.GetHeight()*CleanYFac_1; // spanish hotfix needed int gnd = players[consoleplayer].GetGender(); str = String.Format(StringTable.Localize("$SWWM_AC_COMPLETE2"),(gnd==1)?"a":""); xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2; - Screen.DrawText(newsmallfont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTime()/3.6)),255,255,255)); + Screen.DrawText(newsmallfont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTimeF()/3.6)),255,255,255)); return; } String str1 = StringTable.Localize("$SWWM_AC_UNLOCKED"); diff --git a/zscript/menu/swwm_menus.zsc b/zscript/menu/swwm_menus.zsc index 3f7bb9af9..d336cd55a 100644 --- a/zscript/menu/swwm_menus.zsc +++ b/zscript/menu/swwm_menus.zsc @@ -282,7 +282,7 @@ Class SWWMMainMenu : SWWMCleanMenu { TextureID demotex, gradtex; double demopos; - transient uint prevms; + double prevms; Font mSmallFont; private TextureID GetDemoTex() @@ -321,14 +321,14 @@ Class SWWMMainMenu : SWWMCleanMenu mSmallFont = Font.GetFont('TewiFont'); demotex = GetDemoTex(); demopos = 120; - prevms = MSTime(); + prevms = MSTimeF(); } override void OnReturn() { demotex = GetDemoTex(); demopos = 120; - prevms = MSTime(); + prevms = MSTimeF(); } private int GetMenuYOffset() @@ -339,7 +339,7 @@ Class SWWMMainMenu : SWWMCleanMenu override void Drawer() { - double frametime = (MSTime()-prevms)/1000.; + double frametime = (MSTimeF()-prevms)/1000.; double theta; // naive, but whatever if ( swwm_oldlogo ) theta = clamp(2.*frametime,0.,1.); @@ -371,7 +371,7 @@ Class SWWMMainMenu : SWWMCleanMenu yy = CleanHeight_1-height; Screen.Dim("Black",.75,int(xx*CleanXFac_1),int(yy*CleanYFac_1),int(width*CleanXFac_1),int(height*CleanYFac_1)); Screen.DrawText(mSmallFont,Font.CR_GOLD,(xx+4)*CleanXFac_1,(yy+2)*CleanYFac_1,str,DTA_CleanNoMove_1,true); - prevms = MSTime(); + prevms = MSTimeF(); } override bool MouseEvent( int type, int x, int y ) diff --git a/zscript/menu/swwm_title.zsc b/zscript/menu/swwm_title.zsc index 3b4c1750e..024cba018 100644 --- a/zscript/menu/swwm_title.zsc +++ b/zscript/menu/swwm_title.zsc @@ -150,7 +150,7 @@ Class SWWMTitleStuff : EventHandler Screen.Dim("Black",1.,0,0,Screen.GetWidth(),Screen.GetHeight()); if ( titletimer < -20 ) { - rss = int(MSTime()*(GameTicRate/1000.)); + rss = int(MSTimeF()*(GameTicRate/1000.)); Vector2 ofs = (RandomShiver(),RandomShiver())*clamp((80+titletimer+e.FracTic)/50.,0.,1.); tsize = TexMan.GetScaledSize(tex[3]); ofs *= tsize.y/10.; diff --git a/zscript/swwm_handler.zsc b/zscript/swwm_handler.zsc index e958f0658..b3ddd9da2 100644 --- a/zscript/swwm_handler.zsc +++ b/zscript/swwm_handler.zsc @@ -35,7 +35,6 @@ Class SWWMHandler : EventHandler double prof_ms[8], prof_avg[8]; int prof_calls[8]; double curms; - //double curns; // will require NSTime() enum EProfileTimer { @@ -51,13 +50,11 @@ Class SWWMHandler : EventHandler private void ProfileTick() { - curms = MSTime(); - //curns = NSTime(); + curms = MSTimeF(); } private void ProfileTock( int idx ) { - double diff = (MSTime()-curms); - //double diff = (NSTime()-curns)/1000000.; + double diff = (MSTimeF()-curms); prof_ms[idx] += diff; prof_avg[idx] = (prof_calls[idx]>0)?(prof_avg[idx]+diff)/2.:diff; prof_calls[idx]++; @@ -66,7 +63,7 @@ Class SWWMHandler : EventHandler override void OnRegister() { // oneliner RNG must be relative to consoleplayer - SetRandomSeed[DemoLines](Random[DemoLines]()+consoleplayer+MSTime()); + SetRandomSeed[DemoLines](Random[DemoLines]()+consoleplayer+int(MSTimeF())); // "uninitialize" some vars iwantdie = -1; bossmap = -1; @@ -170,11 +167,11 @@ Class SWWMHandler : EventHandler Console.Printf("Done!"); String str = String.Format( "SWWMHandler profiling info for %d tic%s:\n" - " event name | calls | total ms | avg ms\n" - "---------------------|-------|-----------|-----------\n", + " event name | calls | total ms | avg ms\n" + "---------------------|--------|-------------|-------------\n", bprofiletics,(bprofiletics>1)?"s":""); for ( int i=0; i<8; i++ ) - str.AppendFormat(" %s | %5d | %9.6f | %9.6f\n",prof_name[i],prof_calls[i],prof_ms[i],prof_avg[i]); + str.AppendFormat(" %s | %6d | %11.6f | %11.6f\n",prof_name[i],prof_calls[i],prof_ms[i],prof_avg[i]); Console.Printf(str); }