extensions/sdktools/vglobals.cpp
author Borja Ferrer <faluco@alliedmods.net>
Wed Aug 01 18:50:27 2007 +0000 (2007-08-01)
changeset 1247 26e4ba1e6cd2
parent 1245 bb0611ab4bed
child 1330 ab94316bb52b
permissions -rw-r--r--
added id properties for teame06
teame06@1245
     1
/**
teame06@1245
     2
 * vim: set ts=4 :
teame06@1245
     3
 * ================================================================
teame06@1245
     4
 * SourceMod SDKTools Extension
teame06@1245
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
teame06@1245
     6
 * ================================================================
teame06@1245
     7
 *
teame06@1245
     8
 * This program is free software; you can redistribute it and/or 
teame06@1245
     9
 * modify it under the terms of the GNU General Public License, 
teame06@1245
    10
 * version 3.0, as published by the Free Software Foundation.
teame06@1245
    11
 * 
teame06@1245
    12
 * This program is distributed in the hope that it will be useful,
teame06@1245
    13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
teame06@1245
    14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
teame06@1245
    15
 * GNU General Public License for more details.
teame06@1245
    16
 *
teame06@1245
    17
 * You should have received a copy of the GNU General Public License
teame06@1245
    18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
teame06@1245
    19
 *
teame06@1245
    20
 * As a special exception, AlliedModders LLC gives you permission to 
teame06@1245
    21
 * link the code of this program (as well as its derivative works) to 
teame06@1245
    22
 * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any 
teame06@1245
    23
 * Game MODs that run on software by the Valve Corporation.  You must 
teame06@1245
    24
 * obey the GNU General Public License in all respects for all other 
teame06@1245
    25
 * code used. Additionally, AlliedModders LLC grants this exception 
teame06@1245
    26
 * to all derivative works. AlliedModders LLC defines further 
teame06@1245
    27
 * exceptions, found in LICENSE.txt (as of this writing, version 
faluco@1247
    28
 * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
faluco@1247
    29
 *
faluco@1247
    30
 * Version: $Id$
faluco@1247
    31
 */
faluco@1247
    32
faluco@1247
    33
#include "extension.h"
faluco@1247
    34
faluco@1247
    35
void **g_pGameRules = NULL;
faluco@1247
    36
void *g_EntList = NULL;
faluco@1247
    37
faluco@1247
    38
#ifdef PLATFORM_WINDOWS
faluco@1247
    39
void InitializeValveGlobals()
faluco@1247
    40
{
faluco@1247
    41
	char *addr = NULL;
faluco@1247
    42
	int offset;
faluco@1247
    43
faluco@1247
    44
	/* g_pGameRules */
faluco@1247
    45
	if (!g_pGameConf->GetMemSig("CreateGameRulesObject", (void **)&addr) || !addr)
faluco@1247
    46
	{
faluco@1247
    47
		return;
faluco@1247
    48
	}
faluco@1247
    49
	if (!g_pGameConf->GetOffset("g_pGameRules", &offset) || !offset)
faluco@1247
    50
	{
faluco@1247
    51
		return;
faluco@1247
    52
	}
faluco@1247
    53
	g_pGameRules = *reinterpret_cast<void ***>(addr + offset);
faluco@1247
    54
faluco@1247
    55
	/* gEntList and/or g_pEntityList */
faluco@1247
    56
	if (!g_pGameConf->GetMemSig("LevelShutdown", (void **)&addr) || !addr)
faluco@1247
    57
	{
faluco@1247
    58
		return;
faluco@1247
    59
	}
faluco@1247
    60
	if (!g_pGameConf->GetOffset("gEntList", &offset) || !offset)
faluco@1247
    61
	{
faluco@1247
    62
		return;
faluco@1247
    63
	}
faluco@1247
    64
	g_EntList = *reinterpret_cast<void **>(addr + offset);
faluco@1247
    65
}
faluco@1247
    66
#elif defined PLATFORM_LINUX
faluco@1247
    67
void InitializeValveGlobals()
faluco@1247
    68
{
faluco@1247
    69
	char *addr = NULL;
faluco@1247
    70
faluco@1247
    71
	/* g_pGameRules */
faluco@1247
    72
	if (!g_pGameConf->GetMemSig("g_pGameRules", (void **)&addr) || !addr)
faluco@1247
    73
	{
faluco@1247
    74
		return;
faluco@1247
    75
	}
faluco@1247
    76
	g_pGameRules = reinterpret_cast<void **>(addr);
faluco@1247
    77
faluco@1247
    78
	/* gEntList and/or g_pEntityList */
faluco@1247
    79
	if (!g_pGameConf->GetMemSig("gEntList", (void **)&addr) || !addr)
faluco@1247
    80
	{
faluco@1247
    81
		return;
faluco@1247
    82
	}
faluco@1247
    83
	g_EntList = reinterpret_cast<void *>(addr);
faluco@1247
    84
}
faluco@1247
    85
#endif