Changes to accomodate the new raw faction data.

This commit is contained in:
Noudess 2018-12-18 10:58:01 -05:00
parent cfbd8e727a
commit 688e37f108
4 changed files with 40 additions and 14 deletions

View File

@ -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;

4
common/faction.h Normal file → Executable file
View File

@ -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<std::string, int16> 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];
};

View File

@ -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

32
zone/zonedb.cpp Normal file → Executable file
View File

@ -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;