⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teambattle.cpp

📁 国内著名网络游戏dragon的客户端登陆用完整源码 配套一起上传的服务端部分可开服 无说明文档
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "stdafx.h"
#include "dragon.h"
#include "teambattle.h"
#include "menu.h"
#include "smallmenu.h"
#include "CharDataTable.h"
#include "smallmenuset.h"
#include "MenuSet.h"
#include "menunetwork.h"
#include "gameproc.h"
#include "hangul.h"
#include "hong_sprite.h"
#include "teambattle.h"
#include "char.h"
#include "effect.h"
#include "hong_sub.h"
#include "Convert565to555.h"
#include "item.h"
#include "TextOutMgr.h"
#include "QuestFunction.h"		// 021025 kyo
#include "ArenaManager.h"

CBattleZone			g_BattleZone;
bool				g_FightMapStart;
CFightMapCharInfo	g_FightMapCharInfo;
int fight_map_acc_num[4] = { 116, 108, 106, 118 };	// 辨靛渴...

char FightTeam[5][13];
DWORD FightTeamColor[5] = { RED_COLOR, BLUE_COLOR, GREEN_COLOR, GRAY_COLOR, YELLOW_COLOR };

////////////// class battleteam :: member function /////////////////// 
CBattleTeam::CBattleTeam()
{
	ReSetClass();
}

void CBattleTeam::ReSetClass()
{
	count = 0;
	memset( member, 0, sizeof( k_team_member_info_unit ) * MAX_TEAM_MEMBER );
}

int CBattleTeam::AddMember( k_team_member_info_unit *info )		// 评俊 甸绢埃促.
{
	if( count >= MAX_TEAM_MEMBER ) return -1;		// 菜 谩促.

	for( int i=0; i<MAX_TEAM_MEMBER; i++ )
	{
		if( member[i].name[0] == NULL )
		{
			member[i] = *info;
		}
	}	
	count++;
	return 1;
}


int CBattleTeam::DeleteMember( char *name )
{
	for( int i=0; i< MAX_TEAM_MEMBER; i++ )
	{
		if( strcmp( name, member[i].name ) == 0 )
		{
			memset( &member[i], 0, sizeof( k_team_member_info_unit ) );
			count--;
			return 1;
		}
	}
	return 0;		// 呕硼矫懦 仇捞 绝促.
}

//////////////////////////////////////////////////////////////////////
////////////// class battlezone :: member function /////////////////// 

CBattleZone::CBattleZone()
{
	ReSetClass();
}

void CBattleZone::ReSetClass()
{
	for( int i=0; i<MAX_TEAM; i++ )
	{
		m_team[i].ReSetClass();
	}
}

int CBattleZone::SetAllInfo( k_team_member_info_all *info )
{
	for( int i=0; i<MAX_TEAM; i++ )
	{
		for( int j=0; j<MAX_TEAM_MEMBER; j++ )
		{
			if( info->unit[i][j].lv )
				m_team[i].AddMember( &info->unit[i][j] );
		}
	}	
	return 1;
}

int CBattleZone::GetCount( int team )
{
	return m_team[team].count;
}

int CBattleZone::AddMember( int team, k_team_member_info_unit *info )
{
	return m_team[team].AddMember( info );
}


// 捞固 殿废等 荤恩捞 乐绰啊?
int CBattleZone::IsExist( char *name )
{
	for( int i=0; i<MAX_TEAM; i++ )
	{
		int try_count = 0;
		for( int j=0; j<MAX_TEAM_MEMBER; j++ )
		{
			if( m_team[i].count >= try_count ) break;
			if( m_team[i].member[j].lv )
			{
				try_count ++;
				if( strcmp( name ,m_team[i].member[j].name ) == 0 )
				{
					return 1;
				}
			}
		}
	}
	return 0;
}
///////////////////////////////////////////////////////////////////////


//////////////////////////// protocal function ////////////////////////
void RecvAllTeamInfo( t_packet *p )		// 硅撇粮狼 沥焊甫 罐绰促.
{
	k_team_member_info_all *info = &p->u.kein.team_member_info_all;
	g_BattleZone.ReSetClass();		// 檬扁拳 茄饶俊
	g_BattleZone.SetAllInfo( info );	// 葛电 糕滚甸狼 沥焊甫 悸泼茄促.
}

void SendAddMeOfTeamBattle( int team )		// 评俊 殿废窍摆促.
{
	t_packet p;			// 辑滚肺 傈价
	p.h.header.type = CMD_ADD_TEAM_MEMBER;
		p.u.kein.default_char = team ;
	p.h.header.size = sizeof( char );
	QueuePacket( &p, 1 );	
}

void RecvAddMemberInfo( t_packet *p )		// 绢恫荤恩捞 评俊 眠啊 灯促.
{
	k_team_member_info_one *member_info = &p->u.kein.team_member_info_one;
	g_BattleZone.AddMember( member_info->team_num, &member_info->unit);
}

void StartTembattleWaitMenu(int nGame)
{	//< CSD-030520
	if (SMenu[MN_ARENA_LOBBY].bActive)
	{
		return;
	}
	
	g_pArenaManager->Reset();
	g_pArenaManager->SendEnterLobby(nGame);
	Kein_PutMessage(KM_INFO, kein_GetMenuString(154));
}	//> CSD-030520

///////////////////////////////////////////////////////////////////////
// CFightMapCharInfo member function
void CFightMapCharInfo::AddCharInfo( DWORD total_id, DWORD win_defeat, DWORD ladder, int level, int Class, int type, int dual_cls, int cls_step )
{
	CFightMapCharInfo *temp = this;
	CFightMapCharInfo *temp_prev;
	
	if( !temp->m_TotalId )		// 贸澜捞 酒聪搁
	{
		while( temp )
		{
			if( temp->m_TotalId == total_id )
			{
				memcpy( &temp->m_WinDefeat, &win_defeat, sizeof( DWORD ) );
				temp->m_dwLadderScore = ladder;
				temp->type = type;

        const string strName = g_mgrDual.GetClassName(Class, dual_cls, cls_step, level);
        strcpy(temp->m_szCallLevel, strName.c_str());
				temp->m_wColor= Lv_Color[level-1].GetRGB16();
				return;
			}
			else 
			{
				temp_prev = temp;
				temp = temp->next;
			}
		}
		temp = new CFightMapCharInfo;
		temp_prev->next = temp;
	}
	
	temp->m_TotalId = total_id;
	memcpy( &temp->m_WinDefeat, &win_defeat, sizeof( DWORD ) );
	temp->m_dwLadderScore = ladder;
  const string strName = g_mgrDual.GetClassName(Class, 
                                                Hero->aStepInfo[DUAL_CLS], 
                                                Hero->aStepInfo[CLS_STEP], 
                                                level);
  strcpy(temp->m_szCallLevel, strName.c_str());
	temp->m_wColor= Lv_Color[level-1].GetRGB16();
	temp->type = type;
	
	return;
}

CFightMapCharInfo *CFightMapCharInfo::GetFightMapCharInfo( DWORD total_id )// 沥焊 器牢磐 掘绢坷扁
{
	CFightMapCharInfo *temp = this;
	while( temp )
	{
		if( temp->m_TotalId == total_id ) return temp;
		temp = temp->next;
	}
	return NULL;
}

////////////////////////////////////////////////////////////////////
//global functions
void SetChangeMapOfMenu()
{
	FighMapReset();
	CloseAllMenu();
	bCallGodMeetingMenu = 0;

	g_cQuest.DeleteScriptTimer();		// 021025 kyo 甘捞悼且锭  鸥捞赣,墨款磐 捞静搁 瘤款促. (辑滚绰 甘捞悼矫 瘤况咙..
	g_cQuest.DeleteScriptCounter();		// 021025 kyo 
  g_cQuest.EmptySpellWord();			// 021206 kyo 肺弊酒眶且锭 林巩郴侩 昏力 

}

void RecvFightMapAddOk( t_packet *p )
{
	int team_num = p->u.kein.default_char;
	if( team_num < 0 || team_num >= 4 ) return;
	AddCurrentStatusMessage( 220, 220, 0, lan->OutputMessage(3,42), FightTeam[team_num] ); //010215 lsw

	Hero->fight_map_team_num = team_num+1;
}

void RecvFightMapAddNot( t_packet *p )
{
	int team_num = p->u.kein.default_char;
	if( team_num < 0 || team_num >= 4 ) return;
	AddCurrentStatusMessage( 220, 0, 0, lan->OutputMessage(3,43), FightTeam[team_num] ); //010215 lsw
}

void RecvFightMapStart( )
{	//< CSD-030522
	if (g_pArenaManager->GetMemberTeam(Hero->id) || g_pArenaManager->GetObserveTeam(Hero->id))
	{
		SmallMenuClose();
		MainMenuClose();
		man_to_man_start = 85;
		g_FightMapStart = true;
	}

	AddCurrentStatusMessage( 255, 255, 255, lan->OutputMessage(3,46) ); //010215 lsw
	g_BattleStatusView = 0;

	ChangeEquipForFightMapStart();
}	//> CSD-030522

