Network stuff and Utils Engine

This commit is contained in:
Vladislav Khorev 2013-02-19 12:37:56 +00:00
parent 9627247bdc
commit 06652bfa0d
10 changed files with 42 additions and 13 deletions

View File

@ -41,7 +41,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>UTILS_ENGINE;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG</PreprocessorDefinitions> <PreprocessorDefinitions>UTILS_ENGINE;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
@ -54,7 +54,7 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>UTILS_ENGINE;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501</PreprocessorDefinitions> <PreprocessorDefinitions>UTILS_ENGINE;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
@ -75,6 +75,7 @@
<ClCompile Include="..\src\Utils\WinApi\WinApi.cpp" /> <ClCompile Include="..\src\Utils\WinApi\WinApi.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\include\Engine.h" />
<ClInclude Include="..\include\Utils\BindableVar.h" /> <ClInclude Include="..\include\Utils\BindableVar.h" />
<ClInclude Include="..\include\Utils\Console\console.h" /> <ClInclude Include="..\include\Utils\Console\console.h" />
<ClInclude Include="..\include\Utils\DataTypes\DataTypes.h" /> <ClInclude Include="..\include\Utils\DataTypes\DataTypes.h" />

View File

@ -1,6 +1,14 @@
#ifndef ENGINE_H_INCLUDED #ifndef ENGINE_H_INCLUDED
#define ENGINE_H_INCLUDED #define ENGINE_H_INCLUDED
#ifdef UTILS_ENGINE
#include "include/Utils/Utils.h"
#else
#ifdef TARGET_WIN32 #ifdef TARGET_WIN32
#include "SalmonEngineWindows.h" #include "SalmonEngineWindows.h"
#endif #endif
@ -13,4 +21,6 @@
#include "include/SalmonEngineIos.h" #include "include/SalmonEngineIos.h"
#endif #endif
#endif
#endif //ENGINE_H_INCLUDED #endif //ENGINE_H_INCLUDED

View File

@ -60,7 +60,9 @@ public:
virtual std::string GetHistory(); virtual std::string GetHistory();
#ifndef UTILS_ENGINE
virtual void Draw(); virtual void Draw();
#endif
}; };

View File

