das ist die datei da ist es nicht alles auscommentiert aber sobald ich kalgas betrette crasht mir der world server ohne errors nur mit einem runtime error die anderen dateien aus der source habe ich mal beigefügt vieleicht sieht jemand ein fehler ich danke im vorraus
Partydungeon.lua
--------------------------------------------------------------------
dofile( ".\\LuaFunc\\InstanceDungeonBase.lua" ) --
--------------------------------------------------------------------
AddDungeon( "WI_INSTANCE_KALGAS" )
--{
SetClass( CLASS_LEGEND_HERO )
SetLevel( 135, 200 )
SetCoolTime( MIN(240) )
SetMonster( ID_NORMAL, "MI_KALGASSTELE01", false, 2808, 303, 801 )
SetMonster( ID_NORMAL, "MI_KALGASSTELE02", false, 1944, 303, 356 )
SetMonster( ID_MIDBOSS, "MI_KALGASEGG01", false, 966, 100, 192 )
SetMonster( ID_MIDBOSS, "MI_KALGASEGG01", false, 984, 100, 194 )
SetMonster( ID_MIDBOSS, "MI_KALGASEGG01", false, 983, 100, 213 )
SetMonster( ID_MIDBOSS, "MI_KALGASEGG01", false, 961, 100, 210 )
SetMonster( ID_BOSS, "MI_KALGASBOSS", true, 974, 103, 201 )
--}
AddDungeon( "WI_INSTANCE_OMINOUS" )
--{
SetClass( CLASS_NORMAL, CLASS_MASTER )
SetLevel( 1, 120 )
SetCoolTime( MIN(240) )
SetMonster( ID_NORMAL, "MI_PRICKANT04", true, 1280, 101, 1640 )
SetMonster( ID_NORMAL, "MI_MAULMOUSE04", true, 1234, 101, 1393 )
SetMonster( ID_NORMAL, "MI_CRIPESCENTIPEDE04", true, 1089, 101, 1590 )
SetMonster( ID_MIDBOSS, "MI_LYCANOS01", true, 1078, 101, 1359 )
SetMonster( ID_BOSS, "MI_VEMPAIN01", true, 1079, 101, 1457 )
--}
AddDungeon( "WI_INSTANCE_OMINOUS_1" )
--{
SetClass( CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 121, 200 )
SetCoolTime( MIN(240) )
SetMonster( ID_NORMAL, "MI_PRICKANT04_1", true, 1280, 101, 1640 )
SetMonster( ID_NORMAL, "MI_MAULMOUSE04_1", true, 1234, 101, 1393 )
SetMonster( ID_NORMAL, "MI_CRIPESCENTIPEDE04_1", true, 1089, 101, 1590 )
SetMonster( ID_MIDBOSS, "MI_LYCANOS01_1", true, 1078, 101, 1359 )
SetMonster( ID_BOSS, "MI_VEMPAIN01_1", true, 1079, 101, 1457 )
--}
AddDungeon( "WI_INSTANCE_DREADFULCAVE" )
--{
SetClass( CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 121, 200 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE01", false, 928, 101, 198 )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE02", false, 1504, 101, 419 )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE03", false, 1397, 101, 893 )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE04", false, 764, 101, 867 )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE05", false, 675, 101, 560 )
SetMonster( ID_BOSS, "MI_SKELDEVIL", true, 1809, 101, 1395 )
--}
AddDungeon( "WI_INSTANCE_RUSTIA" )
--{
SetClass( CLASS_NORMAL )
SetLevel( 60, 85 )
SetCoolTime( MIN(180) )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE01", false, 513, 101, 953 )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE02", false, 889, 101, 1121 )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE03", false, 926, 101, 850 )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE04", false, 1247, 101, 1272 )
SetMonster( ID_BOSS, "MI_BESIBIGFOOT01", true, 1126, 103, 1505 )
--}
AddDungeon( "WI_INSTANCE_RUSTIA_1" )
--{
SetClass( CLASS_MASTER )
SetLevel( 60, 85 )
SetCoolTime( MIN(180) )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE01", false, 513, 101, 953 )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE02", false, 889, 101, 1121 )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE03", false, 926, 101, 850 )
SetMonster( ID_MIDBOSS, "MI_RUSTIACRASHGATE04", false, 1247, 101, 1272 )
SetMonster( ID_BOSS, "MI_BESIBIGFOOT02", true, 1126, 103, 1505 )
--}
AddDungeon( "WI_INSTANCE_BEHAMAH" )
--{
SetClass( CLASS_NORMAL,CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 130, 200 )
SetCoolTime( MIN(360) )
SetMonster( ID_MIDBOSS, "MI_BEHESTATUE01", false, 697, 101, 374 )
SetMonster( ID_MIDBOSS, "MI_BEHESTATUE01", false, 624, 101, 494 )
SetMonster( ID_MIDBOSS, "MI_BEHESTATUE01", false, 918, 101, 643 )
SetMonster( ID_MIDBOSS, "MI_BEHESTATUE01", false, 897, 101, 784 )
SetMonster( ID_MIDBOSS, "MI_BEHESTATUE01", false, 579, 101, 748 )
SetMonster( ID_BOSS, "MI_BEHEMOTH", true, 1260, 101, 1392 )
--}
AddDungeon( "WI_INSTANCE_UPRESIA" )
-- Start: X = 1172.089111 / Y = 150 / Z = 658.836121
--{
SetClass( CLASS_NORMAL,CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 75, 170 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE05", false, 2155, 100, 1729 )
SetMonster( ID_BOSS, "MI_DREAMQEEN01", true, 2155, 100, 1729 )
--}
AddDungeon( "WI_INSTANCE_UPRESIA_1" )
-- Start: X = 1172.089111 / Y = 150 / Z = 658.836121
--{
SetClass( CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 75, 170 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_DREADSTONE05", false, 1126, 103, 1505 )
SetMonster( ID_BOSS, "MI_DREAMQEEN01_1", true, 1126, 103, 1505 )
--}
AddDungeon( "WI_INSTANCE_HERNEOS" )
-- Start: X = 828.219910 / Y = 100 / Z = 836.025085
--{
SetClass( CLASS_NORMAL,CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 90, 170 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_HERNSIREN01", true, 689, 100, 508 )
SetMonster( ID_BOSS, "MI_HERNKRAKEN01", true, 1942, 100, 1424 )
--}
AddDungeon( "WI_INSTANCE_HERNEOS_1" )
-- Start: X = 828.219910 / Y = 100 / Z = 836.025085
--{
SetClass( CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 90, 170 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_HERNSIREN01_1", true, 689, 100, 508 )
SetMonster( ID_BOSS, "MI_HERNKRAKEN01_1", true, 1942, 100, 1424 )
--}
AddDungeon( "WI_INSTANCE_SANPRES" )
-- Start: X = 713.724182 / Y = 100 / Z = 211.597763
--{
SetClass( CLASS_NORMAL, CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 105, 170 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_SHIPHIPPOGRIPH", true, 1961, 101, 253 )
SetMonster( ID_BOSS, "MI_SHIPHARPINEES", true, 1362, 109, 1730 )
--}
AddDungeon( "WI_INSTANCE_SANPRES_1" )
-- Start: X = 718.437378 / Y = 100 / Z = 211.180237
--{
SetClass( CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 105, 170 )
SetCoolTime( MIN(240) )
SetMonster( ID_MIDBOSS, "MI_SHIPHIPPOGRIPH_1", true, 1961, 101, 253 )
SetMonster( ID_BOSS, "MI_SHIPHARPINEES_1", true, 1362, 109, 1730 )
--}
AddDungeon( "WI_DUNGEON_DA_DK" )
--{
SetClass( CLASS_NORMAL,CLASS_MASTER, CLASS_HERO, CLASS_LEGEND_HERO )
SetLevel( 135, 200 )
SetCoolTime( MIN(360) )
SetMonster( ID_MIDBOSS, "MI_BIGMUSCLE", false, 2323, 187, 2289 )
SetMonster( ID_MIDBOSS, "MI_GLYPHAXZ", false, 1378, 114, 801 )
SetMonster( ID_MIDBOSS, "MI_LOADCLOCKWORK", false, 1123, 132, 1697 )
SetMonster( ID_MIDBOSS, "MI_KRRR", false, 2305, 104, 298 )
SetMonster( ID_BOSS, "MI_MUSHMOOT", true, 1274, 116, 1066 )
--}
Instancedungeonbase.cpp
// InstanceDungeonBase.cpp: implementation of the CInstanceDungeonBase class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "InstanceDungeonBase.h"
#if __VER >= 14 // __INSTANCE_DUNGEON
#ifdef __WORLDSERVER
#include "User.h"
extern CUserMng g_UserMng;
#include "worldmng.h"
extern CWorldMng g_WorldMng;
#include "DPCoreClient.h"
extern CDPCoreClient g_DPCoreClient;
#include "DPDatabaseClient.h"
extern CDPDatabaseClient g_dpDBClient;
#include "party.h"
extern CPartyMng g_PartyMng;
#endif // __WORLDSERVER
#ifdef __CORESERVER
#include "DPCoreSrvr.h"
extern CDPCoreSrvr g_dpCoreSrvr;
#endif // __CORESERVER
//////////////////////////////////////////////////////////////////////
// CInstanceDungeonBase
//////////////////////////////////////////////////////////////////////
CInstanceDungeonBase::CInstanceDungeonBase( int nIDType )
: m_nIDType( nIDType )
#ifdef __CORESERVER
, m_nCoolTimeCount( 0 )
#endif // __CORESERVER
{
}
CInstanceDungeonBase::~CInstanceDungeonBase()
{
m_mapID.clear();
m_mapCTInfo.clear();
#ifdef __WORLDSERVER
m_mapDungeonData.clear();
#endif // __WORLDSERVER
}
void CInstanceDungeonBase::SerializeAllInfo( CAr & ar )
{
if( ar.IsStoring() )
{
// ´øÀü Á¤º¸
ar << m_mapID.size();
for( MAP_IDBASE::iterator itMap=m_mapID.begin(); itMap!=m_mapID.end(); itMap++ )
{
ar << itMap->first;
VEC_IDINFO* pvecTemp;
pvecTemp = &itMap->second;
ar << pvecTemp->size();
for( VEC_IDINFO::iterator itVec=pvecTemp->begin(); itVec!=pvecTemp->end(); itVec++ )
(*itVec).Serialize( ar );
}
// Ç÷¹À̾î ÄðŸÀÓ Á¤º¸
ar << m_mapCTInfo.size();
for( MAP_CTINFO::iterator it=m_mapCTInfo.begin(); it!=m_mapCTInfo.end(); it++)
{
ar << it->first;
VEC_CTINFO* pvecIDCT;
pvecIDCT = &it->second;
ar << pvecIDCT->size();
for( VEC_CTINFO::iterator itVec=pvecIDCT->begin(); itVec!=pvecIDCT->end(); itVec++)
(*itVec).Serialize( ar );
}
}
else
{
// ´øÀü Á¤º¸
m_mapID.clear();
size_t nSizeMap;
ar >> nSizeMap;
for( DWORD i=0; i<nSizeMap; i++ )
{
DWORD dwDungeonId; ar >> dwDungeonId;
size_t nSizeVec; ar >> nSizeVec;
for( DWORD j=0; j<nSizeVec; j++ )
{
ID_INFO ID_Info( NULL_ID, NULL_ID );
ID_Info.Serialize( ar );
CreateDungeon( ID_Info, dwDungeonId );
}
}
// Ç÷¹À̾î ÄðŸÀÓ Á¤º¸
m_mapCTInfo.clear();
ar >> nSizeMap;
for( DWORD i=0; i<nSizeMap; i++ )
{
DWORD dwPlayerId; ar >> dwPlayerId;
size_t nSizeVec; ar >> nSizeVec;
for( DWORD j=0; j<nSizeVec; j++ )
{
COOLTIME_INFO CT_Info;
CT_Info.Serialize( ar );
SetDungeonCoolTimeInfo( CT_Info, dwPlayerId );
}
}
}
}
BOOL CInstanceDungeonBase::CreateDungeonLayer( ID_INFO & ID_Info, DWORD dwLayer )
{
#ifdef __WORLDSERVER
if( ID_Info.uMultiKey != g_uKey )
return TRUE;
CWorld* pWorld = g_WorldMng.GetWorld( ID_Info.dwWorldId );
if( !pWorld || pWorld->m_linkMap.GetLinkMap( static_cast<int>( dwLayer ) ) )
{
Error( "CInstanceDungeonBase::CreateDungeonLayer() - LinkMap Exist! Type:%d, DungeonID:%d, WorldID:%d", GetType(), dwLayer, ID_Info.dwWorldId );
return FALSE;
}
if( !pWorld->CreateLayer( static_cast<int>( dwLayer ) ) )
{
Error( "CInstanceDungeonBase::CreateDungeonLayer() - CreateLayer Failed! Type:%d, DungeonID:%d, WorldID:%d", GetType(), dwLayer, ID_Info.dwWorldId );
return FALSE;
}
++CInstanceDungeonHelper::GetInstance()->m_nIDLayerNum;
g_dpDBClient.SendLogInstanceDungeon( dwLayer, ID_Info.dwWorldId, g_uIdofMulti, GetType(), 'M' );
//OUTPUTDEBUGSTRING( "CInstanceDungeonBase::CreateDungeonLayer() [ World : %d, Layer : %d ]\n", ID_Info.dwWorldId, dwLayer );
ID_INFO* pInfo = GetDungeonInfo( dwLayer, ID_Info.dwWorldId );
if( pInfo )
while( GetObjCount( pInfo->dwWorldId, dwLayer ) <= 0 && pInfo->nState < ID_BOSS )
pInfo->nState++;
CreateMonster( dwLayer, ID_Info.dwWorldId );
#endif // __WORLDSERVER
return TRUE;
}
BOOL CInstanceDungeonBase::DestroyDungeonLayer( ID_INFO & ID_Info, DWORD dwLayer )
{
#ifdef __WORLDSERVER
if( ID_Info.uMultiKey != g_uKey )
return TRUE;
CWorld* pWorld = g_WorldMng.GetWorld( ID_Info.dwWorldId );
if( !pWorld || !pWorld->m_linkMap.GetLinkMap( static_cast<int>( dwLayer ) ) )
{
Error( "CInstanceDungeonBase::DestroyDungeonLayer() - LinkMap Not Exist! Type:%d, DungeonID:%d, WorldID:%d", GetType(), dwLayer, ID_Info.dwWorldId );
return FALSE;
}
pWorld->Invalidate( static_cast<int>( dwLayer ) );
--CInstanceDungeonHelper::GetInstance()->m_nIDLayerNum;
g_dpDBClient.SendLogInstanceDungeon( dwLayer, ID_Info.dwWorldId, g_uIdofMulti, GetType(), 'R' );
//OUTPUTDEBUGSTRING( "CInstanceDungeonBase::DestroyDungeonLayer() [ World : %d, Layer : %d ]\n", ID_Info.dwWorldId, dwLayer );
#endif // __WORLDSERVER
return TRUE;
}
BOOL CInstanceDungeonBase::CreateDungeon( ID_INFO ID_Info, DWORD dwDungeonId )
{
VEC_IDINFO* pVecInfo = GetDungeonVector( dwDungeonId );
if( pVecInfo )
{
for( VEC_IDINFO::iterator it=pVecInfo->begin(); it!=pVecInfo->end(); it++ )
{
if( (*it).dwWorldId == ID_Info.dwWorldId )
return FALSE;
}
pVecInfo->push_back( ID_Info );
}
else
{
VEC_IDINFO vecTemp;
vecTemp.push_back( ID_Info );
m_mapID.insert( MAP_IDBASE::value_type( dwDungeonId, vecTemp ) );
}
return CreateDungeonLayer( ID_Info, dwDungeonId ); // ÇØ´ç ´øÀü ·¹ÀÌ¾î »ý¼º
}
BOOL CInstanceDungeonBase::DestroyDungeon( ID_INFO ID_Info, DWORD dwDungeonId )
{
MAP_IDBASE::iterator it = m_mapID.find( dwDungeonId );
if( it != m_mapID.end() )
{
for( VEC_IDINFO::iterator itVec=it->second.begin(); itVec!=it->second.end(); itVec++ )
{
if( (*itVec).dwWorldId == ID_Info.dwWorldId )
{
if( !DestroyDungeonLayer( ID_Info, dwDungeonId ) ) // ÇØ´ç ´øÀü ·¹ÀÌ¾î ÆÄ±«
return FALSE;
it->second.erase( itVec );
if( it->second.empty() )
m_mapID.erase( it );
ResetDungeonCoolTimeInfo( ID_Info.dwWorldId, dwDungeonId );
#ifdef __CORESERVER
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonDestroy( GetType(), dwDungeonId, ID_Info );
#endif // __CORESERVER
return TRUE;
}
}
}
return FALSE;
}
void CInstanceDungeonBase::DestroyAllDungeonByDungeonID ( DWORD dwDungeonId )
{
VEC_IDINFO* pvecTemp = GetDungeonVector( dwDungeonId );
if( pvecTemp )
{
VEC_IDINFO vecTemp;
vecTemp.assign( pvecTemp->begin(), pvecTemp->end() );
for( VEC_IDINFO::iterator itVec=vecTemp.begin(); itVec!=vecTemp.end(); itVec++ )
#ifdef __CORESERVER
DestroyDungeon( (*itVec), dwDungeonId ); // 090525 ÇöÀç±îÁö »ç¿ëÇÒ ÀÏ ¾ø´Ù^^
#endif // __CORESERVER
#ifdef __WORLDSERVER
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonDestroy( GetType(), dwDungeonId, (*itVec) );
#endif // __WORLDSERVER
}
}
void CInstanceDungeonBase::DestroyAllDungeonByMultiKey( ULONG uMultiKey )
{
vector< pair<ID_INFO, DWORD> > vecpairTemp;
for( MAP_IDBASE::iterator it=m_mapID.begin(); it!=m_mapID.end(); it++ )
{
for( VEC_IDINFO::iterator itVec=it->second.begin(); itVec!=it->second.end(); itVec++ )
{
if( uMultiKey == (*itVec).uMultiKey )
vecpairTemp.push_back( make_pair( (*itVec), it->first ) );
}
}
for( DWORD i=0; i<vecpairTemp.size(); i++ )
#ifdef __CORESERVER
DestroyDungeon( vecpairTemp[i].first, vecpairTemp[i].second );
#endif // __CORESERVER
#ifdef __WORLDSERVER
// 090525 ÇöÀç±îÁö »ç¿ëÇÒ ÀÏ ¾ø´Ù^^
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonDestroy( GetType(), vecpairTemp[i].second, vecpairTemp[i].first );
#endif // __WORLDSERVER
}
VEC_IDINFO* CInstanceDungeonBase::GetDungeonVector( DWORD dwDungeonId )
{
MAP_IDBASE::iterator it = m_mapID.find( dwDungeonId );
if( it != m_mapID.end() )
return &it->second;
return NULL;
}
ID_INFO* CInstanceDungeonBase::GetDungeonInfo( DWORD dwDungeonId, DWORD dwWorldId )
{
VEC_IDINFO* pVecInfo = GetDungeonVector( dwDungeonId );
if( pVecInfo )
{
for( VEC_IDINFO::iterator it=pVecInfo->begin(); it!=pVecInfo->end(); it++ )
{
if( (*it).dwWorldId == dwWorldId )
return &(*it);
}
}
return NULL;
}
VEC_CTINFO* CInstanceDungeonBase::GetCoolTimeVector( DWORD dwPlayerId )
{
MAP_CTINFO::iterator it = m_mapCTInfo.find( dwPlayerId );
if( it != m_mapCTInfo.end() )
return &it->second;
return NULL;
}
COOLTIME_INFO* CInstanceDungeonBase::GetCoolTimeInfo( DWORD dwPlayerId, DWORD dwWorldId )
{
VEC_CTINFO* pVecCT = GetCoolTimeVector( dwPlayerId );
if( pVecCT )
{
for( VEC_CTINFO::iterator it=pVecCT->begin(); it!=pVecCT->end(); it++ )
{
if( (*it).dwWorldId == dwWorldId )
return &(*it);
}
}
return NULL;
}
void CInstanceDungeonBase::SetDungeonCoolTimeInfo( COOLTIME_INFO CT_Info, DWORD dwPlayerId )
{
VEC_CTINFO* pVecCT = GetCoolTimeVector( dwPlayerId );
if( pVecCT )
{
for( VEC_CTINFO::iterator it=pVecCT->begin(); it!=pVecCT->end(); it++ )
{
if( (*it).dwWorldId == CT_Info.dwWorldId && (*it).dwDungeonId != CT_Info.dwDungeonId )
{
(*it).dwDungeonId = CT_Info.dwDungeonId;
(*it).dwCoolTime = CT_Info.dwCoolTime;
return;
}
}
pVecCT->push_back( CT_Info );
}
else
{
VEC_CTINFO vecTemp;
vecTemp.push_back( CT_Info );
m_mapCTInfo.insert( MAP_CTINFO::value_type( dwPlayerId, vecTemp ) );
}
#ifdef __TIMER
CUser *pUser = g_UserMng.GetUserByPlayerID(dwPlayerId);
if( IsValidObj(pUser) )
{
pUser->AddDungeonCoolTimeUpdate(CT_Info.dwWorldId, CT_Info.dwCoolTime - GetTickCount());
}
#endif
}
void CInstanceDungeonBase::ResetDungeonCoolTimeInfo( DWORD dwWorldId, DWORD dwDungeonId )
{
for( MAP_CTINFO::iterator it=m_mapCTInfo.begin(); it!=m_mapCTInfo.end(); it++ )
{
for( VEC_CTINFO::iterator itVec=it->second.begin(); itVec!=it->second.end(); itVec++ )
{
if( (*itVec).dwWorldId == dwWorldId && (*itVec).dwDungeonId == dwDungeonId )
(*itVec).dwDungeonId = NULL_ID;
}
}
}
#ifdef __CORESERVER
void CInstanceDungeonBase::DungeonCoolTimeCountProcess( )
{
if( ++m_nCoolTimeCount >= COOLTIMECOUNT )
{
m_nCoolTimeCount = 0;
UpdateDungeonCoolTimeInfo();
}
}
void CInstanceDungeonBase::UpdateDungeonCoolTimeInfo()
{
DWORD dwTickCount = GetTickCount();
for( MAP_CTINFO::iterator itMap=m_mapCTInfo.begin(); itMap!=m_mapCTInfo.end(); )
{
BOOL bErase = TRUE;
for( VEC_CTINFO::iterator itVec=itMap->second.begin(); itVec!=itMap->second.end(); itVec++ )
{
if( (*itVec).dwCoolTime > dwTickCount )
{
bErase = FALSE;
break;
}
}
if( bErase )
{
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonDeleteCoolTimeInfo( GetType(), itMap->first );
m_mapCTInfo.erase( itMap++ );
}
else
itMap++;
}
}
#endif // __CORESERVER
#ifdef __WORLDSERVER
void CInstanceDungeonBase::LoadScript( const char* szFilename )
{
CLuaBase Lua;
if( Lua.RunScript( szFilename ) != 0 )
{
Error( "%s Run Failed!!!", szFilename );
exit( 0 );
}
m_nMaxInstanceDungeon = static_cast<int>( Lua.GetGlobalNumber( "nMaxInstanceDungeon" ) );
Lua.GetGloabal( "tDungeon" );
Lua.PushNil();
while( Lua.TableLoop( -2 ) )
{
DUNGEON_DATA data;
for( int i=ID_NORMAL;i<=ID_BOSS; i++ )
data.mapObjCount.insert( map<int,int>::value_type( i, 0 ) );
DWORD dwWorldId = static_cast<DWORD>( CScript::GetDefineNum( Lua.GetFieldToString( -1, "strWorldId" ) ) );
data.dwClass = static_cast<DWORD>( Lua.GetFieldToNumber( -1, "dwClass" ) );
data.nMinLevel = static_cast<int>( Lua.GetFieldToNumber( -1, "nMinLevel" ) );
data.nMaxLevel = static_cast<int>( Lua.GetFieldToNumber( -1, "nMaxLevel" ) );
data.dwCoolTime = static_cast<DWORD>( Lua.GetFieldToNumber( -1, "dwCoolTime" ) );
MAP_IDDATA::iterator it = m_mapDungeonData.insert( MAP_IDDATA::value_type( dwWorldId, data ) ).first;
Lua.GetField( -1, "tTeleport" );
Lua.PushNil();
CWorld* pWorld = g_WorldMng.GetWorld( dwWorldId );
while( Lua.TableLoop( -2 ) )
{
int nState = static_cast<int>( Lua.GetFieldToNumber( -1, "nType" ) );
D3DXVECTOR3 vPos;
vPos.x = static_cast<float>( Lua.GetFieldToNumber( -1, "x" ) );
vPos.y = static_cast<float>( Lua.GetFieldToNumber( -1, "y" ) );
vPos.z = static_cast<float>( Lua.GetFieldToNumber( -1, "z" ) );
if( !pWorld && pWorld->VecInWorld( vPos ) == FALSE )
Error( "Invalid World Pos! WorldId : %d, x : %f, y : %f, z : %f", dwWorldId, vPos.x, vPos.y, vPos.z );
it->second.mapTeleportPos.insert( map<int, D3DXVECTOR3>::value_type( nState, vPos ) );
Lua.Pop( 1 );
}
Lua.Pop( 1 ); // tTeleport ½ºÅÿ¡¼* Á¦°Å
Lua.GetField( -1, "tMonster" );
Lua.PushNil();
while( Lua.TableLoop( -2 ) )
{
DUNGEON_DATA::MONSTER monster;
monster.nState = static_cast<int>( Lua.GetFieldToNumber( -1, "nType" ) );
monster.dwMonsterId = static_cast<DWORD>( CScript::GetDefineNum( Lua.GetFieldToString( -1, "strMonsterId" ) ) );
monster.bRed = static_cast<BOOL>( Lua.GetFieldToBool( -1, "bRed" ) );
monster.vPos.x = static_cast<float>( Lua.GetFieldToNumber( -1, "x" ) );
monster.vPos.y = static_cast<float>( Lua.GetFieldToNumber( -1, "y" ) );
monster.vPos.z = static_cast<float>( Lua.GetFieldToNumber( -1, "z" ) );
if( !prj.GetMoverProp( monster.dwMonsterId ) )
Error( "Invalid Monster! MonsterId : %d", monster.dwMonsterId );
it->second.mapObjCount.find( monster.nState )->second++;
it->second.vecMonster.push_back( monster );
Lua.Pop( 1 );
}
Lua.Pop( 1 ); // tMonster ½ºÅÿ¡¼* Á¦°Å
CInstanceDungeonHelper::GetInstance()->SetDungeonType( dwWorldId, GetType() );
Lua.Pop( 1 );
}
Lua.Pop( 0 );
}
int CInstanceDungeonBase::GetState( DWORD dwWorldId, DWORD dwDungeonId )
{
MAP_IDBASE::iterator it = m_mapID.find( dwDungeonId );
if( it != m_mapID.end() )
{
for( DWORD i=0; i<it->second.size(); i++ )
{
if( it->second[i].dwWorldId == dwWorldId )
return it->second[i].nState;
}
}
return ID_NORMAL;
}
void CInstanceDungeonBase::SetNextState( ID_INFO* pInfo, DWORD dwDungeonId )
{
if( pInfo && pInfo->nState < ID_BOSS )
{
D3DXVECTOR3 vPrevPos = GetTeleportPos( pInfo->dwWorldId, dwDungeonId );
pInfo->nState++;
pInfo->nKillCount = 0;
CreateMonster( dwDungeonId, pInfo->dwWorldId );
D3DXVECTOR3 vNextPos = GetTeleportPos( pInfo->dwWorldId, dwDungeonId );
if( vPrevPos != vNextPos && vNextPos != D3DXVECTOR3( 0, 0, 0 ) )
{
CWorld* pWorld = g_WorldMng.GetWorld( pInfo->dwWorldId );
if( !pWorld )
return;
CObj* pObj;
for( DWORD i=0; i<pWorld->m_dwObjNum; i++ )
{
pObj = pWorld->m_apObject[i];
if( IsValidObj( pObj ) && pObj->GetLayer() == static_cast<int>( dwDungeonId )
&& pObj->GetType() == OT_MOVER && static_cast<CMover*>( pObj )->IsPlayer() )
static_cast<CUser*>( pObj )->REPLACE( g_uIdofMulti, pWorld->GetID(), vNextPos, REPLACE_NORMAL, static_cast<int>( dwDungeonId ) );
}
}
if( pInfo->nKillCount >= GetObjCount( pInfo->dwWorldId, dwDungeonId ) )
SetNextState( pInfo, dwDungeonId );
}
else if( pInfo ) // ´øÀü Ŭ¸®¾î ·Î±×(ÃßÈÄ »èÁ¦ ¿¹Á¤)
{
g_dpDBClient.SendLogInstanceDungeon( dwDungeonId, pInfo->dwWorldId, g_uIdofMulti, GetType(), 'C' );
//OUTPUTDEBUGSTRING( "Instance Dungeon Clear - Party : %07d,\tWorld : %d", dwDungeonId, pInfo->dwWorldId );
}
}
D3DXVECTOR3 CInstanceDungeonBase::GetTeleportPos( DWORD dwWorldId, DWORD dwDungeonId )
{
MAP_IDDATA::iterator it = m_mapDungeonData.find( dwWorldId );
if( it == m_mapDungeonData.end() )
return D3DXVECTOR3( 0, 0, 0 );
map<int, D3DXVECTOR3>::iterator it2 = it->second.mapTeleportPos.find( GetState( dwWorldId, dwDungeonId ) );
if( it2 == it->second.mapTeleportPos.end() )
return D3DXVECTOR3( 0, 0, 0 );
return it2->second;
}
BOOL CInstanceDungeonBase::CheckClassLevel( CUser* pUser, DWORD dwWorldId )
{
MAP_IDDATA::iterator it = m_mapDungeonData.find( dwWorldId );
if( it == m_mapDungeonData.end() )
return FALSE;
WORD wClass = 0x0000;
switch( pUser->GetLegendChar() )
{
case LEGEND_CLASS_NORMAL : wClass = CLASS_NORMAL; break;
case LEGEND_CLASS_MASTER : wClass = CLASS_MASTER; break;
case LEGEND_CLASS_HERO : wClass = CLASS_HERO; break;
#ifdef __3RD_LEGEND16
case LEGEND_CLASS_LEGENDHERO : wClass = CLASS_LEGEND_HERO; break;
#endif // __3RD_LEGEND16
default : wClass = 0x0000;
}
if( wClass & it->second.dwClass )
{
if( pUser->GetLevel() < it->second.nMinLevel || pUser->GetLevel() > it->second.nMaxLevel )
{
pUser->AddDefinedText( TID_GAME_INSTANCE_LEVEL, "%d %d", it->second.nMinLevel, it->second.nMaxLevel );
return FALSE;
}
return TRUE;
}
else
pUser->AddDefinedText( TID_GAME_INSTANCE_CLASS );
return FALSE;
}
BOOL CInstanceDungeonBase::IncreasePlayerCount( DWORD dwDungeonId, DWORD dwWorldId )
{
ID_INFO* pInfo = GetDungeonInfo( dwDungeonId, dwWorldId );
if( pInfo )
{
pInfo->nPlayerCount++;
//OUTPUTDEBUGSTRING( "CInstanceDungeonBase::IncreasePlayerCount() [ World : %d, Layer : %d ] - Count : %d\n", dwWorldId, dwDungeonId, pInfo->nPlayerCount );
return TRUE;
}
return FALSE;
}
BOOL CInstanceDungeonBase::DecreasePlayerCount( CUser* pUser, DWORD dwDungeonId, DWORD dwWorldId )
{
ID_INFO* pInfo = GetDungeonInfo( dwDungeonId, dwWorldId );
if( pInfo )
{
//OUTPUTDEBUGSTRING( "CInstanceDungeonBase::DecreasePlayerCount() [ World : %d, Layer : %d ] - Count : %d\n", dwWorldId, dwDungeonId, pInfo->nPlayerCount-1 );
if( --pInfo->nPlayerCount <= 0 )
{
if( GetType() == IDTYPE_PARTY )
{
CParty* pParty = g_PartyMng.GetParty( dwDungeonId );
if( pParty != NULL )
{
for( int i = 0; i < pParty->GetSizeofMember(); ++i )
{
CUser* pPartyMember = g_UserMng.GetUserByPlayerID( pParty->GetPlayerId( i ) );
if( IsValidObj( pPartyMember ) == TRUE && pPartyMember != pUser )
{
if( pPartyMember->GetWorld() != NULL && pPartyMember->GetWorld()->GetID() == dwWorldId
&& pPartyMember->GetLayer() == dwDungeonId )
{
return FALSE;
}
}
}
}
else
{
return TRUE;
}
}
return TRUE;
}
}
return FALSE;
}
void CInstanceDungeonBase::CreateMonster( DWORD dwDungeonId, DWORD dwWorldId )
{
CWorld* pWorld = g_WorldMng.GetWorld( dwWorldId );
if( !pWorld || !pWorld->m_linkMap.GetLinkMap( static_cast<int>( dwDungeonId ) ) )
return;
MAP_IDDATA::iterator it = m_mapDungeonData.find( pWorld->GetID() );
if( it != m_mapDungeonData.end() )
{
int nState = GetState( dwWorldId, dwDungeonId );
for( vector<DUNGEON_DATA::MONSTER>::iterator itVecMon=it->second.vecMonster.begin(); itVecMon!=it->second.vecMonster.end(); itVecMon++ )
{
if( (*itVecMon).nState != nState )
continue;
MoverProp* pMoverProp = prj.GetMoverProp( (*itVecMon).dwMonsterId );
if( pMoverProp )
{
CObj* pObj = CreateObj( D3DDEVICE, OT_MOVER, pMoverProp->dwID );
if( NULL == pObj )
return;
pObj->SetPos( (*itVecMon).vPos );
pObj->InitMotion( MTI_STAND );
pObj->UpdateLocalMatrix();
((CMover*)pObj)->m_bActiveAttack =(*itVecMon).bRed;
pWorld->ADDOBJ( pObj, TRUE, dwDungeonId );
}
}
}
}
BOOL CInstanceDungeonBase::TeleportToDungeon( CUser* pUser, DWORD dwWorldId, DWORD dwDungeonId )
{
if( !CheckClassLevel( pUser, dwWorldId ) )
return FALSE;
#if __VER >= 14 // __INSTANCE_DUNGEON // Àδø ³» ¶Ç´Â ÀÔÀå½Ã º¯½Å±¸ »ç¿ë ±ÝÁö
if( pUser->HasBuffByIk3( IK3_TEXT_DISGUISE ) )
{
pUser->AddDefinedText( TID_GAME_INSTANCE_DISGUISE02 );
return FALSE;
}
#endif // __INSTANCE_DUNGEON // Àδø ³» ¶Ç´Â ÀÔÀå½Ã º¯½Å±¸ »ç¿ë ±ÝÁö
CWorld* pWorld = g_WorldMng.GetWorld( dwWorldId );
if( !pWorld )
return FALSE;
COOLTIME_INFO* pCT_Info = GetCoolTimeInfo( pUser->m_idPlayer, dwWorldId );
if( pCT_Info )
{
if( pCT_Info->dwDungeonId != dwDungeonId )
{
DWORD dwRemainCoolTime = pCT_Info->dwCoolTime - GetTickCount();
if( static_cast<int>( dwRemainCoolTime ) > 0 )
{
DWORD dwRemainMin = dwRemainCoolTime / MIN( 1 );
DWORD dwRemainSec = ( dwRemainCoolTime % MIN( 1 ) ) / SEC( 1 );
pUser->AddDefinedText( TID_GAME_INSTANCE_COOLTIME, "%d %d", dwRemainMin, dwRemainSec );
return FALSE;
}
}
}
ID_INFO* pInfo = GetDungeonInfo( dwDungeonId, dwWorldId );
if( pInfo ) // ÇØ´ç ´øÀüÀÌ Á¸ÀçÇϸé ä³Î °Ë»ç...
{
if( pInfo->uMultiKey != g_uKey ) // ÇØ´ç ä³Î¿¡ »ý¼ºµÈ ´øÀüÀÌ ¾Æ´Ï¸é ÀÔÀå ºÒ°¡
{
pUser->AddDefinedText( TID_GAME_INSTANCE_CHANNEL );
return FALSE;
}
D3DXVECTOR3 vPos = GetTeleportPos( dwWorldId, dwDungeonId );
if( vPos == D3DXVECTOR3( 0, 0, 0 ) )
{
REGIONELEM* pPortkey = pUser->UpdateRegionAttr();
if( pPortkey && pPortkey->m_dwIdTeleWorld == dwWorldId )
vPos = pPortkey->m_vTeleWorld;
else
return FALSE;
}
if( pWorld->m_linkMap.GetLinkMap( static_cast<int>( dwDungeonId ) ) )
{
SetLeaveMarkingPos( pUser, dwWorldId, vPos );
int nRandx = xRandom(4) - 2;
int nRandz = xRandom(4) - 2;
vPos += D3DXVECTOR3( (float)( nRandx ), (float)( 0 ), (float)( nRandz ) );
pUser->REPLACE( g_uIdofMulti, dwWorldId, vPos, REPLACE_NORMAL, static_cast<int>( dwDungeonId ) );
IncreasePlayerCount( static_cast<DWORD>( pUser->m_idparty ), dwWorldId );
if( !pCT_Info || pCT_Info->dwDungeonId != dwDungeonId ) // 090813 ´øÀüÀÌ À¯ÁöµÇ°í ÀÖ´Â »óÅ¿¡¼*ÀÇ ÀçÀÔÀåÀº setÇÏÁö ¾ÊÀ½
{
#ifdef __VIP
if( pUser->IsVIP() )
{
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonSetCoolTimeInfo( g_uKey, GetType(), pUser->m_idPlayer, COOLTIME_INFO( dwWorldId, dwDungeonId,
( ( GetCoolTime( dwWorldId ) / 2 ) + GetTickCount() ) ) );
}
else
#endif
{
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonSetCoolTimeInfo( g_uKey, GetType(), pUser->m_idPlayer, COOLTIME_INFO( dwWorldId, dwDungeonId,
( GetCoolTime( dwWorldId ) + GetTickCount() ) ) );
}
}
return TRUE;
}
else
return FALSE;
}
else // ÇØ´ç ´øÀüÀÌ Á¸ÀçÇÏÁö ¾ÊÀ¸¸é CoreServer·Î »ý¼º ÇÒ °ÍÀ» ¿äû ÇÑ´Ù.
{
if( CInstanceDungeonHelper::GetInstance()->m_nIDLayerNum < m_nMaxInstanceDungeon )
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonCreate( GetType(), dwDungeonId, ID_INFO( dwWorldId, g_uKey ) );
else
{
pUser->AddDefinedText( TID_GAME_INSTANCE_MAX );
return FALSE;
}
}
return TRUE;
}
BOOL CInstanceDungeonBase::LeaveToOutside( CUser* pUser, DWORD dwWorldId, DWORD dwDungeonId )
{
if( DecreasePlayerCount( pUser, dwDungeonId, dwWorldId ) )
{
CInstanceDungeonHelper::GetInstance()->SendInstanceDungeonDestroy( GetType(), dwDungeonId, ID_INFO( dwWorldId, g_uKey ) );
return TRUE;
}
return FALSE;
}
void CInstanceDungeonBase::SetLeaveMarkingPos( CUser* pUser, DWORD dwWorldId, D3DXVECTOR3 vPos )
{
#ifdef __VIRTUOS_NEW_START
pUser->m_idMarkingWorld = WI_DUNGEON_VOLCANEYELLOW;
pUser->m_vMarkingPos = D3DXVECTOR3( 8445.5f, 0.0f, 2438.2f );
#else
pUser->m_idMarkingWorld = WI_WORLD_MADRIGAL;
pUser->m_vMarkingPos = D3DXVECTOR3( 6983.0f, 0.0f, 3330.0f );
#endif
CWorld* pWorld = g_WorldMng.GetWorld( dwWorldId );
if( !pWorld )
return;
float fDist = static_cast<float>( INT_MAX );
for( int i = 0; i < pWorld->m_aRegion.GetSize(); i++ )
{
LPREGIONELEM lpRegionElem = pWorld->m_aRegion.GetAt( i );
if( !lpRegionElem || lpRegionElem->m_dwIdTeleWorld == WI_WORLD_NONE )
continue;
float fTemp = D3DXVec3LengthSq( &( vPos - lpRegionElem->m_vPos ) );
if( fTemp < fDist )
{
fDist = fTemp;
pUser->m_vMarkingPos = lpRegionElem->m_vTeleWorld;
pUser->m_idMarkingWorld = lpRegionElem->m_dwIdTeleWorld;
}
}
}
DWORD CInstanceDungeonBase::GetCoolTime( DWORD dwWorldId )
{
MAP_IDDATA::iterator it = m_mapDungeonData.find( dwWorldId );
if( it != m_mapDungeonData.end() )
return it->second.dwCoolTime;
return 0;
}
BOOL CInstanceDungeonBase::IsNowStateMonster( DWORD dwWorldId, DWORD dwDungeonId, DWORD dwMonsterId )
{
MAP_IDDATA::iterator it = m_mapDungeonData.find( dwWorldId );
if( it == m_mapDungeonData.end() )
return FALSE;
int nNowState = GetState( dwWorldId, dwDungeonId );
for( vector<DUNGEON_DATA::MONSTER>::iterator i=it->second.vecMonster.begin(); i!=it->second.vecMonster.end(); i++ )
{
if( (*i).nState == nNowState && (*i).dwMonsterId == dwMonsterId )
return TRUE;
}
return FALSE;
}
int CInstanceDungeonBase::GetObjCount( DWORD dwWorldId, DWORD dwDungeonId )
{
MAP_IDDATA::iterator it = m_mapDungeonData.find( dwWorldId );
if( it == m_mapDungeonData.end() )
return 0;
map<int,int>::iterator itObjCount = it->second.mapObjCount.find( GetState( dwWorldId, dwDungeonId ) );
if( itObjCount == it->second.mapObjCount.end() )
return 0;
return itObjCount->second;
}
void CInstanceDungeonBase::SetInstanceDungeonKill( DWORD dwWorldId, DWORD dwDungeonId, DWORD dwMonsterId )
{
if( IsNowStateMonster( dwWorldId, dwDungeonId, dwMonsterId ) )
{
ID_INFO* pInfo = GetDungeonInfo( dwDungeonId, dwWorldId );
if( pInfo )
{
pInfo->nKillCount++;
if( pInfo->nKillCount >= GetObjCount( dwWorldId, dwDungeonId ) )
SetNextState( pInfo, dwDungeonId );
}
}
}
void CInstanceDungeonBase::DeleteDungeonCoolTimeInfo( DWORD dwPlayerId )
{
MAP_CTINFO::iterator itMap = m_mapCTInfo.find( dwPlayerId );
if( itMap != m_mapCTInfo.end() )
m_mapCTInfo.erase( itMap );
}
#ifdef __TIMER
void CInstanceDungeonBase::SerializeCoolTime(CAr & ar, u_long idPlayer)
{
u_long uOffset = ar.GetOffset();
ar << (char)0;
VEC_CTINFO *pInfo = GetCoolTimeVector(idPlayer);
char chCount = 0;
if( pInfo )
{
for( unsigned i = 0; i < pInfo->size(); ++i )
{
if( pInfo->at(i).dwCoolTime > g_tmCurrent )
{
chCount++;
ar << pInfo->at(i).dwWorldId << (pInfo->at(i).dwCoolTime - GetTickCount());
}
}
}
int nBufSize;
LPBYTE lpBuff = ar.GetBuffer(&nBufSize);
*(char*)( lpBuff + uOffset ) = chCount;
}
#endif
#endif // __WORLDSERVER
//////////////////////////////////////////////////////////////////////
// CInstanceDungeonHelper
//////////////////////////////////////////////////////////////////////
#include "InstanceDungeonParty.h"
CInstanceDungeonHelper::CInstanceDungeonHelper()
{
#ifdef __WORLDSERVER
m_uCertifyKey = NULL_ID;
m_nIDLayerNum = 0;
CInstanceDungeonParty::GetInstance()->LoadScript( "PartyDungeon.lua" );
#endif // __WORLDSERVER
}
CInstanceDungeonHelper::~CInstanceDungeonHelper()
{
#ifdef __WORLDSERVER
m_mapDungeonType.clear();
#endif // __WORLDSERVER
}
CInstanceDungeonHelper* CInstanceDungeonHelper::GetInstance()
{
static CInstanceDungeonHelper sIDH;
return &sIDH;
}
CInstanceDungeonBase* CInstanceDungeonHelper::GetDungeonPtr( int nType )
{
switch( nType )
{
case IDTYPE_PARTY : return CInstanceDungeonParty::GetInstance();
}
return NULL;
}
void CInstanceDungeonHelper::OnCreateDungeon( int nType, ID_INFO ID_Info, DWORD dwDungeonId )
{
#ifdef __WORLDSERVER
SetCertifyKey( ID_Info.uMultiKey );
#endif // __WORLDSERVER
CInstanceDungeonBase* pID = GetDungeonPtr( nType );
if( pID )
{
pID->CreateDungeon( ID_Info, dwDungeonId );
#ifdef __CORESERVER
SendInstanceDungeonCreate( nType, dwDungeonId, ID_Info );
#endif // __CORESERVER
}
}
void CInstanceDungeonHelper::OnDestroyDungeon( int nType, ID_INFO ID_Info, DWORD dwDungeonId )
{
CInstanceDungeonBase* pID = GetDungeonPtr( nType );
if( pID )
pID->DestroyDungeon( ID_Info, dwDungeonId );
}
void CInstanceDungeonHelper::OnSetDungeonCoolTimeInfo( ULONG uKey, int nType, COOLTIME_INFO CT_Info, DWORD dwPlayerId )
{
#ifdef __WORLDSERVER
SetCertifyKey( uKey );
#endif // __WORLDSERVER
CInstanceDungeonBase* pID = GetDungeonPtr( nType );
if( pID )
{
pID->SetDungeonCoolTimeInfo( CT_Info, dwPlayerId );
#ifdef __CORESERVER
SendInstanceDungeonSetCoolTimeInfo( uKey, nType, dwPlayerId, CT_Info );
pID->DungeonCoolTimeCountProcess();
#endif // __CORESERVER
}
}
void CInstanceDungeonHelper::SendInstanceDungeonCreate( int nType, DWORD dwDungeonId, ID_INFO & ID_Info )
{
#ifdef __WORLDSERVER
if( !IsCertifying() )
{
SetCertifyKey();
g_DPCoreClient.SendInstanceDungeonCreate( nType, dwDungeonId, ID_Info );
}
#endif // __WORLDSERVER
#ifdef __CORESERVER
g_dpCoreSrvr.SendInstanceDungeonCreate( nType, dwDungeonId, ID_Info );
#endif// __CORESERVER
}
void CInstanceDungeonHelper::SendInstanceDungeonDestroy ( int nType, DWORD dwDungeonId, ID_INFO & ID_Info )
{
#ifdef __WORLDSERVER
g_DPCoreClient.SendInstanceDungeonDestroy( nType, dwDungeonId, ID_Info );
#endif // __WORLDSERVER
#ifdef __CORESERVER
g_dpCoreSrvr.SendInstanceDungeonDestroy( nType, dwDungeonId, ID_Info );
#endif// __CORESERVER
}
void CInstanceDungeonHelper::SendInstanceDungeonSetCool TimeInfo( ULONG uKey, int nType, DWORD dwPlayerId, COOLTIME_INFO & CT_Info )
{
#ifdef __WORLDSERVER
if( !IsCertifying() )
{
SetCertifyKey();
g_DPCoreClient.SendInstanceDungeonSetCoolTimeInfo( nType, dwPlayerId, CT_Info );
}
#endif // __WORLDSERVER
#ifdef __CORESERVER
g_dpCoreSrvr.SendInstanceDungeonSetCoolTimeInfo( uKey, nType, dwPlayerId, CT_Info );
#endif// __CORESERVER
}
void CInstanceDungeonHelper::DestroyAllDungeonByMultiKe y( ULONG uMultiKey )
{
for( int i=IDTYPE_SOLO; i<IDTYPE_MAX; i++ )
{
CInstanceDungeonBase* pID = GetDungeonPtr( i );
if( pID )
pID->DestroyAllDungeonByMultiKey( uMultiKey );
}
}
#ifdef __CORESERVER
void CInstanceDungeonHelper::SendInstanceDungeonAllInfo ( DWORD dpId )
{
for( int i=IDTYPE_SOLO; i<IDTYPE_MAX; i++ )
{
CInstanceDungeonBase* pID = GetDungeonPtr( i );
if( pID )
g_dpCoreSrvr.SendInstanceDungeonAllInfo( i, pID, dpId );
}
}
void CInstanceDungeonHelper::SendInstanceDungeonDeleteC oolTimeInfo( int nType, DWORD dwPlayerId )
{
g_dpCoreSrvr.SendInstanceDungeonDeleteCoolTimeInfo ( nType, dwPlayerId );
}
#endif // __CORESERVER
#ifdef __WORLDSERVER
void CInstanceDungeonHelper::OnInstanceDungeonAllInfo( CAr & ar )
{
int nType;
ar >> nType;
CInstanceDungeonBase* pID = GetDungeonPtr( nType );
if( pID )
pID->SerializeAllInfo( ar );
else
{
Error( "CDPCoreClient::OnInstanceDungeonAllInfo() - Wrong Party Type - %d", nType );
exit( 0 );
}
}
void CInstanceDungeonHelper::SetCertifyKey( ULONG uMultiKey )
{
if( uMultiKey == NULL_ID )
m_uCertifyKey = g_uKey;
else if( m_uCertifyKey == uMultiKey )
m_uCertifyKey = NULL_ID;
}
void CInstanceDungeonHelper::SetDungeonType( DWORD dwWorldId, int nType )
{
m_mapDungeonType.insert( MAP_WORLD2TYPE::value_type( dwWorldId, nType ) );
}
int CInstanceDungeonHelper::GetType( DWORD dwWorldId )
{
MAP_WORLD2TYPE::iterator it = m_mapDungeonType.find( dwWorldId );
if( it == m_mapDungeonType.end() )
return NULL_ID;
return it->second;
}
BOOL CInstanceDungeonHelper::EnteranceDungeon( CUser* pUser, DWORD dwWorldId )
{
CInstanceDungeonBase* pID = GetDungeonPtr( GetType( dwWorldId ) );
if( IsValidObj( pUser ) && pID )
{
if( pID->EnteranceDungeon( pUser, dwWorldId ) )
return TRUE;
else
{
float fPushPower = 0.5f;
AngleToVectorXZ( &pUser->m_pActMover->m_vDeltaE, pUser->GetAngle() + 180.0f, fPushPower );
pUser->Replace( g_uIdofMulti, pUser->GetWorld()->GetID(), pUser->GetPos() + pUser->m_pActMover->m_vDeltaE, REPLACE_NORMAL, pUser->GetLayer() );
g_UserMng.AddPushPower( pUser, pUser->GetPos(), pUser->GetAngle(), pUser->GetAngle() + 180.0f, fPushPower );
}
}
return FALSE;
}
BOOL CInstanceDungeonHelper::LeaveDungeon( CUser* pUser, DWORD dwWorldId )
{
CInstanceDungeonBase* pID = GetDungeonPtr( GetType( dwWorldId ) );
if( pID )
{
if( pID->LeaveDungeon( pUser, dwWorldId ) )
return TRUE;
}
return FALSE;
}
// OnJoin()¿¡¼*¸¸ dwWorldId ¿¡ °ªÀÌ Á¸ÀçÇÑ´Ù. ÇØ´ç ´øÀü¿¡¼* ÀÔÀå ij¸¯Åͼö¸¦ Áõ°¡½ÃŰÁö ¾Ê°í °*Åð½Ã۱âÀ§ÇØ ÀÔÀå ij¸¯Åͼö¸¦ ¹Ì¸® Áõ°¡½ÃŲ´Ù.
void CInstanceDungeonHelper::GoOut( CUser* pUser )
{
pUser->REPLACE( g_uIdofMulti, pUser->m_idMarkingWorld, pUser->m_vMarkingPos, REPLACE_FORCE, nDefaultLayer );
}
void CInstanceDungeonHelper::SetInstanceDungeonKill( DWORD dwWorldId, DWORD dwDungeonId, DWORD dwMonsterId )
{
CInstanceDungeonBase* pID = GetDungeonPtr( GetType( dwWorldId ) );
if( pID )
pID->SetInstanceDungeonKill( dwWorldId, dwDungeonId, dwMonsterId );
}
void CInstanceDungeonHelper::OnDeleteDungeonCoolTimeInf o( int nType, DWORD dwPlayerId )
{
CInstanceDungeonBase* pID = GetDungeonPtr( nType );
if( pID )
pID->DeleteDungeonCoolTimeInfo( dwPlayerId );
}
#ifdef __TIMER
void CInstanceDungeonHelper::SerializeCoolTimeInfo(CAr & ar, u_long idPlayer)
{
CInstanceDungeonBase *pID = GetDungeonPtr(IDTYPE_PARTY);
if( !pID )
{
ar << (char)0;
return;
}
pID->SerializeCoolTime(ar, idPlayer);
}
#endif // __TIMER
#endif // __WORLDSERVER
#endif // __INSTANCE_DUNGEON
Instancedungeonbase.h
// InstanceDungeonBase.h: interface for the CInstanceDungeonBase class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_INSTANCEDUNGEONBASE_H__5F92E1D4_2A9F_ 4602_8D26_35E328B9C160__INCLUDED_)
#define AFX_INSTANCEDUNGEONBASE_H__5F92E1D4_2A9F_4602_8D26 _35E328B9C160__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __VER >= 14 // __INSTANCE_DUNGEON
#include "ar.h"
#ifdef __WORLDSERVER
#include "defineText.h"
#endif // __WORLDSERVER
enum { IDTYPE_SOLO=0, IDTYPE_PARTY, IDTYPE_GUILD, IDTYPE_MAX };
enum { ID_NORMAL=0, ID_MIDBOSS, ID_BOSS };
#ifdef __3RD_LEGEND16
const WORD CLASS_NORMAL=0x0001, CLASS_MASTER=0x0002, CLASS_HERO=0x0004, CLASS_LEGEND_HERO=0x0008;
#else // __3RD_LEGEND16
const WORD CLASS_NORMAL=0x0001, CLASS_MASTER=0x0002, CLASS_HERO=0x0004;
#endif // __3RD_LEGEND16
const int COOLTIMECOUNT = 10;
typedef struct INSTACNEDUNGEON_INFO
{
DWORD dwWorldId;
ULONG uMultiKey;
#ifdef __WORLDSERVER
int nState;
int nPlayerCount;
int nKillCount;
#endif // __WORLDSERVER
INSTACNEDUNGEON_INFO( DWORD dwWI, ULONG uMK ) : dwWorldId( dwWI ), uMultiKey( uMK )
#ifdef __WORLDSERVER
,nState( ID_NORMAL ), nPlayerCount( 0 ), nKillCount( 0 )
#endif // __WORLDSERVER
{}
void Serialize( CAr & ar )
{
if( ar.IsStoring() )
ar << dwWorldId << uMultiKey;
else
ar >> dwWorldId >> uMultiKey;
}
} ID_INFO;
typedef vector<ID_INFO> VEC_IDINFO;
typedef map<DWORD, VEC_IDINFO> MAP_IDBASE;
struct COOLTIME_INFO
{
DWORD dwWorldId;
DWORD dwDungeonId;
DWORD dwCoolTime;
COOLTIME_INFO() : dwWorldId( NULL_ID), dwDungeonId( NULL_ID ), dwCoolTime( 0 ) {}
COOLTIME_INFO( DWORD dwWI, DWORD dwDI, DWORD dwCT ) : dwWorldId( dwWI ), dwDungeonId( dwDI ), dwCoolTime( dwCT ) {}
void Serialize( CAr & ar )
{
if( ar.IsStoring() )
ar << dwWorldId << dwDungeonId << ( dwCoolTime - GetTickCount() );
else
{
ar >> dwWorldId >> dwDungeonId >> dwCoolTime;
dwCoolTime += GetTickCount();
}
}
};
typedef vector<COOLTIME_INFO> VEC_CTINFO;
typedef map<DWORD, VEC_CTINFO> MAP_CTINFO;
//////////////////////////////////////////////////////////////////////
// CInstanceDungeonBase
//////////////////////////////////////////////////////////////////////
class CInstanceDungeonBase
{
public:
CInstanceDungeonBase( int nIDType );
virtual ~CInstanceDungeonBase();
int GetType() { return m_nIDType; }
void SerializeAllInfo( CAr & ar );
BOOL CreateDungeon( ID_INFO ID_Info, DWORD dwDungeonId );
BOOL DestroyDungeon( ID_INFO ID_Info, DWORD dwDungeonId );
void DestroyAllDungeonByDungeonID( DWORD dwDungeonId );
void DestroyAllDungeonByMultiKey( ULONG uMultiKey ); //ÇöÀç±îÁö´Â CoreServer¸¸ »ç¿ë.
void SetDungeonCoolTimeInfo( COOLTIME_INFO CT_Info, DWORD dwPlayerId );
void ResetDungeonCoolTimeInfo( DWORD dwWorldId, DWORD dwDungeonId );
private:
BOOL CreateDungeonLayer( ID_INFO & ID_Info, DWORD dwLayer );
BOOL DestroyDungeonLayer( ID_INFO & ID_Info, DWORD dwLayer );
VEC_IDINFO* GetDungeonVector( DWORD dwDungeonId );
ID_INFO* GetDungeonInfo( DWORD dwDungeonId, DWORD dwWorldId );
VEC_CTINFO* GetCoolTimeVector( DWORD dwPlayerId );
COOLTIME_INFO* GetCoolTimeInfo( DWORD dwPlayerId, DWORD dwWorldId );
int m_nIDType;
MAP_IDBASE m_mapID;
MAP_CTINFO m_mapCTInfo;
#ifdef __CORESERVER
public:
void DungeonCoolTimeCountProcess();
void UpdateDungeonCoolTimeInfo();
private:
int m_nCoolTimeCount;
#endif // __CORESERVER
#ifdef __WORLDSERVER
private:
struct DUNGEON_DATA
{
struct MONSTER
{
int nState;
DWORD dwMonsterId;
BOOL bRed;
D3DXVECTOR3 vPos;
};
DWORD dwClass;
int nMinLevel;
int nMaxLevel;
DWORD dwCoolTime;
map<int, D3DXVECTOR3> mapTeleportPos;
vector<MONSTER> vecMonster;
map<int, int> mapObjCount;
};
typedef map<DWORD, DUNGEON_DATA> MAP_IDDATA;
MAP_IDDATA m_mapDungeonData;
int GetState( DWORD dwWorldId, DWORD dwDungeonId );
void SetNextState( ID_INFO* pInfo, DWORD dwDungeonId );
D3DXVECTOR3 GetTeleportPos( DWORD dwWorldId, DWORD dwDungeonId );
BOOL CheckClassLevel( CUser* pUser, DWORD dwWorldId );
void CreateMonster( DWORD dwDungeonId, DWORD dwWorldId );
BOOL IsNowStateMonster( DWORD dwWorldId, DWORD dwDungeonId, DWORD dwMonsterId );
int GetObjCount( DWORD dwWorldId, DWORD dwDungeonId );
DWORD GetCoolTime( DWORD dwWorldId );
BOOL IncreasePlayerCount( DWORD dwDungeonId, DWORD dwWorldId );
BOOL DecreasePlayerCount( CUser* pUser, DWORD dwDungeonId, DWORD dwWorldId );
BYTE m_nMaxInstanceDungeon;
protected:
BOOL TeleportToDungeon( CUser* pUser, DWORD dwWorldId, DWORD dwDungeonId );
BOOL LeaveToOutside( CUser* pUser, DWORD dwWorldId, DWORD dwDungeonId );
void SetLeaveMarkingPos( CUser* pUser, DWORD dwWorldId, D3DXVECTOR3 vPos );
public:
void LoadScript( const char* szFileName );
virtual BOOL EnteranceDungeon( CUser* pUser, DWORD dwWorldId ) = FALSE;
virtual BOOL LeaveDungeon( CUser* pUser, DWORD dwWorldId ) = FALSE;
void SetInstanceDungeonKill( DWORD dwWorldId, DWORD dwDungeonId, DWORD dwMonsterId );
void DeleteDungeonCoolTimeInfo( DWORD dwPlayerId );
#ifdef __TIMER
void SerializeCoolTime(CAr & ar, u_long idPlayer);
#endif
#endif // __WORLDSERVER
};
//////////////////////////////////////////////////////////////////////
// CInstanceDungeonHelper
//////////////////////////////////////////////////////////////////////
class CInstanceDungeonHelper
{
public:
CInstanceDungeonHelper();
~CInstanceDungeonHelper();
static CInstanceDungeonHelper* GetInstance();
void OnCreateDungeon( int nType, ID_INFO ID_Info, DWORD dwDungeonId );
void OnDestroyDungeon( int nType, ID_INFO ID_Info, DWORD dwDungeonId );
void OnSetDungeonCoolTimeInfo( ULONG uKey, int nType, COOLTIME_INFO CT_Info, DWORD dwPlayerId );
void OnResetDungeonCoolTimeInfo( int nType, DWORD dwWorldId, DWORD dwDungeonId );
void SendInstanceDungeonCreate( int nType, DWORD dwDungeonId, ID_INFO & ID_Info );
void SendInstanceDungeonDestroy( int nType, DWORD dwDungeonId, ID_INFO & ID_Info );
void SendInstanceDungeonSetCoolTimeInfo( ULONG uKey, int nType, DWORD dwPlayerId, COOLTIME_INFO & CT_Info );
void DestroyAllDungeonByMultiKey( ULONG uMultiKey );
private:
CInstanceDungeonBase* GetDungeonPtr( int nType );
typedef map<DWORD, int> MAP_WORLD2TYPE;
MAP_WORLD2TYPE m_mapDungeonType;
#ifdef __CORESERVER
public:
void SendInstanceDungeonAllInfo( DWORD dpId );
void SendInstanceDungeonDeleteCoolTimeInfo( int nType, DWORD dwPlayerId );
#endif // __CORESERVER
#ifdef __WORLDSERVER
public:
void OnInstanceDungeonAllInfo( CAr & ar );
BOOL IsDungeonType( DWORD dwWorldId, int nType ) { return GetType( dwWorldId ) == nType; }
BOOL IsInstanceDungeon( DWORD dwWorldId ) { return GetType( dwWorldId ) != NULL_ID; }
void SetDungeonType( DWORD dwWorldId, int nType );
BOOL EnteranceDungeon( CUser* pUser, DWORD dwWorldId );
BOOL LeaveDungeon( CUser* pUser, DWORD dwWorldId );
void GoOut( CUser* pUser );
void SetInstanceDungeonKill( DWORD dwWorldId, DWORD dwDungeonId, DWORD dwMonsterId );
void OnDeleteDungeonCoolTimeInfo( int nType, DWORD dwPlayerId );
BYTE m_nIDLayerNum;
#ifdef __TIMER
void SerializeCoolTimeInfo(CAr & ar, u_long idPlayer);
#endif // __TIMER
private:
void SetCertifyKey( ULONG uMultiKey = NULL_ID );
BOOL IsCertifying() { return m_uCertifyKey != NULL_ID; }
int GetType( DWORD dwWorldId );
ULONG m_uCertifyKey;
#endif // __WORLDSERVER
};
#endif // __INSTANCE_DUNGEON
#endif // !defined(AFX_INSTANCEDUNGEONBASE_H__5F92E1D4_2A9F_ 4602_8D26_35E328B9C160__INCLUDED_)
InstanceDungeonParty.cpp
// InstanceDungeonParty.cpp: implementation of the CInstanceDungeonParty class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "InstanceDungeonParty.h"
#if __VER >= 14 // __INSTANCE_DUNGEON
#ifdef __WORLDSERVER
#include "Mover.h"
#include "Obj.h"
#include "User.h"
#endif // __WORLDSERVER
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CInstanceDungeonParty::CInstanceDungeonParty()
: CInstanceDungeonBase( IDTYPE_PARTY )
{
}
CInstanceDungeonParty::~CInstanceDungeonParty()
{
#ifdef __WORLDSERVER
m_mapPLTime.clear();
#endif // __WORLDSERVER
}
CInstanceDungeonParty* CInstanceDungeonParty::GetInstance()
{
static CInstanceDungeonParty sIDP;
return & sIDP;
}
#ifdef __WORLDSERVER
BOOL CInstanceDungeonParty::EnteranceDungeon( CUser* pUser, DWORD dwWorldId )
{
if( pUser->m_idparty > 0 )
return TeleportToDungeon( pUser, dwWorldId, pUser->m_idparty );
else
pUser->AddDefinedText( TID_GAME_INSTANCE_PARTY );
return FALSE;
}
BOOL CInstanceDungeonParty::LeaveDungeon( CUser* pUser, DWORD dwWorldId )
{
return LeaveToOutside( pUser, dwWorldId, pUser->GetLayer() );
}
BOOL CInstanceDungeonParty::SetPartyLeaveTime( DWORD dwPlayerId )
{
CUser* pUser = static_cast<CUser*>( prj.GetUserByID( dwPlayerId ) );
if( !IsValidObj( pUser ) )
return FALSE;
CWorld* pWorld = pUser->GetWorld();
if( !pWorld )
return FALSE;
if( CInstanceDungeonHelper::GetInstance()->IsInstanceDungeon( pWorld->GetID() ) )
{
MAP_PLTIME::iterator it = m_mapPLTime.find( dwPlayerId );
if( it == m_mapPLTime.end() )
m_mapPLTime.insert( MAP_PLTIME::value_type( dwPlayerId, GetTickCount() + MIN( 3 ) ) );
else
it->second = GetTickCount() + MIN( 3 );
}
return TRUE;
}
void CInstanceDungeonParty::Process()
{
DWORD dwTickCount = GetTickCount();
for( MAP_PLTIME::iterator it=m_mapPLTime.begin(); it!=m_mapPLTime.end(); )
{
if( it->second < dwTickCount )
{
CUser* pUser = static_cast<CUser*>( prj.GetUserByID( it->first ) );
m_mapPLTime.erase( it++ );
if( !IsValidObj( pUser ) )
return;
CWorld* pWorld = pUser->GetWorld();
if( !pWorld )
return;
if( pUser->GetLayer() != pUser->m_idparty && IsPartyDungeon( pWorld->GetID() ) )
CInstanceDungeonHelper::GetInstance()->GoOut( pUser );
}
else
it++;
}
}
#endif // __WORLDSERVER
#endif // __INSTANCE_DUNGEON
InstanceDungeonParty.h
// InstanceDungeonParty.h: interface for the CInstanceDungeonParty class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_INSTANCEDUNGEONPARTY_H__6DEF4167_3C00 _4369_9AA3_A846FDF6EFD9__INCLUDED_)
#define AFX_INSTANCEDUNGEONPARTY_H__6DEF4167_3C00_4369_9AA 3_A846FDF6EFD9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __VER >= 14 // __INSTANCE_DUNGEON
#include "InstanceDungeonBase.h"
class CInstanceDungeonParty : public CInstanceDungeonBase
{
public:
CInstanceDungeonParty();
virtual ~CInstanceDungeonParty();
static CInstanceDungeonParty* GetInstance();
#ifdef __WORLDSERVER
virtual BOOL EnteranceDungeon( CUser* pUser, DWORD dwWorldId );
virtual BOOL LeaveDungeon( CUser* pUser, DWORD dwWorldId );
BOOL SetPartyLeaveTime( DWORD dwPlayerId );
void Process();
private:
BOOL IsPartyDungeon( DWORD dwWorldId ) { return CInstanceDungeonHelper::GetInstance()->IsDungeonType( dwWorldId, GetType() ); }
typedef map<DWORD, DWORD> MAP_PLTIME;
MAP_PLTIME m_mapPLTime;
#endif // __WORLDSERVER
};
#endif // __INSTANCE_DUNGEON
#endif // !defined(AFX_INSTANCEDUNGEONPARTY_H__6DEF4167_3C00 _4369_9AA3_A846FDF6EFD9__INCLUDED_)