mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-05 19:32:25 +00:00
- License was intended to be GPLv3 per earlier commit of GPLv3 LICENSE FILE - This is confirmed by the inclusion of libraries that are incompatible with GPLv2 - This is also confirmed by KLS and the agreement of KLS's predecessors - Added GPLv3 license headers to the compilable source files - Removed Folly licensing in strings.h since the string functions do not match the Folly functions and are standard functions - this must have been left over from previous implementations - Removed individual contributor license headers since the project has been under the "developer" mantle for many years - Removed comments on files that were previously automatically generated since they've been manually modified multiple times and there are no automatic scripts referencing them (removed in 2023)
183 lines
5.3 KiB
C++
Executable File
183 lines
5.3 KiB
C++
Executable File
/* EQEmu: EQEmulator
|
|
|
|
Copyright (C) 2001-2026 EQEmu Development Team
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "common/repositories/grid_entries_repository.h"
|
|
#include "zone/client.h"
|
|
|
|
void command_grid(Client *c, const Seperator *sep)
|
|
{
|
|
const uint16 arguments = sep->argnum;
|
|
|
|
if (!arguments) {
|
|
c->Message(Chat::White, "Usage: #grid add [Grid ID] [Wander Type] [Pause Type] - Add a grid with the specified wander and pause type");
|
|
c->Message(Chat::White, "Usage: #grid delete [Grid ID] - Delete a grid");
|
|
c->Message(Chat::White, "Usage: #grid hide - Hides waypoint nodes from targeted NPC's grid");
|
|
c->Message(Chat::White, "Usage: #grid max - Displays the highest grid ID used in this zone (for add)");
|
|
c->Message(Chat::White, "Usage: #grid show - Displays waypoint nodes for targeted NPC's grid");
|
|
return;
|
|
}
|
|
|
|
const bool is_add = !strcasecmp(sep->arg[1], "add");
|
|
const bool is_delete = !strcasecmp(sep->arg[1], "delete");
|
|
const bool is_hide = !strcasecmp(sep->arg[1], "hide");
|
|
const bool is_max = !strcasecmp(sep->arg[1], "max");
|
|
const bool is_show = !strcasecmp(sep->arg[1], "show");
|
|
|
|
if (!is_add && !is_delete && !is_hide && !is_max && !is_show) {
|
|
c->Message(Chat::White, "Usage: #grid add [Grid ID] [Wander Type] [Pause Type] - Add a grid with the specified wander and pause type");
|
|
c->Message(Chat::White, "Usage: #grid delete [Grid ID] - Delete a grid");
|
|
c->Message(Chat::White, "Usage: #grid hide - Hides waypoint nodes from targeted NPC's grid");
|
|
c->Message(Chat::White, "Usage: #grid max - Displays the highest grid ID used in this zone (for add)");
|
|
c->Message(Chat::White, "Usage: #grid show - Displays waypoint nodes for targeted NPC's grid");
|
|
return;
|
|
}
|
|
|
|
if (is_add) {
|
|
const uint32 grid_id = Strings::ToUnsignedInt(sep->arg[2]);
|
|
const uint8 wander_type = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[3]));
|
|
const uint8 pause_type = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[4]));
|
|
|
|
if (!grid_id) {
|
|
c->Message(Chat::White, "You must specify a valid grid ID.");
|
|
return;
|
|
}
|
|
|
|
if (!content_db.GridExistsInZone(zone->GetZoneID(), grid_id)) {
|
|
content_db.ModifyGrid(c, false, grid_id, wander_type, pause_type, zone->GetZoneID());
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Grid {} added to zone ID {} with wander type {} and pause type {}.",
|
|
grid_id,
|
|
zone->GetZoneID(),
|
|
wander_type,
|
|
pause_type
|
|
).c_str()
|
|
);
|
|
} else {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Grid {} already exists in zone ID {}.",
|
|
grid_id,
|
|
zone->GetZoneID()
|
|
).c_str()
|
|
);
|
|
}
|
|
} else if (is_delete) {
|
|
const uint32 grid_id = Strings::ToUnsignedInt(sep->arg[2]);
|
|
|
|
content_db.ModifyGrid(c, true, grid_id, 0, 0, zone->GetZoneID());
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Grid {} deleted from zone ID {}.",
|
|
grid_id,
|
|
zone->GetZoneID()
|
|
).c_str()
|
|
);
|
|
} else if (is_hide) {
|
|
Mob* t = c->GetTarget();
|
|
if (!t || !t->IsNPC()) {
|
|
c->Message(Chat::White, "You must target an NPC to use this command.");
|
|
return;
|
|
}
|
|
|
|
const uint32 grid_id = t->CastToNPC()->GetGrid();
|
|
|
|
entity_list.DespawnGridNodes(grid_id);
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Depawning nodes for grid {}.",
|
|
grid_id
|
|
).c_str()
|
|
);
|
|
} else if (is_max) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Highest grid ID in this zone is {}.",
|
|
content_db.GetHighestGrid(zone->GetZoneID())
|
|
).c_str()
|
|
);
|
|
} else if (is_show) {
|
|
Mob* t = c->GetTarget();
|
|
if (!t || !t->IsNPC()) {
|
|
c->Message(Chat::White, "You must target an NPC to use this command.");
|
|
return;
|
|
}
|
|
|
|
const uint32 grid_id = t->CastToNPC()->GetGrid();
|
|
|
|
const auto& l = GridEntriesRepository::GetWhere(
|
|
content_db,
|
|
fmt::format(
|
|
"`zoneid` = {} AND `gridid` = {} ORDER BY `number`",
|
|
zone->GetZoneID(),
|
|
grid_id
|
|
)
|
|
);
|
|
|
|
if (l.empty()) {
|
|
c->Message(Chat::White, "No grid found.");
|
|
return;
|
|
}
|
|
|
|
// Depop any grid nodes already spawned
|
|
entity_list.DespawnGridNodes(grid_id);
|
|
|
|
// Spawn grid nodes
|
|
std::map<std::vector<float>, int32> zoffset;
|
|
|
|
for (const auto& e : l) {
|
|
glm::vec4 node_position = glm::vec4(e.x, e.y, e.z, e.heading);
|
|
|
|
std::vector<float> node_loc{
|
|
node_position.x,
|
|
node_position.y,
|
|
node_position.z
|
|
};
|
|
|
|
// If we already have a node at this location, set the z offset
|
|
// higher from the existing one, so we can see it. Adjust so if
|
|
// there is another at the same spot we adjust again.
|
|
auto search = zoffset.find(node_loc);
|
|
if (search != zoffset.end()) {
|
|
search->second += 3;
|
|
} else {
|
|
zoffset[node_loc] = 0.0;
|
|
}
|
|
|
|
node_position.z += zoffset[node_loc];
|
|
|
|
NPC::SpawnGridNodeNPC(node_position, grid_id, e.number, zoffset[node_loc]);
|
|
}
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Spawning nodes for grid {}.",
|
|
grid_id
|
|
).c_str()
|
|
);
|
|
}
|
|
}
|