[Bug]API calling wrong functions on Linux, when compiled with gcc

Started by habi, Mar 27, 2022, 04:24 PM

Previous topic - Next topic

habi

I had this line
pluginCalls->OnPlayerConnect = OnPlayerConnect; in VcmpPluginInit.

But my OnPlayerConnect was not calling. I was also confused, since i had a problem with OnPlayerJoin
function onPlayerJoin(player)
{
if(player.IP=="127.0.0.1")
{
player.IsAdmin=true;
MessagePlayer("Admin status granted to 127.0.0.1 "+player.Name,player);
}
}
When i join, i saw two messages
QuoteAdmin status granted to 127.0.0.1
Admin status granted to 127.0.0.1
Finally, i came to the conclusion that the squirrel gamemode which i am using may also have OnPlayerConnect function and my plugin (which i am making) is calling squirrel's OnPlayerConnect instead of mine.
I was able to solve the problem by renaming my OnPlayerConnect to OnPlayerConnect2 and
pluginCalls->OnPlayerConnect = OnPlayerConnect2;

This happened in linux only.(i.e. i was making a .so plugin)

habi

#1
Does this have any solution.
Today, i was making a VCMP Server Plugin to send and receive plugin commands in sqgamemode.
But the plugin was not registering my function.
On examination i found that
void OnSquirrelScriptLoad() {
// See if we have any imports from Squirrel
size_t size;
int32_t sqId      = VCMP->FindPlugin(const_cast<char*>("SQHost2"));
const void ** sqExports = VCMP->GetPluginExports(sqId, &size);

// We do!
if (sqExports != NULL && size > 0) {
// Cast to a SquirrelImports structure
SquirrelImports ** sqDerefFuncs = (SquirrelImports **)sqExports;

// Now let's change that to a SquirrelImports pointer
....
this function in my main.cpp is not getting called.
I knew there is some problem with same function names when compiling for linux. So changed function name to
OnSquirrelScriptLoad2Then it works perfectly.
But if my guess is right if i make a third plugin and in that i should name the function as OnSquirrelScriptLoad3 and so on.
This is a serious problem. Any fix for this?