File: MapTiles.pas

package info (click to toggle)
cevomapgen 39.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 476 kB
  • sloc: pascal: 2,766; xml: 181; makefile: 50
file content (170 lines) | stat: -rw-r--r-- 3,819 bytes parent folder | download | duplicates (2)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
unit MapTiles;

{***********************************************************

Project:    C-evo External Map Generator
Copyright:  1999-2023 P Blackman
License:    GPLv3+

Subroutines for Map Tiles that don't need to be in CevoMap.pas

***********************************************************}


interface

const
    lxMax = 126;
    lyMax = 132; // must be a mutiple of 4

type
    tTerrain =
        // Jungle is not used in map files
        // The game itself switches forest near the equator to jungle
        (Ocean, Coast, Grass, Desert, Prairie, Tundra, Arctic, Glacier = Arctic, Swamp,
        Jungle, Forest, Hills, Mountain);

    // Respresentation of one tile in the map, 4 bytes
    tTile =
    packed record
        Terrain,
        Improve,
        StartPos,
        Special:  Byte;
    end;


function Lowlands(R, T: Integer): tterrain;
function Steppe(R, T: Integer): tterrain;
function Highlands(R, T: Integer): tterrain;
function TerrainChar(T: tTerrain): Char;

implementation


function Lowlands(R, T: Integer): tterrain;
begin
    result := Grass;
    case R of
    0:
        case T of
            0: Result := Glacier;
            1: Result := Tundra;
            2: Result := Prairie;
            3: Result := Desert;
        end;
    1:
        case T of
            0: Result := Glacier;
            1: Result := Tundra;
            2: Result := Grass;
            3: Result := Desert;
        end;
    2:
        case T of
            0: Result := Swamp;
            1: Result := Grass;
            2: Result := Grass;
            3: Result := Forest;
        end;
    3:
        case T of
            0: Result := Swamp;
            1: Result := Swamp;
            2: Result := Forest;
            3: Result := Forest;
        end;
    end;
end;

function Steppe(R, T: Integer): tterrain;
begin
    result := Prairie;
    case R of
    0:
        case T of
            0: Result := Tundra;
            1: Result := Tundra;
            2: Result := Prairie;
            3: Result := Desert;
        end;
    1:
        case T of
            0: Result := Tundra;
            1: Result := Prairie;
            2: Result := Forest;
            3: Result := Desert;
        end;
    2:
        case T of
            0: Result := Glacier;
            1: Result := Forest;
            2: Result := Grass;
            3: Result := Prairie;
        end;
    3:
        case T of
            0: Result := Glacier;
            1: Result := Grass;
            2: Result := Forest;
            3: Result := Forest;
        end;
    end;
end;

function Highlands(R, T: Integer): tterrain;
begin
    result := Hills;
    case R of
    0:
        case T of
            0: Result := Tundra;
            1: Result := Hills;
            2: Result := Hills;
            3: Result := Desert;
        end;
    1:
        case T of
            0: Result := Tundra;
            1: Result := Hills;
            2: Result := Hills;
            3: Result := Prairie;
        end;
    2:
        case T of
            0: Result := Glacier;
            1: Result := Hills;
            2: Result := Hills;
            3: Result := Hills;
        end;
    3:
        case T of
            0: Result := Glacier;
            1: Result := Forest;
            2: Result := Hills;
            3: Result := Hills;
        end
    end;
end;


function TerrainChar(T: tTerrain): Char;
begin
    case T of
        Ocean: Result    := 'O';
        Coast: Result    := 'C';
        Grass: Result    := 'G';
        Desert: Result   := 'D';
        Prairie: Result  := 'R';
        Tundra: Result   := 'T';
        Arctic: Result   := 'A';
        Swamp: Result    := 'S';
        Forest: Result   := 'F';
        Hills: Result    := 'H';
        Mountain: Result := 'M';
    otherwise
        Result := '?';
    end;
end;

end.