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

Linking belt refactoring #5206

Merged
merged 2 commits into from
May 27, 2017
Merged
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
9 changes: 2 additions & 7 deletions addons/reload/functions/fnc_startLinkingBelt.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ params ["_player", "_target"];
if (vehicle _target != _target) exitWith {false};

private _magazineType = currentMagazine _target;
private _magazineCfg = configFile >> "CfgMagazines" >> _magazineType;

if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {false};
private _canLink = [_player, _target] call FUNC(canLinkBelt);

// Check if the ammo is not empty or full
private _ammoCount = _target ammo currentWeapon _target;

// Exit if the belt is full or empty
if ((_ammoCount == 0) || (getNumber (_magazineCfg >> "count") - _ammoCount) == 0) exitWith {false};
if ( !_canLink ) exitWith {} ;
Copy link
Member

Choose a reason for hiding this comment

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

if (!_canLink) exitWith {}; would be per our coding guidelines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okey!


// Check if the player has any of the same same magazines
// Calculate max ammo it can link
Copy link
Member

Choose a reason for hiding this comment

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

This section below is already included in FUNC(canLinkBelt) as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okey but I wanted to keep that FUNC(canLinkBelt) returned a bool and not a number.

So thats why i kept the lower part in both cases. But I could redo both of the files to keep them 100% unique?

Just say the word nad ill do it :)

Copy link
Member

@jonpas jonpas May 27, 2017

Choose a reason for hiding this comment

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

I think it would be a good idea to cut down on duplicate code if nothing else. As long as it doesn't make it more complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expand Down