fixe some spacey string

be smater about pausing
This commit is contained in:
Aaron Kimbre 2023-08-16 15:53:13 -05:00
parent 691a42ba20
commit 2bb39f4fa5
2 changed files with 9 additions and 7 deletions

View File

@ -11,16 +11,15 @@
#include "DestroyableComponent.h" #include "DestroyableComponent.h"
void MovementAIComponent::HandleWaypointArrived(uint32_t commandIndex) { void MovementAIComponent::HandleWaypointArrived(uint32_t commandIndex) {
Pause();
if (!m_Path){ if (!m_Path){
Resume(); if(IsPaused()) Resume();
return; return;
} }
if (commandIndex >= m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.size()){ if (commandIndex >= m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.size()){
Resume(); if(IsPaused()) Resume();
return; return;
} }
if(!IsPaused()) Pause();
const auto& data = m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.at(commandIndex).data; const auto& data = m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.at(commandIndex).data;
const auto& command = m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.at(commandIndex).command; const auto& command = m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.at(commandIndex).command;
float delay = 0.0f; float delay = 0.0f;
@ -150,7 +149,7 @@ void MovementAIComponent::HandleWaypointCommandUnequipInventory(const std::strin
float MovementAIComponent::HandleWaypointCommandDelay(const std::string& data) { float MovementAIComponent::HandleWaypointCommandDelay(const std::string& data) {
float delay = 0.0f; float delay = 0.0f;
std::string delayString = data; std::string delayString = data;
std::remove_if(delayString.begin(), delayString.end(), ::isspace); delayString.erase(std::remove_if(delayString.begin(), delayString.end(), isspace), delayString.end());
GeneralUtils::TryParse<float>(delayString, delay); GeneralUtils::TryParse<float>(delayString, delay);
return delay; return delay;
} }

View File

@ -549,8 +549,11 @@ void Zone::LoadPath(std::istream& file) {
LDFBaseData* ldfConfig = nullptr; LDFBaseData* ldfConfig = nullptr;
if (path.pathType == PathType::Movement || path.pathType == PathType::Rail) { if (path.pathType == PathType::Movement || path.pathType == PathType::Rail) {
// :+1: // cause NetDevil puts spaces in things that don't need spaces
waypoint.commands.push_back(WaypointCommand(WaypointCommandType::StringToWaypointCommandType(parameter), value)); parameter.erase(std::remove_if(parameter.begin(), parameter.end(), isspace), parameter.end());
auto waypointCommand = WaypointCommandType::StringToWaypointCommandType(parameter);
if(waypointCommand != eWaypointCommandType::INVALID) waypoint.commands.push_back(WaypointCommand(waypointCommand, value));
else Game::logger->Log("Zone", "Tried to load invalid waypoint command '%s'", parameter.c_str());
} else { } else {
ldfConfig = LDFBaseData::DataFromString(parameter + "=" + value); ldfConfig = LDFBaseData::DataFromString(parameter + "=" + value);
if (ldfConfig) waypoint.config.push_back(ldfConfig); if (ldfConfig) waypoint.config.push_back(ldfConfig);