288 lines
8.8 KiB
C++
288 lines
8.8 KiB
C++
#include "stdafx.h"
|
|
#include "SElementParser.h"
|
|
//#include "Util.h"
|
|
#include "SStringDB.h"
|
|
#include "SItemDB.h"
|
|
#include "SSkillDB.h"
|
|
#include "SMonsterDB.h"
|
|
#include "QuestBase.h"
|
|
#include <toolkit/nsl.h>
|
|
#include <toolkit/nslreg.h>
|
|
#include <toolkit/bits_scramble.h>
|
|
#include <toolkit/XStringUtil.h>
|
|
#include "SQuestMgr.h"
|
|
#include "STitleMgr.h"
|
|
|
|
std::string cElementParser::parsing(char const* strFormat, bool addMobNameDiff)
|
|
{
|
|
std::string strString = strFormat;
|
|
std::vector< std::string > storage;
|
|
std::string strResult;
|
|
|
|
// { #@num:숫자@# 을 숫자로 바꾼다.
|
|
for( ; nsl::regex::match( "#@num:([r0-9]*)@#", strString.c_str(), &storage ); storage.clear() )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
// { 해당 필드의 숫자로 변환함
|
|
int nIndex = getValue(strTo.c_str());
|
|
strTo = CStringUtil::StringFormat( "%d", nIndex );
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
// { #@m_name:숫자@# 를 몬스터 이름으로 바꾼다.
|
|
storage.clear();
|
|
while( nsl::regex::match( "#@m_name:([r0-9]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
std::string getString;
|
|
if( getMonsterName(strTo.c_str(), getString) == false )
|
|
break;
|
|
|
|
/// 2011.12.12 - prodongi
|
|
if (addMobNameDiff)
|
|
strTo += "_";
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, getString );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
// { #@m_location:숫자@# 를 몬스터 지역 이름으로 바꾼다.
|
|
storage.clear();
|
|
while( nsl::regex::match( "#@m_location:([r0-9]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
// { 인덱스 얻어옴
|
|
ENC_INT code = bits_scramble< int, 3 > ( getValue(strTo.c_str()) );
|
|
// }
|
|
|
|
// { 몬스터 지역 이름 얻어옴
|
|
_MONSTER_INFO_FILE *pPtr = GetMonsterDB().GetMonsterData( code );
|
|
if( pPtr == NULL )
|
|
{
|
|
//무엇인가로 표시 ㅡ,.ㅡ
|
|
strTo = GetStringDB().GetString( 88 );
|
|
}
|
|
else
|
|
{
|
|
// 변경 적용 되기 전까지 주석처리.
|
|
strTo = GetStringDB().GetString( pPtr->respawn_name_id );
|
|
// }
|
|
}
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
// { #@status:숫자@# 를 상황으로 바꾼다.
|
|
storage.clear();
|
|
while( nsl::regex::match( "#@status:([0-9]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
// { 인덱스 얻어옴
|
|
int nIndex = atoi( strTo.c_str() ) - 1;
|
|
int nStatus = getStatus(nIndex);
|
|
|
|
//임시코드.. 수락하지 않는 몬스터의 -1을 막는다. 2009.12.21 sfreer
|
|
if(nStatus<0)
|
|
nStatus = 0;
|
|
|
|
XStringUtil::Format( strTo, "%d", nStatus );
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
// { #@i_name:숫자@# 를 아이템 이름으로 바꾼다.
|
|
storage.clear();
|
|
while( nsl::regex::match( "#@i_name:([r0-9]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
// { 인덱스 얻어옴
|
|
int nIndex = getValue(strTo.c_str());
|
|
strTo = GetStringDB().GetString( GetItemDB().GetItemData( nIndex )->nNameId );
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
// { #@s_name:숫자@# 를 스킬 이름으로 바꾼다.
|
|
storage.clear();
|
|
while( nsl::regex::match( "#@s_name:([r0-9]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
// { 인덱스 얻어옴
|
|
int nIndex = getValue(strTo.c_str());
|
|
SkillBase *pBase = GetSkillDB().GetSkillData( nIndex );
|
|
if( pBase ) strTo = GetStringDB().GetString( pBase->GetNameID() );
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
|
|
// { #@status_숫자=숫자:문자열@# 을 적절히 표시하자
|
|
while( nsl::regex::match( "#@status_([0-9]*)=([0-9]*):([^@#]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom= storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strIndex= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
std::string strNum= storage[2]; //( strString.c_str() + storage[2].nStart, strString.c_str() + storage[2].nEnd ); // 숫자
|
|
std::string strTarget= storage[3]; //( strString.c_str() + storage[3].nStart, strString.c_str() + storage[3].nEnd ); // 바꿀 문자
|
|
std::string strTo;
|
|
|
|
// { 인덱스 얻어옴
|
|
int nIndex = atoi( strIndex.c_str() );
|
|
int nTrigger = atoi( strNum.c_str() );
|
|
int nStatus = getStatus(nIndex);
|
|
if( nTrigger == nStatus ) strTo = strTarget;
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
// }
|
|
|
|
/// 2010.11.29 - prodongi
|
|
storage.clear();
|
|
while( nsl::regex::match( "#@t_name:([r0-9]*)@#", strString.c_str(), &storage ) )
|
|
{
|
|
// 바꿔야할 태그와 숫자부분을 얻어냄
|
|
std::string strFrom = storage[0]; //( strString.c_str() + storage[0].nStart, strString.c_str() + storage[0].nEnd ); // 전체 태그
|
|
std::string strTo= storage[1]; //( strString.c_str() + storage[1].nStart, strString.c_str() + storage[1].nEnd ); // 숫자
|
|
|
|
// { 인덱스 얻어옴
|
|
int nIndex = getValue(strTo.c_str());
|
|
if (0 < nIndex) strTo = GetStringDB().GetString( nIndex );
|
|
// }
|
|
|
|
// 문자열 바꿈
|
|
CStringUtil::ReplacePhrase( strString, strFrom, strTo );
|
|
|
|
// regex 결과 지우고 계속 실행
|
|
storage.clear();
|
|
}
|
|
|
|
return strString;
|
|
}
|
|
|
|
int cElementQuestParser::getValue(char const* value)
|
|
{
|
|
if (!value)
|
|
return 0;
|
|
if (!m_quest)
|
|
return 0;
|
|
|
|
if( value && value[0] && value[0] == 'r' )
|
|
{
|
|
int nIndex = atoi( &value[1] ) - 1;
|
|
assert( nIndex >=0 && nIndex <= QuestInstance::MAX_RANDOM_VALUE );
|
|
return SQuestMgr::GetInstance().GetQuestRandomValue( m_quest->nCode, nIndex );
|
|
}
|
|
else
|
|
{
|
|
int nIndex = atoi( value ) - 1;
|
|
assert( nIndex >=0 && nIndex <= QuestBase::MAX_VALUE_NUMBER );
|
|
return m_quest->nValue[nIndex];
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int cElementQuestParser::getStatus(int index)
|
|
{
|
|
return SQuestMgr::GetInstance().GetQuestStatus( m_quest->nCode, index );
|
|
}
|
|
|
|
bool cElementQuestParser::getMonsterName(const char *value, std::string &str)
|
|
{
|
|
// { 인덱스 얻어옴
|
|
ENC_INT code = bits_scramble< int, 3 > ( getValue(value) );
|
|
// }
|
|
|
|
// { 몬스터 이름 얻어옴
|
|
int nTextID = GetMonsterDB().GetTextID( code );
|
|
|
|
if( nTextID == -1 )
|
|
return false;
|
|
else
|
|
{
|
|
str = GetStringDB().GetString( nTextID );
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool cElementTitleParser::getMonsterName(const char *value, std::string &str)
|
|
{
|
|
int code = getValue(value);
|
|
if(code == -1)
|
|
return false;
|
|
else
|
|
{
|
|
str = GetStringDB().GetString(code);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
int cElementTitleParser::getValue(char const* str)
|
|
{
|
|
return STitleMgr::GetInstance().GetTitleValue(m_ConditionTypeID);
|
|
}
|
|
|
|
int cElementTitleParser::getStatus(int index)
|
|
{
|
|
return 0;
|
|
}
|
|
|