forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapgendata.cpp
165 lines (151 loc) · 4.55 KB
/
mapgendata.cpp
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
#include "mapgendata.h"
#include "debug.h"
#include "int_id.h"
#include "map.h"
#include "mapdata.h"
#include "omdata.h"
#include "overmapbuffer.h"
#include "point.h"
#include "regional_settings.h"
mapgendata::mapgendata( oter_id north, oter_id east, oter_id south, oter_id west,
oter_id northeast, oter_id southeast, oter_id southwest, oter_id northwest,
oter_id up, oter_id down, int z, const regional_settings &rsettings, map &mp,
const oter_id &terrain_type, const float density, const time_point &when,
::mission *const miss )
: terrain_type_( terrain_type ), density_( density ), when_( when ), mission_( miss ), zlevel_( z )
, t_nesw{ north, east, south, west, northeast, southeast, southwest, northwest }
, t_above( up )
, t_below( down )
, region( rsettings )
, m( mp )
, default_groundcover( region.default_groundcover )
{
}
mapgendata::mapgendata( const tripoint_abs_omt &over, map &m, const float density,
const time_point &when, ::mission *const miss )
: mapgendata( overmap_buffer.ter( over + tripoint_north ),
overmap_buffer.ter( over + tripoint_east ),
overmap_buffer.ter( over + tripoint_south ),
overmap_buffer.ter( over + tripoint_west ),
overmap_buffer.ter( over + tripoint_north_east ),
overmap_buffer.ter( over + tripoint_south_east ),
overmap_buffer.ter( over + tripoint_south_west ),
overmap_buffer.ter( over + tripoint_north_west ),
overmap_buffer.ter( over + tripoint_above ),
overmap_buffer.ter( over + tripoint_below ),
over.z(), overmap_buffer.get_settings( over ), m,
overmap_buffer.ter( over ), density, when, miss )
{
}
mapgendata::mapgendata( const mapgendata &other, const oter_id &other_id ) : mapgendata( other )
{
terrain_type_ = other_id;
}
void mapgendata::set_dir( int dir_in, int val )
{
switch( dir_in ) {
case 0:
n_fac = val;
break;
case 1:
e_fac = val;
break;
case 2:
s_fac = val;
break;
case 3:
w_fac = val;
break;
case 4:
ne_fac = val;
break;
case 5:
se_fac = val;
break;
case 6:
sw_fac = val;
break;
case 7:
nw_fac = val;
break;
default:
debugmsg( "Invalid direction for mapgendata::set_dir. dir_in = %d", dir_in );
break;
}
}
void mapgendata::fill( int val )
{
n_fac = val;
e_fac = val;
s_fac = val;
w_fac = val;
ne_fac = val;
se_fac = val;
sw_fac = val;
nw_fac = val;
}
int &mapgendata::dir( int dir_in )
{
switch( dir_in ) {
case 0:
return n_fac;
case 1:
return e_fac;
case 2:
return s_fac;
case 3:
return w_fac;
case 4:
return ne_fac;
case 5:
return se_fac;
case 6:
return sw_fac;
case 7:
return nw_fac;
default:
debugmsg( "Invalid direction for mapgendata::set_dir. dir_in = %d", dir_in );
//return something just so the compiler doesn't freak out. Not really correct, though.
return n_fac;
}
}
void mapgendata::square_groundcover( point p1, point p2 )
{
m.draw_square_ter( default_groundcover, p1, p2 );
}
void mapgendata::fill_groundcover()
{
m.draw_fill_background( default_groundcover );
}
bool mapgendata::is_groundcover( const ter_id &iid ) const
{
for( const auto &pr : default_groundcover ) {
if( pr.obj == iid ) {
return true;
}
}
return false;
}
ter_id mapgendata::groundcover()
{
const ter_id *tid = default_groundcover.pick();
return tid != nullptr ? *tid : t_null;
}
const oter_id &mapgendata::neighbor_at( om_direction::type dir ) const
{
// TODO: De-uglify, implement proper conversion somewhere
switch( dir ) {
case om_direction::type::north:
return north();
case om_direction::type::east:
return east();
case om_direction::type::south:
return south();
case om_direction::type::west:
return west();
default:
break;
}
debugmsg( "Tried to get neighbor from invalid direction %d", dir );
return north();
}