Browse Source

Add more temporary hack macros to help speed up conversion and testing

Michael Hansen 12 years ago
parent
commit
442a733fbb
  1. 15
      Sources/Plasma/CoreLib/plString.h
  2. 14
      Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp
  3. 10
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  4. 11
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  5. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  6. 3
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  7. 20
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  8. 7
      Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp
  9. 10
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp
  10. 5
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h
  11. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
  12. 2
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h
  13. 4
      Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp
  14. 36
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  15. 6
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
  16. 3
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrLoad.cpp
  17. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp
  18. 18
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp
  19. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp
  20. 46
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  21. 3
      Sources/Plasma/PubUtilLib/plNetCommon/plNetMember.h
  22. 6
      Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h
  23. 10
      Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.cpp
  24. 4
      Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.cpp
  25. 11
      Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h
  26. 7
      Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp
  27. 2
      Sources/Tools/plResBrowser/plResTreeView.cpp

15
Sources/Plasma/CoreLib/plString.h

@ -33,8 +33,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <vector>
#include <functional>
#define _TEMP_CONVERT_FROM_LITERAL(x) plString::FromUtf8((x))
#define _TEMP_CONVERT_FROM_WCHAR_T(x) plString::FromWchar((x))
/* NOTE & TODO:
* These macros are intentionally annoyingly named, to mark what code
* needs to be cleaned up after a larger portion of Plasma is converted
* to plString.
*/
#define _TEMP_CONVERT_FROM_LITERAL(x) plString::FromUtf8((x))
#define _TEMP_CONVERT_FROM_WCHAR_T(x) plString::FromWchar((x))
#define _TEMP_CONVERT_TO_CONST_CHAR(x) (x).c_str()
#define _TEMP_CONVERT_TO_CONST_CHAR_S(x) (x).s_str()
typedef unsigned int UniChar;
@ -176,7 +183,9 @@ public:
}
const char *c_str() const { return fUtf8Buffer.GetData(); }
const char *s_str() const { return c_str() ? c_str() : ""; }
const char *s_str(const char *safe = "") const { return c_str() ? c_str() : safe; }
char CharAt(size_t position) const { return c_str()[position]; }
plStringBuffer<char> ToUtf8() const { return fUtf8Buffer; }
plStringBuffer<UInt16> ToUtf16() const;
plStringBuffer<wchar_t> ToWchar() const;

14
Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp

@ -333,8 +333,8 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
// InviteReceived
case kSrv2Cli_GameMgr_InviteReceived: {
const Srv2Cli_GameMgr_InviteReceived & gmMsg = *(const Srv2Cli_GameMgr_InviteReceived *)gameMgrMsg->netMsg;
const char * inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite received: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName ? inviterName : "<Unknown>");
const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite received: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.s_str("<Unknown>"));
}
return true;
@ -342,8 +342,8 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
// InviteRevoked
case kSrv2Cli_GameMgr_InviteRevoked: {
const Srv2Cli_GameMgr_InviteRevoked & gmMsg = *(const Srv2Cli_GameMgr_InviteRevoked *)gameMgrMsg->netMsg;
const char * inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite revoked: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName ? inviterName : "<Unknown>");
const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite revoked: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.s_str("<Unknown>"));
}
return true;
@ -372,7 +372,7 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
cli->GetName(),
cli->GetGameId(),
netMsg.playerId
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId)
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId).c_str()
: "Computer"
);
}
@ -387,7 +387,7 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
cli->GetName(),
cli->GetGameId(),
netMsg.playerId
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId)
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId).c_str()
: "Computer"
);
}
@ -503,7 +503,7 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
const Srv2Cli_TTT_MoveMade & netMsg = *(const Srv2Cli_TTT_MoveMade *)gameCliMsg->netMsg;
const char * playerName
= netMsg.playerId
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId)
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId).c_str()
: "Computer";
AddLineF(
"[Game %s:%u] %s moved:",

10
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -229,13 +229,13 @@ PF_CONSOLE_CMD( Net, // groupName
"broadcast chat msg" ) // helpString
{
// send chat text
std::string text=plNetClientMgr::GetInstance()->GetPlayerName();
text += ":";
plString text=plNetClientMgr::GetInstance()->GetPlayerName();
text += _TEMP_CONVERT_FROM_LITERAL(":");
int i;
for(i=0;i<numParams;i++)
{
text += (char*)params[i];
text += " ";
text += plString::FromUtf8( (char*)params[i] );
text += _TEMP_CONVERT_FROM_LITERAL(" ");
}
plConsoleMsg *cMsg = TRACKED_NEW plConsoleMsg( plConsoleMsg::kAddLine, text.c_str() );
cMsg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce);
@ -1014,7 +1014,7 @@ PF_CONSOLE_CMD(
return;
}
if (unsigned playerId = plNetClientMgr::GetInstance()->GetPlayerIdByName((const char *)params[1])) {
if (unsigned playerId = plNetClientMgr::GetInstance()->GetPlayerIdByName(plString::FromUtf8((const char *)params[1]))) {
ttt->InvitePlayer(playerId);
PrintStringF(PrintString, "Sent invite to playerId %u", playerId);
}

11
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -455,8 +455,7 @@ hsBool cyMisc::WasLocallyNotified(pyKey &selfkey)
//
const char* cyMisc::GetClientName(pyKey &avKey)
{
const char* ret=plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey());
return (ret==nil) ? "" : ret;
return plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey()).s_str();
}
PyObject* cyMisc::GetAvatarKeyFromClientID(int clientID)
@ -549,7 +548,7 @@ hsBool cyMisc::ValidateKey(pyKey& key)
//
const char* cyMisc::GetLocalClientName()
{
return plNetClientMgr::GetInstance()->GetPlayerName();
return plNetClientMgr::GetInstance()->GetPlayerName().c_str();
}
@ -946,7 +945,7 @@ PyObject* cyMisc::GetLocalAvatar()
PyObject* cyMisc::GetLocalPlayer()
{
return pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(),
plNetClientMgr::GetInstance()->GetPlayerName(),
plNetClientMgr::GetInstance()->GetPlayerName().c_str(),
plNetClientMgr::GetInstance()->GetPlayerID(),
0.0 );
}
@ -1003,7 +1002,7 @@ std::vector<PyObject*> cyMisc::GetPlayerList()
// only non-ignored people in list and not in ignore list
if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) )
{
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object
// modifies playerObj
@ -1038,7 +1037,7 @@ std::vector<PyObject*> cyMisc::GetPlayerListDistanceSorted()
// only non-ignored people in list and not in ignore list
if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) )
{
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object
// modifies playerObj

2
Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp

@ -1965,7 +1965,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
if ( mbrIndex != -1 )
{
plNetTransportMember *mbr = plNetClientMgr::GetInstance()->TransportMgr().GetMember( mbrIndex );
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
}
else
{

3
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp

@ -609,9 +609,8 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
}
else
{
char str[256];
if (!key)
plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze(str));
plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze().c_str());
else
if (!key->ObjectIsLoaded())
plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s",

20
Sources/Plasma/FeatureLib/pfPython/pyVault.cpp

@ -652,24 +652,24 @@ void pyVault::CreateNeighborhood()
link.GetAgeInfo()->SetAgeFilename(kNeighborhoodAgeFilename);
link.GetAgeInfo()->SetAgeInstanceName(kNeighborhoodAgeInstanceName);
std::string title;
std::string desc;
plString title;
plString desc;
unsigned nameLen = StrLen(nc->GetPlayerName());
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S')
unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
{
xtl::format( title, "%s'", nc->GetPlayerName() );
xtl::format( desc, "%s' %s", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() );
title = plString::Format( "%s'", nc->GetPlayerName().c_str() );
desc = plString::Format( "%s' %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
}
else
{
xtl::format( title, "%s's", nc->GetPlayerName() );
xtl::format( desc, "%s's %s", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() );
title = plString::Format( "%s's", nc->GetPlayerName().c_str() );
desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
}
link.GetAgeInfo()->SetAgeInstanceGuid(&plUUID(GuidGenerate()));
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() );
link.GetAgeInfo()->SetAgeDescription( desc.c_str() );
link.GetAgeInfo()->SetAgeUserDefinedName( _TEMP_CONVERT_TO_CONST_CHAR(title) );
link.GetAgeInfo()->SetAgeDescription( _TEMP_CONVERT_TO_CONST_CHAR(desc) );
VaultRegisterOwnedAge(&link);
}

7
Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp

@ -143,12 +143,9 @@ void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid)
if (!(inUoid == myUoid))
{
#if !HS_BUILD_FOR_UNIX // disable for unix servers
char inStr[255], myStr[255];
inUoid.StringIze(inStr);
myUoid.StringIze(myStr);
hsAssert(false,
xtl::format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s",
fpKey->GetName() ? fpKey->GetName() : "?", inStr, myStr).c_str());
plString::Format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s",
fpKey->GetName() ? fpKey->GetName() : "?", inUoid.StringIze().c_str(), myUoid.StringIze().c_str()).c_str());
#endif
}
((plKeyImp*)fpKey)->UnRegister();

10
Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp

@ -118,10 +118,9 @@ hsBool plLocation::IsVirtual() const
}
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* plLocation::StringIze(char* str) const // Format to displayable string
plString plLocation::StringIze() const // Format to displayable string
{
sprintf(str, "S0x%xF0x%x", fSequenceNumber, int(fFlags));
return str;
return plString::Format("S0x%xF0x%x", fSequenceNumber, int(fFlags));
}
plLocation plLocation::MakeReserved(UInt32 number)
@ -272,13 +271,12 @@ plUoid& plUoid::operator=(const plUoid& rhs)
}
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* plUoid::StringIze(char* str) const // Format to displayable string
plString plUoid::StringIze() const // Format to displayable string
{
sprintf(str, "(0x%x:0x%x:%s:C:[%u,%u])",
return plString::Format("(0x%x:0x%x:%s:C:[%u,%u])",
fLocation.GetSequenceNumber(),
int(fLocation.GetFlags()),
fObjectName,
GetClonePlayerID(),
GetCloneID());
return str;
}

5
Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plLoadMask.h"
class hsStream;
class plString;
//// plLocation //////////////////////////////////////////////////////////////
@ -124,7 +125,7 @@ public:
bool operator<(const plLocation& loc ) const { return fSequenceNumber < loc.fSequenceNumber; }
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* StringIze(char* str) const; // Format to displayable string. Returns the same string for convenience
plString StringIze() const; // Format to displayable string.
static plLocation MakeReserved(UInt32 number);
static plLocation MakeNormal(UInt32 number);
@ -174,7 +175,7 @@ public:
void SetObjectID(UInt32 id) { fObjectID = id; }
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* StringIze(char* str) const; // Format to displayable string
plString StringIze() const; // Format to displayable string
protected:
enum ContentsFlags // for read/write functions

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

@ -178,7 +178,7 @@ public:
// functions that all net client apps should implement
virtual int SendMsg(plNetMessage* msg) = 0;
virtual UInt32 GetPlayerID() const = 0;
virtual const char * GetPlayerName( const plKey avKey=nil ) const = 0;
virtual plString GetPlayerName( const plKey avKey=nil ) const = 0;
// commonly used net client app functions
virtual float GetCurrentAgeTimeOfDayPercent() const { hsAssert(false, "stub"); return 0.; }

2
Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnInputCore/plKeyDef.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include "plString.h"
class plMessage;
struct plMouseInfo;
class plPipeline;
@ -189,6 +190,7 @@ public:
static bool GetInverted() { return plMouseDevice::bInverted; }
static void SetInverted(bool inverted) { plMouseDevice::bInverted = inverted; }
static void AddNameToCursor(const char* name);
static void AddNameToCursor(const plString& name) { AddNameToCursor(_TEMP_CONVERT_TO_CONST_CHAR(name)); }
static void AddIDNumToCursor(UInt32 idNum);
static void AddCCRToCursor();

4
Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp

@ -837,8 +837,8 @@ void plSceneInputInterface::ILinkOffereeToAge()
std::string title;
std::string desc;
unsigned nameLen = StrLen(plNetClientMgr::GetInstance()->GetPlayerName());
if (plNetClientMgr::GetInstance()->GetPlayerName()[nameLen - 1] == 's' || plNetClientMgr::GetInstance()->GetPlayerName()[nameLen - 1] == 'S') {
unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize();
if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') {
xtl::format( title, "%s'", plNetClientMgr::GetInstance()->GetPlayerName() );
xtl::format( desc, "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() );
}

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

@ -619,9 +619,8 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
if ( !hsgResMgr::ResMgr()->FindKey( tmpUoid ) )
{
// discard the state if object not found in dataset.
char tmp[256];
hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'",
tmpUoid.StringIze(tmp),
tmpUoid.StringIze().c_str(),
pl->fSDRec->GetDescriptor()->GetName() ) );
delete pl;
it = fPendingLoads.erase(it);
@ -663,7 +662,6 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
double rawSecs = hsTimer::GetSeconds();
if ((rawSecs - pl->fQueuedTime) > 60.f /*secs*/)
{
char tmp[256], tmp2[256];
if (pl->fQueueTimeResets >= 5)
{
// if this is our fifth time in here then we've been queued
@ -671,7 +669,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. Removing...",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName() : "?",
pl->fUoid.StringIze(tmp2), pl->fKey ? pl->fKey->GetUoid().StringIze(tmp) : "?",
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets);
delete pl;
@ -681,7 +679,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. %s",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName() : "?",
pl->fUoid.StringIze(tmp2), pl->fKey ? pl->fKey->GetUoid().StringIze(tmp) : "?",
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets,
so ? "(not loaded)" : "(not final)" );
// reset queue time so we don't spew too many log msgs.
@ -938,8 +936,7 @@ hsBool plNetClientMgr::MsgReceive( plMessage* msg )
{
hsAssert(fAgeSDLObjectKey==nil, "already have a ref to age sdl hook");
fAgeSDLObjectKey = ref->GetRef()->GetKey();
char tmp[256];
DebugMsg("Age SDL hook object created, uoid=%s", fAgeSDLObjectKey->GetUoid().StringIze(tmp));
DebugMsg("Age SDL hook object created, uoid=%s", fAgeSDLObjectKey->GetUoid().StringIze().c_str());
}
else
{
@ -1149,34 +1146,34 @@ bool plNetClientMgr::CanSendMsg(plNetMessage * msg)
// Return the net client (account) name of the player whose avatar
// key is provided. If avKey is nil, returns local client name.
//
const char* plNetClientMgr::GetPlayerName(const plKey avKey) const
plString plNetClientMgr::GetPlayerName(const plKey avKey) const
{
// local case
if (!avKey || avKey==GetLocalPlayerKey())
return NetCommGetPlayer()->playerNameAnsi;
return plString::FromIso8859_1(NetCommGetPlayer()->playerNameAnsi);
plNetTransportMember* mbr=TransportMgr().GetMember(TransportMgr().FindMember(avKey));
return mbr ? mbr->GetPlayerName() : nil;
return mbr ? mbr->GetPlayerName() : plString::Null;
}
const char * plNetClientMgr::GetPlayerNameById (unsigned playerId) const {
plString plNetClientMgr::GetPlayerNameById (unsigned playerId) const {
// local case
if (NetCommGetPlayer()->playerInt == playerId)
return NetCommGetPlayer()->playerNameAnsi;
return plString::FromIso8859_1(NetCommGetPlayer()->playerNameAnsi);
plNetTransportMember * mbr = TransportMgr().GetMember(TransportMgr().FindMember(playerId));
return mbr ? mbr->GetPlayerName() : nil;
return mbr ? mbr->GetPlayerName() : plString::Null;
}
unsigned plNetClientMgr::GetPlayerIdByName (const char name[]) const {
unsigned plNetClientMgr::GetPlayerIdByName (const plString & name) const {
// local case
if (0 == StrCmp(name, NetCommGetPlayer()->playerNameAnsi, (unsigned)-1))
if (0 == name.Compare(NetCommGetPlayer()->playerNameAnsi))
NetCommGetPlayer()->playerInt;
unsigned n = TransportMgr().GetNumMembers();
for (unsigned i = 0; i < n; ++i)
if (plNetTransportMember * member = TransportMgr().GetMember(i))
if (0 == StrCmp(name, member->GetPlayerName(), (unsigned)-1))
if (0 == name.Compare(member->GetPlayerName()))
return member->GetPlayerID();
return 0;
}
@ -1483,10 +1480,9 @@ void plNetClientMgr::AddPendingLoad(PendingLoad *pl)
pl->fKey = hsgResMgr::ResMgr()->FindKey(pl->fUoid);
// check for age SDL state
char tmp[256];
if (pl->fUoid.GetObjectName() && !strcmp(pl->fUoid.GetObjectName(), plSDL::kAgeSDLObjectName))
{
DebugMsg("Recv SDL state for age hook object, uoid=%s", pl->fUoid.StringIze(tmp));
DebugMsg("Recv SDL state for age hook object, uoid=%s", pl->fUoid.StringIze().c_str());
if (!pl->fKey)
WarningMsg("Can't find age hook object, nil key!");
else
@ -1499,12 +1495,12 @@ void plNetClientMgr::AddPendingLoad(PendingLoad *pl)
if (!pl->fKey->ObjectIsLoaded())
{
WarningMsg("Object %s not loaded, withholding SDL state",
pl->fKey->GetUoid().StringIze(tmp));
pl->fKey->GetUoid().StringIze().c_str());
}
else if (!pl->fKey->ObjectIsLoaded()->IsFinal())
{
WarningMsg("Object %s is not FINAL, withholding SDL state",
pl->fKey->GetUoid().StringIze(tmp));
pl->fKey->GetUoid().StringIze().c_str());
}
}

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

@ -288,9 +288,9 @@ public:
// getters
UInt32 GetPlayerID( void ) const;
const char * GetPlayerName( const plKey avKey=nil ) const;
const char * GetPlayerNameById (unsigned playerId) const;
unsigned GetPlayerIdByName(const char name[]) const;
plString GetPlayerName( const plKey avKey=nil ) const;
plString GetPlayerNameById (unsigned playerId) const;
unsigned GetPlayerIdByName(const plString & name) const;
UInt8 GetJoinOrder() const { return fJoinOrder; } // only valid at join time

3
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrLoad.cpp

@ -107,8 +107,7 @@ plKey plNetClientMgr::ILoadClone(plLoadCloneMsg *pCloneMsg)
{
if (cloneKey->ObjectIsLoaded())
{
char tmp[256];
DebugMsg("ILoadClone: object %s is already loaded, ignoring", cloneKey->GetUoid().StringIze(tmp));
DebugMsg("ILoadClone: object %s is already loaded, ignoring", cloneKey->GetUoid().StringIze().c_str());
return cloneKey;
}

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

@ -159,7 +159,7 @@ void plNetClientMgr::ISendCCRPetition(plCCRPetitionMsg* petMsg)
char buffy[20];
sprintf( buffy, "%lu", GetPlayerID() );
info.AddValue( "Petition", "PlayerID", buffy );
info.AddValue( "Petition", "PlayerName", GetPlayerName() );
info.AddValue( "Petition", "PlayerName", _TEMP_CONVERT_TO_CONST_CHAR(GetPlayerName()) );
// write config info formatted like an ini file to a buffer
hsRAMStream ram;

18
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp

@ -103,7 +103,7 @@ void plNetClientMgr::IShowLists()
sprintf(str, "%s%s %s p2p=%d dist=%.1f",
mbr->GetTransportFlags() & plNetTransportMember::kSendingVoice ? "V" : " ",
mbr->GetTransportFlags() & plNetTransportMember::kSendingActions ? "A" : " ",
mbr->AsStdString().c_str(),
mbr->AsString().c_str(),
mbr->IsPeerToPeer(),
mbr->GetDistSq() != hsScalarMax ? hsSquareRoot(mbr->GetDistSq()) :-1.f);
txt.DrawString(x,y,str);
@ -121,7 +121,7 @@ void plNetClientMgr::IShowLists()
y+=yOff;
for(i=0;i<GetListenList()->GetNumMembers();i++)
{
sprintf(str, "name=%s", GetListenList()->GetMember(i)->AsStdString().c_str());
sprintf(str, "name=%s", GetListenList()->GetMember(i)->AsString().c_str());
txt.DrawString(x,y,str);
y+=yOff;
}
@ -133,7 +133,7 @@ void plNetClientMgr::IShowLists()
y+=yOff;
for(i=0;i<GetTalkList()->GetNumMembers();i++)
{
sprintf(str, "name=%s", GetTalkList()->GetMember(i)->AsStdString().c_str());
sprintf(str, "name=%s", GetTalkList()->GetMember(i)->AsString().c_str());
txt.DrawString(x,y,str);
y+=yOff;
}
@ -231,8 +231,8 @@ void plNetClientMgr::IShowRelevanceRegions()
//
UInt32 maxPlayerName = 0;
txt.DrawString(x, y, GetPlayerName());
maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(GetPlayerName()));
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(GetPlayerName()));
maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(_TEMP_CONVERT_TO_CONST_CHAR(GetPlayerName())));
y += yOff;
int i;
@ -243,9 +243,9 @@ void plNetClientMgr::IShowRelevanceRegions()
if (mbr->IsServer())
continue;
const char* name = mbr->GetPlayerName();
txt.DrawString(x, y, name);
maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(name));
const plString& name = mbr->GetPlayerName();
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(name));
maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(_TEMP_CONVERT_TO_CONST_CHAR(name)));
y += yOff;
}
@ -359,7 +359,7 @@ void plNetClientMgr::IShowAvatars()
ori = (player ? player->GetLocalToWorld() * hsVector3(0, -1, 0) : hsVector3(0, 0, 0));
sprintf(str, "%s: pos(%.2f, %.2f, %.2f) ori(%.2f, %.2f, %.2f)",
mbr->AsStdString().c_str(), pos.fX, pos.fY, pos.fZ, ori.fX, ori.fY, ori.fZ);
mbr->AsString().c_str(), pos.fX, pos.fY, pos.fZ, ori.fX, ori.fY, ori.fZ);
txt.DrawString(x,y,str);
y+=yOff;

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

