delobjs.h

Go to the documentation of this file.
00001 /*
00002  *  delobjs.h - Game objects that have been removed, but need deleting.
00003  *
00004  *  Copyright (C) 2000-2001  The Exult Team
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef DELOBJS_H
00022 #define DELOBJS_H 1
00023 
00024 #include <map>
00025 
00026 /*
00027  *  "Less than" relation for objects
00028  */
00029 class Less_objs
00030   {
00031 public:
00032      bool operator() (const Game_object *a, const Game_object *b) const
00033       {
00034       return a < b;
00035     }
00036   };
00037 
00038 #define DELOBJ_DELAY  (1000*60*3) /* 3 minutes. */
00039 
00040 /*
00041  *  A pool of removed game objects, waiting to be deleted, each with a
00042  *  timestamp.
00043  */
00044 class Deleted_objects : public std::map<Game_object *, unsigned int, Less_objs>
00045   {
00046 public:
00047   Deleted_objects() : std::map<Game_object *, unsigned int, Less_objs> ()
00048     {  }
00049   void insert(Game_object *obj)
00050     { (*this)[obj] = SDL_GetTicks() + DELOBJ_DELAY; }
00051 
00052   void flush();     // Delete them now.
00053   ~Deleted_objects()
00054 // Problems   { flush(); }
00055     {  }
00056   };
00057 
00058 #endif  /* DELOBJS_H */

Generated on Mon Jul 9 14:42:45 2007 for ExultEngine by  doxygen 1.5.1