Add town reputation improvements (#29)

This commit is contained in:
Alexander Batalov 2022-08-06 15:50:33 +03:00
parent ef067cd954
commit 3592a7232c
2 changed files with 67 additions and 4 deletions

View File

@ -292,6 +292,9 @@ static void customKarmaFolderInit();
static void customKarmaFolderFree(); static void customKarmaFolderFree();
static int customKarmaFolderGetFrmId(); static int customKarmaFolderGetFrmId();
static void customTownReputationInit();
static void customTownReputationFree();
// 0x431C40 // 0x431C40
static int gCharacterEditorFrmIds[EDITOR_GRAPHIC_COUNT] = { static int gCharacterEditorFrmIds[EDITOR_GRAPHIC_COUNT] = {
170, 170,
@ -792,6 +795,7 @@ struct CustomKarmaFolderDescription {
}; };
static std::vector<CustomKarmaFolderDescription> gCustomKarmaFolderDescriptions; static std::vector<CustomKarmaFolderDescription> gCustomKarmaFolderDescriptions;
static std::vector<TownReputationEntry> gCustomTownReputationEntries;
// 0x431DF8 // 0x431DF8
int characterEditorShow(bool isCreationMode) int characterEditorShow(bool isCreationMode)
@ -1293,6 +1297,9 @@ static int characterEditorWindowInit()
// SFALL: Custom karma folder. // SFALL: Custom karma folder.
customKarmaFolderInit(); customKarmaFolderInit();
// SFALL: Custom town reputation.
customTownReputationInit();
soundContinueAll(); soundContinueAll();
for (i = 0; i < EDITOR_GRAPHIC_COUNT; i++) { for (i = 0; i < EDITOR_GRAPHIC_COUNT; i++) {
@ -1855,6 +1862,9 @@ static void characterEditorWindowFree()
// SFALL: Custom karma folder. // SFALL: Custom karma folder.
customKarmaFolderFree(); customKarmaFolderFree();
// SFALL: Custom town reputation.
customTownReputationFree();
messageListFree(&gCharacterEditorMessageList); messageListFree(&gCharacterEditorMessageList);
interfaceBarRefresh(); interfaceBarRefresh();
@ -4516,8 +4526,9 @@ static int characterPrintToFile(const char* fileName)
} }
bool hasTownReputationHeading = false; bool hasTownReputationHeading = false;
for (int index = 0; index < TOWN_REPUTATION_COUNT; index++) { // SFALL
const TownReputationEntry* pair = &(gTownReputationEntries[index]); for (int index = 0; index < gCustomTownReputationEntries.size(); index++) {
const TownReputationEntry* pair = &(gCustomTownReputationEntries[index]);
if (_wmAreaIsKnown(pair->city)) { if (_wmAreaIsKnown(pair->city)) {
if (!hasTownReputationHeading) { if (!hasTownReputationHeading) {
fileWriteString("\n", stream); fileWriteString("\n", stream);
@ -5504,8 +5515,9 @@ static void characterEditorDrawKarmaFolder()
} }
bool hasTownReputationHeading = false; bool hasTownReputationHeading = false;
for (int index = 0; index < TOWN_REPUTATION_COUNT; index++) { // SFALL
const TownReputationEntry* pair = &(gTownReputationEntries[index]); for (int index = 0; index < gCustomTownReputationEntries.size(); index++) {
const TownReputationEntry* pair = &(gCustomTownReputationEntries[index]);
if (_wmAreaIsKnown(pair->city)) { if (_wmAreaIsKnown(pair->city)) {
if (!hasTownReputationHeading) { if (!hasTownReputationHeading) {
msg = getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 4000); msg = getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 4000);
@ -7162,3 +7174,53 @@ static int customKarmaFolderGetFrmId()
} }
return gCustomKarmaFolderDescriptions.end()->frmId; return gCustomKarmaFolderDescriptions.end()->frmId;
} }
static void customTownReputationInit()
{
char* reputationList = NULL;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITY_REPUTATION_LIST_KEY, &reputationList);
if (reputationList != NULL && *reputationList == '\0') {
reputationList = NULL;
}
char* curr = reputationList;
while (curr != NULL) {
char* next = strchr(curr, ',');
if (next != NULL) {
*next = '\0';
}
char* sep = strchr(curr, ':');
if (sep != NULL) {
*sep = '\0';
TownReputationEntry entry;
entry.city = atoi(curr);
entry.gvar = atoi(sep + 1);
gCustomTownReputationEntries.push_back(std::move(entry));
*sep = ':';
}
if (next != NULL) {
*next = ',';
curr = next + 1;
} else {
curr = NULL;
}
}
if (gCustomTownReputationEntries.empty()) {
gCustomTownReputationEntries.resize(TOWN_REPUTATION_COUNT);
for (int index = 0; index < TOWN_REPUTATION_COUNT; index++) {
gCustomTownReputationEntries[index].gvar = gTownReputationEntries[index].gvar;
gCustomTownReputationEntries[index].city = gTownReputationEntries[index].city;
}
}
}
static void customTownReputationFree()
{
gCustomTownReputationEntries.clear();
}

View File

@ -40,6 +40,7 @@
#define SFALL_CONFIG_PLASTIC_EXPLOSIVE_MIN_DAMAGE_KEY "PlasticExplosive_DmgMin" #define SFALL_CONFIG_PLASTIC_EXPLOSIVE_MIN_DAMAGE_KEY "PlasticExplosive_DmgMin"
#define SFALL_CONFIG_PLASTIC_EXPLOSIVE_MAX_DAMAGE_KEY "PlasticExplosive_DmgMax" #define SFALL_CONFIG_PLASTIC_EXPLOSIVE_MAX_DAMAGE_KEY "PlasticExplosive_DmgMax"
#define SFALL_CONFIG_EXPLOSION_EMITS_LIGHT_KEY "ExplosionsEmitLight" #define SFALL_CONFIG_EXPLOSION_EMITS_LIGHT_KEY "ExplosionsEmitLight"
#define SFALL_CONFIG_CITY_REPUTATION_LIST_KEY "CityRepsList"
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1 #define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3 #define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3