From 688e37f10857341cd3f7864f1372e60e60e9e05a Mon Sep 17 00:00:00 2001 From: Noudess Date: Tue, 18 Dec 2018 10:58:01 -0500 Subject: [PATCH] Changes to accomodate the new raw faction data. --- common/faction.cpp | 16 ++++++++-------- common/faction.h | 4 ++++ utils/sql/db_update_manifest.txt | 2 ++ zone/zonedb.cpp | 32 ++++++++++++++++++++++++++------ 4 files changed, 40 insertions(+), 14 deletions(-) mode change 100644 => 100755 common/faction.h mode change 100644 => 100755 zone/zonedb.cpp diff --git a/common/faction.cpp b/common/faction.cpp index 65524f623..c1d4fe398 100644 --- a/common/faction.cpp +++ b/common/faction.cpp @@ -59,31 +59,31 @@ FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value) if (fm) { character_value += fm->base + fm->class_mod + fm->race_mod + fm->deity_mod; } - if (character_value >= 1101) { + if (character_value >= 1100) { return FACTION_ALLY; } - if (character_value >= 701 && character_value <= 1100) { + if (character_value >= 750 && character_value <= 1099) { return FACTION_WARMLY; } - if (character_value >= 401 && character_value <= 700) { + if (character_value >= 500 && character_value <= 749) { return FACTION_KINDLY; } - if (character_value >= 101 && character_value <= 400) { + if (character_value >= 100 && character_value <= 499) { return FACTION_AMIABLE; } - if (character_value >= 0 && character_value <= 100) { + if (character_value >= 0 && character_value <= 99) { return FACTION_INDIFFERENT; } if (character_value >= -100 && character_value <= -1) { return FACTION_APPREHENSIVE; } - if (character_value >= -700 && character_value <= -101) { + if (character_value >= -500 && character_value <= -101) { return FACTION_DUBIOUS; } - if (character_value >= -999 && character_value <= -701) { + if (character_value >= -750 && character_value <= -501) { return FACTION_THREATENLY; } - if (character_value <= -1000) { + if (character_value <= -751) { return FACTION_SCOWLS; } return FACTION_INDIFFERENT; diff --git a/common/faction.h b/common/faction.h old mode 100644 new mode 100755 index c98fc0916..bc086669d --- a/common/faction.h +++ b/common/faction.h @@ -50,6 +50,8 @@ struct NPCFactionList { struct FactionMods { int32 base; + int16 min; // The lowest your personal earned faction can go - before race/class/diety adjustments. + int16 max; // The highest your personal earned faction can go - before race/class/diety adjustments. int32 class_mod; int32 race_mod; int32 deity_mod; @@ -59,6 +61,8 @@ struct Faction { int32 id; std::map mods; int16 base; + int16 min; // The lowest your personal earned faction can go - before race/class/diety adjustments. + int16 max; // The highest your personal earned faction can go - before race/class/diety adjustments. char name[50]; }; diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index 81a8fa2d8..1254b2936 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -384,6 +384,8 @@ 9128|2018_08_13_inventory_version_update.sql|SHOW TABLES LIKE 'inventory_version'|not_empty| 9129|2018_08_13_inventory_update.sql|SHOW TABLES LIKE 'inventory_versions'|empty| 9130|2018_11_25_name_filter_update.sql|SHOW COLUMNS FROM `name_filter` LIKE 'id'|empty| +9131|2018_12_12_client_faction_tables.sql|SHOW TABLES LIKE 'faction_base_data'|empty| +9132|2018_12_12_convert_to_client_functions.sql|SELECT `id` FROM `faction_list` WHERE `id` > 4999 |empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp old mode 100644 new mode 100755 index 5fe6560f1..0cfcf64c3 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3901,6 +3901,8 @@ bool ZoneDatabase::GetFactionData(FactionMods* fm, uint32 class_mod, uint32 race } fm->base = faction_array[faction_id]->base; + fm->min = faction_array[faction_id]->min; // The lowest your personal earned faction can go - before race/class/diety adjustments. + fm->max = faction_array[faction_id]->max; // The highest your personal earned faction can go - before race/class/diety adjustments. if(class_mod > 0) { char str[32]; @@ -4047,14 +4049,32 @@ bool ZoneDatabase::LoadFactionData() faction_array[index] = new Faction; strn0cpy(faction_array[index]->name, row[1], 50); faction_array[index]->base = atoi(row[2]); + faction_array[index]->min = MIN_PERSONAL_FACTION; + faction_array[index]->max = MAX_PERSONAL_FACTION; - query = StringFormat("SELECT `mod`, `mod_name` FROM `faction_list_mod` WHERE faction_id = %u", index); - auto modResults = QueryDatabase(query); - if (!modResults.Success()) - continue; + // Load in the mimimum and maximum faction that can be earned for this faction + query = StringFormat("SELECT `min` , `max` FROM `faction_base_data` WHERE client_faction_id = %u", index); + auto baseResults = QueryDatabase(query); + if (!baseResults.Success() || baseResults.RowCount() == 0) { + Log(Logs::General, Logs::General, "Faction %d has no base data", (int)index); + } + else { + for (auto modRow = baseResults.begin(); modRow != baseResults.end(); ++modRow) { + faction_array[index]->min = atoi(modRow[0]); + faction_array[index]->max = atoi(modRow[1]); + Log(Logs::General, Logs::None, "Min(%d), Max(%d) for faction (%u)",faction_array[index]->min, faction_array[index]->max, index); + } + } - for (auto modRow = modResults.begin(); modRow != modResults.end(); ++modRow) - faction_array[index]->mods[modRow[1]] = atoi(modRow[0]); + // Load in modifiers to the faction based on characters race, class and diety. + query = StringFormat("SELECT `mod`, `mod_name` FROM `faction_list_mod` WHERE faction_id = %u", index); + auto modResults = QueryDatabase(query); + if (!modResults.Success()) + continue; + + for (auto modRow = modResults.begin(); modRow != modResults.end(); ++modRow) { + faction_array[index]->mods[modRow[1]] = atoi(modRow[0]); + } } return true;