📄 dungeon.cpp
字号:
if( !pVoteFalse || !pVoteTrue ) return 0;
int count1 = pVoteFalse->GetCount();
int count2 = pVoteTrue->GetCount();
CDungeonMap* pDungeonMap = GetActiveDungeonMap();
pDungeonMap->OpenDragonRoadObject(); // 菊阑 阜绊 乐绰 坷宏璃飘甫 绝矩促.
POINTS data;
data.x = count2;
data.y = count1;
if( !count1 && count2 ) // 蛮己捞 捞变版快
{
pDungeonMap->DeleteDragon();
::SendScenarioMessage(SEND_ALL, SMT_DRAGONROAD_MESSAGE2 , &data, sizeof( POINTS ));
}
else if( count1 && count2 ) // 矫埃 郴俊 给 场辰 版快
{
SendScenarioMessage(SEND_ALL, SMT_DRAGONROAD_MESSAGE5 ); // 捞仇甸 促 磷捞摆促.
}
else if( count1 && !count2 ) // 馆措啊 捞变版快
{
::SendScenarioMessage(SEND_ALL, SMT_DRAGONROAD_MESSAGE3 , &data, sizeof( POINTS ));
}
return 1;
}
int CDungeonMapMgr::ScenarioFightProc( CDungeonObject *pDO )
{
CDungeonMap* pDungeonMap = GetActiveDungeonMap();
if( !pVoteTrue ) // 弊成 靛贰帮 老锭..
{
pDungeonMap->OpenDragonRoadObject();
return 0;
}
int count1 = pVoteFalse->GetCount();
int count2 = pVoteTrue->GetCount();
POINTS data;
data.x = count2;
data.y = count1;
if( !count1 && count2 ) // 蛮己父 乐绰 版快
{
pDungeonMap->OpenDragonRoadObject(); // 菊阑 阜绊 乐绰 坷宏璃飘甫 绝矩促.
::SendScenarioMessage(SEND_ALL, SMT_DRAGONROAD_MESSAGE2 , &data, sizeof( POINTS ));
// 酒捞袍阑 谎府绊 靛贰帮 肺靛甫 绝矩促.
pDO->DeletBoss();
}
else if( count1 && count2 ) // 蛮馆捞 哎赴版快
{ //< CSD-030225
POINT MovePoint[3];
for( int i=0; i<3; i++ )
{
MovePoint[i].x = pDungeonMap->m_nOutX;
MovePoint[i].y = pDungeonMap->m_nOutY;
}
int *team1;
int *team2;
team1= new int[count1];
team2= new int[count2];
TKeinList<int> *target = pVoteFalse;
int ct = 0;
target->SetFind();
while( target->FindNext() )
{
team1[ct++] = target->GetFind();
}
target = pVoteTrue;
ct = 0;
target->SetFind();
while( target->FindNext() )
{
team2[ct++] = target->GetFind();
}
g_pDragonLordWar.ActiveWar(20*60,ScenarioDragonEndWar,30,ScenarioDragonMsgFunc,
MovePoint,count1,team1,count2,team2);
SAFE_DELETE_ARRAY(team1);
SAFE_DELETE_ARRAY(team2);
::SendScenarioMessage(SEND_ALL, SMT_DRAGONROAD_MESSAGE4, &data, sizeof( POINTS ));
} //> CSD-030225
else if( count1 && !count2 ) // 葛滴 馆措茄 版快
{
// 靛贰帮 肺靛窍绊 轿款促.
pDungeonMap->OpenDragonRoadObject(); // 菊阑 阜绊 乐绰 坷宏璃飘甫 绝矩促.
::SendScenarioMessage(SEND_ALL, SMT_DRAGONROAD_MESSAGE3 , &data, sizeof( POINTS ));
}
else
{
// 靛贰帮 肺靛甫 绝矩促.
pDO->DeletBoss();
}
return 1;
}
///////////////////////////////////////////////
int CDungeonHistory::SetData( int type, int layer, char *name, const char *mapname )
{
m_nType = type;
struct tm *now;
time_t nowTime;
time( &nowTime );
now = localtime(&nowTime);
m_nMonth = now->tm_mon + 1;
m_nDay = now->tm_mday;
m_nHour = now->tm_hour;
m_nMin= now->tm_min;
m_nLayer = layer;
strcpy( m_szName, name?name:"" );
strcpy( m_szDungeon, mapname?mapname:MapName );
return 1;
}
int CDungeonMgr::Proc()
{
for( int i=0; i<m_nCount; i++ )
{
CDungeonBasic* pTemp = GetDungeon(i);
if(pTemp)
{
pTemp->Proc();
}
}
return 1;
}
int CDungeonBasic::SendScenarioStatus()
{
t_packet packet;
packet.h.header.type = CMD_SCENARIO_COMMAND;
packet.u.data[0] = TYPE_STATUS;
memcpy( &packet.u.data[1], m_pActive, sizeof( int ) );
packet.h.header.size = 5;
if( CheckMapPort( m_nDungeonMapPort1 ) )
{
RecvScenarioCommand( &packet );
}
else
{
::SendPacket2Map( &packet, m_nDungeonMapPort1 );
}
if( CheckMapPort( m_nDungeonMapPort2 ) )
{
RecvScenarioCommand( &packet );
}
else
{
::SendPacket2Map( &packet, m_nDungeonMapPort2 );
}
return 1;
}
int CDungeonBasic::SaveDungeonStatus( )
{
//return 1;
char query[256];
if( m_nActive )
{
if(LocalMgr.IsFreeBeta())//030102 lsw
{
sprintf( query, "Update scenario_dungeon set start_time = wait_time - 2 where id = %d", m_nId );
}
else
{
sprintf( query, "Update scenario_dungeon set start_time = wait_time - 60 where id = %d", m_nId );
}
}
else
{
sprintf( query, "Update scenario_dungeon set start_time = %d where id = %d", m_nStartTime, m_nId );
}
::Querry_SQL( query );
return 1;
}
int CDungeonBasic::Proc()
{ //< CSD-030324
if( m_nActive )
{
m_nStartTime++;
if (IsCloseDungeon(m_nIndex))
{
// 扁废 巢辫
CDungeonHistory data;
data.SetData( data.DUNGEON_CLOSE, 1, NULL, ::GetMapName2(m_nDungeonMapPort1) );
::SendDungeonHistory(&data);
// close 矫挪促. // 葛滴 泼辫
m_nStartTime = 0;
SetActiveFlag(0);
t_packet packet;
packet.h.header.type = CMD_SCENARIO_MESSAGE_MAP;
packet.h.header.size = sizeof( k_scenario_message );
packet.u.kein.scenario_message.type = 1;
packet.u.kein.scenario_message.port = m_nDungeonMapPort1;
::SendPacket2Maps( &packet );
RecvScenarioMessageMap( &packet, -1 );
}
}
else
{
m_nStartTime++;
for (int i = 0; i < GetStartUpInfoCount(); ++i)
{
if (IsOpenDungeon(i))
{ // open 矫挪促.
CDungeonHistory data;
data.SetData(data.DUNGEON_OPEN, 1, NULL, ::GetMapName2(m_nDungeonMapPort1));
::SendDungeonHistory( &data );
m_nStartTime = 0;
SetActiveFlag(1, 1, 1);
t_packet packet;
packet.h.header.type = CMD_SCENARIO_MESSAGE_MAP;
packet.h.header.size = sizeof( k_scenario_message );
packet.u.kein.scenario_message.type = 2;
packet.u.kein.scenario_message.port = m_nDungeonMapPort1;
::SendPacket2Maps(&packet);
RecvScenarioMessageMap(&packet, -1);
m_nIndex = i;
break;
}
}
}
return 1;
} //> CSD-030324
/////////////////////////////////////////////////
CDungeonMapMgr *g_pDungeonMap = NULL; // 秦寸 甘俊 乐绰 带傈甸( 1摸, 2摸 )狼 包府 努贰胶
CDungeonMgr *g_pDungeonMgr = NULL; // 葛电 带傈( 酒厚胶 固泵,.. )狼 包府 努贰胶
////////////////////////////////////////////////////////
// 坷宏璃飘甫 焊郴临锭 犬牢秦辑 event鸥老档 鞍捞 焊郴霖促.
void CheckDungeonObject( int id, short int cn )
{
if( g_pDungeonMap ) g_pDungeonMap->SendEventWhenAddItem( id, cn );
}
bool DungeonEventTileProc( int event_no, short int cn )
{
if( event_no < 20 ) return 0;
CHARLIST *ch = CheckServerId( cn );
if( !ch ) return 0;
if( !g_pDungeonMap ) return 0;
return g_pDungeonMap->CheckObject( cn, event_no );
}
int SendDungeonHistory( CDungeonHistory *pHistory )
{
if( g_pDungeonMgr )
{
CDungeonHistory *pData = new CDungeonHistory;
*pData = *pHistory;
g_pDungeonMgr->m_History.AddNodeLimit( pData, 5 );
// 030211 YGI
MyLog( 0, "[Scenario message] Manage, type:%d, layer:%d, name:[%s]",
pHistory->m_nType, pHistory->m_nLayer, pHistory->m_szName?pHistory->m_szName:" " );
}
else // 包府 辑滚肺 焊辰促.
{
t_packet packet;
packet.h.header.type = CMD_SEND_DUNGEON_HISTORY;
packet.h.header.size = sizeof( k_send_dungeon_history );
packet.u.kein.send_dungeon_history.type = pHistory->m_nType;
packet.u.kein.send_dungeon_history.layer = pHistory->m_nLayer;
strcpy( packet.u.kein.send_dungeon_history.map, pHistory->m_szDungeon );
// 030211 YGI
strcpy( packet.u.kein.send_dungeon_history.name, pHistory->m_szName?pHistory->m_szName:" " );
SendPacket2Map( &packet, MN_SCENARIO_MAP );
}
return 1;
}
int RecvDungeonHistory( t_packet *p )
{
int type = p->u.kein.send_dungeon_history.type;
int layer = p->u.kein.send_dungeon_history.layer ;
char *name = p->u.kein.send_dungeon_history.name ;
char *map = p->u.kein.send_dungeon_history.map ;
if( g_pDungeonMgr )
{
CDungeonHistory *pData = new CDungeonHistory;
pData->SetData( type, layer, name, map );
g_pDungeonMgr->m_History.AddNodeLimit( pData, 5 );
// 030211 YGI
MyLog( 0, "[Scenario message] Manage, type:%d, layer:%d, name:[%s]", type, layer, name );
}
return 1;
}
void RecvGetScenarioInfo( t_packet *p, short int cn )
{
CHARLIST *ch = CheckServerId( cn );
if( !ch ) return;
if( g_pDungeonMap )//郴啊 带傈甘捞搁 洒胶配府甫 焊郴霖促.
{
CDungeonMap *pDMap = g_pDungeonMap->GetActiveDungeonMap();
if( pDMap )
{
t_packet packet;
packet.h.header.type = CMD_GET_SCENARIO_INFO;
k_get_scenario_info &scenario_info = packet.u.kein.get_scenario_info;
scenario_info.count = pDMap->m_History.GetCount();
if( !scenario_info.count ) return;
for( int i=0; i<=scenario_info.count; i++ )
{
CDungeonHistory *pHistory = pDMap->m_History.GetData(i);
if( !pHistory ) continue;
scenario_info.data[i].day = pHistory->m_nDay;
scenario_info.data[i].SHour= pHistory->m_nHour;
scenario_info.data[i].SMin = pHistory->m_nMin;
scenario_info.data[i].type = pHistory->m_nType;
scenario_info.data[i].layer = pHistory->m_nLayer;
strcpy( scenario_info.data[i].dungeon_map, pHistory->m_szDungeon );
}
packet.h.header.size = 1+sizeof( k_get_scenario_info_basic )*(scenario_info.count);
QueuePacket( connections, cn, &packet, 1 );
}
return;
}
else
{//郴啊 带傈甘捞 酒聪搁 带傈概聪历 辑滚肺 夸没 菩哦阑 焊晨
t_packet packet;
packet.h.header.type = CMD_GET_SCENARIO_INFO_MAP;
packet.h.header.size = sizeof( k_direct_map_req );
packet.u.kein.direct_map_req.port = GetOwnPort();
packet.u.kein.direct_map_req.server_id = cn;
SendPacket2Map( &packet, MN_SCENARIO_MAP );
}
}
void RecvGetScenarioInfoMap( t_packet *p, int type )//促弗甘俊辑 夸没茄 荤亲捞扼搁 攫力凯府绰瘤父 舅妨林搁 等促.
{
if( !g_pDungeonMgr ){return;}//概聪历啊 酒聪搁 府畔
const int port = p->u.kein.direct_map_req.port;
const int server_id = p->u.kein.direct_map_req.server_id;
k_get_scenario_info scenario_info = {0,};
const int iCount = g_pDungeonMgr->GetCount();
for(int i=0, j=0 ; iCount > j ; j++)
{
if(MAX_START_UP_INFO <= i){break;}
CDungeonBasic *pTemp = g_pDungeonMgr->GetDungeon(j);
if(!pTemp){continue;}
const int iSUIct = MAX_START_UP_INFO;//pTemp->GetStartUpInfoCount();
for(int k=0; iSUIct>k;k++)
{
if(MAX_START_UP_INFO <= i){break;}
START_UP_INFO *pSUI= pTemp->GetStartUpInfo(k);
if(!pSUI){continue;}
if(pSUI->nApplyDay < g_wday){continue;}//瘤唱埃朝篮 救焊咯淋
k_get_scenario_info_basic *pSUIB = &scenario_info.data[i];
i++;
pSUIB->day = pSUI->nApplyDay;
pSUIB->SHour = pSUI->nStartHour;
pSUIB->SMin = pSUI->nStartMinute;
pSUIB->EHour = pSUI->nEndHour;
pSUIB->EMin = pSUI->nEndMinute;
pSUIB->layer = j;//带傈 矫唱府坷 鸥涝
pSUIB->type = CDungeonHistory::DUNGEON_WHEN_OPEN_CLOSE_NOTICE;
::strcpy( pSUIB->dungeon_map, ::GetMapName2(pTemp->m_nDungeonMapPort1));
break;//弥檬狼 茄俺父 焊咯淋
}
}
scenario_info.count = i;
int size = sizeof(char) + sizeof( k_get_scenario_info_basic )*i;
if( !type )//促弗甘俊辑 夸没捞 甸绢吭阑 版快
{
SendDirectClientOtherMap( CMD_GET_SCENARIO_INFO, server_id, port, &scenario_info, size );
}
else//辑滚郴何俊辑 何甫 版快
{
SendPacketDefault( CMD_GET_SCENARIO_INFO, &scenario_info, size, server_id );
}
}
void DugeonMgrProc()
{
static old_time = 0;
if( g_curr_time - old_time < 60 ) return;
old_time = g_curr_time;
if( g_pDungeonMgr ) g_pDungeonMgr->Proc();
if( g_pDungeonMap ) g_pDungeonMap->Proc();
}
void RecvScenarioCommand( t_packet *p )
{
int type = p->u.data[0];
switch( type )
{
case CDungeonBasic::TYPE_STATUS :
{
if( !g_pDungeonMap ) return;
g_pDungeonMap->SetSatus( &p->u.data[1] );
break;
}
case CDungeonBasic::TYPE_STATUS_REGIST :
{
if( !g_pDungeonMgr ) return;
int layer = p->u.data[1];
int active = p->u.data[2];
WORD port;
memcpy( &port, &p->u.data[3], sizeof( WORD ) );
CDungeonBasic* pDungeon = g_pDungeonMgr->GetDungeonByPort(port);
if( !pDungeon ) return;
pDungeon->SetActiveFlag( layer, active, 1 );
break;
}
}
}
void SendRegistDungeonMgrServer( int type, void *msg, int size )
{
t_packet packet;
packet.h.header.type = CMD_SCENARIO_COMMAND;
packet.h.header.size = size+1;
packet.u.data[0] = type;
memcpy( &packet.u.data[1], msg, size );
if( CheckMapPort( MN_SCENARIO_MAP ) )
RecvScenarioCommand( &packet );
else
::SendPacket2Map( &packet, MN_SCENARIO_MAP );
}
void SendCheckGotoScenarioDungeon( short int cn, char *map_name, int x, int y )
{
CHARLIST *ch = CheckServerId( cn );
if( !ch ) return;
t_packet packet;
packet.h.header.type = CMD_CHECK_GOTO_SCENARIO_DUNGEON;
strcpy( packet.u.kein.check_goto_scenario_dungeon_map.name, ch->Name );
strcpy( packet.u.kein.check_goto_scenario_dungeon_map.dungeon, map_name );
packet.u.kein.check_goto_scenario_dungeon_map.cn = cn;
packet.u.kein.check_goto_scenario_dungeon_map.x = x;
packet.u.kein.check_goto_scenario_dungeon_map.y = y;
packet.u.kein.check_goto_scenario_dungeon_map.map_port = GetOwnPort();
packet.h.header.size = sizeof( k_check_goto_scenario_dungeon_map );
if( CheckMapPort(MN_SCENARIO_MAP) )
{
RecvCheckGotoScenarioDungeon( &packet, -1 );
}
else
{
SendPacket2Map( &packet, MN_SCENARIO_MAP );
}
}
void RecvCheckGotoScenarioDungeon( t_packet *p, short int cn )
{
if( !g_pDungeonMgr ) return;
int map_port = p->u.kein.check_goto_scenario_dungeon_map.map_port;
char *dungeon_name = p->u.kein.check_goto_scenario_dungeon_map.dungeon;
int port = GetMapPortByName( dungeon_name );
if( !port ) return;
if( g_pDungeonMgr->CheckActive( port ) )
{
p->h.header.type = CMD_CHECK_GOTO_SCENARIO_DUNGEON_RESULT;
if( CheckMapPort( map_port ) )
{
RecvCheckGotoScenarioDungeonResult( p, -1 );
}
else
{
SendPacket2Map( p, map_port );
}
}
else
{
// 角菩矫 皋矫瘤
}
}
void RecvCheckGotoScenarioDungeonResult( t_packet *p, short int cn )
{
int server_id = p->u.kein.check_goto_scenario_dungeon_map.cn;
char *dungeon_name = p->u.kein.check_goto_scenario_dungeon_map.dungeon;
char *name = p->u.kein.check_goto_scenario_dungeon_map.name;
int x = p->u.kein.check_goto_scenario_dungeon_map.x;
int y = p->u.kein.check_goto_scenario_dungeon_map.y;
CHARLIST *ch = CheckServerId( server_id );
if( !ch ) return;
if( strcmp( ch->Name, name ) != 0 ) return; // 促弗 仇捞促.
MapMove( server_id, dungeon_name, x, y );
}
void RecvScenarioMessageMap( t_packet *p, short int cn )
{
p->h.header.type = CMD_SCENARIO_MESSAGE;
g_pUserManager->SendPacket(p); // CSD-CN-031213
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -