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

Get rid of the SDK submodules and move the code into the repo #352

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

lipsanen
Copy link
Collaborator

@lipsanen lipsanen commented Sep 22, 2024

Redo of #351

@lipsanen lipsanen marked this pull request as ready for review September 22, 2024 10:32
@lipsanen lipsanen changed the title SDK change but spt changes are readable Get rid of the SDK submodules and move the code into the repo Sep 22, 2024
@UncraftedName
Copy link
Contributor

This clang-format version crap is very tragic - your version is different from mine so you have a lot of unnecessary format diffs. I'll look into setting up a specific clang-format/uncrustify version, or we should completely nuke the formatting.

playdemoCommand = reinterpret_cast<ConCommand_guts*>(interfaces::g_pCVar->FindCommand("playdemo"));
loadCommand = reinterpret_cast<ConCommand_guts*>(interfaces::g_pCVar->FindCommand("load"));
execCommand = reinterpret_cast<ConCommand_guts*>(interfaces::g_pCVar->FindCommand("exec"));
playdemoCommand = reinterpret_cast<ConCommand_guts*>(g_pCVar->FindCommand("playdemo"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need these _guts classes? With every member being public now, there isn't much of a reason to use these anymore. Even if some piece of code is reading from the vtable member(s), it should be easy to live without it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they aren't really needed but I was too lazy to clean up everything

spt/cvars.cpp Outdated
@@ -88,23 +78,20 @@ extern "C" ICvar* GetCVarIF()
}
}

static void RemoveCommandFromList(ConCommandBase** head, ConCommandBase* command)
static void RemoveCommandFromList(ConCommandBase* command)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it's worth it to make this function specific to s_pConCommandBases but still have a generic version copied below for OE (outside of an #ifdef OE block too). This originally took the list head as parameter to avoid effectively repeating code.

spt/cvars.cpp Outdated
@@ -23,31 +23,21 @@ struct FeatureCommand
bool unhideOnUnregister;
};
static std::vector<FeatureCommand> cmd_to_feature;
static bool first_time_init = true;
static ConCommandBase** pluginCommandListHead = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this was already removed but should be now at least

spt/cvars.cpp Outdated
continue;
}
else
Copy link
Contributor

Choose a reason for hiding this comment

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

This else block is redundant, is it not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in OE. The plugin unload does not get rid of the binary (the fix that works in 3420 hasn't been ported over there). So the commands need to be put back in the plugin list in order to work next time the plugin is loaded.

spt/cvars.cpp Outdated
if (inittedCmd == cmd_to_feature.end())
{
DevWarning("Command %s was unloaded, because it was not initialized!\n", cmdName);
ConCommandBase* todelete = cmd;
cmd = (ConCommandBase*)cmd->GetNext();
RemoveCommandFromList(pluginCommandListHead, todelete);
RemoveCommandFromList(todelete);
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we go through our own list and register each ConCommand by hand, we could probably handle the local list differently, but we can leave that for a day with better moisture and wind speed conditions

spt/cvars.cpp Outdated
return;

ConCommandBase::s_pConCommandBases = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you care about mimicking what the engine does naturally, this should be moved to the end of of Cvar_RegisterSPTCvars. Atm we are kinda living with a somewhat bogus pointer in this variable through the lifetime of the plugin since it's never cleared

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reasoning for this is that in OE the plugin list contains (at least?) one concommand after the cvars have been loaded normally. This caused a crash upon reloading the plugin


extern "C" __declspec(dllexport) const void* CreateInterface(const char* pName, int* pReturnCode) {
if (pReturnCode) {
*pReturnCode = 2007;
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the sdk

if pReturnCode is set, it will return one of the following values (IFACE_OK, IFACE_FAILED)

Also, should we check for the INTERFACEVERSION_ISERVERPLUGINCALLBACKS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Checking for the version is not necessary. I also just set the return code to something funny since it isn't actually used.

@lipsanen lipsanen merged commit d4e0112 into YaLTeR:master Sep 23, 2024
8 checks 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.

4 participants