1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

View File

@ -1,23 +1,23 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib")
include_directories("../../NucleusLib/inc")
set(pnTimer_HEADERS
plTimedValue.h
plTimerCallbackManager.h
pnBuildDates.h
pnTimerCreatable.h
)
set(pnTimer_SOURCES
hsTimer.cpp
plTimedValue.cpp
plTimerCallbackManager.cpp
pnBranchDate.cpp
pnBuildDates.cpp
)
add_library(pnTimer STATIC ${pnTimer_HEADERS} ${pnTimer_SOURCES})
source_group("Header Files" FILES ${pnTimer_HEADERS})
source_group("Source Files" FILES ${pnTimer_SOURCES})
include_directories("../../CoreLib")
include_directories("../../NucleusLib")
include_directories("../../NucleusLib/inc")
set(pnTimer_HEADERS
plTimedValue.h
plTimerCallbackManager.h
pnBuildDates.h
pnTimerCreatable.h
)
set(pnTimer_SOURCES
hsTimer.cpp
plTimedValue.cpp
plTimerCallbackManager.cpp
pnBranchDate.cpp
pnBuildDates.cpp
)
add_library(pnTimer STATIC ${pnTimer_HEADERS} ${pnTimer_SOURCES})
source_group("Header Files" FILES ${pnTimer_HEADERS})
source_group("Source Files" FILES ${pnTimer_SOURCES})

View File

@ -1,405 +1,405 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTimer.h"
#include "hsUtils.h"
#if HS_BUILD_FOR_MAC
#include <Timer.h>
#endif
#include "plTweak.h"
//
// plTimerShare - the actual worker. All process spaces should share a single
// plTimerShare to keep time synchronized across spaces.
//
plTimerShare::plTimerShare()
: fFirstTime(true),
fSysSeconds(0),
fRealSeconds(0),
fDelSysSeconds(0),
fFrameTimeInc(0.03f),
fSysTimeScale(1.f),
fTimeClampSecs(0.1f),
fSmoothingClampSecs(-1.0f),
fRunningFrameTime(false),
fClamping(false),
fResetSmooth(true),
fCurrSlot(0)
{
}
plTimerShare::~plTimerShare()
{
}
double plTimerShare::GetSeconds() const
{
hsWide ticks;
return hsTimer::GetRawTicks(&ticks)->AsDouble() / hsTimer::GetRawBase().AsDouble();
}
double plTimerShare::GetMilliSeconds() const
{
return GetSeconds() * 1.e3;
}
hsWide plTimerShare::DSecondsToRawTicks(double secs)
{
hsWide retVal;
double ticks = secs * hsTimer::GetRawBase().AsDouble();
double hi = ticks / double(65536) / double(65536);
ticks -= hi;
retVal.fHi = Int32(hi);
retVal.fLo = Int32(ticks);
return retVal;
}
double plTimerShare::RawTicksToDSeconds(const hsWide& ticks)
{
return ticks.AsDouble() / hsTimer::GetRawBase().AsDouble();
}
inline hsWide* plTimerShare::FactorInTimeZero(hsWide* ticks) const
{
if( fFirstTime )
{
fFirstTime = false;
fRawTimeZero = *ticks;
ticks->Set(0, 0);
}
else
{
ticks->Sub(&fRawTimeZero);
}
return ticks;
}
double plTimerShare::IncSysSeconds()
{
if( fRunningFrameTime )
{
fDelSysSeconds = fFrameTimeInc * fSysTimeScale;
fSysSeconds += fDelSysSeconds;
fResetSmooth = true;
}
else if( fSmoothingClampSecs >= 0 )
{
double t = GetSeconds();
hsScalar delSys = hsScalar(t - fRealSeconds);
fClamping = ( (fTimeClampSecs > 0) && (delSys > fTimeClampSecs) );
if (fClamping)
{
delSys = fTimeClampSecs;
}
delSys *= fSysTimeScale;
if( fDelSysSeconds > 0 && fDelSysSeconds < fSmoothingClampSecs )
{
const hsScalar kFrac = 0.1f;
const hsScalar kOneMinusFrac = 1.f-kFrac;
delSys *= kFrac;
delSys += fDelSysSeconds * kOneMinusFrac;
}
if (delSys > 4.0f && delSys < 5.0f)
{
//got that mysterious bug, (Win2k? certain CPU's?) try again...
#if HS_BUILD_FOR_WIN32
int count = 10;
while( delSys >= fDelSysSeconds * 2 && count > 0 )
{
fRealSeconds = t;
t = GetSeconds();
delSys = hsScalar(t - fRealSeconds);
count--;
}
#endif
}
fDelSysSeconds = delSys;
fSysSeconds += fDelSysSeconds;
fRealSeconds = t;
fResetSmooth = true;
}
else
{
double t = GetSeconds();
plCONST(int) kSmoothBuffUsed(kSmoothBuffLen);
if( fResetSmooth )
{
int i;
for( i = 0; i < kSmoothBuffUsed; i++ )
fSmoothBuff[i] = t;
fResetSmooth = false;
}
if( ++fCurrSlot >= kSmoothBuffUsed )
fCurrSlot = 0;
fSmoothBuff[fCurrSlot] = t;
double avg = 0;
int j;
for( j = 0; j < kSmoothBuffUsed; j++ )
{
avg += fSmoothBuff[j];
}
avg /= double(kSmoothBuffUsed);
plCONST(hsScalar) kMaxSmoothable(0.15f);
fDelSysSeconds = hsScalar(avg - fRealSeconds) * fSysTimeScale;
if( fDelSysSeconds > kMaxSmoothable * fSysTimeScale )
{
avg = t;
fDelSysSeconds = hsScalar(avg - fRealSeconds) * fSysTimeScale;
fResetSmooth = true;
}
fSysSeconds += fDelSysSeconds;
fRealSeconds = avg;
}
return fSysSeconds;
}
void plTimerShare::SetRealTime(hsBool realTime)
{
fRunningFrameTime = !realTime;
if( realTime )
{
fRealSeconds = GetSeconds();
}
}
#if HS_BUILD_FOR_WIN32
#include <windows.h>
hsWide* plTimerShare::GetRawTicks(hsWide* ticks) const
{
LARGE_INTEGER large;
if (::QueryPerformanceCounter(&large))
{
ticks->Set(large.HighPart, large.LowPart);
}
else
{
ticks->Set(0, ::GetTickCount());
}
return FactorInTimeZero(ticks);
}
hsWide hsTimer::IInitRawBase()
{
hsWide base;
LARGE_INTEGER large;
if (::QueryPerformanceFrequency(&large))
base.Set(large.HighPart, large.LowPart);
else
base.Set(0, 1000);
return base;
}
#elif HS_BUILD_FOR_MAC
#include <Events.h>
#include <DriverServices.h>
//#define HS_USE_TICKCOUNT
hsWide* plTimerShare::GetRawTicks(hsWide* ticks)
{
#ifndef HS_USE_TICKCOUNT
UnsignedWide ns = AbsoluteToNanoseconds(UpTime());
ticks->Set(ns.hi, ns.lo);
#else
ticks->Set(0, TickCount());
#endif
return FactorInTimeZero(ticks);
}
hsWide plTimerShare::IInitRawBase()
{
hsWide base;
#ifndef HS_USE_TICKCOUNT
base.Set(0, 1000000000L);
#else
base.Set(0, 60);
#endif
return base;
}
#elif HS_BUILD_FOR_UNIX
#include <sys/time.h>
#define kMicroSecondsUnit 1000000
static UInt32 gBaseTime = 0;
hsWide* plTimerShare::GetRawTicks(hsWide* ticks) const
{
timeval tv;
(void)::gettimeofday(&tv, nil);
if (gBaseTime == 0)
gBaseTime = tv.tv_sec;
ticks->Mul(tv.tv_sec - gBaseTime, kMicroSecondsUnit)->Add(tv.tv_usec);
return ticks;
}
hsWide hsTimer::IInitRawBase()
{
hsWide base;
base.Set(0, kMicroSecondsUnit);
return base;
}
#elif HS_BUILD_FOR_PS2
extern unsigned long psTimerGetCount();
//#define kTickMul (150000000) // kTickMul/kTickDiv :: 4577.636719
#define kTickMul (100000000) // kTickMul/kTickDiv :: 3051.757813 // for debugger
#define kTickDiv (256*128)
hsWide* plTimerShare::GetRawTicks(hsWide* ticks)
{
unsigned long t= psTimerGetCount();
ticks->Set( (Int32)(t>>32), (Int32)(t&((1ul<<32)-1)));
return ticks;
}
hsWide plTimerShare::IInitRawBase()
{
hsWide base;
base.Set(0, kTickMul/kTickDiv );
return base;
}
#endif
//
// hsTimer - thin static interface to plTimerShare. Also keeps a couple of
// constants.
//
static plTimerShare staticTimer;
plTimerShare* hsTimer::fTimer = &staticTimer; // until overridden.
const double hsTimer::fPrecTicksPerSec = hsTimer::GetPrecTicksPerSec();
const hsWide hsTimer::fRawBase = hsTimer::IInitRawBase();
void hsTimer::SetTheTimer(plTimerShare* timer)
{
fTimer = timer;
}
///////////////////////////
// Precision timer routines
// These remain as statics
// since they are stateless
// anyway.
///////////////////////////
double hsTimer::GetPrecTicksPerSec()
{
#if HS_BUILD_FOR_WIN32
LARGE_INTEGER freq;
if( !QueryPerformanceFrequency(&freq) )
{
return 1000.f;
}
return ((double) freq.LowPart);
#endif
#if HS_BUILD_FOR_MAC
return 1000.f;
#endif
#if HS_BUILD_FOR_PS2
return 1000.f;
#endif
return 1;
}
UInt32 hsTimer::GetPrecTickCount()
{
#if HS_BUILD_FOR_WIN32
LARGE_INTEGER ti;
if( !QueryPerformanceCounter(&ti) )
return GetTickCount();
return ti.LowPart;
#endif
#if HS_BUILD_FOR_MACPPC
return hsTimer::GetMSeconds();
#endif
#if HS_BUILD_FOR_PS2
return hsTimer::GetMSeconds();
#endif
}
UInt32 hsTimer::PrecSecsToTicks(hsScalar secs)
{
return (UInt32)(((double)secs) * fPrecTicksPerSec);
}
double hsTimer::PrecTicksToSecs(UInt32 ticks)
{
return ((double)ticks) / fPrecTicksPerSec;
}
double hsTimer::PrecTicksToHz(UInt32 ticks)
{
return fPrecTicksPerSec / ((double)ticks);
}
UInt64 hsTimer::GetFullTickCount()
{
#if HS_BUILD_FOR_WIN32
LARGE_INTEGER ticks;
QueryPerformanceCounter(&ticks);
return ticks.QuadPart;
#else
return 0;
#endif
}
float hsTimer::FullTicksToMs(UInt64 ticks)
{
#ifdef HS_BUILD_FOR_WIN32
static UInt64 ticksPerTenthMs = 0;
if (ticksPerTenthMs == 0)
{
LARGE_INTEGER perfFreq;
QueryPerformanceFrequency(&perfFreq);
ticksPerTenthMs = perfFreq.QuadPart / 10000;
}
return float(ticks / ticksPerTenthMs) / 10.f;
#else
return 0.f;
#endif
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTimer.h"
#include "hsUtils.h"
#if HS_BUILD_FOR_MAC
#include <Timer.h>
#endif
#include "plTweak.h"
//
// plTimerShare - the actual worker. All process spaces should share a single
// plTimerShare to keep time synchronized across spaces.
//
plTimerShare::plTimerShare()
: fFirstTime(true),
fSysSeconds(0),
fRealSeconds(0),
fDelSysSeconds(0),
fFrameTimeInc(0.03f),
fSysTimeScale(1.f),
fTimeClampSecs(0.1f),
fSmoothingClampSecs(-1.0f),
fRunningFrameTime(false),
fClamping(false),
fResetSmooth(true),
fCurrSlot(0)
{
}
plTimerShare::~plTimerShare()
{
}
double plTimerShare::GetSeconds() const
{
hsWide ticks;
return hsTimer::GetRawTicks(&ticks)->AsDouble() / hsTimer::GetRawBase().AsDouble();
}
double plTimerShare::GetMilliSeconds() const
{
return GetSeconds() * 1.e3;
}
hsWide plTimerShare::DSecondsToRawTicks(double secs)
{
hsWide retVal;
double ticks = secs * hsTimer::GetRawBase().AsDouble();
double hi = ticks / double(65536) / double(65536);
ticks -= hi;
retVal.fHi = Int32(hi);
retVal.fLo = Int32(ticks);
return retVal;
}
double plTimerShare::RawTicksToDSeconds(const hsWide& ticks)
{
return ticks.AsDouble() / hsTimer::GetRawBase().AsDouble();
}
inline hsWide* plTimerShare::FactorInTimeZero(hsWide* ticks) const
{
if( fFirstTime )
{
fFirstTime = false;
fRawTimeZero = *ticks;
ticks->Set(0, 0);
}
else
{
ticks->Sub(&fRawTimeZero);
}
return ticks;
}
double plTimerShare::IncSysSeconds()
{
if( fRunningFrameTime )
{
fDelSysSeconds = fFrameTimeInc * fSysTimeScale;
fSysSeconds += fDelSysSeconds;
fResetSmooth = true;
}
else if( fSmoothingClampSecs >= 0 )
{
double t = GetSeconds();
hsScalar delSys = hsScalar(t - fRealSeconds);
fClamping = ( (fTimeClampSecs > 0) && (delSys > fTimeClampSecs) );
if (fClamping)
{
delSys = fTimeClampSecs;
}
delSys *= fSysTimeScale;
if( fDelSysSeconds > 0 && fDelSysSeconds < fSmoothingClampSecs )
{
const hsScalar kFrac = 0.1f;
const hsScalar kOneMinusFrac = 1.f-kFrac;
delSys *= kFrac;
delSys += fDelSysSeconds * kOneMinusFrac;
}
if (delSys > 4.0f && delSys < 5.0f)
{
//got that mysterious bug, (Win2k? certain CPU's?) try again...
#if HS_BUILD_FOR_WIN32
int count = 10;
while( delSys >= fDelSysSeconds * 2 && count > 0 )
{
fRealSeconds = t;
t = GetSeconds();
delSys = hsScalar(t - fRealSeconds);
count--;
}
#endif
}
fDelSysSeconds = delSys;
fSysSeconds += fDelSysSeconds;
fRealSeconds = t;
fResetSmooth = true;
}
else
{
double t = GetSeconds();
plCONST(int) kSmoothBuffUsed(kSmoothBuffLen);
if( fResetSmooth )
{
int i;
for( i = 0; i < kSmoothBuffUsed; i++ )
fSmoothBuff[i] = t;
fResetSmooth = false;
}
if( ++fCurrSlot >= kSmoothBuffUsed )
fCurrSlot = 0;
fSmoothBuff[fCurrSlot] = t;
double avg = 0;
int j;
for( j = 0; j < kSmoothBuffUsed; j++ )
{
avg += fSmoothBuff[j];
}
avg /= double(kSmoothBuffUsed);
plCONST(hsScalar) kMaxSmoothable(0.15f);
fDelSysSeconds = hsScalar(avg - fRealSeconds) * fSysTimeScale;
if( fDelSysSeconds > kMaxSmoothable * fSysTimeScale )
{
avg = t;
fDelSysSeconds = hsScalar(avg - fRealSeconds) * fSysTimeScale;
fResetSmooth = true;
}
fSysSeconds += fDelSysSeconds;
fRealSeconds = avg;
}
return fSysSeconds;
}
void plTimerShare::SetRealTime(hsBool realTime)
{
fRunningFrameTime = !realTime;
if( realTime )
{
fRealSeconds = GetSeconds();
}
}
#if HS_BUILD_FOR_WIN32
#include <windows.h>
hsWide* plTimerShare::GetRawTicks(hsWide* ticks) const
{
LARGE_INTEGER large;
if (::QueryPerformanceCounter(&large))
{
ticks->Set(large.HighPart, large.LowPart);
}
else
{
ticks->Set(0, ::GetTickCount());
}
return FactorInTimeZero(ticks);
}
hsWide hsTimer::IInitRawBase()
{
hsWide base;
LARGE_INTEGER large;
if (::QueryPerformanceFrequency(&large))
base.Set(large.HighPart, large.LowPart);
else
base.Set(0, 1000);
return base;
}
#elif HS_BUILD_FOR_MAC
#include <Events.h>
#include <DriverServices.h>
//#define HS_USE_TICKCOUNT
hsWide* plTimerShare::GetRawTicks(hsWide* ticks)
{
#ifndef HS_USE_TICKCOUNT
UnsignedWide ns = AbsoluteToNanoseconds(UpTime());
ticks->Set(ns.hi, ns.lo);
#else
ticks->Set(0, TickCount());
#endif
return FactorInTimeZero(ticks);
}
hsWide plTimerShare::IInitRawBase()
{
hsWide base;
#ifndef HS_USE_TICKCOUNT
base.Set(0, 1000000000L);
#else
base.Set(0, 60);
#endif
return base;
}
#elif HS_BUILD_FOR_UNIX
#include <sys/time.h>
#define kMicroSecondsUnit 1000000
static UInt32 gBaseTime = 0;
hsWide* plTimerShare::GetRawTicks(hsWide* ticks) const
{
timeval tv;
(void)::gettimeofday(&tv, nil);
if (gBaseTime == 0)
gBaseTime = tv.tv_sec;
ticks->Mul(tv.tv_sec - gBaseTime, kMicroSecondsUnit)->Add(tv.tv_usec);
return ticks;
}
hsWide hsTimer::IInitRawBase()
{
hsWide base;
base.Set(0, kMicroSecondsUnit);
return base;
}
#elif HS_BUILD_FOR_PS2
extern unsigned long psTimerGetCount();
//#define kTickMul (150000000) // kTickMul/kTickDiv :: 4577.636719
#define kTickMul (100000000) // kTickMul/kTickDiv :: 3051.757813 // for debugger
#define kTickDiv (256*128)
hsWide* plTimerShare::GetRawTicks(hsWide* ticks)
{
unsigned long t= psTimerGetCount();
ticks->Set( (Int32)(t>>32), (Int32)(t&((1ul<<32)-1)));
return ticks;
}
hsWide plTimerShare::IInitRawBase()
{
hsWide base;
base.Set(0, kTickMul/kTickDiv );
return base;
}
#endif
//
// hsTimer - thin static interface to plTimerShare. Also keeps a couple of
// constants.
//
static plTimerShare staticTimer;
plTimerShare* hsTimer::fTimer = &staticTimer; // until overridden.
const double hsTimer::fPrecTicksPerSec = hsTimer::GetPrecTicksPerSec();
const hsWide hsTimer::fRawBase = hsTimer::IInitRawBase();
void hsTimer::SetTheTimer(plTimerShare* timer)
{
fTimer = timer;
}
///////////////////////////
// Precision timer routines
// These remain as statics
// since they are stateless
// anyway.
///////////////////////////
double hsTimer::GetPrecTicksPerSec()
{
#if HS_BUILD_FOR_WIN32
LARGE_INTEGER freq;
if( !QueryPerformanceFrequency(&freq) )
{
return 1000.f;
}
return ((double) freq.LowPart);
#endif
#if HS_BUILD_FOR_MAC
return 1000.f;
#endif
#if HS_BUILD_FOR_PS2
return 1000.f;
#endif
return 1;
}
UInt32 hsTimer::GetPrecTickCount()
{
#if HS_BUILD_FOR_WIN32
LARGE_INTEGER ti;
if( !QueryPerformanceCounter(&ti) )
return GetTickCount();
return ti.LowPart;
#endif
#if HS_BUILD_FOR_MACPPC
return hsTimer::GetMSeconds();
#endif
#if HS_BUILD_FOR_PS2
return hsTimer::GetMSeconds();
#endif
}
UInt32 hsTimer::PrecSecsToTicks(hsScalar secs)
{
return (UInt32)(((double)secs) * fPrecTicksPerSec);
}
double hsTimer::PrecTicksToSecs(UInt32 ticks)
{
return ((double)ticks) / fPrecTicksPerSec;
}
double hsTimer::PrecTicksToHz(UInt32 ticks)
{
return fPrecTicksPerSec / ((double)ticks);
}
UInt64 hsTimer::GetFullTickCount()
{
#if HS_BUILD_FOR_WIN32
LARGE_INTEGER ticks;
QueryPerformanceCounter(&ticks);
return ticks.QuadPart;
#else
return 0;
#endif
}
float hsTimer::FullTicksToMs(UInt64 ticks)
{
#ifdef HS_BUILD_FOR_WIN32
static UInt64 ticksPerTenthMs = 0;
if (ticksPerTenthMs == 0)
{
LARGE_INTEGER perfFreq;
QueryPerformanceFrequency(&perfFreq);
ticksPerTenthMs = perfFreq.QuadPart / 10000;
}
return float(ticks / ticksPerTenthMs) / 10.f;
#else
return 0.f;
#endif
}

View File

@ -1,31 +1,31 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "hsTimer.h"
#include "plTimedValue.h"
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "hsTimer.h"
#include "plTimedValue.h"

View File

@ -1,155 +1,155 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plTimedValue_inc
#define plTimedValue_inc
#include "hsTimer.h"
class hsStream;
// plTimedValue
// To use, replace your member var of type T with plTimedValue<T>.
// You can then pretty much treat it as normal. To set it to interpolate
// to a new value over secs seconds, use Set(newVal, secs).
// For I/O, see plTimedSimple and plTimedCompound.
template <class T> class plTimedValue
{
protected:
T fGoal;
T fInit;
double fStart;
hsScalar fInvSecs;
public:
plTimedValue() {}
plTimedValue(const plTimedValue<T>& o) { Set(o, 0.f); }
plTimedValue(const T& v) { Set(v, 0.f); }
plTimedValue<T>& operator=(const plTimedValue<T>& o) { return Set(o, 0.f); }
plTimedValue<T>& operator=(const T& v) { return Set(v, 0.f); }
plTimedValue<T>& Set(const T& v, hsScalar secs=0);
operator T () const { return Value(); }
T Value() const;
};
// Read/Writable version of plTimedValue, for intrinsic types (e.g. int, float, bool).
// Must be a type that hsStream has an overloaded ReadSwap/WriteSwap defined.
template <class T> class plTimedSimple : public plTimedValue<T>
{
public:
plTimedSimple<T>& operator=(const plTimedValue<T>& o) { return Set(o, 0.f); }
plTimedSimple<T>& operator=(const T& v) { return Set(v, 0.f); }
plTimedSimple<T>& Set(const T& v, hsScalar secs=0) { plTimedValue<T>::Set(v, secs); return *this; }
void Read(hsStream* s);
void Write(hsStream* s) const;
};
// Read/Writable version of plTimedValue, for compound types (e.g. hsVector3, hsColorRGBA).
// May be any type that has Read(hsStream*)/Write(hsStream*) defined.
template <class T> class plTimedCompound : public plTimedValue<T>
{
public:
plTimedCompound<T>& operator=(const plTimedValue<T>& o) { return Set(o, 0.f); }
plTimedCompound<T>& operator=(const T& v) { return Set(v, 0.f); }
plTimedCompound<T>& Set(const T& v, hsScalar secs=0) { plTimedValue<T>::Set(v, secs); return *this; }
void Read(hsStream* s);
void Write(hsStream* s) const;
};
template <class T>
plTimedValue<T>& plTimedValue<T>::Set(const T& v, hsScalar secs)
{
if( secs <= 0 )
{
fGoal = fInit = v;
fInvSecs = 0;
}
else
{
fInit = Value();
fStart = hsTimer::GetSysSeconds();
fInvSecs = 1.f / secs;
fGoal = v;
}
return *this;
}
template <class T>
T plTimedValue<T>::Value() const
{
if( fInvSecs > 0 )
{
hsScalar t = (hsScalar)((hsTimer::GetSysSeconds() - fStart) * fInvSecs);
hsAssert(t >= 0, "Moving back in time");
if( t < 1.f )
return fGoal * t + fInit * (1.f - t);
}
return fGoal;
}
template <class T>
void plTimedSimple<T>::Read(hsStream* s)
{
T val;
s->ReadSwap(&val);
Set(val, 0.f);
}
template <class T>
void plTimedSimple<T>::Write(hsStream* s) const
{
T val = Value();
s->WriteSwap(val);
}
template <class T>
void plTimedCompound<T>::Read(hsStream* s)
{
T val;
val.Read(s);
Set(val, 0.f);
}
template <class T>
void plTimedCompound<T>::Write(hsStream* s) const
{
T val = Value();
val.Write(s);
}
#endif // plTimedValue_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plTimedValue_inc
#define plTimedValue_inc
#include "hsTimer.h"
class hsStream;
// plTimedValue
// To use, replace your member var of type T with plTimedValue<T>.
// You can then pretty much treat it as normal. To set it to interpolate
// to a new value over secs seconds, use Set(newVal, secs).
// For I/O, see plTimedSimple and plTimedCompound.
template <class T> class plTimedValue
{
protected:
T fGoal;
T fInit;
double fStart;
hsScalar fInvSecs;
public:
plTimedValue() {}
plTimedValue(const plTimedValue<T>& o) { Set(o, 0.f); }
plTimedValue(const T& v) { Set(v, 0.f); }
plTimedValue<T>& operator=(const plTimedValue<T>& o) { return Set(o, 0.f); }
plTimedValue<T>& operator=(const T& v) { return Set(v, 0.f); }
plTimedValue<T>& Set(const T& v, hsScalar secs=0);
operator T () const { return Value(); }
T Value() const;
};
// Read/Writable version of plTimedValue, for intrinsic types (e.g. int, float, bool).
// Must be a type that hsStream has an overloaded ReadSwap/WriteSwap defined.
template <class T> class plTimedSimple : public plTimedValue<T>
{
public:
plTimedSimple<T>& operator=(const plTimedValue<T>& o) { return Set(o, 0.f); }
plTimedSimple<T>& operator=(const T& v) { return Set(v, 0.f); }
plTimedSimple<T>& Set(const T& v, hsScalar secs=0) { plTimedValue<T>::Set(v, secs); return *this; }
void Read(hsStream* s);
void Write(hsStream* s) const;
};
// Read/Writable version of plTimedValue, for compound types (e.g. hsVector3, hsColorRGBA).
// May be any type that has Read(hsStream*)/Write(hsStream*) defined.
template <class T> class plTimedCompound : public plTimedValue<T>
{
public:
plTimedCompound<T>& operator=(const plTimedValue<T>& o) { return Set(o, 0.f); }
plTimedCompound<T>& operator=(const T& v) { return Set(v, 0.f); }
plTimedCompound<T>& Set(const T& v, hsScalar secs=0) { plTimedValue<T>::Set(v, secs); return *this; }
void Read(hsStream* s);
void Write(hsStream* s) const;
};
template <class T>
plTimedValue<T>& plTimedValue<T>::Set(const T& v, hsScalar secs)
{
if( secs <= 0 )
{
fGoal = fInit = v;
fInvSecs = 0;
}
else
{
fInit = Value();
fStart = hsTimer::GetSysSeconds();
fInvSecs = 1.f / secs;
fGoal = v;
}
return *this;
}
template <class T>
T plTimedValue<T>::Value() const
{
if( fInvSecs > 0 )
{
hsScalar t = (hsScalar)((hsTimer::GetSysSeconds() - fStart) * fInvSecs);
hsAssert(t >= 0, "Moving back in time");
if( t < 1.f )
return fGoal * t + fInit * (1.f - t);
}
return fGoal;
}
template <class T>
void plTimedSimple<T>::Read(hsStream* s)
{
T val;
s->ReadSwap(&val);
Set(val, 0.f);
}
template <class T>
void plTimedSimple<T>::Write(hsStream* s) const
{
T val = Value();
s->WriteSwap(val);
}
template <class T>
void plTimedCompound<T>::Read(hsStream* s)
{
T val;
val.Read(s);
Set(val, 0.f);
}
template <class T>
void plTimedCompound<T>::Write(hsStream* s) const
{
T val = Value();
val.Write(s);
}
#endif // plTimedValue_inc

View File

@ -1,183 +1,183 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "plTimerCallbackManager.h"
#include "pnMessage/plTimeMsg.h"
#include "plgDispatch.h"
#include "pnKeyedObject/plFixedKey.h"
#include "hsTimer.h"
plTimerCallbackManager::plTimerCallbackManager()
{
}
plTimerCallbackManager::~plTimerCallbackManager()
{
while (fCallbacks.GetCount() > 0)
delete fCallbacks.Pop();
}
hsBool plTimerCallbackManager::MsgReceive(plMessage* msg)
{
plTimeMsg* pTimeMsg = plTimeMsg::ConvertNoRef(msg);
int i = fCallbacks.Count();
if (pTimeMsg )
{
if(i)
{
i--;
if (pTimeMsg->GetTimeStamp() >= fCallbacks[i]->fTime)
{
plgDispatch::MsgSend( fCallbacks[i]->fMsg );
// Set it nil so the TimerCallback destructor doesn't unRef it
fCallbacks[i]->fMsg = nil;
delete(fCallbacks[i]);
fCallbacks.SetCount(i);
}
}
return true;
}
return hsKeyedObject::MsgReceive(msg);
}
plTimerCallback* plTimerCallbackManager::NewTimer(hsScalar time, plMessage* pMsg)
{
plTimerCallback* t = TRACKED_NEW plTimerCallback( hsTimer::GetSysSeconds() + time, pMsg );
fCallbacks.Append(t);
// sort them
for (int i = 0; i < fCallbacks.Count(); i++)
{
for (int j = i + 1; j < fCallbacks.Count(); j++)
{
#if 0
hsScalar a = fCallbacks[i]->fTime;
hsScalar b = fCallbacks[j]->fTime;
#endif
if (fCallbacks[i]->fTime < fCallbacks[j]->fTime)
{
plTimerCallback* pTemp = fCallbacks[i];
fCallbacks[i] = fCallbacks[j];
fCallbacks[j] = pTemp;
}
}
}
return t;
}
hsBool plTimerCallbackManager::CancelCallback(plTimerCallback* pTimer)
{
for (int i = 0; i < fCallbacks.Count(); i++)
{
if (fCallbacks[i] == pTimer)
{ fCallbacks.Remove(i);
return true;
}
}
return false;
}
hsBool plTimerCallbackManager::CancelCallbacksToKey(const plKey& key)
{
const plKey rKey;
bool removed = false;
for (int i = fCallbacks.Count() - 1; i >= 0 ; i--)
{
for (int j = 0; j < fCallbacks[i]->fMsg->GetNumReceivers(); j++)
{
const plKey rKey = fCallbacks[i]->fMsg->GetReceiver(j);
if (rKey == key)
{
delete fCallbacks[i];
fCallbacks.Remove(i);
removed = true;
break;
}
}
}
return removed;
}
void plTimerCallbackManager::Read(hsStream* stream, hsResMgr* mgr)
{
}
void plTimerCallbackManager::Write(hsStream* stream, hsResMgr* mgr)
{
}
plTimerCallback::plTimerCallback(double time, plMessage* pMsg) :
fTime(time),
fMsg(pMsg)
{
}
plTimerCallback::~plTimerCallback()
{
if (fMsg)
hsRefCnt_SafeUnRef(fMsg);
fMsg = nil;
}
void plTimerCallback::Read(hsStream* stream, hsResMgr* mgr)
{
}
void plTimerCallback::Write(hsStream* stream, hsResMgr* mgr)
{
}
plTimerCallbackManager* plgTimerCallbackMgr::fMgr = nil;
void plgTimerCallbackMgr::Init()
{
fMgr = TRACKED_NEW plTimerCallbackManager;
fMgr->RegisterAs( kTimerCallbackManager_KEY ); // fixedKey from plFixedKey.h
plgDispatch::Dispatch()->RegisterForExactType( plTimeMsg::Index(), fMgr->GetKey() );
}
hsBool plgTimerCallbackMgr::CancelCallback(plTimerCallback* pTimer)
{
return (fMgr->CancelCallback(pTimer));
}
hsBool plgTimerCallbackMgr::CancelCallbacksToKey(const plKey& key)
{
return (fMgr->CancelCallbacksToKey(key));
}
void plgTimerCallbackMgr::Shutdown()
{
fMgr->UnRegisterAs(kTimerCallbackManager_KEY);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "plTimerCallbackManager.h"
#include "pnMessage/plTimeMsg.h"
#include "plgDispatch.h"
#include "pnKeyedObject/plFixedKey.h"
#include "hsTimer.h"
plTimerCallbackManager::plTimerCallbackManager()
{
}
plTimerCallbackManager::~plTimerCallbackManager()
{
while (fCallbacks.GetCount() > 0)
delete fCallbacks.Pop();
}
hsBool plTimerCallbackManager::MsgReceive(plMessage* msg)
{
plTimeMsg* pTimeMsg = plTimeMsg::ConvertNoRef(msg);
int i = fCallbacks.Count();
if (pTimeMsg )
{
if(i)
{
i--;
if (pTimeMsg->GetTimeStamp() >= fCallbacks[i]->fTime)
{
plgDispatch::MsgSend( fCallbacks[i]->fMsg );
// Set it nil so the TimerCallback destructor doesn't unRef it
fCallbacks[i]->fMsg = nil;
delete(fCallbacks[i]);
fCallbacks.SetCount(i);
}
}
return true;
}
return hsKeyedObject::MsgReceive(msg);
}
plTimerCallback* plTimerCallbackManager::NewTimer(hsScalar time, plMessage* pMsg)
{
plTimerCallback* t = TRACKED_NEW plTimerCallback( hsTimer::GetSysSeconds() + time, pMsg );
fCallbacks.Append(t);
// sort them
for (int i = 0; i < fCallbacks.Count(); i++)
{
for (int j = i + 1; j < fCallbacks.Count(); j++)
{
#if 0
hsScalar a = fCallbacks[i]->fTime;
hsScalar b = fCallbacks[j]->fTime;
#endif
if (fCallbacks[i]->fTime < fCallbacks[j]->fTime)
{
plTimerCallback* pTemp = fCallbacks[i];
fCallbacks[i] = fCallbacks[j];
fCallbacks[j] = pTemp;
}
}
}
return t;
}
hsBool plTimerCallbackManager::CancelCallback(plTimerCallback* pTimer)
{
for (int i = 0; i < fCallbacks.Count(); i++)
{
if (fCallbacks[i] == pTimer)
{ fCallbacks.Remove(i);
return true;
}
}
return false;
}
hsBool plTimerCallbackManager::CancelCallbacksToKey(const plKey& key)
{
const plKey rKey;
bool removed = false;
for (int i = fCallbacks.Count() - 1; i >= 0 ; i--)
{
for (int j = 0; j < fCallbacks[i]->fMsg->GetNumReceivers(); j++)
{
const plKey rKey = fCallbacks[i]->fMsg->GetReceiver(j);
if (rKey == key)
{
delete fCallbacks[i];
fCallbacks.Remove(i);
removed = true;
break;
}
}
}
return removed;
}
void plTimerCallbackManager::Read(hsStream* stream, hsResMgr* mgr)
{
}
void plTimerCallbackManager::Write(hsStream* stream, hsResMgr* mgr)
{
}
plTimerCallback::plTimerCallback(double time, plMessage* pMsg) :
fTime(time),
fMsg(pMsg)
{
}
plTimerCallback::~plTimerCallback()
{
if (fMsg)
hsRefCnt_SafeUnRef(fMsg);
fMsg = nil;
}
void plTimerCallback::Read(hsStream* stream, hsResMgr* mgr)
{
}
void plTimerCallback::Write(hsStream* stream, hsResMgr* mgr)
{
}
plTimerCallbackManager* plgTimerCallbackMgr::fMgr = nil;
void plgTimerCallbackMgr::Init()
{
fMgr = TRACKED_NEW plTimerCallbackManager;
fMgr->RegisterAs( kTimerCallbackManager_KEY ); // fixedKey from plFixedKey.h
plgDispatch::Dispatch()->RegisterForExactType( plTimeMsg::Index(), fMgr->GetKey() );
}
hsBool plgTimerCallbackMgr::CancelCallback(plTimerCallback* pTimer)
{
return (fMgr->CancelCallback(pTimer));
}
hsBool plgTimerCallbackMgr::CancelCallbacksToKey(const plKey& key)
{
return (fMgr->CancelCallbacksToKey(key));
}
void plgTimerCallbackMgr::Shutdown()
{
fMgr->UnRegisterAs(kTimerCallbackManager_KEY);
}

View File

@ -1,95 +1,95 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plTimerCallbackManager_Defined
#define plTimerCallbackManager_Defined
#include "hsScalar.h"
#include "pnKeyedObject/hsKeyedObject.h"
#include "hsTemplates.h"
class plMessage;
class plTimerCallback
{
public:
plTimerCallback(double time, plMessage* pMsg);
~plTimerCallback();
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
double fTime;
plMessage* fMsg;
};
class plTimerCallbackManager : public hsKeyedObject
{
public:
plTimerCallbackManager();
~plTimerCallbackManager();
CLASSNAME_REGISTER( plTimerCallbackManager );
GETINTERFACE_ANY( plTimerCallbackManager, hsKeyedObject );
virtual plTimerCallback* NewTimer(hsScalar time, plMessage* pMsg);
hsBool CancelCallback(plTimerCallback* pTimer);
hsBool CancelCallbacksToKey(const plKey& key);
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
private:
hsTArray<plTimerCallback*> fCallbacks;
};
class plgTimerCallbackMgr
{
private:
static plTimerCallbackManager* fMgr;
public:
static void Init();
static void Shutdown();
static plTimerCallbackManager* Mgr() { return fMgr; }
// External modifier use only
static void SetTheTimerCallbackMgr(plTimerCallbackManager *mgr) { fMgr = mgr; }
static plTimerCallback* NewTimer(hsScalar time, plMessage* pMsg) { return (fMgr->NewTimer(time, pMsg)); }
static hsBool CancelCallback(plTimerCallback* pTimer);
static hsBool CancelCallbacksToKey(const plKey& key);
};
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plTimerCallbackManager_Defined
#define plTimerCallbackManager_Defined
#include "hsScalar.h"
#include "pnKeyedObject/hsKeyedObject.h"
#include "hsTemplates.h"
class plMessage;
class plTimerCallback
{
public:
plTimerCallback(double time, plMessage* pMsg);
~plTimerCallback();
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
double fTime;
plMessage* fMsg;
};
class plTimerCallbackManager : public hsKeyedObject
{
public:
plTimerCallbackManager();
~plTimerCallbackManager();
CLASSNAME_REGISTER( plTimerCallbackManager );
GETINTERFACE_ANY( plTimerCallbackManager, hsKeyedObject );
virtual plTimerCallback* NewTimer(hsScalar time, plMessage* pMsg);
hsBool CancelCallback(plTimerCallback* pTimer);
hsBool CancelCallbacksToKey(const plKey& key);
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
private:
hsTArray<plTimerCallback*> fCallbacks;
};
class plgTimerCallbackMgr
{
private:
static plTimerCallbackManager* fMgr;
public:
static void Init();
static void Shutdown();
static plTimerCallbackManager* Mgr() { return fMgr; }
// External modifier use only
static void SetTheTimerCallbackMgr(plTimerCallbackManager *mgr) { fMgr = mgr; }
static plTimerCallback* NewTimer(hsScalar time, plMessage* pMsg) { return (fMgr->NewTimer(time, pMsg)); }
static hsBool CancelCallback(plTimerCallback* pTimer);
static hsBool CancelCallbacksToKey(const plKey& key);
};
#endif

View File

@ -1,28 +1,28 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pnBuildDates.h"
char pnBuildDates::fBranchDate[] = "Pre-release";
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pnBuildDates.h"
char pnBuildDates::fBranchDate[] = "Pre-release";

View File

@ -1,78 +1,78 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// pnBuildDates.cpp //
// //
// Thanks to there not being a pre-build step in MSVC, we have to do this //
// kluge instead. Basically, as a post-build step, we run a custom app //
// that inserts the date and time as string resources into the client EXE. //
// Then, on startup, the static class here gets inited and we load the //
// string resources into our char strings. //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsWindows.h"
#include "pnTimer/pnBuildDates.h"
char pnBuildDates::fBuildDate[ 128 ] = __DATE__;
char pnBuildDates::fBuildTime[ 128 ] = __TIME__;
// This forces our constructor to run on app load
static pnBuildDates staticObjToForceResLoad;
#if HS_BUILD_FOR_WIN32
HINSTANCE sModuleHandle = GetModuleHandle( NULL );
#endif
pnBuildDates::pnBuildDates()
{
// Note; these are int konstants so we don't have to worry about sharing symbols
// across apps (in this case, our custom app that updates these strings on post-build)
IGetString( 1000, fBuildDate, sizeof( fBuildDate ) - 1 );
IGetString( 1001, fBuildTime, sizeof( fBuildTime ) - 1 );
}
void pnBuildDates::IGetString( int resID, char *destBuffer, int size )
{
#if HS_BUILD_FOR_WIN32
HRSRC rsrc = ::FindResource( sModuleHandle, MAKEINTRESOURCE( resID ), RT_RCDATA );
if( rsrc != NULL )
{
HGLOBAL handle = ::LoadResource( sModuleHandle, rsrc );
if( handle != NULL )
{
char *str = (char *)::LockResource( handle );
strncpy( destBuffer, str, size );
UnlockResource( handle );
}
}
#endif
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// pnBuildDates.cpp //
// //
// Thanks to there not being a pre-build step in MSVC, we have to do this //
// kluge instead. Basically, as a post-build step, we run a custom app //
// that inserts the date and time as string resources into the client EXE. //
// Then, on startup, the static class here gets inited and we load the //
// string resources into our char strings. //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsWindows.h"
#include "pnTimer/pnBuildDates.h"
char pnBuildDates::fBuildDate[ 128 ] = __DATE__;
char pnBuildDates::fBuildTime[ 128 ] = __TIME__;
// This forces our constructor to run on app load
static pnBuildDates staticObjToForceResLoad;
#if HS_BUILD_FOR_WIN32
HINSTANCE sModuleHandle = GetModuleHandle( NULL );
#endif
pnBuildDates::pnBuildDates()
{
// Note; these are int konstants so we don't have to worry about sharing symbols
// across apps (in this case, our custom app that updates these strings on post-build)
IGetString( 1000, fBuildDate, sizeof( fBuildDate ) - 1 );
IGetString( 1001, fBuildTime, sizeof( fBuildTime ) - 1 );
}
void pnBuildDates::IGetString( int resID, char *destBuffer, int size )
{
#if HS_BUILD_FOR_WIN32
HRSRC rsrc = ::FindResource( sModuleHandle, MAKEINTRESOURCE( resID ), RT_RCDATA );
if( rsrc != NULL )
{
HGLOBAL handle = ::LoadResource( sModuleHandle, rsrc );
if( handle != NULL )
{
char *str = (char *)::LockResource( handle );
strncpy( destBuffer, str, size );
UnlockResource( handle );
}
}
#endif
}

View File

@ -1,55 +1,55 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// pnBuildDates Header //
// //
// This is a tiny cpp/h wrapper for the build/branch dates. Basically, //
// this header defines two string konstants that at runtime will be the //
// build and branch date/timestamps. The pnBranchDate.cpp file is //
// regenerated on branch to fill in the branch date. //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _pnBuildDates_h
#define _pnBuildDates_h
class pnBuildDates
{
private:
void IGetString( int resID, char *destBuffer, int size );
public:
static char fBuildDate[];
static char fBuildTime[];
static char fBranchDate[];
pnBuildDates();
};
#endif //_pnBuildDates_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// pnBuildDates Header //
// //
// This is a tiny cpp/h wrapper for the build/branch dates. Basically, //
// this header defines two string konstants that at runtime will be the //
// build and branch date/timestamps. The pnBranchDate.cpp file is //
// regenerated on branch to fill in the branch date. //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _pnBuildDates_h
#define _pnBuildDates_h
class pnBuildDates
{
private:
void IGetString( int resID, char *destBuffer, int size );
public:
static char fBuildDate[];
static char fBuildTime[];
static char fBranchDate[];
pnBuildDates();
};
#endif //_pnBuildDates_h

View File

@ -1,38 +1,38 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pnTimerCreatable_inc
#define pnTimerCreatable_inc
#include "pnFactory/plCreator.h"
#include "plTimerCallbackManager.h"
REGISTER_CREATABLE( plTimerCallbackManager );
#endif // pnTimerCreatable_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pnTimerCreatable_inc
#define pnTimerCreatable_inc
#include "pnFactory/plCreator.h"
#include "plTimerCallbackManager.h"
REGISTER_CREATABLE( plTimerCallbackManager );
#endif // pnTimerCreatable_inc