[Strings] Refactor Strings Usage (#2305)

* Initial commit checkpoint

* More functions converted

* Commify

* More functions

* Fin

* Sort declarations

* Split functions between files

* Bots

* Update strings.h

* Split

* Revert find replaces

* Repository template

* Money

* Misc function

* Update CMakeLists.txt

* Saylink

* Update strings.cpp

* Swap Strings::Saylink for Saylink::Create since saylink is coupled to zone database

* API casings
This commit is contained in:
Chris Miles
2022-07-14 02:10:52 -05:00
committed by GitHub
parent 44c85a0dd7
commit dfd8f84cac
573 changed files with 5197 additions and 5137 deletions
+37 -37
View File
@@ -12,7 +12,7 @@
#include "zone.h"
#include "client.h"
#include "../common/eqemu_logsys.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/rulesys.h"
extern Zone *zone;
@@ -123,26 +123,26 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g
if (result_start_n.size() == 0) {
return IPath();
}
std::vector<RTreeValue> result_end_n;
m_impl->Tree.query(boost::geometry::index::nearest(Point(end.x, end.y, end.z), 1), std::back_inserter(result_end_n));
if (result_end_n.size() == 0) {
return IPath();
}
auto &nearest_start = *result_start_n.begin();
auto &nearest_end = *result_end_n.begin();
if (nearest_start.second == nearest_end.second) {
IPath Route;
Route.push_back(start);
Route.push_back(end);
return Route;
}
std::vector<GraphType::vertex_descriptor> p(boost::num_vertices(m_impl->Graph));
try {
boost::astar_search(m_impl->Graph, nearest_start.second,
boost::astar_search(m_impl->Graph, nearest_start.second,
distance_heuristic<GraphType, float, Node*>(&m_impl->Nodes[0], nearest_end.second),
boost::predecessor_map(&p[0])
.visitor(astar_goal_visitor<size_t>(nearest_end.second)));
@@ -150,7 +150,7 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g
catch (found_goal)
{
IPath Route;
Route.push_front(end);
for (size_t v = nearest_end.second;; v = p[v]) {
if (p[v] == v) {
@@ -159,7 +159,7 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g
}
else {
auto &node = m_impl->Nodes[v];
auto iter = node.edges.find((int)p[v + 1]);
if (iter != node.edges.end()) {
auto &edge = iter->second;
@@ -176,11 +176,11 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g
}
}
}
Route.push_front(start);
return Route;
}
return IPath();
}
@@ -192,7 +192,7 @@ glm::vec3 PathfinderWaypoint::GetRandomLocation(const glm::vec3 &start)
return node.v;
}
return glm::vec3();
}
@@ -205,32 +205,32 @@ void PathfinderWaypoint::DebugCommand(Client *c, const Seperator *sep)
c->Message(Chat::White, "#path info node_id: Gives information about node info (requires shownode target).");
return;
}
if(!strcasecmp(sep->arg[1], "shownodes"))
{
ShowNodes();
ShowNodes();
return;
}
if (!strcasecmp(sep->arg[1], "show"))
{
if (c->GetTarget() != nullptr) {
auto target = c->GetTarget();
glm::vec3 start(c->GetX(), c->GetY(), c->GetZ());
glm::vec3 end(target->GetX(), target->GetY(), target->GetZ());
ShowPath(c, start, end);
}
return;
}
if (!strcasecmp(sep->arg[1], "reload"))
{
Load(m_impl->FileName);
return;
}
if (!strcasecmp(sep->arg[1], "info"))
{
NodeInfo(c);
@@ -242,25 +242,25 @@ void PathfinderWaypoint::Load(const std::string &filename) {
PathFileHeader Head;
Head.PathNodeCount = 0;
Head.version = 2;
FILE *f = fopen(filename.c_str(), "rb");
if (f) {
char Magic[10];
fread(&Magic, 9, 1, f);
if (strncmp(Magic, "EQEMUPATH", 9))
{
LogError("Bad Magic String in .path file");
fclose(f);
return;
}
fread(&Head, sizeof(Head), 1, f);
LogInfo("Path File Header: Version [{}], PathNodes [{}]",
(long)Head.version, (long)Head.PathNodeCount);
if (Head.version == 2)
{
LoadV2(f, Head);
@@ -281,13 +281,13 @@ void PathfinderWaypoint::Load(const std::string &filename) {
void PathfinderWaypoint::LoadV2(FILE *f, const PathFileHeader &header)
{
std::unique_ptr<PathNode[]> PathNodes(new PathNode[header.PathNodeCount]);
fread(PathNodes.get(), sizeof(PathNode), header.PathNodeCount, f);
int MaxNodeID = header.PathNodeCount - 1;
m_impl->PathFileValid = true;
m_impl->Nodes.reserve(header.PathNodeCount);
for (uint32 i = 0; i < header.PathNodeCount; ++i)
{
@@ -298,7 +298,7 @@ void PathfinderWaypoint::LoadV2(FILE *f, const PathFileHeader &header)
node.bestz = n.bestz;
m_impl->Nodes.push_back(node);
}
auto weightmap = boost::get(boost::edge_weight, m_impl->Graph);
for (uint32 i = 0; i < header.PathNodeCount; ++i) {
for (uint32 j = 0; j < 50; ++j)
@@ -309,18 +309,18 @@ void PathfinderWaypoint::LoadV2(FILE *f, const PathFileHeader &header)
LogError("Path Node [{}], Neighbour [{}] ([{}]) out of range", i, j, PathNodes[i].Neighbours[j].id);
m_impl->PathFileValid = false;
}
if (PathNodes[i].Neighbours[j].id > 0) {
Edge edge;
edge.distance = PathNodes[i].Neighbours[j].distance;
edge.door_id = PathNodes[i].Neighbours[j].DoorID;
edge.teleport = PathNodes[i].Neighbours[j].Teleport;
node.edges[PathNodes[i].Neighbours[j].id] = edge;
}
}
}
BuildGraph();
fclose(f);
}
@@ -339,7 +339,7 @@ void PathfinderWaypoint::LoadV3(FILE *f, const PathFileHeader &header)
float y = 0.0f;
float z = 0.0f;
float best_z = 0.0f;
fread(&id, sizeof(uint32), 1, f);
fread(&x, sizeof(float), 1, f);
fread(&y, sizeof(float), 1, f);
@@ -352,7 +352,7 @@ void PathfinderWaypoint::LoadV3(FILE *f, const PathFileHeader &header)
n.v.x = x;
n.v.y = y;
n.v.z = z;
m_impl->Nodes.push_back(n);
}
@@ -377,10 +377,10 @@ void PathfinderWaypoint::LoadV3(FILE *f, const PathFileHeader &header)
auto &n = m_impl->Nodes[from];
n.edges[to] = e;
}
m_impl->PathFileValid = true;
BuildGraph();
BuildGraph();
fclose(f);
}