From 127bba64e90e8fc08587894007a6ff72e4732bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Wed, 1 Feb 2017 19:33:35 +0200 Subject: [PATCH] Refactor|Server: Initializing a map outline packet --- doomsday/apps/client/include/world/map.h | 5 ++++ .../defaultstyle.pack/colors.dei | 6 ++++ .../defaultstyle.pack/fonts.dei | 6 +++- doomsday/apps/client/src/world/base/map.cpp | 12 ++++++++ doomsday/apps/server/src/remoteuser.cpp | 28 +++++++++++-------- doomsday/apps/server/src/shelluser.cpp | 15 ++-------- .../sdk/libshell/include/de/shell/protocol.h | 2 +- 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/doomsday/apps/client/include/world/map.h b/doomsday/apps/client/include/world/map.h index e5b92e2d2b..de192f7fd3 100644 --- a/doomsday/apps/client/include/world/map.h +++ b/doomsday/apps/client/include/world/map.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -953,6 +954,10 @@ class Map : public world::BaseMap inline de::dint editablePolyobjCount() const { return editablePolyobjs().count(); } inline de::dint editableSectorCount () const { return editableSectors ().count(); } +//- Multiplayer ------------------------------------------------------------------------- + + void initMapOutlinePacket(de::shell::MapOutlinePacket &packet); + private: DENG2_PRIVATE(d) }; diff --git a/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/colors.dei b/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/colors.dei index 194a307e0a..54d669e3f5 100644 --- a/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/colors.dei +++ b/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/colors.dei @@ -118,4 +118,10 @@ home { color icon.heretic { rgb <0.4, 0.7, 0.25> } color icon.hexen { rgb <1.0, 0.25, 0.1> } color icon.other { rgb <1.0, 1.0, 1.0> } + + item.background { + color selected.inverted { + rgb $= gui.colorMix(background.rgb, altaccent.rgb, 0.333) + } + } } diff --git a/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/fonts.dei b/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/fonts.dei index 8779311f8a..42c6d59d38 100644 --- a/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/fonts.dei +++ b/doomsday/apps/client/net.dengine.client.pack/defaultstyle.pack/fonts.dei @@ -122,7 +122,11 @@ font small inherits default { editor { font plaintext inherits default {} - font hint inherits default { + font hint.default inherits default { + style: italic + weight: light + } + font hint.small inherits small { style: italic weight: light } diff --git a/doomsday/apps/client/src/world/base/map.cpp b/doomsday/apps/client/src/world/base/map.cpp index 8bc1b405e1..c930e01b99 100644 --- a/doomsday/apps/client/src/world/base/map.cpp +++ b/doomsday/apps/client/src/world/base/map.cpp @@ -4023,6 +4023,18 @@ Map::Sectors const &Map::editableSectors() const return d->editable.sectors; } +void Map::initMapOutlinePacket(shell::MapOutlinePacket &packet) +{ + forAllLines([&packet] (Line &line) + { + packet.addLine(line.from().origin().toVector2i(), + line.to ().origin().toVector2i(), + (line.front().hasSector() && line.back().hasSector()) ? + shell::MapOutlinePacket::TwoSidedLine : shell::MapOutlinePacket::OneSidedLine); + return LoopContinue; + }); +} + Map::Polyobjs const &Map::editablePolyobjs() const { if (!d->editingEnabled) diff --git a/doomsday/apps/server/src/remoteuser.cpp b/doomsday/apps/server/src/remoteuser.cpp index 6c7c54d99f..a87ea4931c 100644 --- a/doomsday/apps/server/src/remoteuser.cpp +++ b/doomsday/apps/server/src/remoteuser.cpp @@ -23,11 +23,13 @@ #include "network/net_event.h" #include "server/sv_def.h" #include "serverapp.h" +#include "world/map.h" #include #include #include #include +#include #include @@ -56,7 +58,7 @@ DENG2_PIMPL(RemoteUser) { DENG2_ASSERT(socket != 0); - QObject::connect(socket, SIGNAL(disconnected()), thisPublic, SLOT(socketDisconnected())); + QObject::connect(socket, SIGNAL(disconnected()), thisPublic, SLOT(socketDisconnected())); QObject::connect(socket, SIGNAL(messagesReady()), thisPublic, SLOT(handleIncomingPackets())); address = socket->peerAddress(); @@ -129,17 +131,21 @@ DENG2_PIMPL(RemoteUser) // Status query? if (command == "Info?") { - shell::ServerInfo const info = ServerApp::currentServerInfo(); //Sv_GetInfo(&info); - //Str_Init(&msg); - //Str_Appendf(&msg, "Info\n"); + shell::ServerInfo const info = ServerApp::currentServerInfo(); Block const msg = "Info\n" + composeJSON(info); - //Sv_InfoToString(&info, &msg); - - LOGDEV_NET_VERBOSE("Info reply:\n%s") << String::fromUtf8(msg); //Str_Text(&msg); - - self() << msg; //mRefArray(Str_Text(&msg), Str_Length(&msg)); - - //Str_Free(&msg); + LOGDEV_NET_VERBOSE("Info reply:\n%s") << String::fromUtf8(msg); + self() << msg; + } + else if (command == "MapOutline?") + { + shell::MapOutlinePacket packet; + if (ServerApp::world().hasMap()) + { + ServerApp::world().map().initMapOutlinePacket(packet); + } + Block serialized; + Writer(serialized).withHeader() << packet; + self() << Block("MapOutline\n" + serialized.compressed()); } else if (length >= 5 && command.startsWith("Shell")) { diff --git a/doomsday/apps/server/src/shelluser.cpp b/doomsday/apps/server/src/shelluser.cpp index 8c6909b021..16a694ad9b 100644 --- a/doomsday/apps/server/src/shelluser.cpp +++ b/doomsday/apps/server/src/shelluser.cpp @@ -134,18 +134,9 @@ void ShellUser::sendMapOutline() { if (!App_World().hasMap()) return; - std::unique_ptr packet(new shell::MapOutlinePacket); - - App_World().map().forAllLines ([&packet] (Line &line) - { - packet->addLine(line.from().origin().toVector2i(), - line.to ().origin().toVector2i(), - (line.front().hasSector() && line.back().hasSector()) ? - shell::MapOutlinePacket::TwoSidedLine : shell::MapOutlinePacket::OneSidedLine); - return LoopContinue; - }); - - *this << *packet; + shell::MapOutlinePacket packet; + App_World().map().initMapOutlinePacket(packet); + *this << packet; } void ShellUser::sendPlayerInfo() diff --git a/doomsday/sdk/libshell/include/de/shell/protocol.h b/doomsday/sdk/libshell/include/de/shell/protocol.h index 58ef1b8ad0..0565bf201f 100644 --- a/doomsday/sdk/libshell/include/de/shell/protocol.h +++ b/doomsday/sdk/libshell/include/de/shell/protocol.h @@ -140,7 +140,7 @@ class LIBSHELL_PUBLIC MapOutlinePacket : public Packet enum LineType { OneSidedLine = 0, - TwoSidedLine = 1 + TwoSidedLine = 1, }; struct Line {