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

Make CPPI functions obey settings #342

Merged
merged 9 commits into from
Mar 6, 2025
Merged

Conversation

Astralcircle
Copy link
Contributor

Modifies CPPI functions to make them work more correctly. For example, this fixes returning false in CPPICanDamage when damage protection is disabled.

Copy link
Owner

@FPtje FPtje left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Copy link
Owner

@FPtje FPtje left a comment

Choose a reason for hiding this comment

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

Taking a closer look, I understand where you're coming from: none of these functions take toggle into account because that check is done in the FPP.Protect functions. That's a good find!

I did find a problem about the unghosting though. Would it be an idea to separately check for the toggle setting, and then still use FPP.plyCanTouchEnt?

@Astralcircle
Copy link
Contributor Author

This will look like a hardcoded fix since it won't take other settings into account.

@FPtje
Copy link
Owner

FPtje commented Feb 25, 2025

True, but it looks like those other settings are not what we want. The gravgun punting function, for example, may drop the prop. This makes sense to do on the hook, but not so much in the CPPI function

@Astralcircle
Copy link
Contributor Author

Astralcircle commented Feb 25, 2025

I can add more additional checks, or just use the hardcoded fix, since this is already enough for me, but may not be enough for others.

@Astralcircle
Copy link
Contributor Author

Astralcircle commented Feb 26, 2025

Now I think I have taken into account everything that is necessary. If you think I am wrong, then let me know.

@Astralcircle Astralcircle changed the title Better CPPI checks Make CPPI functions obey settings Feb 26, 2025
@FPtje
Copy link
Owner

FPtje commented Mar 2, 2025

Hmm, I think the internal variables in so many places might be a sign that this is trying to mix two functionalities into one. I see a risk here of something going wrong, for example when some addon decides that the GravGunPunt hook should get an extra argument when called. This would break FPP, because it would interpret that extra argument as internal, after which it no longer drops the props on punting.

I've pushed a commit to propose an alternative: just check the toggle setting, but then still just use FPP.plyCanTouchEnt. That way there's no need to change the functions that respond to the hooks. Let me know what you think!

@@ -564,6 +566,7 @@ hook.Add("CanProperty", "FPP.Protect.CanProperty", FPP.Protect.CanProperty)

function FPP.Protect.CanDrive(ply, ent)
-- Use Toolgun because I'm way too lazy to make a new type
if not tobool(FPP.Settings.FPP_TOOLGUN1.toggle) then return true end
Copy link
Owner

Choose a reason for hiding this comment

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

These three fix a different bug: apparently editing variables/properties/driving also used toolgun settings, even if toolgun settings were disabled.

@Astralcircle
Copy link
Contributor Author

Astralcircle commented Mar 6, 2025

Okay, it looks like it can't break anything and that's good enough for me. Sorry for the late reply, my PC broke this week

@FPtje
Copy link
Owner

FPtje commented Mar 6, 2025

Sweet!

@FPtje FPtje merged commit c38b3e7 into FPtje:master Mar 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants