forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspatterdump.cpp
More file actions
197 lines (186 loc) · 4.95 KB
/
Copy pathspatterdump.cpp
File metadata and controls
197 lines (186 loc) · 4.95 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Just show some position data
#include <iostream>
#include <iomanip>
#include <climits>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h>
using namespace DFHack;
//FIXME: A pile of magic numbers. looks like decompiled number
typedef uint32_t _DWORD;
int get_material_vector(uint32_t vein_8, uint16_t vein_4, int WORLD_)
{
int result; // eax@2
int v4; // ecx@11
int v5; // eax@12
if ( (uint16_t)(vein_4 - 0x1A3) > 0xC7u )
{
if ( ((int16_t)vein_4 < 19 || (int16_t)vein_4 > 0xDAu)
&& (uint16_t)(vein_4 - 219) > 0xC7u )
{
if ( vein_4 )
{
if ( vein_4 > 0x292u )
result = 0;
else
result = *(_DWORD *)(WORLD_ + 4 * (int16_t)vein_4 + 0x5DF44);
}
else
{
if ( (signed int)vein_8 >= 0
&& (v4 = *(_DWORD *)(WORLD_ + 0x54B88), vein_8 < (*(_DWORD *)(WORLD_ + 0x54B8C) - v4) >> 2)
&& (v5 = *(_DWORD *)(v4 + 4 * vein_8)) != 0 )
result = v5 + 0x178;
else
result = *(_DWORD *)(WORLD_ + 0x5DF44);
}
}
else
{
/*
result = sub_4D47A0(vein_8, vein_4, WORLD_ + 0x54C84);
if ( !result )
result = *(_DWORD *)(WORLD_ + 0x5DF90);
*/
}
}
else
{
/*
result = sub_41F430(WORLD_ + 0x54B94, vein_4);
if ( !result )
result = *(_DWORD *)(WORLD_ + 0x5E5D0);
*/
}
return result;
}
char shades[10] = {'#','$','O','=','+','|','-','^','.',' '};
void printSpatter(DFHack::Context * DF, t_spattervein & spatter)
{
DFHack::Materials *Mats = DF->getMaterials();
printf("Splatter\nmat1: %d\nunknown: %d\nmat2: %d\n",spatter.mat1,spatter.unk1,spatter.mat2);
printf ("Material : %d - ", spatter.matter_state);
// FIXME: stupid
switch(spatter.matter_state)
{
case state_gas:
printf("Gas ");
break;
case state_solid:
printf("Solid ");
break;
case state_liquid:
printf("Liquid ");
break;
case state_paste:
printf("Paste ");
break;
case state_powder:
printf("Powder ");
break;
case state_pressed:
printf("Pressed ");
break;
default:
printf("Unknown state ");
}
cout << PrintSplatterType(spatter.mat1,spatter.mat2,Mats->race) << endl;
printf("Address 0x%08x\n",spatter.address_of);
for(uint32_t yyy = 0; yyy < 16; yyy++)
{
cout << "|";
for(uint32_t xxx = 0; xxx < 16; xxx++)
{
uint8_t intensity = spatter.intensity[xxx][yyy];
cout << shades[9 - (intensity / 28)];
}
cout << "|" << endl;
}
hexdump(DF, spatter.address_of,20*16);
}
int main (int numargs, const char ** args)
{
uint32_t x_max,y_max,z_max;
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
vector<t_spattervein> splatter;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Maps *Maps =DF->getMaps();
DFHack::Gui *Gui =DF->getGui();
DFHack::Materials *Mats =DF->getMaterials();
Mats->ReadCreatureTypes();
// init the map
if(!Maps->Start())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Gui->getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
// walk the map
for(uint32_t x = 0; x< x_max;x++) for(uint32_t y = 0; y< y_max;y++) for(uint32_t z = 0; z< z_max;z++)
{
if(Maps->isValidBlock(x,y,z))
{
// look for splater veins
Maps->ReadVeins(x,y,z,0,0,&splatter);
if(splatter.size())
{
printf("Block %d/%d/%d\n",x,y,z);
for(uint32_t i = 0; i < splatter.size(); i++)
{
cout << i << ":" << endl;
printSpatter(DF,splatter[i]);
}
}
}
}
}
else
{
uint32_t bx,by,bz;
bx = cx / 16;
by = cy / 16;
bz = cz;
// look for splater veins
Maps->ReadVeins(bx,by,bz,0,0,&splatter);
if(splatter.size())
{
printf("Block %d/%d/%d\n",bx,by,bz);
for(uint32_t i = 0; i < splatter.size(); i++)
{
printSpatter(DF,splatter[i]);
cout << endl;
}
}
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}