File: mappatch.h

package info (click to toggle)
exult 1.2-4
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 9,040 kB
  • ctags: 10,543
  • sloc: cpp: 99,373; sh: 8,333; ansic: 4,659; makefile: 988; yacc: 769; lex: 313; xml: 19
file content (106 lines) | stat: -rw-r--r-- 2,582 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
 **	Mappatch.h - Patches to the game map.
 **
 **	Written: 10-18-2001
 **/

/*
Copyright (C) 2001 The Exult Team

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; either version 2
of the License, or (at your option) any later version.

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 INCL_MAPPATCH
#define INCL_MAPPATCH	1

#include <map>
#include <list>
#include "tiles.h"

class Game_object;

/*
 *	Specify an object by location, shape, etc.
 */
class Object_spec
	{
public:
	Tile_coord loc;			// Where it is.
	int shapenum;			// Shape #, or -359 for 'dont care'.
	int framenum;			// Frame #, or -359.
	int quality;			// Quality, or -359.
	Object_spec(Tile_coord t, int shnum = c_any_shapenum,
			int frnum = c_any_framenum, int qual = c_any_qual) 
		: loc(t), shapenum(shnum), framenum(frnum), quality(qual)
		{  }
	};

/*
 *	Base class for map patches:
 */
class Map_patch
	{
	Object_spec spec;		// Specifies object to modify.
public:
	friend class Map_patch_collection;
	Map_patch(Object_spec s) : spec(s)
		{  }
	Game_object *find();		// Find matching object.
	virtual bool apply() = 0;	// Perform action.
	};

// Sigh, this is needed to prevent compiler error with MSVC
typedef std::list<Map_patch*> Map_patch_list;
typedef std::map<int, Map_patch_list> Map_patch_map;

/*
 *	Remove an object.
 */
class Map_patch_remove : public Map_patch
	{
	bool all;			// Delete all matching.
public:
	Map_patch_remove(Object_spec s, bool a = false) : Map_patch(s)
		{  }
	virtual bool apply();		// Perform action.
	};

/*
 *	Move/modify an object.
 */
class Map_patch_modify : public Map_patch
	{
	Object_spec mod;		// Modification.
public:
	Map_patch_modify(Object_spec s, Object_spec m) : Map_patch(s), mod(m)
		{  }
	virtual bool apply();		// Perform action.
	};

/*
 *	Here's a collection of patches, organized by superchunk.
 */
class Map_patch_collection
	{
	Map_patch_map patches;
public:
	Map_patch_collection()
		{  }
	~Map_patch_collection();
	void add(Map_patch *p);		// Add a patch.
	void apply(int schunk);		// Apply for given superchunk.
	};

#endif