Skip to content

Commit 74812e9

Browse files
committed
Crafting bug fix
- Craft button was drawn on top of barter/dialog windows when they overlap it due to MOVEONTOP flag. Now should fix both issues with/without HRP. - Disassembling multiple-item recipe had incorrect calculation of items, allowing to create infinite items.
1 parent 7d8d145 commit 74812e9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

docs/ecco_changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ v0.9.6:
2222

2323
> Balance:
2424
- changed monster part quests requirements/rewards ratio to make economic sense
25+
- reduced drugs in dead NPC's by further 40%
2526
- minor weapon stat tweaks
2627

2728
> Installer:

scripts_src/_pbs_craft/crafting.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ procedure display_item_options begin
369369
if (max_batch > 0) then SayOption("1. " + mstr_craft(103), batch_one_item);
370370
if (max_batch > 1) then SayOption("2. " + mstr_craft(108) + " (" + (max_batch * cur_recipe_batch_size) + ")", batch_all_items);
371371
if (max_undo > 0) then SayOption("3. " + mstr_craft(104), undo_one_item);
372-
if (max_undo > 1) then SayOption("4. " + mstr_craft(109) + mstr_craft(110) + max_undo + mstr_craft(111), undo_all_items);
372+
if (max_undo > 1) then SayOption("4. " + mstr_craft(109) + mstr_craft(110) + (max_undo * cur_recipe_batch_size) + mstr_craft(111), undo_all_items);
373373
SayOption("0: "+mstr_craft(102), items_list_mode);
374374
if (use_categories) then
375375
SayOption(mstr_craft(112), item_categories_mode);
@@ -750,7 +750,7 @@ procedure draw_item_properties begin
750750
if not(hasTools and hasSkills and hasComponents) then max_batch := 0;
751751

752752
// Check if disassembly is possible.
753-
max_undo := party_is_carrying_obj_pid(cur_recipe.pid)
753+
max_undo := (party_is_carrying_obj_pid(cur_recipe.pid) / cur_recipe.qty)
754754
if (cur_recipe.undo and hasTools and hasSkills)
755755
else 0;
756756

scripts_src/_pbs_craft/gl_pbs_craft.ssl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ procedure delete_button;
2121
#include "crafting.h"
2222

2323
variable crafting_hotkey, schema_pids;
24-
variable warning_msg, show_crafting_scheduled, crafting_button_shown;
24+
variable warning_msg, show_crafting_scheduled, crafting_button_shown, crafting_button_top;
2525

2626
#define WIN_CRAFT_BTN "helwin"
2727
#define SFX_BUTTON_DOWN "butin4"
@@ -132,16 +132,25 @@ end
132132

133133
// Create the button
134134
procedure create_button begin
135-
if crafting_button_shown then return;
135+
// Mash's HRP has a bug when clicking on main interface - it goes on top (sfall doesn't have this).
136+
// Workaround: delete and recreate button when going to/from these UI's with moveontop flag only when button is actually clickable.
137+
variable onTop := not(get_game_mode bwand (BARTER bwor INVENTORY bwor DIALOG));
138+
if crafting_button_shown then begin
139+
if (crafting_button_top != onTop) then
140+
DeleteWin(WIN_CRAFT_BTN);
141+
else
142+
return;
143+
end
136144
variable
137145
x := get_interface_x(WINTYPE_IFACEBAR) + get_interface_width(WINTYPE_IFACEBAR) - BUTTON_RIGHT_OFFSET,
138146
y := (get_screen_height - BUTTON_BOTTOM_OFFSET);
139-
create_win_flag(WIN_CRAFT_BTN, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, WIN_FLAG_DONTMOVE bwor WIN_FLAG_MOVEONTOP);
147+
create_win_flag(WIN_CRAFT_BTN, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, WIN_FLAG_DONTMOVE bwor (WIN_FLAG_MOVEONTOP if onTop else 0));
140148
SelectWin(WIN_CRAFT_BTN);
141149
AddButton("but", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
142150
AddButtonGFX("but", PCX_BUTTON_DOWN, PCX_BUTTON_UP, PCX_BUTTON_UP);
143151
AddButtonProc("but", do_on, do_off, do_down, do_up);
144152
ShowWin;
153+
crafting_button_top := onTop;
145154
crafting_button_shown := true;
146155
end
147156

0 commit comments

Comments
 (0)