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

📄 gameproc.cpp

📁 网络游戏龙族 完整的登陆器 C++ 源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#include "stdafx.h"
#include <Math.H>
#include "gameproc.h"

#include "map.h"
#include "char.h"
#include "path.h"
#include "network.h"
#include "object.h"

#include "Hong_Sprite.h"
#include "Hong_Light.h"
#include "Hong_Sub.h"
#include "menu.h"
#include "Hangul.h"
#include "Dragon.h"
#include "Effect.h"
#include "DirectSound.H"
#include "CharDataTable.h"
#include "Tool.h"
#include "MouseCursor.h"
#include "Skill.h"
#include "Item.h"
#include "SkillTool.h"
#include "SmallMenu.h"
#include "LineCommand.h"
#include "Counseler.h"
#include "NPC_Pattern.h"

#include "Resource.h"
#include "chat.h"

#include "CurrentMsgMgr.h"
#include "ExchangeMgr.h"
#include "NumberAniMgr.h"
#include "NumberAniMgr.h"
#include "TextOutMgr.h"
#include "FrameMgr.h"


///////////////////////////////////////////////////////////////////////////////
//
extern NPC_INFO g_infNpc[MAX_CHARACTER_SPRITE_]; // CSD-030419
extern CHARACTERLIST	g_CharacterList;
extern void DisplayEmote(const int x,const int y,const int iSmileNo);//020515 lsw
extern void WeatherStatus( void );
extern void PutMapLight( LPVOID dest, DWORD alpha);
extern LoadGameInfo( void );
extern int		GetItemAttr(int item_id, int attr); // MenuSet.h

extern void SendAction(int i,int Direction);			// LTS ACTION

extern bool g_bWarBegin;	// 011022 LTS
extern int	g_EventLocalWarBegin;		// 020115 LTS

extern int g_MouseItemType;	// menu.cpp
extern int g_MouseItemNumber;
extern int g_ActionAnger;		// LTS ACTION
extern int g_BoadAndSignNumber;	// CSD-030324 // thai2 YGI

////////////////////// SoundUp lkh 眠啊 ///////////////////////
extern int	BGM_SoundVolume;
extern BOOL	BGM_FadeInOut;

ORDERIFNO		g_OrderInfo;
int				g_OldOrderInfoCount;

static DWORD STDTime;
extern int NPCCOUNT;
extern	int			ListenCommand;		// network.cpp
extern	SystemInfo	system_info;
extern  int BetaTest;
int TestDeter;
DWORD	BeforeWalkClickTime,AfterWalkClickTime;
bool	DontMoveAttackFlag= false;
bool    CheckPC= false;

int NewOrderC = 0;
ORDERTABLE neworder[ 2000]= {0,};

int PathBuildSuccess = 0;

bool HeroActionProcChecked;//  父距 付快胶努腐俊   HeroActionProc()捞 龋免登瘤 臼疽促搁 DoLButtonUp()俊辑 龋免窍霸 茄促. 


const char ordermsg[6][30]= {	"Body.Weapon.Shield",
								"Body.Shield.Weapon",
								"Weapon.Body.Shield",
								"Weapon.Shield,Body",
								"Shield.Weapon,Body",
								"Shield.Body,Weapon"};



int AutoAttackFlag;
int AutoAttackSpriteType;
LPCHARACTER AutoAttacklpcharacter;
int AutoAttackx, AutoAttacky;

bool ScreenCaptureStartFlag;

int YouCanHeroActionProc;
int YouCanViewTipsCheck;
int ViewTipToggle;		// 0818 khs

int Moveoldx, Moveoldy;	// 捞悼阑 困秦 付快胶 努腐茄 瘤痢阑 扁撅窍绊 乐绰促. 
DWORD Movetime;

LPCHARACTER MouseCheckCharacterName;  //  付快胶俊 狼秦 急琶登绰 





///////////////// 0430 lkh 眠啊 ////////////////////
BOOL	g_AttackSkill_Trace1=FALSE;
BOOL	g_AttackSkill_Trace2=FALSE;


