View Single Post
Re: Several problems with HL2DM
Old
  (#8)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Several problems with HL2DM - 27-01-2005

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
   }



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote