Update CS:GO team score gamedata.
2 * vim: set ts=4 sw=4 tw=99 noet :
3 * =============================================================================
5 * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
6 * =============================================================================
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.
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
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/>.
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>.
31 #include "NativeOwner.h"
33 #include "PluginSys.h"
35 CNativeOwner::CNativeOwner() : m_nMarkSerial(0)
39 void CNativeOwner::SetMarkSerial(unsigned int serial)
41 m_nMarkSerial = serial;
44 unsigned int CNativeOwner::GetMarkSerial()
49 void CNativeOwner::AddDependent(CPlugin *pPlugin)
51 m_Dependents.push_back(pPlugin);
54 void CNativeOwner::AddWeakRef(const WeakNative & ref)
56 m_WeakRefs.push_back(ref);
59 void CNativeOwner::AddNatives(const sp_nativeinfo_t *natives)
61 for (const sp_nativeinfo_t *native = natives; native->func && native->name; native++)
62 g_ShareSys.AddNativeToCache(this, native);
64 m_natives.append(natives);
67 void CNativeOwner::PropagateMarkSerial(unsigned int serial)
70 List<CPlugin *>::iterator iter;
72 for (iter = m_Dependents.begin();
73 iter != m_Dependents.end();
77 pOwner->SetMarkSerial(serial);
81 void CNativeOwner::UnbindWeakRef(const WeakNative &ref)
84 IPluginContext *pContext;
86 pContext = ref.pl->GetBaseContext();
87 if ((pContext->GetNativeByIndex(ref.idx, &native)) == SP_ERROR_NONE)
89 native->status = SP_NATIVE_UNBOUND;
94 void CNativeOwner::DropEverything()
96 List<WeakNative>::iterator iter;
98 /* Unbind and remove all weak references to us */
99 iter = m_WeakRefs.begin();
100 while (iter != m_WeakRefs.end())
102 UnbindWeakRef((*iter));
103 iter = m_WeakRefs.erase(iter);
106 /* Strip all of our natives from the cache */
107 for (size_t i = 0; i < m_natives.length(); i++) {
108 const sp_nativeinfo_t *natives = m_natives[i];
109 for (const sp_nativeinfo_t *native = natives; native->func && native->name; native++)
110 g_ShareSys.ClearNativeFromCache(this, native->name);
114 for (size_t i = 0; i < m_fakes.length(); i++)
115 g_ShareSys.ClearNativeFromCache(this, m_fakes[i]->name());
119 void CNativeOwner::DropWeakRefsTo(CPlugin *pPlugin)
121 List<WeakNative>::iterator iter;
123 iter = m_WeakRefs.begin();
124 while (iter != m_WeakRefs.end())
126 WeakNative & ref = (*iter);
128 if (ref.pl == pPlugin)
130 iter = m_WeakRefs.erase(iter);
139 void CNativeOwner::DropRefsTo(CPlugin *pPlugin)
141 m_Dependents.remove(pPlugin);
142 DropWeakRefsTo(pPlugin);