@ -487,7 +487,7 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgMembersList)
{
plNetTransportMember* mbr = TRACKED_NEW plNetTransportMember(nc);
IFillInTransportMember(m->MemberListInfo()->GetMember(i), mbr);
hsLogEntry(nc->DebugMsg("\tAdding transport member, name=%s, p2p=%d, plrID=%d\n", mbr->AsStdString().c_str(), mbr->IsPeerToPeer(), mbr->GetPlayerID()));
hsLogEntry(nc->DebugMsg("\tAdding transport member, name=%s, p2p=%d, plrID=%d\n", mbr->AsString().c_str(), mbr->IsPeerToPeer(), mbr->GetPlayerID()));
int idx=nc->fTransport.AddMember(mbr);
hsAssert(idx>=0, "Failed adding member?");

46
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -932,23 +932,23 @@ UInt8 plNetLinkingMgr::IPreProcessLink(void)
if (!info->HasAgeUserDefinedName())
{
// set user-defined name
std::string title;
unsigned nameLen = StrLen(nc->GetPlayerName());
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S')
xtl::format(title, "%s'", nc->GetPlayerName());
plString title;
unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
title = plString::Format("%s'", nc->GetPlayerName());
else
xtl::format(title, "%s's", nc->GetPlayerName());
info->SetAgeUserDefinedName(title.c_str());
title = plString::Format("%s's", nc->GetPlayerName());
info->SetAgeUserDefinedName(_TEMP_CONVERT_TO_CONST_CHAR(title));
}
if (!info->HasAgeDescription())
{
// set description
std::string desc;
unsigned nameLen = StrLen(nc->GetPlayerName());
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S')
xtl::format(desc, "%s' %s", nc->GetPlayerName(), info->GetAgeInstanceName());
plString desc;
unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
desc = plString::Format("%s' %s", nc->GetPlayerName().c_str(), info->GetAgeInstanceName());
else
xtl::format(desc, "%s's %s", nc->GetPlayerName(), info->GetAgeInstanceName());
desc = plString::Format("%s's %s", nc->GetPlayerName().c_str(), info->GetAgeInstanceName());
info->SetAgeDescription(desc.c_str());
}
if (!info->HasAgeInstanceGuid()) {
@ -970,25 +970,25 @@ UInt8 plNetLinkingMgr::IPreProcessLink(void)
if (!info->HasAgeUserDefinedName())
{
// set user-defined name
std::string title;
unsigned nameLen = StrLen(nc->GetPlayerName());
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S')
xtl::format(title, "%s'", nc->GetPlayerName());
plString title;
unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
title = plString::Format("%s'", nc->GetPlayerName().c_str());
else
xtl::format(title, "%s's", nc->GetPlayerName());
info->SetAgeUserDefinedName(title.c_str());
title = plString::Format("%s's", nc->GetPlayerName().c_str());
info->SetAgeUserDefinedName(_TEMP_CONVERT_TO_CONST_CHAR(title));
}
if (!info->HasAgeDescription())
{
// set description
std::string desc;
unsigned nameLen = StrLen(nc->GetPlayerName());
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S')
xtl::format(desc, "%s' %s", nc->GetPlayerName(), info->GetAgeInstanceName());
plString desc;
unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
desc = plString::Format("%s' %s", nc->GetPlayerName().c_str(), info->GetAgeInstanceName());
else
xtl::format(desc, "%s's %s", nc->GetPlayerName(), info->GetAgeInstanceName());
info->SetAgeDescription( desc.c_str() );
desc = plString::Format("%s's %s", nc->GetPlayerName().c_str(), info->GetAgeInstanceName());
info->SetAgeDescription( _TEMP_CONVERT_TO_CONST_CHAR(desc) );
}
if (!info->HasAgeInstanceGuid()) {

3
Sources/Plasma/PubUtilLib/plNetCommon/plNetMember.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plNetApp;
class plNetGenericServer;
class plString;
////////////////////////////////
// A participant (peer) who we can send and recv messages from/to
////////////////////////////////
@ -93,7 +94,7 @@ public:
Int32 GetPeerID() const { return fPeerID; }
UInt32 GetFlags() const { return fFlags; }
plNetApp* GetNetApp() { return fNetApp; }
virtual std::string AsStdString() const = 0;
virtual plString AsString() const = 0;
// setters
void SetFlags(UInt32 f) { fFlags=f; }

6
Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h

@ -331,8 +331,7 @@ public:
// debug
plString AsString() const
{
char tmp[256];
return plString::Format("object=%s, %s",fObjectHelper.GetUoid().StringIze(tmp), plNetMessage::AsString().c_str());
return plString::Format("object=%s, %s",fObjectHelper.GetUoid().StringIze().c_str(), plNetMessage::AsString().c_str());
}
};
@ -558,8 +557,7 @@ public:
// debug
plString AsString() const
{
char tmp[256];
return plString::Format("object=%s initial=%d, %s",fObjectHelper.GetUoid().StringIze(tmp), fIsInitialState,
return plString::Format("object=%s initial=%d, %s",fObjectHelper.GetUoid().StringIze().c_str(), fIsInitialState,
plNetMsgGameMessage::AsString().c_str());
}
};

10
Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.cpp

@ -61,7 +61,7 @@ int plNetTransport::AddMember(plNetTransportMember* mbr)
if (FindMember(mbr)==-1)
{
fMembers.push_back(mbr);
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg("Adding member %s", mbr->AsStdString().c_str()) );
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg("Adding member %s", mbr->AsString().c_str()) );
plNetClientMgr::GetInstance()->GetListenList()->AddMember(mbr);
plNetClientMgr::GetInstance()->GetTalkList()->AddMember(mbr);
DumpState();
@ -86,7 +86,7 @@ void plNetTransport::IRemoveMember(plNetTransportMember* mbr)
if (!mbr)
return;
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg("Removing member %s", mbr->AsStdString().c_str()) );
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg("Removing member %s", mbr->AsString().c_str()) );
// plNetClientMgr::GetInstance()->GetNetCore()->RemovePeer(mbr->GetPeerID());
plNetClientMgr::GetInstance()->GetTalkList()->RemoveMember(mbr);
@ -100,7 +100,7 @@ void plNetTransport::IRemoveMember(plNetTransportMember* mbr)
// remove member from master list
fMembers.erase(it);
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg("Done Removing member %s", mbr->AsStdString().c_str()) );
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg("Done Removing member %s", mbr->AsString().c_str()) );
DumpState();
delete mbr;
@ -319,7 +319,7 @@ void plNetTransport::DumpState()
for(j=0; j<mList->size();j++)
{
plNetTransportMember * mbr = (*mList)[j];
hsLogEntry( nc->DebugMsg("\t\tMbr %s\n",(*mList)[j]->AsStdString().c_str()) );
hsLogEntry( nc->DebugMsg("\t\tMbr %s\n",(*mList)[j]->AsString().c_str()) );
}
}
@ -328,7 +328,7 @@ void plNetTransport::DumpState()
{
plNetTransportMember * mbr = GetMember(i);
hsLogEntry (nc->DebugMsg("\tMbr %d, name=%s, plyrID=%lu, subs=%d",
i,mbr->AsStdString().c_str(),mbr->GetPlayerID(),mbr->GetNumSubscriptions()) );
i,mbr->AsString().c_str(),mbr->GetPlayerID(),mbr->GetNumSubscriptions()) );
int j;
for(j=0;j<mbr->GetNumSubscriptions();j++)
{

4
Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.cpp

@ -73,11 +73,11 @@ int plNetTransportMember::FindSubscription(int chan)
return (it==fSubscriptions.end()) ? -1 : (it-fSubscriptions.begin());
}
std::string plNetTransportMember::AsStdString() const
plString plNetTransportMember::AsString() const
{
if (IsServer())
{
return "(server)";
return _TEMP_CONVERT_FROM_LITERAL("(server)");
}
else
{

11
Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h

@ -45,7 +45,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsConfig.h"
#include "hsStlUtils.h"
#include "plNetCommon/plNetMember.h"
#include "pnKeyedObject/plKey.h"
#include "pnKeyedObject/plKey.h"
#include "plString.h"
//
// This represents a participant in the game, ie. another
@ -64,7 +65,7 @@ public:
};
protected:
plKey fAvatarKey;
std::string fPlayerName;
plString fPlayerName;
UInt32 fPlayerID;
std::vector<int> fSubscriptions; // list of channelGrp subscriptions
UInt32 fTransportFlags;
@ -88,8 +89,8 @@ public:
{
fAvatarKey=k;
}
void SetPlayerName(const char * value) { fPlayerName=value;}
const char * GetPlayerName() const { return fPlayerName.c_str();}
void SetPlayerName(const plString & value) { fPlayerName=value;}
plString GetPlayerName() const { return fPlayerName;}
void SetPlayerID(UInt32 value) { fPlayerID=value;}
UInt32 GetPlayerID() const { return fPlayerID;}
void SetIsServer(bool value) { (value)?SetFlags(GetFlags()|kIsServer):SetFlags(GetFlags()&!kIsServer);}
@ -108,7 +109,7 @@ public:
UInt32 GetTransportFlags() const { return fTransportFlags; }
bool IsPeerToPeer() const { return hsCheckBits(fFlags, kRequestP2P); }
std::string AsStdString() const;
plString AsString() const;
bool IsEqualTo(const plNetMember * other) const
{
const plNetTransportMember * o = plNetTransportMember::ConvertNoRef(other);

7
Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp

@ -314,8 +314,7 @@ hsBool plResManager::ReadObject(plKeyImp* key)
// it will just inc/dec the open/close count during its read, and not actually
// close the stream, so we don't lose our place, lose our file handle, and thrash.
char locstr[64];
kResMgrLog(4, ILog(4, " ...Opening page data stream for location %s...", key->GetUoid().GetLocation().StringIze(locstr)));
kResMgrLog(4, ILog(4, " ...Opening page data stream for location %s...", key->GetUoid().GetLocation().StringIze().c_str()));
plRegistryPageNode *pageNode = FindPage(key->GetUoid().GetLocation());
if (!pageNode)
{
@ -1576,14 +1575,14 @@ static void sIReportLeak(plKeyImp* key, plRegistryPageNode* page)
if (refsLeft == 0)
return;
char tempStr[256], tempStr2[128];
char tempStr2[128];
if (key->ObjectIsLoaded() == nil)
sprintf(tempStr2, "(key only, %d refs left)", refsLeft);
else
sprintf(tempStr2, "- %d bytes - %d refs left", key->GetDataLen(), refsLeft);
hsStatusMessageF(" %s: %s %s\n", plFactory::GetNameOfClass(key->GetUoid().GetClassType()),
key->GetUoid().StringIze(tempStr), tempStr2);
key->GetUoid().StringIze().c_str(), tempStr2);
}
//// UnloadPageObjects ///////////////////////////////////////////////////////

2
Sources/Tools/plResBrowser/plResTreeView.cpp

@ -396,7 +396,7 @@ void plResTreeView::UpdateInfoDlg( HWND treeCtrl )
SetDlgItemText( fInfoDlg, IDC_AGE, pageInfo.GetAge() );
SetDlgItemText( fInfoDlg, IDC_PAGE, pageInfo.GetPage() );
SetDlgItemText( fInfoDlg, IDC_LOCATION, pageInfo.GetLocation().StringIze( tempStr ) );
SetDlgItemText( fInfoDlg, IDC_LOCATION, pageInfo.GetLocation().StringIze().c_str() );
CheckDlgButton(fInfoDlg, IDC_RESERVED, (pageInfo.GetLocation().GetFlags() & plLocation::kReserved) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(fInfoDlg, IDC_BUILTIN, (pageInfo.GetLocation().GetFlags() & plLocation::kBuiltIn) ? BST_CHECKED : BST_UNCHECKED);

Loading…
Cancel
Save