Anim Error

This commit is contained in:
lanariel 2014-01-31 16:29:50 +01:00
commit 069acee8cc
199 changed files with 7667 additions and 5259 deletions

BIN
Bin/Level.txt Normal file

Binary file not shown.

View File

View File

@ -1,2 +0,0 @@
port 15151
clients 200

View File

@ -1,4 +0,0 @@
ServerInit ..\Settings\ServerInit.ini
More a
more b
more c

BIN
Bin/map Normal file

Binary file not shown.

BIN
Bin/map.txt Normal file

Binary file not shown.

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.2">
<diagram program="umlet" version="12.1">
<zoom_level>10</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>530</x>
<y>320</y>
<x>610</x>
<y>340</y>
<w>100</w>
<h>30</h>
</coordinates>
@ -16,20 +16,8 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>530</x>
<y>250</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>MainLobby
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>510</x>
<y>500</y>
<x>580</x>
<y>480</y>
<w>160</w>
<h>80</h>
</coordinates>
@ -41,89 +29,34 @@
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>620</x>
<y>340</y>
<w>60</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>30;140;40;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>710</x>
<y>320</y>
<y>480</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>LobbyClient</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>550</x>
<y>250</y>
<w>50</w>
<h>90</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>30;70;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>550</x>
<y>420</y>
<w>50</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>30;80;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>600</x>
<y>300</y>
<w>130</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>110;30;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>600</x>
<y>230</y>
<w>180</w>
<h>110</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>160;90;160;30;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>640</x>
<y>410</y>
<w>140</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>120;30;120;120;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>610</x>
<y>140</y>
<w>400</w>
<h>150</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>380;130;170;130;170;30;30;30</additional_attributes>
<panel_attributes>lt=&gt;&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>80;30;30;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>520</x>
<y>160</y>
<x>600</x>
<y>180</y>
<w>120</w>
<h>30</h>
<h>120</h>
</coordinates>
<panel_attributes>GameServer</panel_attributes>
<additional_attributes/>
@ -131,42 +64,19 @@
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>550</x>
<y>160</y>
<x>630</x>
<y>270</y>
<w>50</w>
<h>110</h>
<h>90</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>30;90;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>750</x>
<y>260</y>
<w>260</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>240;30;30;30;30;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>990</x>
<y>250</y>
<w>120</w>
<h>50</h>
</coordinates>
<panel_attributes>NetworkAPI
bg=#a21aff</panel_attributes>
<additional_attributes/>
<additional_attributes>30;70;30;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>510</x>
<y>20</y>
<x>590</x>
<y>100</y>
<w>130</w>
<h>40</h>
</coordinates>
@ -177,22 +87,22 @@ DanBiasServerAPI</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>550</x>
<y>30</y>
<x>630</x>
<y>110</y>
<w>50</w>
<h>150</h>
<h>90</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;&gt;-
</panel_attributes>
<additional_attributes>30;130;30;30</additional_attributes>
<additional_attributes>30;70;30;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>300</x>
<y>320</y>
<x>1060</x>
<y>330</y>
<w>120</w>
<h>30</h>
<h>50</h>
</coordinates>
<panel_attributes>NetworkSession</panel_attributes>
<additional_attributes/>
@ -200,41 +110,41 @@ DanBiasServerAPI</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>330</x>
<y>230</y>
<w>220</w>
<h>110</h>
<x>690</x>
<y>220</y>
<w>390</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>200;30;30;30;30;90</additional_attributes>
<panel_attributes>lt=-&lt;&lt;&lt;&lt;</panel_attributes>
<additional_attributes>30;30;370;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>390</x>
<y>300</y>
<w>160</w>
<x>680</x>
<y>320</y>
<w>400</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>140;30;30;30</additional_attributes>
<additional_attributes>30;30;380;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>330</x>
<y>320</y>
<w>200</w>
<h>210</h>
<x>690</x>
<y>340</y>
<w>390</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>180;190;30;190;30;30</additional_attributes>
<additional_attributes>30;140;40;40;370;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>990</x>
<y>370</y>
<x>460</x>
<y>640</y>
<w>120</w>
<h>50</h>
</coordinates>
@ -245,164 +155,19 @@ bg=blue</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>750</x>
<y>320</y>
<w>260</w>
<h>90</h>
<x>370</x>
<y>530</y>
<w>350</w>
<h>290</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>240;70;30;70;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>990</x>
<y>310</y>
<w>120</w>
<h>40</h>
</coordinates>
<panel_attributes>PhysicsAPI
bg=blue
--
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>780</x>
<y>300</y>
<w>230</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=.&lt;&lt;</panel_attributes>
<additional_attributes>210;30;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>640</x>
<y>380</y>
<w>370</w>
<h>190</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>350;30;190;30;190;170;30;170</additional_attributes>
<additional_attributes>90;150;30;270;330;240;240;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>320</x>
<y>120</y>
<w>130</w>
<h>90</h>
</coordinates>
<panel_attributes>ServerInitReader
--
Helper to load ini files to server
elementstyle=wordwrap
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>420</x>
<y>140</y>
<w>120</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;.
</panel_attributes>
<additional_attributes>100;30;30;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>510</x>
<y>400</y>
<w>160</w>
<h>50</h>
</coordinates>
<panel_attributes>GameSessionManager
--
/Creates game sessions/</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>550</x>
<y>320</y>
<w>50</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;-</panel_attributes>
<additional_attributes>30;30;30;80</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>990</x>
<y>430</y>
<w>120</w>
<h>40</h>
</coordinates>
<panel_attributes>ProtocolManager
bg=#aaaaa</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>310</x>
<y>320</y>
<w>770</w>
<h>300</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>750;150;750;280;30;280;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>1080</x>
<y>260</y>
<w>70</w>
<h>210</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;190;50;190;50;30;30;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>160</x>
<y>310</y>
<w>120</w>
<h>40</h>
</coordinates>
<panel_attributes>/&lt;&lt;interface&gt;&gt;/
INetworkSession</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>250</x>
<y>300</y>
<w>70</w>
<h>50</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;&gt;</panel_attributes>
<additional_attributes>50;30;30;30</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>710</x>
<y>410</y>
<x>790</x>
<y>500</y>
<w>100</w>
<h>30</h>
</coordinates>
@ -412,28 +177,91 @@ INetworkSession</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>730</x>
<y>320</y>
<w>50</w>
<h>110</h>
<x>670</x>
<y>530</y>
<w>150</w>
<h>180</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>30;30;30;90</additional_attributes>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>130;160;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>800</x>
<y>670</y>
<w>120</w>
<h>40</h>
</coordinates>
<panel_attributes>GameProtocols
bg=#aaaaa</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>1040</x>
<y>200</y>
<w>160</w>
<h>190</h>
</coordinates>
<panel_attributes>NetworkAPI
bg=#a21aff</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>150</x>
<y>420</y>
<w>160</w>
<h>50</h>
<x>1060</x>
<y>280</y>
<w>120</w>
<h>40</h>
</coordinates>
<panel_attributes>MapManager
--
Manages all map stuff.
elementstyle=wordwrap
</panel_attributes>
<panel_attributes>NetworkClient</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>1060</x>
<y>230</y>
<w>120</w>
<h>40</h>
</coordinates>
<panel_attributes>NetworkServer</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>690</x>
<y>240</y>
<w>390</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=-&gt;</panel_attributes>
<additional_attributes>30;30;200;30;200;60;370;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>690</x>
<y>260</y>
<w>390</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=-&lt;&lt;&lt;&lt;</panel_attributes>
<additional_attributes>30;30;180;30;180;80;370;80</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>860</x>
<y>270</y>
<w>380</w>
<h>260</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;-</panel_attributes>
<additional_attributes>320;30;360;30;360;230;30;240</additional_attributes>
</element>
</diagram>

View File

@ -0,0 +1,277 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.0">
<zoom_level>8</zoom_level>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>632</x>
<y>232</y>
<w>88</w>
<h>176</h>
</coordinates>
<panel_attributes>lt=.
&lt;Uses</panel_attributes>
<additional_attributes>24;24;24;64;72;64;72;160</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>136</x>
<y>232</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>448</x>
<y>496</y>
<w>40</w>
<h>88</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>24;72;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>432</x>
<y>232</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>608</x>
<y>216</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>Resource Loader
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>232</x>
<y>112</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>GameLogic
&lt;&lt;Erik&gt;&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>120</x>
<y>232</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>352</x>
<y>568</y>
<w>232</w>
<h>136</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
LevelParser
--
Functions:
vector&lt;struct&gt; Parse();
-
Privates:
enum headerType;
const int FileHeaderSize;
const int FileVersion;
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>336</x>
<y>88</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>560</x>
<y>496</y>
<w>136</w>
<h>104</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>120;24;120;88;24;88</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>352</x>
<y>384</y>
<w>232</w>
<h>136</h>
</coordinates>
<panel_attributes>LevelLoader
&lt;&lt;API&gt;&gt;&lt;Interface&gt;&gt;
--
Functions:
vector&lt;struct&gt; LoadLevel(String fileName);
struct LoadLevelHeader(String fileName);
-
Privates:
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>560</x>
<y>600</y>
<w>176</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;160;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>344</x>
<y>344</y>
<w>584</w>
<h>368</h>
</coordinates>
<panel_attributes>LevelLoader</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>472</x>
<y>200</y>
<w>152</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;136;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>416</x>
<y>232</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>LevelLoader
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>48</x>
<y>384</y>
<w>232</w>
<h>104</h>
</coordinates>
<panel_attributes>ObjectDefines.h
&lt;&lt;Header file&gt;&gt;
--
Enum ObjectType(static, dynamic, specials);
.
Struct static;
Struct dynamic;
Struct specials</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>720</x>
<y>584</y>
<w>200</w>
<h>120</h>
</coordinates>
<panel_attributes>Collection of functions
&lt;&lt;lots of functions&gt;&gt;
--
functions for creating the right structs</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>40</x>
<y>344</y>
<w>248</w>
<h>160</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>592</x>
<y>392</y>
<w>208</w>
<h>128</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Loader
--
Functions:
wchar* LoadFile(string fileName);
//Model* LoadHitBoxes(string modelName);
//Model* LoadHitBoxes(int modelID);
-
Privates:</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>176</x>
<y>200</y>
<w>256</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;Knows about</panel_attributes>
<additional_attributes>240;40;24;40</additional_attributes>
</element>
</diagram>

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -72,7 +72,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
@ -80,7 +80,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
@ -88,7 +88,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
@ -96,7 +96,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer\</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -190,8 +190,12 @@
<ProjectReference Include="..\..\OysterMath\OysterMath.vcxproj">
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
</ProjectReference>
<ProjectReference Include="..\GameServer\GameServer.vcxproj">
<Project>{143bd516-20a1-4890-a3e4-f8bfd02220e7}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="GameClientState\Camera.cpp" />
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
@ -202,15 +206,18 @@
<ClCompile Include="GameClientState\GameState.cpp" />
<ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" />
<ClCompile Include="GameClientState\LoginState.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientRecieverFunc.h" />
<ClInclude Include="GameClientState\Camera.h" />
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
<ClInclude Include="GameClientState\GameClientState.h" />
<ClInclude Include="GameClientState\GameState.h" />
<ClInclude Include="GameClientState\LoginState.h" />
<ClInclude Include="Include\DanBiasGame.h" />
<ClInclude Include="GameClientState\LobbyState.h" />
<ClInclude Include="GameClientState\C_Object.h" />

View File

@ -5,6 +5,7 @@
#include "GameClientState/GameClientState.h"
#include "GameClientState\GameState.h"
#include "GameClientState\LobbyState.h"
#include "GameClientState\LoginState.h"
#include <Protocols.h>
#include "NetworkClient.h"
@ -51,6 +52,7 @@ namespace DanBias
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
{
WindowShell::CreateConsoleWindow();
if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
return DanBiasClientReturn_Error;
@ -61,22 +63,20 @@ namespace DanBias
return DanBiasClientReturn_Error;
m_data->recieverObj = new GameRecieverObject;
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
m_data->recieverObj->nwClient->Connect(desc.port, desc.IP);
/*m_data->recieverObj->Connect(desc.port, desc.IP);
if (!m_data->recieverObj->nwClient->IsConnected())
if (!m_data->recieverObj->IsConnected())
{
// failed to connect
return DanBiasClientReturn_Error;
}
}*/
// Start in lobby state
m_data->recieverObj->gameClientState = new Client::LobbyState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
m_data->recieverObj->gameClientState = new Client::LoginState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
return DanBiasClientReturn_Error;
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
m_data->timer->reset();
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
m_data->timer->reset();
return DanBiasClientReturn_Sucess;
}
@ -133,9 +133,10 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime)
{
m_data->recieverObj->Update();
m_data->inputObj->Update();
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj);
@ -157,7 +158,7 @@ namespace DanBias
return E_FAIL;
break;
}
m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient); // send game client
m_data->recieverObj->gameClientState->Init(m_data->recieverObj); // send game client
}
return S_OK;
@ -184,10 +185,9 @@ namespace DanBias
{
m_data->recieverObj->gameClientState->Release();
delete m_data->recieverObj->gameClientState;
m_data->recieverObj->nwClient->Disconnect();
delete m_data->recieverObj->nwClient;
delete m_data->timer;
m_data->recieverObj->Disconnect();
delete m_data->recieverObj;
delete m_data->timer;
delete m_data->inputObj;
delete m_data;

View File

@ -1,316 +0,0 @@
//--------------------------------------------------------------------------------------
// File: TemplateMain.cpp
//
// BTH-D3D-Template
//
// Copyright (c) Stefan Petersson 2011. All rights reserved.
//--------------------------------------------------------------------------------------
#define NOMINMAX
#include <Windows.h>
#include "DllInterfaces/GFXAPI.h"
//#include "IGame.h"
#include "L_inputClass.h"
// debug window include
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
//--------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
//GameLogic::IGame* game;
InputClass* inputObj;
//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HRESULT Render(float deltaTime);
HRESULT Update(float deltaTime);
HRESULT InitDirect3D();
HRESULT InitGame();
HRESULT CleanUp();
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
void SetStdOutToNewConsole()
{
// allocate a console for this app
AllocConsole();
// redirect unbuffered STDOUT to the console
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT);
FILE *fp = _fdopen( fileDescriptor, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
// give the console window a nicer title
SetConsoleTitle(L"Debug Output");
// give the console window a bigger buffer size
CONSOLE_SCREEN_BUFFER_INFO csbi;
if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) )
{
COORD bufferSize;
bufferSize.X = csbi.dwSize.X;
bufferSize.Y = 50;
SetConsoleScreenBufferSize(consoleHandle, bufferSize);
}
}
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
// for dynamic .dll loading
// path is relative to the .exe and .dll pos
// also change the VC directories - working dir is set to $(SolutionDir)..\Bin\Executable\Tester
// to fit with where the .obj files is
// linker/ input/ delayed load .dll - specify the .dll that should be loaded
BOOL success = SetDllDirectory(L"..\\..\\DLL");
if (success == 0)
{
return 0;
}
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
return 0;
if( FAILED( InitDirect3D() ) )
return 0;
if( FAILED( InitGame() ) )
return 0;
__int64 cntsPerSec = 0;
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);
float secsPerCnt = 1.0f / (float)cntsPerSec;
__int64 prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
//debug window
//SetStdOutToNewConsole();
// Main message loop
MSG msg = {0};
while(WM_QUIT != msg.message)
{
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
__int64 currTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
//render
Update(dt);
Render(dt);
prevTimeStamp = currTimeStamp;
}
}
CleanUp();
return (int) msg.wParam;
}
//--------------------------------------------------------------------------------------
// Register class and create window
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
{
// Register class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"BTH_D3D_Template";
wcex.hIconSm = 0;
if( !RegisterClassEx(&wcex) )
return E_FAIL;
// Adjust and create window
g_hInst = hInstance;
RECT rc = { 0, 0, 1024, 768 };
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
if(!(g_hWnd = CreateWindow(
L"BTH_D3D_Template",
L"BTH - Direct3D 11.0 Template",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rc.right - rc.left,
rc.bottom - rc.top,
NULL,
NULL,
hInstance,
NULL)))
{
return E_FAIL;
}
ShowWindow( g_hWnd, nCmdShow );
return S_OK;
}
//--------------------------------------------------------------------------------------
// Create Direct3D with Oyster Graphics
//--------------------------------------------------------------------------------------
HRESULT InitDirect3D()
{
if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
return E_FAIL;
return S_OK;
}
//--------------------------------------------------------------------------------------
// Init the input and the game
//-------------------------------------------------------------------------------------
HRESULT InitGame()
{
inputObj = new InputClass;
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
{
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
return false;
}
/*game = new GameLogic::IGame();
game->Init();
game->StartGame();
*/
return S_OK;
}
HRESULT Update(float deltaTime)
{
inputObj->Update();
//GameLogic::keyInput key = GameLogic::keyInput_none;
//if(inputObj->IsKeyPressed(DIK_W))
//{
// key = GameLogic::keyInput_W;
//}
//else if(inputObj->IsKeyPressed(DIK_A))
//{
// key = GameLogic::keyInput_A;
//}
//else if(inputObj->IsKeyPressed(DIK_S))
//{
// key = GameLogic::keyInput_S;
//}
//else if(inputObj->IsKeyPressed(DIK_D))
//{
// key = GameLogic::keyInput_D;
//}
float pitch = 0;
float yaw = 0;
//if(inputObj->IsMousePressed())
//{
pitch = inputObj->GetPitch();
yaw = inputObj->GetYaw();
//}
//game->Update(key, pitch, yaw);
return S_OK;
}
HRESULT Render(float deltaTime)
{
int isPressed = 0;
if(inputObj->IsKeyPressed(DIK_A))
{
isPressed = 1;
//std::cout<<"test";
}
//game->Render();
wchar_t title[255];
swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed));
SetWindowText(g_hWnd, title);
Oyster::Graphics::API::EndFrame();
return S_OK;
}
HRESULT CleanUp()
{
/*if(game)
{
delete game;
game = NULL;
}*/
return S_OK;
}
//--------------------------------------------------------------------------------------
// Called every time the application receives a message
//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

View File

@ -1,112 +1,143 @@
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
#define DANBIAS_CLIENTRECIEVEROBJECT_H
//WTF!? No headers included???
namespace DanBias
{
struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
{
Oyster::Network::NetworkClient* nwClient;
Client::GameClientState* gameClientState;
// receiver function for server messages
// parsing protocols and sending it to the gameState
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
struct GameRecieverObject :public Oyster::Network::NetworkClient
{
int pType = p[0].value.netInt;
switch (pType)
Client::GameClientState* gameClientState;
// receiver function for server messages
// parsing protocols and sending it to the gameState
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
{
case protocol_General_Status:
int pType = p[0].value.netInt;
switch (pType)
{
GameLogic::Protocol_General_Status::States state;
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
if( state == GameLogic::Protocol_General_Status::States_disconected)
case protocol_General_Status:
{
// server disconnected
DanBiasGame::Release();
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_PlayerNavigation:
{
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
for(int i = 0; i< 6; i++)
break;
case protocol_Gameplay_PlayerMovement:
{
protocolData->key[i] = p[i+1].value.netBool;
}
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
for(int i = 0; i< 6; i++)
{
protocolData->key[i] = p[i+1].value.netBool;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_PlayerPosition:
{
Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
for(int i = 0; i< 3; i++)
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
//case protocol_Gameplay_PlayerPosition:
// {
// Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
// for(int i = 0; i< 3; i++)
// {
// protocolData->playerPos[i] = p[i].value.netFloat;
// }
// if(dynamic_cast<Client::GameState*>(gameClientState))
// ((Client::GameState*)gameClientState)->Protocol(protocolData);
// delete protocolData;
// protocolData = NULL;
// }
// break;
case protocol_Gameplay_ObjectCreate:
{
protocolData->playerPos[i] = p[i].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
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;
}
case protocol_Gameplay_CreateObject:
{
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++)
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:
{
protocolData->worldPos[i] = p[i+3].value.netFloat;
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;
}
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_RemoveObject:
{
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:
{
Client::GameClientState::ObjPos* protocolData = new Client::GameClientState::ObjPos;
protocolData->object_ID = p[1].value.netInt;
for(int i = 0; i< 16; i++)
break;
case protocol_Gameplay_ObjectPosition:
{
protocolData->worldPos[i] = p[i+2].value.netFloat;
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;
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
default:
break;
}
delete protocolData;
protocolData = NULL;
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;
}
break;
default:
break;
}
}
};
}
};
}
#endif

View File

@ -8,6 +8,7 @@ struct C_Player::myData
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
Oyster::Math3D::Float4 lookDir;
int ID;
}privData;
@ -29,7 +30,7 @@ void C_Player::Init(ModelInitData modelInit)
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
privData->ID = modelInit.id;
privData->lookDir = Oyster::Math3D::Float4 (0,0,1,0);
}
void C_Player::setPos(Oyster::Math::Float4x4 world)
{

View File

@ -0,0 +1,192 @@
#include "Camera.h"
Camera::Camera()
{
this->m_position = Oyster::Math::Float3(0, 50, 0);
this->mRight = Oyster::Math::Float3(1, 0, 0);
this->mUp = Oyster::Math::Float3(0, 1, 0);
this->mLook = Oyster::Math::Float3(0, 0, 1);
}
Camera::~Camera()
{
}
void Camera::SetPosition(const Oyster::Math::Float3& v)
{
this->m_position = v;
}
Oyster::Math::Float3 Camera::GetPosition()const
{
return this->m_position;
}
Oyster::Math::Float3 Camera::GetRight()const
{
return this->mRight;
}
Oyster::Math::Float3 Camera::GetUp()const
{
return this->mUp;
}
Oyster::Math::Float3 Camera::GetLook()const
{
return this->mLook;
}
float Camera::GetNearZ()const
{
return this->mNearZ;
}
float Camera::GetFarZ()const
{
return this->mFarZ;
}
float Camera::GetAspect()const
{
return this->mAspect;
}
Oyster::Math::Float3 Camera::CrossMatrix(const Oyster::Math::Float3& vector, const Oyster::Math::Float4x4& matrix)
{
Oyster::Math::Float3 vec;
vec.x = matrix.m11*vector.x + matrix.m12*vector.y + matrix.m13*vector.z;
vec.y = matrix.m21*vector.x + matrix.m22*vector.y + matrix.m23*vector.z;
vec.z = matrix.m31*vector.x + matrix.m32*vector.y + matrix.m33*vector.z;
return vec;
}
void Camera::SetLens(float fovY, float aspect, float zn, float zf)
{
this->mFovY = fovY;
this->mAspect = aspect;
this->mNearZ = zn;
this->mFarZ = zf;
/*float yScale = tan((Oyster::Math::pi*0.5f) - (mFovY*0.5f));
float xScale = yScale/this->mAspect;
mProj = Oyster::Math::Float4x4(xScale, 0, 0, 0,
0, yScale, 0, 0,
0, 0, zf/(zf-zn), 1,
0, 0, -zn*zf/(zf-zn), 0);
mProj.Transpose();*/
mProj = Oyster::Math3D::ProjectionMatrix_Perspective(fovY,aspect,zn,zf);
}
void Camera::LookAt(Oyster::Math::Float3 pos, Oyster::Math::Float3 target, Oyster::Math::Float3 worldUp)
{
Oyster::Math::Float3 L;
L = target - pos;
L.Normalize();
Oyster::Math::Float3 R;
R = worldUp.Cross(L);
R.Normalize();
Oyster::Math::Float3 U;
U = L.Cross(R);
this->m_position = pos;
this->mLook = L;
this->mRight = R;
this->mUp = U;
}
Oyster::Math::Float4x4 Camera::View()const
{
return this->mView;
}
Oyster::Math::Float4x4 Camera::Proj()const
{
return this->mProj;
}
Oyster::Math::Float4x4 Camera::ViewsProj()const
{
Oyster::Math::Float4x4 M;
M = mView * mProj;
return M;
}
void Camera::Walk(float dist)
{
this->m_position += dist*this->mLook;
}
void Camera::Strafe(float dist)
{
this->m_position += dist*this->mRight;
}
void Camera::Pitch(float angle)
{
float radians = angle * 0.0174532925f;
Oyster::Math::Float4x4 R;
Oyster::Math3D::RotationMatrix(radians,-mRight,R);
this->mUp = CrossMatrix(this->mUp, R);
this->mLook = CrossMatrix(this->mLook, R);
}
void Camera::Yaw(float angle)
{
float radians = angle * 0.0174532925f;
Oyster::Math::Float4x4 R;
Oyster::Math::Float3 up(0,1,0);
Oyster::Math3D::RotationMatrix(radians,-up,R);
this->mRight = CrossMatrix(this->mRight, R);
this->mUp = CrossMatrix(mUp, R);
this->mLook = CrossMatrix(this->mLook, R);
}
void Camera::UpdateViewMatrix()
{
mLook.Normalize();
mUp = mLook.Cross(mRight);
mUp.Normalize();
mRight = mUp.Cross(mLook);
mView = Oyster::Math3D::ViewMatrix_LookAtDirection(mLook, mUp, m_position);
/*
mLook.Normalize();
mUp = mLook.Cross(mRight);
mUp.Normalize();
mRight = mUp.Cross(mLook);
float x = -m_position.Dot(mRight);
float y = -m_position.Dot(mUp);
float z = -m_position.Dot(mLook);
mView.m11 = mRight.x;
mView.m21 = mRight.y;
mView.m31 = mRight.z;
mView.m41 = x;
mView.m12 = mUp.x;
mView.m22 = mUp.y;
mView.m32 = mUp.z;
mView.m42 = y;
mView.m13 = mLook.x;
mView.m23 = mLook.y;
mView.m33 = mLook.z;
mView.m43 = z;
mView.m14 = 0.0f;
mView.m24 = 0.0f;
mView.m34 = 0.0f;
mView.m44 = 1.0f;
mView.Transpose();*/
}

View File

@ -0,0 +1,63 @@
#ifndef CAMERA__H
#define CAMERA__H
#include "OysterMath.h"
class Camera
{
private:
Oyster::Math::Float3 m_position;
Oyster::Math::Float3 mRight;
Oyster::Math::Float3 mUp;
Oyster::Math::Float3 mLook;
float mNearZ;
float mFarZ;
float mAspect;
float mFovY;
Oyster::Math::Float4x4 mView;
Oyster::Math::Float4x4 mProj;
public:
Camera();
virtual ~Camera();
void SetPosition(const Oyster::Math::Float3& v);
Oyster::Math::Float3 GetPosition()const;
Oyster::Math::Float3 GetRight()const;
Oyster::Math::Float3 GetUp()const;
Oyster::Math::Float3 GetLook()const;
float GetNearZ()const;
float GetFarZ()const;
float GetAspect()const;
Oyster::Math::Float3 CrossMatrix(const Oyster::Math::Float3& v, const Oyster::Math::Float4x4& m);
void SetLens(float fovY, float aspect, float zn, float zf);
void LookAt(Oyster::Math::Float3 pos, Oyster::Math::Float3 target, Oyster::Math::Float3 worldUp);
void setLook(Oyster::Math::Float3 look) { mLook = look; }
void setUp(Oyster::Math::Float3 up) { mUp = up; }
void setRight(Oyster::Math::Float3 right) { mRight = right; }
Oyster::Math::Float4x4 View()const;
Oyster::Math::Float4x4 Proj()const;
Oyster::Math::Float4x4 ViewsProj()const;
void Walk(float dist);
void Strafe(float dist);
void Pitch(float angle);
void Yaw(float angle);
void UpdateViewMatrix();
};
#endif

View File

@ -51,6 +51,7 @@ public:
};
enum ClientState
{
ClientState_Login,
ClientState_Lobby,
ClientState_Game,
ClientState_Same,

View File

@ -4,7 +4,8 @@
#include "C_obj/C_DynamicObj.h"
#include <Protocols.h>
#include "NetworkClient.h"
#include "Camera.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
@ -17,7 +18,6 @@ struct GameState::myData
int modelCount;
Oyster::Network::NetworkClient* nwClient;
gameStateState state;
}privData;
@ -38,22 +38,35 @@ GameState::~GameState(void)
bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
{
// load models
camera = new Camera;
privData = new myData();
privData->state = gameStateState_loading;
privData->nwClient = nwClient;
privData->state = LoadGame();
return true;
}
GameState::gameStateState GameState::LoadGame()
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(0,3,0);
plight.Pos = Oyster::Math::Float3(0,15,5);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 5;
plight.Radius = 50;
plight.Bright = 2;
Oyster::Graphics::API::AddLight(plight);
plight.Pos = Oyster::Math::Float3(10,15,5);
plight.Color = Oyster::Math::Float3(1,0,0);
plight.Radius = 50;
plight.Bright = 2;
Oyster::Graphics::API::AddLight(plight);
plight.Pos = Oyster::Math::Float3(10,-15,5);
plight.Color = Oyster::Math::Float3(0,0,1);
plight.Radius = 50;
plight.Bright = 2;
Oyster::Graphics::API::AddLight(plight);
LoadModels(L"map");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
InitCamera(Oyster::Math::Float3(0,0,20.0f));
return gameStateState_playing;
}
bool GameState::LoadModels(std::wstring mapFile)
@ -63,46 +76,67 @@ bool GameState::LoadModels(std::wstring mapFile)
// init models
privData->modelCount = 2;
// add world model
ModelInitData modelData;
Oyster::Math3D::Float4x4 translate;
C_Object* obj;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0));
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
scale.v[0].x = 8;
scale.v[1].y = 8;
scale.v[2].z = 8;
modelData.world = scale; //modelData.world * translate
modelData.modelPath = L"..\\Content\\Models\\ball.dan";
modelData.id = 0;
obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
// add box model
modelData.world = Oyster::Math3D::Float4x4::identity;
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,15,0));
modelData.world = modelData.world * translate;
modelData.modelPath = L"..\\Content\\Models\\box.dan";
modelData.id = 1;
obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
modelData.world = Oyster::Math3D::Float4x4::identity;
// add player model
modelData.world = Oyster::Math3D::Float4x4::identity;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0, 15, 0));
modelData.world = modelData.world * translate;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
modelData.id = 0;
modelData.id = 2;
// load models
C_Object* obj = new C_Player();
obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
modelData.world = modelData.world * translate;
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
modelData.id ++;
obj = new C_DynamicObj();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
modelData.id ++;
obj = new C_DynamicObj();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
return true;
}
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
{
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 20);
camera->LookAt(pos, dir, up);
camera->SetLens(3.14f/2, 1024/768, 1, 1000);
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj);
camera->UpdateViewMatrix();
privData->view = camera->View();
privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
@ -110,6 +144,7 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos)
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
{
DanBias::GameServerAPI::ServerUpdate();
switch (privData->state)
{
case gameStateState_loading:
@ -127,83 +162,9 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
// read server data
// update objects
{
bool send = false;
GameLogic::Protocol_PlayerMovement movePlayer;
movePlayer.bForward = false;
movePlayer.bBackward = false;
movePlayer.bStrafeLeft = false;
movePlayer.bStrafeRight = false;
movePlayer.bTurnLeft = false;
movePlayer.bTurnRight = false;
readKeyInput(KeyInput);
camera->UpdateViewMatrix();
if(KeyInput->IsKeyPressed(DIK_W))
{
if(!key_forward)
{
movePlayer.bForward = true;
send = true;
key_forward = true;
}
}
else
key_forward = false;
if(KeyInput->IsKeyPressed(DIK_S))
{
if(!key_backward)
{
movePlayer.bBackward = true;
send = true;
key_backward = true;
}
}
else
key_backward = false;
if(KeyInput->IsKeyPressed(DIK_A))
{
if(!key_strafeLeft)
{
movePlayer.bStrafeLeft = true;
send = true;
key_strafeLeft = true;
}
}
else
key_strafeLeft = false;
if(KeyInput->IsKeyPressed(DIK_D))
{
if(!key_strafeRight)
{
movePlayer.bStrafeRight = true;
send = true;
key_strafeRight = true;
}
}
else
key_strafeRight = false;
if (privData->nwClient->IsConnected() && send)
{
privData->nwClient->Send(movePlayer);
}
//send delta mouse movement
if (KeyInput->IsMousePressed())
{
GameLogic::Protocol_PlayerMouse deltaMouseMove;
deltaMouseMove.dxMouse = KeyInput->GetYaw();
deltaMouseMove.dyMouse = KeyInput->GetPitch();
//privData->nwClient->Send(deltaMouseMove);
}
// send event data
//
if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end;
}
break;
case gameStateState_end:
@ -218,10 +179,12 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
}
bool GameState::Render()
{
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetView(camera->View());
//Oyster::Graphics::API::SetProjection(camera->Proj());
//Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection(privData->proj);
Oyster::Graphics::API::NewFrame();
for (int i = 0; i < privData->object.size(); i++)
for (unsigned int i = 0; i < privData->object.size(); i++)
{
privData->object[i]->Render();
}
@ -230,7 +193,7 @@ bool GameState::Render()
}
bool GameState::Release()
{
for (int i = 0; i < privData->object.size(); i++)
for (unsigned int i = 0; i < privData->object.size(); i++)
{
privData->object[i]->Release();
delete privData->object[i];
@ -241,6 +204,118 @@ bool GameState::Release()
privData = NULL;
return true;
}
void GameState::readKeyInput(InputClass* KeyInput)
{
bool send = false;
GameLogic::Protocol_PlayerMovement movePlayer;
movePlayer.bForward = false;
movePlayer.bBackward = false;
movePlayer.bLeft = false;
movePlayer.bRight = false;
if(KeyInput->IsKeyPressed(DIK_W))
{
if(!key_forward)
{
movePlayer.bForward = true;
send = true;
key_forward = true;
}
}
else
key_forward = false;
if(KeyInput->IsKeyPressed(DIK_S))
{
if(!key_backward)
{
movePlayer.bBackward = true;
send = true;
key_backward = true;
}
}
else
key_backward = false;
if(KeyInput->IsKeyPressed(DIK_A))
{
if(!key_strafeLeft)
{
movePlayer.bLeft = true;
send = true;
key_strafeLeft = true;
}
}
else
key_strafeLeft = false;
if(KeyInput->IsKeyPressed(DIK_D))
{
if(!key_strafeRight)
{
movePlayer.bRight = true;
send = true;
key_strafeRight = true;
}
}
else
key_strafeRight = false;
if (privData->nwClient->IsConnected() && send)
{
privData->nwClient->Send(movePlayer);
}
//send delta mouse movement
if (KeyInput->IsMousePressed())
{
camera->Yaw(KeyInput->GetYaw());
camera->Pitch(KeyInput->GetPitch());
camera->UpdateViewMatrix();
GameLogic::Protocol_PlayerLook playerLookDir;
Oyster::Math::Float3 look = camera->GetLook();
playerLookDir.lookDirX = look.x;
playerLookDir.lookDirY = look.y;
playerLookDir.lookDirZ = look.z;
privData->nwClient->Send(playerLookDir);
}
// shoot
if(KeyInput->IsKeyPressed(DIK_Z))
{
if(!key_Shoot)
{
GameLogic::Protocol_PlayerShot playerShot;
playerShot.hasShot = true;
privData->nwClient->Send(playerShot);
key_Shoot = true;
}
}
else
key_Shoot = false;
// jump
if(KeyInput->IsKeyPressed(DIK_X))
{
if(!key_Jump)
{
GameLogic::Protocol_PlayerJump playerJump;
playerJump.hasJumped = true;
privData->nwClient->Send(playerJump);
key_Jump = true;
}
}
else
key_Jump = false;
// send event data
//
if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end;
}
void GameState::Protocol(ProtocolStruct* pos)
{
@ -266,15 +341,19 @@ void GameState::Protocol( ObjPos* pos )
world[i] = pos->worldPos[i];
}
for (int i = 0; i < privData->object.size(); i++)
for (unsigned int i = 0; i < privData->object.size(); i++)
{
if(privData->object[i]->GetId() == pos->object_ID)
{
privData->object[i]->setPos(world);
//privData->view = world;
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
//camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2])));
//camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6])));
//camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10])));
if(i == 2) // playerobj
{
camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14]));
camera->UpdateViewMatrix();
}
}
}
}
@ -305,7 +384,7 @@ void GameState::Protocol( NewObj* newObj )
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
{
for (int i = 0; i < privData->object.size(); i++)
for (unsigned int i = 0; i < privData->object.size(); i++)
{
if(privData->object[i]->GetId() == obj->object_ID)
{

View File

@ -3,6 +3,7 @@
#include "GameClientState.h"
#include "OysterMath.h"
#include <string>
#include "Camera.h"
namespace DanBias
{
namespace Client
@ -21,6 +22,9 @@ private:
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
bool key_Shoot;
bool key_Jump;
Camera* camera;
struct myData;
myData* privData;
@ -33,6 +37,7 @@ public:
bool InitCamera(Oyster::Math::Float3 startPos) ;
gameStateState LoadGame();
void readKeyInput(InputClass* KeyInput);
bool Render()override;
bool Release()override;

View File

@ -4,6 +4,7 @@
#include "C_obj/C_Player.h"
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
@ -31,7 +32,7 @@ LobbyState::~LobbyState(void)
bool LobbyState::Init(Oyster::Network::NetworkClient* nwClient)
{
privData = new myData();
this->nwClient = nwClient;
// load models
LoadModels(L"UImodels.txt");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
@ -43,7 +44,7 @@ bool LobbyState::LoadModels(std::wstring file)
plight.Pos = Oyster::Math::Float3(-2,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 10;
plight.Bright = 3;
plight.Bright = 1;
Oyster::Graphics::API::AddLight(plight);
// open file
// read file
@ -86,9 +87,15 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
// update animation
// send data to server
// check data from server
DanBias::GameServerAPI::ServerUpdate();
if( KeyInput->IsKeyPressed(DIK_G))
return ClientState_Game;
{
if(!DanBias::GameServerAPI::GameStart())
return GameClientState::ClientState_Same;
return ClientState_Game;
}
return ClientState_Same;
}
bool LobbyState::Render()

View File

@ -3,6 +3,7 @@
#include "GameClientState.h"
#include "OysterMath.h"
#include "NetworkClient.h"
#include <string>
namespace DanBias
{
@ -12,6 +13,7 @@ namespace DanBias
class LobbyState : public GameClientState
{
private:
Oyster::Network::NetworkClient* nwClient;
struct myData;
myData* privData;
public:

View File

@ -0,0 +1,166 @@
#include "LoginState.h"
#include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
struct LoginState::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
// UI object
// game client*
}privData;
LoginState::LoginState(void)
{
}
LoginState::~LoginState(void)
{
}
bool LoginState::Init(Oyster::Network::NetworkClient* nwClient)
{
privData = new myData();
this->nwClient = nwClient;
// load models
LoadModels(L"UImodels.txt");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
return true;
}
bool LoginState::LoadModels(std::wstring file)
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(-2,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 10;
plight.Bright = 1;
Oyster::Graphics::API::AddLight(plight);
// open file
// read file
// init models
privData->modelCount = 2;
ModelInitData modelData;
modelData.world = Oyster::Math3D::Float4x4::identity;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\Models\\box_2.dan";
// load models
privData->object[0] = new C_StaticObj();
privData->object[0]->Init(modelData);
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
privData->object[1] = new C_DynamicObj();
privData->object[1]->Init(modelData);
return true;
}
bool LoginState::InitCamera(Oyster::Math::Float3 startPos)
{
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj);
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
}
GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* KeyInput)
{
// picking
// mouse events
// different menus
// play sounds
// update animation
// send data to server
// check data from server
// create game
if( KeyInput->IsKeyPressed(DIK_C))
{
DanBias::GameServerAPI::ServerInitDesc desc;
DanBias::GameServerAPI::ServerInitiate(desc);
DanBias::GameServerAPI::ServerStart();
// my ip
nwClient->Connect(15151, "127.0.0.1");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_Lobby;
}
// join game
if( KeyInput->IsKeyPressed(DIK_J))
{
// game ip
nwClient->Connect(15151, "194.47.150.56");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_Lobby;
}
return ClientState_Same;
}
bool LoginState::Render()
{
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame();
// render objects
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Render();
}
// render effects
// render lights
Oyster::Graphics::API::EndFrame();
return true;
}
bool LoginState::Release()
{
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Release();
delete privData->object[i];
privData->object[i] = NULL;
}
delete privData;
privData = NULL;
return true;
}
void LoginState::Protocol(ProtocolStruct* protocol)
{
if((PlayerName*)protocol)
PlayerJoinProtocol((PlayerName*)protocol);
}
void LoginState::PlayerJoinProtocol(PlayerName* name)
{
}

View File

@ -0,0 +1,33 @@
#ifndef DANBIAS_CLIENT_LOGINSTATE_H
#define DANBIAS_CLIENT_LOGINSTATE_H
#include "GameClientState.h"
#include "OysterMath.h"
#include "NetworkClient.h"
#include <string>
namespace DanBias
{
namespace Client
{
class LoginState : public GameClientState
{
private:
Oyster::Network::NetworkClient* nwClient;
struct myData;
myData* privData;
public:
LoginState(void);
~LoginState(void);
bool Init(Oyster::Network::NetworkClient* nwClient);
bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos);
ClientState Update(float deltaTime, InputClass* KeyInput);
bool Render();
bool Release();
void Protocol(ProtocolStruct* protocol)override;
void PlayerJoinProtocol(PlayerName* name);
};};};
#endif // ! DANBIAS_CLIENT_LOGINSTATE_H

View File

@ -18,7 +18,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
DanBias::DanBiasGameDesc gameDesc;
gameDesc.port = 15151;
//gameDesc.port = 15152;
//gameDesc.IP = "193.11.184.196";
//gameDesc.IP = "193.11.184.109";
//gameDesc.IP = "193.11.184.31";
//gameDesc.IP = "194.47.150.56";
gameDesc.IP = "127.0.0.1";

View File

@ -1,68 +0,0 @@
#define NOMINMAX
#include "AdminInterface.h"
#include <Thread\OysterThread.h>
#include <WindowShell.h>
#include "..\GameServer.h"
#include "..\GameSession\GameSessionManager.h"
#include "..\GameSession\GameSession.h"
#include "..\Helpers\ServerDataReader.h"
#include "..\LobbySessions\LobbyClient.h"
#include "..\LobbySessions\NetworkSession.h"
#include "..\LobbySessions\GameLobby.h"
#include "..\LobbySessions\MainLobby.h"
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace DanBias;
struct AdminInstanceData :public IThreadObject
{
bool isCreated;
Oyster::Network::NetworkServer adminServer;
NetworkClient* admin;
NetworkSession* parentInstance;
OysterThread worker;
bool DoWork() override
{
//((GameServer*)parentInstance)->serve
return true;
}
}adminInstanceData;
void AdminArrived(NetworkClient* adm)
{
if(adminInstanceData.admin)
{
delete adm;
return;
}
adminInstanceData.admin = adm;
adminInstanceData.worker.Create(&adminInstanceData, true, true);
}
void AdminInterface::Toggle(bool toggle, NetworkSession* parent)
{
if(toggle)
{
if(!parent) return;
if(adminInstanceData.isCreated) return;
NetworkServer::INIT_DESC desc;
desc.port = 15152;
desc.callbackType = NetworkClientCallbackType_Function;
desc.recvObj.clientConnectFnc = AdminArrived;
if(!adminInstanceData.adminServer.Init(desc)) return;
adminInstanceData.parentInstance = parent;
adminInstanceData.adminServer.Start();
}
else
{
adminInstanceData.adminServer.Shutdown();
}
}

View File

@ -1,20 +0,0 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_ADMIN_INTERFACE_H
#define DANBIASSERVER_ADMIN_INTERFACE_H
#include <NetworkServer.h>
namespace DanBias
{
class NetworkSession;
//Global admin
class AdminInterface
{
public:
static void Toggle(bool toggle, NetworkSession* parent);
};
}
#endif // !DANBIASSERVER_ADMIN_INTERFACE_H

View File

@ -1,28 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "DanBiasServerAPI.h"
#include "GameServer.h"
namespace DanBias
{
#pragma region Server Data
static GameServer server;
#pragma endregion
DanBiasServerReturn DanBiasServerAPI::Initiate()
{
return server.Create();
}
DanBiasServerReturn DanBiasServerAPI::Run()
{
return server.Run();
}
DanBiasServerReturn DanBiasServerAPI::Release()
{
return server.Release();
}
} //End namspace DanBias

View File

@ -1,37 +0,0 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIAS_SERVER_DANBIAS_SERVER_H
#define DANBIAS_SERVER_DANBIAS_SERVER_H
#include <vld.h>
#define DANBIAS_SERVER
#ifdef DANBIAS_SERVER_DLL_EXPORT
#define DANBIAS_SERVER_DLL __declspec(dllexport)
#else
#define DANBIAS_SERVER_DLL __declspec(dllimport)
#endif
namespace DanBias
{
enum DanBiasServerReturn
{
DanBiasServerReturn_Error,
DanBiasServerReturn_Sucess,
};
extern "C"
{
class DANBIAS_SERVER_DLL DanBiasServerAPI
{
public:
static DanBiasServerReturn Initiate();
static DanBiasServerReturn Run();
static DanBiasServerReturn Release();
};//End class DanBiasServer
}//End Extern "C"
} //End namspace DanBias
#endif // !DANBIAS_SERVER_DANBIAS_SERVER_H

View File

@ -1,161 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include <Windows.h>
#include <WindowShell.h>
#include <iostream>
#include "GameServer.h"
#include "Helpers\ServerDataReader.h"
#include "GameSession\GameSessionManager.h"
#include "LobbySessions\LobbyClient.h"
#include "GameSession\GameSession.h"
#include "AdminInterface\AdminInterface.h"
#include <Thread\OysterThread.h>
#include <Utilities.h>
#include <CollisionManager.h>
namespace DanBias
{
using namespace Oyster::Network;
GameServer* GameServer::instance = 0;
void GameServer::NetworkCallback(NetworkClient* client)
{
static bool myTest = false;
static int sessionId = -1;
printf("Client with ID [%i] connected.\n", client->GetID());
if(!myTest)
{
Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
GameSessionDescription desc;
desc.mapName = L"test";
desc.clients.Push(c);
desc.exitDestionation = this->mainLobby;
if((sessionId = GameSessionManager::AddSession(desc, true)) == 0)
printf("Failed to create a game session\n");
myTest = true;
//myTest = new GameSession();
//
//DanBias::GameSession::GameSessionDescription desc;
//desc.owner = 0;
//desc.clients.Push(c);
//
//if(!myTest->Create(desc)) return;
//myTest->Run();
}
else
{
Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
GameSessionManager::JoinSession(sessionId, c);
}
//Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
//this->mainLobby->Attach(c, this->mainLobby->GetPostbox());
}
GameServer::GameServer()
: initiated(0)
, running(0)
, released(0)
, maxClients(0)
, mainLobby(0)
, server(0)
{ this->instance = this; }
GameServer::~GameServer()
{
}
DanBiasServerReturn GameServer::Create()
{
this->server = new NetworkServer();
this->mainLobby = new MainLobby();
InitData data;
if(!LoadIniFile(data)) return DanBiasServerReturn_Error;
NetworkServer::INIT_DESC serverDesc;
this->maxClients = data.clients;
serverDesc.port = data.port;
serverDesc.recvObj = this;
serverDesc.callbackType = Oyster::Network::NetworkClientCallbackType_Object;
if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error;
if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error;
this->initiated = true;
return DanBiasServerReturn_Sucess;
}
DanBiasServerReturn GameServer::Run()
{
if(this->running) return DanBiasServerReturn_Error;
if(this->released) return DanBiasServerReturn_Error;
if(!this->initiated) return DanBiasServerReturn_Error;
if(!this->server->Start()) return DanBiasServerReturn_Error;
//Oyster::Thread::OysterThread ioThread;
//ioThread.Create(this, true,
while (true)
{
if(!WindowShell::Frame()) break;
this->mainLobby->Frame();
if(GetAsyncKeyState(0x51)) //Q for exit
break;
}
return DanBiasServerReturn_Sucess;
}
DanBiasServerReturn GameServer::Release()
{
GameSessionManager::CloseSession();
this->mainLobby->Release();
delete this->mainLobby;
this->server->Shutdown();
delete this->server;
this->released = true;
return DanBiasServerReturn_Sucess;
}
NetworkSession* GameServer::MainLobbyInstance()
{
return GameServer::instance->mainLobby;
}
bool GameServer::LoadIniFile(InitData& ini)
{
std::ifstream in;
std::string f = GetInitPath(InitPath_ServerIni);
in.open(f, std::ios::in);
if(!in.is_open()) return false;
std::string buffer;
while (!in.eof())
{
in >> buffer;
if(buffer == "port")
{
in >> ini.port;
}
else if(buffer == "clients")
{
in >> ini.clients;
}
}
in.close();
return true;
}
}//End namespace DanBias

View File

@ -1,50 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_GAME_SERVER_H
#define DANBIASSERVER_GAME_SERVER_H
#include "DanBiasServerAPI.h"
#include "LobbySessions\MainLobby.h"
#include <NetworkServer.h>
#include <NetworkCallbackHelper.h>
namespace DanBias
{
class GameServer :public Oyster::Network::ClientConnectedObject
{
public:
GameServer();
virtual~GameServer();
DanBiasServerReturn Create();
DanBiasServerReturn Run();
DanBiasServerReturn Release();
static NetworkSession* MainLobbyInstance();
private:
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
void NetworkCallback(Oyster::Network::NetworkClient* client) override;
bool initiated;
bool running;
bool released;
int maxClients;
MainLobby *mainLobby;
Oyster::Network::NetworkServer *server;
static GameServer* instance;
private:
struct InitData
{
int port;
int clients;
};
bool LoadIniFile(InitData&);
private:
friend class AdminInterface;
};
}// End namspace DanBias
#endif // !DANBIASSERVER_DBSERVER_H

View File

@ -1,67 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameClient.h"
#include "..\LobbySessions\NetworkSession.h"
#include <Protocols.h>
using namespace Utility::DynamicMemory;
using namespace DanBias;
using namespace GameLogic;
static int gameClientIDCount = 1;
GameClient::GameClient(SmartPointer<LobbyClient> client, IPlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
{
this->callbackValue = value;
this->client = client;
this->id = gameClientIDCount++;
this->player = player;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
c.callbackType = Oyster::Callback::CallbackType_Object;
c.value = this;
this->client->SetCallback(c);
}
GameClient::~GameClient()
{
if(this->client) this->client->Disconnect();
this->player = 0;
this->id = -1;
}
void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
{
this->callbackValue = value;
}
GameLogic::IPlayerData* GameClient::GetPlayer()
{
return this->player;
}
GameLogic::IPlayerData* GameClient::ReleasePlayer()
{
GameLogic::IPlayerData *temp = this->player;
this->player = 0;
return temp;
}
LobbyClient* GameClient::GetClient() const
{
return this->client;
}
Utility::DynamicMemory::SmartPointer<LobbyClient> GameClient::ReleaseClient()
{
SmartPointer<LobbyClient> temp = this->client;
this->client = 0;
return temp;
}
int GameClient::GetID() const
{
return this->id;
}
void GameClient::ObjectCallback(NetworkSession::NetEvent e)
{
e.gameClient = this;
this->callbackValue(e);
}

View File

@ -1,43 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_CLIENT_OBJECT_H
#define DANBIASSERVER_CLIENT_OBJECT_H
#include "..\LobbySessions\LobbyClient.h"
#include <PostBox\PostBox.h>
#include <GameAPI.h>
namespace DanBias
{
class GameClient: Oyster::Callback::CallbackObject<void, NetworkSession::NetEvent>
{
public:
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, GameLogic::IPlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
virtual~GameClient();
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
/* */
GameLogic::IPlayerData* GetPlayer();
GameLogic::IPlayerData* ReleasePlayer();
LobbyClient* GetClient() const;
Utility::DynamicMemory::SmartPointer<LobbyClient> ReleaseClient();
int GetID() const;
private:
//Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
GameLogic::IPlayerData* player;
Utility::DynamicMemory::SmartPointer<LobbyClient> client;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
int id;
void ObjectCallback(NetworkSession::NetEvent) override;
private:
friend class AdminInterface;
};
}//End namespace DanBias
#endif // !DANBIASSERVER_CLIENT_OBJECT_H

View File

@ -30,7 +30,7 @@ namespace DanBias
NetworkSession* owner;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
};
static GameSession* gameSession;
public:
GameSession();
virtual~GameSession();

View File

@ -1,123 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSessionManager.h"
#include "..\LobbySessions\LobbyClient.h"
#include "GameSession.h"
#include <DynamicArray.h>
using namespace DanBias;
using namespace Utility::DynamicMemory;
struct GameSessionData
{
DynamicArray< SmartPointer< GameSession > > sessions;
int freeSpot;
int Existst(int session)
{
for (unsigned int i = 0; i < sessions.Size(); i++)
{
if(!sessions[i] && freeSpot == -1) freeSpot = i;
if(sessions[i]->GetID() == session) return i;
}
return -1;
}
int GetFree()
{
for (unsigned int i = 0; i < sessions.Size(); i++)
{
if(!sessions[i])
{
this->freeSpot = i;
return this->freeSpot;
}
}
this->freeSpot = -1;
return this->freeSpot;
}
} gameSessionData;
int GameSessionManager::AddSession(GameSessionDescription& instance, bool run)
{
int k = gameSessionData.GetFree();
SmartPointer<GameSession> gs = new GameSession();
DanBias::GameSession::GameDescription desc;
desc.owner = instance.exitDestionation;
desc.clients = instance.clients;
desc.mapName = instance.mapName;
if(!gs->Create(desc)) return 0;
if(k == -1) gameSessionData.sessions.Push(gs);
else gameSessionData.sessions[k] = gs;
if(run) gs->Run();
return gs->GetID();
}
bool GameSessionManager::StartSession(int session)
{
int i = -1;
if((i = gameSessionData.Existst(session)) != -1) return false;
gameSessionData.sessions[i]->Run();
return true;
}
bool GameSessionManager::JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client)
{
int i = -1;
if((i = gameSessionData.Existst(session)) == -1) return false;
gameSessionData.sessions[i]->Join(client);
return true;
}
void GameSessionManager::GetSessionInfo(int session, GameSessionInfo& data)
{
memset(&data, 0, sizeof(GameSessionInfo));
int i = -1;
if((i = gameSessionData.Existst(session)) != -1) return;
//data.gametime = gameSessionData.sessions[i]->
//data.mapName = gameSessionData.sessions[i]->
//data.numberOfPlayers = gameSessionData.sessions[i]->
}
void GameSessionManager::CloseSession()
{
for (unsigned int i = 0; i < gameSessionData.sessions.Size(); i++)
{
gameSessionData.sessions[i]->CloseSession();
}
}
void GameSessionManager::CloseSession(int session)
{
int i = -1;
if((i = gameSessionData.Existst(session)) != -1) return;
gameSessionData.sessions[i]->CloseSession();
}
int GameSessionManager::GetSessionSize()
{
return gameSessionData.sessions.Size();
}

View File

@ -1,82 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_GAME_SEESION_MANAGER_H
#define DANBIASSERVER_GAME_SEESION_MANAGER_H
#include <string>
#include <Utilities.h>
#include <DynamicArray.h>
namespace DanBias
{
class LobbyClient;
class NetworkSession;
struct GameSessionDescription
{
std::wstring mapName;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
NetworkSession* exitDestionation; //The new owner when session dies
};
struct GameSessionInfo
{
std::wstring mapName;
unsigned int numberOfPlayers;
float gametime;
};
class GameSessionManager
{
public:
/**
* Add a new game session.
* On success, the function returns the game instance id number greater than 0.
*/
static int AddSession(GameSessionDescription& instance, bool run);
/**
* Starts an existing game session
* @param session The session id recieved when created.
* @param run Indicates if the game session should start imidiatly when created.
* @return Returns false if session is not found.
*/
static bool StartSession(int session);
/**
* Join an exiting session
* @param session The session id recieved when created.
* @param client The client that is to join a game session
* @return Returns false on failure.
*/
static bool JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client);
/**
* Gets information about a given session
* @param session The session id recieved when created.
* @param sessionInformation The output parameter that will be filled.
*/
static void GetSessionInfo(int session, GameSessionInfo& sessionInformation);
/**
* Close a session.
* @param session The session id recieved when created a session.
*/
static void CloseSession(int session);
/**
* Close all sessions.
*/
static void CloseSession();
/**
* Get total sessions running
* @return Returns the total sessions curently running.
*/
static int GetSessionSize();
private:
friend class AdminInterface;
};
}
#endif // !DANBIASSERVER_GAME_SEESION_MANAGER_H

View File

@ -11,7 +11,6 @@
#include <Windows.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
@ -42,35 +41,41 @@ namespace DanBias
{
switch (p[protocol_INDEX_ID].value.netShort)
{
case protocol_Gameplay_PlayerNavigation:
case protocol_Gameplay_PlayerMovement:
{
//Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
if(p[1].value.netBool) //bool bForward;
//world.v[3].x = 2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
if(p[2].value.netBool) //bool bBackward;
//world.v[3].x = -2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
if(p[5].value.netBool) //bool bStrafeRight;
//world.v[3].y = 2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
if(p[6].value.netBool) //bool bStrafeLeft;
//world.v[3].y = -2;
if(p[3].value.netBool) //bool bStrafeLeft;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
if(p[4].value.netBool) //bool bStrafeRight;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
}
break;
case protocol_Gameplay_PlayerMouseMovement:
case protocol_Gameplay_PlayerLookDir:
{
Protocol_PlayerLook m; m = p;
Oyster::Math3D::Float3 lookDir;
lookDir.x = p.Get(1).value.netFloat;
lookDir.y = p.Get(2).value.netFloat;
lookDir.z = p.Get(3).value.netFloat;
c->GetPlayer()->Rotate(lookDir);
}
break;
case protocol_Gameplay_PlayerChangeWeapon:
break;
case protocol_Gameplay_PlayerPosition:
break;
case protocol_Gameplay_CreateObject:
break;
case protocol_Gameplay_ObjectPosition:
case protocol_Gameplay_PlayerShot:
if (p[1].value.netBool)
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
break;
case protocol_Gameplay_PlayerJump:
if (p[1].value.netBool)
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
break;
case protocol_Gameplay_ObjectDamage:
break;
}
}
@ -82,10 +87,6 @@ namespace DanBias
case protocol_General_Status:
switch (p[1].value.netInt)
{
case GameLogic::Protocol_General_Status::States_bussy:
break;
case GameLogic::Protocol_General_Status::States_disconected:
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
this->RemoveClient(c);
@ -98,23 +99,58 @@ namespace DanBias
case GameLogic::Protocol_General_Status::States_ready:
break;
case GameLogic::Protocol_General_Status::States_leave:
break;
}
break;
case protocol_General_Text:
{
GameLogic::Protocol_General_Text temp(p);
printf("Message recieved from (%i):\t %s\n", c->GetID(), temp.text.c_str());
}
break;
}
}
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
{
//if (movedObject->)
//{
//
//}
//movedObject->GetOrientation();
GameLogic::IObjectData* obj = NULL;
if(dynamic_cast<GameLogic::ILevelData*>(movedObject))
{
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(0);
if(obj)
{
if(obj->GetType() == OBJECT_TYPE_WORLD)
{
obj->GetID();
Oyster::Math::Float4x4 world =obj->GetOrientation();
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
scale.v[0].x = 8;
scale.v[1].y = 8;
scale.v[2].z = 8;
//world = world * scale;
Protocol_ObjectPosition p(world, 0);
GameSession::gameSession->Send(p.GetProtocol());
}
}
obj = NULL;
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(1);
if(obj)
{
if(obj->GetType() == OBJECT_TYPE_BOX)
{
obj->GetID();
Oyster::Math::Float4x4 world = obj->GetOrientation();
Protocol_ObjectPosition p(world, 1);
GameSession::gameSession->Send(p.GetProtocol());
}
}
}
}
}//End namespace DanBias

View File

@ -24,24 +24,11 @@ using namespace GameLogic;
namespace DanBias
{
bool GameSession::DoWork( )
{
if(this->isRunning)
{
if(GetAsyncKeyState(VK_UP))
{
Protocol_General_Status p(Protocol_General_Status::States_ready);
Send(p.GetProtocol());
Sleep(100);
}
if(GetAsyncKeyState(VK_DOWN))
{
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
Protocol_CreateObject p(world, 2, "../Content/crate");
Send(p.GetProtocol());
Sleep(100);
}
double dt = this->timer.getElapsedSeconds();
gameInstance.SetFrameTimeLength((float)dt);
@ -65,9 +52,8 @@ namespace DanBias
if(clients.Size() >= 1 && clients[0])
{
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
Protocol_ObjectPosition p(world, 1);
Protocol_ObjectPosition p(world, 2);
Send(p.GetProtocol());
//Sleep(100);
}
}

View File

@ -1,29 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <Windows.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
void GameSession::Send(Oyster::Network::CustomNetProtocol* p)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i] && this->clients[i]->GetClient())
this->clients[i]->GetClient()->Send(p);
}
}
}//End namespace DanBias

View File

@ -1,30 +0,0 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_LEVELMANAGER_H
#define DANBIASSERVER_LEVELMANAGER_H
#include "ServerDataReader.h"
#include "..\LobbySessions\LobbyClient.h"
#include "..\LobbySessions\NetworkSession.h"
#include "..\LobbySessions\GameLobby.h"
#include <Utilities.h>
namespace DanBias
{
class MapManager
{
public:
struct MapInitDesc
{
const wchar_t* map;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
};
public:
static bool InitiateMapPack(const MapInitDesc& desc);
};
}
#endif // !DANBIASSERVER_LEVELMANAGER_H

View File

@ -1,44 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_SERVER_INIT_READER_H
#define DANBIASSERVER_SERVER_INIT_READER_H
#include <fstream>
#include <string>
namespace DanBias
{
enum InitPath
{
InitPath_ServerIni,
};
static std::string GetInitPath(InitPath file)
{
std::string type = "";
std::string path = "";
std::string flag = "";
switch (file)
{
case DanBias::InitPath_ServerIni:
flag = "ServerInit";
break;
}
std::fstream in;
in.open("..\\Settings\\serversearchpath.ini", std::ios::in);
if(!in.is_open()) return "";
while (!in.eof() && type != flag)
{
in >> type;
in >> path;
}
in.close();
return path;
}
}
#endif // !DANBIASSERVER_SERVER_INIT_READER_H

View File

@ -1,21 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameLobby.h"
namespace DanBias
{
GameLobby::GameLobby(Utility::DynamicMemory::SmartPointer<LobbyClient> owner)
{
}
GameLobby::~GameLobby()
{
}
void GameLobby::Release()
{
}
}//End namespace DanBias

View File

@ -1,24 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_GAMELOBBY_H
#define DANBIASSERVER_GAMELOBBY_H
#include "NetworkSession.h"
namespace DanBias
{
class GameLobby :public NetworkSession
{
public:
GameLobby(Utility::DynamicMemory::SmartPointer<LobbyClient> owner);
virtual~GameLobby();
void Release();
private:
friend class AdminInterface;
};
}//End namespace DanBias
#endif // !DANBIASSERVER_GAME_LOBBY_H

View File

@ -1,18 +0,0 @@
#include "INetworkSession.h"
#include <GID.h>
INetworkSession::INetworkSession()
:id(GID())
{}
INetworkSession::INetworkSession(const INetworkSession& orig)
{
id = orig.id;
}
const INetworkSession& INetworkSession::operator=(const INetworkSession& orig)
{
id = orig.id;
return *this;
}
INetworkSession::~INetworkSession()
{}

View File

@ -1,22 +0,0 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_INETWORKSESSION_H
#define DANBIASSERVER_INETWORKSESSION_H
class INetworkSession
{
public:
INetworkSession();
INetworkSession(const INetworkSession& orig);
const INetworkSession& operator=(const INetworkSession& orig);
virtual~INetworkSession();
inline int GetID() const { return this->id; }
private:
int id;
};
#endif // !DANBIASSERVER_INETWORKSESSION_H

View File

@ -1,51 +0,0 @@
#include "LobbyClient.h"
#include <Protocols.h>
using namespace Utility::DynamicMemory;
using namespace Oyster::Network;
using namespace Oyster::Callback;
using namespace GameLogic;
namespace DanBias
{
LobbyClient::LobbyClient(SmartPointer<NetworkClient> client)
{
this->client = client;
this->client->SetRecieverObject(this, NetworkProtocolCallbackType_Object);
}
LobbyClient::~LobbyClient()
{
this->callbackValue.callbackType = CallbackType_Unknown;
}
void LobbyClient::Disconnect()
{
this->client->Disconnect();
}
void LobbyClient::SetCallback(OysterCallback<void, NetworkSession::NetEvent> value)
{
this->callbackValue = value;
}
/** This method is NOT threadsafe. */
void LobbyClient::NetworkCallback(CustomNetProtocol& protocol)
{
if(this->callbackValue.callbackType == CallbackType_Unknown) return;
NetworkSession::NetEvent e;
e.sender = this;
e.protocol = protocol;
this->callbackValue(e);
}
void LobbyClient::Disconnected()
{
if(this->callbackValue.callbackType == CallbackType_Unknown) return;
NetworkSession::NetEvent e;
e.sender = this;
e.protocol = *GameLogic::Protocol_General_Status(Protocol_General_Status::States_disconected).GetProtocol();
this->callbackValue(e);
}
}//End namsapce DanBias

View File

