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

📄 menuserver2.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	
	if (ch == NULL) 
	{
		return;
	}

	CBaseArena* pArena = ch->GetJoinArenaGame();

	if (pArena == NULL)
	{
		return;
	}

	if (!pArena->IsPlayGame())
	{
		return;
	}

	CArenaTeam* pTeam = ch->GetJoinArenaTeam();

	if (pTeam == NULL)
	{
		return;
	}

	const int nItem = p->u.kein.default_short_int;
	
	if (nItem < 0 || nItem >= MAX_ITEM_LIST) 
	{
		return;
	}

	SetStoneByTeam(&ItemList[nItem], pTeam->GetTeamNumber());

	t_packet packet;
	packet.h.header.type = CMD_ATTACK_COLOSSUS_STONE_RESULT;
	packet.h.header.size = sizeof(k_attack_colossus_stone_result);
	packet.u.kein.attack_colossus_stone_result.server_id = cn;
	packet.u.kein.attack_colossus_stone_result.item_id = nItem;
	packet.u.kein.attack_colossus_stone_result.attr = ItemList[nItem].attr[IATTR_ATTR];
	QueuePacket(connections, cn, &packet, 1);
	CastMe2Other(cn, &packet);
	// 泅犁 倒狼 荐甫 墨款飘 秦辑 焊郴霖促.
	int team_stone[4] = {0,};
	g_ColossusStone.GetTeamCount( team_stone );
	
	for (int i = 0; i < 2; ++i)
	{	//< CSD-030520
		CBaseArena* pGame = g_pArenaManager->GetGameInfo(i);

		if (pGame == NULL)
		{
			continue;
		}

		pGame->SendGameMessage(i, 2, team_stone[i]);
	}	//> CSD-030520
	// 傈眉俊霸 穿啊 胶沛阑 瞒瘤 沁绰瘤 舅妨霖促.
	CBaseArena* pGame = ch->GetJoinArenaGame();

	if (pGame != NULL)
	{	//< CSD-030520
		pGame->SendGameMessage(ch, 5, ItemList[nItem].dumno+1);
	}	//> CSD-030520

	// 傈何 瞒瘤 沁绰瘤 舅酒夯促.
	int time = 0;
	int got_stone_team = 0;		// 倒阑 刀痢茄 评
	for( i=0; i<2; i++ )
	{
		if( team_stone[i] == g_ColossusStone.GetMaxStone() )
		{
			got_stone_team = i;
			time = g_curr_time;
			break;
		}
	}
	g_ColossusStone.SetWinCondition( time, got_stone_team );
}	//> CSD-030509

void CallMenu( short int menu, short int cn )
{
	SendPacketDefault( CMD_CALL_MAIN_MENU, &menu, sizeof( short int ), cn );
}

void RecvRevivalColossus(t_packet *p, short int cn)
{	//< CSD-030509
	CHARLIST* ch = CheckServerId(cn);
	
	if (ch == NULL)
	{
		return;
	}

	CBaseArena* pGame = ch->GetJoinArenaGame();

	if (pGame == NULL)
	{
		return;
	}

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

	CArenaTeam* pTeam = ch->GetJoinArenaTeam();

	if (pTeam == NULL)
	{
		return;
	}

	switch (pGame->GetArenaType())
	{
	case AT_STONE:
	case AT_MONSTER:
		{
			if (ch->viewtype != VIEWTYPE_GHOST_ && ch->Hp > 0) 
			{	// 蜡飞捞 酒聪促.
				return;
			}

			int nX = 0, nY = 0;
			pTeam->GetBasePosition(nX, nY);
			MovePc(cn, nX, nY);
			SkillMgr.CharacterToAlive(ch);
			// 傈眉 傍瘤 皋矫瘤
			pGame->SendGameMessage(ch, 4, 0); // CSD-030520
			break;
		}
	}
}	//> CSD-030509

