mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 00:46:46 +00:00
Fixes to #grid show. Added new string utilities.
This commit is contained in:
+24
-13
@@ -2438,10 +2438,10 @@ void command_grid(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
std::string query = StringFormat(
|
||||
"SELECT `x`, `y`, `z`, `heading`, `number`, `pause` "
|
||||
"SELECT `x`, `y`, `z`, `heading`, `number` "
|
||||
"FROM `grid_entries` "
|
||||
"WHERE `zoneid` = %u and `gridid` = %i "
|
||||
"ORDER BY `number` ",
|
||||
"ORDER BY `number`",
|
||||
zone->GetZoneID(),
|
||||
target->CastToNPC()->GetGrid()
|
||||
);
|
||||
@@ -2471,18 +2471,29 @@ void command_grid(Client *c, const Seperator *sep)
|
||||
/**
|
||||
* Spawn grid nodes
|
||||
*/
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
auto node_position = glm::vec4(atof(row[0]), atof(row[1]), atof(row[2]), atof(row[3]));
|
||||
std::map<std::vector<float>, int32> zoffset;
|
||||
|
||||
NPC *npc = NPC::SpawnGridNodeNPC(
|
||||
target->GetCleanName(),
|
||||
node_position,
|
||||
static_cast<uint32>(target->CastToNPC()->GetGrid()),
|
||||
static_cast<uint32>(atoi(row[4])),
|
||||
static_cast<uint32>(atoi(row[5]))
|
||||
);
|
||||
npc->SetFlyMode(GravityBehavior::Flying);
|
||||
npc->GMMove(node_position.x, node_position.y, node_position.z, node_position.w);
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
glm::vec4 node_position = glm::vec4(atof(row[0]), atof(row[1]), atof(row[2]), atof(row[3]));
|
||||
|
||||
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 = search->second + 3;
|
||||
}
|
||||
else {
|
||||
zoffset[node_loc] = 0.0;
|
||||
}
|
||||
|
||||
node_position.z += zoffset[node_loc];
|
||||
|
||||
NPC::SpawnGridNodeNPC(node_position,atoi(row[4]),zoffset[node_loc]);
|
||||
}
|
||||
}
|
||||
else if (strcasecmp("delete", sep->arg[1]) == 0) {
|
||||
|
||||
+14
-7
@@ -1068,14 +1068,20 @@ bool NPC::SpawnZoneController()
|
||||
return true;
|
||||
}
|
||||
|
||||
NPC * NPC::SpawnGridNodeNPC(std::string name, const glm::vec4 &position, uint32 grid_id, uint32 grid_number, uint32 pause) {
|
||||
void NPC::SpawnGridNodeNPC(const glm::vec4 &position, int32 grid_number, int32 zoffset) {
|
||||
|
||||
auto npc_type = new NPCType;
|
||||
memset(npc_type, 0, sizeof(NPCType));
|
||||
|
||||
sprintf(npc_type->name, "%u_%u", grid_id, grid_number);
|
||||
sprintf(npc_type->lastname, "Number: %u Grid: %u Pause: %u", grid_number, grid_id, pause);
|
||||
std::string str_zoffset = numberToWords(zoffset);
|
||||
std::string str_number= numberToWords(grid_number);
|
||||
|
||||
npc_type->current_hp = 4000000;
|
||||
strcpy(npc_type->name, str_number.c_str());
|
||||
if (zoffset != 0) {
|
||||
strcat(npc_type->name, "(Zoffset)");
|
||||
}
|
||||
|
||||
npc_type->current_hp = 4000000;
|
||||
npc_type->max_hp = 4000000;
|
||||
npc_type->race = 2254;
|
||||
npc_type->gender = 2;
|
||||
@@ -1095,11 +1101,12 @@ NPC * NPC::SpawnGridNodeNPC(std::string name, const glm::vec4 &position, uint32
|
||||
|
||||
auto node_position = glm::vec4(position.x, position.y, position.z, position.w);
|
||||
auto npc = new NPC(npc_type, nullptr, node_position, GravityBehavior::Flying);
|
||||
|
||||
npc->name[strlen(npc->name)-3] = (char) NULL;
|
||||
|
||||
npc->GiveNPCTypeData(npc_type);
|
||||
|
||||
entity_list.AddNPC(npc, true, true);
|
||||
|
||||
return npc;
|
||||
entity_list.AddNPC(npc);
|
||||
}
|
||||
|
||||
NPC * NPC::SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4 &position) {
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public:
|
||||
virtual ~NPC();
|
||||
|
||||
static NPC *SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4 &position);
|
||||
static NPC *SpawnGridNodeNPC(std::string name, const glm::vec4 &position, uint32 grid_id, uint32 grid_number, uint32 pause);
|
||||
static void SpawnGridNodeNPC(const glm::vec4 &position, int32 grid_number, int32 zoffset);
|
||||
|
||||
//abstract virtual function implementations requird by base abstract class
|
||||
virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, EQ::skills::SkillType attack_skill);
|
||||
|
||||
Reference in New Issue
Block a user