Moved create new NPC command case (0) from NPCSpawnDB into method CreateNewNPCCommand

This commit is contained in:
Arthur Ice 2014-09-04 10:08:02 -07:00
parent 37d3daaf9a
commit 970f7e01a9
2 changed files with 85 additions and 75 deletions

View File

@ -962,7 +962,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z,
}
}
uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn, uint32 extra) {
uint32 ZoneDatabase::CreateNewNPCCommand(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;
@ -970,8 +970,6 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
uint32 tmp = 0;
uint32 tmp2 = 0;
uint32 last_insert_id = 0;
switch (command) {
case 0: { // Create a new NPC and add all spawn related data
uint32 npc_type_id = 0;
uint32 spawngroupid;
if (extra && c && c->GetZoneID())
@ -997,7 +995,6 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
npc_type_id = starting_npc_id;
}
}
safe_delete_array(query);
mysql_free_result(result);
}
@ -1045,7 +1042,19 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
if(c) c->LogSQL(query);
safe_delete_array(query);
return true;
break;
}
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) {
case 0: { // Create a new NPC and add all spawn related data
return CreateNewNPCCommand(command, zone, zone_version, c, spawn, extra);
}
case 1:{ // Add new spawn group and spawn point for an existing NPC Type ID
tmp2 = spawn->GetNPCTypeID();

View File

@ -372,6 +372,7 @@ public:
*/
const NPCType* GetNPCType(uint32 id);
uint32 NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn = 0, uint32 extra = 0); // 0 = Create 1 = Add; 2 = Update; 3 = Remove; 4 = Delete
uint32 CreateNewNPCCommand(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn, uint32 extra);
bool SetSpecialAttkFlag(uint8 id, const char* flag);
bool GetPetEntry(const char *pet_type, PetRecord *into);
bool GetPoweredPetEntry(const char *pet_type, int16 petpower, PetRecord *into);