MantisBT - Zandronum
View Issue Details
0000372Zandronum[All Projects] Bugpublic2011-04-08 05:462018-09-30 22:37
bluewizard 
Torr Samaho 
lowminoralways
closedfixed 
MicrosoftWindowsXP/Vista/7
98d 
 
0000372: Shooting Grenades on Barrels make them act weird
If you shoot a grenade from Skulltag's grenade launcher, It will make the grenade projectile act in very strange ways. Such as, the grenade might land somewhere but the actual explosion might be shown somewhere else. I'm guessing that it desyncs.
1. Go to any map
2. Open console and summon a barrel(s)
3. Give yourself a grenade launcher.
4. Shoot a grenade at the barrel.
5. Pay close attention to where the grenade falls after bouncing off the barrel, and where it actually explodes.
grenade
related to 0000201closed Torr Samaho Grenade explosion when timer runs out does not have any transparency 
related to 0000371closed Torr Samaho [Skulltag] Grenade disappears on 3D Floor. 
Issue History
2011-04-08 05:46bluewizardNew Issue
2011-04-08 07:32unknownnaNote Added: 0001310
2011-04-08 07:32unknownnaStatusnew => confirmed
2011-04-08 07:33unknownnaRelationship addedrelated to 0000201
2011-04-08 07:38unknownnaRelationship addedrelated to 0000371
2012-02-20 00:42ZzZomboNote Added: 0002651
2012-02-20 01:44Torr SamahoNote Added: 0002652
2012-02-20 01:44Torr SamahoAssigned To => Torr Samaho
2012-02-20 01:44Torr SamahoStatusconfirmed => feedback
2012-02-20 02:30ZzZomboNote Added: 0002653
2012-02-20 02:32Torr SamahoNote Edited: 0002652bug_revision_view_page.php?bugnote_id=2652#r1343
2012-02-20 11:02DuskNote Added: 0002654
2012-02-20 11:02DuskNote Edited: 0002654bug_revision_view_page.php?bugnote_id=2654#r1345
2012-02-20 11:04DuskNote Edited: 0002654bug_revision_view_page.php?bugnote_id=2654#r1346
2012-02-20 11:08DuskNote Edited: 0002654bug_revision_view_page.php?bugnote_id=2654#r1347
2012-02-20 12:38Torr SamahoNote Added: 0002655
2012-02-20 13:20ZzZomboNote Added: 0002656
2012-02-20 13:28DuskNote Added: 0002657
2012-02-20 14:18TIHanNote Added: 0002659
2012-02-21 01:50TIHanNote Added: 0002660
2012-02-22 00:56Torr SamahoNote Added: 0002662
2012-02-22 01:12TIHanNote Added: 0002664
2012-02-22 12:50Torr SamahoNote Added: 0002668
2012-02-22 12:51Torr SamahoNote Edited: 0002668bug_revision_view_page.php?bugnote_id=2668#r1351
2012-02-22 15:58TIHanNote Added: 0002669
2012-02-23 00:19Torr SamahoNote Added: 0002676
2012-06-09 13:22Torr SamahoCategoryGeneral => Bug
2015-09-05 02:01DuskStatusfeedback => resolved
2015-09-05 02:01DuskResolutionopen => fixed
2018-09-30 22:37Blzut3Statusresolved => closed

Notes
(0001310)
unknownna   
2011-04-08 07:32   
You're right.
(0002651)
ZzZombo   
2012-02-20 00:42   
Same I think issue present in Zombie Horde: when you are shooting a fire grenade at barrel the grenade disappear and after a while you see only explosion sprite not fire which must be spawned by grenade after explosion.
(0002652)
Torr Samaho   
2012-02-20 01:44   
(edited on: 2012-02-20 02:32)
This should improve sync when a grenade bounces off another actor.

(0002653)
ZzZombo   
2012-02-20 02:30   
It works for grenades but I can't confirm does it fix fire grenades too lazy to start Zombie Horde server. Please fix URL in your post.
(0002654)
Dusk   
2012-02-20 11:02   
(edited on: 2012-02-20 11:08)
I and TIHan were on about this bug. The grenade was desynced in a couple of ways:
- The initial flight curve is off by a fraction of an unit. Changing A_FireCustomMissileHelper to use ShootMissileExact fixes this.
- The client isn't told about it when the grenade bounces off the barrel nor can it figure it by itself, even when the flight curve is corrected. When I made it to do so, bounces caused further desynchs related to Z-height:
if ( NETWORK_GetState( ) == NETSTATE_SERVER ) {
    SERVERCOMMANDS_SetThingAngleExact( mo );
    SERVERCOMMANDS_MoveThingExact( mo, CM_MOMX|CM_MOMY|CM_MOMZ|CM_X|CM_Y|CM_Z );
}

With these changes applied, the Z-height remains off by momz units:
Server's log:'http://pastebin.com/1ijdWQhn [^]'
Client's log:'http://pastebin.com/XyhmMp03 [^]'
Picture, with grenade trails:'http://i.imgur.com/fihrE.png [^]'
Red trail is client's, green trail is server's.
(I added the function names afterward, I wanted to note which function caused what log entry but didn't want to get the material all over again)

Granted, the desynch isn't very much and informing the clients about the bounce fixes the initial desynch and fixing the flight curve with SpawnMissileExact fixes further desynchs (where the client thought in some cases that the grenade hit the barrel while it actually flew over). The only problem left is that the bounce leaves no bounce sound as clients can't figure that. I'd believe that if clients were told about bounce sounds explicitly it should fix the issue.

Also, TIHan found out that the client thinks grenade seems to be fired twice - this causes the firing sound to be played twice.

I noticed that the debug build you have has the exact same issue of Z-height desynch and no bounce sound. I get the same grenade curve trails with the build and I believe the coordinates won't be very far off either.

(0002655)
Torr Samaho   
2012-02-20 12:38   
> - The initial flight curve is off by a fraction of an unit. Changing A_FireCustomMissileHelper to use ShootMissileExact fixes this.

Sounds good, but I guess you mean SERVERCOMMANDS_SpawnMissileExact instead of ShootMissileExact, right?

> - The client isn't told about it when the grenade bounces off the barrel nor can it figure it by itself, even when the flight curve is corrected.

That's what I changed in my debug build (code is committed now that ZzZombo reported that it improves the situation for him). I still need to make the change in A_FireCustomMissileHelper though, I didn't notice that during my quick tests yesterday.

> Red trail is client's, green trail is server's.

That looks perfect for debugging. Is that an example wad? Can you send it to me?

> Also, TIHan found out that the client thinks grenade seems to be fired twice - this causes the firing sound to be played twice.

Can you elaborate this?

> I noticed that the debug build you have has the exact same issue of Z-height desynch and no bounce sound.

That's weird. I added new netcode for the bounce sound (contained in the build I posted above) and it worked in my tests.
(0002656)
ZzZombo   
2012-02-20 13:20   
I remember I heard the bounce from barrel. Also it may have value I spawned the grenade with "summon grenade" in console because was lazy to cheat ammo for grenade launcher.
(0002657)
Dusk   
2012-02-20 13:28   
>Sounds good, but I guess you mean SERVERCOMMANDS_SpawnMissileExact instead of ShootMissileExact, right?
Yeah. Remembered the name wrong there.

> That looks perfect for debugging. Is that an example wad? Can you send it to me?
Uploaded:'http://www.mediafire.com/?mvnceomn3rbiggw [^]'

> I added new netcode for the bounce sound (contained in the build I posted above) and it worked in my tests.
The bounce sound works, though the z-height desynch remains there. Again, it's neglegible, being only a few units. It happens right after the grenade hits the barrel, and is as if the client misses an application of momz on the grenade's Z position. X/Y coords remain perfectly in sync until further bounces cause minor X/Y desyncing due to the Z coordinate being off.
(0002659)
TIHan   
2012-02-20 14:18   
What Nightfall said, the grenade gets fired twice. client_SpawnMissileExact gets called, then client_SpawnMissile.

In A_FireCustomMissileHelper, P_SpawnPlayerMissile calls SERVERCOMMANDS_SpawnMissileExact then at the end of A_FireCustomMissileHelper, SERVERCOMMANDS_SpawnMissile gets called.
(0002660)
TIHan   
2012-02-21 01:50   
With the help of Nightfall(Dusk), I managed to solve, afaik, all the desync issues with grenades as well as the double firing.

Binaries:
'http://www.mediafire.com/?3n2cb86hg7q9ngs [^]'

Changes:
'https://bitbucket.org/TIHan/tst/changesets/tip/branch(%22grenade_fix%22) [^]'

Tell me if there is any ambiguity here.
(0002662)
Torr Samaho   
2012-02-22 00:56   
> In A_FireCustomMissileHelper, P_SpawnPlayerMissile calls SERVERCOMMANDS_SpawnMissileExact then at the end of A_FireCustomMissileHelper, SERVERCOMMANDS_SpawnMissile gets called.

Good finding! Your fix for this issue works, needs more nettraffic than necessary though. That's why I fixed this differently (see latest changeset).

I'll still need to check your changes in p_mobj.cpp.

BTW: I'm very happy to see that you and Dusk are so actively contributing source changes :). Greatly appreciated.
(0002664)
TIHan   
2012-02-22 01:12   
No problem.

I see how you fixed it differently and it makes sense. Perhaps I'm afraid of adding extra parameters like that elsewhere if it hurts backporting zdoom stuff. We may need a discussion on what and what not to do.

Also in p_mobj, basically, at the end of the function P_ZMOVEMENT, you need to call an update on the actor to the client if the actor bounced. Dusk identified that there was something going on with the z momentum, that is where it was. There is some copy and pasted code there; not sure if I'm allowed to make a separate function to check if something bounced - again worried about hurting zdoom backporting.
(0002668)
Torr Samaho   
2012-02-22 12:50   
(edited on: 2012-02-22 12:51)
> We may need a discussion on what and what not to do.

Sure. And I totally agree that staying compatible with ZDoom is a very important goal. In particular, changes to ZDoom code should only be done if really necessary. Unfortunately saving nettraffic is also an important goal and for this fix a compromise was necessary. Since Skulltag already had altered the signature of P_SpawnPlayerMissile though, adding another argument there didn't make backporting stuff there any more difficult.

Avoiding copy and paste is also very important, i.e. the chunk of code you copied in p_mobj should be avoided. I still didn't have time to look at the effects of the change, so I can't really say more on this yet. One possible way to fix this would be to define a bool at the beginning of the function, set that bool to true if the actor bounced and then call the server code where you call it by only checking the bool instead of replicating all checks that were done before.

(0002669)
TIHan   
2012-02-22 15:58   
The original bounce checks are in P_XYMovement function, and I need the check to see if the actor bounced at the end of P_ZMovement function. Perhaps adding a bool to the AActor class, called, "bBounced", will get set to true if it bounced in P_XYMovement - thus bBouced will be used as a check at the end of P_ZMovement. I'm just thinking outloud here, but at least it reduces code duplication.
(0002676)
Torr Samaho   
2012-02-23 00:19   
Alright, I looked a bit closer into this and introduced a new net flag to handle this. Still a crutch, but it doesn't need any code duplication and is not invasive to ZDoom code.