Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Speedloader Partial Reload #32396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public bool TryRevolverInsert(EntityUid revolverUid, RevolverAmmoProviderCompone
return false;
}

for (var i = Math.Min(ev.Ammo.Count - 1, component.Capacity - 1); i >= 0; i--)
for (var i = 0; i < component.Capacity; i++)
{
var index = (component.CurrentIndex + i) % component.Capacity;
Comment on lines 132 to 135
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't that entirely duplicate lines 171-193 at this point.

Copy link
Contributor Author

@Rainbeon Rainbeon Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part they are very similar but lines 171-193 will not run if the Speedloader Component is present, and vice versa. 171-193 only loads a single bullet and is an alternative to lines 107-168, though its method for finding where to put those bullets is correct, unlike Speedloader's current method. They attempt to do similar things, but Speedloader's version doesn't function correctly because it both looks in the incorrect direction, and it doesn't actually look through the entire cylinder, leading to it just despawning bullets without loading any of them, or putting them in bad places.

Copy link
Contributor Author

@Rainbeon Rainbeon Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore what 133-158 is doing is looking through every slot from the initial position in an attempt to load multiple rounds from a container (the Speedloader), and breaking when it runs out of ammo. It grabs round types of the speedloader (which can be mixed types) and takes it out of the speedloader. It finishes after this loop is ran.

What 171-193 is doing is looking through every slot from the initial position to insert a single round from the hand and then instantly finishing inside the same loop.

They each handle a different case and don't run in parallel, not code dupe, and the loop would need to be the same regardless. These HAVE to be split and have the same For Loop definition. The only actual duping is the end sequence (outside of this loop) where it plays the sound, updates the appearances, and then dirties the comp, which is not part of this.


Expand Down
Loading