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

📄 basefunc.h

📁 SQLBig5BugTool 宽字符操作问题
💻 H
📖 第 1 页 / 共 2 页
字号:
//BASEFUNC.H
#ifndef _BASEFUNC_H
#define _BASEFUNC_H

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <time.h>

#include <windows.h>

#pragma warning(disable: 4786)

#include <map>
#include <list>
#include <deque>
#include <string>
#include <map>
#include <vector>
using namespace std;

#define IN
#define OUT

const DWORD _SHOWWAY_NORMAL	  = 0;
const DWORD _SHOWWAY_ADDITIVE = 1;

const int _MAX_STRING	 = 256;
const int _MAX_NAMESIZE	 = 16;
const int _MAX_TITLESIZE = 128;
const int _MAX_NAME	     = 32;
const int _MAX_NAMESIZE_CLI	=32;

typedef	unsigned long	OBJID;
//typedef ULONG OBJID;

const OBJID	ID_NONE		= 0;
const OBJID	ID_INVALID	= -1;

struct CMouseInfo{
	int iPosX, iPosY;
	int iEvent;
	DWORD dwDownTime;
};

// mouse event define
enum {
	_MOUSE_NONE			= 0,
	_MOUSE_CLICK		= 10,
	_MOUSE_DOWN			= 01,
	_MOUSE_HOLD			= 11,
	_MOUSE_RIGHTCLICK	= -10,
	_MOUSE_RIGHTDOWN	= -01,
	_MOUSE_RIGHTHOLD	= -11,
	_MOUSE_ON			= 20,
};

enum { CRITICAL_FALSE = false, CRITICAL_TRUE = true };

//----------------------------------------------------------
int		Double2Int	(double dValue);
DWORD	Str2ID		(const char* pszString);
__int64	DataReplace	(__int64 iData, UINT uLowDigit, UINT uHighDigit, DWORD dwReplaceNum);
__int64	DataTake 	(__int64 iData, UINT uLowDigit, UINT uHighDigit);

BOOL	IniStrGet	(const char *pszFileName, const char *pszTitle, const char *pszSubTitle, char *pszStr, BOOL bCritical=false);
BOOL	IniDataGet	(const char *pszFileName, const char *pszTitle, const char *pszSubTitle, int &iData, BOOL bCritical=false);

BOOL	MemTxtLineGet	(const char* pBuf, DWORD dwBufSize, DWORD& dwOffset, char* szLine, DWORD dwLineSize);

BOOL	MemIniStrGet	(const char *pBuf, DWORD dwSize, const char *pszTitle, const char *pszSubTitle, char *pszStr, BOOL bCritical=false);
BOOL	MemIniDataGet	(const char *pBuf, DWORD dwSize, const char *pszTitle, const char *pszSubTitle, int &iData, BOOL bCritical=false);

BOOL	TxtStrGet	(const char *pszFileName, const char *pszTitle, char *pszStr, BOOL bCritical=false);
BOOL	TxtDataGet	(const char *pszFileName, const char *pszTitle, int &iData, BOOL bCritical=false);

enum TIME_TYPE{ TIME_MILLISECOND=0, TIME_SECOND, TIME_MINUTE, TIME_DAY, TIME_DAYTIME, TIME_STAMP };

DWORD TimeGet(TIME_TYPE type=TIME_MILLISECOND);

DWORD AddHour(DWORD dwYYMMDDHH, int nAddHour);

DWORD	SysTimeGet  (void);
DWORD	SysTimeGetEx  (void);
DWORD	GetDate		(void);

int		RandGet		(int nMax, BOOL bRealRand=false);

void	ErrorMsg	(const char* fmt, ...);
void	ErrorOut	(const char* fmt, ...);
void	LogMsg		(const char* fmt, ...);
void	Log			(const char* szFile, const char* fmt, ...);
void	DebugMsg	(const char* fmt, ...);
BOOL	StringCheck	(char* pszString);

void	MouseInit		(void);
void	MouseSet		(int x, int y, int event);
void	MouseProcess	(void);
int		MouseCheck		(int& iMouseX, int& iMouseY);

void	KeyClearBuffer	(void);
int		KeyAppend		(void);
int		KeyGet			(void);
bool	KeyUnGet		(void);

void	SafeStrcpy		(char* pszTarget, const char* pszSource, int nBufSize);
void	RepairString	(unsigned char* pszString);
void	ReplaceString	(char* pszString, char cFind, char cReplace);
BOOL	IsDBCSLeadByte	(const char* pszString, int idx);


//----------------------------------------------------------
typedef struct 
{
	int	x, y;
}CMyPos;

typedef struct
{
	int t, l, r, b;
}CMyRect;

typedef struct 
{
	float fHorizontal;
	float fVertical;
}CMy3DDir;

typedef struct 
{
	int	x, y, z;
}CMy3DPos;

typedef struct {
	float		fRadianX;			// 右方向轴,顺时针
	float		fRadianY;			// 上方向轴,顺时针
	float		fRadianZ;			// 内方向轴,顺时针
}CMy3DPose;



typedef struct {
	int	iWidth, iHeight;
}CMySize;

//----------------------------------------------------------
#ifndef SAFE_DELETE
	#ifdef _DEBUG
		#define SAFE_DELETE(p) { if(p) delete p; p=NULL; }
	#else
		#define SAFE_DELETE(p) { if(p){ try{ delete p; } catch(...){} p=NULL; }}
	#endif
#endif

#ifndef SAFE_DELETE_EX
	#ifdef _DEBUG
		#define SAFE_DELETE_EX(p) { if(p) delete[] p; p=NULL; }
	#else
		#define SAFE_DELETE_EX(p) { if(p){ try{ delete[] p; } catch(...){} p=NULL; }}
	#endif
#endif

#undef	SAFE_RELEASE
#define SAFE_RELEASE(ptr)	{ if(ptr){ try{ ptr->Release(); }catch(...){ } ptr = 0; } }

//----------------------------------------------------------
#ifndef MYASSERT
	#ifdef _DEBUG
		#define	MYASSERT(x) assert(x)
	#else
		#define	MYASSERT(x)	{if(!(x)) LogMsg("★ASSERT(" #x ") in %d line of %s★", __LINE__, __FILE__); }
	#endif
#endif

//----------------------------------------------------------
#ifndef IF_SUC
	#ifdef _DEBUG
		#define	IF_SUC(x)  if( ((x)) ? true : ( assert(!("IF_SUC: " #x)), false ) )
	#else
		#define	IF_SUC(x)  if( ((x)) ? true : ( LogMsg("★IF_SUC(%s)★ failed in %s, %d", #x, __FILE__, __LINE__), false ) )
	#endif
#endif

#define IF_TRUE	IF_SUC
#define IF_YES	IF_SUC
#define IF_OK	IF_SUC

//----------------------------------------------------------
#ifndef IF_NOT
	#ifdef _DEBUG
		#define	IF_NOT(x)  if( (!(x)) ? ( assert(!("IF_NOT: " #x)),1 ) : 0 )
	#else
		#define	IF_NOT(x)  if( (!(x)) ? ( LogMsg("★IF_NOT(%s)★ in %s, %d", #x, __FILE__, __LINE__),1 ) : 0 )
	#endif
#endif

//---------------------------------------------------------------------
inline unsigned int	ExchangeShortBits(unsigned long nData, int nBits)
{
	MYASSERT(nBits >= 0 && nBits < 16);
	nData	&= 0xFFFF;
	return ((nData>>nBits) | (nData<<(16-nBits))) & 0xFFFF;
}
inline unsigned int	ExchangeLongBits(unsigned long nData, int nBits)
{
	MYASSERT(nBits >= 0 && nBits < 32);
	return (nData>>nBits) | (nData<<(32-nBits));
}

void SimpleEncrypt(void* pBuf, ULONG ulSize);


//---------------------------------------------------------------------
// version define


// game status define
const unsigned int	_STATUS_NONE		=1000;
const unsigned int	_STATUS_ACCOUNT		=_STATUS_NONE+1;
const unsigned int	_STATUS_CONNECT		=_STATUS_NONE+2;
const unsigned int	_STATUS_LOGIN		=_STATUS_NONE+3;
const unsigned int	_STATUS_REGISTER	=_STATUS_NONE+4;
const unsigned int	_STATUS_MAINTAINROLE=_STATUS_NONE+5;

const unsigned int	_STATUS_WAITING		=_STATUS_NONE+8;
const unsigned int	_STATUS_FIGHTING	=_STATUS_NONE+9;
const unsigned int	_STATUS_NORMAL		=_STATUS_NONE+10;
const unsigned int	_STATUS_TASK		=_STATUS_NONE+11;
const unsigned int	_STATUS_GAMBLE		=_STATUS_NONE+12;

const unsigned int	_STATUS_EXIT		=_STATUS_NONE+100;
const unsigned int	_STATUS_DESTROY		=_STATUS_NONE+101;

// 处于战略层地图
const unsigned int _STATUS_STRATEGY		= _STATUS_NONE+102;

//---------------------------------------------------------------------
// action define

const int _ACTION_DANCE1		=001;
const int _ACTION_DANCE2		=002;
const int _ACTION_DANCE3		=003;
const int _ACTION_DANCE4		=004;
const int _ACTION_DANCE5		=005;
const int _ACTION_DANCE6		=006;
const int _ACTION_DANCE7		=007;
const int _ACTION_DANCE8		=8;	

const int _ACTION_STANDBY		=100;
const int _ACTION_REST1			=101;
const int _ACTION_REST2			=102;
const int _ACTION_REST3			=103;
const int _ACTION_STANDBY_I		=105;

const int _ACTION_WALK			=110;	
const int _ACTION_WALK_I		=115;

const int _ACTION_RUNL			=120;
const int _ACTION_RUNR			=121;

const int _ACTION_RUNL_I		=125;
const int _ACTION_RUNR_I		=126;

const int _ACTION_JUMP	        =130;
const int _ACTION_JUMP_BACK	    =131;
const int _ACTION_JUMP_RUN	    =132;

const int _ACTION_JUMP_ATK		=140;
const int _ACTION_JUMP_ATKEND	=141;

const int _ACTION_LAUGH			=150;
const int _ACTION_GUFFAW		=151;
const int _ACTION_FURY          =160;
const int _ACTION_SAD	        =170;
const int _ACTION_EXCITEMENT	=180;
const int _ACTION_SAYHELLO		=190;
const int _ACTION_SALUTE		=200;
const int _ACTION_GENUFLECT     =210;
const int _ACTION_KNEEL			=220;
const int _ACTION_COOL			=230;
const int _ACTION_COOLPOSE		=231;
const int _ACTION_SWIM			=240;
const int _ACTION_SITDOWN       =250;
const int _ACTION_ZAZEN			=260;
const int _ACTION_ZAZENCOOL		=261;
const int _ACTION_FAINT	        =270;
const int _ACTION_LIE	        =271;
const int _ACTION_ASSAULT       =272;
const int _ACTION_HANDCLAP       =273;
const int _ACTION_ATTENTION       =274;
const int _ACTION_STDATATTN       =275;
const int _ACTION_SITED       =276;


const int _ACTION_PICKUP		=280;
const int _ACTION_MINE			=290;

⌨️ 快捷键说明

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