Skip to content

Commit

Permalink
[SRV] refact(atmos, world): overhaul atmos, make it world's subsystem
Browse files Browse the repository at this point in the history
Base commit for new atmos locales logic, which supports z-levels, and produce more accurate locales. Also locale is mostly prepared for moving to separate thread. For this purpose subsystems are introduced.

closes #15
  • Loading branch information
Insineer committed Oct 30, 2019
1 parent ad0d11f commit dec6769
Show file tree
Hide file tree
Showing 34 changed files with 598 additions and 492 deletions.
9 changes: 9 additions & 0 deletions OSS13 Server/Include/World/ISubsystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <chrono>

#include <Shared/IFaces/IFace.h>

struct ISubsystem : IFace {
virtual void Update(std::chrono::microseconds timeElapsed) = 0;
};
27 changes: 27 additions & 0 deletions OSS13 Server/Include/World/ITile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <chrono>
#include <list>

#include <Shared/IFaces/IFace.h>
#include <Shared/Geometry/DirectionSet.h>

class Object;
class Map;

struct ITile : public IFace {
virtual void Update(std::chrono::microseconds timeElapsed) = 0;

virtual bool MoveTo(Object *) = 0;
virtual void PlaceTo(Object *) = 0;
virtual bool RemoveObject(Object *obj) = 0;

virtual const std::list<Object *> &Content() const = 0;

virtual uf::vec3i GetPos() const = 0;
virtual ITile *StepTo(uf::Direction direction) const = 0;
virtual Map *GetMap() const = 0;

virtual bool IsDense(uf::DirectionSet directions) const = 0;
virtual Object *GetDenseObject(uf::DirectionSet directions) const = 0;
};
22 changes: 22 additions & 0 deletions OSS13 Server/Include/World/Subsystems/IAtmos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <Shared/IFaces/IHasRepeatableID.h>
#include <Shared/Geometry/DirectionSet.h>

#include <World/ISubsystem.h>

namespace subsystem {

namespace atmos {

struct ILocale : public IFace, public IHasRepeatableID {

};

} // namespace atmos

struct IAtmos : public ISubsystem {

};

} // namespace subsystem
20 changes: 20 additions & 0 deletions OSS13 Server/Include/World/Subsystems/IAtmosTile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <World/ITile.h>
#include <World/Subsystems/IAtmos.h>

