faluco@1552: /**
faluco@1552: * vim: set ts=4 :
faluco@1552: * =============================================================================
faluco@1552: * SourceMod Counter-Strike:Source Extension
ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
faluco@1552: * =============================================================================
faluco@1552: *
faluco@1552: * This program is free software; you can redistribute it and/or modify it under
faluco@1552: * the terms of the GNU General Public License, version 3.0, as published by the
faluco@1552: * Free Software Foundation.
faluco@1552: *
faluco@1552: * This program is distributed in the hope that it will be useful, but WITHOUT
faluco@1552: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
faluco@1552: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
faluco@1552: * details.
faluco@1552: *
faluco@1552: * You should have received a copy of the GNU General Public License along with
faluco@1552: * this program. If not, see .
faluco@1552: *
faluco@1552: * As a special exception, AlliedModders LLC gives you permission to link the
faluco@1552: * code of this program (as well as its derivative works) to "Half-Life 2," the
faluco@1552: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
faluco@1552: * by the Valve Corporation. You must obey the GNU General Public License in
faluco@1552: * all respects for all other code used. Additionally, AlliedModders LLC grants
faluco@1552: * this exception to all derivative works. AlliedModders LLC defines further
faluco@1552: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
faluco@1552: * or .
faluco@1552: *
faluco@1552: * Version: $Id$
faluco@1552: */
faluco@1552:
dvander@1459: #include "extension.h"
dvander@1459: #include "timeleft.h"
dvander@1459:
dvander@1459: TimeLeftEvents g_TimeLeftEvents;
dvander@1459: bool get_new_timeleft_offset = false;
dvander@1459: bool round_end_found = false;
dvander@1459:
dvander@1459: bool TimeLeftEvents::LevelInit(char const *pMapName,
dvander@1459: char const *pMapEntities,
dvander@1459: char const *pOldLevel,
dvander@1459: char const *pLandmarkName,
dvander@1459: bool loadGame,
dvander@1459: bool background)
dvander@1459: {
dvander@1459: round_end_found = true;
dvander@1459: get_new_timeleft_offset = false;
dvander@1459:
dvander@1459: return true;
dvander@1459: }
dvander@1459:
dvander@1459: void TimeLeftEvents::FireGameEvent(IGameEvent *event)
dvander@1459: {
dvander@1459: const char *name = event->GetName();
dvander@1459:
dvander@1459: if (strcmp(name, "round_start") == 0)
dvander@1459: {
dvander@1459: if (get_new_timeleft_offset || !round_end_found)
dvander@1459: {
dvander@1459: get_new_timeleft_offset = false;
dvander@1459: timersys->NotifyOfGameStart();
dvander@1459: timersys->MapTimeLeftChanged();
dvander@1459: }
dvander@1459: round_end_found = false;
dvander@1459: }
dvander@1459: else if (strcmp(name, "round_end") == 0)
dvander@1459: {
skamonkey@3113: if (event->GetInt("reason") == 15)
dvander@1459: {
dvander@1459: get_new_timeleft_offset = true;
dvander@1459: }
dvander@1459: round_end_found = true;
dvander@1459: }
dvander@1459: }