Skip to content

Commit

Permalink
Issue #163: Fix storage access inconstancy, more access to closed win…
Browse files Browse the repository at this point in the history
…dow.

Items lists can access a closed storage window if in range.
Now the store all button and alt-click an inventory item can
do the same.
Added sound and visual indication of when access is not valid
for the store all button as already done for alt-click and item lists.
Access is not allowed after changing map locations until re-opened
via and NPC.
Fixed an issue where the storage window could be re-opened after a
map change if using alt-d hide all window before changing and then
restoring after the map change.
  • Loading branch information
pjbroad committed Jan 8, 2022
1 parent 46fcff9 commit e95dd70
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
39 changes: 23 additions & 16 deletions items.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ static int click_items_handler(window_info *win, int mx, int my, Uint32 flags)
my_tcp_send(str, 6);
do_drop_item_sound();
} else if (alt_on && (items_mod_click_any_cursor || (item_action_mode==ACTION_WALK))) {
if ((get_id_MW(MW_STORAGE) >= 0) && (get_show_window_MW(MW_STORAGE)) && (view_only_storage == 0)) {
if ((get_id_MW(MW_STORAGE) >= 0) && (view_only_storage == 0) && storage_use_allowed) {
reset_storage_rate_limit();
str[0]=DEPOSITE_ITEM;
str[1]=item_list[pos].pos;
Expand Down Expand Up @@ -1388,25 +1388,32 @@ static int click_items_handler(window_info *win, int mx, int my, Uint32 flags)
}

// Sto All button
else if(over_button(win, mx, my)==BUT_STORE && get_id_MW(MW_STORAGE) >= 0 && view_only_storage == 0 && get_show_window_MW(MW_STORAGE) /*thanks alberich*/){
reset_storage_rate_limit();
else if (over_button(win, mx, my) == BUT_STORE) {
if ((get_id_MW(MW_STORAGE) >= 0) && (view_only_storage == 0) && storage_use_allowed) {
reset_storage_rate_limit();
#ifdef STORE_ALL
/*
* Future code to save server load by having one byte to represent the 36 slot inventory loop. Will need server support.
*/
str[0]=DEPOSITE_ITEM;
str[1]=STORE_ALL;
my_tcp_send(str, 2);
/*
* Future code to save server load by having one byte to represent the 36 slot inventory loop. Will need server support.
*/
str[0]=DEPOSITE_ITEM;
str[1]=STORE_ALL;
my_tcp_send(str, 2);
#else
for(pos=((items_stoall_nofirstrow)?6:0);pos<((items_stoall_nolastrow)?30:36);pos++){
if(item_list[pos].quantity>0){
str[0]=DEPOSITE_ITEM;
str[1]=item_list[pos].pos;
*((Uint32*)(str+2))=SDL_SwapLE32(item_list[pos].quantity);
my_tcp_send(str, 6);
for(pos=((items_stoall_nofirstrow)?6:0);pos<((items_stoall_nolastrow)?30:36);pos++){
if(item_list[pos].quantity>0){
str[0]=DEPOSITE_ITEM;
str[1]=item_list[pos].pos;
*((Uint32*)(str+2))=SDL_SwapLE32(item_list[pos].quantity);
my_tcp_send(str, 6);
}
}
}
#endif
}
else
{
drop_fail_time = SDL_GetTicks();
do_alert1_sound();
}
}

// Drop All button
Expand Down
6 changes: 6 additions & 0 deletions storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct storage_category {
int no_storage_categories=0;
int selected_category=-1;
int view_only_storage=0;
int storage_use_allowed = 0;
Uint32 drop_fail_time = 0;
int sort_storage_categories = 0;
int sort_storage_items = 0;
Expand Down Expand Up @@ -936,6 +937,7 @@ void display_storage_menu()
cur_item_over = -1;
storage_text[0] = '\0';
set_window_name("", "");
storage_use_allowed = 1;

ui_scale_storage_handler(&windows_list.window[storage_win]);
check_proportional_move(MW_STORAGE);
Expand All @@ -944,5 +946,9 @@ void display_storage_menu()
void close_storagewin()
{
if(!view_only_storage)
{
hide_window_MW(MW_STORAGE);
clear_was_open_MW(MW_STORAGE);
storage_use_allowed = 0;
}
}
1 change: 1 addition & 0 deletions storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern int storage_item_dragged;
extern ground_item storage_items[STORAGE_ITEMS_SIZE]; /*!< list of storage items. */

extern int view_only_storage;
extern int storage_use_allowed;
extern int sort_storage_categories;
extern int sort_storage_items;
extern Uint32 drop_fail_time;
Expand Down

0 comments on commit e95dd70

Please sign in to comment.