Browse Source

Fix UnifiedTime collision

Win32's GetCurrentTime and plUnifiedTime::GetCurrentTime collided. Rather
than hacking around the solution by undefining GetCurrentTime, we rename
plUnifiedTime::GetCurrentTime to plUnifiedTime::GetCurrent. This fix is
less fiddly than an undef hack.
Adam Johnson 12 years ago
parent
commit
5de87cdaca
  1. 10
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  2. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp
  3. 6
      Sources/Plasma/PubUtilLib/plSDL/plSDL.h
  4. 4
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp
  6. 2
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
  7. 6
      Sources/Plasma/PubUtilLib/plUnifiedTime/plClientUnifiedTime.cpp
  8. 2
      Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp
  9. 11
      Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h

10
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -322,7 +322,7 @@ void plNetClientMgr::IDumpOSVersionInfo() const
int plNetClientMgr::Init()
{
int ret=hsOK;
hsLogEntry( DebugMsg("*** plNetClientMgr::Init GMT:%s", plUnifiedTime::GetCurrentTime().Print()) );
hsLogEntry( DebugMsg("*** plNetClientMgr::Init GMT:%s", plUnifiedTime::GetCurrent().Print()) );
IDumpOSVersionInfo();
@ -496,7 +496,7 @@ void plNetClientMgr::UpdateServerTimeOffset(plNetMessage* msg)
const plUnifiedTime& msgSentUT = msg->GetTimeSent();
if (!msgSentUT.AtEpoch())
{
double diff = plUnifiedTime::GetTimeDifference(msgSentUT, plClientUnifiedTime::GetCurrentTime());
double diff = plUnifiedTime::GetTimeDifference(msgSentUT, plUnifiedTime::GetCurrent());
if (fServerTimeOffset == 0)
{
@ -526,13 +526,13 @@ void plNetClientMgr::ResetServerTimeOffset(bool delayed)
plUnifiedTime plNetClientMgr::GetServerTime() const
{
if ( fServerTimeOffset==0 ) // offline mode or before connecting/calibrating to a server
return plUnifiedTime::GetCurrentTime();
return plUnifiedTime::GetCurrent();
plUnifiedTime serverUT;
if (fServerTimeOffset<0)
return plUnifiedTime::GetCurrentTime() - plUnifiedTime(fabs(fServerTimeOffset));
return plUnifiedTime::GetCurrent() - plUnifiedTime(fabs(fServerTimeOffset));
else
return plUnifiedTime::GetCurrentTime() + plUnifiedTime(fServerTimeOffset);
return plUnifiedTime::GetCurrent() + plUnifiedTime(fServerTimeOffset);
}
//

2
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp

@ -424,7 +424,7 @@ int plNetClientMgr::SendMsg(plNetMessage* msg)
msg->SetBit(plNetMessage::kEchoBackToSender, true);
}
msg->SetTimeSent(plUnifiedTime::GetCurrentTime());
msg->SetTimeSent(plUnifiedTime::GetCurrent());
int channel = IPrepMsg(msg);
// hsLogEntry( DebugMsg( "<SND> %s %s", msg->ClassName(), msg->AsStdString().c_str()) );

6
Sources/Plasma/PubUtilLib/plSDL/plSDL.h

@ -154,7 +154,7 @@ public:
void SetDirty(bool d) { if (d) fFlags |= kDirty; else fFlags &= ~kDirty; }
void SetUsed(bool d) { if (d) fFlags |= kUsed; else fFlags &= ~kUsed; }
virtual void SetFromDefaults(bool timeStampNow) = 0;
virtual void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() ) = 0;
virtual void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrent() ) = 0;
virtual const plUnifiedTime& GetTimeStamp() const = 0;
plStateVarNotificationInfo& GetNotificationInfo() { return fNotificationInfo; }
@ -263,7 +263,7 @@ public:
plSDStateVariable* GetAsSDStateVar() { return nil; }
bool operator==(const plSimpleStateVariable &other) const; // assumes matching var descriptors
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() );
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrent() );
void CopyFrom(plVarDescriptor* v);
void CopyData(const plSimpleStateVariable* other, uint32_t writeOptions=0);
bool SetFromString(const plString& value, int idx, bool timeStampNow); // set value from string, type. return false on err
@ -355,7 +355,7 @@ public:
void AddStateDataRecord(plStateDataRecord *sdr) { fDataRecList.push_back(sdr); SetDirty(true); SetUsed(true); }
void InsertStateDataRecord(plStateDataRecord *sdr, int i) { fDataRecList[i] = sdr; SetDirty(true); SetUsed(true);}
void SetFromDefaults(bool timeStampNow);
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() );
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrent() );
const plUnifiedTime& GetTimeStamp() const { static plUnifiedTime foo; return foo; }
void Alloc(int cnt=-1 /* -1 means don't change count */); // wipe and re-create

