2010-02-17 09:49:19 -07:00
|
|
|
#include <integers.h>
|
|
|
|
#include <string.h> // for memset
|
|
|
|
#include <string>
|
2010-02-19 17:12:55 -07:00
|
|
|
#include <fstream>
|
2010-02-17 09:49:19 -07:00
|
|
|
#include <iostream>
|
2010-02-19 17:12:55 -07:00
|
|
|
#include <iomanip>
|
2010-02-17 09:49:19 -07:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
#include <sstream>
|
|
|
|
#include "fake-curses.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <locale.h>
|
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <DFTileTypes.h>
|
|
|
|
#include <DFHackAPI.h>
|
|
|
|
#include <DFProcess.h>
|
2010-02-20 08:33:30 -07:00
|
|
|
#include <DFMemInfo.h>
|
2010-04-04 16:48:19 -06:00
|
|
|
#include <modules/Maps.h>
|
|
|
|
#include <modules/Materials.h>
|
2010-02-17 09:49:19 -07:00
|
|
|
using namespace DFHack;
|
2010-04-04 16:48:19 -06:00
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
|
|
|
|
string error;
|
2010-02-18 18:48:03 -07:00
|
|
|
API * pDF = 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
|
2010-03-20 10:30:13 -06:00
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
static void finish(int sig);
|
|
|
|
|
|
|
|
int gotoxy(int x, int y)
|
|
|
|
{
|
|
|
|
wmove(stdscr, y , x );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int putch(int x, int y, int znak, int color)
|
|
|
|
{
|
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddch(stdscr, y, x, znak);
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
}
|
2010-03-20 10:30:13 -06:00
|
|
|
int putwch(int x, int y, int znak, int color)
|
|
|
|
{
|
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddch(stdscr, y, x, znak);
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
}
|
2010-02-17 09:49:19 -07:00
|
|
|
/*
|
|
|
|
enum TileClass
|
|
|
|
{
|
|
|
|
EMPTY,
|
|
|
|
|
|
|
|
WALL,
|
|
|
|
PILLAR,
|
|
|
|
FORTIFICATION,
|
|
|
|
|
|
|
|
STAIR_UP,
|
|
|
|
STAIR_DOWN,
|
|
|
|
STAIR_UPDOWN,
|
|
|
|
|
|
|
|
RAMP,
|
|
|
|
|
|
|
|
FLOOR,
|
|
|
|
TREE_DEAD,
|
|
|
|
TREE_OK,
|
|
|
|
SAPLING_DEAD,
|
|
|
|
SAPLING_OK,
|
|
|
|
SHRUB_DEAD,
|
|
|
|
SHRUB_OK,
|
|
|
|
BOULDER,
|
|
|
|
PEBBLES
|
|
|
|
};*/
|
|
|
|
|
|
|
|
int puttile(int x, int y, int tiletype, int color)
|
|
|
|
{
|
|
|
|
unsigned int znak;
|
|
|
|
switch(tileTypeTable[tiletype].c)
|
|
|
|
{
|
|
|
|
case EMPTY:
|
|
|
|
znak = ' ';
|
|
|
|
break;
|
2010-03-25 21:04:11 -06:00
|
|
|
case PILLAR:
|
2010-02-17 09:49:19 -07:00
|
|
|
case WALL:
|
2010-03-20 10:30:13 -06:00
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddwstr(stdscr, y, x, L"\u2593");
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
//znak = ;
|
|
|
|
return 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
case FORTIFICATION:
|
|
|
|
znak = '#';
|
|
|
|
break;
|
|
|
|
case STAIR_DOWN:
|
|
|
|
znak = '>';
|
|
|
|
break;
|
|
|
|
case STAIR_UP:
|
|
|
|
znak = '<';
|
|
|
|
break;
|
|
|
|
case STAIR_UPDOWN:
|
|
|
|
znak = '=';
|
|
|
|
break;
|
|
|
|
case RAMP:
|
2010-03-25 17:42:07 -06:00
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddwstr(stdscr, y, x, L"\u25B2");
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
return 0;
|
|
|
|
case RAMP_TOP:
|
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddwstr(stdscr, y, x, L"\u25BC");
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
return 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
case FLOOR:
|
|
|
|
znak = '.';
|
|
|
|
break;
|
|
|
|
case TREE_DEAD:
|
|
|
|
case TREE_OK:
|
2010-03-25 18:21:35 -06:00
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddwstr(stdscr, y, x, L"\u2663");
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
return 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
case SAPLING_DEAD:
|
|
|
|
case SAPLING_OK:
|
2010-03-25 18:21:35 -06:00
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddwstr(stdscr, y, x, L"\u03C4");
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
return 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
case SHRUB_DEAD:
|
|
|
|
case SHRUB_OK:
|
2010-03-25 18:21:35 -06:00
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddwstr(stdscr, y, x, L"\u2666");
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
return 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
case BOULDER:
|
|
|
|
case PEBBLES:
|
|
|
|
znak= '*';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
attron(COLOR_PAIR(color));
|
|
|
|
mvwaddch(stdscr, y, x, znak);
|
|
|
|
attroff(COLOR_PAIR(color));
|
|
|
|
}
|
|
|
|
|
|
|
|
int cprintf(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
int i = vwprintw(stdscr,fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clrscr()
|
|
|
|
{
|
|
|
|
wbkgd(stdscr, COLOR_PAIR(COLOR_BLACK));
|
|
|
|
wclear(stdscr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
enum TileMaterial
|
|
|
|
{
|
|
|
|
AIR,
|
|
|
|
SOIL,
|
|
|
|
STONE,
|
|
|
|
FEATSTONE, // whatever it is
|
|
|
|
OBSIDIAN,
|
|
|
|
|
|
|
|
VEIN,
|
|
|
|
ICE,
|
|
|
|
GRASS,
|
|
|
|
GRASS2,
|
|
|
|
GRASS_DEAD,
|
|
|
|
GRASS_DRY,
|
|
|
|
DRIFTWOOD,
|
|
|
|
HFS,
|
|
|
|
MAGMA,
|
|
|
|
CAMPFIRE,
|
|
|
|
FIRE,
|
|
|
|
ASHES,
|
|
|
|
CONSTRUCTED
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
int pickColor(int tiletype)
|
|
|
|
{
|
|
|
|
switch(tileTypeTable[tiletype].m)
|
|
|
|
{
|
|
|
|
case AIR:
|
|
|
|
return COLOR_BLACK;
|
|
|
|
case STONE:
|
|
|
|
case FEATSTONE:
|
|
|
|
case OBSIDIAN:
|
|
|
|
case CONSTRUCTED:
|
|
|
|
case ASHES:
|
|
|
|
default:
|
|
|
|
return COLOR_WHITE;
|
|
|
|
case SOIL:
|
|
|
|
case GRASS_DEAD:
|
|
|
|
case GRASS_DRY:
|
|
|
|
case DRIFTWOOD:
|
|
|
|
return COLOR_YELLOW;
|
|
|
|
case ICE:
|
|
|
|
return COLOR_CYAN;
|
|
|
|
case VEIN:
|
|
|
|
return COLOR_MAGENTA;
|
|
|
|
case GRASS:
|
|
|
|
case GRASS2:
|
|
|
|
return COLOR_GREEN;
|
|
|
|
case HFS:
|
|
|
|
case MAGMA:
|
|
|
|
case CAMPFIRE:
|
|
|
|
case FIRE:
|
|
|
|
return COLOR_RED;
|
|
|
|
}
|
|
|
|
|
2010-02-18 18:48:03 -07:00
|
|
|
}
|
|
|
|
|
2010-02-19 17:12:55 -07:00
|
|
|
/*
|
|
|
|
address = absolute address of dump start
|
|
|
|
length = length in bytes
|
|
|
|
*/
|
|
|
|
void hexdump (DFHack::API& DF, uint32_t address, uint32_t length, int filenum)
|
2010-02-18 18:48:03 -07:00
|
|
|
{
|
2010-02-19 17:12:55 -07:00
|
|
|
uint32_t reallength;
|
|
|
|
uint32_t lines;
|
|
|
|
lines = (length / 16) + 1;
|
|
|
|
reallength = lines * 16;
|
|
|
|
char *buf = new char[reallength];
|
|
|
|
ofstream myfile;
|
|
|
|
|
2010-02-20 04:58:52 -07:00
|
|
|
stringstream ss;
|
|
|
|
ss << "hexdump" << filenum << ".txt";
|
|
|
|
string name = ss.str();
|
2010-02-19 17:12:55 -07:00
|
|
|
|
|
|
|
myfile.open (name.c_str());
|
|
|
|
|
|
|
|
DF.ReadRaw(address, reallength, (uint8_t *) buf);
|
|
|
|
for (int i = 0; i < lines; i++)
|
|
|
|
{
|
|
|
|
// leading offset
|
|
|
|
myfile << "0x" << hex << setw(4) << i*16 << " ";
|
|
|
|
// groups
|
|
|
|
for(int j = 0; j < 4; j++)
|
|
|
|
{
|
|
|
|
// bytes
|
|
|
|
for(int k = 0; k < 4; k++)
|
|
|
|
{
|
|
|
|
int idx = i * 16 + j * 4 + k;
|
|
|
|
|
|
|
|
myfile << hex << setw(2) << int(static_cast<unsigned char>(buf[idx])) << " ";
|
|
|
|
}
|
|
|
|
myfile << " ";
|
|
|
|
}
|
|
|
|
myfile << endl;
|
|
|
|
}
|
|
|
|
delete buf;
|
|
|
|
myfile.close();
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
|
|
|
|
2010-02-19 17:12:55 -07:00
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
/* initialize your non-curses data structures here */
|
|
|
|
|
|
|
|
signal(SIGINT, finish); /* arrange interrupts to terminate */
|
2010-03-20 10:30:13 -06:00
|
|
|
setlocale(LC_ALL,"");
|
2010-02-17 09:49:19 -07:00
|
|
|
initscr(); /* initialize the curses library */
|
|
|
|
keypad(stdscr, TRUE); /* enable keyboard mapping */
|
|
|
|
nonl(); /* tell curses not to do NL->CR/NL on output */
|
|
|
|
cbreak(); /* take input chars one at a time, no wait for \n */
|
|
|
|
noecho(); /* don't echo input */
|
|
|
|
//nodelay(stdscr, true);
|
|
|
|
int wxMax = getmaxx(stdscr);
|
|
|
|
int wyMax = getmaxy(stdscr);
|
|
|
|
|
|
|
|
keypad(stdscr, TRUE);
|
|
|
|
scrollok(stdscr, TRUE);
|
|
|
|
|
|
|
|
if (has_colors())
|
|
|
|
{
|
|
|
|
start_color();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Simple color assignment, often all we need.
|
|
|
|
*/
|
|
|
|
init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
|
|
|
|
init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
|
|
|
|
init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
|
|
|
|
init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
|
|
|
|
init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
|
|
|
|
|
|
|
|
init_color(COLOR_CYAN, 700, 700, 700); // lt grey
|
|
|
|
init_color(COLOR_MAGENTA, 500, 500, 500); // dk grey
|
|
|
|
init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
|
|
|
|
init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
int x_max,y_max,z_max;
|
|
|
|
uint32_t x_max_a,y_max_a,z_max_a;
|
2010-03-04 16:05:01 -07:00
|
|
|
/*
|
2010-02-17 09:49:19 -07:00
|
|
|
uint16_t tiletypes[16][16];
|
|
|
|
DFHack::t_designation designations[16][16];
|
|
|
|
uint8_t regionoffsets[16];
|
2010-03-04 16:05:01 -07:00
|
|
|
*/
|
2010-02-17 09:49:19 -07:00
|
|
|
map <int16_t, uint32_t> materials;
|
|
|
|
materials.clear();
|
2010-03-18 12:55:01 -06:00
|
|
|
mapblock40d blocks[3][3];
|
2010-02-17 09:49:19 -07:00
|
|
|
vector<DFHack::t_matgloss> stonetypes;
|
2010-03-20 10:30:13 -06:00
|
|
|
vector<DFHack::t_effect_df40d> effects;
|
2010-02-17 09:49:19 -07:00
|
|
|
vector< vector <uint16_t> > layerassign;
|
|
|
|
vector<t_vein> veinVector;
|
2010-02-20 21:51:29 -07:00
|
|
|
vector<t_frozenliquidvein> IceVeinVector;
|
2010-03-26 06:01:46 -06:00
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
DFHack::Materials * Mats = 0;
|
|
|
|
DFHack::Maps * Maps = 0;
|
|
|
|
|
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
DFHack::API DF("Memory.xml");
|
2010-03-26 06:01:46 -06:00
|
|
|
try
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-03-26 06:01:46 -06:00
|
|
|
DF.Attach();
|
2010-04-04 16:48:19 -06:00
|
|
|
Mats = DF.getMaterials();
|
|
|
|
Maps = DF.getMaps();
|
2010-03-26 06:01:46 -06:00
|
|
|
pDF = &DF;
|
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2010-02-17 09:49:19 -07:00
|
|
|
finish(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Process* p = DF.getProcess();
|
|
|
|
// init the map
|
2010-04-04 16:48:19 -06:00
|
|
|
if(!Maps->Start())
|
2010-02-18 18:48:03 -07:00
|
|
|
{
|
|
|
|
error = "Can't find a map to look at.";
|
|
|
|
pDF = 0;
|
|
|
|
finish(0);
|
|
|
|
}
|
2010-02-17 09:49:19 -07:00
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->getSize(x_max_a,y_max_a,z_max_a);
|
2010-02-17 09:49:19 -07:00
|
|
|
x_max = x_max_a;
|
|
|
|
y_max = y_max_a;
|
|
|
|
z_max = z_max_a;
|
|
|
|
|
|
|
|
// get stone matgloss mapping
|
2010-04-04 16:48:19 -06:00
|
|
|
if(!Mats->ReadInorganicMaterials(stonetypes))
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
|
|
|
error = "Can't read stone types.";
|
2010-02-18 18:48:03 -07:00
|
|
|
pDF = 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
finish(0);
|
|
|
|
}
|
2010-04-02 20:41:21 -06:00
|
|
|
/*
|
2010-02-17 09:49:19 -07:00
|
|
|
// get region geology
|
|
|
|
if(!DF.ReadGeology( layerassign ))
|
|
|
|
{
|
|
|
|
error = "Can't read local geology.";
|
2010-02-18 18:48:03 -07:00
|
|
|
pDF = 0;
|
2010-02-17 09:49:19 -07:00
|
|
|
finish(0);
|
|
|
|
}
|
2010-04-02 20:41:21 -06:00
|
|
|
*/
|
2010-02-17 18:10:39 -07:00
|
|
|
// FIXME: could fail on small forts
|
2010-02-17 09:49:19 -07:00
|
|
|
int cursorX = x_max/2 - 1;
|
|
|
|
int cursorY = y_max/2 - 1;
|
|
|
|
int cursorZ = z_max/2 - 1;
|
2010-02-17 12:00:55 -07:00
|
|
|
|
2010-02-17 18:10:39 -07:00
|
|
|
|
2010-02-19 17:12:55 -07:00
|
|
|
bool dig = false;
|
|
|
|
bool dump = false;
|
2010-02-20 04:58:52 -07:00
|
|
|
bool digbit = false;
|
2010-02-17 09:49:19 -07:00
|
|
|
int vein = 0;
|
2010-02-19 17:12:55 -07:00
|
|
|
int filenum = 0;
|
2010-02-20 08:33:30 -07:00
|
|
|
bool dirtybit = false;
|
2010-02-19 17:12:55 -07:00
|
|
|
uint32_t blockaddr = 0;
|
2010-03-04 17:26:39 -07:00
|
|
|
uint32_t blockaddr2 = 0;
|
2010-03-26 04:28:33 -06:00
|
|
|
t_blockflags bflags;
|
|
|
|
bflags.whole = 0;
|
2010-03-18 12:55:01 -06:00
|
|
|
|
|
|
|
// resume so we don't block DF while we wait for input
|
|
|
|
DF.Resume();
|
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
for (;;)
|
|
|
|
{
|
2010-02-19 17:12:55 -07:00
|
|
|
dig = false;
|
|
|
|
dump = false;
|
2010-02-20 04:58:52 -07:00
|
|
|
digbit = false;
|
2010-03-18 12:55:01 -06:00
|
|
|
|
2010-02-17 09:49:19 -07:00
|
|
|
int c = getch(); /* refresh, accept single keystroke of input */
|
2010-03-18 13:05:32 -06:00
|
|
|
flushinp();
|
2010-02-17 09:49:19 -07:00
|
|
|
clrscr();
|
|
|
|
/* process the command keystroke */
|
|
|
|
switch(c)
|
|
|
|
{
|
|
|
|
case KEY_DOWN:
|
|
|
|
cursorY ++;
|
|
|
|
break;
|
|
|
|
case KEY_UP:
|
|
|
|
cursorY --;
|
|
|
|
break;
|
|
|
|
case KEY_LEFT:
|
|
|
|
cursorX --;
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
cursorX ++;
|
|
|
|
break;
|
|
|
|
case KEY_NPAGE:
|
|
|
|
cursorZ --;
|
|
|
|
break;
|
|
|
|
case KEY_PPAGE:
|
|
|
|
cursorZ ++;
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
vein ++;
|
|
|
|
break;
|
2010-02-19 17:12:55 -07:00
|
|
|
case 'd':
|
|
|
|
dig = true;
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
dump = true;
|
|
|
|
break;
|
2010-02-17 09:49:19 -07:00
|
|
|
case '-':
|
|
|
|
vein --;
|
|
|
|
break;
|
2010-02-20 04:58:52 -07:00
|
|
|
case 'z':
|
|
|
|
digbit = true;
|
|
|
|
break;
|
2010-02-17 09:49:19 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cursorX = max(cursorX, 0);
|
|
|
|
cursorY = max(cursorY, 0);
|
|
|
|
cursorZ = max(cursorZ, 0);
|
|
|
|
|
2010-02-17 18:10:39 -07:00
|
|
|
cursorX = min(cursorX, x_max - 1);
|
|
|
|
cursorY = min(cursorY, y_max - 1);
|
2010-03-18 12:55:01 -06:00
|
|
|
cursorZ = min(cursorZ, z_max - 1);
|
|
|
|
|
|
|
|
// clear data before we suspend
|
|
|
|
memset(blocks,0,sizeof(blocks));
|
|
|
|
veinVector.clear();
|
|
|
|
IceVeinVector.clear();
|
2010-03-20 10:30:13 -06:00
|
|
|
effects.clear();
|
2010-03-18 12:55:01 -06:00
|
|
|
dirtybit = 0;
|
|
|
|
|
|
|
|
// Supend, read/write data
|
2010-02-17 09:49:19 -07:00
|
|
|
DF.Suspend();
|
2010-03-20 10:30:13 -06:00
|
|
|
uint32_t effectnum;
|
2010-04-02 20:41:21 -06:00
|
|
|
/*
|
2010-03-20 10:30:13 -06:00
|
|
|
if(DF.InitReadEffects(effectnum))
|
|
|
|
{
|
|
|
|
for(uint32_t i = 0; i < effectnum;i++)
|
|
|
|
{
|
|
|
|
t_effect_df40d effect;
|
|
|
|
DF.ReadEffect(i,effect);
|
|
|
|
effects.push_back(effect);
|
|
|
|
}
|
|
|
|
}
|
2010-04-02 20:41:21 -06:00
|
|
|
*/
|
2010-03-18 12:55:01 -06:00
|
|
|
for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++)
|
2010-02-17 18:10:39 -07:00
|
|
|
{
|
2010-03-18 12:55:01 -06:00
|
|
|
mapblock40d * Block = &blocks[i+1][j+1];
|
|
|
|
|
2010-03-20 10:30:13 -06:00
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
if(Maps->isValidBlock(cursorX+i,cursorY+j,cursorZ))
|
2010-02-17 18:10:39 -07:00
|
|
|
{
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->ReadBlock40d(cursorX+i,cursorY+j,cursorZ, Block);
|
2010-03-18 12:55:01 -06:00
|
|
|
|
|
|
|
// extra processing of the block in the middle
|
|
|
|
if(i == 0 && j == 0)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-03-18 12:55:01 -06:00
|
|
|
// read veins
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector,IceVeinVector);
|
2010-03-04 17:57:51 -07:00
|
|
|
|
2010-03-18 12:55:01 -06:00
|
|
|
// get pointer to block
|
2010-04-04 16:48:19 -06:00
|
|
|
blockaddr = Maps->getBlockPtr(cursorX+i,cursorY+j,cursorZ);
|
2010-03-18 12:55:01 -06:00
|
|
|
blockaddr2 = Block->origin;
|
|
|
|
|
|
|
|
// dig all veins and trees
|
|
|
|
if(dig)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-03-18 12:55:01 -06:00
|
|
|
for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-03-18 12:55:01 -06:00
|
|
|
TileClass tc = tileTypeTable[Block->tiletypes[x][y]].c;
|
|
|
|
TileMaterial tm = tileTypeTable[Block->tiletypes[x][y]].m;
|
|
|
|
if( tc == WALL && tm == VEIN || tc == TREE_OK || tc == TREE_DEAD)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-03-25 14:37:09 -06:00
|
|
|
Block->designation[x][y].bits.dig = designation_default;
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
|
|
|
}
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->WriteDesignations(cursorX+i,cursorY+j,cursorZ, &(Block->designation));
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
2010-03-18 12:55:01 -06:00
|
|
|
// do a dump of the block data
|
|
|
|
if(dump)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-03-18 12:55:01 -06:00
|
|
|
hexdump(DF,blockaddr,0x1E00,filenum);
|
|
|
|
filenum++;
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
2010-03-18 12:55:01 -06:00
|
|
|
// read/write dirty bit of the block
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->ReadDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit);
|
|
|
|
Maps->ReadBlockFlags(cursorX+i,cursorY+j,cursorZ,bflags);
|
2010-03-18 12:55:01 -06:00
|
|
|
if(digbit)
|
|
|
|
{
|
|
|
|
dirtybit = !dirtybit;
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->WriteDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit);
|
2010-03-18 12:55:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Resume, print stuff to the terminal
|
|
|
|
DF.Resume();
|
|
|
|
for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++)
|
|
|
|
{
|
|
|
|
mapblock40d * Block = &blocks[i+1][j+1];
|
|
|
|
for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++)
|
|
|
|
{
|
|
|
|
int color = COLOR_BLACK;
|
|
|
|
color = pickColor(Block->tiletypes[x][y]);
|
2010-04-02 07:47:08 -06:00
|
|
|
//if(!Block->designation[x][y].bits.hidden)
|
2010-03-20 10:30:13 -06:00
|
|
|
/*{
|
2010-03-18 12:55:01 -06:00
|
|
|
puttile(x+(i+1)*16,y+(j+1)*16,Block->tiletypes[x][y], color);
|
|
|
|
}
|
2010-03-20 10:30:13 -06:00
|
|
|
else*/
|
2010-03-18 12:55:01 -06:00
|
|
|
{
|
|
|
|
attron(A_STANDOUT);
|
|
|
|
puttile(x+(i+1)*16,y+(j+1)*16,Block->tiletypes[x][y], color);
|
|
|
|
attroff(A_STANDOUT);
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
2010-02-17 18:10:39 -07:00
|
|
|
}
|
2010-03-20 10:30:13 -06:00
|
|
|
// print effects for the center tile
|
|
|
|
|
|
|
|
if(i == 0 && j == 0)
|
|
|
|
{
|
|
|
|
for(uint zz = 0; zz < effects.size();zz++)
|
|
|
|
{
|
2010-04-02 07:47:08 -06:00
|
|
|
if(effects[zz].z == cursorZ /*&& !effects[zz].isHidden*/)
|
2010-03-20 10:30:13 -06:00
|
|
|
{
|
|
|
|
// block coords to tile coords
|
|
|
|
uint16_t x = effects[zz].x - (cursorX * 16);
|
|
|
|
uint16_t y = effects[zz].y - (cursorY * 16);
|
|
|
|
if(x < 16 && y < 16)
|
|
|
|
{
|
|
|
|
putch(x + 16,y + 16,'@',COLOR_WHITE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-17 18:10:39 -07:00
|
|
|
}
|
2010-02-17 09:49:19 -07:00
|
|
|
gotoxy(0,48);
|
|
|
|
cprintf("arrow keys, PGUP, PGDN = navigate");
|
|
|
|
gotoxy(0,49);
|
|
|
|
cprintf("+,- = switch vein");
|
|
|
|
gotoxy(0,50);
|
2010-02-20 21:51:29 -07:00
|
|
|
uint32_t mineralsize = veinVector.size();
|
|
|
|
uint32_t icesize = IceVeinVector.size();
|
|
|
|
uint32_t totalVeinSize = mineralsize+ icesize;
|
|
|
|
if(vein == totalVeinSize) vein = totalVeinSize - 1;
|
2010-02-17 09:49:19 -07:00
|
|
|
if(vein < -1) vein = -1;
|
2010-02-20 21:51:29 -07:00
|
|
|
cprintf("X %d/%d, Y %d/%d, Z %d/%d. Vein %d of %d",cursorX+1,x_max,cursorY+1,y_max,cursorZ,z_max,vein+1,totalVeinSize);
|
|
|
|
if(!veinVector.empty() || !IceVeinVector.empty())
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-02-20 21:51:29 -07:00
|
|
|
if(vein != -1 && vein < totalVeinSize)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-02-20 21:51:29 -07:00
|
|
|
uint32_t realvein = 0;
|
|
|
|
if(vein < mineralsize)
|
2010-02-17 09:49:19 -07:00
|
|
|
{
|
2010-02-20 21:51:29 -07:00
|
|
|
realvein = vein;
|
2010-02-17 09:49:19 -07:00
|
|
|
//iterate through vein rows
|
|
|
|
for(uint32_t j = 0;j<16;j++)
|
|
|
|
{
|
|
|
|
//iterate through the bits
|
|
|
|
for (uint32_t k = 0; k< 16;k++)
|
|
|
|
{
|
2010-04-02 20:41:21 -06:00
|
|
|
/*
|
2010-03-20 10:30:13 -06:00
|
|
|
if(tileTypeTable[blocks[1][1].tiletypes[k][j]].m != VEIN)
|
|
|
|
continue;
|
2010-04-02 20:41:21 -06:00
|
|
|
*/
|
2010-04-02 07:47:08 -06:00
|
|
|
/*
|
2010-03-25 14:37:09 -06:00
|
|
|
if(blocks[1][1].designation[k][j].bits.hidden)
|
2010-03-20 10:30:13 -06:00
|
|
|
continue;
|
2010-04-02 07:47:08 -06:00
|
|
|
*/
|
2010-02-17 09:49:19 -07:00
|
|
|
// and the bit array with a one-bit mask, check if the bit is set
|
2010-02-20 21:51:29 -07:00
|
|
|
bool set = !!(((1 << k) & veinVector[realvein].assignment[j]) >> k);
|
2010-02-17 09:49:19 -07:00
|
|
|
if(set)
|
|
|
|
{
|
|
|
|
putch(k+16,j+16,'$',COLOR_RED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-20 21:51:29 -07:00
|
|
|
gotoxy(0,51);
|
2010-04-02 20:41:21 -06:00
|
|
|
cprintf("Mineral: %s",stonetypes[veinVector[vein].type].id);
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
2010-02-20 21:51:29 -07:00
|
|
|
else
|
2010-02-20 20:39:01 -07:00
|
|
|
{
|
2010-02-20 21:51:29 -07:00
|
|
|
realvein = vein - mineralsize;
|
|
|
|
t_frozenliquidvein &frozen = IceVeinVector[realvein];
|
|
|
|
for(uint32_t i = 0;i<16;i++)
|
|
|
|
{
|
|
|
|
for (uint32_t j = 0; j< 16;j++)
|
|
|
|
{
|
|
|
|
int color = COLOR_BLACK;
|
|
|
|
int tile = frozen.tiles[i][j];
|
|
|
|
color = pickColor(tile);
|
|
|
|
|
|
|
|
attron(A_STANDOUT);
|
|
|
|
puttile(i+16,j+16,tile, color);
|
|
|
|
attroff(A_STANDOUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gotoxy(0,51);
|
|
|
|
cprintf("ICE");
|
2010-02-20 20:39:01 -07:00
|
|
|
}
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
|
|
|
}
|
2010-02-20 21:51:29 -07:00
|
|
|
gotoxy (0,52);
|
2010-03-26 04:28:33 -06:00
|
|
|
cprintf("block address 0x%x, flags 0x%08x",blockaddr, bflags.whole);
|
2010-02-20 21:51:29 -07:00
|
|
|
gotoxy (0,53);
|
2010-02-20 08:33:30 -07:00
|
|
|
cprintf("dirty bit: %d",dirtybit);
|
2010-02-20 21:51:29 -07:00
|
|
|
gotoxy (0,54);
|
|
|
|
cprintf ("d - dig veins, o - dump map block, z - toggle dirty bit");
|
2010-02-17 09:49:19 -07:00
|
|
|
wrefresh(stdscr);
|
|
|
|
}
|
2010-02-18 18:48:03 -07:00
|
|
|
pDF = 0;
|
2010-02-17 12:00:55 -07:00
|
|
|
finish(0);
|
2010-02-17 09:49:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void finish(int sig)
|
|
|
|
{
|
2010-02-18 18:48:03 -07:00
|
|
|
// ugly
|
|
|
|
if(pDF)
|
|
|
|
{
|
2010-02-18 19:37:16 -07:00
|
|
|
pDF->ForceResume();
|
2010-02-18 18:48:03 -07:00
|
|
|
pDF->Detach();
|
|
|
|
}
|
2010-02-17 09:49:19 -07:00
|
|
|
endwin();
|
|
|
|
if(!error.empty())
|
|
|
|
{
|
|
|
|
cerr << error << endl;
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|