-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further refactoring work for multiple game support.
- Loading branch information
1 parent
6f029a6
commit 95712ff
Showing
148 changed files
with
1,128 additions
and
218,504 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Dark Souls 3 - Open Server | ||
* Copyright (C) 2021 Tim Leonard | ||
* | ||
* This program is free software; licensed under the MIT license. | ||
* You should have received a copy of the license along with this program. | ||
* If not, see <https://opensource.org/licenses/MIT>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
// The version of protobuf we have to use to support DS3 doesn't generate | ||
// code that compiles without warnings under x64 (lots of size_t truncation). | ||
// To keep things a bit cleaner we import all the files through this header and cpp. | ||
#pragma warning(disable: 4267 4244 4018) | ||
|
||
#include "Server.DarkSouls2/Protobuf/Generated/DS2_Frpg2PlayerData.pb.h" | ||
#include "Server.DarkSouls2/Protobuf/Generated/DS2_Frpg2RequestMessage.pb.h" | ||
|
||
#include "Server/Protobuf/SharedProtobufs.h" | ||
|
||
#pragma warning(default: 4267 4244 4018) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Dark Souls 3 - Open Server | ||
* Copyright (C) 2021 Tim Leonard | ||
* | ||
* This program is free software; licensed under the MIT license. | ||
* You should have received a copy of the license along with this program. | ||
* If not, see <https://opensource.org/licenses/MIT>. | ||
*/ | ||
|
||
#include "Server/DS2_Game.h" | ||
#include "Protobuf/DS2_Protobufs.h" | ||
#include "Server/Streams/DarkSouls2/DS2_Frpg2ReliableUdpMessage.h" | ||
#include "Server/GameService/DarkSouls2/DS2_PlayerState.h" | ||
|
||
bool DS2_Game::Protobuf_To_ReliableUdpMessageType(google::protobuf::MessageLite* Message, Frpg2ReliableUdpMessageType& Output) | ||
{ | ||
#define DEFINE_REQUEST_RESPONSE(OpCode, Type, ProtobufClass, ResponseProtobufClass) \ | ||
if (dynamic_cast<DS2_Frpg2RequestMessage::ProtobufClass*>(Message) != nullptr) \ | ||
{ \ | ||
Output = (Frpg2ReliableUdpMessageType)(int)DS2_Frpg2ReliableUdpMessageType::Type; \ | ||
return true; \ | ||
} | ||
#define DEFINE_MESSAGE(OpCode, Type, ProtobufClass) \ | ||
if (dynamic_cast<DS2_Frpg2RequestMessage::ProtobufClass*>(Message) != nullptr) \ | ||
{ \ | ||
Output = (Frpg2ReliableUdpMessageType)(int)DS2_Frpg2ReliableUdpMessageType::Type; \ | ||
return true; \ | ||
} | ||
#define DEFINE_PUSH_MESSAGE(OpCode, Type, ProtobufClass) \ | ||
if (dynamic_cast<DS2_Frpg2RequestMessage::ProtobufClass*>(Message) != nullptr) \ | ||
{ \ | ||
Output = Frpg2ReliableUdpMessageType::Push; /* Not using push */ \ | ||
return true; \ | ||
} | ||
#include "Server.DarkSouls2/Server/Streams/DarkSouls2/DS2_Frpg2ReliableUdpMessageTypes.inc" | ||
#undef DEFINE_PUSH_MESSAGE | ||
#undef DEFINE_MESSAGE | ||
#undef DEFINE_REQUEST_RESPONSE | ||
|
||
return false; | ||
} | ||
|
||
bool DS2_Game::ReliableUdpMessageType_To_Protobuf(Frpg2ReliableUdpMessageType InType, bool IsResponse, std::shared_ptr<google::protobuf::MessageLite>& Output) | ||
{ | ||
#define DEFINE_REQUEST_RESPONSE(OpCode, Type, ProtobufClass, ResponseProtobufClass) \ | ||
if ((int)InType == (int)DS2_Frpg2ReliableUdpMessageType::Type) \ | ||
{ \ | ||
if (IsResponse) \ | ||
{ \ | ||
Output = std::make_shared<DS2_Frpg2RequestMessage::ResponseProtobufClass>(); \ | ||
} \ | ||
else \ | ||
{ \ | ||
Output = std::make_shared<DS2_Frpg2RequestMessage::ProtobufClass>(); \ | ||
} \ | ||
return true; \ | ||
} | ||
#define DEFINE_MESSAGE(OpCode, Type, ProtobufClass) \ | ||
if ((int)InType == (int)DS2_Frpg2ReliableUdpMessageType::Type) \ | ||
{ \ | ||
if (IsResponse) \ | ||
{ \ | ||
return false; \ | ||
} \ | ||
else \ | ||
{ \ | ||
Output = std::make_shared<DS2_Frpg2RequestMessage::ProtobufClass>(); \ | ||
return true; \ | ||
} \ | ||
} | ||
#define DEFINE_PUSH_MESSAGE(OpCode, Type, ProtobufClass) /* Not supported on server, server only sends these */ | ||
#include "Server.DarkSouls2/Server/Streams/DarkSouls2/DS2_Frpg2ReliableUdpMessageTypes.inc" | ||
#undef DEFINE_PUSH_MESSAGE | ||
#undef DEFINE_MESSAGE | ||
#undef DEFINE_REQUEST_RESPONSE | ||
|
||
return false; | ||
} | ||
|
||
bool DS2_Game::ReliableUdpMessageType_Expects_Response(Frpg2ReliableUdpMessageType InType) | ||
{ | ||
if ((int)InType == (int)DS2_Frpg2ReliableUdpMessageType::Push) | ||
{ | ||
return false; | ||
} | ||
|
||
#define DEFINE_REQUEST_RESPONSE(OpCode, Type, ProtobufClass, ResponseProtobufClass) \ | ||
if ((int)InType == (int)DS2_Frpg2ReliableUdpMessageType::Type) \ | ||
{ \ | ||
return true; \ | ||
} | ||
#define DEFINE_MESSAGE(OpCode, Type, ProtobufClass) \ | ||
if ((int)InType == (int)DS2_Frpg2ReliableUdpMessageType::Type) \ | ||
{ \ | ||
return false; \ | ||
} | ||
#define DEFINE_PUSH_MESSAGE(OpCode, Type, ProtobufClass) /* Not required, gets caught by Push test above */ | ||
#include "Server.DarkSouls2/Server/Streams/DarkSouls2/DS2_Frpg2ReliableUdpMessageTypes.inc" | ||
#undef DEFINE_PUSH_MESSAGE | ||
#undef DEFINE_MESSAGE | ||
#undef DEFINE_REQUEST_RESPONSE | ||
|
||
return false; | ||
} | ||
|
||
std::string DS2_Game::GetBossDiscordThumbnailUrl(uint32_t BossId) | ||
{ | ||
// TODO | ||
|
||
return ""; | ||
} | ||
|
||
void DS2_Game::RegisterGameManagers(GameService& Service) | ||
{ | ||
// TODO | ||
} | ||
|
||
std::unique_ptr<PlayerState> DS2_Game::CreatePlayerState() | ||
{ | ||
return std::make_unique<DS2_PlayerState>(); | ||
} | ||
|
||
std::string DS2_Game::GetAreaName(uint32_t AreaId) | ||
{ | ||
// TODO | ||
|
||
return ""; | ||
} | ||
|
||
void DS2_Game::GetStatistics(GameService& Service, std::unordered_map<std::string, std::string>& Stats) | ||
{ | ||
// TODO | ||
} | ||
|
||
void DS2_Game::SendManagementMessage(Frpg2ReliableUdpMessageStream& stream, const std::string& TextMessage) | ||
{ | ||
// TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Dark Souls 3 - Open Server | ||
* Copyright (C) 2021 Tim Leonard | ||
* | ||
* This program is free software; licensed under the MIT license. | ||
* You should have received a copy of the license along with this program. | ||
* If not, see <https://opensource.org/licenses/MIT>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Server/Game.h" | ||
|
||
class DS2_Game : public Game | ||
{ | ||
public: | ||
|
||
virtual bool Protobuf_To_ReliableUdpMessageType(google::protobuf::MessageLite* Message, Frpg2ReliableUdpMessageType& Output) override; | ||
virtual bool ReliableUdpMessageType_To_Protobuf(Frpg2ReliableUdpMessageType Type, bool IsResponse, std::shared_ptr<google::protobuf::MessageLite>& Output) override; | ||
virtual bool ReliableUdpMessageType_Expects_Response(Frpg2ReliableUdpMessageType Type) override; | ||
|
||
virtual void RegisterGameManagers(GameService& Service) override; | ||
virtual std::unique_ptr<PlayerState> CreatePlayerState() override; | ||
|
||
virtual std::string GetAreaName(uint32_t AreaId) override; | ||
|
||
virtual std::string GetBossDiscordThumbnailUrl(uint32_t BossId) override; | ||
|
||
virtual void GetStatistics(GameService& Service, std::unordered_map<std::string, std::string>& Stats) override; | ||
|
||
virtual void SendManagementMessage(Frpg2ReliableUdpMessageStream& stream, const std::string& TextMessage) override; | ||
|
||
}; |
69 changes: 69 additions & 0 deletions
69
Source/Server.DarkSouls2/Server/GameService/DarkSouls2/DS2_PlayerState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Dark Souls 3 - Open Server | ||
* Copyright (C) 2021 Tim Leonard | ||
* | ||
* This program is free software; licensed under the MIT license. | ||
* You should have received a copy of the license along with this program. | ||
* If not, see <https://opensource.org/licenses/MIT>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "Protobuf/DS2_Protobufs.h" | ||
|
||
#include "Server/GameService/PlayerState.h" | ||
|
||
struct DS2_PlayerState : public PlayerState | ||
{ | ||
public: | ||
|
||
virtual uint32_t GetCurrentAreaId() override | ||
{ | ||
return 0; | ||
} | ||
|
||
virtual bool IsInGame() override | ||
{ | ||
return false; | ||
} | ||
|
||
virtual size_t GetSoulCount() override | ||
{ | ||
return 0; | ||
} | ||
|
||
virtual size_t GetSoulMemory() override | ||
{ | ||
return 0; | ||
} | ||
|
||
virtual size_t GetDeathCount() override | ||
{ | ||
return 0; | ||
} | ||
|
||
virtual size_t GetMultiplayerSessionCount() override | ||
{ | ||
return 0; | ||
} | ||
|
||
virtual double GetPlayTime() override | ||
{ | ||
return 0.0; | ||
} | ||
|
||
virtual std::string GetConvenantStatusDescription() override | ||
{ | ||
return ""; | ||
} | ||
|
||
virtual std::string GetStatusDescription() override | ||
{ | ||
return ""; | ||
} | ||
|
||
}; | ||
|
||
#undef DEFINE_FIELD |
32 changes: 32 additions & 0 deletions
32
Source/Server.DarkSouls2/Server/Streams/DarkSouls2/DS2_Frpg2ReliableUdpMessage.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Dark Souls 3 - Open Server | ||
* Copyright (C) 2021 Tim Leonard | ||
* | ||
* This program is free software; licensed under the MIT license. | ||
* You should have received a copy of the license along with this program. | ||
* If not, see <https://opensource.org/licenses/MIT>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Shared/Core/Utils/Endian.h" | ||
#include "Shared/Game/GameType.h" | ||
|
||
#include <vector> | ||
#include <memory> | ||
|
||
#include "Protobuf/SharedProtobufs.h" | ||
|
||
enum class DS2_Frpg2ReliableUdpMessageType : int | ||
{ | ||
Reply = 0x0, | ||
Push = 0x0320, | ||
|
||
#define DEFINE_REQUEST_RESPONSE(OpCode, Type, ProtobufClass, ResponseProtobufClass) Type = OpCode, | ||
#define DEFINE_MESSAGE(OpCode, Type, ProtobufClass) Type = OpCode, | ||
#define DEFINE_PUSH_MESSAGE(OpCode, Type, ProtobufClass) /* Do Nothing */ | ||
#include "Server.DarkSouls2/Server/Streams/DarkSouls2/DS2_Frpg2ReliableUdpMessageTypes.inc" | ||
#undef DEFINE_PUSH_MESSAGE | ||
#undef DEFINE_MESSAGE | ||
#undef DEFINE_REQUEST_RESPONSE | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.