cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
868 stars 115 forks source link

Fix normal guns in melee slot #791

Closed Kurtsley closed 12 months ago

Kurtsley commented 1 year ago

Addresses #781.

This should prevent guns being added to the melee slot. Should an error sound be played as well?

cxong commented 1 year ago

I see, this is a slightly tricky bug I think I would prefer the following:

Kurtsley commented 1 year ago

This appears to accomplish what you wanted the game to do. The only thing I wasn't able to test was picking up a different melee weapon while holding a melee weapon.

Kurtsley commented 12 months ago

Okay, this is what I have now:

Anything else that happens should be the same as before.

I tested this as many ways I could think of, including with and without the grenade slot. Hopefully this works correctly now, but I could be missing an edge case. This was more complicated than I originally thought.

cxong commented 12 months ago

I'll take a look at this myself later, and considering how complex this turned out to be, I think it's worth refactoring this logic to the Actor class and covering with unit tests.

Kurtsley commented 12 months ago

I was looking at possibly adding it to the ActorReplaceGun function in the actors.c file. Either that or put it in a separate bool function , whatever works best. As for the unit tests, that is not a strength of m

Kurtsley commented 12 months ago

Accidentally closed. To continue, I would give the tests a shot.