Files
Client/GameTools/Zallad3D SceneClass/Z3DMapTok2FileName.cpp
LGram16 dd97ddec92 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>
2025-11-29 20:17:20 +09:00

90 lines
1.8 KiB
C++

// Z3DMapTok2FileName.cpp: implementation of the CZ3DMapTok2FileName class.
//
//////////////////////////////////////////////////////////////////////
#include "Z3DMapTok2FileName.h"
#include "SimpleParser.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CZ3DMapTok2FileName::CZ3DMapTok2FileName()
{
}
CZ3DMapTok2FileName::~CZ3DMapTok2FileName()
{
std::map<Z3DTOK, char* >::iterator it;
for( it = m_mapTok2FileName.begin(); it != m_mapTok2FileName.end(); it++ )
{
SAFE_DELETEA( it->second );
}
}
bool CZ3DMapTok2FileName::Load( const char* szFileName, const char* szFilePath, CZ3DStringTable& rTable )
{
CSimpleParser parser;
if( false == parser.OpenFile( szFileName ) )
{
return false;
}
char* szPrefix = NULL;
long lLength = strlen( szFilePath );
if( '/' != szFilePath[lLength-1] && '\\' != szFilePath[lLength-1] )
{
szPrefix = new char[lLength+2];
sprintf( szPrefix, "%s/", szFilePath );
++lLength;
}
else
{
szPrefix = new char[lLength+1];
strcpy( szPrefix, szFilePath );
}
char* szToken;
char* szStr;
Z3DTOK tok;
while( NULL != (szToken = parser.GetNextToken()) )
{
tok = rTable.Add( szToken );
if( m_mapTok2FileName.end() != m_mapTok2FileName.find(tok) )
{
// Áߺ¹
return false;
}
szToken = parser.GetNextToken();
if( NULL == szToken )
{
return false;
}
szStr = new char[lLength + strlen(szToken) + 1];
sprintf( szStr, "%s%s", szPrefix, szToken );
m_mapTok2FileName[tok] = szStr;
}
SAFE_DELETE( szPrefix );
return true;
}
const char* CZ3DMapTok2FileName::GetFileName( Z3DTOK tok )
{
std::map<Z3DTOK, char* >::iterator it;
it = m_mapTok2FileName.find( tok );
if( it == m_mapTok2FileName.end() )
{
//return NULL;
return "";
}
return it->second;
}