GameLogic - Pre-network merge
This commit is contained in:
parent
d95d771c43
commit
fd3776a53b
|
@ -0,0 +1,2 @@
|
|||
port 15151
|
||||
clients 200
|
|
@ -0,0 +1,4 @@
|
|||
ServerInit ..\Settings\ServerInit.ini
|
||||
More a
|
||||
more b
|
||||
more c
|
|
@ -101,6 +101,7 @@ Global
|
|||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.ActiveCfg = Release|x64
|
||||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.Build.0 = Release|x64
|
||||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.Build.0 = Debug|x64
|
||||
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.ActiveCfg = Release|x64
|
||||
|
@ -112,7 +113,6 @@ Global
|
|||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.ActiveCfg = Release|x64
|
||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.Build.0 = Release|x64
|
||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.Build.0 = Debug|x64
|
||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.ActiveCfg = Release|x64
|
||||
|
@ -124,6 +124,7 @@ Global
|
|||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64
|
||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Release|x64
|
||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Debug|x64
|
||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|x64
|
||||
|
@ -207,6 +208,7 @@ Global
|
|||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.Build.0 = Debug|x64
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
|
@ -229,6 +231,7 @@ Global
|
|||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64
|
||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
|
@ -240,6 +243,7 @@ Global
|
|||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.Build.0 = Debug|x64
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
#include "L_inputClass.h"
|
||||
|
||||
#define DANBIAS_CLIENT
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
|
@ -25,8 +23,6 @@ namespace DanBias
|
|||
DanBiasClientReturn_Sucess,
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct DanBiasGameDesc
|
||||
{
|
||||
//Stuff goes here...
|
||||
|
|
|
@ -71,32 +71,32 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -105,13 +105,13 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -121,13 +121,13 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -139,7 +139,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -147,7 +147,7 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -159,7 +159,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -167,34 +167,16 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Launcher.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\GamePhysics\GamePhysics.vcxproj">
|
||||
<Project>{104fa3e9-94d9-4e1d-a941-28a03bc8a095}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Input\Input.vcxproj">
|
||||
<Project>{7e3990d2-3d94-465c-b58d-64a74b3ecf9b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
||||
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OysterGraphics\OysterGraphics.vcxproj">
|
||||
<Project>{0ec83e64-230e-48ef-b08c-6ac9651b4f82}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OysterMath\OysterMath.vcxproj">
|
||||
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
||||
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DanBiasServer\DanBiasServer.vcxproj">
|
||||
<Project>{52380daa-0f4a-4d97-8e57-98df39319caf}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -4,16 +4,10 @@
|
|||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
|
||||
//#define DANBIAS_SERVER
|
||||
#define DANBIAS_CLIENT
|
||||
#include "DanBiasServerAPI.h"
|
||||
//#include "DanBiasGame.h"
|
||||
|
||||
|
||||
#if defined(DANBIAS_SERVER)
|
||||
#include "IDanBiasServer.h"
|
||||
#elif defined(DANBIAS_CLIENT)
|
||||
#include "DanBiasGame.h"
|
||||
#endif
|
||||
|
||||
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
||||
{
|
||||
#if defined(DANBIAS_SERVER)
|
||||
|
@ -21,14 +15,10 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
|||
{
|
||||
return cmdShow;
|
||||
}
|
||||
// Server starter code goes here
|
||||
DanBias::DanBiasServerDesc desc;
|
||||
desc.port = 0;
|
||||
|
||||
if( DanBias::DanBiasServer::Initiate(desc) == DanBias::DanBiasServerReturn_Sucess)
|
||||
if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess)
|
||||
{
|
||||
DanBias::DanBiasServer::Run();
|
||||
DanBias::DanBiasServer::Release();
|
||||
DanBias::DanBiasServerAPI::Run();
|
||||
DanBias::DanBiasServerAPI::Release();
|
||||
}
|
||||
#elif defined(DANBIAS_CLIENT)
|
||||
if(SetDllDirectory(L"..\\DLL") == FALSE)
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include <Windows.h>
|
||||
#include "DBServer.h"
|
||||
//#include "GameLogic\?"
|
||||
#include "Utilities.h"
|
||||
|
||||
using namespace DanBias;
|
||||
|
||||
DBServer::DBServer()
|
||||
: initiated(0)
|
||||
, running(0)
|
||||
, released(0)
|
||||
{
|
||||
}
|
||||
DBServer::~DBServer()
|
||||
{
|
||||
|
||||
}
|
||||
DanBiasServerReturn DBServer::Create(const DanBias::DanBiasServerDesc& desc)
|
||||
{
|
||||
this->initiated = true;
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
DanBiasServerReturn DBServer::Run()
|
||||
{
|
||||
|
||||
if(this->running)
|
||||
{
|
||||
return DanBiasServerReturn_Error;
|
||||
}
|
||||
if(this->released)
|
||||
{
|
||||
return DanBiasServerReturn_Error;
|
||||
}
|
||||
if(!this->initiated)
|
||||
{
|
||||
return DanBiasServerReturn_Error;
|
||||
}
|
||||
this->running = true;
|
||||
while (this->running)
|
||||
{
|
||||
MessageBox(0, L"What to do here...", L"TYPELESS", 0);
|
||||
|
||||
this->running = false;
|
||||
}
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
DanBiasServerReturn DBServer::Release()
|
||||
{
|
||||
this->released = true;
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_DBSERVER_H
|
||||
#define DANBIASSERVER_DBSERVER_H
|
||||
|
||||
#include "Include\IDanBiasServer.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class DBServer
|
||||
{
|
||||
public:
|
||||
DBServer();
|
||||
~DBServer();
|
||||
|
||||
DanBiasServerReturn Create(const DanBias::DanBiasServerDesc& desc);
|
||||
DanBiasServerReturn Run();
|
||||
DanBiasServerReturn Release();
|
||||
|
||||
private:
|
||||
bool initiated;
|
||||
bool running;
|
||||
bool released;
|
||||
};
|
||||
}// End namspace DanBias
|
||||
#endif // !DANBIASSERVER_DBSERVER_H
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved )
|
||||
{
|
||||
MessageBox(0, L"DanBiasServer Loaded", 0, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -73,28 +73,32 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -102,13 +106,15 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\;$(SolutionDir)Game\</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -117,13 +123,15 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\;$(SolutionDir)Game\</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -134,8 +142,9 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\;$(SolutionDir)Game\</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -143,6 +152,7 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -153,8 +163,9 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\;$(SolutionDir)Game\</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -162,18 +173,28 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="IDanBiasServer.cpp" />
|
||||
<ClCompile Include="Include\DanBiasServerAPI.cpp" />
|
||||
<ClCompile Include="DLLMain.cpp" />
|
||||
<ClCompile Include="DBServer.cpp" />
|
||||
<ClCompile Include="GameServer.cpp" />
|
||||
<ClCompile Include="ServerObjects\ClientObject.cpp" />
|
||||
<ClCompile Include="ServerObjects\Lobby\GameLobby.cpp" />
|
||||
<ClCompile Include="ServerObjects\GameSession.cpp" />
|
||||
<ClCompile Include="ServerObjects\Lobby\MainLobby.cpp" />
|
||||
<ClCompile Include="ServerObjects\NetworkSession.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DBServer.h" />
|
||||
<ClInclude Include="Include\IDanBiasServer.h" />
|
||||
<ClInclude Include="Include\ServerWrapper.h" />
|
||||
<ClInclude Include="MainLobby.h" />
|
||||
<ClInclude Include="GameServer.h" />
|
||||
<ClInclude Include="Include\DanBiasServerAPI.h" />
|
||||
<ClInclude Include="ServerInitReader.h" />
|
||||
<ClInclude Include="ServerObjects\ClientObject.h" />
|
||||
<ClInclude Include="ServerObjects\GameSession.h" />
|
||||
<ClInclude Include="ServerObjects\Lobby\GameLobby.h" />
|
||||
<ClInclude Include="ServerObjects\Lobby\MainLobby.h" />
|
||||
<ClInclude Include="ServerObjects\NetworkSession.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include <Windows.h>
|
||||
#include <WindowShell.h>
|
||||
|
||||
#include "GameServer.h"
|
||||
#include "Utilities.h"
|
||||
#include "ServerInitReader.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
using namespace Oyster::Network;
|
||||
|
||||
//void GameServer::ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient)
|
||||
//{
|
||||
// if(
|
||||
//}
|
||||
void GameServer::ClientConnectCallback(NetworkClient &client)
|
||||
{
|
||||
|
||||
}
|
||||
GameServer::GameServer()
|
||||
: initiated(0)
|
||||
, running(0)
|
||||
, released(0)
|
||||
, maxClients(0)
|
||||
, mainLobby(0)
|
||||
, server(0)
|
||||
{
|
||||
}
|
||||
GameServer::~GameServer()
|
||||
{
|
||||
|
||||
}
|
||||
DanBiasServerReturn GameServer::Create()
|
||||
{
|
||||
this->server = new NetworkServer();
|
||||
this->mainLobby = new MainLobby();
|
||||
|
||||
InitData data;
|
||||
if(!LoadIniFile(data)) return DanBiasServerReturn_Error;
|
||||
|
||||
NetworkServer::INIT_DESC serverDesc;
|
||||
serverDesc.port = data.port;
|
||||
this->maxClients = data.clients;
|
||||
serverDesc.callback = this;
|
||||
|
||||
if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error;
|
||||
if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error;
|
||||
if(!WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC())) return DanBiasServerReturn_Error;
|
||||
|
||||
this->initiated = true;
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
DanBiasServerReturn GameServer::Run()
|
||||
{
|
||||
if(this->running) return DanBiasServerReturn_Error;
|
||||
if(this->released) return DanBiasServerReturn_Error;
|
||||
if(!this->initiated) return DanBiasServerReturn_Error;
|
||||
|
||||
this->running = true;
|
||||
while (this->running)
|
||||
{
|
||||
if(!WindowShell::Frame())
|
||||
break;
|
||||
}
|
||||
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
DanBiasServerReturn GameServer::Release()
|
||||
{
|
||||
this->released = true;
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
|
||||
bool GameServer::LoadIniFile(InitData& ini)
|
||||
{
|
||||
std::ifstream in;
|
||||
std::string f = GetInitPath(InitPath_ServerIni);
|
||||
in.open(f, std::ios::in);
|
||||
if(!in.is_open()) return false;
|
||||
|
||||
std::string buffer;
|
||||
while (!in.eof())
|
||||
{
|
||||
in >> buffer;
|
||||
|
||||
if(buffer == "port")
|
||||
{
|
||||
in >> ini.port;
|
||||
}
|
||||
else if(buffer == "clients")
|
||||
{
|
||||
in >> ini.clients;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
in.close();
|
||||
return true;
|
||||
}
|
||||
}//End namespace DanBias
|
|
@ -0,0 +1,46 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_GAME_SERVER_H
|
||||
#define DANBIASSERVER_GAME_SERVER_H
|
||||
|
||||
#include <vld.h>
|
||||
|
||||
#include "Include\DanBiasServerAPI.h"
|
||||
#include "ServerObjects\Lobby\MainLobby.h"
|
||||
#include <NetworkServer.h>
|
||||
#include <NetworkCallbackHelper.h>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameServer :public Oyster::Network::ClientConnectedObject
|
||||
{
|
||||
public:
|
||||
GameServer();
|
||||
~GameServer();
|
||||
|
||||
DanBiasServerReturn Create();
|
||||
DanBiasServerReturn Run();
|
||||
DanBiasServerReturn Release();
|
||||
|
||||
private:
|
||||
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
|
||||
void ClientConnectCallback(Oyster::Network::NetworkClient &client) override;
|
||||
|
||||
bool initiated;
|
||||
bool running;
|
||||
bool released;
|
||||
int maxClients;
|
||||
MainLobby *mainLobby;
|
||||
Oyster::Network::NetworkServer *server;
|
||||
|
||||
private:
|
||||
struct InitData
|
||||
{
|
||||
int port;
|
||||
int clients;
|
||||
};
|
||||
bool LoadIniFile(InitData&);
|
||||
};
|
||||
}// End namspace DanBias
|
||||
#endif // !DANBIASSERVER_DBSERVER_H
|
|
@ -1,26 +1,26 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "Include\IDanBiasServer.h"
|
||||
#include "DBServer.h"
|
||||
#include "DanBiasServerAPI.h"
|
||||
#include "..\GameServer.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
|
||||
#pragma region Server Data
|
||||
static DBServer server;
|
||||
static GameServer server;
|
||||
#pragma endregion
|
||||
|
||||
|
||||
DanBiasServerReturn DanBiasServer::Initiate(DanBiasServerDesc& desc)
|
||||
DanBiasServerReturn DanBiasServerAPI::Initiate()
|
||||
{
|
||||
return server.Create(desc);
|
||||
return server.Create();
|
||||
}
|
||||
DanBiasServerReturn DanBiasServer::Run()
|
||||
DanBiasServerReturn DanBiasServerAPI::Run()
|
||||
{
|
||||
return server.Run();
|
||||
}
|
||||
DanBiasServerReturn DanBiasServer::Release()
|
||||
DanBiasServerReturn DanBiasServerAPI::Release()
|
||||
{
|
||||
return server.Release();
|
||||
}
|
|
@ -4,16 +4,15 @@
|
|||
#ifndef DANBIAS_SERVER_DANBIAS_SERVER_H
|
||||
#define DANBIAS_SERVER_DANBIAS_SERVER_H
|
||||
|
||||
#define DANBIAS_SERVER
|
||||
|
||||
#if defined (DANBIAS_SERVER_DLL_EXPORT)
|
||||
#ifdef DANBIAS_SERVER_DLL_EXPORT
|
||||
#define DANBIAS_SERVER_DLL __declspec(dllexport)
|
||||
#else
|
||||
#define DANBIAS_SERVER_DLL __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
extern "C"
|
||||
{
|
||||
enum DanBiasServerReturn
|
||||
{
|
||||
|
@ -21,20 +20,15 @@ namespace DanBias
|
|||
DanBiasServerReturn_Sucess,
|
||||
};
|
||||
|
||||
struct DanBiasServerDesc
|
||||
extern "C"
|
||||
{
|
||||
//Stuff goes here...
|
||||
int port;
|
||||
};
|
||||
|
||||
class DANBIAS_SERVER_DLL DanBiasServer
|
||||
class DANBIAS_SERVER_DLL DanBiasServerAPI
|
||||
{
|
||||
public:
|
||||
static DanBiasServerReturn Initiate(DanBiasServerDesc& desc);
|
||||
static DanBiasServerReturn Initiate();
|
||||
static DanBiasServerReturn Run();
|
||||
static DanBiasServerReturn Release();
|
||||
};
|
||||
|
||||
};//End class DanBiasServer
|
||||
}//End Extern "C"
|
||||
} //End namspace DanBias
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef NETWORK_SERVER_WRAPPER_H
|
||||
#define NETWORK_SERVER_WRAPPER_H
|
||||
|
||||
|
||||
class SingletonServer
|
||||
{
|
||||
public:
|
||||
|
||||
struct INIT_DESC
|
||||
{
|
||||
bool l;
|
||||
};
|
||||
void CreateServer(/*DATA*/);
|
||||
void StartServer(/*DATA*/);
|
||||
void StopServer(/*DATA*/);
|
||||
void TerminateServer(/*DATA*/);
|
||||
|
||||
void AttachLobby(/*LOBBY*/);
|
||||
void DetachLobby(/*LOBBY*/);
|
||||
void KickClient(/*CLIENT*/);
|
||||
};
|
||||
|
||||
#endif // !NETWORK_SERVER_WRAPPER_H
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef DANBIASGAME_GAMELOBBY_H
|
||||
#define DANBIASGAME_GAMELOBBY_H
|
||||
|
||||
#include "Include\ServerWrapper.h"
|
||||
|
||||
class MainLobby :public SingletonServer
|
||||
{
|
||||
public:
|
||||
MainLobby();
|
||||
~MainLobby();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef DANBIASSERVER_SERVER_INIT_READER_H
|
||||
#define DANBIASSERVER_SERVER_INIT_READER_H
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
enum InitPath
|
||||
{
|
||||
InitPath_ServerIni,
|
||||
};
|
||||
std::string GetInitPath(InitPath file)
|
||||
{
|
||||
std::string type = "";
|
||||
std::string path = "";
|
||||
std::string flag = "";
|
||||
|
||||
switch (file)
|
||||
{
|
||||
case DanBias::InitPath_ServerIni:
|
||||
flag = "ServerInit";
|
||||
break;
|
||||
}
|
||||
|
||||
std::fstream in;
|
||||
in.open("..\\Settings\\serversearchpath.ini", std::ios::in);
|
||||
if(!in.is_open()) return "";
|
||||
|
||||
while (!in.eof() && type != flag)
|
||||
{
|
||||
in >> type;
|
||||
in >> path;
|
||||
}
|
||||
|
||||
in.close();
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !DANBIASSERVER_SERVER_INIT_READER_H
|
|
@ -0,0 +1,12 @@
|
|||
#include "ClientObject.h"
|
||||
|
||||
using namespace DanBias;
|
||||
|
||||
ClientObject::ClientObject()
|
||||
{
|
||||
}
|
||||
ClientObject::~ClientObject()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef DANBIASSERVER_CLIENT_OBJECT_H
|
||||
#define DANBIASSERVER_CLIENT_OBJECT_H
|
||||
|
||||
#include "NetworkClient.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class ClientObject
|
||||
{
|
||||
public:
|
||||
ClientObject();
|
||||
~ClientObject();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}//End namespace DanBias
|
||||
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
|
||||
|
||||
}//End namespace DanBias
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef DANBIASSERVER_GAME_SESSION_H
|
||||
#define DANBIASSERVER_GAME_SESSION_H
|
||||
|
||||
#include "NetworkSession.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameSession :public NetworkSession
|
||||
{
|
||||
public:
|
||||
GameSession();
|
||||
~GameSession();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};//End GameSession
|
||||
}//End namespace DanBias
|
||||
#endif // !DANBIASSERVER_GAME_SESSION_H
|
|
@ -0,0 +1,18 @@
|
|||
#include "GameLobby.h"
|
||||
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
GameLobby::GameLobby()
|
||||
{
|
||||
|
||||
}
|
||||
GameLobby::~GameLobby()
|
||||
{
|
||||
|
||||
}
|
||||
void GameLobby::Release()
|
||||
{
|
||||
|
||||
}
|
||||
}//End namespace DanBias
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef DANBIASSERVER_GAME_LOBBY_H
|
||||
#define DANBIASSERVER_GAME_LOBBY_H
|
||||
|
||||
#include "..\NetworkSession.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameLobby :public NetworkSession
|
||||
{
|
||||
public:
|
||||
GameLobby();
|
||||
~GameLobby();
|
||||
void Release();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
}//End namespace DanBias
|
||||
|
||||
#endif // !DANBIASSERVER_GAME_LOBBY_H
|
|
@ -0,0 +1,18 @@
|
|||
#include "MainLobby.h"
|
||||
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
MainLobby::MainLobby()
|
||||
{
|
||||
|
||||
}
|
||||
MainLobby::~MainLobby()
|
||||
{
|
||||
|
||||
}
|
||||
void MainLobby::Release()
|
||||
{
|
||||
|
||||
}
|
||||
}//End namespace DanBias
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef DANBIASGAME_GAMELOBBY_H
|
||||
#define DANBIASGAME_GAMELOBBY_H
|
||||
|
||||
#include "..\NetworkSession.h"
|
||||
#include <thread>
|
||||
#include <future>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class MainLobby :public NetworkSession
|
||||
{
|
||||
public:
|
||||
MainLobby();
|
||||
~MainLobby();
|
||||
void Release();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
}//End namespace DanBias
|
||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
|
@ -0,0 +1,36 @@
|
|||
#include "NetworkSession.h"
|
||||
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
NetworkSession::NetworkSession()
|
||||
{
|
||||
}
|
||||
NetworkSession::~NetworkSession()
|
||||
{
|
||||
}
|
||||
|
||||
void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||
{
|
||||
}
|
||||
void NetworkSession::DetachClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||
{
|
||||
}
|
||||
void NetworkSession::DetachClient(short ID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NetworkSession::Kick(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||
{
|
||||
}
|
||||
void NetworkSession::Kick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Oyster::Network::NetworkClient* NetworkSession::operator[](int Identification)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}//End namespace DanBias
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef DANBIASSERVER_NETWORK_SESSION_H
|
||||
#define DANBIASSERVER_NETWORK_SESSION_H
|
||||
|
||||
#include "Utilities.h"
|
||||
#include "ClientObject.h"
|
||||
#include <PlayerProtocols.h>
|
||||
#include <vector>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class NetworkSession
|
||||
{
|
||||
public:
|
||||
NetworkSession();
|
||||
~NetworkSession();
|
||||
|
||||
void AttachClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client);
|
||||
|
||||
void DetachClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client);
|
||||
void DetachClient(short ID);
|
||||
|
||||
void Kick(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client);
|
||||
void Kick();
|
||||
|
||||
void Send(Network::CustomNetProtocol& protocol);
|
||||
void Send(Network::CustomNetProtocol& protocol, int ID);
|
||||
|
||||
//TODO: Do more lobby features
|
||||
|
||||
protected:
|
||||
Oyster::Network::NetworkClient* operator[](int Identification);
|
||||
|
||||
private:
|
||||
std::vector<Utility::DynamicMemory::SmartPointer<ClientObject>> clients;
|
||||
};
|
||||
}//End namespace DanBias
|
||||
#endif // !DANBIASSERVER_NETWORK_SESSION_H
|
|
@ -1,7 +1,12 @@
|
|||
//////////////////////////////////////////////////////////
|
||||
// Created 2013 //
|
||||
// Dennis Andersen, Linda Andersson //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H
|
||||
#define GAMELOGIC_PLAYER_PROTOCOLS_H
|
||||
|
||||
#include "CustomNetProtocol.h"
|
||||
#include <CustomNetProtocol.h>
|
||||
#include "ProtocolIdentificationID.h"
|
||||
|
||||
|
||||
|
@ -20,24 +25,24 @@ namespace GameLogic
|
|||
|
||||
Protocol_PlayerMovement()
|
||||
{
|
||||
protocol[0]->value = ProtocolID = protocol_PlayerNavigation;
|
||||
this->protocol[0].value = ProtocolID = protocol_PlayerNavigation;
|
||||
|
||||
protocol[0]->type = Network::NetAttributeType_Int;
|
||||
protocol[1]->type = Network::NetAttributeType_Bool;
|
||||
protocol[2]->type = Network::NetAttributeType_Bool;
|
||||
protocol[3]->type = Network::NetAttributeType_Bool;
|
||||
protocol[4]->type = Network::NetAttributeType_Bool;
|
||||
protocol[5]->type = Network::NetAttributeType_Bool;
|
||||
protocol[6]->type = Network::NetAttributeType_Bool;
|
||||
this->protocol[0].type = Network::NetAttributeType_Int;
|
||||
this->protocol[1].type = Network::NetAttributeType_Bool;
|
||||
this->protocol[2].type = Network::NetAttributeType_Bool;
|
||||
this->protocol[3].type = Network::NetAttributeType_Bool;
|
||||
this->protocol[4].type = Network::NetAttributeType_Bool;
|
||||
this->protocol[5].type = Network::NetAttributeType_Bool;
|
||||
this->protocol[6].type = Network::NetAttributeType_Bool;
|
||||
}
|
||||
Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
protocol[1]->value = bForward;
|
||||
protocol[2]->value = bBackward;
|
||||
protocol[3]->value = bTurnLeft;
|
||||
protocol[4]->value = bTurnRight;
|
||||
protocol[5]->value = bStrafeRight;
|
||||
protocol[6]->value = bStrafeRight;
|
||||
this->protocol[1].value = bForward;
|
||||
this->protocol[2].value = bBackward;
|
||||
this->protocol[3].value = bTurnLeft;
|
||||
this->protocol[4].value = bTurnRight;
|
||||
this->protocol[5].value = bStrafeRight;
|
||||
this->protocol[6].value = bStrafeRight;
|
||||
|
||||
return &protocol;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
|
||||
|
||||
#define protocol_PlayerNavigation 0;
|
||||
#define protocol_PlayerNavigation 0
|
||||
|
||||
#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H
|
||||
|
|
|
@ -1,87 +1,87 @@
|
|||
#include "WindowShell.h"
|
||||
#include <vector>
|
||||
|
||||
// debug window include
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
struct ChildWin;
|
||||
struct _PrSt;
|
||||
|
||||
#pragma region Declarations
|
||||
|
||||
namespace
|
||||
{
|
||||
//Private data
|
||||
static WindowShell* instance = NULL;
|
||||
int childIdCounter = 0;
|
||||
_PrSt *pData = NULL;
|
||||
}
|
||||
|
||||
struct ChildWin
|
||||
{
|
||||
int id;
|
||||
HWND hWnd;
|
||||
|
||||
ChildWin()
|
||||
{
|
||||
hWnd = NULL;
|
||||
childIdCounter++;
|
||||
id = childIdCounter;
|
||||
}
|
||||
int ID() const { return id; }
|
||||
};
|
||||
struct _PrSt
|
||||
struct _PrivateDataContainer
|
||||
{
|
||||
HINSTANCE hIns;
|
||||
HWND hWnd;
|
||||
std::vector<ChildWin> childWindows;
|
||||
HWND parent;
|
||||
bool consoleWindow;
|
||||
WNDPROC callback;
|
||||
const wchar_t* windowClassName;
|
||||
_PrivateDataContainer()
|
||||
: hIns(0)
|
||||
, hWnd(0)
|
||||
, parent(0)
|
||||
, consoleWindow(0)
|
||||
{ }
|
||||
~_PrivateDataContainer() { if(this->consoleWindow) FreeConsole(); }
|
||||
|
||||
_PrSt()
|
||||
{
|
||||
hIns = NULL;
|
||||
hWnd = NULL;
|
||||
}
|
||||
};
|
||||
} __windowShellData;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
|
||||
WindowShell::WindowShell()
|
||||
LRESULT CALLBACK DefaultWindowCallback(HWND h, UINT m, WPARAM w, LPARAM l)
|
||||
{
|
||||
pData = new _PrSt();
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch (m)
|
||||
{
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(h, &ps);
|
||||
EndPaint(h, &ps);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch(w)
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
WindowShell::~WindowShell()
|
||||
{
|
||||
delete pData;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool WindowShell::createWin(WINDOW_INIT_DESC &desc)
|
||||
{
|
||||
if(pData->hWnd)
|
||||
{
|
||||
MessageBox(0, L"There is already a window registered\nPlease use child windows to create more windows!" ,L"Error", 0);
|
||||
return false;
|
||||
}
|
||||
if(!desc.windowProcCallback)
|
||||
{
|
||||
MessageBox(0, L"No callback function for window messages was found!" ,L"Error", 0);
|
||||
return false;
|
||||
}
|
||||
if(desc.windowSize.x < 0 || desc.windowSize.y < 0)
|
||||
{
|
||||
MessageBox(0, L"Size specified for window is invalid!" ,L"Error", 0);
|
||||
return false;
|
||||
return DefWindowProc(h, m, w, l);
|
||||
}
|
||||
|
||||
if(!desc.hInstance)
|
||||
HINSTANCE WindowShell::GetHINSTANCE()
|
||||
{
|
||||
desc.hInstance = GetModuleHandle(0);
|
||||
return __windowShellData.hIns;
|
||||
}
|
||||
HWND WindowShell::GetHWND()
|
||||
{
|
||||
return __windowShellData.hWnd;
|
||||
}
|
||||
HWND WindowShell::GetParent()
|
||||
{
|
||||
return __windowShellData.parent;
|
||||
}
|
||||
bool WindowShell::CreateWin(WINDOW_INIT_DESC &desc)
|
||||
{
|
||||
if(__windowShellData.hWnd) return false;
|
||||
if(!desc.windowProcCallback) desc.windowProcCallback = DefaultWindowCallback;
|
||||
if(!desc.hInstance) desc.hInstance = GetModuleHandle(0);
|
||||
if(desc.windowSize.x <= 0) desc.windowSize.x = 50;
|
||||
if(desc.windowSize.y <= 0) desc.windowSize.y = 50;
|
||||
|
||||
|
||||
pData->hIns = desc.hInstance;
|
||||
|
||||
__windowShellData.parent = desc.parent;
|
||||
__windowShellData.hIns = desc.hInstance;
|
||||
__windowShellData.windowClassName = L"MainWindowShellClassName";
|
||||
|
||||
#pragma region Register
|
||||
|
||||
|
@ -92,12 +92,12 @@ bool WindowShell::createWin(WINDOW_INIT_DESC &desc)
|
|||
wc.lpfnWndProc = desc.windowProcCallback;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = pData->hIns;
|
||||
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wc.lpszMenuName = 0;
|
||||
wc.lpszClassName = L"MainWindowClass";
|
||||
wc.hInstance = __windowShellData.hIns;
|
||||
wc.hIcon = desc.icon;
|
||||
wc.hCursor = desc.cursor;
|
||||
wc.hbrBackground = desc.background;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = __windowShellData.windowClassName;
|
||||
|
||||
if( !RegisterClassEx(&wc) )
|
||||
{
|
||||
|
@ -110,23 +110,70 @@ bool WindowShell::createWin(WINDOW_INIT_DESC &desc)
|
|||
#pragma region Create window
|
||||
|
||||
|
||||
pData->hWnd = CreateWindow(
|
||||
L"MainWindowClass" ,
|
||||
desc.windowName.c_str(),
|
||||
desc.windowStyle,
|
||||
RECT rectW;
|
||||
int width;
|
||||
int height;
|
||||
DWORD style = desc.windowStyle;
|
||||
bool windowed = false;
|
||||
|
||||
width = desc.windowSize.x + GetSystemMetrics(SM_CXFIXEDFRAME)*2;
|
||||
height = desc.windowSize.y + GetSystemMetrics(SM_CYFIXEDFRAME)*2 + GetSystemMetrics(SM_CYCAPTION);
|
||||
|
||||
rectW.left=(GetSystemMetrics(SM_CXSCREEN)-width)/2;
|
||||
rectW.top=(GetSystemMetrics(SM_CYSCREEN)-height)/2;
|
||||
rectW.right=rectW.left+width;
|
||||
rectW.bottom=rectW.top+height;
|
||||
|
||||
|
||||
if(__windowShellData.parent)
|
||||
{
|
||||
rectW.left = 0;
|
||||
rectW.top = 0;
|
||||
rectW.right = desc.windowSize.x;
|
||||
rectW.bottom = desc.windowSize.y;
|
||||
style = WS_CHILD | WS_VISIBLE;
|
||||
windowed = true;
|
||||
}
|
||||
|
||||
if(windowed)
|
||||
{
|
||||
__windowShellData.hWnd = CreateWindowEx(
|
||||
0,
|
||||
__windowShellData.windowClassName ,
|
||||
desc.windowName,
|
||||
style,
|
||||
rectW.left,
|
||||
rectW.top,
|
||||
rectW.right - rectW.left,
|
||||
rectW.bottom - rectW.top,
|
||||
__windowShellData.parent,
|
||||
NULL,
|
||||
__windowShellData.hIns,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
__windowShellData.hWnd = CreateWindowEx(
|
||||
0,
|
||||
__windowShellData.windowClassName ,
|
||||
desc.windowName,
|
||||
style,
|
||||
desc.windowPosition.x,
|
||||
desc.windowPosition.y,
|
||||
desc.windowSize.x,
|
||||
desc.windowSize.y,
|
||||
0,
|
||||
0,
|
||||
pData->hIns,
|
||||
__windowShellData.hIns,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
if( !pData->hWnd )
|
||||
if( !__windowShellData.hWnd )
|
||||
{
|
||||
MessageBox(0, L"Failed to create window", L"Error!", 0);
|
||||
printf("Failed to create window handle : Code ( %ul )", GetLastError());
|
||||
//MessageBox(0, L"Failed to create window", L"Error!", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -134,144 +181,60 @@ bool WindowShell::createWin(WINDOW_INIT_DESC &desc)
|
|||
|
||||
|
||||
//Show and update window
|
||||
ShowWindow(pData->hWnd, SW_SHOW);
|
||||
UpdateWindow(pData->hWnd);
|
||||
ShowWindow(__windowShellData.hWnd, SW_SHOW);
|
||||
UpdateWindow(__windowShellData.hWnd);
|
||||
|
||||
return true;
|
||||
}
|
||||
int WindowShell::createChildWin(CHILD_WINDOW_INIT_DESC &desc)
|
||||
bool WindowShell::CreateConsoleWindow(bool redirectStdOut, const wchar_t* title)
|
||||
{
|
||||
ChildWin win;
|
||||
// allocate a console for this app
|
||||
if(AllocConsole() == FALSE) return false;
|
||||
|
||||
|
||||
char idStr[3];
|
||||
_itoa_s(win.id, idStr, 10);
|
||||
std::string next = idStr;
|
||||
std::wstring str = std::wstring(next.begin(), next.end());
|
||||
std::wstring childClassName = L"ChildWindow_";
|
||||
childClassName += str;
|
||||
|
||||
WNDCLASSEX wcex;
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = CS_VREDRAW;
|
||||
wcex.lpfnWndProc = desc.windowProcCallback;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = pData->hIns;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = childClassName.c_str();
|
||||
wcex.hIconSm = NULL;
|
||||
|
||||
if(!RegisterClassEx(&wcex))
|
||||
if(redirectStdOut)
|
||||
{
|
||||
MessageBox(0, L"", 0, 0);
|
||||
// redirect unbuffered STDOUT to the console
|
||||
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT);
|
||||
FILE *fp = _fdopen( fileDescriptor, "w" );
|
||||
*stdout = *fp;
|
||||
setvbuf( stdout, NULL, _IONBF, 0 );
|
||||
|
||||
|
||||
// give the console window a bigger buffer size
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) )
|
||||
{
|
||||
COORD bufferSize;
|
||||
bufferSize.X = csbi.dwSize.X;
|
||||
bufferSize.Y = 50;
|
||||
SetConsoleScreenBufferSize(consoleHandle, bufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
if(!desc.style)
|
||||
desc.style = WS_EX_CLIENTEDGE;
|
||||
// give the console window a nicer title
|
||||
SetConsoleTitle(title);
|
||||
|
||||
win.hWnd = CreateWindowEx
|
||||
(
|
||||
desc.style,
|
||||
childClassName.c_str(),
|
||||
desc.name.c_str(),
|
||||
WS_CAPTION | WS_SYSMENU ,
|
||||
desc.topLeftPos.x, desc.topLeftPos.y,
|
||||
desc.windowSize.x, desc.windowSize.y,
|
||||
pData->hWnd,
|
||||
NULL,
|
||||
pData->hIns,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
if (win.hWnd)
|
||||
{
|
||||
pData->childWindows.push_back(win);
|
||||
ShowWindow(win.hWnd, 5);
|
||||
UpdateWindow(win.hWnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
MessageBox(0, L"Failed to create child window", L"Error!", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
return win.id;
|
||||
}
|
||||
bool WindowShell::removeChild(int id)
|
||||
{
|
||||
for (int i = 0; i < (int)pData->childWindows.size(); i++)
|
||||
{
|
||||
if(id == pData->childWindows[i].id)
|
||||
{
|
||||
pData->childWindows.erase(pData->childWindows.begin() + i);
|
||||
return true;
|
||||
}
|
||||
bool WindowShell::Frame()
|
||||
{
|
||||
MSG msg = {0};
|
||||
while (true)
|
||||
{
|
||||
if(!__windowShellData.parent)
|
||||
{
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_QUIT) return false;
|
||||
|
||||
DispatchMessage(&msg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
bool WindowShell::removeChild(HWND hwnd)
|
||||
{
|
||||
for (int i = 0; i < (int)pData->childWindows.size(); i++)
|
||||
{
|
||||
if(hwnd == pData->childWindows[i].hWnd)
|
||||
{
|
||||
pData->childWindows.erase(pData->childWindows.begin() + i);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const HINSTANCE WindowShell::getHINSTANCE() const
|
||||
{
|
||||
return pData->hIns;
|
||||
}
|
||||
const HWND WindowShell::getHWND() const
|
||||
{
|
||||
return pData->hWnd;
|
||||
}
|
||||
const HWND WindowShell::getChildHWND(int id) const
|
||||
{
|
||||
for(int i = 0; i<(int)pData->childWindows.size(); i++)
|
||||
{
|
||||
if(id == pData->childWindows[i].id)
|
||||
return pData->childWindows[i].hWnd;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
const int WindowShell::getChildID(HWND hwnd) const
|
||||
{
|
||||
for(int i = 0; i<(int)pData->childWindows.size(); i++)
|
||||
{
|
||||
if(hwnd == pData->childWindows[i].hWnd)
|
||||
return pData->childWindows[i].id;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
WindowShell* WindowShell::self()
|
||||
{
|
||||
if(!instance)
|
||||
instance = new WindowShell();
|
||||
|
||||
return instance;
|
||||
}
|
||||
void WindowShell::destroy()
|
||||
{
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
#ifndef GLARE_WINDOW_H
|
||||
#define GLARE_WINDOW_H
|
||||
//////////////////////////////////////////////////////////
|
||||
// Created 2013 //
|
||||
// Dennis Andersen, Linda Andersson //
|
||||
//////////////////////////////////////////////////////////
|
||||
#ifndef WINDOWMANAGER_WINDOWSHELL_H
|
||||
#define WINDOWMANAGER_WINDOWSHELL_H
|
||||
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
class WindowShell
|
||||
|
@ -10,16 +13,24 @@ class WindowShell
|
|||
public:
|
||||
struct WINDOW_INIT_DESC
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
std::wstring windowName;
|
||||
POINT windowSize;
|
||||
POINT windowPosition;
|
||||
WNDPROC windowProcCallback;
|
||||
UINT windowClassStyle;
|
||||
UINT windowStyle;
|
||||
HWND parent; //!< Optional
|
||||
HINSTANCE hInstance; //!< Optional
|
||||
WNDPROC windowProcCallback; //!< Optional
|
||||
|
||||
const wchar_t* windowName; //!< Optional
|
||||
POINT windowSize; //!< Optional
|
||||
POINT windowPosition; //!< Optional
|
||||
|
||||
UINT windowClassStyle; //!< Optional
|
||||
UINT windowStyle; //!< Optional
|
||||
|
||||
HICON icon; //!< Optional
|
||||
HCURSOR cursor; //!< Optional
|
||||
HBRUSH background; //!< Optional
|
||||
|
||||
WINDOW_INIT_DESC()
|
||||
{
|
||||
parent = 0;
|
||||
hInstance = NULL;
|
||||
windowName = L"MADAFACKA";
|
||||
windowSize.x = 800;
|
||||
|
@ -28,58 +39,24 @@ class WindowShell
|
|||
windowPosition.y = 0;
|
||||
windowProcCallback = NULL;
|
||||
windowClassStyle = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
windowStyle = WS_OVERLAPPEDWINDOW;
|
||||
windowStyle = WS_POPUPWINDOW|WS_SYSMENU|WS_CAPTION;
|
||||
//windowStyle = WS_OVERLAPPEDWINDOW;
|
||||
icon = LoadIcon(0, IDI_APPLICATION);
|
||||
cursor = LoadCursor(NULL, IDC_ARROW);
|
||||
background = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
//background = (HBRUSH)GetStockObject(BACKGROUND_BLUE);(HBRUSH)(COLOR_WINDOW+1);
|
||||
}
|
||||
};
|
||||
struct CHILD_WINDOW_INIT_DESC
|
||||
{
|
||||
std::wstring name;
|
||||
DWORD style;
|
||||
POINT topLeftPos;
|
||||
POINT windowSize;
|
||||
WNDPROC windowProcCallback;
|
||||
|
||||
CHILD_WINDOW_INIT_DESC()
|
||||
{
|
||||
name = L"Child Window";
|
||||
style = WS_CHILD;
|
||||
memset(&topLeftPos, 0, sizeof(POINT));
|
||||
windowSize.x = 300;
|
||||
windowSize.y = 200;
|
||||
windowProcCallback = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
WindowShell ();
|
||||
WindowShell (const WindowShell&);
|
||||
void operator= (const WindowShell&);
|
||||
virtual~WindowShell ();
|
||||
|
||||
public:
|
||||
const HINSTANCE getHINSTANCE () const;
|
||||
/* Returns NULL if no hwnd exists */
|
||||
const HWND getHWND () const;
|
||||
/* Returns NULL if not found */
|
||||
const HWND getChildHWND (int id) const;
|
||||
/* Returns -1 if not found */
|
||||
const int getChildID (HWND hwnd) const;
|
||||
static HINSTANCE GetHINSTANCE ();
|
||||
static HWND GetHWND ();
|
||||
static HWND GetParent ();
|
||||
static bool CreateWin (WINDOW_INIT_DESC&);
|
||||
static bool CreateConsoleWindow (bool redirectStdOut = true, const wchar_t* title = L"Debug Output");
|
||||
|
||||
/* Creates an empty window */
|
||||
bool createWin (WINDOW_INIT_DESC&);
|
||||
/*Creates a child window and returns the id of child window or -1 if failed*/
|
||||
int createChildWin (CHILD_WINDOW_INIT_DESC&);
|
||||
/* Removes a child window */
|
||||
bool removeChild (int id);
|
||||
/* Removes a child window */
|
||||
bool removeChild (HWND hwnd);
|
||||
|
||||
|
||||
/* Returns a pointer to this class, dont forget to destroy on exit */
|
||||
static WindowShell* self();
|
||||
/* Deletes the instance */
|
||||
static void destroy();
|
||||
/** Procces window messages if avalible. If the return value was false, the window was destroyed. */
|
||||
static bool Frame ();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue