Skip to content

Commit

Permalink
初始化仓库
Browse files Browse the repository at this point in the history
  • Loading branch information
sukidesuka committed Jul 22, 2020
1 parent c0df9b9 commit 2f4fdd7
Show file tree
Hide file tree
Showing 16 changed files with 2,294 additions and 0 deletions.
31 changes: 31 additions & 0 deletions WooolC.sln
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions WooolC/Actor.cpp
Original file line number Diff line number Diff line change
@@ -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)
{
}
13 changes: 13 additions & 0 deletions WooolC/Actor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

class CActor
{
public:
CActor(void);
~CActor(void);
DWORD id;
DWORD x;
DWORD y;
CString name;
unsigned char type;
};
69 changes: 69 additions & 0 deletions WooolC/ClientSocket.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
46 changes: 46 additions & 0 deletions WooolC/ClientSocket.h
Original file line number Diff line number Diff line change
@@ -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);
};
Loading

0 comments on commit 2f4fdd7

Please sign in to comment.