diff --git a/src/EterGrnLib/ThingInstance.cpp b/src/EterGrnLib/ThingInstance.cpp index a418584..765c4bf 100644 --- a/src/EterGrnLib/ThingInstance.cpp +++ b/src/EterGrnLib/ThingInstance.cpp @@ -534,7 +534,7 @@ void CGraphicThingInstance::RegisterMotionThing(DWORD dwMotionKey, CGraphicThing { CGraphicThing::TRef * pMotionRef = new CGraphicThing::TRef; pMotionRef->SetPointer(pMotionThing); - m_roMotionThingMap.insert(std::map::value_type(dwMotionKey, pMotionRef)); + m_roMotionThingMap.insert(std::make_pair(dwMotionKey, pMotionRef)); } void CGraphicThingInstance::ResetLocalTime() diff --git a/src/GameLib/RaceManager.cpp b/src/GameLib/RaceManager.cpp index 11d43ee..073e623 100644 --- a/src/GameLib/RaceManager.cpp +++ b/src/GameLib/RaceManager.cpp @@ -3,6 +3,8 @@ #include "RaceMotionData.h" #include "PackLib/PackManager.h" +bool CRaceManager::s_bPreloaded = false; + bool __IsGuildRace(unsigned race) { if (race >= 14000 && race < 15000) @@ -448,3 +450,46 @@ CRaceManager::~CRaceManager() { Destroy(); } + +void CRaceManager::PreloadPlayerRaceMotions() +{ + if (s_bPreloaded) + return; + + // Preload all player races (0-7) + for (DWORD dwRace = 0; dwRace <= 7; ++dwRace) + { + CRaceData* pRaceData = NULL; + if (!Instance().GetRaceDataPointer(dwRace, &pRaceData)) + continue; + + CRaceData::TMotionModeDataIterator itor; + + if (pRaceData->CreateMotionModeIterator(itor)) + { + do + { + CRaceData::TMotionModeData* pMotionModeData = itor->second; + + CRaceData::TMotionVectorMap::iterator itorMotion = pMotionModeData->MotionVectorMap.begin(); + for (; itorMotion != pMotionModeData->MotionVectorMap.end(); ++itorMotion) + { + const CRaceData::TMotionVector& c_rMotionVector = itorMotion->second; + CRaceData::TMotionVector::const_iterator it; + + for (it = c_rMotionVector.begin(); it != c_rMotionVector.end(); ++it) + { + CGraphicThing* pMotion = it->pMotion; + if (pMotion) + { + pMotion->AddReference(); + } + } + } + } + while (pRaceData->NextMotionModeIterator(itor)); + } + } + + s_bPreloaded = true; +} diff --git a/src/GameLib/RaceManager.h b/src/GameLib/RaceManager.h index bdb0fbe..88fb01d 100644 --- a/src/GameLib/RaceManager.h +++ b/src/GameLib/RaceManager.h @@ -29,6 +29,9 @@ class CRaceManager : public CSingleton BOOL GetRaceDataPointer(DWORD dwRaceIndex, CRaceData ** ppRaceData); + // Race motion preloading + static void PreloadPlayerRaceMotions(); + static bool IsPreloaded() { return s_bPreloaded; } protected: CRaceData* __LoadRaceData(DWORD dwRaceIndex); @@ -46,4 +49,5 @@ class CRaceManager : public CSingleton private: std::string m_strPathName; CRaceData * m_pSelectedRaceData; + static bool s_bPreloaded; }; \ No newline at end of file diff --git a/src/UserInterface/PythonCharacterManagerModule.cpp b/src/UserInterface/PythonCharacterManagerModule.cpp index 5549755..e1d6690 100644 --- a/src/UserInterface/PythonCharacterManagerModule.cpp +++ b/src/UserInterface/PythonCharacterManagerModule.cpp @@ -713,6 +713,12 @@ PyObject * chrmgrIsPossibleEmoticon(PyObject* poSelf, PyObject* poArgs) return Py_BuildValue("i", result); } +PyObject * chrmgrPreloadRaceMotions(PyObject* poSelf, PyObject* poArgs) +{ + CRaceManager::PreloadPlayerRaceMotions(); + return Py_BuildNone(); +} + void initchrmgr() { static PyMethodDef s_methods[] = @@ -746,6 +752,7 @@ void initchrmgr() { "SetAffect", chrmgrSetAffect, METH_VARARGS }, { "SetEmoticon", chrmgrSetEmoticon, METH_VARARGS }, { "IsPossibleEmoticon", chrmgrIsPossibleEmoticon, METH_VARARGS }, + { "PreloadRaceMotions", chrmgrPreloadRaceMotions, METH_VARARGS }, { "RegisterEffect", chrmgrRegisterEffect, METH_VARARGS }, { "RegisterCacheEffect", chrmgrRegisterCacheEffect, METH_VARARGS }, { "RegisterPointEffect", chrmgrRegisterPointEffect, METH_VARARGS },