rendered paste bodyvoid CWorldServer::LoadNPCData( )
{
FILE* fh;
char tmpfield[512];
unsigned entrycount;
if ( fopen_s( &fh, "data\\NPCPOS.DAT", "rb" ) != 0 ) {
Log( MSG_ERROR, "Could not load DAT 'data\\NPCPOS.DAT'" );
return;
}else{
fseek( fh, 4, SEEK_SET );
fread( &entrycount, 4, 1, fh );
for( unsigned i = 0; i < entrycount; i++ ) {
fread( &tmpfield, 18, 1, fh );
CNPC* thisnpc = new CNPC( );
thisnpc->clientid = GetNewClientID( );
thisnpc->type = *((unsigned short*)&tmpfield[0]);
thisnpc->chatid = *((unsigned short*)&tmpfield[2]);
thisnpc->posMap = *((unsigned short*)&tmpfield[4]);
thisnpc->pos.x = *((float*)&tmpfield[6]);
thisnpc->pos.y = *((float*)&tmpfield[10]);
thisnpc->dir = *((float*)&tmpfield[14]);
rwmNPCList.acquireWriteLock( );
NPCList.push_back( thisnpc );
rwmNPCList.releaseWriteLock( );
}
fclose( fh );
}
}
void CWorldServer::LoadSpawnData( )
{
FILE* fh;
char tmpfield[512];
unsigned entrycount;
if ( fopen_s( &fh, "data\\SPWNZNS.DAT", "rb" ) != 0 ) {
Log( MSG_ERROR, "Could not load DAT 'data\\SPWNZNS.DAT'" );
return;
}else{
fseek( fh, 4, SEEK_SET );
fread( &entrycount, 4, 1, fh );
for( unsigned i = 0; i < entrycount; i++ ) {
fread( &tmpfield, 10, 1, fh );
CSpawnArea* thisspawn = new CSpawnArea();
thisspawn->type = *((unsigned short*)&tmpfield[0]);
thisspawn->respawntime = *((unsigned short*)&tmpfield[2]);
thisspawn->maxcount = *((unsigned short*)&tmpfield[4]);
thisspawn->map = *((unsigned short*)&tmpfield[6]);
thisspawn->pcount = *((unsigned short*)&tmpfield[8]);
thisspawn->points = new fPoint[ thisspawn->pcount ];
for( unsigned j = 0; j < thisspawn->pcount; j++ ) {
fread( &tmpfield, 8, 1, fh );
thisspawn->points[j].x = *((float*)&tmpfield[0]);
thisspawn->points[j].y = *((float*)&tmpfield[4]);
}
rwmNPCList.acquireWriteLock( );
SpawnList.push_back( thisspawn );
rwmNPCList.releaseWriteLock( );
}
fclose( fh );
}
}