@ -1,38 +0,0 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_LOBBYCLIENT_H
#define DANBIASSERVER_LOBBYCLIENT_H
#include "NetworkSession.h"
#include <NetworkClient.h>
#include <PostBox\PostBox.h>
namespace DanBias
{
class LobbyClient :public Oyster::Network::NetClientEvent
{
public:
LobbyClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client);
virtual~LobbyClient();
void Disconnect();
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
inline void Send(Oyster::Network::CustomProtocolObject& protocol) { this->client->Send(protocol); }
inline void Send(Oyster::Network::CustomNetProtocol* protocol) { this->client->Send(protocol); }
inline int GetID() const { return this->client->GetID(); }
private:
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
private:
void NetworkCallback(Oyster::Network::CustomNetProtocol& protocol) override;
void Disconnected() override;
private:
friend class AdminInterface;
};
}//End namspace DanBias
#endif // !DANBIASSERVER_LOBBYCLIENT_H

View File

@ -1,110 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "MainLobby.h"
#include "LobbyClient.h"
#include <PlayerProtocols.h>
#include <PostBox\PostBox.h>
using namespace Utility::DynamicMemory;
using namespace Oyster::Network;
using namespace Oyster;
namespace DanBias
{
MainLobby::MainLobby()
:gameLobby(5)
{
this->box = new PostBox<DanBias::NetworkSession::NetEvent>();
}
MainLobby::~MainLobby()
{
}
void MainLobby::Release()
{
delete this->box;
this->box = 0;
this->CloseSession(true);
}
void MainLobby::Frame()
{
ParseEvents();
}
IPostBox<NetworkSession::NetEvent>* MainLobby::GetPostbox()
{
return this->box;
}
//////// Private
void MainLobby::ParseEvents()
{
if(this->box && !this->box->IsEmpty())
{
NetEvent &e = this->box->Fetch();
ParseProtocol(e.protocol, e.sender);
}
}
void MainLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::LobbyClient* c)
{
bool update = false;
switch (p[0].value.netShort)
{
case protocol_Lobby_CreateGame:
{
GameLogic::Protocol_LobbyCreateGame val(p);
CreateGame(val, c);
update = true;
}
break;
case protocol_Lobby_JoinLobby:
{
GameLogic::Protocol_LobbyJoinLobby val(p);
JoinLobby(val, c);
}
break;
case protocol_Lobby_LeaveLobby:
{
Detach(c)->Disconnect();
}
break;
}
if(update) SendUpdate();
}
void MainLobby::CreateGame(GameLogic::Protocol_LobbyCreateGame& p, DanBias::LobbyClient* c)
{
for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
{
if(!gameLobby[i])
{
gameLobby[i] = new GameLobby(NetworkSession::Detach(c));
return;
}
}
this->gameLobby.Push(new GameLobby(NetworkSession::Detach(c)));
}
void MainLobby::JoinLobby(GameLogic::Protocol_LobbyJoinLobby& p, DanBias::LobbyClient* c)
{
for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
{
if (this->gameLobby[i]->GetID() == p.LobbyID)
{
this->gameLobby[i]->Attach(Detach(c));
return;
}
}
}
void MainLobby::SendUpdate()
{
//Send Lobbys
GameLogic::Protocol_LobbyUpdate();
}
}//End namespace DanBias

View File

@ -1,42 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_MAINLOBBY_H
#define DANBIASSERVER_MAINLOBBY_H
#include "NetworkSession.h"
#include "GameLobby.h"
#include <Protocols.h>
#include <PostBox\IPostBox.h>
namespace DanBias
{
class MainLobby :public NetworkSession
{
public:
MainLobby();
virtual~MainLobby();
void Release();
void Frame();
Oyster::IPostBox<NetworkSession::NetEvent>* GetPostbox();
private:
void ParseEvents();
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::LobbyClient* c);
void CreateGame(GameLogic::Protocol_LobbyCreateGame& p, DanBias::LobbyClient* c);
void JoinLobby(GameLogic::Protocol_LobbyJoinLobby& p, DanBias::LobbyClient* c);
void SendUpdate();
private:
Oyster::IPostBox<NetworkSession::NetEvent> *box;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameLobby>> gameLobby;
private:
friend class AdminInterface;
};
}//End namespace DanBias
#endif // !DANBIASGAME_GAMELOBBY_H

View File

@ -1,219 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "LobbyClient.h"
#include "NetworkSession.h"
#include <mutex>
namespace DanBias
{
NetworkSession::NetworkSession()
: owner(0)
, clientCount(0)
{}
NetworkSession::NetworkSession(const NetworkSession& orig)
{
this->clients = orig.clients;
this->owner = orig.owner;
this->clientCount = orig.clientCount;
}
const NetworkSession& NetworkSession::operator=(const NetworkSession& orig)
{
this->clients = orig.clients;
this->owner = orig.owner;
this->clientCount = orig.clientCount;
return *this;
}
NetworkSession::~NetworkSession()
{
this->clients.Clear();
this->clientCount = 0;
}
bool NetworkSession::Attach(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
{
clientListLock.lock();
int k = -1;
for (unsigned int i = 0; (k == -1) && i < this->clients.Size(); i++)
{
if(!this->clients[i])
k = i;
}
if(k == -1)
{
this->clients.Push(client);
}
else
{
this->clients[k] = client;
}
this->clientCount++;
clientListLock.unlock();
return true;
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(Oyster::Network::NetworkClient* client)
{
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
clientListLock.lock();
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[0]->GetID() == client->GetID())
{
val = this->clients[i];
this->clients[i] = 0;
this->clientCount--;
}
}
clientListLock.unlock();
return val;
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(const LobbyClient* client)
{
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
clientListLock.lock();
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[0]->GetID() == client->GetID())
{
val = this->clients[i];
this->clients[i] = 0;
this->clientCount--;
}
}
clientListLock.unlock();
return val;
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(const LobbyClient& client)
{
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
clientListLock.lock();
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[0]->GetID() == client.GetID())
{
val = this->clients[i];
this->clients[i] = 0;
this->clientCount--;
}
}
clientListLock.unlock();
return val;
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(short ID)
{
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
clientListLock.lock();
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[0]->GetID() == ID)
{
val = this->clients[i];
this->clients[i] = 0;
this->clientCount--;
}
}
clientListLock.unlock();
return val;
}
bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol)
{
bool returnValue = false;
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i])
{
this->clients[i]->Send(&protocol);
returnValue = true;
}
}
return returnValue;
}
bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i] && this->clients[i]->GetID() == ID)
{
this->clients[i]->Send(&protocol);
return true;
}
}
return false;
}
void NetworkSession::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
this->clients[i]->SetCallback(value);
}
}
void NetworkSession::CloseSession(bool dissconnectClients)
{
clientListLock.lock();
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(dissconnectClients) this->clients[i]->Disconnect();
else if(this->owner) this->owner->Attach(this->clients[i]);
}
this->clients.Clear();
clientListLock.unlock();
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::FindClient(int ID)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i]->GetID() == ID)
return this->clients[i];
}
return Utility::DynamicMemory::SmartPointer<LobbyClient>();
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::FindClient(LobbyClient& obj)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i]->GetID() == obj.GetID())
return this->clients[i];
}
return Utility::DynamicMemory::SmartPointer<LobbyClient>();
}
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::FindClient(LobbyClient* obj)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i]->GetID() == obj->GetID())
return this->clients[i];
}
return Utility::DynamicMemory::SmartPointer<LobbyClient>();
}
}//End namespace DanBias

View File

@ -1,91 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef DANBIASSERVER_NETWORK_SESSION_H
#define DANBIASSERVER_NETWORK_SESSION_H
//warning C4150: deletion of pointer to incomplete type, no destructor called
#pragma warning(disable : 4150)
#define NOMINMAX
#include "INetworkSession.h"
#include <Utilities.h>
#include <OysterCallback.h>
#include <DynamicArray.h>
#include <PostBox\IPostBox.h>
#include <CustomNetProtocol.h>
#include <NetworkClient.h>
#include <vector>
#include <mutex>
namespace DanBias
{
class LobbyClient;
class GameClient;
class NetworkSession :public INetworkSession
{
public:
struct NetEvent
{
LobbyClient* sender;
GameClient* gameClient;
Oyster::Network::CustomNetProtocol protocol;
NetEvent():sender(0), gameClient(0){}
};
public:
NetworkSession();
NetworkSession(const NetworkSession& orig);
const NetworkSession& operator=(const NetworkSession& orig);
virtual~NetworkSession();
virtual bool Attach(Utility::DynamicMemory::SmartPointer<LobbyClient> client);
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(Oyster::Network::NetworkClient* client);
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(const LobbyClient* client);
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(const LobbyClient& client);
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(short ID);
Utility::DynamicMemory::SmartPointer<LobbyClient> FindClient(LobbyClient& obj);
Utility::DynamicMemory::SmartPointer<LobbyClient> FindClient(LobbyClient* obj);
Utility::DynamicMemory::SmartPointer<LobbyClient> FindClient(int ID);
/**
* Sends a message to all clients in this session.
*/
virtual bool Send(Oyster::Network::CustomNetProtocol& message);
/**
* Sends a message to a specific client in this session.
*/
virtual bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
/**
* Set the callback to all clients to where a messages is recieved.
*/
virtual void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
/**
* Closes the session and sends the clients to given owner session if any.
* If session is null, clients is assumed to already be elsewhere and only releases a reference.
*/
virtual void CloseSession(bool dissconnectClients = false);
/** Set where the clients is returned on closed session. */
inline void SetOwner(NetworkSession* owner) { this->owner = owner; }
protected:
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
NetworkSession* owner; //Where clients end up when session is closed.
private:
std::mutex clientListLock;
int clientCount;
private:
friend class AdminInterface;
};
}//End namespace DanBias
#endif // !DANBIASSERVER_NETWORK_SESSION_H

View File

@ -71,7 +71,7 @@
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -79,7 +79,7 @@
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -87,7 +87,7 @@
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -95,7 +95,7 @@
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -111,8 +111,8 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll</DelayLoadDLLs>
<AdditionalDependencies>GameServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -128,8 +128,8 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll</DelayLoadDLLs>
<AdditionalDependencies>GameServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -149,8 +149,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>GameServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -170,13 +170,18 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>GameServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ServerLauncher.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\WindowManager\WindowManager.vcxproj">
<Project>{35aea3c0-e0a7-4e1e-88cd-514aa5a442b1}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -2,12 +2,13 @@
// Launcher to launch Danbias server //
// Created by [Dennis Andersen] [2013] //
//////////////////////////////////////////////////
#define NOMINMAX //Blame it on windows
#define NOMINMAX //Blame it on microsoft
#include <Windows.h>
#include <vld.h>
#include <iostream>
#include <WindowShell.h>
#include <DanBiasServerAPI.h>
#include <GameServerAPI.h>
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
{
@ -15,10 +16,22 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
{
return cmdShow;
}
if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess)
WindowShell::CreateConsoleWindow();
DanBias::GameServerAPI::ServerInitDesc desc;
desc.listenPort = 15151;
if(DanBias::GameServerAPI::ServerInitiate(desc) == DanBias::DanBiasServerReturn_Sucess)
{
DanBias::DanBiasServerAPI::Run();
DanBias::DanBiasServerAPI::Release();
DanBias::GameServerAPI::ServerStart();
//DanBias::GameServerAPI::GameStart();
while (!(GetAsyncKeyState(0x51))) //Q for exit
{
DanBias::GameServerAPI::ServerUpdate();
Sleep(1);
}
DanBias::GameServerAPI::ServerStop();
}
return cmdShow;
}

View File

@ -3,71 +3,68 @@
using namespace GameLogic;
struct AttatchmentMassDriver::PrivateData
{
PrivateData()
{
}
~PrivateData()
{
}
}myData;
AttatchmentMassDriver::AttatchmentMassDriver(void)
{
myData = new PrivateData();
this->owner = 0;
}
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{
myData = new PrivateData();
this->owner = &owner;
}
AttatchmentMassDriver::~AttatchmentMassDriver(void)
{
delete myData;
}
/********************************************************
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage)
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//switch case to determin what functionallity to use in the attatchment
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(usage);
ForcePush(usage,dt);
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(usage);
ForcePull(usage,dt);
break;
}
}
/********************************************************
* Pushes objects in a cone in front of the weapon when fired
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage)
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//create coneRigidBody that will then collide with object and push them in the aimed direction
//Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
int arg = 0;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&arg,ForcePushAction);
}
/********************************************************
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
********************************************************/
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage)
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
{
//Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100);
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
//do something with state
state.ApplyLinearImpulse(Oyster::Math::Float3(this->owner->GetLookDir()) * (500 * dt));
this->owner->GetRigidBody()->SetState(state);
}

View File

@ -15,30 +15,31 @@ namespace GameLogic
~AttatchmentMassDriver(void);
void UseAttatchment(const WEAPON_FIRE &usage);
void UseAttatchment(const WEAPON_FIRE &usage, float dt);
private:
/********************************************************
* Pushes objects and players in a cone in front of the player
* @param fireInput: allows switching on different functionality in this specific function
********************************************************/
void ForcePush(const WEAPON_FIRE &usage);
void ForcePush(const WEAPON_FIRE &usage, float dt);
/********************************************************
* Pulls the player forward, this is a movement tool
* @param fireInput: allows switching on different functionality in this specific function
********************************************************/
void ForcePull(const WEAPON_FIRE &usage);
void ForcePull(const WEAPON_FIRE &usage, float dt);
/********************************************************
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
* @param fireInput: allows switching on different functionality in this specific function
********************************************************/
void ForceSuck(const WEAPON_FIRE &usage);
void ForceSuck(const WEAPON_FIRE &usage, float dt);
static void ForcePushAction(Oyster::Physics::ICustomBody *obj, void* args);
private:
struct PrivateData;
PrivateData *myData;
};
}
#endif

View File

@ -5,25 +5,10 @@
using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct AttatchmentSocket::PrivateData
{
PrivateData()
{
}
~PrivateData()
{
}
SmartPointer<IAttatchment> attatchment;
}myData;
AttatchmentSocket::AttatchmentSocket(void)
{
this->attatchment = 0;
}
@ -34,17 +19,17 @@ AttatchmentSocket::~AttatchmentSocket(void)
IAttatchment* AttatchmentSocket::GetAttatchment()
{
return myData->attatchment;
return this->attatchment;
}
void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment)
{
myData->attatchment = attatchment;
this->attatchment = attatchment;
}
void AttatchmentSocket::RemoveAttatchment()
{
myData->attatchment = 0;
this->attatchment = 0;
}

View File

@ -19,8 +19,7 @@ namespace GameLogic
void RemoveAttatchment();
private:
struct PrivateData;
PrivateData *myData;
IAttatchment *attatchment;
};
}
#endif

View File

@ -1,62 +1,90 @@
#include "CollisionManager.h"
#include "PhysicsAPI.h"
#include "Object.h"
#include "DynamicObject.h"
#include "Player.h"
#include "Level.h"
#include "AttatchmentMassDriver.h"
#include "Game.h"
using namespace Oyster;
using namespace GameLogic;
void PlayerVBox(Player &player, DynamicObject &box);
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss);
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
Physics::ICustomBody::SubscriptMessage CollisionManager::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
//Physics::ICustomBody::SubscriptMessage
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
//Player *player = ((Player*)(rigidBodyPlayer->gameObjectRef));
//Object *realObj = (Object*)obj->gameObjectRef;
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
//switch (realObj->GetType())
//{
//case OBJECT_TYPE::OBJECT_TYPE_BOX:
// PlayerVBox(*player,(*(DynamicObject*) realObj));
// break;
//case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
//
// break;
//}
return;
switch (realObj->GetObjectType())
{
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
PlayerVObject(*player,*realObj, kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_BOX:
PlayerVBox(*player,(*(DynamicObject*) realObj), kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
int test = 5;
break;
}
return Physics::ICustomBody::SubscriptMessage_none;
//return Physics::ICustomBody::SubscriptMessage_none;
}
void PlayerVBox(Player &player, DynamicObject &box)
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss)
{
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
player.DamageLife(20);
}
Physics::ICustomBody::SubscriptMessage CollisionManager::BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
{
if(rigidBodyBox == 0)
//Collision between a player and a general static or dynamic object
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
int damageDone = 0;
int forceThreashHold = 200;
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
{
return Physics::ICustomBody::SubscriptMessage::SubscriptMessage_none;
damageDone = kineticEnergyLoss * 0.10f;
player.DamageLife(damageDone);
}
//DynamicObject *box = (DynamicObject*)rigidBodyBox->gameObjectRef;
//Object *realObj = (Object*)obj->gameObjectRef;
//switch (realObj->GetType())
//{
//case OBJECT_TYPE::OBJECT_TYPE_BOX:
//
// break;
//case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
// //PlayerVBox(*(Player*)realObj,*box);
// break;
//}
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_none;
}
Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj)
//Oyster::Physics::ICustomBody::SubscriptMessage
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
{
Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (1);
Oyster::Physics::ICustomBody::State state;
state = obj->GetState();
state.ApplyLinearImpulse(pushForce);
obj->SetState(state);
//((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
}

