Hand-converted the four .vcproj projects to .vcxproj (Win32, v143, Windows 11 SDK + DXSDK June 2010 for d3dx9/dxerr only). WinTesla.sln now builds the v143 projects; the legacy solution is kept as WinTesla_vc9.sln. Kept: /Zp1 in Munga_L4+RP_L4, Unicode, x86, /DYNAMICBASE:NO, /FORCE:MULTIPLE (header-defined globals still duplicated across TUs). Changed: CRT unified to /MD(d); import libs linked by the exes instead of merged into Munga_L4.lib; WINDOWS_IGNORE_PACKING_MISMATCH and _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS defined; legacy_stdio_definitions.lib for the June-2010 dxerr.lib. Source fixes, all behavior-preserving: Time gains standard (non-volatile) copy-ctor/assignment overloads (rvalues cannot bind to volatile& in standard C++); operator==(SOCKADDR_IN&,...) made inline; L4DINPUT's Enum*Callback pair renamed DIEnum* (collided with L4CTRL's under LTCG); std::ios.in -> std::ios::in in CAMMGR.cpp. Verified: VC9 baseline rebuilt from this tree first, then the v143 build compared against it in a sandboxed game working copy - identical logs and behavior through RIO init (against vRIO) and mission load, including the same pre-existing AV in d3d_OBJECT::LoadTexture (L4D3D.cpp:262) that both toolchains hit; documented in BUILD.md 4 as the next debugging target. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
181 lines
3.7 KiB
C++
181 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include "scalar.h"
|
|
|
|
class Time;
|
|
|
|
//##########################################################################
|
|
//######################## System Clock ##############################
|
|
//##########################################################################
|
|
|
|
class SystemClock SIGNATURED
|
|
{
|
|
friend class Time;
|
|
|
|
public:
|
|
friend float Get_Frame_Percent_Used();
|
|
friend volatile Time& Now();
|
|
friend double HiResNow();
|
|
friend __int64 HiResNowTicks();
|
|
friend __int64 HiResCounterFreq();
|
|
static void TogglePause();
|
|
|
|
SystemClock();
|
|
~SystemClock() { Shutdown(); }
|
|
static SystemClock timer;
|
|
void Shutdown();
|
|
static long GetTicksPerSecond() { return ticksPerSecond; }
|
|
|
|
protected:
|
|
long pauseStart;
|
|
long pauseTime;
|
|
static long ticksPerSecond;
|
|
static __int64 perfCounterFreq;
|
|
|
|
static long GetRTC();
|
|
static double GetHiRes();
|
|
static __int64 GetHiResTicks();
|
|
};
|
|
|
|
//##########################################################################
|
|
//############################ Time ##################################
|
|
//##########################################################################
|
|
|
|
class Time
|
|
{
|
|
public:
|
|
long ticks;
|
|
static Time Null;
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int Is_Signature_Bad(const volatile Time *p);
|
|
#endif
|
|
|
|
Time() {}
|
|
// Non-volatile overloads: rvalues (function returns) cannot bind to a
|
|
// volatile reference in standard C++; VC9 allowed it as an extension.
|
|
Time(const Time &t) : ticks(t.ticks) {}
|
|
Time(const volatile Time &t) : ticks(t.ticks) {}
|
|
Time(SystemClock&) : ticks(0) {}
|
|
|
|
Time& operator=(const Time &t)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&t);
|
|
ticks = t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator=(const volatile Time &t)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&t);
|
|
ticks = t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator=(long t)
|
|
{
|
|
Check_Pointer(this);
|
|
ticks = t;
|
|
return *this;
|
|
}
|
|
Time& operator=(Scalar t)
|
|
{
|
|
Check_Pointer(this);
|
|
ticks = Float_To_Time(t);
|
|
return *this;
|
|
}
|
|
|
|
operator Scalar() const volatile
|
|
{
|
|
Check(this);
|
|
return Time_To_Float(ticks);
|
|
}
|
|
operator long() const volatile
|
|
{
|
|
Check(this);
|
|
return ticks;
|
|
}
|
|
|
|
Scalar operator-(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return Time_To_Float(ticks - t.ticks);
|
|
}
|
|
|
|
Time& operator+=(const volatile Time &t)
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
ticks += t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator+=(Scalar t)
|
|
{
|
|
Check(this);
|
|
ticks += Float_To_Time(t);
|
|
return *this;
|
|
}
|
|
Time& operator+=(long t)
|
|
{
|
|
Check(this);
|
|
ticks += t;
|
|
return *this;
|
|
}
|
|
Time& operator-=(const volatile Time &t)
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
ticks -= t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator-=(Scalar t)
|
|
{
|
|
Check(this);
|
|
ticks -= Float_To_Time(t);
|
|
return *this;
|
|
}
|
|
|
|
Logical operator<(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks < t.ticks;
|
|
}
|
|
Logical operator<=(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks <= t.ticks;
|
|
}
|
|
Logical operator>(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks > t.ticks;
|
|
}
|
|
Logical operator>=(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks >= t.ticks;
|
|
}
|
|
|
|
friend std::ostream& operator <<(std::ostream& stream, const volatile Time& t)
|
|
{
|
|
Check(&t);
|
|
return stream << t.ticks;
|
|
}
|
|
|
|
Logical TestInstance() const volatile;
|
|
static Logical TestClass();
|
|
|
|
private:
|
|
static long Float_To_Time(Scalar t) { return (long)(t * SystemClock::ticksPerSecond + 0.5f); }
|
|
static Scalar Time_To_Float(long t) { return (Scalar)(t / (float)SystemClock::ticksPerSecond); }
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Time functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void Convert_From_Ascii(const char *str, Time *time);
|