Changed the "Radiated" on the char screen to be highlighted in gray

* when the player still has an impending radiation effect

[HRP] Fixed the clickability issue for SCALE_BUTTONS_AND_TEXT_MENU.

Moved some code related to HRP.
Unified the naming style for color variables.
This commit is contained in:
NovaRain
2022-01-06 14:19:05 +08:00
parent 6faf71da66
commit adadf608e7
11 changed files with 76 additions and 45 deletions
+10 -1
View File
@@ -241,6 +241,15 @@ fo::QueueAddictData* __fastcall CheckAddictByPid(fo::GameObject* critter, long p
return queue; // return null or pointer to queue_addict
}
fo::QueueRadiationData* __fastcall GetRadiationEvent(long type) {
fo::QueueRadiationData* queue = (fo::QueueRadiationData*)fo::func::queue_find_first(fo::var::obj_dude, fo::radiation_event);
while (queue) {
if (queue->init == type) return queue;
queue = (fo::QueueRadiationData*)fo::func::queue_find_next(fo::var::obj_dude, fo::radiation_event);
}
return nullptr;
}
// Checks whether the player is under the influence of negative effects of radiation
long __fastcall IsRadInfluence() {
fo::QueueRadiationData* queue = (fo::QueueRadiationData*)fo::func::queue_find_first(fo::var::obj_dude, fo::radiation_event);
@@ -331,7 +340,7 @@ void GetObjectsTileRadius(std::vector<fo::GameObject*> &objs, long sourceTile, l
fo::GameObject* obj = fo::func::obj_find_first_at_tile(elev, tile);
while (obj) {
if (type == -1 || type == obj->Type()) {
bool multiHex = (obj->flags & fo::ObjectFlag::MultiHex) ? true : false;
char multiHex = (obj->flags & fo::ObjectFlag::MultiHex) ? 1 : 0;
if (fo::func::tile_dist(sourceTile, obj->tile) <= (radius + multiHex)) {
objs.push_back(obj);
}
+2
View File
@@ -106,6 +106,8 @@ bool HeroIsFemale();
// Alternative implementation of item_d_check_addict_ engine function with critter argument and returned addict queue data
fo::QueueAddictData* __fastcall CheckAddictByPid(fo::GameObject* critter, long pid);
fo::QueueRadiationData* __fastcall GetRadiationEvent(long type);
// Checks whether the player is under the influence of negative effects of radiation
long __fastcall IsRadInfluence();
@@ -1883,7 +1883,6 @@ FUNC(item_destroy_all_hidden_, 0x477770)
FUNC(item_drop_all_, 0x477804)
FUNC(item_exit_, 0x477148)
FUNC(item_get_type_, 0x477AFC)
FUNC(item_grey_, 0x477F3C)
FUNC(item_hit_with_, 0x477FF8)
FUNC(item_identical_, 0x4779F0)
FUNC(item_init_, 0x4770E0)
+4 -3
View File
@@ -374,16 +374,17 @@
// colors
#define FO_VAR_BlueColor 0x6A38EF
#define FO_VAR_DARK_GREY_Color 0x6A59D8
#define FO_VAR_DarkGreenColor 0x6A3A90
#define FO_VAR_DarkGreenGreyColor 0x6A3DF1
#define FO_VAR_DarkGreyColor 0x6A59D8
#define FO_VAR_DarkRedColor 0x6AA8D0
#define FO_VAR_DarkYellowColor 0x6AB472
#define FO_VAR_DullPinkColor 0x6AB718
#define FO_VAR_GoodColor 0x6AB4EF
#define FO_VAR_GreenColor 0x6A3CB0
#define FO_VAR_LIGHT_GREY_Color 0x6A76BF
#define FO_VAR_LIGHT_RED_Color 0x6AB61A
#define FO_VAR_LightGreyColor 0x6A76BF
#define FO_VAR_LightRedColor 0x6AB61A
#define FO_VAR_NearWhiteColor 0x6A8B64
#define FO_VAR_PeanutButter 0x6A82F3
#define FO_VAR_RedColor 0x6AB4D0
#define FO_VAR_WhiteColor 0x6AB8CF
+6 -2
View File
@@ -43,9 +43,11 @@ VARA(curr_pc_stat, long, fo::PCSTAT_max_pc_stat)
VAR_(curr_stack, DWORD)
VAR_(currentProgram, fo::Program*)
VAR_(cursor_line, DWORD)
VAR_(DARK_GREY_Color, BYTE)
VAR_(DarkGreenColor, BYTE)
VAR_(DarkGreenGreyColor, BYTE)
VAR_(DarkGreyColor, BYTE)
VAR_(DarkRedColor, BYTE)
VAR_(DarkYellowColor, BYTE)
VAR_(dialog_target, fo::GameObject*)
VAR_(dialog_target_is_party, DWORD)
VAR_(dialogue_state, DWORD)
@@ -116,7 +118,8 @@ VAR_(last_button_winID, DWORD)
VAR_(last_level, DWORD)
VAR_(Level_pc, DWORD)
VAR_(Lifegiver, DWORD)
VAR_(LIGHT_GREY_Color, BYTE)
VAR_(LightGreyColor, BYTE)
VAR_(LightRedColor, BYTE)
VAR_(lipsFID, DWORD)
VAR_(list_com, DWORD)
VAR_(list_total, DWORD)
@@ -148,6 +151,7 @@ VAR_(Mutate_, DWORD)
VAR_(name_color, DWORD)
VAR_(name_font, DWORD)
VAR_(name_sort_list, DWORD)
VAR_(NearWhiteColor, BYTE)
VAR_(num_caps, DWORD)
VAR_(num_game_global_vars, DWORD)
VAR_(num_map_global_vars, DWORD)
+2
View File
@@ -152,6 +152,8 @@ static __declspec(naked) void gmouse_bk_process() {
}
void Setting::init(const char* exeFileName, std::string &cmdline) {
ViewMap::RedrawFix();
bool hiResMode = sf::IniReader::GetIntDefaultConfig("Main", "HiResMode", 1) != 0;
if (!Setting::ExternalEnabled() && !hiResMode) return; // vanilla game mode
+4
View File
@@ -304,6 +304,10 @@ void MainMenuScreen::init() {
sf::HookCall(0x481883, main_menu_create_hook_register_button);
sf::MakeCall(0x481933, main_menu_create_hook_text_to_buf, 1);
if (MainMenuScreen::SCALE_BUTTONS_AND_TEXT_MENU) {
sf::SafeWrite32(0x4818A9, (DWORD)&buttonImageData); // main_menu_create_
}
// main_menu_create_
// imul ebp, edx, 640 > mov ebp, edx
sf::SafeWrite16(0x481912, 0xD589);
+3 -3
View File
@@ -23,17 +23,17 @@ public:
Edge* nextEdgeData = nullptr;
void Release() {
Edge* edge = nextEdgeData;
Edge* edge = this->nextEdgeData;
while (edge) {
Edge* edgeNext = edge->nextEdgeData;
delete edge;
edge = edgeNext;
};
nextEdgeData = nullptr;
this->nextEdgeData = nullptr;
}
~Edge() {
Release();
if (nextEdgeData) delete nextEdgeData;
}
};
+25
View File
@@ -7,6 +7,7 @@
#include "..\..\main.h"
#include "..\..\FalloutEngine\Fallout2.h"
#include "..\..\Modules\LoadGameHook.h"
#include "..\..\Modules\MainLoopHook.h"
#include "..\Init.h"
#include "EdgeBorder.h"
@@ -465,4 +466,28 @@ void ViewMap::init() {
//BlockCall(0x4B11A3); // tile_init_
}
static void __declspec(naked) obj_move_to_tile_hook_redraw() {
__asm {
mov sf::MainLoopHook::displayWinUpdateState, 1;
call fo::funcoffs::tile_set_center_;
mov eax, ds:[FO_VAR_display_win];
jmp fo::funcoffs::win_draw_; // update black edges after tile_set_center_
}
}
static void __declspec(naked) map_check_state_hook_redraw() {
__asm {
cmp sf::MainLoopHook::displayWinUpdateState, 0;
je obj_move_to_tile_hook_redraw;
jmp fo::funcoffs::tile_set_center_;
}
}
void ViewMap::RedrawFix() {
// Redraw the screen to update black edges of the map (HRP bug)
// https://github.com/phobos2077/sfall/issues/282
sf::HookCall(0x48A954, obj_move_to_tile_hook_redraw);
sf::HookCall(0x483726, map_check_state_hook_redraw);
}
}
+1
View File
@@ -12,6 +12,7 @@ namespace HRP
class ViewMap {
public:
static void init();
static void RedrawFix();
static long SCROLL_DIST_X;
static long SCROLL_DIST_Y;
+19 -35
View File
@@ -22,7 +22,6 @@
#include "..\Translate.h"
#include "LoadGameHook.h"
#include "MainLoopHook.h"
#include "MiscPatches.h"
@@ -351,23 +350,29 @@ playWalkMovie:
}
}
static long __fastcall GetRadHighlightColor(bool selected) {
if (fo::util::IsRadInfluence()) {
return (selected) ? fo::var::LightRedColor : fo::var::RedColor;
}
if (fo::var::obj_dude->critter.rads == 0 && fo::util::GetRadiationEvent(0)) {
return (selected) ? fo::var::WhiteColor : fo::var::NearWhiteColor;
}
return 0;
}
static void __declspec(naked) ListDrvdStats_hook() {
static const DWORD ListDrvdStats_Ret = 0x4354D9;
__asm {
call fo::util::IsRadInfluence;
cmp dword ptr [esp], 0x4354BE + 5; // from called
sete cl;
call GetRadHighlightColor;
test eax, eax;
jnz influence;
jnz skip;
mov eax, ds:[FO_VAR_obj_dude];
jmp fo::funcoffs::critter_get_rads_;
influence:
xor ecx, ecx;
mov cl, ds:[FO_VAR_RedColor];
cmp dword ptr [esp], 0x4354BE + 5;
jne skip;
mov cl, 131; // color index for selected
skip:
add esp, 4;
jmp ListDrvdStats_Ret;
mov ecx, eax;
mov dword ptr [esp], 0x4354D9; // ListDrvdStats_
retn;
}
}
@@ -460,23 +465,6 @@ static void __declspec(naked) text_object_create_hack() {
}
}
static void __declspec(naked) obj_move_to_tile_hook_redraw() {
__asm {
mov MainLoopHook::displayWinUpdateState, 1;
call fo::funcoffs::tile_set_center_;
mov eax, ds:[FO_VAR_display_win];
jmp fo::funcoffs::win_draw_; // update black edges after tile_set_center_
}
}
static void __declspec(naked) map_check_state_hook_redraw() {
__asm {
cmp MainLoopHook::displayWinUpdateState, 0;
je obj_move_to_tile_hook_redraw;
jmp fo::funcoffs::tile_set_center_;
}
}
static void AdditionalWeaponAnimsPatch() {
if (IniReader::GetConfigInt("Misc", "AdditionalWeaponAnims", 0)) {
dlog("Applying additional weapon animations patch.", DL_INIT);
@@ -995,7 +983,8 @@ void MiscPatches::init() {
dlogr(" Done", DL_INIT);
}
// Highlight "Radiated" in red color when the player is under the influence of negative effects of radiation
// Highlight "Radiated" in red when the player is under the influence of negative effects of radiation
// also highlight in gray when the player still has an impending radiation effect
HookCalls(ListDrvdStats_hook, {0x43549C, 0x4354BE});
// Allow setting custom colors from the game palette for object outlines
@@ -1008,11 +997,6 @@ void MiscPatches::init() {
// Remove an old floating message when creating a new one if the maximum number of floating messages has been reached
HookCall(0x4B03A1, text_object_create_hack); // jge hack
// Redraw the screen to update black edges of the map (HRP bug)
// https://github.com/phobos2077/sfall/issues/282
HookCall(0x48A954, obj_move_to_tile_hook_redraw);
HookCall(0x483726, map_check_state_hook_redraw);
if (!HRP::Setting::IsEnabled()) {
// Corrects the height of the black background for death screen subtitles
if (!HRP::Setting::ExternalEnabled()) SafeWrite32(0x48134D, 38 - (640 * 3)); // main_death_scene_ (shift y-offset 2px up, w/o HRP)