project-navigation
Personal tools

Author Topic: G_ActorInvMove and IA_RELOAD_SWAP  (Read 3858 times)

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
G_ActorInvMove and IA_RELOAD_SWAP
« on: September 13, 2010, 07:40:18 pm »
I found it while running tests for my Encumbrance and TU penalty work

When you swap ammo in combat the wrong item is placed back in the source container:

You can reproduce it: (I checked the latest rev without my changes)

1) Get a soldier equiped with Rocket Launcher with HE Rocket loaded and an spare IC Rocket, lets say in the belt
2) Enter combat
3) Open the soldier inventory and drag the IC Rocket to the Launcher -- Launcher loaded OK but a new IC Rocket will be placed in the belt instead of the HE Rocket that was unloaded
4) Drag the fake IC Rocket to the Launcher -- Launcher is now loaded with a HE Rocket and there is a (fake) HE Rocket in the belt

I've nailed it to G_ActorInvMove and the way it handles IA_RELOAD_SWAP cases
Should I submit a separate patch for this?

Edit: This seems to affect 2.3 as well
« Last Edit: September 13, 2010, 07:47:56 pm by DarkRain »

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: G_ActorInvMove and IA_RELOAD_SWAP
« Reply #1 on: September 13, 2010, 10:18:03 pm »
yes - please make a separate patch for this.

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: G_ActorInvMove and IA_RELOAD_SWAP
« Reply #2 on: September 14, 2010, 09:06:43 pm »
Submited a patch to the tracker: 3066156

Swapping ammo during combat should work as expected EXCEPT . . .
I found a new bug while testing this, if the ammo you are trying to load is the last item in the floor (while swapping ammo) battlescape will crash with:
Code: [Select]
********************
ERROR: InvAdd message ignored... LE not found

********************
/home/eliab/GIT/ufoai/ufo(Sys_Backtrace+0x1f)[0x81acfcd]
/home/eliab/GIT/ufoai/ufo(Com_Error+0xd3)[0x814c34b]
/home/eliab/GIT/ufoai/ufo(CL_InvAdd+0x65)[0x80a316f]
/home/eliab/GIT/ufoai/ufo[0x809f9cd]
/home/eliab/GIT/ufoai/ufo(Qcommon_Frame+0x7b)[0x814e118]
/home/eliab/GIT/ufoai/ufo(main+0x5c)[0x81ab72f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x463bd6]
/home/eliab/GIT/ufoai/ufo[0x806d381]
Shutdown server: Server crashed.
Shutdown the game thread
==== ShutdownGame ====
Free inventory slots in game on shutdown: 0
Unload the game library

I can reproduce this in the unmodified latest rev and in 2.3 this crashes the game as well (so I know I didn't introduce it)

Guess I'll go hunting this one now . . .
« Last Edit: September 14, 2010, 09:08:54 pm by DarkRain »

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: G_ActorInvMove and IA_RELOAD_SWAP
« Reply #3 on: September 16, 2010, 04:35:31 am »
Submiting a new patch to the tracker (3067252), a work around for the LE not found error while trying to swap the last ammo in the floor, just a work around it.
The cause is the client will remove the floor le when removing the last item from it but then we are putting back the ammo we swapped from the weapon to a non existant floor in the client

I'm also attaching (in this post) a test case for test_inventory.c for reload and reload swap in case you are still interested.
« Last Edit: September 16, 2010, 04:41:53 am by DarkRain »

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: G_ActorInvMove and IA_RELOAD_SWAP
« Reply #4 on: September 16, 2010, 08:29:50 am »
thanks a lot for both fixes - i've also applied the workaround to master, but this should get fixed in a different way - as the server should really not care about how the client handles this stuff.

and thanks for the testcase - it's applied, too.

if you are interested in commit rights, let me know ;)

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: G_ActorInvMove and IA_RELOAD_SWAP
« Reply #5 on: September 16, 2010, 08:52:27 am »
maybe we should add a new event type for this - a real EV_INV_MOVE that is not splitted into remove and add events but handles this at once.

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: G_ActorInvMove and IA_RELOAD_SWAP
« Reply #6 on: September 17, 2010, 01:38:01 am »
Workarounds are rarely true fixes, but they are faster to do . . .

There's already an EV_INV_RELOAD event, maybe that sould handle this particular case, but an EV_INV_MOVE still sounds good to me