4
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -318,7 +318,7 @@ void plSimpleStateVariable::CopyFrom(plVarDescriptor* v)
}
}
void plSimpleStateVariable::TimeStamp( const plUnifiedTime & ut/*=plUnifiedTime::GetCurrentTime()*/ )
void plSimpleStateVariable::TimeStamp( const plUnifiedTime & ut/*=plUnifiedTime::GetCurrent()*/ )
{
fTimeStamp = ut;
}
@ -2745,7 +2745,7 @@ void plSDStateVariable::SetFromDefaults(bool timeStampNow)
GetStateDataRecord(i)->SetFromDefaults(timeStampNow);
}
void plSDStateVariable::TimeStamp( const plUnifiedTime & ut/*=plUnifiedTime::GetCurrentTime()*/ )
void plSDStateVariable::TimeStamp( const plUnifiedTime & ut/*=plUnifiedTime::GetCurrent()*/ )
{
hsAssert( false, "not impl" );
}

2
Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp

@ -436,7 +436,7 @@ const wchar_t* plProfileManagerFull::GetProfilePath()
{
initialized = true;
plUnifiedTime curTime = plUnifiedTime::GetCurrentTime(plUnifiedTime::kLocal);
plUnifiedTime curTime = plUnifiedTime::GetCurrent(plUnifiedTime::kLocal);
PathGetUserDirectory(profilePath, arrsize(profilePath));
PathAddFilename(profilePath, profilePath, L"Profile", arrsize(profilePath));

2
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

@ -812,7 +812,7 @@ bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count )
}
if ( fFlags & kTimestampGMT )
{
snprintf(work, arrsize(work), "(%s) ", plUnifiedTime::GetCurrentTime().Format("%m/%d %H:%M:%S UTC").c_str());
snprintf(work, arrsize(work), "(%s) ", plUnifiedTime::GetCurrent().Format("%m/%d %H:%M:%S UTC").c_str());
strncat(buf, work, arrsize(work));
}
if ( fFlags & kTimeInSeconds )

6
Sources/Plasma/PubUtilLib/plUnifiedTime/plClientUnifiedTime.cpp

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#endif
// static
plUnifiedTime plClientUnifiedTime::fFrameStartTime = plUnifiedTime::GetCurrentTime(); // the 'current time' at the start of each time
plUnifiedTime plClientUnifiedTime::fFrameStartTime = plUnifiedTime::GetCurrent(); // the 'current time' at the start of each time
double plClientUnifiedTime::fSysTimeOffset = 0.0;
//
@ -78,7 +78,7 @@ void plClientUnifiedTime::SetFromGameTime(double gameTime, double curGameSecs)
extern bool gMooseDump;
if (gMooseDump)
{
plUnifiedTime ct = plUnifiedTime::GetCurrentTime();
plUnifiedTime ct = plUnifiedTime::GetCurrent();
plUnifiedTime ft = GetFrameStartTime();
plNetObjectDebugger::GetInstance()->LogMsg(hsTempStringF("SFGT: CT=%s\n", ct.PrintWMillis()));
@ -102,7 +102,7 @@ void plClientUnifiedTime::ConvertToGameTime(double* gameTimeOut, double curGameS
extern bool gMooseDump;
if (gMooseDump)
{
plUnifiedTime ct = plUnifiedTime::GetCurrentTime();
plUnifiedTime ct = plUnifiedTime::GetCurrent();
plUnifiedTime ft = GetFrameStartTime();
plNetObjectDebugger::GetInstance()->LogMsg( hsTempStringF("CTGT: this=%s\n", PrintWMillis()));

2
Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp

@ -193,7 +193,7 @@ plUnifiedTime::plUnifiedTime(const plUnifiedTime * src)
*this = *src;
}
plUnifiedTime plUnifiedTime::GetCurrentTime(Mode mode)
plUnifiedTime plUnifiedTime::GetCurrent(Mode mode)
{
plUnifiedTime t;
t.SetMode(mode);

11
Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h

@ -39,14 +39,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#ifndef _PL_UNIFIEDTIME_INC_
#define _PL_UNIFIEDTIME_INC_
#include "HeadSpin.h"
#include "hsStlUtils.h"
#include <string>
#if HS_BUILD_FOR_WIN32
typedef struct _FILETIME FILETIME;
#endif
//
@ -58,10 +59,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct timeval;
class hsStream;
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif
enum plUnifiedTime_CtorNow { kNow };
@ -97,7 +94,7 @@ public:
plUnifiedTime(int mode, const char * buf, const char * fmt);
plUnifiedTime(const plUnifiedTime & src);
plUnifiedTime(const plUnifiedTime * src);
static plUnifiedTime GetCurrentTime(Mode mode=kGmt);
static plUnifiedTime GetCurrent(Mode mode=kGmt);
// assignment
const plUnifiedTime & operator=(const plUnifiedTime & src);

Loading…
Cancel
Save