Adapt code to use MSTimeF().

This commit is contained in:
Mari the Deer 2022-04-29 16:40:57 +02:00
commit b61b4a7dfa
8 changed files with 28 additions and 35 deletions

View file

@ -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"

View file

@ -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"

View file

@ -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();

View file

@ -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");

View file

@ -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 )

View file

@ -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.;

View file

@ -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);
}