#include "StdAfx.h" #include "TotemScript.h" #include "Totem_Common.h" #include "Token.h" #include "Parser.h" #include "Lexer.h" #include "./util/FileLoader.h" #include "./util/Tokenizer.h" #include "./client/ResourceManager.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" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); 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; } else { // ¿¬Ãâ ÆÄÀÏ ·Îµù ·çƾ Ãß°¡ [12/14/2009 Jo_Client] cString path; path.Format( "./Data/Effect/%s", pList->mFileName.Cstr() ); if( RESOURCEMAN->LoadNIF( path, false ) == false ) { cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to load nif", MB_OK | MB_ICONERROR ); } } } return true; ERR: delete pList; cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parse", MB_OK | MB_ICONERROR ); return false; } sTotemScript* cTotemScript::GetTotemInfo( unsigned long totemIdx ) { return (sTotemScript*)mpTotemMap->GetAt( totemIdx ); }