source: network-game/common/WorldMap.h@ 7f884ea

Last change on this file since 7f884ea was 7f884ea, checked in by dportnoy <dmp1488@…>, 11 years ago

Map-related structs are now outside of the WorldMap class

  • 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
11enum TerrainType {
12 TERRAIN_NONE,
13 TERRAIN_GRASS,
14 TERRAIN_OCEAN,
15 TERRAIN_ROCK
16};
17
18enum StructureType {
19 STRUCTURE_NONE,
20 STRUCTURE_BLUE_FLAG,
21 STRUCTURE_RED_FLAG
22};
23
24enum ObjectType {
25 OBJECT_NONE,
26 OBJECT_BLUE_FLAG,
27 OBJECT_RED_FLAG
28};
29
30class WorldMap {
31public:
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 void createObjectsFromStructures();
57
58 TerrainType getElement(int x, int y);
59 void setElement(int x, int y, TerrainType type);
60
61 StructureType getStructure(int x, int y);
62 void setStructure(int x, int y, StructureType type);
63 POSITION getStructureLocation(StructureType type);
64
65 vector<Object>* getObjects();
66 vector<Object> getObjects(int x, int y);
67
68 void addObject(ObjectType type, int x, int y);
69 void updateObject(unsigned int id, ObjectType t, int x, int y);
70 bool removeObject(unsigned int id);
71
72 static WorldMap* createDefaultMap();
73 static WorldMap* loadMapFromFile(string filename);
74};
75
76#endif
Note: See TracBrowser for help on using the repository browser.