namespace subsystem {
namespace atmos {

struct IAtmosTile : public ITile {
virtual bool SynchronizeAtmos() = 0;

virtual ILocale *GetLocale() = 0;
virtual void SetLocale(ILocale *locale) = 0;

virtual uf::DirectionSetFractional GetAirtightness() const = 0;
virtual float GetAirtightnessTo(uf::Direction direction) const = 0;
};

} // namespace atmos
} // namespace subsystem
22 changes: 13 additions & 9 deletions OSS13 Server/OSS13 Server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@
<ClCompile Include="Sources\ScriptEngine\ScriptEngine.cpp" />
<ClCompile Include="Sources\Server.cpp" />
<ClCompile Include="Sources\VerbsHolder.cpp" />
<ClCompile Include="Sources\World\Atmos\Atmos.cpp" />
<ClCompile Include="Sources\World\Atmos\AtmosCameraOverlay.cpp" />
<ClCompile Include="Sources\World\Atmos\AtmosOverlayWindowSink.cpp" />
<ClCompile Include="Sources\World\Atmos\Locale.cpp" />
<ClCompile Include="Sources\World\Subsystems\Atmos\Atmos.cpp" />
<ClCompile Include="Sources\World\Subsystems\Atmos\AtmosCameraOverlay.cpp" />
<ClCompile Include="Sources\World\Subsystems\Atmos\AtmosOverlayWindowSink.cpp" />
<ClCompile Include="Sources\World\Camera\Camera.cpp" />
<ClCompile Include="Sources\World\Map.cpp" />
<ClCompile Include="Sources\World\Objects\Component.cpp" />
Expand All @@ -159,6 +158,7 @@
<ClCompile Include="Sources\World\Objects\CreateObject.cpp" />
<ClCompile Include="Sources\World\Objects\Object.cpp" />
<ClCompile Include="Sources\World\Objects\ObjectHolder.cpp" />
<ClCompile Include="Sources\World\Subsystems\Atmos\AtmosTile.cpp" />
<ClCompile Include="Sources\World\Tile.cpp" />
<ClCompile Include="Sources\World\World.cpp" />
</ItemGroup>
Expand All @@ -167,6 +167,10 @@
<ClInclude Include="Include\IScriptEngine.h" />
<ClInclude Include="Include\IServer.h" />
<ClInclude Include="Include\IVerbsHolder.h" />
<ClInclude Include="Include\World\ISubsystem.h" />
<ClInclude Include="Include\World\ITile.h" />
<ClInclude Include="Include\World\Subsystems\IAtmosTile.h" />
<ClInclude Include="Include\World\Subsystems\IAtmos.h" />
<ClInclude Include="Sources\Chat.h" />
<ClInclude Include="Sources\ClientUI\WelcomeWindowSink.h" />
<ClInclude Include="Sources\Database\UsersDB.hpp" />
Expand All @@ -186,11 +190,11 @@
<ClInclude Include="Sources\ScriptEngine\Trampoline\PyObject.h" />
<ClInclude Include="Sources\Server.hpp" />
<ClInclude Include="Sources\VerbsHolder.h" />
<ClInclude Include="Sources\World\Atmos\Atmos.hpp" />
<ClInclude Include="Sources\World\Atmos\AtmosCameraOverlay.h" />
<ClInclude Include="Sources\World\Atmos\AtmosOverlayWindowSink.h" />
<ClInclude Include="Sources\World\Atmos\Gases.hpp" />
<ClInclude Include="Sources\World\Atmos\Locale.hpp" />
<ClInclude Include="Sources\World\Subsystems\Atmos\Atmos.h" />
<ClInclude Include="Sources\World\Subsystems\Atmos\AtmosCameraOverlay.h" />
<ClInclude Include="Sources\World\Subsystems\Atmos\AtmosOverlayWindowSink.h" />
<ClInclude Include="Sources\World\Subsystems\Atmos\AtmosTile.h" />
<ClInclude Include="Sources\World\Subsystems\Atmos\Gases.hpp" />
<ClInclude Include="Sources\World\Block.hpp" />
<ClInclude Include="Sources\World\Camera\Camera.hpp" />
<ClInclude Include="Sources\World\Camera\ICameraOverlay.h" />
Expand Down
66 changes: 39 additions & 27 deletions OSS13 Server/OSS13 Server.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
<ClCompile Include="Sources\Resources\ResourceManager.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Atmos\Atmos.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Atmos\Locale.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Objects\Component.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
Expand Down Expand Up @@ -57,18 +51,12 @@
<ClCompile Include="Sources\World\Camera\Camera.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Atmos\AtmosCameraOverlay.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\ClientUI\WelcomeWindowSink.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\ClientUI\WindowSink.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Atmos\AtmosOverlayWindowSink.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\Game.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
Expand Down Expand Up @@ -105,6 +93,18 @@
<ClCompile Include="Sources\Player\Player.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Subsystems\Atmos\AtmosCameraOverlay.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Subsystems\Atmos\AtmosOverlayWindowSink.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Subsystems\Atmos\Atmos.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Sources\World\Subsystems\Atmos\AtmosTile.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Sources\Database\UsersDB.hpp">
Expand All @@ -122,15 +122,6 @@
<ClInclude Include="Sources\Resources\ResourceManager.hpp">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Atmos\Atmos.hpp">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Atmos\Gases.hpp">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Atmos\Locale.hpp">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Objects\Component.hpp">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
Expand Down Expand Up @@ -170,9 +161,6 @@
<ClInclude Include="Sources\World\Camera\ICameraOverlay.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Atmos\AtmosCameraOverlay.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\ClientUI\WelcomeWindowSink.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
Expand All @@ -182,9 +170,6 @@
<ClInclude Include="Sources\VerbsHolder.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Atmos\AtmosOverlayWindowSink.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\Game.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
Expand Down Expand Up @@ -230,5 +215,32 @@
<ClInclude Include="Sources\Player\Player.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Include\World\Subsystems\IAtmos.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Subsystems\Atmos\AtmosCameraOverlay.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Subsystems\Atmos\AtmosOverlayWindowSink.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Subsystems\Atmos\Gases.hpp">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Subsystems\Atmos\Atmos.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Include\World\ISubsystem.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Sources\World\Subsystems\Atmos\AtmosTile.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Include\World\ITile.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="Include\World\Subsystems\IAtmosTile.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
</ItemGroup>
</Project>
7 changes: 4 additions & 3 deletions OSS13 Server/Sources/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ Game::Game() :

void Game::gameProcess() {
scriptEngine = std::make_unique<ScriptEngine>();
world.reset(new World());
scriptEngine->FillMap(world->GetMap());
world->CreateTestItems();
world = std::make_unique<World>();

world->Initialize();

auto lastTime = std::chrono::steady_clock::now();
while (active) {
auto curTime = std::chrono::steady_clock::now();
Expand Down
7 changes: 6 additions & 1 deletion OSS13 Server/Sources/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <World/Map.hpp>
#include <World/Objects/Object.hpp>
#include <World/Objects/Control.hpp>
#include <World/Subsystems/Atmos/AtmosOverlayWindowSink.h>
#include <ClientUI/WelcomeWindowSink.h>

#include "PlayerCommandsProcessor.h"
Expand All @@ -24,6 +25,7 @@ Player::Player(std::string ckey) :
{
control = nullptr;
AddVerb("spawn", &Player::OpenSpawnWindow);
AddVerb("toggleoverlay", &Player::ToggleAtmosOverlayVerb);
}

void Player::SetConnection(sptr<Connection> &connection) {
Expand Down Expand Up @@ -52,7 +54,6 @@ void Player::Update(std::chrono::microseconds timeElapsed) {

SetControl(GGame->GetStartControl(this));
verbsHolders["player"] = this;
verbsHolders["atmos"] = GGame->GetWorld()->GetMap()->GetAtmos();
verbsHolders["creature"] = GetControl()->GetOwner();
}

Expand All @@ -69,6 +70,10 @@ void Player::OpenSpawnWindow() {
AddCommandToClient(new network::protocol::server::OpenSpawnWindowCommand());
}

void Player::ToggleAtmosOverlayVerb() {
OpenWindow<AtmosOverlayWindowSink>();
}

void Player::Suspend() {
camera->Suspend();
}
Expand Down
2 changes: 2 additions & 0 deletions OSS13 Server/Sources/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ friend PlayerCommandsProcessor;
}
void OpenSpawnWindow();

void ToggleAtmosOverlayVerb();

const std::string &GetCKey() const { return ckey; }

void Suspend();
Expand Down
2 changes: 2 additions & 0 deletions OSS13 Server/Sources/ScriptEngine/Module/GeometryModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ PYBIND11_EMBEDDED_MODULE(Engine_Geometry, m) {
.value("NORTH_WEST", uf::Direction::NORTH_WEST)
.value("NORTH_EAST", uf::Direction::NORTH_EAST)
.value("SOUTH_EAST", uf::Direction::SOUTH_EAST)
.value("TOP", uf::Direction::TOP)
.value("BOTTOM", uf::Direction::BOTTOM)
.value("CENTER", uf::Direction::CENTER);

m.def("eDirectionToVect", &uf::DirectionToVect);
Expand Down
5 changes: 1 addition & 4 deletions OSS13 Server/Sources/ScriptEngine/Module/WorldModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace se = script_engine;
PYBIND11_EMBEDDED_MODULE(Engine_World, m) {
py::class_<World>(m, "eWorld")
.def("GetObjectById", &World::GetObject)
.def("GetMap", &World::GetMap);
.def("GetMap", &World::GetMap, py::return_value_policy::reference);

py::class_<Map>(m, "eMap")
.def_property_readonly("size", &Map::GetSize)
Expand All @@ -35,7 +35,6 @@ PYBIND11_EMBEDDED_MODULE(Engine_World, m) {
.def_property_readonly("pos", &Tile::GetPos)
.def_property_readonly("map", &Tile::GetMap)
.def("IsDense", &Tile::IsDense)
.def("IsSpace", &Tile::IsSpace)
.def("GetDenseObject", &Tile::GetDenseObject, py::return_value_policy::reference);

m.def("eCreateObject", &CreateObject);
Expand All @@ -56,8 +55,6 @@ PYBIND11_EMBEDDED_MODULE(Engine_World, m) {
.def_property("speed", &Object::GetSpeed, &Object::SetSpeed)
.def_property("moveSpeed", &Object::GetMoveSpeed, &Object::SetMoveSpeed)
.def_property("drawAtTop", &Object::IsDrawAtTop, &Object::SetDrawAtTop)
.def_property("isFloor", &Object::IsFloor, &Object::SetIsFloor)
.def_property("isWall", &Object::IsWall, &Object::SetIsWall)
.def("AddVerb", &Object::AddVerb)
.def("Update", &Object::Update)
.def("InteractedBy", &Object::InteractedBy)
Expand Down
52 changes: 0 additions & 52 deletions OSS13 Server/Sources/World/Atmos/Atmos.cpp

This file was deleted.

Loading

0 comments on commit dec6769

Please sign in to comment.