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

📄 teambattle.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	}

	return false;
}	//> CSD-031013

//////////////////////////////////////////////////////////////////////////
// CColossusStone
CColossusStoneMgr g_ColossusStone;
int CColossusStoneMgr::AddStone( int id )
{
	if( id == -1 ) return 0;
	CColossusStone *temp = &m_StoneList;
	for( ; temp->next; temp=temp->next );
	CColossusStone *data = new CColossusStone;
	data->stone = &ItemList[id];
	temp->next = data;
	return 1;
}
ITEMLIST *CColossusStoneMgr::GetList( int count )
{
	CColossusStone *target = m_StoneList.next;
	for( ;target; target = target->next )
	{
		if( target->stone->dumno == count )
		{
			return target->stone;
		}
	}
	return NULL;
}
void CColossusStoneMgr::GetTeamCount( int team[4] )
{
	memset( team, 0, sizeof( int )*4 );
	CColossusStone *target = m_StoneList.next;
	for( ;target; target = target->next )
	{
		DWORD attr = target->stone->attr[IATTR_ATTR];
		int t= GetTeamByStone( attr );
		if( t>= 0 )
		{
			team[t]++;
		}
	}
}
void CColossusStoneMgr::SetStoneByTeam( int id, int team )		// 绢恫 评捞 胶沛阑 扒靛啡阑锭
{
	ITEMLIST *target = GetList( id );
	if( target )
	{
		::SetStoneByTeam( target, team );
	}
}

void CColossusStoneMgr::SetStoneFirst()		// 檬扁 技泼
{
	DWORD attr = 0;
	SetAttr2( attr, IA2_COLOSSUS_STONE | STONE_SCORE_FIRST );

	CColossusStone *target = m_StoneList.next;
	for( ;target; target = target->next )
	{
		target->stone->attr[IATTR_ATTR] = attr;
	}
	SetWinCondition();
}

int CColossusStoneMgr::GetMaxStone()
{
	if( !m_MaxStone )
	{
		CColossusStone *target = m_StoneList.next;
		for( ;target; target = target->next )
		{
			m_MaxStone++;
		}
	}
	return m_MaxStone;	
}



void SetStoneByTeam( ITEMLIST *item, int team )		// 绢恫 评捞 胶沛阑 扒靛啡阑锭
{
	DWORD attr = 0;
	SetAttr2( attr, IA2_COLOSSUS_STONE );		// or 楷魂 
	switch( team )
	{
		case 0 : break;
		case 1 : 
			SetAttr2( attr, STONE_SCORE_1 );
			break;
		case 2 : 
			SetAttr2( attr, STONE_SCORE_2 );
			break;
		case 3 : 
			SetAttr2( attr, STONE_SCORE_2 );
			SetAttr2( attr, STONE_SCORE_1 );
			break;
	}
	item->attr[IATTR_ATTR] = attr;
}

int GetTeamByStone( DWORD attr )
{
	if( GetAttr2( attr, STONE_SCORE_FIRST )  ) return -1;		// 酒流 评捞 绝促.
	return ( GetAttr2( attr, STONE_SCORE_2 )?2:0 + GetAttr2( attr, STONE_SCORE_1 )?1:0 );
}
//
//////////////////////////////////////////////////////////////////////////

// if( !ch->curr_fight_map ) 扼绰 炼扒巩阑 固府 眉农 秦滴绊 龋免秦具 茄促.
int GetFightTeamNumber( CHARLIST *ch )
{
	return ( ch->curr_fight_map - 100 );
}

/////////////////////////////////////////////////////////////////////////
// CGuildHouse member functions
CGuildHouse	g_GuildHouse;

CGuildHouseUnit *CGuildHouse::GetPointByEventNo(char *map_name, int event_no)
{	// 秦寸 甘苞 捞亥飘 锅龋肺 喀器府酒 努饭胶俊 立辟
	for (int i = 0; i < m_Max; ++i)
	{
		// 措巩磊捞绢具 茄促.
		if (strcmp( m_aGuildHouse[i].map_name, map_name) == 0)
		{
			if (m_aGuildHouse[i].event_no == event_no)
			{
				return &m_aGuildHouse[i];
			}
		}
	}

	return NULL;
}

CGuildHouseUnit *CGuildHouse::GetPointByGuildCode(int guild_code)
{	// 辨靛 内靛肺 骏器府酒 努饭胶俊 立辟
	for (int i = 0; i< m_Max; ++i)
	{
		if (m_aGuildHouse[i].guild_code == guild_code)
		{
			return &m_aGuildHouse[i];
		}
	}

	return NULL;
}

// 020620 YGI
int CGuildHouseUnit::GoToHouse(short int cn)
{
	return GotoUser(map_name, x, y, cn);
}

int CGuildHouse::GoToHouse( CHARLIST *ch ) // 秦寸 骏器府酒肺 捞悼
{	//< CSD-030324
	int guild_code = ch->GetGuildCode();
	if( !guild_code ) return 0;

	CGuildHouseUnit *house = GetPointByGuildCode( guild_code );
	if( !house ) return 0;

	return house->GoToHouse( ch->GetServerID());
}	//> CSD-030324

int CGuildHouse::IsMyGuildHouse(CHARLIST *ch, int event_no)
{	//< CSD-030806 : 秦寸 骏器府酒肺 捞悼
	CGuildHouseUnit* house = GetPointByEventNo(MapName, event_no);
	
	if (house == NULL) 
	{
		return 0;
	}

	if (house->guild_code == 0)
	{
		return 0;
	}

	if (house->guild_code != ch->GetGuildCode())
	{	// 泼败 滚府霸 茄促.
		house->GoToHouse(ch->GetServerID());
		return 0;
	}
	
	return 1;
}	//> CSD-030806

int CGuildHouse::clear()
{
	for( int i=0; i<MAX_GUILD_HOUSE; i++ )
	{
		m_aGuildHouse[i].clear();
	}

	m_Max = 0;
	return 1;
}

CGuildHouseUnit	*CGuildHouse::GetHouseByGuildCode( int guild_code )
{
	for( int i=0; i<m_Max; i++ )
	{
		if( m_aGuildHouse[i].guild_code == guild_code ) return &m_aGuildHouse[i];
	}

	return NULL;
}

// 020620 YGI
void GetTimeForFilename( char *filename1 )
{
	time_t nowTime;
	struct tm *now;
	time( &nowTime );
	now = localtime(&nowTime);

	int year = now->tm_year + 1900;
	int mon  = now->tm_mon + 1;
	int day  = now->tm_mday;
	sprintf(filename1, "%s_%d-%02d-%02d.log", filename1, year, mon, day);
}

////////////////////////////////////////////////////////////////////
// man to man fight

void EndManToManFight( CHARLIST *win, CHARLIST *lose )
{
	Fight_Stone_End( lose->GetServerID(), 1 );		// 沥惑利栏肺 脸促.
}

extern void SendMagicCommand(CHARLIST* lpChar, short int slot1 = 0, short int slot2 = 0, short int slot3 = 0);

void Fight_Stone_End(int cn, int flag)
{
	LPCHARLIST lpChar, lpTarget;

	lpChar = &connections[cn].chrlst;
	lpTarget = &connections[lpChar->fight_id].chrlst;

	if(lpChar)
	{
		switch(flag)
		{
		case 1:	// 柳版快
			{
				if(lpChar->fight_id)
				{
					SendMagicCommand( lpChar, 5, lpChar->fight_id, 2);
				}

				break;
			}
		case 2:	// 捞变版快
			{
				if(lpChar->fight_id)
				{
					SendMagicCommand( lpChar, 5, lpChar->fight_id, 1);
				}
				
				break;
			}
		case 3:	// 厚变版快
			{
				if(lpChar->fight_id)
				{
					SendMagicCommand(  lpChar, 5, lpChar->fight_id, 3);
				}

				break;
			}
		case 4:
			{
				SendMagicCommand(  lpChar, 5, 0, 4);
				break;
			}
		}

		ResultManToMan(cn, lpChar->fight_id, flag);	// 0910_2 YGI
		lpChar->fight_flag = 0;
		lpChar->fight_id = 0;
	}
	
	if(lpTarget)
	{
		switch(flag)
		{
		case 1:
			{
				if(lpChar->GetServerID())
				{
					SendMagicCommand(lpTarget, 5, lpChar->GetServerID(), 1);
				}

				break;
			}
		case 2:
			{
				if(lpChar->GetServerID())
				{
					SendMagicCommand(lpTarget, 5, lpChar->GetServerID(), 2);
				}
			
				break;
			}
		case 3:
			{
				if(lpChar->GetServerID())
				{
					SendMagicCommand(lpTarget, 5, lpChar->GetServerID(), 3);
				}

				break;
			}
		case 4:
			{
				break;
			}
		}

		lpTarget->fight_flag = 0;
		lpTarget->fight_id = 0;
	}
}

bool IsManToManFight( CHARLIST *attack, CHARLIST *defence )
{
	if( !attack || !defence ) return false;
	if( attack->IsNpc() || defence->IsNpc() ) return false;
	if( !attack->fight_flag || !defence->fight_flag ) return false;
	if( attack->fight_id == defence->GetServerID()) return true;
	return false;
}

bool IsArenaFight(CHARLIST* pMember)
{	//< CSD-030509
	CBaseArena* pGame = pMember->GetJoinArenaGame();

	if (pGame == NULL)
	{
		return false;
	}

	if (!pGame->IsPlayGame())
	{
		return false;
	}

	CArenaTeam* pTeam = pMember->GetJoinArenaTeam();

	if (pTeam == NULL)
	{
		return false;
	}

	return true;
}	//> CSD-030509

⌨️ 快捷键说明

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