Add gender-specific text improvements (#130)

This commit is contained in:
Alexander Batalov 2022-08-14 13:06:51 +03:00
parent 31edb19379
commit cac96bfc13
4 changed files with 53 additions and 0 deletions

View File

@ -4,7 +4,9 @@
#include "game_config.h" #include "game_config.h"
#include "memory.h" #include "memory.h"
#include "platform_compat.h" #include "platform_compat.h"
#include "proto_types.h"
#include "random.h" #include "random.h"
#include "sfall_config.h"
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
@ -569,3 +571,46 @@ bool messageListFilterBadwords(MessageList* messageList)
return true; return true;
} }
void messageListFilterGenderWords(MessageList* messageList, int gender)
{
if (messageList == NULL) {
return;
}
bool enabled = false;
configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_GAME_DIALOG_GENDER_WORDS_KEY, &enabled);
if (!enabled) {
return;
}
for (int index = 0; index < messageList->entries_num; index++) {
MessageListItem* item = &(messageList->entries[index]);
char* text = item->text;
char* sep;
while ((sep = strchr(text, '^')) != NULL) {
*sep = '\0';
char* start = strrchr(text, '<');
char* end = strchr(sep + 1, '>');
*sep = '^';
if (start != NULL && end != NULL) {
char* src;
size_t length;
if (gender == GENDER_FEMALE) {
src = sep + 1;
length = end - sep - 1;
} else {
src = start + 1;
length = sep - start - 1;
}
strncpy(start, src, length);
strcpy(start + length, end + 1);
} else {
text = sep + 1;
}
}
}
}

View File

@ -27,4 +27,6 @@ bool _message_make_path(char* dest, const char* path);
char* getmsg(MessageList* msg, MessageListItem* entry, int num); char* getmsg(MessageList* msg, MessageListItem* entry, int num);
bool messageListFilterBadwords(MessageList* messageList); bool messageListFilterBadwords(MessageList* messageList);
void messageListFilterGenderWords(MessageList* messageList, int gender);
#endif /* MESSAGE_H */ #endif /* MESSAGE_H */

View File

@ -24,6 +24,7 @@
#include "proto.h" #include "proto.h"
#include "proto_instance.h" #include "proto_instance.h"
#include "queue.h" #include "queue.h"
#include "stat.h"
#include "tile.h" #include "tile.h"
#include "window_manager.h" #include "window_manager.h"
#include "window_manager_private.h" #include "window_manager_private.h"
@ -2661,6 +2662,10 @@ static int scriptsGetMessageList(int a1, MessageList** messageListPtr)
debugPrint("\nError filtering script dialog message file!"); debugPrint("\nError filtering script dialog message file!");
return -1; return -1;
} }
// SFALL: Gender-specific words.
int gender = critterGetStat(gDude, STAT_GENDER);
messageListFilterGenderWords(messageList, gender);
} }
*messageListPtr = messageList; *messageListPtr = messageList;

View File

@ -55,6 +55,7 @@
#define SFALL_CONFIG_SCIENCE_REPAIR_TARGET_TYPE_KEY "ScienceOnCritters" #define SFALL_CONFIG_SCIENCE_REPAIR_TARGET_TYPE_KEY "ScienceOnCritters"
#define SFALL_CONFIG_GAME_DIALOG_FIX_KEY "DialogueFix" #define SFALL_CONFIG_GAME_DIALOG_FIX_KEY "DialogueFix"
#define SFALL_CONFIG_TWEAKS_FILE_KEY "TweaksFile" #define SFALL_CONFIG_TWEAKS_FILE_KEY "TweaksFile"
#define SFALL_CONFIG_GAME_DIALOG_GENDER_WORDS_KEY "DialogGenderWords"
#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