Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
213
GameTools/Zallad3D SceneClass/Z3DChrEventGenerator.cpp
Normal file
213
GameTools/Zallad3D SceneClass/Z3DChrEventGenerator.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
// Z3DChrEventGenerator.cpp: implementation of the CZ3DChrEventGenerator class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Z3DChrEventGenerator.h"
|
||||
#include "SimpleParser.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
std::map< Z3DTOK, std::vector<Z3D_EVENT_ELEMENT>* > CZ3DChrEventGenerator::ms_mapTok2EventData;
|
||||
|
||||
|
||||
bool CZ3DChrEventGenerator::_Load( const char* szFileName )
|
||||
{
|
||||
CSimpleParser parser;
|
||||
Z3DTOK tokFilename, tokEvent;
|
||||
|
||||
if( false == parser.OpenFile(szFileName) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Z3D_EVENT_ELEMENT ee;
|
||||
|
||||
//long lTokenIndex;
|
||||
|
||||
char* szToken = parser.GetNextToken();
|
||||
while( NULL != szToken )
|
||||
{
|
||||
if( 0 == strcmp( ";", szToken ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
tokFilename = g_TokFileName.Add( szToken );
|
||||
if( ms_mapTok2EventData.end() != ms_mapTok2EventData.find(tokFilename) )
|
||||
{
|
||||
return false; // file<6C><65> <20>ߺ<EFBFBD>
|
||||
}
|
||||
|
||||
std::vector<Z3D_EVENT_ELEMENT>* p_vecEventElement = new std::vector<Z3D_EVENT_ELEMENT>;
|
||||
|
||||
szToken = parser.GetNextToken();
|
||||
while( NULL != szToken )
|
||||
{
|
||||
if( 0 == strcmp( ";", szToken ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// optional field <20><> <20>ʱ<EFBFBD>ȭ
|
||||
ee.tokSecondaryEvent = NULL_TOK;
|
||||
ee.lProb_Denominator = 0; // <20>и<EFBFBD><D0B8><EFBFBD> 0<≯<EFBFBD> Ȯ<><C8AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̺<EFBFBD>Ʈ(<28>ù<C3B9>)
|
||||
ee.lProb_Numerator = 0; // <20>ݵ<EFBFBD><DDB5><EFBFBD> 0<><30><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ <20><> <20>ʿ<EFBFBD><CABF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..<2E><>.
|
||||
|
||||
ee.lFrame = aton( szToken );
|
||||
|
||||
if( NULL == (szToken = parser.GetNextToken()) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ee.tokEvent = g_TokEventName.Add( szToken );
|
||||
|
||||
if( NULL == (szToken = parser.GetNextToken()) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( 0 == strcmp( ":", szToken ) ) // secondary event <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
szToken = parser.GetNextToken();
|
||||
ee.tokSecondaryEvent = g_TokEventName.Add( szToken );
|
||||
szToken = parser.GetNextToken(); // <20><><EFBFBD><EFBFBD> <20>ʵ带 <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
if( 0 == strcmp( "/", szToken ) ) // Ȯ<><C8AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
szToken = parser.GetNextToken();
|
||||
ee.lProb_Numerator = aton( szToken );
|
||||
parser.GetNextToken(); // skipping ":"
|
||||
szToken = parser.GetNextToken(); // <20><><EFBFBD><EFBFBD> <20><>ū
|
||||
ee.lProb_Denominator = aton( szToken );
|
||||
szToken = parser.GetNextToken(); // <20><><EFBFBD><EFBFBD> <20>ʵ带 <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
p_vecEventElement->push_back( ee );
|
||||
}
|
||||
|
||||
std::sort( p_vecEventElement->begin(), p_vecEventElement->end() );
|
||||
ms_mapTok2EventData[tokFilename] = p_vecEventElement;
|
||||
|
||||
szToken = parser.GetNextToken();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CZ3DChrEventGenerator::_Close()
|
||||
{
|
||||
std::map< Z3DTOK, std::vector<Z3D_EVENT_ELEMENT>* >::iterator it;
|
||||
|
||||
for( it = ms_mapTok2EventData.begin(); it != ms_mapTok2EventData.end(); it++ )
|
||||
{
|
||||
SAFE_DELETE( it->second );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CZ3DChrEventGenerator::_RetrieveEventDataList( std::map< Z3DTOK, std::vector<Z3D_EVENT_ELEMENT>* >* &pMap )
|
||||
{
|
||||
pMap = &ms_mapTok2EventData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CZ3DChrEventGenerator::CZ3DChrEventGenerator()
|
||||
{
|
||||
m_rp_vecEventData = NULL;
|
||||
m_tokCurrentAniPack = NULL_TOK;
|
||||
}
|
||||
|
||||
CZ3DChrEventGenerator::~CZ3DChrEventGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CZ3DChrEventGenerator::CheckEvent( float fCurrentFrame, float fPrevFrame,
|
||||
std::vector<Z3DTOK> &r_vecEvent, std::vector<Z3DTOK> &r_vecSecondaryEvent )
|
||||
{
|
||||
if( NULL == m_rp_vecEventData )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( fPrevFrame >= fCurrentFrame )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( 0 == m_rp_vecEventData->size() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int lPrevIdx, lCurrentIdx;
|
||||
|
||||
for( lPrevIdx = 0; lPrevIdx < m_rp_vecEventData->size(); ++lPrevIdx )
|
||||
{
|
||||
if( float((*m_rp_vecEventData)[lPrevIdx].lFrame) > fPrevFrame )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( lCurrentIdx = m_rp_vecEventData->size() - 1; 0 <= lCurrentIdx; --lCurrentIdx )
|
||||
{
|
||||
if( float((*m_rp_vecEventData)[lCurrentIdx].lFrame) <= fCurrentFrame )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( lPrevIdx > lCurrentIdx )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
r_vecEvent.clear();
|
||||
r_vecSecondaryEvent.clear();
|
||||
for( int i = lPrevIdx; i <= lCurrentIdx; ++i )
|
||||
{
|
||||
if( (*m_rp_vecEventData)[i].lProb_Denominator )
|
||||
{
|
||||
// Ȯ<><C8AE> ó<><C3B3>
|
||||
if( (rand() % (*m_rp_vecEventData)[i].lProb_Denominator) <
|
||||
(*m_rp_vecEventData)[i].lProb_Numerator )
|
||||
{
|
||||
r_vecEvent.push_back( (*m_rp_vecEventData)[i].tokEvent );
|
||||
r_vecSecondaryEvent.push_back( (*m_rp_vecEventData)[i].tokSecondaryEvent );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ȯ<><C8AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>( <20><><EFBFBD><EFBFBD><EFBFBD>ǹ<C7B9> )
|
||||
r_vecEvent.push_back( (*m_rp_vecEventData)[i].tokEvent );
|
||||
r_vecSecondaryEvent.push_back( (*m_rp_vecEventData)[i].tokSecondaryEvent );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CZ3DChrEventGenerator::SetTokAniPack( Z3DTOK tokFileName )
|
||||
{
|
||||
std::map< Z3DTOK, std::vector<Z3D_EVENT_ELEMENT>* >::iterator it;
|
||||
|
||||
if( ms_mapTok2EventData.end() == (it = ms_mapTok2EventData.find(tokFileName)) )
|
||||
{
|
||||
m_rp_vecEventData = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rp_vecEventData = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Z3DTOK CZ3DChrEventGenerator::GetTokAniPack()
|
||||
{
|
||||
return m_tokCurrentAniPack;
|
||||
}
|
||||
Reference in New Issue
Block a user