core/logic/intercom.h
author Nicholas Hastings <skamonkey@gmail.com>
Wed May 25 13:31:14 2011 -0400 (2011-05-25)
changeset 3285 065beec73902
parent 3055 4c81256cac43
child 3320 f1ccb4a17a06
permissions -rw-r--r--
Backed out changeset: 65eb3df32b1c
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2009 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #include <sp_vm_api.h>
    33 #include <IHandleSys.h>
    34 #include <IShareSys.h>
    35 
    36 #ifndef _INCLUDE_SOURCEMOD_INTERCOM_H_
    37 #define _INCLUDE_SOURCEMOD_INTERCOM_H_
    38 
    39 using namespace SourceMod;
    40 
    41 /**
    42  * Add 1 to the RHS of this expression to bump the intercom file
    43  * This is to prevent mismatching core/logic binaries
    44  */
    45 #define SM_LOGIC_MAGIC		(0x0F47C0DE - 15)
    46 
    47 #if defined SM_LOGIC
    48 class IVEngineServer
    49 #else
    50 class IVEngineServer_Logic
    51 #endif
    52 {
    53 public:
    54 	virtual bool IsMapValid(const char *map) = 0;
    55 	virtual void ServerCommand(const char *cmd) = 0;
    56 };
    57 
    58 namespace SourceMod
    59 {
    60 	class ISourceMod;
    61 	class ILibrarySys;
    62 	class ITextParsers;
    63 	class IThreader;
    64 	class IRootConsole;
    65 	class IPluginManager;
    66 	class IForwardManager;
    67 	class ITimerSystem;
    68 	class IPlayerManager;
    69 	class IAdminSystem;
    70 	class IGameHelpers;
    71 	class IPhraseCollection;
    72 	class ITranslator;
    73 	class IGameConfig;
    74 }
    75 
    76 class IVEngineServer;
    77 class ConVar;
    78 
    79 struct ServerGlobals
    80 {
    81 	const double *universalTime;
    82 	float *interval_per_tick;
    83 	float *frametime;
    84 };
    85 
    86 struct sm_core_t
    87 {
    88 	/* Objects */
    89 	IHandleSys 		*handlesys;
    90 	IdentityToken_t *core_ident;
    91 	ISourceMod		*sm;
    92 	ILibrarySys		*libsys;
    93 	IVEngineServer	*engine;
    94 	IShareSys		*sharesys;
    95 	IRootConsole	*rootmenu;
    96 	IPluginManager	*pluginsys;
    97 	IForwardManager	*forwardsys;
    98 	ITimerSystem    *timersys;
    99 	IPlayerManager  *playerhelpers;
   100 	IAdminSystem	*adminsys;
   101 	IGameHelpers    *gamehelpers;
   102 	/* Functions */
   103 	void			(*AddNatives)(sp_nativeinfo_t* nlist);
   104 	ConVar *		(*FindConVar)(const char*);
   105 	unsigned int	(*strncopy)(char*, const char*, size_t);
   106 	char *			(*TrimWhitespace)(char *, size_t &);
   107 	void			(*LogError)(const char*, ...);
   108 	const char *	(*GetCvarString)(ConVar*);
   109 	size_t			(*Format)(char*, size_t, const char*, ...);
   110 	void			(*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
   111 	bool			(*gnprintf)(char *, size_t, const char *, IPhraseCollection *, void **,
   112 	                            unsigned int, unsigned int &, size_t *, const char **);
   113 	size_t			(*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *);
   114 	bool            (*GetGameName)(char *buffer, size_t maxlength);
   115 	const char *    (*GetGameDescription)();
   116 	const char *    (*GetSourceEngineName)();
   117 	bool            (*SymbolsAreHidden)();
   118 	/* Data */
   119 	ServerGlobals   *serverGlobals;
   120 	void *          serverFactory;
   121 	void *          engineFactory;
   122 };
   123 
   124 struct sm_logic_t
   125 {
   126 	SMGlobalClass	*head;
   127 	IThreader		*threader;
   128 	IProfiler		*profiler;
   129 	ITranslator		*translator;
   130 	const char      *(*stristr)(const char *, const char *);
   131 	bool			(*CoreTranslate)(char *,  size_t, const char *, unsigned int, size_t *, ...);
   132 	void            (*AddCorePhraseFile)(const char *filename);
   133 	unsigned int	(*ReplaceAll)(char*, size_t, const char *, const char *, bool);
   134 	char            *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool);
   135 	size_t          (*DecodeHexString)(unsigned char *, size_t, const char *);
   136 	IGameConfig *   (*GetCoreGameConfig)();
   137 };
   138 
   139 typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
   140 typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
   141 typedef ITextParsers *(*GetITextParsers)();
   142 
   143 #endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */
   144