diff --git a/Sources/Plasma/CoreLib/hsThread_Unix.cpp b/Sources/Plasma/CoreLib/hsThread_Unix.cpp index 90c515af..c271feff 100644 --- a/Sources/Plasma/CoreLib/hsThread_Unix.cpp +++ b/Sources/Plasma/CoreLib/hsThread_Unix.cpp @@ -153,7 +153,7 @@ static void InitMutexTimerFile() #include #include #include -#include "../NucleusLib/inc/hsTimer.h" +#include "NucleusLib/inc/hsTimer.h" static FILE * gEventLoggingFile = nil; diff --git a/Sources/Plasma/NucleusLib/inc/pnNucleusCreatables.h b/Sources/Plasma/NucleusLib/inc/pnNucleusCreatables.h index 5fa1c115..7d88a38e 100644 --- a/Sources/Plasma/NucleusLib/inc/pnNucleusCreatables.h +++ b/Sources/Plasma/NucleusLib/inc/pnNucleusCreatables.h @@ -45,12 +45,12 @@ REGISTER_NONCREATABLE( plPhysical ); #include "plgDispatch.h" REGISTER_NONCREATABLE( plDispatchBase ); -#include "../pnDispatch/pnDispatchCreatable.h" -#include "../pnKeyedObject/pnKeyedObjectCreatable.h" -#include "../pnMessage/pnMessageCreatable.h" -#include "../pnModifier/pnModifierCreatable.h" -#include "../pnNetCommon/pnNetCommonCreatable.h" -#include "../pnSceneObject/pnSceneObjectCreatable.h" -#include "../pnTimer/pnTimerCreatable.h" +#include "pnDispatch/pnDispatchCreatable.h" +#include "pnKeyedObject/pnKeyedObjectCreatable.h" +#include "pnMessage/pnMessageCreatable.h" +#include "pnModifier/pnModifierCreatable.h" +#include "pnNetCommon/pnNetCommonCreatable.h" +#include "pnSceneObject/pnSceneObjectCreatable.h" +#include "pnTimer/pnTimerCreatable.h" #endif // pnNucleusCreatables_inc diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp index c6256045..a6c2d6a8 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp @@ -34,6 +34,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plUoid.h" #include +#include "plFixedKey.h" +#include "plCreatableIndex.h" +#include "pnKeyedObject/plKey.h" +#include "pnFactory/plCreator.h" + //// plKeySeed /////////////////////////////////////////////////////////////// // Our seed struct. Defined here so it doesn't have to be in the .h file @@ -55,11 +60,6 @@ struct plKeySeed } }; -#include "plFixedKey.h" -#include "plCreatableIndex.h" -#include "../pnKeyedObject/plKey.h" -#include "../pnFactory/plCreator.h" - // Rules for SeedList: // 1) Must be in the Same order as enum fixedKey // 2) For now at least, all your fixed keys get put into the kGlobalFixedLoc room, reserved just for fixed keys diff --git a/Sources/Plasma/NucleusLib/pnMessage/plEnvEffectMsg.cpp b/Sources/Plasma/NucleusLib/pnMessage/plEnvEffectMsg.cpp deleted file mode 100644 index 5e360884..00000000 --- a/Sources/Plasma/NucleusLib/pnMessage/plEnvEffectMsg.cpp +++ /dev/null @@ -1,141 +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 . - -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 "plEnvEffectMsg.h" - -/* Die, die, everybody die! - - -// real-time effects (non environmental); -plAudioEffectMsg::plAudioEffectMsg() : -fEffect(0), -delayModPct(0), -feedbackPct(0), -lfOscillator(0), -feedbackDelay(0), -waveform(0), -phaseDifferential(0), -gainDB(0), -attack(0), -release(0), -compThreshhold(0), -compRatio(0), -attackPreDelay(0), -intensity(0), -effectCenter(0), -effectWidth(0), -lfCutoff(0), -leftFeedbackDelay(0), -rightFeedbackDelay(0), -swapLeftRightDelay(0), -modulationRate(0) -{ - SetBCastFlag(plMessage::kPropagateToModifiers); -} - -plAudioEffectMsg::plAudioEffectMsg(const plKey &s,const plKey &r,const double* t) : -fEffect(0), -wetDryPct(0), -delayModPct(0), -feedbackPct(0), -lfOscillator(0), -feedbackDelay(0), -waveform(0), -phaseDifferential(0), -gainDB(0), -attack(0), -release(0), -compThreshhold(0), -compRatio(0), -attackPreDelay(0), -intensity(0), -effectCenter(0), -effectWidth(0), -lfCutoff(0), -leftFeedbackDelay(0), -rightFeedbackDelay(0), -swapLeftRightDelay(0), -modulationRate(0) - -{ - SetBCastFlag(plMessage::kPropagateToModifiers); -} - -// IO -void plAudioEffectMsg::Read(hsStream* stream, hsResMgr* mgr) -{ - plEnvEffectMsg::Read(stream, mgr); - stream->ReadSwap(&fEffect); - stream->ReadSwap(&wetDryPct); - stream->ReadSwap(&delayModPct); - stream->ReadSwap(&feedbackPct); - stream->ReadSwap(&lfOscillator); - stream->ReadSwap(&feedbackDelay); - stream->ReadSwap(&waveform); - stream->ReadSwap(&phaseDifferential); - stream->ReadSwap(&gainDB); - stream->ReadSwap(&attack); - stream->ReadSwap(&release); - stream->ReadSwap(&compThreshhold); - stream->ReadSwap(&compRatio); - stream->ReadSwap(&attackPreDelay); - stream->ReadSwap(&intensity); - stream->ReadSwap(&effectCenter); - stream->ReadSwap(&effectWidth); - stream->ReadSwap(&lfCutoff); - stream->ReadSwap(&leftFeedbackDelay); - stream->ReadSwap(&rightFeedbackDelay); - stream->ReadSwap(&swapLeftRightDelay); - stream->ReadSwap(&modulationRate); -} - -void plAudioEffectMsg::Write(hsStream* stream, hsResMgr* mgr) -{ - plEnvEffectMsg::Write(stream, mgr); - stream->WriteSwap(fEffect); - stream->WriteSwap(wetDryPct); - stream->WriteSwap(delayModPct); - stream->WriteSwap(feedbackPct); - stream->WriteSwap(lfOscillator); - stream->WriteSwap(feedbackDelay); - stream->WriteSwap(waveform); - stream->WriteSwap(phaseDifferential); - stream->WriteSwap(gainDB); - stream->WriteSwap(attack); - stream->WriteSwap(release); - stream->WriteSwap(compThreshhold); - stream->WriteSwap(compRatio); - stream->WriteSwap(attackPreDelay); - stream->WriteSwap(intensity); - stream->WriteSwap(effectCenter); - stream->WriteSwap(effectWidth); - stream->WriteSwap(lfCutoff); - stream->WriteSwap(leftFeedbackDelay); - stream->WriteSwap(rightFeedbackDelay); - stream->WriteSwap(swapLeftRightDelay); - stream->WriteSwap(modulationRate); - -} -*/ \ No newline at end of file diff --git a/Sources/Plasma/NucleusLib/pnMessage/plEnvEffectMsg.h b/Sources/Plasma/NucleusLib/pnMessage/plEnvEffectMsg.h deleted file mode 100644 index 786483b2..00000000 --- a/Sources/Plasma/NucleusLib/pnMessage/plEnvEffectMsg.h +++ /dev/null @@ -1,214 +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 . - -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 plEnvEffectMsg_inc -#define plEnvEffectMsg_inc - -/* I'm dead, hear me cry - -#include "../pnMessage/plMessage.h" -#include "hsStream.h" - -class hsResMgr; - - -class plEnvEffectMsg : public plMessage -{ - - hsBool fEnable; - hsScalar fPriority; - -public: - plEnvEffectMsg() : fPriority(1.0), fEnable( true ) { SetBCastFlag(plMessage::kPropagateToModifiers); } - - plEnvEffectMsg(const plKey &s, - const plKey &r, - const double* t) : fPriority(1.0), fEnable( true ) {SetBCastFlag(plMessage::kPropagateToModifiers);} - - ~plEnvEffectMsg(){;} - - CLASSNAME_REGISTER( plEnvEffectMsg ); - GETINTERFACE_ANY( plEnvEffectMsg, plMessage ); - - hsBool Enabled() { return fEnable; } - void Enable(hsBool b) { fEnable = b; } - void SetPriority(hsScalar p) { fPriority = p; } - hsScalar GetPriority() { return fPriority; } - // IO - void Read(hsStream* stream, hsResMgr* mgr) - { - plMessage::IMsgRead(stream, mgr); - stream->ReadSwap(&fEnable); - stream->ReadSwap(&fPriority); - } - - void Write(hsStream* stream, hsResMgr* mgr) - { - plMessage::IMsgWrite(stream, mgr); - stream->WriteSwap(fEnable); - stream->WriteSwap(fPriority); - } -}; - - -class plEnvAudioEffectMsg : public plEnvEffectMsg -{ -public: - - int fPreset; - - Int32 fRoomAtten, fRoomHFAtten; - hsScalar fRoomRolloffFactor; - - hsScalar fDecayTime, fDecayHFRatio; - - Int32 fReflect; - hsScalar fReflectDelay; - - Int32 fReverb; - hsScalar fReverbDelay; - - hsScalar fDiffusion, fDensity; - hsScalar fHFReference; - - plEnvAudioEffectMsg(){SetBCastFlag(plMessage::kPropagateToModifiers);} - plEnvAudioEffectMsg(const plKey &s, - const plKey &r, - const double* t){SetBCastFlag(plMessage::kPropagateToModifiers);} - - ~plEnvAudioEffectMsg(){;} - - CLASSNAME_REGISTER( plEnvAudioEffectMsg ); - GETINTERFACE_ANY( plEnvAudioEffectMsg, plEnvEffectMsg ); - - // IO - void Read(hsStream* stream, hsResMgr* mgr) - { - plEnvEffectMsg::Read(stream, mgr); - stream->ReadSwap(&fPreset); - - stream->ReadSwap( &fRoomAtten ); - stream->ReadSwap( &fRoomHFAtten ); - stream->ReadSwap( &fRoomRolloffFactor ); - - stream->ReadSwap( &fDecayTime ); - stream->ReadSwap( &fDecayHFRatio ); - stream->ReadSwap( &fReflect ); - stream->ReadSwap( &fReflectDelay ); - stream->ReadSwap( &fReverb ); - stream->ReadSwap( &fReverbDelay ); - - stream->ReadSwap( &fDiffusion ); - stream->ReadSwap( &fDensity ); - stream->ReadSwap( &fHFReference ); - } - - void Write(hsStream* stream, hsResMgr* mgr) - { - plEnvEffectMsg::Write(stream, mgr); - stream->WriteSwap(fPreset); - - stream->WriteSwap( fRoomAtten ); - stream->WriteSwap( fRoomHFAtten ); - stream->WriteSwap( fRoomRolloffFactor ); - - stream->WriteSwap( fDecayTime ); - stream->WriteSwap( fDecayHFRatio ); - stream->WriteSwap( fReflect ); - stream->WriteSwap( fReflectDelay ); - stream->WriteSwap( fReverb ); - stream->WriteSwap( fReverbDelay ); - - stream->WriteSwap( fDiffusion ); - stream->WriteSwap( fDensity ); - stream->WriteSwap( fHFReference ); - } -}; - -class plAudioEffectMsg : public plEnvEffectMsg -{ -public: - - - enum effectType - { - kChorus = 0, - kCompressor, - kDistortion, - kEcho, - kFlanger, - kGargle, - kReverb, - kIDL32, - }; - - enum waveShape - { - kTriangular = 0, - kSquare, - kSine, - }; - - int fEffect; - int wetDryPct; - int delayModPct; - int feedbackPct; - int lfOscillator; - int feedbackDelay; - int waveform; - int phaseDifferential; - int gainDB; - hsScalar attack; - int release; - int compThreshhold; - int compRatio; - hsScalar attackPreDelay; - int intensity; - int effectCenter; - int effectWidth; - int lfCutoff; - int leftFeedbackDelay; - int rightFeedbackDelay; - hsBool swapLeftRightDelay; - int modulationRate; - - - plAudioEffectMsg(); - plAudioEffectMsg(const plKey &s, - const plKey &r, - const double* t); - - ~plAudioEffectMsg(){;} - - CLASSNAME_REGISTER( plAudioEffectMsg ); - GETINTERFACE_ANY( plAudioEffectMsg, plEnvEffectMsg ); - - void Read(hsStream* stream, hsResMgr* mgr); - void Write(hsStream* stream, hsResMgr* mgr); -}; - -*/ -#endif // plEnvEffectMsg_inc diff --git a/Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp b/Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp index d4c0fa58..84ed8a85 100644 --- a/Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp +++ b/Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp @@ -35,6 +35,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plNotifyMsg.h" +#include "pnNetCommon/plNetApp.h" plNotifyMsg::plNotifyMsg(const plKey &s, const plKey &r) { @@ -878,8 +879,6 @@ enum NotifyMsgFlags kNotifyMsgEDs, }; -#include "../pnNetCommon/plNetApp.h" - void plNotifyMsg::ReadVersion(hsStream* s, hsResMgr* mgr) { plMessage::IMsgReadVersion(s, mgr); diff --git a/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp b/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp index a37be119..76752567 100644 --- a/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp +++ b/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp @@ -330,58 +330,3 @@ void plLogicModBase::Write(hsStream* stream, hsResMgr* mgr) fFlags.Write(stream); stream->Writebool(fDisabled); } - - - -///////////////////////////////////////////////////////////////////////////////////////////////// -// -// Maintainers Marker Component -// -// -#if 0 -#include "../plModifier/plMaintainersMarkerModifier.h" - -//Class that accesses the paramblock below. -class plMaintainersMarkerComponent : public plComponent -{ -public: - plMaintainersMarkerComponent(); - void DeleteThis() { delete this; } - hsBool SetupProperties(plMaxNode* node, plErrorMsg* pErrMsg); - hsBool PreConvert(plMaxNode *pNode, plErrorMsg *pErrMsg); - hsBool Convert(plMaxNode *node, plErrorMsg *pErrMsg); -}; - -//Max desc stuff necessary. -CLASS_DESC(plMaintainersMarkerComponent, gMaintainersDesc, "Maintainers Marker", "MaintainersMarker", COMP_TYPE_TYPE, Class_ID(0x7d7f1f72, 0x405355f5)) - -//The MAX paramblock stuff below -ParamBlockDesc2 gMaintainersBk -( - 1, _T("maintainersMarker"), 0, &gMaintainersDesc, P_AUTO_CONSTRUCT, plComponent::kRefComp, - end -); - -plMaintainersMarkerComponent::plMaintainersMarkerComponent() -{ - fClassDesc = &gMaintainersDesc; - fClassDesc->MakeAutoParamBlocks(this); -} - -hsBool plMaintainersMarkerComponent::SetupProperties(plMaxNode* node, plErrorMsg* pErrMsg) -{ - node->SetForceLocal(true); - return true; -} -hsBool plMaintainersMarkerComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) -{ - plMaintainersMarkerModifier* pSpawn = TRACKED_NEW plMaintainersMarkerModifier; - node->AddModifier(pSpawn); - return true; -} - -hsBool plMaintainersMarkerComponent::PreConvert(plMaxNode *pNode, plErrorMsg *pErrMsg) -{ - return true; -} -#endif diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt index 3d7eac40..b88ce118 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt +++ b/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt @@ -14,6 +14,8 @@ set(pnNetCommon_HEADERS plSDLTypes.h plSynchedObject.h plSynchedValue.h + pnNetCommon.h + pnNetCommonCreatable.h ) set(pnNetCommon_SOURCES diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.h b/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.h index ec93ea0c..9f1616ee 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.h +++ b/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.h @@ -31,7 +31,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsStlUtils.h" #include "hsRefCnt.h" #include "hsStream.h" -#include "../pnFactory/plCreatable.h" +#include "pnFactory/plCreatable.h" // // main logging switch diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommonCreatable.h b/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommonCreatable.h index a98cb90a..bab1d013 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommonCreatable.h +++ b/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommonCreatable.h @@ -26,7 +26,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef pnNetCommonCreatable_inc #define pnNetCommonCreatable_inc -#include "../pnFactory/plCreator.h" +#include "pnFactory/plCreator.h" #include "plSynchedObject.h" REGISTER_CREATABLE( plSynchedObject ); diff --git a/Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBuildId.h b/Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBuildId.h index eb40764c..77f57911 100644 --- a/Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBuildId.h +++ b/Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBuildId.h @@ -45,10 +45,10 @@ unsigned BuildId (); void OverrideBuildId (unsigned buildId); -/***************************************************************************** -* -* BuildType definition -* -***/ - +/***************************************************************************** +* +* BuildType definition +* +***/ + #define BUILD_TYPE_LIVE 50 diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp index 56b10619..876e4f6b 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp @@ -39,7 +39,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plgDispatch.h" // other -// #include "../pnMessage/plRefMsg.h" #include "plMessage/plAnimCmdMsg.h" #include "pnMessage/plSDLModifierMsg.h" #include "pnMessage/plSDLNotificationMsg.h" diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp index 8af9c3ab..9960a950 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp @@ -70,6 +70,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plMessage/plClimbEventMsg.h" #include "pnNetCommon/plSDLTypes.h" +#include "plSDL/plSDL.h" +#include "plAvatarSDLModifier.h" + ///////////////////////////////////////////////////////////////// // // IMPLEMENTATION @@ -769,8 +772,6 @@ hsBool plAvBrainClimb::IInitAnimations() // SDL-BASED PERSISTENCE // ///////////////////////////////////////////////////////////////////////////////////////// -#include "../plSDL/plSDL.h" -#include "plAvatarSDLModifier.h" // SaveToSDL ----------------------------------------- // --------- diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp index 13b5a7db..10f443f6 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp @@ -36,6 +36,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // other #include "plMessage/plAvatarMsg.h" +#include "plMessage/plOneShotMsg.h" +#include "plMessage/plOneShotCallbacks.h" // CTOR() plOneShotMod::plOneShotMod() @@ -91,9 +93,6 @@ plOneShotMod::~plOneShotMod() } -#include "../plMessage/plOneShotMsg.h" -#include "../plMessage/plOneShotCallbacks.h" - // MSGRECEIVE hsBool plOneShotMod::MsgReceive(plMessage* msg) { diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp index ad1890ce..d35a0458 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp @@ -83,6 +83,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plScene/plVisMgr.h" #include "plScene/plVisRegion.h" +#include "plStatusLog/plStatusLog.h" + #include //// Local Konstants ///////////////////////////////////////////////////////// @@ -460,8 +462,6 @@ static inline hsMatrix44 IMatrixMul34(const hsMatrix44& lhs, const hsMatrix44& r return ret; } -#include "../plStatusLog/plStatusLog.h" - #ifdef MF_TEST_UPDATE plProfile_CreateCounter("DSSetTrans", "Update", DSSetTrans); plProfile_CreateCounter("DSMatSpans", "Update", DSMatSpans); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp index 0c269f64..155998e4 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp @@ -68,6 +68,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnMessage/plPipeResMakeMsg.h" +#include "plGImage/plBumpMapGen.h" + // Stuff for creating a bumpenv decal on demand. #include "plGImage/plMipmap.h" #include "plSurface/plLayer.h" @@ -1547,8 +1549,6 @@ hsBool plDynaDecalMgr::ICutoutTargets(double secs) ////////////////////////////////////////////////////////////////////////////////// -#include "../plGImage/plBumpMapGen.h" - hsGMaterial* plDynaDecalMgr::IConvertToEnvMap(hsGMaterial* mat, plBitmap* envMap) { if( !mat || !envMap ) diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plVisLOSMgr.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plVisLOSMgr.cpp index 60e79b0a..d84b9505 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plVisLOSMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plVisLOSMgr.cpp @@ -41,6 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plScene/plSceneNode.h" #include "plScene/plPageTreeMgr.h" + +#include "plPipeline.h" +#include "pnSceneObject/plSceneObject.h" + // Stuff for cursor los #include "plInputCore/plInputDevice.h" #include "plPipeline.h" @@ -411,9 +415,6 @@ hsBool plVisLOSMgr::CursorCheck(plVisHit& hit) ///////////////////////////////////////////////////////////////// -#include "plPipeline.h" -#include "../pnSceneObject/plSceneObject.h" - static plSceneObject* marker = nil; static plPipeline* pipe = nil; diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp index d7c8423c..31caf3ba 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp @@ -32,6 +32,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/plKey.h" #include "pnSceneObject/plSceneObject.h" +#include "plMessage/plOneShotCallbacks.h" + #ifndef SERVER #include "plAvatar/plAvBrain.h" #endif @@ -331,8 +333,6 @@ void plAvTaskSeekDoneMsg::Write(hsStream *stream, hsResMgr *mgr) // ///////////////// -#include "../plMessage/plOneShotCallbacks.h" - // CTOR() plAvOneShotMsg::plAvOneShotMsg() : plAvSeekMsg(), fAnimName(nil), fDrivable(false), fReversible(false), fCallbacks(nil) diff --git a/Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.cpp b/Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.cpp index 1a8e7098..8692df94 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.cpp @@ -31,7 +31,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plNetCommon/plNetServerSessionInfo.h" #include "plNetCommon/plNetCommon.h" #include "hsBitVector.h" - +#include "pnNetCommon/plNetApp.h" ///////////////////////////////////////////////////////////////////////// // @@ -203,7 +203,6 @@ enum LinkEffectsFlags kLinkEffectsLinkInAnimKey, }; -#include "../pnNetCommon/plNetApp.h" void plLinkEffectsTriggerMsg::ReadVersion(hsStream* s, hsResMgr* mgr) { plMessage::IMsgReadVersion(s, mgr); diff --git a/Sources/Plasma/PubUtilLib/plModifier/plAnimEventModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plAnimEventModifier.cpp index 3415644b..04dacc92 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plAnimEventModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plAnimEventModifier.cpp @@ -32,6 +32,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnMessage/plEnableMsg.h" #include "pnMessage/plEventCallbackMsg.h" +#include "pnNetCommon/plNetApp.h" +#include "pnMessage/plNotifyMsg.h" + plAnimEventModifier::plAnimEventModifier() : fCallback(nil), fDisabled(false) { } @@ -105,9 +108,6 @@ hsBool plAnimEventModifier::MsgReceive(plMessage* msg) return plSingleModifier::MsgReceive(msg); } -#include "../pnNetCommon/plNetApp.h" -#include "../pnMessage/plNotifyMsg.h" - void plAnimEventModifier::ISendNotify(bool triggered) { if (fDisabled) diff --git a/Sources/Plasma/PubUtilLib/plModifier/plAnimTimeConvertSDLModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plAnimTimeConvertSDLModifier.cpp index ffc9e72d..642e23e5 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plAnimTimeConvertSDLModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plAnimTimeConvertSDLModifier.cpp @@ -61,7 +61,6 @@ void plAnimTimeConvertSDLModifier::IPutATC(plStateDataRecord* atcStateDataRec, p // // Apply state in SDL record to current animation state // -//#include "../pnSceneObject/plSceneObject.h" void plAnimTimeConvertSDLModifier::ISetCurrentATC(const plStateDataRecord* atcStateDataRec, plAnimTimeConvert* objAtc) { // if ( GetTarget(0)->GetKeyName() && stricmp( GetTarget(0)->GetKeyName(), "RTDirLight01" )==0 ) diff --git a/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp index 3cd9f4a2..2373bb6c 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp @@ -35,6 +35,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plgDispatch.h" #include "pnMessage/plWarpMsg.h" #include "pnMessage/plNodeRefMsg.h" +#include "plMessage/plLoadCloneMsg.h" plCloneSpawnModifier::plCloneSpawnModifier() : fTemplateName(nil), fExportTime(false) { @@ -80,7 +81,6 @@ void plCloneSpawnModifier::SetTarget(plSceneObject* so) } } -#include "../plMessage/plLoadCloneMsg.h" plKey plCloneSpawnModifier::SpawnClone(const char* cloneName, const char* cloneAge, const hsMatrix44& pos, plKey requestor) { diff --git a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp index 75b8bcb0..072d41e7 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp @@ -59,6 +59,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plAvatar/plArmatureMod.h" #include "plAvatar/plAvatarMgr.h" +#include "plPipeline/plDebugText.h" + //#ifdef HS_DEBUGGING #define STATUS_LOG @@ -699,7 +701,6 @@ void plResponderModifier::Write(hsStream* stream, hsResMgr* mgr) stream->WriteByte(fFlags); } -#include "../plPipeline/plDebugText.h" bool plResponderModifier::fDebugAnimBox = false; diff --git a/Sources/Plasma/PubUtilLib/plModifier/plTagModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plTagModifier.cpp deleted file mode 100644 index 3f2dc72c..00000000 --- a/Sources/Plasma/PubUtilLib/plModifier/plTagModifier.cpp +++ /dev/null @@ -1,103 +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 . - -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 "plTagModifier.h" - -#include "hsResMgr.h" -#include "../pnMessage/plRemoteAvatarInfoMsg.h" -#include "../plMessage/plAvatarMsg.h" -//#include "../pfMessage/plClothingMsg.h" -#include "../plMessage/plCollideMsg.h" -#include "../plMessage/plSimInfluenceMsg.h" - -#include "../plStatusLog/plStatusLog.h" - -static plStatusLog* gLog = nil; - -plTagModifier::plTagModifier() -{ - if (!gLog) - gLog = plStatusLogMgr::GetInstance().CreateStatusLog(15, "Tag", plStatusLog::kFilledBackground | plStatusLog::kDeleteForMe | plStatusLog::kDontWriteFile | plStatusLog::kAlignToTop); -} - -plTagModifier::~plTagModifier() -{ -} - -hsBool plTagModifier::MsgReceive(plMessage* msg) -{ - plCollideMsg* collideMsg = plCollideMsg::ConvertNoRef(msg); - if (collideMsg) - { - gLog->AddLineF("Kicked by %s", collideMsg->fOtherKey->GetName()); - return true; - } - - plRemoteAvatarInfoMsg* avInfoMsg = plRemoteAvatarInfoMsg::ConvertNoRef(msg); - if (avInfoMsg) - { - // TODO - // Check if the local av is frozen -// plKey localAvKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey(); - - // Freeze clicked av - plKey clickedAvKey = avInfoMsg->GetAvatarKey(); - if (clickedAvKey) - { - static hsBool tempHack = true; - tempHack = !tempHack; - - plAvEnableMsg* avEnableMsg = new plAvEnableMsg(GetKey(), clickedAvKey, tempHack); - avEnableMsg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kPropagateToModifiers); - avEnableMsg->Send(); - - gLog->AddLineF("Tagged %s", clickedAvKey->GetName()); - } - - return true; - } - - return plSingleModifier::MsgReceive(msg); -} - -void plTagModifier::Read(hsStream* stream, hsResMgr* mgr) -{ - plSingleModifier::Read(stream, mgr); -} - -void plTagModifier::Write(hsStream* stream, hsResMgr* mgr) -{ - plSingleModifier::Write(stream, mgr); -} - -#include "plgDispatch.h" - -void plTagModifier::SetTarget(plSceneObject* so) -{ - if (so) - plgDispatch::Dispatch()->RegisterForExactType(plRemoteAvatarInfoMsg::Index(), GetKey()); - else - plgDispatch::Dispatch()->UnRegisterForExactType(plRemoteAvatarInfoMsg::Index(), GetKey()); -} diff --git a/Sources/Plasma/PubUtilLib/plModifier/plTagModifier.h b/Sources/Plasma/PubUtilLib/plModifier/plTagModifier.h deleted file mode 100644 index 8f9d13b9..00000000 --- a/Sources/Plasma/PubUtilLib/plModifier/plTagModifier.h +++ /dev/null @@ -1,51 +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 . - -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 plTagModifier_inc -#define plTagModifier_inc - -#include "../pnModifier/plSingleModifier.h" - -class plTagModifier : public plSingleModifier -{ -protected: - virtual hsBool IEval(double secs, hsScalar del, UInt32 dirty) { return true; } - -public: - plTagModifier(); - virtual ~plTagModifier(); - - CLASSNAME_REGISTER(plTagModifier); - GETINTERFACE_ANY(plTagModifier, plSingleModifier); - - virtual hsBool MsgReceive(plMessage* msg); - - virtual void Read(hsStream* stream, hsResMgr* mgr); - virtual void Write(hsStream* stream, hsResMgr* mgr); - - virtual void SetTarget(plSceneObject* so); -}; - -#endif // plTagModifier_inc diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVNodeMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVNodeMgr.cpp deleted file mode 100644 index f862acc3..00000000 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVNodeMgr.cpp +++ /dev/null @@ -1,164 +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 . - -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 "plNetClientMgr.h" -#include "plNetClientVNodeMgr.h" -#include "../plNetMessage/plNetMessage.h" -#include "../plGImage/plMipmap.h" -#include "../plJPEG/plJPEG.h" -#include "../plVault/plVault.h" -#include "hsResMgr.h" -#include "../pnMessage/plRefMsg.h" -#include "../plVault/plDniCoordinateInfo.h" -#include "../plVault/plAgeInfoSource.h" -#include "plNetLinkingMgr.h" -#include "../plStatusLog/plStatusLog.h" -#include "../plClientState/plClientStateMgr.h" -#include "../plSDL/plSDL.h" -#include "../plAgeLoader/plAgeLoader.h" - -#include "../../FeatureLib/pfMessage/pfKIMsg.h" - - -//////////////////////////////////////////////////////////////////// - -class plNetClientAgeInfoSource : public plAgeInfoSource -{ - plDniCoordinateInfo fNilCoords; // TEMPORARY -public: - const plDniCoordinateInfo * GetAgeCoords( void ) const - { - return &fNilCoords; // tmp - } - const plUnifiedTime * GetAgeTime( void ) const - { - static plUnifiedTime ut; - ut.SetSecsDouble(plNetClientMgr::GetInstance()->GetCurrentAgeElapsedSeconds()); - return &ut; - } - const char * GetAgeName( void ) const - { - return plNetLinkingMgr::GetInstance()->GetAgeLink()->GetAgeInfo()->GetAgeInstanceName(); - } - const plUUID * GetAgeGuid( void ) const - { - return plNetLinkingMgr::GetInstance()->GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); - } - static plNetClientAgeInfoSource * GetInstance( void ) - { - static plNetClientAgeInfoSource Me; - return &Me; - } -}; - - -//// Image/Mipmap Conversion ////////////////////////////////////////////////// - -hsBool StuffImageIntoNode( plMipmap * src, RelVaultNode * dst ) -{ - VaultImageNode image(dst); - hsRAMStream ramStream; - - // Create our JPEG stream - plJPEG::Instance().SetWriteQuality( 30 ); // In percent quality - - if( !plJPEG::Instance().WriteToStream( &ramStream, src ) ) - return false; - - unsigned bytes = ramStream.GetEOF(); - byte * buffer = (byte *)ALLOC(bytes); - ramStream.CopyToMem(buffer); - - image.SetImageData(buffer, bytes); - - image.SetImageType( VaultImageNode::kJPEG ); - - // possibly make a plKey for the mipmap. - return ExtractImageFromNode( dst ); -} - -hsBool ExtractImageFromNode( RelVaultNode * src) -{ - // no id? exit now. we will be called again when element is given an id. - if ( src->nodeId == 0 ) - return false; - - VaultCliImageNode image(src); - - // already have a mipmap and it has a key? release it - if ( image.fMipmap && image.fMipmap->GetKey()!=nil ) - { - plNetClientMgr::GetInstance()->GetKey()->Release( image.fMipmap->GetKey() ); - image.fMipmap = nil; - } - - // convert image data to a plMipmap - switch( image.imgType ) - { - case VaultImageNode::kJPEG: - { - // Copy to a RAM stream so the JPEG class is happy - hsRAMStream ramStream; - ramStream.Write( image.imgDataLen, image.imgData ); - ramStream.Rewind(); - // create mipmap from image data - image.fMipmap = plJPEG::Instance().ReadFromStream( &ramStream ); - } - break; - - default: - { - hsAssert( false, "ExtractImageFromNode: Invalid image type" ); - return false; // Invalid image type - } - } - - if ( !image.fMipmap ) - { - hsAssert( false, "ExtractImageFromNode failed" ); - return false; - } - - // we now have a mipmap, but it doesn't have a key. make a key for it - static int UniqueIdentifier = 0; - - char keyName[512]; - sprintf( keyName, "VaultImage_%lu_%d", src->nodeId, UniqueIdentifier++ ); - - // create a key for the mipmap - plKey imageKey = hsgResMgr::ResMgr()->NewKey( keyName, image.fMipmap, plLocation::kGlobalFixedLoc ); - - // ref the image key - hsgResMgr::ResMgr()->AddViaNotify( imageKey, TRACKED_NEW plGenRefMsg( - plNetClientMgr::GetInstance()->GetKey(), plRefMsg::kOnCreate, 0, plNetClientMgr::kVaultImage ), - plRefFlags::kActiveRef ); - - return ( image.fMipmap->GetKey()!=nil ); -} - - -//////////////////////////////////////////////////////////////////// -// End. - diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVault.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVault.cpp deleted file mode 100644 index 2e20e6b2..00000000 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVault.cpp +++ /dev/null @@ -1,234 +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 . - -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 "plNetClientMgr.h" -#include "plNetClientVault.h" -#include "../pnNetCommon/plNetMsg.h" -#include "../plGImage/plMipmap.h" -#include "../plJPEG/plJPEG.h" -#include "../plVault/plVaultTasks.h" -#include "hsResMgr.h" -#include "../pnMessage/plRefMsg.h" -#include "../plVault/plDniCoordinateInfo.h" -#include "../plVault/plAgeInfoSource.h" - -//////////////////////////////////////////////////////////////////// - -class plNetClientAgeInfoSource : public plAgeInfoSource -{ - plDniCoordinateInfo fNilCoords; // TEMPORARY -public: - const plDniCoordinateInfo * GetAgeCoords( void ) const - { - return &fNilCoords; // tmp - } - const plUnifiedTime * GetAgeTime( void ) const - { - static plUnifiedTime ut; - ut.SetSecsDouble(plNetClientMgr::GetInstance()->GetCurrentAgeElapsedSeconds()); - return &ut; - } - const char * GetAgeName( void ) const - { - return plNetClientMgr::GetInstance()->GetAgeName(); - } - const plServerGuid * GetAgeGuid( void ) const - { - return plNetClientMgr::GetInstance()->GetCurrSessionInfo()->GetServerGuid(); - } - static plNetClientAgeInfoSource * GetInstance( void ) - { - static plNetClientAgeInfoSource Me; - return &Me; - } -}; - -//////////////////////////////////////////////////////////////////// - -plNetClientVault::plNetClientVault() -{ -} - -plNetApp * plNetClientVault::GetNetApp( void ) const -{ - return plNetClientMgr::GetInstance(); -} - -plAgeInfoSource * plNetClientVault::GetAgeInfo( void ) const -{ - return plNetClientAgeInfoSource::GetInstance(); -} - - -void plNetClientVault::IInitNode( plVaultNode * node ) -{ - plVaultImageNode * IMG = plVaultImageNode::ConvertNoRef( node ); - if ( IMG ) - { - plNetClientVault::ExtractImageFromNode( IMG ); - } -} - -void plNetClientVault::IFiniNode( plVaultNode * node ) -{ - plVaultImageNode * IMG = plVaultImageNode::ConvertNoRef( node ); - if ( IMG && IMG->GetMipmap() ) - { - plNetClientMgr::GetInstance()->GetKey()->Release( IMG->GetMipmap()->GetKey() ); - IMG->ISetMipmap( nil ); - } -} - -int plNetClientVault::ISendNetMsg( plNetMsgVault * msg, UInt32 sendFlags ) -{ - return plNetClientMgr::GetInstance()->SendMsg( msg, sendFlags ); -} - -void plNetClientVault::IOnTaskTimedOut( plVaultTask * task ) -{ - std::string msg; - xtl::format( msg, "KI task timed out: %s", task->ClassName() ); - plNetClientMgr::GetInstance()->OnNetFailure( msg.c_str(), true ); -} - -bool plNetClientVault::IAmOnline( void ) const -{ - return plNetClientMgr::GetInstance()->IsEnabled()!=0; -} - -//// Image/Mipmap Conversion ////////////////////////////////////////////////// - -hsBool plNetClientVault::StuffImageIntoNode( plMipmap * src, plVaultImageNode * dst ) -{ - hsRAMStream ramStream; - - // Create our JPEG stream - plJPEG::Instance().SetWriteQuality( 50 ); // In percent quality - - if( !plJPEG::Instance().WriteToStream( &ramStream, src ) ) - return false; - - // Copy the stream to the image element now - void * buffer = dst->AllocBuffer( ramStream.GetEOF() ); - if( buffer == nil ) - return false; - ramStream.CopyToMem( buffer ); - dst->SetImageType( plVaultImageNode::kJPEG ); - - // possibly make a plKey for the mipmap. - return plNetClientVault::ExtractImageFromNode( dst ); -} - -hsBool plNetClientVault::ExtractImageFromNode( plVaultImageNode * src) -{ - // no id? exit now. we will be called again when element is given an id. - if ( src->GetID()==0 ) - return false; - - // already have a mipmap and it has a key? release it - if ( src->GetMipmap() && src->GetMipmap()->GetKey()!=nil ) - { - plNetClientMgr::GetInstance()->GetKey()->Release( src->GetMipmap()->GetKey() ); - src->ISetMipmap( nil ); - } - - // convert image data to a plMipmap - switch( src->GetImageType() ) - { - case plVaultImageNode::kJPEG: - { - // Copy to a RAM stream so the JPEG class is happy - hsRAMStream ramStream; - ramStream.Write( src->GetBufSize(), src->GetBuffer() ); - ramStream.Rewind(); - // create mipmap from image data - src->ISetMipmap( plJPEG::Instance().ReadFromStream( &ramStream ) ); - } - break; - - default: - { - hsAssert( false, "ExtractImageFromNode: Invalid image type" ); - return false; // Invalid image type - } - } - - if ( !src->GetMipmap() ) - { - hsAssert( false, "ExtractImageFromNode failed" ); - return false; - } - - // we now have a mipmap, but it doesn't have a key. make a key for it - static int UniqueIdentifier = 0; - - char keyName[512]; - sprintf( keyName, "VaultImage_%lu_%d", src->GetID(), UniqueIdentifier++ ); - - // create a key for the mipmap - plKey imageKey = hsgResMgr::ResMgr()->NewKey( keyName, src->IGetMipmap(), - plLocation::kGlobalFixedLoc ); - - // ref the image key - hsgResMgr::ResMgr()->AddViaNotify( imageKey, new plGenRefMsg( - plNetClientMgr::GetInstance()->GetKey(), plRefMsg::kOnCreate, 0, 0 ), - plRefFlags::kActiveRef ); - - return ( src->GetMipmap()->GetKey()!=nil ); -} - - -//////////////////////////////////////////////////////////////////// - -plNetPlayerVault::plNetPlayerVault() -{ -} - -bool plNetPlayerVault::IIsThisMe( plVaultPlayerInfoNode * node ) const -{ - return GetPlayer()->GetPlayerInfo()->GetID()==node->GetID(); -} - -plVaultPlayerNode * plNetPlayerVault::GetPlayer( void ) const -{ - return plVaultPlayerNode::ConvertNoRef( GetRootNode() ); -} - -void plNetPlayerVault::IFillOutConnectFields( plNetMsgVault * msg ) const -{ - msg->AddInt( plVault::kArg_VaultClientType, plVault::kNodeType_VaultPlayer ); - msg->AddInt( plVault::kArg_VaultClientID, plNetClientMgr::GetInstance()->GetDesiredPlayerID() ); -} - -bool plNetPlayerVault::IIsThisMsgMine( plNetMsgVault * msg ) const -{ - if ( plVaultClient::IIsThisMsgMine( msg ) ) - return true; - return ( msg->GetInt( plVault::kArg_VaultClientID )==plNetClientMgr::GetInstance()->GetDesiredPlayerID() ); -} - - -//////////////////////////////////////////////////////////////////// -// End. diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVault.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVault.h deleted file mode 100644 index 6c01fdbf..00000000 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientVault.h +++ /dev/null @@ -1,71 +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 . - -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 plNetClientVault_h_inc -#define plNetClientVault_h_inc - -#include "../plVault/plVaultClient.h" - -class plMipmap; -class plVaultImageNode; - - -//////////////////////////////////////////////////////////////////// - -class plNetClientVault : public plVaultClient -{ -protected: - void IInitNode( plVaultNode * node ); - void IFiniNode( plVaultNode * node ); - int ISendNetMsg( plNetMsgVault * msg, UInt32 sendFlags=0 ); - void IOnTaskTimedOut( plVaultTask * task ); - bool IAmOnline( void ) const; - -public: - plNetClientVault(); - - plNetApp * GetNetApp( void ) const; - plAgeInfoSource * GetAgeInfo( void ) const; - - // static helpers to convert between plMipmap and plVaultImageNode - static hsBool StuffImageIntoNode( plMipmap * src, plVaultImageNode * dst ); - static hsBool ExtractImageFromNode( plVaultImageNode * src ); -}; - -//////////////////////////////////////////////////////////////////// - -class plNetPlayerVault : public plNetClientVault -{ -protected: - bool IIsThisMe( plVaultPlayerInfoNode * node ) const; - void IFillOutConnectFields( plNetMsgVault * msg ) const; - bool IIsThisMsgMine( plNetMsgVault * msg ) const; - -public: - plNetPlayerVault(); - plVaultPlayerNode * GetPlayer( void ) const; -}; - -#endif // plNetClientVault_h_inc diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plServerGuid.cpp b/Sources/Plasma/PubUtilLib/plNetCommon/plServerGuid.cpp index 19fb902e..196e09e2 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plServerGuid.cpp +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plServerGuid.cpp @@ -25,8 +25,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "hsWindows.h" #include "plServerGuid.h" -#include "../pnMessage/plMessage.h" -#include "../PubUtilLib/plStreamLogger/plStreamLogger.h" +#include "pnMessage/plMessage.h" +#include "PubUtilLib/plStreamLogger/plStreamLogger.h" #if HS_BUILD_FOR_WIN32 #include #else diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp index 4a0d6ceb..0e593f90 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp @@ -56,7 +56,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plPXConvert.h" #include "plPXPhysicalControllerCore.h" -#include "../plModifier/plDetectorLog.h" +#include "plModifier/plDetectorLog.h" + +#include "plSurface/hsGMaterial.h" +#include "plSurface/plLayerInterface.h" #if 0 @@ -1254,9 +1257,6 @@ hsBool plPXPhysical::IsDynamic() const !GetProperty(plSimulationInterface::kPhysAnim); } -#include "../plSurface/hsGMaterial.h" -#include "../plSurface/plLayerInterface.h" - // Some helper functions for pulling info out of a PhysX trimesh description inline hsPoint3& GetTrimeshVert(NxTriangleMeshDesc& desc, int idx) { diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalController.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalController.cpp index 361ab0a3..7aafe94e 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalController.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalController.cpp @@ -35,9 +35,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plDrawable/plDrawableGenerator.h" #include "plPhysical/plPhysicalProxy.h" -#include "pnMessage/plSetNetGroupIDMsg.h" +#include "pnMessage/plSetNetGroupIDMsg.h + +#include "plSurface/hsGMaterial.h" +#include "plSurface/plLayerInterface.h"" #include "plMessage/plCollideMsg.h" + #include #include #include @@ -55,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef PLASMA_EXTERNAL_RELEASE +#include "plPipeline/plDebugText.h" hsBool plPXPhysicalController::fDebugDisplay = false; #endif // PLASMA_EXTERNAL_RELEASE @@ -1197,9 +1202,6 @@ void plPXPhysicalController::IDeleteController() } } -#include "../plSurface/hsGMaterial.h" -#include "../plSurface/plLayerInterface.h" - // Make a visible object that can be viewed by users for debugging purposes. plDrawableSpans* plPXPhysicalController::CreateProxy(hsGMaterial* mat, hsTArray& idx, plDrawableSpans* addTo) { @@ -1226,7 +1228,6 @@ plDrawableSpans* plPXPhysicalController::CreateProxy(hsGMaterial* mat, hsTArray< } #ifndef PLASMA_EXTERNAL_RELEASE -#include "../plPipeline/plDebugText.h" void plPXPhysicalController::IDrawDebugDisplay() { diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp index 9ea60604..83720bc7 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp @@ -27,22 +27,31 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plSimulationMgr.h" #include "plPXPhysical.h" #include "plPXConvert.h" -#include "../pnSceneObject/plSimulationInterface.h" -#include "../pnSceneObject/plSceneObject.h" -#include "../pnMessage/plCorrectionMsg.h" -#include "../plAvatar/plArmatureMod.h" -#include "../pnSceneObject/plCoordinateInterface.h" -#include "../plDrawable/plDrawableGenerator.h" -#include "../plPhysical/plPhysicalProxy.h" -#include "../pnMessage/plSetNetGroupIDMsg.h" -#include "../plMessage/plCollideMsg.h" -#include "../plModifier/plDetectorLog.h" +#include "pnSceneObject/plSimulationInterface.h" +#include "pnSceneObject/plSceneObject.h" +#include "pnMessage/plCorrectionMsg.h" +#include "plAvatar/plArmatureMod.h" +#include "pnSceneObject/plCoordinateInterface.h" +#include "plDrawable/plDrawableGenerator.h" +#include "plPhysical/plPhysicalProxy.h" +#include "pnMessage/plSetNetGroupIDMsg.h" +#include "plMessage/plCollideMsg.h" +#include "plModifier/plDetectorLog.h" //#include "NxVecExtendedVec3.h" #include "NxPhysics.h" #include "ControllerManager.h" #include "NxCapsuleController.h" #include "NxCapsuleShape.h" + +#include "plSurface/hsGMaterial.h" +#include "plSurface/plLayerInterface.h" + + +#ifndef PLASMA_EXTERNAL_RELEASE +#include "plPipeline/plDebugText.h" +#endif + #define kPhysxSkinWidth 0.1f #define kPhysZOffset ((fRadius + (fHeight / 2)) + kPhysxSkinWidth) //#define kSLOPELIMIT (cosf(NxMath::degToRad(55.f))) @@ -1162,9 +1171,6 @@ const hsVector3& plPXPhysicalControllerCore::GetLinearVelocity() } } -#include "../plSurface/hsGMaterial.h" -#include "../plSurface/plLayerInterface.h" - // Make a visible object that can be viewed by users for debugging purposes. plDrawableSpans* plPXPhysicalControllerCore::CreateProxy(hsGMaterial* mat, hsTArray& idx, plDrawableSpans* addTo) { @@ -1189,7 +1195,6 @@ plDrawableSpans* plPXPhysicalControllerCore::CreateProxy(hsGMaterial* mat, hsTAr return myDraw; } #ifndef PLASMA_EXTERNAL_RELEASE -#include "../plPipeline/plDebugText.h" void plPXPhysicalControllerCore::IDrawDebugDisplay() { diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.h b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.h index 2748b9b7..d1eac73a 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.h +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.h @@ -23,7 +23,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ -#include "../plAvatar/plPhysicalControllerCore.h" +#include "plAvatar/plPhysicalControllerCore.h" #include "hsQuat.h" #define PHYSX_ONLY_TRIGGER_FROM_KINEMATIC 1 diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index 4a545e49..65e8874d 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plModifier/plDetectorLog.h" #ifndef PLASMA_EXTERNAL_RELEASE +#include "plPipeline/plDebugText.h" bool plSimulationMgr::fDisplayAwakeActors=false; #endif //PLASMA_EXTERNAL_RELEASE // This gets called by PhysX whenever a trigger gets penetrated. This is used @@ -989,7 +990,6 @@ void plSimulationMgr::ClearLog() } } #ifndef PLASMA_EXTERNAL_RELEASE -#include "../plPipeline/plDebugText.h" void plSimulationMgr::IDrawActiveActorList() { diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plEnvEffectDetector.cpp b/Sources/Plasma/PubUtilLib/plPhysical/plEnvEffectDetector.cpp deleted file mode 100644 index 4101e472..00000000 --- a/Sources/Plasma/PubUtilLib/plPhysical/plEnvEffectDetector.cpp +++ /dev/null @@ -1,76 +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 . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -#include "hsTypes.h" -#include "plEnvEffectDetector.h" -#include "../plMessage/plCollideMsg.h" -#include "plgDispatch.h" -#include "../pnMessage/plEnvEffectMsg.h" - -/* -hsBool plEnvEffectDetector::MsgReceive(plMessage* msg) -{ - plCollideMsg* pCollMsg = plCollideMsg::ConvertNoRef(msg); - - if (pCollMsg) - { - for (int i = 0; i < fEffectMsg.Count(); i++) - { - fEffectMsg[i]->ClearReceivers(); - if(pCollMsg->fEntering) - { - fEffectMsg[i]->Enable( true ); - } else { - fEffectMsg[i]->Enable( false ); - } - fEffectMsg[i]->AddReceiver( pCollMsg->fOtherKey ); - hsRefCnt_SafeRef(fEffectMsg[i]); - plgDispatch::MsgSend( fEffectMsg[i] ); - } - } - return plDetectorModifier::MsgReceive(msg); -} - -void plEnvEffectDetector::Read(hsStream* stream, hsResMgr* mgr) -{ - plDetectorModifier::Read(stream, mgr); - int n = stream->ReadSwap32(); - fEffectMsg.SetCountAndZero(n); - for(int i = 0; i < n; i++ ) - { - plEnvEffectMsg* pMsg = plEnvEffectMsg::ConvertNoRef(mgr->ReadCreatable(stream)); - fEffectMsg[i] = pMsg; - } -} - -void plEnvEffectDetector::Write(hsStream* stream, hsResMgr* mgr) -{ - plDetectorModifier::Write(stream, mgr); - stream->WriteSwap32(fEffectMsg.GetCount()); - for(int i = 0; i < fEffectMsg.GetCount(); i++ ) - mgr->WriteCreatable( stream, fEffectMsg[i] ); - -} -*/ \ No newline at end of file diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plEnvEffectDetector.h b/Sources/Plasma/PubUtilLib/plPhysical/plEnvEffectDetector.h deleted file mode 100644 index 53025cd1..00000000 --- a/Sources/Plasma/PubUtilLib/plPhysical/plEnvEffectDetector.h +++ /dev/null @@ -1,57 +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 . - -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 plEnvEffectDetector_inc -#define plEnvEffectDetector_inc - -#include "plDetectorModifier.h" - -class plEnvEffectMsg; -class plMessage; -class hsStream; -class hsResMgr; - -class plEnvEffectDetector : public plDetectorModifier -{ -protected: - -public: - plEnvEffectDetector(){;} - virtual ~plEnvEffectDetector(){;} - - virtual hsBool MsgReceive(plMessage* msg); - - CLASSNAME_REGISTER( plEnvEffectDetector ); - GETINTERFACE_ANY( plEnvEffectDetector, plDetectorModifier ); - - hsTArray fEffectMsg; - - void Read(hsStream* stream, hsResMgr* mgr); - void Write(hsStream* stream, hsResMgr* mgr); - -}; - -#endif plEnvEffectDetector_inc diff --git a/Sources/Plasma/PubUtilLib/plPipeline/hsGEnviron.cpp b/Sources/Plasma/PubUtilLib/plPipeline/hsGEnviron.cpp deleted file mode 100644 index f230671e..00000000 --- a/Sources/Plasma/PubUtilLib/plPipeline/hsGEnviron.cpp +++ /dev/null @@ -1,1254 +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 . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ - -#include "hsTypes.h" -#include "hsGEnviron.h" -#include "../plSurface/hsGLayer.h" -#include "../plSurface/hsGMaterial.h" -//#include "hsG3DDevice.h" -//#include "plCamera.h" -#include "hsFogControl.h" -#include "../plGRenderProcs/hsGRenderProcs.h" -#if 0 // SCENENODE_DEFER -#include "hsScene.h" -#endif // SCENENODE_DEFER -#include "../plResMgr/hsResMgr.h" -#include "hsGStatGather3.h" -#include "../plResMgr/plKey.h" -#include "hsTimer.h" -#include "../plResMgr/plRefMsg.h" - -const UInt16 hsGEnvironment::kSaveMagicNumber = 0x1f7a; -const UInt16 hsGEnvironment::kSaveVersion = 2; - -hsScalar hsGEnvironment::fYonScale = 1.f; - -hsGEnvironment::hsGEnvironment() - : fFlags(0), - fValidScale(1.f), - fMap(nil), - fPos(0,0,0), - fRadius(0), - fFogDistance(0), - fFogDepth(0), - fCurrentDepth(0), - fFogDensity(0), - fDevCache(nil), - fYon(0), - fFogControl(nil) -{ - fFogColor.SetValue(hsColorRGBA().Set(0, 0, 0, hsScalar1)); - SetFogColor(fFogColor.GetValue()); - *fMapName = 0; -} - -hsGEnvironment::~hsGEnvironment() -{ - hsRefCnt_SafeUnRef(fMap); - hsRefCnt_SafeUnRef(fDevCache); - - hsRefCnt_SafeUnRef(fFogControl); - - Int32 i; - for (i=0; iGetKey()); -} -#endif // SCENENODE_DEFER - -hsBool32 hsGEnvironment::AddNodeKey(plKey *key) -{ - Int32 i; - for (i = 0; i < GetNumNodes(); i++) - { - if (GetNodeKey(i) == key) // nothing to do - return false; - } - fNodeKeys.Append(key); - - hsSceneNode *node = (hsSceneNode *)(key->GetObjectPtr()); -#if 0 // SCENENODE_DEFER - if (node) - { - if (!(GetFlags() & hsGEnvironment::kFarOut)) - { - node->SetEnvironment(this); - } - else - { - node->SetFarEnvironment(this); - } - } -#endif // SCENENODE_DEFER - - return true; -} - -hsSceneNode* hsGEnvironment::GetNode(Int32 i) -{ - return (hsSceneNode*)(fNodeKeys[i]->GetObjectPtr()); -} - -void hsGEnvironment::FogState::ValidateEnv(hsGEnvironment* env) -{ - char* msg = "hsGEnvironment not in reset state."; - if( fFlags & kYonSet ) - { - hsAssert(env->GetFlags() & hsGEnvironment::kYonSet, msg); - hsAssert(fYon == env->YonState(), msg); - } - - if( fFlags & kDistanceSet ) - { - hsAssert(env->GetFlags() & hsGEnvironment::kFogDistanceSet, msg); - hsAssert(fDistance == env->FogDistanceState(), msg); - } - - if( fFlags & kDepthSet ) - { - hsAssert(env->GetFlags() & hsGEnvironment::kFogDepthSet, msg); - hsAssert(fDepth == env->FogDepthState(), msg); - } - - if( fFlags & kDensitySet ) - { - hsAssert(env->GetFlags() & hsGEnvironment::kFogDensitySet, msg); - hsAssert(fDensity == env->FogDensityState(), msg); - } - - if( fFlags & kColorSet ) - { - hsAssert(env->GetFlags() & hsGEnvironment::kFogColorSet, msg); - hsAssert(fColor == env->FogColorState(), msg); - } - - if( fFlags & kClearSet ) - { - hsAssert(env->GetFlags() & hsGEnvironment::kClearColorSet, msg); - hsAssert(fClear == env->ClearColorState(), msg); - } - - UInt32 envFogType = env->GetFlags() & hsGEnvironment::kFogTypeMask; - switch( fFlags & kTypeMask ) - { - case kLinear: - hsAssert(envFogType == hsGEnvironment::kFogLinear, msg); - break; - case kExp: - hsAssert(envFogType == hsGEnvironment::kFogExp, msg); - break; - case kExp2: - hsAssert(envFogType == hsGEnvironment::kFogExp2, msg); - break; - default: - hsAssert(false, msg); - break; - } -} - -void hsGEnvironment::FogState::SetFromEnv(hsGEnvironment* env) -{ - if( env->GetFlags() & hsGEnvironment::kYonSet ) - { - fYon = env->YonState(); - fFlags |= kYonSet; - } - if( env->GetFlags() & hsGEnvironment::kFogDistanceSet ) - { - fDistance = env->FogDistanceState(); - fFlags |= kDistanceSet; - } - if( env->GetFlags() & hsGEnvironment::kFogDepthSet ) - { - fDepth = env->FogDepthState(); - fFlags |= kDepthSet; - } - if( env->GetFlags() & hsGEnvironment::kFogDensitySet ) - { - fDensity = env->FogDensityState(); - fFlags |= kDensitySet; - } - if( env->GetFlags() & hsGEnvironment::kFogColorSet ) - { - fColor = env->FogColorState(); - fFlags |= kColorSet; - } - if( env->GetFlags() & hsGEnvironment::kClearColorSet ) - { - fClear = env->ClearColorState(); - fFlags |= kClearSet; - } - - fFlags &= ~kTypeMask; - switch( env->GetFlags() & hsGEnvironment::kFogTypeMask ) - { - case hsGEnvironment::kFogLinear: - fFlags |= kLinear; - break; - case hsGEnvironment::kFogExp: - fFlags |= kExp; - break; - case hsGEnvironment::kFogExp2: - fFlags |= kExp2; - break; - default: - hsAssert(false, "Fog type should at least default at load"); - break; - } -} - -void hsGEnvironment::FogState::SetToEnv(hsGEnvironment* env) -{ - if( fFlags & kYonSet ) - env->SetYon(fYon); - else - env->UnSetYon(); - - if( fFlags & kDistanceSet ) - env->SetFogDistance(fDistance); - else - env->UnSetFogDistance(); - - if( fFlags & kDepthSet ) - { - env->SetFogDepth(fDepth); - env->SetCurrentDepth(fDepth.GetValue()); - } - else - env->UnSetFogDepth(); - - if( fFlags & kDensitySet ) - env->SetFogDensity(fDensity); - else - env->UnSetFogDensity(); - - if( fFlags & kColorSet ) - env->SetFogColor(fColor); - else - env->UnSetFogColor(); - - if( fFlags & kClearSet ) - env->SetClearColor(fClear); - else - env->UnSetClearColor(); - - switch( fFlags & kTypeMask ) - { - case kLinear: - env->SetFogType(hsGEnvironment::kFogLinear); - break; - case kExp: - env->SetFogType(hsGEnvironment::kFogExp); - break; - case kExp2: - env->SetFogType(hsGEnvironment::kFogExp2); - break; - default: - hsAssert(false, "Setting lack of fog type"); - env->SetFogType(0); - break; - } -} - -const UInt16 hsGEnvironment::FogState::kSaveMagicNumber = 0x7385; -const UInt16 hsGEnvironment::FogState::kSaveVersion = 1; - -void hsGEnvironment::FogState::Save(hsStream *stream, hsResMgr* mgr) -{ - stream->WriteSwap16(kSaveMagicNumber); - stream->WriteSwap16(kSaveVersion); - - hsScalar currSecs = hsTimer::GetSysSeconds(); - stream->WriteSwap32(fFlags); - fColor.Write(stream, currSecs); - fClear.Write(stream, currSecs); - fDistance.WriteScalar(stream, currSecs); - fDensity.WriteScalar(stream, currSecs); - fDepth.WriteScalar(stream, currSecs); - fYon.WriteScalar(stream, currSecs); -} - -void hsGEnvironment::FogState::Load(hsStream *stream, hsResMgr* mgr) -{ - UInt16 magic = stream->ReadSwap16(); - hsAssert(magic == kSaveMagicNumber, "Bad magic number in hsGEnvironment::FogState on load."); - - UInt16 version = stream->ReadSwap16(); - hsAssert(version == kSaveVersion, "Bad version in hsGEnvironment::FogState on load."); - - hsScalar currSecs = hsTimer::GetSysSeconds(); - fFlags = stream->ReadSwap32(); - fColor.Read(stream, currSecs); - fClear.Read(stream, currSecs); - fDistance.ReadScalar(stream, currSecs); - fDensity.ReadScalar(stream, currSecs); - fDepth.ReadScalar(stream, currSecs); - fYon.ReadScalar(stream, currSecs); -} - - -void hsGEnvironment::SetResetState() -{ - fResetState.SetFromEnv(this); -} - -void hsGEnvironment::Reset() -{ - fResetState.SetToEnv(this); - - Int32 i; - for (i=0; iWriteSwap16(kSaveMagicNumber); - stream->WriteSwap16(kSaveVersion); - - stream->WriteSwap32(fFlags); - - if( fFlags & hsGEnvironment::kCenterSet ) - fPos.Write(stream); - - if( fFlags & hsGEnvironment::kRadiusSet ) - stream->WriteSwapScalar(fRadius); - - FogState tempState; - tempState.SetFromEnv(this); - - tempState.Save(stream, mgr); - fResetState.Save(stream, mgr); - - UInt32 numFogStates = fFogStateStack.GetCount(); - stream->WriteSwap32(numFogStates); - for (UInt32 i = 0; i < numFogStates; i++) - { - fFogStateStack[i]->Save(stream, mgr); - } -} - -void hsGEnvironment::Load(hsStream *stream, hsResMgr* mgr) -{ - // Clear old data - UInt32 i; - for (i=0; iReadSwap16(); - hsAssert(magic == kSaveMagicNumber, "Bad magic number in hsGEnvironment on load."); - - UInt16 version = stream->ReadSwap16(); - hsAssert(version == kSaveVersion, "Bad version in hsGEnvironment on load."); - - fFlags = stream->ReadSwap32(); - - if( fFlags & hsGEnvironment::kCenterSet ) - fPos.Read(stream); - - if( fFlags & hsGEnvironment::kRadiusSet ) - fRadius = stream->ReadSwapScalar(); - - FogState tempState; - tempState.Load(stream, mgr); - tempState.SetToEnv(this); - fResetState.Load(stream, mgr); - - UInt32 numFogStates = stream->ReadSwap32(); - for (i = 0; i < numFogStates; i++) - { - FogState *newFogState = new FogState; - newFogState->Load(stream, mgr); - fFogStateStack.Append(newFogState); - } -} - -void hsGEnvironment::Update(hsScalar s, const hsPoint3& vPos) -{ - if( fFlags & kFogDepthSet ) - fFogDepth.Update(s); - if( fFlags & kFogDensitySet ) - fFogDensity.Update(s); - if( fFlags & kFogColorSet ) - fFogColor.Update(s); - if( fFlags & kClearColorSet ) - fClearColor.Update(s); - if( fFlags & kYonSet ) - fYon.Update(s); - if( fFlags & kMapSet ) - { - hsGStatGather3::UpdateMaterialBegin(); - fMap->Update(s); - hsGStatGather3::UpdateMaterialEnd(); - - if( fFlags & kClearColorAmbient ) - SetClearColor(fMap->GetLayer(0)->GetAmbientColor()); - - if( fFlags & kFogColorAmbient ) - SetFogColor(fMap->GetLayer(0)->GetAmbientColor()); - else - if( fFlags & kFogColorDiffuse ) - SetFogColor(fMap->GetLayer(0)->GetColor()); - } - - if( fFlags & kFogDistanceSet ) - { - fFogDistance.Update(s); - - - hsVector3 del(&vPos, &fPos); - hsScalar dist = del.Magnitude(); - - hsScalar yon = hsMaximum(dist, fFogDistance.GetValue()); - - SetYon(yon); - - hsScalar depth = fFogDistance.GetValue(); - if( fFlags & kFogDepthSet ) - depth *= fFogDepth.GetValue(); - - depth += yon - dist; - depth /= yon; - - if( depth > hsScalar1 ) - depth = hsScalar1; - - fCurrentDepth = depth; - fFlags |= kCurrentDepthSet; - } - else if( fFlags & kFogDepthSet ) - { - fCurrentDepth = fFogDepth.GetValue(); - fFlags |= kCurrentDepthSet; - } - else - fFlags &= ~kCurrentDepthSet; - - if( fValidScale != fYonScale ) - { - if( fDevCache ) - fDevCache->Validate(false); - fValidScale = fYonScale; - } -} - -void hsGEnvironment::SetTimedFogDistance(const hsScalar g, const hsScalar s) -{ - if( fFlags & kFogDistanceSet ) - { - fFogDistance.Update(hsTimer::GetSysSeconds()); - fFogDistance.SetGoal(g); - fFogDistance.SetDuration(s); - fFogDistance.StartClock(hsTimer::GetSysSeconds()); - } - else - SetFogDistance(g); -} - -void hsGEnvironment::SetTimedFogDepth(const hsScalar g, const hsScalar s) -{ - if( fFlags & kFogDepthSet ) - { - fFogDepth.Update(hsTimer::GetSysSeconds()); - fFogDepth.SetGoal(g); - fFogDepth.SetDuration(s); - fFogDepth.StartClock(hsTimer::GetSysSeconds()); - } - else - SetFogDepth(g); -} - -void hsGEnvironment::SetTimedFogDensity(const hsScalar g, const hsScalar s) -{ - if( fFlags & kFogDensitySet ) - { - fFogDensity.Update(hsTimer::GetSysSeconds()); - fFogDensity.SetGoal(g); - fFogDensity.SetDuration(s); - fFogDensity.StartClock(hsTimer::GetSysSeconds()); - } - else - SetFogDensity(g); -} - -void hsGEnvironment::SetTimedFogColor(const hsColorRGBA& g, const hsScalar s) -{ - if( fFlags & kFogColorSet ) - { - fFogColor.Update(hsTimer::GetSysSeconds()); - fFogColor.SetGoal(g); - fFogColor.SetDuration(s); - fFogColor.StartClock(hsTimer::GetSysSeconds()); - } - else - SetFogColor(g); -} - -void hsGEnvironment::SetTimedClearColor(const hsColorRGBA& g, const hsScalar s) -{ - if( fFlags & kClearColorSet ) - { - fClearColor.Update(hsTimer::GetSysSeconds()); - fClearColor.SetGoal(g); - fClearColor.SetDuration(s); - fClearColor.StartClock(hsTimer::GetSysSeconds()); - } - else - SetClearColor(g); -} - -void hsGEnvironment::SetTimedYon(const hsScalar g, const hsScalar s) -{ - if( fFlags & kYonSet ) - { - fYon.Update(hsTimer::GetSysSeconds()); - fYon.SetGoal(g); - fYon.SetDuration(s); - fYon.StartClock(hsTimer::GetSysSeconds()); - } - else - SetYon(g); -} - -void hsGEnvironment::SetMapName(const char *n) -{ - if( n ) - { - hsAssert(strlen(n) < 255, "Environment name overflow"); - fFlags |= kMapSet; - strcpy(fMapName, n); - } - else - { - fFlags &= ~kMapSet; - *fMapName = 0; - } -} - -void hsGEnvironment::SetMap(hsGMaterial *m) -{ - fFlags |= kMapSet; - hsRefCnt_SafeAssign(fMap, m); -} - -void hsGEnvironment::SetCenter(const hsPoint3 &p) -{ - fFlags |= kCenterSet; fPos = p; -} - -void hsGEnvironment::SetRadius(hsScalar r) -{ - fFlags |= kRadiusSet; - fRadius = r; -} - -void hsGEnvironment::SetFogDistance(hsScalar f) -{ - if( fDevCache &&( f != fFogDistance.GetValue()) ) - fDevCache->Validate(false); - fFlags |= kFogDistanceSet; - fFogDistance.SetValue(f); -} - -void hsGEnvironment::SetCurrentDepth(hsScalar f) -{ - if( fDevCache && (f != fCurrentDepth) ) - fDevCache->Validate(false); - fFlags |= kCurrentDepthSet; - fCurrentDepth = f; -} - -void hsGEnvironment::SetFogDepth(hsScalar f) -{ - if( fDevCache && (f != fFogDepth.GetValue()) ) - fDevCache->Validate(false); - fFlags |= kFogDepthSet; - fFogDepth.SetValue(f); -} - -void hsGEnvironment::SetFogDensity(hsScalar f) -{ - if( fDevCache && (f != fFogDensity.GetValue()) ) - fDevCache->Validate(false); - fFlags |= kFogDensitySet; - fFogDensity.SetValue(f); -} - -void hsGEnvironment::SetFogColor(const hsColorRGBA &c) -{ - if( fDevCache - && ( - (c.r != fFogColor.GetValue().r) - || (c.g != fFogColor.GetValue().g) - || (c.b != fFogColor.GetValue().b) - ) ) - fDevCache->Validate(false); - fFlags |= kFogColorSet; - fFogColor.SetValue(c); -} - -void hsGEnvironment::SetClearColor(const hsColorRGBA &c) -{ - fFlags |= kClearColorSet; - fClearColor.SetValue(c); -} - -void hsGEnvironment::SetYon(hsScalar f) -{ - if( fDevCache && (f != fYon.GetValue()) ) - fDevCache->Validate(false); - fFlags |= kYonSet; - fYon.SetValue(f); -} - -void hsGEnvironment::SetFogDistance(const hsTimedValue& f) -{ - if( fDevCache ) - fDevCache->Validate(false); - fFlags |= kFogDistanceSet; - fFogDistance = f; -} - -void hsGEnvironment::SetFogDepth(const hsTimedValue& f) -{ - if( fDevCache ) - fDevCache->Validate(false); - fFlags |= kFogDepthSet; - fFogDepth = f; -} - -void hsGEnvironment::SetFogDensity(const hsTimedValue& f) -{ - if( fDevCache ) - fDevCache->Validate(false); - fFlags |= kFogDensitySet; - fFogDensity = f; -} - -void hsGEnvironment::SetFogColor(const hsTimedValue& c) -{ - if( fDevCache ) - fDevCache->Validate(false); - fFlags |= kFogColorSet; - fFogColor = c; -} - -void hsGEnvironment::SetClearColor(const hsTimedValue& c) -{ - fFlags |= kClearColorSet; - fClearColor = c; -} - -void hsGEnvironment::SetYon(const hsTimedValue& f) -{ - if( fDevCache ) - fDevCache->Validate(false); - fFlags |= kYonSet; - fYon = f; -} - -void hsGEnvironment::SetFogType(UInt32 t) -{ - fFlags &= ~kFogTypeMask; - fFlags |= (t & kFogTypeMask); -} - -void hsGEnvironment::SetFogColorAmbient(hsBool32 on) -{ - if( on ) - { - fFlags &= ~kFogColorDiffuse; - fFlags |= kFogColorAmbient; - } - else - fFlags &= ~kFogColorAmbient; -} - -void hsGEnvironment::SetFogColorDiffuse(hsBool32 on) -{ - if( on ) - { - fFlags &= ~kFogColorAmbient; - fFlags |= kFogColorDiffuse; - } - else - fFlags &= ~kFogColorDiffuse; -} - -void hsGEnvironment::SetClearColorAmbient(hsBool32 on) -{ - if( on ) - fFlags |= kClearColorAmbient; - else - fFlags &= ~kClearColorAmbient; -} - -void hsGEnvironment::SetOverride(hsBool32 on) -{ - if( on ) - fFlags |= kOverride; - else - fFlags &= ~kOverride; -} - -void hsGEnvironment::SetIsFar(hsBool32 on) -{ - if( on ) - fFlags |= kFarOut; - else - fFlags &= ~kFarOut; -} - -void hsGEnvironment::SetSortObjects(hsBool32 on) -{ - if( on ) - fFlags |= kSortObjects; - else - fFlags &= ~kSortObjects; -} - -void hsGEnvironment::SetHasFogControl(hsBool32 on) -{ - if( on ) - fFlags |= kFogControl; - else - fFlags &= ~kFogControl; -} - -void hsGEnvironment::SetFogControl(hsFogControl* fc) -{ - hsRefCnt_SafeAssign(fFogControl, fc); -} - -void hsGEnvironment::SetDeviceCache(hsGDevEnvCache *p) -{ - hsRefCnt_SafeAssign(fDevCache, p); -} - -hsGEnvironment *hsGEnvironment::Copy(hsGEnvironment *env) -{ - if( env->GetFlags() & kMapSet ) - SetMap(env->GetMap()); - else - fFlags &= ~kMapSet; - if( env->GetFlags() & kCenterSet ) - SetCenter(env->GetCenter()); - else - fFlags &= ~kCenterSet; - if( env->GetFlags() & kRadiusSet ) - SetRadius(env->GetRadius()); - else - fFlags &= ~kRadiusSet; - if( env->GetFlags() & kFogDepthSet ) - SetFogDepth(env->GetFogDepth()); - else - fFlags &= ~kFogDepthSet; - if( env->GetFlags() & kFogDensitySet ) - SetFogDensity(env->GetFogDensity()); - else - fFlags &= ~kFogDensitySet; - if( env->GetFlags() & kFogColorSet ) - SetFogColor(env->GetFogColor()); - else - fFlags &= ~kFogColorSet; - if( env->GetFlags() & kClearColorSet ) - SetClearColor(env->GetClearColor()); - else - fFlags &= ~kClearColorSet; - if( env->GetFlags() & kYonSet ) - SetYon(env->GetUnscaledYon()); - else - fFlags &= ~kYonSet; - - if( env->GetFlags() & kCurrentDepthSet ) - { - fCurrentDepth = env->GetCurrentDepth(); - fFlags |= kCurrentDepthSet; - } - - fFlags &= ~hsGEnvironment::kFogTypeMask; - fFlags |= env->GetFlags() & hsGEnvironment::kFogTypeMask; - - SetOverride(env->GetOverride()); - - SetDeviceCache(env->GetDeviceCache()); - - if( env->GetFlags() & kCacheInvalid ) - fFlags |= kCacheInvalid; - else - fFlags &= ~kCacheInvalid; - - int i; - for( i = 0; i < env->GetNumRenderProcs(); i++ ) - AddRenderProc(env->GetRenderProc(i)); - - return this; -} - -void hsGEnvironment::MixEnvirons(hsGEnvironment *env, hsGEnvironment *def) -{ - if( env && (env->GetFlags() & kMapSet) ) - { - SetMap(env->GetMap()); - } - else if( def && (def->GetFlags() & kMapSet) ) - { - hsGMaterial *map = def->GetMap(); - if( map ) - { - SetMap(def->GetMap()); - } - else - { - def->SetMapName(nil); - hsRefCnt_SafeUnRef(fMap); - fMap = nil; - fFlags &= ~kMapSet; - } - } - else - { - hsRefCnt_SafeUnRef(fMap); - fMap = nil; - fFlags &= ~kMapSet; - } - if( env && (env->GetFlags() & kCenterSet) ) - SetCenter(env->GetCenter()); - else if( def &&(def->GetFlags() & kCenterSet) ) - SetCenter(def->GetCenter()); - else - fFlags &= ~kCenterSet; - if( env && (env->GetFlags() & kRadiusSet) ) - SetRadius(env->GetRadius()); - else if( def &&(def->GetFlags() & kRadiusSet) ) - SetRadius(def->GetRadius()); - else - fFlags &= ~kRadiusSet; - - if( env && (env->GetFlags() & kFogDepthSet) ) - SetFogDepth(env->GetFogDepth()); - else if( def &&(def->GetFlags() & kFogDepthSet) ) - SetFogDepth(def->GetFogDepth()); - else - fFlags &= ~kFogDepthSet; - - if( env &&(env->GetFlags() & kCurrentDepthSet) ) - { - fCurrentDepth = env->GetCurrentDepth(); - fFlags |= kCurrentDepthSet; - } - else - if( def &&(def->GetFlags() & kCurrentDepthSet) ) - { - fCurrentDepth = def->GetCurrentDepth(); - fFlags |= kCurrentDepthSet; - } - else - fFlags &= ~kCurrentDepthSet; - - fFlags &= ~kFogTypeMask; - if( env && (env->GetFlags() & kFogTypeMask) ) - fFlags |= env->GetFlags() & kFogTypeMask; - else if( def && (def->GetFlags() & kFogTypeMask) ) - fFlags |= def->GetFlags() & kFogTypeMask; - else - fFlags &= ~kFogTypeMask; - - if( env && (env->GetFlags() & kFogDensitySet) ) - SetFogDensity(env->GetFogDensity()); - else if( def &&(def->GetFlags() & kFogDensitySet) ) - SetFogDensity(def->GetFogDensity()); - else - SetFogDensity(hsScalar1); - - if( env &&(env->GetFlags() & kFogColorSet) ) - SetFogColor(env->GetFogColor()); - else if( def &&(def->GetFlags() & kFogColorSet) ) - SetFogColor(def->GetFogColor()); - else - { - hsColorRGBA col; - col.r = col.g = col.b = col.a = 0; - SetFogColor(col); - } - if( env &&(env->GetFlags() & kClearColorSet) ) - SetClearColor(env->GetClearColor()); - else if( def &&(def->GetFlags() & kClearColorSet) ) - SetClearColor(def->GetClearColor()); - else - fFlags &= ~kClearColorSet; - - if( env && (env->GetFlags() & kYonSet) ) - SetYon(env->GetUnscaledYon()); - else if( def &&(def->GetFlags() & kYonSet) ) - SetYon(def->GetUnscaledYon()); - else - fFlags &= ~kYonSet; - - if( env && (env->GetOverride()) ) - SetOverride(true); - else if( def &&(def->GetOverride()) ) - SetOverride(true); - else - SetOverride(false); - - if( env && env->GetDeviceCache() ) - SetDeviceCache(env->GetDeviceCache()); - else if( def && def->GetDeviceCache() ) - SetDeviceCache(def->GetDeviceCache()); - else - SetDeviceCache(nil); - - int i; - for( i = 0; i < GetNumRenderProcs(); i++ ) - { - hsRefCnt_SafeUnRef(GetRenderProc(i)); - } - fRenderProcs.Reset(); - if( env ) - { - for( i = 0; i < env->GetNumRenderProcs(); i++ ) - AddRenderProc(env->GetRenderProc(i)); - } - if( def ) - { - for( i = 0; i < def->GetNumRenderProcs(); i++ ) - AddRenderProc(def->GetRenderProc(i)); - } - -} - -void hsGEnvironment::Blend() -{ - if( fFogControl ) - fFogControl->Blend(); -} - -void hsGEnvironment::Restore() -{ - if( fFogControl ) - fFogControl->Restore(); -} - -void hsGEnvironment::Init(hsSceneNode* node) -{ - if (!node) - { - char str[256]; - sprintf(str, "hsGEnvironment %s initted with nil room. Weirdness may result.", - GetKeyName()); - HSDebugProc(str); - } - else - { - if( fFogControl ) - fFogControl->Init(node); - } - - SetResetState(); -} - -void hsGEnvironment::SaveFogState() -{ - FogState* curFogState = new FogState; - curFogState->SetFromEnv(this); - fFogStateStack.Push(curFogState); -} - -void hsGEnvironment::RestoreFogState() -{ - FogState* curFogState = fFogStateStack.GetCount() ? fFogStateStack.Pop() : nil; - if (curFogState) - { - curFogState->SetToEnv(this); - } - delete curFogState; -} - -void hsGEnvironment::Read(hsStream *stream) -{ - fFlags = stream->ReadSwap32(); - - if( fFlags & hsGEnvironment::kFogDistanceSet ) - { - hsScalar d = stream->ReadSwapScalar(); - SetFogDistance(d); - } - if( fFlags & hsGEnvironment::kFogDepthSet ) - { - hsScalar d = stream->ReadSwapScalar(); - SetFogDepth(d); - SetCurrentDepth(d); - } - if( fFlags & hsGEnvironment::kFogDensitySet ) - { - hsScalar d = stream->ReadSwapScalar(); - SetFogDensity(d); - } - if( fFlags & hsGEnvironment::kFogColorSet ) - { - hsColorRGBA c; - c.r = stream->ReadSwapScalar(); - c.g = stream->ReadSwapScalar(); - c.b = stream->ReadSwapScalar(); - c.a = stream->ReadSwapScalar(); - SetFogColor(c); - } - if( fFlags & hsGEnvironment::kClearColorSet ) - { - hsColorRGBA c; - c.r = stream->ReadSwapScalar(); - c.g = stream->ReadSwapScalar(); - c.b = stream->ReadSwapScalar(); - c.a = stream->ReadSwapScalar(); - SetClearColor(c); - } - if( fFlags & hsGEnvironment::kYonSet ) - { - hsScalar d = stream->ReadSwapScalar(); - SetYon(d); - } - - if( fFlags & hsGEnvironment::kCenterSet ) - fPos.Read(stream); - if( fFlags & hsGEnvironment::kRadiusSet ) - fRadius = stream->ReadSwapScalar(); - // still don't write the map out - - if( !(fFlags & kFogTypeMask) ) - { - if( GetFogDepth() <= 0.5f ) - fFlags |= kFogLinear; - else - fFlags |= kFogExp; - } -} - -void hsGEnvironment::Write(hsStream *stream) -{ - stream->WriteSwap32(fFlags); - - if( fFlags & hsGEnvironment::kFogDistanceSet ) - stream->WriteSwapScalar(GetFogDistance()); - if( fFlags & hsGEnvironment::kFogDepthSet ) - stream->WriteSwapScalar(GetFogDepth()); - if( fFlags & hsGEnvironment::kFogDensitySet ) - stream->WriteSwapScalar(GetFogDensity()); - if( fFlags & hsGEnvironment::kFogColorSet ) - { - hsColorRGBA c = GetFogColor(); - stream->WriteSwapScalar(c.r); - stream->WriteSwapScalar(c.g); - stream->WriteSwapScalar(c.b); - stream->WriteSwapScalar(c.a); - } - if( fFlags & hsGEnvironment::kClearColorSet ) - { - hsColorRGBA c = GetClearColor(); - stream->WriteSwapScalar(c.r); - stream->WriteSwapScalar(c.g); - stream->WriteSwapScalar(c.b); - stream->WriteSwapScalar(c.a); - } - if( fFlags & hsGEnvironment::kYonSet ) - stream->WriteSwapScalar(GetUnscaledYon()); - - if( fFlags & hsGEnvironment::kCenterSet ) - fPos.Write(stream); - if( fFlags & hsGEnvironment::kRadiusSet ) - stream->WriteSwapScalar(fRadius); - // still don't write the map out - -} - -void hsGEnvironment::Write(hsStream* stream, hsResMgr* group) -{ - Write(stream); - - if( fFlags & hsGEnvironment::kHasRenderProcs ) - { - int n = GetNumRenderProcs(); - stream->WriteSwap32(n); - int i; - for( i = 0; i < n; i++ ) - { -hsAssert(0,"Its Pauls fault"); -// plFactory::LabelAndWrite(stream, group, GetRenderProc(i)); - } - } - - if ((GetFlags() & hsGEnvironment::kEnvironMapSet) == hsGEnvironment::kEnvironMapSet) - { - group->WriteKey(stream, GetMap()); - } - - stream->WriteSwap32(fNodeKeys.GetCount()); - Int32 i; - for (i = 0; i < fNodeKeys.GetCount(); i++) - { - group->WriteKey(stream, fNodeKeys[i]); - } - - if( fFlags & hsGEnvironment::kFogControl ) - IWriteFogControl(stream, group); -} - -void hsGEnvironment::Read(hsStream* stream, hsResMgr* group) -{ - Read(stream); - - if( fFlags & hsGEnvironment::kHasRenderProcs ) - { - int n = stream->ReadSwap32(); - int i; - for( i = 0; i < n; i++ ) - { -hsAssert(0,"Its Pauls fault"); -// hsGRenderProcs* rp = hsGRenderProcs::ConvertNoRef(plFactory::CreateAndRead(stream, group)); -// AddRenderProc(rp); -// hsRefCnt_SafeUnRef(rp); - } - } - - if ((GetFlags() & hsGEnvironment::kEnvironMapSet) == hsGEnvironment::kEnvironMapSet) - { - plRefMsg* refMsg = new plRefMsg(GetKey(), plRefMsg::kOnCreate); - group->ReadKeyNotifyMe(stream,refMsg); - } - - hsAssert(fNodeKeys.GetCount() == 0, "fNodeKeys not empty in hsGEnvironment::Read."); - Int32 nodeCount = stream->ReadSwap32(); - hsAssert(nodeCount > 0, "Environment node not in any rooms in hsGEnvironment::Read."); - Int32 i; - for (i = 0; i < nodeCount; i++) - { - plKey *key = group->ReadKey(stream); - AddNodeKey(key); - } - - if( fFlags & hsGEnvironment::kFogControl ) - IReadFogControl(stream, group); -} - -void hsGEnvironment::IReadFogControl(hsStream* s, hsResMgr* mgr) -{ -hsAssert(0,"Its Pauls fault"); -// hsFogControl* fc = hsFogControl::ConvertNoRef(plFactory::CreateAndRead(s, mgr)); -// SetFogControl(fc); -// hsRefCnt_SafeUnRef(fc); - -} - -void hsGEnvironment::IWriteFogControl(hsStream* s, hsResMgr* mgr) -{ -hsAssert(0,"Its Pauls fault"); -// plFactory::LabelAndWrite(s, mgr, fFogControl); -} - -void hsGEnvironment::Push(hsG3DDevice* d) -{ -#if 0 // Nuking old device - mf - int i; - - for( i = 0; i < GetNumRenderProcs(); i++ ) - d->AddRenderProc(GetRenderProc(i)); -#endif // Nuking old device - mf -} - -void hsGEnvironment::Pop(hsG3DDevice* d) -{ -#if 0 // Nuking old device - mf - int i; - for( i = 0; i < GetNumRenderProcs(); i++ ) - d->RemoveRenderProc(GetRenderProc(i)); -#endif // Nuking old device - mf -} - -void hsGEnvironment::AddRenderProc(hsGRenderProcs* rp) -{ - hsRefCnt_SafeRef(rp); - fRenderProcs.Append(rp); - fFlags |= hsGEnvironment::kHasRenderProcs; -} - -hsGRenderProcs* hsGEnvironment::GetRenderProc(int i) -{ - return fRenderProcs[i]; -} - -UInt32 hsGEnvironment::GetNumRenderProcs() -{ - return fRenderProcs.GetCount(); -} - -hsScalar hsGEnvironment::SetYonScale(hsScalar s) -{ - const hsScalar kMinYonScale = 0.05f; - const hsScalar kMaxYonScale = 100.f; - - if( s < kMinYonScale ) - s = kMinYonScale; - else if( s > kMaxYonScale ) - s = kMaxYonScale; - return fYonScale = s; -} - -hsBool hsGEnvironment::MsgReceive(plMessage* msg) -{ - plRefMsg* refMsg = plRefMsg::ConvertNoRef(msg); - - if( refMsg ) - { - - hsGMaterial *mat = hsGMaterial::ConvertNoRef(refMsg->GetRef()); - SetMap(mat); - } - return false; -} \ No newline at end of file diff --git a/Sources/Plasma/PubUtilLib/plPipeline/hsGEnviron.h b/Sources/Plasma/PubUtilLib/plPipeline/hsGEnviron.h deleted file mode 100644 index db10215a..00000000 --- a/Sources/Plasma/PubUtilLib/plPipeline/hsGEnviron.h +++ /dev/null @@ -1,273 +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 . - -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 hsGEnviron_inc -#define hsGEnviron_inc - -#include "hsGeometry3.h" // hsPoint3 -#include "../plInterp/hsTimedValue.h" -#include "../plResMgr/hsKeyedObject.h" -#include "hsColorRGBA.h" -#include "hsTemplates.h" - -// -//----------------------------------- -// Environment -//----------------------------------- -// - -class hsGMaterial; -class hsGDevEnvCache; -class hsFogControl; -class hsSceneNode; -class hsScene; -class hsGRenderProcs; -class hsG3DDevice; -class plKey; -class hsResMgr; - -class hsGEnvironment : public hsKeyedObject { -private: - static const UInt16 kSaveMagicNumber; - static const UInt16 kSaveVersion; - -public: - struct FogState { - private: - static const UInt16 kSaveMagicNumber; - static const UInt16 kSaveVersion; - - public: - FogState() : fFlags(0) {}; - enum { - kColorSet = 0x1, - kDistanceSet = 0x2, - kDepthSet = 0x4, - kDensitySet = 0x8, - kYonSet = 0x10, - kClearSet = 0x20, - - kLinear = 0x10000000, - kExp = 0x20000000, - kExp2 = 0x40000000, - kTypeMask = kLinear | kExp | kExp2 - }; - UInt32 fFlags; - hsTimedValue fColor; - hsTimedValue fClear; - hsTimedValue fDistance; - hsTimedValue fDensity; - hsTimedValue fDepth; - hsTimedValue fYon; - - void ValidateEnv(class hsGEnvironment* env); - void SetFromEnv(class hsGEnvironment* env); - void SetToEnv(class hsGEnvironment* env); - void Save(hsStream *stream, hsResMgr* mgr); - void Load(hsStream *stream, hsResMgr* mgr); - }; - - enum { - kMapSet = 0x1, - kCenterSet = 0x2, - kRadiusSet = 0x4, - kEnvironMapSet = kMapSet | kCenterSet | kRadiusSet, - kFogDepthSet = 0x8, - kFogColorSet = 0x10, - kFogDensitySet = 0x20, - kYonSet = 0x40, - kOverride = 0x80, - kFarOut = 0x100, - kFogDistanceSet = 0x200, - kCacheInvalid = 0x400, - kClearColorSet = 0x800, - kCurrentDepthSet = 0x1000, - kFogControl = 0x2000, - kSortObjects = 0x4000, - kHasRenderProcs = 0x8000, - kFogLinear = 0x10000, - kFogExp = 0x20000, - kFogExp2 = 0x40000, - kFogTypeMask = kFogLinear | kFogExp | kFogExp2, - kClearColorAmbient = 0x80000, - kFogColorAmbient = 0x100000, - kFogColorDiffuse = 0x200000 - }; -protected: - static hsScalar fYonScale; - - UInt32 fFlags; - hsGMaterial* fMap; - char fMapName[256]; - hsPoint3 fPos; - hsScalar fRadius; - hsScalar fValidScale; - hsTArray fFogStateStack; - hsTimedValue fFogDistance; - hsTimedValue fFogDepth; // value 0..1, as fraction of yon, 0 is no fog - hsTimedValue fFogDensity; - hsTimedValue fFogColor; - hsTimedValue fClearColor; - hsTimedValue fYon; - hsScalar fCurrentDepth; // function of Depth and Distance - - FogState fResetState; - hsGDevEnvCache* fDevCache; - - hsDynamicArray fRenderProcs; - hsTArray fNodeKeys; - - hsFogControl* fFogControl; - - void IReadFogControl(hsStream* s, hsResMgr* mgr); - void IWriteFogControl(hsStream* s, hsResMgr* mgr); - -public: - hsGEnvironment(); - virtual ~hsGEnvironment(); - - hsBool32 AddNode(hsSceneNode *node); - hsBool32 AddNodeKey(plKey *key); - Int32 GetNumNodes() { return fNodeKeys.GetCount(); } - hsSceneNode* GetNode(Int32 i); - plKey* GetNodeKey(Int32 i) { return fNodeKeys[i]; } - - char* GetMapName() { return fMapName; } - hsGMaterial* GetMap() const { return fMap; } - hsPoint3 GetCenter() const { return fPos; } - hsScalar GetRadius() const { return fRadius; } - hsScalar GetFogDistance() const { return fFogDistance.GetValue(); } - hsScalar GetFogDepth() const { return fFogDepth.GetValue(); } - hsScalar GetCurrentDepth() const { return fCurrentDepth; } - hsScalar GetFogDensity() const { return fFogDensity.GetValue(); } - hsColorRGBA GetFogColor() const { return fFogColor.GetValue(); } - hsColorRGBA GetClearColor() const { return fClearColor.GetValue(); } - hsScalar GetYon() const { return fYonScale * fYon.GetValue(); } - hsScalar GetUnscaledYon() const { return fYon.GetValue(); } - hsBool32 GetOverride() const { return 0 != (fFlags & kOverride); } - UInt32 GetFlags() const { return fFlags; } - - hsScalar GoalFogDistance() const { return fFogDistance.GetGoal(); } - hsScalar GoalFogDepth() const { return fFogDepth.GetGoal(); } - hsScalar GoalFogDensity() const { return fFogDensity.GetGoal(); } - hsColorRGBA GoalFogColor() const { return fFogColor.GetGoal(); } - hsColorRGBA GoalClearColor() const { return fClearColor.GetGoal(); } - hsScalar GoalYon() const { return fYon.GetGoal(); } - - const hsTimedValue& FogDistanceState() const { return fFogDistance; } - const hsTimedValue& FogDepthState() const { return fFogDepth; } - const hsTimedValue& FogDensityState() const { return fFogDensity; } - const hsTimedValue& FogColorState() const { return fFogColor; } - const hsTimedValue& ClearColorState() const { return fClearColor; } - const hsTimedValue& YonState() const { return fYon; } - - void SetFogDistance(const hsTimedValue& v); - void SetFogDepth(const hsTimedValue& v); - void SetFogDensity(const hsTimedValue& v); - void SetFogColor(const hsTimedValue& v); - void SetClearColor(const hsTimedValue& v); - void SetYon(const hsTimedValue& v); - - void SetMapName(const char *name); - void SetMap(hsGMaterial *m); // refs - void SetCenter(const hsPoint3 &p); - void SetRadius(hsScalar r); - void SetFogDistance(hsScalar d); - void SetFogDepth(hsScalar f); - void SetCurrentDepth(hsScalar f); - void SetFogDensity(hsScalar f); - void SetFogColor(const hsColorRGBA &c); - void SetClearColor(const hsColorRGBA &c); - void SetYon(hsScalar f); - void SetOverride(hsBool32 on); - void SetIsFar(hsBool32 on=true); - void SetHasFogControl(hsBool32 on=true); - void SetSortObjects(hsBool32 on=true); - void SetFogType(UInt32 t); - void SetFogColorAmbient(hsBool32 on=true); - void SetFogColorDiffuse(hsBool32 on=true); - void SetClearColorAmbient(hsBool32 on=true); - - void SetTimedFogDistance(const hsScalar g, const hsScalar s); - void SetTimedFogDepth(const hsScalar g, const hsScalar s); - void SetTimedFogDensity(const hsScalar g, const hsScalar s); - void SetTimedFogColor(const hsColorRGBA& g, const hsScalar s); - void SetTimedClearColor(const hsColorRGBA& g, const hsScalar s); - void SetTimedYon(const hsScalar g, const hsScalar s); - - void UnSetMapName() { *fMapName = 0; } - void UnSetEnvironMap() { fFlags &= ~kEnvironMapSet; } - void UnSetFogDistance() { fFlags &= ~kFogDistanceSet; } - void UnSetFogDepth() { fFlags &= ~kFogDepthSet; } - void UnSetFogDensity() { fFlags &= ~kFogDensitySet; } - void UnSetFogColor() { fFlags &= ~kFogColorSet; } - void UnSetClearColor() { fFlags &= ~kClearColorSet; } - void UnSetYon() { fFlags &= ~kYonSet; } - - hsGEnvironment* Copy(hsGEnvironment* env); // returns this - - void MixEnvirons(hsGEnvironment* env, hsGEnvironment* def); - - void Push(hsG3DDevice* d); - void Pop(hsG3DDevice* d); - - void Blend(); - void Restore(); - void Init(hsSceneNode* node); - - void SetDeviceCache(hsGDevEnvCache* p); - hsGDevEnvCache* GetDeviceCache(){ return fDevCache; } - - void SetFogControl(hsFogControl* fc); - hsFogControl* GetFogControl() { return fFogControl; } - - void SaveFogState(); // push - hsGEnvironment::FogState* PopFogState() { return fFogStateStack.GetCount() ? fFogStateStack.Pop() : nil; } // doesn't restore - void RestoreFogState(); // pop and restore - - void AddRenderProc(hsGRenderProcs* rp); // refs - hsGRenderProcs* GetRenderProc(int i); // no ref - UInt32 GetNumRenderProcs(); - - virtual void SetResetState(); - virtual void Reset(); - virtual void ValidateInResetState(); - virtual void Save(hsStream *stream, hsResMgr* mgr); - virtual void Load(hsStream *stream, hsResMgr* mgr); - virtual void Update(hsScalar secs, const hsPoint3& vPos); - - virtual void Read(hsStream* s); - virtual void Write(hsStream* s); - - virtual void Write(hsStream *stream, hsResMgr *group); - virtual void Read(hsStream *stream, hsResMgr *group); - - static hsScalar GetYonScale() { return fYonScale; } - static hsScalar SetYonScale(hsScalar s); - - virtual hsBool MsgReceive(plMessage* msg); -}; - -#endif // hsGEnviron_inc diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp index cbbd49a2..e52ef7ba 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp @@ -40,6 +40,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pfGameGUIMgr/pfGameGUIMgr.h" +#else // MF_FRONTBUFF_CAPTURE + +#include "plPipeline.h" +#include "plgDispatch.h" + +#include "plMessage/plCaptureRenderMsg.h" +#include "plGImage/plMipmap.h" + +#endif // MF_FRONTBUFF_CAPTURE + + +#ifndef MF_FRONTBUFF_CAPTURE // CaptureRenderRequest // void plCaptureRenderRequest::Render(plPipeline* pipe, plPageTreeMgr* pageMgr) @@ -179,12 +191,6 @@ void plCaptureRender::Update() #else // MF_FRONTBUFF_CAPTURE -#include "plPipeline.h" -#include "plgDispatch.h" - -#include "../plMessage/plCaptureRenderMsg.h" -#include "../plGImage/plMipmap.h" - hsTArray plCaptureRender::fCapReqs; void plCaptureRender::Update(plPipeline* pipe) diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.h b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.h index fc8b7d25..bf876d9e 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.h @@ -62,7 +62,7 @@ public: #else // MF_FRONTBUFF_CAPTURE #include "hsTemplates.h" -#include "../pnKeyedObject/plKey.h" +#include "pnKeyedObject/plKey.h" class plPipeline; diff --git a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp index 7ba9f65d..1b7008a5 100644 --- a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp @@ -38,7 +38,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plProgressMgr.h" #include "hsTimer.h" -#include "../plPipeline/plPlates.h" +#include "plPipeline/plPlates.h" #include diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plIndexFile.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plIndexFile.cpp deleted file mode 100644 index acf3c53e..00000000 --- a/Sources/Plasma/PubUtilLib/plResMgr/plIndexFile.cpp +++ /dev/null @@ -1,195 +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 . - -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==*/ -#define plIndexFile_cpp // for version numbers in plVersion.h - -#include "plIndexFile.h" -#include "hsStream.h" -#include "plVersion.h" - -//-------------------- -// plIndexFileHeader -//-------------------- - -plIndexFileHeader::plIndexFileHeader() -{ - fTimeStamp[ 0 ] = fTimeStamp[ 1 ] = 0; - fStrTblStartPos = 0; - fStrTblKnt = 0; - fMajorVersion = plVersion::GetMajorVersion(); - fMinorVersion = plVersion::GetMinorVersion(); - fExportLocal = 0; -} - -void plIndexFileHeader::Write(hsStream *s) -{ - s->WriteSwap32(2,fTimeStamp); - s->WriteSwap32(fStrTblStartPos); - s->WriteSwap16(fStrTblKnt); - s->WriteSwap16(fMajorVersion); - s->WriteSwap16(fMinorVersion); - s->WriteSwap16(fExportLocal); -} -void plIndexFileHeader::Read(hsStream *s) -{ - s->ReadSwap32(2,fTimeStamp); - fStrTblStartPos = s->ReadSwap32(); - fStrTblKnt = s->ReadSwap16(); - fMajorVersion = s->ReadSwap16(); - fMinorVersion = s->ReadSwap16(); - fExportLocal = s->ReadSwap16(); -} - -//-------------------- -// plIndexFileRoom -//-------------------- - -void plIndexFileRoom::Write(hsStream *s) -{ - fRmUoid.Write(s); - s->WriteSwap32(fTypesInRoom); - s->WriteSwap16(fFiller1_16); - s->WriteSwap32(fFiller2_32); - s->WriteSwap32(fFiller3_32); -} -void plIndexFileRoom::Read(hsStream *s) -{ - fRmUoid.Read(s); - fTypesInRoom = s->ReadSwap32(); - s->ReadSwap16(); - s->ReadSwap32(); - s->ReadSwap32(); -} -//-------------------- -// plIndexFileType -//-------------------- - - -void plIndexFileType::Write(hsStream *s) -{ - fTypeUoid.Write(s); - s->WriteSwap32(fNumKeys); - s->WriteSwap32(fFiller1_32); - s->WriteSwap32(fFiller2_32); -} - -void plIndexFileType::Read(hsStream *s) -{ - fTypeUoid.Read(s); - fNumKeys = s->ReadSwap32(); - s->ReadSwap32(); - s->ReadSwap32(); -} -//-------------------- -// plIndexFileKey -//-------------------- - - -void plIndexFileKey::Write(hsStream *s) -{ - fKeyUoid.Write(s); - s->WriteSwap32(fStartPos); - s->WriteSwap32(fDataLen); - s->WriteSwap16(fNameIx); - s->WriteSwap16(fFiller1_16); -} - - -void plIndexFileKey::Read(hsStream *s) -{ - fKeyUoid.Read(s); - fStartPos = s->ReadSwap32(); - fDataLen = s->ReadSwap32(); - fNameIx = s->ReadSwap16(); - s->ReadSwap16(); -} - - - - -//-------------------- -// plIxStrTbl -//-------------------- - -plIxStrTbl::~plIxStrTbl() -{ - if (fpStrings) delete []fpStrings; // if strings came from elsewhere, not our responsibility -} - -UInt16 plIxStrTbl::AddString(const char *p) -{ Int16 ix = FindString(p); - if (ix != -1) - return ix; // duplicate - fStringTbl.push_back(p); return fStringTbl.size() - 1; -} - -Int16 plIxStrTbl::FindString(const char *p) -{ - for (int i=0; i < fStringTbl.size(); i++) - { - if (!_stricmp(p,fStringTbl[i])) - return i; - } - return -1; -} - -void plIxStrTbl::Write(hsStream *s) -{ - for (int i=0; i < fStringTbl.size(); i++) - { Int32 len= fStringTbl[i] ? strlen(fStringTbl[i]) : 0; - hsAssert(len < 256,"Name string too long"); - UInt8 l = (UInt8) len; - s->WriteByte(l); // FUTURE, don't really need length! - if (len) - { - s->Write(len, fStringTbl[i]); - } - s->WriteByte(0); // Null terminate - } -} - -void plIxStrTbl::Read(hsStream *s) -{ UInt32 pos = s->GetPosition(); - s->FastFwd(); - fTabSize = s->GetPosition() - pos; // Get size of table - s->SetPosition(pos); - fpStrings = new char[fTabSize]; - hsAssert(fpStrings,"new failed"); - s->Read(fTabSize,fpStrings); // Read all the string in - - char *p = fpStrings; - while (p < fpStrings + fTabSize) - { - UInt8 len = *p; - p++; - hsAssert(p < fpStrings + fTabSize,"String Index error"); - fStringTbl.push_back(p); - p += len + 1; // past len and NULL - }; -} - - - - diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plIndexFile.h b/Sources/Plasma/PubUtilLib/plResMgr/plIndexFile.h deleted file mode 100644 index 14c2523a..00000000 --- a/Sources/Plasma/PubUtilLib/plResMgr/plIndexFile.h +++ /dev/null @@ -1,152 +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 . - -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 PLINDEXFILE_H -#define PLINDEXFILE_H - -#include "../pnKeyedObject/plUoid.h" -#include - //--------------------------------------------------------------- - // These Classes are used to Read and Write the Index file for the Database - // Records are kept the same size Currently 20 Bytes - // At the End of the file, the Strings are stored - // plIxStrTbl is used to Read and Write the String section of the Index - //--------------------------------------------------------------- - - //--------------------------------------------------------------- - // Main header Entry, One per Index file - //--------------------------------------------------------------- -class plIndexFileHeader -{ -public: - plIndexFileHeader(); // I buried Paul - ~plIndexFileHeader(){} - - UInt32 fTimeStamp[2]; - UInt32 fStrTblStartPos; // where the String table starts in the Index file - UInt16 fStrTblKnt; // how many strings in the string table - UInt16 fMajorVersion; - UInt16 fMinorVersion; - UInt16 fExportLocal; // was this file exported locally or downloaded from server? - - void Write(hsStream *s); - void Read(hsStream *s); -}; - - //--------------------------------------------------------------- - // Room Entry One Entry per Room - //--------------------------------------------------------------- -class plIndexFileRoom -{ -public: - plIndexFileRoom() { memset(this,1,sizeof(this)); } // no virtuals...relax - ~plIndexFileRoom(){} - - plUoid fRmUoid; - UInt16 fTypesInRoom; - UInt16 fFiller1_16; - UInt32 fFiller2_32; - UInt32 fFiller3_32; - - void Write(hsStream *s); - void Read(hsStream *s); -}; - - //--------------------------------------------------------------- - // Type Entry One Entry per Type in each Room - //--------------------------------------------------------------- - -class plIndexFileType -{ -public: - plIndexFileType() { memset(this,1,sizeof(this)); } // no virtuals...relax - ~plIndexFileType(){} - - plUoid fTypeUoid; - UInt16 fNumKeys; - UInt32 fFiller1_32; - UInt32 fFiller2_32; - - void Write(hsStream *s); - void Read(hsStream *s); -}; - - //--------------------------------------------------------------- - // Key Entry One Entry per Type in each Room - //--------------------------------------------------------------- - -class plIndexFileKey -{ -public: - plIndexFileKey() { memset(this,1,sizeof(this)); } // no virtuals...relax - ~plIndexFileKey(){} - - - plUoid fKeyUoid; - UInt32 fStartPos; - UInt32 fDataLen; - UInt16 fNameIx; // Index into string table of name - UInt16 fFiller1_16; - - void Write(hsStream *s) ; - void Read(hsStream *s); -}; - - //--------------------------------------------------------------- - // String Table, Lives at the end of the Index File - //--------------------------------------------------------------- -class plIxStrTbl -{ - std::vectorfStringTbl; - char *fpStrings; - UInt32 fTabSize; // buffer size for strings - -public: - - plIxStrTbl() :fpStrings(nil), fTabSize(0){} - ~plIxStrTbl(); - - Int16 FindString(const char *p); // returns -1 if not found, otherwise the index from zero - UInt16 AddString(const char *p); - UInt16 NumStrings() { return fStringTbl.size(); } - const char * GetString(UInt16 x) { return fStringTbl[x]; } - - void Write(hsStream *s); - void Read(hsStream *s); -}; - -class plLinkRecord -{ -public: - plLinkRecord(UInt16 a, UInt16 d, UInt16 r) : fAgeIx(a), fDistIx(d), fRoomIx(r){} - ~plLinkRecord(){} - - UInt16 fAgeIx; // Index into string table - UInt16 fDistIx; - UInt16 fRoomIx; - UInt32 fTimeStamp[2]; -}; - -#endif diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plLoc.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plLoc.cpp index d85630b1..4c2a5573 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plLoc.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plLoc.cpp @@ -24,7 +24,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "plLoc.h" -#include "../pnKeyedObject/hsKeyedObject.h" +#include "pnKeyedObject/hsKeyedObject.h" plLocFileParser::plLocFileParser(): fThrowBack(nil), fThrowBackLevel(0) diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plCalculatedProfiles.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plCalculatedProfiles.cpp index f3654438..c6eb9185 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plCalculatedProfiles.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plCalculatedProfiles.cpp @@ -27,6 +27,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plProfileManager.h" #include "plNetClient/plNetClientMgr.h" #include "hsTimer.h" +#include "plPipeline/plPlates.h" plProfile_CreateCounter("Age Upload BitsPerSec", "Network", UploadAgeBitsPerSec); plProfile_CreateMemCounter("Upload Bytes", "Network", UploadBW); @@ -119,8 +120,6 @@ void CalculateProfiles() } } -#include "../plPipeline/plPlates.h" - static plGraphPlate* fFPSPlate = nil; static plGraphPlate* fNetBWPlate = nil; static plGraphPlate* fNetPPSPlate = nil; diff --git a/Sources/Plasma/PubUtilLib/plStreamLogger/plStreamLogger.h b/Sources/Plasma/PubUtilLib/plStreamLogger/plStreamLogger.h index a96de745..81082290 100644 --- a/Sources/Plasma/PubUtilLib/plStreamLogger/plStreamLogger.h +++ b/Sources/Plasma/PubUtilLib/plStreamLogger/plStreamLogger.h @@ -28,7 +28,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsStream.h" #include "hsStlUtils.h" -#include "../../NucleusLib/pnNetCommon/plGenericVar.h" +#include "pnNetCommon/plGenericVar.h" class plStreamLogger { diff --git a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp index b6015513..6ec87228 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp @@ -29,7 +29,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsTypes.h" #include "hsMemory.h" -//#include "../plGeometry/hsTriangle3.h" #include "hsResMgr.h" #include "plLayerInterface.h" #include "plLayer.h" diff --git a/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTimeCreatable.h b/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTimeCreatable.h deleted file mode 100644 index 61d7811d..00000000 --- a/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTimeCreatable.h +++ /dev/null @@ -1,36 +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 . - -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 plUnifiedTimeCreatable_inc -#define plUnifiedTimeCreatable_inc - -#if 0 -#include "../pnFactory/plCreator.h" - -#include "plUnifiedTime.h" -REGISTER_CREATABLE( plUnifiedTime ); -#endif - -#endif // plUnifiedTimeCreatable_inc diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultNode.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultNode.cpp deleted file mode 100644 index a6d63758..00000000 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultNode.cpp +++ /dev/null @@ -1,2743 +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 . - -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==*/ -#if 0 -#include "hsTemplates.h" -#include "hsStlUtils.h" -#include "plVaultNode.h" -#include "plVaultNodeIterator.h" -#include "../pnMessage/plMessage.h" -#include "../plNetMessage/plNetMessage.h" -#include "../plNetCommon/plNetCommon.h" -#include "../plStatusLog/plStatusLog.h" -#include "../plSDL/plSDL.h" -#include -#include "hsGeometry3.h" -#include "hsStringTokenizer.h" - -//////////////////////////////////////////////////////////////////// - -#define plSafeGetLog() if (fMyNodeMgr) fMyNodeMgr->GetStatusLog() - - -//////////////////////////////////////////////////////////////////// - - -bool plVaultNode::MatchesNode::operator()( const plVaultNode * node ) const -{ - if ( !node ) - return false; - - bool matches = true; - - if ( fNode->IIsFieldFlagSet( plVaultNode::kID ) ) - { - matches &= ( fNode->GetID()==node->GetID() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kType ) ) - { - matches &= ( fNode->GetType()==node->GetType() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kPermissions ) ) - { - matches &= ( fNode->GetPermissions()==node->GetPermissions() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kOwnerNodeID ) ) - { - matches &= ( fNode->GetOwnerNodeID()==node->GetOwnerNodeID() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kGroupNodeID ) ) - { - matches &= ( fNode->GetGroupNodeID()==node->GetGroupNodeID() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kModifyTime ) ) - { - matches &= ( *fNode->GetModifyTime()==*node->GetModifyTime() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kCreatorNodeID ) ) - { - matches &= ( fNode->GetCreatorNodeID()==node->GetCreatorNodeID() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kCreateTime ) ) - { - matches &= ( *fNode->GetCreateTime()==*node->GetCreateTime() ); - } -// if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kCreateAgeCoords ) ) -// { -// hsAssert( false, "Compare age coords not supported" ); -// } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kCreateAgeTime ) ) - { - matches &= ( *fNode->GetCreateAgeTime()==*node->GetCreateAgeTime() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kCreateAgeName ) ) - { - matches &= ( strcmp( fNode->GetCreateAgeName(), node->GetCreateAgeName() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kCreateAgeGuid ) ) - { - matches &= ( fNode->GetCreateAgeGuid()->IsEqualTo( node->GetCreateAgeGuid() ) ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kInt32_1 ) ) - { - matches &= ( fNode->IGetInt32_1()==node->IGetInt32_1() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kInt32_2 ) ) - { - matches &= ( fNode->IGetInt32_2()==node->IGetInt32_2() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kInt32_3 ) ) - { - matches &= ( fNode->IGetInt32_3()==node->IGetInt32_3() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kInt32_4 ) ) - { - matches &= ( fNode->IGetInt32_4()==node->IGetInt32_4() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kUInt32_1 ) ) - { - matches &= ( fNode->IGetUInt32_1()==node->IGetUInt32_1() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kUInt32_2 ) ) - { - matches &= ( fNode->IGetUInt32_2()==node->IGetUInt32_2() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kUInt32_3 ) ) - { - matches &= ( fNode->IGetUInt32_3()==node->IGetUInt32_3() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kUInt32_4 ) ) - { - matches &= ( fNode->IGetUInt32_4()==node->IGetUInt32_4() ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kString64_1 ) ) - { - matches &= ( strcmp( fNode->IGetString64_1(), node->IGetString64_1() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kString64_2 ) ) - { - matches &= ( strcmp( fNode->IGetString64_2(), node->IGetString64_2() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kString64_3 ) ) - { - matches &= ( strcmp( fNode->IGetString64_3(), node->IGetString64_3() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kString64_4 ) ) - { - matches &= ( strcmp( fNode->IGetString64_4(), node->IGetString64_4() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kString64_5 ) ) - { - matches &= ( strcmp( fNode->IGetString64_5(), node->IGetString64_5() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kString64_6 ) ) - { - matches &= ( strcmp( fNode->IGetString64_6(), node->IGetString64_6() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kIString64_1 ) ) - { - matches &= ( stricmp( fNode->IGetIString64_1(), node->IGetIString64_1() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kIString64_2 ) ) - { - matches &= ( stricmp( fNode->IGetIString64_2(), node->IGetIString64_2() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kText_1 ) ) - { - matches &= ( strcmp( fNode->IGetText_1(), node->IGetText_1() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kText_2 ) ) - { - matches &= ( strcmp( fNode->IGetText_2(), node->IGetText_2() )==0 ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kBlob_1 ) ) - { -// hsAssert( false, "Compare blobs not supported" ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kBlob_2 ) ) - { -// hsAssert( false, "Compare blobs not supported" ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kBlob_1_Guid ) ) - { - matches &= ( fNode->IGetBlob_1_Guid()->IsEqualTo( node->IGetBlob_1_Guid() ) ); - } - if ( matches && fNode->IIsFieldFlagSet( plVaultNode::kBlob_2_Guid ) ) - { - matches &= ( fNode->IGetBlob_2_Guid()->IsEqualTo( node->IGetBlob_2_Guid() ) ); - } - - return matches; -} - -bool plVaultNode::MatchesNode::operator()( const plVaultNodeRef * nodeRef ) const -{ - return operator()( nodeRef->GetChild() ); -} - -plVaultNode::plVaultNode() -: fID( 0 ) -, fType( 0 ) -, fPermissions( 0 ) -, fOwnerNodeID( 0 ) -, fGroupNodeID( 0 ) -, fCreatorNodeID( 0 ) -, fInt32_1( 0 ) -, fInt32_2( 0 ) -, fInt32_3( 0 ) -, fInt32_4( 0 ) -, fUInt32_1( 0 ) -, fUInt32_2( 0 ) -, fUInt32_3( 0 ) -, fUInt32_4( 0 ) -, fOwnerNode( nil ) -, fGroupNode( nil ) -, fCreatorNode( nil ) -, fPersistent( true ) -, fSaving( false ) -, fInitialized( false ) -, fUserData( 0 ) -, fMyNodeMgr( nil ) -{ -} - -plVaultNode::~plVaultNode() -{ - IFailPendingSaves(); - std::for_each( fChildNodes.begin(), fChildNodes.end(), xtl::delete_ptr() ); - fChildNodes.clear(); -} - -bool plVaultNode::IIsFieldFlagSet( int b ) const -{ - return fFieldFlags.IsBitSet( b )?true:false; -} - -void plVaultNode::IGotUpdated( void ) -{ - hsLogEntry( plSafeGetLog()->AddLineF( "Updated remotely: %s", AsStdString().c_str() ) ); -} - - -UInt32 plVaultNode::GetID( void ) const -{ - return fID; -} - -void plVaultNode::ISetID( UInt32 v ) -{ - ISetFieldFlag( kID ); - fID = v; -} - - -const plVaultPlayerInfoNode * plVaultNode::GetOwnerNode( void ) const -{ - if (!fMyNodeMgr) - return nil; - - plVaultPlayerInfoNode templateNode; - templateNode.SetPlayerID( fOwnerNodeID ); - plVaultNode * result; - fMyNodeMgr->FindNode( &templateNode, result ); - return plVaultPlayerInfoNode::ConvertNoRef( result ); -} - - -const plVaultPlayerInfoNode * plVaultNode::GetCreatorNode( void ) const -{ - if (!fMyNodeMgr) - return nil; - - plVaultPlayerInfoNode templateNode; - templateNode.SetPlayerID( fCreatorNodeID ); - plVaultNode * result; - fMyNodeMgr->FindNode( &templateNode, result ); - return plVaultPlayerInfoNode::ConvertNoRef( result ); -} - -const plVaultNode * plVaultNode::GetGroupNode( void ) const -{ - return nil; -} - - -bool plVaultNode::IHasFieldFlagsSet( void ) -{ - fFieldFlags.Compact(); - return fFieldFlags.GetSize()>0; -} - -bool plVaultNode::HasValidID( void ) const -{ - return ( fID>0 ) && ( !fPersistent || ( fPersistent && ( fID>=plVault::kFirstStoredNodeID ) ) ); -} - -bool plVaultNode::IsStored( void ) const -{ - if( !fMyNodeMgr ) - { - return fID>plVault::kFirstStoredNodeID; - } - else - { - return ( fMyNodeMgr->IAmOnline() && ( ( fID>plVault::kFirstStoredNodeID ) || fSaving ) ) - || ( !fMyNodeMgr->IAmOnline() ); // if not online then, sure... it's stored.. yeah. - } -} - -bool plVaultNode::IsMgrNode( void ) const -{ - return ( IsStored() && fType>plVault::kNodeType_VNodeMgrLow && fTypeAddLineF( "Starting pending save operation on node %lu", GetID() )); - task->Start(); - } -} - -void plVaultNode::IFailPendingSaves() -{ - while ( !fPendingSaves.empty() ) - { - plVaultSaveNodeTask * task = fPendingSaves.front(); - fPendingSaves.erase( fPendingSaves.begin() ); - hsLogEntry(plSafeGetLog()->AddLineF( "Aborting pending save operation on node %lu", GetID() )); - task->TaskComplete( false ); - } -} - -void plVaultNode::IAddPendingSave( plVaultSaveNodeTask * task ) -{ - hsLogEntry(plSafeGetLog()->AddLineF( "Adding pending save operation to node %lu", GetID() )); - fPendingSaves.push_back( task ); -} - - -static bool CompareNodeRefCreateTimes( const plVaultNodeRef * A, const plVaultNodeRef * B ) -{ - return ( A->GetCreateTime()->GetSecs()GetCreateTime()->GetSecs() ); -} - -plVaultNodeRef * plVaultNode::ILocalAddNode( plVaultNode * node, bool notify ) -{ - plVaultNodeRef nodeRef; - nodeRef.ISetChildNode( node ); - return ILocalAddNode( &nodeRef, notify ); -} - -plVaultNodeRef * plVaultNode::ILocalAddNode( const plVaultNodeRef * in, bool notify ) -{ - hsAssert( in->GetChildID()!=0, "ILocalAddNode: Invalid child ID" ); - - if ( in->fChildIDGetChildID() ) ) - { -// plSafeGetLog()->AddLine( "ILocalAddNode: node being added as a child exists above me in family tree!" ); - hsAssert( false, "ILocalAddNode: node being added as a child exists above me in family tree!" ); - return nil; - } - - plVaultNodeRef * nodeRef; - bool found = GetNode( in->GetChildID(), nodeRef ); - if ( !found && fMyNodeMgr) - { - nodeRef = fMyNodeMgr->CreateNodeRef(); - nodeRef->CopyFrom( in ); - nodeRef->ISetParentID( GetID() ); - if ( in->GetChild() ) - nodeRef->ISetChildNode( in->GetChild() ); - // add node - fChildNodes.push_back( nodeRef ); - // sort nodes by create time - std::sort( fChildNodes.begin(), fChildNodes.end(), CompareNodeRefCreateTimes ); - // call internal notify - ILocalNodeAdded( nodeRef ); - hsLogEntry(plSafeGetLog()->AddLineF( "Added child %lu to parent %lu", nodeRef->GetChildID(), nodeRef->GetParentID() )); - // do callbacks - if ( notify ) - fMyNodeMgr->INotifyNodeRefAdded( nodeRef ); - } - return nodeRef; -} - -bool plVaultNode::ILocalRemoveNode( UInt32 nodeID, bool notify ) -{ - plVaultNode tmp; - tmp.ISetID( nodeID ); - plVault::NodeRefVec::iterator it = - std::find_if( fChildNodes.begin(), fChildNodes.end(), - plVaultNode::MatchesNode( &tmp ) ); - bool found = ( it!=fChildNodes.end() ); - if ( found && fMyNodeMgr) - { - plVaultNodeRef * nodeRef = *it; - if ( notify ) - fMyNodeMgr->INotifyRemovingNodeRef( nodeRef ); - delete *it; - fChildNodes.erase( it ); - if ( notify ) - fMyNodeMgr->INotifyNodeRefRemoved( nodeID, GetID() ); - } - return found; -} - -bool plVaultNode::IIsAnUpstreamNode( UInt32 nodeID ) -{ - plVaultNode * node; - if ( fMyNodeMgr && fMyNodeMgr->GetNode( nodeID, node ) ) - return node->IIsADownstreamNode( GetID() ); - return false; -} - -bool plVaultNode::IIsADownstreamNode( UInt32 nodeID ) -{ - for ( int i=0; iGetChildID()==nodeID ) - return true; - if ( fChildNodes[i]->GetChild()->IIsADownstreamNode( nodeID ) ) - return true; - } - return false; -} - -plVaultNodeRef * plVaultNode::AddNode( plVaultNode * node, plVaultOperationCallback * cb, UInt32 cbContext ) -{ - if ( IsPersistent() && !IsStored() && node->IsPersistent() ) - { - std::string msg; - xtl::format( msg, "Tried to add persistent child to non-saved persistent parent. parent fSaving=%s", fSaving?"yep":"nope" ); - hsLogEntry(plSafeGetLog()->AddLineF( plStatusLog::kRed, "%s", msg.c_str() )); -// hsAssert( false, msg.c_str() ); - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.OperationComplete( hsFail ); - return false; - } - plVaultNodeRef * nodeRef; - if ( FindNode( node, nodeRef ) ) - { - // we already have this child, short circuit. - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.SetCbFields( nodeRef->GetChild(), nodeRef ); - cbHolder.OperationComplete( hsOK ); - return nodeRef; - } - - return fMyNodeMgr ? fMyNodeMgr->IAddNodeRef( node, GetID(), cb, cbContext ) : nil; // starts network operation -} - -bool plVaultNode::LinkToNode( const plVaultNode * templateNode, int childFetchLevel, bool allowCreate, plVaultOperationCallback * cb, UInt32 cbContext ) -{ - if ( IsPersistent() && !IsStored() ) - { - std::string msg; - xtl::format( msg, "Tried to link a child to non-saved persistent parent. parent fSaving=%s", fSaving?"yep":"nope" ); - hsLogEntry(plSafeGetLog()->AddLineF( plStatusLog::kRed, "%s", msg.c_str() )); -// hsAssert( false, msg.c_str() ); - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.OperationComplete( hsFail ); - return false; - } - plVaultNodeRef * nodeRef; - if ( FindNode( templateNode, nodeRef ) ) - { - // we already have this child, short circuit. - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.SetCbFields( nodeRef->GetChild(), nodeRef ); - cbHolder.OperationComplete( hsOK ); - return true; - } - - // Can't allowCreate if template specified an ID, unless we aren't online. - allowCreate &= ( fMyNodeMgr && !templateNode->IIsFieldFlagSet( plVaultNode::kID ) || !fMyNodeMgr->IAmOnline() ); - - fMyNodeMgr ? fMyNodeMgr->ILinkToNode( templateNode, childFetchLevel, allowCreate, GetID(), cb, cbContext ) : NULL_STMT; - - return true; -} - -bool plVaultNode::LinkToNode( UInt32 nodeID, int childFetchLevel, plVaultOperationCallback * cb, UInt32 cbContext ) -{ - plVaultNode templateNode; - templateNode.ISetID( nodeID ); - return LinkToNode( &templateNode, childFetchLevel, false, cb,cbContext ); -} - -bool plVaultNode::RemoveNode( const plVaultNode * node, plVaultOperationCallback * cb/*=nil*/, UInt32 cbContext/*=0 */) -{ - // remove by id - if ( node->GetID()!=0 ) - return RemoveNode( node->GetID(), cb, cbContext ); - // remove by template match - plVaultNodeRef * nodeRef; - if ( FindNode( node, nodeRef ) ) - return RemoveNode( nodeRef->GetChildID(), cb, cbContext ); - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.OperationComplete( hsFail ); - return false; -} - -bool plVaultNode::RemoveNode( UInt32 nodeID, plVaultOperationCallback * cb/*=nil*/, UInt32 cbContext/*=0 */) -{ - fMyNodeMgr ? fMyNodeMgr->IRemoveNodeRef( nodeID, GetID(), cb, cbContext ) : NULL_STMT;// starts network operation - return true; -} - -void plVaultNode::GetNodes( plVault::NodeRefVec & out ) -{ - std::copy( fChildNodes.begin(), fChildNodes.end(), std::back_inserter( out ) ); -} - -bool plVaultNode::GetNode( UInt32 nodeID, plVaultNodeRef *& out ) const -{ - plVaultNode tmp; - tmp.ISetID( nodeID ); - return FindNode( &tmp, out ); -} - -bool plVaultNode::FindNode( const plVaultNode * templateNode, plVaultNodeRef *& out ) const -{ - plVaultNode tmp; - if ( templateNode->IsStored() ) - tmp.ISetID( templateNode->GetID() ); - else - tmp.CopyFrom( templateNode ); - - out = nil; - plVault::NodeRefVec::const_iterator it = - std::find_if( fChildNodes.begin(), fChildNodes.end(), - plVaultNode::MatchesNode( &tmp ) ); - bool found = ( it!=fChildNodes.end() ); - if ( found ) - out = *it; - return found; -} - -bool plVaultNode::FindNodes( const plVaultNode * templateNode, plVault::NodeRefVec & out ) const -{ - plVaultNode tmp; - if ( templateNode->IsStored() ) - tmp.ISetID( templateNode->GetID() ); - else - tmp.CopyFrom( templateNode ); - - int n = out.size(); - MatchesNode matcher( &tmp ); - for ( int i=0; i 0 ); -} - -bool plVaultNode::FindNodeRecurse( const plVaultNode * templateNode, plVaultNodeRef *& out ) const -{ - if ( !FindNode( templateNode, out ) ) - { - for ( plVault::NodeRefVec::const_iterator it=fChildNodes.begin(); it!=fChildNodes.end(); ++it ) - { - if ( (*it)->GetChild()->FindNodeRecurse( templateNode, out ) ) - return true; - } - } - return false; -} - -bool plVaultNode::HasNode( UInt32 nodeID ) -{ - plVaultNode templateNode; - templateNode.SetID( nodeID ); - return HasNode( &templateNode ); -} - -bool plVaultNode::HasNode( const plVaultNode * templateNode ) -{ - plVaultNodeRef * nodeRef; - return FindNode( templateNode, nodeRef ); -} - -bool plVaultNode::Modified( void ) const -{ - fFieldFlags.Compact(); - return ( fFieldFlags.GetSize()>0 ); -} - -void plVaultNode::SetModified( bool b ) -{ - if ( !b ) - { - IClearAllFieldFlags(); - } - else - { - ISetAllFieldFlags(); - SetModifyTime( &plUnifiedTime::GetCurrentTime() ); - } -} - - - -UInt32 plVaultNode::GetClientID( void ) const -{ - if ( !fMyNodeMgr ) - return 0; - return fMyNodeMgr->GetClientID(); -} - - -void plVaultNode::Save( plVaultOperationCallback * cb, UInt32 cbContext ) -{ - if (Modified() && fMyNodeMgr) - { - fMyNodeMgr->ISaveNode( this, cb, cbContext ); - } - else - { - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.OperationComplete( hsOK ); - } -} - -void plVaultNode::SaveAll( plVaultOperationCallback * cb, UInt32 cbContext ) -{ - for ( int i=0; iGetChild(); - child->SaveAll( cb, cbContext ); - } - Save( cb, cbContext ); -} - - -void plVaultNode::SendTo( UInt32 destClientNodeID, plVaultOperationCallback * cb, UInt32 cbContext ) -{ - if (!fMyNodeMgr) - return; - fMyNodeMgr->ISendNode( this, destClientNodeID, cb, cbContext ); -} - - -void plVaultNode::RemoveAllNodes( void ) -{ - plVault::IDVec ids; - for ( plVaultNodeIterator nodeIt=GetIterator(); nodeIt; ++nodeIt ) - { - ids.push_back( (*nodeIt)->GetChildID() ); - } - for ( int i=0; iReadSwap( &fID ); - s->ReadSwap( &fType ); - s->ReadSwap( &fPermissions ); - s->ReadSwap( &fOwnerNodeID ); - s->ReadSwap( &fGroupNodeID ); - fModifyTime.Read( s ); - // set these to nil in case their corresponding ID changed above. - fOwnerNode = nil; - fGroupNode = nil; - - // fields relating to creation of this node - if ( IIsFieldFlagSet( kCreatorNodeID ) ) - { - s->ReadSwap( &fCreatorNodeID ); - fCreatorNode = nil; - } - if ( IIsFieldFlagSet( kCreateTime ) ) - { - fCreateTime.Read( s ); - } -// if ( IIsFieldFlagSet( kCreateAgeCoords ) ) -// { -// fCreateAgeCoords.Read( s, mgr ); -// } - if ( IIsFieldFlagSet( kCreateAgeTime ) ) - { - fCreateAgeTime.Read( s ); - } - if ( IIsFieldFlagSet( kCreateAgeName ) ) - { - plMsgStdStringHelper::Peek( fCreateAgeName, s ); - } - if ( IIsFieldFlagSet( kCreateAgeGuid ) ) - { - fCreateAgeGuid.Read( s ); - } - // generic fields - if ( IIsFieldFlagSet( kInt32_1 ) ) - { - s->ReadSwap( &fInt32_1 ); - } - if ( IIsFieldFlagSet( kInt32_2 ) ) - { - s->ReadSwap( &fInt32_2 ); - } - if ( IIsFieldFlagSet( kInt32_3 ) ) - { - s->ReadSwap( &fInt32_3 ); - } - if ( IIsFieldFlagSet( kInt32_4 ) ) - { - s->ReadSwap( &fInt32_4 ); - } - if ( IIsFieldFlagSet( kUInt32_1 ) ) - { - s->ReadSwap( &fUInt32_1 ); - } - if ( IIsFieldFlagSet( kUInt32_2 ) ) - { - s->ReadSwap( &fUInt32_2 ); - } - if ( IIsFieldFlagSet( kUInt32_3 ) ) - { - s->ReadSwap( &fUInt32_3 ); - } - if ( IIsFieldFlagSet( kUInt32_4 ) ) - { - s->ReadSwap( &fUInt32_4 ); - } - if ( IIsFieldFlagSet( kString64_1 ) ) - { - plMsgStdStringHelper::Peek( fString64_1, s ); - } - if ( IIsFieldFlagSet( kString64_2 ) ) - { - plMsgStdStringHelper::Peek( fString64_2, s ); - } - if ( IIsFieldFlagSet( kString64_3 ) ) - { - plMsgStdStringHelper::Peek( fString64_3, s ); - } - if ( IIsFieldFlagSet( kString64_4 ) ) - { - plMsgStdStringHelper::Peek( fString64_4, s ); - } - if ( IIsFieldFlagSet( kString64_5 ) ) - { - plMsgStdStringHelper::Peek( fString64_5, s ); - } - if ( IIsFieldFlagSet( kString64_6 ) ) - { - plMsgStdStringHelper::Peek( fString64_6, s ); - } - if ( IIsFieldFlagSet( kIString64_1 ) ) - { - plMsgStdStringHelper::Peek( fIString64_1, s ); - } - if ( IIsFieldFlagSet( kIString64_2 ) ) - { - plMsgStdStringHelper::Peek( fIString64_2, s ); - } - if ( IIsFieldFlagSet( kText_1 ) ) - { - plMsgStdStringHelper::Peek( fText_1, s ); - } - if ( IIsFieldFlagSet( kText_2 ) ) - { - plMsgStdStringHelper::Peek( fText_2, s ); - } - if ( IIsFieldFlagSet( kBlob_1 ) ) - { - UInt32 buflen; - s->ReadSwap( &buflen ); - IAllocBufferBlob_1( buflen ); - if (buflen) - s->Read( buflen,(void*)IGetBufferBlob_1() ); - } - if ( IIsFieldFlagSet( kBlob_2 ) ) - { - UInt32 buflen; - s->ReadSwap( &buflen ); - IAllocBufferBlob_2( buflen ); - if (buflen) - s->Read( buflen,(void*)IGetBufferBlob_2() ); - } - if ( IIsFieldFlagSet( kBlob_1_Guid ) ) - { - fBlob_1_Guid.Read( s ); - } - if ( IIsFieldFlagSet( kBlob_2_Guid ) ) - { - fBlob_2_Guid.Read( s ); - } -} - -// NOTE: IF YOU CHANGE plVaultNode STREAM FORMAT, BE SURE TO -// INCREMENT VaultNodeVersion (ABOVE). -void plVaultNode::Write( hsStream * s, hsResMgr * mgr ) -{ - hsAssert( s, "nil stream" ); -#ifdef HS_BUILD_FOR_UNIX - plOperationTimer t( "plVaultNode::Write" ); - t.Start( "write operation", 2 ); -#endif - - - fFieldFlags.Write( s ); - - // these fields are always streamed - s->WriteSwap( fID ); - s->WriteSwap( fType ); - s->WriteSwap( fPermissions ); - s->WriteSwap( fOwnerNodeID ); - s->WriteSwap( fGroupNodeID ); - fModifyTime.Write( s ); - - // fields relating to creation of this node - if ( IIsFieldFlagSet( kCreatorNodeID ) ) - { - s->WriteSwap( fCreatorNodeID ); - } - if ( IIsFieldFlagSet( kCreateTime ) ) - { - fCreateTime.Write( s ); - } -// if ( IIsFieldFlagSet( kCreateAgeCoords ) ) -// { -// fCreateAgeCoords.Write( s, mgr ); -// } - if ( IIsFieldFlagSet( kCreateAgeTime ) ) - { - fCreateAgeTime.Write( s ); - } - if ( IIsFieldFlagSet( kCreateAgeName ) ) - { - plMsgStdStringHelper::Poke( fCreateAgeName, s ); - } - if ( IIsFieldFlagSet( kCreateAgeGuid ) ) - { - fCreateAgeGuid.Write( s ); - } - // generic fields - if ( IIsFieldFlagSet( kInt32_1 ) ) - { - s->WriteSwap( fInt32_1 ); - } - if ( IIsFieldFlagSet( kInt32_2 ) ) - { - s->WriteSwap( fInt32_2 ); - } - if ( IIsFieldFlagSet( kInt32_3 ) ) - { - s->WriteSwap( fInt32_3 ); - } - if ( IIsFieldFlagSet( kInt32_4 ) ) - { - s->WriteSwap( fInt32_4 ); - } - if ( IIsFieldFlagSet( kUInt32_1 ) ) - { - s->WriteSwap( fUInt32_1 ); - } - if ( IIsFieldFlagSet( kUInt32_2 ) ) - { - s->WriteSwap( fUInt32_2 ); - } - if ( IIsFieldFlagSet( kUInt32_3 ) ) - { - s->WriteSwap( fUInt32_3 ); - } - if ( IIsFieldFlagSet( kUInt32_4 ) ) - { - s->WriteSwap( fUInt32_4 ); - } - if ( IIsFieldFlagSet( kString64_1 ) ) - { - plMsgStdStringHelper::Poke( fString64_1, s ); - } - if ( IIsFieldFlagSet( kString64_2 ) ) - { - plMsgStdStringHelper::Poke( fString64_2, s ); - } - if ( IIsFieldFlagSet( kString64_3 ) ) - { - plMsgStdStringHelper::Poke( fString64_3, s ); - } - if ( IIsFieldFlagSet( kString64_4 ) ) - { - plMsgStdStringHelper::Poke( fString64_4, s ); - } - if ( IIsFieldFlagSet( kString64_5 ) ) - { - plMsgStdStringHelper::Poke( fString64_5, s ); - } - if ( IIsFieldFlagSet( kString64_6 ) ) - { - plMsgStdStringHelper::Poke( fString64_6, s ); - } - if ( IIsFieldFlagSet( kIString64_1 ) ) - { - plMsgStdStringHelper::Poke( fIString64_1, s ); - } - if ( IIsFieldFlagSet( kIString64_2 ) ) - { - plMsgStdStringHelper::Poke( fIString64_2, s ); - } - if ( IIsFieldFlagSet( kText_1 ) ) - { - plMsgStdStringHelper::Poke( fText_1, s ); - } - if ( IIsFieldFlagSet( kText_2 ) ) - { - plMsgStdStringHelper::Poke( fText_2, s ); - } - if ( IIsFieldFlagSet( kBlob_1 ) ) - { - UInt32 buflen = IGetBufferSizeBlob_1(); - s->WriteSwap( buflen ); - if ( buflen ) - s->Write( buflen, IGetBufferBlob_1() ); - } - if ( IIsFieldFlagSet( kBlob_2 ) ) - { - UInt32 buflen = IGetBufferSizeBlob_2(); - s->WriteSwap( buflen ); - if ( buflen ) - s->Write( buflen, IGetBufferBlob_2() ); - } - if ( IIsFieldFlagSet( kBlob_1_Guid ) ) - { - fBlob_1_Guid.Write( s ); - } - if ( IIsFieldFlagSet( kBlob_2_Guid ) ) - { - fBlob_2_Guid.Write( s ); - } -} - -void plVaultNode::CopyFrom( const plVaultNode * other, bool forceCopyAllFields ) -{ - hsRAMStream ram; - plVaultNode * nonConstOther = const_cast( other ); - - hsBitVector saveFlags; - if ( forceCopyAllFields ) - { - saveFlags = nonConstOther->fFieldFlags; - nonConstOther->ISetAllFieldFlags(); - } - - nonConstOther->Write( &ram, nil ); - ram.Rewind(); - this->Read( &ram, nil ); - - if ( forceCopyAllFields ) - { - nonConstOther->fFieldFlags = saveFlags; - } -} - -std::string plVaultNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%sNode[ID:%lu,Owner:%lu,Creator:%lu,Mod:%s]", - space.c_str(), GetID(), GetOwnerNodeID(), GetCreatorNodeID(), - fModifyTime.Format("%m/%d/%y %H:%M:%S GMT").c_str() ); - return result; -} - -std::string plVaultNode::FieldsAsStdString( void ) const -{ - std::stringstream stm; - - stm << "ID=" << GetID(); - - if ( IIsFieldFlagSet( plVaultNode::kPermissions ) ) - { - stm << ", Permissions=" << GetPermissions(); - } - if ( IIsFieldFlagSet( plVaultNode::kOwnerNodeID ) ) - { - stm << ", OwnerIdx=" <GetStatusLog(); - std::string str; - if ( displaySeen ) - xtl::format( str, "%s, seen:%s", AsStdString( level ).c_str(), beenSeen?"yes":"no" ); - else - xtl::format( str, "%s", AsStdString( level ).c_str() ); - hsLogEntry(log->AddLine( str.c_str() )); - for ( plVault::NodeRefVec::const_iterator it=fChildNodes.begin(); it!=fChildNodes.end(); ++it ) - { - plVaultNodeRef * nodeRef = *it; - plVaultNode * node = nodeRef->GetChild(); - if ( node ) - node->Dump( level+2, true, nodeRef->BeenSeen() ); - } -} - -void plVaultNode::SetInitialized( bool b ) -{ - fInitialized = b; - if (!fMyNodeMgr) - return; - if ( fInitialized ) - fMyNodeMgr->INotifyNodeInitialized( this ); -} - -bool plVaultNode::StartInitializing( plVaultOperationCallback * cb, UInt32 cbContext ) -{ - plVNodeInitTask * initTask = fMyNodeMgr ? fMyNodeMgr->IGetNodeInitializationTask( this ) : nil; - if ( initTask ) - { - initTask->SetCbObject( cb, cbContext ); - initTask->Start(); - return true; // initTask started - } - else - { - SetInitialized( true ); - plVaultOperationCallbackHolder cbHolder( fMyNodeMgr, cb, cbContext ); - cbHolder.OperationComplete( hsOK ); - return false; // no initTask started - } -} - - - -//////////////////////////////////////////////////////////////////// - -plVaultFolderNode::plVaultFolderNode() -{ - ISetType( plVault::kNodeType_Folder ); -} - -plVaultFolderNode::~plVaultFolderNode() -{ -} - -std::string plVaultFolderNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Type:%s,Name:%s] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), plVault::StandardNodeStr( GetFolderType() ), - GetFolderName(), plVaultNode::AsStdString().c_str() ); - return result; -} - -std::string plVaultFolderNode::AsHtmlForm( const char * action ) -{ - std::stringstream ss; - ss << "
" << std::endl; - ss << "
" << std::endl; - return ss.str(); -} - - -//////////////////////////////////////////////////////////////////// - -plVaultImageNode::plVaultImageNode() -: fMipmap( nil ) -{ - ISetType( plVault::kNodeType_Image ); -} - -plVaultImageNode::~plVaultImageNode() -{ -} - -void plVaultImageNode::CopyFrom( const plVaultNode * other, bool forceCopyAllFields ) -{ - const plVaultImageNode * IMG = plVaultImageNode::ConvertNoRef( other ); - if ( IMG ) - fMipmap = IMG->fMipmap; - plVaultNode::CopyFrom( other, forceCopyAllFields ); -} - -std::string plVaultImageNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Size:%d] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), GetBufSize(), plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -plVaultTextNoteNode::plVaultTextNoteNode() -{ - ISetType( plVault::kNodeType_TextNote ); -} - -plVaultTextNoteNode::~plVaultTextNoteNode() -{ -} - -void plVaultTextNoteNode::SetText( const char * text ) -{ - std::string work=text; memcpy( IAllocBufferBlob_1( work.size() ), work.c_str(), work.size() ); -} - -std::string plVaultTextNoteNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Title:%s,Text:%s,Type:%d,Sub:%d] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), GetTitle(), - GetText(), GetNoteType(), GetNoteSubType(), plVaultNode::AsStdString().c_str() ); - return result; -} - -plVaultFolderNode * plVaultTextNoteNode::GetDeviceInbox() const -{ - hsAssert( GetNoteType()==plVault::kNoteType_Device, "This text note is not a device." ); - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kDeviceInboxFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - return plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - return nil; -} - -void plVaultTextNoteNode::SetDeviceInbox( const char * inboxName, - plVaultOperationCallback * cb/*=nil*/, UInt32 cbContext/*=0*/ ) -{ - // Remove old inbox. - plVaultFolderNode * inbox = GetDeviceInbox(); - if ( inbox ) - RemoveNode( inbox->GetID() ); - // Link to new inbox. - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kDeviceInboxFolder ); - tmp.SetFolderName( inboxName ); - // if the inbox name matches our device title, then - // connect to our own personal version of the inbox, - // else connect to the shared copy of the inbox. - if ( stricmp( inboxName, GetTitle() )==0 ) - tmp.SetOwnerNodeID( GetID() ); - LinkToNode( &tmp, plVault::kFetchAllChildren, true, cb, cbContext ); -} - - -//////////////////////////////////////////////////////////////////// - -plVaultSDLNode::plVaultSDLNode() -: fSDLDataRec( nil ) -{ - ISetType( plVault::kNodeType_SDL ); -} - -plVaultSDLNode::~plVaultSDLNode() -{ - delete fSDLDataRec; -} - -void plVaultSDLNode::Save( - plVaultOperationCallback * cb/*=nil*/, - UInt32 cbContext/*=0 */) -{ -#ifdef HS_DEBUGGING - hsLogEntry( DumpStateDataRecord("Saving plVaultSDLNode", false ) ); -#endif - plVaultNode::Save( cb, cbContext ); -} - -plStateDataRecord * plVaultSDLNode::GetStateDataRecord( UInt32 readOptions/*=0 */) const -{ - delete fSDLDataRec; - fSDLDataRec = nil; - - if ( GetBufSize()==0 || GetBuffer()==nil ) - return nil; - - hsRAMStream ram; - ram.Write( GetBufSize(), GetBuffer() ); - ram.Rewind(); - char * sdlRecName=nil; - int sdlRecVersion; - plStateDataRecord::ReadStreamHeader( &ram, &sdlRecName, &sdlRecVersion ); - - hsLogEntry(plSafeGetLog()->AddLineF( "SDLNode: SDL: name %s, version %d.", sdlRecName, sdlRecVersion )); - - plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, sdlRecVersion ); - if (!des) - { - hsLogEntry(plSafeGetLog()->AddLineF( "SDLNode: Can't find SDL desc, name:%s ver:%d. Attempting to read with latest descriptor.", sdlRecName, sdlRecVersion )); - des = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, plSDL::kLatestVersion ); - if (!des) - { - hsLogEntry(plSafeGetLog()->AddLineF( "SDLNode: Can't find SDL desc, name:%s ver:kLatestVersion. Cannot read sdl record.", sdlRecName )); - return nil; - } - } - - fSDLDataRec = TRACKED_NEW plStateDataRecord( des ); - if ( !fSDLDataRec->Read( &ram, 0, readOptions ) ) - { - hsLogEntry(plSafeGetLog()->AddLineF( "SDLNode: Failed to read SDL desc, name:%s ver:%d", sdlRecName, sdlRecVersion )); - delete fSDLDataRec; - fSDLDataRec = nil; - } - else - { - hsLogEntry(plSafeGetLog()->AddLineF( "SDLNode: After reading SDL: name %s, version %d.", - fSDLDataRec->GetDescriptor()->GetName(), fSDLDataRec->GetDescriptor()->GetVersion() )); - } - - delete [] sdlRecName; - return fSDLDataRec; -} - -void plVaultSDLNode::InitStateDataRecord( const char * sdlRecName, UInt32 writeOptions/*=0 */) -{ - if ( !GetStateDataRecord() ) - { - delete fSDLDataRec; - fSDLDataRec = nil; - - plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, plSDL::kLatestVersion); - if ( !des ) - { - hsLogEntry( plSafeGetLog()->AddLineF( "SDLNode: Can't find SDL desc, name:%s", sdlRecName ) ); - return; - } - - fSDLDataRec = TRACKED_NEW plStateDataRecord( des ); - fSDLDataRec->SetFromDefaults( false ); - SetStateDataRecord( fSDLDataRec, writeOptions|plSDL::kDontWriteDirtyFlag ); - Save(); - } -} - - -void plVaultSDLNode::SetStateDataRecord( const plStateDataRecord * rec, UInt32 writeOptions/*=0 */) -{ - hsRAMStream ram; - rec->WriteStreamHeader( &ram ); - rec->Write( &ram, 0, writeOptions ); - ram.Rewind(); - ram.CopyToMem( AllocBuffer( ram.GetEOF() ) ); -} - -void plVaultSDLNode::DumpStateDataRecord( const char * msg/*=nil */, bool dirtyOnly/*=false*/ ) const -{ - if ( !fSDLDataRec ) - GetStateDataRecord(); - - if ( !fSDLDataRec ) - return; - - if ( !msg ) - msg = "VaultSDLNode"; - - fSDLDataRec->DumpToObjectDebugger( msg, dirtyOnly ); -} - -std::string plVaultSDLNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Size:%d,Ident:%s] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - GetBufSize(), plVault::StandardNodeStr( GetIdent() ), - plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -plVaultAgeInfoNode::plVaultAgeInfoNode() -: fCanVisitFolder( nil ) -, fAgeOwnersFolder( nil ) -, fChildAgesFolder( nil ) -, fAgeSDL( nil ) -{ - ISetType( plVault::kNodeType_AgeInfo ); -} - -plVaultAgeInfoNode::~plVaultAgeInfoNode() -{ -} - -plVaultAgeLinkNode * plVaultAgeInfoNode::IGetLink( plVaultFolderNode * folder, const plAgeInfoStruct * info ) const -{ - plVaultNodeIterator it = folder->GetIterator(); - - for ( it; it; ++it ) - { - plVaultAgeLinkNode * linkNode = plVaultAgeLinkNode::ConvertNoRef( it->GetChild() ); - if ( !linkNode ) - continue; - plVaultAgeInfoNode * infoNode = linkNode->GetAgeInfo(); - if ( !infoNode ) - continue; - if ( info->HasAgeInstanceGuid() && infoNode->GetAgeInstanceGuid()->IsEqualTo( info->GetAgeInstanceGuid() ) ) - return linkNode; - if ( info->HasAgeInstanceName() && stricmp( infoNode->GetAgeInstanceName(), info->GetAgeInstanceName() )==0 ) - return linkNode; - if ( info->HasAgeFilename() && stricmp( infoNode->GetAgeFilename(), info->GetAgeFilename() )==0 ) - return linkNode; - } - - return nil; -} - -const plNetServerSessionInfo * plVaultAgeInfoNode::AsServerInfo() const -{ - fServerInfo.Clear(); - fServerInfo.SetServerName( GetAgeInstanceName() ); - fServerInfo.SetServerGuid( GetAgeInstanceGuid() ); - return &fServerInfo; -} - -const plAgeInfoStruct * plVaultAgeInfoNode::AsAgeInfoStruct() const -{ - fAgeInfoStruct.SetAgeFilename( GetAgeFilename() ); - fAgeInfoStruct.SetAgeInstanceName( GetAgeInstanceName() ); - fAgeInfoStruct.SetAgeInstanceGuid( GetAgeInstanceGuid() ); - fAgeInfoStruct.SetAgeUserDefinedName( GetAgeUserDefinedName() ); - fAgeInfoStruct.SetAgeSequenceNumber( GetSequenceNumber() ); - fAgeInfoStruct.SetAgeDescription( GetAgeDescription() ); - return &fAgeInfoStruct; -} - - -void plVaultAgeInfoNode::FromAgeInfoStruct( const plAgeInfoStruct * ageInfo ) -{ - if ( ageInfo->HasAgeFilename() ) - SetAgeFilename( ageInfo->GetAgeFilename() ); - if ( ageInfo->HasAgeInstanceName() ) - SetAgeInstanceName( ageInfo->GetAgeInstanceName() ); - if ( ageInfo->HasAgeInstanceGuid() ) - SetAgeInstanceGuid( ageInfo->GetAgeInstanceGuid() ); - if ( ageInfo->HasAgeUserDefinedName() ) - SetAgeUserDefinedName( ageInfo->GetAgeUserDefinedName() ); - if ( ageInfo->HasAgeSequenceNumber() ) - SetSequenceNumber( ageInfo->GetAgeSequenceNumber() ); - if ( ageInfo->HasAgeDescription() ) - SetAgeDescription( ageInfo->GetAgeDescription() ); -} - -plVaultPlayerInfoListNode * plVaultAgeInfoNode::GetCanVisitFolder( void ) const -{ - if ( fCanVisitFolder ) - return fCanVisitFolder; - plVaultPlayerInfoListNode tmp; - tmp.SetFolderType( plVault::kCanVisitFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fCanVisitFolder = plVaultPlayerInfoListNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fCanVisitFolder ) - hsLogEntry(plSafeGetLog()->AddLineF( "fCanVisitFolder node not found" )); - return fCanVisitFolder; -} - -plVaultPlayerInfoListNode * plVaultAgeInfoNode::GetAgeOwnersFolder( void ) const -{ - if ( fAgeOwnersFolder ) - return fAgeOwnersFolder; - plVaultPlayerInfoListNode tmp; - tmp.SetFolderType( plVault::kAgeOwnersFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgeOwnersFolder = plVaultPlayerInfoListNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgeOwnersFolder ) - hsLogEntry(plSafeGetLog()->AddLineF( "fAgeOwnersFolder node not found" )); - return fAgeOwnersFolder; -} - -plVaultFolderNode * plVaultAgeInfoNode::GetChildAgesFolder( void ) const -{ - if ( fChildAgesFolder ) - return fChildAgesFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kChildAgesFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fChildAgesFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fChildAgesFolder ) - hsLogEntry(plSafeGetLog()->AddLineF( "fChildAgesFolder node not found" )); - return fChildAgesFolder; -} - -plVaultAgeLinkNode * plVaultAgeInfoNode::GetChildAgeLink( const plAgeInfoStruct * info ) const -{ - GetChildAgesFolder(); - hsAssert( fChildAgesFolder, "Missing ChildAges folder" ); - if (fChildAgesFolder) - return IGetLink( fChildAgesFolder, info ); - return nil; -} - -plVaultSDLNode * plVaultAgeInfoNode::IGetAgeSDL() const -{ - if ( fAgeSDL ) - return fAgeSDL; - plVaultSDLNode tmp; - tmp.SetIdent( plVault::kAgeInstanceSDLNode ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgeSDL = plVaultSDLNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgeSDL ) - hsLogEntry(plSafeGetLog()->AddLineF( "fAgeSDL node not found" )); - return fAgeSDL; -} - -plVaultPlayerInfoNode * plVaultAgeInfoNode::GetCzar() const -{ - if ( !GetAgeOwnersFolder() ) - return nil; - GetAgeOwnersFolder()->Sort(); - plVaultNodeIterator it = GetAgeOwnersFolder()->GetIterator(); - if ( it.GetCount()==0 ) - return nil; - return plVaultPlayerInfoNode::ConvertNoRef( it.GetAt( 0 )->GetChild() ); -} - - -const char * plVaultAgeInfoNode::GetDisplayName() const -{ - return AsAgeInfoStruct()->GetDisplayName(); -} - -std::string plVaultAgeInfoNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Age:%lu,FName:%s,IName:%s,Guid:%s,UName:%s,Seq:%d,Pub:%s] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - GetAgeID(), GetAgeFilename(), GetAgeInstanceName(), - GetAgeInstanceGuid()->AsStdString().c_str(), GetAgeUserDefinedName(), - GetSequenceNumber(), IsPublic()?"yes":"no", plVaultNode::AsStdString().c_str() ); - return result; -} - - - -//////////////////////////////////////////////////////////////////// - -plVaultAgeLinkNode::plVaultAgeLinkNode() -: fAgeInfo( nil ) -{ - ISetType( plVault::kNodeType_AgeLink ); -} - -plVaultAgeLinkNode::~plVaultAgeLinkNode() -{ -} - -plVaultAgeInfoNode * plVaultAgeLinkNode::GetAgeInfo() const -{ - if ( fAgeInfo ) - return fAgeInfo; - plVaultAgeInfoNode tmp; - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgeInfo = plVaultAgeInfoNode::ConvertNoRef( nodeRef->GetChild() ); - return fAgeInfo; -} - -void plVaultAgeLinkNode::SetAgeInfo( plVaultAgeInfoNode * node ) -{ - plVaultAgeInfoNode * curr = GetAgeInfo(); - if ( curr ) - { - if ( curr->GetID()==node->GetID() ) - return; - - RemoveNode( curr->GetID() ); - } - fAgeInfo = nil; - AddNode( node ); -} - -struct MatchesSpawnPointTitle -{ - std::string fTitle; - MatchesSpawnPointTitle( const char * title ):fTitle( title ){} - bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fTitle==fTitle ); } -}; -struct MatchesSpawnPointName -{ - std::string fName; - MatchesSpawnPointName( const char * name ):fName( name ){} - bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fSpawnPt==fName ); } -}; - -void plVaultAgeLinkNode::AddSpawnPoint( const plSpawnPointInfo & point ) -{ - plSpawnPointVec points; - GetSpawnPoints( points ); - if ( std::find_if( points.begin(), points.end(), MatchesSpawnPointTitle( point.fTitle.c_str() ) )!=points.end() ) - return; - - // only check to see if the titles are the same... - //... so we can add the same spawnpoint as long as they have different titles - //if ( std::find_if( points.begin(), points.end(), MatchesSpawnPointName( point.fSpawnPt.c_str() ) )!=points.end() ) - // return; - - points.push_back( point ); - SetSpawnPoints( points ); -} - -void plVaultAgeLinkNode::RemoveSpawnPoint( const char * spawnPtName ) -{ - plSpawnPointVec points; - GetSpawnPoints( points ); - plSpawnPointVec::iterator it = std::find_if( points.begin(), points.end(), MatchesSpawnPointName( spawnPtName ) ); - if ( it!=points.end() ) - { - points.erase( it ); - SetSpawnPoints( points ); - } -} - -bool plVaultAgeLinkNode::HasSpawnPoint( const plSpawnPointInfo & point ) const -{ - return HasSpawnPoint( point.GetName() ); -} - -bool plVaultAgeLinkNode::HasSpawnPoint( const char * spawnPtName ) const -{ - plSpawnPointVec points; - GetSpawnPoints( points ); - return ( std::find_if( points.begin(), points.end(), MatchesSpawnPointName( spawnPtName ) )!=points.end() ); -} - -void plVaultAgeLinkNode::GetSpawnPoints( plSpawnPointVec & out ) const -{ - char token1[ 1024 ]; - hsStringTokenizer izer1( (const char *)IGetBufferBlob_1(), ";" ); - while ( izer1.Next( token1, sizeof( token1 ) ) ) - { - plSpawnPointInfo point; - char token2[ 1024 ]; - hsStringTokenizer izer2( token1, ":" ); - if ( izer2.Next( token2, sizeof( token2 ) ) ) - point.fTitle = token2; - if ( izer2.Next( token2, sizeof( token2 ) ) ) - point.fSpawnPt = token2; - if ( izer2.Next( token2, sizeof( token2 ) ) ) - point.fCameraStack = token2; - out.push_back( point ); - } -} - -void plVaultAgeLinkNode::SetSpawnPoints( const plSpawnPointVec & in ) -{ - std::stringstream ss; - for ( int i=0; iIIsThisMe( this ) ) ); - ISetIString64_1( text ); -} - -void plVaultPlayerInfoNode::SetPlayerID( UInt32 v ) -{ - if ( fMyNodeMgr ) - CheckIAmSuperUserOr_VoidReturn( fMyNodeMgr, ( !IsStored()||fMyNodeMgr->IIsThisMe( this ) ) ); - ISetUInt32_1( v ); -} - -void plVaultPlayerInfoNode::SetAgeInstanceName( const char * v ) -{ - ISetString64_1( v ); -} - -const char * plVaultPlayerInfoNode::GetAgeInstanceName( void ) const -{ - return ( IsOnline() ) ? IGetString64_1() : ""; -} - -void plVaultPlayerInfoNode::SetAgeGuid( const plUUID * v) -{ - ISetString64_2( v->AsStdString().c_str() ); -} - -const plUUID * plVaultPlayerInfoNode::GetAgeGuid( void ) const -{ - if ( IsOnline() ) - fGuid.FromString( IGetString64_2() ); - else - fGuid.Clear(); - return &fGuid; -} - -void plVaultPlayerInfoNode::SetOnline( bool b ) -{ - ISetInt32_1( b ); -} - - -std::string plVaultPlayerInfoNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[PlayerID:%lu,PlayerName:%s,IsOnline:%s,InAge:%s,InAgeGuid:%s] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), GetPlayerID(), - GetPlayerName(), (IsOnline())?"yes":"no", - GetAgeInstanceName(), GetAgeGuid()->AsStdString().c_str(), - plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -// true if A is less than B -bool PlayerInfoNodeCompare( const plVaultNode * a, const plVaultNode * b ) -{ - const plVaultPlayerInfoNode * A = plVaultPlayerInfoNode::ConvertNoRef( a ); - const plVaultPlayerInfoNode * B = plVaultPlayerInfoNode::ConvertNoRef( b ); - - if ( !A ) - return false; - if ( !B ) - return true; - if ( A->IsOnline() && !B->IsOnline() ) - return true; - if ( B->IsOnline() && !A->IsOnline() ) - return false; - return ( stricmp( A->GetPlayerName(), B->GetPlayerName() )<0 ); -} - -bool PlayerInfoNodeRefCompare( const plVaultNodeRef * nodeRefA, const plVaultNodeRef * nodeRefB ) -{ - if ( !nodeRefA || !nodeRefB ) - return false; - - return PlayerInfoNodeCompare( nodeRefA->GetChild(), nodeRefB->GetChild() ); -}; - -plVaultPlayerInfoListNode::plVaultPlayerInfoListNode() -{ - ISetType( plVault::kNodeType_PlayerInfoList ); -} - -plVaultPlayerInfoListNode::~plVaultPlayerInfoListNode() -{ -} - -bool plVaultPlayerInfoListNode::HasPlayer( UInt32 playerID ) -{ - plVaultPlayerInfoNode templateNode; - templateNode.SetPlayerID( playerID ); - plVaultNodeRef * tmp; - return FindNode( &templateNode, tmp ); -} - -bool plVaultPlayerInfoListNode::AddPlayer( UInt32 playerID ) -{ - plVaultPlayerInfoNode templateNode; - templateNode.SetPlayerID( playerID ); - plVaultNodeRef * tmp; - if ( !FindNode( &templateNode, tmp ) ) - return LinkToNode( &templateNode ); - return true; -} - -void plVaultPlayerInfoListNode::RemovePlayer( UInt32 playerID ) -{ - plVaultPlayerInfoNode templateNode; - templateNode.SetPlayerID( playerID ); - plVaultNodeRef * tmp; - if ( FindNode( &templateNode, tmp ) ) - RemoveNode( tmp->GetChildID() ); -} - -plVaultPlayerInfoNode * plVaultPlayerInfoListNode::GetPlayer( UInt32 playerID ) -{ - plVaultPlayerInfoNode templateNode; - templateNode.SetPlayerID( playerID ); - plVaultNodeRef * tmp; - if ( FindNode( &templateNode, tmp ) ) - return plVaultPlayerInfoNode::ConvertNoRef( tmp->GetChild() ); - return nil; -} - - -void plVaultPlayerInfoListNode::SetPlayers( const plVault::IDVec & playerIDs ) -{ - RemoveAllNodes(); - for ( int i=0; iGetChildID() ); -} - -//////////////////////////////////////////////////////////////////// -plVaultMgrNode::plVaultMgrNode() -: fMyInboxFolder( nil ), fSystemNode(nil) -{ -} - -plVaultMgrNode::~plVaultMgrNode() -{ -} - -plVaultFolderNode * plVaultMgrNode::GetInbox( void ) const -{ - if ( fMyInboxFolder ) - return fMyInboxFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kInboxFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fMyInboxFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - return fMyInboxFolder; -} - -plVaultSystemNode * plVaultMgrNode::GetSystemNode( ) const -{ - if ( fSystemNode ) - return fSystemNode; - plVaultSystemNode tmp; - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fSystemNode = plVaultSystemNode::ConvertNoRef( nodeRef->GetChild() ); - return fSystemNode; -} - -//////////////////////////////////////////////////////////////////// - -plVaultPlayerNode::plVaultPlayerNode() -: fPlayerInfo( nil ) -, fAvatarOutfitFolder( nil ) -, fAvatarClosetFolder( nil ) -, fChronicleFolder( nil ) -, fIgnoreListFolder( nil ) -, fBuddyListFolder( nil ) -, fPeopleIKnowAboutFolder( nil ) -, fAgeJournalsFolder( nil ) -, fAgesICanVisitFolder( nil ) -, fAgesIOwnFolder( nil ) -, fInviteFolder( nil ) -{ - ISetType( plVault::kNodeType_VNodeMgrPlayer ); -} - -plVaultPlayerNode::~plVaultPlayerNode() -{ -} - -plVaultPlayerInfoNode * plVaultPlayerNode::GetPlayerInfo() const -{ - static plVaultPlayerInfoNode s_nilNode; - if ( fPlayerInfo && fPlayerInfo != &s_nilNode) - return fPlayerInfo; - fPlayerInfo = nil; - plVaultPlayerInfoNode tmp; - tmp.SetPlayerID( GetID() ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fPlayerInfo = plVaultPlayerInfoNode::ConvertNoRef( nodeRef->GetChild() ); - if (!fPlayerInfo) { - hsLogEntry(plSafeGetLog()->AddLineF( "fPlayerInfo node not found" )); - fPlayerInfo = &s_nilNode; - } - return fPlayerInfo; -} - -plVaultFolderNode * plVaultPlayerNode::GetAvatarOutfitFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fAvatarOutfitFolder && fAvatarOutfitFolder != &s_nilNode) - return fAvatarOutfitFolder; - fAvatarOutfitFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAvatarOutfitFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAvatarOutfitFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAvatarOutfitFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fAvatarOutfitFolder node not found" )); - fAvatarOutfitFolder = &s_nilNode; - } - return fAvatarOutfitFolder; -} - -plVaultFolderNode * plVaultPlayerNode::GetAvatarClosetFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fAvatarClosetFolder && fAvatarClosetFolder != &s_nilNode) - return fAvatarClosetFolder; - fAvatarClosetFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAvatarClosetFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAvatarClosetFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAvatarClosetFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fAvatarClosetFolder node not found" )); - fAvatarClosetFolder = &s_nilNode; - } - return fAvatarClosetFolder; -} - -plVaultFolderNode * plVaultPlayerNode::GetChronicleFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fChronicleFolder && fChronicleFolder != &s_nilNode) - return fChronicleFolder; - fChronicleFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kChronicleFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fChronicleFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fChronicleFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fChronicleFolder node not found" )); - fChronicleFolder = &s_nilNode; - } - return fChronicleFolder; -} - -plVaultFolderNode * plVaultPlayerNode::GetAgeJournalsFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fAgeJournalsFolder && fAgeJournalsFolder != &s_nilNode) - return fAgeJournalsFolder; - fAgeJournalsFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAgeJournalsFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgeJournalsFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgeJournalsFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fAgeJournalsFolder node not found" )); - fAgeJournalsFolder = &s_nilNode; - } - return fAgeJournalsFolder; -} - -plVaultFolderNode * plVaultPlayerNode::GetAgesICanVisitFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fAgesICanVisitFolder && fAgesICanVisitFolder != &s_nilNode) - return fAgesICanVisitFolder; - fAgesICanVisitFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAgesICanVisitFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgesICanVisitFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgesICanVisitFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fAgesICanVisitFolder node not found" )); - fAgesICanVisitFolder = &s_nilNode; - } - return fAgesICanVisitFolder; -} - -plVaultFolderNode * plVaultPlayerNode::GetAgesIOwnFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fAgesIOwnFolder && fAgesIOwnFolder != &s_nilNode) - return fAgesIOwnFolder; - fAgesIOwnFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAgesIOwnFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgesIOwnFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgesIOwnFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fAgesIOwnFolder node not found" )); - fAgesIOwnFolder = &s_nilNode; - } - return fAgesIOwnFolder; -} - -plVaultPlayerInfoListNode * plVaultPlayerNode::GetIgnoreListFolder( void ) const -{ - static plVaultPlayerInfoListNode s_nilNode; - if ( fIgnoreListFolder && fIgnoreListFolder != &s_nilNode) - return fIgnoreListFolder; - fIgnoreListFolder = nil; - plVaultPlayerInfoListNode tmp; - tmp.SetFolderType( plVault::kIgnoreListFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fIgnoreListFolder = plVaultPlayerInfoListNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fIgnoreListFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fIgnoreListFolder node not found" )); - fIgnoreListFolder = &s_nilNode; - } - return fIgnoreListFolder; -} - -plVaultPlayerInfoListNode * plVaultPlayerNode::GetBuddyListFolder( void ) const -{ - static plVaultPlayerInfoListNode s_nilNode; - if ( fBuddyListFolder && fBuddyListFolder != &s_nilNode) - return fBuddyListFolder; - fBuddyListFolder = nil; - plVaultPlayerInfoListNode tmp; - tmp.SetFolderType( plVault::kBuddyListFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fBuddyListFolder = plVaultPlayerInfoListNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fBuddyListFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fBuddyListFolder node not found" )); - fBuddyListFolder = &s_nilNode; - } - return fBuddyListFolder; -} - -plVaultPlayerInfoListNode * plVaultPlayerNode::GetPeopleIKnowAboutFolder( void ) const -{ - static plVaultPlayerInfoListNode s_nilNode; - if ( fPeopleIKnowAboutFolder && fPeopleIKnowAboutFolder != &s_nilNode) - return fPeopleIKnowAboutFolder; - fPeopleIKnowAboutFolder = nil; - plVaultPlayerInfoListNode tmp; - tmp.SetFolderType( plVault::kPeopleIKnowAboutFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fPeopleIKnowAboutFolder = plVaultPlayerInfoListNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fPeopleIKnowAboutFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fPeopleIKnowAboutFolder node not found" )); - fPeopleIKnowAboutFolder = &s_nilNode; - } - return fPeopleIKnowAboutFolder; -} - -plVaultFolderNode * plVaultPlayerNode::GetInviteFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fInviteFolder && fInviteFolder != &s_nilNode) - return fInviteFolder; - fInviteFolder = nil; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kPlayerInviteFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fInviteFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fInviteFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fInviteFolder node not found" )); - fInviteFolder = &s_nilNode; - } - return fInviteFolder; -} - -////// - -plVaultAgeLinkNode * plVaultPlayerNode::GetLinkToMyNeighborhood() const -{ - plAgeInfoStruct info; - info.SetAgeFilename( kNeighborhoodAgeFilename ); - return GetOwnedAgeLink( &info ); -} - - -plVaultAgeLinkNode * plVaultPlayerNode::GetLinkToCity() const -{ - plAgeInfoStruct info; - info.SetAgeFilename( kCityAgeFilename ); - return GetOwnedAgeLink( &info ); -} - -////// - -plVaultAgeLinkNode * plVaultPlayerNode::IFindLink( plVaultFolderNode * folder, const plAgeInfoStruct * info ) const -{ - plVaultNodeIterator it = folder->GetIterator(); - - for ( it; it; ++it ) - { - plVaultAgeLinkNode * linkNode = plVaultAgeLinkNode::ConvertNoRef( it->GetChild() ); - if ( !linkNode ) - continue; - plVaultAgeInfoNode * infoNode = linkNode->GetAgeInfo(); - if ( !infoNode ) - continue; - if ( info->IsEqualTo( infoNode->AsAgeInfoStruct() ) ) - return linkNode; - } - - return nil; -} - -void plVaultPlayerNode::IRemoveLink( plVaultFolderNode * folder, const plUUID * guid ) -{ - plVaultNodeIterator it = folder->GetIterator(); - - for ( it; it; ++it ) - { - plVaultAgeLinkNode * linkNode = plVaultAgeLinkNode::ConvertNoRef( it->GetChild() ); - if ( !linkNode ) - continue; - plVaultAgeInfoNode * infoNode = linkNode->GetAgeInfo(); - if ( !infoNode ) - continue; - if ( infoNode->GetAgeInstanceGuid()->IsEqualTo( guid ) ) - { - folder->RemoveNode( linkNode->GetID() ); - } - } -} - -/////////// - -plVaultAgeLinkNode * plVaultPlayerNode::GetOwnedAgeLink( const plAgeInfoStruct * info, bool skipVolatile/*=false */) const -{ - GetAgesIOwnFolder(); - hsAssert( fAgesIOwnFolder, "Missing AgesIOwn folder" ); - plAgeInfoStruct tmp; - if ( info->HasAgeFilename() ) - tmp.SetAgeFilename( info->GetAgeFilename() ); - else if ( info->HasAgeInstanceGuid() ) - tmp.SetAgeInstanceGuid( info->GetAgeInstanceGuid() ); - else - tmp.CopyFrom( info ); - plVaultAgeLinkNode * result = IFindLink( fAgesIOwnFolder, &tmp ); - - if ( result && result->GetVolatile() && skipVolatile ) - return nil; - - return result; -} - - -void plVaultPlayerNode::RemoveOwnedAgeLink( const plUUID * guid ) -{ - GetAgesIOwnFolder(); - hsAssert( fAgesIOwnFolder, "Missing AgesIOwn folder" ); - IRemoveLink( fAgesIOwnFolder, guid ); -} - -/////////// - -plVaultAgeLinkNode * plVaultPlayerNode::GetVisitAgeLink( const plAgeInfoStruct * info ) const -{ - GetAgesICanVisitFolder(); - hsAssert( fAgesICanVisitFolder, "Missing AgesICanVisit folder" ); - plAgeInfoStruct tmp; - if ( info->HasAgeInstanceGuid() ) - tmp.SetAgeInstanceGuid( info->GetAgeInstanceGuid() ); - else - tmp.CopyFrom( info ); - return IFindLink( fAgesICanVisitFolder, &tmp ); -} - -void plVaultPlayerNode::RemoveVisitAgeLink( const plUUID * guid ) -{ - GetAgesICanVisitFolder(); - hsAssert( fAgesICanVisitFolder, "Missing AgesICanVisit folder" ); - IRemoveLink( fAgesICanVisitFolder, guid ); -} - -/////////// - -plVaultChronicleNode * plVaultPlayerNode::FindChronicleEntry( const char * entryName ) -{ - GetChronicleFolder(); - hsAssert( fChronicleFolder, "Missing Chronicle folder" ); - plVaultChronicleNode templateNode; - templateNode.SetName( entryName ); - plVaultNodeRef * tmp; - if ( fChronicleFolder->FindNode( &templateNode, tmp ) ) - return plVaultChronicleNode::ConvertNoRef( tmp->GetChild() ); - return nil; -} - - -/////////// - -void plVaultPlayerNode::SetAccountUUID( const plUUID * v ) -{ - if ( fMyNodeMgr ) - CheckIAmSuperUserOr_VoidReturn( fMyNodeMgr, ( !IsStored()||fMyNodeMgr->IIsThisMe( this ) ) ); - fAcctUUID.CopyFrom( v ); - ISetIString64_2( fAcctUUID.AsStdString().c_str() ); -} - -const plUUID * plVaultPlayerNode::GetAccountUUID( void ) const -{ - if ( fAcctUUID.IsNull() ) - fAcctUUID.FromString( IGetIString64_2() ); - return &fAcctUUID; -} - -void plVaultPlayerNode::SetPlayerName( const char * v ) -{ - if ( fMyNodeMgr ) - CheckIAmSuperUserOr_VoidReturn( fMyNodeMgr, ( !IsStored()||fMyNodeMgr->IIsThisMe( this ) ) ); - ISetIString64_1( v ); - plVaultPlayerInfoNode * playerInfo = GetPlayerInfo(); - if ( playerInfo ) - playerInfo->SetPlayerName( v ); -} - -void plVaultPlayerNode::SetAvatarShapeName( const char * v ) -{ - if ( fMyNodeMgr ) - CheckIAmSuperUserOr_VoidReturn( fMyNodeMgr, ( !IsStored()||fMyNodeMgr->IIsThisMe( this ) ) ); - ISetString64_1( v ); -} - -void plVaultPlayerNode::Save( plVaultOperationCallback * cb, UInt32 cbContext ) -{ - if ( GetPlayerInfo() ) - GetPlayerInfo()->Save(); - plVaultNode::Save( cb, cbContext ); -} - - -std::string plVaultPlayerNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[ID:%lu,Nam:%s,Av:%s:Acct:%s] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), GetID(), - GetPlayerName(), GetAvatarShapeName(), GetAccountUUID()->AsStdString().c_str(), - plVaultMgrNode::AsStdString().c_str() ); - return result; -} - - -//////////////////////////////////////////////////////////////////// - -plVaultAgeNode::plVaultAgeNode() -: fAgeInfo( nil ) -, fAgesIOwnFolder( nil ) -, fAgeDevicesFolder( nil ) -, fSubAgesFolder( nil ) -, fPeopleIKnowAboutFolder( nil ) -, fPublicAgesFolder( nil ) -, fChronicleFolder( nil ) -{ - ISetType( plVault::kNodeType_VNodeMgrAge ); -} - -plVaultAgeNode::~plVaultAgeNode() -{ -} - -plVaultAgeLinkNode * plVaultAgeNode::IGetLink( plVaultFolderNode * folder, const plAgeInfoStruct * info ) const -{ - plVaultNodeIterator it = folder->GetIterator(); - - for ( it; it; ++it ) - { - plVaultAgeLinkNode * linkNode = plVaultAgeLinkNode::ConvertNoRef( it->GetChild() ); - if ( !linkNode ) - continue; - plVaultAgeInfoNode * infoNode = linkNode->GetAgeInfo(); - if ( !infoNode ) - continue; - if ( info->HasAgeInstanceGuid() && infoNode->GetAgeInstanceGuid()->IsEqualTo( info->GetAgeInstanceGuid() ) ) - return linkNode; - if ( info->HasAgeInstanceName() && stricmp( infoNode->GetAgeInstanceName(), info->GetAgeInstanceName() )==0 ) - return linkNode; - if ( info->HasAgeFilename() && stricmp( infoNode->GetAgeFilename(), info->GetAgeFilename() )==0 ) - return linkNode; - } - - return nil; -} - - -void plVaultAgeNode::SetAgeGuid( const plUUID * guid ) -{ - fAgeGuid.CopyFrom( guid ); - ISetString64_1( guid->AsStdString().c_str() ); - if ( GetAgeInfo() ) - GetAgeInfo()->SetAgeInstanceGuid( guid ); -} - -void plVaultAgeNode::Save( plVaultOperationCallback * cb/* =nil */, UInt32 cbContext/* =0 */) -{ - if ( GetAgeInfo() ) - GetAgeInfo()->Save(); - plVaultNode::Save( cb, cbContext ); -} - -plVaultAgeInfoNode * plVaultAgeNode::GetAgeInfo() const -{ - if ( fAgeInfo ) - return fAgeInfo; - plVaultAgeInfoNode tmp; - tmp.SetAgeID( GetID() ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgeInfo = plVaultAgeInfoNode::ConvertNoRef( nodeRef->GetChild() ); - return fAgeInfo; -} - -plVaultFolderNode * plVaultAgeNode::GetAgeDevicesFolder( void ) const -{ - if ( fAgeDevicesFolder ) - return fAgeDevicesFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAgeDevicesFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgeDevicesFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgeDevicesFolder ) - hsLogEntry(plSafeGetLog()->AddLineF( "fAgeDevicesFolder node not found" )); - return fAgeDevicesFolder; -} - -plVaultFolderNode * plVaultAgeNode::GetSubAgesFolder( void ) const -{ - if ( fSubAgesFolder ) - return fSubAgesFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kSubAgesFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fSubAgesFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fSubAgesFolder ) - hsLogEntry(plSafeGetLog()->AddLineF( "fSubAgesFolder node not found" )); - return fSubAgesFolder; -} - -plVaultPlayerInfoListNode * plVaultAgeNode::GetPeopleIKnowAboutFolder( void ) const -{ - if ( fPeopleIKnowAboutFolder ) - return fPeopleIKnowAboutFolder; - plVaultPlayerInfoListNode tmp; - tmp.SetFolderType( plVault::kPeopleIKnowAboutFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fPeopleIKnowAboutFolder = plVaultPlayerInfoListNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fPeopleIKnowAboutFolder ) - hsLogEntry(plSafeGetLog()->AddLineF( "fPeopleIKnowAboutFolder node not found" )); - return fPeopleIKnowAboutFolder; -} - -plVaultFolderNode * plVaultAgeNode::GetChronicleFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fChronicleFolder && fChronicleFolder != &s_nilNode) - return fChronicleFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kChronicleFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fChronicleFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fChronicleFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fChronicleFolder node not found" )); - fChronicleFolder = &s_nilNode; - } - return fChronicleFolder; -} - -plVaultFolderNode * plVaultAgeNode::GetAgesIOwnFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fAgesIOwnFolder && fAgesIOwnFolder != &s_nilNode) - return fAgesIOwnFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kAgesIOwnFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fAgesIOwnFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fAgesIOwnFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fAgesIOwnFolder node not found" )); - fAgesIOwnFolder = &s_nilNode; - } - return fAgesIOwnFolder; -} - -plVaultFolderNode * plVaultAgeNode::GetPublicAgesFolder( void ) const -{ - static plVaultFolderNode s_nilNode; - if ( fPublicAgesFolder && fPublicAgesFolder != &s_nilNode) - return fPublicAgesFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kPublicAgesFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fPublicAgesFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - if ( !fPublicAgesFolder ) { - hsLogEntry(plSafeGetLog()->AddLineF( "fPublicAgesFolder node not found" )); - fPublicAgesFolder = &s_nilNode; - } - return fPublicAgesFolder; -} - -// Add a new device. -void plVaultAgeNode::AddDevice( const char * deviceName, - plVaultOperationCallback * cb /*=nil*/, UInt32 cbContext /*=0*/ ) -{ - plVaultTextNoteNode * device = GetDevice( deviceName ); - if ( !device && fMyNodeMgr) - { - device = plVaultTextNoteNode::ConvertNoRef( fMyNodeMgr->CreateNode( plVault::kNodeType_TextNote, kNewPersistentNodeOptions( fMyNodeMgr ) ) ); - device->SetTitle( deviceName ); - device->SetNoteType( plVault::kNoteType_Device ); - GetAgeDevicesFolder()->AddNode( device, cb, cbContext ); - } - else - { - if ( cb ) - { - cb->fNode = device; - cb->VaultOperationStarted( cbContext ); - cb->VaultOperationComplete( cbContext, device->IsStored()?hsOK:hsFail ); - } - } -} - -// Remove a device. -void plVaultAgeNode::RemoveDevice( const char * deviceName ) -{ - plVaultTextNoteNode * device = GetDevice( deviceName ); - if ( device ) - GetAgeDevicesFolder()->RemoveNode( device->GetID() ); -} - -// True if device exists in age. -bool plVaultAgeNode::HasDevice( const char * deviceName ) -{ - return ( GetDevice( deviceName )!=nil ); -} - -plVaultTextNoteNode * plVaultAgeNode::GetDevice( const char * deviceName ) -{ - GetAgeDevicesFolder(); - hsAssert( fAgeDevicesFolder, "Missing AgeDevicesFolder" ); - plVaultTextNoteNode tmp; - tmp.SetTitle( deviceName ); - tmp.SetNoteType( plVault::kNoteType_Device ); - plVaultNodeRef * nodeRef; - if ( fAgeDevicesFolder->FindNode( &tmp, nodeRef ) ) - return plVaultTextNoteNode::ConvertNoRef( nodeRef->GetChild() ); - hsLogEntry(plSafeGetLog()->AddLineF( "Device %s not found", deviceName )); - return nil; -} - - -plVaultAgeLinkNode * plVaultAgeNode::GetSubAgeLink( const plAgeInfoStruct * info ) const -{ - GetSubAgesFolder(); - hsAssert( fSubAgesFolder, "Missing SubAges folder" ); - return IGetLink( fSubAgesFolder, info ); -} - -plVaultChronicleNode * plVaultAgeNode::FindChronicleEntry( const char * entryName ) -{ - GetChronicleFolder(); - hsAssert( fChronicleFolder, "Missing Chronicle folder" ); - plVaultChronicleNode templateNode; - templateNode.SetName( entryName ); - plVaultNodeRef * tmp; - if ( fChronicleFolder->FindNode( &templateNode, tmp ) ) - return plVaultChronicleNode::ConvertNoRef( tmp->GetChild() ); - return nil; -} - -std::string plVaultAgeNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Guid:%s] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - GetAgeGuid()->AsStdString().c_str(), - plVaultNode::AsStdString().c_str() ); - return result; -} - - -//////////////////////////////////////////////////////////////////// - -plVaultAdminNode::plVaultAdminNode() -: fAllAgeSDLEventInboxesFolder(nil) -{ - ISetType( plVault::kNodeType_VNodeMgrAdmin ); -} - -plVaultAdminNode::~plVaultAdminNode() -{ -} - -std::string plVaultAdminNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -plVaultMarkerNode::plVaultMarkerNode() -{ - ISetType(plVault::kNodeType_Marker); -} - -plVaultMarkerNode::~plVaultMarkerNode() -{ -} - -void plVaultMarkerNode::SetPosition(const hsPoint3& pos) -{ - // To be efficient, write our floats as UInt32's, so we don't have to allocate - // a blob or some crap like that. - UInt32 x = *((UInt32*)&pos.fX); - UInt32 y = *((UInt32*)&pos.fY); - UInt32 z = *((UInt32*)&pos.fZ); - - ISetUInt32_1(x); - ISetUInt32_2(y); - ISetUInt32_3(z); -} - -hsPoint3 plVaultMarkerNode::GetPosition() const -{ - UInt32 uX = IGetUInt32_1(); - UInt32 uY = IGetUInt32_2(); - UInt32 uZ = IGetUInt32_3(); - - float x = *((float*)&uX); - float y = *((float*)&uY); - float z = *((float*)&uZ); - - return hsPoint3(x, y, z); -} - -std::string plVaultMarkerNode::AsStdString(int level) const -{ - std::string result; - std::string space( level, ' ' ); - hsPoint3 pos = GetPosition(); - xtl::format( result, "%s%s[Text:%s Pos: %.1f,%.1f,%.1f GPS: %d,%d,%d] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - GetText(), pos.fX, pos.fY, pos.fZ, GetGPSTorans(),GetGPSHSpans(),GetGPSVSpans(), plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -plVaultMarkerListNode::plVaultMarkerListNode() -{ - ISetType(plVault::kNodeType_MarkerList); -} - -plVaultMarkerListNode::~plVaultMarkerListNode() -{ -} - -std::string plVaultMarkerListNode::AsStdString(int level) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[Owner:%s[%d], GameType: %d, RoundLength: %d] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - GetOwnerName(),GetOwnerID(),GetGameType(),GetRoundLength(), plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -plVaultSystemNode::plVaultSystemNode() -: fGlobalInboxFolder( nil ) -{ - ISetType( plVault::kNodeType_System ); -} - -plVaultFolderNode * plVaultSystemNode::GetGlobalInbox( void ) const -{ - if ( fGlobalInboxFolder ) - return fGlobalInboxFolder; - plVaultFolderNode tmp; - tmp.SetFolderType( plVault::kGlobalInboxFolder ); - plVaultNodeRef * nodeRef; - if ( FindNode( &tmp, nodeRef ) ) - fGlobalInboxFolder = plVaultFolderNode::ConvertNoRef( nodeRef->GetChild() ); - return fGlobalInboxFolder; -} - - -std::string plVaultSystemNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%s%s[CCRAway:%d] %s", - space.c_str(), plVault::NodeTypeStr( GetType() ), - GetCCRAwayStatus(), - plVaultNode::AsStdString().c_str() ); - return result; -} - -//////////////////////////////////////////////////////////////////// - -plNetVaultServerNode::plNetVaultServerNode() -: fCityInfo( nil ) -, fAllPlayersFolderID( 0 ) -, fAllAgeGlobalSDLNodesFolderID( 0 ) -, fPublicAgesFolderID( 0 ) -{ - ISetType( plVault::kNodeType_VNodeMgrServer ); -} - -plNetVaultServerNode::~plNetVaultServerNode() -{ -} - -std::string plNetVaultServerNode::AsStdString( int level ) const -{ - std::string result; - std::string space( level, ' ' ); - xtl::format( result, "%sVAULT[] %s", - space.c_str(), plVaultNode::AsStdString().c_str() ); - return result; -} - - -// End. - - -#endif \ No newline at end of file diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultNode.h b/Sources/Plasma/PubUtilLib/plVault/plVaultNode.h deleted file mode 100644 index 17ce38f4..00000000 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultNode.h +++ /dev/null @@ -1,1013 +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 . - -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==*/ -#if 0 -#ifndef plVaultNode_h_inc -#define plVaultNode_h_inc - -#include "hsTypes.h" -#include "hsBitVector.h" -#include "../plUnifiedTime/plUnifiedTime.h" -#include "../plNetCommon/plNetServerSessionInfo.h" -#include "../plNetCommon/plSpawnPointInfo.h" -#include "../plNetCommon/plNetCommon.h" -#include "../plUUID/plUUID.h" -#include "plVault.h" -#include "plVaultNodeIterator.h" -#include -#include - -//////////////////////////////////////////////////////////////////// - -class plVaultNode; -class plVaultFolderNode; -class plVaultImageNode; -class plVaultTextNoteNode; -class plVaultSDLNode; -class plVaultAgeLinkNode; -class plVaultChronicleNode; -class plVaultMgrNode; -class plVaultPlayerNode; -class plVaultPlayerInfoNode; -class plVaultPlayerInfoListNode; -class plVaultAgeNode; -class plVaultAgeInfoNode; -class plVaultAgeInfoListNode; -class plVaultSystemNode; -class plStateDataRecord; -class plURL; - -struct hsPoint3; - - -//////////////////////////////////////////////////////////////////// - -typedef bool (*plNodeCompareProc)( const plVaultNode * A, const plVaultNode * B ); - - -class plVaultNode -{ -public: - struct MatchesNode - { - const plVaultNode * fNode; - MatchesNode( const plVaultNode * node ): fNode( node ) {} - bool operator()( const plVaultNode * node ) const; - }; - friend struct MatchesNode; - - void SetID( UInt32 v ); - void SetType( UInt8 v ); - void SetPermissions( UInt32 v ); - void SetOwnerNodeID( UInt32 v ); - void SetGroupNodeID( UInt32 v ); - void SetCreatorNodeID( UInt32 v ); - void SetCreateTime( const plUnifiedTime * v ); - void SetCreateTime( const plUnifiedTime & v ); - void SetCreateAgeTime( const plUnifiedTime * v ); - void SetCreateAgeTime( const plUnifiedTime & v ); - void SetCreateAgeName( const char * v ); - void SetCreateAgeGuid( const plUUID * v ); - void SetCreateAgeGuid( const plUUID & v ); - void SetInt32_1( Int32 v ); - void SetInt32_2( Int32 v ); - void SetInt32_3( Int32 v ); - void SetInt32_4( Int32 v ); - void SetUInt32_1( UInt32 v ); - void SetUInt32_2( UInt32 v ); - void SetUInt32_3( UInt32 v ); - void SetUInt32_4( UInt32 v ); - void SetString64_1( const char * v ); - void SetString64_2( const char * v ); - void SetString64_3( const char * v ); - void SetString64_4( const char * v ); - void SetString64_5( const char * v ); - void SetString64_6( const char * v ); - void SetIString64_1( const char * v ); - void SetIString64_2( const char * v ); - void SetText_1( const char * v ); - void SetText_2( const char * v ); - void SetBlob_1_Guid( const plUUID * v ); - void SetBlob_2_Guid( const plUUID * v ); - void * AllocBufferBlob_1( int size ); - void * AllocBufferBlob_2( int size ); - - UInt32 GetID () const; - UInt8 GetType () const; - UInt32 GetPermissions () const; - UInt32 GetOwnerNodeID () const; - const plVaultPlayerInfoNode * GetOwnerNode () const; - UInt32 GetGroupNodeID () const; - const plVaultNode * GetGroupNode () const; - const plUnifiedTime * GetModifyTime () const; - UInt32 GetCreatorNodeID () const; - const plVaultPlayerInfoNode * GetCreatorNode () const; - const plUnifiedTime * GetCreateTime () const; - const plUnifiedTime * GetCreateAgeTime () const; - const char * GetCreateAgeName () const; - const plUUID * GetCreateAgeGuid () const; - Int32 GetInt32_1 () const; - Int32 GetInt32_2 () const; - Int32 GetInt32_3 () const; - Int32 GetInt32_4 () const; - UInt32 GetUInt32_1 () const; - UInt32 GetUInt32_2 () const; - UInt32 GetUInt32_3 () const; - UInt32 GetUInt32_4 () const; - const char * GetString64_1 () const; - const char * GetString64_2 () const; - const char * GetString64_3 () const; - const char * GetString64_4 () const; - const char * GetString64_5 () const; - const char * GetString64_6 () const; - const char * GetIString64_1 () const; - const char * GetIString64_2 () const; - const char * GetText_1 () const; - const char * GetText_2 () const; - std::string & GetBlob_1 (); - const std::string & GetBlob_1 () const; - void * GetBufferBlob_1 () const; - int GetBufferSizeBlob_1 () const; - const plUUID * GetBlob_1_Guid () const; - std::string & GetBlob_2 (); - const std::string & GetBlob_2 () const; - void * GetBufferBlob_2 () const; - int GetBufferSizeBlob_2 () const; - const plUUID * GetBlob_2_Guid () const; - -public: - plVaultNode(); - virtual ~plVaultNode(); - - bool IsADownstreamNode( UInt32 nodeID ) const; - - - ///////////////////////////////////////////////// - // Vault Node API - -#if 0 - // Add child node - plVaultNodeRef * AddNode( - plVaultNode * node, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - // Find matching node on server and add it to this node. - // Optionally don't fetch children of this node. - bool LinkToNode( - const plVaultNode * templateNode, - int childFetchLevel=plVault::kFetchAllChildren, - bool allowCreate=true, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - bool LinkToNode( - UInt32 nodeID, - int childFetchLevel=plVault::kFetchAllChildren, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - // Remove child node - bool RemoveNode( const plVaultNode * node, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - bool RemoveNode( UInt32 nodeID, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - // Remove all child nodes - void RemoveAllNodes( void ); - // Add/Save this node to vault - virtual void Save( - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - // Save this node and all child nodes that need saving. - // NOTE: Currently, the cb object is called back for - // each node saved. - void SaveAll( - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - // Send this node to the destination client node. will be received in it's inbox folder. - void SendTo( - UInt32 destClientNodeID, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); -#endif - - // Get an iterator to this node's children - plVaultNodeIterator GetIterator( void ); - - -#if 0 - // Get child node count - int GetNodeCount( void ) const { return fChildNodes.size(); } - // Get all child nodes. - void GetNodes( plVault::NodeRefVec & out ); - // Get child node by ID - bool GetNode( UInt32 nodeID, plVaultNodeRef *& out ) const; - // Get child node matching template node - bool FindNode( const plVaultNode * templateNode, plVaultNodeRef *& out ) const; - // Get all matching child nodes - bool FindNodes( const plVaultNode * templateNode, plVault::NodeRefVec & out ) const; - // Get first matching node recursively among children - bool FindNodeRecurse( const plVaultNode * templateNode, plVaultNodeRef *& out ) const; - // Returns true if node is a child of this node - bool HasNode( UInt32 nodeID ); - bool HasNode( const plVaultNode * templateNode ); - - // true if node needs saving - bool Modified( void ) const; - void SetModified( bool b ); - - // Get the client ID from my Vault client. - UInt32 GetClientID( void ) const; - - // application data keyed to this node. not stored. - void SetUserData( UInt32 v ) { fUserData=v; } - UInt32 GetUserData( void ) const { return fUserData; } -#endif - - ///////////////////////////////////////////////// - -#if 0 - void Read( hsStream * s, hsResMgr * mgr ); - void Write( hsStream * s, hsResMgr * mgr ); - virtual void CopyFrom( const plVaultNode * other, bool forceCopyAllFields=false ); - - virtual std::string AsStdString( int level=0 ) const; - std::string FieldsAsStdString( void ) const; - void Dump( int level=0, bool displaySeen=false, bool beenSeen=true, plStatusLog * log=nil ) const; - void GetChildNodes( const plVault::NodeRefVec *& out ) const { out=&fChildNodes; } - - virtual std::string AsHtmlForm( const char * action ) { return ""; } - bool FromHtmlPost( plURL & url ) { return false; } -#endif - -private: - plVaultNode( const plVaultNode & ); - plVaultNode & operator =( const plVaultNode & ); -}; - - -//============================================================================ -//============================================================================ -//============================================================================ -//============================================================================ -#if 0 - -//////////////////////////////////////////////////////////////////// - -class plVaultFolderNode : public plVaultNode -{ -public: - enum FieldMap - { - kFolderType = kInt32_1, - kFolderName = kString64_1, - }; - - plVaultFolderNode(); - ~plVaultFolderNode(); - CLASSNAME_REGISTER( plVaultFolderNode ); - GETINTERFACE_ANY( plVaultFolderNode, plVaultNode ); - - void SetFolderType( int type ) { ISetInt32_1( type ); } - int GetFolderType( void ) const { return IGetInt32_1();} - void SetFolderName( const char * v ) { ISetString64_1( v ); } - const char * GetFolderName( void ) const{ return IGetString64_1();} - - std::string AsStdString( int level=0 ) const; - - std::string AsHtmlForm( const char * action ); -}; - -//////////////////////////////////////////////////////////////////// - -class plMipmap; -class plVaultImageNode : public plVaultNode -{ - friend class plNetClientVNodeMgr; - - plMipmap * fMipmap; - void ISetMipmap( plMipmap * v ) { fMipmap=v; } - plMipmap * IGetMipmap( void ) const { return fMipmap; } - -public: - enum FieldMap - { - kImageType = kInt32_1, - kImageTitle = kString64_1, - kImageData = kBlob_1, - }; - - enum ImageTypes { kJPEG=1 }; - - plVaultImageNode(); - ~plVaultImageNode(); - CLASSNAME_REGISTER( plVaultImageNode ); - GETINTERFACE_ANY( plVaultImageNode, plVaultNode ); - - const plMipmap * GetMipmap( void ) const { return fMipmap; } - // this override copies the mipmap ptr too. - void CopyFrom( const plVaultNode * other, bool forceCopyAllFields=false ); - - void SetImageType( int type ) { ISetInt32_1( type ); } - int GetImageType( void ) const { return IGetInt32_1(); } - void * AllocBuffer( int size ) { return IAllocBufferBlob_1( size ); } - void * GetBuffer( void ) const { return IGetBufferBlob_1(); } - int GetBufSize() const { return IGetBufferSizeBlob_1(); } - - void SetTitle( const char * text ) { ISetString64_1( text ); } - const char * GetTitle( void ) const { return IGetString64_1(); } - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultTextNoteNode : public plVaultNode -{ -public: - enum FieldMap - { - kNoteType = kInt32_1, - kNoteSubType = kInt32_2, - kNoteTitle = kString64_1, - kNoteText = kBlob_1, - }; - - plVaultTextNoteNode(); - ~plVaultTextNoteNode(); - CLASSNAME_REGISTER( plVaultTextNoteNode ); - GETINTERFACE_ANY( plVaultTextNoteNode, plVaultNode ); - - void SetText( const char * text ); - const char * GetText( void ) const { return IGetBlob_1().c_str(); } - - void SetTitle( const char * text ) { ISetString64_1( text ); } - const char * GetTitle( void ) const { return IGetString64_1(); } - - void SetNoteType( Int32 type ) { ISetInt32_1( type ); } - Int32 GetNoteType( void ) const { return IGetInt32_1(); } - - void SetNoteSubType( Int32 type ) { ISetInt32_2( type ); } - Int32 GetNoteSubType( void ) const { return IGetInt32_2(); } - - // Device-specific: - plVaultFolderNode * GetDeviceInbox() const; - void SetDeviceInbox( const char * inboxName, - plVaultOperationCallback * cb=nil, UInt32 cbContext=0 ); - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultSDLNode : public plVaultNode -{ - mutable plStateDataRecord * fSDLDataRec; // for GetStateDataRecord() - -public: - enum FieldMap - { - kName = kString64_1, - kIdent = kInt32_1, // pgmr-defined, from plVault::StandardNodes enum. - kSDLData = kBlob_1, - }; - - plVaultSDLNode(); - ~plVaultSDLNode(); - CLASSNAME_REGISTER( plVaultSDLNode ); - GETINTERFACE_ANY( plVaultSDLNode, plVaultNode ); - - void SetIdent( int v ) { ISetInt32_1( v ); } - int GetIdent() const { return IGetInt32_1(); } - - void * AllocBuffer( int size ) { return IAllocBufferBlob_1( size ); } - void * GetBuffer( void ) const { return IGetBufferBlob_1(); } - int GetBufSize() const { return IGetBufferSizeBlob_1(); } - - plStateDataRecord * GetStateDataRecord( UInt32 readOptions=0 ) const; // returned pointer will be valid until next call to this fxn, or until this node instance goes away. - void SetStateDataRecord( const plStateDataRecord * rec, UInt32 writeOptions=0 ); - void InitStateDataRecord( const char * sdlRecName, UInt32 writeOptions=0 ); - void DumpStateDataRecord( const char * msg=nil, bool dirtyOnly=false ) const; - - // override to dump debug info. - void Save( - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultAgeInfoNode : public plVaultNode -{ - mutable plVaultPlayerInfoListNode * fCanVisitFolder; - mutable plVaultPlayerInfoListNode * fAgeOwnersFolder; - mutable plVaultSDLNode * fAgeSDL; - mutable plVaultFolderNode * fChildAgesFolder; - - mutable plUUID fAgeInstanceGuid; - mutable plNetServerSessionInfo fServerInfo; - mutable plAgeInfoStruct fAgeInfoStruct; - - ///////////////////////////////// - friend class pyVault; - friend class pyAgeVault; - friend class plVaultAgeInfoInitializationTask; - plVaultSDLNode * IGetAgeSDL() const; - plVaultAgeLinkNode * IGetLink( plVaultFolderNode * folder, const plAgeInfoStruct * info ) const; - ///////////////////////////////// - -public: - enum FieldMap - { - kAgeFilename = kString64_1, // "Garden" - kAgeInstanceName = kString64_2, // "Eder Kemo" - kAgeUserDefinedName = kString64_3, // "Joe's" - kAgeInstanceGuid = kString64_4, - kAgeDescription = kText_1, // "Stay out!" - kAgeSequenceNumber = kInt32_1, - kIsPublic = kInt32_2, - kAgeLanguage = kInt32_3, // The language of the client that made this age - kAgeID = kUInt32_1, - kAgeCzarID = kUInt32_2, - kAgeInfoFlags = kUInt32_3, - }; - - enum AgeFlagBits // 32 bits max - { - kIsStartupNeighborhood = 1<<0, - }; - - plVaultAgeInfoNode(); - ~plVaultAgeInfoNode(); - - CLASSNAME_REGISTER( plVaultAgeInfoNode ); - GETINTERFACE_ANY( plVaultAgeInfoNode, plVaultNode ); - - plVaultPlayerInfoListNode * GetCanVisitFolder() const; - plVaultPlayerInfoListNode * GetAgeOwnersFolder() const; - plVaultFolderNode * GetChildAgesFolder( void ) const; - plVaultAgeLinkNode * GetChildAgeLink( const plAgeInfoStruct * info ) const; - const plVaultSDLNode * GetAgeSDL() const { return IGetAgeSDL(); } - plVaultSDLNode * GetAgeSDL() { return IGetAgeSDL(); } - plVaultPlayerInfoNode * GetCzar() const; - - const char * GetAgeFilename() const { return IGetString64_1(); } - void SetAgeFilename( const char * v ) { ISetString64_1( v ); } - - const char * GetAgeInstanceName() const { return IGetString64_2(); } - void SetAgeInstanceName( const char * v ) { ISetString64_2( v ); } - - const char * GetAgeUserDefinedName() const { return IGetString64_3(); } - void SetAgeUserDefinedName( const char * v ) { ISetString64_3( v ); } - - const plUUID * GetAgeInstanceGuid() const { fAgeInstanceGuid.FromString( IGetString64_4() ); return &fAgeInstanceGuid; } - void SetAgeInstanceGuid( const plUUID * guid ) { fAgeInstanceGuid.CopyFrom( guid ); ISetString64_4( fAgeInstanceGuid.AsString() ); } - - const char * GetAgeDescription() const { return IGetText_1(); } - void SetAgeDescription( const char * v ) { ISetText_1( v ); } - - Int32 GetSequenceNumber() const { return IGetInt32_1(); } - void SetSequenceNumber( Int32 v ) { ISetInt32_1( v ); } - - UInt32 GetAgeID() const { return IGetUInt32_1(); } - void SetAgeID( UInt32 v ) { ISetUInt32_1( v ); } - - // aka mayor - UInt32 GetCzarID() const { return IGetUInt32_2(); } - void SetCzarID( UInt32 v ) { ISetUInt32_2( v ); } - - bool IsPublic() const { return ( IGetInt32_2()!=0 ); } - // no glue for this one. Use plVaultAgeMgr::SetAgePublic() instead. - void ISetPublic( bool v ) { ISetInt32_2( v ); } - - Int32 GetAgeLanguage() const { return IGetInt32_3(); } - void SetAgeLanguage( Int32 v ) { ISetInt32_3( v ); } - - bool GetAgeFlag( UInt32 bit ) const { return ( IGetUInt32_3()&bit )!=0; } - void SetAgeFlag( UInt32 bit, bool on=true ) - { if ( on ) ISetUInt32_3( IGetUInt32_3()|bit ); - else ISetUInt32_3( IGetUInt32_3()&~bit ); - } - - // helpers for linking. - const plNetServerSessionInfo * AsServerInfo() const; - const plAgeInfoStruct * AsAgeInfoStruct() const; - // helpers for init - void FromAgeInfoStruct( const plAgeInfoStruct * ageInfo ); - // other helpers - const char * GetDisplayName() const; - - // debug - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultAgeInfoListNode : public plVaultFolderNode -{ -public: - enum FieldMap - { - }; - - plVaultAgeInfoListNode(); - ~plVaultAgeInfoListNode(); - CLASSNAME_REGISTER( plVaultAgeInfoListNode ); - GETINTERFACE_ANY( plVaultAgeInfoListNode, plVaultFolderNode ); - bool HasAge( UInt32 AgeID ); - bool AddAge( UInt32 AgeID ); - void RemoveAge( UInt32 AgeID ); -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultAgeLinkNode : public plVaultNode -{ - mutable plVaultAgeInfoNode * fAgeInfo; - -public: - enum FieldMap - { - kLocked = kInt32_1, // locked on psnl bookshelf - kVolatile = kInt32_2, // volatile on psnl bookshelf - kSpawnPoints = kBlob_1, // aka treasure stones. - }; - - plVaultAgeLinkNode(); - ~plVaultAgeLinkNode(); - CLASSNAME_REGISTER( plVaultAgeLinkNode ); - GETINTERFACE_ANY( plVaultAgeLinkNode, plVaultNode ); - - plVaultAgeInfoNode * GetAgeInfo() const; - void SetAgeInfo( plVaultAgeInfoNode * v ); - // locked on psnl age bookshelf - void SetLocked( bool v ) { ISetInt32_1( v?1:0 ); } - bool GetLocked() const { return ( IGetInt32_1()!=0 ); } - // volatile on psnl age bookshelf - void SetVolatile( bool v ) { ISetInt32_2( v?1:0 ); } - bool GetVolatile() const { return ( IGetInt32_2()!=0 ); } - // spawn points - void AddSpawnPoint( const plSpawnPointInfo & point ); // will only add if not there already. - void RemoveSpawnPoint( const char * spawnPtName ); - bool HasSpawnPoint( const char * spawnPtName ) const; - bool HasSpawnPoint( const plSpawnPointInfo & point ) const; // compares spawn name only, not title. - void GetSpawnPoints( plSpawnPointVec & out ) const; - void SetSpawnPoints( const plSpawnPointVec & in ); - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultChronicleNode : public plVaultNode -{ -public: - enum FieldMap - { - kEntryType = kInt32_1, - kEntryName = kString64_1, - kEntryValue = kText_1, - }; - - plVaultChronicleNode(); - ~plVaultChronicleNode(); - CLASSNAME_REGISTER( plVaultChronicleNode ); - GETINTERFACE_ANY( plVaultChronicleNode, plVaultNode ); - - void SetName( const char * text ) { ISetString64_1( text ); } - const char * GetName( void ) const { return IGetString64_1(); } - void SetValue( const char * text ) { ISetText_1( text ); } - const char * GetValue( void ) const { return IGetText_1(); } - void SetEntryType( UInt32 type ) { ISetInt32_1( type ); } - UInt32 GetEntryType( void ) const { return IGetInt32_1(); } - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultPlayerInfoNode : public plVaultNode -{ - mutable plUUID fGuid; // used with GetAgeGuid() only. - -public: - enum FieldMap - { - kPlayerID = kUInt32_1, - kPlayerName = kIString64_1, - kAgeInstanceName = kString64_1, // name of age player is currently in - kAgeInstanceGuid = kString64_2, // guid of age player is currently in - kOnline = kInt32_1, // whether or not player is online - }; - - plVaultPlayerInfoNode(); - ~plVaultPlayerInfoNode(); - CLASSNAME_REGISTER( plVaultPlayerInfoNode ); - GETINTERFACE_ANY( plVaultPlayerInfoNode, plVaultNode ); - - // player ID - void SetPlayerID( UInt32 v ); - UInt32 GetPlayerID( void ) const { return IGetUInt32_1(); } - // player name - void SetPlayerName( const char * text ); - const char * GetPlayerName( void ) const { return IGetIString64_1(); } - // age the player is currently in, if any. - void SetAgeInstanceName( const char * v ); - const char * GetAgeInstanceName( void ) const; - void SetAgeGuid( const plUUID * v); - const plUUID * GetAgeGuid( void ) const; - // online status - void SetOnline( bool b ); - bool IsOnline( void ) const { return IGetInt32_1()!=0; } - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultPlayerInfoListNode : public plVaultFolderNode -{ - void ISortPlayers( plNodeRefCompareProc proc ); - void ILocalNodeAdded( plVaultNodeRef * nodeRef ); - -public: - enum FieldMap - { - }; - - plVaultPlayerInfoListNode(); - ~plVaultPlayerInfoListNode(); - CLASSNAME_REGISTER( plVaultPlayerInfoListNode ); - GETINTERFACE_ANY( plVaultPlayerInfoListNode, plVaultFolderNode ); - bool HasPlayer( UInt32 playerID ); - bool AddPlayer( UInt32 playerID ); - void RemovePlayer( UInt32 playerID ); - plVaultPlayerInfoNode * GetPlayer( UInt32 playerID ); - void SetPlayers( const plVault::IDVec & playerIDs ); - void SortBy( plNodeRefCompareProc proc ) { ISortPlayers( proc ); } - void Sort(); -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultMgrNode : public plVaultNode -{ - friend class plVaultServer; - friend class plVaultConnectTask; - friend class plVNodeMgrInitializationTask; - - mutable plVaultFolderNode * fMyInboxFolder; - mutable plVaultSystemNode * fSystemNode; -public: - enum FieldMap - { - }; - - plVaultMgrNode(); - ~plVaultMgrNode(); - CLASSNAME_REGISTER( plVaultMgrNode ); - GETINTERFACE_ANY( plVaultMgrNode, plVaultNode ); - plVaultFolderNode * GetInbox( void ) const; - plVaultSystemNode * GetSystemNode() const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultPlayerNode : public plVaultMgrNode -{ - mutable plVaultPlayerInfoNode * fPlayerInfo; - mutable plVaultFolderNode * fAvatarOutfitFolder; - mutable plVaultFolderNode * fAvatarClosetFolder; - mutable plVaultFolderNode * fChronicleFolder; - mutable plVaultFolderNode * fAgeJournalsFolder; - mutable plVaultPlayerInfoListNode * fIgnoreListFolder; - mutable plVaultPlayerInfoListNode * fBuddyListFolder; - mutable plVaultPlayerInfoListNode * fPeopleIKnowAboutFolder; - mutable plVaultFolderNode * fAgesICanVisitFolder; - mutable plVaultFolderNode * fAgesIOwnFolder; - mutable plVaultFolderNode * fInviteFolder; - mutable plUUID fAcctUUID; - - plVaultAgeLinkNode * IFindLink( plVaultFolderNode * folder, const plAgeInfoStruct * info ) const; - void IRemoveLink( plVaultFolderNode * folder, const plUUID * guid ); - -public: - enum FieldMap - { - kPlayerName = kIString64_1, - kAvatarShapeName = kString64_1, - kDisabled = kInt32_2, - kOnlineTime = kUInt32_2, // seconds - kAccountUUID = kIString64_2, - }; - - plVaultPlayerNode(); - ~plVaultPlayerNode(); - CLASSNAME_REGISTER( plVaultPlayerNode ); - GETINTERFACE_ANY( plVaultPlayerNode, plVaultMgrNode ); - - plVaultPlayerInfoNode * GetPlayerInfo( void ) const; - plVaultFolderNode * GetAvatarOutfitFolder( void ) const; - plVaultFolderNode * GetAvatarClosetFolder( void ) const; - plVaultFolderNode * GetChronicleFolder( void ) const; - plVaultFolderNode * GetAgeJournalsFolder( void ) const; - plVaultPlayerInfoListNode * GetIgnoreListFolder( void ) const; - plVaultPlayerInfoListNode * GetBuddyListFolder( void ) const; - plVaultPlayerInfoListNode * GetPeopleIKnowAboutFolder( void ) const; - plVaultFolderNode * GetAgesICanVisitFolder( void ) const; - plVaultFolderNode * GetAgesIOwnFolder( void ) const; - plVaultFolderNode * GetInviteFolder( void ) const; - - plVaultAgeLinkNode * GetLinkToMyNeighborhood() const; - plVaultAgeLinkNode * GetLinkToCity() const; - - /////////////// - // Owned ages - plVaultAgeLinkNode * GetOwnedAgeLink( const plAgeInfoStruct * info, bool skipVolatile=false ) const; - void RemoveOwnedAgeLink( const plUUID * guid ); - // Visit ages - plVaultAgeLinkNode * GetVisitAgeLink( const plAgeInfoStruct * info ) const; - void RemoveVisitAgeLink( const plUUID * guid ); - /////////////// - // Chronicle - plVaultChronicleNode * FindChronicleEntry( const char * entryName ); - - // player name - void SetPlayerName( const char * v ); - const char * GetPlayerName( void ) const { return IGetIString64_1(); } - // avatar shape name - void SetAvatarShapeName( const char * v ); - const char * GetAvatarShapeName( void ) const{return IGetString64_1(); } - // disabled? - void SetDisabled( bool v ) { ISetInt32_2( v ); } - bool IsDisabled( void ) const { return IGetInt32_2()!=0; } - // account ID - void SetAccountUUID( const plUUID * v ); - const plUUID * GetAccountUUID( void ) const; - // online time accumulator (plUnifiedTime.GetSecs()) - void SetOnlineTime( UInt32 v ) { ISetUInt32_2( v ); } - UInt32 GetOnlineTime( void ) const { return IGetUInt32_2(); } - void IncOnlineTime( UInt32 v ) { SetOnlineTime( GetOnlineTime()+v ); } - - // override to also save player info node. - void Save( - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultAgeNode : public plVaultMgrNode -{ - mutable plUUID fAgeGuid; - - mutable plVaultAgeInfoNode * fAgeInfo; - mutable plVaultFolderNode * fAgeDevicesFolder; - mutable plVaultFolderNode * fSubAgesFolder; - mutable plVaultPlayerInfoListNode * fPeopleIKnowAboutFolder; - mutable plVaultFolderNode * fChronicleFolder; - // used only with personal ages - mutable plVaultFolderNode * fAgesIOwnFolder; - // used only with nexus age - mutable plVaultFolderNode * fPublicAgesFolder; - - plVaultAgeLinkNode * IGetLink( plVaultFolderNode * folder, const plAgeInfoStruct * info ) const; - -public: - enum FieldMap - { - kAgeGuid = kString64_1, - }; - - plVaultAgeNode(); - ~plVaultAgeNode(); - CLASSNAME_REGISTER( plVaultAgeNode ); - GETINTERFACE_ANY( plVaultAgeNode, plVaultMgrNode ); - - plVaultAgeInfoNode * GetAgeInfo() const; - - plVaultFolderNode * GetAgeDevicesFolder( void ) const; - plVaultFolderNode * GetSubAgesFolder( void ) const; - // age chronicle - plVaultFolderNode * GetChronicleFolder( void ) const; - // People who have published to devices in this age - plVaultPlayerInfoListNode * GetPeopleIKnowAboutFolder( void ) const; - - // PERSONAL AGE SPECIFIC - plVaultFolderNode * GetAgesIOwnFolder( void ) const; - - // NEXUS AGE SPECIFIC - plVaultFolderNode * GetPublicAgesFolder( void ) const; - - // To publish a node to a device, get its device inbox ID, then - // call node->SendTo( deviceInboxID ); - plVaultAgeLinkNode * GetSubAgeLink( const plAgeInfoStruct * info ) const; - - // AGE DEVICES. AKA IMAGERS, WHATEVER. - // Add a new device. - void AddDevice( const char * deviceName, - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - // Remove a device. - void RemoveDevice( const char * deviceName ); - // True if device exists in age. - bool HasDevice( const char * deviceName ); - // Get a device. - plVaultTextNoteNode * GetDevice( const char * deviceName ); - - // age guid - const plUUID * GetAgeGuid() const { fAgeGuid.FromString( IGetString64_1() ); return &fAgeGuid; } - void SetAgeGuid( const plUUID * guid ); - - // Age chronicle - plVaultChronicleNode * FindChronicleEntry( const char * entryName ); - - // override to also save age info node. - void Save( - plVaultOperationCallback * cb=nil, - UInt32 cbContext=0 ); - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultAdminNode : public plVaultMgrNode -{ - mutable plVaultFolderNode * fAllAgeSDLEventInboxesFolder; - -public: - enum FieldMap - { - }; - - plVaultAdminNode(); - ~plVaultAdminNode(); - CLASSNAME_REGISTER( plVaultAdminNode ); - GETINTERFACE_ANY( plVaultAdminNode, plVaultMgrNode ); - - plVaultFolderNode * GetAllAgeSDLEventInboxesFolder( void ) const; - - std::string AsStdString( int level=0 ) const; -}; - - -//////////////////////////////////////////////////////////////////// - -class plVaultMarkerNode : public plVaultNode -{ -public: - enum FieldMap - { - kAgeName = kCreateAgeName, - kMarkerText = kText_1, - kGPSTorans = kInt32_1, - kGPSHSpans = kInt32_2, - kGPSVSpans = kInt32_3, - kMarkerPosX = kUInt32_1, - kMarkerPosY = kUInt32_2, - kMarkerPosZ = kUInt32_3, - }; - - plVaultMarkerNode(); - ~plVaultMarkerNode(); - CLASSNAME_REGISTER(plVaultMarkerNode); - GETINTERFACE_ANY(plVaultMarkerNode, plVaultNode); - - void SetAge(const char* ageName) { ISetCreateAgeName(ageName); } - const char* GetAge() const { return IGetCreateAgeName(); } - - void SetPosition(const hsPoint3& pos); - hsPoint3 GetPosition() const; - - void SetText(const char* text) { ISetText_1(text); } - const char* GetText() const { return IGetText_1(); } - - void SetGPS(Int32 t, Int32 h, Int32 v) { ISetInt32_1(t);ISetInt32_2(h);ISetInt32_3(v); } - Int32 GetGPSTorans() const { return IGetInt32_1(); } - Int32 GetGPSHSpans() const { return IGetInt32_2(); } - Int32 GetGPSVSpans() const { return IGetInt32_3(); } - - std::string AsStdString(int level=0) const; -}; - -//////////////////////////////////////////////////////////////////// - -class plVaultMarkerListNode : public plVaultFolderNode -{ -public: - enum FieldMap - { - kOwnerID = kUInt32_1, - kOwnerName = kString64_2, - kGameType = kInt32_1, - kRoundLength = kInt32_2, - }; - - plVaultMarkerListNode(); - ~plVaultMarkerListNode(); - - CLASSNAME_REGISTER(plVaultMarkerListNode); - GETINTERFACE_ANY(plVaultMarkerListNode, plVaultFolderNode); - - void SetOwnerName( const char * v ) { ISetString64_2( v ); } - const char * GetOwnerName( void ) const{ return IGetString64_2();} - - Int32 GetGameType() const { return IGetInt32_1(); } - void SetGameType( Int32 v ) { ISetInt32_1( v ); } - - Int32 GetRoundLength() const { return IGetInt32_2(); } - void SetRoundLength( Int32 v ) { ISetInt32_2( v ); } - - std::string AsStdString(int level=0) const; - -}; - -//////////////////////////////////////////////////////////////////// - -// -// A node that ALL vault mgrs get - for system wide info -// -class plVaultSystemNode : public plVaultNode -{ - mutable plVaultFolderNode * fGlobalInboxFolder; - -public: - enum FieldMap - { - kCCRAwayStatus = kInt32_1 - }; - - plVaultSystemNode(); - CLASSNAME_REGISTER( plVaultSystemNode); - GETINTERFACE_ANY( plVaultSystemNode, plVaultNode ); - - void SetCCRAwayStatus( bool b) { ISetInt32_1( b); } - int GetCCRAwayStatus( void ) const { return IGetInt32_1();} - - plVaultFolderNode * GetGlobalInbox( void ) const; - - std::string AsStdString( int level=0 ) const; -}; - -//////////////////////////////////////////////////////////////////// -// Vault Server VNode -// Makes sure nodes like AllPlayers exist. - -class plNetVaultServerNode : public plVaultMgrNode -{ - friend class plNetVaultServerInitializationTask; - - mutable plVaultAgeInfoNode * fCityInfo; - UInt32 fAllPlayersFolderID; - UInt32 fAllAgeGlobalSDLNodesFolderID; - UInt32 fPublicAgesFolderID; - -public: - plNetVaultServerNode(); - ~plNetVaultServerNode(); - CLASSNAME_REGISTER( plNetVaultServerNode ); - GETINTERFACE_ANY( plNetVaultServerNode, plVaultMgrNode ); - - UInt32 GetAllPlayersFolderID() const { return fAllPlayersFolderID; } - UInt32 GetAllAgeGlobalSDLNodesFolderID() const { return fAllAgeGlobalSDLNodesFolderID; } - UInt32 GetPublicAgesFolderID() const { return fPublicAgesFolderID; } - - std::string AsStdString( int level=0 ) const; -}; - -#endif // 0 -//============================================================================ -//============================================================================ -//============================================================================ -//============================================================================ - - -#endif // plVaultNode_h_inc - -#endif diff --git a/Sources/Plasma/PythonLib/pyPlasma/creatables.cpp b/Sources/Plasma/PythonLib/pyPlasma/creatables.cpp index deb82618..8468a7b9 100644 --- a/Sources/Plasma/PythonLib/pyPlasma/creatables.cpp +++ b/Sources/Plasma/PythonLib/pyPlasma/creatables.cpp @@ -23,12 +23,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ -#include "../plNetClientComm/plNetClientCommCreatable.h" -#include "../plUnifiedTime/plUnifiedTimeCreatable.h" -#include "../pnKeyedObject/pnKeyedObjectCreatable.h" -#include "../pnNetCommon/pnNetCommonCreatable.h" -#include "../pnMessage/pnMessageCreatable.h" -#include "../plNetMessage/plNetMessageCreatable.h" -#include "../plNetCommon/plNetCommonCreatable.h" -#include "../plVault/plVaultCreatable.h" -#include "../plSDL/plSDLCreatable.h" +#include "plNetClientComm/plNetClientCommCreatable.h" +#include "pnKeyedObject/pnKeyedObjectCreatable.h" +#include "pnNetCommon/pnNetCommonCreatable.h" +#include "pnMessage/pnMessageCreatable.h" +#include "plNetMessage/plNetMessageCreatable.h" +#include "plNetCommon/plNetCommonCreatable.h" +#include "plVault/plVaultCreatable.h" +#include "plSDL/plSDLCreatable.h" diff --git a/Sources/Tools/plFontConverter/plFontConverter.cpp b/Sources/Tools/plFontConverter/plFontConverter.cpp index be9abf1e..bf2e5480 100644 --- a/Sources/Tools/plFontConverter/plFontConverter.cpp +++ b/Sources/Tools/plFontConverter/plFontConverter.cpp @@ -32,18 +32,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "res/resource.h" #include "pnAllCreatables.h" -#include "../plResMgr/plResManager.h" -#include "../plResMgr/plResMgrCreatable.h" -#include "../plResMgr/plResMgrSettings.h" -#include "../plMessage/plResMgrHelperMsg.h" -#include "../plUnifiedTime/plUnifiedTimeCreatable.h" +#include "plResMgr/plResManager.h" +#include "plResMgr/plResMgrCreatable.h" +#include "plResMgr/plResMgrSettings.h" +#include "plMessage/plResMgrHelperMsg.h" REGISTER_CREATABLE(plResMgrHelperMsg); -#include "../plGImage/plFont.h" +#include "plGImage/plFont.h" REGISTER_CREATABLE(plFont); -#include "../plGImage/plBitmap.h" -#include "../plGImage/plMipmap.h" +#include "plGImage/plBitmap.h" +#include "plGImage/plMipmap.h" REGISTER_NONCREATABLE(plBitmap); REGISTER_CREATABLE(plMipmap); diff --git a/Sources/Tools/plResBrowser/plResBrowser.cpp b/Sources/Tools/plResBrowser/plResBrowser.cpp index be002d70..c57fe40f 100644 --- a/Sources/Tools/plResBrowser/plResBrowser.cpp +++ b/Sources/Tools/plResBrowser/plResBrowser.cpp @@ -36,7 +36,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plResMgr/plResManager.h" #include "plResMgr/plResMgrSettings.h" #include "plMessage/plResMgrHelperMsg.h" -#include "plUnifiedTime/plUnifiedTimeCreatable.h" REGISTER_CREATABLE(plResMgrHelperMsg);