Browse Source

Merge pull request #497 from zrax/del_plStringFormat

plString::Format deprecation
Adam Johnson 9 years ago
parent
commit
f98222ee59
  1. 12
      Sources/Plasma/CoreLib/hsMatrix44.cpp
  2. 1
      Sources/Plasma/CoreLib/hsStream.h
  3. 3
      Sources/Plasma/CoreLib/plFormat.h
  4. 9
      Sources/Plasma/CoreLib/plString.cpp
  5. 9
      Sources/Plasma/CoreLib/plString.h
  6. 1
      Sources/Plasma/FeatureLib/pfLocalizationMgr/CMakeLists.txt
  7. 1
      Sources/Plasma/NucleusLib/inc/CMakeLists.txt
  8. 248
      Sources/Plasma/NucleusLib/inc/plLoggable.h
  9. 1
      Sources/Plasma/NucleusLib/pnAsyncCore/CMakeLists.txt
  10. 1
      Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt
  11. 56
      Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp
  12. 36
      Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
  13. 6
      Sources/Plasma/NucleusLib/pnNetCommon/plNetResManager.cpp
  14. 18
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
  15. 36
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  16. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
  17. 4
      Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.h
  18. 3
      Sources/Plasma/PubUtilLib/plSDL/plSDL.h
  19. 11
      Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp
  20. 2
      Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp
  21. 7
      Sources/Plasma/PubUtilLib/plStatusLog/CMakeLists.txt
  22. 181
      Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.cpp
  23. 86
      Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.h
  24. 17
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
  25. 6
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h
  26. 4
      Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp

12
Sources/Plasma/CoreLib/hsMatrix44.cpp

@ -925,6 +925,16 @@ void hsMatrix44::Write(hsStream *stream)
int i,j;
for(i=0; i<4; i++)
for(j=0; j<4; j++)
stream->WriteLEFloat(fMap[i][j]);
stream->WriteLEFloat(fMap[i][j]);
}
}
PL_FORMAT_IMPL(const hsMatrix44&)
{
PL_FORMAT_FORWARD(plFormat("hsMatrix44[[{.4f}, {.4f}, {.4f}, {.4f}]; [{.4f}, {.4f}, {.4f}, {.4f}]; [{.4f}, {.4f}, {.4f}, {.4f}]; [{.4f}, {.4f}, {.4f}, {.4f}]]",
value.fMap[0][0], value.fMap[0][1], value.fMap[0][2], value.fMap[0][3],
value.fMap[1][0], value.fMap[1][1], value.fMap[1][2], value.fMap[1][3],
value.fMap[2][0], value.fMap[2][1], value.fMap[2][2], value.fMap[2][3],
value.fMap[3][0], value.fMap[3][1], value.fMap[3][2], value.fMap[3][3]));
}

1
Sources/Plasma/CoreLib/hsStream.h

@ -120,6 +120,7 @@ public:
virtual bool IsCompressed() { return false; }
uint32_t WriteString(const plString & string) { return Write(string.GetSize(), string.c_str()); }
hsDeprecated("hsStream::WriteFmt is deprecated -- use plFormat instead")
uint32_t WriteFmt(const char * fmt, ...);
uint32_t WriteFmtV(const char * fmt, va_list av);

3
Sources/Plasma/CoreLib/plFormat.h

@ -216,6 +216,9 @@ namespace plFormat_Private
// Format for plUUID
PL_FORMAT_TYPE(const class plUUID &)
// Format for hsMatrix44
PL_FORMAT_TYPE(const struct hsMatrix44 &)
// ==================================
// END: Formattable type declarations
// ==================================

9
Sources/Plasma/CoreLib/plString.cpp

@ -550,15 +550,6 @@ plString plString::IFormat(const char *fmt, va_list vptr)
return plString::FromUtf8(buffer, chars);
}
plString plString::Format(const char *fmt, ...)
{
va_list vptr;
va_start(vptr, fmt);
plString str = IFormat(fmt, vptr);
va_end(vptr);
return str;
}
ssize_t plString::Find(char ch, CaseSensitivity sense) const
{
if (sense == kCaseSensitive) {

9
Sources/Plasma/CoreLib/plString.h

@ -454,15 +454,10 @@ public:
/** Convert the string to a double precision floating point value. */
double ToDouble() const;
/** Construct a plString using a printf-like format string. */
hsDeprecated("plString::Format is deprecated -- use plFormat instead")
static plString Format(const char *fmt, ...);
/** Construct a plString using a printf-like format string.
* This function should be called inside of vararg functions, such as
* plString::Format().
* This function should be called inside of other vararg functions,
* but those should be eventually replaced with plFormat-based variants.
*/
hsDeprecated("plString::IFormat is deprecated -- use plFormat instead")
static plString IFormat(const char *fmt, va_list vptr);
enum CaseSensitivity {

1
Sources/Plasma/FeatureLib/pfLocalizationMgr/CMakeLists.txt

@ -1,4 +1,5 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
include_directories(${EXPAT_INCLUDE_DIR})

1
Sources/Plasma/NucleusLib/inc/CMakeLists.txt

@ -14,6 +14,7 @@ set(pnNucleusInc_HEADERS
plCreatableStrings.h
plDrawable.h
plgDispatch.h
plLoggable.h
plPhysical.h
plPipeline.h
plPipeResReq.h

248
Sources/Plasma/NucleusLib/inc/plLoggable.h

@ -0,0 +1,248 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plLoggable_inc
#define plLoggable_inc
#include "HeadSpin.h"
#include "plString.h"
#include "plFormat.h"
// Stub interface implemented by plStatusLog
class plLog
{
public:
virtual ~plLog() { }
virtual bool AddLine(const plString& line) = 0;
};
// An abstract base class which contains a status log and simple functions
// for writing Debug and Error msgs to the log
class plLoggable
{
protected:
mutable plLog* fStatusLog;
mutable bool fWeCreatedLog;
mutable bool fComplainAboutMissingLog;
// call plStatusLogMgr::CreateStatusLog with the options you want
virtual void ICreateStatusLog() const { };
void IDeleteLog()
{
if (fWeCreatedLog) {
delete fStatusLog;
}
fWeCreatedLog = false;
fStatusLog = nullptr;
}
public:
plLoggable()
: fStatusLog(nullptr), fWeCreatedLog(false),
fComplainAboutMissingLog(true)
{ }
virtual ~plLoggable()
{
IDeleteLog();
}
plLog* GetLog() const
{
// create status log if necessary
if (fStatusLog == nullptr) {
ICreateStatusLog(); // Usually overridden by derived class
if (fStatusLog) {
fWeCreatedLog = true;
}
}
#ifdef HS_DEBUGGING
if (fComplainAboutMissingLog) {
hsAssert(fStatusLog, "null log: override ICreateStatusLog()");
}
#endif
return fStatusLog;
}
void SetLog(plLog* log, bool deleteOnDestruct=false)
{
IDeleteLog();
fStatusLog = log;
fWeCreatedLog = deleteOnDestruct;
}
// logging
virtual bool Log(const plString& str) const
{
if (str.IsNull() || str.IsEmpty()) {
return true;
}
GetLog();
if (fStatusLog) {
return fStatusLog->AddLine(str);
}
return true;
}
virtual bool ErrorMsg(const plString& msg) const
{
return Log(plFormat("ERR: {}", msg));
}
virtual bool WarningMsg(const plString& msg) const
{
return Log(plFormat("WRN: {}", msg));
}
virtual bool AppMsg(const plString& msg) const
{
return Log(plFormat("APP: {}", msg));
}
virtual bool DebugMsg(const plString& msg) const
{
return Log(plFormat("DBG: {}", msg));
}
/////////////////////////////////////////////////////////////////////////
// DEPRECATED Log methods
/////////////////////////////////////////////////////////////////////////
hsDeprecated("plLoggable::LogF is deprecated -- use plFormat instead")
virtual bool LogF( const char * fmt, ... ) const
{
va_list args;
va_start(args, fmt);
bool ret = Log(plString::IFormat(fmt, args));
va_end(args);
return ret;
}
virtual bool LogV( const char * fmt, va_list args ) const
{
return Log(plString::IFormat(fmt, args));
}
virtual bool ErrorMsgV(const char* fmt, va_list args) const
{
return ErrorMsg(plString::IFormat(fmt, args));
}
virtual bool DebugMsgV(const char* fmt, va_list args) const
{
return DebugMsg(plString::IFormat(fmt, args));
}
virtual bool WarningMsgV(const char* fmt, va_list args) const
{
return WarningMsg(plString::IFormat(fmt, args));
}
virtual bool AppMsgV(const char* fmt, va_list args) const
{
return AppMsg(plString::IFormat(fmt, args));
}
hsDeprecated("plLoggable::ErrorMsg with format is deprecated -- use plFormat instead")
virtual bool ErrorMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = ErrorMsgV(fmt, args);
va_end(args);
return ret;
}
hsDeprecated("plLoggable::DebugMsg with format is deprecated -- use plFormat instead")
virtual bool DebugMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = DebugMsgV(fmt, args);
va_end(args);
return ret;
}
hsDeprecated("plLoggable::WarningMsg with format is deprecated -- use plFormat instead")
virtual bool WarningMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = WarningMsgV(fmt, args);
va_end(args);
return ret;
}
hsDeprecated("plLoggable::AppMsg with format is deprecated -- use plFormat instead")
virtual bool AppMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = AppMsgV(fmt, args);
va_end(args);
return ret;
}
};
#endif // plLoggable_inc

