-
Notifications
You must be signed in to change notification settings - Fork 498
Expand file tree
/
Copy pathfrozen.cpp
More file actions
91 lines (77 loc) · 2.39 KB
/
Copy pathfrozen.cpp
File metadata and controls
91 lines (77 loc) · 2.39 KB
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
#include "Console.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Maps.h"
#include "df/block_square_event_frozen_liquidst.h"
#include "df/map_block.h"
#include "df/world.h"
using std::vector;
using std::string;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
int changeLiquid (df::tile_liquid type)
{
int tiles = 0;
for (df::map_block *block : world->map.map_blocks)
{
for (df::block_square_event *evt : block->block_events)
{
if (evt->getType() != block_square_event_type::frozen_liquid)
continue;
df::block_square_event_frozen_liquidst *frozen = (df::block_square_event_frozen_liquidst *)evt;
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 16; y++)
{
if ((frozen->tiles[x][y] != tiletype::Void) && (frozen->liquid_type[x][y] != type))
{
frozen->liquid_type[x][y] = type;
tiles++;
}
}
}
}
}
return tiles;
}
command_result df_frozenlava (color_ostream &out, vector <string> & parameters)
{
if (parameters.size())
return CR_WRONG_USAGE;
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
int tiles = changeLiquid(tile_liquid::Magma);
if (tiles)
out.print("Changed {} tiles of ice into frozen lava.\n", tiles);
return CR_OK;
}
command_result df_frozenwater (color_ostream &out, vector <string> & parameters)
{
if (parameters.size())
return CR_WRONG_USAGE;
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
int tiles = changeLiquid(tile_liquid::Water);
if (tiles)
out.print("Changed {} tiles of ice into frozen water.\n", tiles);
return CR_OK;
}
DFHACK_PLUGIN("frozen");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("frozenlava", "Changes all ice into frozen magma.", df_frozenlava));
commands.push_back(PluginCommand("frozenwater", "Changes all ice into frozen water.", df_frozenwater));
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{
return CR_OK;
}