// 011018 KHS 噶肚 ; 捞镑俊档 噶肚甫 持绢具 窍绰啊? 
void ChangeEquipForFightMapStart()
{	//< CSD-030521
	CArenaManager::VECTOR_TEAM vtTeam = g_pArenaManager->GetTeamInfo();

	for (CArenaManager::ITOR_TEAM i = vtTeam.begin(); i != vtTeam.end(); ++i)
	{
		const int nTeam = (*i)->GetTeamNumber();

		CArenaTeam::LIST_MEMBER ltMember = (*i)->GetMemberSet();
		
		for (CArenaTeam::ITOR_MEMBER j = ltMember.begin(); j != ltMember.end(); ++j)
		{
			LPCHARACTER pMember = ::ReturnCharacterPoint(*j);
	
			if (pMember == NULL)
			{
				continue;
			}

			int equip[2];
			equip[AT_ARMOR] = fight_map_acc_num[nTeam];
			equip[AT_HELMET] = 1;
			
			if	(pMember->accessory[0] != equip[0])
			{ 
				FreeHeroClothAccessoryDataOne(pMember->sprno, pMember->accessory[0]);
				FreeHeroClothAccessoryDataOne(pMember->sprno, pMember->accessory[0] + 1);
			}
			
			pMember->accessory[0] = equip[AT_ARMOR];
			LoadHeroClothAccessoryDataOne(pMember->sprno, equip[AT_ARMOR]);
			LoadHeroClothAccessoryDataOne(pMember->sprno, equip[AT_ARMOR] + 1);

			if (pMember->accessory[1] != equip[AT_HELMET])
			{
				FreeHeroClothAccessoryDataOne(pMember->sprno, pMember->accessory[1]);
			}

			pMember->accessory[1] = equip[AT_HELMET];
			LoadHeroClothAccessoryDataOne(pMember->sprno, equip[AT_HELMET]);
		}
	}
}	//> CSD-030521

void FighMapReset()
{	//< CSD-030520
	g_BattleStatusView = 0;
	g_FightMapStart = false;
	
	LPCHARACTER ch = Hero;
	while( ch )
	{
		if( ch->fight_map_team_num )
		{
			ResetMagicFlag( ch );
		}
		ch->fight_map_team_num = 0;		
		ch = ch->lpNext;
	}

	memset( &fight_map_live_man, 0, sizeof( int )*4 );
	MenuSoundClose( MN_FIGHT_MAP_SIGN );
	SmallMenuClose();
	MainMenuClose();
	g_FightMapCharInfo.DeleteAll();		// 沥焊甫 盎脚窍扁 困秦辑
}	//> CSD-030520

void RecvFightMapEnd( )
{	//< CSD-030522
	if (g_pArenaManager->GetMemberTeam(Hero->id) || g_pArenaManager->GetObserveTeam(Hero->id))
	{
		fight_map_stop = 85;
		if( g_fight_win ) g_fight_win = 1;
		if( g_fight_lose ) g_fight_lose = 1;
	}

	AddCurrentStatusMessage( 255, 255, 255,lan->OutputMessage(3,47) );
	g_pArenaManager->Reset();
	FighMapReset();
}   //> CSD-030522

void RecvFightMapCharInfo( t_packet *p )		// colossus 措扁磊 棺 殿废磊 沥焊甫 啊廉柯促.
{
	DWORD	win_defeat = p->u.kein.fight_map_char_info.win_defeat;
	DWORD	ladderscore = p->u.kein.fight_map_char_info.ladderscore ;
	DWORD	total_id = p->u.kein.fight_map_char_info.total_id;
	int		level = p->u.kein.fight_map_char_info.level;
	int		cls = p->u.kein.fight_map_char_info.Class;
	int		dual_cls = p->u.kein.fight_map_char_info.dual_cls;
	int		cls_step = p->u.kein.fight_map_char_info.cls_step;

	g_FightMapCharInfo.AddCharInfo( total_id, win_defeat, ladderscore, level, cls, 1, dual_cls, cls_step );
}

////////////////////////////////////////////////////////////////////////
void ViewFightMapCharInfo( char *name, DWORD total_id, int x, int y )
{
	if(!name || !::strlen(name))
	{
		return;
	}
	CFightMapCharInfo *pCharInfo= g_FightMapCharInfo.GetFightMapCharInfo( total_id );
	if( !pCharInfo )
	{
		SendPacketDefault( CMD_FIGHT_MAP_CHAR_INFO, &total_id, sizeof( DWORD ) );
		g_FightMapCharInfo.AddCharInfo( total_id, 0, 0, 0, 0, 0, 0, 0 );		// 老矫利栏肺 殿废茄促.
		return;
	}

	const int iLG = TxtOut.GetLineGab();
	const int iBlankGabSize = TxtOut.GetBlankGabSize();
	const int iWidth = TXT_BG_SHORT_WIDTH;//021001 lsw	
	const int iX = x, iY = y;
	int iBlkG = 0;
	int iCt = 0;
	int iReultLineCount = 0;	

	SetHangulAlign( TA_LEFT);
	Hcolor( FONT_COLOR_NAME );

	TxtOut.Init(COLOR_BLACK,iWidth,9);
	TxtOut.PutTextHeaderBGImg(iX,iY+iBlkG+iLG*iCt,iWidth);
	

	iReultLineCount = TxtOut.RcTXTOut(iX,iY+iBlkG+iLG*iCt,iWidth,1,"%s", name);
	iCt += iReultLineCount;

	if( pCharInfo->type )		// 辑滚俊辑 傈价 罐篮芭搁 促 焊咯霖促.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -