wdmisc_plugin/dll_plugin.cpp
author Scott Ehlert <ds@alliedmods.net>
Thu Sep 26 15:56:37 2013 -0500 (2013-09-26)
changeset 280 622b9760d7ae
parent 0 d15304fcb7a7
permissions -rw-r--r--
Avoid linking to libstdc++ on Linux.
     1 // vi: set ts=4 sw=4 :
     2 // vim: set tw=75 :
     3 
     4 // dll_plugin.cpp - implementation of plugin's HL DLL routines
     5 
     6 /*
     7  * Copyright (c) 2001-2003 Will Day <[email protected]>
     8  *
     9  *    This file is part of Metamod.
    10  *
    11  *    Metamod is free software; you can redistribute it and/or modify it
    12  *    under the terms of the GNU General Public License as published by the
    13  *    Free Software Foundation; either version 2 of the License, or (at
    14  *    your option) any later version.
    15  *
    16  *    Metamod is distributed in the hope that it will be useful, but
    17  *    WITHOUT ANY WARRANTY; without even the implied warranty of
    18  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    19  *    General Public License for more details.
    20  *
    21  *    You should have received a copy of the GNU General Public License
    22  *    along with Metamod; if not, write to the Free Software Foundation,
    23  *    Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24  *
    25  *    In addition, as a special exception, the author gives permission to
    26  *    link the code of this program with the Half-Life Game Engine ("HL
    27  *    Engine") and Modified Game Libraries ("MODs") developed by Valve,
    28  *    L.L.C ("Valve").  You must obey the GNU General Public License in all
    29  *    respects for all of the code used other than the HL Engine and MODs
    30  *    from Valve.  If you modify this file, you may extend this exception
    31  *    to your version of the file, but you are not obligated to do so.  If
    32  *    you do not wish to do so, delete this exception statement from your
    33  *    version.
    34  *
    35  */
    36 
    37 #include <extdll.h>
    38 #include <sdk_util.h>
    39 
    40 #include <meta_api.h>
    41 #include <sdk_util.h>
    42 
    43 #include "wdmisc.h"
    44 #include "dll_plugin.h"
    45 #include "log_plugin.h"
    46 
    47 void wd_ServerDeactivate( void ) {
    48 	bounce_check();
    49 	RETURN_META(MRES_HANDLED);
    50 }
    51 
    52 static DLL_FUNCTIONS gFunctionTable = 
    53 {
    54 	NULL,						//! pfnGameInit()
    55 	NULL,						//! pfnSpawn()
    56 	NULL,						//! pfnThink()
    57 	NULL,						//! pfnUse()
    58 	NULL,						//! pfnTouch()
    59 	NULL,						//! pfnBlocked()
    60 	NULL,						//! pfnKeyValue()
    61 	NULL,						//! pfnSave()
    62 	NULL,						//! pfnRestore()
    63 	NULL,						//! pfnSetAbsBox()
    64 
    65 	NULL,						//! pfnSaveWriteFields()
    66 	NULL,						//! pfnSaveReadFields()
    67 
    68 	NULL,						//! pfnSaveGlobalState()
    69 	NULL,						//! pfnRestoreGlobalState()
    70 	NULL,						//! pfnResetGlobalState()
    71 
    72 	NULL,						//! pfnClientConnect()
    73 	NULL,						//! pfnClientDisconnect()
    74 	NULL,						//! pfnClientKill()
    75 	NULL,						//! pfnClientPutInServer()
    76 	NULL,						//! pfnClientCommand()
    77 	NULL,						//! pfnClientUserInfoChanged()
    78 	NULL,						//! pfnServerActivate()
    79 	wd_ServerDeactivate,		//! pfnServerDeactivate()
    80 
    81 	NULL,						//! pfnPlayerPreThink()
    82 	NULL,						//! pfnPlayerPostThink()
    83 
    84 	NULL,						//! pfnStartFrame()
    85 	NULL,						//! pfnParmsNewLevel()
    86 	NULL,						//! pfnParmsChangeLevel()
    87 
    88 	NULL,						//! pfnGetGameDescription()
    89 	NULL,						//! pfnPlayerCustomization()
    90 
    91 	NULL,						//! pfnSpectatorConnect()
    92 	NULL,						//! pfnSpectatorDisconnect()
    93 	NULL,						//! pfnSpectatorThink()
    94 	
    95 	NULL,						//! pfnSys_Error()
    96 
    97 	NULL,						//! pfnPM_Move()
    98 	NULL,						//! pfnPM_Init()
    99 	NULL,						//! pfnPM_FindTextureType()
   100 	
   101 	NULL,						//! pfnSetupVisibility()
   102 	NULL,						//! pfnUpdateClientData()
   103 	NULL,						//! pfnAddToFullPack()
   104 	NULL,						//! pfnCreateBaseline()
   105 	NULL,						//! pfnRegisterEncoders()
   106 	NULL,						//! pfnGetWeaponData()
   107 	NULL,						//! pfnCmdStart()
   108 	NULL,						//! pfnCmdEnd()
   109 	NULL,						//! pfnConnectionlessPacket()
   110 	NULL,						//! pfnGetHullBounds()
   111 	NULL,						//! pfnCreateInstancedBaselines()
   112 	NULL,						//! pfnInconsistentFile()
   113 	NULL,						//! pfnAllowLagCompensation()
   114 };
   115 
   116 C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, 
   117 		int *interfaceVersion)
   118 {
   119 	LOG_DEVELOPER(PLID, "called: GetEntityAPI2; version=%d", *interfaceVersion);
   120 	if(!pFunctionTable) {
   121 		LOG_ERROR(PLID, "GetEntityAPI2 called with null pFunctionTable");
   122 		return(FALSE);
   123 	}
   124 	else if(*interfaceVersion != INTERFACE_VERSION) {
   125 		LOG_ERROR(PLID, "GetEntityAPI2 version mismatch; requested=%d ours=%d",
   126 				*interfaceVersion, INTERFACE_VERSION);
   127 		//! Tell engine what version we had, so it can figure out who is 
   128 		//! out of date.
   129 		*interfaceVersion = INTERFACE_VERSION;
   130 		return(FALSE);
   131 	}
   132 	memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
   133 	return(TRUE);
   134 }