Interrupt / systemshock

Shockolate - A minimalist and cross platform System Shock source port.
GNU General Public License v3.0
802 stars 62 forks source link

Fix the problem with weapon reload when running low on ammo #360

Closed shamazmazum closed 4 years ago

shamazmazum commented 4 years ago

Hello. If you reload a weapon with the last clip, you will not able to unload and then load it again (the remaining ammo disappears). Also it can be rendered incorrectly in HUD (screenshot shows a railgun loaded with magcarts). 20200420_10h42m33s_grim

The problem is caused by incorrect check in mfd_weapon_expose_projectile(). A comment before that check seems to be incorrect. Tested it by swapping weapons of different type (pistol/automatic/beam) in weapon slots in all possible combinations, all seem to be OK.

donnierussellii commented 4 years ago

The oob comment and check was added by me in response to Issue #265.

I presume the two uses of the memory location do get mixed up somehow, leading to the crash mentioned in the issue. It may be related to use of the cheat command to obtain weapons (which overwrite slots haphazardly) and doesn't occur in normal gameplay.

shamazmazum commented 4 years ago

Uh, sorry, @donnierussellii. I think I skipped git blame for this one. I'll see how #265 can be reproduced

shamazmazum commented 4 years ago

@donnierussellii About cheat codes, you are right! Great thinking!

Just after starting the game, press CTRL+2. You'll see something like this: 20200421_09h10m57s_grim

Compare with the screenshot in #265. You'll see the same weapon set, which means the reporter is a cheater ;) Also the weapons obtained with CTRL+2 cannot be removed from the inventory and also use wrong ammo type. Again, a rail gun is loaded with magcarts.

I'll create an issue for this.