mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
AddSpawnFromSpawnGroup converted to QueryDatabase
This commit is contained in:
parent
a216672443
commit
0799b47c9c
72
zone/npc.cpp
72
zone/npc.cpp
@ -1241,31 +1241,52 @@ uint32 ZoneDatabase::DeleteSpawnRemoveFromNPCTypeTable(const char* zone, uint32
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::AddSpawnFromSpawnGroup(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID) {
|
uint32 ZoneDatabase::AddSpawnFromSpawnGroup(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
uint32 last_insert_id = 0;
|
||||||
MYSQL_RES *result;
|
std::string query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
||||||
MYSQL_ROW row;
|
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
||||||
uint32 tmp = 0;
|
zone, zone_version, client->GetX(), client->GetY(), client->GetZ(),
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) values('%s', %u, %f, %f, %f, %i, %f, %i)", zone, zone_version, client->GetX(), client->GetY(), client->GetZ(), 120, client->GetHeading(), spawnGroupID), errbuf, 0, 0, &tmp)) {
|
120, client->GetHeading(), spawnGroupID);
|
||||||
safe_delete(query);
|
auto results = QueryDatabase(query);
|
||||||
return false;
|
if (!results.Success())
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
if(client)
|
if(client)
|
||||||
client->LogSQL(query);
|
client->LogSQL(query.c_str());
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
return true;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 ZoneDatabase::AddNPCTypes(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID) {
|
||||||
|
|
||||||
|
uint32 npc_type_id;
|
||||||
|
char numberlessName[64];
|
||||||
|
|
||||||
|
EntityList::RemoveNumbers(strn0cpy(numberlessName, spawn->GetName(), sizeof(numberlessName)));
|
||||||
|
std::string query = StringFormat("INSERT INTO npc_types (name, level, race, class, hp, gender, "
|
||||||
|
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
||||||
|
"runspeed, prim_melee_type, sec_melee_type) "
|
||||||
|
"VALUES(\"%s\", %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
||||||
|
numberlessName, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(),
|
||||||
|
spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(),
|
||||||
|
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
||||||
|
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success())
|
||||||
|
return 0;
|
||||||
|
npc_type_id = results.LastInsertedID();
|
||||||
|
|
||||||
|
if(client)
|
||||||
|
client->LogSQL(query.c_str());
|
||||||
|
|
||||||
|
if(client)
|
||||||
|
client->Message(0, "%s npc_type ID %i created successfully!", numberlessName, npc_type_id);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn, uint32 extra) {
|
uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn, uint32 extra) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
uint32 tmp = 0;
|
|
||||||
uint32 tmp2 = 0;
|
|
||||||
uint32 last_insert_id = 0;
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 0: { // Create a new NPC and add all spawn related data
|
case 0: { // Create a new NPC and add all spawn related data
|
||||||
return CreateNewNPCCommand(zone, zone_version, c, spawn, extra);
|
return CreateNewNPCCommand(zone, zone_version, c, spawn, extra);
|
||||||
@ -1286,18 +1307,7 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
return AddSpawnFromSpawnGroup(zone, zone_version, c, spawn, extra);
|
return AddSpawnFromSpawnGroup(zone, zone_version, c, spawn, extra);
|
||||||
}
|
}
|
||||||
case 6: { // add npc_type
|
case 6: { // add npc_type
|
||||||
uint32 npc_type_id;
|
return AddNPCTypes(zone, zone_version, c, spawn, extra);
|
||||||
char tmpstr[64];
|
|
||||||
EntityList::RemoveNumbers(strn0cpy(tmpstr, spawn->GetName(), sizeof(tmpstr)));
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO npc_types (name, level, race, class, hp, gender, texture, helmtexture, size, loottable_id, merchant_id, face, runspeed, prim_melee_type, sec_melee_type) values(\"%s\",%i,%i,%i,%i,%i,%i,%i,%f,%i,%i,%i,%f,%i,%i)", tmpstr, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(), spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(), spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28), errbuf, 0, 0, &npc_type_id)) {
|
|
||||||
safe_delete(query);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(c) c->LogSQL(query);
|
|
||||||
safe_delete_array(query);
|
|
||||||
if(c) c->Message(0, "%s npc_type ID %i created successfully!", tmpstr, npc_type_id);
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -377,6 +377,7 @@ public:
|
|||||||
uint32 DeleteSpawnLeaveInNPCTypeTable(const char* zone, Client *client, NPC* spawn);
|
uint32 DeleteSpawnLeaveInNPCTypeTable(const char* zone, Client *client, NPC* spawn);
|
||||||
uint32 DeleteSpawnRemoveFromNPCTypeTable(const char* zone, uint32 zone_version, Client *client, NPC* spawn);
|
uint32 DeleteSpawnRemoveFromNPCTypeTable(const char* zone, uint32 zone_version, Client *client, NPC* spawn);
|
||||||
uint32 AddSpawnFromSpawnGroup(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID);
|
uint32 AddSpawnFromSpawnGroup(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID);
|
||||||
|
uint32 AddNPCTypes(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID);
|
||||||
uint32 UpdateNPCTypeAppearance(Client *client, NPC* spawn);
|
uint32 UpdateNPCTypeAppearance(Client *client, NPC* spawn);
|
||||||
bool SetSpecialAttkFlag(uint8 id, const char* flag);
|
bool SetSpecialAttkFlag(uint8 id, const char* flag);
|
||||||
bool GetPetEntry(const char *pet_type, PetRecord *into);
|
bool GetPetEntry(const char *pet_type, PetRecord *into);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user