Bug Tracker – Attachment #355: Weapon desync correction for bug #269

View | Details | Raw Unified | Return to bug 269
Collapse All | Expand All

(-)client/src/m_options.cpp (+2 lines)
Lines 152-157 Link Here
152
EXTERN_CVAR (cl_unlag)
152
EXTERN_CVAR (cl_unlag)
153
EXTERN_CVAR (cl_updaterate)
153
EXTERN_CVAR (cl_updaterate)
154
EXTERN_CVAR (cl_interp)
154
EXTERN_CVAR (cl_interp)
155
EXTERN_CVAR (cl_predictpickup)
155
156
156
// Weapon Preferences
157
// Weapon Preferences
157
EXTERN_CVAR (cl_switchweapon)
158
EXTERN_CVAR (cl_switchweapon)
Lines 620-625 Link Here
620
	{ discrete,		"Position update freq",			{&cl_updaterate},	{3.0},		{0.0},		{0.0},		{UpdateRate} },
621
	{ discrete,		"Position update freq",			{&cl_updaterate},	{3.0},		{0.0},		{0.0},		{UpdateRate} },
621
	{ slider,		"Interpolation time",			{&cl_interp},		{0.0},		{4.0},		{1.0},		{NULL} },
622
	{ slider,		"Interpolation time",			{&cl_interp},		{0.0},		{4.0},		{1.0},		{NULL} },
622
	{ discrete,		"Adjust weapons for lag",		{&cl_unlag},		{2.0},		{0.0},		{0.0},		{OnOff} },
623
	{ discrete,		"Adjust weapons for lag",		{&cl_unlag},		{2.0},		{0.0},		{0.0},		{OnOff} },
624
	{ discrete,		"Predict weapon pickups",		{&cl_predictpickup},{2.0},		{0.0},		{0.0},		{OnOff} },
623
};
625
};
624
626
625
menu_t NetworkMenu = {
627
menu_t NetworkMenu = {
(-)client/src/cl_main.cpp (+20 lines)
Lines 60-65 Link Here
60
#include "cl_maplist.h"
60
#include "cl_maplist.h"
61
#include "cl_vote.h"
61
#include "cl_vote.h"
62
#include "p_mobj.h"
62
#include "p_mobj.h"
63
#include "p_pspr.h"
63
64
64
#include <string>
65
#include <string>
65
#include <vector>
66
#include <vector>
Lines 2071-2076 Link Here
2071
///// CL_Fire* called when someone uses a weapon  /////////
2072
///// CL_Fire* called when someone uses a weapon  /////////
2072
///////////////////////////////////////////////////////////
2073
///////////////////////////////////////////////////////////
2073
2074
2075
// [tm512] attempt at squashing weapon desyncs.
2076
// The server will send us what weapon we fired, and if that
2077
// doesn't match the weapon we have up at the moment, fix it
2078
// and request that we get a full update of playerinfo - apr 14 2012
2079
void CL_FireWeapon (void)
2080
{
2081
	player_t *p = &consoleplayer ();
2082
	weapontype_t firedweap = (weapontype_t) MSG_ReadByte ();
2083
2084
	if (firedweap != p->readyweapon)
2085
	{
2086
		p->readyweapon = firedweap;
2087
		P_SetPsprite (p, ps_weapon, weaponinfo[p->readyweapon].atkstate);
2088
		p->psprites[p->psprnum].sy = WEAPONTOP;
2089
		MSG_WriteMarker (&net_buffer, clc_getplayerinfo);
2090
	}
2091
}
2092
2074
//
2093
//
2075
// CL_FirePistol
2094
// CL_FirePistol
2076
//
2095
//
Lines 2916-2921 Link Here
2916
//	cmds[svc_spawnhiddenplayer]	= &CL_SpawnHiddenPlayer;
2935
//	cmds[svc_spawnhiddenplayer]	= &CL_SpawnHiddenPlayer;
2917
	cmds[svc_damageplayer]		= &CL_DamagePlayer;
2936
	cmds[svc_damageplayer]		= &CL_DamagePlayer;
2918
	cmds[svc_firepistol]		= &CL_FirePistol;
2937
	cmds[svc_firepistol]		= &CL_FirePistol;
2938
	cmds[svc_fireweapon]		= &CL_FireWeapon;
2919
2939
2920
	cmds[svc_fireshotgun]		= &CL_FireShotgun;
2940
	cmds[svc_fireshotgun]		= &CL_FireShotgun;
2921
	cmds[svc_firessg]			= &CL_FireSSG;
2941
	cmds[svc_firessg]			= &CL_FireSSG;
(-)server/src/sv_main.cpp (+7 lines)
Lines 4152-4157 Link Here
4152
//
4152
//
4153
// SV_ParseCommands
4153
// SV_ParseCommands
4154
//
4154
//
4155
4156
void SV_SendPlayerInfo(player_t &player);
4157
4155
void SV_ParseCommands(player_t &player)
4158
void SV_ParseCommands(player_t &player)
4156
{
4159
{
4157
	 while(validplayer(player))
4160
	 while(validplayer(player))
Lines 4171-4176 Link Here
4171
			SV_SetupUserInfo(player);
4174
			SV_SetupUserInfo(player);
4172
			break;
4175
			break;
4173
4176
4177
		case clc_getplayerinfo:
4178
			SV_SendPlayerInfo (player);
4179
			break;
4180
4174
		case clc_say:
4181
		case clc_say:
4175
			SV_Say(player);
4182
			SV_Say(player);
4176
			break;
4183
			break;
(-)common/p_pspr.h (+4 lines)
Lines 47-53 Link Here
47
#define FF_FULLBRIGHT	0x8000	// flag in thing->frame
47
#define FF_FULLBRIGHT	0x8000	// flag in thing->frame
48
#define FF_FRAMEMASK	0x7fff
48
#define FF_FRAMEMASK	0x7fff
49
49
50
#define LOWERSPEED				FRACUNIT*6
51
#define RAISESPEED				FRACUNIT*6
50
52
53
#define WEAPONBOTTOM			128*FRACUNIT
54
#define WEAPONTOP				32*FRACUNIT
51
55
52
//
56
//
53
// Overlay psprites are scaled shapes
57
// Overlay psprites are scaled shapes
(-)common/p_pspr.cpp (-6 / +8 lines)
Lines 41-52 Link Here
41
41
42
#include "p_unlag.h"
42
#include "p_unlag.h"
43
43
44
#define LOWERSPEED				FRACUNIT*6
45
#define RAISESPEED				FRACUNIT*6
46
47
#define WEAPONBOTTOM			128*FRACUNIT
48
#define WEAPONTOP				32*FRACUNIT
49
50
EXTERN_CVAR(sv_infiniteammo)
44
EXTERN_CVAR(sv_infiniteammo)
51
EXTERN_CVAR(sv_freelook)
45
EXTERN_CVAR(sv_freelook)
52
EXTERN_CVAR(sv_allowmovebob)
46
EXTERN_CVAR(sv_allowmovebob)
Lines 467-472 Link Here
467
	if (!P_CheckAmmo (player))
461
	if (!P_CheckAmmo (player))
468
		return;
462
		return;
469
463
464
	// [tm512] Send the client the weapon they just fired so
465
	// that they can fix any weapon desyncs that they get - apr 14 2012
466
	if (serverside && !clientside)
467
	{
468
		MSG_WriteMarker (&player->client.reliablebuf, svc_fireweapon);
469
		MSG_WriteByte (&player->client.reliablebuf, (char)player->readyweapon);
470
	}
471
470
	P_SetMobjState (player->mo, S_PLAY_ATK1);
472
	P_SetMobjState (player->mo, S_PLAY_ATK1);
471
	newstate = weaponinfo[player->readyweapon].atkstate;
473
	newstate = weaponinfo[player->readyweapon].atkstate;
472
	P_SetPsprite (player, ps_weapon, newstate);
474
	P_SetPsprite (player, ps_weapon, newstate);
(-)common/i_net.h (+1 lines)
Lines 175-180 Link Here
175
	clc_vote,				// [AM] - Casting a vote
175
	clc_vote,				// [AM] - Casting a vote
176
	clc_maplist,			// [AM] - Maplist status request.
176
	clc_maplist,			// [AM] - Maplist status request.
177
	clc_maplist_update,     // [AM] - Request the entire maplist from the server.
177
	clc_maplist_update,     // [AM] - Request the entire maplist from the server.
178
	clc_getplayerinfo,
178
179
179
	// for when launcher packets go astray
180
	// for when launcher packets go astray
180
	clc_launcher_challenge = 212,
181
	clc_launcher_challenge = 212,
(-)common/c_cvarlist.cpp (+2 lines)
Lines 168-173 Link Here
168
CVAR (cl_deathcam, "1", "Dead player's view follows the actor who killed them", 
168
CVAR (cl_deathcam, "1", "Dead player's view follows the actor who killed them", 
169
      CVARTYPE_BOOL, CVAR_ARCHIVE)
169
      CVARTYPE_BOOL, CVAR_ARCHIVE)
170
170
171
CVAR (cl_predictpickup, "1", "Predict weapon pickups", CVARTYPE_BOOL, CVAR_ARCHIVE)
172
171
// Movebob
173
// Movebob
172
CVAR_FUNC_DECL (cl_movebob, "1.0", "Adjust weapon and movement bobbing", 
174
CVAR_FUNC_DECL (cl_movebob, "1.0", "Adjust weapon and movement bobbing", 
173
      CVARTYPE_BOOL, CVAR_CLIENTARCHIVE | CVAR_NOENABLEDISABLE | CVAR_CLIENTINFO)
175
      CVARTYPE_BOOL, CVAR_CLIENTARCHIVE | CVAR_NOENABLEDISABLE | CVAR_CLIENTINFO)
(-)common/i_net.cpp (+1 lines)
Lines 902-907 Link Here
902
      MSG(clc_callvote,           "x"),
902
      MSG(clc_callvote,           "x"),
903
      MSG(clc_vote,               "x"),
903
      MSG(clc_vote,               "x"),
904
      MSG(clc_maplist,            "x"),
904
      MSG(clc_maplist,            "x"),
905
      MSG(clc_getplayerinfo,      "x"),
905
      MSG(clc_launcher_challenge, "x"),
906
      MSG(clc_launcher_challenge, "x"),
906
      MSG(clc_challenge,          "x")
907
      MSG(clc_challenge,          "x")
907
   };
908
   };
(-)common/p_interaction.cpp (-8 / +2 lines)
Lines 48-53 Link Here
48
EXTERN_CVAR(sv_forcerespawn)
48
EXTERN_CVAR(sv_forcerespawn)
49
EXTERN_CVAR(sv_forcerespawntime)
49
EXTERN_CVAR(sv_forcerespawntime)
50
EXTERN_CVAR(co_zdoomphys)
50
EXTERN_CVAR(co_zdoomphys)
51
EXTERN_CVAR (cl_predictpickup)
51
52
52
int shotclock = 0;
53
int shotclock = 0;
53
int MeansOfDeath;
54
int MeansOfDeath;
Lines 913-928 Link Here
913
	if (delta > toucher->height || delta < lowerbound)
914
	if (delta > toucher->height || delta < lowerbound)
914
		return;
915
		return;
915
916
916
/*	// [SL] 2012-04-06 - Commented out as it occasionally desyncs when a player
917
	// spawns on top of a weapon.  Needs to be investigated more thoroughly
918
	// before being enabled.
919
920
	// Only allow clients to predict touching weapons, not health, armor, etc
917
	// Only allow clients to predict touching weapons, not health, armor, etc
921
	if (!serverside && !P_SpecialIsWeapon(special))
918
	if (!serverside && (!cl_predictpickup || !P_SpecialIsWeapon(special)))
922
		return;
919
		return;
923
*/
924
	if (!serverside)
925
		return;
926
920
927
	P_GiveSpecial(toucher->player, special);
921
	P_GiveSpecial(toucher->player, special);
928
}
922
}
(-)common/p_user.cpp (-6 lines)
Lines 658-669 Link Here
658
			}
658
			}
659
		}
659
		}
660
660
661
		// [SL] 2012-03-31 - Client is trying to switch to a weapon they don't own
662
		// Server should send them their weapon inventory
663
		if (!clientside && newweapon >= 0 && newweapon < NUMWEAPONS &&
664
			!player->weaponowned[newweapon])
665
			SV_SendPlayerInfo(*player);
666
667
		if ((newweapon >= 0 && newweapon < NUMWEAPONS)
661
		if ((newweapon >= 0 && newweapon < NUMWEAPONS)
668
			&& player->weaponowned[newweapon]
662
			&& player->weaponowned[newweapon]
669
			&& newweapon != player->readyweapon)
663
			&& newweapon != player->readyweapon)

Return to bug 269