Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Code/client/Services/Debug/DebugService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
#include <inttypes.h>
extern thread_local bool g_overrideFormId;

constexpr char kBuildTag[] = "Build: " BUILD_COMMIT " " BUILD_BRANCH " EVO\nBuilt: " __TIMESTAMP__;
#define COMPAT_STRING
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
#define COMPAT_STRING "\nCompatible with protocol version " COMPATIBLE_WITH_BUILD_COMMIT
#endif
constexpr char kBuildTag[] = "Build: " BUILD_COMMIT " " BUILD_BRANCH " EVO\nBuilt: " __TIMESTAMP__ COMPAT_STRING;

static void DrawBuildTag()
{
auto* pWindow = BSGraphics::GetMainWindow();
Expand Down
5 changes: 5 additions & 0 deletions Code/client/Services/Generic/InputService.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <TiltedOnlinePCH.h>
#include <BranchInfo.h>

#include <Services/InputService.h>
#include <Services/OverlayService.h>
Expand Down Expand Up @@ -103,7 +104,11 @@ void SetUIActive(OverlayService& aOverlay, auto apRenderer, bool aActive)
aOverlay.SetActive(aActive);

// Ensures the game is actually loaded, in case the initial event was sent too early
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
aOverlay.SetVersion(COMPATIBLE_WITH_BUILD_COMMIT);
#else
aOverlay.SetVersion(BUILD_COMMIT);
#endif
aOverlay.GetOverlayApp()->ExecuteAsync("enterGame");

apRenderer->SetCursorVisible(aActive);
Expand Down
5 changes: 5 additions & 0 deletions Code/client/Services/Generic/OverlayService.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <TiltedOnlinePCH.h>
#include <BranchInfo.h>

#include <Services/OverlayService.h>

Expand Down Expand Up @@ -217,7 +218,11 @@ void OverlayService::SetInGame(bool aInGame) noexcept

if (m_inGame)
{
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
SetVersion(COMPATIBLE_WITH_BUILD_COMMIT);
#else
SetVersion(BUILD_COMMIT);
#endif
m_pOverlay->ExecuteAsync("enterGame");
}
else
Expand Down
13 changes: 11 additions & 2 deletions Code/client/Services/Generic/TransportService.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include <BranchInfo.h>
#include <Services/TransportService.h>

#include <Events/ConnectedEvent.h>
Expand Down Expand Up @@ -112,7 +113,11 @@ void TransportService::OnConsume(const void* apData, uint32_t aSize)
void TransportService::OnConnected()
{
AuthenticationRequest request{};
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
request.Version = COMPATIBLE_WITH_BUILD_COMMIT;
#else
request.Version = BUILD_COMMIT;
#endif
request.SKSEActive = IsScriptExtenderLoaded();
request.MO2Active = GetModuleHandleW(kMO2DllName);

Expand Down Expand Up @@ -211,14 +216,18 @@ void TransportService::HandleAuthenticationResponse(const AuthenticationResponse
// error finding

TiltedPhoques::String ErrorInfo;

ErrorInfo = "{";

TiltedPhoques::String protocolVersion{BUILD_COMMIT};
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
protocolVersion = COMPATIBLE_WITH_BUILD_COMMIT;
#endif

switch (acMessage.Type)
{
case AR::kWrongVersion:
ErrorInfo += "\"error\": \"wrong_version\", \"data\": {";
ErrorInfo += fmt::format("\"expectedVersion\": \"{}\", \"version\": \"{}\"", acMessage.Version, BUILD_COMMIT);
ErrorInfo += fmt::format("\"expectedVersion\": \"{}\", \"protocolVersion\": \"{}\", \"version\": \"{}\"", acMessage.Version, protocolVersion, BUILD_COMMIT);
ErrorInfo += "}";
break;
case AR::kModsMismatch:
Expand Down
23 changes: 18 additions & 5 deletions Code/server/GameServer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <Components.h>
#include <BranchInfo.h>
#include <Components.h>
#include <GameServer.h>
#include <Packet.hpp>

Expand Down Expand Up @@ -183,6 +184,9 @@ GameServer::GameServer(Console::ConsoleRegistry& aConsole) noexcept

UpdateInfo();
spdlog::info("Server {} started on port {}", BUILD_COMMIT, GetPort());
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
spdlog::info("Server is compatible with protocol version {}", COMPATIBLE_WITH_BUILD_COMMIT);
#endif
UpdateTitle();

m_pWorld = MakeUnique<World>();
Expand Down Expand Up @@ -825,9 +829,14 @@ void GameServer::HandleAuthenticationRequest(const ConnectionId_t aConnectionId,
};
#if 1
// to make our testing life a bit easier.
if (acRequest->Version != BUILD_COMMIT)
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
const auto effectiveVersion = COMPATIBLE_WITH_BUILD_COMMIT;
#else
const auto effectiveVersion = BUILD_COMMIT;
#endif
if (acRequest->Version != effectiveVersion)
{
spdlog::info("New player {:x} '{}' tried to connect with client {} - Version mismatch", aConnectionId, remoteAddress, acRequest->Version.c_str());
spdlog::info("New player {:x} '{}' tried to connect with client protocol version {} - Version mismatch", aConnectionId, remoteAddress, acRequest->Version.c_str());
sendKick(RT::kWrongVersion);
return;
}
Expand Down Expand Up @@ -1037,8 +1046,12 @@ void GameServer::UpdateTitle() const
{
const auto name = m_info.name.empty() ? "Private server" : m_info.name;
const char* playerText = GetClientCount() <= 1 ? " player" : " players";

const auto title = fmt::format("{} - {} {} - {} Ticks - " BUILD_BRANCH "@" BUILD_COMMIT, name.c_str(), GetClientCount(), playerText, GetTickRate());
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
constexpr auto protocolVersion = ", protocol version " COMPATIBLE_WITH_BUILD_COMMIT;
#else
constexpr auto protocolVersion = "";
#endif
const auto title = fmt::format("{} - {} {} - {} Ticks - " BUILD_BRANCH "@" BUILD_COMMIT "{}", name.c_str(), GetClientCount(), playerText, GetTickRate(), protocolVersion);

#if TP_PLATFORM_WINDOWS
SetConsoleTitleA(title.c_str());
Expand Down
5 changes: 5 additions & 0 deletions Code/server/Services/ServerListService.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <BranchInfo.h>
#include <Events/PlayerJoinEvent.h>
#include <Events/PlayerLeaveEvent.h>
#include <Events/UpdateEvent.h>
Expand Down Expand Up @@ -75,7 +76,11 @@ void ServerListService::PostAnnouncement(String acName, String acDesc, String ac
uint16_t aPlayerCount, uint16_t aPlayerMaxCount, String acTagList,
bool aPublic, bool aPassword, int32 aFlags) noexcept
{
#ifdef COMPATIBLE_WITH_BUILD_COMMIT
const std::string kVersion{COMPATIBLE_WITH_BUILD_COMMIT};
#else
const std::string kVersion{BUILD_COMMIT};
#endif
const httplib::Params params{
{"name", std::string(acName.c_str(), acName.size())},
{"desc", std::string(acDesc.c_str(), acDesc.size())},
Expand Down
Loading
Loading