int ChangeMapFlag;				// 0825 KHS
t_server_change_map ChangeMapPacket;		


///////////////////////////////////////////////////////////////////////////////
//

BOOL		GameProc( LPDIRECTDRAWINFO lpDirectDrawInfo );
void		KeyboardProc( void );
void		MouseProc( void );

int			ProtocolProc( t_connection *c, bool flag );
void		CharacterProcCheck( void );
void		CharacterProcFrameCount( void );

void		DoLButtonDown( void );
void		DoLButtonUp( void );
void		DoRButtonDown( void );
void		DoRButtonUp( void );
void		DoLDButtonDown( void );
void		DoRDButtonDown( void );
void		DoLbuttonStill();
	
void		CalcOrder( void );
void		DisplaySprite( void );
void		DisplaySkillCursor( void );
void		DisplayTileFirst( void );
void		DisplaySpriteBottom( void );
void		DisplayShadowFirst( void);
void		DisplaySpriteCeiling( void );
void		DisplaySpriteTrans( void );
void		DisplaySpriteUnderTile( void );
void		DisplaySpriteNo( void );

void		_DisplayMapObjectAfter( void );

void		ViewAllCharacter( int x, int y );

void		SettingDestPoint( int x, int y );
void		PutDestPoint( void );
void		UnDisplayDestPoing( LPCHARACTER ch );


void		DoHeroAttack( int x, int y );

///////////////////// 0204 lkh 荐沥 /////////////////////////
bool		ReturnCheckObject( LPMAPOBJECT mo );
bool		GetBoardData(int board_Number, char* str_Data);
bool		GetDirectBoardData(int board_Number, DIRECTBOARDDATA* directboardData);
extern void	PutBoardMenu(int board_Number, char* str_Data);
extern void	PutDirectBoardMenu(const DIRECTBOARDDATA* directboardData);

extern void DisplayFightStone(void);
extern bool isOurSquad(LPCHARACTER hero,LPCHARACTER ch);		// 011018 LTS
extern void LocalWarInfoDisPlay();								// LTS LOCALWAR
extern void DrawParticleEffect();	// LTS DRAGON
extern void	CheckParticleEffect();	// LTS DRAGON

///////////////////// SoundUp lkh 眠啊 /////////////////////////
void	ObjectSoundPlay(void)
{
	int soundNo=0, soundFrame=0, soundDelay=0;
	int	soundCount=0, soundOverlap=0, soundType=0;

	LPMAPOBJECT		mo;
	Spr *sp;
	
	for( int i = 0 ; i < TotalMapObject ; i ++ )
	{
		mo = &Mo[i];
		int mox=mo->x;
		int moy=mo->y;

		if( IsScreenAreaView(mox,moy) )
		{
			sp = &MoImage[mo->id-1].spr[mo->curframe];

						
			soundNo		= mo->soundno%1000;

			if(soundNo>0)
			{
				soundCount	= mo->soundno/1000;

				soundFrame	= mo->soundframe%1000;
				soundOverlap= mo->soundframe/1000;		//吝酶 瓤苞澜 免仿阑 困秦

				soundDelay	= mo->sounddelay%1000;
				soundType	= mo->sounddelay/1000;		//技何 免仿 规过
				
				if(mo->delay==0)// || soundFrame==99)		//map_delay啊 0牢 版快 肚绰 公炼扒 吝酶 风俏 免仿牢 版快
				{
					int sx = mo->x;
					int	sy = mo->y;

					//int distance_X = abs(Hero->x - sx)/(TILE_SIZE);		//芭府甫 鸥老 窜困肺 券魂	// LTS SOUND
					//int distance_Y = abs(Hero->y - sy)/(TILE_SIZE);									// LTS SOUND

					int distance_X = sx-Hero->x;		//芭府甫 鸥老 窜困肺 券魂	// LTS SOUND
					int distance_Y = sy-Hero->y;									// LTS SOUND
					int tempsx=sx;				// LTS SOUND
					int tempsy=sy;

					//if( sx < Hero->x)	distance_X = -distance_X;
					//if( sy < Hero->y)	distance_Y = -distance_Y;

					int mo_X = sx/TILE_SIZE;
					int	mo_Y = sy/TILE_SIZE;

					if( soundNo && (mo->curframe == soundFrame || soundFrame==99) )			//风俏 瓤苞澜捞芭唱 荤款靛 免仿 秦寸 橇饭烙牢 版快牢 版快
					{
						BOOL	play=1;

						if(soundType!=2 && soundDelay)		// type->random 免仿
						{
							if( (soundCount) <= 0 )
								mo->soundno = (mo->soundno%1000)+soundDelay*1000;		//soundcount set
							else
								play=0;
							mo->soundno -= 1000;			//soundcount--
						}

						int	sound_Num=0;
						
						BOOL	play_Rate=0;//	= (mo->sounddelay%1000)/100;	//0->秦寸 橇饭烙俊辑 公炼扒 免仿 1->秦寸 橇饭烙俊辑 秦寸 厚啦俊 嘎苗 免仿
						
						int		probability=0;

						switch(soundType)
						{
						case 1:		//3way
							sound_Num		= soundNo+rand()%3;
							break;
						case 2:		//犬伏俊 狼秦 家府 免仿
							play_Rate		= 1;
							probability		= soundDelay;
							sound_Num		= soundNo;
							break;
						default:	
							sound_Num		= soundNo;
							break;
						}
						
						if( play )
						{
							if( ( play_Rate && (rand()%101 <= probability ) ) || !play_Rate )	//犬伏俊 狼秦 免仿登绰 版快客 犬伏俊 包拌 绝绰 版快
							{
								if(soundOverlap)		//true->公炼扒 秦寸 橇饭烙俊辑 免仿(坷宏璃飘狼 橇饭烙捞 利篮 版快 吝酶凳)
									//PlayListAutoSounds( sound_Num, distance_X, distance_Y, 0 );	//3D sound肺 钎泅 // LTS SOUND
									PlayListAutoSounds( sound_Num, distance_X, distance_Y, 0 );	//3D sound肺 钎泅 // LTS SOUND
								else					//false->免仿 橇饭烙俊 惑包绝捞 吝酶登瘤 臼霸 
								{
									if( !IsPlaying(sound_Num))
										//PlayListAutoSounds( sound_Num, distance_X, distance_Y, 0 );
									PlayListAutoSounds( sound_Num, distance_X, distance_Y, 0 );	//3D sound肺 钎泅 // LTS SOUND
								}
							}
						}
					}
				}
			}
		}		
	}							
}								
							
void DisplayDebug( void )	
{							
#ifdef _DEBUG				
	int i;					
	ViewCounselerStatus();	
	
	if( tool_ID_INPUT_MAP_ATTR )
	{
		Hcolor( 0,255,0 );	
		Hprint2(10, 300, g_DestBackBuf , "Working Map Attr." );
		if( tMapAttrAllAffect == IDC_SOURCE_AFFECT_YES )
		{
			Hcolor( 255,0,0 );
			Hprint2(10, 320, g_DestBackBuf , "Effect to All Source" );
		}
		
		switch( tMapAttr )
		{
		case IDC_ATTR_DONT		:	Hcolor( 255,0,0 );
									Hprint2( 10, 340, g_DestBackBuf, "Dont Attr" );
			break;
		case IDC_ATTR_RIVER		:	Hcolor( 0,100,200 );
									Hprint2( 10, 340, g_DestBackBuf, "Watter Attr" );
			break;
		case IDC_ATTR_GEFFECT	:	Hcolor( 0xffff );
									Hprint2( 10, 340, g_DestBackBuf, "EffectWall Attr" );
			break;
		}
	}
	
	Hcolor( 0,255,0 );
	if( GetSysInfo( SI_GAME_MAKE_MODE ) )
	{			
		Hprint2( 400, 400, g_DestBackBuf, "%d ", Hero->toflag);
		if( tool_MouseCursorBlock )
		{	
			Hprint2(10-1, 110-1, g_DestBackBuf , "CursorAni NO : %d ", CurMouseCursorNo );
			Hprint2(10+1, 110+1, g_DestBackBuf , "CursorAni NO : %d ", CurMouseCursorNo );
			Hcolor( 255,0,0 );
			Hprint2(10, 110, g_DestBackBuf , "CursorAni NO : %d ", CurMouseCursorNo );
			Hcolor( 0,255,0 );
		}
		if( SysInfo.notconectserver == 0 )
		{	
			Hcolor( 0,255,0 );
			Hprint2( 200,440, g_DestBackBuf , "R:%d S:%d", g_RecvBytes, g_SendBytes );
			Hprint2( 200,455, g_DestBackBuf , "0:%d 1:%d", connections.packet_count[0], connections.packet_count[1]);
		}	
		if( SkillStatus )
		{	
			switch( SkillStatus )
			{
				case SKILL_ON : Hprint2( 200,180, g_DestBackBuf , "Skill_ON" );		break;
				case SKILL_ING :  Hprint2( 200,180, g_DestBackBuf , "Skill_ING" );	break;
			}
		}	
			
		LPCHARACTER ch = Hero;
		i = 1;
		int npcno = 0, pcno = 0;
		int itemno_ = 0;
		if( SysInfo.notconectserver == 0 )
		while( ch != NULL )
		{
			if( ch->id >= 10000 ) npcno ++;
			else pcno ++;
			ch = ch->lpNext;
		}
		LPITEMGROUND titem = g_Item;
		while( titem )
		{
			itemno_ ++;
			titem  = titem->next;
		}
		Hprint2( 640, 7, g_DestBackBuf, "NPC: %d  PC:%d  Item:%d ", npcno, pcno, itemno_ );
		
		if( tool_ViewAllCharacter )	ViewAllCharacter( 0, 0 );
		
		if( tool_IDD_INPUT_MAPOBJECT )
		{
			static int tt, tto;
			if( tto )	{ tt ++; if( tt > 5  ){ tto = !tto; } }
			else		{ tt --; if( tt < -5 ){ tto = !tto; } }

			if( TempMoImage.spr[0].img )	PutCompressedImage( 160, 300+tt, &TempMoImage.spr[0] );
		}
	}	

	if( SysInfo.viewcharacterframe )
	{	
		h_DisplayPC_Temp( Hero );
		Hcolor( 0xffff );
		Hprint2(10, 120, g_DestBackBuf , "Dir:%d  Frame:%d ", SpriteOrderDir, SpriteOrderFrame );
		Hprint2(10, 140, g_DestBackBuf , "%s", ordermsg[ SpriteOrder[Hero->sprno][ SpriteOrderDir][SpriteOrderFrame]] );
	}	
#endif
}		

BOOL StartMenuProc(LPDIRECTDRAWINFO lpDirectDrawInfo)
{	//< CSD-030806

	char*	pTemp = NULL;//soto-HK;
	if (ProtocolProc(&connections) < 0)
	{
		return	FALSE;
	}

	if (!g_bIsActive)
	{
		goto SKIP__;
	}

	if (UpdateInputState( ) == DI_OK)
	{												
		KeyboardProc();									
		MouseProc();								
	}													

	if (!g_FrameMgr.CanNextFrame())
	{
		goto SKIP__;
	}
	
	if (g_DirectDrawInfo.lpDirectDraw == NULL)
	{
		if (!InitDirectDraw(g_hwndMain, &g_DirectDrawInfo))
		{
			return 0;
		}
	}
	
	g_DestBackBuf = GetSurfacePointer( g_DirectDrawInfo.lpDirectDrawSurfaceBack );											
	StartMenuChecking();
	StartMenuDisplay();
	g_nLButtonState = 0;g_nRButtonState = 0;
	g_nLDButtonState = 0; g_nRDButtonState = 0;
	ViewTips(); // 001030 KHS	
	CursorDisplayBack();
	FlipScreen(lpDirectDrawInfo);

//<soto-HK	
	g_FrameMgr.DoFrameDelay(&pTemp);
	
	strcpy(pTemp,"c8");
	delete pTemp; pTemp = NULL;
//>soto-HK

SKIP__:
	CheckingAccelator_Sub1();	// 020620 YGI
	return	TRUE;
}	//> CSD-030806
//010604 lsw	
extern DWORD ServerAccelTime;
extern void CheckAccelerator();
extern DWORD g_ClientTime_accel;
extern DWORD g_ClientTimeNoGap;		//011122 lsw

extern int RecvChangeMap( t_server_change_map *p );
	
BOOL GameProc( LPDIRECTDRAWINFO lpDirectDrawInfo )//030703 lsw
{
#ifdef USE_PROFILER	// 031013 kyo
	g_ProFileMgr.StartCounter("GameProc");
#endif 
	char*	pTemp = NULL;//soto-HK
	g_OldOrderInfoCount = g_OrderInfo.count;									
	g_OrderInfo.count = 0;											
	LightCount = 0;												
	HeroActionProcChecked = false;
	
	ViewCheckRoutine( 0 );
	
	DWORD time = ::timeGetTime();
	g_ClientTime = time + g_ServerClientTimeGap;

	CrackMgr.AutoCheckAccel();
	CheckingAccelator_Sub1();

	if( ProtocolProc( &connections, false ) < 0 )	{return FALSE;}			// 010612 YGI

	ViewCheckRoutine( 10 );
													
	if( ChangeMapFlag )	if( RecvChangeMap( &ChangeMapPacket ) == FALSE ){return FALSE;}
	if( CheckSumError )	
	{
		SendHexaEditing( CheckSumError, Hero->id); 
		PostMessage( g_hwndMain, WM_CLOSE, 0, 0 );
	}
	
	ViewCheckRoutine( 20 );
														
	if( g_GameInfo.displayOptionDelay > 0 ) 
	{														
		if( g_GameInfo.displayOption == DISPLAY_EARTHQUAKE)
		{											
			g_Map.oX = (rand()%10) - 5;
			g_Map.oY = (rand()%10) - 5;
		}								
		g_GameInfo.displayOptionDelay --;
		if( g_GameInfo.displayOptionDelay <= 0 ) 		g_GameInfo.displayOption = 0;
	}										
	
	///////////////// 0604 lkh 眠啊(父距 付快胶 钮俊 啊侩茄 单捞磐 蔼捞 乐绰 版快: 贸府饶 府畔) //////////////
	if(g_queue.lb && g_queue.ch!=Hero)	//哭率 滚瓢捞 喘赴 钮 单捞磐
	{
		if(g_queue.ch == g_GameInfo.lpcharacter && g_queue.ch != NULL && g_GameInfo.lpcharacter != NULL)
		{
			if( !(Hero->animationType==ACTION_ATTACKED || Hero->animationType==ACTION_DIE ||
				Hero->animationType==ACTION_NONE || Hero->animationType==ACTION_BASIC_WALK ) && !IsDead(g_queue.ch) )
			{
				int minrange, maxrange;
				minrange = AttackRangeTable[Hero->sprno][ Hero->accessory[ 2]][0];
				maxrange = AttackRangeTable[Hero->sprno][ Hero->accessory[ 2]][1];
															
				int minormax = IsAttackRange( &minrange, &maxrange, Hero, g_queue.ch->x, g_queue.ch->y );
				if( minormax == ATTACKRANGE_IN_AREA_ )
				{				
					g_mgrBattle.SendPcAttack(Hero, g_queue.ch);
					ZeroMemory( &g_queue, sizeof( t_queue ) );
					goto	JUMP_SKIP;
				}							
			}									
		}												
	}									

	ViewCheckRoutine( 30 );

⌨️ 快捷键说明

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