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

📄 stdafx.h

📁 韩国英雄王座倒闭后流出来部分源代码
💻 H
字号:
////////////////////////////////////////////////////////////////////////////////////////
//	stdafx.h : include file for standard system include files,
//      or project specific include files that are used frequently,
//      but are changed infrequently
//
////////////////////////////////////////////////////////////////////////////////////////
#if !defined( _STDAFX_H_ )
#define _STDAFX_H_

#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#define _ATL_APARTMENT_THREADED

#pragma warning(disable: 4244)
#pragma warning(disable: 4018)

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <winsock2.h>
#include <winbase.h>

#include <afxdb.h>			// MFC ODBC database classes
#include <atlbase.h>
#include <assert.h>
#include <math.h>

#include "command.h"
#include "MapChart.h"

#pragma comment(lib, "RegCrypt.lib")

#ifdef CHINESE_VERSION
	#include "ServerChinessMsgList.h"
#else
	#include "ServerMsgList.h"
#endif

//	STL	Include Header 
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <ctime>
#include <string>
#include <map>	
#include <Mmsystem.h>

#include "Strtok.h"
#include "Resource.h"


#ifdef DEF_AZIT				//	AZIT
	class AzitManager;
#endif

#ifdef DEF_UNIQUEITEM	
	class UniqueManager;	//	Unique Item
#endif




using namespace std;

#ifndef FD_SETSIZE
	#define  FD_SETSIZE 10000
#endif 




////////////////////////////////////////////////////////////////////////////////////////
//	Server Stting 
////////////////////////////////////////////////////////////////////////////////////////


#ifdef DEF_INTERNALMEM			 // 叼滚彪 滚傈 趣篮 郴何 辑滚狼 皋葛府 荤侩樊 
	#define MAX_SOCKET_CONTEXT	5000					// MAX User Number
#else
	#define MAX_SOCKET_CONTEXT	5000					// MAX User Number
#endif

#define MAX_USER_LIMIT			MAX_SOCKET_CONTEXT * 2

#ifdef DEF_INTERNALMEM			 // 叼滚彪 滚傈 趣篮 郴何 辑滚狼 皋葛府 荤侩樊 

		#define MAX_SIOCOUNT		1000				// MAX Send IO Number甫 力茄
		#define MAX_RIOCOUNT		5000				// MAX Recv IO Number
#else

		#define MAX_SIOCOUNT		2000				// MAX Send IO Number甫 力茄
		#define MAX_RIOCOUNT		1000				// MAX Recv IO Number
#endif

#define MAX_IO_CONTEXT		MAX_RIOCOUNT + MAX_SIOCOUNT	// 力茄等 Send IO 肮荐狼 滴硅..

////////////////////////////////////////////////////////////////////////////////////////
//	Server Max Values
////////////////////////////////////////////////////////////////////////////////////////
#define MAX_WORKER_THREAD	16
#define	MAX_MAPTILE_SIZE	512							//	MAP Tile Size

#ifdef DEF_PACKETSIZEDOWN_BADAJOA20041011
	#define	MAX_BIGAOITILE_SIZE	30							//	BIG AOI Tile Size // 按眉 积己 棺 家戈篮 承篮 瘤开俊 焊辰促. 唱吝俊 CELL 窜困肺 荐沥
	#define	MAX_AOITILE_SIZE	20							//	AOI Tile Size
#else
	#define	MAX_AOITILE_SIZE	30							//	AOI Tile Size
#endif

#define	MAX_AOICHAT_SIZE	15							//	AOI Chat Size

#define	MAX_ITEM_ALIVETIME	35							//	Item Alive Time
#define MAX_LEVEL			299							//	霸烙狼 弥绊 饭骇

//
//	Duke Kim	2004.12.24	
//
//	20 -> 25肺 Size函版
//
#define	MAX_MAPLAYER		300

#define MAX_NPCTURN_NUM		4							//	NPC悼累 畔 2檬俊 5锅 畔捞 倒酒柯促.
#define	COUNTATTACK_TURN	1							//	馆拜畔 菊第肺 茄畔捞搁 馆拜茄促. 


#define MAX_MONSTERPOOL_NUM	100


const int MAX_FIGHTZONE		= 50 ;
const int MAX_MATCH			= 10 ;
const int PLAYERID_LEN		= 20 ;						//	DB 包访 惑荐 


////////////////////////////////////////////////////////////////////////////////////////
//	Message Functions
////////////////////////////////////////////////////////////////////////////////////////
void	ErrorMsg(const char *pszParam, ...);
void	MessagePrint(const char *pszParam, ...);
void	MessageCount( CString pMessage );
void	MapLog(const char *pszParam, ...);

////////////////////////////////////////////////////////////////////////////////////////
//	Item Loots Functions
////////////////////////////////////////////////////////////////////////////////////////
int		iHeavyWeightSegementRandom(int iSpan);
int		iWeightSegementRandom(int iSpan,int iSegWeight = 15 );



////////////////////////////////////////////////////////////////////////////////////////
//	辑滚狼 惑怕 沥狼
////////////////////////////////////////////////////////////////////////////////////////
enum	SERVER_STATUS
{
	SERVER_READY			,	
	SERVER_START			,
	SERVER_DISCONNECTWORLD	,
	SERVER_RECOVERYWORLD	,
	SERVER_STOP
};


/*
 *	Speed Hack Checking
 */
#if defined(DEF_SPEEDHACK) || defined(DEF_KORSPEEDHACK)

enum 
{
	PACKETTYPE_MOVE,				// Move (ZP_MOVEPOINT_ASK)
	PACKETTYPE_MOVEWARP,			// Warp (ZP_MOVEWARP_ASK)
	PACKETTYPE_NORMALATTACK,		// normal Attack (ZP_NORMALATTACK_ASK,)
	PACKETTYPE_ARCHERNORMALATTACK,	// normal Attack (ZP_ARCHERATTACK_ASK)
	PACKETTYPE_SKILLATTACK,			// Skill  Attack (ZP_SKILLATTACK_ASK,ZP_SKILLINSTANTATTACK_ASK)
	PACKETTYPE_MAGICSKILLATTACK,	// Skill  Attack (ZP_SKILLATTACK_ASK,ZP_SKILLCHAINLIGHTING_ASK)
	PACKETTYPE_ARCHERSKILLATTACK,	// Skill  Attack (ZP_SKILLATTACK_ASK)
	PACKETTYPE_PCMOVE,				// Move (ZP_PCMOVE_ASK)
	PACKETTYPE_CHAINLIGHTNING,		// Chain Lightning(ZP_SKILLCHAINLIGHTING_ASK)

	MAX_PACKETTYPE
}  ; 

#endif

////////////////////////////////////////////////////////////////////////////////////////
//	You may derive a class from CComModule and use it if you want to override
//	something, but do not change the name of _Module
////////////////////////////////////////////////////////////////////////////////////////
class CServiceModule : public CComModule
{
public:
	CServiceModule();
	~CServiceModule();

public:
	
	HRESULT RegisterServer(BOOL bRegTypeLib, BOOL bService);
	HRESULT UnregisterServer()
	{
		HRESULT hr = CoInitialize(NULL);
		if (FAILED(hr))
			return hr;

		// Remove service entries
		UpdateRegistryFromResource(IDR_MapServer, FALSE);
		// Remove service
		Uninstall();
		// Remove object entries
		CComModule::UnregisterServer(TRUE);
		CoUninitialize();
		return S_OK;
	}

	void Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, UINT nServiceNameID, const GUID* plibid = NULL);
    void Start();
	void ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
    void Handler(DWORD dwOpcode)
	{
		switch (dwOpcode)
		{
		case SERVICE_CONTROL_STOP:
			SetServiceStatus(SERVICE_STOP_PENDING);
			PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
			break;

		case SERVICE_CONTROL_PAUSE:
			break;

		case SERVICE_CONTROL_CONTINUE:
			break;

		case SERVICE_CONTROL_INTERROGATE:
			break;

		case SERVICE_CONTROL_SHUTDOWN:
			break;

		default:
			LogEvent(_T("Bad service request"));
		}
	}

    void Run();
    BOOL IsInstalled();
    BOOL Install();
    BOOL Uninstall();
	LONG Unlock();
	void LogEvent(LPCTSTR pszFormat, ...);
    void SetServiceStatus(DWORD dwState);
    void SetupAsLocalServer();

//Implementation
private:
	static void WINAPI _ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
    static void WINAPI _Handler(DWORD dwOpcode);

// data members
public:
	
    TCHAR m_szServiceName[256];
    
	SERVICE_STATUS_HANDLE m_hServiceStatus;
    SERVICE_STATUS m_status;
	DWORD dwThreadID;

	BOOL m_bService;

	//	--------------------------------------------------------------------------------
	//	角青 颇老 疙阑 掘澜
	//	--------------------------------------------------------------------------------
	TCHAR m_szFilename[MAX_PATH];
	TCHAR m_szDrv[MAX_PATH];
	TCHAR m_szPath[MAX_PATH];
	TCHAR m_szFname[MAX_PATH];
	TCHAR m_szExt[MAX_PATH];

	SERVER_STATUS	m_ServerStatus;						//	Server Mode函荐 眠啊 
	
	//	--------------------------------------------------------------------------------
	//	Map Server 券版 函荐 甸 
	//	--------------------------------------------------------------------------------
	char			m_szMapIP[50];						//	Map Server IP Address
	char			m_szUdpIP[20];						//	Map Server UDP IP Address
	unsigned long	m_nMapPORT;							//	Map Server Port

	unsigned long	m_nPKMode;							//	PK	Mode

	char			m_szWorldIP[50];					//	World Server IP Address
	char			m_szDBIP[50];						//	db Server IP Address
	unsigned long	m_nWorldPORT;						//	World Server Port
	

	char			m_szLogIP[50];						//	Log Server IP Address
	unsigned long	m_nLogPORT;							//	World Server Port

	unsigned long	m_nMapSeq;							//	Map Seq	
	unsigned long	m_nServerUniqNum;					//	Map Server Unique Number
	int				m_nWorldID;							//	World 锅龋
	int				m_nServerID;						//	Map   锅龋

	char			m_strMapFile[MAX_MAPLAYER][256];

#ifdef CHINESE_VERSION
	char			m_strMapName[MAX_MAPLAYER][100];
#endif

	char			m_szDBID[64];	
	char			m_szDBPWD[128];
	DWORD			m_dwMaxUser;

	DWORD			m_dwSaveAccountDB;					//DEF_MAPINOUT_REGISTRY

	int				m_iMaxMapLayer;


#if defined(DEF_SPEEDHACK) || defined(DEF_KORSPEEDHACK)
	//Jason 2004-08-16-china
	//	Speed Hack 阑 check 窍扁 困秦辑 荤侩登绰 函荐
	DWORD			m_dwIntervalTick[MAX_PACKETTYPE];
	DWORD			m_dwInitIntervalTick[MAX_PACKETTYPE];
	FLOAT			m_wPacketCount[MAX_PACKETTYPE];
	WORD			m_wAllowedHackCount[MAX_PACKETTYPE];	
#endif

	//	--------------------------------------------------------------------------------
	//	Event包访 Values
	//
	//	-	阿辆 Event Contorl Values甫 历厘矫糯
	//	--------------------------------------------------------------------------------
private:
	BYTE			m_nEventFlag ;

	//
	//	郴何 Global Values
	//
public:

	#ifdef DEF_AZIT
		AzitManager		*m_pAzitManager;
	#endif

	#ifdef DEF_UNIQUEITEM
		UniqueManager	*m_pUniqueManager;
	#endif

public:

	BOOL ReadRegisteryValue();
	BOOL Run_MapServer();
	void Clean_MapServer();
	
	bool IsEvent(BYTE nEVENT)	{	return(nEVENT == m_nEventFlag) ;
	}

	void SetGMEvent(BYTE nEVENT , bool bValue = true)
	{
		if(bValue )
			m_nEventFlag = nEVENT ;
		else
			m_nEventFlag = 0 ;
	}

	void GMEventClear()		{	m_nEventFlag = 0 ;		}
	BYTE GetGMEvent()		{	return m_nEventFlag ;	}
};


extern CServiceModule _Module;
#include <atlcom.h>


template < class _DataType >
BOOL SAFE_DELETE(_DataType **pDT)
{
    if (*pDT == NULL)
        return FALSE;
	
    __try
    {
        delete *pDT;
    }
    __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
    {
        *pDT = NULL;
        return FALSE;
    }
	
    *pDT = NULL;
	
    return TRUE;
}


#define STR(id)				#id
#define PACKETTRACE(id )	case id:  TRACE("[%s]\n",STR(id));  break;
#define USERTRACE(p, id, msg)	case id:  UserLog(p, "%s", msg);  break;

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif

⌨️ 快捷键说明

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