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

📄 protocol.h

📁 是一个基于热血战国协议的网络游戏。现在脱机客户端先放出来给大家研究
💻 H
字号:


/* 
**  梁健雄:[所有代码都是我理解后,注释的,原来全是韩国的文字注释]
**  2005/08/12
**  网络传送协议定义
**
*/

#pragma once
#include "StdAfx.h"

#define	DWORD_PTR			DWORD



/*
================
sLogItem 时间+文字+字体 日志的格式
================
*/
typedef struct tag_TLOGITEM
{
	CTime time;
	std::string text;
	COLORREF crFont;
}_TLOGITEM,*_LPTLOGITEM;

/*
================
sLogDebug 调试信息
================
*/
#ifndef PUBLIC_EDTION
typedef struct tag_TLOGDEBUG
{
	CTime time;
	std::string text;
}_TLOGDEBUG,*_LPTLOGDEBUG;
#endif

/*
================
sChatItem 聊天信息
================
*/
//struct sChatItem
typedef struct tag_TCHARITEM
{
	CTime time;
	std::string text;
	COLORREF crFont,crBack;
}_TCHARITEM,*_LPTCHARITEM;

/*
================
  游戏阶段
================
*/
enum eGameStage 
{
	GS_LOGIN, //登陆
	GS_SEL,   //设置
	GS_GAME,  //游戏
};
/*
================
  角色类型
================
*/
enum eActorType
{
	AT_Unknow,  //未知
	AT_Human,   //人类
	AT_Monst,   //怪物
	AT_Merchant,//商人 
	AT_Guard,   //哨兵
	AT_Baby,    //宠物
};
/*
================
  角色信息
================
*/
typedef struct tag_TACTOR
{
	DWORD ServerId;
	int xx;
	int yy;
	int dir;
	eActorType Type;
	std::string Name;
	//COLORREF NameColor;
	DWORD Feature;
	DWORD Status;
	long ChrLight;

	WORD Hp;
	WORD MaxHp;

	//bool Death;
}_TACTOR,*_LPTACTOR;
typedef std::list<_TACTOR> sActorList;          //角色信息
typedef sActorList::iterator itActor;
/*
================
  地面道具
================
*/
typedef struct tag_TDROPEDITEM
{
	DWORD ServerId;
	DWORD LastPick;
	int x,y,RetryCount;
	std::string Name;
}_TDROPEDITEM,*_LPTDROPEDITEM;
typedef std::list<_TDROPEDITEM> sDropedItemList;//地面道具
typedef sDropedItemList::iterator itDropedItem;
/*
================
  门口
================
*/
typedef struct tag_TDOORDIST
{
	std::string mapname;
	POINT pos1;
	POINT pos2;
	int dist;
}_TDOORDIST,*_LPTDOORDIST;
/*
================
  门口
================
*/
typedef struct tag_TDOORLINK
{
	struct
	{
		std::string mapname;
		POINT pos;
	} source,dest;
	std::string dlg_name;
}_TDOORLINK,*_LPTDOORLINK; 
typedef std::vector<_TDOORDIST> tDoorDistList;  //门口
typedef std::vector<_TDOORLINK> tDoorLinkList;  //门口
/*
================
  地图		
================
*/
typedef struct tag_TMAP
{
	std::string mapname;
	std::string maptitle;
	tDoorLinkList DoorLinks;
	tDoorDistList DoorDists;
}_TMAP,*_LPTMAP;
typedef std::vector<_TMAP> tMapList;            //地图 

const int MAX_BAG_ITEMS = 99 ; //最大物品书
const int MAX_USE_ITEMS = 13 ; //最大装备数

/*
================
  传奇消息
================
*/
typedef struct tag_TMIRMESSAGE
{
	union
	{
		DWORD	dwFlag;
		struct
		{
			WORD	wa;
			WORD	wb;
		};
	};
	WORD	wCmd;
	WORD	w1;
	WORD	w2;
	WORD	w3;
}_TMIRMESSAGE,*_LPTMIRMESSAGE,MMSG;
//typedef sMirMessage MMSG;

/*
================
  角色信息
================
*/
typedef struct tag_TABILITY
{
	//DWORD	dwGold;
	//WORD	wCmd;
	//BYTE	bProf;
	//BYTE	bHair;
	//BYTE	bSex;
	//BYTE	bOO;
	//WORD	wUnknow;
	BYTE	bLevel;
	BYTE	bUnknow;

	BYTE	ACLow;
	BYTE	ACHi;

	BYTE	MACLow;
	BYTE	MACHi;

	BYTE	DCLow;
	BYTE	DCHi;

	BYTE	MCLow;
	BYTE	MCHi;

	BYTE	SCLow;
	BYTE	SCHi;

	WORD	Hp;
	WORD	Mp;
	WORD	MaxHp;
	WORD	MaxMp;
	DWORD	dwUnknow;
	DWORD	Exp;
	DWORD	MaxExp;
	WORD	BagWeight;
	WORD	MaxBagWeight;
	BYTE	BodyWeight;
	BYTE	MaxBodyWeight;
	BYTE	HandWeight;
	BYTE	MaxHandWeight;
}_TABILITY,*_LPTABILITY;

/*
================
  数据包
================
*/
typedef struct tag_TMESSAGEBODYWL
{
	DWORD lParam1;
	DWORD lParam2;
	DWORD lTag1;
	DWORD lTag2;
}_TMESSAGEBODYWL,*_LPTMESSAGEBODYWL;

/*
================
  玩家外貌
================
*/
typedef struct tag_TCHARDESC
{
	DWORD Feature;
	DWORD Status;
}_TCHARDESC,*_LPTCHARDESC;

/*
================
  装备信息
================
*/
typedef struct tag_TSTDITEM
{
	BYTE NameLen;
	char Name[14];
	BYTE StdMode;
	BYTE Shape;
	BYTE Weight;
	BYTE AniCount;
	BYTE SpecialPwr;
	BYTE ItemDesc;

	WORD Looks;
	WORD DuraMax ;
	BYTE AC;
	BYTE MaxAC;
	BYTE MAC;
	BYTE MaxMAC;
	BYTE DC;
	BYTE MaxDC;
	BYTE MC;
	BYTE MaxMC;
	BYTE SC;
	BYTE MaxSC;
	BYTE Need; // 0:Level, 1:DC, 2:MC, 3:SC
	BYTE NeedLevel;// 1..60 level value...
	DWORD Price;
}_TSTDITEM,*_LPTSTDITEM;
/*
================
  玩家装备信息
================
*/
typedef struct tag_TCLIENTITEM
{
	_TSTDITEM S;  //函版等 瓷仿摹绰 咯扁俊 利侩凳.
	DWORD MakeIndex;
	WORD Dura;
	WORD DuraMax;
}_TCLIENTITEM,*_LPTCLIENTITEM;
typedef std::list<_TCLIENTITEM> sClientItemList;//玩家装备信息
typedef sClientItemList::iterator itClientItem;
/*
================
fCompareMakeId
================
*/
class fCompareMakeId{
private:
	DWORD m_mid;
public:
	fCompareMakeId(DWORD id):m_mid(id){}
	bool operator()(const _TCLIENTITEM &item)const{ return (item.MakeIndex==m_mid); }
};

/*
================
  魔法信息
================
*/
typedef struct tag_TDEFMAGIC
{
	WORD MagicId;

	BYTE MagicNameLen;
	char MagicName[12];       //沫 疵副巴

	BYTE EffectType;
	BYTE Effect;
	WORD Spell;
	WORD MinPower;
	BYTE NeedLevel[4];
	long MaxTrain[4];
	BYTE MaxTrainLevel;  //荐访 饭骇
	BYTE Job;         //0: 傈荤 1:贱荤  2:档荤   99:葛滴啊瓷
	long DelayTime; //茄规 金促澜俊 促澜 付过阑 镜 荐 乐绰单 吧府绰 矫埃
	BYTE DefSpell;
	BYTE DefMinPower;
	WORD MaxPower;
	BYTE DefMaxPower;

	BYTE DescLen;
	char Desc[15];
}_TDEFMAGIC,*_LPTDEFMAGIC;

/*
================
  玩家魔法信息
================
*/
typedef struct tag_TCLIENTMAGIC
{
	char Key;
	BYTE Level;
	long CurTrain;
	_TDEFMAGIC Def;
}_TCLIENTMAGIC,*_LPTCLIENTMAGIC;
typedef std::vector<_TCLIENTMAGIC> sClientMagicList;
typedef sClientMagicList::iterator itClientMagic;

/*
================
  sMySelf 自己管理
================
*/
typedef struct tag_TMYSELF
{
	tag_TMYSELF() :Gold(0), Feature(0), State(0), Job(0), ServerId(0)
		, xx(0), yy(0), dir(0), ChrLight(0),Name(""), MapTitle("")
	{
	ZeroMemory(&Ability,sizeof(Ability));
	}
	long Gold;
	DWORD Feature;
	DWORD State;
	BYTE Job;
	_TABILITY Ability;
	int xx;
	int yy;
	int dir;
	DWORD ServerId;
	std::string Name;
	std::string MapTitle;
	long ChrLight;
}_TMYSELF, *_LPTMYSELF;

/*
================
穿着装备位置
================
*/
const int U_DRESS         = 0;
const int U_WEAPON        = 1;
const int U_RIGHTHAND     = 2;
const int U_NECKLACE      = 3;
const int U_HELMET        = 4;
const int U_ARMRINGL      = 5;
const int U_ARMRINGR      = 6;
const int U_RINGL         = 7;
const int U_RINGR         = 8;
const int U_BUJUK         = 9;
const int U_BELT          = 10;
const int U_BOOTS         = 11;
const int U_CHARM         = 12;

/*
================
For Login Process 登陆处理数据包定义
================
*/
const int CM_PROTOCOL					= 2000;
const int CM_IDPASSWORD					= 2001;
const int CM_ADDNEWUSER					= 2002;
const int CM_CHANGEPASSWORD				= 2003;
const int CM_UPDATEUSER					= 2004;

const int CM_SELECTSERVER				= 104;
const int SM_CHGPASSWD_SUCCESS			= 506;
const int SM_CHGPASSWD_FAIL				= 507;


const int SM_CERTIFICATION_FAIL			= 501;
const int SM_ID_NOTFOUND				= 502;
const int SM_PASSWD_FAIL				= 503;
const int SM_NEWID_SUCCESS				= 504;
const int SM_NEWID_FAIL					= 505;
const int SM_PASSOK_SELECTSERVER		= 529;
const int SM_SELECTSERVER_OK			= 530;
const int SM_NEEDUPDATE_ACCOUNT			= 531;
const int SM_UPDATEID_SUCCESS			= 532;
const int SM_UPDATEID_FAIL				= 533;

/*
================
For Select Character Process 角色选择处理数据包定义
================
*/
const int CM_QUERYCHR					= 100;
const int CM_NEWCHR						= 101;
const int CM_DELCHR						= 102;
const int CM_SELCHR						= 103;

const int SM_QUERYCHR					= 520;
const int SM_NEWCHR_SUCCESS				= 521;
const int SM_NEWCHR_FAIL				= 522;
const int SM_DELCHR_SUCCESS				= 523;
const int SM_DELCHR_FAIL				= 524;
const int SM_STARTPLAY					= 525;
const int SM_STARTFAIL					= 526;
const int SM_QUERYCHR_FAIL				= 527;
const int SM_SENDNOTICE					= 658;

/*
================
For game process 游戏处理数据包定义
================
*/

/*
================
Client To Server Commands 客户端发给服务器的
================
*/
const int CM_QUERYUSERNAME				= 80;
const int CM_QUERYBAGITEMS				= 81;

const int CM_DROPITEM					= 1000;
const int CM_PICKUP						= 1001;
const int CM_TAKEONITEM					= 1003;
const int CM_TAKEOFFITEM				= 1004;
const int CM_BUTCH						= 1007;
const int CM_MAGICKEYCHANGE				= 1008;
const int CM_EAT						= 1006;
const int CM_CLICKNPC					= 1010;
const int CM_MERCHANTDLGSELECT			= 1011;
const int CM_MERCHANTQUERYSELLPRICE		= 1012;
const int CM_USERSELLITEM				= 1013;  //酒捞袍 迫扁
const int CM_USERBUYITEM				= 1014;
const int CM_USERGETDETAILITEM			= 1015;
const int CM_DROPGOLD					= 1016;
const int CM_TEST						= 1017; //抛胶飘
const int CM_LOGINNOTICEOK				= 1018;
const int CM_DEALTRY					= 1025;
const int CM_WANTMINIMAP				= 1033;
const int CM_TURN						= 3010;
const int CM_WALK						= 3011;
const int CM_SITDOWN					= 3012;
const int CM_RUN						= 3013;
const int CM_HIT						= 3014;
const int CM_HEAVYHIT					= 3015;
const int CM_BIGHIT						= 3016;
const int CM_SPELL						= 3017;
const int CM_POWERHIT					= 3018;
const int CM_LONGHIT					= 3019;
const int CM_WIDEHIT					= 3024;
const int CM_FIREHIT					= 3025;
const int CM_SAY						= 3030;
const int CM_RIDE						= 3031;

/*
================
Server to Client Commands 服务器发给客户端的
================
*/
const int SM_RUSH						= 6;
const int SM_FIREHIT					= 8;
const int SM_BACKSTEP					= 9;
const int SM_TURN						= 10;
const int SM_WALK						= 11;
const int SM_SITDOWN					= 12;
const int SM_RUN						= 13;
const int SM_HIT						= 14;
const int SM_HEAVYHIT					= 15;
const int SM_BIGHIT						= 16;
const int SM_SPELL						= 17;
const int SM_POWERHIT					= 18;
const int SM_LONGHIT					= 19;
const int SM_DIGUP						= 20;
const int SM_DIGDOWN					= 21;
const int SM_FLYAXE						= 22;
const int SM_LIGHTING					= 23;
const int SM_WIDEHIT					= 24;
const int SM_ALIVE						= 27;
const int SM_DISAPPEAR					= 30;
const int SM_STRUCK						= 31;
const int SM_DEATH						= 32;
const int SM_SKELETON					= 33;
const int SM_NOWDEATH					= 34;

const int SM_HEAR						= 40;
const int SM_FEATURECHANGED				= 41;
const int SM_USERNAME					= 42;
const int SM_WINEXP						= 44;
const int SM_LEVELUP					= 45;
const int SM_DAYCHANGING				= 46;
const int SM_LOGON						= 50;
const int SM_NEWMAP						= 51;
const int SM_ABILITY					= 52;
const int SM_HEALTHSPELLCHANGED			= 53;
const int SM_MAPDESCRIPTION				= 54;
const int SM_SPELL2						= 117;

const int SM_SYSMESSAGE					= 100;
const int SM_GROUPMESSAGE				= 101;
const int SM_CRY						= 102;
const int SM_WHISPER					= 103;
const int SM_GUILDMESSAGE				= 104;

const int SM_ADDITEM					= 200;
const int SM_BAGITEMS					= 201;
const int SM_ADDMAGIC					= 210;
const int SM_SENDMYMAGIC				= 211;

const int SM_DROPITEM_SUCCESS			= 600;
const int SM_DROPITEM_FAIL				= 601;

const int SM_ITEMSHOW					= 610;
const int SM_ITEMHIDE					= 611;
const int SM_DOOROPEN					= 612;
const int SM_TAKEON_OK					= 615;
const int SM_TAKEON_FAIL				= 616;
const int SM_TAKEOFF_OK					= 619;
const int SM_TAKEOFF_FAIL				= 620;
const int SM_SENDUSEITEMS				= 621;
const int SM_WEIGHTCHANGED				= 622;
const int SM_CLEAROBJECTS				= 633;
const int SM_CHANGEMAP					= 634;
const int SM_EAT_OK						= 635;
const int SM_EAT_FAIL					= 636;
const int SM_BUTCH						= 637;
const int SM_MAGICFIRE					= 638;
const int SM_MAGIC_LVEXP				= 640;
const int SM_DURACHANGE					= 642;
const int SM_MERCHANTSAY				= 643;
const int SM_MERCHANTDLGCLOSE			= 644;
const int SM_SENDGOODSLIST				= 645;
const int SM_SENDUSERSELL				= 646;
const int SM_SENDBUYPRICE				= 647;
const int SM_USERSELLITEM_OK			= 648;
const int SM_USERSELLITEM_FAIL			= 649;
const int SM_BUYITEM_SUCCESS			= 650;
const int SM_BUYITEM_FAIL				= 651;
const int SM_SENDDETAILGOODSLIST		= 652;
const int SM_GOLDCHANGED				= 653;
const int SM_CHANGELIGHT				= 654;
const int SM_CHANGENAMECOLOR			= 656;
const int SM_CHARSTATUSCHANGED			= 657;

const int SM_AREASTATE					= 766; //救傈,措访,老馆..
const int SM_READMINIMAP_OK				= 710;
const int SM_READMINIMAP_FAIL			= 711;
const int SM_SUBABILITY					= 752;

const int SM_SHOWEVENT					= 804;
const int SM_HIDEEVENT					= 805;
const int SM_ADJUST_BONUS               = 811;

const int SM_OPENHEALTH					= 1100;
const int SM_CLOSEHEALTH				= 1101;
const int SM_CHANGEFACE					= 1104;
const int SM_CHECK_CLIENTVALID			= 1106;  //努扼捞攫飘狼 荐沥 咯何 犬牢

const int SM_ITEMUPDATE					= 1500;
const int SM_MONSTERSAY					= 1501;

⌨️ 快捷键说明

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