MirGame.h
资源名称:盛大传奇外挂原代码.rar [点击查看]
上传用户:marco7834
上传日期:2010-02-24
资源大小:82k
文件大小:6k
源码类别:
游戏引擎
开发平台:
Visual C++
- // MirGame.h: interface for the CMirGame class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_MIRGAME_H__C95390B9_4D2A_4493_917D_9AE1FF626D68__INCLUDED_)
- #define AFX_MIRGAME_H__C95390B9_4D2A_4493_917D_9AE1FF626D68__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "mirmsg.h"
- #include "mirsocket.h"
- #include "mirminimap.h"
- #include "mirgamemap.h"
- typedef struct
- {
- char Name[64];
- int prof;
- int sex;
- int level;
- int hair;
- }CHARBASEINFO;
- typedef struct
- {
- CHARBASEINFO Chars[2];
- int CharCount;
- int ActiveChar;
- }SELCHARINFO;
- typedef struct
- {
- int min;
- int max;
- }MAXMININFO;
- typedef struct
- {
- int low;
- int hi;
- }LOWHIINFO;
- typedef struct
- {
- DWORD dwServerId;
- char Name[64];
- int prof;
- int sex;
- int level;
- int hair;
- int pos_x;
- int pos_y;
- LOWHIINFO AC;
- LOWHIINFO MAC;
- LOWHIINFO DC;
- LOWHIINFO MC;
- LOWHIINFO SC;
- MAXMININFO HandWeight;
- MAXMININFO BodyWeight;
- MAXMININFO BagWeight;
- MAXMININFO Hp;
- MAXMININFO Mp;
- MAXMININFO Exp;
- int Zhunque;
- int Minjie;
- int MagicAgainst;
- int PoisonAgainst;
- int PoisonRecover;
- int HpRecover;
- int MpRecover;
- }CHARACTERINFO;
- enum __SEX
- {
- MAN = 0,
- WOMAN = 1,
- };
- enum __PROF
- {
- FIGHTER = 0,
- MAGICMAN = 1,
- TAOSHI = 2,
- };
- enum __GAMESTATE
- {
- MGS_NOCONNECTION,
- MGS_GATECONNECTED,
- MGS_WAITINGCHECKINFO,
- MGS_MAKECLIENTINFO,
- MGS_WAITINGCHECKPASS,
- MGS_CLIENTCHECKPASSED,
- MGS_MODIFYPASSWORDWAIT,
- MGS_REGNEWACCOUNTWAIT,
- MGS_LOGINWAITING,
- MGS_SELECTSERVER,
- MGS_WAITFORSELCHARADDRESS,
- MGS_GOTSELCHARADDRESS,
- MGS_SELCHARCONNECTED,
- MGS_WAITFORSELCHARVERIFY,
- MGS_WAITFORSELCHAR,
- MGS_WAITFORGAMESERVERADDRESS,
- MGS_GAMESERVERCONNECTED,
- MGS_WAITFORGAMESERVERVERIFY,
- MGS_WAITFORENTERGAME,
- MGS_ENTEREDGAME,
- };
- enum __MSGCMD
- {
- };
- enum __ERRINFO
- {
- ERR_LOGIN_OK,
- ERR_LOGIN_WRONGPASSWORD,
- ERR_LOGIN_NOTREGISTERED,
- ERR_LOGIN_WRONGPASSWORDTHREETIMES,
- ERR_MODIFYPASS_OK,
- ERR_MODIFYPASS_WRONGPASSWORD,
- ERR_REGNEWACCOUNT_OK,
- ERR_REGNEWACCOUNT_NAMEUSED,
- ERR_REGNEWACCOUNT_WRONGCHAR,
- };
- enum __ATTACKMODE
- {
- ATM_ALL, // 全体攻击模式
- ATM_PIECE, // 和平
- ATM_GROUP, // 编组
- ATM_GUILD, // 行会
- ATM_ENEMY, // 敌我
- };
- enum __CHARSTATE
- {
- CST_NORMAL, // 正常状态
- CST_GREENPOISON = 1, // 绿毒
- CST_REDPOISON = 2, // 红毒
- CST_PAUSED = 4, // 麻痹
- CST_ACTING = 8, // 动作中(等待#+GOOD或者#+FAIL)
- };
- enum __ACTION
- {
- ACT_STAND, // 站立,无动作
- ACT_WALK, // 走路
- ACT_RUN, // 跑步
- ACT_ATTACK, // 攻击
- ACT_SKILL, // 魔法技能攻击
- };
- enum __DIRECTION
- {
- DIR_UP = 0,
- DIR_UR = 1,
- DIR_RT = 2,
- DIR_DR = 3,
- DIR_DN = 4,
- DIR_DL = 5,
- DIR_LT = 6,
- DIR_UL = 7,
- };
- #define MSGQUEUELEN 1024
- typedef char TMSGLINE[MSGLENGTH];
- class CMsgQueue2
- {
- public:
- CMsgQueue2()
- {
- m_iGet = 0;
- m_iPut = 0;
- Clear();
- };
- virtual ~CMsgQueue2()
- {
- Clear();
- };
- int NextPos( int now )
- {
- now++;
- if( now >= MSGQUEUELEN )
- now = 0;
- return now;
- }
- int PutMsg( char * pMsg )
- {
- int iNext = NextPos( m_iPut );
- if( pMsg == NULL )
- return 0;
- if( iNext == m_iGet )
- {
- return 0;
- }
- strcpy( m_Msgs[m_iPut], pMsg );
- m_iPut = iNext;
- return 1;
- };
- int GetMsg( char * pMsg )
- {
- if( m_iGet == m_iPut )
- return 0;
- strcpy( pMsg, m_Msgs[m_iGet] );
- // printf( "m_iPut = %d, m_iGet = %dn", m_iPut, m_iGet );
- m_iGet = NextPos( m_iGet );
- return 1;
- };
- int Clear()
- {
- memset( (void*)m_Msgs, 0, sizeof( TMSGLINE ) * MSGQUEUELEN );
- return 1;
- };
- private:
- TMSGLINE m_Msgs[MSGQUEUELEN];
- int m_iGet;
- int m_iPut;
- };
- typedef char TSTRING[256];
- enum _action
- {
- ACTION_STAND,
- ACTION_WALK,
- ACTION_ATTACK,
- ACTION_RUN,
- ACTION_TRUN,
- ACTION_RUNTHROUGH,
- };
- typedef struct
- {
- int x;
- int y;
- int dir;
- int action;
- }ACTION_LAST;
- DWORD MessageProc( PVOID * p );
- class CMirGame
- {
- public:
- friend DWORD MessageProc( PVOID * p );
- void Walk( int dir );
- BOOL SelectChar( char * charname );
- BOOL GetSelCharInfo( SELCHARINFO * pInfo );
- BOOL EnterServer( char * ServerName );
- BOOL Login( char * username, char * password );
- BOOL OpenGateServer( char * ip );
- int GetString( char * string );
- public:
- void LogToList( HWND hList, char * line );
- void LogChat( char * line,... );
- void LogSystem( char * line,... );
- public:
- BOOL EnterGame( int CharIndex );
- BOOL CloseAll();
- BOOL EnterSelCharServer();
- BOOL CloseGateServer();
- BOOL InitLogSystem( HWND hSysLog, HWND hChatLog, int MaxLine);
- BOOL GetMsgInfo( SOCKET s );
- BOOL GetMsg( MMSG * pMsg );
- public:
- BOOL RunThrough( int dir );
- CMirMiniMap * GetMiniMap();
- CMirGameMap * GetGameMap();
- void SetCharacterPos( int x, int y );
- void Turn( int dir );
- void Run(int dir );
- void HandleCommand( char * command );
- BOOL CloseSelCharServer();
- BOOL Logout();
- BOOL Say( char * word, ...);
- BOOL StartGame();
- CMirGame();
- virtual ~CMirGame();
- private:
- CMsgQueue2 m_MsgQueue;
- DWORD m_dwGameState;
- SOCKET m_sGate;
- SOCKET m_sSelChar;
- SOCKET m_sGame;
- SELCHARINFO m_SelCharInfo;
- BOOL m_bInGame;
- char m_Account[32];
- char m_SelCharIp[20];
- char m_GameServerIp[20];
- int m_SelCharPort;
- int m_GameServerPort;
- char m_SID[32];
- private:
- void ActionFail();
- void ActionOk();
- BOOL CanDoAction();
- private:
- int m_LeftHours;
- HWND m_hSysLog;
- HWND m_hChatLog;
- TSTRING m_StringList[20];
- int m_MaxLogLine;
- char * m_tmpBuffer;
- char * m_tmpBuffer2;
- char * m_MsgLeftBuf;
- ACTION_LAST m_LastAction;
- CHARACTERINFO m_CharSelf;
- CMirMsg m_MirMsg;
- CMirSocket m_MirSocket;
- CMirMiniMap m_MiniMap;
- CMirGameMap m_GameMap;
- };
- #endif // !defined(AFX_MIRGAME_H__C95390B9_4D2A_4493_917D_9AE1FF626D68__INCLUDED_)