Skip to content

Conversation

@RaphaelIT7
Copy link
Contributor

[+] Added TIER1_PROJECTCALLBACK
This allows one to add for example definitions for tier0.
Example

function TIER1_PROJECTCALLBACK()
	defines("CULL_ALL_CVARS_NOT_FCVAR_RELEASE") -- When people intentionally want this enabled.
end
IncludeSDKTier1()

[+] Added TIER1_CUSTOMCONVARREGISTER and TIER1_CUSTOMCONVARUNREGISTER
Some people might want to implement custom ConVar_Register and _Unregister functions so why not provide an option.
[+] Exposed some vars from convar.cpp adding functions like ConVar_GetConVarFlag and such.
[#] Fixed some windows 64x compile errors
Some of the threadtools stuff caused linker issues as some of the CThreadSpinRWLock seem to already exists in the tier0.lib file.
[-] Removed CULL_ALL_CVARS_NOT_FCVAR_RELEASE flag from convar.cpp
This only exists on 64x and any convar without some specific flags will have the development flag automatically added amking them hidden.

@danielga danielga self-requested a review May 18, 2025 12:31
Comment on lines -35 to +36
#define CULL_ALL_CVARS_NOT_FCVAR_RELEASE
// RaphaelIT7: Fk this, why would anyone want this in a SDK.
// #define CULL_ALL_CVARS_NOT_FCVAR_RELEASE
Copy link
Owner

Choose a reason for hiding this comment

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

What's the purpose of this? Can't you just add a FCVAR_RELEASE flag to the convar/concommand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc FCVAR_RELEASE doesn't exist on 32x so if modules don't consider this, they have random issues with their convars being invisible/never registered.

Copy link
Owner

Choose a reason for hiding this comment

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

I can add a simple

#ifndef FCVAR_RELEASE
#define FCVAR_RELEASE 0
#endif

like in the haptics files for the main branch.

Copy link
Contributor Author

@RaphaelIT7 RaphaelIT7 Jul 27, 2025

Choose a reason for hiding this comment

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

It would work, though still on 32x by default this isn't a thing, and adding that would still cause useless debugging/pain when its missing and it doesn't really seem to be necessary to have this for modules.

Copy link
Owner

Choose a reason for hiding this comment

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

I like to avoid making incompatible changes or with different behavior from the original. I'm way beyond the "hopeful" part for the x86-64 branch becoming the main one, but still... Defining a new FCVAR_RELEASE on the main branch is the solution that deviates the least from the regular behavior. If people develop modules for the x86-64 branch, then they must be aware of the caveats of using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe having a flag or something to disable this on x86-64 would be useful instead of having to add this on 32x everywhere.

Copy link
Owner

Choose a reason for hiding this comment

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

You don't have to add the flag on modules that only use the main branch. If you use the x86-64 branch, then you add the flag, simple. It will do nothing when you build the module for the main branch.

Comment on lines +130 to +132
if TIER1_PROJECTCALLBACK then
TIER1_PROJECTCALLBACK()
end
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like this workaround, specially for something that doesn't seem to be a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above, I might remove this again.

class ALIGN8 PLATFORM_CLASS CThreadSpinRWLock
{
public:
#ifndef WIN32
Copy link
Owner

Choose a reason for hiding this comment

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

What are these changes trying to do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc I had some linker issues on Windows where these were already defined in the tier0.lib or another lib file & caused a pain for a while until the best decision seemed to just wrap it with WIN32 which worked.

Comment on lines +48 to +61
int* ConVar_GetConVarFlag()
{
return &s_nCVarFlag;
}

int* ConVar_GetDLLIdentifier()
{
return &s_nDLLIdentifier;
}

bool* ConVar_GetIsRegistered()
{
return &s_bRegistered;
}
Copy link
Owner

Choose a reason for hiding this comment

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

These don't seem specially useful, as they won't return the real instances from Garry's Mod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example use case: https://github.com/RaphaelIT7/gmod-holylib/blob/main/source/util.cpp#L691
Using ConVar_GetDLLIdentifier, for example, I can iterate over all convars and find all those from my DLL easily.

return &s_DefaultAccessor;
}

#ifndef TIER1_CUSTOMCONVARREGISTER
Copy link
Owner

Choose a reason for hiding this comment

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

Do you have an example of these custom functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had used them a good while ago, though they then lost their purpose and were removed again.
Tbh I think I can remove the TIER1_CUSTOMCONVARREGISTER stuff since its really not that useful as I first had thought it would be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants