Skip to content

Commit

Permalink
Issue #165: Re-validate ground bag window status on reconnect.
Browse files Browse the repository at this point in the history
If we disconnect with an open ground bag, on reconnect the
bag or its contents may no longer be valid.  If the bags was closed
the state many still have changed.  If the window is open and there
is still a bag then re-validate its contents.  Otherwise close any
invalid open bag and/or clear the state of a previously opened bag.
  • Loading branch information
pjbroad committed Jan 8, 2022
1 parent 1240201 commit 46fcff9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions bags.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,31 @@ static float get_bag_tilt(float pos_x, float pos_y, int bag_id, int map_x, int m
digest[6]) + cosf(digest[7])) / 5.0f) * 30;
}

void revalidate_ground_bag_window(void)
{
// never opened a bag window so nothing to do
if (get_id_MW(MW_BAGS) < 0)
return;

// if we are over an open bag, refresh its contents
if (your_actor && get_show_window_MW(MW_BAGS))
{
size_t i;
for (i = 0; i < NUM_BAGS; i++)
if ((bag_list[i].obj_3d_id != -1) &&
(bag_list[i].x == (your_actor->x_pos * 2)) &&
(bag_list[i].y == (your_actor->y_pos * 2)))
{
Uint8 str[2] = { INSPECT_BAG, i };
my_tcp_send(str, 2);
return;
}
}

// either we have an open window but no bag, or a previously opened window - clear the state
client_close_bag();
}

void put_bag_on_ground(int bag_x,int bag_y,int bag_id)
{
float x,y,z;
Expand Down
8 changes: 8 additions & 0 deletions bags.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ void server_close_bag(void);
*/
void client_close_bag(void);

/*!
* \ingroup item
* \brief Revalidate ground bag window status on reconnect.
*
* \callgraph
*/
void revalidate_ground_bag_window(void);

/*!
* \ingroup item
* \brief Handle the inventory Get All button.
Expand Down
1 change: 1 addition & 0 deletions multiplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ void process_message_from_server (const Uint8 *in_data, int data_length)
load_channel_colors();
send_video_info();
check_glow_perk();
revalidate_ground_bag_window();
#ifdef USE_SSL
set_logged_in(1);
#else // USE_SSL
Expand Down

0 comments on commit 46fcff9

Please sign in to comment.