Fixed minor bugs in HeroAppearance & CritterStats

Fixed incorrect display of name and damage values for unarmed attacks
in some cases.

Minor code edits.
This commit is contained in:
NovaRain
2021-11-15 10:55:52 +08:00
parent 32924db37c
commit be4978324c
13 changed files with 33 additions and 32 deletions
+1 -1
View File
@@ -511,7 +511,7 @@ notDude:
}
}
void ApplyAnimationsAtOncePatches(signed char aniMax) {
static void ApplyAnimationsAtOncePatches(signed char aniMax) {
//allocate memory to store larger animation struct arrays
sf_anim_set.resize(aniMax + 1); // include a dummy
sf_sad.resize(aniMax + 1); // -8?
+3 -3
View File
@@ -17,9 +17,9 @@ public:
static int MaxBox() { return boxCount - 1; }
static void SetText(int box, const char* text, DWORD color);
static bool GetBox(int);
static void AddBox(int);
static void RemoveBox(int);
static bool GetBox(int i);
static void AddBox(int i);
static void RemoveBox(int i);
static long AddExtraBox();
};
+2 -2
View File
@@ -543,7 +543,7 @@ static void CombatProcPatch() {
dlogr(" Done", DL_INIT);
}
static void Combat_OnGameLoad() {
static void ResetOnGameLoad() {
baseHitChance.SetDefault();
mTargets.clear();
mAttackers.clear();
@@ -592,7 +592,7 @@ void Combat::init() {
SafeWriteBatch<BYTE>(fo::BodyPart::Uncalled, bodypartAddr); // replace Body_Torso with Body_Uncalled
HookCalls(ai_pick_hit_mode_hook_bodypart, {0x429E8C, 0x429ECC, 0x429F09});
LoadGameHook::OnGameReset() += Combat_OnGameLoad;
LoadGameHook::OnGameReset() += ResetOnGameLoad;
}
}
+2 -2
View File
@@ -439,7 +439,7 @@ void CritterStats::SaveStatData(HANDLE file) {
bool CritterStats::LoadStatData(HANDLE file) {
DWORD count, sizeRead;
ReadFile(file, &count, 4, &sizeRead, 0);
//if (sizeRead != 4) return true;
if (sizeRead != 4) return false; // wrong/old file data version
if (count) s_baseStatProto.reserve(count + 10);
for (size_t i = 0; i < count; i++) {
@@ -455,7 +455,7 @@ bool CritterStats::LoadStatData(HANDLE file) {
}
ReadFile(file, &count, 4, &sizeRead, 0);
//if (sizeRead != 4) return true;
if (sizeRead != 4) return true;
if (count) s_bonusStatProto.reserve(count + 10);
for (size_t i = 0; i < count; i++) {
+6 -6
View File
@@ -87,28 +87,28 @@ static bool CreateWordWrapList(char *TextMsg, DWORD WrapWidth, DWORD *lineNum, L
LineNode *NextLine = StartLine->next;
DWORD lineWidth = 0, wordWidth = 0, i = 0;
char CurrentChar;
unsigned char currentChar;
while (TextMsg[i] != '\0') {
CurrentChar = TextMsg[i++];
currentChar = TextMsg[i++];
int cWidth = fo::util::GetCharWidth(CurrentChar) + GapWidth;
int cWidth = fo::util::GetCharWidth(currentChar) + GapWidth;
lineWidth += cWidth;
wordWidth += cWidth;
if (lineWidth <= WrapWidth) {
if (isspace(CurrentChar) || CurrentChar == '-') {
if (isspace(currentChar) || currentChar == '-') {
NextLine->offset = i;
wordWidth = 0;
}
} else {
if (isspace(CurrentChar)) {
if (isspace(currentChar)) {
NextLine->offset = i;
wordWidth = 0;
}
lineWidth = wordWidth;
wordWidth = 0;
CurrentChar = '\0';
currentChar = '\0';
*lineNum += 1;
NextLine->next = new LineNode;
NextLine = NextLine->next;
+7 -6
View File
@@ -120,10 +120,10 @@ skip:
static void __declspec(naked) intface_init_hack() {
__asm {
add eax, 9276 - (54 / 2); // x offset
mov edx, 144 - 90; // width
add [esp + 4], edx;
add [esp + 0x10 + 4], edx;
add eax, 9276 - (54 / 2); // x offset
mov edx, 144 - 90; // width
add [esp + 4], edx;
add [esp + 0x10 + 4], edx;
retn;
}
}
@@ -158,8 +158,9 @@ static void ActionPointsBarPatch() {
} else {
APBarRectPatch();
}
SafeWrite32(0x45E343, (DWORD)&movePointBackground);
SafeWrite32(0x45EE3F, (DWORD)&movePointBackground);
// intface_init_
SafeWriteBatch<DWORD>((DWORD)&movePointBackground, {0x45E343, 0x45EE3F});
// intface_update_move_points_
SafeWriteBatch<BYTE>(16, {0x45EE55, 0x45EE7B, 0x45EE82, 0x45EE9C, 0x45EEA0});
SafeWriteBatch<DWORD>(9276 - (54 / 2), {0x45EE33, 0x45EEC8, 0x45EF16});
+2 -2
View File
@@ -140,7 +140,7 @@ static void __stdcall SaveGame2() {
WriteFile(h, &Objects::uniqueID, 4, &size, 0); // save unique id counter
data = Worldmap::GetAddedYears(false) << 16; // save to high bytes (short)
WriteFile(h, &data, 4, &size, 0);
Perks::save(h);
Perks::Save(h);
script::SaveArrays(h);
BugFixes::DrugsSaveFix(h);
CloseHandle(h);
@@ -242,7 +242,7 @@ static bool LoadGame_Before() {
if (uID > UniqueID::Start) Objects::uniqueID = uID;
ReadFile(h, &data, 4, &size, 0);
Worldmap::SetAddedYears(data >> 16);
if (size != 4 || !Perks::load(h)) goto errorLoad;
if (size != 4 || !Perks::Load(h)) goto errorLoad;
long result = script::LoadArrays(h); // 1 - old save, -1 - broken save
if (result == -1 || (!result && BugFixes::DrugsLoadFix(h))) goto errorLoad;
CloseHandle(h);
+2 -2
View File
@@ -1244,7 +1244,7 @@ void PerksReset() {
if (perksReInit) PerkSetup(); // restore perk data
}
void Perks::save(HANDLE file) {
void Perks::Save(HANDLE file) {
DWORD unused, count = fakeTraits.size();
WriteFile(file, &count, 4, &unused, 0);
for (DWORD i = 0; i < count; i++) {
@@ -1262,7 +1262,7 @@ void Perks::save(HANDLE file) {
}
}
bool Perks::load(HANDLE file) {
bool Perks::Load(HANDLE file) {
DWORD count, size;
ReadFile(file, &count, 4, &size, 0);
if (size != 4) return false;
+2 -2
View File
@@ -36,8 +36,8 @@ public:
static DWORD GetTraitStatBonus(int statID, int traitIndex);
static DWORD GetTraitSkillBonus(int skillID, int traitIndex);
static void save(HANDLE file);
static bool load(HANDLE file);
static void Save(HANDLE file);
static bool Load(HANDLE file);
static void SetSelectablePerk(const char* name, int active, int image, const char* desc, int npcID = 0);
static void SetFakePerk(const char* name, int level, int image, const char* desc, int npcID = 0);
+2 -2
View File
@@ -298,7 +298,7 @@ void __stdcall SetPickpocketMax(fo::GameObject* critter, DWORD maximum, DWORD mo
pickpocketMods.emplace_back(id, maximum, mod);
}
static void Skills_OnGameLoad() {
static void ResetOnGameLoad() {
pickpocketMods.clear();
basePickpocket.SetDefault();
@@ -330,7 +330,7 @@ void Skills::init() {
// 0x00000400 - Energy Weapon (forces weapon to use Energy Weapons skill)
HookCall(0x47831E, item_w_skill_hook);
LoadGameHook::OnGameReset() += Skills_OnGameLoad;
LoadGameHook::OnGameReset() += ResetOnGameLoad;
char buf[512], key[16];
auto skillsFile = IniReader::GetConfigString("Misc", "SkillsFile", "", MAX_PATH);
+1 -1
View File
@@ -373,7 +373,7 @@ static void SlotsStoreCurrentHitMode() {
}
fo::AttackType Unarmed::GetStoredHitMode(fo::HandSlot slot) {
fo::AttackType hit;
fo::AttackType hit = fo::AttackType::ATKTYPE_LWEAPON_PRIMARY;
switch (slotHitData[slot].mode) {
case fo::HandSlotMode::Primary:
+2 -2
View File
@@ -562,7 +562,7 @@ bool Worldmap::LoadData(HANDLE file) {
ReadFile(file, &mID, 4, &sizeRead, 0);
ReadFile(file, &elevData, sizeof(levelRest), &sizeRead, 0);
if (sizeRead != sizeof(levelRest)) return true;
mapRestInfo.insert(std::make_pair(mID, elevData));
mapRestInfo.emplace(mID, elevData);
}
if (count && !restMap) {
HookCall(0x42E57A, critter_can_obj_dude_rest_hook);
@@ -637,7 +637,7 @@ void Worldmap::SetRestMapLevel(int mapId, long elev, bool canRest) {
elev++;
}
elevData.level[elev] = canRest;
mapRestInfo.insert(std::make_pair(mapId, elevData));
mapRestInfo.emplace(mapId, elevData);
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ namespace sfall
class Translate {
public:
static void init(const char*);
static void init(const char* config);
// Translates given string using sfall translation INI file and puts the result into given buffer
static size_t Get(const char* section, const char* setting, const char* defaultValue, char* buffer, size_t bufSize = 128);