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

CS2 ConVar RE #154

Open
wants to merge 36 commits into
base: cs2
Choose a base branch
from
Open

CS2 ConVar RE #154

wants to merge 36 commits into from

Conversation

Kenzzer
Copy link
Member

@Kenzzer Kenzzer commented Oct 4, 2023

ConVarRefAbstract and ConCommandRefAbstract, replaced by ConVar and ConCommand respectively.

It seems valve has offset'd the creation of the actual ConVar and ConCommand object to tier0 through the ICvar interface.
I've observed through some RE, that valve has trimmed down the ConVar and ConCommand classes to essentially just this :

class ConVar
{
	ConVarHandle m_Handle;
	ConVar* m_ConVar;
};
class ConCommand
{
	ConVarHandle m_Handle;
};

Everything else has been moved to a struct, which describes a command or convar. Those structs are then stored in a static vector, until ICvar interface is retrieved and ConVar_Register called.

The creation struct essentially looks like this :

struct ConVarOrConCommand_t
{
	const char* name;
	const char* desc;
	int8_t pad[];// specific convar/command data
	ConVarHandle* referenceToHandle;
};

The ptr to the handles are then filled with whatever ICvar returned.

public/tier1/convar.h Outdated Show resolved Hide resolved
public/tier1/convar.h Outdated Show resolved Hide resolved
@Kenzzer Kenzzer marked this pull request as ready for review October 7, 2023 22:45
public/icvar.h Outdated Show resolved Hide resolved
public/icvar.h Outdated Show resolved Hide resolved
public/icvar.h Outdated Show resolved Hide resolved
public/icvar.h Outdated Show resolved Hide resolved
tier1/convar.cpp Outdated Show resolved Hide resolved
public/tier1/convar.h Outdated Show resolved Hide resolved
public/icvar.h Show resolved Hide resolved
public/igameevents.h Outdated Show resolved Hide resolved
public/tier1/convar.h Outdated Show resolved Hide resolved
tier1/convar.cpp Outdated Show resolved Hide resolved
public/icvar.h Outdated
template<> constexpr EConVarType TranslateConVarType<void*>( void ) { return EConVarType_Invalid; }

template<typename T>
class IConVar
Copy link

@mixern6 mixern6 Oct 8, 2023

Choose a reason for hiding this comment

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

I'd like to suggest this structure if it's possible to implement it this way:
IConVar (or something with I) pure abstract, not templated. The header file doesn't contain anything but this interface with forward declaration of all the used types.
CConVarBase inherited from IConVar, not templated, with all the general data and logic.
CConVar < T > inherited from CConVarBase with only the type-specific data and logic.
Put the C* to cconvar.h/cconvar.cpp if it is acceptable by the design.

In the current version it will be hard to use IConVar without the type information.

Copy link
Member

Choose a reason for hiding this comment

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

To not give an impression that this was ignored, you can review the current structure if you have anything to add (Since some of your points were addressed). For the file naming, it's better to not rename something that's was like that since forever.

tier1/convar.cpp Outdated Show resolved Hide resolved
public/icvar.h Outdated Show resolved Hide resolved
public/icvar.h Outdated Show resolved Hide resolved
@Kenzzer Kenzzer requested a review from GAMMACASE October 9, 2023 17:36
@Kenzzer
Copy link
Member Author

Kenzzer commented Oct 29, 2023

Getting closer to finishing the metamod PR. I had to however rebase this, if I wanted to continue my work over there

@psychonic
Copy link
Member

This MR breaks MMS in a minor way:

* https://github.com/alliedmodders/metamod-source/blob/eb4fcf21eac83ae80cecd1ba8ebf8bddda467ad6/core/ISmmPlugin.h#L428

* https://github.com/alliedmodders/metamod-source/blob/eb4fcf21eac83ae80cecd1ba8ebf8bddda467ad6/core/ISmmAPI.h#L137-L145

Because this MR removes class ConCommandBase;.

This is known and expected. MM:S will have to be adapted to the SDK. Work on that is still in-progress.

This commit will be reverted eventually
Wend4r added a commit to Wend4r/hl2sdk that referenced this pull request Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants