2007-10-07 05:12:19 +02:00
|
|
|
/**
|
2009-11-14 01:25:56 +01:00
|
|
|
* vim: set ts=4 sw=4 tw=99 noet :
|
2007-10-07 05:12:19 +02:00
|
|
|
* ======================================================
|
|
|
|
* Metamod:Source Sample Plugin
|
|
|
|
* Written by AlliedModders LLC.
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
* In no event will the authors be held liable for any damages arising from
|
|
|
|
* the use of this software.
|
|
|
|
*
|
|
|
|
* This sample plugin is public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE_SOURCE_ENGINE_WRAPPERS_
|
|
|
|
#define _INCLUDE_SOURCE_ENGINE_WRAPPERS_
|
|
|
|
|
|
|
|
#include <eiface.h>
|
|
|
|
|
|
|
|
extern IVEngineServer *engine;
|
2008-11-24 19:03:02 +01:00
|
|
|
extern CGlobalVars *gpGlobals;
|
2007-10-07 05:12:19 +02:00
|
|
|
|
2009-02-18 08:38:23 +01:00
|
|
|
#if SOURCE_ENGINE == SE_EPISODEONE && defined METAMOD_PLAPI_VERSION
|
|
|
|
#error "Metamod:Source 1.6 API is not supported on the old engine."
|
|
|
|
#endif
|
2008-02-17 23:56:20 +01:00
|
|
|
|
2009-11-14 01:25:56 +01:00
|
|
|
#define ENGINE_CALL(func) SH_CALL(engine, &IVEngineServer::func)
|
|
|
|
|
2008-02-17 23:56:20 +01:00
|
|
|
/**
|
2009-11-14 01:25:56 +01:00
|
|
|
* Wrap some API calls for legacy MM:S.
|
2008-02-17 23:56:20 +01:00
|
|
|
*/
|
|
|
|
#if !defined METAMOD_PLAPI_VERSION
|
|
|
|
#define GetEngineFactory engineFactory
|
|
|
|
#define GetServerFactory serverFactory
|
|
|
|
#define MM_Format snprintf
|
2008-11-24 19:03:02 +01:00
|
|
|
#define GetCGlobals pGlobals
|
2008-02-17 23:56:20 +01:00
|
|
|
#else
|
2009-02-18 08:38:23 +01:00
|
|
|
#define MM_Format g_SMAPI->Format
|
2008-02-17 23:56:20 +01:00
|
|
|
#endif
|
|
|
|
|
2009-02-18 08:38:23 +01:00
|
|
|
#if SOURCE_ENGINE <= SE_DARKMESSIAH
|
2008-02-17 23:56:20 +01:00
|
|
|
/**
|
2009-02-18 08:38:23 +01:00
|
|
|
* Wrap the CCommand class so our code looks the same on all engines.
|
2008-02-17 23:56:20 +01:00
|
|
|
*/
|
2007-10-07 05:12:19 +02:00
|
|
|
class CCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const char *ArgS()
|
|
|
|
{
|
|
|
|
return engine->Cmd_Args();
|
|
|
|
}
|
|
|
|
int ArgC()
|
|
|
|
{
|
|
|
|
return engine->Cmd_Argc();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Arg(int index)
|
|
|
|
{
|
|
|
|
return engine->Cmd_Argv(index);
|
|
|
|
}
|
|
|
|
};
|
2008-02-17 23:56:20 +01:00
|
|
|
|
2009-02-18 08:38:23 +01:00
|
|
|
#define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION
|
2008-11-24 19:03:02 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Left 4 Dead engine removed these from IVEngineServer.
|
|
|
|
*/
|
|
|
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
|
|
|
|
|
|
|
inline int IndexOfEdict(const edict_t *pEdict)
|
|
|
|
{
|
2010-07-22 10:22:28 +02:00
|
|
|
return (int)(pEdict - gpGlobals->pEdicts);
|
2008-11-24 19:03:02 +01:00
|
|
|
}
|
|
|
|
inline edict_t *PEntityOfEntIndex(int iEntIndex)
|
|
|
|
{
|
|
|
|
if (iEntIndex >= 0 && iEntIndex < gpGlobals->maxEntities)
|
|
|
|
{
|
2010-07-22 10:22:28 +02:00
|
|
|
return (edict_t *)(gpGlobals->pEdicts + iEntIndex);
|
2008-11-24 19:03:02 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
inline int IndexOfEdict(const edict_t *pEdict)
|
|
|
|
{
|
|
|
|
return engine->IndexOfEdict(pEdict);
|
|
|
|
}
|
|
|
|
inline edict_t *PEntityOfEntIndex(int iEntIndex)
|
|
|
|
{
|
|
|
|
return engine->PEntityOfEntIndex(iEntIndex);
|
|
|
|
}
|
2008-02-17 23:56:20 +01:00
|
|
|
|
2007-10-07 05:12:19 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCE_ENGINE_WRAPPERS_
|
2008-02-18 00:40:37 +01:00
|
|
|
|