mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
Updated to new API
This commit is contained in:
parent
88e5f0e8fb
commit
685bd5d45b
@ -2175,8 +2175,8 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
|||||||
update.velocity,
|
update.velocity,
|
||||||
update.angularVelocity,
|
update.angularVelocity,
|
||||||
update.onGround,
|
update.onGround,
|
||||||
update.velocity != NiPoint3::ZERO,
|
update.velocity != NiPoint3Constant::ZERO,
|
||||||
update.angularVelocity != NiPoint3::ZERO
|
update.angularVelocity != NiPoint3Constant::ZERO
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,13 +538,13 @@ void EntityManager::CheckGhosting(Entity* entity) {
|
|||||||
|
|
||||||
const auto precondition = ServerPreconditions::CheckPreconditions(entity, player);
|
const auto precondition = ServerPreconditions::CheckPreconditions(entity, player);
|
||||||
|
|
||||||
if (observed && (distance > ghostingDistanceMax || !precondition)) {
|
if (observed && (distance > m_GhostDistanceMaxSquared || !precondition)) {
|
||||||
ghostComponent->GhostEntity(id);
|
ghostComponent->GhostEntity(id);
|
||||||
|
|
||||||
DestructEntity(entity, player->GetSystemAddress());
|
DestructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
entity->SetObservers(entity->GetObservers() - 1);
|
||||||
} else if (!observed && (ghostingDistanceMin > distance && precondition)) {
|
} else if (!observed && (m_GhostDistanceMinSqaured > distance && precondition)) {
|
||||||
ghostComponent->ObserveEntity(id);
|
ghostComponent->ObserveEntity(id);
|
||||||
|
|
||||||
ConstructEntity(entity, player->GetSystemAddress());
|
ConstructEntity(entity, player->GetSystemAddress());
|
||||||
|
@ -1081,11 +1081,7 @@ Cinema::Recording::PlayEffectRecord::PlayEffectRecord(const std::string& effect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Cinema::Recording::PlayEffectRecord::Act(Entity* actor) {
|
void Cinema::Recording::PlayEffectRecord::Act(Entity* actor) {
|
||||||
int32_t effectID = 0;
|
int32_t effectID = GeneralUtils::TryParse<int32_t>(effect).value_or(0);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(effect, effectID)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMessages::SendPlayFXEffect(
|
GameMessages::SendPlayFXEffect(
|
||||||
actor->GetObjectID(),
|
actor->GetObjectID(),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Player.h"
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
@ -716,9 +716,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "removemission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "removemission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
if (args.size() == 0) return;
|
if (args.size() == 0) return;
|
||||||
|
|
||||||
uint32_t missionID;
|
uint32_t missionID = GeneralUtils::TryParse<uint32_t>(args.at(0)).value_or(0);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], missionID)) {
|
if (missionID == 0) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -914,9 +914,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
// If there is an argument, set the lot
|
// If there is an argument, set the lot
|
||||||
if (args.size() > 0) {
|
if (args.size() > 0) {
|
||||||
if (!GeneralUtils::TryParse(args[0], info.lot)) {
|
const auto lotOptional = GeneralUtils::TryParse<LOT>(args[0]);
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid lot.");
|
if (lotOptional) {
|
||||||
return;
|
info.lot = lotOptional.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,9 +998,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
|
|
||||||
if (args.size() >= 2) {
|
if (args.size() >= 2) {
|
||||||
if (!GeneralUtils::TryParse(args[1], scale)) {
|
const auto scaleOptional = GeneralUtils::TryParse<float>(args[1]);
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid scale.");
|
if (scaleOptional) {
|
||||||
return;
|
scale = scaleOptional.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,9 +1012,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "prefab-destroy" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
if (chatCommand == "prefab-destroy" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
||||||
size_t id;
|
size_t id = GeneralUtils::TryParse<size_t>(args[0]).value_or(0);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], id)) {
|
if (id == 0) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid prefab ID.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid prefab ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2240,16 +2240,28 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args[1] == "-rotate" && args.size() >= 4) {
|
} else if (args[1] == "-rotate" && args.size() >= 4) {
|
||||||
const auto& rx = args[2];
|
const auto rx = GeneralUtils::TryParse<float>(args.at(2));
|
||||||
const auto& ry = args[3];
|
if (!rx) {
|
||||||
const auto& rz = args[4];
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
||||||
|
|
||||||
float x, y, z;
|
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(rx, x) || !GeneralUtils::TryParse(ry, y) || !GeneralUtils::TryParse(rz, z)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto ry = GeneralUtils::TryParse<float>(args.at(3));
|
||||||
|
if (!ry) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid y.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto rz = GeneralUtils::TryParse<float>(args.at(4));
|
||||||
|
if (!rz) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float x = rx.value();
|
||||||
|
float y = ry.value();
|
||||||
|
float z = rz.value();
|
||||||
|
|
||||||
// Degrees to radia
|
// Degrees to radia
|
||||||
x *= 0.0174533f;
|
x *= 0.0174533f;
|
||||||
y *= 0.0174533f;
|
y *= 0.0174533f;
|
||||||
@ -2261,41 +2273,67 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
Game::entityManager->SerializeEntity(closest);
|
Game::entityManager->SerializeEntity(closest);
|
||||||
} else if (args[1] == "-translate" && args.size() >= 4) {
|
} else if (args[1] == "-translate" && args.size() >= 4) {
|
||||||
const auto& tx = args[2];
|
const auto rx = GeneralUtils::TryParse<float>(args.at(2));
|
||||||
const auto& ty = args[3];
|
if (!rx) {
|
||||||
const auto& tz = args[4];
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
||||||
|
|
||||||
float x, y, z;
|
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(tx, x) || !GeneralUtils::TryParse(ty, y) || !GeneralUtils::TryParse(tz, z)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto ry = GeneralUtils::TryParse<float>(args.at(3));
|
||||||
|
if (!ry) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid y.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto rz = GeneralUtils::TryParse<float>(args.at(4));
|
||||||
|
if (!rz) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float x = rx.value();
|
||||||
|
float y = ry.value();
|
||||||
|
float z = rz.value();
|
||||||
|
|
||||||
const auto translation = NiPoint3(x, y, z);
|
const auto translation = NiPoint3(x, y, z);
|
||||||
|
|
||||||
closest->SetPosition(closest->GetPosition() + translation);
|
closest->SetPosition(closest->GetPosition() + translation);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(closest);
|
Game::entityManager->SerializeEntity(closest);
|
||||||
} else if (args[1] == "-warp" && args.size() >= 4) {
|
} else if (args[1] == "-warp" && args.size() >= 4) {
|
||||||
const auto& tx = args[2];
|
const auto rx = GeneralUtils::TryParse<float>(args.at(2));
|
||||||
const auto& ty = args[3];
|
if (!rx) {
|
||||||
const auto& tz = args[4];
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
||||||
|
|
||||||
float x, y, z;
|
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(tx, x) || !GeneralUtils::TryParse(ty, y) || !GeneralUtils::TryParse(tz, z)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto ry = GeneralUtils::TryParse<float>(args.at(3));
|
||||||
|
if (!ry) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid y.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto rz = GeneralUtils::TryParse<float>(args.at(4));
|
||||||
|
if (!rz) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float x = rx.value();
|
||||||
|
float y = ry.value();
|
||||||
|
float z = rz.value();
|
||||||
|
|
||||||
|
|
||||||
const auto translation = NiPoint3(x, y, z);
|
const auto translation = NiPoint3(x, y, z);
|
||||||
|
|
||||||
closest->SetPosition(translation);
|
closest->SetPosition(translation);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(closest);
|
Game::entityManager->SerializeEntity(closest);
|
||||||
} else if (args[1] == "-fx" && args.size() >= 4) {
|
} else if (args[1] == "-fx" && args.size() >= 4) {
|
||||||
int32_t effectID = 0;
|
int32_t effectID = GeneralUtils::TryParse<int32_t>(args[2]).value_or(-1);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[2], effectID)) {
|
if (effectID == -1) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid effect ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user