diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 9c7e9e00..8203915d 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1474,7 +1474,7 @@ bool plClient::StartInit() plSynchedObject::PushSynchDisabled(false); // enable dirty tracking - if (StrCmp(NetCommGetStartupAge()->ageDatasetName, "StartUp") == 0) + if (NetCommGetStartupAge()->ageDatasetName.CompareI("StartUp") == 0) { plNetCommAuthMsg * msg = new plNetCommAuthMsg(); msg->result = kNetSuccess; diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index 4da327e6..2f596bde 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -3916,7 +3916,7 @@ PF_CONSOLE_CMD( Nav, ExcludePage, "string pageName", "Excludes the given page fr { char str[ 256 ]; sprintf( str, "Page %s excluded from load", (char *)params[ 0 ] ); - plAgeLoader::GetInstance()->AddExcludedPage( params[ 0 ] ); + plAgeLoader::GetInstance()->AddExcludedPage( (char*)params[ 0 ] ); PrintString( str ); } } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 16e31063..c50ead65 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -614,7 +614,7 @@ plString cyMisc::GetLocalClientName() // : Return the current guid of the instance of the age the player is in // -const char * cyMisc::GetAgeName() +plString cyMisc::GetAgeName() { return NetCommGetAge()->ageDatasetName; } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h index 02d80f12..051d6105 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h @@ -299,7 +299,7 @@ public: // : Return the current coordinates of the player within this age // : Return the current time with the current age the player is in // - static const char* GetAgeName(); + static plString GetAgeName(); static PyObject* GetAgeInfo(); // returns pyAgeInfoStruct static plString GetPrevAgeName(); static PyObject* GetPrevAgeInfo(); diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp index fa252671..a6b00c5d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp @@ -53,7 +53,7 @@ PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtFlashWindow, cyMisc::FlashWindow, "Flash PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeName, "DEPRECIATED - use ptDniInfoSource instead") { - return PyString_FromString(cyMisc::GetAgeName()); + return PyString_FromPlString(cyMisc::GetAgeName()); } PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeInfo, "Returns ptAgeInfoStruct of the current Age") diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp index 721eef1a..6a867a26 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp @@ -590,10 +590,10 @@ plPythonSDLModifier* ExternFindAgePySDL() plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL() { - const char* ageName = cyMisc::GetAgeName(); + plString ageName = cyMisc::GetAgeName(); - if (strcmp(ageName, "") == 0) - return nil; // don't have an age, probably because we're running in max? + if (ageName.IsEmpty()) + return nullptr; // don't have an age, probably because we're running in max? // find the Age Global object plLocation loc = plKeyFinder::Instance().FindLocation(ageName,plAgeDescription::GetCommonPage(plAgeDescription::kGlobal)); @@ -613,27 +613,27 @@ plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL() return sdlMod; plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s", - pfmod->GetKeyName().c_str("?"), ageName); + pfmod->GetKeyName().c_str("?"), ageName.c_str()); } else { if (!key) - plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze().c_str()); + plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName.c_str(), oid.StringIze().c_str()); else if (!key->ObjectIsLoaded()) plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s", - key->GetName().c_str("?"), ageName); + key->GetName().c_str("?"), ageName.c_str()); else if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded())) plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s", - key->GetName().c_str("?"), ageName); + key->GetName().c_str("?"), ageName.c_str()); } } else - plNetClientApp::StaticErrorMsg("Invalid plUoid for age sdl %s", ageName); + plNetClientApp::StaticErrorMsg("Invalid plUoid for age sdl %s", ageName.c_str()); } else - plNetClientApp::StaticErrorMsg("Invalid plLocation for age sdl %s", ageName); + plNetClientApp::StaticErrorMsg("Invalid plLocation for age sdl %s", ageName.c_str()); // couldn't find one (maybe because we didn't look) return nil; @@ -680,8 +680,8 @@ pySDLModifier::pySDLModifier(plPythonSDLModifier* sdlMod) PyObject* pySDLModifier::GetAgeSDL() { - const char* ageName = cyMisc::GetAgeName(); - if (strcmp(ageName, "") == 0) + plString ageName = cyMisc::GetAgeName(); + if (ageName.IsEmpty()) PYTHON_RETURN_NONE; // just return none if the age is blank (running in max?) const plPythonSDLModifier* ageSDL = plPythonSDLModifier::FindAgeSDL(); @@ -691,10 +691,9 @@ PyObject* pySDLModifier::GetAgeSDL() } // didn't find one, throw an exception for the python programmer to chew on - char errmsg[256]; - sprintf(errmsg,"Age Global SDL for %s does not exist!",ageName); - plNetClientApp::StaticErrorMsg(errmsg); - PyErr_SetString(PyExc_KeyError, errmsg); + plString err = plFormat("Age Global SDL for {} does not exist!", ageName); + plNetClientApp::StaticErrorMsg(err.c_str()); + PyErr_SetString(PyExc_KeyError, err.c_str()); PYTHON_RETURN_ERROR; } diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h b/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h index 5c0a2d6e..f78b2590 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h +++ b/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h @@ -189,7 +189,7 @@ public: virtual plNetGroupId GetEffectiveNetGroup(const plSynchedObject* obj) const { hsAssert(false, "stub"); return plNetGroup::kNetGroupUnknown; } virtual int Update(double secs) { return hsOK;} virtual const char* GetServerLogTimeAsString(plString& ts) const { hsAssert(false, "stub"); return nil; } - virtual plUoid GetAgeSDLObjectUoid(const char* ageName) const { hsAssert(false, "stub"); return plUoid(); } + virtual plUoid GetAgeSDLObjectUoid(const plString& ageName) const { hsAssert(false, "stub"); return plUoid(); } virtual void StayAlive(double secs) {} virtual void QueueDisableNet( bool showDlg, const char msg[] ) {} diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp index d126767d..ccb765ff 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp @@ -171,13 +171,13 @@ bool plAgeLoader::MsgReceive(plMessage* msg) // return false on error // //============================================================================ -bool plAgeLoader::LoadAge(const char ageName[]) +bool plAgeLoader::LoadAge(const plString& ageName) { return ILoadAge(ageName); } //============================================================================ -void plAgeLoader::UpdateAge(const char ageName[]) +void plAgeLoader::UpdateAge(const plString& ageName) { plResPatcher::GetInstance()->Update(ageName); } @@ -199,14 +199,14 @@ void plAgeLoader::NotifyAgeLoaded( bool loaded ) //// ILoadAge //////////////////////////////////////////////////////////////// // Does the loading-specific stuff for queueing an age to load -bool plAgeLoader::ILoadAge(const char ageName[]) +bool plAgeLoader::ILoadAge(const plString& ageName) { plNetClientApp* nc = plNetClientApp::GetInstance(); ASSERT(!nc->GetFlagsBit(plNetClientApp::kPlayingGame)); - StrCopy(fAgeName, ageName, arrsize(fAgeName)); - - nc->DebugMsg( "Net: Loading age %s", fAgeName); + fAgeName = ageName; + + nc->DebugMsg( "Net: Loading age %s", fAgeName.c_str()); if ((fFlags & kLoadMask) != 0) ErrorAssert(__LINE__, __FILE__, "Fatal Error:\nAlready loading or unloading an age.\n%s will now exit.", @@ -227,20 +227,15 @@ bool plAgeLoader::ILoadAge(const char ageName[]) /// Step 2: Load the keys for this age, so we can find sceneNodes for them // exec age .fni file when data is done loading - char consoleIniName[ 256 ]; - sprintf( consoleIniName, "dat\\%s.fni", fAgeName); - fPendingAgeFniFiles.push_back( consoleIniName ); + fPendingAgeFniFiles.emplace_back(plFormat("dat\\{}.fni", fAgeName)); + fPendingAgeCsvFiles.emplace_back(plFormat("dat\\{}.csv", fAgeName)); - char csvName[256]; - sprintf(csvName, "dat\\%s.csv", fAgeName); - fPendingAgeCsvFiles.push_back(csvName); - plSynchEnabler p( false ); // turn off dirty tracking while in this function hsStream* stream=GetAgeDescFileStream(fAgeName); if (!stream) { - nc->ErrorMsg("Failed loading age. Age desc file %s has nil stream", fAgeName); + nc->ErrorMsg("Failed loading age. Age desc file %s has nil stream", fAgeName.c_str()); fFlags &= ~kLoadingAge; return false; } @@ -329,13 +324,13 @@ class plUnloadAgeCollector : public plRegistryPageIterator { public: hsTArray fPages; - const char *fAge; - - plUnloadAgeCollector( const char *a ) : fAge( a ) {} + const plString fAge; + + plUnloadAgeCollector(const plString& a) : fAge( a ) {} virtual bool EatPage( plRegistryPageNode *page ) { - if( fAge && page->GetPageInfo().GetAge().CompareI(fAge) == 0 ) + if ( !fAge.IsEmpty() && page->GetPageInfo().GetAge().CompareI(fAge) == 0 ) { fPages.Append( page ); } @@ -351,7 +346,7 @@ class plUnloadAgeCollector : public plRegistryPageIterator bool plAgeLoader::IUnloadAge() { plNetClientApp* nc = plNetClientApp::GetInstance(); - nc->DebugMsg( "Net: Unloading age %s", fAgeName); + nc->DebugMsg( "Net: Unloading age %s", fAgeName.c_str()); hsAssert( (fFlags & kLoadMask)==0, "already loading or unloading an age?"); fFlags |= kUnLoadingAge; @@ -362,7 +357,7 @@ bool plAgeLoader::IUnloadAge() // Note: instead of going from the .age file, we just want a list of what // is REALLY paged in for this age. So ask the resMgr! - plUnloadAgeCollector collector( fAgeName); + plUnloadAgeCollector collector(fAgeName); // WARNING: unsafe cast here, but it's ok, until somebody is mean and makes a non-plResManager resMgr ( (plResManager *)hsgResMgr::ResMgr() )->IterateAllPages( &collector ); @@ -413,7 +408,7 @@ void plAgeLoader::ExecPendingAgeFniFiles() int i; for (i=0;iParseCsvInput(stream); @@ -439,21 +434,18 @@ void plAgeLoader::ExecPendingAgeCsvFiles() // return alloced stream or nil // static // -hsStream* plAgeLoader::GetAgeDescFileStream(const char* ageName) +hsStream* plAgeLoader::GetAgeDescFileStream(const plString& ageName) { - if (!ageName) - return nil; + if (ageName.IsEmpty()) + return nullptr; - char ageDescFileName[256]; - sprintf(ageDescFileName, "dat\\%s.age", ageName); + plFileName ageDescFileName = plFormat("dat\\{}.age", ageName); hsStream* stream = plEncryptedStream::OpenEncryptedFile(ageDescFileName); if (!stream) { - char str[256]; - sprintf(str, "Can't find age desc file %s", ageDescFileName); - hsAssert(false, str); - return nil; + hsAssert(false, plFormat("Can't find age desc file {}", ageDescFileName).c_str()); + return nullptr; } return stream; diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.h b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.h index 09998288..5b9c9d67 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.h +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.h @@ -68,7 +68,7 @@ class plAgeLoader : public hsKeyedObject friend class plNetClientJoinTask; private: typedef std::vector plKeyVec; - typedef std::vector plStringVec; + typedef std::vector plFileNameVec; enum Flags { @@ -80,15 +80,15 @@ private: static plAgeLoader* fInstance; uint32_t fFlags; - plStringVec fPendingAgeFniFiles; // list of age .fni files to be parsed - plStringVec fPendingAgeCsvFiles; // list of age .csv files to be parsed + plFileNameVec fPendingAgeFniFiles; // list of age .fni files to be parsed + plFileNameVec fPendingAgeCsvFiles; // list of age .csv files to be parsed plKeyVec fPendingPageIns; // keys of rooms which are currently being paged in. plKeyVec fPendingPageOuts; // keys of rooms which are currently being paged out. plAgeDescription fCurAgeDescription; plStateDataRecord* fInitialAgeState; - char fAgeName[kMaxAgeNameLength]; - - bool ILoadAge(const char ageName[]); + plString fAgeName; + + bool ILoadAge(const plString& ageName); bool IUnloadAge(); void ISetInitialAgeState(plStateDataRecord* s); // sent from server with joinAck const plStateDataRecord* IGetInitialAgeState() const { return fInitialAgeState; } @@ -102,21 +102,21 @@ public: static plAgeLoader* GetInstance(); static void SetInstance(plAgeLoader* inst); - static hsStream* GetAgeDescFileStream(const char* ageName); + static hsStream* GetAgeDescFileStream(const plString& ageName); void Init(); void Shutdown(); bool MsgReceive(plMessage* msg); - bool LoadAge(const char ageName[]); + bool LoadAge(const plString& ageName); bool UnloadAge() { return IUnloadAge(); } - void UpdateAge(const char ageName[]); + void UpdateAge(const plString& ageName); void NotifyAgeLoaded( bool loaded ); const plKeyVec& PendingPageOuts() const { return fPendingPageOuts; } const plKeyVec& PendingPageIns() const { return fPendingPageIns; } - const plStringVec& PendingAgeCsvFiles() const { return fPendingAgeCsvFiles; } - const plStringVec& PendingAgeFniFiles() const { return fPendingAgeFniFiles; } - + const plFileNameVec& PendingAgeCsvFiles() const { return fPendingAgeCsvFiles; } + const plFileNameVec& PendingAgeFniFiles() const { return fPendingAgeFniFiles; } + void AddPendingPageInRoomKey(plKey r); bool RemovePendingPageInRoomKey(plKey r); bool IsPendingPageInRoomKey(plKey p, int* idx=nil); @@ -126,12 +126,12 @@ public: // Fun debugging exclude commands (to prevent certain pages from loading) void ClearPageExcludeList( void ); - void AddExcludedPage( const char *pageName, const char *ageName = nil ); - bool IsPageExcluded( const plAgePage *page, const char *ageName = nil ); + void AddExcludedPage( const plString& pageName, const plString& ageName = "" ); + bool IsPageExcluded( const plAgePage *page, const plString& ageName = "" ); const plAgeDescription &GetCurrAgeDesc( void ) const { return fCurAgeDescription; } - - // paging + + // paging void FinishedPagingInRoom(plKey* rmKey, int numRms); // call when finished paging in/out a room void StartPagingOutRoom(plKey* rmKey, int numRms); // call when starting to page in/out a room void FinishedPagingOutRoom(plKey* rmKey, int numRms); diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp index c5aa42ee..288800ef 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp @@ -259,42 +259,28 @@ bool plAgeLoader::RemovePendingPageInRoomKey(plKey pKey) class plExcludePage { public: - char *fPageName; - char *fAgeName; + plString fPageName; + plString fAgeName; - plExcludePage() { fPageName = nil; fAgeName = nil; } - plExcludePage( char *p, char *a ) - { - fPageName = p; - fAgeName = a; - } + plExcludePage() { } + plExcludePage(const plString& p, const plString& a) + : fPageName(p), fAgeName(a) + { } }; static hsTArray sExcludeList; void plAgeLoader::ClearPageExcludeList( void ) { - int i; - - - for( i = 0; i < sExcludeList.GetCount(); i++ ) - { - delete [] sExcludeList[ i ].fPageName; - delete [] sExcludeList[ i ].fAgeName; - } + sExcludeList.Reset(); } -void plAgeLoader::AddExcludedPage( const char *pageName, const char *ageName ) +void plAgeLoader::AddExcludedPage( const plString& pageName, const plString& ageName ) { - char *p = hsStrcpy( pageName ); - char *a = nil; - if( ageName != nil ) - a = hsStrcpy( ageName ); - - sExcludeList.Append( plExcludePage( p, a ) ); + sExcludeList.Append( plExcludePage( pageName, ageName ) ); } -bool plAgeLoader::IsPageExcluded( const plAgePage *page, const char *ageName ) +bool plAgeLoader::IsPageExcluded( const plAgePage *page, const plString& ageName ) { // check page flags if (page->GetFlags() & plAgePage::kPreventAutoLoad) @@ -307,8 +293,8 @@ bool plAgeLoader::IsPageExcluded( const plAgePage *page, const char *ageName { if( pageName.CompareI( sExcludeList[ i ].fPageName ) == 0 ) { - if( ageName == nil || sExcludeList[ i ].fAgeName == nil || - stricmp( ageName, sExcludeList[ i ].fAgeName ) == 0 ) + if( ageName.IsEmpty() || !sExcludeList[ i ].fAgeName.IsEmpty() || + ageName.CompareI(sExcludeList[ i ].fAgeName) == 0 ) { return true; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp index 7fdc18cd..486d2021 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp @@ -226,7 +226,7 @@ void plNCAgeJoiner::Start () { // if we're linking to startup then set the OfflineAge flag // so we by-pass the game server - if (StrLen(age.ageDatasetName) == 0 || StrCmpI(age.ageDatasetName, "StartUp") == 0) { + if (age.ageDatasetName.IsEmpty() || age.ageDatasetName.CompareI("StartUp") == 0) { nc->SetFlagsBit(plNetClientApp::kLinkingToOfflineAge); // no need to update if we're not using a GameSrv diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 2373185a..b9853f9f 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -1007,12 +1007,11 @@ bool plNetClientMgr::MsgReceive( plMessage* msg ) } // if we're linking to startup we don't need (or want) a player set - char ageName[kMaxAgeNameLength]; - StrCopy(ageName, NetCommGetStartupAge()->ageDatasetName, arrsize(ageName)); - if (!StrLen(ageName)) - StrCopy(ageName, "StartUp", arrsize(ageName)); - if (0 == StrCmpI(ageName, "StartUp")) - NetCommSetActivePlayer(0, nil); + plString ageName = NetCommGetStartupAge()->ageDatasetName; + if (ageName.IsEmpty()) + ageName = "StartUp"; + if (ageName.CompareI("StartUp") == 0) + NetCommSetActivePlayer(0, nullptr); plAgeLinkStruct link; link.GetAgeInfo()->SetAgeFilename(NetCommGetStartupAge()->ageDatasetName); @@ -1365,9 +1364,9 @@ bool plNetClientMgr::IFindModifier(plSynchedObject* obj, int16_t classIdx) return cnt==0 ? false : true; } -plUoid plNetClientMgr::GetAgeSDLObjectUoid(const char* ageName) const +plUoid plNetClientMgr::GetAgeSDLObjectUoid(const plString& ageName) const { - hsAssert(ageName, "nil ageName"); + hsAssert(!ageName.IsEmpty(), "nil ageName"); // if age sdl hook is loaded if (fAgeSDLObjectKey) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h index d7ab4207..196ed715 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h @@ -356,7 +356,7 @@ public: void AddPendingLoad(PendingLoad *pl); const plKey& GetAgeSDLObjectKey() const { return fAgeSDLObjectKey; } - plUoid GetAgeSDLObjectUoid(const char* ageName) const; + plUoid GetAgeSDLObjectUoid(const plString& ageName) const; plNetClientComm& GetNetClientComm() { return fNetClientComm; } plString GetNextAgeFilename() const; void SetOverrideAgeTimeOfDayPercent(float f) { fOverrideAgeTimeOfDayPercent=f; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp index 5557ccbc..6b39475f 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp @@ -434,11 +434,7 @@ void plNetLinkingMgr::IDoLink(plLinkToAgeMsg* msg) NlmJoinAgeOp * joinAgeOp = new NlmJoinAgeOp; joinAgeOp->age.ageInstId = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); joinAgeOp->muteSfx = !msg->PlayLinkInSfx(); - StrCopy( - joinAgeOp->age.ageDatasetName, - GetAgeLink()->GetAgeInfo()->GetAgeFilename().c_str(), - arrsize(joinAgeOp->age.ageDatasetName) - ); + joinAgeOp->age.ageDatasetName = GetAgeLink()->GetAgeInfo()->GetAgeFilename(); StrCopy( joinAgeOp->age.spawnPtName, GetAgeLink()->SpawnPoint().GetName().c_str(), diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index 93f66d88..2e3211ae 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -121,7 +121,7 @@ static ShaDigest s_namePassHash; static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength]; static wchar_t s_iniOS[kMaxGTOSIdLength]; static bool s_iniReadAccountInfo = true; -static wchar_t s_iniStartupAgeName[kMaxAgeNameLength]; +static plString s_iniStartupAgeName; static plUUID s_iniStartupAgeInstId; static plString s_iniStartupPlayerName; static bool s_netError = false; @@ -392,10 +392,8 @@ static void INetCliAuthLoginRequestCallback ( s_player = nil; s_players.Clear(); - bool wantsStartUpAge = ( - !StrLen(s_startupAge.ageDatasetName) || - 0 == StrCmpI(s_startupAge.ageDatasetName, "StartUp") - ); + bool wantsStartUpAge = (s_startupAge.ageDatasetName.IsEmpty() || + s_startupAge.ageDatasetName.CompareI("StartUp") == 0); s_loginComplete = true; @@ -423,7 +421,7 @@ static void INetCliAuthLoginRequestCallback ( // If they specified an alternate age, but we couldn't find the player, force // the StartUp age to load so that they may select/create a player first. if (!wantsStartUpAge && !s_player) - StrCopy(s_startupAge.ageDatasetName, "StartUp", arrsize(s_startupAge.ageDatasetName)); + s_startupAge.ageDatasetName = "StartUp"; // If they specified an alternate age, and we found the player, set the active player now // so that the link operation will be successful once the client is finished initializing. @@ -758,8 +756,8 @@ void NetCommStartup () { // Set startup age info memset(&s_startupAge, 0, sizeof(s_startupAge)); - StrCopy(s_iniStartupAgeName, L"StartUp", arrsize(s_iniStartupAgeName)); - StrCopy(s_startupAge.ageDatasetName, "StartUp", arrsize(s_startupAge.ageDatasetName)); + s_iniStartupAgeName = "StartUp"; + s_startupAge.ageDatasetName = s_iniStartupAgeName; s_startupAge.ageInstId = s_iniStartupAgeInstId; StrCopy(s_startupAge.spawnPtName, "LinkInPointDefault", arrsize(s_startupAge.spawnPtName)); @@ -1086,11 +1084,8 @@ void NetCommLinkToAge ( // --> plNetCommLinkToAgeMsg return; } - wchar_t wAgeName[kMaxAgeNameLength]; - StrToUnicode(wAgeName, s_age.ageDatasetName, arrsize(wAgeName)); - NetCliAuthAgeRequest( - wAgeName, + s_age.ageDatasetName, s_age.ageInstId, INetCliAuthAgeRequestCallback, param diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h index 178517d2..7f92975a 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h @@ -89,12 +89,11 @@ struct NetCommAccount { struct NetCommAge { plUUID ageInstId; unsigned ageVaultId; - char ageDatasetName[kMaxAgeNameLength]; + plString ageDatasetName; char spawnPtName[64]; NetCommAge() : ageVaultId(0) { - memset(ageDatasetName, 0, sizeof(ageDatasetName)); memset(spawnPtName, 0, sizeof(spawnPtName)); } }; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index cff07b97..1ec72ce1 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -194,14 +194,14 @@ struct LoginRequestTrans : NetAuthTrans { struct AgeRequestTrans : NetAuthTrans { FNetCliAuthAgeRequestCallback m_callback; void * m_param; - wchar_t m_ageName[kMaxAgeNameLength]; + plString m_ageName; unsigned m_ageMcpId; plUUID m_ageInstId; unsigned m_ageVaultId; uint32_t m_gameSrvNode; AgeRequestTrans ( - const wchar_t ageName[], + const plString& ageName, const plUUID& ageInstId, FNetCliAuthAgeRequestCallback callback, void * param @@ -2723,16 +2723,16 @@ bool LoginRequestTrans::Recv ( //============================================================================ AgeRequestTrans::AgeRequestTrans ( - const wchar_t ageName[], + const plString& ageName, const plUUID& ageInstId, FNetCliAuthAgeRequestCallback callback, void * param ) : NetAuthTrans(kAgeRequestTrans) +, m_ageName(ageName) , m_ageInstId(ageInstId) , m_callback(callback) , m_param(param) { - StrCopy(m_ageName, ageName, arrsize(m_ageName)); } //============================================================================ @@ -2744,10 +2744,12 @@ bool AgeRequestTrans::Send () { if (!AcquireConn()) return true; + plStringBuffer ageName = m_ageName.ToUtf16(); + const uintptr_t msg[] = { - kCli2Auth_AgeRequest, - m_transId, - (uintptr_t) m_ageName, + kCli2Auth_AgeRequest, + m_transId, + (uintptr_t) ageName.GetData(), (uintptr_t) &m_ageInstId, }; @@ -5254,7 +5256,7 @@ void NetCliAuthLoginRequest ( //============================================================================ void NetCliAuthAgeRequest ( - const wchar_t ageName[], + const plString& ageName, const plUUID& ageInstId, FNetCliAuthAgeRequestCallback callback, void * param diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h index dacdb320..7d19660b 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h @@ -330,7 +330,7 @@ typedef void (*FNetCliAuthAgeRequestCallback)( plNetAddress gameAddr ); void NetCliAuthAgeRequest ( - const wchar_t ageName[], // L"Teledahn" + const plString& ageName, // "Teledahn" const plUUID& ageInstId, FNetCliAuthAgeRequestCallback callback, void * param diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp index b5eec790..385e7ebc 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp @@ -210,7 +210,7 @@ void plAutoProfileImp::INextProfile() // Log the stats for this spawn point if (!fLastSpawnPointName.IsNull()) { - const char * ageName = NetCommGetAge()->ageDatasetName; + plString ageName = NetCommGetAge()->ageDatasetName; plProfileManagerFull::Instance().LogStats(ageName, fLastSpawnPointName); plMipmap mipmap;