DeleteCharacter converted to StringFormat

This commit is contained in:
Arthur Ice 2014-07-08 19:47:01 -07:00 committed by Arthur Ice
parent bf5ce11ff1
commit 80a8a1fde3

View File

@ -375,7 +375,7 @@ returns false on failure, true otherwise
*/ */
bool Database::DeleteCharacter(char *name) bool Database::DeleteCharacter(char *name)
{ {
char *query=nullptr; std::string query=StringFormat("SELECT id from character_ WHERE name='%s'", name);
int charid; int charid;
if(!name || !strlen(name)) if(!name || !strlen(name))
@ -390,9 +390,7 @@ bool Database::DeleteCharacter(char *name)
std::cout << "DeleteCharacter: Attempting to delete '" << name << "'" << std::endl; std::cout << "DeleteCharacter: Attempting to delete '" << name << "'" << std::endl;
#endif #endif
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT id from character_ WHERE name='%s'", name)); auto results = QueryDatabase(query);
safe_delete_array(query);
if(results.RowCount() != 1) if(results.RowCount() != 1)
{ {
@ -409,138 +407,138 @@ bool Database::DeleteCharacter(char *name)
std::cout << " quest_globals"; std::cout << " quest_globals";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from quest_globals WHERE charid='%d'", charid)); query = StringFormat("DELETE from quest_globals WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " character_tasks"; std::cout << " character_tasks";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from character_tasks WHERE charid='%d'", charid)); query = StringFormat("DELETE from character_tasks WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " character_activities"; std::cout << " character_activities";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from character_activities WHERE charid='%d'", charid)); query = StringFormat("DELETE from character_activities WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " character_enabledtasks"; std::cout << " character_enabledtasks";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from character_enabledtasks WHERE charid='%d'", charid)); query = StringFormat("DELETE from character_enabledtasks WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " completed_tasks"; std::cout << " completed_tasks";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from completed_tasks WHERE charid='%d'", charid)); query = StringFormat("DELETE from completed_tasks WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " friends"; std::cout << " friends";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from friends WHERE charid='%d'", charid)); query = StringFormat("DELETE from friends WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " mail"; std::cout << " mail";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from mail WHERE charid='%d'", charid)); query = StringFormat( "DELETE from mail WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " ptimers"; std::cout << " ptimers";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from timers WHERE char_id='%d'", charid)); query = StringFormat("DELETE from timers WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " inventory"; std::cout << " inventory";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE from inventory WHERE charid='%d'", charid)); query = StringFormat("DELETE from inventory WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " guild_members"; std::cout << " guild_members";
#endif #endif
#ifdef BOTS #ifdef BOTS
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE char_id='%d' AND GetMobTypeById(%i) = 'C'", charid)); query = StringFormat("DELETE FROM guild_members WHERE char_id='%d' AND GetMobTypeById(%i) = 'C'", charid);
#else #else
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM guild_members WHERE char_id='%d'", charid);
#endif #endif
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " recipes"; std::cout << " recipes";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM char_recipe_list WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM char_recipe_list WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " adventure_stats"; std::cout << " adventure_stats";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM adventure_stats WHERE player_id='%d'", charid)); query = StringFormat("DELETE FROM adventure_stats WHERE player_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " zone_flags"; std::cout << " zone_flags";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM zone_flags WHERE charID='%d'", charid)); query = StringFormat("DELETE FROM zone_flags WHERE charID='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " titles"; std::cout << " titles";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM titles WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM titles WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " titlesets"; std::cout << " titlesets";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM player_titlesets WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM player_titlesets WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " keyring"; std::cout << " keyring";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM keyring WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM keyring WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " factions"; std::cout << " factions";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM faction_values WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " instances"; std::cout << " instances";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM instance_list_player WHERE charid='%d'", charid)); query = StringFormat("DELETE FROM instance_list_player WHERE charid='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << " _character"; std::cout << " _character";
#endif #endif
results = QueryDatabase(query, MakeAnyLenString(&query, "DELETE from character_ WHERE id='%d'", charid)); query = StringFormat("DELETE from character_ WHERE id='%d'", charid);
safe_delete_array(query); results = QueryDatabase(query);
if(results.RowsAffected() != 1) // here we have to have a match or it's an error if(results.RowsAffected() != 1) // here we have to have a match or it's an error
{ {
@ -552,8 +550,8 @@ bool Database::DeleteCharacter(char *name)
std::cout << " alternate currency"; std::cout << " alternate currency";
#endif #endif
QueryDatabase(query, MakeAnyLenString(&query, "DELETE FROM character_alt_currency WHERE char_id='%d'", charid)); query = StringFormat("DELETE FROM character_alt_currency WHERE char_id='%d'", charid);
safe_delete_array(query); QueryDatabase(query);
#if DEBUG >= 5 #if DEBUG >= 5
std::cout << std::endl; std::cout << std::endl;