File: map.h

package info (click to toggle)
glest 3.2.2-2
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze
  • size: 2,800 kB
  • ctags: 6,581
  • sloc: cpp: 32,575; sh: 8,341; makefile: 63
file content (117 lines) | stat: -rw-r--r-- 2,911 bytes parent folder | download
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
107
108
109
110
111
112
113
114
115
116
117
#ifndef _GLEST_MAPEDITOR_MAP_H_
#define _GLEST_MAPEDITOR_MAP_H_

#include "util.h"
#include "types.h"
#include "random.h"

using Shared::Platform::int8;
using Shared::Platform::int32;
using Shared::Platform::float32;
using Shared::Util::Random;

struct MapFileHeader{
	int32 version;
	int32 maxPlayers;
	int32 width;
	int32 height;
	int32 altFactor;
	int32 waterLevel;
	int8 title[128];
	int8 author[128];
	int8 description[256];
};

namespace Glest{ namespace MapEditor{

// ===============================================
//	class Map
// ===============================================

class Map{
public:
	static const int maxHeight= 20;
	static const int minHeight= 0;

private:
    struct Cell{
        int surface;
        int object;
        int resource;
        float height;
    };
    
    struct StartLocation{
        int x;
        int y;
    }; 

	Random random;
    string title;
    string author;
    string desc;
    string recScn;
    int type;
    int h;
	int w;
    int altFactor;
    int waterLevel;
    Cell **cells;
    int maxPlayers;
    StartLocation *startLocations;
	int refAlt;

public:
    Map();
    ~Map();      
    float getHeight(int x, int y) const;
    int getSurface(int x, int y) const;
    int getObject(int x, int y) const;
    int getResource(int x, int y) const;
    int getStartLocationX(int index) const;
    int getStartLocationY(int index) const;
    int getHeightFactor() const;
    int getWaterLevel() const;
    bool inside(int x, int y);

	void setRefAlt(int x, int y); 
	void setAdvanced(int altFactor, int waterLevel);
    void setTitle(const string &title);
    void setDesc(const string &desc);
    void setAuthor(const string &author);
	
	int getH() const			{return h;}
	int getW() const			{return w;}
	int getMaxPlayers() const	{return maxPlayers;}
	string getTitle() const		{return title;}
	string getDesc() const		{return desc;}
	string getAuthor() const	{return author;}

    void changeHeight(int x, int y, int height, int radius);
	void changeSurface(int x, int y, int surface, int radius);
    void changeObject(int x, int y, int object, int radius);
    void changeResource(int x, int y, int resource, int radius);
    void changeStartLocation(int x, int y, int player);
    
	void flipX();
	void flipY();
	void reset(int w, int h, float alt, int surf);
    void resize(int w, int h, float alt, int surf);
    void resetPlayers(int maxPlayers);
	void randomizeHeights();
	void randomize();
	void switchSurfaces(int surf1, int surf2);

    void loadFromFile(const string &path);
    void saveToFile(const string &path);

public:
	void resetHeights(int height);
	void sinRandomize(int strenght);
	void decalRandomize(int strenght);
	void applyNewHeight(float newHeight, int x, int y, int strenght);
};

}}// end namespace

#endif