@ -81,6 +81,7 @@ public:
typedef boost::variant<std::shared_ptr<TSimpleAuthorization>> TAuthorizationVariant; typedef boost::variant<std::shared_ptr<TSimpleAuthorization>> TAuthorizationVariant;
class TClientSocket : public boost::enable_shared_from_this<TClientSocket> class TClientSocket : public boost::enable_shared_from_this<TClientSocket>
{ {
protected: protected:

View File

@ -7,7 +7,7 @@
namespace SE namespace SE
{ {
#ifndef UTILS_ENGINE
struct TFuncToPerform struct TFuncToPerform
{ {
private: private:
@ -34,6 +34,8 @@ namespace SE
template<typename RETURNTYPE> template<typename RETURNTYPE>
RETURNTYPE PerformInMainThread(boost::function<RETURNTYPE()> f); RETURNTYPE PerformInMainThread(boost::function<RETURNTYPE()> f);
#endif
} //namespace SE } //namespace SE
#endif #endif

View File

@ -12,6 +12,8 @@ const int CONST_ROW_WIDTH = 14;
const std::string CONST_CONSOLE_TEX_NAME = "console_bkg.bmp"; const std::string CONST_CONSOLE_TEX_NAME = "console_bkg.bmp";
#ifndef UTILS_ENGINE
void TSimpleConsole::Draw() void TSimpleConsole::Draw()
{ {
@ -59,6 +61,7 @@ void TSimpleConsole::Draw()
} }
#endif
void TSimpleConsole::CutHistory() void TSimpleConsole::CutHistory()
{ {

View File

@ -93,7 +93,7 @@ TSimpleAuthorization::TSimpleAuthorization(boost::asio::io_service& ioService, b
void TSimpleAuthorization::Authorize() void TSimpleAuthorization::Authorize()
{ {
std::shared_ptr<TDataReader> dataReader(new TDataReader(Socket)); boost::shared_ptr<TDataReader> dataReader(new TDataReader(Socket));
dataReader->DataReadSignal.connect(boost::bind(&TSimpleAuthorization::HandleGetData, this, _1)); dataReader->DataReadSignal.connect(boost::bind(&TSimpleAuthorization::HandleGetData, this, _1));
@ -115,8 +115,8 @@ void TSimpleAuthorization::HandleGetData(boost::property_tree::ptree pTree)
{ {
if (pTree.find("OnHello") != pTree.not_found()) if (pTree.find("OnHello") != pTree.not_found())
{ {
Login = p.get<std::string>("OnHello.Login"); Login = pTree.get<std::string>("OnHello.Login");
Password = p.get<std::string>("OnHello.Password"); Password = pTree.get<std::string>("OnHello.Password");
SaveLoginPasswordSignal(Login, Password); SaveLoginPasswordSignal(Login, Password);
AuthorizedSignal(); AuthorizedSignal();
@ -172,7 +172,7 @@ void TClientSocket::Open(const std::string address, const std::string& port)
return; return;
} }
boost::asio::async_connect(Socket, iterator, boost::bind(&TClientSocket::HandleConnect, shared_from_this(), boost::asio::placeholders::error)); boost::asio::async_connect(Socket, iterator, boost::bind(&TClientSocket::HandleConnect, this, boost::asio::placeholders::error));
ConnectionTimeoutTimer = boost::shared_ptr<boost::asio::deadline_timer>(new boost::asio::deadline_timer(IoService, boost::posix_time::seconds(CONST_CONNECTION_TIMEOUT_SECONDS))); ConnectionTimeoutTimer = boost::shared_ptr<boost::asio::deadline_timer>(new boost::asio::deadline_timer(IoService, boost::posix_time::seconds(CONST_CONNECTION_TIMEOUT_SECONDS)));

View File

@ -53,7 +53,11 @@ boost::property_tree::ptree::iterator ReplaceIncludeFile(boost::property_tree::p
} }
} }
#ifdef UTILS_ENGINE
xmlFileArr = CreateMemFromFile<char>(fileName, xmlFileSize);
#else
xmlFileArr = CreateMemFromFile<char>(ResourceManager->PathToResources + fileName, xmlFileSize); xmlFileArr = CreateMemFromFile<char>(ResourceManager->PathToResources + fileName, xmlFileSize);
#endif
std::string xmlString = std::string(&xmlFileArr[0], &xmlFileArr[xmlFileSize]); std::string xmlString = std::string(&xmlFileArr[0], &xmlFileArr[xmlFileSize]);
@ -143,7 +147,11 @@ std::shared_ptr<boost::property_tree::ptree> FileToPropertyTree(const std::strin
{ {
cardinal byteCount; cardinal byteCount;
#ifdef UTILS_ENGINE
boost::shared_array<char> file = CreateMemFromFile<char>(fileName, byteCount);
#else
boost::shared_array<char> file = CreateMemFromFile<char>(ResourceManager->PathToResources + fileName, byteCount); boost::shared_array<char> file = CreateMemFromFile<char>(ResourceManager->PathToResources + fileName, byteCount);
#endif
return FileToPropertyTree(file, byteCount, replaceMap); return FileToPropertyTree(file, byteCount, replaceMap);
} }

View File

@ -3,6 +3,7 @@
namespace SE namespace SE
{ {
#ifndef UTILS_ENGINE
void AssertIfInMainThread() void AssertIfInMainThread()
{ {
if (boost::this_thread::get_id() != ResourceManager->MainThreadId) if (boost::this_thread::get_id() != ResourceManager->MainThreadId)
@ -30,5 +31,6 @@ namespace SE
ResourceManager->MainThreadAsyncFunctionArr.push_back(f); ResourceManager->MainThreadAsyncFunctionArr.push_back(f);
} }
} }
#endif
} //namespace SE } //namespace SE

View File

@ -8,27 +8,27 @@ Here goes all functions that are platform-specific
When I make iOS/Mac/Linux port, I will make same API pair h/cpp When I make iOS/Mac/Linux port, I will make same API pair h/cpp
*/ */
void GetWindowWidthHeight(int& width, int& height) void GetWindowWidthHeight(HWND hwnd, int& width, int& height)
{ {
RECT rc; RECT rc;
GetClientRect(Hwnd, &rc); GetClientRect(hwnd, &rc);
width = rc.right; width = rc.right;
height = rc.bottom; height = rc.bottom;
} }
int GetWindowWidth() int GetWindowWidth(HWND hwnd)
{ {
RECT rc; RECT rc;
GetClientRect(Hwnd, &rc); GetClientRect(hwnd, &rc);
return rc.right; return rc.right;
} }
int GetWindowHeight() int GetWindowHeight(HWND hwnd)
{ {
RECT rc; RECT rc;
GetClientRect(Hwnd, &rc); GetClientRect(hwnd, &rc);
return rc.bottom; return rc.bottom;
} }