| 1 |
// Copyright © 2001-2003 Rob Kaper <[email protected]>, |
| 2 |
// 2001 Erik Bourget <[email protected]> |
| 3 |
// 2010-2015 Sylvain Rochet <[email protected]> |
| 4 |
// |
| 5 |
// This program is free software; you can redistribute it and/or |
| 6 |
// modify it under the terms of the GNU General Public License |
| 7 |
// version 2 as published by the Free Software Foundation. |
| 8 |
// |
| 9 |
// This program is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
// General Public License for more details. |
| 13 |
// |
| 14 |
// You should have received a copy of the GNU General Public License |
| 15 |
// along with this program; see the file COPYING. If not, see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
#include "config.h" |
| 19 |
|
| 20 |
#include <stdlib.h> |
| 21 |
#include <sys/time.h> |
| 22 |
|
| 23 |
#include "event.h" |
| 24 |
|
| 25 |
Event::Event(int id, EventType type, Game *game) : GameObject(id, GameObject::Unknown, game) |
| 26 |
{ |
| 27 |
m_type = type; |
| 28 |
m_launchTime.tv_sec = 0; |
| 29 |
m_launchTime.tv_usec = 0; |
| 30 |
m_frequency = 0; |
| 31 |
m_object = NULL; |
| 32 |
} |
| 33 |
|
| 34 |
void Event::setLaunchTime(int ms) { |
| 35 |
struct timeval timenow, timeout; |
| 36 |
|
| 37 |
/* ISO C++ does not allow C99 designated initializers */ |
| 38 |
timeout.tv_sec = ms/1000; |
| 39 |
timeout.tv_usec = (ms%1000)*1000; |
| 40 |
|
| 41 |
gettimeofday(&timenow, NULL); |
| 42 |
timeradd(&timenow, &timeout, &m_launchTime); |
| 43 |
} |