void RecvGuildHouseInfo( t_packet *p, short int cn )
{	//< CSD-030324
	CHARLIST *ch = CheckServerId( cn ); 
	if( !ch ) return;

	//if( !ch->GetGuildCode() ) return;
	int nation = ch->name_status.nation;

	t_packet packet;
	packet.h.header.type = CMD_GUILD_HOUSE_INFO;
	k_guild_house_info *t = (k_guild_house_info *)packet.u.data;
	CGuildHouseUnit *pData;
	t->count=0;
	for( int i=0; i<g_GuildHouse.m_Max; i++ )
	{
		pData = &g_GuildHouse.m_aGuildHouse[i];
		if( !pData->id ) continue;
		if( pData->nation != nation ) continue;
		t->data[t->count].id = pData->id;
		t->data[t->count].guild_code = pData->guild_code;
		t->data[t->count].blue = pData->blue;
		t->data[t->count].red = pData->red;
		t->data[t->count].lv = pData->level;

		t->data[t->count].time = 0;
		// 031009 CI YGI
		int time = 0;
		if( pData->year >= 1900 )
		{
			time += (pData->year-g_year )*365;
			time += (pData->month-g_mon-1)*30;
			time += pData->day-g_day;
			if( time < 0 ) t->data[t->count].time = 0;
			else if( time > 125 ) t->data[t->count].time = 60;
			else
			{
				t->data[t->count].time = time;
			}
		}
		
		strcpy( t->data[t->count].map_name, pData->map_name );
		t->count ++;
	}
	packet.h.header.size = sizeof( k_guild_house_info_unit )*t->count+sizeof( char );
	QueuePacket( connections, cn, &packet, 1 );
	static check_day = g_day;
	//if( check_day != g_day )
	{
		check_day = g_day;
		CallClient( DB_DEMON, CMD_CHECK_GUILD_HOUSE );		// 绝绢廉具 且 辨靛啊 乐绰瘤 眉农茄促. // 函版 荤亲阑 傈 甘俊 谎妨霖促.
	}
}	//> CSD-030324

void RecvBuyGuildHouse( t_packet *p, short int cn )
{	//< CSD-030324
	CHARLIST *ch = CheckServerId( cn );
	if( !ch ) return;

	int house_id = p->u.kein.default_char;
	int guild_code = ch->GetGuildCode();

	if( !CheckGuildPower( GDP_BUY_GUILD_HOUSE, ch ) ) return;		// 辨付父 荤侩且 荐 乐促.

	CGuildHouseUnit	*pHouse = g_GuildHouse.GetHouseByIndex( house_id );		// 扁粮 辨靛啊 乐促.
	if( !pHouse  || !pHouse->id ) return;
	if( pHouse->nation != ch->name_status.nation ) return;


	if( GetItemMuchByMuchItem( ch, IN_BLUE_SIGNET ) < pHouse->blue ) return;		// 矫弊齿捞 何练窍促.
	if( GetItemMuchByMuchItem( ch, IN_RED_SIGNET ) < pHouse->red ) return;		// 矫弊齿捞 何练窍促.

	k_change_guild_house_info data;
	data.guild_code = guild_code;
	data.id = pHouse->id;		// 骏器府酒 牢郸胶
	if( pHouse->guild_code )
	{
		if( pHouse->guild_code != guild_code ) return;

		int time = 0;
		if( pHouse->year >= 1900 )
		{
			time += (pHouse->year-g_year )*365;
			time += (pHouse->month-g_mon-1)*30;
			time += pHouse->day-g_day;
		}
		if( time < 0 || time > 5 )
		{
			// 茄锅父 楷厘 且 荐 乐促.
			SendPutMenuString( KM_FAIL, 174, cn );
			return;
		}
		// 捞版快浚 叼厚 单阁捞 葛电辑滚肺 焊郴林霸 窍磊..
		data.day_type = 2;		// 楷厘
	}
	else
	{
		CGuildHouseUnit	*pData = g_GuildHouse.GetHouseByGuildCode( guild_code );
		if( pData ) return;		// 捞固 啊瘤绊 乐绰 骏器府酒啊 乐促.
		// 货肺 脚没
		data.day_type = 1;		// 脚痹 脚没
	}

	// 昏力 // 秒家 灯阑 版快 昏力 登骨肺 DB-demon俊辑 秒家 登搁 救等促.
	SendDeleteMuchItemQuantity( ch, IN_BLUE_SIGNET, pHouse->blue );
	SendDeleteMuchItemQuantity( ch, IN_RED_SIGNET, pHouse->red );

	SendPacketDefault( CMD_CHANGE_GUILDHOUSE_INFO, &data, sizeof( k_change_guild_house_info ), DB_DEMON );
}	//> CSD-030324

