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

📄 sealstone.cpp

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

#define __SEALSTONE__
#include "SealStone.h"

#include "SealStoneGameServer.h"

#include "..\LowerLayers\servertable.h"

#include "NationSys.h"						// LTS LOCALWAR
#include "LTSSupport.h"

#include "..\LowerLayers\MyLog.h"
#include "UserManager.h"
	
extern void SendCMD_SEALSTONE_BROKED(SealStoneStatus* tp);		// LTSSupport.cpp		// LTS LOCALWAR
extern void SendCMD_SEALSTONE_ATTACKED(SealStoneStatus* tp);

extern cNation*	g_pNation;						// LTS NEW LOCALWAR	

//--------------------------------------------------------------------
//	
//   User Functions..
//	
	
/*---------------------------------------------------------------------
	倒捞 府哩登芭唱 
    倒捞 何辑瘤搁 霸烙辑滚俊辑 焊郴霖促. 
	
  status : 0 --> 何辑咙   1 : 府哩凳..
---------------------------------------------------------------------*/
void RecvSealStoneStatus( t_packet *p )			// LTS LCOALWAR
{	
	t_sealstone_status *tp;
	int status;
	int i;
	
	tp = &p->u.sealstone_status ;

	switch( tp->status )
	{
		// 磷菌促. 
	case 0 :		status = 0;		break;
		// 登混酒车促. 
	case 1 :		status = 1;		break;
		// 鸥拜阑 罐疽促. 
	case 2 :		status = 2;		break;		// LTS LOCALWAR

	}

	switch( tp->sealstonesprno )//<<< // 030516 kyo
	{
	case 98 :	// 官捞辑胶
		{
			SealStone[ N_VYSEUS].status[tp->id] = status;
			if (g_pNation!=NULL) 
			{
				g_pNation->SetSealStoneStatus(0,tp->id,status,tp->Hp);	// LTS NEW LOCALWAR
			}
			break;
		}	
	case 99 :// 磊捞戚
		{
			SealStone[ N_ZYPERN].status[tp->id] = status;
			if (g_pNation!=NULL)
			{
				g_pNation->SetSealStoneStatus(1,tp->id,status,tp->Hp);	// LTS NEW LOCALWAR
			}
			break;
		}
	case 91 :// 老胶
		{
			SealStone[ N_YILSE ].status[tp->id] = status;
			
			if (g_pNation!=NULL) 
			{
				g_pNation->SetSealStoneStatus(2,tp->id,status,tp->Hp);	// LTS NEW LOCALWAR
			}
			break;
		}
	}//>>>// 030516 kyo

/*	if (g_pNation!=NULL)
	{
		g_pNation->CheckSealStoneStatus();
	}*/

	if( status == 0 )
	{
		for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)		// 011213 LTS
		{
			if( connections[i].dwAgentConnectionIndex )
			{
				if( connections[i].server_check ) QueuePacket( connections, i, p, 1 );
			}
		}
				// 咯扁辑 傈眉皋技瘤甫 焊辰促.
 		SendCMD_SEALSTONE_BROKED((SealStoneStatus*)tp);
	}


	if ( status == 2 )	SendCMD_SEALSTONE_ATTACKED((SealStoneStatus*)tp);
}	
	
/*---------------------------------------------------------------------
	空捞 急傈器绊甫 沁促.	->  搬拌籍捞 府哩瞪锭俊绰 且荐 绝栏哥
	汲傍窍搁 急傈器绊 沁促绰 皋矫瘤啊 夺促
---------------------------------------------------------------------*/
void RecvSealStoneFromKing( int nation )
{	
	if( SealStone[ nation].regentime ||  SealStone[ nation].waraftertime ) return; // 府哩窍绰悼救俊绰 促矫 急傈器绊啊 登瘤 臼绰促. 
	SealStone[ nation].warlefttime = g_curr_time + SEALSTONE_WARTIME_;
	
	t_packet p;
	int i;
	
	p.h.header.type = CMD_SEALSTONE_WAR_START;
	p.h.header.size = sizeof( t_sealstone_war_start);
	p.u.sealstone_war_start.nation = nation;
	
	for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)
		if( connections[i].dwAgentConnectionIndex )
			if( connections[i].server_check )
				QueuePacket( connections, i, &p, 1 );
}	
	
	
void SendResultNationWar( int aresult, int anation, int bresult, int bnation )
{	
	t_packet p;
	int i;
	
	p.h.header.type = CMD_SEALSTONE_RESULT;
	p.h.header.size = sizeof( t_sealstone_result );
		p.u.sealstone_result.aresult = aresult;
		p.u.sealstone_result.anation = anation;
		p.u.sealstone_result.bresult = bresult;
		p.u.sealstone_result.bnation = bnation;
	for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)
		if( connections[i].dwAgentConnectionIndex )
			if( connections[i].server_check )
				QueuePacket( connections, i, &p, 1 );
}	
	
// 捞力 搬拌籍阑 府哩瞪巴捞绊 寸盒埃 搬拌籍阑 何贱荐 绝促. 
void SendSealStoneReGenStart( void )
{	
	int i;		
	t_packet p;	
				
	p.h.header.type = CMD_SEALSTONE_START_RE_GENTIME;
	p.h.header.size = 0;
	
	for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)
		if( connections[i].dwAgentConnectionIndex )
			if( connections[i].server_check )
				QueuePacket( connections, i, &p, 1 );
}	
	
	
// 捞力 急傈器绊甫 且荐 乐澜阑 Client鳖瘤 舅赴促. 	
void SendEndOfReGenTime( void )
{	
	int i;		
	t_packet p;	
	
	p.h.header.type = CMD_SEALSTONE_END_RE_GENTIME;
	p.h.header.size = 0;
	
	for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)
		if( connections[i].dwAgentConnectionIndex )
			if( connections[i].server_check )
				QueuePacket( connections, i, &p, 1 );
}	
	
//	泅犁 巢篮 矫埃阑 Client鳖瘤 谎妨霖促.
void SendWarLeftTime_sub( int nation )
{				
	int i;		
	t_packet p;	
				
	p.h.header.type = CMD_SEALSTONE_WAR_LEFTTIME;
	p.h.header.size = sizeof( t_sealstone_warlefttime );
		p.u.sealstone_warlefttime.nation = nation;
		p.u.sealstone_warlefttime.lefttime = SealStone[ nation].warlefttime - g_curr_time;
	for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)
		if( connections[i].dwAgentConnectionIndex )
			if( connections[i].server_check )
				QueuePacket( connections, i, &p, 1 );
}				

// int nation狼 唱扼啊 惑措狼 搬霸籍阑 葛滴 何继绰啊?
// 1 : 葛滴 何继促. 
// 0 : 酒流 巢篮霸 乐促. 
int CheckVictory( int nation )
{	
	int i;
	
	for( i = 0 ; i < MAX_SEALSTONE_NATION_ ; i ++)
	{
		if( SealStone[ antination[nation]].status[i] ) break;
	}
	if( i == MAX_SEALSTONE_NATION_ )
	{	
		return 1;	// 葛电霸 何寂脸促. 
	}	

	return 0; // 酒流 巢篮霸 乐促. 

}	
	

				
void CheckWarLeftTime( void )
{				
	static DWORD t;
	int nation;
				
	if( g_curr_time - t > 6 )
	{			
		t = g_curr_time;
	}	
	else return;

	for( nation = N_VYSEUS ; nation <= N_ZYPERN ; nation ++ )
	{
		if( SealStone[ nation].warlefttime == 0) continue;
				
		if( SealStone[ nation].warlefttime - g_curr_time  < SEALSTONE_WARTIME_ )
		{		
			SendWarLeftTime_sub( nation );
		}		
		else	
		{		
			SealStone[				nation].warlefttime	= 0;
			SealStone[	antination[nation]].warlefttime	= 0;
			SealStone[				nation].waraftertime	= g_curr_time + SEALSTONE_WAR_AFTERTIME_;
			SealStone[	antination[nation]].waraftertime	= g_curr_time + SEALSTONE_WAR_AFTERTIME_;
				
			if( CheckVictory( nation ) == 1 ) // nation捞 捞板促. 
			{	
				SendResultNationWar( SSR_VICTORY, nation, SSR_FAIL, antination[ nation]  );
			}	
			else	//何铰何促. 
			{	
				SendResultNationWar( SSR_DRAW, nation, SSR_DRAW, antination[ nation]  );				
			}	
		}		
	}			
}				
				
				
// 傈里捞 场唱绊 泪矫炼侩茄 矫埃阑 爱绰促.
void CheckSealStoneWarAfterTime( void )
{
	int nation;	
	static DWORD t;
		
	if( g_curr_time - t > 10 )
	{	
		t = g_curr_time;
	}	
	else return;

	for( nation = N_VYSEUS ; nation <= N_ZYPERN ; nation ++ )
	{			
		if( SealStone[ nation].waraftertime == 0) continue;
				
		if( SealStone[ nation].waraftertime - g_curr_time  < SEALSTONE_WAR_AFTERTIME_ )
		{			
		}			
		else		
		{			
			SealStone[				nation].waraftertime = 0;
			SealStone[	antination[nation]].waraftertime = 0;
			SealStone[				nation].regentime	 = g_curr_time + SEALSTONE_RE_GENTIME_;
			SealStone[	antination[nation]].regentime	 = g_curr_time + SEALSTONE_RE_GENTIME_;

			SendSealStoneReGenStart();
		}	
	}	
}

// 捞矫埃捞 瘤唱搁 促矫 搬拌利阑 何贱荐 乐促. 
void CheckReGenTime( void )
{	
	static DWORD t;
	int    nation;

	if( g_curr_time - t > 6 )
	{						
		t = g_curr_time;
	}			
	else return;	
				
	for( nation = N_VYSEUS ; nation <= N_ZYPERN ; nation ++ )
	{			
		if( SealStone[ nation].regentime == 0) continue;
				
		if( SealStone[ nation].regentime - g_curr_time  > SEALSTONE_RE_GENTIME_)
		{			
		}			
		else		
		{			
			SealStone[				nation].regentime  = 0;
			SealStone[	antination[nation]].regentime  = 0;
			SealStone[				nation].warlefttime= 0;
			SealStone[	antination[nation]].warlefttime= 0;

⌨️ 快捷键说明

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