diff --git a/code/client/src/core/modules/human.cpp b/code/client/src/core/modules/human.cpp index 6bec9286..9dbd69d0 100644 --- a/code/client/src/core/modules/human.cpp +++ b/code/client/src/core/modules/human.cpp @@ -20,7 +20,7 @@ #include "sdk/ue/game/camera/c_game_camera.h" #include "sdk/wrappers/c_human_2_car_wrapper.h" -#include "shared/game_rpc/add_weapon.h" +#include "shared/game_rpc/human/human_add_weapon.h" #include "shared/game_rpc/human/human_changeskin.h" #include "shared/game_rpc/human/human_reload.h" #include "shared/game_rpc/human/human_setprops.h" @@ -165,8 +165,8 @@ namespace MafiaMP::Core::Modules { } void Human::Create(flecs::entity e, uint64_t spawnProfile) { - auto info = Core::gApplication->GetEntityFactory()->RequestHuman(spawnProfile); - auto &trackingData = e.ensure(); + auto info = Core::gApplication->GetEntityFactory()->RequestHuman(spawnProfile); + auto &trackingData = e.ensure(); trackingData.info = info; trackingData.human = nullptr; @@ -229,7 +229,7 @@ namespace MafiaMP::Core::Modules { } void Human::SetupLocalPlayer(Application *, flecs::entity e) { - auto &trackingData = e.ensure(); + auto &trackingData = e.ensure(); trackingData.human = Game::Helpers::Controls::GetLocalPlayer(); trackingData.info = nullptr; @@ -240,7 +240,7 @@ namespace MafiaMP::Core::Modules { e.set({Shared::Modules::Mod::MOD_PLAYER}); e.add(); - auto es = e.get_mut(); + auto es = e.get_mut(); es->modEvents.updateProc = [](Framework::Networking::NetworkPeer *peer, uint64_t guid, flecs::entity e) { const auto updateData = e.get(); @@ -499,7 +499,7 @@ namespace MafiaMP::Core::Modules { } }); - net->RegisterGameRPC([app](SLNet::RakNetGUID guid, Shared::RPC::AddWeapon *msg) { + net->RegisterGameRPC([app](SLNet::RakNetGUID guid, Shared::RPC::HumanAddWeapon *msg) { if (!msg->Valid()) return; diff --git a/code/server/CMakeLists.txt b/code/server/CMakeLists.txt index 0e4c6a51..963d4260 100644 --- a/code/server/CMakeLists.txt +++ b/code/server/CMakeLists.txt @@ -2,6 +2,7 @@ set(MAFIAMP_SERVER_FILES src/main.cpp src/core/server.cpp + src/core/builtins/human.cpp src/core/builtins/player.cpp src/core/builtins/vehicle.cpp diff --git a/code/server/src/core/builtins/builtins.h b/code/server/src/core/builtins/builtins.h index 9e60af21..6989ca54 100644 --- a/code/server/src/core/builtins/builtins.h +++ b/code/server/src/core/builtins/builtins.h @@ -5,6 +5,7 @@ #include "scripting/server_engine.h" #include "chat.h" +#include "human.h" #include "player.h" #include "vehicle.h" #include "world.h" @@ -15,6 +16,7 @@ namespace MafiaMP::Scripting { static void Register(sol::state &luaEngine) { Scripting::Chat::Register(luaEngine); Scripting::Human::Register(luaEngine); + Scripting::Player::Register(luaEngine); Scripting::Vehicle::Register(luaEngine); Scripting::World::Register(luaEngine); } diff --git a/code/server/src/core/builtins/chat.h b/code/server/src/core/builtins/chat.h index 8f647507..a7c784f6 100644 --- a/code/server/src/core/builtins/chat.h +++ b/code/server/src/core/builtins/chat.h @@ -2,47 +2,45 @@ #include -#include "scripting/server_engine.h" +#include "core/server.h" #include "shared/rpc/chat_message.h" #include "player.h" -#include "core_modules.h" - namespace MafiaMP::Scripting { class Chat final { public: - static void SendToPlayer(Human *human, std::string message) { - if (human) { - const auto ent = human->GetHandle(); - const auto str = ent.get(); - - if (!str) - return; + static void EventChatMessage(flecs::entity e, std::string message) { + const auto engine = MafiaMP::Server::GetScriptingEngine(); + engine->InvokeEvent("onChatMessage", Player(e), message); + } - FW_SEND_COMPONENT_RPC_TO(Shared::RPC::ChatMessage, SLNet::RakNetGUID(str->guid), message); - } + static void EventChatCommand(flecs::entity e, std::string message, std::string command, std::vector args) { + const auto engine = MafiaMP::Server::GetScriptingEngine(); + engine->InvokeEvent("onChatCommand", Player(e), message, command, args); } static void SendToAll(std::string message) { FW_SEND_COMPONENT_RPC(Shared::RPC::ChatMessage, message); } - static void EventChatMessage(flecs::entity e, std::string message) { - const auto engine = MafiaMP::Server::GetScriptingEngine(); - engine->InvokeEvent("onChatMessage", Human(e), message); - } + static void SendToPlayer(Player *player, std::string message) { + if (player) { + const auto ent = player->GetHandle(); + const auto str = ent.get(); - static void EventChatCommand(flecs::entity e, std::string message, std::string command, std::vector args) { - const auto engine = MafiaMP::Server::GetScriptingEngine(); - engine->InvokeEvent("onChatCommand", Human(e), message, command, args); + if (!str) + return; + + FW_SEND_COMPONENT_RPC_TO(Shared::RPC::ChatMessage, SLNet::RakNetGUID(str->guid), message); + } } static void Register(sol::state &luaEngine) { sol::usertype cls = luaEngine.new_usertype("Chat"); - cls["sendToPlayer"] = &Chat::SendToPlayer; - cls["sendToAll"] = &Chat::SendToAll; + cls["sendToAll"] = &Chat::SendToAll; + cls["sendToPlayer"] = &Chat::SendToPlayer; } }; } // namespace MafiaMP::Scripting diff --git a/code/server/src/core/builtins/human.cpp b/code/server/src/core/builtins/human.cpp new file mode 100644 index 00000000..dab54332 --- /dev/null +++ b/code/server/src/core/builtins/human.cpp @@ -0,0 +1,62 @@ +#include "human.h" + +#include "core/server.h" + +#include "shared/game_rpc/human/human_add_weapon.h" +#include "shared/game_rpc/human/human_setprops.h" + +#include "shared/modules/human_sync.hpp" + +#include "vehicle.h" + +namespace MafiaMP::Scripting { + std::string Human::ToString() const { + std::ostringstream ss; + ss << "Human{ id: " << _ent.id() << " }"; + return ss.str(); + } + + void Human::AddWeapon(int weaponId, int ammo) { + FW_SEND_SERVER_COMPONENT_GAME_RPC(MafiaMP::Shared::RPC::HumanAddWeapon, _ent, weaponId, ammo); + } + + float Human::GetHealth() const { + auto h = _ent.get(); + return h->_healthPercent; + } + + void Human::SetHealth(float health) { + auto h = _ent.get_mut(); + h->_healthPercent = health; + MafiaMP::Shared::RPC::HumanSetProps msg {}; + msg.health = health; + FW_SEND_SERVER_COMPONENT_GAME_RPC(MafiaMP::Shared::RPC::HumanSetProps, _ent, msg); + } + + Vehicle Human::GetVehicle() const { + const auto updateData = _ent.get(); + const auto carEnt = flecs::entity(_ent.world(), updateData->carPassenger.carId); + if (carEnt.is_valid() && carEnt.is_alive()) { + return Vehicle(carEnt); + } + return Vehicle(-1); + } + + int Human::GetVehicleSeat() const { + const auto updateData = _ent.get(); + const auto carEnt = flecs::entity(_ent.world(), updateData->carPassenger.carId); + if (carEnt.is_valid() && carEnt.is_alive()) { + return updateData->carPassenger.seatId; + } + return -1; + } + + void Human::Register(sol::state &luaEngine) { + sol::usertype cls = luaEngine.new_usertype("Human", sol::constructors(), sol::base_classes, sol::bases()); + cls["addWeapon"] = &Human::AddWeapon; + cls["getHealth"] = &Human::GetHealth; + cls["setHealth"] = &Human::SetHealth; + cls["getVehicle"] = &Human::GetVehicle; + cls["getVehicleSeat"] = &Human::GetVehicleSeat; + } +} // namespace MafiaMP::Scripting diff --git a/code/server/src/core/builtins/human.h b/code/server/src/core/builtins/human.h new file mode 100644 index 00000000..80899b9b --- /dev/null +++ b/code/server/src/core/builtins/human.h @@ -0,0 +1,37 @@ +#pragma once + +#include + +#include "integrations/server/scripting/builtins/entity.h" + +#include "shared/modules/human_sync.hpp" + +namespace MafiaMP::Scripting { + class Vehicle; + class Human: public Framework::Integrations::Scripting::Entity { + public: + Human(flecs::entity_t ent): Entity(ent) { + const auto humanData = _ent.get(); + + if (!humanData) { + throw std::runtime_error(fmt::format("Entity handle '{}' is not a Human!", ent)); + } + } + + Human(flecs::entity ent): Human(ent.id()) {} + + std::string ToString() const override; + + void AddWeapon(int weaponId, int ammo); + + float GetHealth() const; + + void SetHealth(float health); + + Vehicle GetVehicle() const; + + int GetVehicleSeat() const; + + static void Register(sol::state &luaEngine); + }; +} // namespace MafiaMP::Scripting diff --git a/code/server/src/core/builtins/player.cpp b/code/server/src/core/builtins/player.cpp index 47226c15..ec1a9c54 100644 --- a/code/server/src/core/builtins/player.cpp +++ b/code/server/src/core/builtins/player.cpp @@ -1,91 +1,49 @@ + #include "player.h" -#include "vehicle.h" +#include "core/server.h" -#include "shared/modules/human_sync.hpp" -#include "shared/game_rpc/add_weapon.h" -#include "shared/game_rpc/human/human_setprops.h" #include "shared/rpc/chat_message.h" namespace MafiaMP::Scripting { - std::string Human::ToString() const { - std::ostringstream ss; - ss << "Human{ id: " << _ent.id() << " }"; - return ss.str(); + void Player::EventPlayerConnected(flecs::entity e) { + const auto engine = MafiaMP::Server::GetScriptingEngine(); + engine->InvokeEvent("onPlayerConnected", Player(e)); } - void Human::Destroy() { - // Nothing should happen here, as the entity is destroyed by the game and network systems + void Player::EventPlayerDisconnected(flecs::entity e) { + const auto engine = MafiaMP::Server::GetScriptingEngine(); + engine->InvokeEvent("onPlayerDisconnected", Player(e)); } - void Human::AddWeapon(int weaponId, int ammo) { - FW_SEND_SERVER_COMPONENT_GAME_RPC(MafiaMP::Shared::RPC::AddWeapon, _ent, weaponId, ammo); + void Player::EventPlayerDied(flecs::entity e) { + const auto engine = MafiaMP::Server::GetScriptingEngine(); + engine->InvokeEvent("onPlayerDied", Player(e)); } - void Human::SendChat(std::string message) { - const auto str = _ent.get(); - FW_SEND_COMPONENT_RPC_TO(Shared::RPC::ChatMessage, SLNet::RakNetGUID(str->guid), message); + std::string Player::ToString() const { + std::ostringstream ss; + ss << "Player{ id: " << _ent.id() << " }"; + return ss.str(); } - Vehicle Human::GetVehicle() const { - const auto updateData = _ent.get(); - const auto carEnt = flecs::entity(_ent.world(), updateData->carPassenger.carId); - if (carEnt.is_valid() && carEnt.is_alive()) { - return Vehicle(carEnt); - } - return Vehicle(-1); + void Player::Destroy() { + // Nothing should happen here, as the player entity is destroyed by the game and network systems } - int Human::GetVehicleSeat() const { - const auto updateData = _ent.get(); - const auto carEnt = flecs::entity(_ent.world(), updateData->carPassenger.carId); - if (carEnt.is_valid() && carEnt.is_alive()) { - return updateData->carPassenger.seatId; - } - return -1; + void Player::SendChat(std::string message) { + const auto str = _ent.get(); + FW_SEND_COMPONENT_RPC_TO(Shared::RPC::ChatMessage, SLNet::RakNetGUID(str->guid), message); } - void Human::SendChatToAll(std::string message) { + void Player::SendChatToAll(std::string message) { FW_SEND_COMPONENT_RPC(Shared::RPC::ChatMessage, message); } - void Human::SetHealth(float health) { - auto h = _ent.get_mut(); - h->_healthPercent = health; - MafiaMP::Shared::RPC::HumanSetProps msg {}; - msg.health = health; - FW_SEND_SERVER_COMPONENT_GAME_RPC(MafiaMP::Shared::RPC::HumanSetProps, _ent, msg); - } - - float Human::GetHealth() const { - auto h = _ent.get(); - return h->_healthPercent; - } - - void Human::EventPlayerDied(flecs::entity e) { - const auto engine = MafiaMP::Server::GetScriptingEngine(); - engine->InvokeEvent("onPlayerDied", Human(e)); - } - - void Human::EventPlayerConnected(flecs::entity e) { - const auto engine = MafiaMP::Server::GetScriptingEngine(); - engine->InvokeEvent("onPlayerConnected", Human(e)); - } - - void Human::EventPlayerDisconnected(flecs::entity e) { - const auto engine = MafiaMP::Server::GetScriptingEngine(); - engine->InvokeEvent("onPlayerDisconnected", Human(e)); - } - - void Human::Register(sol::state &luaEngine) { - sol::usertype cls = luaEngine.new_usertype("Human", sol::constructors(), sol::base_classes, sol::bases()); - cls["destroy"] = &Human::Destroy; - cls["addWeapon"] = &Human::AddWeapon; - cls["setHealth"] = &Human::SetHealth; - cls["getHealth"] = &Human::GetHealth; - cls["getVehicle"] = &Human::GetVehicle; - cls["getVehicleSeat"] = &Human::GetVehicleSeat; - cls["sendChat"] = &Human::SendChat; - cls["sendChatToAll"] = &Human::SendChatToAll; + void Player::Register(sol::state &luaEngine) { + sol::usertype cls = luaEngine.new_usertype("Player", sol::constructors(), sol::base_classes, sol::bases()); + cls["destroy"] = &Player::Destroy; + cls["sendChat"] = &Player::SendChat; + cls["sendChatToAll"] = &Player::SendChatToAll; } -} +} // namespace MafiaMP::Scripting diff --git a/code/server/src/core/builtins/player.h b/code/server/src/core/builtins/player.h index 0903adcd..11914e2f 100644 --- a/code/server/src/core/builtins/player.h +++ b/code/server/src/core/builtins/player.h @@ -2,44 +2,29 @@ #include -#include "integrations/server/scripting/builtins/entity.h" -#include "shared/modules/human_sync.hpp" -#include "scripting/server_engine.h" +#include "human.h" namespace MafiaMP::Scripting { - class Vehicle; - class Human final: public Framework::Integrations::Scripting::Entity { + class Player final: public MafiaMP::Scripting::Human { public: - Human(flecs::entity_t ent): Entity(ent) { - const auto humanData = _ent.get(); + Player(flecs::entity_t ent): Human(ent) {} - if (!humanData) { - throw std::runtime_error(fmt::format("Entity handle '{}' is not a Human!", ent)); - } - } + Player(flecs::entity ent): Human(ent.id()) {} - Human(flecs::entity ent): Human(ent.id()) {} - - static void EventPlayerDied(flecs::entity e); static void EventPlayerConnected(flecs::entity e); + static void EventPlayerDisconnected(flecs::entity e); - static void Register(sol::state &luaEngine); + static void EventPlayerDied(flecs::entity e); std::string ToString() const override; void Destroy(); - void AddWeapon(int weaponId, int ammo); - void SendChat(std::string message); - Vehicle GetVehicle() const; - int GetVehicleSeat() const; - static void SendChatToAll(std::string message); - void SetHealth(float health); - float GetHealth() const; + static void Register(sol::state &luaEngine); }; } // namespace MafiaMP::Scripting diff --git a/code/server/src/core/builtins/vehicle.cpp b/code/server/src/core/builtins/vehicle.cpp index 263d659e..c7b17aeb 100644 --- a/code/server/src/core/builtins/vehicle.cpp +++ b/code/server/src/core/builtins/vehicle.cpp @@ -1,17 +1,18 @@ #include "vehicle.h" -#include "player.h" -#include "scripting/engine.h" +#include "core/server.h" #include "shared/game_rpc/vehicle/vehicle_setprops.h" #include "shared/modules/vehicle_sync.hpp" +#include "player.h" + namespace MafiaMP::Scripting { void Vehicle::EventVehiclePlayerEnter(flecs::entity vehicle, flecs::entity player, int seatIndex) { const auto engine = MafiaMP::Server::GetScriptingEngine(); auto vehicleObj = Vehicle(vehicle); - auto playerObj = Human(player); + auto playerObj = Player(player); engine->InvokeEvent("onVehiclePlayerEnter", vehicleObj, playerObj, seatIndex); } @@ -20,7 +21,7 @@ namespace MafiaMP::Scripting { const auto engine = MafiaMP::Server::GetScriptingEngine(); auto vehicleObj = Vehicle(vehicle); - auto playerObj = Human(player); + auto playerObj = Player(player); engine->InvokeEvent("onVehiclePlayerLeave", vehicleObj, playerObj); } @@ -253,35 +254,35 @@ namespace MafiaMP::Scripting { void Vehicle::Register(sol::state &luaEngine) { sol::usertype cls = luaEngine.new_usertype("Vehicle", sol::constructors(), sol::base_classes, sol::bases()); - cls["getBeaconLightsOn"] = &Vehicle::GetBeaconLightsOn; - cls["setBeaconLightsOn"] = &Vehicle::SetBeaconLightsOn; - cls["getColorPrimary"] = &Vehicle::GetColorPrimary; - cls["setColorPrimary"] = &Vehicle::SetColorPrimary; - cls["getColorSecondary"] = &Vehicle::GetColorSecondary; - cls["setColorSecondary"] = &Vehicle::SetColorSecondary; - cls["getDirt"] = &Vehicle::GetDirt; - cls["setDirt"] = &Vehicle::SetDirt; - cls["getEngineOn"] = &Vehicle::GetEngineOn; - cls["setEngineOn"] = &Vehicle::SetEngineOn; - cls["getFuel"] = &Vehicle::GetFuel; - cls["setFuel"] = &Vehicle::SetFuel; - cls["getLicensePlate"] = &Vehicle::GetLicensePlate; - cls["setLicensePlate"] = &Vehicle::SetLicensePlate; - cls["getLockState"] = &Vehicle::GetLockState; - cls["setLockState"] = &Vehicle::SetLockState; - cls["getRadioOn"] = &Vehicle::GetRadioOn; - cls["setRadioOn"] = &Vehicle::SetRadioOn; - cls["getRadioStationId"] = &Vehicle::GetRadioStationId; - cls["setRadioStationId"] = &Vehicle::SetRadioStationId; - cls["getRimColor"] = &Vehicle::GetRimColor; - cls["setRimColor"] = &Vehicle::SetRimColor; - cls["getRust"] = &Vehicle::GetRust; - cls["setRust"] = &Vehicle::SetRust; - cls["getSirenOn"] = &Vehicle::GetSirenOn; - cls["setSirenOn"] = &Vehicle::SetSirenOn; - cls["getTireColor"] = &Vehicle::GetTireColor; - cls["setTireColor"] = &Vehicle::SetTireColor; - cls["getWindowTint"] = &Vehicle::GetWindowTint; - cls["setWindowTint"] = &Vehicle::SetWindowTint; + cls["getBeaconLightsOn"] = &Vehicle::GetBeaconLightsOn; + cls["setBeaconLightsOn"] = &Vehicle::SetBeaconLightsOn; + cls["getColorPrimary"] = &Vehicle::GetColorPrimary; + cls["setColorPrimary"] = &Vehicle::SetColorPrimary; + cls["getColorSecondary"] = &Vehicle::GetColorSecondary; + cls["setColorSecondary"] = &Vehicle::SetColorSecondary; + cls["getDirt"] = &Vehicle::GetDirt; + cls["setDirt"] = &Vehicle::SetDirt; + cls["getEngineOn"] = &Vehicle::GetEngineOn; + cls["setEngineOn"] = &Vehicle::SetEngineOn; + cls["getFuel"] = &Vehicle::GetFuel; + cls["setFuel"] = &Vehicle::SetFuel; + cls["getLicensePlate"] = &Vehicle::GetLicensePlate; + cls["setLicensePlate"] = &Vehicle::SetLicensePlate; + cls["getLockState"] = &Vehicle::GetLockState; + cls["setLockState"] = &Vehicle::SetLockState; + cls["getRadioOn"] = &Vehicle::GetRadioOn; + cls["setRadioOn"] = &Vehicle::SetRadioOn; + cls["getRadioStationId"] = &Vehicle::GetRadioStationId; + cls["setRadioStationId"] = &Vehicle::SetRadioStationId; + cls["getRimColor"] = &Vehicle::GetRimColor; + cls["setRimColor"] = &Vehicle::SetRimColor; + cls["getRust"] = &Vehicle::GetRust; + cls["setRust"] = &Vehicle::SetRust; + cls["getSirenOn"] = &Vehicle::GetSirenOn; + cls["setSirenOn"] = &Vehicle::SetSirenOn; + cls["getTireColor"] = &Vehicle::GetTireColor; + cls["setTireColor"] = &Vehicle::SetTireColor; + cls["getWindowTint"] = &Vehicle::GetWindowTint; + cls["setWindowTint"] = &Vehicle::SetWindowTint; } } // namespace MafiaMP::Scripting diff --git a/code/server/src/core/builtins/world.h b/code/server/src/core/builtins/world.h index 8ed262b5..c9d082b9 100644 --- a/code/server/src/core/builtins/world.h +++ b/code/server/src/core/builtins/world.h @@ -2,20 +2,28 @@ #include -#include "scripting/server_engine.h" +#include "core/server.h" +#include "core_modules.h" -#include "../modules/environment.h" -#include "../modules/vehicle.h" +#include "core/modules/environment.h" +#include "core/modules/vehicle.h" -#include "../../shared/rpc/environment.h" +#include "shared/rpc/environment.h" #include "vehicle.h" -#include "core_modules.h" - namespace MafiaMP::Scripting { class World final { public: + static Vehicle CreateVehicle(std::string modelName) { + auto e = MafiaMP::Core::Modules::Vehicle::Create(Server::_serverRef); + + auto &frame = e.ensure(); + frame.modelName = modelName; + + return Vehicle(e); + } + static void SetWeather(std::string weatherSetName) { auto world = Framework::CoreModules::GetWorldEngine()->GetWorld(); @@ -32,20 +40,11 @@ namespace MafiaMP::Scripting { FW_SEND_COMPONENT_RPC(MafiaMP::Shared::RPC::SetEnvironment, {}, weather->_dayTimeHours); } - static Vehicle CreateVehicle(std::string modelName) { - auto e = MafiaMP::Core::Modules::Vehicle::Create(Server::_serverRef); - - auto &frame = e.ensure(); - frame.modelName = modelName; - - return Vehicle(e); - } - static void Register(sol::state &luaEngine) { sol::usertype cls = luaEngine.new_usertype("World"); + cls["createVehicle"] = &World::CreateVehicle; cls["setWeather"] = &World::SetWeather; cls["setDayTimeHours"] = &World::SetDayTimeHours; - cls["createVehicle"] = &World::CreateVehicle; } }; } // namespace MafiaMP::Scripting diff --git a/code/server/src/core/modules/human.cpp b/code/server/src/core/modules/human.cpp index 3393f018..9be0e9e8 100644 --- a/code/server/src/core/modules/human.cpp +++ b/code/server/src/core/modules/human.cpp @@ -23,7 +23,7 @@ namespace MafiaMP::Core::Modules { } void Human::Create(Framework::Networking::NetworkServer *net, flecs::entity e) { - auto &frame = e.ensure(); + auto &frame = e.ensure(); frame.modelHash = 335218123840277515; /* TODO */ e.add(); @@ -156,7 +156,7 @@ namespace MafiaMP::Core::Modules { return; } - Scripting::Human::EventPlayerDied(e); + Scripting::Player::EventPlayerDied(e); }); } } // namespace MafiaMP::Core::Modules diff --git a/code/server/src/core/modules/human.h b/code/server/src/core/modules/human.h index 9fed4980..a1a68826 100644 --- a/code/server/src/core/modules/human.h +++ b/code/server/src/core/modules/human.h @@ -5,14 +5,14 @@ namespace MafiaMP::Core::Modules { class Human { + private: + static void InitRPCs(std::shared_ptr srv, Framework::Networking::NetworkServer *net); + public: Human(flecs::world &world); static void Create(Framework::Networking::NetworkServer *net, flecs::entity e); static void SetupMessages(std::shared_ptr srv, Framework::Networking::NetworkServer *net); - - private: - static void InitRPCs(std::shared_ptr srv, Framework::Networking::NetworkServer *net); }; -} // namespace MafiaMP +} // namespace MafiaMP::Core::Modules diff --git a/code/server/src/core/modules/vehicle.cpp b/code/server/src/core/modules/vehicle.cpp index 7b68788c..939fe61f 100644 --- a/code/server/src/core/modules/vehicle.cpp +++ b/code/server/src/core/modules/vehicle.cpp @@ -45,7 +45,7 @@ namespace MafiaMP::Core::Modules { const auto net = server->GetNetworkingEngine()->GetNetworkServer(); auto e = server->GetWorldEngine()->CreateEntity(); server->GetStreamingFactory()->SetupServer(e, SLNet::UNASSIGNED_RAKNET_GUID.g); - auto& frame = e.ensure(); + auto &frame = e.ensure(); frame.modelName = "berkley_810"; /* TODO */ auto updateData = e.ensure(); @@ -143,7 +143,7 @@ namespace MafiaMP::Core::Modules { } void Vehicle::InitRPCs(std::shared_ptr srv, Framework::Networking::NetworkServer *net) { - net->RegisterGameRPC([srv](SLNet::RakNetGUID guid, Shared::RPC::VehiclePlayerEnter* msg) { + net->RegisterGameRPC([srv](SLNet::RakNetGUID guid, Shared::RPC::VehiclePlayerEnter *msg) { const auto playerEntity = srv->GetEntityByGUID(guid.g); if (!playerEntity.is_alive()) { return; diff --git a/code/server/src/core/modules/vehicle.h b/code/server/src/core/modules/vehicle.h index 80c58e0b..ab5333b8 100644 --- a/code/server/src/core/modules/vehicle.h +++ b/code/server/src/core/modules/vehicle.h @@ -10,7 +10,7 @@ namespace MafiaMP::Core::Modules { public: // server only data struct CarData { - uint64_t seats[4]{}; + uint64_t seats[4] {}; }; Vehicle(flecs::world &world); diff --git a/code/server/src/core/server.cpp b/code/server/src/core/server.cpp index 0024b444..4b9ec3af 100644 --- a/code/server/src/core/server.cpp +++ b/code/server/src/core/server.cpp @@ -29,7 +29,7 @@ namespace MafiaMP { GetWorldEngine()->GetWorld()->import (); // Setup specific components - default values - auto weather = GetWorldEngine()->GetWorld()->ensure(); + auto weather = GetWorldEngine()->GetWorld()->ensure(); weather._weatherSetName = "_default_game"; weather._dayTimeHours = 11.0f; } @@ -49,11 +49,11 @@ namespace MafiaMP { const auto weather = GetWorldEngine()->GetWorld()->get(); FW_SEND_COMPONENT_RPC_TO(Shared::RPC::SetEnvironment, SLNet::RakNetGUID(guid), SLNet::RakString(weather->_weatherSetName.c_str()), weather->_dayTimeHours); - Scripting::Human::EventPlayerConnected(player); + Scripting::Player::EventPlayerConnected(player); }); SetOnPlayerDisconnectCallback([this](flecs::entity player, uint64_t) { - Scripting::Human::EventPlayerDisconnected(player); + Scripting::Player::EventPlayerDisconnected(player); }); InitRPCs(); diff --git a/code/server/src/core/server.h b/code/server/src/core/server.h index 4b9ea788..271a1f18 100644 --- a/code/server/src/core/server.h +++ b/code/server/src/core/server.h @@ -9,7 +9,7 @@ namespace MafiaMP { private: static inline Framework::Scripting::ServerEngine *_scriptingEngine; void InitNetworkingMessages(); - + public: void PostInit() override; @@ -23,7 +23,7 @@ namespace MafiaMP { static inline Server *_serverRef = nullptr; - static Framework::Scripting::ServerEngine* GetScriptingEngine() { + static Framework::Scripting::ServerEngine *GetScriptingEngine() { return _scriptingEngine; } }; diff --git a/code/shared/game_rpc/add_weapon.h b/code/shared/game_rpc/human/human_add_weapon.h similarity index 89% rename from code/shared/game_rpc/add_weapon.h rename to code/shared/game_rpc/human/human_add_weapon.h index 976b8705..365fa1dd 100644 --- a/code/shared/game_rpc/add_weapon.h +++ b/code/shared/game_rpc/human/human_add_weapon.h @@ -6,7 +6,7 @@ #include namespace MafiaMP::Shared::RPC { - class AddWeapon final: public Framework::Networking::RPC::IGameRPC { + class HumanAddWeapon final: public Framework::Networking::RPC::IGameRPC { private: int weaponId; int ammo;