#include "StdAfx.h" #include "TotemScript.h" #include "Totem_Common.h" #include "Token.h" #include "Parser.h" #include "Lexer.h" #include "FileLoader.h" #include "Tokenizer.h" cTotemScript* cTotemScript::mpTotemScript = NULL; cTotemScript::cTotemScript(void) { /// ½Ì±ÛÅæ if( mpTotemScript ) { assert(NULL); } else { mpTotemScript = this; } mpTotemMap = new cPointHashMap( 100 ); } bool cTotemScript::Init( ) { /// ÅäÅÛ Á¤º¸ ·Îµå if( !LoadTotemList() ) { assert(NULL); return false; } return true; } void cTotemScript::Release() { if( mpTotemMap ) { cPointHashMap::cIterator k = mpTotemMap->Begin(); cPointHashMap::cIterator kend = mpTotemMap->End(); for( ; k != kend; ++k ) { delete (sTotemScript*)(k->mSecond); } mpTotemMap->Clear(); delete mpTotemMap; mpTotemMap = 0; } } bool cTotemScript::LoadTotemList() { cFileLoader loader; cString pathName = "./Script/Resource/SkillList_Trap.txt"; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load TotemList.txt" ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; sTotemScript* pList = NULL; while( tokenizer.IsEnd() == false ) { pList = new sTotemScript; /// ÅäÅÛ °íÀ¯¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mTotemIdx = str.ToInt(); /// Àû¿ë È¿°ú ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mInfluenceIdx = str.ToInt(); /// ¿¬ÃâÆÄÀϸí if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mFileName = str; /// Á¾¼Ó/ºñÁ¾¼Ó ¿©ºÎ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mDependent = str.ToInt() == 0 ? true : false; /// À¯Áö½Ã°£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mContinuanceTime = str.ToInt(); /// Àû¿ëÁÖ±â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mApplyTime = str.ToInt(); /// À¯Áö°Å¸® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mAttackerRange = (unsigned short)str.ToInt(); /// Àû¿ë¹üÀ§1 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mApplyRange1 = (unsigned short)str.ToInt(); /// Àû¿ë¹üÀ§2 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pList->mApplyRange2 = (unsigned short)str.ToInt(); /// ÇØ½¬¿¡ ¸ó½ºÅÍ º°·Î ±â·Ï if( mpTotemMap->Insert( pList->mTotemIdx, pList ) == false ) { assert(0); goto ERR; } } return true; ERR: delete pList; return false; } sTotemScript* cTotemScript::GetTotemInfo( unsigned long totemIdx ) { return (sTotemScript*)mpTotemMap->GetAt( totemIdx ); }