Files
Client/Server/AdminTool/AdminToolClient/CharacterDoc.h
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

250 lines
6.1 KiB
C++

#ifndef _CHARACTER_DOC_H_
#define _CHARACTER_DOC_H_
#include <Pattern/Singleton.h>
#include <Character/ModifyCharacter.h>
#include <DBComponent/RYL_GameDB.h>
class CCharacterDoc : public CStaticSingleton<CCharacterDoc>
{
public:
#pragma pack(1)
// 캐릭터 찾기 기본정보
struct In_CharacterIndex
{
TCHAR m_szCharName[16]; // 캐릭터 이름
unsigned long m_UID; // 캐릭터 UID
unsigned long m_CID; // 캐릭터 CID
};
// 1개의 서버군이 가지고있는 캐릭터
struct In_ServerCharacter
{
unsigned long dwServerGroup; // 서버군 Index
unsigned char dwCharCount; // 등록되어있는 캐릭터
In_CharacterIndex CharIdx[CGameDB::MAX_CHAR_SLOT]; // 캐릭터 정보
};
// 필요한 항목이 있으면 여기에 계속 추가하면서 작업한다.
struct CharDocInfo // MDI에서 1개의 View는 CCharDocInfo의 내용을 통해서 정보를 구성한다.
{
typedef std::list<In_ServerCharacter> isListCharIdx;
enum STATE
{
EMPTY, // 아무런 작업을 하지 않는 캐릭터
LOADING, // 로딩중인 캐릭터
FINISH // 로딩이 완료된 캐릭터
};
unsigned char m_cCharacterState;
CDocument* m_ModifyDocument;
bool m_bLoaded;
unsigned long m_dwDocKey;
isListCharIdx m_listTreeInfo; // 트리 컨트롤에서 사용하게될 데이터
CModifyCharacter* m_ModifyCharacter; // 현재 작업중인 캐릭터데이터
unsigned char m_cOldServerGroup; // Part2Selectable 타입일때 참조
CharDocInfo()
: m_ModifyCharacter(NULL)
, m_bLoaded(false)
, m_ModifyDocument(NULL)
, m_cCharacterState(EMPTY) {}
// 지지하게 new, delete 쓰지말고 왠만하면 이놈을 쓰자...
void ReleaseCharacter()
{
if(m_ModifyCharacter)
{
delete m_ModifyCharacter;
m_ModifyCharacter = NULL;
}
}
In_CharacterIndex* GetSrvChar(unsigned long dwServer, unsigned long dwCID)
{
isListCharIdx::iterator pos = m_listTreeInfo.begin();
while(pos != m_listTreeInfo.end())
{
if((*pos).dwServerGroup == dwServer)
{
for(int search = 0; (*pos).dwCharCount > search; search++)
{
if((*pos).CharIdx[search].m_CID == dwCID)
{
return ((*pos).CharIdx + search);
}
}
}
}
return NULL;
}
CModifyCharacter* Createcharacter()
{
ReleaseCharacter();
if(NULL == m_ModifyCharacter)
{
m_ModifyCharacter = new CModifyCharacter;
}
return m_ModifyCharacter;
}
~CharDocInfo()
{
m_listTreeInfo.clear();
if(NULL != m_ModifyCharacter)
{
delete m_ModifyCharacter;
}
}
};
struct Zone
{
enum
{
MAX_NAME = 100,
};
TCHAR m_szName[MAX_NAME];
unsigned char m_Zone;
float m_fPosX;
float m_fPosZ;
};
struct ZoneList
{
typedef std::vector<Zone> vecZoneList;
vecZoneList ZoneInfo;
void Serialize_In(char* Out_Data)
{
unsigned long* dwSize = reinterpret_cast<unsigned long*>(Out_Data);
unsigned char* cRowCount = reinterpret_cast<unsigned char*>(Out_Data + sizeof(unsigned long));
char* cDataBody = static_cast<char*>(Out_Data + sizeof(unsigned long) + sizeof(unsigned char));
ZoneInfo.clear();
for(unsigned char cnt = 0; cnt < *cRowCount; ++cnt)
{
Zone* Data = reinterpret_cast< Zone* >( cDataBody + ( cnt * sizeof( Zone ) ) );
ZoneInfo.push_back( *Data );
}
}
bool Serialize_Out( char* In_Data, unsigned short& wLength )
{
unsigned long* dwSize = reinterpret_cast< unsigned long* > ( In_Data );
unsigned char* cRowCount = reinterpret_cast< unsigned char* > ( In_Data + sizeof( unsigned long ) );
char* cDataBody = static_cast< char* > ( In_Data + sizeof( unsigned long ) + sizeof( unsigned char ) );
unsigned char cCount = 0;
unsigned short wBufferLength = wLength;
vecZoneList::iterator pos = ZoneInfo.begin( );
wLength = sizeof( unsigned long ) + sizeof( unsigned char );
wBufferLength ++;
while( pos != ZoneInfo.end( ) )
{
if( wBufferLength < ( wLength + sizeof( Zone ) ) ) return false;
CopyMemory( ( cDataBody + ( cCount * sizeof( Zone ) ) ), &(*pos), sizeof( Zone ) ); wLength += sizeof( Zone );
++cCount;
++pos;
}
*cRowCount = cCount;
*dwSize = ( unsigned long )wLength;
return true;
}
bool Erase( TCHAR* szName )
{
vecZoneList::iterator begin = ZoneInfo.begin( );
while( begin != ZoneInfo.end( ) )
{
Zone& stZone = ( *begin );
if( !_tcsicmp( szName, stZone.m_szName ) )
{
ZoneInfo.erase( begin );
return true;
}
else
{
++begin;
}
}
return false;
}
vecZoneList::iterator Find( TCHAR* szName )
{
vecZoneList::iterator begin = ZoneInfo.begin( );
while( begin != ZoneInfo.end( ) )
{
if( false == _tcsicmp( szName, ( *begin ).m_szName ) )
{
return begin;
}
++begin;
}
return ZoneInfo.end( );
}
};
struct ServerInfo
{
CString m_strServerName;
unsigned long m_dwServerIndex;
ServerInfo(CString strServerName, unsigned long dwServerIndex)
: m_strServerName(strServerName), m_dwServerIndex(dwServerIndex) {}
};
#pragma pack()
typedef std::list<ServerInfo> islistServerInfo;
typedef std::map<unsigned long, CharDocInfo*> isMapDoc;
typedef islistServerInfo::iterator listServerInfoPos;
public:
CCharacterDoc ( ) : m_dwKey( 0 ) {}
~CCharacterDoc ( );
void Destroy();
unsigned long NextKey ( ) { return m_dwKey + 1; }
unsigned long PushCharDocInfo ( CharDocInfo* lpCharDocInfo );
CharDocInfo* GetCharDocInfo ( unsigned long dwKey );
bool DeleteCharDocInfo ( unsigned long dwKey );
void PushServerGroup ( CString strServerName, unsigned long dwServerIndex );
bool GetServerIndex ( CString strServerName, unsigned long& dwServerIndex );
bool GetServerName ( unsigned long dwServerGroup, CString& strServerName );
listServerInfoPos GetServerInfoBegin ( ) { return m_listServerInfo.begin( ); }
listServerInfoPos GetServerInfoEnd ( ) { return m_listServerInfo.end( ); }
ZoneList& GetZoneList ( ) { return m_ZoneList; }
private:
unsigned long m_dwKey;
isMapDoc m_mapCharDoc;
islistServerInfo m_listServerInfo;
ZoneList m_ZoneList;
};
#endif