View File

@ -10,14 +10,7 @@ namespace GameLogic
class CollisionManager
{
public:
//these are the main collision functions
//typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj);
//these are the specific collision case functions
//void PlayerVBox(Player &player, DynamicObject &box);
//void BoxVBox(DynamicObject &box1, DynamicObject &box2);
//put general collision functions here that are not part of a specific object
};

View File

@ -7,15 +7,34 @@ using namespace GameLogic;
DynamicObject::DynamicObject()
:Object()
{
}
DynamicObject::DynamicObject(void* collisionFunc, OBJECT_TYPE type)
:Object(collisionFunc, type)
}
DynamicObject::DynamicObject(OBJECT_TYPE type)
:Object(type)
{
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
:Object(rigidBody,type)
{
}
DynamicObject::DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:Object(collisionFuncBefore,collisionFuncAfter,type)
{
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
{
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
{
}
DynamicObject::~DynamicObject(void)
{

View File

@ -14,7 +14,12 @@ namespace GameLogic
public:
DynamicObject();
DynamicObject(void* collisionFunc, OBJECT_TYPE type);
DynamicObject(OBJECT_TYPE type);
DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
~DynamicObject(void);
private:

View File

@ -93,6 +93,7 @@ void Game::CreateTeam()
bool Game::NewFrame()
{
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->BeginFrame();
@ -104,6 +105,30 @@ bool Game::NewFrame()
{
if(this->players[i]->player) this->players[i]->player->EndFrame();
}
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->BeginFrame();
}
API::Instance().Update();
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->EndFrame();
}
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->BeginFrame();
}
API::Instance().Update();
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->EndFrame();
}
gameInstance.onMoveFnc(this->level);
return true;
}
@ -151,9 +176,9 @@ float Game::GetFrameTime() const
void Game::PhysicsOnMove(const ICustomBody *object)
{
IObjectData* temp = 0;
//IObjectData* temp = ((IObjectData*)object->GetDataTag());
if(gameInstance.onMoveFnc) gameInstance.onMoveFnc(temp);
IObjectData* temp = (IObjectData*)object->GetCustomTag();
if(gameInstance.onMoveFnc && temp) gameInstance.onMoveFnc(temp);
}
void Game::PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<ICustomBody> proto)
{

View File

@ -39,6 +39,8 @@ namespace GameLogic
Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override;
OBJECT_TYPE GetObjectType() const override;
void Rotate(const Oyster::Math3D::Float3 lookDir) override;
Player *player;
};
@ -51,7 +53,7 @@ namespace GameLogic
Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override;
OBJECT_TYPE GetObjectType() const override;
IObjectData* GetObjectAt(int ID) const override;
Level *level;
};

View File

@ -75,6 +75,12 @@ namespace GameLogic
********************************************************/
virtual void Move(const PLAYER_MOVEMENT &movement) = 0;
/** Relative rotation around given axis
* @param x: The relative x axis
* @param y: The relative y axis
**/
virtual void Rotate(const Oyster::Math3D::Float3 lookDir) = 0;
/********************************************************
* Uses the chosen players weapon based on input
* @param Usage: enum value on what kind of action is to be taken
@ -94,7 +100,7 @@ namespace GameLogic
class ILevelData :public IObjectData
{
public:
virtual IObjectData* GetObjectAt(int ID) const = 0;
};
class DANBIAS_GAMELOGIC_DLL GameAPI

View File

@ -184,7 +184,12 @@
<ClInclude Include="GameMode.h" />
<ClInclude Include="IAttatchment.h" />
<ClInclude Include="Level.h" />
<ClInclude Include="LevelLoader\LevelLoader.h" />
<ClInclude Include="LevelLoader\Loader.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="StaticObject.h" />
<ClInclude Include="Team.h" />
@ -202,7 +207,11 @@
<ClCompile Include="Game_PlayerData.cpp" />
<ClCompile Include="IAttatchment.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="LevelLoader\ParseFunctions.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="StaticObject.cpp" />
<ClCompile Include="Team.cpp" />

View File

@ -24,7 +24,8 @@ namespace GameLogic
{
OBJECT_TYPE_PLAYER = 0,
OBJECT_TYPE_BOX = 1,
OBJECT_TYPE_WORLD = 2,
OBJECT_TYPE_WORLD = 2,
OBJECT_TYPE_GENERIC = 4,
OBJECT_TYPE_UNKNOWN = -1,
};

View File

@ -25,13 +25,18 @@ Oyster::Math::Float4x4 Game::LevelData::GetOrientation()
//return this->level->GetOrientation();
return Oyster::Math::Float4x4();
}
int Game::LevelData::GetID() const
{
//this->level->GetID();
return -1;
return ((IObjectData*)this->level)->GetID();
}
OBJECT_TYPE Game::LevelData::GetObjectType() const
{
//return this->level->GetType();
return OBJECT_TYPE_UNKNOWN;
return ((IObjectData*)this->level)->GetObjectType();
//return OBJECT_TYPE_UNKNOWN;
}
IObjectData* Game::LevelData::GetObjectAt(int ID) const
{
return this->level->GetObj(ID);
}

View File

@ -4,8 +4,19 @@
using namespace GameLogic;
Game::PlayerData::PlayerData()
{
this->player = new Player();
{
//set some stats that are appropriate to a player
Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(0,165,0);
sbDesc.size = Oyster::Math::Float3(4,7,4);
//create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
//create player with this rigid body
this->player = new Player(rigidBody,Object::DefaultCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
this->player->GetRigidBody()->SetCustomTag(this);
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
@ -44,7 +55,12 @@ int Game::PlayerData::GetTeamID() const
{
return this->player->GetTeamID();
}
OBJECT_TYPE Game::PlayerData::GetObjectType() const
{
return this->player->GetType();
return this->player->GetObjectType();
}
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
{
this->player->Rotate(lookDir);
}

View File

@ -19,7 +19,7 @@ namespace GameLogic
IAttatchment(void);
~IAttatchment(void);
virtual void UseAttatchment(const WEAPON_FIRE &usage) = 0;
virtual void UseAttatchment(const WEAPON_FIRE &usage, float dt) = 0;
private:

View File

@ -8,6 +8,7 @@ using namespace Oyster::Physics;
Level::Level(void)
{
}
Level::~Level(void)
{
@ -19,25 +20,48 @@ void Level::InitiateLevel(std::string levelPath)
}
void Level::InitiateLevel(float radius)
{
//API::SphericalBodyDescription sbDesc;
//sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
//sbDesc.ignoreGravity = true;
//sbDesc.radius = radius;
//sbDesc.mass = 1e16f; //10^16
//sbDesc.mass = 0; //10^16
//sbDesc.subscription_onCollision = CollisionManager::LevelCollision;
//
//ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
//API::Instance().AddObject(rigidBody);
// add level sphere
API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
sbDesc.ignoreGravity = true;
sbDesc.radius = 150;
sbDesc.mass = 10e12f;
//API::Gravity gravityWell;
//
//gravityWell.gravityType = API::Gravity::GravityType_Well;
//gravityWell.well.mass = 1e16f;
//gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
//
//API::Instance().AddGravity(gravityWell);
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
ICustomBody::State state;
rigidBody->GetState(state);
state.SetRestitutionCoeff(0.01);
rigidBody->SetState(state);
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
rigidBody->SetCustomTag(levelObj);
// add box
API::SimpleBodyDescription sbDesc_TestBox;
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(-5,15,0,0);
sbDesc_TestBox.ignoreGravity = false;
sbDesc_TestBox.mass = 10;
sbDesc_TestBox.size = Oyster::Math::Float4(0.5f,0.5f,0.5f,0);
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
testBox = new DynamicObject(rigidBody_TestBox, OBJECT_TYPE::OBJECT_TYPE_BOX);
rigidBody_TestBox->SetCustomTag(testBox);
rigidBody_TestBox->GetState(state);
state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,4));
rigidBody_TestBox->SetState(state);
// add gravitation
API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well;
gravityWell.well.mass = 10e16f;
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
API::Instance().AddGravity(gravityWell);
}
void Level::AddPlayerToTeam(Player *player, int teamID)
@ -55,4 +79,15 @@ void Level::RespawnPlayer(Player *player)
this->teamManager.RespawnPlayerRandom(player);
}
Object* Level::GetObj( int ID) const
{
if( ID == 0 )
return (Object*)levelObj;
else
return (Object*)testBox;
}
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
{
// function call from physics update when object was moved
Object* temp = (Object*)object->GetCustomTag();
}

View File

@ -51,12 +51,27 @@ namespace GameLogic
********************************************************/
void RespawnPlayer(Player *player);
/********************************************************
* Collision function for level, this is to be sent to physics through the subscribe function with the rigidbody
* Will be called when the physics detect a collision
* @param rigidBodyLevel: physics object of the level
* @param obj: physics object for the object that collided with the level
********************************************************/
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
Object* GetObj( int ID ) const;
static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object);
private:
TeamManager teamManager;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
GameMode gameMode;
Utility::DynamicMemory::SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
StaticObject *levelObj;
DynamicObject *testBox;
};

View File

@ -0,0 +1,18 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#include "LevelLoader.h"
using namespace GameLogic;
using namespace GameLogic::LevelFileLoader;
std::vector<ObjectTypeHeader> LevelLoader::LoadLevel(std::string fileName)
{
return parser.Parse(fileName);
}
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
{
return parser.ParseHeader(fileName);
}

View File

@ -0,0 +1,42 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#ifndef LEVELLOADER_H
#define LEVELLOADER_H
#include <string>
#include <vector>
#include <Vector.h>
#include "ObjectDefines.h"
#include "LevelParser.h"
namespace GameLogic
{
class LevelLoader
{
public:
LevelLoader(){this->parser = GameLogic::LevelFileLoader::LevelParser(); }
~LevelLoader(){}
/********************************************************
* Loads the level and objects from file.
* @param fileName: Path to the level-file that you want to load.
* @return: Returns all structs with objects and information about the level.
********************************************************/
std::vector<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); //.
private:
GameLogic::LevelFileLoader::LevelParser parser;
};
}
#endif

View File

@ -0,0 +1,117 @@
#include "LevelParser.h"
#include "Loader.h"
#include "ParseFunctions.h"
using namespace GameLogic;
using namespace ::LevelFileLoader;
LevelParser::LevelParser()
{
formatVersion.formatVersionMajor = 1;
formatVersion.formatVersionMinor = 0;
}
LevelParser::~LevelParser()
{
}
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
{
int bufferSize = 0;
int counter = 0;
std::vector<ObjectTypeHeader> objects;
//Read entire level file.
Loader loader;
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
//Read format version
FormatVersion levelFormatVersion;
//ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
if(this->formatVersion != levelFormatVersion)
{
//Do something if it's not the same version
}
while(counter < bufferSize)
{
//Get typeID
ObjectTypeHeader typeID;
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
switch((int)typeID.typeID)
{
case ObjectType_LevelMetaData:
{
LevelMetaData header;
ParseLevelMetaData(&buffer[counter], header, counter);
objects.push_back(header);
break;
}
case ObjectType_Dynamic:
{
ObjectHeader header;
ParseObject(&buffer[counter], &header, sizeof(header));
objects.push_back(header);
counter += sizeof(header);
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
FormatVersion levelFormatVersion;
//ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
if(this->formatVersion != levelFormatVersion)
{
//Do something if it's not the same version
}
//Find the header in the returned string.
while(counter < bufferSize)
{
ObjectTypeHeader typeID;
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
switch(typeID.typeID)
{
case ObjectType_LevelMetaData:
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
return levelHeader;
break;
case ObjectType_Dynamic:
//Do not call parse this object, since we are only interested in the LevelMetaData
//Only increase the counter size
counter += sizeof(ObjectHeader);
break;
default:
//Couldn't find typeID. FAIL!!!!!!
break;
}
}
return levelHeader;
}

View File

@ -0,0 +1,30 @@
#ifndef LEVEL_PARSER_H
#define LEVEL_PARSER_H
#include <string>
#include <vector>
#include "ObjectDefines.h"
namespace GameLogic
{
namespace LevelFileLoader
{
class LevelParser
{
public:
LevelParser();
~LevelParser();
//
std::vector<ObjectTypeHeader> Parse(std::string filename);
//
LevelMetaData ParseHeader(std::string filename);
private:
FormatVersion formatVersion;
};
}
}
#endif

View File

@ -0,0 +1,22 @@
//////////////////////////////////
// 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;
}

View File

@ -0,0 +1,28 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#ifndef LOADER_H
#define LOADER_H
#include "..\Misc\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;

View File

@ -0,0 +1,109 @@
#ifndef OBJECT_DEFINES_H
#define OBJECT_DEFINES_H
#include <string>
#include <vector>
namespace GameLogic
{
/************************************
Enums
*************************************/
enum ObjectType
{
ObjectType_LevelMetaData,
ObjectType_Static,
ObjectType_Dynamic,
//Etc
ObjectType_NUM_OF_TYPES,
ObjectType_Unknown = -1,
};
enum UsePhysics
{
UsePhysics_UseFullPhysics,
UsePhysics_IgnoreGravity,
UsePhysics_IgnorePhysics,
UsePhysics_Count,
UsePhysics_Unknown = -1,
};
//Should this be moved somewhere else?
enum GameMode
{
GameMode_FreeForAll,
GameMode_TeamDeathMatch,
//Etc
GameMode_Count,
GameMode_Unknown = -1,
};
/************************************
Structs
*************************************/
struct FormatVersion
{
int formatVersionMajor;
int formatVersionMinor;
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;
};
struct PhysicsObject
{
float mass;
float elasticity;
float frictionCoeffStatic;
float frictionCoeffDynamic;
float inertiaTensor[16];
UsePhysics usePhysics;
};
struct LevelMetaData : ObjectTypeHeader
{
std::string levelName;
FormatVersion levelVersion;
std::string levelDescription;
std::string levelAuthor;
int maxNumberOfPlayer;
float worldSize;
int overviewPictureID;
std::vector<GameMode> gameModesSupported;
};
struct ObjectHeader : public ObjectTypeHeader
{
//Model,
int ModelID;
//Texture
int TextureID;
//Position
float position[3];
//Rotation
float rotation[3];
//Scale
float scale[3];
};
}
#endif

View File

@ -0,0 +1,80 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#include "ParseFunctions.h"
#include "../../../Misc/Packing/Packing.h"
#include <string>
using namespace Oyster::Packing;
using namespace GameLogic::LevelFileLoader;
using namespace GameLogic;
using namespace std;
namespace GameLogic
{
namespace LevelFileLoader
{
void ParseObject(char* buffer, void *header, int size)
{
memcpy(header, buffer, size);
}
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
{
int start = 0;
int tempSize;
char tempName[100];
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], 8);
start += 8;
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(&header.overviewPictureID, &buffer[start], 4);
start += 4;
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;
}
}
}

View File

@ -0,0 +1,19 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#ifndef PARSERFUNCTIONS_H
#define PARSERFUNCTIONS_H
#include "ObjectDefines.h"
namespace GameLogic
{
namespace LevelFileLoader
{
void ParseObject(char* buffer, void *header, int size);
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
}
}
#endif

View File

@ -16,38 +16,83 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
Object::Object()
{
API::SimpleBodyDescription sbDesc;
//sbDesc.centerPosition =
//poi
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
this->rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
Oyster::Physics::API::Instance().AddObject(rigidBody);
//rigidBody->gameObjectRef = this;
this->objectID = GID();
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
this->objectID = GID();
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
Object::Object(void* collisionFunc, OBJECT_TYPE type)
Object::Object(OBJECT_TYPE type)
{
API::SimpleBodyDescription sbDesc;
//sbDesc.centerPosition =
//poi
this->rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
Oyster::Physics::API::Instance().AddObject(rigidBody);
this->type = type;
this->objectID = GID();
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
{
Oyster::Physics::API::Instance().AddObject(rigidBody);
this->rigidBody = rigidBody;
this->type = type;
this->objectID = GID();
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
{
API::SimpleBodyDescription sbDesc;
this->rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
Oyster::Physics::API::Instance().AddObject(rigidBody);
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
//rigidBody->gameObjectRef = this;
this->type = type;
this->objectID = GID();
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
{
Oyster::Physics::API::Instance().AddObject(rigidBody);
this->rigidBody = rigidBody;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type;
this->objectID = GID();
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
{
Oyster::Physics::API::Instance().AddObject(rigidBody);
this->rigidBody = rigidBody;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type;
this->objectID = GID();
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
void Object::ApplyLinearImpulse(Oyster::Math::Float3 force)
{
setState.ApplyLinearImpulse(force);
}
@ -56,7 +101,7 @@ Object::~Object(void)
}
OBJECT_TYPE Object::GetType() const
OBJECT_TYPE Object::GetObjectType() const
{
return this->type;
}
@ -73,10 +118,40 @@ Oyster::Physics::ICustomBody* Object::GetRigidBody()
void Object::BeginFrame()
{
this->rigidBody->SetState(this->setState);
}
// update physic
void Object::EndFrame()
{
this->rigidBody->GetState(this->getState);
Oyster::Math::Float4x4 rotMatrix = setState.GetOrientation(); //Oyster::Math3D::RotationMatrix(rot, axis);
//Oyster::Math3D::SnapAxisYToNormal_UsingNlerp(rotMatrix, -setState.GetGravityNormal());
//setState.SetOrientation(rotMatrix);
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}
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::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return state.GetCenterPosition();
}
Oyster::Math::Float4x4 Object::GetOrientation()
{
Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return state.GetOrientation();
}

View File

@ -7,26 +7,41 @@
#define OBJECT_H
#include "GameLogicStates.h"
#include "GameAPI.h"
#include <PhysicsAPI.h>
namespace GameLogic
{
class Game;
class Object
class Object :public IObjectData
{
public:
Object();
Object(void* collisionFunc, OBJECT_TYPE type);
Object(OBJECT_TYPE type);
Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
~Object(void);
OBJECT_TYPE GetType() const;
// API overrides
OBJECT_TYPE GetObjectType() const;
int GetID() const;
Oyster::Math::Float3 GetPosition();
Oyster::Math::Float4x4 GetOrientation();
Oyster::Physics::ICustomBody* GetRigidBody();
void ApplyLinearImpulse(Oyster::Math::Float3 force);
void BeginFrame();
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 DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
private:
OBJECT_TYPE type;
int objectID;

View File

@ -8,23 +8,56 @@ using namespace GameLogic;
using namespace Oyster::Physics;
Player::Player()
:DynamicObject(CollisionManager::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER)
:DynamicObject()
{
weapon = new Weapon();
life = 100;
teamID = -1;
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
}
Player::Player(OBJECT_TYPE type)
:DynamicObject(type)
{
InitPlayer();
}
Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
:DynamicObject(rigidBody,type)
{
InitPlayer();
}
Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:DynamicObject(collisionFuncBefore,collisionFuncAfter,type)
{
InitPlayer();
}
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
{
InitPlayer();
}
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
:DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
{
InitPlayer();
}
void Player::InitPlayer()
{
weapon = new Weapon(2,this);
this->life = 100;
this->teamID = -1;
this->playerState = PLAYER_STATE_IDLE;
lookDir = Oyster::Math::Float4(0,0,-1,0);
}
Player::~Player(void)
{
delete weapon;
weapon = NULL;
if(weapon)
{
delete weapon;
weapon = NULL;
}
}
void Player::Move(const PLAYER_MOVEMENT &movement)
{
switch(movement)
@ -53,31 +86,29 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
void Player::MoveForward()
{
setState.ApplyLinearImpulse(this->lookDir * (100 * this->gameInstance->GetFrameTime()));
setState.ApplyLinearImpulse(this->lookDir * (20 * this->gameInstance->GetFrameTime()));
}
void Player::MoveBackwards()
{
setState.ApplyLinearImpulse(-this->lookDir * 100 * this->gameInstance->GetFrameTime());
setState.ApplyLinearImpulse(-this->lookDir * 20 * this->gameInstance->GetFrameTime());
}
void Player::MoveRight()
{
//Do cross product with forward vector and negative gravity vector
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
//Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
setState.ApplyLinearImpulse(r * 100 * this->gameInstance->GetFrameTime());
Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime());
}
void Player::MoveLeft()
{
//Do cross product with forward vector and negative gravity vector
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
//Oyster::Math::Float4 r1 = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero
setState.ApplyLinearImpulse(-r * 100 * this->gameInstance->GetFrameTime());
Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero
setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime());
}
void Player::UseWeapon(const WEAPON_FIRE &usage)
{
this->weapon->Use(usage);
this->weapon->Use(usage,gameInstance->GetFrameTime());
}
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
@ -88,6 +119,22 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->lookDir = Oyster::Math::Float4(1,0,0);
}
void Player::Rotate(const Oyster::Math3D::Float3 lookDir)
{
this->lookDir = lookDir;
Oyster::Math::Float4 up(0,1,0,0);//-setState.GetGravityNormal();
Oyster::Math::Float4 pos = setState.GetCenterPosition();
Oyster::Math::Float4x4 world = Oyster::Math3D::OrientationMatrix_LookAtDirection(lookDir, up.xyz, pos.xyz);
// cant set rotation
//setState.SetOrientation(world);
//this->lookDir = lookDir - up.xyz;
//this->lookDir = lookDir;
//this->setState.AddRotation(Oyster::Math::Float4(x, y));
//this->setState.SetRotation();
}
void Player::Jump()
{
@ -116,7 +163,7 @@ Oyster::Math::Float4x4 Player::GetOrientation() const
}
Oyster::Math::Float3 Player::GetLookDir() const
{
return this->lookDir.xyz;
return this->lookDir;
}
int Player::GetTeamID() const
{

View File

@ -16,7 +16,13 @@ namespace GameLogic
{
public:
Player(void);
Player(OBJECT_TYPE type);
Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
~Player(void);
void InitPlayer();
/********************************************************
* Moves the player based on input
@ -41,6 +47,17 @@ namespace GameLogic
********************************************************/
void Respawn(Oyster::Math::Float3 spawnPoint);
void Rotate(const Oyster::Math3D::Float3 lookDir);
/********************************************************
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
* Will be called when the physics detect a collision
* @param rigidBodyPlayer: physics object of the player
* @param obj: physics object for the object that collided with the player
********************************************************/
static void PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
bool IsWalking();
bool IsJumping();
@ -62,7 +79,10 @@ namespace GameLogic
int teamID;
Weapon *weapon;
PLAYER_STATE playerState;
Oyster::Math::Float4 lookDir;
Oyster::Math::Float3 lookDir;
bool hasTakenDamage;
float invincibleCooldown;
};
}

View File

@ -9,13 +9,32 @@ StaticObject::StaticObject()
{
}
StaticObject::StaticObject(OBJECT_TYPE type)
:Object(type)
{
StaticObject::StaticObject(void* collisionFunc, OBJECT_TYPE type)
:Object(collisionFunc,type)
}
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
:Object(rigidBody,type)
{
}
StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:Object(collisionFuncBefore,collisionFuncAfter,type)
{
}
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
{
}
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
{
}
StaticObject::~StaticObject(void)
{

View File

@ -16,7 +16,12 @@ namespace GameLogic
public:
StaticObject();
StaticObject(void* collisionFunc, OBJECT_TYPE type);
StaticObject(OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
~StaticObject(void);
private:

View File

@ -1,60 +1,52 @@
#include "Weapon.h"
#include "AttatchmentSocket.h"
#include "AttatchmentMassDriver.h"
#include "DynamicArray.h"
#include "Player.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct Weapon::PrivateData
{
PrivateData()
{
weaponState = WEAPON_STATE_IDLE;
selectedAttatchment = 0;
currentNrOfAttatchments = 0;
selectedSocketID = 0;
attatchmentSockets = 0;
}
~PrivateData()
{
}
WEAPON_STATE weaponState;
DynamicArray<SmartPointer<AttatchmentSocket>> attatchmentSockets;
int currentNrOfAttatchments;
SmartPointer<IAttatchment> selectedAttatchment;
int selectedSocketID;
}myData;
Weapon::Weapon()
{
myData = new PrivateData();
weaponState = WEAPON_STATE_IDLE;
selectedAttatchment = 0;
currentNrOfAttatchments = 0;
selectedSocketID = 0;
attatchmentSockets = 0;
}
Weapon::Weapon(int MaxNrOfSockets)
Weapon::Weapon(int MaxNrOfSockets,Player *owner)
{
myData = new PrivateData();
myData->attatchmentSockets.Resize(MaxNrOfSockets);
attatchmentSockets.Resize(MaxNrOfSockets);
attatchmentSockets[0] = new AttatchmentSocket();
weaponState = WEAPON_STATE_IDLE;
currentNrOfAttatchments = 0;
selectedAttatchment = 0;
//give the weapon a massdriver on socket 0
IAttatchment *mD = new AttatchmentMassDriver(*owner);
attatchmentSockets[0]->SetAttatchment(mD);
this->currentNrOfAttatchments = 1;
SelectAttatchment(0);
//give the weapon a massdriver on socket 0
}
Weapon::~Weapon(void)
{
delete myData;
}
/********************************************************
* Uses the weapon based on the input given and the current chosen attatchment
********************************************************/
void Weapon::Use(const WEAPON_FIRE &usage)
void Weapon::Use(const WEAPON_FIRE &usage, float dt)
{
if (myData->selectedAttatchment)
if (selectedAttatchment)
{
myData->selectedAttatchment->UseAttatchment(usage);
selectedAttatchment->UseAttatchment(usage, dt);
}
}
@ -68,24 +60,24 @@ void Weapon::Use(const WEAPON_FIRE &usage)
********************************************************/
bool Weapon::IsFireing()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIRING);
return (weaponState == WEAPON_STATE::WEAPON_STATE_FIRING);
}
bool Weapon::IsIdle()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_IDLE);
return (weaponState == WEAPON_STATE::WEAPON_STATE_IDLE);
}
bool Weapon::IsReloading()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
return (weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
}
bool Weapon::IsValidSocket(int socketID)
{
if(socketID < (int)myData->attatchmentSockets.Size() && socketID >= 0)
if(socketID < (int)attatchmentSockets.Size() && socketID >= 0)
{
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
if (attatchmentSockets[socketID]->GetAttatchment() != 0)
{
return true;
}
@ -96,16 +88,16 @@ bool Weapon::IsValidSocket(int socketID)
int Weapon::GetCurrentSocketID()
{
return myData->selectedSocketID;
return selectedSocketID;
}
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
{
if(myData->currentNrOfAttatchments < (int)myData->attatchmentSockets.Size())
if(currentNrOfAttatchments < (int)attatchmentSockets.Size())
{
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
myData->currentNrOfAttatchments++;
attatchmentSockets[currentNrOfAttatchments]->SetAttatchment(attatchment);
currentNrOfAttatchments++;
}
}
@ -113,7 +105,7 @@ void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *
{
if (IsValidSocket(socketID))
{
myData->attatchmentSockets[socketID]->SetAttatchment(attatchment);
attatchmentSockets[socketID]->SetAttatchment(attatchment);
}
}
@ -121,7 +113,7 @@ void Weapon::RemoveAttatchment(int socketID)
{
if (IsValidSocket(socketID))
{
myData->attatchmentSockets[socketID]->RemoveAttatchment();
attatchmentSockets[socketID]->RemoveAttatchment();
}
}
@ -129,8 +121,8 @@ void Weapon::SelectAttatchment(int socketID)
{
if (IsValidSocket(socketID))
{
myData->selectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment();
myData->selectedSocketID = socketID;
selectedAttatchment = attatchmentSockets[socketID]->GetAttatchment();
selectedSocketID = socketID;
}
}

View File

@ -6,21 +6,20 @@
#include "GameLogicStates.h"
#include "IAttatchment.h"
#include "Player.h"
#include "AttatchmentSocket.h"
#include "DynamicArray.h"
namespace GameLogic
{
class Weapon
{
public:
Weapon(void);
Weapon(int nrOfAttatchmentSockets);
Weapon(int nrOfAttatchmentSockets, Player *owner);
~Weapon(void);
void Use(const WEAPON_FIRE &fireInput);
void Use(const WEAPON_FIRE &usage, float dt);
void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
@ -35,9 +34,12 @@ namespace GameLogic
int GetCurrentSocketID();
private:
struct PrivateData;
PrivateData *myData;
private:
WEAPON_STATE weaponState;
Utility::DynamicMemory::DynamicArray<AttatchmentSocket*> attatchmentSockets;
int currentNrOfAttatchments;
IAttatchment *selectedAttatchment;
int selectedSocketID;
};
}

View File

@ -154,8 +154,7 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ControlProtocols.h" />
<ClInclude Include="GameplayProtocols.h" />
<ClInclude Include="GeneralProtocols.h" />
<ClInclude Include="Protocols.h" />
<ClInclude Include="LobbyProtocols.h" />
<ClInclude Include="ObjectProtocols.h" />

View File

@ -1,63 +0,0 @@
#ifndef GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
#define GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
#include <vector>
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
namespace GameLogic
{
struct Protocol_GameplayInitiateSession :public Oyster::Network::CustomProtocolObject
{
struct SessionInitData
{
int id;
int type;
//std::string text;
};
std::vector<SessionInitData> element;
Protocol_GameplayInitiateSession()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_Initiate;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_GameplayInitiateSession(Oyster::Network::CustomNetProtocol& p)
{
int size = p[1].value.netInt;
for (int i = 0; i < size; i++)
{
SessionInitData d = { p[i+2].value.netInt, p[i+3].value.netInt /*, p[i+4].value.netCharPtr */ };
element.push_back(d);
}
}
void Add(int id, int type, std::string text)
{
SessionInitData d = { id, type /*, text*/ };
element.push_back(d);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
//Store the elements count
this->protocol[1].value = element.size();
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (unsigned int i = 0; i < element.size(); i+=3)
{
this->protocol[i+2].value = element[i].id;
this->protocol[i+3].value = element[i].type;
//element[i].text.copy(this->protocol[i+4].value.netCharPtr, element[i].text.size());
this->protocol[i+2].type = Oyster::Network::NetAttributeType_Int;
this->protocol[i+3].type = Oyster::Network::NetAttributeType_Int;
//this->protocol[i+4].type = Oyster::Network::NetAttributeType_CharArray;
}
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
}
#endif // !GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H

View File

@ -1,5 +1,5 @@
#ifndef GAMELOGIC_CONTROL_PROTOCOLS_H
#define GAMELOGIC_CONTROL_PROTOCOLS_H
#ifndef GAMELOGIC_GENERAL_PROTOCOLS_H
#define GAMELOGIC_GENERAL_PROTOCOLS_H
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
@ -12,23 +12,27 @@ namespace GameLogic
{
States_ready,
States_idle,
States_bussy,
State_waiting,
States_disconected,
States_leave
};
States status;
Protocol_General_Status()
{
this->protocol[protocol_INDEX_ID].value = protocol_General_Status;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_General_Status;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_General_Status(Oyster::Network::CustomNetProtocol& p)
{
this->protocol = p;
status = (States)p[1].value.netShort;
}
Protocol_General_Status(States state)
{
this->protocol[protocol_INDEX_ID].value = protocol_General_Status;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_General_Status;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->status = state;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
}
@ -45,18 +49,21 @@ namespace GameLogic
struct Protocol_General_Text :public Oyster::Network::CustomProtocolObject
{
char* text;
int destination;
std::string text; //The text to send
int destination; //The destination if any (Ie a whisper to a player)
Protocol_General_Text()
: destination(-1) {}
Protocol_General_Text(Oyster::Network::CustomNetProtocol& p)
{
this->protocol[protocol_INDEX_ID].value = protocol_General_Text;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_CharArray;
destination = p.Get(1).value.netInt;
text = p.Get(2).value.netCharPtr;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value.netCharPtr = text;
this->protocol.Set(0, protocol_General_Text, Oyster::Network::NetAttributeType_Short);
this->protocol.Set(1, destination, Oyster::Network::NetAttributeType_Int);
this->protocol.Set(2, text);
return &protocol;
}

View File

@ -9,8 +9,12 @@
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
#include <DynamicArray.h>
namespace GameLogic
{
/*
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
{
char* mapName;
@ -18,8 +22,8 @@ namespace GameLogic
Protocol_LobbyCreateGame()
{
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_CreateGame;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Lobby_Create;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_CharArray;
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
@ -39,38 +43,21 @@ namespace GameLogic
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject
{
char gameId;
Protocol_LobbyJoinGame()
{
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_JoinGame;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
protocol[1].value = gameId;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
*/
struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject
{
char gameId;
short gameId;
Protocol_LobbyStartGame()
{
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_StartGame;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Lobby_Start;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_LobbyStartGame(Oyster::Network::CustomNetProtocol& o)
{
gameId = o[1].value.netInt;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
@ -82,39 +69,19 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_LobbyJoinLobby :public Oyster::Network::CustomProtocolObject
struct Protocol_LobbyLogin :public Oyster::Network::CustomProtocolObject
{
int LobbyID;
Protocol_LobbyJoinLobby(int id = -1)
// Login stuff
Protocol_LobbyLogin()
{
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_JoinLobby;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Lobby_Join;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
LobbyID = id;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_LobbyJoinLobby(Oyster::Network::CustomNetProtocol& o)
Protocol_LobbyLogin(Oyster::Network::CustomNetProtocol& p)
{
LobbyID = o[1].value.netInt;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = LobbyID;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_LobbyLeaveLobby :public Oyster::Network::CustomProtocolObject
{
Protocol_LobbyLeaveLobby()
{
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_LeaveLobby;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
@ -125,53 +92,176 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_LobbyUpdate :public Oyster::Network::CustomProtocolObject
//struct Protocol_LobbyJoin :public Oyster::Network::CustomProtocolObject
//{
// short value;
//
// Protocol_LobbyJoin()
// {
// this->protocol[0].value = protocol_Lobby_Join;
// this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
// this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
// }
// Protocol_LobbyJoin(Oyster::Network::CustomNetProtocol& p)
// {
// this->protocol[0].value = protocol_Lobby_Join;
// this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
// this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
// value = p[1].value.netShort;
// }
// Oyster::Network::CustomNetProtocol* GetProtocol() override
// {
// protocol[1].value = value;
// return &protocol;
// }
//
// private:
// Oyster::Network::CustomNetProtocol protocol;
//};
struct Protocol_LobbyRefresh :public Oyster::Network::CustomProtocolObject
{
struct LobbyUpdateData
Protocol_LobbyRefresh()
{
std::string mapName;
int LobbyId;
this->protocol[0].value = protocol_Lobby_Login;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_LobbyRefresh(Oyster::Network::CustomNetProtocol& o)
{
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{ return &protocol; }
private:
Oyster::Network::CustomNetProtocol protocol;
};
/**
* A protocol that contains all data to send to client when update game lobby
*/
struct Protocol_LobbyClientData :public Oyster::Network::CustomProtocolObject
{
// Player list
struct PlayerData
{
std::string name;
std::string ip;
int id;
int team;
};
int count;
LobbyUpdateData* data;
Protocol_LobbyUpdate()
Utility::DynamicMemory::DynamicArray<PlayerData> list;
Protocol_LobbyClientData()
{
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_LeaveLobby;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Lobby_ClientData;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
list.Reserve(10);
}
Protocol_LobbyUpdate( Oyster::Network::CustomNetProtocol* p )
Protocol_LobbyClientData(Oyster::Network::CustomNetProtocol& p)
{
count = (*p)[1].value.netInt;
data = new LobbyUpdateData[count];
for (int i = 0; i < count; i++)
unsigned int size = this->protocol[1].value.netUInt;
list.Reserve(size);
int a = 2;
for (unsigned int i = 0; i < list.Size(); i++)
{
//data[i].mapName = (*p)[i].value.
PlayerData d;
d.id = this->protocol[a++].value.netInt;
d.team = this->protocol[a++].value.netInt;
d.name = this->protocol.Get(a++).value.netCharPtr;
d.ip = this->protocol.Get(a++).value.netCharPtr;
list.Push(d);
}
}
~Protocol_LobbyUpdate()
{
delete [] data;
data = 0;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value.netInt = count;
for (int i = 2; i < count; i++)
{
protocol[i].type = Oyster::Network::NetAttributeType_CharArray;
protocol[i+1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].value = list.Size();
protocol[i].value.netCharPtr = const_cast<char*>(data[i-2].mapName.c_str());
protocol[i+1].value.netInt = data[i-1].LobbyId;
int a = 2;
for (unsigned int i = 0; i < list.Size(); i++)
{
this->protocol[a].type = Oyster::Network::NetAttributeType_Int; // client-id
this->protocol[a++].value = list[i].id;
this->protocol[a].type = Oyster::Network::NetAttributeType_Int; // team-id
this->protocol[a++].value = list[i].team;
this->protocol[a].type = Oyster::Network::NetAttributeType_CharArray; // clientName
this->protocol.Set(a++, list[i].name);
this->protocol[a].type = Oyster::Network::NetAttributeType_CharArray; // clientIP
this->protocol.Set(a++, list[i].ip);
}
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_LobbyGameData :public Oyster::Network::CustomProtocolObject
{
std::string mapName;
int majorVersion;
int minorVersion;
Protocol_LobbyGameData()
{
this->protocol[0].value = protocol_Lobby_GameData;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
}
Protocol_LobbyGameData(Oyster::Network::CustomNetProtocol& p)
{
majorVersion = (int)p.Get(1).value.netInt;
minorVersion = (int)p.Get(2).value.netInt;
mapName = p.Get(3).value.netCharPtr;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = majorVersion;
this->protocol[2].value = minorVersion;
this->protocol.Set(3, mapName.c_str());
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
/**
* A protocol that contains all data to send to client when update main lobby
*/
//struct Protocol_LobbyMainData :public Oyster::Network::CustomProtocolObject
//{
// // Game instance list
//
// Protocol_LobbyMainData()
// {
// this->protocol[0].value = protocol_Lobby_MainData;
// this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
//
// this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
// }
// Protocol_LobbyMainData(Oyster::Network::CustomNetProtocol& p)
// {
//
// }
// Oyster::Network::CustomNetProtocol* GetProtocol() override
// {
// return &protocol;
// }
//
// private:
// Oyster::Network::CustomNetProtocol protocol;
//};
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -4,21 +4,244 @@
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
namespace GameLogic
{
struct Protocol_CreateObject :public Oyster::Network::CustomProtocolObject
struct Protocol_ObjectPickup :public Oyster::Network::CustomProtocolObject
{
short object_ID;
short pickup_ID;
Protocol_ObjectPickup()
{
this->protocol[0].value = protocol_Gameplay_ObjectPickup;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Short;
object_ID = -1;
pickup_ID = -1;
}
Protocol_ObjectPickup(Oyster::Network::CustomNetProtocol& p)
{
object_ID = p[1].value.netShort;
pickup_ID = p[2].value.netShort;
}
Protocol_ObjectPickup(int objectID, short pickupID)
{
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Short;
object_ID = objectID;
pickup_ID = pickupID;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = pickup_ID;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject
{
int object_ID;
float health; //Precentage%
Protocol_ObjectDamage()
{
this->protocol[0].value = protocol_Gameplay_ObjectDamage;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
object_ID = -1;
health = 0.0f;
}
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
{
}
Protocol_ObjectDamage(int id, float hp)
{
this->protocol[0].value = protocol_Gameplay_ObjectDamage;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
object_ID = id;
health = hp;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = health;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
{
int object_ID;
char *path;
float worldMatrix[16];
Protocol_CreateObject()
Protocol_ObjectPosition()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_CreateObject;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = -1;
memset(&worldMatrix[0], 0, sizeof(float) * 16);
}
Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p)
{
}
Protocol_ObjectPosition(float m[16], int id)
{
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = id;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].value = worldMatrix[i-2];
}
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectEnable :public Oyster::Network::CustomProtocolObject
{
int object_ID;
float worldMatrix[16];
Protocol_ObjectEnable()
{
this->protocol[0].value = protocol_Gameplay_ObjectEnabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = -1;
memset(&worldMatrix[0], 0, sizeof(float) * 16);
}
Protocol_ObjectEnable(Oyster::Network::CustomNetProtocol& p)
{
}
Protocol_ObjectEnable(float m[16], int id)
{
this->protocol[0].value = protocol_Gameplay_ObjectEnabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{ this->protocol[i].type = Oyster::Network::NetAttributeType_Float; }
object_ID = id;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].value = worldMatrix[i-2];
}
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject
{
int object_ID;
float timer;
Protocol_ObjectDisable()
{
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
}
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p)
{
}
Protocol_ObjectDisable(int id, float time)
{
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
object_ID = id;
timer = time;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = timer;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject
{
int object_ID;
char *name;
float worldMatrix[16];
Protocol_ObjectCreate()
{
this->protocol[0].value = protocol_Gameplay_ObjectCreate;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
@ -28,10 +251,14 @@ namespace GameLogic
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
}
Protocol_CreateObject(float m[16], int id, char *path)
Protocol_ObjectCreate(Oyster::Network::CustomNetProtocol& p)
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_CreateObject;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int;
}
Protocol_ObjectCreate(float m[16], int id, char *path)
{
this->protocol[0].value = protocol_Gameplay_ObjectCreate;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
@ -42,14 +269,14 @@ namespace GameLogic
}
object_ID = id;
this->path = path;
this->name = path;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = path;
this->protocol[2].value = name;
this->protocol[3].value = worldMatrix[0];
this->protocol[4].value = worldMatrix[1];
this->protocol[5].value = worldMatrix[2];
@ -70,77 +297,6 @@ namespace GameLogic
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
{
int object_ID;
float worldMatrix[16];
// look at dir
Protocol_ObjectPosition()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectPosition;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = -1;
memset(&worldMatrix[0], 0, sizeof(float) * 16);
}
Protocol_ObjectPosition(float m[16], int id)
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectPosition;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = id;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].value = worldMatrix[i-2];
}
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_RemoveObject :public Oyster::Network::CustomProtocolObject
{
int object_ID;
Protocol_RemoveObject()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_RemoveObject;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
return &protocol;
}

View File

@ -8,41 +8,44 @@
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
#include <bitset>
//protocol_Gameplay_PlayerMovement 300
//protocol_Gameplay_PlayerMouseMovement 301
//protocol_Gameplay_PlayerChangeWeapon 302
namespace GameLogic
{
struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject
{
bool bForward;
bool bBackward;
bool bTurnLeft;
bool bTurnRight;
bool bStrafeRight;
bool bStrafeLeft;
bool bLeft;
bool bRight;
Protocol_PlayerMovement()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerNavigation;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Gameplay_PlayerMovement;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[4].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[5].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[6].type = Oyster::Network::NetAttributeType_Bool;
}
Protocol_PlayerMovement(Oyster::Network::CustomNetProtocol& p)
{
bForward = p[1].value.netBool;
bBackward = p[2].value.netBool;
bLeft = p[3].value.netBool;
bRight = p[4].value.netBool;
}
const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val)
{
bForward = val[1].value.netBool;
bBackward = val[2].value.netBool;
bTurnLeft = val[3].value.netBool;
bTurnRight = val[4].value.netBool;
bStrafeRight = val[5].value.netBool;
bStrafeLeft = val[6].value.netBool;
bLeft = val[3].value.netBool;
bRight = val[4].value.netBool;
return *this;
}
@ -50,10 +53,8 @@ namespace GameLogic
{
this->protocol[1].value = bForward;
this->protocol[2].value = bBackward;
this->protocol[3].value = bTurnLeft;
this->protocol[4].value = bTurnRight;
this->protocol[5].value = bStrafeRight;
this->protocol[6].value = bStrafeLeft;
this->protocol[3].value = bLeft;
this->protocol[4].value = bRight;
return &protocol;
}
@ -62,70 +63,43 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
{
float dxMouse;
float dyMouse;
float lookDirX;
float lookDirY;
float lookDirZ;
Protocol_PlayerMouse()
Protocol_PlayerLook()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerMouseMovement;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
}
const Protocol_PlayerMouse& operator=(Oyster::Network::CustomNetProtocol& val)
{
dxMouse = val[1].value.netFloat;
dyMouse = val[2].value.netFloat;
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = dxMouse;
this->protocol[2].value = dyMouse;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject
{
float position[3];
// look at dir
Protocol_PlayerPosition()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerPosition;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
}
const Protocol_PlayerPosition& operator=(Oyster::Network::CustomNetProtocol& val)
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
{
position[0] = val[1].value.netFloat;
position[1] = val[2].value.netFloat;
position[2] = val[3].value.netFloat;
lookDirX = p[1].value.netFloat;
lookDirY = p[2].value.netFloat;
lookDirZ = p[3].value.netFloat;
}
const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val)
{
lookDirX = val[1].value.netFloat;
lookDirY = val[2].value.netFloat;
lookDirZ = val[3].value.netFloat;
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = position[0];
this->protocol[2].value = position[1];
this->protocol[3].value = position[2];
this->protocol[1].value = lookDirX;
this->protocol[2].value = lookDirY;
this->protocol[3].value = lookDirZ;
return &protocol;
}
@ -133,6 +107,92 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject
{
int ID;
Protocol_PlayerChangeWeapon()
{
this->protocol[0].value = protocol_Gameplay_PlayerChangeWeapon;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_PlayerChangeWeapon(Oyster::Network::CustomNetProtocol& p)
{
}
const Protocol_PlayerChangeWeapon& operator=(Oyster::Network::CustomNetProtocol& val)
{
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject
{
bool hasShot;
Protocol_PlayerShot()
{
this->protocol[0].value = protocol_Gameplay_PlayerShot;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
}
Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p)
{
hasShot = p[1].value.netBool;
}
const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val)
{
hasShot = val[1].value.netBool;
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = hasShot;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject
{
bool hasJumped;
Protocol_PlayerJump()
{
this->protocol[0].value = protocol_Gameplay_PlayerJump;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
}
Protocol_PlayerJump(Oyster::Network::CustomNetProtocol& p)
{
hasJumped = p[1].value.netBool;
}
const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val)
{
hasJumped = val[1].value.netBool;
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = hasJumped;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -8,20 +8,15 @@
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
/** Index where the identifier is located(aka protocol identification index) **/
/* Use this as id accesser since it may change in the future. */
#define protocol_INDEX_ID 0
/***********************************/
/********* RESERVERD PROTOCOLS ***************************************************************************************************/
/********** [ 0 - 100 ] *********/
/********** [ 0 - 99 ] *********/
#define protocol_RESERVED_MIN 0
#define protocol_RESERVED_MAX 99
/***********************************/
/********* GENERAL PROTOCOLS ***************************************************************************************************/
/***********[ 100 - 200 ]***********/
/***********[ 100 - 199 ]***********/
#define protocol_GeneralMIN 100
#define protocol_General_Status 100
#define protocol_General_Text 101
@ -30,28 +25,33 @@
/***********************************/
/********* LOBBY PROTOCOLS ***************************************************************************************************/
/***********[ 200 - 300 ]***********/
/***********[ 200 - 299 ]***********/
#define protocol_LobbyMIN 200
#define protocol_Lobby_CreateGame 200
#define protocol_Lobby_JoinGame 201
#define protocol_Lobby_StartGame 202
#define protocol_Lobby_JoinLobby 203
#define protocol_Lobby_LeaveLobby 204
#define protocol_Lobby_CreateGameLobby 205
#define protocol_Lobby_Create 200
#define protocol_Lobby_Start 201
#define protocol_Lobby_Join 202
#define protocol_Lobby_Login 203
#define protocol_Lobby_Refresh 204
#define protocol_Lobby_ClientData 205
#define protocol_Lobby_GameData 206
#define protocol_LobbyMAX 299
/***********************************/
/********* GAMEPLAY PROTOCOLS ***************************************************************************************************/
/***********[ 300 - 400 ]***********/
/***********[ 300 - 399 ]***********/
#define protocol_GameplayMIN 300
#define protocol_Gameplay_PlayerNavigation 300
#define protocol_Gameplay_PlayerMouseMovement 301
#define protocol_Gameplay_PlayerPosition 302
#define protocol_Gameplay_CreateObject 303
#define protocol_Gameplay_RemoveObject 304
#define protocol_Gameplay_ObjectPosition 305
#define protocol_Gameplay_Initiate 306
#define protocol_Gameplay_PlayerMovement 300
#define protocol_Gameplay_PlayerLookDir 301
#define protocol_Gameplay_PlayerChangeWeapon 302
#define protocol_Gameplay_PlayerShot 303
#define protocol_Gameplay_PlayerJump 304
#define protocol_Gameplay_ObjectPickup 305
#define protocol_Gameplay_ObjectDamage 306
#define protocol_Gameplay_ObjectPosition 307
#define protocol_Gameplay_ObjectEnabled 308
#define protocol_Gameplay_ObjectDisabled 309
#define protocol_Gameplay_ObjectCreate 310
#define protocol_GameplayMAX 399

View File

@ -4,7 +4,6 @@
#include "ObjectProtocols.h"
#include "PlayerProtocols.h"
#include "LobbyProtocols.h"
#include "ControlProtocols.h"
#include "GameplayProtocols.h"
#include "GeneralProtocols.h"
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H

Some files were not shown because too many files have changed in this diff Show More