Merge branch 'GameClient' of https://github.com/dean11/Danbias into GameClientGraphics
This commit is contained in:
commit
273995e204
|
@ -45,6 +45,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameClient", "Game\GameClie
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utilities", "Misc\Utilities\Utilities.vcxproj", "{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utilities", "Misc\Utilities\Utilities.vcxproj", "{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LevelLoader", "Game\LevelLoader\LevelLoader.vcxproj", "{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -679,6 +681,40 @@ Global
|
||||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
|
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
|
||||||
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.RelWithDebInfo|x86.Build.0 = Release|Win32
|
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.RelWithDebInfo|x86.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|Any CPU.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|Win32.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|Win32.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|x64.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|x86.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.MinSizeRel|x86.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|x64.Build.0 = Release|x64
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|Mixed Platforms.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|Win32.Build.0 = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -692,6 +728,7 @@ Global
|
||||||
{C83A6FAD-E71F-4B1E-9D63-E93E61DDC012} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{C83A6FAD-E71F-4B1E-9D63-E93E61DDC012} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
|
{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{C4C76A8D-44C5-4452-9F61-39C7E01CBDB4} = {F156EEBC-0195-4020-8700-4433208DE12B}
|
{C4C76A8D-44C5-4452-9F61-39C7E01CBDB4} = {F156EEBC-0195-4020-8700-4433208DE12B}
|
||||||
{3EA5F14D-2A71-4588-A69D-87C4571C580F} = {F156EEBC-0195-4020-8700-4433208DE12B}
|
{3EA5F14D-2A71-4588-A69D-87C4571C580F} = {F156EEBC-0195-4020-8700-4433208DE12B}
|
||||||
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B} = {1322B12B-5E37-448A-AAAF-F637460DCB23}
|
{7E3990D2-3D94-465C-B58D-64A74B3ECF9B} = {1322B12B-5E37-448A-AAAF-F637460DCB23}
|
||||||
|
|
|
@ -106,7 +106,7 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\OysterMath;$(SolutionDir)Misc\Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc\Utilities;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -196,12 +196,17 @@
|
||||||
<ProjectReference Include="..\GameServer\GameServer.vcxproj">
|
<ProjectReference Include="..\GameServer\GameServer.vcxproj">
|
||||||
<Project>{143bd516-20a1-4890-a3e4-f8bfd02220e7}</Project>
|
<Project>{143bd516-20a1-4890-a3e4-f8bfd02220e7}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\LevelLoader\LevelLoader.vcxproj">
|
||||||
|
<Project>{6391e709-d9fa-4fef-a3b9-4343db5a0c63}</Project>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="DanBiasGame_Impl.cpp" />
|
<ClCompile Include="DanBiasGame_Impl.cpp" />
|
||||||
<ClCompile Include="GameClientState\Camera_Basic.cpp" />
|
<ClCompile Include="GameClientState\Camera_Basic.cpp" />
|
||||||
<ClCompile Include="GameClientState\Camera.cpp" />
|
<ClCompile Include="GameClientState\Camera.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\Camera_BasicV2.cpp" />
|
||||||
<ClCompile Include="GameClientState\Camera_FPS.cpp" />
|
<ClCompile Include="GameClientState\Camera_FPS.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\Camera_FPSV2.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_Light.cpp" />
|
<ClCompile Include="GameClientState\C_Light.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
||||||
|
@ -210,16 +215,15 @@
|
||||||
<ClCompile Include="DLLMain.cpp" />
|
<ClCompile Include="DLLMain.cpp" />
|
||||||
<ClCompile Include="GameClientState\GameClientState.cpp" />
|
<ClCompile Include="GameClientState\GameClientState.cpp" />
|
||||||
<ClCompile Include="GameClientState\GameState.cpp" />
|
<ClCompile Include="GameClientState\GameState.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\GameStateUI.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\GamingUI.cpp" />
|
||||||
<ClCompile Include="GameClientState\LanMenuState.cpp" />
|
<ClCompile Include="GameClientState\LanMenuState.cpp" />
|
||||||
<ClCompile Include="GameClientState\LevelLoader\LevelLoader.cpp" />
|
|
||||||
<ClCompile Include="GameClientState\LevelLoader\LevelParser.cpp" />
|
|
||||||
<ClCompile Include="GameClientState\LevelLoader\Loader.cpp" />
|
|
||||||
<ClCompile Include="GameClientState\LevelLoader\ParseFunctions.cpp" />
|
|
||||||
<ClCompile Include="GameClientState\LobbyAdminState.cpp" />
|
<ClCompile Include="GameClientState\LobbyAdminState.cpp" />
|
||||||
<ClCompile Include="GameClientState\LobbyState.cpp" />
|
<ClCompile Include="GameClientState\LobbyState.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_Object.cpp" />
|
<ClCompile Include="GameClientState\C_Object.cpp" />
|
||||||
<ClCompile Include="GameClientState\MainState.cpp" />
|
<ClCompile Include="GameClientState\MainState.cpp" />
|
||||||
<ClCompile Include="GameClientState\NetLoadState.cpp" />
|
<ClCompile Include="GameClientState\NetLoadState.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\RespawnUI.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="GameClientState\Camera_Basic.h" />
|
<ClInclude Include="GameClientState\Camera_Basic.h" />
|
||||||
|
@ -227,7 +231,9 @@
|
||||||
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />
|
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />
|
||||||
<ClInclude Include="GameClientState\Buttons\ButtonRectangle.h" />
|
<ClInclude Include="GameClientState\Buttons\ButtonRectangle.h" />
|
||||||
<ClInclude Include="GameClientState\Camera.h" />
|
<ClInclude Include="GameClientState\Camera.h" />
|
||||||
|
<ClInclude Include="GameClientState\Camera_BasicV2.h" />
|
||||||
<ClInclude Include="GameClientState\Camera_FPS.h" />
|
<ClInclude Include="GameClientState\Camera_FPS.h" />
|
||||||
|
<ClInclude Include="GameClientState\Camera_FPSV2.h" />
|
||||||
<ClInclude Include="GameClientState\C_Light.h" />
|
<ClInclude Include="GameClientState\C_Light.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
||||||
|
@ -235,15 +241,13 @@
|
||||||
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
|
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
|
||||||
<ClInclude Include="GameClientState\GameClientState.h" />
|
<ClInclude Include="GameClientState\GameClientState.h" />
|
||||||
<ClInclude Include="GameClientState\GameState.h" />
|
<ClInclude Include="GameClientState\GameState.h" />
|
||||||
|
<ClInclude Include="GameClientState\GameStateUI.h" />
|
||||||
|
<ClInclude Include="GameClientState\GamingUI.h" />
|
||||||
<ClInclude Include="GameClientState\LanMenuState.h" />
|
<ClInclude Include="GameClientState\LanMenuState.h" />
|
||||||
<ClInclude Include="GameClientState\LevelLoader\LevelLoader.h" />
|
|
||||||
<ClInclude Include="GameClientState\LevelLoader\LevelParser.h" />
|
|
||||||
<ClInclude Include="GameClientState\LevelLoader\Loader.h" />
|
|
||||||
<ClInclude Include="GameClientState\LevelLoader\ObjectDefines.h" />
|
|
||||||
<ClInclude Include="GameClientState\LevelLoader\ParseFunctions.h" />
|
|
||||||
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
||||||
<ClInclude Include="GameClientState\MainState.h" />
|
<ClInclude Include="GameClientState\MainState.h" />
|
||||||
<ClInclude Include="GameClientState\NetLoadState.h" />
|
<ClInclude Include="GameClientState\NetLoadState.h" />
|
||||||
|
<ClInclude Include="GameClientState\RespawnUI.h" />
|
||||||
<ClInclude Include="GameClientState\SharedStateContent.h" />
|
<ClInclude Include="GameClientState\SharedStateContent.h" />
|
||||||
<ClInclude Include="Include\GameClient.h" />
|
<ClInclude Include="Include\GameClient.h" />
|
||||||
<ClInclude Include="GameClientState\LobbyState.h" />
|
<ClInclude Include="GameClientState\LobbyState.h" />
|
||||||
|
|
|
@ -1,192 +0,0 @@
|
||||||
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
|
|
||||||
#define DANBIAS_CLIENTRECIEVEROBJECT_H
|
|
||||||
|
|
||||||
//WTF!? No headers included???
|
|
||||||
#include "../DanBiasGame/Include/DanBiasGame.h"
|
|
||||||
#include "../GameProtocols/GeneralProtocols.h"
|
|
||||||
#include "../GameProtocols/Protocols.h"
|
|
||||||
#include "../Network/NetworkAPI/NetworkClient.h"
|
|
||||||
#include "GameClientState\GameClientState.h"
|
|
||||||
#include "GameClientState\GameState.h"
|
|
||||||
|
|
||||||
#include <Utilities.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
struct GameRecieverObject : public Oyster::Network::NetworkClient
|
|
||||||
{
|
|
||||||
Client::GameClientState* gameClientState;
|
|
||||||
|
|
||||||
// receiver function for server messages
|
|
||||||
// parsing protocols and sending it to the gameState
|
|
||||||
//void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
|
||||||
void GameRecieverObject::DataRecieved( Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e ) override
|
|
||||||
{
|
|
||||||
Oyster::Network::CustomNetProtocol p = e.args.data.protocol;
|
|
||||||
int pType = p[0].value.netInt;
|
|
||||||
|
|
||||||
//printf("Message(%i) arrived at client(%i)\n", pType, this->GetID());
|
|
||||||
|
|
||||||
|
|
||||||
switch (pType)
|
|
||||||
{
|
|
||||||
case protocol_General_Status:
|
|
||||||
{
|
|
||||||
GameLogic::Protocol_General_Status::States state;
|
|
||||||
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
|
|
||||||
if( state == GameLogic::Protocol_General_Status::States_disconected)
|
|
||||||
{
|
|
||||||
// server disconnected
|
|
||||||
DanBiasGame::Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Gameplay_ObjectCreate:
|
|
||||||
{
|
|
||||||
Client::GameClientState::NewObj protocolData;// = new Client::GameClientState::NewObj;
|
|
||||||
protocolData.object_ID = p[1].value.netInt;
|
|
||||||
protocolData.path = p[2].value.netCharPtr;
|
|
||||||
for(int i = 0; i< 16; i++)
|
|
||||||
{
|
|
||||||
protocolData.worldPos[i] = p[i+3].value.netFloat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
|
||||||
((Client::GameState*)gameClientState)->Protocol(&protocolData);
|
|
||||||
|
|
||||||
//delete p[2].value.netCharPtr; //delete char array
|
|
||||||
//delete protocolData;
|
|
||||||
//protocolData = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Gameplay_ObjectDisabled:
|
|
||||||
{
|
|
||||||
Client::GameClientState::RemoveObj* protocolData = new Client::GameClientState::RemoveObj;
|
|
||||||
protocolData->object_ID = p[1].value.netInt;
|
|
||||||
|
|
||||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
|
||||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
|
||||||
|
|
||||||
delete protocolData;
|
|
||||||
protocolData = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Gameplay_ObjectPosition:
|
|
||||||
{
|
|
||||||
// 0: reserved
|
|
||||||
// 1: objectID
|
|
||||||
// 2,3,4: position
|
|
||||||
// 5,6,7,8: rotation quaternion
|
|
||||||
|
|
||||||
GameLogic::Protocol_ObjectPosition data(p);
|
|
||||||
|
|
||||||
Client::GameClientState::ObjPos protocolData;
|
|
||||||
protocolData.object_ID = data.object_ID;
|
|
||||||
//protocolData.object_ID = p[1].value.netInt;
|
|
||||||
|
|
||||||
for( int i = 0; i < 3; ++i )
|
|
||||||
{
|
|
||||||
protocolData.position[i] = data.position[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
//for(int i = 0; i< 16; i++)
|
|
||||||
//{
|
|
||||||
// protocolData.worldPos[i] = p[i+2].value.netFloat;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
|
||||||
((Client::GameState*)gameClientState)->Protocol(&protocolData);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Gameplay_ObjectPositionRotation:
|
|
||||||
{
|
|
||||||
|
|
||||||
Client::GameClientState::ObjPos protocolData;
|
|
||||||
protocolData.object_ID = p[1].value.netInt;
|
|
||||||
for(int i = 0; i< 16; i++)
|
|
||||||
{
|
|
||||||
protocolData.worldPos[i] = p[i+2].value.netFloat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
|
||||||
((Client::GameState*)gameClientState)->Protocol(&protocolData);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Lobby_Create:
|
|
||||||
{
|
|
||||||
if(dynamic_cast<Client::LobbyState*>(gameClientState))
|
|
||||||
{
|
|
||||||
int id = p.Get(1).value.netInt;
|
|
||||||
std::string name = p.Get(19).value.netCharPtr;
|
|
||||||
Oyster::Math::Float4x4 w;
|
|
||||||
for(int i = 0; i< 16; i++)
|
|
||||||
{
|
|
||||||
w[i] = p[i+2].value.netFloat;
|
|
||||||
}
|
|
||||||
|
|
||||||
gameClientState->Release();
|
|
||||||
delete gameClientState;
|
|
||||||
|
|
||||||
gameClientState = new Client::GameState();
|
|
||||||
gameClientState->Init(this);
|
|
||||||
std::wstring temp;
|
|
||||||
Utility::String::StringToWstring(name, temp);
|
|
||||||
((Client::GameState*)gameClientState)->InitiatePlayer(id, temp, w);
|
|
||||||
|
|
||||||
//Do some wait state?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Lobby_Start:
|
|
||||||
{
|
|
||||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
|
||||||
{
|
|
||||||
//Game state should start in n seconds
|
|
||||||
GameLogic::Protocol_LobbyStartGame p(p);
|
|
||||||
p.seconds;
|
|
||||||
|
|
||||||
//Sleep((int)(p.seconds * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ProtocolIsLobby(p[0].value.netInt)) ParseLobbyProtocol(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p)
|
|
||||||
{
|
|
||||||
switch (p[0].value.netShort)
|
|
||||||
{
|
|
||||||
case protocol_General_Status: //this->GeneralStatus (Protocol_General_Status (p), c);
|
|
||||||
break;
|
|
||||||
case protocol_General_Text: //this->GeneralText (Protocol_General_Text (p), c);
|
|
||||||
break;
|
|
||||||
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
|
|
||||||
//break;
|
|
||||||
case protocol_Lobby_Start: //this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
|
|
||||||
break;
|
|
||||||
//case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
|
|
||||||
//break;
|
|
||||||
case protocol_Lobby_Login: //this->LobbyLogin (Protocol_LobbyLogin (p), c);
|
|
||||||
break;
|
|
||||||
case protocol_Lobby_Refresh: //this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
|
|
||||||
break;
|
|
||||||
case protocol_Lobby_GameData: //this->LobbyGameData (Protocol_LobbyGameData (p), c);
|
|
||||||
{
|
|
||||||
//GameLogic::Protocol_LobbyGameData temp(p);
|
|
||||||
//printf("%s, %i.%i\n", temp.mapName.c_str(), temp.majorVersion, temp.minorVersion);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Lobby_ClientData: //this->LobbyMainData (Protocol_LobbyClientData (p), c);
|
|
||||||
break;
|
|
||||||
//case protocol_Lobby_GameData: this->LobbyGameData (Protocol_LobbyGameData (p), c);
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
#include "Camera_BasicV2.h"
|
||||||
|
|
||||||
|
using namespace ::Oyster::Math3D;
|
||||||
|
|
||||||
|
Camera_BasicV2::Camera_BasicV2()
|
||||||
|
{
|
||||||
|
this->translation = Float3::null;
|
||||||
|
this->rotation = Quaternion::identity;
|
||||||
|
this->projection = Float4x4::identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera_BasicV2::Camera_BasicV2( const Float3 &position, const Quaternion &rotation, const Float4x4 &projection )
|
||||||
|
{
|
||||||
|
this->translation = position;
|
||||||
|
this->rotation = rotation;
|
||||||
|
this->projection = projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera_BasicV2::~Camera_BasicV2() {}
|
||||||
|
|
||||||
|
Camera_BasicV2 & Camera_BasicV2::operator = ( const Camera_BasicV2 &camera )
|
||||||
|
{
|
||||||
|
this->translation = camera.translation;
|
||||||
|
this->rotation = camera.rotation;
|
||||||
|
this->projection = camera.projection;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetPosition( const Float3 &translation )
|
||||||
|
{
|
||||||
|
this->translation = translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetRotation( const Quaternion &rotation )
|
||||||
|
{
|
||||||
|
this->rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetAngular( const Float3 &axis )
|
||||||
|
{
|
||||||
|
this->rotation = Rotation( axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetProjection( const Float4x4 &matrix )
|
||||||
|
{
|
||||||
|
this->projection = matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
ProjectionMatrix_Orthographic( width, height, nearClip, farClip, this->projection );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, this->projection );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::Move( const Float3 &deltaPosition )
|
||||||
|
{
|
||||||
|
this->translation += deltaPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::Rotate( const Quaternion &deltaRotation )
|
||||||
|
{
|
||||||
|
this->rotation *= deltaRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::Rotate( const Float3 &deltaAngularAxis )
|
||||||
|
{
|
||||||
|
this->rotation *= Rotation( deltaAngularAxis );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float3 & Camera_BasicV2::GetPosition() const
|
||||||
|
{
|
||||||
|
return this->translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 & Camera_BasicV2::GetAngularAxis( Float3 &targetMem ) const
|
||||||
|
{
|
||||||
|
return targetMem = AngularAxis( this->rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_BasicV2::GetNormalOf( const Float3 &axis ) const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->rotation, axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Quaternion & Camera_BasicV2::GetRotation() const
|
||||||
|
{
|
||||||
|
return this->rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3x3 & Camera_BasicV2::GetRotationMatrix( Float3x3 &targetMem ) const
|
||||||
|
{
|
||||||
|
return RotationMatrix( this->rotation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_BasicV2::GetRotationMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return RotationMatrix( this->rotation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_BasicV2::GetViewMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return ViewMatrix( this->rotation, this->translation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float4x4 & Camera_BasicV2::GetProjectionMatrix() const
|
||||||
|
{
|
||||||
|
return this->projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_BasicV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return TransformMatrix( this->projection, this->GetViewMatrix(), targetMem );
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef CAMERA_BASIC_V2_H
|
||||||
|
#define CAMERA_BASIC_V2_H
|
||||||
|
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
class Camera_BasicV2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Camera_BasicV2();
|
||||||
|
Camera_BasicV2( const ::Oyster::Math::Float3 &position, const ::Oyster::Math::Quaternion &rotation, const ::Oyster::Math::Float4x4 &projection );
|
||||||
|
virtual ~Camera_BasicV2();
|
||||||
|
|
||||||
|
Camera_BasicV2 & operator = ( const Camera_BasicV2 &camera );
|
||||||
|
|
||||||
|
void SetPosition( const ::Oyster::Math::Float3 &translation );
|
||||||
|
void SetRotation( const ::Oyster::Math::Quaternion &rotation );
|
||||||
|
void SetAngular( const ::Oyster::Math::Float3 &axis );
|
||||||
|
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
|
||||||
|
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
|
||||||
|
void Move( const ::Oyster::Math::Float3 &deltaPosition );
|
||||||
|
void Rotate( const ::Oyster::Math::Quaternion &deltaRotation );
|
||||||
|
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
|
||||||
|
|
||||||
|
const ::Oyster::Math::Float3 & GetPosition() const;
|
||||||
|
::Oyster::Math::Float3 & GetAngularAxis( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||||
|
::Oyster::Math::Float3 GetNormalOf( const ::Oyster::Math::Float3 &axis ) const;
|
||||||
|
const ::Oyster::Math::Quaternion & GetRotation() const;
|
||||||
|
::Oyster::Math::Float3x3 & GetRotationMatrix( ::Oyster::Math::Float3x3 &targetMem ) const;
|
||||||
|
::Oyster::Math::Float4x4 & GetRotationMatrix( ::Oyster::Math::Float4x4 &targetMem ) const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
::Oyster::Math::Float3 translation;
|
||||||
|
mutable ::Oyster::Math::Quaternion rotation;
|
||||||
|
::Oyster::Math::Float4x4 projection;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,186 @@
|
||||||
|
#include "Camera_FPSV2.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
using namespace ::Oyster::Math3D;
|
||||||
|
using namespace ::Utility::Value;
|
||||||
|
|
||||||
|
Camera_FPSV2::Camera_FPSV2()
|
||||||
|
{ // this->head is default set to identity uniformprojection at origo
|
||||||
|
this->pitchUp = 0.0f;
|
||||||
|
this->headOffset =
|
||||||
|
this->body.translation = Float3::null;
|
||||||
|
this->body.rotation = Quaternion::identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera_FPSV2::~Camera_FPSV2() {}
|
||||||
|
|
||||||
|
Camera_FPSV2 & Camera_FPSV2::operator = ( const Camera_FPSV2 &camera )
|
||||||
|
{
|
||||||
|
this->head = camera.head;
|
||||||
|
this->pitchUp = camera.pitchUp;
|
||||||
|
this->headOffset = camera.headOffset;
|
||||||
|
this->body.translation = camera.body.translation;
|
||||||
|
this->body.rotation = camera.body.rotation;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetHeadOffset( const Float3 &translation )
|
||||||
|
{
|
||||||
|
this->head.Move( translation - this->headOffset );
|
||||||
|
this->headOffset = translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetPosition( const Float3 &translation )
|
||||||
|
{
|
||||||
|
this->head.Move( translation - this->body.translation );
|
||||||
|
this->body.translation = translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetRotation( const Quaternion &rotation )
|
||||||
|
{
|
||||||
|
this->body.rotation = rotation;
|
||||||
|
this->head.SetRotation( rotation * Rotation(this->pitchUp, this->GetNormalOf(Float3::standard_unit_x) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetAngular( const Float3 &axis )
|
||||||
|
{
|
||||||
|
this->SetRotation( Rotation(axis) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetProjection( const Float4x4 &matrix )
|
||||||
|
{
|
||||||
|
this->head.SetProjection( matrix );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
this->head.SetOrthographicProjection( width, height, nearClip, farClip );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
this->head.SetPerspectiveProjection( verticalFoV, aspectRatio, nearClip, farClip );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::UpdateOrientation()
|
||||||
|
{
|
||||||
|
Float4x4 orientation;
|
||||||
|
OrientationMatrix( this->body.rotation, this->body.translation, orientation );
|
||||||
|
|
||||||
|
this->head.SetPosition( (orientation * Float4(this->headOffset, 1.0f)).xyz );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SnapUpToNormal( const Float3 &normal )
|
||||||
|
{
|
||||||
|
this->body.rotation = Rotation( SnapAngularAxis(AngularAxis(this->body.rotation), WorldAxisOf(this->body.rotation, Float3::standard_unit_y), normal) );
|
||||||
|
this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp * Float3::standard_unit_x) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::Move( const Float3 &deltaPosition )
|
||||||
|
{
|
||||||
|
this->head.Move( deltaPosition );
|
||||||
|
this->body.translation += deltaPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::Rotate( const Quaternion &deltaRotation )
|
||||||
|
{
|
||||||
|
this->head.Rotate( deltaRotation );
|
||||||
|
this->body.rotation *= deltaRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::Rotate( const Float3 &deltaAngularAxis )
|
||||||
|
{
|
||||||
|
this->Rotate( Rotation(deltaAngularAxis) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::MoveForward( Float distance )
|
||||||
|
{
|
||||||
|
this->MoveBackward( -distance );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::MoveBackward( Float distance )
|
||||||
|
{
|
||||||
|
this->Move( distance * WorldAxisOf(this->body.rotation, Float3::standard_unit_z) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::StrafeRight( Float distance )
|
||||||
|
{
|
||||||
|
this->Move( distance * WorldAxisOf(this->body.rotation, Float3::standard_unit_x) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::StrafeLeft( Float distance )
|
||||||
|
{
|
||||||
|
this->StrafeRight( -distance );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::PitchUp( Float radian )
|
||||||
|
{
|
||||||
|
this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi );
|
||||||
|
this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, Float3::standard_unit_x) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::PitchDown( Float radian )
|
||||||
|
{
|
||||||
|
this->PitchUp( -radian );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::YawRight( Float radian )
|
||||||
|
{
|
||||||
|
this->YawLeft( -radian );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::YawLeft( Float radian )
|
||||||
|
{
|
||||||
|
Quaternion deltaRotation = Rotation( radian, WorldAxisOf(this->body.rotation, Float3::standard_unit_y) );
|
||||||
|
this->Rotate( deltaRotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float3 & Camera_FPSV2::GetHeadOffset() const
|
||||||
|
{
|
||||||
|
return this->headOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float3 & Camera_FPSV2::GetPosition() const
|
||||||
|
{
|
||||||
|
return this->body.translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_FPSV2::GetViewMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return this->head.GetViewMatrix( targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float4x4 & Camera_FPSV2::GetProjectionMatrix() const
|
||||||
|
{
|
||||||
|
return this->head.GetProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_FPSV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return this->head.GetViewsProjMatrix( targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetNormalOf( const Float3 &axis ) const
|
||||||
|
{
|
||||||
|
return this->head.GetNormalOf( axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetRight() const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->body.rotation, Float3::standard_unit_x );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetUp() const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->body.rotation, Float3::standard_unit_y );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetLook() const
|
||||||
|
{
|
||||||
|
return this->head.GetNormalOf( -Float3::standard_unit_z );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetForward() const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->body.rotation, -Float3::standard_unit_z );
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
#ifndef CAMERA_FPSV2_H
|
||||||
|
#define CAMERA_FPSV2_H
|
||||||
|
|
||||||
|
#include "OysterMath.h"
|
||||||
|
#include "Camera_BasicV2.h"
|
||||||
|
|
||||||
|
class Camera_FPSV2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Camera_FPSV2();
|
||||||
|
virtual ~Camera_FPSV2();
|
||||||
|
|
||||||
|
Camera_FPSV2 & operator = ( const Camera_FPSV2 &camera );
|
||||||
|
|
||||||
|
void SetHeadOffset( const ::Oyster::Math::Float3 &translation );
|
||||||
|
void SetPosition( const ::Oyster::Math::Float3 &translation );
|
||||||
|
void SetRotation( const ::Oyster::Math::Quaternion &rotation );
|
||||||
|
void SetAngular( const ::Oyster::Math::Float3 &axis );
|
||||||
|
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
|
||||||
|
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
|
||||||
|
void UpdateOrientation();
|
||||||
|
|
||||||
|
void SnapUpToNormal( const ::Oyster::Math::Float3 &normal );
|
||||||
|
|
||||||
|
void Move( const ::Oyster::Math::Float3 &deltaPosition );
|
||||||
|
void Rotate( const ::Oyster::Math::Quaternion &deltaRotation );
|
||||||
|
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
|
||||||
|
|
||||||
|
void MoveForward( ::Oyster::Math::Float distance );
|
||||||
|
void MoveBackward( ::Oyster::Math::Float distance );
|
||||||
|
void StrafeRight( ::Oyster::Math::Float distance );
|
||||||
|
void StrafeLeft( ::Oyster::Math::Float distance );
|
||||||
|
|
||||||
|
void PitchUp( ::Oyster::Math::Float radian );
|
||||||
|
void PitchDown( ::Oyster::Math::Float radian );
|
||||||
|
void YawRight( ::Oyster::Math::Float radian );
|
||||||
|
void YawLeft( ::Oyster::Math::Float radian );
|
||||||
|
|
||||||
|
const ::Oyster::Math::Float3 & GetHeadOffset() const;
|
||||||
|
const ::Oyster::Math::Float3 & GetPosition() const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
::Oyster::Math::Float3 GetNormalOf( const ::Oyster::Math::Float3 &axis ) const;
|
||||||
|
::Oyster::Math::Float3 GetRight() const;
|
||||||
|
::Oyster::Math::Float3 GetUp() const;
|
||||||
|
::Oyster::Math::Float3 GetLook() const;
|
||||||
|
::Oyster::Math::Float3 GetForward() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Camera_BasicV2 head;
|
||||||
|
::Oyster::Math::Float pitchUp;
|
||||||
|
::Oyster::Math::Float3 headOffset;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
::Oyster::Math::Float3 translation;
|
||||||
|
::Oyster::Math::Quaternion rotation;
|
||||||
|
} body;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,9 +3,14 @@
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
|
const GameClientState::NetEvent GameClientState::event_processed = GameClientState::NetEvent();
|
||||||
|
|
||||||
GameClientState::GameClientState() {}
|
GameClientState::GameClientState() {}
|
||||||
|
|
||||||
GameClientState::~GameClientState() {}
|
GameClientState::~GameClientState() {}
|
||||||
|
|
||||||
void GameClientState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & GameClientState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{ /* do nothing */ }
|
{
|
||||||
|
/* do nothing */
|
||||||
|
return message;
|
||||||
|
}
|
|
@ -22,7 +22,9 @@ namespace DanBias { namespace Client
|
||||||
ClientState_Quit
|
ClientState_Quit
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent;
|
||||||
|
static const NetEvent event_processed;
|
||||||
|
|
||||||
GameClientState();
|
GameClientState();
|
||||||
virtual ~GameClientState();
|
virtual ~GameClientState();
|
||||||
virtual bool Init( SharedStateContent &shared ) = 0;
|
virtual bool Init( SharedStateContent &shared ) = 0;
|
||||||
|
@ -31,7 +33,11 @@ namespace DanBias { namespace Client
|
||||||
virtual bool Release() = 0;
|
virtual bool Release() = 0;
|
||||||
virtual void ChangeState( ClientState next ) = 0;
|
virtual void ChangeState( ClientState next ) = 0;
|
||||||
|
|
||||||
virtual void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
/******************************************************************
|
||||||
|
* @param message of the event
|
||||||
|
* @return message or a reference to GameClientState::event_processed.
|
||||||
|
******************************************************************/
|
||||||
|
virtual const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
};
|
};
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "DllInterfaces/GFXAPI.h"
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "Camera_FPS.h"
|
#include "Camera_FPSV2.h"
|
||||||
#include <GameServerAPI.h>
|
#include <GameServerAPI.h>
|
||||||
#include "C_Light.h"
|
#include "C_Light.h"
|
||||||
#include "C_obj/C_Player.h"
|
#include "C_obj/C_Player.h"
|
||||||
|
@ -44,7 +44,7 @@ struct GameState::MyData
|
||||||
// !DEGUG KEYS
|
// !DEGUG KEYS
|
||||||
|
|
||||||
C_Player player;
|
C_Player player;
|
||||||
Camera_FPS camera;
|
Camera_FPSV2 camera;
|
||||||
|
|
||||||
int myId;
|
int myId;
|
||||||
|
|
||||||
|
@ -91,11 +91,8 @@ bool GameState::Init( SharedStateContent &shared )
|
||||||
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
|
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
|
||||||
|
|
||||||
//tell server ready
|
//tell server ready
|
||||||
//this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
|
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
|
||||||
|
|
||||||
// Debugg hack
|
|
||||||
this->InitiatePlayer( 0, "crate_generic.dan",Float3( 0,132, 10), Quaternion::identity, Float3(1), true );
|
|
||||||
// end debug hack
|
|
||||||
// DEGUG KEYS
|
// DEGUG KEYS
|
||||||
this->privData->key_Reload_Shaders = false;
|
this->privData->key_Reload_Shaders = false;
|
||||||
this->privData->key_Wireframe_Toggle = false;
|
this->privData->key_Wireframe_Toggle = false;
|
||||||
|
@ -107,6 +104,7 @@ bool GameState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
light->second->Render();
|
light->second->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +122,8 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
RBInitData RBData;
|
RBInitData RBData;
|
||||||
RBData.position = position;
|
RBData.position = position;
|
||||||
RBData.rotation = ArrayToQuaternion( rotation );
|
RBData.rotation = ArrayToQuaternion( rotation );
|
||||||
RBData.scale = Float3( 1 );
|
RBData.scale = scale;
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
|
|
||||||
if( isMyPlayer )
|
if( isMyPlayer )
|
||||||
{
|
{
|
||||||
if( this->privData->player.Init(modelData) )
|
if( this->privData->player.Init(modelData) )
|
||||||
|
@ -138,7 +135,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
this->privData->myId = id;
|
this->privData->myId = id;
|
||||||
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
||||||
Float3 offset = Float3( 0.0f );
|
Float3 offset = Float3( 0.0f );
|
||||||
offset.y = this->privData->player.getScale().y + 0.5f; // debug hack +0.5f
|
offset.y = this->privData->player.getScale().y * 0.9f;
|
||||||
this->privData->camera.SetHeadOffset( offset );
|
this->privData->camera.SetHeadOffset( offset );
|
||||||
this->privData->camera.UpdateOrientation();
|
this->privData->camera.UpdateOrientation();
|
||||||
}
|
}
|
||||||
|
@ -181,7 +178,8 @@ bool GameState::Render()
|
||||||
auto dynamicObject = this->privData->dynamicObjects->begin();
|
auto dynamicObject = this->privData->dynamicObjects->begin();
|
||||||
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
||||||
{
|
{
|
||||||
dynamicObject->second->Render();
|
if( dynamicObject->second )
|
||||||
|
dynamicObject->second->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,13 +216,16 @@ bool GameState::Render()
|
||||||
dynamicObject = this->privData->dynamicObjects->begin();
|
dynamicObject = this->privData->dynamicObjects->begin();
|
||||||
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
||||||
{
|
{
|
||||||
if( dynamicObject->second->getBRtype() == RB_Type_Cube)
|
if( dynamicObject->second )
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
|
if( dynamicObject->second->getBRtype() == RB_Type_Cube)
|
||||||
}
|
{
|
||||||
if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
|
Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
|
||||||
{
|
}
|
||||||
Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
|
if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
|
||||||
|
{
|
||||||
|
Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +275,7 @@ void GameState::ReadKeyInput()
|
||||||
{
|
{
|
||||||
if( this->privData->input->IsKeyPressed(DIK_W) )
|
if( this->privData->input->IsKeyPressed(DIK_W) )
|
||||||
{
|
{
|
||||||
if(!this->privData->key_forward)
|
//if(!this->privData->key_forward)
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
||||||
this->privData->key_forward = true;
|
this->privData->key_forward = true;
|
||||||
|
@ -285,7 +286,7 @@ void GameState::ReadKeyInput()
|
||||||
|
|
||||||
if( this->privData->input->IsKeyPressed(DIK_S) )
|
if( this->privData->input->IsKeyPressed(DIK_S) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_backward )
|
//if( !this->privData->key_backward )
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
||||||
this->privData->key_backward = true;
|
this->privData->key_backward = true;
|
||||||
|
@ -296,7 +297,7 @@ void GameState::ReadKeyInput()
|
||||||
|
|
||||||
if( this->privData->input->IsKeyPressed(DIK_A) )
|
if( this->privData->input->IsKeyPressed(DIK_A) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_strafeLeft )
|
//if( !this->privData->key_strafeLeft )
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
|
||||||
this->privData->key_strafeLeft = true;
|
this->privData->key_strafeLeft = true;
|
||||||
|
@ -307,7 +308,7 @@ void GameState::ReadKeyInput()
|
||||||
|
|
||||||
if( this->privData->input->IsKeyPressed(DIK_D) )
|
if( this->privData->input->IsKeyPressed(DIK_D) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_strafeRight )
|
//if( !this->privData->key_strafeRight )
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
||||||
this->privData->key_strafeRight = true;
|
this->privData->key_strafeRight = true;
|
||||||
|
@ -413,13 +414,22 @@ void GameState::ReadKeyInput()
|
||||||
// TODO: implement sub-menu
|
// TODO: implement sub-menu
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
CustomNetProtocol data = e.args.data.protocol;
|
if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend )
|
||||||
short ID = data[0].value.netShort; // fetching the id data.
|
{ // TODO: Reconnect
|
||||||
|
const char *breakpoint = "temp trap";
|
||||||
|
this->privData->nwClient->Disconnect();
|
||||||
|
this->ChangeState( GameClientState::ClientState_Main );
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetching the id data.
|
||||||
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
if( ProtocolIsGameplay(ID) )
|
if( ProtocolIsGameplay(ID) )
|
||||||
{
|
{
|
||||||
|
CustomNetProtocol data = message.args.data.protocol;
|
||||||
|
|
||||||
switch(ID)
|
switch(ID)
|
||||||
{
|
{
|
||||||
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
||||||
|
@ -438,7 +448,7 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBPos ( decoded.position );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBPos ( decoded.position );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectScale:
|
case protocol_Gameplay_ObjectScale:
|
||||||
{
|
{
|
||||||
Protocol_ObjectScale decoded(data);
|
Protocol_ObjectScale decoded(data);
|
||||||
|
@ -447,7 +457,7 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBScale ( decoded.scale );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBScale ( decoded.scale );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectRotation:
|
case protocol_Gameplay_ObjectRotation:
|
||||||
{
|
{
|
||||||
Protocol_ObjectRotation decoded(data);
|
Protocol_ObjectRotation decoded(data);
|
||||||
|
@ -455,14 +465,14 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
// if is this player. Remember to change camera
|
||||||
if( this->privData->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
this->privData->camera.SetAngular( AngularAxis(rotation) );
|
this->privData->camera.SetRotation( rotation );
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBRot ( rotation );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBRot ( rotation );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectPositionRotation:
|
case protocol_Gameplay_ObjectPositionRotation:
|
||||||
{
|
{
|
||||||
Protocol_ObjectPositionRotation decoded(data);
|
Protocol_ObjectPositionRotation decoded(data);
|
||||||
|
@ -473,18 +483,24 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
if( this->privData->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
{
|
{
|
||||||
this->privData->camera.SetPosition( position );
|
this->privData->camera.SetPosition( position );
|
||||||
this->privData->camera.SetAngular( AngularAxis(rotation) );
|
this->privData->camera.SetRotation( rotation );
|
||||||
|
this->privData->player.setPos( position );
|
||||||
|
//this->privData->player.setRot( rotation );
|
||||||
}
|
}
|
||||||
|
|
||||||
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
object->setPos( position );
|
|
||||||
object->setRot( rotation );
|
if( object )
|
||||||
// RB DEBUG
|
{
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBPos ( position );
|
object->setPos( position );
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBRot ( rotation );
|
object->setRot( rotation );
|
||||||
// !RB DEBUG
|
// RB DEBUG
|
||||||
|
object->setRBPos ( position );
|
||||||
|
object->setRBRot ( rotation );
|
||||||
|
// !RB DEBUG
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectDisabled:
|
case protocol_Gameplay_ObjectDisabled:
|
||||||
{
|
{
|
||||||
|
@ -497,7 +513,7 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
this->privData->dynamicObjects->erase( object );
|
this->privData->dynamicObjects->erase( object );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreate:
|
case protocol_Gameplay_ObjectCreate:
|
||||||
{
|
{
|
||||||
Protocol_ObjectCreate decoded(data);
|
Protocol_ObjectCreate decoded(data);
|
||||||
|
@ -527,13 +543,13 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreatePlayer:
|
case protocol_Gameplay_ObjectCreatePlayer:
|
||||||
{
|
{
|
||||||
Protocol_ObjectCreatePlayer decoded(data);
|
Protocol_ObjectCreatePlayer decoded(data);
|
||||||
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner );
|
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner );
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
|
||||||
|
@ -552,4 +568,6 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace DanBias { namespace Client
|
||||||
bool Release()override;
|
bool Release()override;
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "GameStateUI.h"
|
||||||
|
|
||||||
|
using namespace ::DanBias::Client;
|
||||||
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
|
GameStateUI::GameStateUI()
|
||||||
|
{
|
||||||
|
this->nextState = GameStateUI::UIState_same;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameStateUI::~GameStateUI() { /* Do nothing */ }
|
||||||
|
|
||||||
|
const GameStateUI::NetEvent & GameStateUI::DataRecieved( const GameStateUI::NetEvent &message )
|
||||||
|
{
|
||||||
|
/* Do nothing */
|
||||||
|
return message;
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
||||||
|
#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
||||||
|
|
||||||
|
#include "Utilities.h"
|
||||||
|
#include "NetworkClient.h"
|
||||||
|
|
||||||
|
namespace DanBias { namespace Client
|
||||||
|
{
|
||||||
|
class GameStateUI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum UIState
|
||||||
|
{
|
||||||
|
UIState_same,
|
||||||
|
UIState_gaming,
|
||||||
|
|
||||||
|
|
||||||
|
UIState_main_menu,
|
||||||
|
UIState_shut_down
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent;
|
||||||
|
static const NetEvent event_processed;
|
||||||
|
|
||||||
|
GameStateUI();
|
||||||
|
virtual ~GameStateUI();
|
||||||
|
virtual UIState Update( float deltaTime ) = 0;
|
||||||
|
virtual bool HaveGUIRender() const = 0;
|
||||||
|
virtual bool HaveTextRender() const = 0;
|
||||||
|
virtual void RenderGUI() const = 0;
|
||||||
|
virtual void RenderText() const = 0;
|
||||||
|
virtual bool Release() = 0;
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* @param message of the event
|
||||||
|
* @return message or a reference to GameStateUI::event_processed.
|
||||||
|
******************************************************************/
|
||||||
|
virtual const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UIState nextState;
|
||||||
|
};
|
||||||
|
} }
|
||||||
|
|
||||||
|
namespace Utility { namespace DynamicMemory
|
||||||
|
{ // template specializationto allowuse of dynamicmemory tools
|
||||||
|
template<>
|
||||||
|
inline void SafeDeleteInstance( ::DanBias::Client::GameStateUI *dynamicInstance )
|
||||||
|
{
|
||||||
|
if( dynamicInstance )
|
||||||
|
{
|
||||||
|
dynamicInstance->Release();
|
||||||
|
delete dynamicInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,153 @@
|
||||||
|
#include "GamingUI.h"
|
||||||
|
#include <Protocols.h>
|
||||||
|
|
||||||
|
using namespace ::DanBias::Client;
|
||||||
|
using namespace ::Oyster::Network;
|
||||||
|
using namespace ::GameLogic;
|
||||||
|
|
||||||
|
GamingUI::GamingUI() :
|
||||||
|
GameStateUI()
|
||||||
|
{
|
||||||
|
/* Should never be called! */
|
||||||
|
this->input = nullptr;
|
||||||
|
this->netClient = nullptr;
|
||||||
|
this->camera = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *camera ) :
|
||||||
|
GameStateUI()
|
||||||
|
{
|
||||||
|
this->input = input;
|
||||||
|
this->netClient = connection;
|
||||||
|
this->camera = camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
GamingUI::~GamingUI() { /* Do nothing */ }
|
||||||
|
|
||||||
|
GameStateUI::UIState GamingUI::Update( float deltaTime )
|
||||||
|
{
|
||||||
|
return this->nextState;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GamingUI::HaveGUIRender() const
|
||||||
|
{
|
||||||
|
return false; // TODO: change to true when we want UI elements like a crosshair
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GamingUI::HaveTextRender() const
|
||||||
|
{
|
||||||
|
return false; // TODO: change to true when we want UI elements like a chat window
|
||||||
|
}
|
||||||
|
|
||||||
|
void GamingUI::RenderGUI() const
|
||||||
|
{
|
||||||
|
// TODO: Render crosshairs and such here. Don't forget to adjust GamingUI::HaveGUIRender
|
||||||
|
}
|
||||||
|
|
||||||
|
void GamingUI::RenderText() const
|
||||||
|
{
|
||||||
|
// TODO: Render chattext and such here. Don't forget to adjust GamingUI::HaveGUIRender
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GamingUI::Release()
|
||||||
|
{
|
||||||
|
// TODO: Release UI components here.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GamingUI::ReadKeyInput()
|
||||||
|
{
|
||||||
|
if( this->input->IsKeyPressed(DIK_W) )
|
||||||
|
{
|
||||||
|
this->netClient->Send( Protocol_PlayerMovementForward() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this->input->IsKeyPressed(DIK_S) )
|
||||||
|
{
|
||||||
|
this->netClient->Send( Protocol_PlayerMovementBackward() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this->input->IsKeyPressed(DIK_A) )
|
||||||
|
{
|
||||||
|
this->netClient->Send( Protocol_PlayerMovementLeft() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this->input->IsKeyPressed(DIK_D) )
|
||||||
|
{
|
||||||
|
this->netClient->Send( Protocol_PlayerMovementRight() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// if( this->input->IsKeyPressed(DIK_R) )
|
||||||
|
// {
|
||||||
|
// if( !this->key_Reload_Shaders )
|
||||||
|
// {
|
||||||
|
//#ifdef _DEBUG
|
||||||
|
// Graphics::API::ReloadShaders();
|
||||||
|
//#endif
|
||||||
|
// this->key_Reload_Shaders = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// this->key_Reload_Shaders = false;
|
||||||
|
|
||||||
|
//send delta mouse movement
|
||||||
|
{
|
||||||
|
this->camera->YawRight( this->input->GetYaw() * 0.017f );
|
||||||
|
this->camera->PitchDown( this->input->GetPitch() * 0.017f );
|
||||||
|
this->camera->UpdateOrientation();
|
||||||
|
|
||||||
|
this->netClient->Send( Protocol_PlayerLook(this->camera->GetLook(), this->camera->GetRight()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// shoot
|
||||||
|
//if( this->input->IsKeyPressed(DIK_Z) )
|
||||||
|
//{
|
||||||
|
// if( !this->key_Shoot )
|
||||||
|
// {
|
||||||
|
// Protocol_PlayerShot playerShot;
|
||||||
|
// playerShot.primaryPressed = true;
|
||||||
|
// playerShot.secondaryPressed = false;
|
||||||
|
// playerShot.utilityPressed = false;
|
||||||
|
// this->netClient->Send( playerShot );
|
||||||
|
// this->key_Shoot = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
// this->key_Shoot = false;
|
||||||
|
|
||||||
|
//if( this->input->IsKeyPressed(DIK_X) )
|
||||||
|
//{
|
||||||
|
// if( !this->key_Shoot )
|
||||||
|
// {
|
||||||
|
// Protocol_PlayerShot playerShot;
|
||||||
|
// playerShot.primaryPressed = false;
|
||||||
|
// playerShot.secondaryPressed = true;
|
||||||
|
// playerShot.utilityPressed = false;
|
||||||
|
// this->netClient->Send( playerShot );
|
||||||
|
// this->key_Shoot = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
// this->key_Shoot = false;
|
||||||
|
|
||||||
|
//if( this->input->IsKeyPressed(DIK_C) )
|
||||||
|
//{
|
||||||
|
// if( !this->key_Shoot )
|
||||||
|
// {
|
||||||
|
// Protocol_PlayerShot playerShot;
|
||||||
|
// playerShot.primaryPressed = false;
|
||||||
|
// playerShot.secondaryPressed = false;
|
||||||
|
// playerShot.utilityPressed = true;
|
||||||
|
// this->netClient->Send( playerShot );
|
||||||
|
// this->key_Shoot = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
// this->key_Shoot = false;
|
||||||
|
|
||||||
|
// jump
|
||||||
|
if( this->input->IsKeyPressed(DIK_SPACE) )
|
||||||
|
{
|
||||||
|
this->netClient->Send( Protocol_PlayerJump() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef DANBIAS_CLIENT_GAMING_UI_H
|
||||||
|
#define DANBIAS_CLIENT_GAMING_UI_H
|
||||||
|
|
||||||
|
#include "GameStateUI.h"
|
||||||
|
#include "L_inputClass.h"
|
||||||
|
#include "Camera_FPSV2.h"
|
||||||
|
|
||||||
|
namespace DanBias { namespace Client
|
||||||
|
{
|
||||||
|
class GamingUI : public GameStateUI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GamingUI( InputClass *input, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
|
||||||
|
virtual ~GamingUI();
|
||||||
|
|
||||||
|
UIState Update( float deltaTime );
|
||||||
|
bool HaveGUIRender() const;
|
||||||
|
bool HaveTextRender() const;
|
||||||
|
void RenderGUI() const;
|
||||||
|
void RenderText() const;
|
||||||
|
bool Release();
|
||||||
|
|
||||||
|
private:
|
||||||
|
InputClass *input;
|
||||||
|
::Oyster::Network::NetworkClient *netClient;
|
||||||
|
Camera_FPSV2 *camera;
|
||||||
|
|
||||||
|
GamingUI();
|
||||||
|
void ReadKeyInput();
|
||||||
|
};
|
||||||
|
} }
|
||||||
|
|
||||||
|
#endif
|
|
@ -61,6 +61,7 @@ bool LanMenuState::Init( SharedStateContent &shared )
|
||||||
this->privData->connectIP = new TextField<LanMenuState*>( L"color_white.png", Float4(1.0f), Float4(0.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
|
this->privData->connectIP = new TextField<LanMenuState*>( L"color_white.png", Float4(1.0f), Float4(0.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
|
||||||
this->privData->connectIP->ReserveLines( 1 );
|
this->privData->connectIP->ReserveLines( 1 );
|
||||||
this->privData->connectIP->AppendText( L"127.0.0.1" );
|
this->privData->connectIP->AppendText( L"127.0.0.1" );
|
||||||
|
//this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server
|
||||||
this->privData->connectIP->SetFontHeight( 0.08f );
|
this->privData->connectIP->SetFontHeight( 0.08f );
|
||||||
this->privData->connectIP->SetLineSpacing( 0.005f );
|
this->privData->connectIP->SetLineSpacing( 0.005f );
|
||||||
this->privData->connectIP->SetTopAligned();
|
this->privData->connectIP->SetTopAligned();
|
||||||
|
@ -125,6 +126,9 @@ void LanMenuState::ChangeState( ClientState next )
|
||||||
// attempt to connect to lobby
|
// attempt to connect to lobby
|
||||||
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
||||||
return;
|
return;
|
||||||
|
//this->privData->nwClient->Disconnect();
|
||||||
|
//if( !this->privData->nwClient->Reconnect() )
|
||||||
|
//return;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#include "LevelLoader.h"
|
|
||||||
#include "LevelParser.h"
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
|
||||||
using namespace GameLogic::LevelFileLoader;
|
|
||||||
|
|
||||||
struct LevelLoader::PrivData
|
|
||||||
{
|
|
||||||
LevelParser parser;
|
|
||||||
std::string folderPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
LevelLoader::LevelLoader()
|
|
||||||
: pData(new PrivData)
|
|
||||||
{
|
|
||||||
//standard path
|
|
||||||
pData->folderPath = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelLoader::LevelLoader(std::string folderPath)
|
|
||||||
: pData(new PrivData)
|
|
||||||
{
|
|
||||||
pData->folderPath = folderPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelLoader::~LevelLoader()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName)
|
|
||||||
{
|
|
||||||
return pData->parser.Parse(pData->folderPath + fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
|
|
||||||
{
|
|
||||||
return pData->parser.ParseHeader(pData->folderPath + fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string LevelLoader::GetFolderPath()
|
|
||||||
{
|
|
||||||
return this->pData->folderPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LevelLoader::SetFolderPath(std::string folderPath)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,317 +0,0 @@
|
||||||
/////////////////////////////////////
|
|
||||||
// Created by Pontus Fransson 2013 //
|
|
||||||
/////////////////////////////////////
|
|
||||||
|
|
||||||
#include "LevelParser.h"
|
|
||||||
|
|
||||||
#include "Loader.h"
|
|
||||||
#include "ParseFunctions.h"
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
|
||||||
using namespace ::LevelFileLoader;
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
|
|
||||||
LevelParser::LevelParser()
|
|
||||||
{
|
|
||||||
formatVersion.formatVersionMajor = 3;
|
|
||||||
formatVersion.formatVersionMinor = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelParser::~LevelParser()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filename)
|
|
||||||
{
|
|
||||||
int bufferSize = 0;
|
|
||||||
int counter = 0;
|
|
||||||
bool loadCgf;
|
|
||||||
|
|
||||||
std::vector<SmartPointer<ObjectTypeHeader>> objects;
|
|
||||||
|
|
||||||
//Read entire level file.
|
|
||||||
Loader loader;
|
|
||||||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
|
||||||
|
|
||||||
//Read format version
|
|
||||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
|
||||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
|
||||||
counter += sizeof(levelFormatVersion);
|
|
||||||
if(this->formatVersion != levelFormatVersion)
|
|
||||||
{
|
|
||||||
//Returns an empty vector, because it will most likely fail to read the level format.
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(counter < bufferSize)
|
|
||||||
{
|
|
||||||
loadCgf = true;
|
|
||||||
//Get typeID
|
|
||||||
ObjectType typeID;
|
|
||||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
|
||||||
switch((int)typeID)
|
|
||||||
{
|
|
||||||
case ObjectType_LevelMetaData:
|
|
||||||
{
|
|
||||||
SmartPointer<ObjectTypeHeader> header = new LevelMetaData;
|
|
||||||
ParseLevelMetaData(&buffer[counter], *(LevelMetaData*)header.Get(), counter);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectType_SpawnPoint:
|
|
||||||
{
|
|
||||||
loadCgf = false;
|
|
||||||
ObjectHeader* header = new ObjectHeader;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
SpawnPointAttributes* spawn = new SpawnPointAttributes;
|
|
||||||
|
|
||||||
spawn->typeID = header->typeID;
|
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
spawn->position[i] = header->position[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
delete header;
|
|
||||||
//objects.push_back(header);
|
|
||||||
objects.push_back(spawn);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
|
||||||
//Unless they are changed to not be the same.
|
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
|
||||||
{
|
|
||||||
//Get specialType.
|
|
||||||
ObjectSpecialType specialType;
|
|
||||||
ParseObject(&buffer[counter+4], &specialType, sizeof(typeID));
|
|
||||||
|
|
||||||
switch(specialType)
|
|
||||||
{
|
|
||||||
//there is no difference when parsing these specialTypes.
|
|
||||||
case ObjectSpecialType_CrystalShard:
|
|
||||||
case ObjectSpecialType_CrystalFormation:
|
|
||||||
case ObjectSpecialType_Spike:
|
|
||||||
case ObjectSpecialType_SpikeBox:
|
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
|
||||||
case ObjectSpecialType_StandarsBox:
|
|
||||||
case ObjectSpecialType_Stone:
|
|
||||||
case ObjectSpecialType_Building:
|
|
||||||
{
|
|
||||||
ObjectHeader* header = new ObjectHeader;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
objects.push_back(header);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_JumpPad:
|
|
||||||
{
|
|
||||||
JumpPadAttributes* header = new JumpPadAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
//Read the spec
|
|
||||||
ParseObject(&buffer[counter], header->direction, 16);
|
|
||||||
counter += 16;
|
|
||||||
objects.push_back(header);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_Portal:
|
|
||||||
{
|
|
||||||
PortalAttributes* header = new PortalAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
ParseObject(&buffer[counter], header->destination, 12);
|
|
||||||
counter += 12;
|
|
||||||
objects.push_back(header);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_World:
|
|
||||||
{
|
|
||||||
WorldAttributes* header = new WorldAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
ParseObject(&buffer[counter], &header->worldSize, 8);
|
|
||||||
counter += 8;
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_Sky:
|
|
||||||
{
|
|
||||||
loadCgf = false;
|
|
||||||
SkyAttributes* header = new SkyAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
ParseObject(&buffer[counter], &header->skySize, 4);
|
|
||||||
counter += 4;
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
|
||||||
//Couldn't find specialType
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectType_Light:
|
|
||||||
{
|
|
||||||
LightType lightType;
|
|
||||||
|
|
||||||
//Get Light type
|
|
||||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
|
||||||
|
|
||||||
//We only support PointLight for now.
|
|
||||||
BasicLight* header = new BasicLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
/*switch(lightType)
|
|
||||||
{
|
|
||||||
case LightType_PointLight:
|
|
||||||
{
|
|
||||||
PointLight* header = new PointLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_DirectionalLight:
|
|
||||||
{
|
|
||||||
DirectionalLight* header = new DirectionalLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_SpotLight:
|
|
||||||
{
|
|
||||||
SpotLight* header = new SpotLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
//Undefined LightType.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;*/
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
//för meta information om leveln.
|
|
||||||
LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|
||||||
{
|
|
||||||
int bufferSize = 0;
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
LevelMetaData levelHeader;
|
|
||||||
levelHeader.typeID = ObjectType::ObjectType_Unknown;
|
|
||||||
|
|
||||||
//Read entire level file.
|
|
||||||
Loader loader;
|
|
||||||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
|
||||||
|
|
||||||
//Read format version
|
|
||||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
|
||||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
|
||||||
counter += sizeof(levelFormatVersion);
|
|
||||||
if(this->formatVersion != levelFormatVersion)
|
|
||||||
{
|
|
||||||
//Do something if it's not the same version
|
|
||||||
|
|
||||||
//Returns an empty levelHeader with ObjectType_Unknown.
|
|
||||||
//Because it will not be able to read another version of the level format.
|
|
||||||
return levelHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Find the header in the returned string.
|
|
||||||
while(counter < bufferSize)
|
|
||||||
{
|
|
||||||
ObjectType typeID;
|
|
||||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
|
||||||
|
|
||||||
switch(typeID)
|
|
||||||
{
|
|
||||||
case ObjectType_LevelMetaData:
|
|
||||||
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
|
||||||
return levelHeader;
|
|
||||||
break;
|
|
||||||
|
|
||||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
|
||||||
{
|
|
||||||
ObjectHeader header;
|
|
||||||
ParseObject(&buffer[counter], &header, counter);
|
|
||||||
|
|
||||||
switch(header.specialTypeID)
|
|
||||||
{
|
|
||||||
case ObjectSpecialType_JumpPad:
|
|
||||||
counter += sizeof(16);
|
|
||||||
break;
|
|
||||||
case ObjectSpecialType_Portal:
|
|
||||||
counter += sizeof(12);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectType_Light:
|
|
||||||
{
|
|
||||||
LightType lightType;
|
|
||||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
|
||||||
|
|
||||||
//We only support pointlight for now.
|
|
||||||
counter += sizeof(BasicLight);
|
|
||||||
/*
|
|
||||||
switch(lightType)
|
|
||||||
{
|
|
||||||
case LightType_PointLight:
|
|
||||||
{
|
|
||||||
counter += sizeof(PointLight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_DirectionalLight:
|
|
||||||
{
|
|
||||||
counter += sizeof(DirectionalLight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_SpotLight:
|
|
||||||
{
|
|
||||||
counter += sizeof(SpotLight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
//Undefined LightType.
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return levelHeader;
|
|
||||||
}
|
|
|
@ -112,10 +112,10 @@ void LobbyAdminState::ChangeState( ClientState next )
|
||||||
|
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & LobbyAdminState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
CustomNetProtocol data = e.args.data.protocol;
|
// fetching the id data.
|
||||||
short ID = data[0].value.netShort; // fetching the id data.
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
// Block irrelevant messages.
|
// Block irrelevant messages.
|
||||||
if( ProtocolIsLobby(ID) )
|
if( ProtocolIsLobby(ID) )
|
||||||
|
@ -141,6 +141,7 @@ void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::Clie
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyAdminState*>& e )
|
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyAdminState*>& e )
|
||||||
|
|
|
@ -29,8 +29,8 @@ namespace DanBias
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||||
|
|
|
@ -112,10 +112,10 @@ void LobbyState::ChangeState( ClientState next )
|
||||||
|
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & LobbyState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
CustomNetProtocol data = e.args.data.protocol;
|
// fetching the id data.
|
||||||
short ID = data[0].value.netShort; // fetching the id data.
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
// Block irrelevant messages.
|
// Block irrelevant messages.
|
||||||
if( ProtocolIsLobby(ID) )
|
if( ProtocolIsLobby(ID) )
|
||||||
|
@ -141,6 +141,8 @@ void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEve
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyState*>& e )
|
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyState*>& e )
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace DanBias
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "Protocols.h"
|
#include "Protocols.h"
|
||||||
#include "LevelLoader\LevelLoader.h"
|
#include "LevelLoader.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "C_obj\C_StaticObj.h"
|
#include "C_obj\C_StaticObj.h"
|
||||||
#include "C_obj\C_DynamicObj.h"
|
#include "C_obj\C_DynamicObj.h"
|
||||||
|
@ -57,11 +57,8 @@ bool NetLoadState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
// we may assume that nwClient is properly connected to the server
|
// we may assume that nwClient is properly connected to the server
|
||||||
// signals querry to server for loading instructions
|
// signals querry to server for loading instructions
|
||||||
//this->privData->nwClient->Send( Protocol_QuerryGameType() );
|
this->privData->nwClient->Send( Protocol_QuerryGameType() );
|
||||||
|
|
||||||
// debugg
|
|
||||||
this->LoadGame( "..//Content//Worlds//2ofAll_updated.bias");
|
|
||||||
this->ChangeState( ClientState_Game );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,16 +93,25 @@ void NetLoadState::ChangeState( ClientState next )
|
||||||
this->privData->nextState = next;
|
this->privData->nextState = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & NetLoadState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
// fetching the id data.
|
// fetching the id data.
|
||||||
short ID = e.args.data.protocol[0].value.netShort;
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
if( ID == protocol_Lobby_CreateGame && !this->privData->loading )
|
if( ID == protocol_Lobby_CreateGame )
|
||||||
{
|
{
|
||||||
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
|
if( !this->privData->loading )
|
||||||
this->ChangeState( ClientState_Game );
|
{
|
||||||
this->privData->loading = false;
|
this->LoadGame( Protocol_LobbyCreateGame(message.args.data.protocol).mapName );
|
||||||
|
this->ChangeState( ClientState_Game );
|
||||||
|
this->privData->loading = false;
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // HACK: Debug trap
|
||||||
|
const char *breakPoint = "Being greedy.";
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +119,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
||||||
{
|
{
|
||||||
this->privData->loading = true;
|
this->privData->loading = true;
|
||||||
|
|
||||||
LevelLoader loader;
|
LevelLoader loader( "..\\Content\\Worlds\\" );
|
||||||
auto objects = loader.LoadLevel( fileName );
|
auto objects = loader.LoadLevel( fileName );
|
||||||
auto object = objects.begin();
|
auto object = objects.begin();
|
||||||
ObjectTypeHeader *oth;
|
ObjectTypeHeader *oth;
|
||||||
|
@ -234,16 +240,5 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG added a static light for testing
|
|
||||||
Graphics::Definitions::Pointlight pointLight;
|
|
||||||
pointLight.Color = Float3(1,1,0);
|
|
||||||
pointLight.Pos = Float3( 0,132, 10);
|
|
||||||
pointLight.Bright = 2;
|
|
||||||
pointLight.Radius = 50;
|
|
||||||
|
|
||||||
C_Light *newLight = new C_Light( pointLight, objectID );
|
|
||||||
|
|
||||||
(*this->privData->lights)[objectID] = newLight;
|
|
||||||
|
|
||||||
this->privData->nextState = ClientState::ClientState_Game;
|
this->privData->nextState = ClientState::ClientState_Game;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace DanBias
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include "RespawnUI.h"
|
||||||
|
|
||||||
|
using namespace ::DanBias::Client;
|
||||||
|
using namespace ::Oyster::Network;
|
||||||
|
using namespace ::Utility::Value;
|
||||||
|
|
||||||
|
RespawnUI::RespawnUI() :
|
||||||
|
GameStateUI()
|
||||||
|
{
|
||||||
|
/* Should never be called! */
|
||||||
|
this->netClient = nullptr;
|
||||||
|
this->countDown = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
RespawnUI::RespawnUI( NetworkClient *connection, float delay ) :
|
||||||
|
GameStateUI()
|
||||||
|
{
|
||||||
|
this->netClient = connection;
|
||||||
|
this->countDown = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
RespawnUI::~RespawnUI() { /* Do nothing */ }
|
||||||
|
|
||||||
|
GameStateUI::UIState RespawnUI::Update( float deltaTime )
|
||||||
|
{
|
||||||
|
this->countDown = Max( this->countDown - deltaTime, 0.0f );
|
||||||
|
return this->nextState;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RespawnUI::HaveGUIRender() const
|
||||||
|
{
|
||||||
|
return false; // TODO: change to true when we want UI elements like a crosshair
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RespawnUI::HaveTextRender() const
|
||||||
|
{
|
||||||
|
return false; // TODO: change to true when we want UI elements like a chat window
|
||||||
|
}
|
||||||
|
|
||||||
|
void RespawnUI::RenderGUI() const
|
||||||
|
{
|
||||||
|
// TODO: We need?
|
||||||
|
}
|
||||||
|
|
||||||
|
void RespawnUI::RenderText() const
|
||||||
|
{
|
||||||
|
// TODO: Text countdown somewhere on screen would be nice
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RespawnUI::Release()
|
||||||
|
{
|
||||||
|
// TODO: Release UI components here.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef DANBIAS_CLIENT_RESPAWN_UI_H
|
||||||
|
#define DANBIAS_CLIENT_RESPAWN_UI_H
|
||||||
|
|
||||||
|
#include "GameStateUI.h"
|
||||||
|
|
||||||
|
namespace DanBias { namespace Client
|
||||||
|
{
|
||||||
|
class RespawnUI : public GameStateUI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RespawnUI( ::Oyster::Network::NetworkClient *connection, float delay );
|
||||||
|
virtual ~RespawnUI();
|
||||||
|
|
||||||
|
UIState Update( float deltaTime );
|
||||||
|
bool HaveGUIRender() const;
|
||||||
|
bool HaveTextRender() const;
|
||||||
|
void RenderGUI() const;
|
||||||
|
void RenderText() const;
|
||||||
|
bool Release();
|
||||||
|
|
||||||
|
private:
|
||||||
|
::Oyster::Network::NetworkClient *netClient;
|
||||||
|
float countDown;
|
||||||
|
|
||||||
|
RespawnUI();
|
||||||
|
};
|
||||||
|
} }
|
||||||
|
|
||||||
|
#endif
|
|
@ -46,7 +46,7 @@ using namespace GameLogic;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
|
case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
|
||||||
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision());
|
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->GetExtraDamageOnCollision());
|
||||||
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -170,18 +170,18 @@ using namespace GameLogic;
|
||||||
|
|
||||||
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
|
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
|
||||||
{
|
{
|
||||||
int damageDone = 0;
|
Oyster::Math::Float damageDone = 0;
|
||||||
int forceThreashHold = 200000;
|
Oyster::Math::Float forceThreashHold = 200000;
|
||||||
|
|
||||||
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
||||||
{
|
{
|
||||||
damageDone = (int)(kineticEnergyLoss * 0.10f);
|
damageDone = (kineticEnergyLoss * 0.10f);
|
||||||
damageDone += ExtraDamage;
|
damageDone += ExtraDamage;
|
||||||
//player.DamageLife(damageDone);
|
//player.DamageLife(damageDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
return Physics::ICustomBody::SubscriptMessage_none;
|
return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,22 +68,41 @@ void Game::GetAllPlayerPositions() const
|
||||||
Game::PlayerData* Game::CreatePlayer()
|
Game::PlayerData* Game::CreatePlayer()
|
||||||
{
|
{
|
||||||
// Find a free space in array or insert at end
|
// Find a free space in array or insert at end
|
||||||
int i = InsertObject(this->players, (PlayerData*)0);
|
int insert = InsertObject(this->players, (PlayerData*)0);
|
||||||
|
int freeID = 0;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
this->players[i] = new PlayerData();
|
for(int i = 0; i < 100; i++)
|
||||||
this->players[i]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
{
|
||||||
|
found = true;
|
||||||
|
freeID = i;
|
||||||
|
|
||||||
return this->players[i];
|
for(int j = 0; j < players.Size(); j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(this->players[j] && this->players[j]->GetID() == freeID)
|
||||||
|
{
|
||||||
|
found = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!found) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->players[insert] = new PlayerData(freeID, 0); // user constructor with objectID and teamID
|
||||||
|
this->players[insert]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
||||||
|
|
||||||
|
return this->players[insert];
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::LevelData* Game::CreateLevel()
|
Game::LevelData* Game::CreateLevel(const wchar_t mapName[255])
|
||||||
{
|
{
|
||||||
if(this->level) return this->level;
|
if(this->level) return this->level;
|
||||||
|
|
||||||
this->level = new LevelData();
|
this->level = new LevelData();
|
||||||
//this->level->level->InitiateLevel(1000);
|
this->level->level->InitiateLevel(mapName);
|
||||||
this->level->level->InitiateLevel("../Content/Worlds/ccc.bias");
|
|
||||||
|
|
||||||
|
|
||||||
return this->level;
|
return this->level;
|
||||||
}
|
}
|
||||||
|
@ -97,21 +116,16 @@ bool Game::NewFrame()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
API::Instance().UpdateWorld();
|
API::Instance().UpdateWorld();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
this->onMoveFnc(this->players[i]);
|
||||||
gameInstance.onMoveFnc(this->players[i]);
|
if(this->players[i] && this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < this->level->level->dynamicObjects.Size(); i++)
|
|
||||||
{
|
|
||||||
gameInstance.onMoveFnc(this->level->level->dynamicObjects[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,11 @@ namespace GameLogic
|
||||||
Oyster::Math::Float3 GetScale() override;
|
Oyster::Math::Float3 GetScale() override;
|
||||||
Oyster::Math::Float4x4 GetOrientation() override;
|
Oyster::Math::Float4x4 GetOrientation() override;
|
||||||
int GetID() const override;
|
int GetID() const override;
|
||||||
ObjectSpecialType GetObjectType() const override;
|
ObjectSpecialType GetObjectType() const override;
|
||||||
int getNrOfDynamicObj()const override;
|
int getNrOfDynamicObj()const override;
|
||||||
IObjectData* GetObjectAt(int ID) const override;
|
IObjectData* GetObjectAt(int ID) const override;
|
||||||
|
void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const override;
|
||||||
|
|
||||||
Level *level;
|
Level *level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ namespace GameLogic
|
||||||
|
|
||||||
void GetAllPlayerPositions() const override;
|
void GetAllPlayerPositions() const override;
|
||||||
PlayerData* CreatePlayer() override;
|
PlayerData* CreatePlayer() override;
|
||||||
LevelData* CreateLevel() override;
|
LevelData* CreateLevel(const wchar_t mapName[255] ) override;
|
||||||
void CreateTeam() override;
|
void CreateTeam() override;
|
||||||
bool NewFrame() override;
|
bool NewFrame() override;
|
||||||
void SetFPS( int FPS ) override;
|
void SetFPS( int FPS ) override;
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
#include "GameLogicDef.h"
|
#include "GameLogicDef.h"
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include <OysterMath.h>
|
#include <OysterMath.h>
|
||||||
#include "LevelLoader\ObjectDefines.h"
|
#include "..\LevelLoader\ObjectDefines.h"
|
||||||
|
#include "DynamicArray.h"
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
|
@ -107,6 +108,7 @@ namespace GameLogic
|
||||||
public:
|
public:
|
||||||
virtual int getNrOfDynamicObj()const = 0;
|
virtual int getNrOfDynamicObj()const = 0;
|
||||||
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
||||||
|
virtual void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& destMem) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DANBIAS_GAMELOGIC_DLL GameAPI
|
class DANBIAS_GAMELOGIC_DLL GameAPI
|
||||||
|
@ -137,7 +139,7 @@ namespace GameLogic
|
||||||
/** Creates a level
|
/** Creates a level
|
||||||
* @return Returns a ILevelData container to use for level manipulation
|
* @return Returns a ILevelData container to use for level manipulation
|
||||||
*/
|
*/
|
||||||
virtual ILevelData* CreateLevel( void ) = 0;
|
virtual ILevelData* CreateLevel( const wchar_t mapName[255] ) = 0;
|
||||||
|
|
||||||
/** Creates a team
|
/** Creates a team
|
||||||
* @return ?
|
* @return ?
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;$(SolutionDir)Misc\OysterMath;$(SolutionDir)Physics\OysterPhysics3D;$(SolutionDir)Physics\GamePhysics;$(SolutionDir)Game\LevelLoader</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DANBIAS_GAMELOGIC_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -172,12 +172,7 @@
|
||||||
<ClInclude Include="IAttatchment.h" />
|
<ClInclude Include="IAttatchment.h" />
|
||||||
<ClInclude Include="JumpPad.h" />
|
<ClInclude Include="JumpPad.h" />
|
||||||
<ClInclude Include="Level.h" />
|
<ClInclude Include="Level.h" />
|
||||||
<ClInclude Include="LevelLoader\LevelLoader.h" />
|
|
||||||
<ClInclude Include="LevelLoader\Loader.h" />
|
|
||||||
<ClInclude Include="Object.h" />
|
<ClInclude Include="Object.h" />
|
||||||
<ClInclude Include="LevelLoader\ObjectDefines.h" />
|
|
||||||
<ClInclude Include="LevelLoader\LevelParser.h" />
|
|
||||||
<ClInclude Include="LevelLoader\ParseFunctions.h" />
|
|
||||||
<ClInclude Include="Player.h" />
|
<ClInclude Include="Player.h" />
|
||||||
<ClInclude Include="Portal.h" />
|
<ClInclude Include="Portal.h" />
|
||||||
<ClInclude Include="StaticObject.h" />
|
<ClInclude Include="StaticObject.h" />
|
||||||
|
@ -198,11 +193,7 @@
|
||||||
<ClCompile Include="IAttatchment.cpp" />
|
<ClCompile Include="IAttatchment.cpp" />
|
||||||
<ClCompile Include="JumpPad.cpp" />
|
<ClCompile Include="JumpPad.cpp" />
|
||||||
<ClCompile Include="Level.cpp" />
|
<ClCompile Include="Level.cpp" />
|
||||||
<ClCompile Include="LevelLoader\LevelLoader.cpp" />
|
|
||||||
<ClCompile Include="LevelLoader\Loader.cpp" />
|
|
||||||
<ClCompile Include="LevelLoader\LevelParser.cpp" />
|
|
||||||
<ClCompile Include="Object.cpp" />
|
<ClCompile Include="Object.cpp" />
|
||||||
<ClCompile Include="LevelLoader\ParseFunctions.cpp" />
|
|
||||||
<ClCompile Include="Player.cpp" />
|
<ClCompile Include="Player.cpp" />
|
||||||
<ClCompile Include="Portal.cpp" />
|
<ClCompile Include="Portal.cpp" />
|
||||||
<ClCompile Include="StaticObject.cpp" />
|
<ClCompile Include="StaticObject.cpp" />
|
||||||
|
@ -223,6 +214,9 @@
|
||||||
<ProjectReference Include="..\..\Physics\OysterPhysics3D\OysterPhysics3D.vcxproj">
|
<ProjectReference Include="..\..\Physics\OysterPhysics3D\OysterPhysics3D.vcxproj">
|
||||||
<Project>{3ea5f14d-2a71-4588-a69d-87c4571c580f}</Project>
|
<Project>{3ea5f14d-2a71-4588-a69d-87c4571c580f}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\LevelLoader\LevelLoader.vcxproj">
|
||||||
|
<Project>{6391e709-d9fa-4fef-a3b9-4343db5a0c63}</Project>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ShowAllFiles>false</ShowAllFiles>
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
|
|
@ -50,4 +50,13 @@ int Game::LevelData::getNrOfDynamicObj()const
|
||||||
IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
||||||
{
|
{
|
||||||
return this->level->GetObj(ID);
|
return this->level->GetObj(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
||||||
|
{
|
||||||
|
mem.Resize(level->dynamicObjects.Size());
|
||||||
|
for(int i = 0; i < (int)level->dynamicObjects.Size(); i++)
|
||||||
|
{
|
||||||
|
mem[i] = level->dynamicObjects[i];
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ Game::PlayerData::PlayerData()
|
||||||
{
|
{
|
||||||
//set some stats that are appropriate to a player
|
//set some stats that are appropriate to a player
|
||||||
|
|
||||||
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(50,130,0);
|
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0);
|
||||||
|
|
||||||
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
||||||
Oyster::Math::Float mass = 60;
|
Oyster::Math::Float mass = 60;
|
||||||
|
@ -21,15 +21,23 @@ Game::PlayerData::PlayerData()
|
||||||
rigidBody->SetAngularFactor(0.0f);
|
rigidBody->SetAngularFactor(0.0f);
|
||||||
//create player with this rigid body
|
//create player with this rigid body
|
||||||
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
||||||
|
|
||||||
//this->player->GetRigidBody()->SetCustomTag(this);
|
|
||||||
player->EndFrame();
|
|
||||||
}
|
}
|
||||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||||
{
|
{
|
||||||
Oyster::Physics::ICustomBody* rigidBody;
|
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0);
|
||||||
this->player = new Player();
|
|
||||||
|
|
||||||
|
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
||||||
|
Oyster::Math::Float mass = 60;
|
||||||
|
Oyster::Math::Float restitutionCoeff = 0.5f;
|
||||||
|
Oyster::Math::Float frictionCoeff_Static = 0.4f;
|
||||||
|
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
|
||||||
|
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
||||||
|
|
||||||
|
//create rigid body
|
||||||
|
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
|
||||||
|
rigidBody->SetAngularFactor(0.0f);
|
||||||
|
//create player with this rigid body
|
||||||
|
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID);
|
||||||
}
|
}
|
||||||
Game::PlayerData::~PlayerData()
|
Game::PlayerData::~PlayerData()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
#include "JumpPad.h"
|
#include "JumpPad.h"
|
||||||
#include "ExplosiveCrate.h"
|
#include "ExplosiveCrate.h"
|
||||||
#include "Portal.h"
|
#include "Portal.h"
|
||||||
|
|
||||||
|
//Conversion from wstring to string
|
||||||
|
#include <codecvt>
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
@ -26,14 +30,14 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
{
|
{
|
||||||
case ObjectSpecialType_None:
|
case ObjectSpecialType_None:
|
||||||
{
|
{
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Sky:
|
case ObjectSpecialType_Sky:
|
||||||
{
|
{
|
||||||
float skySize = ((SkyAttributes*)obj)->skySize;
|
float skySize = ((SkyAttributes*)obj)->skySize;
|
||||||
//gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
//gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_World:
|
case ObjectSpecialType_World:
|
||||||
|
@ -44,28 +48,28 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
float worldSize = ((WorldAttributes*)obj)->worldSize;
|
float worldSize = ((WorldAttributes*)obj)->worldSize;
|
||||||
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
|
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
|
||||||
|
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Building:
|
case ObjectSpecialType_Building:
|
||||||
{
|
{
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
case ObjectSpecialType_Stone:
|
case ObjectSpecialType_Stone:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_StandardBox:
|
case ObjectSpecialType_StandardBox:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
{
|
{
|
||||||
int dmg = 50;
|
Oyster::Math::Float dmg = 50;
|
||||||
Oyster::Math::Float force = 50;
|
Oyster::Math::Float force = 50;
|
||||||
int radie = 50;
|
Oyster::Math::Float radie = 50;
|
||||||
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -75,24 +79,24 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
// break;
|
// break;
|
||||||
case ObjectSpecialType_SpikeBox:
|
case ObjectSpecialType_SpikeBox:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Spike:
|
case ObjectSpecialType_Spike:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_CrystalFormation:
|
case ObjectSpecialType_CrystalFormation:
|
||||||
{
|
{
|
||||||
int dmg = 50;
|
int dmg = 50;
|
||||||
//gameObj = new Crystal(rigidBody);
|
//gameObj = new Crystal(rigidBody);
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_CrystalShard:
|
case ObjectSpecialType_CrystalShard:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_JumpPad:
|
case ObjectSpecialType_JumpPad:
|
||||||
|
@ -100,13 +104,13 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
float power = 500; //((JumpPadAttributes*)obj)->power;
|
float power = 500; //((JumpPadAttributes*)obj)->power;
|
||||||
Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction;
|
Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction;
|
||||||
Oyster::Math::Float3 pushForce = dir * power;
|
Oyster::Math::Float3 pushForce = dir * power;
|
||||||
gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++ , pushForce);
|
gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID , pushForce);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Portal:
|
case ObjectSpecialType_Portal:
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 destination = ((PortalAttributes*)obj)->destination;
|
Oyster::Math::Float3 destination = ((PortalAttributes*)obj)->destination;
|
||||||
gameObj = new Portal(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, destination);
|
gameObj = new Portal(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID, destination);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//case ObjectSpecialType_SpawnPoint:
|
//case ObjectSpecialType_SpawnPoint:
|
||||||
|
@ -122,12 +126,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Generic:
|
case ObjectSpecialType_Generic:
|
||||||
{
|
{
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -197,11 +201,22 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj)
|
||||||
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
||||||
return rigidBody;
|
return rigidBody;
|
||||||
}
|
}
|
||||||
void Level::InitiateLevel(std::string levelPath)
|
bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
{
|
{
|
||||||
LevelLoader ll;
|
LevelLoader ll;
|
||||||
|
ll.SetFolderPath("..\\Content\\Worlds\\");
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
|
||||||
objects = ll.LoadLevel(levelPath);
|
|
||||||
|
//Convert from wstring to string
|
||||||
|
typedef std::codecvt_utf8<wchar_t> convert_typeX;
|
||||||
|
std::wstring_convert<convert_typeX, wchar_t> converterX;
|
||||||
|
|
||||||
|
std::string convertedLevelPath = converterX.to_bytes(levelPath);
|
||||||
|
objects = ll.LoadLevel(convertedLevelPath);
|
||||||
|
|
||||||
|
|
||||||
|
if(objects.size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
API::Instance().SetGravity(200);
|
API::Instance().SetGravity(200);
|
||||||
|
@ -209,6 +224,7 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
|
|
||||||
for (int i = 0; i < objCount; i++)
|
for (int i = 0; i < objCount; i++)
|
||||||
{
|
{
|
||||||
|
++this->objID;
|
||||||
ObjectTypeHeader* obj = objects.at(i);
|
ObjectTypeHeader* obj = objects.at(i);
|
||||||
switch (obj->typeID)
|
switch (obj->typeID)
|
||||||
{
|
{
|
||||||
|
@ -225,39 +241,9 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
staticObjData->ModelFile;
|
staticObjData->ModelFile;
|
||||||
|
|
||||||
ICustomBody* rigidBody_Static = NULL;
|
ICustomBody* rigidBody_Static = NULL;
|
||||||
if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_Sky)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_World)
|
|
||||||
{
|
|
||||||
|
|
||||||
Oyster::Math::Float3 rigidWorldPos;
|
|
||||||
Oyster::Math::Float4 rigidWorldRotation;
|
|
||||||
float rigidBodyMass;
|
|
||||||
float rigidBodyRadius;
|
|
||||||
|
|
||||||
//offset the rigidPosition from modelspace to worldspace;
|
|
||||||
rigidWorldPos = Oyster::Math::Float3(0,0,0);
|
|
||||||
//scales the position so the collision geomentry is in the right place
|
|
||||||
|
|
||||||
//offset the rigidRotation from modelspace to worldspace;
|
|
||||||
|
|
||||||
rigidWorldRotation = Oyster::Math::Float4(0,0,0,1);
|
|
||||||
|
|
||||||
|
|
||||||
//mass scaled
|
|
||||||
rigidBodyMass = 100;
|
|
||||||
|
|
||||||
//Radius scaled
|
|
||||||
rigidBodyRadius = 150;
|
|
||||||
|
|
||||||
//create the rigid body
|
|
||||||
rigidBody_Static = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, 1,1,1);
|
|
||||||
|
|
||||||
}
|
|
||||||
// collision shape
|
// collision shape
|
||||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||||
{
|
{
|
||||||
rigidBody_Static = InitRigidBodySphere(staticObjData);
|
rigidBody_Static = InitRigidBodySphere(staticObjData);
|
||||||
}
|
}
|
||||||
|
@ -332,8 +318,9 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
void Level::InitiateLevel(float radius)
|
bool Level::InitiateLevel(float radius)
|
||||||
{
|
{
|
||||||
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
API::Instance().SetGravity(200);
|
API::Instance().SetGravity(200);
|
||||||
|
@ -353,16 +340,16 @@ void Level::InitiateLevel(float radius)
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for(int i =0; i< nrOfBoxex; i ++)
|
for(int i =0; i< nrOfBoxex; i ++)
|
||||||
{
|
{
|
||||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
|
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
|
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
||||||
}
|
}
|
||||||
/*offset += nrOfBoxex;
|
/*offset += nrOfBoxex;
|
||||||
for(int i =0; i< nrOfBoxex; i ++)
|
for(int i =0; i< nrOfBoxex; i ++)
|
||||||
{
|
{
|
||||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5);
|
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5);
|
||||||
|
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
|
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -371,7 +358,7 @@ void Level::InitiateLevel(float radius)
|
||||||
{
|
{
|
||||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(200, 620 + ( i*7), 0), 5);
|
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(200, 620 + ( i*7), 0), 5);
|
||||||
|
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
|
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
|
||||||
}
|
}
|
||||||
offset += nrOfBoxex;
|
offset += nrOfBoxex;
|
||||||
|
@ -379,23 +366,24 @@ void Level::InitiateLevel(float radius)
|
||||||
{
|
{
|
||||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(5, 605 + i*5, 0), 5);
|
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(5, 605 + i*5, 0), 5);
|
||||||
|
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// add crystal
|
// add crystal
|
||||||
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
||||||
|
|
||||||
// add house
|
// add house
|
||||||
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
|
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultOnCollision, ObjectSpecialType_Generic, idCount++));
|
||||||
|
|
||||||
// add jumppad
|
// add jumppad
|
||||||
|
|
||||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1.0f, 1.0f, 1.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(4.0f, 600.3f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::AddPlayerToTeam(Player *player, int teamID)
|
void Level::AddPlayerToTeam(Player *player, int teamID)
|
||||||
|
@ -419,7 +407,7 @@ int Level::getNrOfDynamicObj()
|
||||||
}
|
}
|
||||||
Object* Level::GetObj( int ID) const
|
Object* Level::GetObj( int ID) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->dynamicObjects.Size(); i++)
|
for (int i = 0; i < (int)this->dynamicObjects.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->dynamicObjects[i]->GetID() == ID)
|
if(this->dynamicObjects[i]->GetID() == ID)
|
||||||
return this->dynamicObjects[i];
|
return this->dynamicObjects[i];
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "PhysicsAPI.h"
|
#include "PhysicsAPI.h"
|
||||||
#include "TeamManager.h"
|
#include "TeamManager.h"
|
||||||
#include "DynamicArray.h"
|
#include "DynamicArray.h"
|
||||||
#include "LevelLoader/LevelLoader.h"
|
#include "LevelLoader.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -30,8 +30,8 @@ namespace GameLogic
|
||||||
* Initiates a level for players to play on
|
* Initiates a level for players to play on
|
||||||
* @param levelPath: Path to a file that contains all information on the level
|
* @param levelPath: Path to a file that contains all information on the level
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void InitiateLevel(std::string levelPath);
|
bool InitiateLevel(std::wstring levelPath);
|
||||||
void InitiateLevel(float radius);
|
bool InitiateLevel(float radius);
|
||||||
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
||||||
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
||||||
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef LEVELLOADER_H
|
|
||||||
#define LEVELLOADER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "Utilities.h"
|
|
||||||
#include "ObjectDefines.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
class LevelLoader
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
LevelLoader();
|
|
||||||
/***********************************************************
|
|
||||||
* Lets you set the standard folderpath for the levels
|
|
||||||
********************************************************/
|
|
||||||
LevelLoader(std::string folderPath);
|
|
||||||
~LevelLoader();
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Loads the level and objects from file.
|
|
||||||
* @param fileName: Path/name to the level-file that you want to load.
|
|
||||||
* @return: Returns all structs with objects and information about the level.
|
|
||||||
********************************************************/
|
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Just for fast access for the meta information about the level.
|
|
||||||
* @param fileName: Path to the level-file that you want to load.
|
|
||||||
* @return: Returns the meta information about the level.
|
|
||||||
********************************************************/
|
|
||||||
LevelMetaData LoadLevelHeader(std::string fileName); //.
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* @return: Returns the current standard folder path
|
|
||||||
********************************************************/
|
|
||||||
std::string GetFolderPath();
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Sets the standard folder path
|
|
||||||
********************************************************/
|
|
||||||
void SetFolderPath(std::string folderPath);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct PrivData;
|
|
||||||
Utility::DynamicMemory::SmartPointer<PrivData> pData;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,314 +0,0 @@
|
||||||
/////////////////////////////////////
|
|
||||||
// Created by Pontus Fransson 2013 //
|
|
||||||
/////////////////////////////////////
|
|
||||||
|
|
||||||
#include "LevelParser.h"
|
|
||||||
#include "Loader.h"
|
|
||||||
#include "ParseFunctions.h"
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
|
||||||
using namespace ::LevelFileLoader;
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
|
|
||||||
LevelParser::LevelParser()
|
|
||||||
{
|
|
||||||
formatVersion.formatVersionMajor = 3;
|
|
||||||
formatVersion.formatVersionMinor = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelParser::~LevelParser()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filename)
|
|
||||||
{
|
|
||||||
int bufferSize = 0;
|
|
||||||
int counter = 0;
|
|
||||||
bool loadCgf;
|
|
||||||
|
|
||||||
std::vector<SmartPointer<ObjectTypeHeader>> objects;
|
|
||||||
|
|
||||||
//Read entire level file.
|
|
||||||
Loader loader;
|
|
||||||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
|
||||||
|
|
||||||
//Read format version
|
|
||||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
|
||||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
|
||||||
counter += sizeof(levelFormatVersion);
|
|
||||||
if(this->formatVersion != levelFormatVersion)
|
|
||||||
{
|
|
||||||
//Returns an empty vector, because it will most likely fail to read the level format.
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(counter < bufferSize)
|
|
||||||
{
|
|
||||||
loadCgf = true;
|
|
||||||
//Get typeID
|
|
||||||
ObjectType typeID;
|
|
||||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
|
||||||
switch((int)typeID)
|
|
||||||
{
|
|
||||||
case ObjectType_LevelMetaData:
|
|
||||||
{
|
|
||||||
SmartPointer<ObjectTypeHeader> header = new LevelMetaData;
|
|
||||||
ParseLevelMetaData(&buffer[counter], *(LevelMetaData*)header.Get(), counter);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectType_SpawnPoint:
|
|
||||||
{
|
|
||||||
loadCgf = false;
|
|
||||||
ObjectHeader* header = new ObjectHeader;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
SpawnPointAttributes* spawn = new SpawnPointAttributes;
|
|
||||||
|
|
||||||
spawn->typeID = header->typeID;
|
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
spawn->position[i] = header->position[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
delete header;
|
|
||||||
//objects.push_back(header);
|
|
||||||
objects.push_back(spawn);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
|
||||||
//Unless they are changed to not be the same.
|
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
|
||||||
{
|
|
||||||
//Get specialType.
|
|
||||||
ObjectSpecialType specialType;
|
|
||||||
ParseObject(&buffer[counter+4], &specialType, sizeof(typeID));
|
|
||||||
|
|
||||||
switch(specialType)
|
|
||||||
{
|
|
||||||
//there is no difference when parsing these specialTypes.
|
|
||||||
case ObjectSpecialType_CrystalShard:
|
|
||||||
case ObjectSpecialType_CrystalFormation:
|
|
||||||
case ObjectSpecialType_Spike:
|
|
||||||
case ObjectSpecialType_SpikeBox:
|
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
|
||||||
case ObjectSpecialType_StandardBox:
|
|
||||||
case ObjectSpecialType_Stone:
|
|
||||||
case ObjectSpecialType_Building:
|
|
||||||
{
|
|
||||||
ObjectHeader* header = new ObjectHeader;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
objects.push_back(header);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_JumpPad:
|
|
||||||
{
|
|
||||||
JumpPadAttributes* header = new JumpPadAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
//Read the spec
|
|
||||||
ParseObject(&buffer[counter], header->direction, 16);
|
|
||||||
counter += 16;
|
|
||||||
objects.push_back(header);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_Portal:
|
|
||||||
{
|
|
||||||
PortalAttributes* header = new PortalAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
ParseObject(&buffer[counter], header->destination, 12);
|
|
||||||
counter += 12;
|
|
||||||
objects.push_back(header);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_World:
|
|
||||||
{
|
|
||||||
WorldAttributes* header = new WorldAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
ParseObject(&buffer[counter], &header->worldSize, 8);
|
|
||||||
counter += 8;
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectSpecialType_Sky:
|
|
||||||
{
|
|
||||||
loadCgf = false;
|
|
||||||
SkyAttributes* header = new SkyAttributes;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
|
|
||||||
ParseObject(&buffer[counter], &header->skySize, 4);
|
|
||||||
counter += 4;
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
//Couldn't find specialType
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectType_Light:
|
|
||||||
{
|
|
||||||
LightType lightType;
|
|
||||||
|
|
||||||
//Get Light type
|
|
||||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
|
||||||
|
|
||||||
//We only support PointLight for now.
|
|
||||||
BasicLight* header = new BasicLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
/*switch(lightType)
|
|
||||||
{
|
|
||||||
case LightType_PointLight:
|
|
||||||
{
|
|
||||||
PointLight* header = new PointLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_DirectionalLight:
|
|
||||||
{
|
|
||||||
DirectionalLight* header = new DirectionalLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_SpotLight:
|
|
||||||
{
|
|
||||||
SpotLight* header = new SpotLight;
|
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
|
||||||
objects.push_back(header);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
//Undefined LightType.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;*/
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
//för meta information om leveln.
|
|
||||||
LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|
||||||
{
|
|
||||||
int bufferSize = 0;
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
LevelMetaData levelHeader;
|
|
||||||
levelHeader.typeID = ObjectType::ObjectType_Unknown;
|
|
||||||
|
|
||||||
//Read entire level file.
|
|
||||||
Loader loader;
|
|
||||||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
|
||||||
|
|
||||||
//Read format version
|
|
||||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
|
||||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
|
||||||
counter += sizeof(levelFormatVersion);
|
|
||||||
if(this->formatVersion != levelFormatVersion)
|
|
||||||
{
|
|
||||||
//Do something if it's not the same version
|
|
||||||
|
|
||||||
//Returns an empty levelHeader with ObjectType_Unknown.
|
|
||||||
//Because it will not be able to read another version of the level format.
|
|
||||||
return levelHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Find the header in the returned string.
|
|
||||||
while(counter < bufferSize)
|
|
||||||
{
|
|
||||||
ObjectType typeID;
|
|
||||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
|
||||||
|
|
||||||
switch(typeID)
|
|
||||||
{
|
|
||||||
case ObjectType_LevelMetaData:
|
|
||||||
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
|
||||||
return levelHeader;
|
|
||||||
break;
|
|
||||||
|
|
||||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
|
||||||
{
|
|
||||||
ObjectHeader header;
|
|
||||||
ParseObject(&buffer[counter], &header, counter);
|
|
||||||
|
|
||||||
switch(header.specialTypeID)
|
|
||||||
{
|
|
||||||
case ObjectSpecialType_JumpPad:
|
|
||||||
counter += sizeof(16);
|
|
||||||
break;
|
|
||||||
case ObjectSpecialType_Portal:
|
|
||||||
counter += sizeof(12);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ObjectType_Light:
|
|
||||||
{
|
|
||||||
LightType lightType;
|
|
||||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
|
||||||
|
|
||||||
//We only support pointlight for now.
|
|
||||||
counter += sizeof(BasicLight);
|
|
||||||
/*
|
|
||||||
switch(lightType)
|
|
||||||
{
|
|
||||||
case LightType_PointLight:
|
|
||||||
{
|
|
||||||
counter += sizeof(PointLight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_DirectionalLight:
|
|
||||||
{
|
|
||||||
counter += sizeof(DirectionalLight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LightType_SpotLight:
|
|
||||||
{
|
|
||||||
counter += sizeof(SpotLight);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
//Undefined LightType.
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return levelHeader;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
#ifndef LEVEL_PARSER_H
|
|
||||||
#define LEVEL_PARSER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "ObjectDefines.h"
|
|
||||||
#include "Utilities.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
namespace LevelFileLoader
|
|
||||||
{
|
|
||||||
class LevelParser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LevelParser();
|
|
||||||
~LevelParser();
|
|
||||||
|
|
||||||
//
|
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> Parse(std::string filename);
|
|
||||||
|
|
||||||
//
|
|
||||||
LevelMetaData ParseHeader(std::string filename);
|
|
||||||
|
|
||||||
private:
|
|
||||||
LevelLoaderInternal::FormatVersion formatVersion;
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,22 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#include "Loader.h"
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
using namespace GameLogic::LevelFileLoader;
|
|
||||||
using namespace Oyster::Resource;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
char* Loader::LoadFile(std::string fileName, int &size)
|
|
||||||
{
|
|
||||||
//convert from string to wstring
|
|
||||||
std::wstring temp(fileName.begin(), fileName.end());
|
|
||||||
|
|
||||||
//convert from wstring to wchar then loads the file
|
|
||||||
char* buffer = (char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
|
|
||||||
|
|
||||||
size = OysterResource::GetResourceSize(buffer);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef LOADER_H
|
|
||||||
#define LOADER_H
|
|
||||||
|
|
||||||
#include "Resource\OysterResource.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
namespace LevelFileLoader
|
|
||||||
{
|
|
||||||
class Loader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Loader (){};
|
|
||||||
~Loader(){};
|
|
||||||
char* LoadFile(std::string fileName, int &size);
|
|
||||||
|
|
||||||
//TODO:
|
|
||||||
//Add functionality to load physicsObjects (hitboxes)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif;
|
|
|
@ -1,274 +0,0 @@
|
||||||
#ifndef OBJECT_DEFINES_H
|
|
||||||
#define OBJECT_DEFINES_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
/************************************
|
|
||||||
Enums
|
|
||||||
*************************************/
|
|
||||||
|
|
||||||
enum ObjectType
|
|
||||||
{
|
|
||||||
ObjectType_LevelMetaData,
|
|
||||||
ObjectType_Static,
|
|
||||||
ObjectType_Dynamic,
|
|
||||||
ObjectType_Light,
|
|
||||||
ObjectType_SpawnPoint,
|
|
||||||
//Etc
|
|
||||||
|
|
||||||
ObjectType_NUM_OF_TYPES,
|
|
||||||
|
|
||||||
ObjectType_Unknown = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ObjectSpecialType
|
|
||||||
{
|
|
||||||
ObjectSpecialType_None,
|
|
||||||
ObjectSpecialType_Sky,
|
|
||||||
ObjectSpecialType_World, //Always the main celestial body
|
|
||||||
ObjectSpecialType_Building,
|
|
||||||
ObjectSpecialType_Stone,
|
|
||||||
ObjectSpecialType_StandardBox,
|
|
||||||
ObjectSpecialType_RedExplosiveBox,
|
|
||||||
ObjectSpecialType_SpikeBox,
|
|
||||||
ObjectSpecialType_Spike,
|
|
||||||
ObjectSpecialType_CrystalFormation,
|
|
||||||
ObjectSpecialType_CrystalShard,
|
|
||||||
ObjectSpecialType_JumpPad,
|
|
||||||
ObjectSpecialType_Portal,
|
|
||||||
ObjectSpecialType_Player,
|
|
||||||
ObjectSpecialType_Generic,
|
|
||||||
|
|
||||||
|
|
||||||
ObjectSpecialType_Count,
|
|
||||||
ObjectSpecialType_Unknown = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CollisionGeometryType
|
|
||||||
{
|
|
||||||
CollisionGeometryType_Box,
|
|
||||||
CollisionGeometryType_Sphere,
|
|
||||||
CollisionGeometryType_Cylinder,
|
|
||||||
|
|
||||||
CollisionGeometryType_Count,
|
|
||||||
CollisionGeometryType_Unknown = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
//Only supports Pointlight right now.
|
|
||||||
enum LightType
|
|
||||||
{
|
|
||||||
LightType_PointLight,
|
|
||||||
//LightType_DirectionalLight,
|
|
||||||
//LightType_SpotLight,
|
|
||||||
|
|
||||||
LightType_Count,
|
|
||||||
LightType_Unknown = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
//Should this be moved somewhere else?
|
|
||||||
enum GameMode
|
|
||||||
{
|
|
||||||
GameMode_FreeForAll,
|
|
||||||
GameMode_TeamDeathMatch,
|
|
||||||
//Etc
|
|
||||||
|
|
||||||
GameMode_Count,
|
|
||||||
GameMode_Unknown = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum WorldSize
|
|
||||||
{
|
|
||||||
WorldSize_Tiny,
|
|
||||||
WorldSize_Small,
|
|
||||||
WorldSize_Medium,
|
|
||||||
WorldSize_Big,
|
|
||||||
WorldSize_Humongous,
|
|
||||||
|
|
||||||
WorldSize_Count,
|
|
||||||
WorldSize_Unknown = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/************************************
|
|
||||||
Structs
|
|
||||||
*************************************/
|
|
||||||
namespace LevelLoaderInternal
|
|
||||||
{
|
|
||||||
struct FormatVersion
|
|
||||||
{
|
|
||||||
unsigned int formatVersionMajor;
|
|
||||||
unsigned int formatVersionMinor;
|
|
||||||
|
|
||||||
FormatVersion()
|
|
||||||
: formatVersionMajor(0), formatVersionMinor(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
FormatVersion(unsigned int major, unsigned int minor)
|
|
||||||
: formatVersionMajor(major), formatVersionMinor(minor)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool operator ==(const FormatVersion& obj)
|
|
||||||
{
|
|
||||||
return (this->formatVersionMajor == obj.formatVersionMajor && this->formatVersionMinor == obj.formatVersionMinor);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator !=(const FormatVersion& obj)
|
|
||||||
{
|
|
||||||
return !(*this == obj);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ObjectTypeHeader
|
|
||||||
{
|
|
||||||
ObjectType typeID;
|
|
||||||
|
|
||||||
//Unless this is here the object destructor wont be called.
|
|
||||||
virtual ~ObjectTypeHeader(){}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace LevelLoaderInternal
|
|
||||||
{
|
|
||||||
const FormatVersion boundingVolumeVersion(2, 0);
|
|
||||||
|
|
||||||
struct BoundingVolumeBase
|
|
||||||
{
|
|
||||||
CollisionGeometryType geoType;
|
|
||||||
float position[3];
|
|
||||||
float rotation[4];
|
|
||||||
float frictionCoeffStatic;
|
|
||||||
float frictionCoeffDynamic;
|
|
||||||
float restitutionCoeff;
|
|
||||||
float mass;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BoundingVolumeBox : public BoundingVolumeBase
|
|
||||||
{
|
|
||||||
float size[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BoundingVolumeSphere : public BoundingVolumeBase
|
|
||||||
{
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BoundingVolumeCylinder : public BoundingVolumeBase
|
|
||||||
{
|
|
||||||
float length;
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BoundingVolume
|
|
||||||
{
|
|
||||||
CollisionGeometryType geoType;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
LevelLoaderInternal::BoundingVolumeBox box;
|
|
||||||
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
|
||||||
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
struct LevelMetaData : public ObjectTypeHeader
|
|
||||||
{
|
|
||||||
std::string levelName;
|
|
||||||
unsigned int levelVersion;
|
|
||||||
std::string levelDescription;
|
|
||||||
std::string levelAuthor;
|
|
||||||
unsigned int maxNumberOfPlayer;
|
|
||||||
WorldSize worldSize;
|
|
||||||
std::string overviewPicturePath;
|
|
||||||
std::vector<GameMode> gameModesSupported;
|
|
||||||
|
|
||||||
virtual ~LevelMetaData(){}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ObjectHeader : public ObjectTypeHeader
|
|
||||||
{
|
|
||||||
//Special type id for special objects: portal, jumppad, exploding objects, etc.
|
|
||||||
ObjectSpecialType specialTypeID;
|
|
||||||
//Model,
|
|
||||||
std::string ModelFile;
|
|
||||||
//Position
|
|
||||||
float position[3];
|
|
||||||
//Rotation Quaternion
|
|
||||||
float rotation[4];
|
|
||||||
//Scale
|
|
||||||
float scale[3];
|
|
||||||
|
|
||||||
::GameLogic::LevelLoaderInternal::BoundingVolume boundingVolume;
|
|
||||||
|
|
||||||
virtual ~ObjectHeader(){}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SpawnPointAttributes : public ObjectTypeHeader
|
|
||||||
{
|
|
||||||
ObjectSpecialType specialTypeID;
|
|
||||||
float position[3];
|
|
||||||
};
|
|
||||||
/************************************
|
|
||||||
Special objects
|
|
||||||
*************************************/
|
|
||||||
|
|
||||||
struct JumpPadAttributes : public ObjectHeader
|
|
||||||
{
|
|
||||||
float direction[3];
|
|
||||||
float power;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PortalAttributes : public ObjectHeader
|
|
||||||
{
|
|
||||||
float destination[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WorldAttributes : public ObjectHeader
|
|
||||||
{
|
|
||||||
float worldSize;
|
|
||||||
float atmoSphereSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SkyAttributes : public ObjectHeader
|
|
||||||
{
|
|
||||||
float skySize;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************
|
|
||||||
Lights
|
|
||||||
*************************************/
|
|
||||||
|
|
||||||
struct BasicLight : public ObjectTypeHeader
|
|
||||||
{
|
|
||||||
LightType lightType; //Is not used right now
|
|
||||||
float color[3];
|
|
||||||
float position[3];
|
|
||||||
float raduis;
|
|
||||||
float intensity;
|
|
||||||
};
|
|
||||||
/* We only support pointlight right now.
|
|
||||||
struct PointLight : public BasicLight
|
|
||||||
{
|
|
||||||
float position[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DirectionalLight : public BasicLight
|
|
||||||
{
|
|
||||||
float direction[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SpotLight : public BasicLight
|
|
||||||
{
|
|
||||||
float direction[3];
|
|
||||||
float range;
|
|
||||||
float attenuation[3];
|
|
||||||
};*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,183 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#include "ParseFunctions.h"
|
|
||||||
#include "Packing/Packing.h"
|
|
||||||
#include "Loader.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace Oyster::Packing;
|
|
||||||
using namespace GameLogic::LevelFileLoader;
|
|
||||||
using namespace GameLogic;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
namespace LevelFileLoader
|
|
||||||
{
|
|
||||||
//can parse any struct if the struct doesnt contain strings or char[]
|
|
||||||
void ParseObject(char* buffer, void *header, int size)
|
|
||||||
{
|
|
||||||
memcpy(header, buffer, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParseObject(char* buffer, ObjectHeader& header, int& size, bool loadCgf)
|
|
||||||
{
|
|
||||||
char tempName[128];
|
|
||||||
unsigned int tempSize = 0;
|
|
||||||
int start = 0;
|
|
||||||
|
|
||||||
memcpy(&header.typeID, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&header.specialTypeID, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
header.ModelFile.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
|
|
||||||
//The reset of the object struct
|
|
||||||
//3 float[3], 1 float
|
|
||||||
memcpy(&header.position, &buffer[start], 40);
|
|
||||||
start += 40;
|
|
||||||
|
|
||||||
//if loadCgf : Read path for bounding volume
|
|
||||||
if(loadCgf)
|
|
||||||
{
|
|
||||||
ParseBoundingVolume(&buffer[start], header.boundingVolume, start);
|
|
||||||
}
|
|
||||||
|
|
||||||
//else make sure the counter counts the name so we can jump over the string in the buffer.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
|
|
||||||
string fileName;
|
|
||||||
fileName.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size += start;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
|
|
||||||
{
|
|
||||||
int start = 0;
|
|
||||||
unsigned int tempSize;
|
|
||||||
char tempName[128];
|
|
||||||
|
|
||||||
memcpy(&header.typeID, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempSize , &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
header.levelName.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
|
|
||||||
memcpy(&header.levelVersion, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start +=4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
header.levelDescription.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
header.levelAuthor.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
|
|
||||||
memcpy(&header.maxNumberOfPlayer, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&header.worldSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
header.overviewPicturePath.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
int temp;
|
|
||||||
|
|
||||||
for(int i = 0; i < tempSize; i++)
|
|
||||||
{
|
|
||||||
memcpy(&temp, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
header.gameModesSupported.push_back((GameMode)temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
size += start;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size)
|
|
||||||
{
|
|
||||||
int start = 0;
|
|
||||||
int tempSize = 0;
|
|
||||||
char tempName[128];
|
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
|
||||||
start += 4;
|
|
||||||
|
|
||||||
memcpy(&tempName, &buffer[start], tempSize);
|
|
||||||
|
|
||||||
string fileName;
|
|
||||||
fileName.assign(&tempName[0], &tempName[tempSize]);
|
|
||||||
start += tempSize;
|
|
||||||
|
|
||||||
size += start;
|
|
||||||
|
|
||||||
//Läs in filen.
|
|
||||||
int fileLength = 0;
|
|
||||||
Loader loader;
|
|
||||||
char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength);
|
|
||||||
|
|
||||||
start = 0;
|
|
||||||
LevelLoaderInternal::FormatVersion version;
|
|
||||||
memcpy(&version, &buf[0], sizeof(version));
|
|
||||||
start += 8;
|
|
||||||
|
|
||||||
memcpy(&volume.geoType, &buf[start], sizeof(volume.geoType));
|
|
||||||
|
|
||||||
switch(volume.geoType)
|
|
||||||
{
|
|
||||||
case CollisionGeometryType_Box:
|
|
||||||
memcpy(&volume.box, &buf[start], sizeof(volume.box));
|
|
||||||
start += sizeof(volume.box);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CollisionGeometryType_Sphere:
|
|
||||||
memcpy(&volume.sphere, &buf[start], sizeof(volume.sphere));
|
|
||||||
start += sizeof(volume.sphere);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CollisionGeometryType_Cylinder:
|
|
||||||
memcpy(&volume.cylinder, &buf[start], sizeof(volume.cylinder));
|
|
||||||
start += sizeof(volume.cylinder);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef PARSERFUNCTIONS_H
|
|
||||||
#define PARSERFUNCTIONS_H
|
|
||||||
#include "ObjectDefines.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
namespace LevelFileLoader
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
These functions will copy data from where the buffer pointer points.
|
|
||||||
header is the destination where the data will be copied.
|
|
||||||
size is either the size of the data to be copied (if it is NOT sent by reference).
|
|
||||||
Or the current index that is being used to parse the entire file (if it is sent by reference) this means you have to increase size with the appropiate size after you have copied.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void ParseObject(char* buffer, void *header, int size);
|
|
||||||
void ParseObject(char* buffer, ObjectHeader& header, int& size , bool loadCgf);
|
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
|
||||||
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -15,11 +15,11 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
|
||||||
|
|
||||||
Object::Object()
|
Object::Object()
|
||||||
{
|
{
|
||||||
|
|
||||||
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||||
|
|
||||||
this->type = ObjectSpecialType_Unknown;
|
this->type = ObjectSpecialType_Unknown;
|
||||||
this->objectID = -1;
|
this->objectID = -1;
|
||||||
|
this->scale = Float3(1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||||
|
@ -48,39 +48,12 @@ Object::~Object(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectSpecialType Object::GetObjectType() const
|
|
||||||
|
void Object::SetOnCollision(OnCollisionCallback func)
|
||||||
{
|
{
|
||||||
return this->type;
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(func));
|
||||||
}
|
|
||||||
int Object::GetID() const
|
|
||||||
{
|
|
||||||
return this->objectID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody* Object::GetRigidBody()
|
|
||||||
{
|
|
||||||
return this->rigidBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Object::BeginFrame()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
// update physic
|
|
||||||
void Object::EndFrame()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter))
|
|
||||||
{
|
|
||||||
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
|
|
||||||
}
|
|
||||||
void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss))
|
|
||||||
{
|
|
||||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
|
||||||
}
|
|
||||||
|
|
||||||
Oyster::Math::Float3 Object::GetPosition()
|
Oyster::Math::Float3 Object::GetPosition()
|
||||||
{
|
{
|
||||||
|
@ -94,21 +67,9 @@ Oyster::Math::Quaternion Object::GetRotation()
|
||||||
state = this->rigidBody->GetState();
|
state = this->rigidBody->GetState();
|
||||||
return state.quaternion;
|
return state.quaternion;
|
||||||
}
|
}
|
||||||
Oyster::Math::Float3 Object::GetScale()
|
|
||||||
{
|
|
||||||
Oyster::Physics::ICustomBody::State state;
|
|
||||||
state = this->rigidBody->GetState();
|
|
||||||
return Float3();
|
|
||||||
}
|
|
||||||
Oyster::Math::Float4x4 Object::GetOrientation()
|
Oyster::Math::Float4x4 Object::GetOrientation()
|
||||||
{
|
{
|
||||||
Oyster::Physics::ICustomBody::State state;
|
Oyster::Physics::ICustomBody::State state;
|
||||||
state = this->rigidBody->GetState();
|
state = this->rigidBody->GetState();
|
||||||
return state.GetOrientation();
|
return state.GetOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Oyster::Math::Float Object::getExtraDamageOnCollision()
|
|
||||||
{
|
|
||||||
return this->extraDamageOnCollision;
|
|
||||||
}
|
|
|
@ -16,47 +16,39 @@ namespace GameLogic
|
||||||
|
|
||||||
class Object :public IObjectData
|
class Object :public IObjectData
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef Oyster::Physics::ICustomBody::SubscriptMessage (*OnCollisionCallback)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Object();
|
Object();
|
||||||
|
|
||||||
Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||||
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||||
~Object(void);
|
~Object(void);
|
||||||
|
|
||||||
ObjectSpecialType GetObjectType() const override;
|
inline ObjectSpecialType GetObjectType() const override { return this->type; }
|
||||||
int GetID() const override;
|
inline int GetID() const override { return this->objectID; }
|
||||||
void setID(int id);
|
inline Oyster::Math::Float3 GetScale() override { return this->scale; }
|
||||||
Oyster::Math::Float3 GetPosition() override;
|
inline Oyster::Math::Float3 GetPosition() override;
|
||||||
Oyster::Math::Quaternion GetRotation() override;
|
inline Oyster::Math::Quaternion GetRotation() override;
|
||||||
Oyster::Math::Float3 GetScale() override;
|
inline Oyster::Math::Float4x4 GetOrientation() override;
|
||||||
Oyster::Math::Float4x4 GetOrientation() override;
|
inline Oyster::Physics::ICustomBody* GetRigidBody() { return this->rigidBody; }
|
||||||
|
inline Oyster::Math::Float GetExtraDamageOnCollision() { return this->extraDamageOnCollision; }
|
||||||
|
|
||||||
Oyster::Math::Float getExtraDamageOnCollision();
|
virtual void BeginFrame() { };
|
||||||
|
virtual void EndFrame() { };
|
||||||
|
|
||||||
// API overrides
|
void SetOnCollision(OnCollisionCallback func);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
|
||||||
|
|
||||||
virtual void BeginFrame();
|
|
||||||
virtual void EndFrame();
|
|
||||||
|
|
||||||
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
|
|
||||||
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
|
|
||||||
|
|
||||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
|
||||||
|
|
||||||
|
|
||||||
public: //TODO: Hax This should be private when level is dynamic
|
|
||||||
|
|
||||||
|
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Oyster::Physics::ICustomBody *rigidBody;
|
Oyster::Physics::ICustomBody *rigidBody;
|
||||||
|
|
||||||
static const Game* gameInstance;
|
static const Game* gameInstance;
|
||||||
Oyster::Math::Float3 currLook;
|
|
||||||
Oyster::Math::Float3 newLook;
|
Oyster::Math::Float3 lookDirection; //The look direction for the camera
|
||||||
|
Oyster::Math::Float3 forwardDirection; //The forward direction of the rigid body
|
||||||
|
Oyster::Math::Float3 scale; //The scale of both rigid body and the mesh
|
||||||
|
|
||||||
ObjectSpecialType type;
|
ObjectSpecialType type;
|
||||||
int objectID;
|
int objectID;
|
||||||
|
|
|
@ -90,7 +90,7 @@ void Player::BeginFrame()
|
||||||
forwardDir.Normalize();
|
forwardDir.Normalize();
|
||||||
rightDir.Normalize();
|
rightDir.Normalize();
|
||||||
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
||||||
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2;
|
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f;
|
||||||
|
|
||||||
if (key_forward > 0.001)
|
if (key_forward > 0.001)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,7 @@ void Player::BeginFrame()
|
||||||
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
|
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
|
||||||
{
|
{
|
||||||
/* Dampen when on the ground and not being moved by the player */
|
/* Dampen when on the ground and not being moved by the player */
|
||||||
linearVelocity *= 0.2;
|
linearVelocity *= 0.2f;
|
||||||
this->rigidBody->SetLinearVelocity (linearVelocity);
|
this->rigidBody->SetLinearVelocity (linearVelocity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -160,7 +160,6 @@ void Player::EndFrame()
|
||||||
|
|
||||||
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
|
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
|
||||||
|
|
||||||
|
|
||||||
Object::EndFrame();
|
Object::EndFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,61 +41,41 @@ namespace GameLogic
|
||||||
|
|
||||||
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
|
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short clientID; // The unuiqe id reprsenting a specific client
|
char majorVersion;
|
||||||
std::string modelName;
|
char minorVersion;
|
||||||
float worldMatrix[16];
|
std::string mapName;
|
||||||
|
|
||||||
Protocol_LobbyCreateGame()
|
Protocol_LobbyCreateGame()
|
||||||
{
|
{
|
||||||
int c = 0;
|
this->protocol[0].value = protocol_Lobby_CreateGame;
|
||||||
this->protocol[c].value = protocol_Lobby_CreateGame;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
|
||||||
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
for (int i = 0; i <= 16; i++)
|
|
||||||
{
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
}
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_CharArray;
|
|
||||||
}
|
}
|
||||||
Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16])
|
Protocol_LobbyCreateGame(char majorVersion, char minorVersion, std::string name)
|
||||||
{
|
{
|
||||||
int c = 0;
|
this->protocol[0].value = protocol_Lobby_CreateGame;
|
||||||
this->protocol[c].value = protocol_Lobby_CreateGame;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
|
||||||
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
|
||||||
|
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->majorVersion = majorVersion;
|
||||||
for (int i = 0; i <= 16; i++)
|
this->minorVersion = minorVersion;
|
||||||
{
|
this->mapName = name;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_CharArray;
|
|
||||||
|
|
||||||
clientID = _clientID;
|
|
||||||
modelName = name;
|
|
||||||
memcpy(&worldMatrix[0], &world[0], sizeof(float) * 16);
|
|
||||||
}
|
}
|
||||||
Protocol_LobbyCreateGame(Oyster::Network::CustomNetProtocol o)
|
Protocol_LobbyCreateGame(Oyster::Network::CustomNetProtocol o)
|
||||||
{
|
{
|
||||||
int c = 1;
|
this->majorVersion = o[1].value.netChar;
|
||||||
clientID = o[c++].value.netInt;
|
this->minorVersion = o[2].value.netChar;
|
||||||
for (int i = 0; i <= 16; i++)
|
this->mapName.assign(o[3].value.netCharPtr);
|
||||||
{
|
|
||||||
this->worldMatrix[i] = o[c++].value.netFloat;
|
|
||||||
}
|
|
||||||
modelName.assign(o[c++].value.netCharPtr);
|
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
int c = 1;
|
protocol[1].value = this->majorVersion;
|
||||||
protocol[c++].value = clientID;
|
protocol[2].value = this->minorVersion;
|
||||||
|
protocol.Set(3, this->mapName);
|
||||||
for (int i = 0; i <= 16; i++)
|
|
||||||
{
|
|
||||||
this->protocol[c++].value = this->worldMatrix[i];
|
|
||||||
}
|
|
||||||
protocol.Set(c++, this->modelName);
|
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -561,11 +561,11 @@ namespace GameLogic
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
//PLAYER_ID
|
//PLAYER_ID
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
//TEAM_ID
|
//TEAM_ID
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
//OWNER
|
//OWNER
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
|
||||||
//PLAYER-NAME
|
//PLAYER-NAME
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
//MESH-NAME
|
//MESH-NAME
|
||||||
|
@ -585,9 +585,10 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->object_ID = p[1].value.netInt;
|
this->owner = p[1].value.netBool;
|
||||||
this->teamId = this->protocol[2].value.netInt;
|
this->object_ID = p[2].value.netInt;
|
||||||
this->owner = this->protocol[3].value.netBool;
|
this->teamId = p[3].value.netInt;
|
||||||
|
|
||||||
this->name.assign(p[4].value.netCharPtr);
|
this->name.assign(p[4].value.netCharPtr);
|
||||||
this->meshName.assign(p[5].value.netCharPtr);
|
this->meshName.assign(p[5].value.netCharPtr);
|
||||||
|
|
||||||
|
@ -610,11 +611,11 @@ namespace GameLogic
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
//PLAYER_ID
|
//PLAYER_ID
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
//TEAM_ID
|
//TEAM_ID
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
//OWNER
|
//OWNER
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
|
||||||
//PLAYER-NAME
|
//PLAYER-NAME
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
//MESH-NAME
|
//MESH-NAME
|
||||||
|
@ -644,10 +645,10 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
|
this->protocol[1].value = this->owner;
|
||||||
this->protocol[1].value = this->object_ID;
|
this->protocol[2].value = this->object_ID;
|
||||||
this->protocol[2].value = this->teamId;
|
this->protocol[3].value = this->teamId;
|
||||||
this->protocol[3].value = this->owner;
|
|
||||||
this->protocol.Set(4, this->name);
|
this->protocol.Set(4, this->name);
|
||||||
this->protocol.Set(5, this->meshName);
|
this->protocol.Set(5, this->meshName);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#define DANBIASSERVER_CLIENT_OBJECT_H
|
#define DANBIASSERVER_CLIENT_OBJECT_H
|
||||||
|
|
||||||
#include <NetworkClient.h>
|
#include <NetworkClient.h>
|
||||||
|
#include <NetworkSession.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameAPI.h>
|
#include <GameAPI.h>
|
||||||
#include <Utilities.h>
|
#include <Utilities.h>
|
||||||
|
@ -17,27 +18,59 @@ namespace DanBias
|
||||||
class GameClient
|
class GameClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client, GameLogic::IPlayerData* player);
|
enum ClientState
|
||||||
|
{
|
||||||
|
ClientState_CreatingGame,
|
||||||
|
ClientState_Ready,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient);
|
||||||
virtual~GameClient();
|
virtual~GameClient();
|
||||||
|
|
||||||
GameLogic::IPlayerData* GetPlayer();
|
inline bool operator==(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
|
||||||
GameLogic::IPlayerData* ReleasePlayer();
|
inline bool operator==(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> GetClient();
|
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> ReleaseClient();
|
|
||||||
|
|
||||||
float GetSinceLastResponse() const;
|
inline bool Equals(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
|
||||||
bool IsReady() const;
|
inline bool Equals(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
|
||||||
bool Equals(const Oyster::Network::NetworkClient* c);
|
|
||||||
|
|
||||||
|
inline float GetSinceLastResponse() const { return this->secondsSinceLastResponse; }
|
||||||
|
inline std::wstring GetAlias() const { return this->alias; }
|
||||||
|
inline std::wstring GetCharacter() const { return this->character; }
|
||||||
|
inline bool IsReady() const { return this->isReady; }
|
||||||
|
inline GameLogic::IPlayerData* GetPlayer() const { return this->player; }
|
||||||
|
Oyster::Network::NetClient GetClient() const { return this->client; }
|
||||||
|
ClientState GetState() const { return this->state; }
|
||||||
|
|
||||||
|
|
||||||
|
void SetPlayer(GameLogic::IPlayerData* player);
|
||||||
void SetReadyState(bool isReady);
|
void SetReadyState(bool isReady);
|
||||||
|
void SetAlias(std::wstring alias);
|
||||||
|
void SetCharacter(std::wstring character);
|
||||||
void SetSinceLastResponse(float seconds);
|
void SetSinceLastResponse(float seconds);
|
||||||
|
void SetState(ClientState state);
|
||||||
|
|
||||||
|
GameLogic::IPlayerData* ReleasePlayer();
|
||||||
|
Oyster::Network::NetClient ReleaseClient();
|
||||||
|
|
||||||
|
//NetworkSpecific
|
||||||
|
void SetOwner(Oyster::Network::NetworkSession* owner);
|
||||||
|
void UpdateClient();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameLogic::IPlayerData* player;
|
GameLogic::IPlayerData* player;
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
Oyster::Network::NetClient client;
|
||||||
|
|
||||||
bool isReady;
|
bool isReady;
|
||||||
float secondsSinceLastResponse;
|
float secondsSinceLastResponse;
|
||||||
};
|
|
||||||
|
|
||||||
|
std::wstring alias;
|
||||||
|
std::wstring character;
|
||||||
|
|
||||||
|
ClientState state;
|
||||||
|
};
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
typedef Utility::DynamicMemory::SmartPointer<DanBias::GameClient> gClient;
|
||||||
|
|
||||||
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
||||||
|
|
|
@ -15,11 +15,18 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
struct LobbyLevelData
|
struct LobbyLevelData
|
||||||
{
|
{
|
||||||
int mapNumber;
|
|
||||||
int maxClients;
|
int maxClients;
|
||||||
int gameMode;
|
int gameTimeInMinutes;
|
||||||
int gameTime;
|
std::wstring gameMode;
|
||||||
std::string gameName;
|
std::wstring mapName;
|
||||||
|
std::wstring gameName;
|
||||||
|
LobbyLevelData()
|
||||||
|
: maxClients(10)
|
||||||
|
, gameTimeInMinutes(10)
|
||||||
|
, gameMode(L"unknown")
|
||||||
|
, mapName(L"unknown")
|
||||||
|
, gameName(L"unknown")
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
class GameLobby :public Oyster::Network::NetworkSession
|
class GameLobby :public Oyster::Network::NetworkSession
|
||||||
{
|
{
|
||||||
|
@ -31,35 +38,44 @@ namespace DanBias
|
||||||
|
|
||||||
void SetGameDesc(const LobbyLevelData& desc);
|
void SetGameDesc(const LobbyLevelData& desc);
|
||||||
void GetGameDesc(LobbyLevelData& desc);
|
void GetGameDesc(LobbyLevelData& desc);
|
||||||
bool StartGameSession();
|
/**
|
||||||
|
* If param is true, the server will start a game session regardless of clients connected.
|
||||||
|
*/
|
||||||
|
bool StartGameSession( bool forceStart );
|
||||||
|
|
||||||
|
int GetGameSessionClientCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
||||||
|
|
||||||
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
|
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
|
||||||
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
|
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
|
||||||
//void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
|
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
|
||||||
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
|
void LobbyJoin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
|
||||||
//void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join:
|
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
|
||||||
void LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
|
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
|
||||||
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
|
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
|
||||||
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
|
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
|
||||||
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
|
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
|
||||||
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
|
|
||||||
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
|
private:
|
||||||
|
int FindClient(Oyster::Network::NetworkClient* c);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
void ProcessClients() override;
|
||||||
|
bool Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utility::WinTimer timer;
|
//Utility::WinTimer timer;
|
||||||
float refreshFrequency;
|
//float refreshFrequency;
|
||||||
|
|
||||||
Utility::DynamicMemory::LinkedList<Oyster::Network::NetworkClient*> readyList;
|
Utility::DynamicMemory::LinkedList<Oyster::Network::NetworkClient*> readyList;
|
||||||
GameSession gameSession;
|
GameSession gameSession;
|
||||||
LobbyLevelData description;
|
LobbyLevelData description;
|
||||||
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
|
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> gClients;
|
||||||
};
|
};
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
#endif // !DANBIASGAME_GAMELOBBY_H
|
||||||
|
|
|
@ -55,16 +55,24 @@ namespace DanBias
|
||||||
static void NotifyWhenClientConnect(ClientConnectedNotify func);
|
static void NotifyWhenClientConnect(ClientConnectedNotify func);
|
||||||
static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
|
static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
|
||||||
|
|
||||||
static void GameSetMapName(const wchar_t* val);
|
|
||||||
static void GameSetMaxClients(const int& val);
|
|
||||||
static void GameSetGameMode(const wchar_t* val);
|
|
||||||
static void GameSetGameTime(const int& val);
|
static void GameSetGameTime(const int& val);
|
||||||
static int GameGetMapId();
|
static void GameSetMaxClients(const int& val);
|
||||||
static int GameGetMaxClients();
|
static void GameSetGameName(const wchar_t* val);
|
||||||
static int GameGetGameMode();
|
static void GameSetMapName(const wchar_t* val);
|
||||||
|
static void GameSetGameMode(const wchar_t* val);
|
||||||
|
|
||||||
static int GameGetGameTime();
|
static int GameGetGameTime();
|
||||||
static const char* GameGetGameName();
|
static int GameGetMaxClients();
|
||||||
static bool GameStart();
|
static const wchar_t* GameGetGameMode();
|
||||||
|
static const wchar_t* GameGetGameName();
|
||||||
|
static const wchar_t* GameGetMapName();
|
||||||
|
static int GetConnectedClientCount();
|
||||||
|
|
||||||
|
/* Starts a game
|
||||||
|
* @param forceStart If forceStart is true, server will start with or without clients.
|
||||||
|
* If there are clients not "ready" the will be stareted anyways.
|
||||||
|
*/
|
||||||
|
static bool GameStart(bool forceStart);
|
||||||
|
|
||||||
|
|
||||||
};//End class DanBiasServer
|
};//End class DanBiasServer
|
||||||
|
|
|
@ -31,12 +31,12 @@ namespace DanBias
|
||||||
*/
|
*/
|
||||||
struct GameDescription
|
struct GameDescription
|
||||||
{
|
{
|
||||||
int maxClients;
|
unsigned int maxClients;
|
||||||
int mapNumber;
|
std::wstring mapName;
|
||||||
int gameMode;
|
std::wstring gameMode;
|
||||||
int gameTime;
|
int gameTimeMinutes;
|
||||||
Oyster::Network::NetworkSession* owner;
|
Oyster::Network::NetworkSession* owner;
|
||||||
Utility::DynamicMemory::DynamicArray<Oyster::Network::NetClient> clients;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -44,7 +44,7 @@ namespace DanBias
|
||||||
virtual~GameSession();
|
virtual~GameSession();
|
||||||
|
|
||||||
/** Initiates and creates a game session. */
|
/** Initiates and creates a game session. */
|
||||||
bool Create(GameDescription& desc);
|
bool Create(GameDescription& desc, bool forceStart);
|
||||||
|
|
||||||
/** Runs the game session (ie starts the game loop). */
|
/** Runs the game session (ie starts the game loop). */
|
||||||
void Run();
|
void Run();
|
||||||
|
@ -52,23 +52,27 @@ namespace DanBias
|
||||||
/** Join an existing/running game session
|
/** Join an existing/running game session
|
||||||
* @param client The client to attach to the session
|
* @param client The client to attach to the session
|
||||||
*/
|
*/
|
||||||
bool Attach(Oyster::Network::NetClient client) override;
|
bool Join(gClient client);
|
||||||
void CloseSession( bool dissconnectClients ) override;
|
|
||||||
|
//void CloseSession( bool dissconnectClients ) override;
|
||||||
|
|
||||||
inline bool IsCreated() const { return this->isCreated; }
|
inline bool IsCreated() const { return this->isCreated; }
|
||||||
inline bool IsRunning() const { return this->isRunning; }
|
inline bool IsRunning() const { return this->isRunning; }
|
||||||
operator bool() { return (this->isCreated && this->isCreated); }
|
operator bool() { return (this->isCreated && this->isRunning); }
|
||||||
|
|
||||||
//Private member functions
|
//Private member functions
|
||||||
private:
|
private:
|
||||||
// TODO: find out what this method does..
|
// Client event callback function
|
||||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
|
void ProcessClients() override;
|
||||||
|
bool Send(Oyster::Network::CustomNetProtocol& message) override;
|
||||||
|
bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID) override;
|
||||||
|
|
||||||
//Sends a client to the owner, if obj is NULL then all clients is sent
|
//Sends a client to the owner, if param is NULL then all clients is sent
|
||||||
void SendToOwner(DanBias::GameClient* obj);
|
void SendToOwner(DanBias::GameClient* obj);
|
||||||
|
|
||||||
//Derived from IThreadObject
|
//Derived from IThreadObject
|
||||||
void ThreadEntry() override;
|
void ThreadEntry( ) override;
|
||||||
bool DoWork ( ) override;
|
bool DoWork ( ) override;
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,8 +102,8 @@ namespace DanBias
|
||||||
|
|
||||||
//Private member variables
|
//Private member variables
|
||||||
private:
|
private:
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
Utility::DynamicMemory::DynamicArray<gClient> gClients;
|
||||||
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
|
gClient sessionOwner;
|
||||||
Oyster::Thread::OysterThread worker;
|
Oyster::Thread::OysterThread worker;
|
||||||
GameLogic::GameAPI& gameInstance;
|
GameLogic::GameAPI& gameInstance;
|
||||||
GameLogic::ILevelData *levelData;
|
GameLogic::ILevelData *levelData;
|
||||||
|
@ -115,6 +119,7 @@ namespace DanBias
|
||||||
//TODO: Remove this uggly hax
|
//TODO: Remove this uggly hax
|
||||||
static GameSession* gameSession;
|
static GameSession* gameSession;
|
||||||
|
|
||||||
|
|
||||||
};//End GameSession
|
};//End GameSession
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
#endif // !DANBIASSERVER_GAME_SESSION_H
|
#endif // !DANBIASSERVER_GAME_SESSION_H
|
|
@ -12,51 +12,27 @@ using namespace DanBias;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
|
||||||
GameClient::GameClient(SmartPointer<NetworkClient> client, GameLogic::IPlayerData* player)
|
GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient)
|
||||||
{
|
{
|
||||||
this->client = client;
|
this->client = nwClient;
|
||||||
this->player = player;
|
this->player = 0;
|
||||||
isReady = false;
|
isReady = false;
|
||||||
|
this->character = L"crate_colonists.dan";
|
||||||
|
this->alias = L"Unknown";
|
||||||
|
this->secondsSinceLastResponse = 0.0f;
|
||||||
}
|
}
|
||||||
GameClient::~GameClient()
|
GameClient::~GameClient()
|
||||||
{
|
{
|
||||||
this->client->Disconnect();
|
|
||||||
this->player = 0;
|
this->player = 0;
|
||||||
isReady = false;
|
this->isReady = false;
|
||||||
|
this->character = L"crate_colonists.dan";
|
||||||
|
this->alias = L"Unknown";
|
||||||
|
this->secondsSinceLastResponse = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLogic::IPlayerData* GameClient::GetPlayer()
|
void GameClient::SetPlayer(GameLogic::IPlayerData* player)
|
||||||
{
|
{
|
||||||
return this->player;
|
this->player = player;
|
||||||
}
|
|
||||||
GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
|
||||||
{
|
|
||||||
GameLogic::IPlayerData *temp = this->player;
|
|
||||||
this->player = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
SmartPointer<Oyster::Network::NetworkClient> GameClient::GetClient()
|
|
||||||
{
|
|
||||||
return this->client;
|
|
||||||
}
|
|
||||||
SmartPointer<Oyster::Network::NetworkClient> GameClient::ReleaseClient()
|
|
||||||
{
|
|
||||||
SmartPointer<Oyster::Network::NetworkClient> temp = this->client;
|
|
||||||
this->client = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
float GameClient::GetSinceLastResponse() const
|
|
||||||
{
|
|
||||||
return this->secondsSinceLastResponse;
|
|
||||||
}
|
|
||||||
bool GameClient::IsReady() const
|
|
||||||
{
|
|
||||||
return this->isReady;
|
|
||||||
}
|
|
||||||
bool GameClient::Equals(const NetworkClient* c)
|
|
||||||
{
|
|
||||||
return (c->GetID() == this->client->GetID());
|
|
||||||
}
|
}
|
||||||
void GameClient::SetReadyState(bool r)
|
void GameClient::SetReadyState(bool r)
|
||||||
{
|
{
|
||||||
|
@ -66,5 +42,44 @@ void GameClient::SetSinceLastResponse(float s)
|
||||||
{
|
{
|
||||||
this->secondsSinceLastResponse = s;
|
this->secondsSinceLastResponse = s;
|
||||||
}
|
}
|
||||||
|
void GameClient::SetAlias(std::wstring alias)
|
||||||
|
{
|
||||||
|
this->alias = alias;
|
||||||
|
}
|
||||||
|
void GameClient::SetCharacter(std::wstring character)
|
||||||
|
{
|
||||||
|
this->character = character;
|
||||||
|
}
|
||||||
|
void GameClient::SetState(ClientState state)
|
||||||
|
{
|
||||||
|
this->state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameClient::SetOwner(Oyster::Network::NetworkSession* owner)
|
||||||
|
{
|
||||||
|
this->client->SetOwner(owner);
|
||||||
|
}
|
||||||
|
void GameClient::UpdateClient()
|
||||||
|
{
|
||||||
|
switch (this->state)
|
||||||
|
{
|
||||||
|
case ClientState_Ready:
|
||||||
|
this->client->Update();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IPlayerData* GameClient::ReleasePlayer()
|
||||||
|
{
|
||||||
|
IPlayerData* temp = this->player;
|
||||||
|
this->player = 0;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
NetClient GameClient::ReleaseClient()
|
||||||
|
{
|
||||||
|
NetClient temp = this->client;
|
||||||
|
this->client = 0;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@ using namespace GameLogic;
|
||||||
using namespace DanBias;
|
using namespace DanBias;
|
||||||
|
|
||||||
GameLobby::GameLobby()
|
GameLobby::GameLobby()
|
||||||
{ }
|
{ }
|
||||||
GameLobby::~GameLobby()
|
GameLobby::~GameLobby()
|
||||||
{
|
{
|
||||||
this->clients.Clear();
|
this->gClients.Clear();
|
||||||
}
|
}
|
||||||
void GameLobby::Release()
|
void GameLobby::Release()
|
||||||
{
|
{
|
||||||
|
@ -26,62 +26,86 @@ void GameLobby::Release()
|
||||||
}
|
}
|
||||||
void GameLobby::Update()
|
void GameLobby::Update()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
this->clients[i]->Update();
|
this->gClients[i]->GetClient()->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::SetGameDesc(const LobbyLevelData& desc)
|
void GameLobby::SetGameDesc(const LobbyLevelData& desc)
|
||||||
{
|
{
|
||||||
this->description.gameMode = desc.gameMode;
|
this->description.gameMode = desc.gameMode;
|
||||||
this->description.gameTime = desc.gameTime;
|
this->description.gameName = desc.gameName;
|
||||||
this->description.mapNumber = desc.mapNumber;
|
this->description.mapName = desc.mapName;
|
||||||
|
this->description.gameTimeInMinutes = desc.gameTimeInMinutes;
|
||||||
this->description.maxClients = desc.maxClients;
|
this->description.maxClients = desc.maxClients;
|
||||||
|
|
||||||
|
if(this->gClients.Size() > (unsigned int)desc.maxClients)
|
||||||
|
{
|
||||||
|
//Kick overflow
|
||||||
|
for (unsigned int i = (unsigned int)desc.maxClients - 1; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->gClients.Resize((unsigned int)desc.maxClients);
|
||||||
|
|
||||||
}
|
}
|
||||||
void GameLobby::GetGameDesc(LobbyLevelData& desc)
|
void GameLobby::GetGameDesc(LobbyLevelData& desc)
|
||||||
{
|
{
|
||||||
desc.gameMode = this->description.gameMode;
|
desc.gameTimeInMinutes = this->description.gameTimeInMinutes;
|
||||||
desc.gameTime = this->description.gameTime;
|
|
||||||
desc.mapNumber = this->description.mapNumber;
|
|
||||||
desc.maxClients = this->description.maxClients;
|
desc.maxClients = this->description.maxClients;
|
||||||
|
desc.mapName = this->description.mapName;
|
||||||
|
desc.gameName = this->description.gameName;
|
||||||
|
desc.gameMode = this->description.gameMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
bool GameLobby::StartGameSession( )
|
bool GameLobby::StartGameSession( bool forceStart )
|
||||||
{
|
{
|
||||||
//Check if all clients is ready
|
//Check if all clients is ready, in not force start
|
||||||
if(this->GetClientCount() && this->GetClientCount() == this->readyList.Size())
|
if(!forceStart)
|
||||||
{
|
{
|
||||||
GameSession::GameDescription desc;
|
if(!this->GetClientCount())
|
||||||
desc.maxClients = this->description.maxClients;
|
{ /*None connected*/ return false;}
|
||||||
desc.gameMode = this->description.gameMode;
|
else if( this->GetClientCount() != this->readyList.Size() )
|
||||||
desc.gameTime = this->description.gameTime;
|
{ /*Not enough connected*/ return false; }
|
||||||
desc.mapNumber = this->description.mapNumber;
|
}
|
||||||
desc.owner = this;
|
|
||||||
desc.clients = this->clients;
|
|
||||||
|
|
||||||
if(desc.gameTime == 0.0f)
|
GameSession::GameDescription desc;
|
||||||
desc.gameTime = (int)(60.0f * 10.0f); //note: should be fetched from somewhere.
|
desc.maxClients = this->description.maxClients;
|
||||||
|
desc.gameMode = this->description.gameMode;
|
||||||
|
desc.gameTimeMinutes = this->description.gameTimeInMinutes;
|
||||||
|
desc.mapName = this->description.mapName;
|
||||||
|
desc.owner = this;
|
||||||
|
desc.clients = this->gClients;
|
||||||
|
|
||||||
if(desc.maxClients == 0)
|
if(desc.gameTimeMinutes == 0)
|
||||||
desc.maxClients = 10; //note: should be fetched somewhere else..
|
desc.gameTimeMinutes = 10; //note: should be fetched from somewhere.
|
||||||
|
|
||||||
this->clients.Clear(); //Remove clients from lobby list
|
if(desc.maxClients == 0)
|
||||||
|
desc.maxClients = 10; //note: should be fetched somewhere else..
|
||||||
|
|
||||||
|
this->gClients.Clear(); //Remove clients from lobby list
|
||||||
|
|
||||||
if(this->gameSession.Create(desc))
|
if(this->gameSession.Create(desc, forceStart))
|
||||||
{
|
|
||||||
this->gameSession.Run();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
//?
|
this->gameSession.Run();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int GameLobby::GetGameSessionClientCount()
|
||||||
|
{
|
||||||
|
return this->gameSession.GetClientCount();
|
||||||
|
}
|
||||||
|
|
||||||
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||||
{
|
{
|
||||||
|
@ -95,9 +119,9 @@ void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::Clie
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
e.sender->Disconnect();
|
//e.sender->Disconnect();
|
||||||
this->readyList.Remove(e.sender);
|
//this->readyList.Remove(e.sender);
|
||||||
this->clients.Remove(e.sender);
|
//this->gClients.Remove(e.sender);
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
|
@ -111,21 +135,30 @@ void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster
|
||||||
|
|
||||||
if(this->gameSession)
|
if(this->gameSession)
|
||||||
{
|
{
|
||||||
Attach(client);
|
if(!this->Attach(client))
|
||||||
|
{
|
||||||
|
client->Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Attach(client);
|
if(!this->Attach(client))
|
||||||
|
{
|
||||||
|
//Send message that lobby full
|
||||||
|
client->Disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Protocol_LobbyClientData p1;
|
Protocol_LobbyClientData p1;
|
||||||
Protocol_LobbyGameData p2;
|
Protocol_LobbyGameData p2;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
Protocol_LobbyClientData::PlayerData t;
|
Protocol_LobbyClientData::PlayerData t;
|
||||||
t.id = this->clients[i]->GetID();
|
t.id = client->GetID();
|
||||||
t.ip = this->clients[i]->GetIpAddress();
|
t.ip = client->GetIpAddress();
|
||||||
t.team = 0;
|
t.team = 0;
|
||||||
t.name = "Dennis är kung tycker Erik!";
|
t.name = "Dennis är kung tycker Erik!";
|
||||||
p1.list.Push(t);
|
p1.list.Push(t);
|
||||||
|
@ -139,4 +172,44 @@ void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster
|
||||||
client->Send(p2.GetProtocol());
|
client->Send(p2.GetProtocol());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void GameLobby::ProcessClients()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->UpdateClient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool GameLobby::Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||||
|
{
|
||||||
|
if(this->clientCount == this->description.maxClients) return false;
|
||||||
|
|
||||||
|
client->SetOwner(this);
|
||||||
|
|
||||||
|
bool added = false;
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(!this->gClients[i])
|
||||||
|
{
|
||||||
|
added = true;
|
||||||
|
this->gClients[i] = new GameClient(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!added)
|
||||||
|
{
|
||||||
|
this->gClients.Push(new GameClient(client));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,27 +12,23 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie
|
||||||
{
|
{
|
||||||
switch (p[0].value.netShort)
|
switch (p[0].value.netShort)
|
||||||
{
|
{
|
||||||
case protocol_General_Status: this->GeneralStatus (Protocol_General_Status (p), c);
|
case protocol_General_Status: this->GeneralStatus (Protocol_General_Status (p), c);
|
||||||
break;
|
break;
|
||||||
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
|
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
|
||||||
break;
|
break;
|
||||||
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
|
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
|
||||||
//break;
|
|
||||||
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
|
|
||||||
break;
|
break;
|
||||||
//case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
|
case protocol_Lobby_JoinGame: this->LobbyJoin (Protocol_LobbyJoinGame (p), c);
|
||||||
//break;
|
|
||||||
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c);
|
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
|
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_GameData: this->LobbyGameData (Protocol_LobbyGameData (p), c);
|
case protocol_Lobby_GameData: this->LobbyGameData (Protocol_LobbyGameData (p), c);
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_ClientData: this->LobbyMainData (Protocol_LobbyClientData (p), c);
|
case protocol_Lobby_ClientData: this->LobbyMainData (Protocol_LobbyClientData (p), c);
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_ClientReadyState: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
|
case protocol_Lobby_ClientReadyState: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_QuerryGameType: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
|
case protocol_Lobby_QuerryGameType: this->LobbyQuerryGameData (Protocol_QuerryGameType (), c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,52 +40,75 @@ void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Net
|
||||||
{
|
{
|
||||||
case Protocol_General_Status::States_ready:
|
case Protocol_General_Status::States_ready:
|
||||||
{
|
{
|
||||||
|
int temp = FindClient(c);
|
||||||
|
if(temp != -1 )
|
||||||
|
{
|
||||||
|
switch (this->gClients[temp]->GetState())
|
||||||
|
{
|
||||||
|
case GameClient::ClientState_CreatingGame:
|
||||||
|
{
|
||||||
|
this->gameSession.Join(this->gClients[temp]);
|
||||||
|
this->gClients[temp] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c->Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_idle:
|
case Protocol_General_Status::States_idle:
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_leave:
|
case Protocol_General_Status::States_leave:
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_disconected:
|
case Protocol_General_Status::States_disconected:
|
||||||
{
|
{
|
||||||
Detach(c)->Disconnect();
|
Detach(c)->Disconnect();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
printf(p.text.c_str());
|
printf(p.text.c_str());
|
||||||
}
|
}
|
||||||
//void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
|
|
||||||
//{
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
|
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
|
||||||
{
|
{
|
||||||
|
//Send countdown timer before lobby shuts down
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(Protocol_LobbyStartGame(3.0f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Someone else tried to start the server..
|
//Someone else tried to start the server..
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
|
||||||
//{
|
|
||||||
// //for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
|
||||||
// //{
|
|
||||||
// // if (this->gameLobby[i]->GetID() == p.value)
|
|
||||||
// // {
|
|
||||||
// // this->gameLobby[i]->Attach(Detach(c));
|
|
||||||
// // return;
|
|
||||||
// // }
|
|
||||||
// //}
|
|
||||||
//}
|
|
||||||
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
|
|
||||||
{
|
{
|
||||||
|
//for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
||||||
|
//{
|
||||||
|
// if (this->gameLobby[i]->GetID() == p.value)
|
||||||
|
// {
|
||||||
|
// this->gameLobby[i]->Attach(Detach(c));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
|
@ -112,31 +131,48 @@ void GameLobby::LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->readyList.Remove(c);
|
this->readyList.Remove(c);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
NetClient temp;
|
if(this->gameSession)
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
//find client in waiting list
|
|
||||||
for (unsigned int i = 0; !found && i < this->clients.Size(); i++)
|
|
||||||
{
|
{
|
||||||
if(this->clients[i]->GetID() == c->GetID())
|
int temp = FindClient(c);
|
||||||
|
|
||||||
|
//Something is wrong
|
||||||
|
if(temp == -1)
|
||||||
{
|
{
|
||||||
temp = this->clients[i];
|
c->Disconnect();
|
||||||
found = true;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Send game data
|
||||||
|
Protocol_LobbyCreateGame lcg((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
|
||||||
|
c->Send(lcg);
|
||||||
|
this->gClients[temp]->SetState(GameClient::ClientState_CreatingGame);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Something is wrong
|
|
||||||
if(!found)
|
|
||||||
{
|
|
||||||
c->Disconnect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Send game data
|
// Nothing.-
|
||||||
this->gameSession.Attach(temp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GameLobby::FindClient(Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
int temp = -1;
|
||||||
|
|
||||||
|
//find client in waiting list
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i]->GetClient()->GetID() == c->GetID())
|
||||||
|
{
|
||||||
|
temp = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
|
@ -118,69 +118,81 @@ void GameServerAPI::NotifyWhenClientDisconnect(ClientDisconnectedNotify func)
|
||||||
else clientDisconnectedCallback = func;
|
else clientDisconnectedCallback = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameServerAPI::GameSetMapName(const wchar_t* val)
|
void GameServerAPI::GameSetMapName(const wchar_t* val)
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
//d.mapNumber = val; //TODO: implement
|
d.mapName = val;
|
||||||
lobby.SetGameDesc(d);
|
lobby.SetGameDesc(d);
|
||||||
}
|
}
|
||||||
void GameServerAPI::GameSetMaxClients(const int& val)
|
void GameServerAPI::GameSetGameMode(const wchar_t* val)
|
||||||
|
{
|
||||||
|
LobbyLevelData d;
|
||||||
|
lobby.GetGameDesc(d);
|
||||||
|
d.gameMode = val;
|
||||||
|
lobby.SetGameDesc(d);
|
||||||
|
}
|
||||||
|
void GameServerAPI::GameSetGameName(const wchar_t* val)
|
||||||
|
{
|
||||||
|
LobbyLevelData d;
|
||||||
|
lobby.GetGameDesc(d);
|
||||||
|
d.gameName = val;
|
||||||
|
lobby.SetGameDesc(d);
|
||||||
|
}
|
||||||
|
void GameServerAPI::GameSetMaxClients(const int& val)
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
d.maxClients = val;
|
d.maxClients = val;
|
||||||
lobby.SetGameDesc(d);
|
lobby.SetGameDesc(d);
|
||||||
}
|
}
|
||||||
void GameServerAPI::GameSetGameMode(const wchar_t* val)
|
void GameServerAPI::GameSetGameTime(const int& val)
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
//d.gameMode = val; //TODO: implement
|
d.gameTimeInMinutes = val;
|
||||||
lobby.SetGameDesc(d);
|
lobby.SetGameDesc(d);
|
||||||
}
|
}
|
||||||
void GameServerAPI::GameSetGameTime(const int& val)
|
|
||||||
|
const wchar_t* GameServerAPI::GameGetMapName()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
d.gameTime = val;
|
return d.mapName.c_str();
|
||||||
lobby.SetGameDesc(d);
|
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetMapId()
|
int GameServerAPI::GameGetMaxClients()
|
||||||
{
|
|
||||||
LobbyLevelData d;
|
|
||||||
lobby.GetGameDesc(d);
|
|
||||||
return d.mapNumber;
|
|
||||||
}
|
|
||||||
int GameServerAPI::GameGetMaxClients()
|
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.maxClients;
|
return d.maxClients;
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetGameMode()
|
const wchar_t* GameServerAPI::GameGetGameMode()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.gameMode;
|
return d.gameMode.c_str();
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetGameTime()
|
int GameServerAPI::GameGetGameTime()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.gameTime;
|
return d.gameTimeInMinutes;
|
||||||
}
|
}
|
||||||
const char* GameServerAPI::GameGetGameName()
|
const wchar_t* GameServerAPI::GameGetGameName()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.gameName.c_str();
|
return d.gameName.c_str();
|
||||||
}
|
}
|
||||||
bool GameServerAPI::GameStart()
|
int GameServerAPI::GetConnectedClientCount()
|
||||||
{
|
{
|
||||||
if(lobby.StartGameSession())
|
return lobby.GetGameSessionClientCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameServerAPI::GameStart( bool forceStart )
|
||||||
|
{
|
||||||
|
if(lobby.StartGameSession( forceStart ))
|
||||||
{
|
{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,11 +19,8 @@ using namespace Oyster;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
using namespace DanBias;
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
Utility::WinTimer testTimer;
|
|
||||||
int testID = -1;
|
|
||||||
|
|
||||||
bool GameSession::DoWork( )
|
bool GameSession::DoWork( )
|
||||||
{
|
{
|
||||||
|
@ -46,9 +43,9 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
int temp = -1;
|
int temp = -1;
|
||||||
//Find the idiot
|
//Find the idiot
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i]->Equals(e.sender))
|
if(this->gClients[i] && this->gClients[i]->Equals(e.sender))
|
||||||
{
|
{
|
||||||
temp = i;
|
temp = i;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +56,7 @@ namespace DanBias
|
||||||
this->Detach(e.sender)->Disconnect();
|
this->Detach(e.sender)->Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SmartPointer<GameClient> cl = this->clients[temp];
|
SmartPointer<GameClient> cl = this->gClients[temp];
|
||||||
|
|
||||||
switch (e.args.type)
|
switch (e.args.type)
|
||||||
{
|
{
|
||||||
|
@ -69,19 +66,52 @@ namespace DanBias
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
this->Detach(e.sender);
|
//this->Detach(e.sender);
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
//printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
testID = 2;
|
|
||||||
if(cl->GetPlayer()->GetID() == testID)//TODO: TEST
|
|
||||||
{
|
|
||||||
testTimer.reset();
|
|
||||||
}
|
|
||||||
this->ParseProtocol(e.args.data.protocol, cl);
|
this->ParseProtocol(e.args.data.protocol, cl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void GameSession::ProcessClients()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i] )
|
||||||
|
{
|
||||||
|
this->gClients[i]->UpdateClient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool GameSession::Send(Oyster::Network::CustomNetProtocol& message)
|
||||||
|
{
|
||||||
|
bool returnValue = false;
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(message);
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
|
||||||
|
}
|
||||||
|
bool GameSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID)
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(protocol);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
||||||
{
|
{
|
||||||
|
@ -246,7 +276,6 @@ namespace DanBias
|
||||||
printf("Message recieved from (%i):\t %s\n", c->GetClient()->GetID(), p.text.c_str());
|
printf("Message recieved from (%i):\t %s\n", c->GetClient()->GetID(), p.text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
#include "..\GameSession.h"
|
#include "..\GameSession.h"
|
||||||
#include "..\GameClient.h"
|
#include "..\GameClient.h"
|
||||||
|
#include "..\GameLobby.h"
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
|
@ -24,217 +25,256 @@ using namespace Oyster;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
using namespace DanBias;
|
||||||
|
|
||||||
namespace DanBias
|
GameSession* GameSession::gameSession = nullptr;
|
||||||
|
|
||||||
|
GameSession::GameSession()
|
||||||
|
:gameInstance(GameAPI::Instance())
|
||||||
{
|
{
|
||||||
GameSession* GameSession::gameSession = nullptr;
|
this->owner = 0;
|
||||||
|
this->isCreated = false;
|
||||||
|
this->isRunning = false;
|
||||||
|
this->gameSession = this;
|
||||||
|
this->logicFrameTime = DELTA_TIME_20;
|
||||||
|
this->networkFrameTime = DELTA_TIME_20;
|
||||||
|
this->networkTimer.reset();
|
||||||
|
this->logicTimer.reset();
|
||||||
|
|
||||||
GameSession::GameSession()
|
memset(&this->description, 0, sizeof(GameDescription));
|
||||||
:gameInstance(GameAPI::Instance())
|
}
|
||||||
|
|
||||||
|
GameSession::~GameSession()
|
||||||
|
{
|
||||||
|
this->worker.Terminate();
|
||||||
|
this->clients.Clear();
|
||||||
|
this->gameInstance;
|
||||||
|
this->owner = 0;
|
||||||
|
this->isCreated = false;
|
||||||
|
this->isRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameSession::Create(GameDescription& desc, bool forceStart)
|
||||||
|
{
|
||||||
|
this->description = desc;
|
||||||
|
/* Do some error checking */
|
||||||
|
if(!forceStart && desc.clients.Size() == 0) return false;
|
||||||
|
if(!desc.owner) return false;
|
||||||
|
if(this->isCreated) return false;
|
||||||
|
|
||||||
|
/* standard initialization of some data */
|
||||||
|
this->gClients.Resize((unsigned int)desc.maxClients);
|
||||||
|
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||||
{
|
{
|
||||||
this->owner = 0;
|
if(desc.clients[i])
|
||||||
this->isCreated = false;
|
|
||||||
this->isRunning = false;
|
|
||||||
this->gameSession = this;
|
|
||||||
this->logicFrameTime = DELTA_TIME_20;
|
|
||||||
this->networkFrameTime = DELTA_TIME_20;
|
|
||||||
this->networkTimer.reset();
|
|
||||||
this->logicTimer.reset();
|
|
||||||
|
|
||||||
memset(&this->description, 0, sizeof(GameDescription));
|
|
||||||
}
|
|
||||||
|
|
||||||
GameSession::~GameSession()
|
|
||||||
{
|
|
||||||
this->worker.Terminate();
|
|
||||||
this->clients.Clear();
|
|
||||||
this->gameInstance;
|
|
||||||
this->owner = 0;
|
|
||||||
this->isCreated = false;
|
|
||||||
this->isRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameSession::Create(GameDescription& desc)
|
|
||||||
{
|
|
||||||
this->description = desc;
|
|
||||||
/* Do some error checking */
|
|
||||||
if(desc.clients.Size() == 0) return false;
|
|
||||||
if(!desc.owner) return false;
|
|
||||||
if(this->isCreated) return false;
|
|
||||||
|
|
||||||
/* standard initialization of some data */
|
|
||||||
NetworkSession::clients = desc.clients;
|
|
||||||
NetworkSession::clients.Resize((unsigned int)desc.maxClients);
|
|
||||||
this->clients.Resize((unsigned int)desc.maxClients);
|
|
||||||
this->owner = desc.owner;
|
|
||||||
|
|
||||||
/* Initiate the game instance */
|
|
||||||
if(!this->gameInstance.Initiate())
|
|
||||||
{
|
{
|
||||||
printf("Failed to initiate the game instance\n");
|
this->clientCount++;
|
||||||
|
this->gClients[i] = desc.clients[i];
|
||||||
|
this->gClients[i]->SetOwner(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this->owner = desc.owner;
|
||||||
|
|
||||||
/* Create the players in the game instance */
|
/* Initiate the game instance */
|
||||||
GameLogic::IPlayerData* p = 0;
|
if(!this->gameInstance.Initiate())
|
||||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
{
|
||||||
|
printf("Failed to initiate the game instance\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the players in the game instance */
|
||||||
|
GameLogic::IPlayerData* p = 0;
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
if(desc.clients[i])
|
if( (p = this->gameInstance.CreatePlayer()) )
|
||||||
{
|
{
|
||||||
if( (p = this->gameInstance.CreatePlayer()) )
|
this->gClients[i]->SetPlayer(p);
|
||||||
{
|
}
|
||||||
desc.clients[i]->SetOwner(this);
|
else
|
||||||
this->clients[i] = (new GameClient(desc.clients[i], p));
|
{
|
||||||
}
|
printf("Failed to create player (%i)\n", i);
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Failed to create player (%i)\n", i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the game level */
|
|
||||||
if(!(this->levelData = this->gameInstance.CreateLevel()))
|
|
||||||
{
|
|
||||||
printf("Level not created!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set some game instance data options */
|
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectMove);
|
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
|
||||||
this->gameInstance.SetFPS(60);
|
|
||||||
|
|
||||||
this->description.clients.Clear();
|
|
||||||
|
|
||||||
this->isCreated = true;
|
|
||||||
|
|
||||||
/* Create the worker thread */
|
|
||||||
if(this->worker.Create(this, false) != OYSTER_THREAD_ERROR_SUCCESS)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return this->isCreated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::Run()
|
/* Create the game level */
|
||||||
|
if(!(this->levelData = this->gameInstance.CreateLevel(this->description.mapName.c_str())))
|
||||||
{
|
{
|
||||||
if(this->isRunning) return;
|
printf("Level not created!");
|
||||||
|
return false;
|
||||||
if(this->clients.Size() > 0)
|
|
||||||
{
|
|
||||||
this->worker.Start();
|
|
||||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
|
||||||
this->isRunning = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::ThreadEntry( )
|
/* Set some game instance data options */
|
||||||
{
|
this->gameInstance.SetSubscription(GameSession::ObjectMove);
|
||||||
//List with clients that we are waiting on..
|
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
||||||
DynamicArray<SmartPointer<GameClient>> readyList;// = this->clients;
|
this->gameInstance.SetFPS(60);
|
||||||
|
|
||||||
//First we need to clean invalid clients, if any, and tell them to start loading game data
|
this->description.clients.Clear();
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
this->isCreated = true;
|
||||||
if(this->clients[i])
|
|
||||||
{
|
/* Create the worker thread */
|
||||||
if(this->clients[i]->IsReady())
|
if(this->worker.Create(this, false) != OYSTER_THREAD_ERROR_SUCCESS)
|
||||||
{
|
return false;
|
||||||
readyList.Push(this->clients[i]);
|
|
||||||
Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_white.dan", readyList[i]->GetPlayer()->GetOrientation());
|
return this->isCreated;
|
||||||
readyList[readyList.Size() - 1]->GetClient()->Send(p);
|
}
|
||||||
}
|
|
||||||
}
|
void GameSession::Run()
|
||||||
}
|
{
|
||||||
|
if(this->isRunning) return;
|
||||||
|
|
||||||
|
this->worker.Start();
|
||||||
|
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
||||||
|
this->isRunning = true;
|
||||||
|
|
||||||
unsigned int readyCounter = readyList.Size();
|
}
|
||||||
|
|
||||||
//Sync with clients
|
void GameSession::ThreadEntry( )
|
||||||
while (readyCounter != 0)
|
{
|
||||||
|
//List with clients that we are waiting on..
|
||||||
|
DynamicArray<gClient> readyList;// = this->clients;
|
||||||
|
|
||||||
|
//First we need to clean invalid clients, if any, and tell them to start loading game data
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
this->ProcessClients();
|
readyList.Push(this->gClients[i]);
|
||||||
for (unsigned int i = 0; i < readyList.Size(); i++)
|
Protocol_LobbyCreateGame p((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
|
||||||
|
readyList[readyList.Size() - 1]->GetClient()->Send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int readyCounter = readyList.Size();
|
||||||
|
|
||||||
|
//Sync with clients
|
||||||
|
while (readyCounter != 0)
|
||||||
|
{
|
||||||
|
this->ProcessClients();
|
||||||
|
for (unsigned int i = 0; i < readyList.Size(); i++)
|
||||||
|
{
|
||||||
|
if(readyList[i] && readyList[i]->IsReady())
|
||||||
{
|
{
|
||||||
if(readyList[i] && readyList[i]->IsReady())
|
//Need to send information about other players, to all players
|
||||||
|
for (unsigned int k = 0; k < this->gClients.Size(); k++)
|
||||||
{
|
{
|
||||||
//Need to send information about other players, to all players
|
if((this->gClients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->gClients[k]->GetClient()->GetID())
|
||||||
for (unsigned int k = 0; k < this->clients.Size(); k++)
|
|
||||||
{
|
{
|
||||||
if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID())
|
IPlayerData* pl = this->gClients[k]->GetPlayer();
|
||||||
{
|
Protocol_ObjectCreatePlayer p( pl->GetPosition(), pl->GetRotation(), pl->GetScale(),
|
||||||
//Protocol_ObjectCreatePlayer
|
pl->GetID(), true, this->gClients[k]->GetPlayer()->GetTeamID(),
|
||||||
Protocol_ObjectCreate p( this->clients[k]->GetPlayer()->GetPosition(),
|
Utility::String::WStringToString(this->gClients[k]->GetAlias(), std::string()),
|
||||||
this->clients[k]->GetPlayer()->GetRotation(),
|
Utility::String::WStringToString(this->gClients[k]->GetCharacter(), std::string()));
|
||||||
this->clients[k]->GetPlayer()->GetScale(),
|
readyList[i]->GetClient()->Send(p);
|
||||||
this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later..
|
|
||||||
readyList[i]->GetClient()->Send(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readyCounter-- ;
|
|
||||||
readyList[i] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Sleep(5); //TODO: This might not be needed here.
|
readyCounter-- ;
|
||||||
}
|
readyList[i] = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i])
|
|
||||||
{
|
|
||||||
this->clients[i]->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(5));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Sleep(5); //TODO: This might not be needed here.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameSession::Attach(Utility::DynamicMemory::SmartPointer<NetworkClient> client)
|
//Sync with clients before starting countdown
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(!this->isCreated) return false;
|
if(this->gClients[i])
|
||||||
if(this->GetClientCount() == this->clients.Capacity()) return false;
|
|
||||||
|
|
||||||
client->SetOwner(this);
|
|
||||||
|
|
||||||
IPlayerData* player = this->gameInstance.CreatePlayer();
|
|
||||||
if(!player) return false;
|
|
||||||
|
|
||||||
SmartPointer<GameClient> obj = new GameClient(client, player);
|
|
||||||
|
|
||||||
// Send the chosen mesh name
|
|
||||||
Protocol_LobbyCreateGame lcg(obj->GetPlayer()->GetID(), "char_white.dan", obj->GetPlayer()->GetOrientation());
|
|
||||||
obj->GetClient()->Send(lcg);
|
|
||||||
|
|
||||||
// Send the player data only
|
|
||||||
for (unsigned int i = 0; i < this->clients.Capacity(); i++)
|
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
this->gClients[i]->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(5.0f));
|
||||||
{
|
|
||||||
IPlayerData* p = this->clients[i]->GetPlayer();
|
|
||||||
Protocol_ObjectCreate oc(p->GetPosition(), p->GetRotation(), p->GetScale(), p->GetID(), "char_white.dan");
|
|
||||||
//Protocol_ObjectCreatePlayer oc(p->GetPosition(), p->GetRotation(), p->GetScale(), p->GetID(), "char_white.dan");
|
|
||||||
this->clients[i]->GetClient()->Send(oc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(0));
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(!clients[i])
|
|
||||||
{
|
|
||||||
NetworkSession::clients[i] = client;
|
|
||||||
clients[i] = obj;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameSession::CloseSession( bool dissconnectClients )
|
bool GameSession::Join(gClient gameClient)
|
||||||
|
{
|
||||||
|
if(!this->isCreated) return false;
|
||||||
|
if(this->GetClientCount() == this->gClients.Capacity()) return false;
|
||||||
|
|
||||||
|
gameClient->SetOwner(this);
|
||||||
|
|
||||||
|
IPlayerData* playerData = this->gameInstance.CreatePlayer();
|
||||||
|
if(!playerData) return false;
|
||||||
|
|
||||||
|
gameClient->SetPlayer(playerData);
|
||||||
|
NetworkClient* nwClient = gameClient->GetClient();
|
||||||
|
|
||||||
|
// Send the player data only
|
||||||
{
|
{
|
||||||
this->worker.Terminate();
|
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
|
||||||
NetworkSession::CloseSession(true);
|
playerData->GetID(), true, playerData->GetTeamID(),
|
||||||
this->clients.Clear();
|
Utility::String::WStringToString(gameClient->GetAlias(), std::string()),
|
||||||
|
Utility::String::WStringToString(gameClient->GetCharacter(), std::string()));
|
||||||
|
nwClient->Send(oc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
// Send information about other clients
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
IPlayerData* temp = this->gClients[i]->GetPlayer();
|
||||||
|
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
|
||||||
|
temp->GetID(), false, temp->GetTeamID(),
|
||||||
|
Utility::String::WStringToString(this->gClients[i]->GetAlias(), std::string()),
|
||||||
|
Utility::String::WStringToString(this->gClients[i]->GetCharacter(), std::string()));
|
||||||
|
nwClient->Send(oc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Need to be able to get the current gameplay data from the logic, to sync it with the client
|
||||||
|
{
|
||||||
|
DynamicArray<IObjectData*> objects;
|
||||||
|
this->levelData->GetAllDynamicObjects(objects);
|
||||||
|
for (unsigned int i = 0; i < objects.Size(); i++)
|
||||||
|
{
|
||||||
|
//Protocol_ObjectPosition p(movedObject->GetPosition(), id);
|
||||||
|
Protocol_ObjectPositionRotation p(objects[i]->GetPosition(), objects[i]->GetRotation(), objects[i]->GetID());
|
||||||
|
GameSession::gameSession->Send(p.GetProtocol());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the new client to the update list
|
||||||
|
bool added = false;
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; !added && i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(!this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i] = gameClient;
|
||||||
|
// Send the start signal
|
||||||
|
{
|
||||||
|
nwClient->Send(GameLogic::Protocol_LobbyStartGame(0));
|
||||||
|
}
|
||||||
|
added = true;
|
||||||
|
this->clientCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameClient->SetState(GameClient::ClientState_Ready);
|
||||||
|
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
//DynamicArray<gClient> GameSession::CloseSession( bool dissconnectClients )
|
||||||
|
//{
|
||||||
|
// this->worker.Terminate();
|
||||||
|
// //TODO: Send clients to lobby
|
||||||
|
//
|
||||||
|
// //for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
// //{
|
||||||
|
// // if(this->gClients[i])
|
||||||
|
// // {
|
||||||
|
// // ((GameLobby*)this->owner)-> this->gClients[i]
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
//
|
||||||
|
// this->gClients.Clear();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,26 +72,32 @@ void StandaloneGameServerCLI::GameSetMapName(String^ value)
|
||||||
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
||||||
DanBias::GameServerAPI::GameSetMapName(wch);
|
DanBias::GameServerAPI::GameSetMapName(wch);
|
||||||
}
|
}
|
||||||
|
void StandaloneGameServerCLI::GameSetGameMode(String^ value)
|
||||||
|
{
|
||||||
|
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
||||||
|
DanBias::GameServerAPI::GameSetGameMode(wch);
|
||||||
|
}
|
||||||
|
void StandaloneGameServerCLI::GameSetGameName(String^ value)
|
||||||
|
{
|
||||||
|
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
||||||
|
DanBias::GameServerAPI::GameSetGameName(wch);
|
||||||
|
}
|
||||||
|
|
||||||
void StandaloneGameServerCLI::GameSetMaxClients(const int val)
|
void StandaloneGameServerCLI::GameSetMaxClients(const int val)
|
||||||
{
|
{
|
||||||
DanBias::GameServerAPI::GameSetMaxClients(val);
|
DanBias::GameServerAPI::GameSetMaxClients(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandaloneGameServerCLI::GameSetGameMode(String^ value)
|
|
||||||
{
|
|
||||||
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
|
||||||
DanBias::GameServerAPI::GameSetGameMode(wch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StandaloneGameServerCLI::GameSetGameTime(const int val)
|
void StandaloneGameServerCLI::GameSetGameTime(const int val)
|
||||||
{
|
{
|
||||||
DanBias::GameServerAPI::GameSetGameTime(val);
|
DanBias::GameServerAPI::GameSetGameTime(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetMapId()
|
String^ StandaloneGameServerCLI::GameGetMapName()
|
||||||
{
|
{
|
||||||
return DanBias::GameServerAPI::GameGetMapId();
|
return gcnew String( DanBias::GameServerAPI::GameGetMapName());
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetMaxClients()
|
int StandaloneGameServerCLI::GameGetMaxClients()
|
||||||
|
@ -99,9 +105,9 @@ int StandaloneGameServerCLI::GameGetMaxClients()
|
||||||
return DanBias::GameServerAPI::GameGetMaxClients();
|
return DanBias::GameServerAPI::GameGetMaxClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetGameMode()
|
String^ StandaloneGameServerCLI::GameGetGameMode()
|
||||||
{
|
{
|
||||||
return DanBias::GameServerAPI::GameGetGameMode();
|
return gcnew String( DanBias::GameServerAPI::GameGetGameMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetGameTime()
|
int StandaloneGameServerCLI::GameGetGameTime()
|
||||||
|
@ -111,10 +117,17 @@ int StandaloneGameServerCLI::GameGetGameTime()
|
||||||
|
|
||||||
String^ StandaloneGameServerCLI::GameGetGameName()
|
String^ StandaloneGameServerCLI::GameGetGameName()
|
||||||
{
|
{
|
||||||
return gcnew String(DanBias::GameServerAPI::GameGetGameName());
|
return gcnew String( DanBias::GameServerAPI::GameGetGameName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandaloneGameServerCLI::GameStart()
|
bool StandaloneGameServerCLI::GameStart(bool f)
|
||||||
{
|
{
|
||||||
return DanBias::GameServerAPI::GameStart();
|
return DanBias::GameServerAPI::GameStart(f);
|
||||||
}
|
}
|
||||||
|
int StandaloneGameServerCLI::GetClientsConnectedCount()
|
||||||
|
{
|
||||||
|
return DanBias::GameServerAPI::GetConnectedClientCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,18 @@ namespace System { namespace Windows { namespace Interop
|
||||||
bool ServerIsRunning();
|
bool ServerIsRunning();
|
||||||
|
|
||||||
void GameSetMapName(String^ val);
|
void GameSetMapName(String^ val);
|
||||||
void GameSetMaxClients(const int val);
|
|
||||||
void GameSetGameMode(String^ val);
|
void GameSetGameMode(String^ val);
|
||||||
|
void GameSetGameName(String^ val);
|
||||||
|
void GameSetMaxClients(const int val);
|
||||||
void GameSetGameTime(const int val);
|
void GameSetGameTime(const int val);
|
||||||
int GameGetMapId();
|
|
||||||
int GameGetMaxClients();
|
int GameGetMaxClients();
|
||||||
int GameGetGameMode();
|
|
||||||
int GameGetGameTime();
|
int GameGetGameTime();
|
||||||
|
System::String^ GameGetMapName();
|
||||||
|
System::String^ GameGetGameMode();
|
||||||
System::String^ GameGetGameName();
|
System::String^ GameGetGameName();
|
||||||
bool GameStart();
|
bool GameStart( bool forceStart );
|
||||||
|
int GetClientsConnectedCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="StandAloneLauncher.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
</startup>
|
</startup>
|
||||||
|
@ -8,4 +13,11 @@
|
||||||
<probing privatePath="..\..\Bin\DLL\" />
|
<probing privatePath="..\..\Bin\DLL\" />
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
<userSettings>
|
||||||
|
<StandAloneLauncher.Properties.Settings>
|
||||||
|
<setting name="Dennis" serializeAs="String">
|
||||||
|
<value>.\..\Content\</value>
|
||||||
|
</setting>
|
||||||
|
</StandAloneLauncher.Properties.Settings>
|
||||||
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -36,32 +36,58 @@
|
||||||
this.label_listenPort = new System.Windows.Forms.Label();
|
this.label_listenPort = new System.Windows.Forms.Label();
|
||||||
this.panel_serverOptions = new System.Windows.Forms.Panel();
|
this.panel_serverOptions = new System.Windows.Forms.Panel();
|
||||||
this.panel_commands = new System.Windows.Forms.Panel();
|
this.panel_commands = new System.Windows.Forms.Panel();
|
||||||
|
this.timeLimit = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.gameModes = new System.Windows.Forms.ComboBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.forceStart = new System.Windows.Forms.CheckBox();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.labelClientsConnected = new System.Windows.Forms.Label();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.buttonStartGame = new System.Windows.Forms.Button();
|
||||||
this.panel_clientArea = new System.Windows.Forms.Panel();
|
this.panel_clientArea = new System.Windows.Forms.Panel();
|
||||||
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
|
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
|
||||||
this.splitter1 = new System.Windows.Forms.Splitter();
|
this.splitter1 = new System.Windows.Forms.Splitter();
|
||||||
this.clientInfoBox = new System.Windows.Forms.ListBox();
|
this.clientInfoBox = new System.Windows.Forms.ListBox();
|
||||||
this.buttonStartGame = new System.Windows.Forms.Button();
|
this.panel_CommanArea = new System.Windows.Forms.Panel();
|
||||||
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.mapName = new System.Windows.Forms.ComboBox();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.panelServerCommands = new System.Windows.Forms.Panel();
|
||||||
this.gameModes = new System.Windows.Forms.ComboBox();
|
this.buttonExecuteSend = new System.Windows.Forms.Button();
|
||||||
this.timeLimit = new System.Windows.Forms.NumericUpDown();
|
this.panel2 = new System.Windows.Forms.Panel();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||||
this.mapName = new System.Windows.Forms.TextBox();
|
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||||
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
|
this.label8 = new System.Windows.Forms.Label();
|
||||||
|
this.dataProtocolFields = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.buttonAddNewDataField = new System.Windows.Forms.Button();
|
||||||
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
|
this.buttonsAtBottom = new System.Windows.Forms.TableLayoutPanel();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
|
||||||
this.panel_serverOptions.SuspendLayout();
|
this.panel_serverOptions.SuspendLayout();
|
||||||
this.panel_commands.SuspendLayout();
|
this.panel_commands.SuspendLayout();
|
||||||
this.panel_clientArea.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
|
||||||
|
this.panel_clientArea.SuspendLayout();
|
||||||
|
this.panel_CommanArea.SuspendLayout();
|
||||||
|
this.panelServerCommands.SuspendLayout();
|
||||||
|
this.panel2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||||
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
|
this.dataProtocolFields.SuspendLayout();
|
||||||
|
this.buttonsAtBottom.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// serverToggle
|
// serverToggle
|
||||||
//
|
//
|
||||||
this.serverToggle.Location = new System.Drawing.Point(9, 81);
|
this.serverToggle.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
this.serverToggle.Location = new System.Drawing.Point(0, 83);
|
||||||
this.serverToggle.Name = "serverToggle";
|
this.serverToggle.Name = "serverToggle";
|
||||||
this.serverToggle.Size = new System.Drawing.Size(75, 23);
|
this.serverToggle.Size = new System.Drawing.Size(241, 20);
|
||||||
this.serverToggle.TabIndex = 0;
|
this.serverToggle.TabIndex = 0;
|
||||||
this.serverToggle.Text = "Start server";
|
this.serverToggle.Text = "Start server";
|
||||||
this.serverToggle.UseVisualStyleBackColor = true;
|
this.serverToggle.UseVisualStyleBackColor = true;
|
||||||
|
@ -111,7 +137,7 @@
|
||||||
this.listenPort.Size = new System.Drawing.Size(95, 20);
|
this.listenPort.Size = new System.Drawing.Size(95, 20);
|
||||||
this.listenPort.TabIndex = 5;
|
this.listenPort.TabIndex = 5;
|
||||||
this.listenPort.Value = new decimal(new int[] {
|
this.listenPort.Value = new decimal(new int[] {
|
||||||
2048,
|
15151,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
|
@ -133,83 +159,123 @@
|
||||||
this.panel_serverOptions.Controls.Add(this.label_listenPort);
|
this.panel_serverOptions.Controls.Add(this.label_listenPort);
|
||||||
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
|
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
|
||||||
this.panel_serverOptions.Controls.Add(this.label_serverName);
|
this.panel_serverOptions.Controls.Add(this.label_serverName);
|
||||||
this.panel_serverOptions.Location = new System.Drawing.Point(12, 12);
|
this.panel_serverOptions.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel_serverOptions.Location = new System.Drawing.Point(0, 0);
|
||||||
this.panel_serverOptions.Name = "panel_serverOptions";
|
this.panel_serverOptions.Name = "panel_serverOptions";
|
||||||
this.panel_serverOptions.Size = new System.Drawing.Size(183, 113);
|
this.panel_serverOptions.Size = new System.Drawing.Size(241, 103);
|
||||||
this.panel_serverOptions.TabIndex = 6;
|
this.panel_serverOptions.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// panel_commands
|
// panel_commands
|
||||||
//
|
//
|
||||||
this.panel_commands.Controls.Add(this.mapName);
|
|
||||||
this.panel_commands.Controls.Add(this.timeLimit);
|
this.panel_commands.Controls.Add(this.timeLimit);
|
||||||
|
this.panel_commands.Controls.Add(this.mapName);
|
||||||
this.panel_commands.Controls.Add(this.gameModes);
|
this.panel_commands.Controls.Add(this.gameModes);
|
||||||
this.panel_commands.Controls.Add(this.label3);
|
this.panel_commands.Controls.Add(this.label3);
|
||||||
|
this.panel_commands.Controls.Add(this.forceStart);
|
||||||
this.panel_commands.Controls.Add(this.label2);
|
this.panel_commands.Controls.Add(this.label2);
|
||||||
this.panel_commands.Controls.Add(this.label4);
|
this.panel_commands.Controls.Add(this.label4);
|
||||||
|
this.panel_commands.Controls.Add(this.label5);
|
||||||
|
this.panel_commands.Controls.Add(this.labelClientsConnected);
|
||||||
this.panel_commands.Controls.Add(this.label1);
|
this.panel_commands.Controls.Add(this.label1);
|
||||||
this.panel_commands.Controls.Add(this.nrOfClients);
|
this.panel_commands.Controls.Add(this.nrOfClients);
|
||||||
this.panel_commands.Controls.Add(this.buttonStartGame);
|
this.panel_commands.Controls.Add(this.buttonStartGame);
|
||||||
this.panel_commands.Location = new System.Drawing.Point(12, 131);
|
this.panel_commands.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel_commands.Location = new System.Drawing.Point(0, 103);
|
||||||
this.panel_commands.Name = "panel_commands";
|
this.panel_commands.Name = "panel_commands";
|
||||||
this.panel_commands.Size = new System.Drawing.Size(183, 230);
|
this.panel_commands.Size = new System.Drawing.Size(241, 188);
|
||||||
this.panel_commands.TabIndex = 7;
|
this.panel_commands.TabIndex = 7;
|
||||||
this.panel_commands.Visible = false;
|
this.panel_commands.Visible = false;
|
||||||
//
|
//
|
||||||
// panel_clientArea
|
// timeLimit
|
||||||
//
|
//
|
||||||
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
|
this.timeLimit.Location = new System.Drawing.Point(112, 89);
|
||||||
this.panel_clientArea.Controls.Add(this.splitter1);
|
this.timeLimit.Minimum = new decimal(new int[] {
|
||||||
this.panel_clientArea.Controls.Add(this.clientInfoBox);
|
5,
|
||||||
this.panel_clientArea.Location = new System.Drawing.Point(202, 12);
|
0,
|
||||||
this.panel_clientArea.Name = "panel_clientArea";
|
0,
|
||||||
this.panel_clientArea.Size = new System.Drawing.Size(303, 349);
|
0});
|
||||||
this.panel_clientArea.TabIndex = 8;
|
this.timeLimit.Name = "timeLimit";
|
||||||
|
this.timeLimit.Size = new System.Drawing.Size(123, 20);
|
||||||
|
this.timeLimit.TabIndex = 11;
|
||||||
|
this.timeLimit.ThousandsSeparator = true;
|
||||||
|
this.timeLimit.Value = new decimal(new int[] {
|
||||||
|
15,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
//
|
//
|
||||||
// ServerInfoTextArea
|
// gameModes
|
||||||
//
|
//
|
||||||
this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
|
this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.gameModes.FormattingEnabled = true;
|
||||||
this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.gameModes.Items.AddRange(new object[] {
|
||||||
this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
"Free-for-all",
|
||||||
this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
|
"Team death-match"});
|
||||||
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
|
this.gameModes.Location = new System.Drawing.Point(77, 61);
|
||||||
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
|
this.gameModes.Name = "gameModes";
|
||||||
this.ServerInfoTextArea.ReadOnly = true;
|
this.gameModes.Size = new System.Drawing.Size(158, 21);
|
||||||
this.ServerInfoTextArea.Size = new System.Drawing.Size(303, 197);
|
this.gameModes.TabIndex = 10;
|
||||||
this.ServerInfoTextArea.TabIndex = 1;
|
|
||||||
this.ServerInfoTextArea.Text = "";
|
|
||||||
//
|
//
|
||||||
// splitter1
|
// label3
|
||||||
//
|
//
|
||||||
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
this.label3.AutoSize = true;
|
||||||
this.splitter1.Location = new System.Drawing.Point(0, 147);
|
this.label3.Location = new System.Drawing.Point(8, 96);
|
||||||
this.splitter1.Name = "splitter1";
|
this.label3.Name = "label3";
|
||||||
this.splitter1.Size = new System.Drawing.Size(303, 5);
|
this.label3.Size = new System.Drawing.Size(95, 13);
|
||||||
this.splitter1.TabIndex = 2;
|
this.label3.TabIndex = 9;
|
||||||
this.splitter1.TabStop = false;
|
this.label3.Text = "Time limit (minutes)";
|
||||||
//
|
//
|
||||||
// clientInfoBox
|
// forceStart
|
||||||
//
|
//
|
||||||
this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
|
this.forceStart.AutoSize = true;
|
||||||
this.clientInfoBox.FormattingEnabled = true;
|
this.forceStart.Checked = true;
|
||||||
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
|
this.forceStart.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.clientInfoBox.Name = "clientInfoBox";
|
this.forceStart.Location = new System.Drawing.Point(12, 120);
|
||||||
this.clientInfoBox.Size = new System.Drawing.Size(303, 147);
|
this.forceStart.Name = "forceStart";
|
||||||
this.clientInfoBox.TabIndex = 0;
|
this.forceStart.Size = new System.Drawing.Size(115, 17);
|
||||||
|
this.forceStart.TabIndex = 1;
|
||||||
|
this.forceStart.Text = "Ignore empty lobby";
|
||||||
|
this.forceStart.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// buttonStartGame
|
// label2
|
||||||
//
|
//
|
||||||
this.buttonStartGame.Location = new System.Drawing.Point(53, 195);
|
this.label2.AutoSize = true;
|
||||||
this.buttonStartGame.Name = "buttonStartGame";
|
this.label2.Location = new System.Drawing.Point(8, 69);
|
||||||
this.buttonStartGame.Size = new System.Drawing.Size(75, 23);
|
this.label2.Name = "label2";
|
||||||
this.buttonStartGame.TabIndex = 6;
|
this.label2.Size = new System.Drawing.Size(64, 13);
|
||||||
this.buttonStartGame.Text = "Start game";
|
this.label2.TabIndex = 9;
|
||||||
this.buttonStartGame.UseVisualStyleBackColor = true;
|
this.label2.Text = "Game mode";
|
||||||
this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(9, 15);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(57, 13);
|
||||||
|
this.label4.TabIndex = 8;
|
||||||
|
this.label4.Text = "Map name";
|
||||||
|
//
|
||||||
|
// labelClientsConnected
|
||||||
|
//
|
||||||
|
this.labelClientsConnected.AutoSize = true;
|
||||||
|
this.labelClientsConnected.Location = new System.Drawing.Point(131, 147);
|
||||||
|
this.labelClientsConnected.Name = "labelClientsConnected";
|
||||||
|
this.labelClientsConnected.Size = new System.Drawing.Size(80, 13);
|
||||||
|
this.labelClientsConnected.TabIndex = 8;
|
||||||
|
this.labelClientsConnected.Text = "Game clients: 0";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(8, 38);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(53, 13);
|
||||||
|
this.label1.TabIndex = 8;
|
||||||
|
this.label1.Text = "Client limit";
|
||||||
//
|
//
|
||||||
// nrOfClients
|
// nrOfClients
|
||||||
//
|
//
|
||||||
this.nrOfClients.Location = new System.Drawing.Point(78, 36);
|
this.nrOfClients.Location = new System.Drawing.Point(72, 34);
|
||||||
this.nrOfClients.Maximum = new decimal(new int[] {
|
this.nrOfClients.Maximum = new decimal(new int[] {
|
||||||
20,
|
20,
|
||||||
0,
|
0,
|
||||||
|
@ -221,105 +287,307 @@
|
||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
this.nrOfClients.Name = "nrOfClients";
|
this.nrOfClients.Name = "nrOfClients";
|
||||||
this.nrOfClients.Size = new System.Drawing.Size(39, 20);
|
this.nrOfClients.Size = new System.Drawing.Size(163, 20);
|
||||||
this.nrOfClients.TabIndex = 7;
|
this.nrOfClients.TabIndex = 7;
|
||||||
this.nrOfClients.Value = new decimal(new int[] {
|
this.nrOfClients.Value = new decimal(new int[] {
|
||||||
2,
|
10,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
//
|
//
|
||||||
// label1
|
// buttonStartGame
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.buttonStartGame.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.label1.Location = new System.Drawing.Point(8, 38);
|
this.buttonStartGame.Location = new System.Drawing.Point(0, 166);
|
||||||
this.label1.Name = "label1";
|
this.buttonStartGame.Name = "buttonStartGame";
|
||||||
this.label1.Size = new System.Drawing.Size(53, 13);
|
this.buttonStartGame.Size = new System.Drawing.Size(241, 22);
|
||||||
this.label1.TabIndex = 8;
|
this.buttonStartGame.TabIndex = 6;
|
||||||
this.label1.Text = "Client limit";
|
this.buttonStartGame.Text = "Start game";
|
||||||
|
this.buttonStartGame.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
|
||||||
//
|
//
|
||||||
// label2
|
// panel_clientArea
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
|
||||||
this.label2.Location = new System.Drawing.Point(8, 69);
|
this.panel_clientArea.Controls.Add(this.splitter1);
|
||||||
this.label2.Name = "label2";
|
this.panel_clientArea.Controls.Add(this.clientInfoBox);
|
||||||
this.label2.Size = new System.Drawing.Size(64, 13);
|
this.panel_clientArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.label2.TabIndex = 9;
|
this.panel_clientArea.Location = new System.Drawing.Point(241, 0);
|
||||||
this.label2.Text = "Game mode";
|
this.panel_clientArea.Name = "panel_clientArea";
|
||||||
|
this.panel_clientArea.Size = new System.Drawing.Size(494, 616);
|
||||||
|
this.panel_clientArea.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// gameModes
|
// ServerInfoTextArea
|
||||||
//
|
//
|
||||||
this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
|
||||||
this.gameModes.FormattingEnabled = true;
|
this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.gameModes.Items.AddRange(new object[] {
|
this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
"Free-for-all",
|
this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
"Team death-match"});
|
this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
|
||||||
this.gameModes.Location = new System.Drawing.Point(78, 66);
|
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 269);
|
||||||
this.gameModes.Name = "gameModes";
|
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
|
||||||
this.gameModes.Size = new System.Drawing.Size(99, 21);
|
this.ServerInfoTextArea.ReadOnly = true;
|
||||||
this.gameModes.TabIndex = 10;
|
this.ServerInfoTextArea.Size = new System.Drawing.Size(494, 347);
|
||||||
|
this.ServerInfoTextArea.TabIndex = 1;
|
||||||
|
this.ServerInfoTextArea.Text = "";
|
||||||
//
|
//
|
||||||
// timeLimit
|
// splitter1
|
||||||
//
|
//
|
||||||
this.timeLimit.Location = new System.Drawing.Point(109, 94);
|
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.timeLimit.Minimum = new decimal(new int[] {
|
this.splitter1.Location = new System.Drawing.Point(0, 264);
|
||||||
5,
|
this.splitter1.Name = "splitter1";
|
||||||
0,
|
this.splitter1.Size = new System.Drawing.Size(494, 5);
|
||||||
0,
|
this.splitter1.TabIndex = 2;
|
||||||
0});
|
this.splitter1.TabStop = false;
|
||||||
this.timeLimit.Name = "timeLimit";
|
|
||||||
this.timeLimit.Size = new System.Drawing.Size(68, 20);
|
|
||||||
this.timeLimit.TabIndex = 11;
|
|
||||||
this.timeLimit.ThousandsSeparator = true;
|
|
||||||
this.timeLimit.Value = new decimal(new int[] {
|
|
||||||
5,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
//
|
//
|
||||||
// label3
|
// clientInfoBox
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.label3.Location = new System.Drawing.Point(8, 96);
|
this.clientInfoBox.FormattingEnabled = true;
|
||||||
this.label3.Name = "label3";
|
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.label3.Size = new System.Drawing.Size(95, 13);
|
this.clientInfoBox.Name = "clientInfoBox";
|
||||||
this.label3.TabIndex = 9;
|
this.clientInfoBox.Size = new System.Drawing.Size(494, 264);
|
||||||
this.label3.Text = "Time limit (minutes)";
|
this.clientInfoBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// label4
|
// panel_CommanArea
|
||||||
//
|
//
|
||||||
this.label4.AutoSize = true;
|
this.panel_CommanArea.Controls.Add(this.panelServerCommands);
|
||||||
this.label4.Location = new System.Drawing.Point(9, 15);
|
this.panel_CommanArea.Controls.Add(this.panel_commands);
|
||||||
this.label4.Name = "label4";
|
this.panel_CommanArea.Controls.Add(this.panel_serverOptions);
|
||||||
this.label4.Size = new System.Drawing.Size(57, 13);
|
this.panel_CommanArea.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
this.label4.TabIndex = 8;
|
this.panel_CommanArea.Location = new System.Drawing.Point(0, 0);
|
||||||
this.label4.Text = "Map name";
|
this.panel_CommanArea.Name = "panel_CommanArea";
|
||||||
|
this.panel_CommanArea.Size = new System.Drawing.Size(241, 616);
|
||||||
|
this.panel_CommanArea.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(23, 147);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(81, 13);
|
||||||
|
this.label5.TabIndex = 8;
|
||||||
|
this.label5.Text = "Lobby clients: 0";
|
||||||
//
|
//
|
||||||
// mapName
|
// mapName
|
||||||
//
|
//
|
||||||
this.mapName.Location = new System.Drawing.Point(78, 7);
|
this.mapName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.mapName.FormattingEnabled = true;
|
||||||
|
this.mapName.IntegralHeight = false;
|
||||||
|
this.mapName.Items.AddRange(new object[] {
|
||||||
|
"Set default"});
|
||||||
|
this.mapName.Location = new System.Drawing.Point(72, 7);
|
||||||
this.mapName.Name = "mapName";
|
this.mapName.Name = "mapName";
|
||||||
this.mapName.Size = new System.Drawing.Size(98, 20);
|
this.mapName.Size = new System.Drawing.Size(163, 21);
|
||||||
this.mapName.TabIndex = 12;
|
this.mapName.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// panelServerCommands
|
||||||
|
//
|
||||||
|
this.panelServerCommands.Controls.Add(this.dataProtocolFields);
|
||||||
|
this.panelServerCommands.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panelServerCommands.Location = new System.Drawing.Point(0, 291);
|
||||||
|
this.panelServerCommands.Name = "panelServerCommands";
|
||||||
|
this.panelServerCommands.Size = new System.Drawing.Size(241, 85);
|
||||||
|
this.panelServerCommands.TabIndex = 8;
|
||||||
|
this.panelServerCommands.Visible = false;
|
||||||
|
//
|
||||||
|
// buttonExecuteSend
|
||||||
|
//
|
||||||
|
this.buttonExecuteSend.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.buttonExecuteSend.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.buttonExecuteSend.Location = new System.Drawing.Point(116, 0);
|
||||||
|
this.buttonExecuteSend.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.buttonExecuteSend.Name = "buttonExecuteSend";
|
||||||
|
this.buttonExecuteSend.Size = new System.Drawing.Size(117, 21);
|
||||||
|
this.buttonExecuteSend.TabIndex = 0;
|
||||||
|
this.buttonExecuteSend.Text = "Send";
|
||||||
|
this.buttonExecuteSend.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// panel2
|
||||||
|
//
|
||||||
|
this.panel2.Controls.Add(this.button2);
|
||||||
|
this.panel2.Controls.Add(this.textBox1);
|
||||||
|
this.panel2.Controls.Add(this.comboBox1);
|
||||||
|
this.panel2.Controls.Add(this.numericUpDown1);
|
||||||
|
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panel2.Location = new System.Drawing.Point(4, 32);
|
||||||
|
this.panel2.Name = "panel2";
|
||||||
|
this.panel2.Size = new System.Drawing.Size(233, 21);
|
||||||
|
this.panel2.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// comboBox1
|
||||||
|
//
|
||||||
|
this.comboBox1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
|
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBox1.FormattingEnabled = true;
|
||||||
|
this.comboBox1.IntegralHeight = false;
|
||||||
|
this.comboBox1.Items.AddRange(new object[] {
|
||||||
|
"netBool;",
|
||||||
|
"netChar;",
|
||||||
|
"netUChar;",
|
||||||
|
"netShort;",
|
||||||
|
"netUShort;",
|
||||||
|
"netInt;",
|
||||||
|
"netUInt;",
|
||||||
|
"netInt64;",
|
||||||
|
"netUInt64;",
|
||||||
|
"netFloat;",
|
||||||
|
"netDouble;",
|
||||||
|
"netCharPtr;"});
|
||||||
|
this.comboBox1.Location = new System.Drawing.Point(42, 0);
|
||||||
|
this.comboBox1.Name = "comboBox1";
|
||||||
|
this.comboBox1.Size = new System.Drawing.Size(78, 21);
|
||||||
|
this.comboBox1.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// numericUpDown1
|
||||||
|
//
|
||||||
|
this.numericUpDown1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
|
this.numericUpDown1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.numericUpDown1.Name = "numericUpDown1";
|
||||||
|
this.numericUpDown1.Size = new System.Drawing.Size(42, 20);
|
||||||
|
this.numericUpDown1.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
this.textBox1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
|
this.textBox1.Location = new System.Drawing.Point(120, 0);
|
||||||
|
this.textBox1.Name = "textBox1";
|
||||||
|
this.textBox1.Size = new System.Drawing.Size(64, 20);
|
||||||
|
this.textBox1.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// tableLayoutPanel1
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
|
||||||
|
this.tableLayoutPanel1.ColumnCount = 3;
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35.29412F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 64.70588F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 110F));
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.label7, 1, 0);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.label8, 2, 0);
|
||||||
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 4);
|
||||||
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
|
this.tableLayoutPanel1.RowCount = 1;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 27.05882F));
|
||||||
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(233, 21);
|
||||||
|
this.tableLayoutPanel1.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Location = new System.Drawing.Point(4, 1);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(18, 13);
|
||||||
|
this.label6.TabIndex = 8;
|
||||||
|
this.label6.Text = "ID";
|
||||||
|
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
this.label7.AutoSize = true;
|
||||||
|
this.label7.Location = new System.Drawing.Point(46, 1);
|
||||||
|
this.label7.Name = "label7";
|
||||||
|
this.label7.Size = new System.Drawing.Size(31, 13);
|
||||||
|
this.label7.TabIndex = 8;
|
||||||
|
this.label7.Text = "Type";
|
||||||
|
//
|
||||||
|
// label8
|
||||||
|
//
|
||||||
|
this.label8.AutoSize = true;
|
||||||
|
this.label8.Location = new System.Drawing.Point(123, 1);
|
||||||
|
this.label8.Name = "label8";
|
||||||
|
this.label8.Size = new System.Drawing.Size(34, 13);
|
||||||
|
this.label8.TabIndex = 8;
|
||||||
|
this.label8.Text = "Value";
|
||||||
|
//
|
||||||
|
// dataProtocolFields
|
||||||
|
//
|
||||||
|
this.dataProtocolFields.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
|
||||||
|
this.dataProtocolFields.ColumnCount = 1;
|
||||||
|
this.dataProtocolFields.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 21F));
|
||||||
|
this.dataProtocolFields.Controls.Add(this.panel2, 0, 1);
|
||||||
|
this.dataProtocolFields.Controls.Add(this.tableLayoutPanel1, 0, 0);
|
||||||
|
this.dataProtocolFields.Controls.Add(this.buttonsAtBottom, 0, 2);
|
||||||
|
this.dataProtocolFields.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataProtocolFields.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataProtocolFields.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.dataProtocolFields.Name = "dataProtocolFields";
|
||||||
|
this.dataProtocolFields.RowCount = 3;
|
||||||
|
this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
|
||||||
|
this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
|
||||||
|
this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
|
this.dataProtocolFields.Size = new System.Drawing.Size(241, 85);
|
||||||
|
this.dataProtocolFields.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// buttonAddNewDataField
|
||||||
|
//
|
||||||
|
this.buttonAddNewDataField.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.buttonAddNewDataField.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.buttonAddNewDataField.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.buttonAddNewDataField.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.buttonAddNewDataField.Name = "buttonAddNewDataField";
|
||||||
|
this.buttonAddNewDataField.Size = new System.Drawing.Size(116, 21);
|
||||||
|
this.buttonAddNewDataField.TabIndex = 1;
|
||||||
|
this.buttonAddNewDataField.Text = "Add field";
|
||||||
|
this.buttonAddNewDataField.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddNewDataField.Click += new System.EventHandler(this.buttonAddNewDataField_Click);
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
this.button2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.button2.FlatAppearance.BorderColor = System.Drawing.Color.Black;
|
||||||
|
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.button2.Location = new System.Drawing.Point(184, 0);
|
||||||
|
this.button2.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.button2.Name = "button2";
|
||||||
|
this.button2.Size = new System.Drawing.Size(49, 21);
|
||||||
|
this.button2.TabIndex = 0;
|
||||||
|
this.button2.Text = "remove";
|
||||||
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonsAtBottom
|
||||||
|
//
|
||||||
|
this.buttonsAtBottom.ColumnCount = 2;
|
||||||
|
this.buttonsAtBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.buttonsAtBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.buttonsAtBottom.Controls.Add(this.buttonAddNewDataField, 0, 0);
|
||||||
|
this.buttonsAtBottom.Controls.Add(this.buttonExecuteSend, 1, 0);
|
||||||
|
this.buttonsAtBottom.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.buttonsAtBottom.Location = new System.Drawing.Point(4, 60);
|
||||||
|
this.buttonsAtBottom.Name = "buttonsAtBottom";
|
||||||
|
this.buttonsAtBottom.RowCount = 1;
|
||||||
|
this.buttonsAtBottom.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.buttonsAtBottom.Size = new System.Drawing.Size(233, 21);
|
||||||
|
this.buttonsAtBottom.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(517, 373);
|
this.ClientSize = new System.Drawing.Size(735, 616);
|
||||||
this.Controls.Add(this.panel_clientArea);
|
this.Controls.Add(this.panel_clientArea);
|
||||||
this.Controls.Add(this.panel_commands);
|
this.Controls.Add(this.panel_CommanArea);
|
||||||
this.Controls.Add(this.panel_serverOptions);
|
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClosingEvent);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit();
|
||||||
this.panel_serverOptions.ResumeLayout(false);
|
this.panel_serverOptions.ResumeLayout(false);
|
||||||
this.panel_serverOptions.PerformLayout();
|
this.panel_serverOptions.PerformLayout();
|
||||||
this.panel_commands.ResumeLayout(false);
|
this.panel_commands.ResumeLayout(false);
|
||||||
this.panel_commands.PerformLayout();
|
this.panel_commands.PerformLayout();
|
||||||
this.panel_clientArea.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
|
||||||
|
this.panel_clientArea.ResumeLayout(false);
|
||||||
|
this.panel_CommanArea.ResumeLayout(false);
|
||||||
|
this.panelServerCommands.ResumeLayout(false);
|
||||||
|
this.panel2.ResumeLayout(false);
|
||||||
|
this.panel2.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||||
|
this.tableLayoutPanel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel1.PerformLayout();
|
||||||
|
this.dataProtocolFields.ResumeLayout(false);
|
||||||
|
this.buttonsAtBottom.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -346,7 +614,25 @@
|
||||||
private System.Windows.Forms.NumericUpDown timeLimit;
|
private System.Windows.Forms.NumericUpDown timeLimit;
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.Label label4;
|
private System.Windows.Forms.Label label4;
|
||||||
private System.Windows.Forms.TextBox mapName;
|
private System.Windows.Forms.CheckBox forceStart;
|
||||||
|
private System.Windows.Forms.Label labelClientsConnected;
|
||||||
|
private System.Windows.Forms.Panel panel_CommanArea;
|
||||||
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.ComboBox mapName;
|
||||||
|
private System.Windows.Forms.Panel panelServerCommands;
|
||||||
|
private System.Windows.Forms.Button buttonExecuteSend;
|
||||||
|
private System.Windows.Forms.Panel panel2;
|
||||||
|
private System.Windows.Forms.ComboBox comboBox1;
|
||||||
|
private System.Windows.Forms.TextBox textBox1;
|
||||||
|
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel dataProtocolFields;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||||
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.Label label7;
|
||||||
|
private System.Windows.Forms.Label label8;
|
||||||
|
private System.Windows.Forms.Button buttonAddNewDataField;
|
||||||
|
private System.Windows.Forms.Button button2;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel buttonsAtBottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Timers;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace StandAloneLauncher
|
namespace StandAloneLauncher
|
||||||
{
|
{
|
||||||
|
@ -16,12 +19,22 @@ namespace StandAloneLauncher
|
||||||
{
|
{
|
||||||
System.Windows.Interop.StandaloneGameServerCLI gameServer;
|
System.Windows.Interop.StandaloneGameServerCLI gameServer;
|
||||||
bool serverIsRunning = false;
|
bool serverIsRunning = false;
|
||||||
|
bool gameIsStarted = false;
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
string[] maps = Directory.GetFiles("..\\Content\\Worlds\\");
|
||||||
|
|
||||||
|
for (int i = 0; i < maps.Length; i++)
|
||||||
|
{
|
||||||
|
string temp = maps[i].Split('\\').Last() ;
|
||||||
|
this.mapName.Items.Add(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gameModes.SelectedIndex = 0;
|
||||||
|
this.mapName.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Initiate()
|
public bool Initiate()
|
||||||
|
@ -30,17 +43,17 @@ namespace StandAloneLauncher
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
while (this.Created)
|
while (this.Created)
|
||||||
{
|
{
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
//Do some stuff
|
|
||||||
this.gameServer.ServerUpdate();
|
this.gameServer.ServerUpdate();
|
||||||
|
this.labelClientsConnected.Text = "Clients connected: " + this.gameServer.GetClientsConnectedCount().ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_serverToggle_Click(object sender, EventArgs e)
|
private void button1_serverToggle_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (this.serverIsRunning)
|
if (this.serverIsRunning)
|
||||||
|
@ -53,6 +66,7 @@ namespace StandAloneLauncher
|
||||||
this.serverToggle.Text = "Start server";
|
this.serverToggle.Text = "Start server";
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server terminated!\n");
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server terminated!\n");
|
||||||
this.panel_commands.Visible = false;
|
this.panel_commands.Visible = false;
|
||||||
|
this.panelServerCommands.Visible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -75,6 +89,7 @@ namespace StandAloneLauncher
|
||||||
this.gameServer.ServerStart();
|
this.gameServer.ServerStart();
|
||||||
this.panel_commands.Visible = true;
|
this.panel_commands.Visible = true;
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server initiated!\n\tListening on port " + this.listenPort.Value.ToString() + "\n\tLocal IP: " + info.serverIp + "\n");
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server initiated!\n\tListening on port " + this.listenPort.Value.ToString() + "\n\tLocal IP: " + info.serverIp + "\n");
|
||||||
|
this.panelServerCommands.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -85,18 +100,59 @@ namespace StandAloneLauncher
|
||||||
|
|
||||||
private void buttonStartGame_Click(object sender, EventArgs e)
|
private void buttonStartGame_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
|
if (!gameIsStarted)
|
||||||
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
|
|
||||||
//this.gameServer.GameSetMapId(0);
|
|
||||||
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
|
|
||||||
if (!this.gameServer.GameStart())
|
|
||||||
{
|
{
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
|
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
|
||||||
|
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
|
||||||
|
this.gameServer.GameSetMapName(this.mapName.Text);
|
||||||
|
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
|
||||||
|
|
||||||
|
if (!(gameIsStarted = this.gameServer.GameStart(this.forceStart.Checked)))
|
||||||
|
{
|
||||||
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
|
||||||
|
this.buttonStartGame.Text = "Stop Game";
|
||||||
|
|
||||||
|
this.mapName.Enabled = false;
|
||||||
|
this.nrOfClients.Enabled = false;
|
||||||
|
this.gameModes.Enabled = false;
|
||||||
|
this.timeLimit.Enabled = false;
|
||||||
|
this.forceStart.Enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
|
this.gameIsStarted = false;
|
||||||
|
this.buttonStartGame.Text = "Start Game";
|
||||||
|
this.mapName.Enabled = true;
|
||||||
|
this.nrOfClients.Enabled = true;
|
||||||
|
this.gameModes.Enabled = true;
|
||||||
|
this.timeLimit.Enabled = true;
|
||||||
|
this.forceStart.Enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FormClosingEvent(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (serverIsRunning)
|
||||||
|
{
|
||||||
|
this.gameServer.ServerStop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddNewDataField_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.dataProtocolFields.RowCount++;
|
||||||
|
this.dataProtocolFields.SetRow(this.buttonsAtBottom, this.dataProtocolFields.RowCount - 1);
|
||||||
|
|
||||||
|
Panel p = new Panel();
|
||||||
|
p = this.panel2;
|
||||||
|
|
||||||
|
this.dataProtocolFields.RowStyles.Add(new RowStyle(SizeType.Absolute, 27));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,31 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace StandAloneLauncher.Properties
|
namespace StandAloneLauncher.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute(".\\..\\Content\\")]
|
||||||
|
public string Dennis {
|
||||||
|
get {
|
||||||
|
return ((string)(this["Dennis"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["Dennis"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="StandAloneLauncher.Properties" GeneratedClassName="Settings">
|
||||||
<Profiles>
|
<Profiles />
|
||||||
<Profile Name="(Default)" />
|
<Settings>
|
||||||
</Profiles>
|
<Setting Name="Dennis" Type="System.String" Scope="User">
|
||||||
<Settings />
|
<Value Profile="(Default)">.\..\Content\</Value>
|
||||||
</SettingsFile>
|
</Setting>
|
||||||
|
</Settings>
|
||||||
|
</SettingsFile>
|
|
@ -80,6 +80,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.DirectoryServices" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
|
|
@ -48,5 +48,5 @@ std::string LevelLoader::GetFolderPath()
|
||||||
|
|
||||||
void LevelLoader::SetFolderPath(std::string folderPath)
|
void LevelLoader::SetFolderPath(std::string folderPath)
|
||||||
{
|
{
|
||||||
|
this->pData->folderPath = folderPath;
|
||||||
}
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}</ProjectGuid>
|
||||||
|
<RootNamespace>LevelLoader</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
<Lib>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Lib>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="LevelLoader.cpp" />
|
||||||
|
<ClCompile Include="LevelParser.cpp" />
|
||||||
|
<ClCompile Include="Loader.cpp" />
|
||||||
|
<ClCompile Include="ParseFunctions.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="LevelLoader.h" />
|
||||||
|
<ClInclude Include="LevelParser.h" />
|
||||||
|
<ClInclude Include="Loader.h" />
|
||||||
|
<ClInclude Include="ObjectDefines.h" />
|
||||||
|
<ClInclude Include="ParseFunctions.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Misc\Utilities\Utilities.vcxproj">
|
||||||
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,320 @@
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Created by Pontus Fransson 2013 //
|
||||||
|
/////////////////////////////////////
|
||||||
|
|
||||||
|
#include "LevelParser.h"
|
||||||
|
|
||||||
|
#include "Loader.h"
|
||||||
|
#include "ParseFunctions.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
using namespace ::LevelFileLoader;
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
LevelParser::LevelParser()
|
||||||
|
{
|
||||||
|
formatVersion.formatVersionMajor = 3;
|
||||||
|
formatVersion.formatVersionMinor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LevelParser::~LevelParser()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filename)
|
||||||
|
{
|
||||||
|
int bufferSize = 0;
|
||||||
|
int counter = 0;
|
||||||
|
bool loadCgf;
|
||||||
|
|
||||||
|
std::vector<SmartPointer<ObjectTypeHeader>> objects;
|
||||||
|
|
||||||
|
//Read entire level file.
|
||||||
|
Loader loader;
|
||||||
|
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
||||||
|
|
||||||
|
if(buffer)
|
||||||
|
{
|
||||||
|
//Read format version
|
||||||
|
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
||||||
|
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
||||||
|
counter += sizeof(levelFormatVersion);
|
||||||
|
if(this->formatVersion != levelFormatVersion)
|
||||||
|
{
|
||||||
|
//Returns an empty vector, because it will most likely fail to read the level format.
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(counter < bufferSize)
|
||||||
|
{
|
||||||
|
loadCgf = true;
|
||||||
|
//Get typeID
|
||||||
|
ObjectType typeID;
|
||||||
|
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
||||||
|
switch((int)typeID)
|
||||||
|
{
|
||||||
|
case ObjectType_LevelMetaData:
|
||||||
|
{
|
||||||
|
SmartPointer<ObjectTypeHeader> header = new LevelMetaData;
|
||||||
|
ParseLevelMetaData(&buffer[counter], *(LevelMetaData*)header.Get(), counter);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectType_SpawnPoint:
|
||||||
|
{
|
||||||
|
loadCgf = false;
|
||||||
|
ObjectHeader* header = new ObjectHeader;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
SpawnPointAttributes* spawn = new SpawnPointAttributes;
|
||||||
|
|
||||||
|
spawn->typeID = header->typeID;
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
spawn->position[i] = header->position[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete header;
|
||||||
|
//objects.push_back(header);
|
||||||
|
objects.push_back(spawn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
||||||
|
//Unless they are changed to not be the same.
|
||||||
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
|
{
|
||||||
|
//Get specialType.
|
||||||
|
ObjectSpecialType specialType;
|
||||||
|
ParseObject(&buffer[counter+4], &specialType, sizeof(typeID));
|
||||||
|
|
||||||
|
switch(specialType)
|
||||||
|
{
|
||||||
|
//there is no difference when parsing these specialTypes.
|
||||||
|
case ObjectSpecialType_CrystalShard:
|
||||||
|
case ObjectSpecialType_CrystalFormation:
|
||||||
|
case ObjectSpecialType_Spike:
|
||||||
|
case ObjectSpecialType_SpikeBox:
|
||||||
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
|
case ObjectSpecialType_StandardBox:
|
||||||
|
case ObjectSpecialType_Stone:
|
||||||
|
case ObjectSpecialType_Building:
|
||||||
|
{
|
||||||
|
ObjectHeader* header = new ObjectHeader;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
objects.push_back(header);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectSpecialType_JumpPad:
|
||||||
|
{
|
||||||
|
JumpPadAttributes* header = new JumpPadAttributes;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
//Read the spec
|
||||||
|
ParseObject(&buffer[counter], header->direction, 16);
|
||||||
|
counter += 16;
|
||||||
|
objects.push_back(header);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectSpecialType_Portal:
|
||||||
|
{
|
||||||
|
PortalAttributes* header = new PortalAttributes;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
ParseObject(&buffer[counter], header->destination, 12);
|
||||||
|
counter += 12;
|
||||||
|
objects.push_back(header);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectSpecialType_World:
|
||||||
|
{
|
||||||
|
WorldAttributes* header = new WorldAttributes;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
ParseObject(&buffer[counter], &header->worldSize, 8);
|
||||||
|
counter += 8;
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectSpecialType_Sky:
|
||||||
|
{
|
||||||
|
loadCgf = false;
|
||||||
|
SkyAttributes* header = new SkyAttributes;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
ParseObject(&buffer[counter], &header->skySize, 4);
|
||||||
|
counter += 4;
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
//Couldn't find specialType
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectType_Light:
|
||||||
|
{
|
||||||
|
LightType lightType;
|
||||||
|
|
||||||
|
//Get Light type
|
||||||
|
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||||
|
|
||||||
|
//We only support PointLight for now.
|
||||||
|
BasicLight* header = new BasicLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
/*switch(lightType)
|
||||||
|
{
|
||||||
|
case LightType_PointLight:
|
||||||
|
{
|
||||||
|
PointLight* header = new PointLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_DirectionalLight:
|
||||||
|
{
|
||||||
|
DirectionalLight* header = new DirectionalLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_SpotLight:
|
||||||
|
{
|
||||||
|
SpotLight* header = new SpotLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
//Undefined LightType.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;*/
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
//Couldn't find typeID. FAIL!!!!!!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//för meta information om leveln.
|
||||||
|
LevelMetaData LevelParser::ParseHeader(std::string filename)
|
||||||
|
{
|
||||||
|
int bufferSize = 0;
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
LevelMetaData levelHeader;
|
||||||
|
levelHeader.typeID = ObjectType::ObjectType_Unknown;
|
||||||
|
|
||||||
|
//Read entire level file.
|
||||||
|
Loader loader;
|
||||||
|
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
||||||
|
|
||||||
|
//Read format version
|
||||||
|
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
||||||
|
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
||||||
|
counter += sizeof(levelFormatVersion);
|
||||||
|
if(this->formatVersion != levelFormatVersion)
|
||||||
|
{
|
||||||
|
//Do something if it's not the same version
|
||||||
|
|
||||||
|
//Returns an empty levelHeader with ObjectType_Unknown.
|
||||||
|
//Because it will not be able to read another version of the level format.
|
||||||
|
return levelHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find the header in the returned string.
|
||||||
|
while(counter < bufferSize)
|
||||||
|
{
|
||||||
|
ObjectType typeID;
|
||||||
|
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
||||||
|
|
||||||
|
switch(typeID)
|
||||||
|
{
|
||||||
|
case ObjectType_LevelMetaData:
|
||||||
|
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
||||||
|
return levelHeader;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
||||||
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
|
{
|
||||||
|
ObjectHeader header;
|
||||||
|
ParseObject(&buffer[counter], &header, counter);
|
||||||
|
|
||||||
|
switch(header.specialTypeID)
|
||||||
|
{
|
||||||
|
case ObjectSpecialType_JumpPad:
|
||||||
|
counter += sizeof(16);
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_Portal:
|
||||||
|
counter += sizeof(12);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectType_Light:
|
||||||
|
{
|
||||||
|
LightType lightType;
|
||||||
|
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||||
|
|
||||||
|
//We only support pointlight for now.
|
||||||
|
counter += sizeof(BasicLight);
|
||||||
|
/*
|
||||||
|
switch(lightType)
|
||||||
|
{
|
||||||
|
case LightType_PointLight:
|
||||||
|
{
|
||||||
|
counter += sizeof(PointLight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_DirectionalLight:
|
||||||
|
{
|
||||||
|
counter += sizeof(DirectionalLight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_SpotLight:
|
||||||
|
{
|
||||||
|
counter += sizeof(SpotLight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
//Undefined LightType.
|
||||||
|
break;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
//Couldn't find typeID. FAIL!!!!!!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return levelHeader;
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ namespace GameLogic
|
||||||
ObjectSpecialType_World, //Always the main celestial body
|
ObjectSpecialType_World, //Always the main celestial body
|
||||||
ObjectSpecialType_Building,
|
ObjectSpecialType_Building,
|
||||||
ObjectSpecialType_Stone,
|
ObjectSpecialType_Stone,
|
||||||
ObjectSpecialType_StandarsBox,
|
ObjectSpecialType_StandardBox,
|
||||||
ObjectSpecialType_RedExplosiveBox,
|
ObjectSpecialType_RedExplosiveBox,
|
||||||
ObjectSpecialType_SpikeBox,
|
ObjectSpecialType_SpikeBox,
|
||||||
ObjectSpecialType_Spike,
|
ObjectSpecialType_Spike,
|
||||||
|
@ -40,6 +40,7 @@ namespace GameLogic
|
||||||
ObjectSpecialType_JumpPad,
|
ObjectSpecialType_JumpPad,
|
||||||
ObjectSpecialType_Portal,
|
ObjectSpecialType_Portal,
|
||||||
ObjectSpecialType_Player,
|
ObjectSpecialType_Player,
|
||||||
|
ObjectSpecialType_Generic,
|
||||||
|
|
||||||
|
|
||||||
ObjectSpecialType_Count,
|
ObjectSpecialType_Count,
|
|
@ -117,7 +117,7 @@ namespace GameLogic
|
||||||
|
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
for(int i = 0; i < tempSize; i++)
|
for(int i = 0; i < (int)tempSize; i++)
|
||||||
{
|
{
|
||||||
memcpy(&temp, &buffer[start], 4);
|
memcpy(&temp, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
|
@ -7,6 +7,7 @@
|
||||||
#ifndef _INPUTCLASS_H_
|
#ifndef _INPUTCLASS_H_
|
||||||
#define _INPUTCLASS_H_
|
#define _INPUTCLASS_H_
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
#define DIRECTINPUT_VERSION 0x0800
|
||||||
|
|
||||||
#pragma comment(lib, "dinput8.lib")
|
#pragma comment(lib, "dinput8.lib")
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace LinearAlgebra
|
||||||
const ScalarType & operator [] ( int i ) const;
|
const ScalarType & operator [] ( int i ) const;
|
||||||
|
|
||||||
Quaternion<ScalarType> & operator = ( const Quaternion<ScalarType> &quaternion );
|
Quaternion<ScalarType> & operator = ( const Quaternion<ScalarType> &quaternion );
|
||||||
|
Quaternion<ScalarType> & operator *= ( const Quaternion<ScalarType> &quaternion );
|
||||||
Quaternion<ScalarType> & operator *= ( const ScalarType &scalar );
|
Quaternion<ScalarType> & operator *= ( const ScalarType &scalar );
|
||||||
Quaternion<ScalarType> & operator /= ( const ScalarType &scalar );
|
Quaternion<ScalarType> & operator /= ( const ScalarType &scalar );
|
||||||
Quaternion<ScalarType> & operator += ( const Quaternion<ScalarType> &quaternion );
|
Quaternion<ScalarType> & operator += ( const Quaternion<ScalarType> &quaternion );
|
||||||
|
@ -112,6 +113,12 @@ namespace LinearAlgebra
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const Quaternion<ScalarType> &quaternion )
|
||||||
|
{
|
||||||
|
return *this = *this * quaternion;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const ScalarType &scalar )
|
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const ScalarType &scalar )
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,8 @@ OHRESOURCE OysterResource::LoadResource(const wchar_t* filename, ResourceType ty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!resourceData) return 0;
|
||||||
|
|
||||||
return resourceData->GetResourceHandle();
|
return resourceData->GetResourceHandle();
|
||||||
}
|
}
|
||||||
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)
|
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)
|
||||||
|
|
|
@ -337,11 +337,7 @@ namespace Utility
|
||||||
|
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max )
|
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max )
|
||||||
{
|
{ return value < min ? Max( value, max ) : min; }
|
||||||
if( value < min ) return min;
|
|
||||||
if( value > max ) return max;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
inline ValueType Average( const ValueType &valueA, const ValueType &valueB )
|
inline ValueType Average( const ValueType &valueA, const ValueType &valueB )
|
||||||
|
|
|
@ -40,12 +40,13 @@ CustomNetProtocol::CustomNetProtocol()
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
}
|
}
|
||||||
CustomNetProtocol::CustomNetProtocol(CustomNetProtocol& o)
|
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
this->privateData->attributes = o.privateData->attributes;
|
this->privateData->attributes = o.privateData->attributes;
|
||||||
}
|
}
|
||||||
const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
|
|
||||||
|
CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
if(this->privateData)
|
if(this->privateData)
|
||||||
{
|
{
|
||||||
|
@ -56,11 +57,29 @@ const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
|
||||||
this->privateData->attributes = o.privateData->attributes;
|
this->privateData->attributes = o.privateData->attributes;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomNetProtocol::~CustomNetProtocol()
|
CustomNetProtocol::~CustomNetProtocol()
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
delete this->privateData;
|
||||||
this->privateData = 0;
|
this->privateData = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetAttributeContainer& CustomNetProtocol::operator[](int ID) const
|
||||||
|
{
|
||||||
|
//if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
if((unsigned int)ID >= this->privateData->attributes.Size())
|
||||||
|
{
|
||||||
|
NetAttributeContainer temp;
|
||||||
|
|
||||||
|
temp.type = NetAttributeType_UNKNOWN;
|
||||||
|
memset(&temp.value, 0, sizeof(NetAttributeValue));
|
||||||
|
|
||||||
|
this->privateData->attributes.Push(ID, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->privateData->attributes[ID];
|
||||||
|
}
|
||||||
|
|
||||||
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
||||||
{
|
{
|
||||||
//if(!this->privateData) this->privateData = new PrivateData();
|
//if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
|
@ -130,10 +130,12 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
CustomNetProtocol();
|
CustomNetProtocol();
|
||||||
~CustomNetProtocol();
|
~CustomNetProtocol();
|
||||||
CustomNetProtocol(CustomNetProtocol& o);
|
CustomNetProtocol( const CustomNetProtocol& o);
|
||||||
const CustomNetProtocol& operator=(CustomNetProtocol& o);
|
CustomNetProtocol& operator=(const CustomNetProtocol& o);
|
||||||
|
|
||||||
|
const NetAttributeContainer& operator[](int ID) const;
|
||||||
|
NetAttributeContainer& operator[](int ID);
|
||||||
|
|
||||||
NetAttributeContainer& operator[](int ID);
|
|
||||||
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
||||||
void Set(int ID, std::string s);
|
void Set(int ID, std::string s);
|
||||||
const NetAttributeContainer& Get(int id);
|
const NetAttributeContainer& Get(int id);
|
||||||
|
|
|
@ -96,6 +96,10 @@ struct NetworkClient::PrivateData : public IThreadObject
|
||||||
//printf("\t(%i)\n", this->sendQueue.Size());
|
//printf("\t(%i)\n", this->sendQueue.Size());
|
||||||
OysterByte temp;
|
OysterByte temp;
|
||||||
CustomNetProtocol p = this->sendQueue.Pop();
|
CustomNetProtocol p = this->sendQueue.Pop();
|
||||||
|
|
||||||
|
if(p[0].value.netShort == 304)
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
this->translator.Pack(temp, p);
|
this->translator.Pack(temp, p);
|
||||||
errorCode = this->connection.Send(temp);
|
errorCode = this->connection.Send(temp);
|
||||||
|
|
||||||
|
@ -313,6 +317,27 @@ bool NetworkClient::Connect(unsigned short port, std::wstring serverIP)
|
||||||
return this->Connect(port, ip.c_str());
|
return this->Connect(port, ip.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NetworkClient::Reconnect()
|
||||||
|
{
|
||||||
|
if(this->IsConnected())
|
||||||
|
return false;
|
||||||
|
//if(this->privateData)
|
||||||
|
//return false;
|
||||||
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
|
int result = this->privateData->connection.Reconnect();
|
||||||
|
|
||||||
|
if(result != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this->privateData->owner = 0;
|
||||||
|
this->privateData->parent = this;
|
||||||
|
this->privateData->thread.Start();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkClient::Disconnect()
|
void NetworkClient::Disconnect()
|
||||||
{
|
{
|
||||||
if(!privateData) return;
|
if(!privateData) return;
|
||||||
|
|
|
@ -93,6 +93,11 @@ namespace Oyster
|
||||||
*/
|
*/
|
||||||
bool Connect(unsigned short port, std::wstring serverIP);
|
bool Connect(unsigned short port, std::wstring serverIP);
|
||||||
|
|
||||||
|
/**Tries to connect with the same port and ip it earlier used for Connect.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool Reconnect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -133,13 +138,7 @@ namespace Oyster
|
||||||
*/
|
*/
|
||||||
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
|
||||||
/** ! Deprecate !
|
std::string GetIpAddress();
|
||||||
* Do not use this furthermore, instead use void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
|
||||||
* @see DataRecieved
|
|
||||||
*/
|
|
||||||
//virtual void NetworkCallback(Oyster::Network::CustomNetProtocol& p);
|
|
||||||
|
|
||||||
virtual std::string GetIpAddress();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkClient(const NetworkClient& obj);
|
NetworkClient(const NetworkClient& obj);
|
||||||
|
|
|
@ -98,9 +98,9 @@ namespace Oyster
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NetClientList clients;
|
NetClientList clients;
|
||||||
|
|
||||||
private:
|
|
||||||
int clientCount;
|
int clientCount;
|
||||||
|
|
||||||
|
private:
|
||||||
struct PrivateSessionData;
|
struct PrivateSessionData;
|
||||||
PrivateSessionData* data;
|
PrivateSessionData* data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,6 +58,9 @@ int Connection::Connect(unsigned short port , const char serverName[], bool bloc
|
||||||
{
|
{
|
||||||
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
||||||
|
|
||||||
|
lastConnectPort = port;
|
||||||
|
lastConnectAddr = serverName;
|
||||||
|
|
||||||
struct hostent *hostEnt;
|
struct hostent *hostEnt;
|
||||||
if((hostEnt = gethostbyname(serverName)) == NULL)
|
if((hostEnt = gethostbyname(serverName)) == NULL)
|
||||||
{
|
{
|
||||||
|
@ -83,6 +86,37 @@ int Connection::Connect(unsigned short port , const char serverName[], bool bloc
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Connection::Reconnect()
|
||||||
|
{
|
||||||
|
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
||||||
|
|
||||||
|
struct hostent *hostEnt;
|
||||||
|
if((hostEnt = gethostbyname(lastConnectAddr.c_str())) == NULL)
|
||||||
|
{
|
||||||
|
return WSAGetLastError();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sockaddr_in server;
|
||||||
|
server.sin_family = AF_INET;
|
||||||
|
server.sin_port = htons(lastConnectPort);
|
||||||
|
server.sin_addr.s_addr = *(unsigned long*) hostEnt->h_addr;
|
||||||
|
|
||||||
|
SetBlockingMode(true);
|
||||||
|
|
||||||
|
if(connect(this->socket, (sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
return WSAGetLastError();
|
||||||
|
}
|
||||||
|
|
||||||
|
closed = false;
|
||||||
|
stillSending = true;
|
||||||
|
|
||||||
|
SetBlockingMode(blocking);
|
||||||
|
|
||||||
|
//connection succesfull!
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int Connection::InitiateServer(unsigned short port)
|
int Connection::InitiateServer(unsigned short port)
|
||||||
{
|
{
|
||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace Oyster
|
||||||
virtual int Disconnect();
|
virtual int Disconnect();
|
||||||
virtual int Connect(ConnectionInfo info, bool blocking = false);
|
virtual int Connect(ConnectionInfo info, bool blocking = false);
|
||||||
virtual int Connect(unsigned short port , const char serverName[], bool blocking = false);
|
virtual int Connect(unsigned short port , const char serverName[], bool blocking = false);
|
||||||
|
virtual int Reconnect();
|
||||||
|
|
||||||
virtual ConnectionInfo Listen();
|
virtual ConnectionInfo Listen();
|
||||||
|
|
||||||
|
@ -47,6 +48,11 @@ namespace Oyster
|
||||||
bool stillSending;
|
bool stillSending;
|
||||||
bool closed;
|
bool closed;
|
||||||
std::string addr;
|
std::string addr;
|
||||||
|
|
||||||
|
std::string lastConnectAddr;
|
||||||
|
unsigned short lastConnectPort;
|
||||||
|
|
||||||
|
bool blocking;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,9 @@ namespace Oyster
|
||||||
//(servers uses Listen instead of connect)
|
//(servers uses Listen instead of connect)
|
||||||
virtual int Connect( unsigned short port, const char serverName[] ) { return false; };
|
virtual int Connect( unsigned short port, const char serverName[] ) { return false; };
|
||||||
|
|
||||||
|
//Tries to connect with the same port and ip used for Connect.
|
||||||
|
virtual int Reconnect() = 0;
|
||||||
|
|
||||||
//Disconnects the client or server TODO: optimize!
|
//Disconnects the client or server TODO: optimize!
|
||||||
virtual int Disconnect() = 0;
|
virtual int Disconnect() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -338,8 +338,8 @@ namespace Oyster
|
||||||
dTDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
dTDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
dTDesc.CPUAccessFlags=0;
|
dTDesc.CPUAccessFlags=0;
|
||||||
dTDesc.MiscFlags=0;
|
dTDesc.MiscFlags=0;
|
||||||
dTDesc.Height = Core::resolution.y;
|
dTDesc.Height = (UINT)Core::resolution.y;
|
||||||
dTDesc.Width = Core::resolution.x;
|
dTDesc.Width = (UINT)Core::resolution.x;
|
||||||
dTDesc.SampleDesc.Count=1;
|
dTDesc.SampleDesc.Count=1;
|
||||||
dTDesc.SampleDesc.Quality=0;
|
dTDesc.SampleDesc.Quality=0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(BulletFileLoader_SRCS
|
||||||
|
bChunk.cpp
|
||||||
|
bDNA.cpp
|
||||||
|
bFile.cpp
|
||||||
|
btBulletFile.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(BulletFileLoader_HDRS
|
||||||
|
bChunk.h
|
||||||
|
bCommon.h
|
||||||
|
bDefines.h
|
||||||
|
bDNA.h
|
||||||
|
bFile.h
|
||||||
|
btBulletFile.h
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_LIBRARY(BulletFileLoader ${BulletFileLoader_SRCS} ${BulletFileLoader_HDRS})
|
||||||
|
|
||||||
|
IF (BUILD_SHARED_LIBS)
|
||||||
|
TARGET_LINK_LIBRARIES(BulletFileLoader LinearMath)
|
||||||
|
ENDIF (BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(BulletFileLoader PROPERTIES VERSION ${BULLET_VERSION})
|
||||||
|
SET_TARGET_PROPERTIES(BulletFileLoader PROPERTIES SOVERSION ${BULLET_VERSION})
|
||||||
|
|
||||||
|
IF (INSTALL_EXTRA_LIBS)
|
||||||
|
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
||||||
|
#FILES_MATCHING requires CMake 2.6
|
||||||
|
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
||||||
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
INSTALL(TARGETS BulletFileLoader DESTINATION .)
|
||||||
|
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
INSTALL(TARGETS BulletFileLoader DESTINATION lib${LIB_SUFFIX})
|
||||||
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||||
|
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||||
|
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
||||||
|
|
||||||
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
SET_TARGET_PROPERTIES(BulletFileLoader PROPERTIES FRAMEWORK true)
|
||||||
|
SET_TARGET_PROPERTIES(BulletFileLoader PROPERTIES PUBLIC_HEADER "${BulletFileLoader_HDRS}")
|
||||||
|
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
||||||
|
ENDIF (INSTALL_EXTRA_LIBS)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
bParse
|
||||||
|
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "bChunk.h"
|
||||||
|
#include "bDefines.h"
|
||||||
|
#include "bFile.h"
|
||||||
|
|
||||||
|
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||||
|
#include <memory.h>
|
||||||
|
#endif
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace bParse;
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
short ChunkUtils::swapShort(short sht)
|
||||||
|
{
|
||||||
|
SWITCH_SHORT(sht);
|
||||||
|
return sht;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int ChunkUtils::swapInt(int inte)
|
||||||
|
{
|
||||||
|
SWITCH_INT(inte);
|
||||||
|
return inte;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
long64 ChunkUtils::swapLong64(long64 lng)
|
||||||
|
{
|
||||||
|
SWITCH_LONGINT(lng);
|
||||||
|
return lng;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int ChunkUtils::getOffset(int flags)
|
||||||
|
{
|
||||||
|
// if the file is saved in a
|
||||||
|
// different format, get the
|
||||||
|
// file's chunk size
|
||||||
|
int res = CHUNK_HEADER_LEN;
|
||||||
|
|
||||||
|
if (VOID_IS_8)
|
||||||
|
{
|
||||||
|
if (flags &FD_BITS_VARIES)
|
||||||
|
res = sizeof(bChunkPtr4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (flags &FD_BITS_VARIES)
|
||||||
|
res = sizeof(bChunkPtr8);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//eof
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
bParse
|
||||||
|
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BCHUNK_H__
|
||||||
|
#define __BCHUNK_H__
|
||||||
|
|
||||||
|
#if defined (_WIN32) && ! defined (__MINGW32__)
|
||||||
|
#define long64 __int64
|
||||||
|
#elif defined (__MINGW32__)
|
||||||
|
#include <stdint.h>
|
||||||
|
#define long64 int64_t
|
||||||
|
#else
|
||||||
|
#define long64 long long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace bParse {
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
class bChunkPtr4
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bChunkPtr4(){}
|
||||||
|
int code;
|
||||||
|
int len;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
int m_uniqueInt;
|
||||||
|
};
|
||||||
|
int dna_nr;
|
||||||
|
int nr;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
class bChunkPtr8
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bChunkPtr8(){}
|
||||||
|
int code, len;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
long64 oldPrev;
|
||||||
|
int m_uniqueInts[2];
|
||||||
|
};
|
||||||
|
int dna_nr, nr;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
class bChunkInd
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bChunkInd(){}
|
||||||
|
int code, len;
|
||||||
|
void *oldPtr;
|
||||||
|
int dna_nr, nr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
class ChunkUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// file chunk offset
|
||||||
|
static int getOffset(int flags);
|
||||||
|
|
||||||
|
// endian utils
|
||||||
|
static short swapShort(short sht);
|
||||||
|
static int swapInt(int inte);
|
||||||
|
static long64 swapLong64(long64 lng);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const int CHUNK_HEADER_LEN = ((sizeof(bChunkInd)));
|
||||||
|
const bool VOID_IS_8 = ((sizeof(void*)==8));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif//__BCHUNK_H__
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
bParse
|
||||||
|
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BCOMMON_H__
|
||||||
|
#define __BCOMMON_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
//#include "bLog.h"
|
||||||
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
#include "LinearMath/btHashMap.h"
|
||||||
|
|
||||||
|
namespace bParse {
|
||||||
|
|
||||||
|
class bMain;
|
||||||
|
class bFileData;
|
||||||
|
class bFile;
|
||||||
|
class bDNA;
|
||||||
|
|
||||||
|
// delete void* undefined
|
||||||
|
typedef struct bStructHandle {int unused;}bStructHandle;
|
||||||
|
typedef btAlignedObjectArray<bStructHandle*> bListBasePtr;
|
||||||
|
typedef btHashMap<btHashPtr, bStructHandle*> bPtrMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif//__BCOMMON_H__
|
|
@ -0,0 +1,644 @@
|
||||||
|
/*
|
||||||
|
bParse
|
||||||
|
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "bDNA.h"
|
||||||
|
#include "bChunk.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
//this define will force traversal of structures, to check backward (and forward) compatibility
|
||||||
|
//#define TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||||
|
|
||||||
|
|
||||||
|
using namespace bParse;
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
bDNA::bDNA()
|
||||||
|
: mPtrLen(0)
|
||||||
|
{
|
||||||
|
// --
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
bDNA::~bDNA()
|
||||||
|
{
|
||||||
|
// --
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
bool bDNA::lessThan(bDNA *file)
|
||||||
|
{
|
||||||
|
return ( m_Names.size() < file->m_Names.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
char *bDNA::getName(int ind)
|
||||||
|
{
|
||||||
|
assert(ind <= (int)m_Names.size());
|
||||||
|
return m_Names[ind].m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
char *bDNA::getType(int ind)
|
||||||
|
{
|
||||||
|
assert(ind<= (int)mTypes.size());
|
||||||
|
return mTypes[ind];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
short *bDNA::getStruct(int ind)
|
||||||
|
{
|
||||||
|
assert(ind <= (int)mStructs.size());
|
||||||
|
return mStructs[ind];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
short bDNA::getLength(int ind)
|
||||||
|
{
|
||||||
|
assert(ind <= (int)mTlens.size());
|
||||||
|
return mTlens[ind];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int bDNA::getReverseType(short type)
|
||||||
|
{
|
||||||
|
|
||||||
|
int* intPtr = mStructReverse.find(type);
|
||||||
|
if (intPtr)
|
||||||
|
return *intPtr;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int bDNA::getReverseType(const char *type)
|
||||||
|
{
|
||||||
|
|
||||||
|
btHashString key(type);
|
||||||
|
int* valuePtr = mTypeLookup.find(key);
|
||||||
|
if (valuePtr)
|
||||||
|
return *valuePtr;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int bDNA::getNumStructs()
|
||||||
|
{
|
||||||
|
return (int)mStructs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
bool bDNA::flagNotEqual(int dna_nr)
|
||||||
|
{
|
||||||
|
assert(dna_nr <= (int)mCMPFlags.size());
|
||||||
|
return mCMPFlags[dna_nr] == FDF_STRUCT_NEQU;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
bool bDNA::flagEqual(int dna_nr)
|
||||||
|
{
|
||||||
|
assert(dna_nr <= (int)mCMPFlags.size());
|
||||||
|
int flag = mCMPFlags[dna_nr];
|
||||||
|
return flag == FDF_STRUCT_EQU;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
bool bDNA::flagNone(int dna_nr)
|
||||||
|
{
|
||||||
|
assert(dna_nr <= (int)mCMPFlags.size());
|
||||||
|
return mCMPFlags[dna_nr] == FDF_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int bDNA::getPointerSize()
|
||||||
|
{
|
||||||
|
return mPtrLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
void bDNA::initRecurseCmpFlags(int iter)
|
||||||
|
{
|
||||||
|
// iter is FDF_STRUCT_NEQU
|
||||||
|
|
||||||
|
short *oldStrc = mStructs[iter];
|
||||||
|
short type = oldStrc[0];
|
||||||
|
|
||||||
|
for (int i=0; i<(int)mStructs.size(); i++)
|
||||||
|
{
|
||||||
|
if (i != iter && mCMPFlags[i] == FDF_STRUCT_EQU )
|
||||||
|
{
|
||||||
|
short *curStruct = mStructs[i];
|
||||||
|
int eleLen = curStruct[1];
|
||||||
|
curStruct+=2;
|
||||||
|
|
||||||
|
for (int j=0; j<eleLen; j++, curStruct+=2)
|
||||||
|
{
|
||||||
|
if (curStruct[0] == type)
|
||||||
|
{
|
||||||
|
//char *name = m_Names[curStruct[1]].m_name;
|
||||||
|
//if (name[0] != '*')
|
||||||
|
if (m_Names[curStruct[1]].m_isPointer)
|
||||||
|
{
|
||||||
|
mCMPFlags[i] = FDF_STRUCT_NEQU;
|
||||||
|
initRecurseCmpFlags(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
void bDNA::initCmpFlags(bDNA *memDNA)
|
||||||
|
{
|
||||||
|
|
||||||
|
// compare the file to memory
|
||||||
|
// this ptr should be the file data
|
||||||
|
|
||||||
|
|
||||||
|
assert(!m_Names.size() == 0 && "SDNA empty!");
|
||||||
|
mCMPFlags.resize(mStructs.size(), FDF_NONE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for ( i=0; i<(int)mStructs.size(); i++)
|
||||||
|
{
|
||||||
|
short *oldStruct = mStructs[i];
|
||||||
|
|
||||||
|
int oldLookup = getReverseType(oldStruct[0]);
|
||||||
|
if (oldLookup == -1)
|
||||||
|
{
|
||||||
|
mCMPFlags[i] = FDF_NONE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//char* typeName = mTypes[oldStruct[0]];
|
||||||
|
|
||||||
|
//#define SLOW_FORWARD_COMPATIBLE 1
|
||||||
|
#ifdef SLOW_FORWARD_COMPATIBLE
|
||||||
|
char* typeName = mTypes[oldLookup];
|
||||||
|
int newLookup = memDNA->getReverseType(typeName);
|
||||||
|
if (newLookup == -1)
|
||||||
|
{
|
||||||
|
mCMPFlags[i] = FDF_NONE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
short *curStruct = memDNA->mStructs[newLookup];
|
||||||
|
#else
|
||||||
|
// memory for file
|
||||||
|
|
||||||
|
if (oldLookup < memDNA->mStructs.size())
|
||||||
|
{
|
||||||
|
short *curStruct = memDNA->mStructs[oldLookup];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// rebuild...
|
||||||
|
mCMPFlags[i] = FDF_STRUCT_NEQU;
|
||||||
|
|
||||||
|
#ifndef TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||||
|
|
||||||
|
if (curStruct[1] == oldStruct[1])
|
||||||
|
{
|
||||||
|
// type len same ...
|
||||||
|
if (mTlens[oldStruct[0]] == memDNA->mTlens[curStruct[0]])
|
||||||
|
{
|
||||||
|
bool isSame = true;
|
||||||
|
int elementLength = oldStruct[1];
|
||||||
|
|
||||||
|
|
||||||
|
curStruct+=2;
|
||||||
|
oldStruct+=2;
|
||||||
|
|
||||||
|
|
||||||
|
for (int j=0; j<elementLength; j++, curStruct+=2, oldStruct+=2)
|
||||||
|
{
|
||||||
|
// type the same
|
||||||
|
//const char* typeFileDNA = mTypes[oldStruct[0]];
|
||||||
|
//const char* typeMemDNA = mTypes[curStruct[0]];
|
||||||
|
if (strcmp(mTypes[oldStruct[0]], memDNA->mTypes[curStruct[0]])!=0)
|
||||||
|
{
|
||||||
|
isSame=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// name the same
|
||||||
|
if (strcmp(m_Names[oldStruct[1]].m_name, memDNA->m_Names[curStruct[1]].m_name)!=0)
|
||||||
|
{
|
||||||
|
isSame=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// flag valid ==
|
||||||
|
if (isSame)
|
||||||
|
mCMPFlags[i] = FDF_STRUCT_EQU;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// recurse in
|
||||||
|
for ( i=0; i<(int)mStructs.size(); i++)
|
||||||
|
{
|
||||||
|
if (mCMPFlags[i] == FDF_STRUCT_NEQU)
|
||||||
|
initRecurseCmpFlags(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int name_is_array(char* name, int* dim1, int* dim2) {
|
||||||
|
int len = strlen(name);
|
||||||
|
/*fprintf(stderr,"[%s]",name);*/
|
||||||
|
/*if (len >= 1) {
|
||||||
|
if (name[len-1] != ']')
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;*/
|
||||||
|
char *bp;
|
||||||
|
int num;
|
||||||
|
if (dim1) {
|
||||||
|
*dim1 = 1;
|
||||||
|
}
|
||||||
|
if (dim2) {
|
||||||
|
*dim2 = 1;
|
||||||
|
}
|
||||||
|
bp = strchr(name, '[');
|
||||||
|
if (!bp) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
num = 0;
|
||||||
|
while (++bp < name+len-1) {
|
||||||
|
const char c = *bp;
|
||||||
|
if (c == ']') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (c <= '9' && c >= '0') {
|
||||||
|
num *= 10;
|
||||||
|
num += (c - '0');
|
||||||
|
} else {
|
||||||
|
printf("array parse error.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dim2) {
|
||||||
|
*dim2 = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find second dim, if any. */
|
||||||
|
bp = strchr(bp, '[');
|
||||||
|
if (!bp) {
|
||||||
|
return 1; /* at least we got the first dim. */
|
||||||
|
}
|
||||||
|
num = 0;
|
||||||
|
while (++bp < name+len-1) {
|
||||||
|
const char c = *bp;
|
||||||
|
if (c == ']') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (c <= '9' && c >= '0') {
|
||||||
|
num *= 10;
|
||||||
|
num += (c - '0');
|
||||||
|
} else {
|
||||||
|
printf("array2 parse error.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dim1) {
|
||||||
|
if (dim2) {
|
||||||
|
*dim1 = *dim2;
|
||||||
|
*dim2 = num;
|
||||||
|
} else {
|
||||||
|
*dim1 = num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
void bDNA::init(char *data, int len, bool swap)
|
||||||
|
{
|
||||||
|
int *intPtr=0;short *shtPtr=0;
|
||||||
|
char *cp = 0;int dataLen =0;long nr=0;
|
||||||
|
intPtr = (int*)data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
SDNA (4 bytes) (magic number)
|
||||||
|
NAME (4 bytes)
|
||||||
|
<nr> (4 bytes) amount of names (int)
|
||||||
|
<string>
|
||||||
|
<string>
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (strncmp(data, "SDNA", 4)==0)
|
||||||
|
{
|
||||||
|
// skip ++ NAME
|
||||||
|
intPtr++; intPtr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Parse names
|
||||||
|
if (swap)
|
||||||
|
{
|
||||||
|
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||||
|
}
|
||||||
|
dataLen = *intPtr;
|
||||||
|
intPtr++;
|
||||||
|
|
||||||
|
cp = (char*)intPtr;
|
||||||
|
int i;
|
||||||
|
for ( i=0; i<dataLen; i++)
|
||||||
|
{
|
||||||
|
bNameInfo info;
|
||||||
|
info.m_name = cp;
|
||||||
|
info.m_isPointer = (info.m_name[0] == '*') || (info.m_name[1] == '*');
|
||||||
|
name_is_array(info.m_name,&info.m_dim0,&info.m_dim1);
|
||||||
|
m_Names.push_back(info);
|
||||||
|
while (*cp)cp++;
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
nr= (long)cp;
|
||||||
|
//long mask=3;
|
||||||
|
nr= ((nr+3)&~3)-nr;
|
||||||
|
while (nr--)
|
||||||
|
{
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TYPE (4 bytes)
|
||||||
|
<nr> amount of types (int)
|
||||||
|
<string>
|
||||||
|
<string>
|
||||||
|
*/
|
||||||
|
|
||||||
|
intPtr = (int*)cp;
|
||||||
|
assert(strncmp(cp, "TYPE", 4)==0); intPtr++;
|
||||||
|
|
||||||
|
if (swap)
|
||||||
|
{
|
||||||
|
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||||
|
}
|
||||||
|
dataLen = *intPtr;
|
||||||
|
intPtr++;
|
||||||
|
|
||||||
|
cp = (char*)intPtr;
|
||||||
|
for ( i=0; i<dataLen; i++)
|
||||||
|
{
|
||||||
|
mTypes.push_back(cp);
|
||||||
|
while (*cp)cp++;
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
nr= (long)cp;
|
||||||
|
// long mask=3;
|
||||||
|
nr= ((nr+3)&~3)-nr;
|
||||||
|
while (nr--)
|
||||||
|
{
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TLEN (4 bytes)
|
||||||
|
<len> (short) the lengths of types
|
||||||
|
<len>
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Parse type lens
|
||||||
|
intPtr = (int*)cp;
|
||||||
|
assert(strncmp(cp, "TLEN", 4)==0); intPtr++;
|
||||||
|
|
||||||
|
dataLen = (int)mTypes.size();
|
||||||
|
|
||||||
|
shtPtr = (short*)intPtr;
|
||||||
|
for ( i=0; i<dataLen; i++, shtPtr++)
|
||||||
|
{
|
||||||
|
if (swap)
|
||||||
|
shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]);
|
||||||
|
mTlens.push_back(shtPtr[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataLen & 1) shtPtr++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
STRC (4 bytes)
|
||||||
|
<nr> amount of structs (int)
|
||||||
|
<typenr>
|
||||||
|
<nr_of_elems>
|
||||||
|
<typenr>
|
||||||
|
<namenr>
|
||||||
|
<typenr>
|
||||||
|
<namenr>
|
||||||
|
*/
|
||||||
|
|
||||||
|
intPtr = (int*)shtPtr;
|
||||||
|
cp = (char*)intPtr;
|
||||||
|
assert(strncmp(cp, "STRC", 4)==0); intPtr++;
|
||||||
|
|
||||||
|
if (swap)
|
||||||
|
{
|
||||||
|
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||||
|
}
|
||||||
|
dataLen = *intPtr;
|
||||||
|
intPtr++;
|
||||||
|
|
||||||
|
|
||||||
|
shtPtr = (short*)intPtr;
|
||||||
|
for ( i=0; i<dataLen; i++)
|
||||||
|
{
|
||||||
|
mStructs.push_back (shtPtr);
|
||||||
|
if (swap)
|
||||||
|
{
|
||||||
|
shtPtr[0]= ChunkUtils::swapShort(shtPtr[0]);
|
||||||
|
shtPtr[1]= ChunkUtils::swapShort(shtPtr[1]);
|
||||||
|
|
||||||
|
int len = shtPtr[1];
|
||||||
|
shtPtr+= 2;
|
||||||
|
|
||||||
|
for (int a=0; a<len; a++, shtPtr+=2)
|
||||||
|
{
|
||||||
|
shtPtr[0]= ChunkUtils::swapShort(shtPtr[0]);
|
||||||
|
shtPtr[1]= ChunkUtils::swapShort(shtPtr[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
shtPtr+= (2*shtPtr[1])+2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// build reverse lookups
|
||||||
|
for ( i=0; i<(int)mStructs.size(); i++)
|
||||||
|
{
|
||||||
|
short *strc = mStructs.at(i);
|
||||||
|
if (!mPtrLen && strcmp(mTypes[strc[0]],"ListBase")==0)
|
||||||
|
{
|
||||||
|
mPtrLen = mTlens[strc[0]]/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
mStructReverse.insert(strc[0], i);
|
||||||
|
mTypeLookup.insert(btHashString(mTypes[strc[0]]),i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------- //
|
||||||
|
int bDNA::getArraySize(char* string)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
int len = strlen(string);
|
||||||
|
|
||||||
|
|
||||||
|
char* next = 0;
|
||||||
|
for (int i=0; i<len; i++)
|
||||||
|
{
|
||||||
|
char c = string[i];
|
||||||
|
|
||||||
|
if (c == '[')
|
||||||
|
next = &string[i+1];
|
||||||
|
else if (c==']')
|
||||||
|
if (next)
|
||||||
|
ret *= atoi(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
// print (string << ' ' << ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void bDNA::dumpTypeDefinitions()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
int numTypes = mTypes.size();
|
||||||
|
|
||||||
|
for (i=0;i<numTypes;i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i=0; i<(int)mStructs.size(); i++)
|
||||||
|
{
|
||||||
|
int totalBytes=0;
|
||||||
|
short *oldStruct = mStructs[i];
|
||||||
|
|
||||||
|
int oldLookup = getReverseType(oldStruct[0]);
|
||||||
|
if (oldLookup == -1)
|
||||||
|
{
|
||||||
|
mCMPFlags[i] = FDF_NONE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
short* newStruct = mStructs[oldLookup];
|
||||||
|
char* typeName = mTypes[newStruct[0]];
|
||||||
|
printf("%3d: %s ",i,typeName);
|
||||||
|
|
||||||
|
//char *name = mNames[oldStruct[1]];
|
||||||
|
int len = oldStruct[1];
|
||||||
|
printf(" (%d fields) ",len);
|
||||||
|
oldStruct+=2;
|
||||||
|
|
||||||
|
printf("{");
|
||||||
|
int j;
|
||||||
|
for (j=0; j<len; ++j,oldStruct+=2) {
|
||||||
|
const char* name = m_Names[oldStruct[1]].m_name;
|
||||||
|
printf("%s %s", mTypes[oldStruct[0]],name);
|
||||||
|
int elemNumBytes= 0;
|
||||||
|
int arrayDimensions = getArraySizeNew(oldStruct[1]);
|
||||||
|
|
||||||
|
if (m_Names[oldStruct[1]].m_isPointer)
|
||||||
|
{
|
||||||
|
elemNumBytes = VOID_IS_8 ? 8 : 4;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
elemNumBytes = getLength(oldStruct[0]);
|
||||||
|
}
|
||||||
|
printf(" /* %d bytes */",elemNumBytes*arrayDimensions);
|
||||||
|
|
||||||
|
if (j == len-1) {
|
||||||
|
printf(";}");
|
||||||
|
} else {
|
||||||
|
printf("; ");
|
||||||
|
}
|
||||||
|
totalBytes+=elemNumBytes*arrayDimensions;
|
||||||
|
}
|
||||||
|
printf("\ntotalBytes=%d\n\n",totalBytes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* dump out display of types and their sizes */
|
||||||
|
for (i=0; i<bf->types_count; ++i) {
|
||||||
|
/* if (!bf->types[i].is_struct)*/
|
||||||
|
{
|
||||||
|
printf("%3d: sizeof(%s%s)=%d",
|
||||||
|
i,
|
||||||
|
bf->types[i].is_struct ? "struct " : "atomic ",
|
||||||
|
bf->types[i].name, bf->types[i].size);
|
||||||
|
if (bf->types[i].is_struct) {
|
||||||
|
int j;
|
||||||
|
printf(", %d fields: { ", bf->types[i].fieldtypes_count);
|
||||||
|
for (j=0; j<bf->types[i].fieldtypes_count; ++j) {
|
||||||
|
printf("%s %s",
|
||||||
|
bf->types[bf->types[i].fieldtypes[j]].name,
|
||||||
|
bf->names[bf->types[i].fieldnames[j]]);
|
||||||
|
if (j == bf->types[i].fieldtypes_count-1) {
|
||||||
|
printf(";}");
|
||||||
|
} else {
|
||||||
|
printf("; ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//eof
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
bParse
|
||||||
|
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BDNA_H__
|
||||||
|
#define __BDNA_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include "bCommon.h"
|
||||||
|
|
||||||
|
namespace bParse {
|
||||||
|
|
||||||
|
struct bNameInfo
|
||||||
|
{
|
||||||
|
char* m_name;
|
||||||
|
bool m_isPointer;
|
||||||
|
int m_dim0;
|
||||||
|
int m_dim1;
|
||||||
|
};
|
||||||
|
|
||||||
|
class bDNA
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bDNA();
|
||||||
|
~bDNA();
|
||||||
|
|
||||||
|
void init(char *data, int len, bool swap=false);
|
||||||
|
|
||||||
|
int getArraySize(char* str);
|
||||||
|
int getArraySizeNew(short name)
|
||||||
|
{
|
||||||
|
const bNameInfo& nameInfo = m_Names[name];
|
||||||
|
return nameInfo.m_dim0*nameInfo.m_dim1;
|
||||||
|
}
|
||||||
|
int getElementSize(short type, short name)
|
||||||
|
{
|
||||||
|
const bNameInfo& nameInfo = m_Names[name];
|
||||||
|
int size = nameInfo.m_isPointer ? mPtrLen*nameInfo.m_dim0*nameInfo.m_dim1 : mTlens[type]*nameInfo.m_dim0*nameInfo.m_dim1;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getNumNames() const
|
||||||
|
{
|
||||||
|
return m_Names.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
char *getName(int ind);
|
||||||
|
char *getType(int ind);
|
||||||
|
short *getStruct(int ind);
|
||||||
|
short getLength(int ind);
|
||||||
|
int getReverseType(short type);
|
||||||
|
int getReverseType(const char *type);
|
||||||
|
|
||||||
|
|
||||||
|
int getNumStructs();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool lessThan(bDNA* other);
|
||||||
|
|
||||||
|
void initCmpFlags(bDNA *memDNA);
|
||||||
|
bool flagNotEqual(int dna_nr);
|
||||||
|
bool flagEqual(int dna_nr);
|
||||||
|
bool flagNone(int dna_nr);
|
||||||
|
|
||||||
|
|
||||||
|
int getPointerSize();
|
||||||
|
|
||||||
|
void dumpTypeDefinitions();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum FileDNAFlags
|
||||||
|
{
|
||||||
|
FDF_NONE=0,
|
||||||
|
FDF_STRUCT_NEQU,
|
||||||
|
FDF_STRUCT_EQU
|
||||||
|
};
|
||||||
|
|
||||||
|
void initRecurseCmpFlags(int i);
|
||||||
|
|
||||||
|
btAlignedObjectArray<int> mCMPFlags;
|
||||||
|
|
||||||
|
btAlignedObjectArray<bNameInfo> m_Names;
|
||||||
|
btAlignedObjectArray<char*> mTypes;
|
||||||
|
btAlignedObjectArray<short*> mStructs;
|
||||||
|
btAlignedObjectArray<short> mTlens;
|
||||||
|
btHashMap<btHashInt, int> mStructReverse;
|
||||||
|
btHashMap<btHashString,int> mTypeLookup;
|
||||||
|
|
||||||
|
int mPtrLen;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif//__BDNA_H__
|
|
@ -0,0 +1,140 @@
|
||||||
|
/* Copyright (C) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
#ifndef __B_DEFINES_H__
|
||||||
|
#define __B_DEFINES_H__
|
||||||
|
|
||||||
|
|
||||||
|
// MISC defines, see BKE_global.h, BKE_utildefines.h
|
||||||
|
#define SIZEOFBLENDERHEADER 12
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
|
||||||
|
# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
|
||||||
|
#else
|
||||||
|
# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
|
||||||
|
# define MAKE_ID2(c, d) ( (c)<<8 | (d) )
|
||||||
|
# define MOST_SIG_BYTE 0
|
||||||
|
# define BBIG_ENDIAN
|
||||||
|
#else
|
||||||
|
# define MAKE_ID2(c, d) ( (d)<<8 | (c) )
|
||||||
|
# define MOST_SIG_BYTE 1
|
||||||
|
# define BLITTLE_ENDIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#define ID_SCE MAKE_ID2('S', 'C')
|
||||||
|
#define ID_LI MAKE_ID2('L', 'I')
|
||||||
|
#define ID_OB MAKE_ID2('O', 'B')
|
||||||
|
#define ID_ME MAKE_ID2('M', 'E')
|
||||||
|
#define ID_CU MAKE_ID2('C', 'U')
|
||||||
|
#define ID_MB MAKE_ID2('M', 'B')
|
||||||
|
#define ID_MA MAKE_ID2('M', 'A')
|
||||||
|
#define ID_TE MAKE_ID2('T', 'E')
|
||||||
|
#define ID_IM MAKE_ID2('I', 'M')
|
||||||
|
#define ID_IK MAKE_ID2('I', 'K')
|
||||||
|
#define ID_WV MAKE_ID2('W', 'V')
|
||||||
|
#define ID_LT MAKE_ID2('L', 'T')
|
||||||
|
#define ID_SE MAKE_ID2('S', 'E')
|
||||||
|
#define ID_LF MAKE_ID2('L', 'F')
|
||||||
|
#define ID_LA MAKE_ID2('L', 'A')
|
||||||
|
#define ID_CA MAKE_ID2('C', 'A')
|
||||||
|
#define ID_IP MAKE_ID2('I', 'P')
|
||||||
|
#define ID_KE MAKE_ID2('K', 'E')
|
||||||
|
#define ID_WO MAKE_ID2('W', 'O')
|
||||||
|
#define ID_SCR MAKE_ID2('S', 'R')
|
||||||
|
#define ID_VF MAKE_ID2('V', 'F')
|
||||||
|
#define ID_TXT MAKE_ID2('T', 'X')
|
||||||
|
#define ID_SO MAKE_ID2('S', 'O')
|
||||||
|
#define ID_SAMPLE MAKE_ID2('S', 'A')
|
||||||
|
#define ID_GR MAKE_ID2('G', 'R')
|
||||||
|
#define ID_ID MAKE_ID2('I', 'D')
|
||||||
|
#define ID_AR MAKE_ID2('A', 'R')
|
||||||
|
#define ID_AC MAKE_ID2('A', 'C')
|
||||||
|
#define ID_SCRIPT MAKE_ID2('P', 'Y')
|
||||||
|
#define ID_FLUIDSIM MAKE_ID2('F', 'S')
|
||||||
|
#define ID_NT MAKE_ID2('N', 'T')
|
||||||
|
#define ID_BR MAKE_ID2('B', 'R')
|
||||||
|
|
||||||
|
|
||||||
|
#define ID_SEQ MAKE_ID2('S', 'Q')
|
||||||
|
#define ID_CO MAKE_ID2('C', 'O')
|
||||||
|
#define ID_PO MAKE_ID2('A', 'C')
|
||||||
|
#define ID_NLA MAKE_ID2('N', 'L')
|
||||||
|
|
||||||
|
#define ID_VS MAKE_ID2('V', 'S')
|
||||||
|
#define ID_VN MAKE_ID2('V', 'N')
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#define FORM MAKE_ID('F','O','R','M')
|
||||||
|
#define DDG1 MAKE_ID('3','D','G','1')
|
||||||
|
#define DDG2 MAKE_ID('3','D','G','2')
|
||||||
|
#define DDG3 MAKE_ID('3','D','G','3')
|
||||||
|
#define DDG4 MAKE_ID('3','D','G','4')
|
||||||
|
#define GOUR MAKE_ID('G','O','U','R')
|
||||||
|
#define BLEN MAKE_ID('B','L','E','N')
|
||||||
|
#define DER_ MAKE_ID('D','E','R','_')
|
||||||
|
#define V100 MAKE_ID('V','1','0','0')
|
||||||
|
#define DATA MAKE_ID('D','A','T','A')
|
||||||
|
#define GLOB MAKE_ID('G','L','O','B')
|
||||||
|
#define IMAG MAKE_ID('I','M','A','G')
|
||||||
|
#define TEST MAKE_ID('T','E','S','T')
|
||||||
|
#define USER MAKE_ID('U','S','E','R')
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#define DNA1 MAKE_ID('D','N','A','1')
|
||||||
|
#define REND MAKE_ID('R','E','N','D')
|
||||||
|
#define ENDB MAKE_ID('E','N','D','B')
|
||||||
|
#define NAME MAKE_ID('N','A','M','E')
|
||||||
|
#define SDNA MAKE_ID('S','D','N','A')
|
||||||
|
#define TYPE MAKE_ID('T','Y','P','E')
|
||||||
|
#define TLEN MAKE_ID('T','L','E','N')
|
||||||
|
#define STRC MAKE_ID('S','T','R','C')
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#define SWITCH_INT(a) { \
|
||||||
|
char s_i, *p_i; \
|
||||||
|
p_i= (char *)&(a); \
|
||||||
|
s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
|
||||||
|
s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#define SWITCH_SHORT(a) { \
|
||||||
|
char s_i, *p_i; \
|
||||||
|
p_i= (char *)&(a); \
|
||||||
|
s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
#define SWITCH_LONGINT(a) { \
|
||||||
|
char s_i, *p_i; \
|
||||||
|
p_i= (char *)&(a); \
|
||||||
|
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
|
||||||
|
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
|
||||||
|
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
|
||||||
|
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
|
||||||
|
|
||||||
|
#endif//__B_DEFINES_H__
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue