source: network-game/common/WorldMap.h@ e70b66b

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

All server warnings have been fixed and the WorldMap class has a new method to create flags (and, in the future, other objects) based on structures present on the map

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