void RecvChangeGuildHouse( t_packet *p, short int cn )
{
	// 骏器府酒 沥焊 盎脚
	int house_id = p->u.kein.change_guild_house_info_db2map.house_id;
	CGuildHouseUnit	*pHouse = g_GuildHouse.GetHouseByIndex( house_id );
	if( !pHouse  || !pHouse->id ) return;

	pHouse->guild_code		=	p->u.kein.change_guild_house_info_db2map.guild_code;
	pHouse->year			=	p->u.kein.change_guild_house_info_db2map.year;
	pHouse->month			=	p->u.kein.change_guild_house_info_db2map.month;
	pHouse->day				=	p->u.kein.change_guild_house_info_db2map.day;
}

void RecvCheckGuildHouse( t_packet *p, short int cn )
{
	int count = p->u.kein.check_guild_house.count;
	char *pHouseId = p->u.kein.check_guild_house.pHouseId;
	if( !count ) return;

	for( int i=0; i<count; i++ )
	{
		CGuildHouseUnit	*pHouse = g_GuildHouse.GetHouseByIndex( pHouseId[i] );
		if( !pHouse ) continue;
		pHouse->guild_code = 0 ;
	}
}

/////////////////////////////////////////////////////////////////////////////////////
// CPotionBox member fuctions
int CPotionBox::PutItem( ItemAttr *item )
{
	//if( !box_type ) return 0;
	CItem *t= ::ItemUnit( item->item_no );
	if( !t ) return 0;

	switch( t->GetItemKind())
	{
	case IK_POTION_BAG:		// BBD 040213	器记归档 器记冠胶俊 甸绢啊谷 臼等促
	case IK_POTION_BOX:
	case IK_CANDLE:
	case IK_GOOD_CANDLE:
		{
			return 0;
		}break;
	}
	if( t->GetRbutton() != USE_ITEM ) {return 0;}

	if(item->attr[IATTR_RARE_MAIN])//扁瓷 酒捞袍篮 给冈绢
	{
		return 0;
	}

	if( much )
	{
		if( item_no != item->item_no ) {return 0;}
		if( 50<= much){return 0;}//020520 lsw 50俺肺 力茄
	}
	else
	{
		item_no = item->item_no ;
	}
 
	much++;
	SaveData();
	::DeleteItem(item);
	
	return 1;
}

int CPotionBox::DeleteItem()
{
	if( !much ) return 0;		// 滑芭 绝澜
	much--;
	SaveData();
	return 1;
}

int CPotionBox::UseItem()
{
	if( !DeleteItem() ) return 0;		// 绝促.
	CItem *t = ::ItemUnit( item_no );
	if( !t ) 
	{
		return 0;
	}
	
	switch( t->GetItemKind())//剧檬唱 器记 惑磊老 版快 瘤况 滚赴促
	{
	case IK_POTION_BAG:		// BBD 040213	器记归档 器记冠胶俊 甸绢啊谷 臼等促, 寸辟 荤侩档 臼凳
	case IK_POTION_BOX:
	case IK_CANDLE:
	case IK_GOOD_CANDLE:
		{
			item_no = 0;
			much = 0;
			return 0;
		}break;
	}
	const int add_hp = t->EatItem( hero );
	return add_hp;
}

void CPotionBox::SaveData( )		// 酒捞袍阑 荤侩茄饶  历厘茄促.
{
	DWORD temp;
	temp = MAKELONG( item_no, much );
	hero->Sight = temp;
	hero->SendCharInfoBasic( CIB_POTION_BOX, GetData() );		// 函版 荤亲阑 舅妨霖促.////020704 lsw
}

void RecvPkOnOff( t_packet *p, short int cn )
{
	CHARLIST *ch = CheckServerId( cn );
	if( !ch ) return;

	int pk_on_off= p->u.kein.default_char;
	if( ch->pk_on_off != pk_on_off )
	{
		ch->pk_on_off = pk_on_off;
		QueuePacket( connections, cn, p, 1 );
	}
}

void RecvCMD_GET_PK_ON_OFF( t_packet *p, short int cn )
{
	CHARLIST *ch = CheckServerId( cn );
	if( !ch ) return;

	SendPacketDefault( CMD_GET_PK_ON_OFF, &ch->pk_on_off, sizeof( char ), cn );
}

// 020430 YGI acer 3
//////////////////////////////////////////////////////////////////////
// CItemLog member functions
CItemLog	g_item_log;
//acer4
void CItemLog::Load( int port )
{
	int temp = 0;
	char MapServerConfigFileName[MAX_PATH];
	sprintf(MapServerConfigFileName,"%s/data/MapServerConfig.ini", GameServerDataPath);
	//if( GetOwnPort() == GetManagementMapPort( port ) )
	{
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "DeleteDay",0,MapServerConfigFileName);
		if( !temp ) return;
		m_nDeleteDay = temp;

		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "SaveLevel",0,MapServerConfigFileName);
		if( temp ) m_nSaveLv = temp;

		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "ItemLevel",0,MapServerConfigFileName);
		if( temp ) m_nItemLv = temp;

		MyLog( LOG_NORMAL, "Item Log config, DeleteDay = %d, SaveLevel = %d, ItemLevel = %d", m_nDeleteDay, m_nSaveLv, m_nItemLv );

		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "trade",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_PUT_OTHER_CH] = temp;
			m_aType2Lv[SILT_GET_OTHER_CH] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "store",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_GET_STORE] = temp;
			m_aType2Lv[SILT_PUT_STORE] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "ground",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_PUT_GROUND] = temp;
			m_aType2Lv[SILT_GET_GROUND] = temp;
			m_aType2Lv[SILT_PUT_GROUND_MAX_INVEN] = temp;
			m_aType2Lv[SILT_DROP_BY_PK] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "duration",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_DELETE_BY_DURATION] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "stolen",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_GET_OTHER_CH_INVEN] = temp;
			m_aType2Lv[SILT_GET_STOLEN] = temp;
			m_aType2Lv[SILT_PUT_STOLEN] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "make_by_skill",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_MAKE_BY_SKILL] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "make_by_event",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_MAKE_BY_DB] = temp;
			m_aType2Lv[SILT_MAKE_BY_SCRIPT] = temp;
			m_aType2Lv[SILT_GET_GAMBLE_ITEM] = temp;
			m_aType2Lv[SILT_PUT_GAMBLE_ITEM] = temp;
			m_aType2Lv[SILT_DELETE_BY_SCRIPT] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "resource",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_RESOURCE_BY_SKILL] = temp;
			m_aType2Lv[SILT_NEED_ITEM] = temp;
		}
		temp = 0; temp = (int)GetPrivateProfileInt("ItemLog", "man2man",0,MapServerConfigFileName);
		if( temp ) 
		{
			m_aType2Lv[SILT_GET_MEN_TO_MEN] = temp;
			m_aType2Lv[SILT_PUT_MEN_TO_MEN] = temp;
		}
	}
	// 020620 YGI
	sprintf(MapServerConfigFileName,"%s/data/NoItemLog.txt", GameServerDataPath);
	m_NoItemList.Load( MapServerConfigFileName );
}

bool CItemLog::IsSave( ItemAttr *item, int event_type, int lv )
{
	if( lv == 100 ) return true;		// 公炼扒 历厘 // 030506 YGI

	if( !item ) return false;
	if( item->attr[IATTR_RARE_MAIN] ) return true;			// 饭绢 历厘
	
	if( m_NoItemList.Search( item->item_no ) ) return false;		// 历厘窍瘤 富酒扼 格废俊 乐栏搁 历厘窍瘤 臼绰促.
	if( item->item_no/1000 == ACCESSORY ) return true;		// 蜡聪农搁 历厘
	
	CItem *t = ::ItemUnit( item->item_no );
	if( !t ) return false;

	if( t->GetLevel() < m_nItemLv ) return false;			// 酒捞袍 饭骇捞 撤栏搁 历厘窍瘤 臼绰促.
	if( !m_aType2Lv[event_type] ) return false;				// 0 老版快 历厘窍瘤 臼绰促.
	if( m_nSaveLv && m_aType2Lv[event_type] > m_nSaveLv ) return false;	// 捞亥飘 鸥涝捞 撤栏搁 历厘窍瘤 臼绰促.
	
	return true;		// 酒捞袍 饭骇苞 鸥涝捞 臭酒具瘤父 历厘茄促.
}

// 020620 YGI
////////////////////////////////////////////////////////////////////////////
// class C2JinSearch

⌨️ 快捷键说明

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