MantisBT - Zandronum
View Issue Details
0003491Zandronum[All Projects] Bugpublic2018-09-10 14:442024-06-02 19:13
unknownna 
Kaminsky 
normalmajoralways
feedbackopen 
3.0 
3.2 
0003491: Berserk powerup causes weapons to desync and client to fire weapon too early
While testing a map in DUEL40 (UROBUROS) with some bots on a server, I noticed that my SSG desynced rather badly when picking up a berserk powerup and then quickly selecting my SSG again after the client was forced to switch to the fist. The client fires the weapon too early when selecting the former weapon again, causing the timing to be completely off and projectiles even disappearing.

Players will notice this desync very often on this map considering that the berserk is seemingly strategically placed as a health pickup when needed. When players then switch back to their SSG, the timing of the puffs will be completely off compared to the animation and sounds at the corresponding ping, causing the shots to be broken and potentially making players blame the unlagged etc.
1. zandronum -host -iwad doom2.wad -file wepdesync_berserk.wad +sv_itemrespawn 1
2. Connect a client to the server with an emulated ping of 160.
3. Copy-paste "join;wait 23;+forward;wait 10;-forward;wait 14;weapprev;+attack;wait 20;-attack" into the console. The rocket launcher animation will be displayed and ammo used, but no rocket will come out.
4. Spectate and re-enter bind to reproduce the desync every time.
ACTOR Berserk : CustomInventory 2023
{
    Game Doom
    SpawnID 134
    +COUNTITEM
    +INVENTORY.ALWAYSPICKUP
    Inventory.PickupMessage "$GOTBERSERK"
    Inventory.PickupSound "misc/p_pkup"
    States
    {
    Spawn:
        PSTR A -1
        Stop
    Pickup:
        TNT1 A 0 A_GiveInventory("PowerStrength")
        TNT1 A 0 HealThing(100, 0)
        TNT1 A 0 A_SelectWeapon("Fist")
        Stop
    }
}

This is not a 3.1 regression.
No tags attached.
related to 0001116resolved Kaminsky Client fires weapon too early after respawning 
child of 0003980feedback Kaminsky Desync with firing weapons with WEAPON.NOAUTOFIRE flag 
? wepdesync_berserk.wad (1,134) 2018-09-10 14:44
https://zandronum.com/tracker/file_download.php?file_id=2382&type=bug
Issue History
2018-09-10 14:44unknownnaNew Issue
2018-09-10 14:44unknownnaFile Added: wepdesync_berserk.wad
2018-09-10 14:45unknownnaStatusnew => confirmed
2018-09-10 14:45unknownnaRelationship addedrelated to 0001116
2024-05-27 06:26unknownnaNote Added: 0023723
2024-05-27 18:27unknownnaRelationship addedchild of 0003980
2024-05-28 15:06KaminskyNote Added: 0023729
2024-05-28 15:06KaminskyAssigned To => Kaminsky
2024-05-28 15:06KaminskyStatusconfirmed => needs review
2024-05-28 15:06KaminskyTarget Version => 3.2
2024-05-28 15:06KaminskyNote Edited: 0023729bug_revision_view_page.php?bugnote_id=23729#r14219
2024-05-28 17:05unknownnaNote Added: 0023730
2024-05-28 17:06unknownnaStatusneeds review => feedback
2024-05-28 17:26unknownnaNote Edited: 0023730bug_revision_view_page.php?bugnote_id=23730#r14221
2024-05-28 17:54unknownnaNote Edited: 0023730bug_revision_view_page.php?bugnote_id=23730#r14222
2024-05-28 17:55unknownnaNote Edited: 0023730bug_revision_view_page.php?bugnote_id=23730#r14223
2024-05-28 18:27unknownnaNote Edited: 0023730bug_revision_view_page.php?bugnote_id=23730#r14224
2024-05-28 20:49unknownnaNote Edited: 0023730bug_revision_view_page.php?bugnote_id=23730#r14225
2024-05-29 14:44unknownnaNote Edited: 0023730bug_revision_view_page.php?bugnote_id=23730#r14228
2024-06-01 18:07KaminskyNote Added: 0023746
2024-06-01 18:07KaminskyStatusfeedback => needs review
2024-06-01 18:55unknownnaNote Added: 0023748
2024-06-01 20:58unknownnaNote Edited: 0023748bug_revision_view_page.php?bugnote_id=23748#r14244
2024-06-01 20:58unknownnaStatusneeds review => feedback
2024-06-01 21:28unknownnaNote Edited: 0023748bug_revision_view_page.php?bugnote_id=23748#r14245
2024-06-02 02:44KaminskyNote Added: 0023750
2024-06-02 02:44KaminskyStatusfeedback => needs review
2024-06-02 18:46unknownnaNote Added: 0023751
2024-06-02 18:46unknownnaStatusneeds review => feedback
2024-06-02 18:46unknownnaNote Edited: 0023751bug_revision_view_page.php?bugnote_id=23751#r14247
2024-06-02 18:48unknownnaNote Edited: 0023751bug_revision_view_page.php?bugnote_id=23751#r14248
2024-06-02 19:04unknownnaNote Edited: 0023751bug_revision_view_page.php?bugnote_id=23751#r14249
2024-06-02 19:13unknownnaNote Edited: 0023751bug_revision_view_page.php?bugnote_id=23751#r14250

Notes
(0023723)
unknownna   
2024-05-27 06:26   
I believe A_SelectWeapon("Fist") in the Pickup state is causing this.
(0023729)
Kaminsky   
2024-05-28 15:06   
I created a merge request to address this issue:'https://foss.heptapod.net/zandronum/zandronum-stable/-/merge_requests/123 [^]'

I already mentioned in the MR what the underlying issue seems to be. For now, it's in draft mode since I'd first like to know if the fix works properly for anyone else. Here's a build with the fix:'https://www.mediafire.com/file/thym0b8tnwmfj5d/ZandroDev3.2-beserk-wepdesync-fix.zip [^]'

It would also be great if someone can confirm that the fix doesn't cause any unwanted side effects. Thanks!

(0023730)
unknownna   
2024-05-28 17:05   
(edited on: 2024-05-29 14:44)
Hey, it seems to work, but when I tested it with 300 ping I was able to desync it and causing missing rockets. After checking with the other respawn desync, it seems that the build above doesn't include the fix for it. Could you make me a build that contains both fixes so I can test it more thoroughly? Thank you.

Edit:
It still desyncs if you're firing the weapon as you pick up the berserk. It might very well be caused by the other ammo pickup desync,'https://zandronum.com/tracker/view.php?id=534 [^]'

If I use a "changemap" map change, I can see that the player fired 1 rocket too many for some reason. I'll try to make a bind that reproduces it.

Edit2:
I found 2 separate desyncs perhaps, or they're the same issue expressed in different ways.

MISSING ROCKET 1:

Using a ping of 160, if the initial delay between the first +forward and -forward is less than 3, it desyncs. The client fires too early after switching back to the rocket launcher and fires a missing rocket. On rare occasions, the desync doesn't occur with the bind below, but 90% of the time it does.

1. zandronum -host -iwad doom2.wad -file wepdesync_berserk.wad +sv_itemrespawn 1
2. Connect a client to the server with an emulated ping of 160 and join the game.
3. Copy-paste "+forward;wait 2;-forward;wait 18;weapprev;+attack;wait 20;-attack" into the console.

MISSING ROCKET 2:

Using a ping of 160, the client fires 1 rocket too many when walking over the berserk, causing it to spend ammo and fire a missing rocket.

1. zandronum -host -iwad doom2.wad -file wepdesync_berserk.wad +sv_itemrespawn 1
2. Connect a client to the server with an emulated ping of 160 and join the game.
3. Copy-paste "+attack;wait 13;+forward;wait 10;-attack;-forward" into the console.

It may not be possible to fix the issues completely, as the client doesn't know locally that it walks over items until the server tells it, and having the client do item checks on its own could break it badly in different ways, for instance when getting pushed by something on the server after the client already did the item check locally, but I'm not sure.

Edit3:
MISSING ROCKET 1 is caused by the berserk pickup respawning very fast with sv_itemrespawn 1 and it being picked up twice in close succession, so it shouldn't happen at all in regular gameplay.

MISSING ROCKET 2 however still happens without sv_itemrespawn 1.

Thinking about this a bit more, maybe the way to fix this is to let the client finish firing its current weapon before telling it to lower it.
When instructing the client to lower its weapon, check if the client is in a weapon fire state, and if true, let it finish the state before telling the client to lower it.

(0023746)
Kaminsky   
2024-06-01 18:07   
I changed my approach to fixing the weapon desyncs. Now, when the server executes "A_SelectWeapon" or "SetWeapon", it doesn't immediately change the client's weapon on its end (it'll still tell the client to select the new weapon for the latter). Instead, it waits until the client has told the server that it selected the weapon on its end. Here's the build that contains this change:'https://www.mediafire.com/file/e4lq1an50xskhad/ZandroDev3.2-weapondesync-fixes.zip [^]'

By following the steps listed above, I wasn't able to reproduce the desyncs anymore. However, it would be nice if you can test it yourself to confirm that. I'm also not certain on whether the changes I made may unintentionally break something else, or cause unwanted side effects. It'd be nice if this can be tested thoroughly to be sure. Thanks.

P.S. this build also contains the respawn weapon desync fix.
(0023748)
unknownna   
2024-06-01 18:55   
(edited on: 2024-06-01 21:28)
Amazing work! The fix seems to work well now, I can't fire any missing rockets anymore. Let me toy around with the fix in some mods and see if I notice anything broken.

It seems to break All out War 2. When you select a class, you select your fists instead of the intended weapon. This also breaks bots, desyncing their weapon sprites with their actual fist weapons. They run around helplessly trying to attack you with their fists while looking like they are using actual weapons, and actually dropping decals as well.
You also can't use the self-heal item for some reason, so the player inventory is also affected by this side-effect.

(0023750)
Kaminsky   
2024-06-02 02:44   
Thanks for the feedback! It turns out that I made a few oversights:

1. This was also affecting bots when it shouldn't.

2. When a client's weapon was changed via "SetWeapon", the server didn't actually tell the client to change their pending weapon properly. Thus, they could never change their weapon in the first place.

I fixed these issues, and that seemed to resolve the issues in All Out War 2 that you mentioned. Feel free to test out this build:'https://www.mediafire.com/file/kqfe63ipni2nwzh/ZandroDev3.2-weapondesync-fixes-v2.zip [^]' to confirm that, and that there's no more unwanted side effects.

Thanks!
(0023751)
unknownna   
2024-06-02 18:46   
(edited on: 2024-06-02 19:13)
Tested it again just now. There's still some desync left in AOW2. Using 160 ping and selecting the machine gunner class, the self-heal item glitches it up. You can cancel using it by holding in +attack/+altattack, but for some reason the server sometimes ignores this and still goes through with the state, causing you to be forced to spend it. Your client thinks it still has the item in the inventory, but you can never use it again since it was spent on the server.
And sometimes the fist is brought up randomly instead of the machine gun.

And the weapon that is switched to when canceling is many times brought up twice, but this also sometimes happens in 3.1, though less frequently, after double checking.

And using the rifleman class with a ping of 160, I can see that the server fires one bullet too many compared to the client when using the self-heal while holding in +attack before it automatically lowers the weapon to switch to the self-heal.

This definitely still desyncs the weapon states.