mappatch.h

Go to the documentation of this file.
00001 
00007 /*
00008 Copyright (C) 2001 The Exult Team
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef INCL_MAPPATCH
00026 #define INCL_MAPPATCH 1
00027 
00028 #include <map>
00029 #include <list>
00030 #include "tiles.h"
00031 
00032 class Game_object;
00033 
00034 /*
00035  *  Specify an object by location, shape, etc.
00036  */
00037 class Object_spec
00038   {
00039 public:
00040   Tile_coord loc;     // Where it is.
00041   int shapenum;     // Shape #, or -359 for 'dont care'.
00042   int framenum;     // Frame #, or -359.
00043   int quality;      // Quality, or -359.
00044   Object_spec(Tile_coord t, int shnum = c_any_shapenum,
00045       int frnum = c_any_framenum, int qual = c_any_qual) 
00046     : loc(t), shapenum(shnum), framenum(frnum), quality(qual)
00047     {  }
00048   };
00049 
00050 /*
00051  *  Base class for map patches:
00052  */
00053 class Map_patch
00054   {
00055   Object_spec spec;   // Specifies object to modify.
00056 public:
00057   friend class Map_patch_collection;
00058   Map_patch(Object_spec s) : spec(s)
00059     {  }
00060   Game_object *find();    // Find matching object.
00061   virtual bool apply() = 0; // Perform action.
00062   };
00063 
00064 // Sigh, this is needed to prevent compiler error with MSVC
00065 typedef std::list<Map_patch*> Map_patch_list;
00066 typedef std::map<int, Map_patch_list> Map_patch_map;
00067 
00068 /*
00069  *  Remove an object.
00070  */
00071 class Map_patch_remove : public Map_patch
00072   {
00073   bool all;     // Delete all matching.
00074 public:
00075   Map_patch_remove(Object_spec s, bool a = false) : Map_patch(s)
00076     {  }
00077   virtual bool apply();   // Perform action.
00078   };
00079 
00080 /*
00081  *  Move/modify an object.
00082  */
00083 class Map_patch_modify : public Map_patch
00084   {
00085   Object_spec mod;    // Modification.
00086 public:
00087   Map_patch_modify(Object_spec s, Object_spec m) : Map_patch(s), mod(m)
00088     {  }
00089   virtual bool apply();   // Perform action.
00090   };
00091 
00092 /*
00093  *  Here's a collection of patches, organized by superchunk.
00094  */
00095 class Map_patch_collection
00096   {
00097   Map_patch_map patches;
00098 public:
00099   Map_patch_collection()
00100     {  }
00101   ~Map_patch_collection();
00102   void add(Map_patch *p);   // Add a patch.
00103   void apply(int schunk);   // Apply for given superchunk.
00104   };
00105 
00106 #endif

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