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

📄 sealstone.cpp

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

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

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

	switch( tp->sealstonesprno )
	{
		// 官捞辑胶
	case 98 :	SealStone[ N_VYSEUS].status[tp->id] = status;
		break;
		// 磊捞戚
	case 99 :	SealStone[ N_ZYPERN].status[tp->id] = status;
		break;
	}

	if( status == 0 )
	{
		for(i = 0; i < LOGIN_MAX_CONNECTIONS; ++ i)
				if( connections[i].server_check )
					QueuePacket( connections, i, p, 1 );

		::MyLog(0,"RecvSealStoneStatus");

	}
}	
	
/*---------------------------------------------------------------------
	空捞 急傈器绊甫 沁促.	->  搬拌籍捞 府哩瞪锭俊绰 且荐 绝栏哥
	汲傍窍搁 急傈器绊 沁促绰 皋矫瘤啊 夺促
---------------------------------------------------------------------*/
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].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].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].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].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].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;
			SealStone[				nation].regentime  = 0;
			SealStone[	antination[nation]].regentime  = 0;

			SendEndOfReGenTime();
		}	
	}
}	
	
//	傈傈器绊啊 等第俊 ,葛电 搬拌籍捞 柄脸绰啊?
void CheckSealStoneStatus( void )
{		
	int nation, j;	
	static DWORD t;
		
	if( g_curr_time - t > 10 )
	{	

⌨️ 快捷键说明

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