source: network-game/common/WorldMap.h@ 5b92307

Last change on this file since 5b92307 was 9ba9b96, checked in by dportnoy <dmp1488@…>, 11 years ago

All ids should now be unsigned ints

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#ifndef _WORLDMAP_H
2#define _WORLDMAP_H
3
4#include <string>
5#include <vector>
6
7#include "Common.h"
8
9using namespace std;
10
11class WorldMap {
12public:
13 enum TerrainType {
14 TERRAIN_NONE,
15 TERRAIN_GRASS,
16 TERRAIN_OCEAN,
17 TERRAIN_ROCK
18 };
19
20 enum StructureType {
21 STRUCTURE_NONE,
22 STRUCTURE_BLUE_FLAG,
23 STRUCTURE_RED_FLAG
24 };
25
26 enum ObjectType {
27 OBJECT_NONE,
28 OBJECT_BLUE_FLAG,
29 OBJECT_RED_FLAG
30 };
31
32 class Object {
33 public:
34 unsigned int id;
35 ObjectType type;
36 POSITION pos;
37
38 Object(unsigned int id, ObjectType type, int x, int y);
39 Object(unsigned int id, ObjectType type, POSITION pos);
40
41 ~Object();
42
43 void serialize(char* buffer);
44 void deserialize(char* buffer);
45 };
46
47 int width, height;
48 vector<vector<TerrainType>*>* vctMap;
49 vector<vector<StructureType>*>* vctStructures;
50 vector<Object>* vctObjects;
51
52 WorldMap(int width, int height);
53
54 ~WorldMap();
55
56 TerrainType getElement(int x, int y);
57 void setElement(int x, int y, TerrainType type);
58
59 StructureType getStructure(int x, int y);
60 void setStructure(int x, int y, StructureType type);
61 POSITION getStructureLocation(StructureType type);
62
63 vector<Object>* getObjects();
64 vector<Object> getObjects(int x, int y);
65
66 void addObject(ObjectType type, int x, int y);
67 void updateObject(unsigned int id, WorldMap::ObjectType t, int x, int y);
68 bool removeObject(unsigned int id);
69
70 static WorldMap* createDefaultMap();
71 static WorldMap* loadMapFromFile(string filename);
72};
73
74#endif
Note: See TracBrowser for help on using the repository browser.