Update CS:GO team score gamedata.
2 * vim: set ts=4 sw=4 tw=99 noet:
3 * =============================================================================
5 * Copyright (C) 2004-2008 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>.
32 #define _WIN32_WINNT 0x0400
33 #include "WinThreads.h"
34 #include "ThreadWorker.h"
36 IThreadWorker *WinThreader::MakeWorker(IThreadWorkerCallbacks *hooks, bool threaded)
40 return new ThreadWorker(hooks, this, DEFAULT_THINK_TIME_MS);
42 return new BaseWorker(hooks);
46 void WinThreader::DestroyWorker(IThreadWorker *pWorker)
51 void WinThreader::ThreadSleep(unsigned int ms)
56 IMutex *WinThreader::MakeMutex()
58 return new CompatMutex();
61 IThreadHandle *WinThreader::MakeThread(IThread *pThread, ThreadFlags flags)
63 ThreadParams defparams;
65 defparams.flags = flags;
66 defparams.prio = ThreadPrio_Normal;
68 return MakeThread(pThread, &defparams);
71 void WinThreader::MakeThread(IThread *pThread)
73 ThreadParams defparams;
75 defparams.flags = Thread_AutoRelease;
76 defparams.prio = ThreadPrio_Normal;
78 MakeThread(pThread, &defparams);
81 void WinThreader::ThreadHandle::Run()
83 // Wait for an unpause if necessary.
85 ke::AutoLock lock(&suspend_);
86 if (m_state == Thread_Paused)
90 m_run->RunThread(this);
91 m_state = Thread_Done;
92 m_run->OnTerminate(this, false);
93 if (m_params.flags & Thread_AutoRelease)
97 void WinThreader::GetPriorityBounds(ThreadPriority &max, ThreadPriority &min)
99 max = ThreadPrio_Maximum;
100 min = ThreadPrio_Minimum;
103 ThreadParams g_defparams;
104 IThreadHandle *WinThreader::MakeThread(IThread *pThread, const ThreadParams *params)
107 params = &g_defparams;
109 ke::AutoPtr<ThreadHandle> pHandle(new ThreadHandle(this, pThread, params));
111 pHandle->m_thread = new ke::Thread(pHandle, "SourceMod");
112 if (!pHandle->m_thread->Succeeded())
115 if (pHandle->m_params.prio != ThreadPrio_Normal)
116 pHandle->SetPriority(pHandle->m_params.prio);
118 if (!(params->flags & Thread_CreateSuspended))
121 return pHandle.take();
124 IEventSignal *WinThreader::MakeEventSignal()
126 return new CompatCondVar();
133 WinThreader::ThreadHandle::ThreadHandle(IThreader *parent, IThread *run, const ThreadParams *params) :
134 m_parent(parent), m_run(run), m_params(*params),
135 m_state(Thread_Paused)
139 WinThreader::ThreadHandle::~ThreadHandle()
143 bool WinThreader::ThreadHandle::WaitForThread()
152 ThreadState WinThreader::ThreadHandle::GetState()
157 IThreadCreator *WinThreader::ThreadHandle::Parent()
162 void WinThreader::ThreadHandle::DestroyThis()
164 if (m_params.flags & Thread_AutoRelease)
170 void WinThreader::ThreadHandle::GetParams(ThreadParams *ptparams)
175 *ptparams = m_params;
178 ThreadPriority WinThreader::ThreadHandle::GetPriority()
180 return m_params.prio;
183 bool WinThreader::ThreadHandle::SetPriority(ThreadPriority prio)
187 if (prio >= ThreadPrio_Maximum)
188 res = SetThreadPriority(m_thread->handle(), THREAD_PRIORITY_HIGHEST);
189 else if (prio <= ThreadPrio_Minimum)
190 res = SetThreadPriority(m_thread->handle(), THREAD_PRIORITY_LOWEST);
191 else if (prio == ThreadPrio_Normal)
192 res = SetThreadPriority(m_thread->handle(), THREAD_PRIORITY_NORMAL);
193 else if (prio == ThreadPrio_High)
194 res = SetThreadPriority(m_thread->handle(), THREAD_PRIORITY_ABOVE_NORMAL);
195 else if (prio == ThreadPrio_Low)
196 res = SetThreadPriority(m_thread->handle(), THREAD_PRIORITY_BELOW_NORMAL);
198 m_params.prio = prio;
200 return (res != FALSE);
203 bool WinThreader::ThreadHandle::Unpause()
205 if (m_state != Thread_Paused)
208 ke::AutoLock lock(&suspend_);
209 m_state = Thread_Running;