.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   Several problems with HL2DM (http://forums.bots-united.com/showthread.php?t=3481)

Pierre-Marie Baty 26-01-2005 02:44

Several problems with HL2DM
 
I have several problems when trying to make my plugins work in HL2DM.

1. Returning "false" in the plugin's Load() virtual method, which would normally tell Source to skip this plugin and not attempt to load it, makes the server crash.

2. I am unable to load the IPlayerInfoManager and IBotManager interfaces through gameServerFactory (which noteworthy, are not interfaces from the engine but from the game DLL, hence the need to load them from gameServerFactory() and not interfaceFactory()). The same code works fine in CS:Source, where I can load all the interfaces I want.

Here's my Load() function:
Code:

virtual bool Load (CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
{
        // get the interfaces we want to use
        if (!(playerinfomanager = (IPlayerInfoManager *) gameServerFactory (INTERFACEVERSION_PLAYERINFOMANAGER,NULL))
                || !(gameclients = (IServerGameClients *) gameServerFactory (INTERFACEVERSION_SERVERGAMECLIENTS, NULL))
                || !(debugoverlay = (IVDebugOverlay *) interfaceFactory (VDEBUG_OVERLAY_INTERFACE_VERSION, NULL))
                || !(engine = (IVEngineServer *) interfaceFactory (INTERFACEVERSION_VENGINESERVER, NULL))
                || !(gameeventmanager = (IGameEventManager *) interfaceFactory (INTERFACEVERSION_GAMEEVENTSMANAGER,NULL))
                || !(filesystem = (IFileSystem *) interfaceFactory (FILESYSTEM_INTERFACE_VERSION, NULL))
                || !(helpers = (IServerPluginHelpers *) interfaceFactory (INTERFACEVERSION_ISERVERPLUGINHELPERS, NULL))
                || !(enginetrace = (IEngineTrace *) interfaceFactory (INTERFACEVERSION_ENGINETRACE_SERVER,NULL))
                || !(serverconsole = (ICvar *) interfaceFactory (VENGINE_CVAR_INTERFACE_VERSION, NULL)))
                return (false); // we require all these interface to function
 
        gpGlobals = playerinfomanager->GetGlobalVars (); // get a pointer to the engine's globalvars
        ConCommandBaseMgr::OneTimeInit (&g_ConVarAccessor); // register any cvars and server commands
        return (true); // return true so as to enable the engine to load this plugin
}

I precise that I don't try to get gpGlobals when I don't load playerinfomanager, so the crash does not come from here.

Is it me or is it that HL2DM is buggy ?

stefanhendriks 26-01-2005 08:51

Re: Several problems with HL2DM
 
lol, well thats odd. The only thing that first did not work was createfakeclient, and now somehow the interfaces do not work. I think you should contact Alfred about this..

stefanhendriks 26-01-2005 08:54

Re: Several problems with HL2DM
 
from the hlcoders list this mail gives you an answer:

Quote:

From what I've seen, it seems IPlayerInfoManager on HL2DM is still at version 001 while IPlayerInfoManager on CS:S is at version 002.

While all Valve needs to do is recompile, the fact that the version number and interface name are in one string make it very difficult for good backward compatibility. Assuming they were separated, and Valve simply added new functions to the end of the vtable, it wouldn't be a problem. But that's not going to happen.

What's the solution to this? Are we going to have to do ugly hacks to check the name's last three digits from X to 001 until we get a valid interface pointer? Other than that, I see nasty compatibility problems in the future.

Thanks for any help,

-----David "BAILOPAN" Anderson

http://www.sourcemod.net/

Pierre-Marie Baty 26-01-2005 21:30

Re: Several problems with HL2DM
 
Haha! I suspected something like that. Gotta toy with the version numbers a bit.

I should sign up for this mailing list someday.

Pierre-Marie Baty 26-01-2005 23:00

Re: Several problems with HL2DM
 
w00t! IPlayerInfoManager interface loaded in HL2DM. Now on the IBotManager one...

Stefan, it's totally normal that creating a fake client wouldn't work, since this function is a member of IBotManager, and the interface has not been attached! The problem is not that calling botmanager->CreateBot crashes, but that botmanager is NULL ;)

*edit* found the interface version strings all in hl2mp/bin/server.dll if you hexedit it. Bailopan was right, there's a version mismatch between HL2MP and CS:Source for the IPlayerInfoManager interface. On the IBotManager one though, it's more complicated as its version is already 001 in the SDK and I find no occurence of it in the server DLL. It looks like the IBotManager interface is unknown in HL2DM!!! o_O it means HL2DM doesn't support bots, simply.

*edit 2* OK, IPlayerInfoManager interface correctly loaded as version "PlayerInfoManager001" but still unusable. Calling playerinfomanager->GetGlobalVars () leads to a memory access crash. I suspect they added GetGlobalVars to the interface just for this version 002, which means it's inexistent so far in the current server DLL. Dat sux0rz teh big 0n3.

Iced_Eagle 27-01-2005 00:47

Re: Several problems with HL2DM
 
Well there is an update tonight on the SDK... let's hope they fix that!! :)

Pierre-Marie Baty 27-01-2005 00:58

Re: Several problems with HL2DM
 
where did you see that ? the steam news don't mention it...

Pierre-Marie Baty 27-01-2005 01:04

Re: Several problems with HL2DM
 
In the meantime, here's a helpful macro for you guys
Code:

// plugin interface loader
#define LOAD_SINGLE_INTERFACE(type,name,version,provider,halt_on_error) \
  name = (type *) provider (version, NULL); \
  if (name == NULL) \
  { \
          Warning (PLUGIN_NAME " - unable to load version #" version " of the " #type " interface as \"" #name "\"!\n"); \
          if (halt_on_error) return (false); \
  } \
  else if (interface_verbose) Msg (PLUGIN_NAME " - " #type " interface loaded at 0x%x as \"" #name "\"\n", name);

use it like that:
Code:

  virtual bool Load (CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
  {
          bool interface_verbose = true;
 
          // get the interfaces we want from the engine
          LOAD_SINGLE_INTERFACE (IVEngineServer, engine, INTERFACEVERSION_VENGINESERVER, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (ISpatialPartition, spatialpartition, INTERFACEVERSION_SPATIALPARTITION, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IVDebugOverlay, debugoverlay, VDEBUG_OVERLAY_INTERFACE_VERSION, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IGameEventManager, gameeventmanager, INTERFACEVERSION_GAMEEVENTSMANAGER, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IBaseFileSystem, basefilesystem, BASEFILESYSTEM_INTERFACE_VERSION, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IFileSystem, filesystem, FILESYSTEM_INTERFACE_VERSION, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IServerPluginHelpers, helpers, INTERFACEVERSION_ISERVERPLUGINHELPERS, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IEngineTrace, enginetrace, INTERFACEVERSION_ENGINETRACE_SERVER, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IVModelInfo, modelinfo, VMODELINFO_SERVER_INTERFACE_VERSION, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (ICvar, serverconsole, VENGINE_CVAR_INTERFACE_VERSION, interfaceFactory, false);
          LOAD_SINGLE_INTERFACE (IUniformRandomStream, randomstream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION, interfaceFactory, false);
 
          // get the interfaces we want from the game DLL
          LOAD_SINGLE_INTERFACE (IServerGameDLL, gamedll, INTERFACEVERSION_SERVERGAMEDLL, gameServerFactory, false);
          LOAD_SINGLE_INTERFACE (IServerGameEnts, gameents, INTERFACEVERSION_SERVERGAMEENTS, gameServerFactory, false);
          LOAD_SINGLE_INTERFACE (IServerGameClients, gameclients, INTERFACEVERSION_SERVERGAMECLIENTS, gameServerFactory, false);
          LOAD_SINGLE_INTERFACE (IPluginHelpersCheck, helperscheck, INTERFACEVERSION_PLUGINHELPERSCHECK, gameServerFactory, false);
          LOAD_SINGLE_INTERFACE (IEffects, effects, IEFFECTS_INTERFACE_VERSION, gameServerFactory, false);
          LOAD_SINGLE_INTERFACE (IPlayerInfoManager, playerinfomanager, INTERFACEVERSION_PLAYERINFOMANAGER, gameServerFactory, false);
          LOAD_SINGLE_INTERFACE (IBotManager, botmanager, INTERFACEVERSION_PLAYERBOTMANAGER, gameServerFactory, false);
 
          gpGlobals = playerinfomanager->GetGlobalVars (); // get a pointer to the engine's globalvars
          ConCommandBaseMgr::OneTimeInit (&g_ConVarAccessor); // register any cvars and server commands
 
          return (true); // return true so as to enable the engine to load this plugin
  }



All times are GMT +2. The time now is 16:29.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.