mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-16 20:24:39 -06:00
Compare commits
15 Commits
v3.0.0
...
mybestofri
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c305af7172 | ||
|
|
0c948a8df6 | ||
|
|
6ed6efa921 | ||
|
|
dcc9e023a6 | ||
|
|
8509ec8856 | ||
|
|
18295017c1 | ||
|
|
e8f011b830 | ||
|
|
a787673baf | ||
|
|
e869c0ad03 | ||
|
|
b2af3fa9d4 | ||
|
|
2560bb00da | ||
|
|
1ae21c423f | ||
|
|
0ae9eb4a96 | ||
|
|
fced6d753a | ||
|
|
15dc5feeb5 |
@@ -1,5 +1,5 @@
|
||||
PROJECT_VERSION_MAJOR=2
|
||||
PROJECT_VERSION_MINOR=3
|
||||
PROJECT_VERSION_MAJOR=3
|
||||
PROJECT_VERSION_MINOR=0
|
||||
PROJECT_VERSION_PATCH=0
|
||||
|
||||
# Debugging
|
||||
|
||||
11
README.md
11
README.md
@@ -24,13 +24,14 @@ Darkflame Universe is a server emulator and does not distribute any LEGO® Unive
|
||||
Warning: WSL version 1 does NOT support using sqlite as a database due to how it handles filesystem synchronization.
|
||||
You must use Version 2 if you must run the server under WSL. Not doing so will result in save data loss.
|
||||
* Single player installs now no longer require building the server from source or installing development tools.
|
||||
* Download the [latest release](https://github.com/DarkflameUniverse/DarkflameServer/releases) and extract the files into a folder inside your client.
|
||||
* You should be able to see the folder with the server executables in the same folder as `legouniverse.exe`.
|
||||
* Open `sharedconfig.ini` and find the line that says `client_location` and put `..` after it so the line reads `client_location=..`.
|
||||
* Download the [latest windows release](https://github.com/DarkflameUniverse/DarkflameServer/releases) (or whichever release you need) and extract the files into a folder inside your client. Note that this setup is expecting that when double clicking the folder that you put in the same folder as `legouniverse.exe`, the file `MasterServer.exe` is in there.
|
||||
* You should be able to see the folder with the server files in the same folder as `legouniverse.exe`.
|
||||
* Go into the server files folder and open `sharedconfig.ini`. Find the line that says `client_location` and put `..` after it so the line reads `client_location=..`.
|
||||
* To run the server, double-click `MasterServer.exe`.
|
||||
* You will be asked to create an account the first time you run the server.
|
||||
* You will be asked to create an account the first time you run the server. After you have created the account, the server will shutdown and need to be restarted.
|
||||
* To connect to the server, either delete the file `boot.cfg` which is found in your LEGO Universe client, rename the file `boot.cfg` to something else or follow the steps [here](#allowing-a-user-to-connect-to-your-server) if you wish to keep the file.
|
||||
* When shutting down the server, it is highly recommended to click the `MasterServer.exe` window and hold `ctrl` while pressing `c` to stop the server.
|
||||
* We are working on a way to make it so when you close the game, the server saves automatically alongside when you open the game, the server starts automatically.
|
||||
* We are working on a way to make it so when you close the game, the server stops automatically alongside when you open the game, the server starts automatically.
|
||||
|
||||
<font size="32">**If you are not planning on hosting a server for others, working in the codebase or wanting to use MariaDB for a database, you can stop reading here.**</font>
|
||||
|
||||
|
||||
@@ -2,16 +2,25 @@
|
||||
#include <string>
|
||||
|
||||
//For reading null-terminated strings
|
||||
std::string BinaryIO::ReadString(std::istream& instream) {
|
||||
std::string toReturn;
|
||||
char buffer;
|
||||
template<typename StringType>
|
||||
StringType ReadString(std::istream& instream) {
|
||||
StringType toReturn{};
|
||||
typename StringType::value_type buffer{};
|
||||
|
||||
BinaryIO::BinaryRead(instream, buffer);
|
||||
|
||||
while (buffer != 0x00) {
|
||||
toReturn += buffer;
|
||||
BinaryRead(instream, buffer);
|
||||
BinaryIO::BinaryRead(instream, buffer);
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
std::string BinaryIO::ReadString(std::istream& instream) {
|
||||
return ::ReadString<std::string>(instream);
|
||||
}
|
||||
|
||||
std::u8string BinaryIO::ReadU8String(std::istream& instream) {
|
||||
return ::ReadString<std::u8string>(instream);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace BinaryIO {
|
||||
|
||||
std::string ReadString(std::istream& instream);
|
||||
|
||||
std::u8string ReadU8String(std::istream& instream);
|
||||
|
||||
inline bool DoesFileExist(const std::string& name) {
|
||||
std::ifstream f(name.c_str());
|
||||
return f.good();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Diagnostics.h"
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#define _XOPEN_SOURCE
|
||||
// If we're on Win32, we'll include our minidump writer
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -60,7 +60,7 @@ LONG CALLBACK unhandled_handler(EXCEPTION_POINTERS* e) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) //&& !defined(__clang__) // backtrace is a gcc exclusive system library
|
||||
// #if defined(__linux__) //&& !defined(__clang__) // backtrace is a gcc exclusive system library
|
||||
#include <execinfo.h>
|
||||
#include <ucontext.h>
|
||||
#include <unistd.h>
|
||||
@@ -219,16 +219,16 @@ void MakeBacktrace() {
|
||||
|
||||
std::set_terminate(OnTerminate);
|
||||
}
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
void Diagnostics::Initialize() {
|
||||
#ifdef _WIN32
|
||||
SetUnhandledExceptionFilter(unhandled_handler);
|
||||
#elif defined(__linux__) //&& !defined(__clang__)
|
||||
// #ifdef _WIN32
|
||||
// SetUnhandledExceptionFilter(unhandled_handler);
|
||||
// #elif defined(__linux__) //&& !defined(__clang__)
|
||||
MakeBacktrace();
|
||||
#else
|
||||
fprintf(stderr, "Diagnostics not supported on this platform.\n");
|
||||
#endif
|
||||
// #else
|
||||
// fprintf(stderr, "Diagnostics not supported on this platform.\n");
|
||||
// #endif
|
||||
}
|
||||
|
||||
std::string Diagnostics::m_ProcessName{};
|
||||
|
||||
@@ -65,13 +65,14 @@ int64_t FdbToSqlite::Convert::ReadInt64(std::istream& cdClientBuffer) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// cdclient is encoded in latin1
|
||||
std::string FdbToSqlite::Convert::ReadString(std::istream& cdClientBuffer) {
|
||||
int32_t prevPosition = SeekPointer(cdClientBuffer);
|
||||
|
||||
auto readString = BinaryIO::ReadString(cdClientBuffer);
|
||||
const auto readString = BinaryIO::ReadU8String(cdClientBuffer);
|
||||
|
||||
cdClientBuffer.seekg(prevPosition);
|
||||
return readString;
|
||||
return GeneralUtils::Latin1ToUTF8(readString);
|
||||
}
|
||||
|
||||
int32_t FdbToSqlite::Convert::SeekPointer(std::istream& cdClientBuffer) {
|
||||
|
||||
@@ -167,6 +167,15 @@ std::u16string GeneralUtils::ASCIIToUTF16(const std::string_view string, const s
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string GeneralUtils::Latin1ToUTF8(const std::u8string_view string, const size_t size) {
|
||||
std::string toReturn{};
|
||||
|
||||
for (const auto u : string) {
|
||||
PushUTF8CodePoint(toReturn, u);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
//! Converts a (potentially-ill-formed) UTF-16 string to UTF-8
|
||||
//! See: <http://simonsapin.github.io/wtf-8/#decoding-ill-formed-utf-16>
|
||||
std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const size_t size) {
|
||||
@@ -175,9 +184,9 @@ std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const si
|
||||
ret.reserve(newSize);
|
||||
|
||||
for (size_t i = 0; i < newSize; ++i) {
|
||||
const char16_t u = string[i];
|
||||
const auto u = string[i];
|
||||
if (IsLeadSurrogate(u) && (i + 1) < newSize) {
|
||||
const char16_t next = string[i + 1];
|
||||
const auto next = string[i + 1];
|
||||
if (IsTrailSurrogate(next)) {
|
||||
i += 1;
|
||||
const char32_t cp = 0x10000
|
||||
@@ -291,11 +300,12 @@ std::u16string GeneralUtils::ReadWString(RakNet::BitStream& inStream) {
|
||||
|
||||
std::vector<std::string> GeneralUtils::GetSqlFileNamesFromFolder(const std::string_view folder) {
|
||||
// Because we dont know how large the initial number before the first _ is we need to make it a map like so.
|
||||
std::map<uint32_t, std::string> filenames{};
|
||||
std::map<uint32_t, std::string> filenames{};
|
||||
for (const auto& t : std::filesystem::directory_iterator(folder)) {
|
||||
auto filename = t.path().filename().string();
|
||||
const auto index = std::stoi(GeneralUtils::SplitString(filename, '_').at(0));
|
||||
filenames.emplace(index, std::move(filename));
|
||||
if (t.is_directory() || t.is_symlink()) continue;
|
||||
auto filename = t.path().filename().string();
|
||||
const auto index = std::stoi(GeneralUtils::SplitString(filename, '_').at(0));
|
||||
filenames.emplace(index, std::move(filename));
|
||||
}
|
||||
|
||||
// Now sort the map by the oldest migration.
|
||||
|
||||
@@ -51,6 +51,14 @@ namespace GeneralUtils {
|
||||
bool _NextUTF8Char(std::string_view& slice, uint32_t& out);
|
||||
}
|
||||
|
||||
//! Converts a Latin1 string to a UTF-8 string
|
||||
/*!
|
||||
\param string The string to convert
|
||||
\param size A size to trim the string to. Default is SIZE_MAX (No trimming)
|
||||
\return An UTF-8 representation of the string
|
||||
*/
|
||||
std::string Latin1ToUTF8(const std::u8string_view string, const size_t size = SIZE_MAX);
|
||||
|
||||
//! Converts a UTF-16 string to a UTF-8 string
|
||||
/*!
|
||||
\param string The string to convert
|
||||
|
||||
@@ -58,6 +58,7 @@ void Logger::vLog(const char* format, va_list args) {
|
||||
for (const auto& writer : m_Writers) {
|
||||
writer->Log(timeStr, message);
|
||||
}
|
||||
Flush();
|
||||
}
|
||||
|
||||
void Logger::Log(const char* className, const char* format, ...) {
|
||||
|
||||
@@ -1253,6 +1253,7 @@ namespace MessageType {
|
||||
VEHICLE_NOTIFY_HIT_EXPLODER = 1385,
|
||||
CHECK_NEAREST_ROCKET_LAUNCH_PRE_CONDITIONS = 1386,
|
||||
REQUEST_NEAREST_ROCKET_LAUNCH_PRE_CONDITIONS = 1387,
|
||||
CONFIGURE_RACING_CONTROL = 1388,
|
||||
CONFIGURE_RACING_CONTROL_CLIENT = 1389,
|
||||
NOTIFY_RACING_CLIENT = 1390,
|
||||
RACING_PLAYER_HACK_CAR = 1391,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "dConfig.h"
|
||||
#include "Logger.h"
|
||||
#include "dPlatforms.h"
|
||||
#include "BinaryPathFinder.h"
|
||||
|
||||
// Static Variables
|
||||
|
||||
@@ -17,7 +18,14 @@ namespace {
|
||||
void SQLiteDatabase::Connect() {
|
||||
LOG("Using SQLite database");
|
||||
con = new CppSQLite3DB();
|
||||
con->open(Game::config->GetValue("sqlite_database_path").c_str());
|
||||
const auto path = BinaryPathFinder::GetBinaryDir() / Game::config->GetValue("sqlite_database_path");
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
LOG("Creating sqlite path %s", path.string().c_str());
|
||||
std::filesystem::create_directories(path.parent_path());
|
||||
}
|
||||
|
||||
con->open(path.string().c_str());
|
||||
isConnected = true;
|
||||
|
||||
// Make sure wal is enabled for the database.
|
||||
|
||||
@@ -7,7 +7,6 @@ set(DGAME_DCOMPONENTS_SOURCES
|
||||
"BuildBorderComponent.cpp"
|
||||
"CharacterComponent.cpp"
|
||||
"CollectibleComponent.cpp"
|
||||
"Component.cpp"
|
||||
"ControllablePhysicsComponent.cpp"
|
||||
"DestroyableComponent.cpp"
|
||||
"DonationVendorComponent.cpp"
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#include "Component.h"
|
||||
|
||||
|
||||
Component::Component(Entity* parent) {
|
||||
m_Parent = parent;
|
||||
}
|
||||
|
||||
Component::~Component() {
|
||||
|
||||
}
|
||||
|
||||
Entity* Component::GetParent() const {
|
||||
return m_Parent;
|
||||
}
|
||||
|
||||
void Component::Update(float deltaTime) {
|
||||
|
||||
}
|
||||
|
||||
void Component::OnUse(Entity* originator) {
|
||||
|
||||
}
|
||||
|
||||
void Component::UpdateXml(tinyxml2::XMLDocument& doc) {
|
||||
|
||||
}
|
||||
|
||||
void Component::LoadFromXml(const tinyxml2::XMLDocument& doc) {
|
||||
|
||||
}
|
||||
|
||||
void Component::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "tinyxml2.h"
|
||||
namespace tinyxml2 {
|
||||
class XMLDocument;
|
||||
}
|
||||
|
||||
namespace RakNet {
|
||||
class BitStream;
|
||||
}
|
||||
|
||||
class Entity;
|
||||
|
||||
@@ -9,40 +15,40 @@ class Entity;
|
||||
*/
|
||||
class Component {
|
||||
public:
|
||||
Component(Entity* parent);
|
||||
virtual ~Component();
|
||||
Component(Entity* parent) : m_Parent{ parent } {}
|
||||
virtual ~Component() = default;
|
||||
|
||||
/**
|
||||
* Gets the owner of this component
|
||||
* @return the owner of this component
|
||||
*/
|
||||
Entity* GetParent() const;
|
||||
Entity* GetParent() const { return m_Parent; }
|
||||
|
||||
/**
|
||||
* Updates the component in the game loop
|
||||
* @param deltaTime time passed since last update
|
||||
*/
|
||||
virtual void Update(float deltaTime);
|
||||
virtual void Update(float deltaTime) {}
|
||||
|
||||
/**
|
||||
* Event called when this component is being used, e.g. when some entity interacted with it
|
||||
* @param originator
|
||||
*/
|
||||
virtual void OnUse(Entity* originator);
|
||||
virtual void OnUse(Entity* originator) {}
|
||||
|
||||
/**
|
||||
* Save data from this componennt to character XML
|
||||
* @param doc the document to write data to
|
||||
*/
|
||||
virtual void UpdateXml(tinyxml2::XMLDocument& doc);
|
||||
virtual void UpdateXml(tinyxml2::XMLDocument& doc) {}
|
||||
|
||||
/**
|
||||
* Load base data for this component from character XML
|
||||
* @param doc the document to read data from
|
||||
*/
|
||||
virtual void LoadFromXml(const tinyxml2::XMLDocument& doc);
|
||||
virtual void LoadFromXml(const tinyxml2::XMLDocument& doc) {}
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& outBitStream, bool isConstruction);
|
||||
virtual void Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "eStateChangeType.h"
|
||||
#include "eUseItemResponse.h"
|
||||
#include "Mail.h"
|
||||
#include "ProximityMonitorComponent.h"
|
||||
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDInventoryComponentTable.h"
|
||||
@@ -829,6 +830,30 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (item->GetLot() == 8092) {
|
||||
// Trying to equip a car
|
||||
const auto proximityObjects = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROXIMITY_MONITOR);
|
||||
|
||||
// look for car instancers and check if we are in its setup range
|
||||
for (auto* const entity : proximityObjects) {
|
||||
if (!entity) continue;
|
||||
|
||||
auto* proximityMonitorComponent = entity->GetComponent<ProximityMonitorComponent>();
|
||||
if (!proximityMonitorComponent) continue;
|
||||
|
||||
if (proximityMonitorComponent->IsInProximity("Interaction_Distance", m_Parent->GetObjectID())) {
|
||||
// in the range of a car instancer
|
||||
entity->OnUse(m_Parent);
|
||||
GameMessages::UseItemOnClient itemMsg;
|
||||
itemMsg.target = entity->GetObjectID();
|
||||
itemMsg.itemLOT = item->GetLot();
|
||||
itemMsg.itemToUse = item->GetId();
|
||||
itemMsg.playerId = m_Parent->GetObjectID();
|
||||
itemMsg.Send(m_Parent->GetSystemAddress());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
RacingControlComponent::RacingControlComponent(Entity* parent)
|
||||
: Component(parent) {
|
||||
m_PathName = u"MainPath";
|
||||
m_RemainingLaps = 3;
|
||||
m_NumberOfLaps = 3;
|
||||
m_RemainingLaps = m_NumberOfLaps;
|
||||
m_LeadingPlayer = LWOOBJID_EMPTY;
|
||||
m_RaceBestTime = 0;
|
||||
m_RaceBestLap = 0;
|
||||
@@ -658,23 +659,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn imagination pickups
|
||||
auto* minSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Min")[0];
|
||||
auto* medSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Med")[0];
|
||||
auto* maxSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Max")[0];
|
||||
|
||||
minSpawner->Activate();
|
||||
|
||||
if (m_LoadedPlayers > 2) {
|
||||
medSpawner->Activate();
|
||||
}
|
||||
|
||||
if (m_LoadedPlayers > 4) {
|
||||
maxSpawner->Activate();
|
||||
}
|
||||
GameMessages::ZoneLoadedInfo zoneLoadInfo{};
|
||||
zoneLoadInfo.maxPlayers = m_LoadedPlayers;
|
||||
m_Parent->GetScript()->OnZoneLoadedInfo(m_Parent, zoneLoadInfo);
|
||||
|
||||
// Reset players to their start location, without smashing them
|
||||
for (auto& player : m_RacingPlayers) {
|
||||
@@ -764,7 +751,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// new checkpoint
|
||||
uint32_t respawnIndex = 0;
|
||||
for (const auto& waypoint : path->pathWaypoints) {
|
||||
if (player.lap == 3) {
|
||||
if (player.lap == m_NumberOfLaps) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -835,7 +822,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// Progress lap time tasks
|
||||
missionComponent->Progress(eMissionTaskType::RACING, lapTime.count(), static_cast<LWOOBJID>(eRacingTaskParam::LAP_TIME));
|
||||
|
||||
if (player.lap == 3) {
|
||||
if (player.lap == m_NumberOfLaps) {
|
||||
m_Finished++;
|
||||
player.finished = m_Finished;
|
||||
|
||||
@@ -882,3 +869,20 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RacingControlComponent::MsgConfigureRacingControl(const GameMessages::ConfigureRacingControl& msg) {
|
||||
for (const auto& dataUnique : msg.racingSettings) {
|
||||
if (!dataUnique) continue;
|
||||
const auto* const data = dataUnique.get();
|
||||
if (data->GetKey() == u"Race_PathName" && data->GetValueType() == LDF_TYPE_UTF_16) {
|
||||
m_PathName = static_cast<const LDFData<std::u16string>*>(data)->GetValue();
|
||||
} else if (data->GetKey() == u"activityID" && data->GetValueType() == LDF_TYPE_S32) {
|
||||
m_ActivityID = static_cast<const LDFData<int32_t>*>(data)->GetValue();
|
||||
} else if (data->GetKey() == u"Number_of_Laps" && data->GetValueType() == LDF_TYPE_S32) {
|
||||
m_NumberOfLaps = static_cast<const LDFData<int32_t>*>(data)->GetValue();
|
||||
m_RemainingLaps = m_NumberOfLaps;
|
||||
} else if (data->GetKey() == u"Minimum_Players_for_Group_Achievements" && data->GetValueType() == LDF_TYPE_S32) {
|
||||
m_MinimumPlayersForGroupAchievements = static_cast<const LDFData<int32_t>*>(data)->GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,8 @@ public:
|
||||
*/
|
||||
RacingPlayerInfo* GetPlayerData(LWOOBJID playerID);
|
||||
|
||||
void MsgConfigureRacingControl(const GameMessages::ConfigureRacingControl& msg);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -161,11 +163,13 @@ private:
|
||||
|
||||
/**
|
||||
* The paths that are followed for the camera scenes
|
||||
* Configurable in the ConfigureRacingControl msg with the key `Race_PathName`.
|
||||
*/
|
||||
std::u16string m_PathName;
|
||||
|
||||
/**
|
||||
* The ID of the activity for participating in this race
|
||||
* Configurable in the ConfigureRacingControl msg with the key `activityID`.
|
||||
*/
|
||||
uint32_t m_ActivityID;
|
||||
|
||||
@@ -245,5 +249,20 @@ private:
|
||||
* Value for message box response to know if we are exiting the race via the activity dialogue
|
||||
*/
|
||||
const int32_t m_ActivityExitConfirm = 1;
|
||||
|
||||
bool m_AllPlayersReady = false;
|
||||
|
||||
/**
|
||||
* @brief The number of laps in this race. Configurable in the ConfigureRacingControl msg
|
||||
* with the key `Number_of_Laps`.
|
||||
*
|
||||
*/
|
||||
int32_t m_NumberOfLaps{ 3 };
|
||||
|
||||
/**
|
||||
* @brief The minimum number of players required to progress group achievements.
|
||||
* Configurable with the ConfigureRacingControl msg with the key `Minimum_Players_for_Group_Achievements`.
|
||||
*
|
||||
*/
|
||||
int32_t m_MinimumPlayersForGroupAchievements{ 2 };
|
||||
};
|
||||
|
||||
@@ -6342,36 +6342,57 @@ void GameMessages::SendUpdateInventoryUi(LWOOBJID objectId, const SystemAddress&
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void GameMessages::DisplayTooltip::Send() const {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
namespace GameMessages {
|
||||
void GameMsg::Send(const SystemAddress& sysAddr) const {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(target);
|
||||
bitStream.Write(msgId);
|
||||
bitStream.Write(target); // Who this message will be sent to on the (a) client
|
||||
bitStream.Write(msgId); // the ID of this message
|
||||
|
||||
bitStream.Write(doOrDie);
|
||||
bitStream.Write(noRepeat);
|
||||
bitStream.Write(noRevive);
|
||||
bitStream.Write(isPropertyTooltip);
|
||||
bitStream.Write(show);
|
||||
bitStream.Write(translate);
|
||||
bitStream.Write(time);
|
||||
bitStream.Write<int32_t>(id.size());
|
||||
bitStream.Write(id);
|
||||
Serialize(bitStream); // write the message data
|
||||
|
||||
std::string toWrite;
|
||||
for (const auto* item : localizeParams) {
|
||||
toWrite += item->GetString() + "\n";
|
||||
// Send to everyone if someone sent unassigned system address, or to one specific client.
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) {
|
||||
SEND_PACKET_BROADCAST;
|
||||
} else {
|
||||
SEND_PACKET;
|
||||
}
|
||||
}
|
||||
if (!toWrite.empty()) toWrite.pop_back();
|
||||
bitStream.Write<int32_t>(toWrite.size());
|
||||
bitStream.Write(GeneralUtils::ASCIIToUTF16(toWrite));
|
||||
if (!toWrite.empty()) bitStream.Write<uint16_t>(0x00); // Null Terminator
|
||||
|
||||
bitStream.Write<int32_t>(imageName.size());
|
||||
bitStream.Write(imageName);
|
||||
bitStream.Write<int32_t>(text.size());
|
||||
bitStream.Write(text);
|
||||
void DisplayTooltip::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(doOrDie);
|
||||
bitStream.Write(noRepeat);
|
||||
bitStream.Write(noRevive);
|
||||
bitStream.Write(isPropertyTooltip);
|
||||
bitStream.Write(show);
|
||||
bitStream.Write(translate);
|
||||
bitStream.Write(time);
|
||||
bitStream.Write<int32_t>(id.size());
|
||||
bitStream.Write(id);
|
||||
|
||||
SEND_PACKET;
|
||||
std::string toWrite;
|
||||
for (const auto* item : localizeParams) {
|
||||
toWrite += item->GetString() + "\n";
|
||||
}
|
||||
if (!toWrite.empty()) toWrite.pop_back();
|
||||
bitStream.Write<int32_t>(toWrite.size());
|
||||
bitStream.Write(GeneralUtils::ASCIIToUTF16(toWrite));
|
||||
if (!toWrite.empty()) bitStream.Write<uint16_t>(0x00); // Null Terminator
|
||||
|
||||
bitStream.Write<int32_t>(imageName.size());
|
||||
bitStream.Write(imageName);
|
||||
bitStream.Write<int32_t>(text.size());
|
||||
bitStream.Write(text);
|
||||
}
|
||||
|
||||
void UseItemOnClient::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(itemLOT);
|
||||
bitStream.Write(itemToUse);
|
||||
bitStream.Write(itemType);
|
||||
bitStream.Write(playerId);
|
||||
bitStream.Write(targetPosition.x);
|
||||
bitStream.Write(targetPosition.y);
|
||||
bitStream.Write(targetPosition.z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace GameMessages {
|
||||
struct GameMsg {
|
||||
GameMsg(MessageType::Game gmId) : msgId{ gmId } {}
|
||||
virtual ~GameMsg() = default;
|
||||
virtual void Send() const {}
|
||||
void Send(const SystemAddress& sysAddr) const;
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const {}
|
||||
MessageType::Game msgId;
|
||||
LWOOBJID target{ LWOOBJID_EMPTY };
|
||||
SystemAddress sysAddr{ UNASSIGNED_SYSTEM_ADDRESS };
|
||||
};
|
||||
|
||||
class PropertyDataMessage;
|
||||
@@ -705,7 +705,27 @@ namespace GameMessages {
|
||||
std::vector<LDFBaseData*> localizeParams{};
|
||||
std::u16string imageName{};
|
||||
std::u16string text{};
|
||||
void Send() const override;
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct UseItemOnClient : public GameMsg {
|
||||
UseItemOnClient() : GameMsg(MessageType::Game::USE_ITEM_ON_CLIENT) {}
|
||||
LWOOBJID playerId{};
|
||||
LWOOBJID itemToUse{};
|
||||
uint32_t itemType{};
|
||||
LOT itemLOT{};
|
||||
NiPoint3 targetPosition{};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct ZoneLoadedInfo : public GameMsg {
|
||||
ZoneLoadedInfo() : GameMsg(MessageType::Game::ZONE_LOADED_INFO) {}
|
||||
int32_t maxPlayers{};
|
||||
};
|
||||
|
||||
struct ConfigureRacingControl : public GameMsg {
|
||||
ConfigureRacingControl() : GameMsg(MessageType::Game::CONFIGURE_RACING_CONTROL) {}
|
||||
std::vector<std::unique_ptr<LDFBaseData>> racingSettings{};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -84,6 +84,24 @@ int main(int argc, char** argv) {
|
||||
Server::SetupLogger("MasterServer");
|
||||
if (!Game::logger) return EXIT_FAILURE;
|
||||
|
||||
auto folders = { "navmeshes", "migrations", "vanity" };
|
||||
|
||||
for (const auto folder : folders) {
|
||||
if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / folder)) {
|
||||
std::string msg = "The (" +
|
||||
std::string(folder) +
|
||||
") folder was not copied to the binary directory. Please copy the (" +
|
||||
std::string(folder) +
|
||||
") folder from your download to the binary directory or re-run cmake.";
|
||||
LOG("%s", msg.c_str());
|
||||
// toss an error box up for windows users running the download
|
||||
#ifdef DARKFLAME_PLATFORM_WIN32
|
||||
MessageBoxA(nullptr, msg.c_str(), "Missing Folder", MB_OK | MB_ICONERROR);
|
||||
#endif
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dConfig::Exists("authconfig.ini")) LOG("Could not find authconfig.ini, using default settings");
|
||||
if (!dConfig::Exists("chatconfig.ini")) LOG("Could not find chatconfig.ini, using default settings");
|
||||
if (!dConfig::Exists("masterconfig.ini")) LOG("Could not find masterconfig.ini, using default settings");
|
||||
@@ -126,6 +144,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
MigrationRunner::RunMigrations();
|
||||
const auto resServerPath = BinaryPathFinder::GetBinaryDir() / "resServer";
|
||||
std::filesystem::create_directories(resServerPath);
|
||||
const bool cdServerExists = std::filesystem::exists(resServerPath / "CDServer.sqlite");
|
||||
const bool oldCDServerExists = std::filesystem::exists(Game::assetManager->GetResPath() / "CDServer.sqlite");
|
||||
const bool fdbExists = std::filesystem::exists(Game::assetManager->GetResPath() / "cdclient.fdb");
|
||||
@@ -176,7 +195,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
// Run migrations should any need to be run.
|
||||
MigrationRunner::RunSQLiteMigrations();
|
||||
MigrationRunner::RunSQLiteMigrations();
|
||||
|
||||
//If the first command line argument is -a or --account then make the user
|
||||
//input a username and password, with the password being hidden.
|
||||
|
||||
@@ -329,6 +329,8 @@
|
||||
#include "WblRobotCitizen.h"
|
||||
#include "EnemyClearThreat.h"
|
||||
#include "AgSpiderBossMessage.h"
|
||||
#include "GfRaceInstancer.h"
|
||||
#include "NsRaceServer.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -690,6 +692,8 @@ namespace {
|
||||
{"scripts\\zone\\LUPs\\RobotCity Intro\\WBL_RCIntro_RobotCitizenYellow.lua", []() {return new WblRobotCitizen();}},
|
||||
{"scripts\\02_server\\Map\\General\\L_ENEMY_CLEAR_THREAT.lua", []() {return new EnemyClearThreat();}},
|
||||
{"scripts\\ai\\AG\\L_AG_SPIDER_BOSS_MESSAGE.lua", []() {return new AgSpiderBossMessage();}},
|
||||
{"scripts\\ai\\GF\\L_GF_RACE_INSTANCER.lua", []() {return new GfRaceInstancer();}},
|
||||
{"scripts\\ai\\RACING\\TRACK_NS\\NS_RACE_SERVER.lua", []() {return new NsRaceServer();}},
|
||||
|
||||
};
|
||||
|
||||
@@ -702,7 +706,12 @@ namespace {
|
||||
"scripts\\empty.lua",
|
||||
"scripts\\zone\\AG\\L_ZONE_AG.lua",
|
||||
"scripts\\zone\\NS\\L_ZONE_NS.lua",
|
||||
"scripts\\zone\\GF\\L_ZONE_GF.lua",
|
||||
"scripts\\ai\\GF\\L_ZONE_GF.lua",
|
||||
"scripts\\ai\\AG\\CONCERT_STAGE.lua",
|
||||
"scripts\\ai\\NS\\L_NS_CAR_MODULAR_BUILD.lua", // In our implementation, this is done in GameMessages.cpp
|
||||
"scripts\\ai\\PETS\\PET_BLOCKER.lua",
|
||||
"scripts\\ai\\PETS\\PET_FLEA_MISSION.lua",
|
||||
"scripts\\ai\\ACT\\L_ACT_PET_INSTANCE_EXIT.lua",
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -354,7 +354,9 @@ namespace CppScripts {
|
||||
* @param player the player to remove
|
||||
* @param canceled if it was done via the cancel button
|
||||
*/
|
||||
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled){};
|
||||
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {};
|
||||
|
||||
virtual void OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {};
|
||||
};
|
||||
|
||||
Script* const GetScript(Entity* parent, const std::string& scriptName);
|
||||
|
||||
@@ -25,11 +25,10 @@ void AgSpiderBossMessage::MakeBox(Entity* self) const {
|
||||
if (!tgt) return;
|
||||
GameMessages::DisplayTooltip tooltip;
|
||||
tooltip.target = tgt->GetObjectID();
|
||||
tooltip.sysAddr = tgt->GetSystemAddress();
|
||||
tooltip.show = true;
|
||||
tooltip.text = box.boxText;
|
||||
tooltip.time = box.boxTime * 1000; // to ms
|
||||
tooltip.Send();
|
||||
tooltip.Send(tgt->GetSystemAddress());
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DSCRIPTS_SOURCES_AI_GF
|
||||
"GfRaceInstancer.cpp"
|
||||
"GfCampfire.cpp"
|
||||
"GfOrgan.cpp"
|
||||
"GfBanana.cpp"
|
||||
|
||||
7
dScripts/ai/GF/GfRaceInstancer.cpp
Normal file
7
dScripts/ai/GF/GfRaceInstancer.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "GfRaceInstancer.h"
|
||||
|
||||
#include "Entity.h"
|
||||
|
||||
void GfRaceInstancer::OnStartup(Entity* self) {
|
||||
self->SetProximityRadius(self->HasVar(u"interaction_distance") ? self->GetVar<float>(u"interaction_distance") : 16.0f, "Interaction_Distance");
|
||||
}
|
||||
11
dScripts/ai/GF/GfRaceInstancer.h
Normal file
11
dScripts/ai/GF/GfRaceInstancer.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef GFRACEINSTANCER_H
|
||||
#define GFRACEINSTANCER_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
class GfRaceInstancer : public CppScripts::Script {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
||||
|
||||
#endif //!GFRACEINSTANCER_H
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DSCRIPTS_SOURCES_AI_RACING)
|
||||
set(DSCRIPTS_SOURCES_AI_RACING
|
||||
"RaceImaginationServer.cpp")
|
||||
|
||||
add_subdirectory(OBJECTS)
|
||||
|
||||
@@ -6,6 +7,12 @@ foreach(file ${DSCRIPTS_SOURCES_AI_RACING_OBJECTS})
|
||||
set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "OBJECTS/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(TRACK_NS)
|
||||
|
||||
foreach(file ${DSCRIPTS_SOURCES_AI_RACING_TRACK_NS})
|
||||
set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "TRACK_NS/${file}")
|
||||
endforeach()
|
||||
|
||||
add_library(dScriptsAiRacing OBJECT ${DSCRIPTS_SOURCES_AI_RACING})
|
||||
target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS")
|
||||
target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS" "TRACK_NS")
|
||||
target_precompile_headers(dScriptsAiRacing REUSE_FROM dScriptsBase)
|
||||
|
||||
19
dScripts/ai/RACING/RaceImaginationServer.cpp
Normal file
19
dScripts/ai/RACING/RaceImaginationServer.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "RaceImaginationServer.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void StartSpawner(const std::vector<Spawner*>& spawner) {
|
||||
for (auto* const entity : spawner) {
|
||||
entity->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
void RaceImaginationServer::OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {
|
||||
// Spawn imagination pickups
|
||||
StartSpawner(Game::zoneManager->GetSpawnersByName("ImaginationSpawn_Min"));
|
||||
if (info.maxPlayers > 2) {
|
||||
StartSpawner(Game::zoneManager->GetSpawnersByName("ImaginationSpawn_Med"));
|
||||
}
|
||||
if (info.maxPlayers > 4) {
|
||||
StartSpawner(Game::zoneManager->GetSpawnersByName("ImaginationSpawn_Max"));
|
||||
}
|
||||
}
|
||||
11
dScripts/ai/RACING/RaceImaginationServer.h
Normal file
11
dScripts/ai/RACING/RaceImaginationServer.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef RACEIMAGINATIONSERVER_H
|
||||
#define RACEIMAGINATIONSERVER_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
class RaceImaginationServer : public virtual CppScripts::Script {
|
||||
public:
|
||||
void OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) override;
|
||||
};
|
||||
|
||||
#endif //!RACEIMAGINATIONSERVER_H
|
||||
3
dScripts/ai/RACING/TRACK_NS/CMakeLists.txt
Normal file
3
dScripts/ai/RACING/TRACK_NS/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
set(DSCRIPTS_SOURCES_AI_RACING_TRACK_NS
|
||||
"NsRaceServer.cpp"
|
||||
PARENT_SCOPE)
|
||||
54
dScripts/ai/RACING/TRACK_NS/NsRaceServer.cpp
Normal file
54
dScripts/ai/RACING/TRACK_NS/NsRaceServer.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "NsRaceServer.h"
|
||||
|
||||
#include "RacingControlComponent.h"
|
||||
#include "Entity.h"
|
||||
|
||||
using std::unique_ptr;
|
||||
using std::make_unique;
|
||||
|
||||
void NsRaceServer::OnStartup(Entity* self) {
|
||||
GameMessages::ConfigureRacingControl config;
|
||||
auto& raceSet = config.racingSettings;
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<std::u16string>>(u"GameType", u"Racing"));
|
||||
raceSet.push_back(make_unique<LDFData<std::u16string>>(u"GameState", u"Starting"));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Number_Of_PlayersPerTeam", 6));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Minimum_Players_to_Start", 2));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Minimum_Players_for_Group_Achievements", 2));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Car_Object", 7703));
|
||||
raceSet.push_back(make_unique<LDFData<std::u16string>>(u"Race_PathName", u"MainPath"));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Current_Lap", 1));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Number_of_Laps", 3));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"activityID", 42));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_1", 100));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_2", 90));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_3", 80));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_4", 70));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_5", 60));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_6", 50));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_1", 15));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_2", 25));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_3", 50));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_4", 85));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_5", 90));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_6", 100));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Number_of_Spawn_Groups", 1));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Spawners", 4847));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Spawners", 4848));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Flag", 4850));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Flag", 4851));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Point", 4846));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Point", 4845));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Mark", 4844));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Mark", 4843));
|
||||
|
||||
std::vector<Entity*> racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
|
||||
for (auto* const racingController : racingControllers) {
|
||||
auto* racingComponent = racingController->GetComponent<RacingControlComponent>();
|
||||
if (racingComponent) racingComponent->MsgConfigureRacingControl(config);
|
||||
}
|
||||
}
|
||||
12
dScripts/ai/RACING/TRACK_NS/NsRaceServer.h
Normal file
12
dScripts/ai/RACING/TRACK_NS/NsRaceServer.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef NSRACESERVER_H
|
||||
#define NSRACESERVER_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
#include "RaceImaginationServer.h"
|
||||
|
||||
class NsRaceServer : public RaceImaginationServer {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
||||
|
||||
#endif //!NSRACESERVER_H
|
||||
@@ -13,7 +13,7 @@ void Server::SetupLogger(const std::string_view serviceName) {
|
||||
|
||||
const auto logsDir = BinaryPathFinder::GetBinaryDir() / "logs";
|
||||
|
||||
if (!std::filesystem::exists(logsDir)) std::filesystem::create_directory(logsDir);
|
||||
if (!std::filesystem::exists(logsDir)) std::filesystem::create_directories(logsDir);
|
||||
|
||||
std::string logPath = (logsDir / serviceName).string() + "_" + std::to_string(time(nullptr)) + ".log";
|
||||
bool logToConsole = false;
|
||||
|
||||
@@ -267,8 +267,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
// pre calculate the FDB checksum
|
||||
if (Game::config->GetValue("check_fdb") == "1") {
|
||||
std::ifstream fileStream;
|
||||
|
||||
static const std::vector<std::string> aliases = {
|
||||
"CDServers.fdb",
|
||||
"cdserver.fdb",
|
||||
@@ -277,31 +275,29 @@ int main(int argc, char** argv) {
|
||||
};
|
||||
|
||||
for (const auto& file : aliases) {
|
||||
fileStream.open(Game::assetManager->GetResPath() / file, std::ios::binary | std::ios::in);
|
||||
if (fileStream.is_open()) {
|
||||
auto cdclient = Game::assetManager->GetFile("cdclient.fdb");
|
||||
if (cdclient) {
|
||||
|
||||
const int32_t bufferSize = 1024;
|
||||
MD5 md5;
|
||||
|
||||
char fileStreamBuffer[1024] = {};
|
||||
|
||||
while (!cdclient.eof()) {
|
||||
memset(fileStreamBuffer, 0, bufferSize);
|
||||
cdclient.read(fileStreamBuffer, bufferSize);
|
||||
md5.update(fileStreamBuffer, cdclient.gcount());
|
||||
}
|
||||
|
||||
const char* nullTerminateBuffer = "\0";
|
||||
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
||||
md5.finalize();
|
||||
databaseChecksum = md5.hexdigest();
|
||||
|
||||
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int32_t bufferSize = 1024;
|
||||
MD5 md5;
|
||||
|
||||
char fileStreamBuffer[1024] = {};
|
||||
|
||||
while (!fileStream.eof()) {
|
||||
memset(fileStreamBuffer, 0, bufferSize);
|
||||
fileStream.read(fileStreamBuffer, bufferSize);
|
||||
md5.update(fileStreamBuffer, fileStream.gcount());
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
|
||||
const char* nullTerminateBuffer = "\0";
|
||||
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
||||
md5.finalize();
|
||||
databaseChecksum = md5.hexdigest();
|
||||
|
||||
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
||||
}
|
||||
|
||||
uint32_t currentFrameDelta = highFrameDelta;
|
||||
@@ -548,115 +544,115 @@ void HandlePacketChat(Packet* packet) {
|
||||
if (packet->data[0] == ID_USER_PACKET_ENUM && packet->length >= 4) {
|
||||
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT) {
|
||||
switch (static_cast<MessageType::Chat>(packet->data[3])) {
|
||||
case MessageType::Chat::WORLD_ROUTE_PACKET: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID;
|
||||
inStream.Read(playerID);
|
||||
case MessageType::Chat::WORLD_ROUTE_PACKET: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID;
|
||||
inStream.Read(playerID);
|
||||
|
||||
auto player = Game::entityManager->GetEntity(playerID);
|
||||
if (!player) return;
|
||||
auto player = Game::entityManager->GetEntity(playerID);
|
||||
if (!player) return;
|
||||
|
||||
auto sysAddr = player->GetSystemAddress();
|
||||
auto sysAddr = player->GetSystemAddress();
|
||||
|
||||
//Write our stream outwards:
|
||||
CBITSTREAM;
|
||||
unsigned char data;
|
||||
while (inStream.Read(data)) {
|
||||
bitStream.Write(data);
|
||||
}
|
||||
|
||||
SEND_PACKET; //send routed packet to player
|
||||
break;
|
||||
//Write our stream outwards:
|
||||
CBITSTREAM;
|
||||
unsigned char data;
|
||||
while (inStream.Read(data)) {
|
||||
bitStream.Write(data);
|
||||
}
|
||||
|
||||
case MessageType::Chat::GM_ANNOUNCE: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
SEND_PACKET; //send routed packet to player
|
||||
break;
|
||||
}
|
||||
|
||||
std::string title;
|
||||
std::string msg;
|
||||
case MessageType::Chat::GM_ANNOUNCE: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
|
||||
uint32_t len;
|
||||
inStream.Read<uint32_t>(len);
|
||||
for (uint32_t i = 0; len > i; i++) {
|
||||
char character;
|
||||
inStream.Read<char>(character);
|
||||
title += character;
|
||||
}
|
||||
std::string title;
|
||||
std::string msg;
|
||||
|
||||
len = 0;
|
||||
inStream.Read<uint32_t>(len);
|
||||
for (uint32_t i = 0; len > i; i++) {
|
||||
char character;
|
||||
inStream.Read<char>(character);
|
||||
msg += character;
|
||||
}
|
||||
uint32_t len;
|
||||
inStream.Read<uint32_t>(len);
|
||||
for (uint32_t i = 0; len > i; i++) {
|
||||
char character;
|
||||
inStream.Read<char>(character);
|
||||
title += character;
|
||||
}
|
||||
|
||||
//Send to our clients:
|
||||
AMFArrayValue args;
|
||||
len = 0;
|
||||
inStream.Read<uint32_t>(len);
|
||||
for (uint32_t i = 0; len > i; i++) {
|
||||
char character;
|
||||
inStream.Read<char>(character);
|
||||
msg += character;
|
||||
}
|
||||
|
||||
args.Insert("title", title);
|
||||
args.Insert("message", msg);
|
||||
//Send to our clients:
|
||||
AMFArrayValue args;
|
||||
|
||||
GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", args);
|
||||
args.Insert("title", title);
|
||||
args.Insert("message", msg);
|
||||
|
||||
GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", args);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MessageType::Chat::GM_MUTE: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerId;
|
||||
time_t expire = 0;
|
||||
inStream.Read(playerId);
|
||||
inStream.Read(expire);
|
||||
|
||||
auto* entity = Game::entityManager->GetEntity(playerId);
|
||||
auto* character = entity != nullptr ? entity->GetCharacter() : nullptr;
|
||||
auto* user = character != nullptr ? character->GetParentUser() : nullptr;
|
||||
if (user) {
|
||||
user->SetMuteExpire(expire);
|
||||
|
||||
entity->GetCharacter()->SendMuteNotice();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MessageType::Chat::TEAM_GET_STATUS: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
|
||||
LWOOBJID teamID = 0;
|
||||
char lootOption = 0;
|
||||
char memberCount = 0;
|
||||
std::vector<LWOOBJID> members;
|
||||
|
||||
inStream.Read(teamID);
|
||||
bool deleteTeam = inStream.ReadBit();
|
||||
|
||||
if (deleteTeam) {
|
||||
TeamManager::Instance()->DeleteTeam(teamID);
|
||||
|
||||
LOG("Deleting team (%llu)", teamID);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MessageType::Chat::GM_MUTE: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerId;
|
||||
time_t expire = 0;
|
||||
inStream.Read(playerId);
|
||||
inStream.Read(expire);
|
||||
inStream.Read(lootOption);
|
||||
inStream.Read(memberCount);
|
||||
LOG("Updating team (%llu), (%i), (%i)", teamID, lootOption, memberCount);
|
||||
for (char i = 0; i < memberCount; i++) {
|
||||
LWOOBJID member = LWOOBJID_EMPTY;
|
||||
inStream.Read(member);
|
||||
members.push_back(member);
|
||||
|
||||
auto* entity = Game::entityManager->GetEntity(playerId);
|
||||
auto* character = entity != nullptr ? entity->GetCharacter() : nullptr;
|
||||
auto* user = character != nullptr ? character->GetParentUser() : nullptr;
|
||||
if (user) {
|
||||
user->SetMuteExpire(expire);
|
||||
|
||||
entity->GetCharacter()->SendMuteNotice();
|
||||
}
|
||||
|
||||
break;
|
||||
LOG("Updating team member (%llu)", member);
|
||||
}
|
||||
|
||||
case MessageType::Chat::TEAM_GET_STATUS: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
TeamManager::Instance()->UpdateTeam(teamID, lootOption, members);
|
||||
|
||||
LWOOBJID teamID = 0;
|
||||
char lootOption = 0;
|
||||
char memberCount = 0;
|
||||
std::vector<LWOOBJID> members;
|
||||
|
||||
inStream.Read(teamID);
|
||||
bool deleteTeam = inStream.ReadBit();
|
||||
|
||||
if (deleteTeam) {
|
||||
TeamManager::Instance()->DeleteTeam(teamID);
|
||||
|
||||
LOG("Deleting team (%llu)", teamID);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
inStream.Read(lootOption);
|
||||
inStream.Read(memberCount);
|
||||
LOG("Updating team (%llu), (%i), (%i)", teamID, lootOption, memberCount);
|
||||
for (char i = 0; i < memberCount; i++) {
|
||||
LWOOBJID member = LWOOBJID_EMPTY;
|
||||
inStream.Read(member);
|
||||
members.push_back(member);
|
||||
|
||||
LOG("Updating team member (%llu)", member);
|
||||
}
|
||||
|
||||
TeamManager::Instance()->UpdateTeam(teamID, lootOption, members);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG("Received an unknown chat: %i", int(packet->data[3]));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG("Received an unknown chat: %i", int(packet->data[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -869,10 +865,12 @@ void HandlePacket(Packet* packet) {
|
||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
LOG("server %s client %s", databaseChecksum.c_str(), clientDatabaseChecksum.string.c_str());
|
||||
|
||||
// Developers may skip this check
|
||||
if (clientDatabaseChecksum.string != databaseChecksum) {
|
||||
|
||||
LOG("");
|
||||
if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER) {
|
||||
LOG("Client's database checksum does not match the server's, aborting connection.");
|
||||
std::vector<Stamp> stamps;
|
||||
@@ -884,6 +882,7 @@ void HandlePacket(Packet* packet) {
|
||||
Game::config->GetValue("cdclient_mismatch_message"), "", 0, "", stamps);
|
||||
return;
|
||||
} else {
|
||||
LOG("");
|
||||
AMFArrayValue args;
|
||||
|
||||
args.Insert("title", Game::config->GetValue("cdclient_mismatch_title"));
|
||||
@@ -896,18 +895,21 @@ void HandlePacket(Packet* packet) {
|
||||
}
|
||||
}
|
||||
|
||||
LOG("");
|
||||
//Request the session info from Master:
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_SESSION_KEY);
|
||||
bitStream.Write(username);
|
||||
Game::server->SendToMaster(bitStream);
|
||||
|
||||
LOG("");
|
||||
//Insert info into our pending list
|
||||
tempSessionInfo info;
|
||||
info.sysAddr = SystemAddress(packet->systemAddress);
|
||||
info.hash = sessionKey.GetAsString();
|
||||
m_PendingUsers.insert(std::make_pair(username.GetAsString(), info));
|
||||
|
||||
LOG("");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ client_location=
|
||||
|
||||
# The maximum outgoing bandwidth in bits. If your clients are having
|
||||
# issues with enemies taking a while to catch up to them, increse this value.
|
||||
maximum_outgoing_bandwidth=80000
|
||||
# Empty or 0 means no limit
|
||||
maximum_outgoing_bandwidth=0
|
||||
|
||||
# The Maximum Translation Unit (MTU) size for packets. If players are
|
||||
# getting stuck at 55% on the loading screen, lower this number to
|
||||
|
||||
Reference in New Issue
Block a user