extensions/sdktools/vglobals.cpp
author Scott Ehlert <ds@alliedmods.net>
Wed Aug 01 07:18:58 2007 +0000 (2007-08-01)
changeset 1240 79eebacc9d02
child 1245 bb0611ab4bed
permissions -rw-r--r--
Implemented amb584 - CGlobalEntityList support in SDKTools
Also added FindEntityByClassname native to start this off
ds@1240
     1
/**
ds@1240
     2
 * vim: set ts=4 :
ds@1240
     3
 * ===============================================================
ds@1240
     4
 * SourceMod SDK Tools Extension
ds@1240
     5
 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
ds@1240
     6
 * ===============================================================
ds@1240
     7
 *
ds@1240
     8
 * This program is free software; you can redistribute it and/or
ds@1240
     9
 * modify it under the terms of the GNU General Public License
ds@1240
    10
 * as published by the Free Software Foundation; either version 2
ds@1240
    11
 * of the License, or (at your option) any later version.
ds@1240
    12
 * This program is distributed in the hope that it will be useful,
ds@1240
    13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ds@1240
    14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ds@1240
    15
 * GNU General Public License for more details.
ds@1240
    16
 * 
ds@1240
    17
 * You should have received a copy of the GNU General Public License
ds@1240
    18
 * along with this program; if not, write to the Free Software
ds@1240
    19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
ds@1240
    20
 *
ds@1240
    21
 * Version: $Id$
ds@1240
    22
 */
ds@1240
    23
ds@1240
    24
#include "extension.h"
ds@1240
    25
ds@1240
    26
void **g_pGameRules = NULL;
ds@1240
    27
void *g_EntList = NULL;
ds@1240
    28
ds@1240
    29
#ifdef PLATFORM_WINDOWS
ds@1240
    30
void InitializeValveGlobals()
ds@1240
    31
{
ds@1240
    32
	char *addr = NULL;
ds@1240
    33
	int offset;
ds@1240
    34
ds@1240
    35
	/* g_pGameRules */
ds@1240
    36
	if (!g_pGameConf->GetMemSig("CreateGameRulesObject", (void **)&addr) || !addr)
ds@1240
    37
	{
ds@1240
    38
		return;
ds@1240
    39
	}
ds@1240
    40
	if (!g_pGameConf->GetOffset("g_pGameRules", &offset) || !offset)
ds@1240
    41
	{
ds@1240
    42
		return;
ds@1240
    43
	}
ds@1240
    44
	g_pGameRules = *reinterpret_cast<void ***>(addr + offset);
ds@1240
    45
ds@1240
    46
	/* gEntList and/or g_pEntityList */
ds@1240
    47
	if (!g_pGameConf->GetMemSig("LevelShutdown", (void **)&addr) || !addr)
ds@1240
    48
	{
ds@1240
    49
		return;
ds@1240
    50
	}
ds@1240
    51
	if (!g_pGameConf->GetOffset("gEntList", &offset) || !offset)
ds@1240
    52
	{
ds@1240
    53
		return;
ds@1240
    54
	}
ds@1240
    55
	g_EntList = *reinterpret_cast<void **>(addr + offset);
ds@1240
    56
}
ds@1240
    57
#elif defined PLATFORM_LINUX
ds@1240
    58
void InitializeValveGlobals()
ds@1240
    59
{
ds@1240
    60
	char *addr = NULL;
ds@1240
    61
ds@1240
    62
	/* g_pGameRules */
ds@1240
    63
	if (!g_pGameConf->GetMemSig("g_pGameRules", (void **)&addr) || !addr)
ds@1240
    64
	{
ds@1240
    65
		return;
ds@1240
    66
	}
ds@1240
    67
	g_pGameRules = reinterpret_cast<void **>(addr);
ds@1240
    68
ds@1240
    69
	/* gEntList and/or g_pEntityList */
ds@1240
    70
	if (!g_pGameConf->GetMemSig("gEntList", (void **)&addr) || !addr)
ds@1240
    71
	{
ds@1240
    72
		return;
ds@1240
    73
	}
ds@1240
    74
	g_EntList = reinterpret_cast<void *>(addr);
ds@1240
    75
}
ds@1240
    76
#endif