From: Keith F. <ven...@us...> - 2002-06-30 11:33:51
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory usw-pr-cvs1:/tmp/cvs-serv31477 Added Files: gameevent.cpp gameevent.h Log Message: Added psGameEvent class from which all scheduled events must inherit. --- NEW FILE: gameevent.cpp --- /* * gameevent.cpp * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include <config.h> #include "util/gameevent.h" int psGameEvent::nextid; /// id counter sequence number psGameEvent::psGameEvent(int ticks) { triggerticks = ticks; id = ++nextid; } psGameEvent::~psGameEvent() { } --- NEW FILE: gameevent.h --- /* * gameevent.h * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef __GAMEEVENT_H__ #define __GAMEEVENT_H__ /** * All scheduled events must inherit from this class. These events are * queued by the EventManager and are passed to the various subscribed * handlers at the appropriate time. */ class psGameEvent { public: csTicks triggerticks; /// ticks value when event should be triggered. int id; /// id value combined with ticks ensures uniqueness for tree static int nextid; /// id counter sequence psGameEvent(int ticks); virtual ~psGameEvent(); virtual void Trigger()=0; // Abstract event processing function bool operator==(psGameEvent& other) { return (triggerticks==other.triggerticks && id==other.id); }; bool operator<(psGameEvent& other) { if (triggerticks<other.triggerticks) return true; if (triggerticks>other.triggerticks) return false; if (id<other.id) return true; return false; }; }; #endif |