📄 nationsys.cpp
字号:
WarfieldNo=1;
}
if (g_pWarfieldStatus[2].Status==StatusNo)
{
WarfieldNo=2;
}
}
return WarfieldNo;
}
void InitConnectionsSquadData(const int cn)// 目臣记狼 NWCharacter甫 檬扁拳 茄促.
{
if (connections[cn].chrlst.name_status.nation!=NW_YL) // 011020 LTS // 老胶捞搁 AM_I_DEFEAT俊辑 檬扁拳 茄促
memset(&connections[cn].chrlst.NWCharacter,0,sizeof(DWORD)); // 010915 LTS
}
void DeleteSquadMember(const int cn) // DragonServer.cpp Extern捞扁 锭巩俊 努贰胶俊 器窃矫虐瘤 臼疽促.
{
if (isNationWarfieldServer())
{
g_pWarfield->DeleteSquadMember(cn);
g_pWarfield->DecNationMemberCount(connections[cn].chrlst.name_status.nation);
}
if (isNewWarfieldServer())
{
g_pNewWarfield->DeleteMember(cn);
}
}
bool LoadWarfieldPossession() // 胶鸥飘诀矫 DB俊辑 WarfieldPossession狼 蔼阑 佬绢柯促.
{
HSTMT hStmt=NULL;
RETCODE ret;
SWORD nClos;
char query_stmt[80]={0,};
SDWORD cbValue;
SQLAllocStmt(hDBC,&hStmt);
wsprintf(query_stmt,"select WarfieldCode,NationCode from WarfieldTBL order by WarFieldCode");
ret=SQLExecDirect(hStmt,(UCHAR*)query_stmt,SQL_NTS);
if (ret!=SQL_SUCCESS_WITH_INFO && ret !=SQL_SUCCESS)
{
MyLog(0,"LoadWarfieldPossession(), WarField Table Query Error!!");
SQLFreeStmt(hStmt,SQL_DROP);
return false;
}
SQLNumResultCols(hStmt,&nClos);
ret=SQLFetch(hStmt);
if (ret!=SQL_SUCCESS_WITH_INFO && ret !=SQL_SUCCESS)
{
MyLog(0,"LoadWarfieldPossession(), WarField Table Fetch Error!!");
SQLFreeStmt(hStmt,SQL_DROP);
return false;
}
int index=0;
while (ret==SQL_SUCCESS)
{
ret=SQLGetData(hStmt,2,SQL_C_SLONG,&g_pWarfieldStatus[index].Possession,sizeof(int),&cbValue);
if (ret!=SQL_SUCCESS_WITH_INFO && ret!=SQL_SUCCESS)
{
MyLog(0,"LoadWarfieldPossession(), Warfield Table SQL Return Error(%d)!!",ret);
SQLFreeStmt(hStmt,SQL_DROP);
return false;
}
index++;
if (index>=3) break;
ret=SQLFetch(hStmt);
}
SQLFreeStmt(hStmt,SQL_DROP);
return true;
}
// Where : Call From Main.cpp InitDrmapServerDatas()
// Usage : Initializing Nation War System
bool InitNationSystem()
{
SERVER_DATA *pData=g_pServerTable->GetOwnServerData();
g_wMapServerPort=pData->wPort;
if (isNationManageServer())
{
g_pNation=new cNation;
if (g_pNation==NULL)
{
return false;
}
}
if (isNationWarfieldServer())
{
g_pWarfield=new cWarfield;
if (g_pWarfield==NULL)
{
return false;
}
}
if (isNewWarfieldServer())
{
g_pNewWarfield=new CNewWarfield;
if (g_pNewWarfield==NULL)
{
return false;
}
if (!g_pNewWarfield->InitWarfield())
{
return false;
}
}
//LoadAIConfig(); // 030919 HK YGI
if (!LoadNewWarMaxMin())
return false;
if (!LoadNationWar_Exp())
{
return false; // LTS NEW LOCALWAR
}
return LoadWarfieldPossession();
}
// Where : Call From SealStone.cpp CheckNationWar()
// Usage : Update Nation War System
bool UpdateNationWarData()
{
if (isNationManageServer())
{
if (g_pNation==NULL)
{
MyLog(0,"g_pNation was not Initiaized..!!");
return false;
}
g_pNation->UpdateStatus();
return true;
}
if (isNationWarfieldServer())
{
if (g_pWarfield==NULL)
{
MyLog(0,"g_pWarLoop was not Intialized..!!");
return false;
}
g_pWarfield->UpdateWarfieldStatus();
}
if (isNewWarfieldServer())
{
if (g_pNewWarfield==NULL)
{
JustMsg("g_pNewWarfield Not Inialized..!!");
return false;
}
g_pNewWarfield->Update();
}
return true;
}
// Where : Call From MapServer.cpp EndMapServer()
// Usage : Close Nation War System
void CloseNationSystem() // LTS 措父//020205 lsw
{
SAFE_DELETE(g_pWarfield);
SAFE_DELETE(g_pNation);
SAFE_DELETE(g_pNewWarfield);
ClearNationWar_Exp(); // LTS NEW LOCALWAR
ClearAIData(); // LTS NEW AI
}
void SendCMD_NW_MAP_MOVE_FAIL(t_connection c[],const int cn,const int Type) // 011213 LTS
{
t_packet packet;
packet.h.header.type=CMD_NW_MAP_MOVE_FAIL; // 甘捞悼捞 救邓聪促.
packet.u.NationWar.CommonDataC.Data=Type;
packet.h.header.size=sizeof(t_CommonDataC);
QueuePacket(c,cn,&packet,1);
}
void SendCMD_CHECK_WARFIELD_NATION_MEMBERCOUNT(t_packet *p,t_connection c[],const int cn)
{
t_packet packet;
packet.h.header.type=CMD_CHECK_WARFIELD_NATION_MEMBERCOUNT;
packet.u.NationWar.CheckNationMemberCount.Nation=c[cn].chrlst.name_status.nation;
packet.u.NationWar.CheckNationMemberCount.WarfieldNo=p->u.NationWar.NWMapMove.WarfieldNo;
packet.h.header.size=sizeof(t_CheckNationMemberCount);
int WarfieldNo=p->u.NationWar.NWMapMove.WarfieldNo;
if (WarfieldNo>=0&&WarfieldNo<=2)
SendCMD_REQUEST_DELIVERY(BASE_WARFIELD_PORT+p->u.NationWar.NWMapMove.WarfieldNo,&packet,c,cn);
else
if (WarfieldNo>=3)
SendCMD_REQUEST_DELIVERY(BASE_NEW_WARFIELD_PORT+WarfieldNo-3,&packet,c,cn);
}
void RecvCMD_NW_MAP_MOVE(t_packet *p,t_connection c[],const int cn)
{
LPCHARLIST ch = ::CheckServerId(cn);
if(!ch){return;}
const int WarfieldNo=p->u.NationWar.NWMapMove.WarfieldNo;
int WarfieldStatus = 0;
if (isNationManageServer())
{
if (WarfieldNo>=0&&WarfieldNo<=2)
{
WarfieldStatus=g_pNation->GetWarfieldStatus(WarfieldNo); // 傈里磐 惑怕甫 掘绢柯促.
}
else if (WarfieldNo>=3)
{
WarfieldStatus=g_pNation->GetNewWarfieldStatus(WarfieldNo); // 傈里磐 惑怕甫 掘绢柯促.
}
}
else
{
if (WarfieldNo>=0&&WarfieldNo<=2)
{
WarfieldStatus=g_pWarfieldStatus[WarfieldNo].Status;
}
else if (WarfieldNo>=3)
{
/* // 030515 kyo
if (isNewWarfieldServer()) // 030509 kyo //傈里辑滚捞搁
{
WarfieldStatus=g_pNewWarfield->GetWarfieldStatus();
}
else
*/
WarfieldStatus=g_pNewWarfieldStatus[WarfieldNo-3];
}
}
if (ch->GetLevel() <= ENABLE_NATIONWAR_LEVEL)
{ //< CSD-030806 : 傈里磐 捞悼 饭骇力茄
SendCMD_NW_MAP_MOVE_FAIL(c,cn,1);
return;
} //> CSD-030806
if (WarfieldStatus!=NW_WAR) {SendCMD_NW_MAP_MOVE_FAIL(c,cn,4); return; } // 傈里 霖厚扁埃捞 酒聪搁
if (WarfieldNo>=0&&WarfieldNo<=2)
{
if (ch->name_status.nation!=NW_YL)
{
if (!ch->IsReporter()) // 府器磐啊 酒聪搁
{
if (!ch->NWCharacter.SquadNo) //何措锅龋啊 绝促搁
{
if (!ch->NWCharacter.isCommander) {SendCMD_NW_MAP_MOVE_FAIL(c,cn,2); return; } // 荤飞包府 酒聪扼搁 府畔
}
}
} //炼扒 八荤啊 场车促.
}
else
if (WarfieldNo>=3)
{
if (ch->GetLevel() < MoveLevelMin[WarfieldNo - 3] || ch->GetLevel() > MoveLevelMax[WarfieldNo - 3])
{ //< CSD-030806
SendCMD_NW_MAP_MOVE_FAIL(c,cn,1);
return;
} //> CSD-030806
}
SendCMD_CHECK_WARFIELD_NATION_MEMBERCOUNT(p,c,cn);
}
void CallNWMapMove(const int WarfieldNo,t_connection c[],const int cn) //努扼捞攫飘狼 牢磐其捞胶 甘捞悼 // 011217 LTS
{
char tempMapName[20] = {0,};
int WarfieldStatus;
if (isNationManageServer())
{
if (WarfieldNo>=0&&WarfieldNo<=2)
WarfieldStatus=g_pNation->GetWarfieldStatus(WarfieldNo); // 傈里磐 惑怕甫 掘绢柯促.
else
if (WarfieldNo>=3)
WarfieldStatus=g_pNation->GetNewWarfieldStatus(WarfieldNo-3); // 傈里磐 惑怕甫 掘绢柯促.
}
else
{
if (WarfieldNo>=0&&WarfieldNo<=2)
WarfieldStatus=g_pWarfieldStatus[WarfieldNo].Status;
else
if (WarfieldNo>=3)
{
/* // 030515 kyo
if (isNewWarfieldServer()) // 030509 kyo //傈里辑滚捞搁
{
WarfieldStatus=g_pNewWarfield->GetWarfieldStatus();
}
else
*/
WarfieldStatus=g_pNewWarfieldStatus[WarfieldNo-3];
}
}
if (WarfieldNo==0) sprintf(tempMapName,"Nation1");
if (WarfieldNo==1) sprintf(tempMapName,"Nation2");
if (WarfieldNo==2) sprintf(tempMapName,"Nation3");
if (WarfieldNo==3) sprintf(tempMapName,"Nation4");
if (WarfieldStatus!=NW_WAR)
{
if(WarfieldNo>=3) // 乞拳矫 绢痘霸 窍瘤??? ぱ.ぱ
{
/*int Nation=connections[cn].chrlst.name_status.nation;
if (Nation==NW_YL)
Nation=connections[cn].chrlst.NWCharacter.YL_JoinNation;
switch(Nation)
{
case NW_BY : MapMove(cn,tempMapName,NEW_BYPoint.x,NEW_BYPoint.y); break;
case NW_ZY : MapMove(cn,tempMapName,NEW_ZYPoint.x,NEW_ZYPoint.y); break;
}*/
SendCMD_NW_MAP_MOVE_FAIL(c,cn,3); // 011213 LTS
}
else
{
if (!isAttacker(WarfieldNo,c,cn))
{
POINTS tempPoint = DefencePoint[WarfieldNo];
MapMove(cn,tempMapName,tempPoint.x,tempPoint.y);
}
else SendCMD_NW_MAP_MOVE_FAIL(c,cn,3); // 011213 LTS
}
}
else
{
if (WarfieldNo>=3)
{
int Nation=connections[cn].chrlst.name_status.nation;
if (Nation==NW_YL)
Nation=connections[cn].chrlst.NWCharacter.YL_JoinNation;
switch(Nation)
{
case NW_BY : MapMove(cn,tempMapName,NEW_BYPoint.x,NEW_BYPoint.y); break;
case NW_ZY : MapMove(cn,tempMapName,NEW_ZYPoint.x,NEW_ZYPoint.y); break;
}
}
else
{
if (isAttacker(WarfieldNo,c,cn))
{
int LoadPoint=g_pLoadingPoint[WarfieldNo][c[cn].chrlst.NWCharacter.SquadNo]-1;
if (LoadPoint<0||LoadPoint>3) LoadPoint=0;
POINTS tempPoint = AttackPoint[WarfieldNo][LoadPoint]; // 肺爹器牢飘啊 1俊辑 矫累等促搁 俊矾 惯积
MapMove(cn,tempMapName,tempPoint.x,tempPoint.y);
}
else
{ //规绢磊捞促...
POINTS tempPoint = DefencePoint[WarfieldNo];
MapMove(cn,tempMapName,tempPoint.x,tempPoint.y);
}
}
}
}
void FindCommander(const char* CommanderName) // 甘辑滚俊 秦寸捞抚狼 蜡历啊 乐绰瘤 犬牢茄促.
{ //< CSD-CN-031213
CUserManager::HASH_USER mpUser = g_pUserManager->GetUserSet();
for (CUserManager::ITOR_USER i = mpUser.begin(); i != mpUser.end(); ++i)
{
const int idUser = i->second;
CHARLIST* pUser = CheckServerId(idUser);
if (pUser != NULL)
{
if (0 == strcmp(connections[idUser].name, CommanderName))
{
pUser->NWCharacter.isCommander = 1;
t_packet packet;
packet.h.header.type = CMD_YOU_ARE_SQUAD_COMMANDER;
packet.h.header.size = sizeof(t_CommonDataC);
if (NW_YL == pUser->name_status.nation)
{
packet.u.NationWar.CommonDataC.Data = CheckJoinReinforce();
}
else
{
packet.u.NationWar.CommonDataC.Data = 0;
}
QueuePacket(connections, idUser, &packet, 1);
break;
}
}
}
} //> CSD-CN-031213
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -