Added multi_send_theif_frame() function to update thief bot more frequently (by PPS) and even if it is not controlled by a player to counter discrepancies caused by client side AI movement of the bot

This commit is contained in:
zico 2015-09-03 15:13:56 +02:00
parent 51049794ce
commit 4a562bf098
3 changed files with 34 additions and 0 deletions

View file

@ -52,6 +52,9 @@ void multi_send_boss_start_gate(objnum_t bossobjnum);
void multi_send_boss_stop_gate(objnum_t bossobjnum);
void multi_send_boss_create_robot(objnum_t bossobjnum, int robot_type, vobjptridx_t objnum);
int multi_send_robot_frame(int sent);
#if defined(DXX_BUILD_DESCENT_II)
void multi_send_thief_frame();
#endif
void multi_do_robot_explode(const ubyte *buf);
void multi_do_robot_position(playernum_t pnum, const ubyte *buf);

View file

@ -391,6 +391,34 @@ multi_send_robot_frame(int sent)
return(rval);
}
#if defined(DXX_BUILD_DESCENT_II)
/*
* The thief bot moves around even when not controlled by a player. Due to its erratic and random behaviour, it's movement will diverge heavily between players and cause it to teleport when a player takes over.
* To counter this, let host update positions when no one controls it OR the client which does.
* Seperated this function to allow the positions being updated more frequently then multi_send_robot_frame (see net_udp_do_frame()).
*/
void multi_send_thief_frame()
{
if (!(Game_mode & GM_MULTI_ROBOTS))
return;
range_for (const auto i, highest_valid(Objects))
{
if (Objects[i].type == OBJ_ROBOT)
{
if (robot_is_thief(&Robot_info[get_robot_id(&Objects[i])]))
{
if ((multi_i_am_master() && (Objects[i].ctype.ai_info.REMOTE_OWNER == -1)) || (Objects[i].ctype.ai_info.REMOTE_OWNER == Player_num))
{
multi_send_robot_position_sub(i,1);
}
return;
}
}
}
}
#endif
void multi_send_robot_position_sub(const vobjptridx_t objnum, int now)
{
int loc = 0;

View file

@ -4626,6 +4626,9 @@ void net_udp_do_frame(int force, int listen)
{
last_pdata_time = time;
net_udp_send_pdata();
#if defined(DXX_BUILD_DESCENT_II)
multi_send_thief_frame();
#endif
}
if (force || (time >= (last_mdata_time+(F1_0/10))))