📄 deathcontend.c
字号:
}
if( PKLIST_LoadPkTeamListDataMyTeamMans( array, buf1) == FALSE ){
print("err 5 buf:%s\n", buf);
continue;
}
if( getStringFromIndexWithDelim( buf, "_", 4, buf1, sizeof( buf1)) != FALSE ){
if( PKLIST_LoadPkTeamListDataBHistory( array, buf1) == FALSE ){
print("err 7 buf:%s\n", buf);
continue;
}
}
teamcount++;
}
//andy_log
print("\nteamcount:%d \n", teamcount);
if( teamcount <= 0 ) return TRUE;
return TRUE;
}
*/
void PKLIST_InsertTeamNum( int charaindex )
{
int i, k;
char *cdkey, *name;
if( !CHAR_CHECKINDEX( charaindex) ) return;
cdkey = CHAR_getChar( charaindex, CHAR_CDKEY);
name = CHAR_getChar( charaindex, CHAR_NAME);
for( i=0; i<maxteam; i++ ){
if( PkTeamList[i].use == 0 ) continue;
for( k=0;k<MAXTEAMMANNUM;k++){
if( PkTeamList[i].MyTeamMans[k].use == 0 ) continue;
if( strcmp( PkTeamList[i].MyTeamMans[k].cdkey, cdkey) )continue;
// if( !strcmp( PkTeamList[i].MyTeamMans[k].name, name) ){
CHAR_setInt( charaindex, CHAR_PKLISTTEAMNUM, PkTeamList[i].teamnum );
if( !strcmp( PkTeamList[i].leadercdkey, cdkey) ){
CHAR_setInt( charaindex, CHAR_PKLISTLEADER, 1);
}else{
CHAR_setInt( charaindex, CHAR_PKLISTLEADER, 0);
}
//andy_log
print("teamnum:%d leadercdkey:%d ok\n",
PkTeamList[i].teamnum, CHAR_getInt( charaindex, CHAR_PKLISTLEADER));
return;
// }
}
}
return;
}
void PKLIST_ShowPkListTeamData( void)
{
int i;
{
int k;
print( "\n");
for( i=0; i<maxteam; i++ ){
if( PkTeamList[i].use != 1 ) continue;
print("PkTeamList[%d] [%d|%d|%s|%s|%s|%d|%d|%d|%d|%d] \n", i,
PkTeamList[i].use,
PkTeamList[i].teamnum,
PkTeamList[i].teamname,
PkTeamList[i].pathdir,
PkTeamList[i].leadercdkey,
PkTeamList[i].win,
PkTeamList[i].lost,
PkTeamList[i].battleplay,
PkTeamList[i].score,
PkTeamList[i].inside
);
for( k=0; k<MAXTEAMMANNUM; k++){
if( PkTeamList[i].MyTeamMans[k].use == 0 ) continue;
print( "[%s,%s]," , PkTeamList[i].MyTeamMans[k].cdkey,
PkTeamList[i].MyTeamMans[k].name );
}
print( "\n");
for( k=0; k<MAXBATTLENUM; k++){
if( PkTeamList[i].BHistory[k].use == 0 ) continue;
if( k!=0 && k%10 == 0 ) print( "\n");
print( "%d,%d|" , PkTeamList[i].BHistory[k].teamnum,
PkTeamList[i].BHistory[k].flg );
}
print( "\n");
}
print( "\n");
}
}
BOOL PKLIST_GetTeamLeaderCdkey( int teamnum, char *buf)
{
int i;
for( i=0; i<maxteam; i++ ){
if( PkTeamList[i].use == 0 ) continue;
if( PkTeamList[i].teamnum != teamnum ) continue;
sprintf( buf, "%s", PkTeamList[i].leadercdkey );
return TRUE;
}
return FALSE;
}
void NPC_PKLIST_PlayerLogout_Exit( int charaindex )
{
char token[256];
int menum, tonum;
#ifdef _DEATH_CONTENDAB
{
int i,j,side;
char tocdkey[256], mecdkey[256];
int mearray, toarray,battlearray;
ArrangeBattleC *aBo=NULL;
ArrangeBattleC *aB1=NULL;
ArrangeBattleC *aB2=NULL;
if( (menum=CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM)) < 0 ) return;
if( (mearray = PKLIST_GetPkTeamListArrayFromNum( menum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( menum, mecdkey ) == FALSE ){
print("Can't Get Data menum:%d err !!\n", menum);
return;
}
if( (battlearray = PKLIST_GetPKProcedureArray( menum)) < 0 ) return;
for( j=0; j<2; j++ ){
if( PKProcedure[battlearray].Team[j].use == 0 ) continue;
if( PKProcedure[battlearray].Team[j].teamnum != menum ) continue;
if( PKProcedure[battlearray].type != PKTYPE_STANDBY ) return;
if( PKProcedure[battlearray].time+1 >= (int)time(NULL) ) return;
side = (j+1)%2;
if( PKProcedure[battlearray].Team[side].use == 0 ) return;
if( (tonum = PKProcedure[battlearray].Team[side].teamnum ) < 0 ) return;
if( (toarray = PKLIST_GetPkTeamListArrayFromNum( tonum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( tonum, tocdkey ) == FALSE ){
print("Can't Get Data tonum:%d err !!\n", tonum);
return;
}
break;
}
//andy_log
print("NPC_PKLIST_PlayerLogout_Exit( %d) \n", charaindex);
if( (menum=CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM)) < 0 ) return;
if( (aB1=ABATTLE_getInBattle( menum))==NULL ) return;
if( (aBo=aB1->top) == NULL ) return;
if( (aB1=aBo->next[0]) == NULL || (aB2=aBo->next[1]) == NULL ) return;
if( aB1->teamnum == menum ){
sprintf( token, "%s 队 胜 %s 队。", aB2->teamname, aB1->teamname );
LogPkContend( aB2->teamname , aB1->teamname, 0, 0, 0, 0);
ABATTLE_RecordBattle( -1, aB1->teamname, "", aB2->teamname, "胜");
tonum = aB2->teamnum;
ABATTLE_EnterBattle( aB2);
}else{
sprintf( token, "%s 队 胜 %s 队。", aB1->teamname, aB2->teamname );
LogPkContend( aB1->teamname , aB2->teamname, 0, 0, 0, 0);
ABATTLE_RecordBattle( -1, aB1->teamname, "胜", aB2->teamname, "");
tonum = aB1->teamnum;
ABATTLE_EnterBattle( aB1);
}
for( i=0; i<MAXBATTLEPAGE; i++){
if( InBattle[i] == NULL) continue;
if( InBattle[i] == aBo ) InBattle[i] = NULL;
}
{ //广播胜负
int i;
int playernum = CHAR_getPlayerMaxNum();
for( i=0; i<playernum; i++){
if( !CHAR_getCharUse(i) || CHAR_getInt( i , CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue;
CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW );
if( CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == menum ||
CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == tonum ){
CHAR_warpToSpecificPoint( i, 8250, 20, 20);
}
}
}
PKLIST_LOCKTeam( menum);
PKLIST_LOCKTeam( tonum);
PKLIST_UpData(tocdkey,mecdkey,tonum,menum,0,0);
PKLIST_Sort_PKListSort();
PKLIST_SavePkTeamListData();
}
#else
char tocdkey[256], mecdkey[256];
int battlearray;
int j, side, mearray, toarray;
if( (menum=CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM)) < 0 ) return;
if( (mearray = PKLIST_GetPkTeamListArrayFromNum( menum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( menum, mecdkey ) == FALSE ){
print("Can't Get Data menum:%d err !!\n", menum);
return;
}
if( (battlearray = PKLIST_GetPKProcedureArray( menum)) < 0 ) return;
for( j=0; j<2; j++ ){
if( PKProcedure[battlearray].Team[j].use == 0 ) continue;
if( PKProcedure[battlearray].Team[j].teamnum != menum ) continue;
if( PKProcedure[battlearray].type != PKTYPE_STANDBY ) return;
if( PKProcedure[battlearray].time+1 >= (int)time(NULL) ) return;
side = (j+1)%2;
if( PKProcedure[battlearray].Team[side].use == 0 ) return;
if( (tonum = PKProcedure[battlearray].Team[side].teamnum ) < 0 ) return;
if( (toarray = PKLIST_GetPkTeamListArrayFromNum( tonum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( tonum, tocdkey ) == FALSE ){
print("Can't Get Data tonum:%d err !!\n", tonum);
return;
}
PKLIST_LOCKTeam( menum);
PKLIST_LOCKTeam( tonum);
//saacproto_PkListUpDate_send( acfd , tocdkey, mecdkey,tonum, menum, 0, 0);
PKLIST_UpData(tocdkey,mecdkey,tonum,menum,0,0);
sprintf( token, "%s 队 胜 %s 队。",
PkTeamList[toarray].teamname, PkTeamList[mearray].teamname);
LogPkContend( PkTeamList[toarray].teamname, PkTeamList[mearray].teamname,
CHAR_getInt( charaindex, CHAR_FLOOR),
CHAR_getInt( charaindex, CHAR_X), CHAR_getInt( charaindex, CHAR_Y), 0);
PKLIST_DelPKProcedures( battlearray, 0, PKTYPE_WAIT);
PKLIST_DelPKProcedures( battlearray, 1, PKTYPE_WAIT);
{ //广播胜负
int i;
int playernum = CHAR_getPlayerMaxNum();
for( i=0; i<playernum; i++){
if( !CHAR_getCharUse(i) || CHAR_getInt( i , CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue;
CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW );
if( CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == menum ||
CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == tonum ){
CHAR_warpToSpecificPoint( i, 8250, 20, 20);
}
}
}
break;
}
PKLIST_Sort_PKListSort();
PKLIST_SavePkTeamListData();
#endif
}
int NPC_PKLIST_Finish_Exit( int menum, int tonum, int winside, int battlemap)
{
char token[256];
#ifdef _DEATH_CONTENDAB
{
int i;
char mecdkey[256], tocdkey[256];
int mearray, toarray;
ArrangeBattleC *aB1=NULL;
ArrangeBattleC *aB2=NULL;
if( (mearray = PKLIST_GetPkTeamListArrayFromNum( menum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( menum, mecdkey ) == FALSE ){
print("Can't Get Data menum:%d err !!\n", menum);
return -1;
}
if( (toarray = PKLIST_GetPkTeamListArrayFromNum( tonum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( tonum, tocdkey ) == FALSE ){
print("Can't Get Data tonum:%d err !!\n", tonum);
return -1;
}
//andy_log
print("NPC_PKLIST_Finish_Exit( %d, %d, %d, %d) \n", menum, tonum, winside, battlemap);
if( (aB1=ABATTLE_getInBattle( menum))==NULL ) return 0;
if( (aB2=ABATTLE_getInBattle( tonum))==NULL ) return 0;
if( aB1->top == NULL || aB2->top == NULL ||
aB1->top != aB2->top ) return 0;
if( winside == 0 ){
sprintf( token, "%s 队 胜 %s 队。", aB1->teamname, aB2->teamname );
LogPkContend( aB1->teamname , aB2->teamname, 0, 0, 0, 0);
ABATTLE_RecordBattle( -1, aB1->teamname, "胜", aB2->teamname, "");
ABATTLE_EnterBattle( aB1);
}else{
sprintf( token, "%s 队 胜 %s 队。", aB2->teamname, aB1->teamname );
LogPkContend( aB2->teamname , aB1->teamname, 0, 0, 0, 0);
ABATTLE_RecordBattle( -1, aB1->teamname, "", aB2->teamname, "胜");
ABATTLE_EnterBattle( aB2);
}
for( i=0; i<MAXBATTLEPAGE; i++){
if( InBattle[i] == NULL) continue;
if( InBattle[i] == aB1->top ) InBattle[i] = NULL;
}
{ //广播胜负
int i;
int playernum = CHAR_getPlayerMaxNum();
for( i=0; i<playernum; i++){
if( !CHAR_getCharUse(i) || CHAR_getInt( i , CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue;
CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW );
if( CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == menum ||
CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == tonum ){
CHAR_warpToSpecificPoint( i, 8250, 20, 20);
}
}
}
PKLIST_LOCKTeam( menum);
PKLIST_LOCKTeam( tonum);
PKLIST_UpData(mecdkey,tocdkey,menum,tonum,winside,0);
PKLIST_Sort_PKListSort();
PKLIST_SavePkTeamListData();
}
#else
char mecdkey[256], tocdkey[256];
int mearray, toarray, battlearray;
if( (mearray = PKLIST_GetPkTeamListArrayFromNum( menum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( menum, mecdkey ) == FALSE ){
print("Can't Get Data menum:%d err !!\n", menum);
return -1;
}
if( (toarray = PKLIST_GetPkTeamListArrayFromNum( tonum)) == -1 ||
PKLIST_GetTeamLeaderCdkey( tonum, tocdkey ) == FALSE ){
print("Can't Get Data tonum:%d err !!\n", tonum);
return -1;
}
PKLIST_LOCKTeam( menum);
PKLIST_LOCKTeam( tonum);
//saacproto_PkListUpDate_send( acfd , mecdkey, tocdkey, menum, tonum, winside, 0);
PKLIST_UpData(mecdkey,tocdkey,menum,tonum,winside,0);
sprintf( token, "%s 队 胜 %s 队。",
(winside==0)?PkTeamList[mearray].teamname:PkTeamList[toarray].teamname,
(winside==0)?PkTeamList[toarray].teamname:PkTeamList[mearray].teamname );
LogPkContend(
(winside==0)?PkTeamList[mearray].teamname:PkTeamList[toarray].teamname ,
(winside==0)?PkTeamList[toarray].teamname:PkTeamList[mearray].teamname,
0, 0, 0 ,0);
{ //广播胜负
int i;
int playernum = CHAR_getPlayerMaxNum();
for( i=0; i<playernum; i++){
if( !CHAR_getCharUse(i) || CHAR_getInt( i , CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue;
CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW );
if( CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == menum ||
CHAR_getInt( i , CHAR_PKLISTTEAMNUM ) == tonum ){
CHAR_warpToSpecificPoint( i, 8250, 20, 20);
}
}
}
if( (battlearray = PKLIST_GetPKProcedureArray( menum)) < 0 ) return 1;
PKLIST_DelPKProcedures( battlearray, 0, PKTYPE_WAIT);
PKLIST_DelPKProcedures( battlearray, 1, PKTYPE_WAIT);
PKLIST_Sort_PKListSort();
PKLIST_SavePkTeamListData();
#endif
return 1;
}
BOOL PKLIST_HandleChartsMess( int fd, char *data, int type, int flg)
{
int datalen=0;
switch(type){
case 1:
break;
case 2:
datalen = strlen(data);
if( data==NULL || datalen <= 0 ) return FALSE;
memset( chartslist, 0, sizeof(chartslist) );
memcpy( chartslist, data, datalen+1 );
chartslist[datalen+1]=0;
break;
}
return TRUE;
}
BOOL PKLIST_GetChartsListData( int ti, char *data, int sizes )
{
if( getStringFromIndexWithDelim( chartslist, " ", ti, data, sizes) == FALSE ){
//andy_log
print("err chartslist:%s.. !!\n", data);
return FALSE;
}
return TRUE;
}
BOOL PKLIST_GetMyPKListTeamData( int teamnum, char *data, int sizes )
{
int ti, k;
char buf[256];
if( (ti=PKLIST_GetPkTeamListArrayFromNum( teamnum)) == -1 ) return FALSE;
if( PkTeamList[ti].use == 0 ) return FALSE;
if( PkTeamList[ti].MyTeamMans[0].use == 0 ) return FALSE;
/*snprintf( data, sizes, "队伍:%s\n胜:%d 负:%d 场:%d 积:%d分 \n",
PkTeamList[ti].teamname, PkTeamList[ti].win, PkTeamList[ti].lost,
PkTeamList[ti].battleplay, PkTeamList[ti].score );*/
snprintf( data, sizes, "队伍:%s\n胜:%d 负:%d 场:%d\n",
PkTeamList[ti].teamname, PkTeamList[ti].win, PkTeamList[ti].lost,
PkTeamList[ti].battleplay);
sprintf( buf, "队长:%s \n", PkTeamList[ti].MyTeamMans[0].name );
strcat( data, buf);
strcat( data, "队员:");
for( k=1; k<MAXTEAMMANNUM; k++){
if( PkTeamList[ti].MyTeamMans[k].use == 0 ) continue;
sprintf( buf, "%s ", PkTeamList[ti].MyTeamMans[k].name );
strcat( data, buf);
}
strcat( data, "\n");
return TRUE;
}
//赛程
void PKLIST_DelPKProcedures( int ti, int side, int type)
{
if( ti<0 || ti>=40 ) return;
if( side<0 || side >1 ) return;
PKProcedure[ti].use = 0;
PKProcedure[ti].type = type;
PKProcedure[ti].Team[side].use = 0;
PKProcedure[ti].Team[side].teamnum = -1;
PKProcedure[ti].Team[side].fd = -1;
}
BOOL PKLIST_CheckPklistInServerMap( int ti, int side)
{
if( !CHAR_CHECKINDEX( PKProcedure[ti].Team[side].toindex) ||
PKLIST_GetPkTeamListArrayFromNum( PKProcedure[ti].Team[side].teamnum ) == -1 ||
PKProcedure[ti].Team[side].fd != getfdFromCharaIndex( PKProcedure[ti].Team[side].toindex) ||
CHAR_getInt( PKProcedure[ti].Team[side].toindex, CHAR_FLOOR ) == 8250 ){
return FALSE;
}
return TRUE;
}
BOOL PKLIST_CheckPKSameTeam( int charaindex )
{
int teamnum, i, meti;
char szMsg[128];
if( !CHAR_CHECKINDEX( charaindex) ){
print( "CHAR_CHECKINDEX err !!\n");
return FALSE;
}
if( (teamnum=CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM)) < 0 ){
print( "CHAR_PKLISTTEAMNUM err !!\n");
return FALSE;
}
if( (meti=PKLIST_GetPkTeamListArrayFromNum( teamnum )) == -1 ){
print( "GetPkTeamListArray err !!\n");
return FALSE;
}
#ifdef _DEATH_CONTENDAB
if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER) != 1 ){
return FALSE;
}
#else
if( PkTeamList[meti].battleplay >= DEFMAXBATTLENUM ){
CHAR_talkToCli( charaindex, -1, "对战场数已满!", CHAR_COLORYELLOW);
return FALSE;
}
if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER) != 1 ){
CHAR_talkToCli( charaindex, -1, "只有参赛队伍的队长才能加入赛程喔!", CHAR_COLORYELLOW);
return FALSE;
}
#endif
if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER ){
return TRUE;
}
for( i=0; i<5; i++){
int pindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i);
if( !CHAR_CHECKINDEX( pindex) ) continue;
if( teamnum != CHAR_getInt( pindex, CHAR_PKLISTTEAMNUM) ){
CHAR_talkToCli( charaindex, -1, "你的队里怎会有不同队伍的人呢?", CHAR_COLORYELLOW);
return FALSE;
}
}
for( i=0; i<5; i++){
int pindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i);
if(!CHAR_CHECKINDEX(pindex)) continue;
if(CHAR_getInt(pindex,CHAR_LV) < 120){
sprintf(szMsg,"你的队里 %s 等级 %d 未达比赛标准喔!",CHAR_getChar(pindex,CHAR_NAME),CHAR_getInt(pindex,CHAR_LV));
CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW);
return FALSE;
}
if(CHAR_getInt(pindex,CHAR_TRANSMIGRATION) < 3){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -