diff --git a/WooolC.sln b/WooolC.sln new file mode 100644 index 0000000..991dc84 --- /dev/null +++ b/WooolC.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30320.27 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WooolC", "WooolC\WooolC.vcxproj", "{5E1218FE-25E1-4559-B61F-F012DD01EFBB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Debug|x64.ActiveCfg = Debug|x64 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Debug|x64.Build.0 = Debug|x64 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Debug|x86.ActiveCfg = Debug|Win32 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Debug|x86.Build.0 = Debug|Win32 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Release|x64.ActiveCfg = Release|x64 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Release|x64.Build.0 = Release|x64 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Release|x86.ActiveCfg = Release|Win32 + {5E1218FE-25E1-4559-B61F-F012DD01EFBB}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CF4FF3E2-9294-4223-9C6D-88D151D7C9BA} + EndGlobalSection +EndGlobal diff --git a/WooolC/Actor.cpp b/WooolC/Actor.cpp new file mode 100644 index 0000000..3d00c03 --- /dev/null +++ b/WooolC/Actor.cpp @@ -0,0 +1,15 @@ +#include "stdafx.h" +#include "actor.h" + +CActor::CActor(void) + : id(0) + , x(0) + , y(0) + , name(_T("")) + , type(0) +{ +} + +CActor::~CActor(void) +{ +} diff --git a/WooolC/Actor.h b/WooolC/Actor.h new file mode 100644 index 0000000..2e7f8a2 --- /dev/null +++ b/WooolC/Actor.h @@ -0,0 +1,13 @@ +#pragma once + +class CActor +{ +public: + CActor(void); + ~CActor(void); + DWORD id; + DWORD x; + DWORD y; + CString name; + unsigned char type; +}; diff --git a/WooolC/ClientSocket.cpp b/WooolC/ClientSocket.cpp new file mode 100644 index 0000000..634fe75 --- /dev/null +++ b/WooolC/ClientSocket.cpp @@ -0,0 +1,69 @@ +#include "StdAfx.h" +#include "ClientSocket.h" +#include "MainFram.h" + +// CClientSocket +CClientSocket::CClientSocket(CWnd* pNotifyWnd) +{ + pWnd = pNotifyWnd; + CClientSocket* LastSocket = ((CMainFrame*)pWnd)->m_pSocket; + ((CMainFrame*)pWnd)->m_pSocket = this; + if (LastSocket != NULL) + { + LastSocket->Close(); + delete LastSocket; + } +} + +CClientSocket::~CClientSocket() +{ + if (((CMainFrame*)pWnd)->m_pSocket == this) + { + ((CMainFrame*)pWnd)->m_pSocket = NULL; + } +} + + +// CClientSocket Ա + +void CClientSocket::OnConnect(int nErrorCode) +{ + if (pWnd) + { + if (nErrorCode == 0) + ((CMainFrame*)pWnd)->m_pSocket = this; + ((CMainFrame*)pWnd)->OnConnect(nErrorCode, this); + } + CAsyncSocket::OnConnect(nErrorCode); +} + +void CClientSocket::OnReceive(int nErrorCode) +{ + if (pWnd)((CMainFrame*)pWnd)->OnReceive(nErrorCode, this); + CAsyncSocket::OnReceive(nErrorCode); +} + +void CClientSocket::OnClose(int nErrorCode) +{ + if (pWnd)((CMainFrame*)pWnd)->OnClose(nErrorCode, this); + CAsyncSocket::OnClose(nErrorCode); +} + +int CClientSocket::SendString(LPCTSTR string) +{ + return Send(string, strlen(string)); +} + +int CClientSocket::SendMsg(MMSG* msg, const char* data) +{ + char buf[BUF_LENGTH]; + char buf2[BUF_LENGTH]; + ZeroMemory(buf, BUF_LENGTH); + ZeroMemory(buf2, BUF_LENGTH); + int pos = Encode6BitBuf((unsigned char*)msg, buf, 12/*sizeof(MMSG)*/, BUF_LENGTH); + pos += Encode6BitBuf((unsigned char*)data, buf + pos, strlen(data), BUF_LENGTH - pos); + sprintf(buf2, "#%c%s!", ((CMainFrame*)pWnd)->m_chFlag, buf); + ((CMainFrame*)pWnd)->m_chFlag++; + if (((CMainFrame*)pWnd)->m_chFlag > '9')((CMainFrame*)pWnd)->m_chFlag = '1'; + return SendString(buf2); +} diff --git a/WooolC/ClientSocket.h b/WooolC/ClientSocket.h new file mode 100644 index 0000000..97fe159 --- /dev/null +++ b/WooolC/ClientSocket.h @@ -0,0 +1,46 @@ +#pragma once +#include "StdAfx.h" + +enum __GAMESTATE +{ + WGS_LOGINGATE, + WGS_SELGATE, + WGS_GAMEGATE, + /* 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,*/ +}; + + +// CClientSocket Ŀ + +class CClientSocket : public CAsyncSocket +{ +public: + CClientSocket(CWnd* pNotifyWnd); + virtual ~CClientSocket(); + virtual void OnConnect(int nErrorCode); + virtual void OnReceive(int nErrorCode); + virtual void OnClose(int nErrorCode); + CWnd* pWnd; +public: + int SendString(LPCTSTR string); + int SendMsg(MMSG* msg, const char* data); +}; \ No newline at end of file diff --git a/WooolC/GameLogic.cpp b/WooolC/GameLogic.cpp new file mode 100644 index 0000000..1688a7d --- /dev/null +++ b/WooolC/GameLogic.cpp @@ -0,0 +1,608 @@ +#include "StdAfx.h" +#include "MainFram.h" + +extern TCHAR g_szGamePath[STRING_LENGTH]; +char buf[BUF_LENGTH * 16]; +BOOL CMainFrame::GameLoop(const MMSG& msg, const char* data, CClientSocket* socket) +{ + MMSG send_msg; + CString str, str2, str3; + CStringList strList; + int retval = 0; + char* token; + switch (msg.wCmd) + { + /////////////////////////////////////////////////////////////////////////////////////////////////// + // ǽ¼غϢ + /////////////////////////////////////////////////////////////////////////////////////////////////// + case 0x211: + LogSystem("ʺ/ ֤ͨ. ͷ=>" + m_server_name); + ZeroMemory((char*)&send_msg, sizeof(send_msg)); + send_msg.wCmd = 0x68; + socket->SendMsg(&send_msg, m_server_name); + if (msg.wb > 0) + { + str.Format("˻ʣ%dСʱ!", msg.wb); + LogSystem(str); + } + break; + case 0x1f7: + socket->Close(); + if (msg.dwFlag == 0xffffffff) + { + LogSystem("!", RGB(255, 0, 0)); + } + if (msg.dwFlag == 0) + { + LogSystem("û!", RGB(255, 0, 0)); + } + if (msg.dwFlag == 0xfffffffe) + { + LogSystem("󣬷ܾ!", RGB(255, 0, 0)); + } + if (msg.dwFlag == 0xfffffffd) + { + LogSystem("ûʹУܱ߳", RGB(255, 0, 0)); + } + delete socket; + break; + case 0x212: + LogSystem(""); + + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + + token = strtok(buf, "/"); + while (token != NULL) + { + str = token; + if (str.GetLength() > 0) + break; + token = strtok(NULL, "/"); + } + token = strtok(NULL, "/"); + while (token != NULL) + { + str2 = token; + if (str2.GetLength() > 0) + break; + token = strtok(NULL, "/"); + } + token = strtok(NULL, "/"); + while (token != NULL) + { + str3 = token; + if (str3.GetLength() > 0) + break; + token = strtok(NULL, "/"); + } + m_SID = str3; + LogSystem("õɫصַ:" + str + ":" + str2 + " ֤=" + str3, RGB(255, 255, 0)); + + { + CClientSocket* socket = new CClientSocket(this); + if (!socket->Create()) + { + LogSystem("׽ֳ!", RGB(255, 0, 0)); + break; + } + LogSystem("ʼӽɫ..."); + m_GameStatus = WGS_SELGATE; + socket->Connect(str, atol(str2)); + } + break; + + + /////////////////////////////////////////////////////////////////////////////////////////////////// + // ǽɫغϢ + /////////////////////////////////////////////////////////////////////////////////////////////////// + case 0x20F: + LogSystem("ȡɫбʧ!", RGB(255, 0, 0)); + socket->Close(); + delete socket; + break; + case 0x208: + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogSystem("õɫб:"); + LogSystem("=================================="); + { + CString CharInfo[20]; + unsigned int i = 0; + strList.RemoveAll(); + token = strtok(buf, "/"); + while (token != NULL) + { + CharInfo[i++] = token; + token = strtok(NULL, "/"); + } + for (i = 0; i < msg.dwFlag; i++) + { + LogSystem(CharInfo[5 * i], RGB(192, 192, 192)); + } + LogSystem("=================================="); + m_CharacterName = CharInfo[5 * 0]; + if (m_CharacterName[0] == '*') + { + m_CharacterName = m_CharacterName.Mid(1); + } + LogSystem("ʹá" + m_CharacterName + "¼!"); + ZeroMemory((char*)&send_msg, sizeof(send_msg)); + send_msg.wCmd = 0x67; + socket->SendMsg(&send_msg, m_account + "/" + m_CharacterName); + } + break; + case 0x20d: + Sleep(1000); + + LogSystem(""); + + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + + token = strtok(buf, "/"); + while (token != NULL) + { + str = token; + if (str.GetLength() > 0) + break; + token = strtok(NULL, "/"); + } + token = strtok(NULL, "/"); + while (token != NULL) + { + str2 = token; + if (str2.GetLength() > 0) + break; + token = strtok(NULL, "/"); + } + LogSystem("õϷصַ:" + str + ":" + str2, RGB(255, 255, 0)); + { + CClientSocket* socket = new CClientSocket(this); + if (!socket->Create()) + { + LogSystem("׽ֳ!", RGB(255, 0, 0)); + break; + } + LogSystem("ʼϷ...", RGB(255, 0, 255)); + m_GameStatus = WGS_GAMEGATE; + socket->Connect(str, atol(str2)); + } + break; + + + /////////////////////////////////////////////////////////////////////////////////////////////////// + // ǽϷغϢ + /////////////////////////////////////////////////////////////////////////////////////////////////// + case 0x9: + if (msg.dwFlag == m_CharSelf.dwServerId) + { + str.Format("ýɫ%d,%d...", msg.w1, msg.w2); + LogSystem(str); + } + break; + case 0xa: + case 0xb: + case 0xd://ɫ + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + ActorAppear(msg.dwFlag, msg.w1, msg.w2, buf + 12, buf[0]); + break; + case 0xe: + /* + flag = attacker id + wcmd = 0x0e + w1 = x + w2 = y + w3 = dir + */ + str.Format("%s ,(%d,%d)!%d!%s", + ParseActorName(GetActorByIndex(msg.dwFlag)->name), + msg.w1, msg.w2, msg.w3, data); + LogSystem(str, RGB(128, 128, 255)); + break; + case 0x1e://ɫʧ + ActorDisappear(msg.dwFlag); + break; + case 0x1f: + /* + flag = char id + wcmd = 0x1f + w1 = cur hp + w2 = max hp + w3 = dir + data = feather [4bytes] + + 0 [4bytes] + + attacker id[4 bytes]+ + 0 [4bytes] + */ + ZeroMemory(buf, sizeof(buf)); + retval = Decode6BitBuf(data, buf, sizeof(buf)); + if (msg.dwFlag == m_CharSelf.dwServerId) + { + str.Format("%s ,%d˺,ʣ%d,ܹ%d.", + ParseActorName(GetActorByIndex(*((DWORD*)(buf + 8)))->name), + msg.w3, msg.w1, msg.w2); + //OnHpChange(recv_msg.head.w1,recv_msg.head.w2); + LogSystem(str, RGB(255, 0, 0)); + m_CharSelf.Hp.min = msg.w1; + m_CharSelf.Hp.max = msg.w2; + + //char strbuf[512]; + //str=""; + //for(int i=0;iname); + if (GetActorByIndex(msg.dwFlag) != NULL) + str3 = ParseActorName(GetActorByIndex(msg.dwFlag)->name); + str.Format("%s %s,%d˺,ʣ%d,ܹ%d.", + str2, str3, + msg.w3, msg.w1, msg.w2); + LogSystem(str, RGB(255, 128, 128)); + + //char strbuf[512]; + //str=""; + //for(int i=0;i<20;i++) + //{ + // sprintf(strbuf,"%02x ",(unsigned char)buf[i]); + // str+=strbuf; + //} + //LogSystem(str,RGB(0,255,0)); + } + break; + case 0x22: + /* + wMsgFlag = char id + wcmd = 0x22 + w1 = x + w2 = y + w3 = dir + data = feather and 0 */ + ZeroMemory(buf, sizeof(buf)); + retval = Decode6BitBuf(data, buf, sizeof(buf)); + if (msg.dwFlag == m_CharSelf.dwServerId) + { + str.Format("㱻ɱ!%s", data); + LogSystem(str, RGB(255, 0, 0)); + char strbuf[512]; + str = ""; + for (int i = 0; i < retval; i++) + { + sprintf(strbuf, "%02x ", (unsigned char)buf[i]); + str += strbuf; + } + LogSystem(str, RGB(0, 0, 255)); + } + else + { + str.Format("%sɱ!%s", ParseActorName(GetActorByIndex(msg.dwFlag)->name), data); + LogSystem(str); + char strbuf[512]; + str = ""; + for (int i = 0; i < retval; i++) + { + sprintf(strbuf, "%02x ", (unsigned char)buf[i]); + str += strbuf; + } + LogSystem(str, RGB(0, 0, 255)); + } + break; + case 0x2a://ҽɫ + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + if (m_CharSelf.dwServerId == msg.dwFlag) + { + str.Format("ҽɫ[%s]", buf); + LogSystem(str); + m_CharSelf.Name = buf; + //UpdateSelfStatus(); + } + else + { + str.Format("ֲѯ0x%x=%s", msg.dwFlag, ParseActorName(buf)); + LogSystem(str); + } + break; + case 0x32: + str.Format("ҵID:0x%08x / ڵͼ(%d,%d).", msg.dwFlag, msg.w1, msg.w2); + LogSystem(str); + m_CharSelf.pos_x = msg.w1; + m_CharSelf.pos_y = msg.w2; + m_CharSelf.dwServerId = msg.dwFlag; + break; + case 0x33: + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + str.Format("ҵID:0x%08x / ڵͼ[%s](%d,%d).", msg.dwFlag, buf, msg.w1, msg.w2); + LogSystem(str); + m_CharSelf.pos_x = msg.w1; + m_CharSelf.pos_y = msg.w2; + m_CharSelf.dwServerId = msg.dwFlag; + m_MapFilename = buf; + str.Format("%sData\\map\\%s.nmp", m_game_path, buf); + m_GameMap.LoadMap(str); + break; + case 0x34: +#define pmsginfo ((MMSGSETCHARINFO*)&buf) + ZeroMemory(buf, sizeof(buf)); + memcpy(buf, &msg, sizeof(MMSG)); + Decode6BitBuf(data, buf + sizeof(MMSG), sizeof(buf)); + + m_CharSelf.prof = pmsginfo->bProf; + m_CharSelf.gold = pmsginfo->dwGold; + m_CharSelf.level = pmsginfo->bLevel; + m_CharSelf.AC.hi = pmsginfo->ACHi; + m_CharSelf.AC.low = pmsginfo->ACLow; + m_CharSelf.MAC.hi = pmsginfo->MACHi; + m_CharSelf.MAC.low = pmsginfo->MACLow; + m_CharSelf.DC.hi = pmsginfo->DCHi; + m_CharSelf.DC.low = pmsginfo->DCLow; + m_CharSelf.MC.hi = pmsginfo->MCHi; + m_CharSelf.MC.low = pmsginfo->MCLow; + m_CharSelf.SC.hi = pmsginfo->SCHi; + m_CharSelf.SC.low = pmsginfo->SCLow; + m_CharSelf.HandWeight.min = pmsginfo->HandWeight; + m_CharSelf.HandWeight.max = pmsginfo->MaxHandWeight; + m_CharSelf.BodyWeight.min = pmsginfo->BodyWeight; + m_CharSelf.BodyWeight.max = pmsginfo->MaxBodyWeight; + m_CharSelf.BagWeight.min = pmsginfo->BagWeight; + m_CharSelf.BagWeight.max = pmsginfo->MaxBagWeight; + + m_CharSelf.Hp.min = pmsginfo->Hp; + m_CharSelf.Hp.max = pmsginfo->MaxHp; + m_CharSelf.Mp.min = pmsginfo->Mp; + m_CharSelf.Mp.max = pmsginfo->MaxMp; + m_CharSelf.Exp.min = pmsginfo->Exp; + m_CharSelf.Exp.max = pmsginfo->MaxExp; +#undef pmsginfo + break; + case 0x35: + /*ħhpı + dwMsgFlag = char id + wcmd = 0x35 + w1 = curhp + w2 = curmp + w3 = maxhp*/ + if (msg.dwFlag == m_CharSelf.dwServerId) + { + str.Format(" HP:%d/%d MP:%d", msg.w1, msg.w3, msg.w2); + LogSystem(str); + m_CharSelf.Hp.min = msg.w1; + m_CharSelf.Hp.max = msg.w3; + m_CharSelf.Mp.min = msg.w2; + } + else + { + if (GetActorByIndex(msg.dwFlag) != NULL) + { + str2 = ParseActorName(GetActorByIndex(msg.dwFlag)->name); + } + str.Format("%s HP:%d/%d MP:%d", str2, msg.w1, msg.w3, msg.w2); + LogSystem(str); + } + //OnHpChange(recv_msg.head.w1,recv_msg.head.w3); + //OnMpChange(recv_msg.head.w2,0); + break; + case 0x36: + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + str.Format("ǰͼ[%s].", buf); + LogSystem(str); + //LogChat(str); + m_MapCaption = buf; + //ZeroMemory(&send_msg,sizeof(send_msg)); + //send_msg.head.wCmd=0x409; + //SendMsg(send_msg,Socket); + break; + case 0x28://ͨ + case 0x64://ϵͳϢ + case 0x65://Ϣ + case 0x66:// + case 0x67://˽ + case 0x68://лϢ + { + BYTE b = msg.w1 & 0xff; + BYTE f = (msg.w1 & 0xff00) >> 8; + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogChat(buf, + RGB(ColorTable[b * 3], ColorTable[b * 3 + 1], ColorTable[b * 3 + 2]), + RGB(ColorTable[f * 3], ColorTable[f * 3 + 1], ColorTable[f * 3 + 2])); + } + break; + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogChat(buf, RGB(0, 0, 0), RGB(255, 0, 0)); + memprintf(buf, (unsigned char*)&msg, sizeof(msg)); + LogSystem(buf, RGB(255, 0, 255)); + break; + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogChat(buf, RGB(255, 255, 64)); + break; + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogChat(buf, 0, RGB(255, 255, 64)); + break; + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogChat(buf, RGB(64, 64, 255)); + break; + ZeroMemory(buf, sizeof(buf)); + Decode6BitBuf(data, buf, sizeof(buf)); + LogChat(buf, RGB(64, 255, 64)); + break; + case 0xd3://ħб + ZeroMemory(buf, sizeof(buf)); + retval = Decode6BitBuf(data, buf, sizeof(buf)); + //LogSystem("õħб",RGB(255,0,0)); + { + char strbuf[512]; + magic_in_buf* p; + int i; + for (i = 0; i < MAX_MAGIC_COUNT; i++) + { + m_MagicList[i].name = ""; + } + //p=(magic_in_buf*)buf; + for (i = 0;/*iname_len > 0 && ((DWORD)p - (DWORD)buf) < retval) + { + ZeroMemory(strbuf, 512); + memcpy(strbuf, p->name, ((p->name_len > 14) ? 14 : p->name_len)); + //LogSystem(strbuf,RGB(255,128,128)); + //LogSystem(p->name); + m_MagicList[i].name = strbuf; + m_MagicList[i].magic_id = p->magic_id; + m_MagicList[i].level = p->level; + m_MagicList[i].exp = p->exp; + m_MagicList[i].exp_need[0] = p->exp_need[0]; + m_MagicList[i].exp_need[1] = p->exp_need[1]; + m_MagicList[i].exp_need[2] = p->exp_need[2]; + } + else + { + break; + } + } + //str=""; + //for(int i=0;imagic > 0) + { + ZeroMemory(strbuf, 16); + memcpy(strbuf, p->name, ((p->magic > 14) ? 14 : p->magic)); + m_BodyItem[p->idx].name = strbuf; + m_BodyItem[p->idx].dura.low = p->dura; + m_BodyItem[p->idx].dura.hi = p->dura_max; + p++; + } + } + ZeroMemory(&send_msg, sizeof(send_msg)); + send_msg.wCmd = 0x51; + m_pSocket->SendMsg(&send_msg, ""); + break; + case 0xc9:// + ZeroMemory(buf, sizeof(buf)); + retval = Decode6BitBuf(data, buf, sizeof(buf)); + { + char strbuf[512]; + bagitem_in_buf* p = (bagitem_in_buf*)buf; + int i = 0; + while (p->magic > 0) + { + if (((DWORD)p - (DWORD)buf) > retval) + break; + ZeroMemory(strbuf, 512); + memcpy(strbuf, p->name, ((p->magic > 14) ? 14 : p->magic)); + m_BagItem[i].name = strbuf; + m_BagItem[i].dura.low = p->dura; + m_BagItem[i].dura.hi = p->dura_max; + p++; + i++; + } + m_BagItem[i].name = ""; + ////char strbuf[512]; + //str=""; + //for(int i=0;iSendMsg(&send_msg, buf); + break; + } + /////////////////////////////////////////////////////////////////////////////////////////////////// + // δ֪ + /////////////////////////////////////////////////////////////////////////////////////////////////// + default: + //str.Format("δ֪[% 4X],% 8X,% 4X,% 4X,% 4X, %s",msg.wCmd,msg.dwFlag,msg.w1,msg.w2,msg.w3,data); + //LogSystem(str,RGB(255,0,255)); + //ZeroMemory(buf,BUF_LENGTH); + //Decode6BitBuf(data,buf,BUF_LENGTH); + //LogSystem(buf,RGB(255,0,255)); + break; + } + return 0; +} diff --git a/WooolC/GameLogic.h b/WooolC/GameLogic.h new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/WooolC/GameLogic.h @@ -0,0 +1 @@ +#pragma once diff --git a/WooolC/MainFarm.cpp b/WooolC/MainFarm.cpp new file mode 100644 index 0000000..fa04b8b --- /dev/null +++ b/WooolC/MainFarm.cpp @@ -0,0 +1,386 @@ +#include "MainFram.h" +#include "StdAfx.h" +#include + + +CMainFrame::CMainFrame() + : m_SID(_T("")) + , m_CharacterName(_T("")) + , m_pSocket(NULL) + , m_IsMoveRun(false) + , m_MapCaption(_T("")) + , m_MapFilename(_T("")) + , m_DStarArray(NULL) + , m_DStarWidth(0) + , m_DStarHeight(0) +{ + m_account = "srauni"; + m_password = "123456"; + m_server_host = "192.168.1.107"; + m_server_port = 7000; + m_server_name = "ϼ"; + m_game_path = "C:\\Program Files (x86)\\Shanda\\Woool\\"; +} + +CMainFrame::~CMainFrame() +{ +} + +BOOL CMainFrame::OnIdle(LONG lCount) +{ + CString str, str2; + str.Format("ǰλ:%s[%s](%u,%u)", m_MapCaption, m_MapFilename, m_CharSelf.pos_x, m_CharSelf.pos_y); + if (this->m_DStarArray != NULL) + { + POINT current; + current.x = m_CharSelf.pos_x; + current.y = m_CharSelf.pos_y; + long g = m_DStarArray[current.x * m_DStarHeight + current.y]; + str2.Format("ʣ%d", g); + if (g > 0) + { + str += str2; + } + } + LogSystem(str); + return TRUE; +} + + +void CMainFrame::OnConnect(int nErrorCode, CClientSocket* socket) +{ + if (socket != m_pSocket) + { + delete socket; + return; + } + if (nErrorCode == 0) + { + if (m_GameStatus == WGS_LOGINGATE) + { + LogSystem("ӵ¼ɹ", RGB(0, 255, 255)); + Sleep(500); + LogSystem("˺/"); + char buf[STRING_LENGTH]; + MMSG msg; + ZeroMemory(&msg, sizeof(MMSG)); + sprintf(buf, "%s/%s", m_account, m_password); + msg.wCmd = 0x7d1; + socket->SendMsg(&msg, buf); + } + else if (m_GameStatus == WGS_SELGATE) + { + LogSystem("ӽɫسɹ", RGB(0, 255, 255)); + Sleep(500); + char buf[STRING_LENGTH]; + MMSG msg; + ZeroMemory(&msg, sizeof(MMSG)); + sprintf(buf, "%s/%s", m_account, m_SID); + LogSystem(buf,RGB(64,255,64)); + msg.wCmd = 0x64; + socket->SendMsg(&msg, buf); + } + else if (m_GameStatus == WGS_GAMEGATE) + { + LogSystem("Ϸسɹ", RGB(0, 255, 255)); + Sleep(500); + char buf[STRING_LENGTH]; + ZeroMemory(&buf, STRING_LENGTH); + sprintf(buf, "**%s/%s/%s/20041118/0", m_account, m_CharacterName, m_SID); + LogSystem(buf); + socket->SendMsg((MMSG*)buf, buf + 12); + } + } + else + { + LogSystem("ӷ,׽ֱ!", RGB(255, 0, 0)); + delete socket; + } + +} + +char g_RecvBuf[BUF_LENGTH * 8] = { (char)0 }; +void CMainFrame::OnReceive(int nErrorCode, CClientSocket* socket) +{ + if (socket != m_pSocket) + { + delete socket; + return; + } + if (nErrorCode != 0) + { + LogSystem("ݳ!", RGB(255, 0, 0)); + return; + } + + char buf[BUF_LENGTH]; + MMSG msg; + int retval; + int i; + int pos = 0; + int NewStart = 0; + CString str; + + ZeroMemory(buf, sizeof(buf)); + retval = socket->Receive(buf, BUF_LENGTH); + buf[retval] = (char)0; + //LogSystem(buf,RGB(0,255,0)); + strcat(g_RecvBuf, buf); + + ZeroMemory(buf, sizeof(buf)); + NewStart = 0; + long len = strlen(g_RecvBuf); + for (i = 0; i < len; i++) + { + if (g_RecvBuf[i] == '#') + { + pos = 0; + while (i < len) + { + buf[pos] = g_RecvBuf[i]; + if (buf[pos] == '!') + { + break; + } + //if(i>strlen(m_RecvBuf))break; + i++; + pos++; + } + if (buf[pos] == '!') + { + NewStart = i + 1; + buf[pos + 1] = (char)0; + buf[pos] = (char)0; + if (buf[1] == '+') + { + char* token; + bool isG = false; + token = strtok(buf, "/"); + if (token != NULL) + { + if (token[2] == 'G') + { + LogSystem("ɹ", RGB(0, 255, 0)); + isG = true; + } + else if ((*(WORD*)(token + 2)) == ((WORD)'FL')) + { + LogSystem("ʧ"); + } + } + token = strtok(NULL, "/"); + if (token != NULL) + { + m_CharSelf.pos_x = atol(token); + } + token = strtok(NULL, "/"); + if (token != NULL) + { + m_CharSelf.pos_y = atol(token); + } + } + else + { + ZeroMemory(&msg, sizeof(msg)); + //LogSystem(buf); + Decode6BitBuf(buf + 1, (char*)&msg, sizeof(msg)); + if (!GameLoop(msg, buf + 16 + 1, socket)) + { + //LogString(buf,clFuchsia); + } + } + } + } + if (g_RecvBuf[i] == '*') + { + socket->Send("*", 1); + } + } + strcpy(buf, &g_RecvBuf[NewStart]); + strcpy(g_RecvBuf, buf); + + return; +} + +void CMainFrame::OnClose(int nErrorCode, CClientSocket* socket) +{ + if (socket != m_pSocket) + { + delete socket; + return; + } + LogSystem("ӱر", RGB(255, 0, 0)); +} + + +CString CMainFrame::ParseActorName(CString name) +{ + int FindAt = name.Find("/"); + if (FindAt != -1) + { + name = name.Left(FindAt); + } + FindAt = name.Find("\\"); + if (FindAt != -1) + { + name = name.Left(FindAt); + } + return name; +} + + +const int xofs_walk[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; +const int yofs_walk[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; +char dir_string[8][8] = { + "","J","","K","","L","","I" }; +void CMainFrame::Walk(int dir) +{ + CString s; + s.Format("%s",dir_string[dir]); + LogSystem(s); + MMSG msg; + dir &= 7; + ZeroMemory(&msg, sizeof(MMSG)); + msg.wa = m_CharSelf.pos_x + xofs_walk[dir]; + msg.wb = m_CharSelf.pos_y + yofs_walk[dir]; + msg.wCmd = 0xbc3; + msg.w3 = dir; + if (m_GameMap.TestMap(msg.wa, msg.wb)) + m_pSocket->SendMsg(&msg, ""); + else + LogSystem("ǰ޷ͨ"); +} + + +void CMainFrame::Run(int dir) +{ + CString s; + s.Format("%s",dir_string[dir]); + LogSystem(s); + MMSG msg; + dir &= 7; + ZeroMemory(&msg, sizeof(MMSG)); + msg.wa = m_CharSelf.pos_x + xofs_walk[dir] * 2; + msg.wb = m_CharSelf.pos_y + yofs_walk[dir] * 2; + msg.wCmd = 0xbc5; + msg.w3 = dir; + if (m_GameMap.TestMap(msg.wa, msg.wb) && m_GameMap.TestMap(m_CharSelf.pos_x + xofs_walk[dir], m_CharSelf.pos_y + yofs_walk[dir])) + m_pSocket->SendMsg(&msg, ""); + else + LogSystem("ǰ޷ͨ"); +} + + +inline void GetTypeName(CString& name, unsigned char type) +{ + switch (type) + { + case 0: + name = ""; + break; + case 3: + name = "-ʬ"; + break; + case 10: + name = "-"; + break; + case 11: + name = "()"; + break; + case 12: + name = "ʿ"; + break; + case 19: + name = ""; + break; + case 50: + name = "NPC"; + break; + case 54: + name = "-"; + break; + case 55: + name = "-"; + break; + default: + name.Format("%d", type); + break; + } +} + +CActor* CMainFrame::GetActorByIndex(DWORD idx) +{ + POSITION pos; + CActor* pActor; + pos = m_ActorList.GetHeadPosition(); + while (pos != NULL) + { + pActor = (CActor*)m_ActorList.GetAt(pos); + if (pActor->id == idx) + { + return pActor; + } + m_ActorList.GetNext(pos); + } + return NULL; +} + +//ɫ +void CMainFrame::ActorAppear(DWORD idx, long x, long y, LPCTSTR name, unsigned char type) +{ + POSITION pos; + CActor* pActor; + bool hasName = (strlen(name) > 0); + int count, i; + CString str; + /////////////////////////////////////////////////////////////////////////////////// + // ݸ + /////////////////////////////////////////////////////////////////////////////////// + pos = m_ActorList.GetHeadPosition(); + while (pos != NULL)//ش洢Ľɫб + { + pActor = (CActor*)m_ActorList.GetAt(pos); + if (pActor->id == idx)//Ѿھ͸ + { + pActor->x = x; + pActor->y = y; + if (hasName)pActor->name = name; + pActor->type = type; + break; + } + m_ActorList.GetNext(pos); + } + if (pos == NULL)// ½һɫб + { + pActor = new CActor; + pActor->id = idx; + pActor->x = x; + pActor->y = y; + if (hasName)pActor->name = name; + pActor->type = type; + m_ActorList.AddTail(pActor); + } +} + +//ɫʧ +void CMainFrame::ActorDisappear(DWORD idx) +{ + POSITION pos; + CActor* pActor; + int count; + CString str; + /////////////////////////////////////////////////////////////////////////////////// + // ݸ + /////////////////////////////////////////////////////////////////////////////////// + pos = m_ActorList.GetHeadPosition(); + while (pos != NULL)//ش洢Ľɫб + { + pActor = (CActor*)m_ActorList.GetAt(pos); + if (pActor->id == idx)//ھʹбɾ + { + m_ActorList.RemoveAt(pos); + break; + } + m_ActorList.GetNext(pos); + } +} diff --git a/WooolC/MainFram.h b/WooolC/MainFram.h new file mode 100644 index 0000000..1a2982a --- /dev/null +++ b/WooolC/MainFram.h @@ -0,0 +1,191 @@ +#pragma once +#include "StdAfx.h" +#include "ClientSocket.h" +#include "WoolMap.h" +#include "Actor.h" + +//Ϸ״̬ +struct MAXMININFO +{ + int min; + int max; +}; +struct LOWHIINFO +{ + int low; + int hi; +}; +struct __DWORD +{ + WORD l; + WORD h; +}; +class CHARACTERINFO +{ +public: + CString Name; + DWORD dwServerId; + int prof; + int sex; + int level; + int hair; + int pos_x; + int pos_y; + long gold; + 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() + { + Name = ""; + dwServerId = 0; + prof = 0; + sex = 0; + level = 0; + hair = 0; + pos_x = 0; + pos_y = 0; + gold = 0; + AC.hi = 0; + AC.low = 0; + MAC.hi = 0; + MAC.low = 0; + DC.hi = 0; + DC.low = 0; + MC.hi = 0; + MC.low = 0; + SC.hi = 0; + SC.low = 0; + HandWeight.max = 0; + HandWeight.min = 0; + BodyWeight.max = 0; + BodyWeight.min = 0; + BagWeight.max = 0; + BagWeight.min = 0; + Hp.max = 0; + Hp.min = 0; + Mp.max = 0; + Mp.min = 0; + Exp.max = 0; + Exp.min = 0; + Zhunque = 0; + Minjie = 0; + MagicAgainst = 0; + PoisonAgainst = 0; + PoisonRecover = 0; + HpRecover = 0; + MpRecover = 0; + }; +}; + +enum CHAR_INFO_INDEX +{ + CI_NAME, + CI_SEX, + CI_GOLD,// + CI_SPOUSE,//ż + CI_HP, + CI_MP, + CI_PROF,//ְҵ + CI_LEVEL,//ȼ + CI_AC,// + CI_MAC,//ħ + CI_DC,// + CI_MC,//ħ + CI_SC,// + CI_EXP,// + CI_BAGWEIGHT,// + CI_BODYWEIGHT,// + CI_HANDWEIGHT,// + CI_ZHUNQUE,//׼ȷ + CI_MINJIE,// +}; + +struct item +{ + CString name; + DWORD id; + LOWHIINFO dc; + LOWHIINFO mc; + LOWHIINFO sc; + LOWHIINFO ac; + LOWHIINFO mac; + LOWHIINFO dura; + int need_level; + int weight; + int need; +}; + +struct magic_item +{ + CString name; + WORD magic_id; + unsigned int level; + unsigned long exp; + unsigned long exp_need[3]; +}; + +#define CFrameWnd CBCGPFrameWnd +#define MAX_BAG_ITEM_COUNT (100) +#define MAX_MAGIC_COUNT (100) +#define MAX_BODY_ITEM_COUNT (100) +class CMainFrame : CWnd +{ +public: + CMainFrame(); + ~CMainFrame(); + + CString m_server_host; + int m_server_port; + CString m_server_name; + CString m_game_path; + + CString m_account; + CString m_password; + + CPtrList m_ActorList; + CHARACTERINFO m_CharSelf; // ɫϢ + bool m_IsMoveRun; + void OnConnect(int nErrorCode, CClientSocket* socket); + void OnReceive(int nErrorCode, CClientSocket* socket); + void OnClose(int nErrorCode, CClientSocket* socket); + BOOL GameLoop(const MMSG& msg, const char* data, CClientSocket* socket); + CString m_SID; + CWoolMap m_GameMap; + CString m_CharacterName; + CClientSocket* m_pSocket; + void Walk(int dir); + void Run(int dir); + unsigned char m_chFlag; + // TODO ѸĴˣʵֵİMFCȥٿ.cppӿڳþ + long m_GameStatus; + void ActorAppear(DWORD idx, long x, long y, LPCTSTR name, unsigned char type); + void ActorDisappear(DWORD idx); + CActor* GetActorByIndex(DWORD idx); + item m_BodyItem[MAX_BAG_ITEM_COUNT]; + item m_BagItem[MAX_BODY_ITEM_COUNT]; + magic_item m_MagicList[MAX_MAGIC_COUNT]; + CString m_MapCaption; + CString m_MapFilename; + BOOL OnIdle(LONG lCount); + long* m_DStarArray; + long m_DStarWidth; + long m_DStarHeight; + CString ParseActorName(CString name); +}; \ No newline at end of file diff --git a/WooolC/StdAfx.cpp b/WooolC/StdAfx.cpp new file mode 100644 index 0000000..faa22d1 --- /dev/null +++ b/WooolC/StdAfx.cpp @@ -0,0 +1,415 @@ +#include "stdafx.h" +#include +void LogSystem(LPCTSTR log, COLORREF tc) +{ + std::cout << log << std::endl; +} +void LogChat(LPCTSTR log, COLORREF tc, COLORREF bc) +{ + std::cout << log << std::endl; +} + + +// hex2int +int hex2int(char c) +{ + if (c >= 'A' && c <= 'F') + return(int)(c - 'A' + 10); + else if (c >= 'a' && c <= 'f') + return(int)(c - 'a' + 10); + else if (c >= '0' && c <= '9') + return(int)(c - '0'); + return 0; +} + +int WINAPI Encode6BitBuf(const unsigned char* pszSrc, char* pszDest, int nSrcLen, int nDestLen) +//int CodeWoool(const BYTE * pIn, int size, CHAR * pOut) +{ + nDestLen--; + int nDestPos = 0; + unsigned char chMade, chRest = 0; + int nRestCount = 0; + + for (int i = 0; i < nSrcLen; i++) + { + chMade = pszSrc[i] ^ 0xeb; + if (nDestPos >= nDestLen)break; + if (nRestCount == 2) + { + pszDest[nDestPos++] = (chMade & 0x3f) + 0x3b; + chRest |= ((chMade >> 2) & 0x30); + if (nDestPos >= nDestLen)break; + pszDest[nDestPos++] = chRest + 0x3b; + nRestCount = 0; + chRest = 0; + } + else + { + pszDest[nDestPos++] = ((chMade & 0xF0) >> 2 | (chMade & 3)) + 0x3b; + chRest <<= 2; + chRest |= (chMade >> 2) & 3; + nRestCount++; + } + } + if ((nRestCount != 0) && (nDestPos < nDestLen)) + { + pszDest[nDestPos++] = chRest + 0x3b; + } + pszDest[nDestPos] = (char)0; + return nDestPos; +} +//--------------------------------------------------------------------------- +int WINAPI Decode6BitBuf(const char* pszSrc, char* pszDest, int nDestLen) +{ + char ch1, ch2, ch3, ch4; + + --nDestLen; //returnǰǸֵ1ֽڿռ + + int nSrcLen = strlen(pszSrc); + + for (int i = 0; i < nSrcLen; i++) + { + if (pszSrc[i] < 0x3b) + return 0; + } + + // if(nSrcLen<=0) + // return 0; + + int nSrcGroup = nSrcLen >> 2; // 4ֽ1 + + nSrcLen = nSrcLen % 4; //ʣ೤ + + int nDestPos = 0; + + //4ֽһ + for (int i = 0; i < nSrcGroup; i++) + { + ch1 = pszSrc[i * 4] - 0x3b; + ch2 = pszSrc[i * 4 + 1] - 0x3b; + ch3 = pszSrc[i * 4 + 2] - 0x3b; + ch4 = pszSrc[i * 4 + 3] - 0x3b; + + if (nDestPos >= nDestLen)goto _decode_exit_; + pszDest[nDestPos++] = (((ch1 << 2) & 0xF0) | (ch1 & 0x03) | (ch4 & 0x0C)) ^ 0xeb; + if (nDestPos >= nDestLen)goto _decode_exit_; + pszDest[nDestPos++] = (((ch2 << 2) & 0xF0) | (ch2 & 0x03) | ((ch4 << 2) & 0x0C)) ^ 0xeb; + if (nDestPos >= nDestLen)goto _decode_exit_; + pszDest[nDestPos++] = (ch3 | ((ch4 << 2) & 0xC0)) ^ 0xeb; + } + + //ʣֽ + if (nSrcLen == 2) + { + ch1 = pszSrc[nSrcGroup * 4] - 0x3b; + ch4 = pszSrc[nSrcGroup * 4 + 1] - 0x3b; + + if (nDestPos >= nDestLen)goto _decode_exit_; + pszDest[nDestPos++] = (((ch1 << 2) & 0xF0) | (ch1 & 0x03) | ((ch4 << 2) & 0x0C)) ^ 0xeb; + } + else if (nSrcLen == 3) + { + ch1 = pszSrc[nSrcGroup * 4] - 0x3b; + ch2 = pszSrc[nSrcGroup * 4 + 1] - 0x3b; + ch4 = pszSrc[nSrcGroup * 4 + 2] - 0x3b; + + if (nDestPos >= nDestLen)goto _decode_exit_; + pszDest[nDestPos++] = (((ch1 << 2) & 0xF0) | (ch1 & 0x03) | (ch4 & 0x0C)) ^ 0xeb; + if (nDestPos >= nDestLen)goto _decode_exit_; + pszDest[nDestPos++] = (((ch2 << 2) & 0xF0) | (ch2 & 0x03) | ((ch4 << 2) & 0x0C)) ^ 0xeb; + } + +_decode_exit_: + pszDest[nDestPos] = '\0'; + return nDestPos; +} + +int memprintf(char* dest, const unsigned char* src, unsigned long len) +{ + const static char hextable[] = "0123456789ABCDEF"; + unsigned long SrcPos = 0, DestPos = 0; + unsigned char ch; + for (unsigned long SrcPos = 0; SrcPos < len; SrcPos++) + { + ch = src[SrcPos]; + dest[DestPos++] = hextable[(ch & 0xf0) >> 4]; + dest[DestPos++] = hextable[ch & 0x0f]; + if ((SrcPos & 15) == 15) + { + dest[DestPos++] = (char)0xd; + dest[DestPos++] = (char)0xa; + } + else if ((SrcPos & 7) == 7) + { + dest[DestPos++] = ' '; + dest[DestPos++] = '-'; + dest[DestPos++] = ' '; + } + else + { + dest[DestPos++] = ' '; + } + } + dest[DestPos] = (char)0; + return DestPos; +} + +const int ColorTable[] = +{ + 0, 0, 0, +128, 0, 0, + 0,128, 0, +128,128, 0, + 0, 0,128, +128, 0,128, + 0,128,128, +192,192,192, + 85,128,151, +157,185,200, +123,115,115, + 45, 41, 41, + 90, 82, 82, + 99, 90, 90, + 66, 57, 57, + 29, 24, 24, + 24, 16, 16, + 41, 24, 24, + 16, 8, 8, +242,121,113, +225,103, 95, +255, 90, 90, +255, 49, 49, +214, 90, 82, +148, 16, 0, +148, 41, 24, + 57, 8, 0, +115, 16, 0, +181, 24, 0, +189, 99, 82, + 66, 24, 16, +255,170,153, + 90, 16, 0, +115, 57, 41, +165, 74, 49, +148,123,115, +189, 82, 49, + 82, 33, 16, +123, 49, 24, + 45, 24, 16, +140, 74, 49, +148, 41, 0, +189, 49, 0, +198,115, 82, +107, 49, 24, +198,107, 66, +206, 74, 0, +165, 99, 57, + 90, 49, 24, + 42, 16, 0, + 21, 8, 0, + 58, 24, 0, + 8, 0, 0, + 41, 0, 0, + 74, 0, 0, +157, 0, 0, +220, 0, 0, +222, 0, 0, +251, 0, 0, +156,115, 82, +148,107, 74, +115, 74, 41, + 82, 49, 24, +140, 74, 24, +136, 68, 17, + 74, 33, 0, + 33, 24, 16, +214,148, 90, +198,107, 33, +239,107, 0, +255,119, 0, +165,148,132, + 66, 49, 33, + 24, 16, 8, + 41, 24, 8, + 33, 16, 0, + 57, 41, 24, +140, 99, 57, + 66, 41, 16, +107, 66, 24, +123, 74, 24, +148, 74, 0, +140,132,123, +107, 99, 90, + 74, 66, 57, + 41, 33, 24, + 70, 57, 41, +181,165,148, +123,107, 90, +206,177,148, +165,140,115, +140,115, 90, +181,148,115, +214,165,115, +239,165, 74, +239,198,140, +123, 99, 66, +107, 86, 57, +189,148, 90, + 99, 57, 0, +214,198,173, + 82, 66, 41, +148, 99, 24, +239,214,173, +165,140, 99, + 99, 90, 74, +189,165,123, + 90, 66, 24, +189,140, 49, + 53, 49, 41, +148,132, 99, +123,107, 74, +165,140, 90, + 90, 74, 41, +156,123, 57, + 66, 49, 16, +239,173, 33, + 24, 16, 0, + 41, 33, 0, +156,107, 0, +148,132, 90, + 82, 66, 24, +107, 90, 41, +123, 99, 33, +156,123, 33, +222,165, 0, + 90, 82, 57, + 49, 41, 16, +206,189,123, + 99, 90, 57, +148,132, 74, +198,165, 41, + 16,156, 24, + 66,140, 74, + 49,140, 66, + 16,148, 41, + 8, 24, 16, + 8, 24, 24, + 8, 41, 16, + 24, 66, 41, +165,181,173, +107,115,115, + 24, 41, 41, + 24, 66, 74, + 49, 66, 74, + 99,198,222, + 68,221,255, +140,214,239, +115,107, 57, +247,222, 57, +247,239,140, +247,231, 0, +107,107, 90, + 90,140,165, + 57,181,239, + 74,156,206, + 49,132,181, + 49, 82,107, +222,222,214, +189,189,181, +140,140,132, +247,247,222, + 0, 8, 24, + 8, 24, 57, + 8, 16, 41, + 8, 24, 0, + 8, 41, 0, + 0, 82,165, + 0,123,222, + 16, 41, 74, + 16, 57,107, + 16, 82,140, + 33, 90,165, + 16, 49, 90, + 16, 66,132, + 49, 82,132, + 24, 33, 49, + 74, 90,123, + 82,107,165, + 41, 57, 99, + 16, 74,222, + 41, 41, 33, + 74, 74, 57, + 41, 41, 24, + 74, 74, 41, +123,123, 66, +156,156, 74, + 90, 90, 41, + 66, 66, 20, + 57, 57, 0, + 89, 89, 0, +202, 53, 44, +107,115, 33, + 41, 49, 0, + 49, 57, 16, + 49, 57, 24, + 66, 74, 0, + 82, 99, 24, + 90,115, 41, + 49, 74, 24, + 24, 33, 0, + 24, 49, 0, + 24, 57, 16, + 99,132, 74, +107,189, 74, + 99,181, 74, + 99,189, 74, + 90,156, 74, + 74,140, 57, + 99,198, 74, + 99,214, 74, + 82,132, 74, + 49,115, 41, + 99,198, 90, + 82,189, 74, + 16,255, 0, + 24, 41, 24, + 74,136, 74, + 74,231, 74, + 0, 90, 0, + 0,136, 0, + 0,148, 0, + 0,222, 0, + 0,238, 0, + 0,251, 0, + 74, 90,148, + 99,115,181, +123,140,214, +107,123,214, +119,136,255, +198,198,206, +148,148,156, +156,148,198, + 49, 49, 57, + 41, 24,132, + 24, 0,132, + 74, 66, 82, + 82, 66,123, + 99, 90,115, +206,181,247, +140,123,156, +119, 34,204, +221,170,255, +240,180, 42, +223, 0,159, +227, 23,179, +255,251,240, +160,160,164, +128,128,128, +255, 0, 0, + 0,255, 0, +255,255, 0, + 0, 0,255, +255, 0,255, + 0,255,255, +255,255,255, +}; \ No newline at end of file diff --git a/WooolC/StdAfx.h b/WooolC/StdAfx.h new file mode 100644 index 0000000..9ab6042 --- /dev/null +++ b/WooolC/StdAfx.h @@ -0,0 +1,163 @@ +#pragma once + +#include + +typedef BYTE u8; +typedef WORD u16; +typedef DWORD u32; + +#define STRING_LENGTH (1024) +#define BUF_LENGTH (0x2000) +int WINAPI Encode6BitBuf(const unsigned char* pszSrc, char* pszDest, int nSrcLen, int nDestLen); +int WINAPI Decode6BitBuf(const char* pszSrc, char* pszDest, int nDestLen); +int hex2int(char c); +void LogSystem(LPCTSTR log, COLORREF tc = RGB(0xff, 0xff, 0xff)); +void LogChat(LPCTSTR log, COLORREF tc = RGB(0, 0, 0), COLORREF bc = RGB(0xff, 0xff, 0xff)); +int memprintf(char* dest, const unsigned char* src, unsigned long len); +extern const int ColorTable[]; + + +//Ϣݽṹ +struct MMSG +{ + union + { + DWORD dwFlag; + struct + { + WORD wa; + WORD wb; + }; + }; + WORD wCmd; + WORD w1; + WORD w2; + WORD w3; + //char __u[20]; +}; +//еװṹ +struct item_in_buf +{ + u16 idx; + u8 magic; + char name[14]; + u8 stdmod; + u8 shape; + u8 weight; + u8 anicount; + u8 source; + u8 reserved; + u8 unknow; + u16 looks; + u16 default_dura; + u8 ac; + u8 ac_max; + u8 mac; + u8 mac_max; + u8 dc; + u8 dc_max; + u8 mc; + u8 mc_max; + u8 sc; + u8 sc_max; + u8 need; + u8 need_level; + u16 unknow_2; + u32 price; + u32 id; + u16 dura; + u16 dura_max; +}; +//еıƷṹ +struct bagitem_in_buf +{ + u8 magic; + char name[14]; + u8 stdmod; + u8 shape; + u8 weight; + u8 anicount; + u8 source; + u8 reserved; + u8 unknow; + u16 looks; + u16 default_dura; + u8 ac; + u8 ac_max; + u8 mac; + u8 mac_max; + u8 dc; + u8 dc_max; + u8 mc; + u8 mc_max; + u8 sc; + u8 sc_max; + u8 need; + u8 need_level; + u16 unknow_2; + u32 price; + u32 id; + u16 dura; + u16 dura_max; +}; +struct magic_in_buf +{ + unsigned char key; + unsigned char level; + unsigned short unknow_1; + unsigned long exp; + unsigned short magic_id; + unsigned char name_len; + char name[12]; + unsigned char effect_type; + unsigned char effect; + unsigned short spell; + unsigned short power; + unsigned char unkonw_3; + unsigned char need_l1; + unsigned char need_l2; + unsigned char need_l3; + unsigned char unknow_2[3]; + unsigned long exp_need[3]; +}; +struct MMSGSETCHARINFO +{ + 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; +}; \ No newline at end of file diff --git a/WooolC/WoolMap.cpp b/WooolC/WoolMap.cpp new file mode 100644 index 0000000..d16928a --- /dev/null +++ b/WooolC/WoolMap.cpp @@ -0,0 +1,108 @@ +#include "stdafx.h" +#include "woolmap.h" + +CWoolMap::CWoolMap(void) + : m_Height(0) + , m_Width(0) + , m_pData(NULL) +{ +} + +CWoolMap::~CWoolMap(void) +{ +} + +bool CWoolMap::TestMap(long x, long y) +{ + if (x < 0 || x >= m_Width || y < 0 || y >= m_Height) + { + return false; + } + return m_pData[y * m_Width + x]; +} + +void CWoolMap::GetMapSize(long& w, long& h) +{ + w = m_Width; + h = m_Height; +} + +struct file_header +{ + unsigned long unknow_1[2]; + unsigned long map_width; + unsigned long map_height; + unsigned long unknow_2[4]; +}; + +void CWoolMap::LoadMap(LPCTSTR lpszPathName) +{ + CFile file; + file.Open(lpszPathName, CFile::modeRead); + file_header fh; + file.Read(&fh, sizeof(fh)); + m_Width = fh.map_width; + m_Height = fh.map_height; + char* p; + char b; + long len = file.GetLength() - sizeof(fh); + p = new char[len]; + long i = 0; + long j = 0; + file.Read(p, len); + file.Close(); + if (m_pData != NULL)delete[]m_pData; + m_pData = new bool[m_Width * m_Height]; + while (i < len) + { + b = p[i]; + if (b >= 0x0 && b <= 0x1) + { + i += 1; + } + else if (b >= 0x2 && b <= 0x5) + { + i += 3; + } + else if (b >= 0x6 && b <= 0x9) + { + i += 5; + } + else if (b >= 0xa && b <= 0xd) + { + i += 7; + } + else if (b >= 0xe && b <= 0xf) + { + i += 9; + } + else if (b >= 0x10 && b <= 0x11) + { + i += 2; + } + else if (b >= 0x12 && b <= 0x15) + { + i += 4; + } + else if (b >= 0x16 && b <= 0x19) + { + i += 6; + } + else if (b >= 0x1a && b <= 0x1d) + { + i += 8; + } + else if (b >= 0x1e && b <= 0x1f) + { + i += 10; + } + else + break; + if ((b & 1) == 0) + m_pData[j] = true; + else + m_pData[j] = false; + j++; + } + delete[]p; +} diff --git a/WooolC/WoolMap.h b/WooolC/WoolMap.h new file mode 100644 index 0000000..c858a22 --- /dev/null +++ b/WooolC/WoolMap.h @@ -0,0 +1,17 @@ +#pragma once +#include "StdAfx.h" + +class CWoolMap +{ +public: + CWoolMap(void); + ~CWoolMap(void); +protected: + long m_Height; + long m_Width; + bool* m_pData; +public: + bool TestMap(long x, long y); + void GetMapSize(long& w, long& h); + void LoadMap(LPCTSTR lpszPathName); +}; diff --git a/WooolC/WooolC.vcxproj b/WooolC/WooolC.vcxproj new file mode 100644 index 0000000..e1a34db --- /dev/null +++ b/WooolC/WooolC.vcxproj @@ -0,0 +1,164 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {5e1218fe-25e1-4559-b61f-f012dd01efbb} + WooolC + 10.0 + + + + Application + true + v142 + MultiByte + Dynamic + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + 32768 + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + 32768 + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WooolC/WooolC.vcxproj.filters b/WooolC/WooolC.vcxproj.filters new file mode 100644 index 0000000..2ee57fc --- /dev/null +++ b/WooolC/WooolC.vcxproj.filters @@ -0,0 +1,60 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + \ No newline at end of file diff --git a/WooolC/main.cpp b/WooolC/main.cpp new file mode 100644 index 0000000..637cd87 --- /dev/null +++ b/WooolC/main.cpp @@ -0,0 +1,7 @@ +#include "StdAfx.h" + +int main(void) +{ + + return 0; +} \ No newline at end of file