📄 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>
#include "mouse.H"
#ifdef _ANALYSIS_ON
extern DWORD g_dwIniGetAmount;
extern DWORD g_dwIniSearchLineAmount;
extern DWORD g_dwIniGetAmountFrame;
extern DWORD g_dwIniSearchLineAmountFrame;
#endif
//#define _NOTUSETRY
#pragma warning(disable: 4786)
extern int _SCR_WIDTH, _SCR_HEIGHT;
const DWORD _SHOWWAY_NORMAL =0;
const DWORD _SHOWWAY_ADDITIVE =1;
const DWORD _LOADWAY_NORMAL =0;
const DWORD _LOADWAY_MASK =0xff000000;
const DWORD _LOADWAY_TRANS =0xffff00ff;
enum {CRITICAL_FALSE=false, CRITICAL_TRUE=true};
//----------------------------------------------------------
int Double2Int (double dValue);
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 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);
DWORD TimeGet (void);
DWORD SysTimeGet (void);
int RandGet (int nMax, BOOL bRealRand=false);
void ErrorMsg (const char* fmt, ...);
void ErrorOut (const char* fmt, ...);
void LogMsg (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 RepairString (char* pszString);
void ReplaceString (char* pszString, char cFind, char cReplace);
DWORD GetDate ();
BOOL IsDBCSLeadByte (const char* pszString, int idx);
//----------------------------------------------------------
typedef DWORD OBJID;
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;
//----------------------------------------------------------
const int _MAX_STRING =256;
const int _MAX_NAMESIZE =16;
const int _MAX_NAMESIZE_CLI =32;
const int _MAX_TITLESIZE =128;
const OBJID ID_NONE =0;
//----------------------------------------------------------
#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 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));
}
//---------------------------------------------------------------------
// version define
const int _VERSION =108;
// 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;
//---------------------------------------------------------------------
// 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_WALKL =110;
const int _ACTION_WALKR =111;
const int _ACTION_WALKL_I =115;
const int _ACTION_WALKR_I =116;
const int _ACTION_RUNL =120;
const int _ACTION_RUNR =121;
const int _ACTION_TRANSFORM =122;
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 =140;
const int _ACTION_GUFFAW =151;
const int _ACTION_FURY =160;
const int _ACTION_SAD =150;
const int _ACTION_EXCITEMENT =180;
const int _ACTION_SAYHELLO =190;
const int _ACTION_SALUTE =160;
const int _ACTION_GENUFLECT =170;
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_SITDOWN_STATIC=251;
const int _ACTION_ZAZEN =260;
const int _ACTION_ZAZENCOOL =261;
const int _ACTION_FAINT =190;
const int _ACTION_LIE =200;
const int _ACTION_PICKUP =262;
const int _ACTION_MINE =360;
const int _ACTION_ALERT =340;
const int _ACTION_ALERT_I =305;
const int _ACTION_DODGE0 =311;
const int _ACTION_BRUISE0 =321;
const int _ACTION_BRUISE1 =321;
const int _ACTION_DIE0 =330;
const int _ACTION_BODY0 =331;
const int _ACTION_DIE1 =332;
const int _ACTION_BODY1 =333;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -