wdmisc_plugin/engine_api.cpp
author bailopan
Tue Jul 12 22:43:16 2005 +0000 (2005-07-12)
branchB-work
changeset 132 eab0aebcdbf2
parent 0 d15304fcb7a7
permissions -rw-r--r--
Updated documentation
     1 // vi: set ts=4 sw=4 :
     2 // vim: set tw=75 :
     3 
     4 // engine_api.cpp - implementation of Half-Life engine functions
     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 <stdio.h>
    38 #include <stdarg.h>
    39 
    40 #include <extdll.h>
    41 
    42 #include "engine_api.h"
    43 #include "meta_api.h"
    44 #include "log_plugin.h"
    45 
    46 enginefuncs_t meta_engfuncs;
    47 
    48 C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, 
    49 		int *interfaceVersion) 
    50 {
    51 	LOG_DEVELOPER(PLID, "called: GetEngineFunctions; version=%d", 
    52 			*interfaceVersion);
    53 	if(!pengfuncsFromEngine) {
    54 		LOG_ERROR(PLID, 
    55 				"GetEngineFunctions called with null pengfuncsFromEngine");
    56 		return(FALSE);
    57 	}
    58 	else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) {
    59 		LOG_ERROR(PLID, 
    60 				"GetEngineFunctions version mismatch; requested=%d ours=%d", 
    61 				*interfaceVersion, ENGINE_INTERFACE_VERSION);
    62 		// Tell metamod what version we had, so it can figure out who is 
    63 		// out of date.
    64 		*interfaceVersion = ENGINE_INTERFACE_VERSION;
    65 		return(FALSE);
    66 	}
    67 	memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t));
    68 	return TRUE;
    69 }