Hello everyone/anyone (first email?!)
Currently, if you hot-unload SourceMM plugins which have any type of
ConCommandBase (cvar, concmd), it will crash.
This is because the HL2 engine does not provide a way to unregister
cvars/concmds. Rather than provide a way, Valve has done some weird
things. For example, you can't actually unload server plugins from
memory (plugin_unload does not free them), because the HL2 engine is
still relying on their cvars.
However, Metamod:Source frees plugins properly so you can write over the
file and keep testing. This means, if you use "meta unload", the HL2
engine will keep trying to access your cvars/concmds and promptly crash.
The server might also crash on exit.
How do you prevent this? The next release of SourceMM will expand
support for cvars/concmds. Besides having two new commands ("meta cmds",
"meta cvars"), it will also provide new macros for properly registering
ConCommandBases.
Currently, your code might look like this:
Code:
bool MyAccessor::RegisterConCommandBase(ConCommandBase *pCommand)
{
pCommand->SetNext(0);
pICvar->RegisterConCommandBase(pCommand);
return true;
}
To prevent crashing, you should instead register your ConCommandBases
through SourceMM. SourceMM will then keep track of them and properly
unlink them from the HL2 engine when needed. To do this, use the handy
new macro:
Code:
bool MyAccessor::RegisterConCommandBase(ConCommandBase *pCommand)
{
META_REGCVAR(pCommand);
return true;
}
Want to see an example of this code, or test the code out before the
next release? You can build SourceMM from CVS, and sample_mm in CVS has
updated code demonstrating correct cvar/concmd usage.
---David "BAILOPAN" Anderson
http://www.sourcemod.net/
http://www.sourcemm.net/
|