1
Sources/Plasma/NucleusLib/pnAsyncCore/CMakeLists.txt

@ -1,5 +1,6 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
set(pnAsyncCore_HEADERS

1
Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt

@ -39,7 +39,6 @@ target_link_libraries(pnNetCommon pnDispatch)
target_link_libraries(pnNetCommon pnFactory)
target_link_libraries(pnNetCommon pnKeyedObject)
target_link_libraries(pnNetCommon pnUUID)
target_link_libraries(pnNetCommon plStatusLog)
if(WIN32)
target_link_libraries(pnNetCommon ws2_32)
endif(WIN32)

56
Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp

@ -58,40 +58,70 @@ void plNetApp::SetInstance(plNetApp* app)
fInstance = app;
}
bool plNetApp::StaticErrorMsg(const char* fmt, ...)
bool plNetApp::StaticErrorMsg(const plString& msg)
{
if (!GetInstance()) {
return true;
}
return GetInstance()->ErrorMsg(msg);
}
bool plNetApp::StaticWarningMsg(const plString& msg)
{
if ( !GetInstance() )
if (!GetInstance()) {
return true;
}
return GetInstance()->WarningMsg(msg);
}
bool plNetApp::StaticAppMsg(const plString& msg)
{
if (!GetInstance()) {
return true;
}
return GetInstance()->AppMsg(msg);
}
bool plNetApp::StaticDebugMsg(const plString& msg)
{
if (!GetInstance()) {
return true;
}
return GetInstance()->DebugMsg(msg);
}
bool plNetApp::StaticErrorMsg(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
return GetInstance()->ErrorMsgV(fmt, args);
return StaticErrorMsg(plString::IFormat(fmt, args));
}
bool plNetApp::StaticDebugMsg(const char* fmt, ...)
{
if ( !GetInstance() )
return true;
va_list args;
va_start(args, fmt);
return GetInstance()->DebugMsgV(fmt, args);
return StaticDebugMsg(plString::IFormat(fmt, args));
}
bool plNetApp::StaticWarningMsg(const char* fmt, ...)
{
if ( !GetInstance() )
return true;
va_list args;
va_start(args, fmt);
return GetInstance()->WarningMsgV(fmt, args);
return StaticWarningMsg(plString::IFormat(fmt, args));
}
bool plNetApp::StaticAppMsg(const char* fmt, ...)
{
if ( !GetInstance() )
return true;
va_list args;
va_start(args, fmt);
return GetInstance()->AppMsgV(fmt, args);
return StaticAppMsg(plString::IFormat(fmt, args));
}
@ -165,4 +195,4 @@ void plNetClientApp::UnInheritNetMsgFlags(plMessage* msg)
// clear the 'force' option, so it doesn't get sent out again
msg->SetBCastFlag(plMessage::kNetForce | plMessage::kNetNonDeterministic, 0);
}
}
}

36
Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h

@ -46,11 +46,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsBitVector.h"
#include "plNetGroup.h"
#include "plLoggable.h"
#include "pnKeyedObject/hsKeyedObject.h"
#include "pnKeyedObject/plUoid.h"
#include "plStatusLog/plLoggable.h"
#define plVerifyConditionRet(NetApp,cond,ret,str) \
do { \
if (!(cond)) { \
@ -73,7 +73,7 @@ class plNetMessage;
typedef std::vector<plNetMember*> plNetMemberList;
typedef std::vector<uint32_t> plNetPlayerIDList;
//
//
// Common baseclasses for client and server net apps
//
@ -87,29 +87,43 @@ public:
{
kNullSend=0,
kNetCoreSingleThreaded,
kScreenMessages, // filter out illegal net game messages, used by gameserver&client
kScreenMessages, // filter out illegal net game messages, used by gameserver&client
FLAG_CEILING = 10 // stay below this or conflict with client/server specific flags
FLAG_CEILING = 10 // stay below this or conflict with client/server specific flags
};
static plNetApp* GetInstance();
static void SetInstance(plNetApp* app);
plNetApp() {}
plNetApp() {}
virtual ~plNetApp() {}
CLASSNAME_REGISTER( plNetApp );
GETINTERFACE_ANY( plNetApp, hsKeyedObject);
CLASSNAME_REGISTER(plNetApp);
GETINTERFACE_ANY(plNetApp, hsKeyedObject);
virtual void Shutdown() {}
void SetFlagsBit(int b, bool on=true) { fFlagsVec.SetBit(b, on); }
bool GetFlagsBit(int b) const { return fFlagsVec.IsBitSet(b) ? true : false; }
bool GetFlagsBit(int b) const { return fFlagsVec.IsBitSet(b) ? true : false; }
static bool StaticWarningMsg(const char* fmt, ...);
static bool StaticErrorMsg(const plString& msg);
static bool StaticWarningMsg(const plString& msg);
static bool StaticAppMsg(const plString& msg);
static bool StaticDebugMsg(const plString& msg);
// Deprecated
hsDeprecated("StaticErrorMsg with format is deprecated -- use plFormat instead")
static bool StaticErrorMsg(const char* fmt, ...);
static bool StaticDebugMsg(const char* fmt, ...);
hsDeprecated("StaticWarningMsg with format is deprecated -- use plFormat instead")
static bool StaticWarningMsg(const char* fmt, ...);
hsDeprecated("StaticAppMsg with format is deprecated -- use plFormat instead")
static bool StaticAppMsg(const char* fmt, ...);
hsDeprecated("StaticDebugMsg with format is deprecated -- use plFormat instead")
static bool StaticDebugMsg(const char* fmt, ...);
};
//

6
Sources/Plasma/NucleusLib/pnNetCommon/plNetResManager.cpp

@ -66,7 +66,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/hsKeyedObject.h"
#include "pnFactory/plCreatable.h"
#include "pnNetCommon/plNetApp.h"
#include "hsStream.h"
#include "hsStream.h"
plNetResManager::plNetResManager()
{
@ -83,12 +83,12 @@ plCreatable* plNetResManager::IReadCreatable(hsStream* s) const
{
plCreatable *pCre = plFactory::Create(hClass);
if (!pCre)
hsAssert( hClass == 0x8000, "Invalid creatable index" );
hsAssert(hClass == 0x8000, "Invalid creatable index");
return pCre;
}
plNetApp::StaticWarningMsg("NetResMgr::Can't create class %s", plFactory::GetNameOfClass(hClass));
plNetApp::StaticWarningMsg(plFormat("NetResMgr::Can't create class {}", plFactory::GetNameOfClass(hClass)));
return nil;
}

18
Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp

@ -209,8 +209,8 @@ bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t syn
{
#if 0
if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("NotOKToDirty - Not queueing SDL state, obj %s, sdl %s",
GetKeyName().c_str(), SDLStateName.c_str());
plNetClientApp::GetInstance()->DebugMsg(plFormat("NotOKToDirty - Not queueing SDL state, obj {}, sdl {}",
GetKeyName(), SDLStateName));
#endif
return false;
}
@ -219,8 +219,8 @@ bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t syn
{
#if 0
if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("LocalOnly Object - Not queueing SDL msg, obj %s, sdl %s",
GetKeyName().c_str(), SDLStateName.c_str());
plNetClientApp::GetInstance()->DebugMsg(plFormat("LocalOnly Object - Not queueing SDL msg, obj {}, sdl {}",
GetKeyName(), SDLStateName));
#endif
return false;
}
@ -235,8 +235,8 @@ bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t syn
else
{
if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("Queueing SDL state with 'maybe' ownership, obj %s, sdl %s",
GetKeyName().c_str(), SDLStateName.c_str());
plNetClientApp::GetInstance()->DebugMsg(plFormat("Queueing SDL state with 'maybe' ownership, obj {}, sdl {}",
GetKeyName(), SDLStateName));
}
}
@ -267,7 +267,7 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const plString& sdlName, uint
if (sendFlags & kForceFullSend)
(*it).fSendFlags |= kForceFullSend;
if (sendFlags & kBCastToClients)
(*it).fSendFlags |= kBCastToClients;
(*it).fSendFlags |= kBCastToClients;
found=true;
break;
}
@ -281,8 +281,8 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const plString& sdlName, uint
else
{
#if 0
plNetClientApp::GetInstance()->DebugMsg("Not queueing diplicate request for SDL state, obj %s, sdl %s",
objKey->GetName().c_str(), sdlName.c_str());
plNetClientApp::GetInstance()->DebugMsg(plFormat("Not queueing diplicate request for SDL state, obj {}, sdl {}",
objKey->GetName(), sdlName));
#endif
}
}

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

@ -274,31 +274,43 @@ const char* ProcessTab(const char* fmt)
return fmt;
}
//
// create StatusLog if necessary
//
void plNetClientMgr::ICreateStatusLog() const
{
if (!fStatusLog)
{
fStatusLog = plStatusLogMgr::GetInstance().CreateStatusLog(40, "network.log",
plStatusLog::kTimestamp | plStatusLog::kFilledBackground | plStatusLog::kAlignToTop |
plStatusLog::kServerTimestamp);
}
}
//
// override for plLoggable
//
bool plNetClientMgr::Log(const char* str) const
bool plNetClientMgr::Log(const plString& str) const
{
if (strlen(str) == 0)
if (str.IsNull() || str.IsEmpty()) {
return true;
}
// prepend raw time
plString buf2 = plFormat("{.2f} {}", hsTimer::GetSeconds(), ProcessTab(str));
plString buf2 = plFormat("{.2f} {}", hsTimer::GetSeconds(), ProcessTab(str.c_str()));
if ( GetConsoleOutput() )
hsStatusMessage(buf2.c_str());
// create status log if necessary
if(fStatusLog==nil)
{
fStatusLog = plStatusLogMgr::GetInstance().CreateStatusLog(40, "network.log",
plStatusLog::kTimestamp | plStatusLog::kFilledBackground | plStatusLog::kAlignToTop |
plStatusLog::kServerTimestamp);
fWeCreatedLog = true;
}
GetLog();
plNetObjectDebugger::GetInstance()->LogMsgIfMatch(buf2.c_str());
return fStatusLog->AddLine(buf2.c_str());
if (fStatusLog) {
return fStatusLog->AddLine(buf2);
}
return true;
}
//

4
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h

@ -237,6 +237,8 @@ private:
int ISendGameMessage(plMessage* msg);
void IDisableNet ();
void ICreateStatusLog() const override;
public:
plNetClientMgr();
~plNetClientMgr();
@ -263,7 +265,7 @@ public:
void SendApplyAvatarCustomizationsMsg(const plKey msgReceiver, bool netPropagate=true, bool localPropagate=true);
// plLoggable
bool Log(const char* str) const;
bool Log(const plString& str) const override;
// setters
void SetIniAuthServer(const char * value) { fIniAuthServer=value;}

4
Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.h

@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plNetMsgScreener_h
#include "pnKeyedObject/plKey.h"
#include "plStatusLog/plLoggable.h"
#include "plLoggable.h"
//
// Class which decides what game messages are allowed to be sent to the server.
@ -78,4 +78,4 @@ protected:
virtual bool IAmClient() const = 0;
};
#endif // plNetMsgScreener_h
#endif // plNetMsgScreener_h

3
Sources/Plasma/PubUtilLib/plSDL/plSDL.h

@ -516,6 +516,9 @@ private:
bool IParseStateDesc(const plFileName& fileName, hsStream* stream, char token[],
plStateDescriptor*& curDesc) const;
void DebugMsg(const plString& msg) const;
hsDeprecated("plSDLParser::DebugMsg with format is deprecated -- use plFormat instead")
void DebugMsg(const char* fmt, ...) const;
void DebugMsgV(const char* fmt, va_list args) const;

11
Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp

@ -47,6 +47,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
static const int kTokenLen=256;
void plSDLParser::DebugMsg(const plString& msg) const
{
return;
plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp();
if (netApp)
hsLogEntry(netApp->DebugMsg(msg));
else
hsStatusMessage(msg.c_str());
}
void plSDLParser::DebugMsg(const char* fmt, ...) const
{
return;

2
Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp

@ -129,7 +129,7 @@ void plStateDataRecord::IDeleteVarsList(VarsList& vars)
void plStateDataRecord::IInitDescriptor(const plString& name, int version)
{
plStateDescriptor* sd = plSDLMgr::GetInstance()->FindDescriptor(name, version);
//hsAssert( sd, plString::Format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", name.c_str(), version ).c_str() );
//hsAssert( sd, plFormat("Failed to find sdl descriptor: {},{}. Missing legacy descriptor?", name, version ).c_str() );
if (sd)
IInitDescriptor(sd);
}

7
Sources/Plasma/PubUtilLib/plStatusLog/CMakeLists.txt

@ -5,18 +5,19 @@ include_directories("../../PubUtilLib")
set(plStatusLog_SOURCES
plEncryptLogLine.cpp
plLoggable.cpp
plStatusLog.cpp
)
set(plStatusLog_HEADERS
plEncryptLogLine.h
plLoggable.h
plStatusLog.h
)
add_library(plStatusLog STATIC ${plStatusLog_SOURCES} ${plStatusLog_HEADERS})
target_link_libraries(plStatusLog CoreLib plFile plUnifiedTime)
target_link_libraries(plStatusLog CoreLib)
target_link_libraries(plStatusLog pnNucleusInc)
target_link_libraries(plStatusLog plFile)
target_link_libraries(plStatusLog plUnifiedTime)
source_group("Source Files" FILES ${plStatusLog_SOURCES})
source_group("Header Files" FILES ${plStatusLog_HEADERS})

181
Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.cpp

@ -1,181 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 "plLoggable.h"
#include "plStatusLog.h"
#include "hsTemplates.h"
plLoggable::~plLoggable()
{
IDeleteLog();
}
void plLoggable::IDeleteLog()
{
if ( fWeCreatedLog )
delete fStatusLog;
fWeCreatedLog = false;
fStatusLog = nil;
}
plStatusLog* plLoggable::GetLog() const
{
// create status log if necessary
if(fStatusLog==nil)
{
ICreateStatusLog(); // Usually overridden by derived class
if ( fStatusLog )
fWeCreatedLog = true;
}
#ifdef HS_DEBUGGING
if ( fComplainAboutMissingLog )
{
hsAssert(fStatusLog, "nil fStatusLog. Should override ICreateStatusLog()");
}
#endif
return fStatusLog;
}
void plLoggable::SetLog( plStatusLog * log, bool deleteOnDestruct/*=false */)
{
IDeleteLog();
fStatusLog = log;
fWeCreatedLog = deleteOnDestruct;
}
bool plLoggable::Log( const char * str ) const
{
return Log(plString::FromUtf8(str));
}
bool plLoggable::Log(const plString& str) const
{
if (str.IsNull() || str.IsEmpty()) {
return true;
}
GetLog();
if (fStatusLog) {
return fStatusLog->AddLine(str.c_str());
}
return true;
}
bool plLoggable::LogF( const char * fmt, ... ) const
{
va_list args;
va_start(args, fmt);
bool ret = Log(plString::IFormat(fmt, args));
va_end(args);
return ret;
}
bool plLoggable::LogV( const char * fmt, va_list args ) const
{
return Log(plString::IFormat(fmt, args));
}
bool plLoggable::DebugMsgV(const char* fmt, va_list args) const
{
return Log(plString("DBG: ") + plString::IFormat(fmt, args));
}
bool plLoggable::ErrorMsgV(const char* fmt, va_list args) const
{
return Log(plString("ERR: ") + plString::IFormat(fmt, args));
}
bool plLoggable::WarningMsgV(const char* fmt, va_list args) const
{
return Log(plString("WRN: ") + plString::IFormat(fmt, args));
}
bool plLoggable::AppMsgV(const char* fmt, va_list args) const
{
return Log(plString("APP: ") + plString::IFormat(fmt, args));
}
///////////////////////////////////////////////////////////////
bool plLoggable::DebugMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = DebugMsgV(fmt, args);
va_end(args);
return ret;
}
bool plLoggable::ErrorMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = ErrorMsgV(fmt, args);
va_end(args);
return ret;
}
bool plLoggable::WarningMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = WarningMsgV(fmt, args);
va_end(args);
return ret;
}
bool plLoggable::AppMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
bool ret = AppMsgV(fmt, args);
va_end(args);
return ret;
}

86
Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.h

@ -1,86 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plLoggable_inc
#define plLoggable_inc
#include "HeadSpin.h"
#include "plString.h"
//
// An abstract base class which contains a status log and simple functions
// for writing Debug and Error msgs to the log
//
class plStatusLog;
class plLoggable
{
protected:
mutable plStatusLog* fStatusLog;
mutable bool fWeCreatedLog;
mutable bool fComplainAboutMissingLog;
virtual void ICreateStatusLog() const { }; // call plStatusLogMgr::CreateStatusLog with the options you want
void IDeleteLog();
public:
plLoggable() : fStatusLog(nil), fWeCreatedLog(false),fComplainAboutMissingLog(true) { }
virtual ~plLoggable();
plStatusLog* GetLog() const;
void SetLog( plStatusLog * log, bool deleteOnDestruct=false );
// logging
virtual bool Log( const char * str ) const;
virtual bool Log(const plString& str) const;
virtual bool LogF( const char * fmt, ... ) const;
virtual bool LogV( const char * fmt, va_list args ) const;
virtual bool ErrorMsgV(const char* fmt, va_list args) const ;
virtual bool DebugMsgV(const char* fmt, va_list args) const ;
virtual bool WarningMsgV(const char* fmt, va_list args) const ;
virtual bool AppMsgV(const char* fmt, va_list args) const ;
virtual bool ErrorMsg(const char* fmt, ...) const ;
virtual bool DebugMsg(const char* fmt, ...) const ;
virtual bool WarningMsg(const char* fmt, ...) const ;
virtual bool AppMsg(const char* fmt, ...) const ;
};
#endif // plLoggable_inc

17
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

@ -495,6 +495,23 @@ bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
//// AddLine /////////////////////////////////////////////////////////////////
bool plStatusLog::AddLine(const plString& line)
{
if (fLoggingOff && !fForceLog) {
return true;
}
bool ret = true;
std::vector<plString> lines = line.Split("\n");
for (plString& str : lines)
{
ret &= IAddLine(str.c_str(), -1, kWhite);
}
return ret;
}
bool plStatusLog::AddLine( const char *line, uint32_t color )
{
char *c, *str;

6
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsThread.h"
#include "plFileSystem.h"
#include "plLoggable.h"
#include <string>
@ -70,7 +71,8 @@ class plPipeline;
class plStatusLogMgr;
class plStatusLogDrawerStub;
class plStatusLog
class plStatusLog : public plLog
{
friend class plStatusLogMgr;
friend class plStatusLogDrawerStub;
@ -157,6 +159,8 @@ class plStatusLog
~plStatusLog();
bool AddLine(const plString& line) override;
bool AddLine( const char *line, uint32_t color = kWhite );
/// printf-like functions

4
Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp

@ -306,8 +306,8 @@ const char* plUnifiedTime::Print() const
// short year, month, day, hour, minute, second;
// GetTime(year, month, day, hour, minute, second);
//
// s = plString::Format("yr %d mo %d day %d hour %d min %d sec %d",
// year, month, day, hour, minute, second);
// s = plFormat("yr {} mo {} day {} hour {} min {} sec {}",
// year, month, day, hour, minute, second);
s = Format("%c");
return s.c_str();

Loading…
Cancel
Save