Faction update

This commit is contained in:
Paul Coene
2015-02-01 15:02:14 -05:00
parent 1ff2a043f4
commit 614014a238
3 changed files with 38 additions and 46 deletions
+11 -19
View File
@@ -3212,16 +3212,7 @@ bool ZoneDatabase::GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, in
bool ZoneDatabase::SetCharacterFactionLevel(uint32 char_id, int32 faction_id, int32 value, uint8 temp, faction_map &val_list)
{
std::string query = StringFormat("DELETE FROM faction_values "
"WHERE char_id=%i AND faction_id = %i",
char_id, faction_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
if(value == 0)
return true;
std::string query;
if(temp == 2)
temp = 0;
@@ -3229,17 +3220,18 @@ bool ZoneDatabase::SetCharacterFactionLevel(uint32 char_id, int32 faction_id, in
if(temp == 3)
temp = 1;
query = StringFormat("INSERT INTO faction_values (char_id, faction_id, current_value, temp) "
"VALUES (%i, %i, %i, %i)", char_id, faction_id, value, temp);
results = QueryDatabase(query);
if (!results.Success()) {
query = StringFormat("INSERT INTO `faction_values` "
"(`char_id`, `faction_id`, `current_value`, `temp`) "
"VALUES (%i, %i, %i, %i) "
"ON DUPLICATE KEY UPDATE `current_value`=%i,`temp`=%i",
char_id, faction_id, value, temp, value, temp);
auto results = QueryDatabase(query);
if (!results.Success())
return false;
}
else
val_list[faction_id] = value;
if (results.RowsAffected() == 0)
return false;
val_list[faction_id] = value;
return true;
}