Broekn branch not broekn more
This commit is contained in:
parent
91e825dbfb
commit
36f057d2cc
|
@ -32,9 +32,6 @@ EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {52380DAA-0F4A-4D97-8E57-98DF39319CAF}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -44,8 +41,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Ga
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDependencies", "Game\ServerDependencies\ServerDependencies.vcxproj", "{52380DAA-0F4A-4D97-8E57-98DF39319CAF}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
@ -274,18 +269,6 @@ Global
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.Build.0 = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|x64.Build.0 = Release|x64
|
|
||||||
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.ActiveCfg = Debug|Win32
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
@ -313,7 +296,6 @@ Global
|
||||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
|
||||||
{143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?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>
|
<zoom_level>10</zoom_level>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>380</x>
|
<x>610</x>
|
||||||
<y>360</y>
|
<y>340</y>
|
||||||
<w>100</w>
|
<w>100</w>
|
||||||
<h>30</h>
|
<h>30</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>360</x>
|
<x>580</x>
|
||||||
<y>540</y>
|
<y>480</y>
|
||||||
<w>160</w>
|
<w>160</w>
|
||||||
<h>80</h>
|
<h>80</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -28,77 +28,33 @@
|
||||||
/players./</panel_attributes>
|
/players./</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>560</x>
|
|
||||||
<y>360</y>
|
|
||||||
<w>100</w>
|
|
||||||
<h>30</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>LobbyClient</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>400</x>
|
<x>620</x>
|
||||||
<y>460</y>
|
<y>340</y>
|
||||||
<w>50</w>
|
<w>60</w>
|
||||||
<h>100</h>
|
<h>160</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>></panel_attributes>
|
<panel_attributes>lt=->>>></panel_attributes>
|
||||||
<additional_attributes>30;80;30;30</additional_attributes>
|
<additional_attributes>30;140;40;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>450</x>
|
<x>710</x>
|
||||||
<y>340</y>
|
<y>480</y>
|
||||||
<w>130</w>
|
<w>100</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
<panel_attributes>lt=>>>>-</panel_attributes>
|
||||||
<additional_attributes>110;30;30;30</additional_attributes>
|
<additional_attributes>80;30;30;30</additional_attributes>
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>460</x>
|
|
||||||
<y>270</y>
|
|
||||||
<w>170</w>
|
|
||||||
<h>110</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
|
||||||
<additional_attributes>150;90;150;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>490</x>
|
|
||||||
<y>450</y>
|
|
||||||
<w>140</w>
|
|
||||||
<h>140</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
|
||||||
<additional_attributes>120;30;120;120;30;120</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>460</x>
|
|
||||||
<y>180</y>
|
|
||||||
<w>400</w>
|
|
||||||
<h>150</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>380;130;170;130;170;30;30;30</additional_attributes>
|
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>370</x>
|
<x>600</x>
|
||||||
<y>200</y>
|
<y>180</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>120</h>
|
<h>120</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -108,42 +64,19 @@
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>400</x>
|
<x>630</x>
|
||||||
<y>290</y>
|
<y>270</y>
|
||||||
<w>50</w>
|
<w>50</w>
|
||||||
<h>90</h>
|
<h>90</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>>-</panel_attributes>
|
<panel_attributes>lt=>>>>-</panel_attributes>
|
||||||
<additional_attributes>30;70;30;30</additional_attributes>
|
<additional_attributes>30;70;30;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>600</x>
|
|
||||||
<y>300</y>
|
|
||||||
<w>260</w>
|
|
||||||
<h>80</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>240;30;30;30;30;60</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Package</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>840</x>
|
|
||||||
<y>290</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>NetworkAPI
|
|
||||||
bg=#a21aff</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>360</x>
|
<x>590</x>
|
||||||
<y>120</y>
|
<y>100</y>
|
||||||
<w>130</w>
|
<w>130</w>
|
||||||
<h>40</h>
|
<h>40</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -154,8 +87,8 @@ DanBiasServerAPI</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>400</x>
|
<x>630</x>
|
||||||
<y>130</y>
|
<y>110</y>
|
||||||
<w>50</w>
|
<w>50</w>
|
||||||
<h>90</h>
|
<h>90</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -166,10 +99,10 @@ DanBiasServerAPI</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>150</x>
|
<x>1060</x>
|
||||||
<y>360</y>
|
<y>330</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>30</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>NetworkSession</panel_attributes>
|
<panel_attributes>NetworkSession</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
|
@ -177,41 +110,41 @@ DanBiasServerAPI</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>180</x>
|
<x>690</x>
|
||||||
<y>270</y>
|
<y>220</y>
|
||||||
<w>210</w>
|
<w>390</w>
|
||||||
<h>110</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
<panel_attributes>lt=-<<<<</panel_attributes>
|
||||||
<additional_attributes>190;30;30;30;30;90</additional_attributes>
|
<additional_attributes>30;30;370;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>240</x>
|
<x>680</x>
|
||||||
<y>340</y>
|
<y>320</y>
|
||||||
<w>160</w>
|
<w>400</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
<panel_attributes>lt=->>>>></panel_attributes>
|
||||||
<additional_attributes>140;30;30;30</additional_attributes>
|
<additional_attributes>30;30;380;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>180</x>
|
<x>690</x>
|
||||||
<y>360</y>
|
<y>340</y>
|
||||||
<w>200</w>
|
<w>390</w>
|
||||||
<h>210</h>
|
<h>160</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
<panel_attributes>lt=->>>>></panel_attributes>
|
||||||
<additional_attributes>180;190;30;190;30;30</additional_attributes>
|
<additional_attributes>30;140;40;40;370;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Package</type>
|
<type>com.umlet.element.Package</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>840</x>
|
<x>460</x>
|
||||||
<y>410</y>
|
<y>640</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -222,164 +155,19 @@ bg=blue</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>600</x>
|
<x>370</x>
|
||||||
<y>360</y>
|
<y>530</y>
|
||||||
<w>260</w>
|
<w>350</w>
|
||||||
<h>90</h>
|
<h>290</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
<additional_attributes>240;70;30;70;30;30</additional_attributes>
|
<additional_attributes>90;150;30;270;330;240;240;30</additional_attributes>
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Package</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>840</x>
|
|
||||||
<y>350</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>630</x>
|
|
||||||
<y>340</y>
|
|
||||||
<w>230</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=.<<</panel_attributes>
|
|
||||||
<additional_attributes>210;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>490</x>
|
|
||||||
<y>420</y>
|
|
||||||
<w>370</w>
|
|
||||||
<h>190</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>350;30;190;30;190;170;30;170</additional_attributes>
|
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>170</x>
|
<x>790</x>
|
||||||
<y>160</y>
|
<y>500</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>270</x>
|
|
||||||
<y>180</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>.
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes>100;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>360</x>
|
|
||||||
<y>440</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>400</x>
|
|
||||||
<y>360</y>
|
|
||||||
<w>50</w>
|
|
||||||
<h>100</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>-</panel_attributes>
|
|
||||||
<additional_attributes>30;30;30;80</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Package</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>840</x>
|
|
||||||
<y>470</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>160</x>
|
|
||||||
<y>360</y>
|
|
||||||
<w>770</w>
|
|
||||||
<h>300</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>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>930</x>
|
|
||||||
<y>300</y>
|
|
||||||
<w>70</w>
|
|
||||||
<h>210</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>30;190;50;190;50;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>10</x>
|
|
||||||
<y>350</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>40</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>/<<interface>>/
|
|
||||||
INetworkSession</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>100</x>
|
|
||||||
<y>340</y>
|
|
||||||
<w>70</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
|
||||||
<additional_attributes>50;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>560</x>
|
|
||||||
<y>450</y>
|
|
||||||
<w>100</w>
|
<w>100</w>
|
||||||
<h>30</h>
|
<h>30</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -389,28 +177,91 @@ INetworkSession</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>580</x>
|
<x>670</x>
|
||||||
<y>360</y>
|
<y>530</y>
|
||||||
<w>50</w>
|
<w>150</w>
|
||||||
<h>110</h>
|
<h>180</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
<additional_attributes>30;30;30;90</additional_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>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>0</x>
|
<x>1060</x>
|
||||||
<y>460</y>
|
<y>280</y>
|
||||||
<w>160</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>40</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>MapManager
|
<panel_attributes>NetworkClient</panel_attributes>
|
||||||
--
|
|
||||||
Manages all map stuff.
|
|
||||||
|
|
||||||
elementstyle=wordwrap
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</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=-></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=-<<<<</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=>>>-</panel_attributes>
|
||||||
|
<additional_attributes>320;30;360;30;360;230;30;240</additional_attributes>
|
||||||
|
</element>
|
||||||
</diagram>
|
</diagram>
|
||||||
|
|
|
@ -192,6 +192,7 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="GameClientState\Camera.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
|
||||||
|
@ -205,6 +206,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="GameClientRecieverFunc.h" />
|
<ClInclude Include="GameClientRecieverFunc.h" />
|
||||||
|
<ClInclude Include="GameClientState\Camera.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
|
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
|
||||||
|
|
|
@ -61,22 +61,20 @@ namespace DanBias
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
m_data->recieverObj = new GameRecieverObject;
|
m_data->recieverObj = new GameRecieverObject;
|
||||||
|
m_data->recieverObj->Connect(desc.port, desc.IP);
|
||||||
|
|
||||||
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
|
if (!m_data->recieverObj->IsConnected())
|
||||||
m_data->recieverObj->nwClient->Connect(desc.port, desc.IP);
|
|
||||||
|
|
||||||
if (!m_data->recieverObj->nwClient->IsConnected())
|
|
||||||
{
|
{
|
||||||
// failed to connect
|
// failed to connect
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
}
|
}
|
||||||
// Start in lobby state
|
// Start in lobby state
|
||||||
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
||||||
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
|
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
|
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
|
||||||
m_data->timer->reset();
|
m_data->timer->reset();
|
||||||
return DanBiasClientReturn_Sucess;
|
return DanBiasClientReturn_Sucess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +155,7 @@ namespace DanBias
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
break;
|
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;
|
return S_OK;
|
||||||
|
@ -184,10 +182,9 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
m_data->recieverObj->gameClientState->Release();
|
m_data->recieverObj->gameClientState->Release();
|
||||||
delete m_data->recieverObj->gameClientState;
|
delete m_data->recieverObj->gameClientState;
|
||||||
m_data->recieverObj->nwClient->Disconnect();
|
m_data->recieverObj->Disconnect();
|
||||||
delete m_data->recieverObj->nwClient;
|
|
||||||
delete m_data->timer;
|
|
||||||
delete m_data->recieverObj;
|
delete m_data->recieverObj;
|
||||||
|
delete m_data->timer;
|
||||||
delete m_data->inputObj;
|
delete m_data->inputObj;
|
||||||
delete m_data;
|
delete m_data;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
|
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
|
||||||
#define DANBIAS_CLIENTRECIEVEROBJECT_H
|
#define DANBIAS_CLIENTRECIEVEROBJECT_H
|
||||||
|
|
||||||
|
//WTF!? No headers included???
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
struct GameRecieverObject :public Oyster::Network::NetworkClient
|
||||||
{
|
{
|
||||||
Oyster::Network::NetworkClient* nwClient;
|
|
||||||
Client::GameClientState* gameClientState;
|
Client::GameClientState* gameClientState;
|
||||||
|
|
||||||
// receiver function for server messages
|
// receiver function for server messages
|
||||||
|
|
|
@ -8,6 +8,7 @@ struct C_Player::myData
|
||||||
Oyster::Math3D::Float4x4 view;
|
Oyster::Math3D::Float4x4 view;
|
||||||
Oyster::Math3D::Float4x4 proj;
|
Oyster::Math3D::Float4x4 proj;
|
||||||
Oyster::Graphics::Model::Model *model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
Oyster::Math3D::Float4 lookDir;
|
||||||
int ID;
|
int ID;
|
||||||
}privData;
|
}privData;
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ void C_Player::Init(ModelInitData modelInit)
|
||||||
privData->model->WorldMatrix = modelInit.world;
|
privData->model->WorldMatrix = modelInit.world;
|
||||||
privData->model->Visible = modelInit.visible;
|
privData->model->Visible = modelInit.visible;
|
||||||
privData->ID = modelInit.id;
|
privData->ID = modelInit.id;
|
||||||
|
privData->lookDir = Oyster::Math3D::Float4 (0,0,1,0);
|
||||||
}
|
}
|
||||||
void C_Player::setPos(Oyster::Math::Float4x4 world)
|
void C_Player::setPos(Oyster::Math::Float4x4 world)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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();*/
|
||||||
|
}
|
|
@ -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
|
|
@ -4,7 +4,7 @@
|
||||||
#include "C_obj/C_DynamicObj.h"
|
#include "C_obj/C_DynamicObj.h"
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ struct GameState::myData
|
||||||
gameStateState state;
|
gameStateState state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}privData;
|
}privData;
|
||||||
|
|
||||||
GameState::GameState(void)
|
GameState::GameState(void)
|
||||||
|
@ -38,10 +37,12 @@ GameState::~GameState(void)
|
||||||
bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
||||||
{
|
{
|
||||||
// load models
|
// load models
|
||||||
|
camera = new Camera;
|
||||||
privData = new myData();
|
privData = new myData();
|
||||||
privData->state = gameStateState_loading;
|
privData->state = gameStateState_loading;
|
||||||
privData->nwClient = nwClient;
|
privData->nwClient = nwClient;
|
||||||
privData->state = LoadGame();
|
privData->state = LoadGame();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
GameState::gameStateState GameState::LoadGame()
|
GameState::gameStateState GameState::LoadGame()
|
||||||
|
@ -92,14 +93,14 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
||||||
modelData.id ++;
|
modelData.id ++;
|
||||||
|
|
||||||
obj = new C_DynamicObj();
|
obj = new C_Player();
|
||||||
privData->object.push_back(obj);
|
privData->object.push_back(obj);
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
|
/*translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
|
||||||
modelData.world = modelData.world * translate;
|
modelData.world = modelData.world * translate;
|
||||||
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
||||||
modelData.id ++;
|
modelData.id ++;*/
|
||||||
|
|
||||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0));
|
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0));
|
||||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
|
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
|
||||||
|
@ -110,7 +111,7 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
modelData.modelPath = L"..\\Content\\Models\\ball.dan";
|
modelData.modelPath = L"..\\Content\\Models\\ball.dan";
|
||||||
modelData.id ++;
|
modelData.id ++;
|
||||||
|
|
||||||
obj = new C_DynamicObj();
|
obj = new C_Player();
|
||||||
privData->object.push_back(obj);
|
privData->object.push_back(obj);
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
|
@ -119,10 +120,19 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
}
|
}
|
||||||
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
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_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
|
||||||
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
|
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
|
||||||
Oyster::Graphics::API::SetProjection(privData->proj);
|
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::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
|
||||||
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
||||||
return true;
|
return true;
|
||||||
|
@ -147,85 +157,9 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
||||||
// read server data
|
// read server data
|
||||||
// update objects
|
// update objects
|
||||||
{
|
{
|
||||||
bool send = false;
|
readKeyInput(KeyInput);
|
||||||
GameLogic::Protocol_PlayerMovement movePlayer;
|
camera->UpdateViewMatrix();
|
||||||
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;
|
|
||||||
|
|
||||||
GameLogic::Protocol_General_Text tp;
|
|
||||||
tp.text = "What!?";
|
|
||||||
this->privData->nwClient->Send(tp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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())
|
|
||||||
{
|
|
||||||
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;
|
break;
|
||||||
case gameStateState_end:
|
case gameStateState_end:
|
||||||
|
@ -240,7 +174,9 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
||||||
}
|
}
|
||||||
bool GameState::Render()
|
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::SetProjection(privData->proj);
|
||||||
Oyster::Graphics::API::NewFrame();
|
Oyster::Graphics::API::NewFrame();
|
||||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
for (unsigned int i = 0; i < privData->object.size(); i++)
|
||||||
|
@ -259,10 +195,108 @@ bool GameState::Release()
|
||||||
privData->object[i] = NULL;
|
privData->object[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete this->camera;
|
||||||
|
|
||||||
delete privData;
|
delete privData;
|
||||||
privData = NULL;
|
privData = NULL;
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
// send event data
|
||||||
|
//
|
||||||
|
if(KeyInput->IsKeyPressed(DIK_L))
|
||||||
|
privData->state = GameState::gameStateState_end;
|
||||||
|
}
|
||||||
|
|
||||||
void GameState::Protocol(ProtocolStruct* pos)
|
void GameState::Protocol(ProtocolStruct* pos)
|
||||||
{
|
{
|
||||||
|
@ -290,13 +324,17 @@ void GameState::Protocol( ObjPos* pos )
|
||||||
|
|
||||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
for (unsigned int i = 0; i < privData->object.size(); i++)
|
||||||
{
|
{
|
||||||
if(privData->object[i] && privData->object[i]->GetId() == pos->object_ID)
|
if(privData->object[i]->GetId() == pos->object_ID)
|
||||||
{
|
{
|
||||||
privData->object[i]->setPos(world);
|
privData->object[i]->setPos(world);
|
||||||
|
//camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2])));
|
||||||
//privData->view = world;
|
//camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6])));
|
||||||
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
//camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10])));
|
||||||
|
if(i == 0)
|
||||||
|
{
|
||||||
|
camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14]));
|
||||||
|
camera->UpdateViewMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "GameClientState.h"
|
#include "GameClientState.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "Camera.h"
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
|
@ -21,6 +22,8 @@ private:
|
||||||
bool key_backward;
|
bool key_backward;
|
||||||
bool key_strafeRight;
|
bool key_strafeRight;
|
||||||
bool key_strafeLeft;
|
bool key_strafeLeft;
|
||||||
|
bool key_Shoot;
|
||||||
|
Camera* camera;
|
||||||
|
|
||||||
struct myData;
|
struct myData;
|
||||||
myData* privData;
|
myData* privData;
|
||||||
|
@ -33,6 +36,7 @@ public:
|
||||||
bool InitCamera(Oyster::Math::Float3 startPos) ;
|
bool InitCamera(Oyster::Math::Float3 startPos) ;
|
||||||
gameStateState LoadGame();
|
gameStateState LoadGame();
|
||||||
|
|
||||||
|
void readKeyInput(InputClass* KeyInput);
|
||||||
bool Render()override;
|
bool Render()override;
|
||||||
bool Release()override;
|
bool Release()override;
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -71,7 +71,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\GameServer;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>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\GameServer;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>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\GameServer;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>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\GameServer;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>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -111,8 +111,8 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -128,8 +128,8 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -149,8 +149,8 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -170,13 +170,18 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="ServerLauncher.cpp" />
|
<ClCompile Include="ServerLauncher.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\WindowManager\WindowManager.vcxproj">
|
||||||
|
<Project>{35aea3c0-e0a7-4e1e-88cd-514aa5a442b1}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#define NOMINMAX //Blame it on windows
|
#define NOMINMAX //Blame it on windows
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <WindowShell.h>
|
||||||
|
|
||||||
#include <GameServerAPI.h>
|
#include <GameServerAPI.h>
|
||||||
|
|
||||||
|
@ -16,13 +17,14 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
||||||
return cmdShow;
|
return cmdShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
DanBias::GameServerAPI::GameInitDesc desc;
|
WindowShell::CreateConsoleWindow();
|
||||||
desc.connectionPort = 15151;
|
|
||||||
desc.maxNumberOfClients = 0;
|
|
||||||
desc.threaded = false;
|
|
||||||
if( !DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
DanBias::GameServerAPI::GameInitDesc desc;
|
||||||
|
desc.listenPort = 15151;
|
||||||
|
if(DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
|
||||||
|
{
|
||||||
|
DanBias::GameServerAPI::Start();
|
||||||
|
DanBias::GameServerAPI::Terminate();
|
||||||
}
|
}
|
||||||
return cmdShow;
|
return cmdShow;
|
||||||
}
|
}
|
|
@ -56,33 +56,36 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject
|
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
|
|
||||||
float dxMouse;
|
float lookDirX;
|
||||||
float dyMouse;
|
float lookDirY;
|
||||||
|
float lookDirZ;
|
||||||
|
|
||||||
|
Protocol_PlayerLook()
|
||||||
Protocol_PlayerMouse()
|
|
||||||
{
|
{
|
||||||
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerMouseMovement;
|
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerLookDir;
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
}
|
}
|
||||||
const Protocol_PlayerMouse& operator=(Oyster::Network::CustomNetProtocol& val)
|
const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||||
{
|
{
|
||||||
dxMouse = val[1].value.netFloat;
|
lookDirX = val[1].value.netFloat;
|
||||||
dyMouse = val[2].value.netFloat;
|
lookDirY = val[2].value.netFloat;
|
||||||
|
lookDirZ = val[3].value.netFloat;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = dxMouse;
|
this->protocol[1].value = lookDirX;
|
||||||
this->protocol[2].value = dyMouse;
|
this->protocol[2].value = lookDirY;
|
||||||
|
this->protocol[3].value = lookDirZ;
|
||||||
|
|
||||||
return &protocol;
|
return &protocol;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +122,32 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject
|
||||||
|
{
|
||||||
|
bool hasShot;
|
||||||
|
|
||||||
|
Protocol_PlayerShot()
|
||||||
|
{
|
||||||
|
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerShot;
|
||||||
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|
||||||
|
|
|
@ -47,14 +47,15 @@
|
||||||
/***********[ 300 - 399 ]***********/
|
/***********[ 300 - 399 ]***********/
|
||||||
#define protocol_GameplayMIN 300
|
#define protocol_GameplayMIN 300
|
||||||
#define protocol_Gameplay_PlayerMovement 300
|
#define protocol_Gameplay_PlayerMovement 300
|
||||||
#define protocol_Gameplay_PlayerMouseMovement 301
|
#define protocol_Gameplay_PlayerLookDir 301
|
||||||
#define protocol_Gameplay_PlayerChangeWeapon 302
|
#define protocol_Gameplay_PlayerChangeWeapon 302
|
||||||
#define protocol_Gameplay_ObjectPickup 303
|
#define protocol_Gameplay_PlayerShot 303
|
||||||
#define protocol_Gameplay_ObjectDamage 304
|
#define protocol_Gameplay_ObjectPickup 304
|
||||||
#define protocol_Gameplay_ObjectPosition 305
|
#define protocol_Gameplay_ObjectDamage 305
|
||||||
#define protocol_Gameplay_ObjectEnabled 306
|
#define protocol_Gameplay_ObjectPosition 306
|
||||||
#define protocol_Gameplay_ObjectDisabled 307
|
#define protocol_Gameplay_ObjectEnabled 307
|
||||||
#define protocol_Gameplay_ObjectCreate 308
|
#define protocol_Gameplay_ObjectDisabled 308
|
||||||
|
#define protocol_Gameplay_ObjectCreate 309
|
||||||
#define protocol_GameplayMAX 399
|
#define protocol_GameplayMAX 399
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,26 +7,28 @@
|
||||||
#include <NetworkClient.h>
|
#include <NetworkClient.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameAPI.h>
|
#include <GameAPI.h>
|
||||||
|
#include <Utilities.h>
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Container to keep logic player and network client together as a unit.
|
||||||
|
*/
|
||||||
class GameClient
|
class GameClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameClient(Oyster::Network::NetworkClient client, GameLogic::IPlayerData* player);
|
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client, GameLogic::IPlayerData* player);
|
||||||
virtual~GameClient();
|
virtual~GameClient();
|
||||||
|
|
||||||
//void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
|
||||||
|
|
||||||
GameLogic::IPlayerData* GetPlayer();
|
GameLogic::IPlayerData* GetPlayer();
|
||||||
GameLogic::IPlayerData* ReleasePlayer();
|
GameLogic::IPlayerData* ReleasePlayer();
|
||||||
Oyster::Network::NetworkClient* GetClient();
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> GetClient();
|
||||||
Oyster::Network::NetworkClient ReleaseClient();
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> ReleaseClient();
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameLogic::IPlayerData* player;
|
GameLogic::IPlayerData* player;
|
||||||
Oyster::Network::NetworkClient client;
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\IPostBox.h>
|
#include <PostBox\IPostBox.h>
|
||||||
#include <WinTimer.h>
|
#include <WinTimer.h>
|
||||||
|
#include "GameSession.h"
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
|
@ -16,33 +17,32 @@ namespace DanBias
|
||||||
public:
|
public:
|
||||||
GameLobby();
|
GameLobby();
|
||||||
virtual~GameLobby();
|
virtual~GameLobby();
|
||||||
|
|
||||||
void Release();
|
void Release();
|
||||||
|
void Update();
|
||||||
|
|
||||||
void Frame();
|
operator bool();
|
||||||
|
|
||||||
//void ClientEventCallback(NetEvent<Client*, Client::ClientEventArgs> e) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseEvents();
|
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
||||||
void ParseGeneralProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
|
||||||
void ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
|
||||||
|
|
||||||
//Lobby events
|
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
|
||||||
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c);
|
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
|
||||||
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c);
|
void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
|
||||||
|
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
|
||||||
//General events
|
void LobbyJoin(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join:
|
||||||
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c);
|
void LobbyLogin(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
|
||||||
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c);
|
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
|
||||||
|
void LobbyMainData(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
|
||||||
|
void LobbyGameData(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
void ClientConnectedEvent(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utility::WinTimer timer;
|
Utility::WinTimer timer;
|
||||||
float refreshFrequency;
|
float refreshFrequency;
|
||||||
|
GameSession* gameSession;
|
||||||
};
|
};
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
#endif // !DANBIASGAME_GAMELOBBY_H
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_GAME_SERVER_H
|
|
||||||
#define DANBIASSERVER_GAME_SERVER_H
|
|
||||||
|
|
||||||
#include "GameServerAPI.h"
|
|
||||||
#include "GameLobby.h"
|
|
||||||
#include <NetworkServer.h>
|
|
||||||
#include <Utilities.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class GameServer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GameServer();
|
|
||||||
virtual~GameServer();
|
|
||||||
|
|
||||||
DanBiasServerReturn Create(const GameServerAPI::GameInitDesc& desc);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void Run(GameServer* owner);
|
|
||||||
void Run();
|
|
||||||
void Release();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int maxClients;
|
|
||||||
Utility::DynamicMemory::SmartPointer<GameLobby> lobby;
|
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkServer> server;
|
|
||||||
};
|
|
||||||
}// End namspace DanBias
|
|
||||||
#endif // !DANBIASSERVER_DBSERVER_H
|
|
|
@ -178,31 +178,20 @@
|
||||||
<ClCompile Include="Implementation\GameClient.cpp" />
|
<ClCompile Include="Implementation\GameClient.cpp" />
|
||||||
<ClCompile Include="Implementation\GameLobby.cpp" />
|
<ClCompile Include="Implementation\GameLobby.cpp" />
|
||||||
<ClCompile Include="Implementation\GameServer.cpp" />
|
<ClCompile Include="Implementation\GameServer.cpp" />
|
||||||
<ClCompile Include="Implementation\GameSessionManager.cpp" />
|
|
||||||
<ClCompile Include="Implementation\GameSession_Events.cpp" />
|
|
||||||
<ClCompile Include="Implementation\GameSession_General.cpp" />
|
<ClCompile Include="Implementation\GameSession_General.cpp" />
|
||||||
<ClCompile Include="Implementation\GameSession_Logic.cpp" />
|
<ClCompile Include="Implementation\GameSession_Gameplay.cpp" />
|
||||||
<ClCompile Include="Implementation\GameSession_Network.cpp" />
|
<ClCompile Include="Implementation\GameLobby_ProtocolParser.cpp">
|
||||||
<ClCompile Include="Implementation\LobbyGeneralProtocolParser.cpp">
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Implementation\LobbyProtocolParser.cpp">
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="GameClient.h" />
|
<ClInclude Include="GameClient.h" />
|
||||||
<ClInclude Include="GameLobby.h" />
|
<ClInclude Include="GameLobby.h" />
|
||||||
<ClInclude Include="GameServer.h" />
|
|
||||||
<ClInclude Include="GameServerAPI.h" />
|
<ClInclude Include="GameServerAPI.h" />
|
||||||
<ClInclude Include="GameSession.h" />
|
<ClInclude Include="GameSession.h" />
|
||||||
<ClInclude Include="GameSessionManager.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
DanBiasServerReturn_Error,
|
DanBiasServerReturn_Error,
|
||||||
DanBiasServerReturn_Sucess,
|
DanBiasServerReturn_Sucess,
|
||||||
|
DanBiasServerReturn_GameNotCreated,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -29,13 +30,16 @@ namespace DanBias
|
||||||
public:
|
public:
|
||||||
struct GameInitDesc
|
struct GameInitDesc
|
||||||
{
|
{
|
||||||
//stuff
|
int listenPort;
|
||||||
int connectionPort;
|
|
||||||
int maxNumberOfClients;
|
|
||||||
bool threaded;
|
bool threaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static DanBiasServerReturn Create(const GameInitDesc& desc);
|
static DanBiasServerReturn Create(const GameInitDesc& desc);
|
||||||
|
static void Start();
|
||||||
|
static void Stop();
|
||||||
|
static void Terminate();
|
||||||
|
|
||||||
};//End class DanBiasServer
|
};//End class DanBiasServer
|
||||||
}//End Extern "C"
|
}//End Extern "C"
|
||||||
} //End namspace DanBias
|
} //End namspace DanBias
|
||||||
|
|
|
@ -15,20 +15,24 @@
|
||||||
#include <GameAPI.h>
|
#include <GameAPI.h>
|
||||||
#include <Queue.h>
|
#include <Queue.h>
|
||||||
#include <NetworkSession.h>
|
#include <NetworkSession.h>
|
||||||
|
#include <DynamicArray.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
class GameSession : public Oyster::Thread::IThreadObject
|
class GameSession : public Oyster::Network::NetworkSession
|
||||||
|
, public Oyster::Thread::IThreadObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A container to use when initiating a new session
|
* A container to use when initiating a new session
|
||||||
*/
|
*/
|
||||||
struct GameDescription
|
struct GameDescription
|
||||||
{
|
{
|
||||||
std::wstring mapName;
|
std::wstring mapName;
|
||||||
NetworkSession* owner;
|
Oyster::Network::NetworkSession* owner;
|
||||||
Utility::DynamicMemory::DynamicArray<NetworkClient> clients;
|
Utility::DynamicMemory::DynamicArray<Oyster::Network::NetClient> clients;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -44,13 +48,7 @@ namespace DanBias
|
||||||
/** Join an existing/running game session
|
/** Join an existing/running game session
|
||||||
* @param client The client to attach to the session
|
* @param client The client to attach to the session
|
||||||
*/
|
*/
|
||||||
bool Join(Utility::DynamicMemory::SmartPointer<NetworkSession> client);
|
bool Attach(Oyster::Network::NetClient client) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the game session
|
|
||||||
* @param disconnectClients If set to true clients is dissconnected from the server, if false the clients is sent to the given owner of the session.
|
|
||||||
*/
|
|
||||||
void CloseSession(bool disconnectClients = false);
|
|
||||||
|
|
||||||
inline bool IsCreated() const { return this->isCreated; }
|
inline bool IsCreated() const { return this->isCreated; }
|
||||||
inline bool IsRunning() const { return this->isRunning; }
|
inline bool IsRunning() const { return this->isRunning; }
|
||||||
|
@ -58,31 +56,20 @@ namespace DanBias
|
||||||
//Private member functions
|
//Private member functions
|
||||||
private:
|
private:
|
||||||
//Handles all events recieved
|
//Handles all events recieved
|
||||||
void ParseEvents();
|
//void ParseEvents();
|
||||||
//Handles all gameplay events
|
|
||||||
void ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
//Handles all general events
|
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
||||||
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
|
||||||
//Adds a client to the client list
|
|
||||||
void InsertClient(Utility::DynamicMemory::SmartPointer<GameClient> obj);
|
|
||||||
//Removes a client from the client list
|
|
||||||
void RemoveClient(DanBias::GameClient* obj);
|
|
||||||
//Sends a protocol ta all clients in session
|
|
||||||
void Send(Oyster::Network::CustomNetProtocol* p);
|
|
||||||
//Frame function, derived from IThreadObject
|
|
||||||
bool DoWork ( ) override;
|
|
||||||
//Sends a client to the owner, if obj is NULL then all clients is sent
|
//Sends a client to the owner, if obj is NULL then all clients is sent
|
||||||
void SendToOwner(DanBias::GameClient* obj);
|
void SendToOwner(DanBias::GameClient* obj);
|
||||||
//Do a cleanup on all the private data
|
|
||||||
void Clean();
|
//Frame function, derived from IThreadObject
|
||||||
//Update game objects if needed
|
bool DoWork ( ) override;
|
||||||
void UpdateGameObjects();
|
|
||||||
|
|
||||||
//Private member variables
|
//Private member variables
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||||
//Oyster::PostBox<DanBias::NetworkSession::NetEvent> *box;
|
|
||||||
Oyster::Thread::OysterThread worker;
|
Oyster::Thread::OysterThread worker;
|
||||||
GameLogic::GameAPI& gameInstance;
|
GameLogic::GameAPI& gameInstance;
|
||||||
GameLogic::ILevelData *levelData;
|
GameLogic::ILevelData *levelData;
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_GAME_SEESION_MANAGER_H
|
|
||||||
#define DANBIASSERVER_GAME_SEESION_MANAGER_H
|
|
||||||
|
|
||||||
#include <NetworkSession.h>
|
|
||||||
#include <string>
|
|
||||||
#include <Utilities.h>
|
|
||||||
#include <DynamicArray.h>
|
|
||||||
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
struct GameSessionDescription
|
|
||||||
{
|
|
||||||
std::wstring mapName;
|
|
||||||
Utility::DynamicMemory::DynamicArray<NetworkClient> 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<NetworkSession> 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 CloseSessions();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get total sessions running
|
|
||||||
* @return Returns the total sessions curently running.
|
|
||||||
*/
|
|
||||||
static int GetSessionSize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // !DANBIASSERVER_GAME_SEESION_MANAGER_H
|
|
|
@ -7,12 +7,13 @@
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Oyster::Network;
|
||||||
using namespace DanBias;
|
using namespace DanBias;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
static int gameClientIDCount = 1;
|
static int gameClientIDCount = 1;
|
||||||
|
|
||||||
GameClient::GameClient(Oyster::Network::NetworkClient client, GameLogic::IPlayerData* player)
|
GameClient::GameClient(SmartPointer<NetworkClient> client, GameLogic::IPlayerData* player)
|
||||||
{
|
{
|
||||||
this->client = client;
|
this->client = client;
|
||||||
this->id = gameClientIDCount++;
|
this->id = gameClientIDCount++;
|
||||||
|
@ -20,7 +21,7 @@ GameClient::GameClient(Oyster::Network::NetworkClient client, GameLogic::IPlayer
|
||||||
}
|
}
|
||||||
GameClient::~GameClient()
|
GameClient::~GameClient()
|
||||||
{
|
{
|
||||||
this->client.Disconnect();
|
this->client->Disconnect();
|
||||||
this->player = 0;
|
this->player = 0;
|
||||||
this->id = -1;
|
this->id = -1;
|
||||||
}
|
}
|
||||||
|
@ -35,13 +36,14 @@ GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
||||||
this->player = 0;
|
this->player = 0;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
Oyster::Network::NetworkClient* GameClient::GetClient()
|
SmartPointer<Oyster::Network::NetworkClient> GameClient::GetClient()
|
||||||
{
|
{
|
||||||
return &this->client;
|
return this->client;
|
||||||
}
|
}
|
||||||
Oyster::Network::NetworkClient GameClient::ReleaseClient()
|
SmartPointer<Oyster::Network::NetworkClient> GameClient::ReleaseClient()
|
||||||
{
|
{
|
||||||
Oyster::Network::NetworkClient temp = this->client;
|
SmartPointer<Oyster::Network::NetworkClient> temp = this->client;
|
||||||
|
this->client = 0;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
int GameClient::GetID() const
|
int GameClient::GetID() const
|
||||||
|
|
|
@ -18,34 +18,37 @@ namespace DanBias
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void GameLobby::Release()
|
void GameLobby::Release()
|
||||||
{ }
|
|
||||||
|
|
||||||
void GameLobby::Frame()
|
|
||||||
{
|
{
|
||||||
ParseEvents();
|
NetworkSession::CloseSession(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameLobby::Update()
|
||||||
|
{
|
||||||
|
this->ProcessClients();
|
||||||
|
}
|
||||||
|
GameLobby::operator bool()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||||
{
|
{
|
||||||
|
switch (e.args.type)
|
||||||
|
{
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
||||||
|
break;
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
|
||||||
|
break;
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
|
break;
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
|
this->ParseProtocol(e.args.data.protocol, e.sender);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::ClientConnectedEvent(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||||
{
|
{
|
||||||
|
//Attach(client);
|
||||||
}
|
|
||||||
|
|
||||||
//////// Private
|
|
||||||
void GameLobby::ParseEvents()
|
|
||||||
{
|
|
||||||
//if(this->box && !this->box->IsEmpty())
|
|
||||||
//{
|
|
||||||
// NetEvent &e = this->box->Fetch();
|
|
||||||
//
|
|
||||||
// short type = e.protocol[0].value.netShort;
|
|
||||||
//
|
|
||||||
// if(ProtocolIsLobby(type)) ParseLobbyProtocol(e.protocol, e.sender);
|
|
||||||
// else if(ProtocolIsGeneral(type)) ParseGeneralProtocol(e.protocol, e.sender);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
|
@ -0,0 +1,100 @@
|
||||||
|
#include "..\GameLobby.h"
|
||||||
|
|
||||||
|
using namespace DanBias;
|
||||||
|
using namespace GameLogic;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
|
|
||||||
|
void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClient* c)
|
||||||
|
{
|
||||||
|
switch (p[0].value.netShort)
|
||||||
|
{
|
||||||
|
//LobbyStartGame(GameLogic::Protocol_LobbyStartGame(p), c);
|
||||||
|
//LobbyRefresh(GameLogic::Protocol_LobbyRefresh(p), c);
|
||||||
|
//LobbyLogin(GameLogic::Protocol_LobbyLogin(p), c);
|
||||||
|
//LobbyJoin(GameLogic::Protocol_LobbyJoin(p), c);
|
||||||
|
//GeneralStatus(GameLogic::Protocol_General_Status(p), c);
|
||||||
|
//GeneralText(GameLogic::Protocol_General_Text(p), c);
|
||||||
|
|
||||||
|
case protocol_General_Status:
|
||||||
|
break;
|
||||||
|
case protocol_General_Text:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Create:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Start:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Join:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Login:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Refresh:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_MainData:
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_GameData:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
switch (p.status)
|
||||||
|
{
|
||||||
|
case Protocol_General_Status::States_ready:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
case Protocol_General_Status::States_idle:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
case Protocol_General_Status::States_leave:
|
||||||
|
case Protocol_General_Status::States_disconected:
|
||||||
|
{
|
||||||
|
Detach(c)->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
printf(p.text.c_str());
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
//for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
||||||
|
//{
|
||||||
|
// if (this->gameLobby[i]->GetID() == p.value)
|
||||||
|
// {
|
||||||
|
// this->gameLobby[i]->Attach(Detach(c));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
//Dont need to handle this on the server...
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyMainData(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyGameData(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,137 +3,93 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <WindowShell.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vld.h>
|
||||||
|
|
||||||
|
#include "..\GameServerAPI.h"
|
||||||
#include "..\GameServer.h"
|
#include "..\GameLobby.h"
|
||||||
#include "..\GameSessionManager.h"
|
|
||||||
#include "..\GameSession.h"
|
#include "..\GameSession.h"
|
||||||
|
|
||||||
#include <Thread\OysterThread.h>
|
#include <NetworkServer.h>
|
||||||
#include <Utilities.h>
|
|
||||||
#include <NetworkClient.h>
|
#include <NetworkClient.h>
|
||||||
#include <thread>
|
|
||||||
#include <CollisionManager.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
#include <WindowShell.h>
|
||||||
|
#include <Utilities.h>
|
||||||
|
#include <WinTimer.h>
|
||||||
|
#include <Thread\OysterThread.h>
|
||||||
|
|
||||||
|
using namespace DanBias;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
using namespace Oyster::Thread;
|
||||||
|
using namespace Utility;
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
using namespace Oyster::Network;
|
GameLobby lobby;
|
||||||
|
NetworkServer server;
|
||||||
|
WinTimer timer;
|
||||||
|
GameServerAPI instance;
|
||||||
|
//typedef void(*WorkerThreadFnc)(GameServerAPI*);
|
||||||
|
}
|
||||||
|
|
||||||
GameServer* instance = 0;
|
|
||||||
std::thread workerThread;
|
|
||||||
typedef void(*WorkerThreadFnc)(GameServer*);
|
|
||||||
|
|
||||||
DanBiasServerReturn GameServerAPI::Create(const GameInitDesc& desc)
|
DanBiasServerReturn GameServerAPI::Create(const GameInitDesc& desc)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(server.Init(desc.listenPort, &lobby) == NetworkServer::ServerReturnCode_Error)
|
||||||
{
|
{
|
||||||
if(!instance)
|
return DanBiasServerReturn_Error;
|
||||||
instance = new GameServer();
|
|
||||||
|
|
||||||
return instance->Create(desc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::printf("Server created!\t-\t%s: [%i]\n", server.GetLanAddress().c_str(), desc.listenPort);
|
||||||
|
|
||||||
|
return DanBiasServerReturn_Sucess;
|
||||||
|
}
|
||||||
|
void GameServerAPI::Start()
|
||||||
|
{
|
||||||
|
server.Start();
|
||||||
|
|
||||||
GameServer::GameServer()
|
timer.reset();
|
||||||
: maxClients(0)
|
|
||||||
{ }
|
while (true)
|
||||||
GameServer::~GameServer()
|
|
||||||
{ }
|
|
||||||
DanBiasServerReturn GameServer::Create(const GameServerAPI::GameInitDesc& desc)
|
|
||||||
{
|
{
|
||||||
this->maxClients = desc.maxNumberOfClients;
|
int c = server.ProcessConnectedClients();
|
||||||
this->server = new NetworkServer();
|
if(c > 0) printf(" - [%i] client(s) connected!\n", c);
|
||||||
this->lobby = new GameLobby();
|
lobby.Update();
|
||||||
|
|
||||||
if(desc.threaded)
|
if(GetAsyncKeyState(0x51)) //Q for exit
|
||||||
{
|
break;
|
||||||
if(!this->server->Init(desc.connectionPort, this->lobby))
|
|
||||||
return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
if(!this->server->Start())
|
|
||||||
return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
WorkerThreadFnc temp = GameServer::Run;
|
|
||||||
workerThread = std::thread(temp, this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!this->server->Init(desc.connectionPort, this->lobby))
|
|
||||||
return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
if(!this->server->Start())
|
|
||||||
return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
return DanBiasServerReturn_Sucess;
|
|
||||||
}
|
|
||||||
void GameServer::Run(GameServer* owner)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
owner->server->ProcessConnectedClients();
|
|
||||||
owner->lobby->ProcessClients();
|
|
||||||
|
|
||||||
if(GetAsyncKeyState(0x51)) //Q for exit
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void GameServer::Run()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
this->server->ProcessConnectedClients();
|
|
||||||
this->lobby->Frame();
|
|
||||||
|
|
||||||
if(GetAsyncKeyState(0x51)) //Q for exit
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void GameServer::Release()
|
|
||||||
{
|
|
||||||
GameSessionManager::CloseSessions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double total = timer.getElapsedSeconds();
|
||||||
|
int time = (int)total;
|
||||||
|
int hour, min, sec;
|
||||||
|
|
||||||
|
hour=time / 3600;
|
||||||
|
time=time % 3600;
|
||||||
|
min=time / 60;
|
||||||
|
time=time % 60;
|
||||||
|
sec = time;
|
||||||
|
|
||||||
|
printf( "Server has been running for: %i:%i:%i - [hh:mm:ss] \n\n", hour, min, sec );
|
||||||
|
printf( "Terminating in : ");
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
printf( "%i ", 3-i );
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
//void GameServer::ClientConnected(NetworkClient* client)
|
}
|
||||||
//{
|
void GameServerAPI::Stop()
|
||||||
// static bool myTest = false;
|
{
|
||||||
// static int sessionId = -1;
|
server.Stop();
|
||||||
// printf("Client with ID [%i] connected.\n", client->GetID());
|
lobby.ProcessClients();
|
||||||
//
|
}
|
||||||
// if(!myTest)
|
void GameServerAPI::Terminate()
|
||||||
// {
|
{
|
||||||
// Utility::DynamicMemory::SmartPointer<NetworkSession> c = new Client(client);
|
lobby.Release();
|
||||||
//
|
server.Shutdown();
|
||||||
// GameSessionDescription desc;
|
|
||||||
// desc.mapName = L"test";
|
printf( "Server terminated!" );
|
||||||
// desc.clients.Push(c);
|
|
||||||
// desc.exitDestionation = this->lobby;
|
}
|
||||||
// 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<NetworkSession> c = new NetworkSession(client);
|
|
||||||
// GameSessionManager::JoinSession(sessionId, c);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //Utility::DynamicMemory::SmartPointer<NetworkSession> c = new NetworkSession(client);
|
|
||||||
// //this->mainLobby->Attach(c, this->mainLobby->GetPostbox());
|
|
||||||
//}
|
|
||||||
}//End namespace DanBias
|
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "..\GameSessionManager.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<NetworkSession> 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::CloseSessions()
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,18 @@
|
||||||
#include "..\GameSession.h"
|
#include "..\GameSession.h"
|
||||||
#include "..\GameClient.h"
|
#include "..\GameClient.h"
|
||||||
|
|
||||||
#include <NetworkServerEventStruct.h>
|
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
#include <OysterMath.h>
|
#include <OysterMath.h>
|
||||||
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#define DELTA_TIME_20 0.05f
|
||||||
|
#define DELTA_TIME_24 0.04166666666666666666666666666667f
|
||||||
|
#define DELTA_TIME_30 0.03333333333333333333333333333333f
|
||||||
|
#define DELTA_TIME_60 0.01666666666666666666666666666667f
|
||||||
|
#define DELTA_TIME_120 0.00833333333333333333333333333333f
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
|
@ -21,25 +25,45 @@ using namespace GameLogic;
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
void GameSession::ParseEvents()
|
bool GameSession::DoWork( )
|
||||||
{
|
{
|
||||||
if( !this->box->IsEmpty() )
|
if(this->isRunning)
|
||||||
{
|
{
|
||||||
NetworkSession::NetEvent &e = this->box->Fetch();
|
double dt = this->timer.getElapsedSeconds();
|
||||||
static int ii = 0;
|
gameInstance.SetFrameTimeLength((float)dt);
|
||||||
printf("%i - Message recieved! [%i]\n", ii++, e.protocol[0].value);
|
|
||||||
|
|
||||||
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
if(dt >= DELTA_TIME_20)
|
||||||
|
{
|
||||||
|
this->ProcessClients();
|
||||||
|
|
||||||
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
|
this->gameInstance.NewFrame();
|
||||||
ParseGameplayEvent(e.protocol, e.gameClient);
|
|
||||||
|
|
||||||
if( ProtocolIsGeneral(e.protocol[protocol_INDEX_ID].value.netShort) )
|
this->timer.reset();
|
||||||
ParseGeneralEvent(e.protocol, e.gameClient);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this->isRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
//void GameSession::ParseEvents()
|
||||||
|
//{
|
||||||
|
// if( !this->box->IsEmpty() )
|
||||||
|
// {
|
||||||
|
// NetworkSession::NetEvent &e = this->box->Fetch();
|
||||||
|
// static int ii = 0;
|
||||||
|
// printf("%i - Message recieved! [%i]\n", ii++, e.protocol[0].value);
|
||||||
|
//
|
||||||
|
// if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
||||||
|
//
|
||||||
|
// if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||||
|
// ParseGameplayEvent(e.protocol, e.gameClient);
|
||||||
|
//
|
||||||
|
// if( ProtocolIsGeneral(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||||
|
// ParseGeneralEvent(e.protocol, e.gameClient);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
void GameSession::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||||
{
|
{
|
||||||
switch (p[protocol_INDEX_ID].value.netShort)
|
switch (p[protocol_INDEX_ID].value.netShort)
|
||||||
{
|
{
|
||||||
|
@ -55,10 +79,10 @@ namespace DanBias
|
||||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_PlayerMouseMovement:
|
case protocol_Gameplay_PlayerLookDir:
|
||||||
{
|
{
|
||||||
Protocol_PlayerMouse m; m = p;
|
Protocol_PlayerLook m; m = p;
|
||||||
c->GetPlayer()->Rotate(m.dxMouse, m.dyMouse);
|
//c->GetPlayer()->Rotate(m.dxMouse, m.dyMouse);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_PlayerChangeWeapon:
|
case protocol_Gameplay_PlayerChangeWeapon:
|
||||||
|
@ -67,19 +91,12 @@ namespace DanBias
|
||||||
case protocol_Gameplay_ObjectDamage:
|
case protocol_Gameplay_ObjectDamage:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
|
||||||
{
|
|
||||||
switch (p[protocol_INDEX_ID].value.netShort)
|
|
||||||
{
|
|
||||||
case protocol_General_Status:
|
case protocol_General_Status:
|
||||||
switch (p[1].value.netInt)
|
switch (p[1].value.netInt)
|
||||||
{
|
{
|
||||||
case GameLogic::Protocol_General_Status::States_disconected:
|
case GameLogic::Protocol_General_Status::States_disconected:
|
||||||
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
|
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
|
||||||
this->RemoveClient(c);
|
this->Detach(c->GetClient()->GetID());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GameLogic::Protocol_General_Status::States_idle:
|
case GameLogic::Protocol_General_Status::States_idle:
|
||||||
|
@ -101,17 +118,18 @@ namespace DanBias
|
||||||
printf("Message recieved from (%i):\t %s\n", c->GetID(), temp.text.c_str());
|
printf("Message recieved from (%i):\t %s\n", c->GetID(), temp.text.c_str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
||||||
{
|
{
|
||||||
movedObject->GetID();
|
movedObject->GetID();
|
||||||
movedObject->GetOrientation();
|
movedObject->GetOrientation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameSession::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
#include "..\GameSession.h"
|
#include "..\GameSession.h"
|
||||||
#include "..\GameClient.h"
|
#include "..\GameClient.h"
|
||||||
#include "..\GameServer.h"
|
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,16 +23,18 @@ namespace DanBias
|
||||||
:gameInstance(GameAPI::Instance())
|
:gameInstance(GameAPI::Instance())
|
||||||
{
|
{
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
this->box = 0;
|
|
||||||
this->isCreated = false;
|
this->isCreated = false;
|
||||||
this->isRunning = false;
|
this->isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSession::~GameSession()
|
GameSession::~GameSession()
|
||||||
{
|
{
|
||||||
delete this->box;
|
this->worker.Terminate();
|
||||||
this->box = 0;
|
this->clients.Clear();
|
||||||
|
this->gameInstance;
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
|
this->isCreated = false;
|
||||||
|
this->isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameSession::Create(GameDescription& desc)
|
bool GameSession::Create(GameDescription& desc)
|
||||||
|
@ -45,7 +47,6 @@ namespace DanBias
|
||||||
|
|
||||||
/* standard initialization of some data */
|
/* standard initialization of some data */
|
||||||
this->clients.Resize(desc.clients.Size());
|
this->clients.Resize(desc.clients.Size());
|
||||||
this->box = new PostBox<NetworkSession::NetEvent>();
|
|
||||||
this->owner = desc.owner;
|
this->owner = desc.owner;
|
||||||
|
|
||||||
/* Initiate the game instance */
|
/* Initiate the game instance */
|
||||||
|
@ -61,18 +62,13 @@ namespace DanBias
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a callback object */
|
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
|
||||||
c.value.callbackPostBox = this->box;
|
|
||||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
|
||||||
|
|
||||||
/* Create the players in the game instance */
|
/* Create the players in the game instance */
|
||||||
GameLogic::IPlayerData* p = 0;
|
GameLogic::IPlayerData* p = 0;
|
||||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if( (p = this->gameInstance.CreatePlayer()) )
|
if( (p = this->gameInstance.CreatePlayer()) )
|
||||||
{
|
{
|
||||||
this->clients[i] = new GameClient(desc.clients[i], p, c);
|
this->clients[i] = new GameClient(desc.clients[i], p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -81,12 +77,12 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the worker thread */
|
/* Create the worker thread */
|
||||||
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS)
|
if(this->worker.Create(this, false) != OYSTER_THREAD_ERROR_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this->worker.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_3);
|
this->worker.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_3);
|
||||||
|
|
||||||
/* Set some gameinstance data options */
|
/* Set some game instance data options */
|
||||||
this->gameInstance.SetSubscription(GameLogic::GameEvent::ObjectEventFunctionType_OnMove, GameSession::ObjectMove);
|
this->gameInstance.SetSubscription(GameLogic::GameEvent::ObjectEventFunctionType_OnMove, GameSession::ObjectMove);
|
||||||
|
|
||||||
this->isCreated = true;
|
this->isCreated = true;
|
||||||
|
@ -95,106 +91,39 @@ namespace DanBias
|
||||||
|
|
||||||
void GameSession::Run()
|
void GameSession::Run()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(this->isRunning) return;
|
if(this->isRunning) return;
|
||||||
|
|
||||||
if(this->clients.Size() > 0)
|
if(this->clients.Size() > 0)
|
||||||
{
|
{
|
||||||
|
this->worker.Start();
|
||||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
||||||
this->isRunning = true;
|
this->isRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<NetworkSession> client)
|
|
||||||
|
|
||||||
|
bool GameSession::Attach(Utility::DynamicMemory::SmartPointer<NetworkClient> client)
|
||||||
{
|
{
|
||||||
if(!this->isCreated) return false;
|
if(!this->isCreated) return false;
|
||||||
|
|
||||||
Oyster::Callback::OysterCallback<void, DanBias::NetworkSession::NetEvent> c;
|
client->SetOwner(this);
|
||||||
c.value.callbackPostBox = this->box;
|
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer());
|
||||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
|
||||||
|
|
||||||
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer(), c);
|
|
||||||
InsertClient(obj);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::CloseSession(bool dissconnectClients)
|
|
||||||
{
|
|
||||||
if(dissconnectClients)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
this->clients[i]->GetClient()->Disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->SendToOwner(0); //Send all clients to the current owner
|
|
||||||
}
|
|
||||||
this->Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::InsertClient(SmartPointer<GameClient> obj)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(!clients[i])
|
if(!clients[i])
|
||||||
{
|
{
|
||||||
clients[i] = obj;
|
clients[i] = obj;
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clients.Push(obj);
|
clients.Push(obj);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::RemoveClient(DanBias::GameClient* obj)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(clients[i] && clients[i]->GetID() == obj->GetID())
|
|
||||||
{
|
|
||||||
clients[i] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::SendToOwner(DanBias::GameClient* obj)
|
|
||||||
{
|
|
||||||
DanBias::NetworkSession *s = GameServer::MainLobbyInstance();
|
|
||||||
|
|
||||||
if(this->owner) s = this->owner;
|
|
||||||
|
|
||||||
if(obj)
|
|
||||||
{
|
|
||||||
s->Attach(obj->ReleaseClient());
|
|
||||||
RemoveClient(obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i])
|
|
||||||
{
|
|
||||||
s->Attach(this->clients[i]->ReleaseClient());
|
|
||||||
RemoveClient(this->clients[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::Clean()
|
|
||||||
{
|
|
||||||
this->worker.Terminate();
|
|
||||||
this->clients.Clear();
|
|
||||||
delete this->box;
|
|
||||||
this->box = 0;
|
|
||||||
this->gameInstance;
|
|
||||||
this->owner = 0;
|
|
||||||
this->isCreated = false;
|
|
||||||
this->isRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
|
|
@ -1,74 +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>
|
|
||||||
#include <OysterMath.h>
|
|
||||||
|
|
||||||
#define DELTA_TIME_20 0.05f
|
|
||||||
#define DELTA_TIME_24 0.04166666666666666666666666666667f
|
|
||||||
#define DELTA_TIME_30 0.03333333333333333333333333333333f
|
|
||||||
#define DELTA_TIME_60 0.01666666666666666666666666666667f
|
|
||||||
#define DELTA_TIME_120 0.00833333333333333333333333333333f
|
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
using namespace Oyster;
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
using namespace Oyster::Thread;
|
|
||||||
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_ObjectCreate p(world, 2, "../Content/crate");
|
|
||||||
Send(p.GetProtocol());
|
|
||||||
Sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
double dt = this->timer.getElapsedSeconds();
|
|
||||||
gameInstance.SetFrameTimeLength((float)dt);
|
|
||||||
|
|
||||||
if(dt >= DELTA_TIME_20)
|
|
||||||
{
|
|
||||||
this->ParseEvents();
|
|
||||||
|
|
||||||
this->gameInstance.NewFrame();
|
|
||||||
|
|
||||||
this->UpdateGameObjects();
|
|
||||||
|
|
||||||
this->timer.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->isRunning;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::UpdateGameObjects()
|
|
||||||
{
|
|
||||||
if(clients.Size() >= 1 && clients[0])
|
|
||||||
{
|
|
||||||
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
|
|
||||||
Protocol_ObjectPosition p(world, 1);
|
|
||||||
Send(p.GetProtocol());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}//End namespace DanBias
|
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
#include "GameLobby.h"
|
|
||||||
#include "NetworkSession.h"
|
|
||||||
|
|
||||||
using namespace DanBias;
|
|
||||||
using namespace GameLogic;
|
|
||||||
|
|
||||||
void GameLobby::ParseGeneralProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
switch (p[0].value.netShort)
|
|
||||||
{
|
|
||||||
case protocol_General_Status:
|
|
||||||
{
|
|
||||||
GeneralStatus(GameLogic::Protocol_General_Status(p), c);
|
|
||||||
} break;
|
|
||||||
case protocol_General_Text:
|
|
||||||
{
|
|
||||||
GeneralText(GameLogic::Protocol_General_Text(p), c);
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
switch (p.status)
|
|
||||||
{
|
|
||||||
case Protocol_General_Status::States_ready:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
case Protocol_General_Status::States_idle:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
case Protocol_General_Status::States_leave:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
case Protocol_General_Status::States_disconected:
|
|
||||||
{
|
|
||||||
Detach(c)->Disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
#include "..\GameLobby.h"
|
|
||||||
|
|
||||||
using namespace DanBias;
|
|
||||||
|
|
||||||
void GameLobby::ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
switch (p[0].value.netShort)
|
|
||||||
{
|
|
||||||
case protocol_Lobby_Start:
|
|
||||||
LobbyStartGame(GameLogic::Protocol_LobbyStartGame(p), c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case protocol_Lobby_Refresh:
|
|
||||||
LobbyRefresh(GameLogic::Protocol_LobbyRefresh(p), c);
|
|
||||||
break;
|
|
||||||
case protocol_Lobby_Login:
|
|
||||||
{
|
|
||||||
LobbyLogin(GameLogic::Protocol_LobbyLogin(p), c);
|
|
||||||
} break;
|
|
||||||
case protocol_Lobby_Join:
|
|
||||||
{
|
|
||||||
LobbyJoin(GameLogic::Protocol_LobbyJoin(p), c);
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
double now = this->timer.getElapsedSeconds() + c->lastPoll;
|
|
||||||
|
|
||||||
if(now > this->refreshFrequency)
|
|
||||||
{
|
|
||||||
c->lastPoll = (float)now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyLogin& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoin& p, DanBias::NetworkSession* c)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
|
||||||
{
|
|
||||||
if (this->gameLobby[i]->GetID() == p.value)
|
|
||||||
{
|
|
||||||
this->gameLobby[i]->Attach(Detach(c));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,18 +4,19 @@
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
|
||||||
#include "DanBiasGame.h"
|
#include "DanBiasGame.h"
|
||||||
#include <DanBiasServerAPI.h>
|
#include <GameServerAPI.h>
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
void ServerFnc()
|
void ServerFnc()
|
||||||
{
|
{
|
||||||
|
DanBias::GameServerAPI::GameInitDesc desc;
|
||||||
if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess)
|
desc.listenPort = 15151;
|
||||||
|
if( DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
|
||||||
{
|
{
|
||||||
DanBias::DanBiasServerAPI::Run();
|
DanBias::GameServerAPI::Start();
|
||||||
DanBias::DanBiasServerAPI::Release();
|
DanBias::GameServerAPI::Terminate();
|
||||||
}
|
}
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -177,6 +177,9 @@
|
||||||
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
||||||
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\GameServer\GameServer.vcxproj">
|
||||||
|
<Project>{143bd516-20a1-4890-a3e4-f8bfd02220e7}</Project>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -118,15 +118,17 @@ using namespace Utility::DynamicMemory;
|
||||||
{
|
{
|
||||||
SmartPointer<RefData> data;
|
SmartPointer<RefData> data;
|
||||||
|
|
||||||
PrivateData(){}
|
PrivateData()
|
||||||
|
{
|
||||||
|
data = new RefData();
|
||||||
|
}
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
data.Release();
|
data = 0;
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
|
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
|
||||||
{
|
{
|
||||||
if(data) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
if(!data) data = new RefData();
|
||||||
data = new RefData();
|
|
||||||
return data->Create(fnc, worker, start, detach);
|
return data->Create(fnc, worker, start, detach);
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR Terminate()
|
OYSTER_THREAD_ERROR Terminate()
|
||||||
|
@ -205,9 +207,8 @@ using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
|
||||||
OysterThread::OysterThread()
|
OysterThread::OysterThread()
|
||||||
{
|
:privateData(0)
|
||||||
this->privateData = new PrivateData();
|
{ }
|
||||||
}
|
|
||||||
OysterThread::OysterThread(const OysterThread& original)
|
OysterThread::OysterThread(const OysterThread& original)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData(*original.privateData);
|
this->privateData = new PrivateData(*original.privateData);
|
||||||
|
@ -227,9 +228,8 @@ OysterThread::~OysterThread()
|
||||||
|
|
||||||
OYSTER_THREAD_ERROR OysterThread::Create(IThreadObject* worker, bool start, bool detach)
|
OYSTER_THREAD_ERROR OysterThread::Create(IThreadObject* worker, bool start, bool detach)
|
||||||
{
|
{
|
||||||
if(!this->privateData) this->privateData = new PrivateData();
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
if(this->privateData->data->isCreated) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
|
||||||
OwnerContainer c;
|
OwnerContainer c;
|
||||||
c.type = Oyster::Callback::CallbackType_Object;
|
c.type = Oyster::Callback::CallbackType_Object;
|
||||||
c.value = worker;
|
c.value = worker;
|
||||||
|
@ -237,7 +237,7 @@ OYSTER_THREAD_ERROR OysterThread::Create(IThreadObject* worker, bool start, bool
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR OysterThread::Create(ThreadFnc worker, bool start, bool detach)
|
OYSTER_THREAD_ERROR OysterThread::Create(ThreadFnc worker, bool start, bool detach)
|
||||||
{
|
{
|
||||||
if(!this->privateData) this->privateData = new PrivateData();
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
OwnerContainer c;
|
OwnerContainer c;
|
||||||
c.type = Oyster::Callback::CallbackType_Function;
|
c.type = Oyster::Callback::CallbackType_Function;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#ifndef WINTIMER_H
|
#ifndef WINTIMER_H
|
||||||
#define WINTIMER_H
|
#define WINTIMER_H
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
namespace Utility
|
namespace Utility
|
||||||
|
|
|
@ -4,36 +4,27 @@
|
||||||
#include "CustomNetProtocol.h"
|
#include "CustomNetProtocol.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
|
#include "Utilities.h"
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
|
||||||
struct CustomNetProtocol::PrivateData
|
struct CustomNetProtocol::PrivateData
|
||||||
{
|
{
|
||||||
std::map<int, NetAttributeContainer> attributes;
|
std::map<int, NetAttributeContainer> attributes; //...Im an idiot
|
||||||
|
Utility::DynamicMemory::ReferenceCount *c;
|
||||||
|
|
||||||
PrivateData()
|
PrivateData()
|
||||||
{ }
|
|
||||||
PrivateData( const CustomNetProtocol::PrivateData& o)
|
|
||||||
{
|
{
|
||||||
for (auto i = o.attributes.begin(); i != o.attributes.end(); i++)
|
//this->attributes = new std::map<int, NetAttributeContainer>();
|
||||||
{
|
this->c = new ReferenceCount();
|
||||||
if(i->second.type == NetAttributeType_CharArray)
|
c->Incref();
|
||||||
{
|
|
||||||
size_t size = strlen(i->second.value.netCharPtr);
|
|
||||||
if(size == 0) continue;
|
|
||||||
|
|
||||||
attributes[i->first].value.netCharPtr = new char[size + 1];
|
|
||||||
memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1);
|
|
||||||
attributes[i->first].type = NetAttributeType_CharArray;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
attributes[i->first] = i->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
|
delete c;
|
||||||
|
c = 0;
|
||||||
for (auto i = attributes.begin(); i != attributes.end(); i++)
|
for (auto i = attributes.begin(); i != attributes.end(); i++)
|
||||||
{
|
{
|
||||||
RemoveAttribute(i->first);
|
RemoveAttribute(i->first);
|
||||||
|
@ -49,7 +40,6 @@ struct CustomNetProtocol::PrivateData
|
||||||
{
|
{
|
||||||
case NetAttributeType_CharArray:
|
case NetAttributeType_CharArray:
|
||||||
delete [] i->second.value.netCharPtr;
|
delete [] i->second.value.netCharPtr;
|
||||||
//i->second.value.netCharPtr = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,17 +54,40 @@ CustomNetProtocol::CustomNetProtocol()
|
||||||
}
|
}
|
||||||
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData(*o.privateData);
|
this->privateData = o.privateData;
|
||||||
|
if(this->privateData)
|
||||||
|
{
|
||||||
|
this->privateData->c = o.privateData->c;
|
||||||
|
this->privateData->c->Incref();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
const CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
if(this->privateData && this->privateData->c)
|
||||||
this->privateData = new PrivateData(*o.privateData);
|
{
|
||||||
|
if(this->privateData->c->Decref() == 0)
|
||||||
|
{
|
||||||
|
delete this->privateData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->privateData = o.privateData;
|
||||||
|
if(this->privateData)
|
||||||
|
{
|
||||||
|
this->privateData->c = o.privateData->c;
|
||||||
|
this->privateData->c->Incref();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
CustomNetProtocol::~CustomNetProtocol()
|
CustomNetProtocol::~CustomNetProtocol()
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
if(this->privateData && this->privateData->c)
|
||||||
|
{
|
||||||
|
if(this->privateData->c->Decref() == 0)
|
||||||
|
{
|
||||||
|
delete this->privateData;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,16 +88,16 @@
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86);</LibraryPath>
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSDK_LibraryPath_x64);</LibraryPath>
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -107,6 +107,7 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -121,6 +122,7 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -137,6 +139,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -155,6 +158,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
|
|
@ -26,8 +26,9 @@ using namespace Utility::Container;
|
||||||
PrivateData
|
PrivateData
|
||||||
*************************************/
|
*************************************/
|
||||||
typedef NetworkClient::ClientEventArgs CEA;
|
typedef NetworkClient::ClientEventArgs CEA;
|
||||||
struct NetDataContainer : public IThreadObject
|
|
||||||
{ //This struct is contained within a smart pointer. To avoide dependencies in link its implemented here..
|
struct NetworkClient::PrivateData : public IThreadObject
|
||||||
|
{
|
||||||
NetworkSession *owner;
|
NetworkSession *owner;
|
||||||
NetworkClient *parent;
|
NetworkClient *parent;
|
||||||
Connection connection;
|
Connection connection;
|
||||||
|
@ -43,19 +44,17 @@ struct NetDataContainer : public IThreadObject
|
||||||
static unsigned int currID;
|
static unsigned int currID;
|
||||||
const unsigned int ID;
|
const unsigned int ID;
|
||||||
|
|
||||||
NetDataContainer()
|
PrivateData()
|
||||||
: ID(currID++)
|
: ID(currID++)
|
||||||
, parent(0)
|
, parent(0)
|
||||||
, owner(0)
|
, owner(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
InitWinSock();
|
InitWinSock();
|
||||||
this->thread.Create(this, true);
|
this->thread.Create(this, false);
|
||||||
this->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
this->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
||||||
}
|
}
|
||||||
NetDataContainer(const NetDataContainer& obj)
|
~PrivateData()
|
||||||
:ID(obj.ID) { }
|
|
||||||
~NetDataContainer()
|
|
||||||
{
|
{
|
||||||
ShutdownWinSock();
|
ShutdownWinSock();
|
||||||
this->connection.Disconnect();
|
this->connection.Disconnect();
|
||||||
|
@ -73,7 +72,6 @@ struct NetDataContainer : public IThreadObject
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Send()
|
int Send()
|
||||||
{
|
{
|
||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
|
@ -96,7 +94,6 @@ struct NetDataContainer : public IThreadObject
|
||||||
|
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Recv()
|
int Recv()
|
||||||
{
|
{
|
||||||
int errorCode = -1;
|
int errorCode = -1;
|
||||||
|
@ -119,33 +116,19 @@ struct NetDataContainer : public IThreadObject
|
||||||
this->recieveQueue.Push(e);
|
this->recieveQueue.Push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
CEA parg;
|
// CEA parg;
|
||||||
parg.type = CEA::EventType_ProtocolFailedToRecieve;
|
// parg.type = CEA::EventType_ProtocolFailedToRecieve;
|
||||||
parg.data.nothing = 0;
|
// parg.data.nothing = 0;
|
||||||
NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e = { this->parent, parg };
|
// NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e = { this->parent, parg };
|
||||||
this->recieveQueue.Push(e);
|
// this->recieveQueue.Push(e);
|
||||||
}
|
//}
|
||||||
|
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
unsigned int NetworkClient::PrivateData::currID = 0;
|
||||||
|
|
||||||
struct NetworkClient::PrivateData
|
|
||||||
{
|
|
||||||
SmartPointer<NetDataContainer> dat;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PrivateData()
|
|
||||||
{ this->dat = new NetDataContainer(); }
|
|
||||||
PrivateData(const PrivateData& obj)
|
|
||||||
{ this->dat = obj.dat; }
|
|
||||||
~PrivateData()
|
|
||||||
{ this->dat = 0; }
|
|
||||||
};
|
|
||||||
unsigned int NetDataContainer::currID = 0;
|
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
NetworkClient
|
NetworkClient
|
||||||
|
@ -155,21 +138,6 @@ NetworkClient::NetworkClient()
|
||||||
: privateData(0)
|
: privateData(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
NetworkClient::NetworkClient(const NetworkClient& obj)
|
|
||||||
{
|
|
||||||
if(obj.privateData) this->privateData = new PrivateData(*obj.privateData);
|
|
||||||
else this->privateData = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient& NetworkClient::operator =(const NetworkClient& obj)
|
|
||||||
{
|
|
||||||
delete privateData;
|
|
||||||
this->privateData = 0;
|
|
||||||
if(obj.privateData) this->privateData = new PrivateData(*obj.privateData);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient::~NetworkClient()
|
NetworkClient::~NetworkClient()
|
||||||
{
|
{
|
||||||
if(this->privateData)
|
if(this->privateData)
|
||||||
|
@ -181,22 +149,25 @@ NetworkClient::~NetworkClient()
|
||||||
|
|
||||||
bool NetworkClient::operator ==(const NetworkClient& obj)
|
bool NetworkClient::operator ==(const NetworkClient& obj)
|
||||||
{
|
{
|
||||||
return (this->privateData->dat->ID == obj.privateData->dat->ID);
|
return (this->privateData->ID == obj.privateData->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkClient::operator ==(const int& ID)
|
bool NetworkClient::operator ==(const int& ID)
|
||||||
{
|
{
|
||||||
return this->privateData->dat->ID == ID;
|
return this->privateData->ID == ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::ProcessMessages()
|
void NetworkClient::Update()
|
||||||
{
|
{
|
||||||
while (!this->privateData->dat->recieveQueue.IsEmpty())
|
while (!this->privateData->recieveQueue.IsEmpty())
|
||||||
{
|
{
|
||||||
if(this->privateData->dat->owner)
|
NetEvent<NetworkClient*, ClientEventArgs> temp = this->privateData->recieveQueue.Pop();
|
||||||
{
|
|
||||||
this->privateData->dat->owner->ClientEventCallback(this->privateData->dat->recieveQueue.Pop());
|
this->DataRecieved(temp);
|
||||||
}
|
|
||||||
|
//--------- Deprecate ---------
|
||||||
|
this->NetworkCallback(temp.args.data.protocol);
|
||||||
|
//------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,13 +177,16 @@ bool NetworkClient::Connect(int socket)
|
||||||
if(this->privateData) return false;
|
if(this->privateData) return false;
|
||||||
if(!this->privateData) this->privateData = new PrivateData();
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
int result = this->privateData->dat->connection.Connect(socket, true);
|
int result = this->privateData->connection.Connect(socket, false);
|
||||||
|
|
||||||
//Connect has succeeded
|
//Connect has succeeded
|
||||||
if(result == 0) return true;
|
if(result != 0) return false;
|
||||||
|
|
||||||
|
this->privateData->parent = this;
|
||||||
|
this->privateData->thread.Start();
|
||||||
|
|
||||||
//Connect has failed
|
//Connect has failed
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
||||||
|
@ -221,46 +195,59 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
||||||
if(this->privateData) return false;
|
if(this->privateData) return false;
|
||||||
if(!this->privateData) this->privateData = new PrivateData();
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
int result = this->privateData->dat->connection.Connect(port, serverIP, false);
|
int result = this->privateData->connection.Connect(port, serverIP, false);
|
||||||
|
|
||||||
//Connect has succeeded
|
//Connect has succeeded
|
||||||
if(result == 0) return true;
|
if(result != 0) return false;
|
||||||
|
|
||||||
|
this->privateData->parent = this;
|
||||||
|
this->privateData->thread.Start();
|
||||||
|
|
||||||
//Connect has failed
|
//Connect has failed
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::Disconnect()
|
void NetworkClient::Disconnect()
|
||||||
{
|
{
|
||||||
privateData->dat->connection.Disconnect();
|
privateData->connection.Disconnect();
|
||||||
privateData->dat->thread.Terminate();
|
privateData->thread.Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::Send(CustomProtocolObject& protocol)
|
void NetworkClient::Send(CustomProtocolObject& protocol)
|
||||||
{
|
{
|
||||||
this->privateData->dat->sendQueue.Push(*protocol.GetProtocol());
|
this->privateData->sendQueue.Push(*protocol.GetProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::Send(CustomNetProtocol* protocol)
|
void NetworkClient::Send(CustomNetProtocol* protocol)
|
||||||
{
|
{
|
||||||
this->privateData->dat->sendQueue.Push(*protocol);
|
this->privateData->sendQueue.Push(*protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::SetOwner(NetworkSession* owner)
|
void NetworkClient::SetOwner(NetworkSession* owner)
|
||||||
{
|
{
|
||||||
this->privateData->dat->owner = owner;
|
this->privateData->owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkClient::IsConnected()
|
bool NetworkClient::IsConnected()
|
||||||
{
|
{
|
||||||
if(!this->privateData) return false;
|
if(!this->privateData) return false;
|
||||||
return privateData->dat->connection.IsConnected();
|
return privateData->connection.IsConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkClient::GetID() const
|
int NetworkClient::GetID() const
|
||||||
{
|
{
|
||||||
return this->privateData->dat->ID;
|
return this->privateData->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkClient::DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e)
|
||||||
|
{
|
||||||
|
if(this->privateData->owner)
|
||||||
|
{
|
||||||
|
this->privateData->owner->ClientEventCallback(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::NetworkCallback(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,6 @@ namespace Oyster
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkClient();
|
NetworkClient();
|
||||||
NetworkClient(const NetworkClient& obj);
|
|
||||||
NetworkClient& operator =(const NetworkClient& obj);
|
|
||||||
virtual ~NetworkClient();
|
virtual ~NetworkClient();
|
||||||
|
|
||||||
bool operator ==(const NetworkClient& obj);
|
bool operator ==(const NetworkClient& obj);
|
||||||
|
@ -51,7 +49,7 @@ namespace Oyster
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void ProcessMessages();
|
void Update();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -93,7 +91,21 @@ namespace Oyster
|
||||||
*/
|
*/
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
|
||||||
|
/** ! Deprecate !
|
||||||
|
* Do not use this furthermore, instead use void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
* @see DataRecieved
|
||||||
|
*/
|
||||||
|
virtual void NetworkCallback(Oyster::Network::CustomNetProtocol& p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
NetworkClient(const NetworkClient& obj);
|
||||||
|
NetworkClient& operator =(const NetworkClient& obj);
|
||||||
|
|
||||||
struct PrivateData;
|
struct PrivateData;
|
||||||
PrivateData* privateData;
|
PrivateData* privateData;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
#include "../NetworkDependencies/PostBox.h"
|
#include "../NetworkDependencies/PostBox.h"
|
||||||
#include "../NetworkDependencies/WinsockFunctions.h"
|
#include "../NetworkDependencies/WinsockFunctions.h"
|
||||||
|
|
||||||
#include "../../Misc/Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "../../Misc/Thread/OysterThread.h"
|
#include "Thread/OysterThread.h"
|
||||||
|
|
||||||
|
#ifndef _DEBUG
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace ::Server;
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
|
|
||||||
|
@ -21,6 +24,41 @@ using namespace Oyster::Thread;
|
||||||
PrivateData
|
PrivateData
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
|
void Broadcast()
|
||||||
|
{
|
||||||
|
char pkt[4];
|
||||||
|
size_t pkt_length = 4;
|
||||||
|
sockaddr_in dest;
|
||||||
|
sockaddr_in local;
|
||||||
|
WSAData data;
|
||||||
|
WSAStartup( MAKEWORD( 2, 2 ), &data );
|
||||||
|
|
||||||
|
local.sin_family = AF_INET;
|
||||||
|
local.sin_addr.s_addr = inet_addr( "127.0.0.1" );
|
||||||
|
local.sin_port = 15151; // choose any
|
||||||
|
|
||||||
|
dest.sin_family = AF_INET;
|
||||||
|
dest.sin_port = htons( 15151 );
|
||||||
|
|
||||||
|
// create the socket
|
||||||
|
SOCKET s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
||||||
|
// bind to the local address
|
||||||
|
bind( s, (sockaddr *)&local, sizeof(local) );
|
||||||
|
|
||||||
|
std::string addr;
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
addr = "192.168.0.";
|
||||||
|
char buff[5];
|
||||||
|
_itoa_s<5>(i, buff, 10);
|
||||||
|
|
||||||
|
addr.append(buff);
|
||||||
|
dest.sin_addr.s_addr = inet_addr( addr.c_str() );
|
||||||
|
// send the pkt
|
||||||
|
int ret = sendto( s, pkt, pkt_length, 0, (sockaddr *)&dest, sizeof(dest) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct NetworkServer::PrivateData : public IThreadObject
|
struct NetworkServer::PrivateData : public IThreadObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -30,6 +68,7 @@ public:
|
||||||
, isInitiated(0)
|
, isInitiated(0)
|
||||||
, isReleased(0)
|
, isReleased(0)
|
||||||
, isRunning(0)
|
, isRunning(0)
|
||||||
|
, port(-1)
|
||||||
{ }
|
{ }
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{ }
|
{ }
|
||||||
|
@ -37,11 +76,11 @@ public:
|
||||||
bool DoWork();
|
bool DoWork();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IListener* listener;
|
Listener* listener;
|
||||||
PostBox<int> postBox; //Postbox for new clients
|
PostBox<int> postBox; //Postbox for new clients
|
||||||
OysterThread thread; //Server thread
|
OysterThread thread; //Server thread
|
||||||
NetworkSession *mainSession;
|
NetworkSession *mainSession;
|
||||||
Utility::Container::ThreadSafeQueue<NetworkClient> clientQueue;
|
Utility::Container::ThreadSafeQueue<SmartPointer<NetworkClient>> clientQueue;
|
||||||
|
|
||||||
bool isInitiated;
|
bool isInitiated;
|
||||||
bool isReleased;
|
bool isReleased;
|
||||||
|
@ -51,6 +90,8 @@ public:
|
||||||
|
|
||||||
bool NetworkServer::PrivateData::DoWork()
|
bool NetworkServer::PrivateData::DoWork()
|
||||||
{
|
{
|
||||||
|
//Broadcast();
|
||||||
|
|
||||||
/** Check for new clients **/
|
/** Check for new clients **/
|
||||||
if(postBox.IsFull())
|
if(postBox.IsFull())
|
||||||
{
|
{
|
||||||
|
@ -61,11 +102,10 @@ bool NetworkServer::PrivateData::DoWork()
|
||||||
//Something went wrong somewhere... do we care?
|
//Something went wrong somewhere... do we care?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SmartPointer<NetworkClient> client(new NetworkClient());
|
||||||
|
client->Connect(clientSocketNum);
|
||||||
|
|
||||||
Oyster::Network::NetworkClient client;
|
this->clientQueue.Push(client);
|
||||||
client.Connect(clientSocketNum);
|
|
||||||
if(this->mainSession)
|
|
||||||
this->clientQueue.Push(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -101,6 +141,7 @@ NetworkServer::~NetworkServer()
|
||||||
|
|
||||||
NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSession const* mainSession)
|
NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSession const* mainSession)
|
||||||
{
|
{
|
||||||
|
this->privateData->mainSession = const_cast<NetworkSession*>(mainSession);
|
||||||
//Check if it's a valid port
|
//Check if it's a valid port
|
||||||
if(port == 0 || port == -1)
|
if(port == 0 || port == -1)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +158,7 @@ NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSess
|
||||||
|
|
||||||
//Initiate listener
|
//Initiate listener
|
||||||
this->privateData->listener = new Listener(&this->privateData->postBox);
|
this->privateData->listener = new Listener(&this->privateData->postBox);
|
||||||
if(!((Listener*)this->privateData->listener)->Init(port, false))
|
if(!this->privateData->listener->Init(port, false))
|
||||||
{
|
{
|
||||||
return NetworkServer::ServerReturnCode_Error;
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
}
|
}
|
||||||
|
@ -129,14 +170,13 @@ NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSess
|
||||||
|
|
||||||
this->privateData->isInitiated = true;
|
this->privateData->isInitiated = true;
|
||||||
this->privateData->isReleased = false;
|
this->privateData->isReleased = false;
|
||||||
this->privateData->mainSession = 0;
|
|
||||||
return NetworkServer::ServerReturnCode_Sucess;
|
return NetworkServer::ServerReturnCode_Sucess;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkServer::ServerReturnCode NetworkServer::Start()
|
NetworkServer::ServerReturnCode NetworkServer::Start()
|
||||||
{
|
{
|
||||||
//Start listener
|
//Start listener
|
||||||
if(!((Listener*)this->privateData->listener)->Start())
|
if(!this->privateData->listener->Start())
|
||||||
{
|
{
|
||||||
return NetworkServer::ServerReturnCode_Error;
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +194,7 @@ void NetworkServer::Stop()
|
||||||
{
|
{
|
||||||
if(this->privateData->listener)
|
if(this->privateData->listener)
|
||||||
{
|
{
|
||||||
((Listener*)this->privateData->listener)->Stop();
|
this->privateData->listener->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->privateData->thread.Stop();
|
this->privateData->thread.Stop();
|
||||||
|
@ -164,6 +204,10 @@ void NetworkServer::Stop()
|
||||||
|
|
||||||
void NetworkServer::Shutdown()
|
void NetworkServer::Shutdown()
|
||||||
{
|
{
|
||||||
|
if(this->privateData->mainSession)
|
||||||
|
{
|
||||||
|
this->privateData->mainSession->CloseSession(true);
|
||||||
|
}
|
||||||
if(this->privateData->listener)
|
if(this->privateData->listener)
|
||||||
{
|
{
|
||||||
this->privateData->listener->Shutdown();
|
this->privateData->listener->Shutdown();
|
||||||
|
@ -180,12 +224,23 @@ void NetworkServer::Shutdown()
|
||||||
this->privateData->isReleased = true;
|
this->privateData->isReleased = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkServer::ProcessConnectedClients()
|
int NetworkServer::ProcessConnectedClients()
|
||||||
{
|
{
|
||||||
|
int c = 0;
|
||||||
while(!this->privateData->clientQueue.IsEmpty())
|
while(!this->privateData->clientQueue.IsEmpty())
|
||||||
{
|
{
|
||||||
if(this->privateData->mainSession) this->privateData->mainSession->Attach(this->privateData->clientQueue.Pop());
|
if(this->privateData->mainSession)
|
||||||
|
{
|
||||||
|
this->privateData->mainSession->ClientConnectedEvent(this->privateData->clientQueue.Pop());
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Clients have nowhere to go?
|
||||||
|
this->privateData->clientQueue.Pop()->Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkServer::SetSession(NetworkSession const* mainSession)
|
void NetworkServer::SetSession(NetworkSession const* mainSession)
|
||||||
|
@ -198,7 +253,7 @@ NetworkSession const* NetworkServer::GetMainSession()
|
||||||
return this->privateData->mainSession;
|
return this->privateData->mainSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkSession const* NetworkServer::ReleaseMainSessionSession()
|
NetworkSession const* NetworkServer::ReleaseMainSession()
|
||||||
{
|
{
|
||||||
NetworkSession const * temp;
|
NetworkSession const * temp;
|
||||||
temp = this->privateData->mainSession;
|
temp = this->privateData->mainSession;
|
||||||
|
@ -211,7 +266,22 @@ bool NetworkServer::IsStarted() const
|
||||||
return this->privateData->isRunning;
|
return this->privateData->isRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string NetworkServer::GetLanAddress()
|
||||||
|
{
|
||||||
|
std::string szLocalIP;
|
||||||
|
char szHostName[255];
|
||||||
|
struct hostent *host_entry;
|
||||||
|
|
||||||
|
gethostname(szHostName, 255);
|
||||||
|
|
||||||
|
host_entry = gethostbyname(szHostName);
|
||||||
|
char* temp = inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
|
||||||
|
|
||||||
|
char buff[255];
|
||||||
|
strcpy_s(buff, temp);
|
||||||
|
szLocalIP = buff;
|
||||||
|
return szLocalIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace Oyster
|
||||||
|
|
||||||
/** Parses asynchronous connected clients.
|
/** Parses asynchronous connected clients.
|
||||||
*/
|
*/
|
||||||
void ProcessConnectedClients();
|
int ProcessConnectedClients();
|
||||||
|
|
||||||
/** Set the main session connected clients will enter when connected to server.
|
/** Set the main session connected clients will enter when connected to server.
|
||||||
* @param mainSession The session to connect as main server session.
|
* @param mainSession The session to connect as main server session.
|
||||||
|
@ -72,13 +72,17 @@ namespace Oyster
|
||||||
/** Sets the main session to NULL and returns it
|
/** Sets the main session to NULL and returns it
|
||||||
* @return Returns the main session
|
* @return Returns the main session
|
||||||
*/
|
*/
|
||||||
NetworkSession const* ReleaseMainSessionSession();
|
NetworkSession const* ReleaseMainSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool IsStarted() const;
|
bool IsStarted() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::string GetLanAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
struct PrivateData;
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
|
|
||||||
struct NetworkSession::PrivateSessionData
|
struct NetworkSession::PrivateSessionData
|
||||||
{
|
{
|
||||||
Utility::DynamicMemory::DynamicArray<NetworkClient> clients;
|
Utility::DynamicMemory::DynamicArray<NetClient> clients;
|
||||||
NetworkClient::ClientEventFunction messageCallback;
|
NetworkClient::ClientEventFunction messageCallback;
|
||||||
std::mutex clientListLock;
|
std::mutex clientListLock;
|
||||||
NetworkSession* owner; //Where clients end up when session is closed.
|
NetworkSession* owner; //Where clients end up when session is closed.
|
||||||
|
@ -32,7 +32,7 @@ struct NetworkSession::PrivateSessionData
|
||||||
|
|
||||||
|
|
||||||
NetworkSession::NetworkSession()
|
NetworkSession::NetworkSession()
|
||||||
: data(0)
|
: data(new PrivateSessionData())
|
||||||
{}
|
{}
|
||||||
NetworkSession::NetworkSession(const NetworkSession& orig)
|
NetworkSession::NetworkSession(const NetworkSession& orig)
|
||||||
{
|
{
|
||||||
|
@ -59,24 +59,26 @@ NetworkSession::~NetworkSession()
|
||||||
this->data->clients.Clear();
|
this->data->clients.Clear();
|
||||||
this->data->clientCount = 0;
|
this->data->clientCount = 0;
|
||||||
this->data->messageCallback = 0;
|
this->data->messageCallback = 0;
|
||||||
|
delete this->data;
|
||||||
|
this->data = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSession::ProcessClients()
|
void NetworkSession::ProcessClients()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
this->data->clients[i].ProcessMessages();
|
if(this->data->clients[i]) this->data->clients[i]->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkSession::Attach(NetworkClient client)
|
bool NetworkSession::Attach(NetClient client)
|
||||||
{
|
{
|
||||||
this->data->clientListLock.lock();
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
int k = -1;
|
int k = -1;
|
||||||
for (unsigned int i = 0; (k == -1) && i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; (k == -1) && i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(!this->data->clients[i].IsConnected()) //TODO: Dont check connection status, check more general status..
|
if(!this->data->clients[i]->IsConnected()) //TODO: Dont check connection status, check more general status..
|
||||||
k = i;
|
k = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,23 +93,44 @@ bool NetworkSession::Attach(NetworkClient client)
|
||||||
|
|
||||||
this->data->clientCount++;
|
this->data->clientCount++;
|
||||||
|
|
||||||
|
client->SetOwner(this);
|
||||||
this->data->clientListLock.unlock();
|
this->data->clientListLock.unlock();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkClient NetworkSession::Detach(const NetworkClient& client)
|
void NetworkSession::Detach()
|
||||||
{
|
{
|
||||||
NetworkClient val;
|
if(this->data->owner)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
this->data->owner->Attach(this->data->clients[i]);
|
||||||
|
this->data->clients[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
this->data->clients[i]->Disconnect();
|
||||||
|
this->data->clients[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NetClient NetworkSession::Detach(const NetworkClient* client)
|
||||||
|
{
|
||||||
|
NetClient val;
|
||||||
|
|
||||||
this->data->clientListLock.lock();
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->data->clients[0].GetID() == client.GetID())
|
if(this->data->clients[i] && this->data->clients[0]->GetID() == client->GetID())
|
||||||
{
|
{
|
||||||
val = this->data->clients[i];
|
val = this->data->clients[i];
|
||||||
this->data->clients[i] = NetworkClient();
|
this->data->clients[i] = 0;
|
||||||
this->data->clientCount--;
|
this->data->clientCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,18 +140,18 @@ NetworkClient NetworkSession::Detach(const NetworkClient& client)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkClient NetworkSession::Detach(short ID)
|
NetClient NetworkSession::Detach(short ID)
|
||||||
{
|
{
|
||||||
NetworkClient val;
|
NetClient val;
|
||||||
|
|
||||||
this->data->clientListLock.lock();
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->data->clients[0].GetID() == ID)
|
if(this->data->clients[i] && this->data->clients[0]->GetID() == ID)
|
||||||
{
|
{
|
||||||
val = this->data->clients[i];
|
val = this->data->clients[i];
|
||||||
this->data->clients[i] = NetworkClient();
|
this->data->clients[i] = 0;
|
||||||
this->data->clientCount--;
|
this->data->clientCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,8 +166,11 @@ bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol)
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
this->data->clients[i].Send(&protocol);
|
if(this->data->clients[i])
|
||||||
returnValue = true;
|
{
|
||||||
|
this->data->clients[i]->Send(&protocol);
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
@ -154,9 +180,9 @@ bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->data->clients[i].GetID() == ID)
|
if(this->data->clients[i] && this->data->clients[i]->GetID() == ID)
|
||||||
{
|
{
|
||||||
this->data->clients[i].Send(&protocol);
|
this->data->clients[i]->Send(&protocol);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,9 +195,12 @@ void NetworkSession::CloseSession(bool dissconnectClients)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(dissconnectClients) this->data->clients[i].Disconnect();
|
if(this->data->clients[i])
|
||||||
else if(this->data->owner) this->data->owner->Attach(this->data->clients[i]);
|
{
|
||||||
else this->data->clients[i].Disconnect();
|
if(dissconnectClients) this->data->clients[i]->Disconnect();
|
||||||
|
else if(this->data->owner) this->data->owner->Attach(this->data->clients[i]);
|
||||||
|
else this->data->clients[i]->Disconnect(); //Idiot check, clients have to go somewhere..
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->data->clients.Clear();
|
this->data->clients.Clear();
|
||||||
|
@ -180,5 +209,23 @@ void NetworkSession::CloseSession(bool dissconnectClients)
|
||||||
this->data->clientListLock.unlock();
|
this->data->clientListLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkSession::SetOwner(NetworkSession* owner)
|
||||||
|
{
|
||||||
|
this->data->owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NetworkSession::GetClientCount() const
|
||||||
|
{
|
||||||
|
int c = 0;
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i]) c++;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSession::ClientConnectedEvent(NetClient client)
|
||||||
|
{
|
||||||
|
this->Attach(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,13 @@
|
||||||
#include "NetworkAPI_Preprocessor.h"
|
#include "NetworkAPI_Preprocessor.h"
|
||||||
#include "NetworkServerEventStruct.h"
|
#include "NetworkServerEventStruct.h"
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Network
|
namespace Network
|
||||||
{
|
{
|
||||||
|
typedef Utility::DynamicMemory::SmartPointer<NetworkClient> NetClient;
|
||||||
class NET_API_EXPORT NetworkSession
|
class NET_API_EXPORT NetworkSession
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -30,49 +32,60 @@ namespace Oyster
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool Attach(NetworkClient client);
|
virtual bool Attach(NetClient client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detaches all clients and sends them to owner.
|
||||||
|
* If no owner is set the clients is disconnected.
|
||||||
|
*/
|
||||||
|
virtual void Detach();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NetworkClient Detach(const NetworkClient& client);
|
virtual NetClient Detach(const NetworkClient* client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NetworkClient Detach(short ID);
|
virtual NetClient Detach(short ID);
|
||||||
|
|
||||||
/** Send a message to all clients in this session
|
/** Send a message to all clients in this session
|
||||||
* @param message The message
|
* @param message The message
|
||||||
*/
|
*/
|
||||||
bool Send(Oyster::Network::CustomNetProtocol& message);
|
virtual bool Send(Oyster::Network::CustomNetProtocol& message);
|
||||||
|
|
||||||
/** Send a message to a specific client in this session
|
/** Send a message to a specific client in this session
|
||||||
* @param message The message
|
* @param message The message
|
||||||
*/
|
*/
|
||||||
bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
|
virtual bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void CloseSession( bool dissconnectClients = false );
|
virtual void CloseSession( bool dissconnectClients = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the owner that clients will be returned to.
|
* Set the owner that clients will be returned to.
|
||||||
* @param owner If owner is NULL, clients will be disconnected when session is over.
|
* @param owner If owner is NULL, clients will be disconnected when session is over.
|
||||||
*/
|
*/
|
||||||
void SetOwner(NetworkSession* owner);
|
virtual void SetOwner(NetworkSession* owner);
|
||||||
|
|
||||||
|
/** Get the number of clients active in this session
|
||||||
|
* @return The client count
|
||||||
|
*/
|
||||||
|
int GetClientCount() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void ClientConnectedEvent(NetClient client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual void ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e) = 0;
|
virtual void ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual void ClientConnectedEvent(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e) = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateSessionData;
|
struct PrivateSessionData;
|
||||||
PrivateSessionData* data;
|
PrivateSessionData* data;
|
||||||
|
|
|
@ -18,6 +18,7 @@ using namespace std;
|
||||||
struct MyCastingStruct
|
struct MyCastingStruct
|
||||||
{
|
{
|
||||||
std::map<int, NetAttributeContainer> attributes;
|
std::map<int, NetAttributeContainer> attributes;
|
||||||
|
Utility::DynamicMemory::ReferenceCount *c;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Check if the package has been packed correctly.
|
// TODO: Check if the package has been packed correctly.
|
||||||
|
|
|
@ -53,6 +53,8 @@ int Connection::Connect(int socket, bool blocking)
|
||||||
|
|
||||||
int Connection::Connect(unsigned short port , const char serverName[], bool blocking)
|
int Connection::Connect(unsigned short port , const char serverName[], bool blocking)
|
||||||
{
|
{
|
||||||
|
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
||||||
|
|
||||||
struct hostent *hostEnt;
|
struct hostent *hostEnt;
|
||||||
if((hostEnt = gethostbyname(serverName)) == NULL)
|
if((hostEnt = gethostbyname(serverName)) == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#ifndef NETWORK_SERVER_ILISTENER_H
|
|
||||||
#define NETWORK_SERVER_ILISTENER_H
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
|
||||||
// Created by Pontus Fransson 2013 //
|
|
||||||
/////////////////////////////////////
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Network
|
|
||||||
{
|
|
||||||
namespace Server
|
|
||||||
{
|
|
||||||
class IListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IListener() {}
|
|
||||||
virtual bool Init(unsigned int port) = 0;
|
|
||||||
virtual int Accept() = 0;
|
|
||||||
virtual void Shutdown() = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Listener.h"
|
#include "Listener.h"
|
||||||
|
|
||||||
using namespace Oyster::Network::Server;
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
Listener::Listener()
|
Listener::Listener()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
// Created by Pontus Fransson 2013 //
|
// Created by Pontus Fransson 2013 //
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
#include "IListener.h"
|
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "IPostBox.h"
|
#include "IPostBox.h"
|
||||||
#include "../../Misc/Thread/OysterThread.h"
|
#include "../../Misc/Thread/OysterThread.h"
|
||||||
|
@ -17,45 +16,43 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Network
|
namespace Network
|
||||||
{
|
{
|
||||||
namespace Server
|
class Listener : public ::Oyster::Thread::IThreadObject
|
||||||
{
|
{
|
||||||
class Listener : public IListener, public ::Oyster::Thread::IThreadObject
|
public:
|
||||||
{
|
Listener();
|
||||||
public:
|
Listener(Oyster::Network::IPostBox<int>* postBox);
|
||||||
Listener();
|
~Listener();
|
||||||
Listener(Oyster::Network::IPostBox<int>* postBox);
|
|
||||||
~Listener();
|
|
||||||
|
|
||||||
bool Init(unsigned int port) override;
|
bool Init(unsigned int port);
|
||||||
bool Init(unsigned int port, bool start);
|
bool Init(unsigned int port, bool start);
|
||||||
bool Start();
|
bool Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void SetPostBox(IPostBox<int>* postBox);
|
void SetPostBox(IPostBox<int>* postBox);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//Thread functions
|
//Thread functions
|
||||||
bool DoWork();
|
bool DoWork();
|
||||||
void ThreadEntry();
|
void ThreadEntry();
|
||||||
void ThreadExit();
|
void ThreadExit();
|
||||||
|
|
||||||
//Function that runs in the thread.
|
//Function that runs in the thread.
|
||||||
int Accept();
|
int Accept();
|
||||||
void StopListen();
|
void StopListen();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::Oyster::Network::Connection* connection;
|
::Oyster::Network::Connection* connection;
|
||||||
|
|
||||||
::Oyster::Thread::OysterThread thread;
|
::Oyster::Thread::OysterThread thread;
|
||||||
OysterMutex mutex;
|
OysterMutex mutex;
|
||||||
std::mutex stdMutex;
|
std::mutex stdMutex;
|
||||||
|
|
||||||
|
IPostBox<int>* postBox;
|
||||||
|
std::atomic<bool> isListening;
|
||||||
|
int port;
|
||||||
|
};
|
||||||
|
|
||||||
IPostBox<int>* postBox;
|
|
||||||
std::atomic<bool> isListening;
|
|
||||||
int port;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Connection.h" />
|
<ClInclude Include="Connection.h" />
|
||||||
<ClInclude Include="IConnection.h" />
|
<ClInclude Include="IConnection.h" />
|
||||||
<ClInclude Include="IListener.h" />
|
|
||||||
<ClInclude Include="IPostBox.h" />
|
<ClInclude Include="IPostBox.h" />
|
||||||
<ClInclude Include="Listener.h" />
|
<ClInclude Include="Listener.h" />
|
||||||
<ClInclude Include="Messages\MessageHeader.h" />
|
<ClInclude Include="Messages\MessageHeader.h" />
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Connection.h" />
|
<ClInclude Include="Connection.h" />
|
||||||
<ClInclude Include="IConnection.h" />
|
<ClInclude Include="IConnection.h" />
|
||||||
<ClInclude Include="IListener.h" />
|
|
||||||
<ClInclude Include="IPostBox.h" />
|
<ClInclude Include="IPostBox.h" />
|
||||||
<ClInclude Include="Listener.h" />
|
<ClInclude Include="Listener.h" />
|
||||||
<ClInclude Include="Messages\MessageHeader.h" />
|
<ClInclude Include="Messages\MessageHeader.h" />
|
||||||
|
|
|
@ -132,13 +132,14 @@ void Oyster::Graphics::Loading::UnloadDAN(void* data)
|
||||||
delete info;
|
delete info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wchar_t* charToWChar(const char* text)
|
static std::wstring charToWChar(const char* text)
|
||||||
{
|
{
|
||||||
// Convert to a wchar_t*
|
// Convert to a wchar_t*
|
||||||
size_t origsize = strlen(text) + 1;
|
size_t origsize = strlen(text) + 1;
|
||||||
size_t convertedChars = 0;
|
size_t convertedChars = 0;
|
||||||
wchar_t* wcstring = new wchar_t[origsize];
|
//wchar_t* wcstring = new wchar_t[origsize];
|
||||||
mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE);
|
std::wstring wcstring; wcstring.resize(origsize);
|
||||||
|
mbstowcs_s(&convertedChars, &wcstring[0], origsize, text, _TRUNCATE);
|
||||||
return wcstring;
|
return wcstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resour
|
||||||
buffer = new char[4];
|
buffer = new char[4];
|
||||||
danFile.read(buffer, 4);
|
danFile.read(buffer, 4);
|
||||||
memcpy(&headerType, buffer, 4);
|
memcpy(&headerType, buffer, 4);
|
||||||
//delete[] buffer; // ( note: may crash here.)
|
delete[] buffer; // ( note: may crash here.)
|
||||||
|
|
||||||
// handle header type
|
// handle header type
|
||||||
switch ((HeaderType)headerType)
|
switch ((HeaderType)headerType)
|
||||||
|
@ -276,11 +277,14 @@ void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resour
|
||||||
delete[] buffer; // ( note: may crash here.)
|
delete[] buffer; // ( note: may crash here.)
|
||||||
|
|
||||||
//
|
//
|
||||||
ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.diffuseMapPath), Oyster::Graphics::Loading::LoadTexture);
|
ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.diffuseMapPath).c_str(), Oyster::Graphics::Loading::LoadTexture);
|
||||||
ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.normalMapPath), Oyster::Graphics::Loading::LoadTexture);
|
ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.normalMapPath).c_str(), Oyster::Graphics::Loading::LoadTexture);
|
||||||
modelInfo->Material.push_back(diffuseMap);
|
modelInfo->Material.push_back(diffuseMap);
|
||||||
modelInfo->Material.push_back(normalMap);
|
modelInfo->Material.push_back(normalMap);
|
||||||
|
|
||||||
|
delete materialHeader.normalMapPath;
|
||||||
|
delete materialHeader.diffuseMapPath;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// skeleton header
|
// skeleton header
|
||||||
|
@ -298,6 +302,7 @@ void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// close file
|
// close file
|
||||||
danFile.close();
|
danFile.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue