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

Last change on this file since e487381 was e487381, checked in by dportnoy <dmp1488@…>, 12 years ago

The server removes objects from its map when they are picked up by players and processes DROP_FLAG messages

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