#include "StdAfx.h" #include ".\communityscript.h" #include "FileLoader.h" #include "Tokenizer.h" cCommunityScript* cCommunityScript::mpCommunityScript = NULL; cCommunityScript::cCommunityScript() { mpCommunityScript = this; } cCommunityScript::~cCommunityScript() { Release(); } void cCommunityScript::Release() { cComHashMap::cIterator iter; for(iter = mComSkillMap.Begin() ; iter != mComSkillMap.End() ; ++iter) { delete (sCommunitySkillInfo*)(*iter).mSecond; } mComSkillMap.Clear(); } bool cCommunityScript::Init() { Release(); /// script load #ifdef _CLIENT if( CommunitySkillScriptLoad_Client() == false ) #else if( CommunitySkillScriptLoad_Server() == false ) #endif { assert(0); return false; } return true; } #ifdef _CLIENT bool cCommunityScript::CommunitySkillScriptLoad_Client() { cFileLoader loader; cString pathName = "./Script/resource/CommunitySkillList.txt"; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load CommunitySkillList.txt" ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; sCommunitySkillInfo* pInfo = 0; while( tokenizer.IsEnd() == false ) { pInfo = new sCommunitySkillInfo; /// ºÐ·ù ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mIndex = str.ToInt(); /// ŸÀÔ 0:»ýȰ, 1:°¨Á¤ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mType = static_cast(str.ToInt()); /// type¿¡ µû¸¥ ¸í·É¾î Á¾·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mRoleIndex = str.ToInt(); /// ½ºÅ³Ã¢ Ç¥½Ã ¾ÆÀÌÄÜ ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mIconIndex = str.ToInt(); /// äÆÃ ¸í·É¾î À妽º ( interface msg ) for( unsigned int i=0; i<5; i++ ) { if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mCommandIndex[i] = str.ToInt(); } /// ÅøÆÁ À妽º ( tooltip msg ) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mTooltipIndex = str.ToInt(); /// ¾ÆÀÌÄÜ Ç¥½Ã À§Ä¡ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mPosX = str.ToInt(); if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mPosY = str.ToInt(); for( unsigned int i=0;imAnimationTime[i] = str.ToFloat(); } /// º¸°ü¼Ò ÀúÀå if( mComSkillMap.Insert( pInfo->mIndex, pInfo ) == false ) { assert(0); goto ERR; } } return true; ERR: delete pInfo; return false; } #endif bool cCommunityScript::CommunitySkillScriptLoad_Server() { cFileLoader loader; cString pathName = "./Script/resource/CommunitySkillList.txt"; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load CommunitySkillList.txt" ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; sCommunitySkillInfo* pInfo = 0; while( tokenizer.IsEnd() == false ) { pInfo = new sCommunitySkillInfo; /// ºÐ·ù ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mIndex = str.ToInt(); /// ŸÀÔ 0:»ýȰ, 1:°¨Á¤ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } pInfo->mType = static_cast(str.ToInt()); // skip value ////////////////////////////////////////////////////////////////////////// /// type¿¡ µû¸¥ ¸í·É¾î Á¾·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// ½ºÅ³Ã¢ Ç¥½Ã ¾ÆÀÌÄÜ ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// äÆÃ ¸í·É¾î À妽º ( interface msg ) for( unsigned int i=0; i<5; i++ ) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// ÅøÆÁ À妽º ( tooltip msg ) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// ¾ÆÀÌÄÜ Ç¥½Ã À§Ä¡ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } if( tokenizer.GetNext( &str ) == false ) { goto ERR; } ////////////////////////////////////////////////////////////////////////// for( unsigned int i=0;imAnimationTime[i] = str.ToFloat(); } /// º¸°ü¼Ò ÀúÀå if( mComSkillMap.Insert( pInfo->mIndex, pInfo ) == false ) { assert(0); goto ERR; } } return true; ERR: delete pInfo; return false; }