Merge branch 'develop' of https://github.com/DFHack/dfhack into develop
commit
f2461254d4
@ -0,0 +1,6 @@
|
|||||||
|
language: cpp
|
||||||
|
script:
|
||||||
|
- python travis/lint.py
|
||||||
|
- python travis/pr-check-base.py
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
Subproject commit e1151e8d6401c286f1d7df45abbd14562bedc7e9
|
Subproject commit 7ff793882032374e8f9819978aa7a29d5236798c
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,189 +1,189 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
#include "MemAccess.h"
|
#include "MemAccess.h"
|
||||||
#include "MiscUtils.h"
|
#include "MiscUtils.h"
|
||||||
#include <tinythread.h> //not sure if correct
|
#include <tinythread.h> //not sure if correct
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
using namespace DFHack;
|
using namespace DFHack;
|
||||||
|
|
||||||
uint64_t timeLast=0;
|
uint64_t timeLast=0;
|
||||||
static tthread::mutex* mymutex=0;
|
static tthread::mutex* mymutex=0;
|
||||||
|
|
||||||
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
||||||
|
|
||||||
struct memory_data
|
struct memory_data
|
||||||
{
|
{
|
||||||
void * addr;
|
void * addr;
|
||||||
size_t len;
|
size_t len;
|
||||||
size_t refresh;
|
size_t refresh;
|
||||||
int state;
|
int state;
|
||||||
uint8_t *buf,*lbuf;
|
uint8_t *buf,*lbuf;
|
||||||
vector<t_memrange> ranges;
|
vector<t_memrange> ranges;
|
||||||
}memdata;
|
}memdata;
|
||||||
enum HEXVIEW_STATES
|
enum HEXVIEW_STATES
|
||||||
{
|
{
|
||||||
STATE_OFF,STATE_ON
|
STATE_OFF,STATE_ON
|
||||||
};
|
};
|
||||||
command_result memview (color_ostream &out, vector <string> & parameters);
|
command_result memview (color_ostream &out, vector <string> & parameters);
|
||||||
|
|
||||||
DFHACK_PLUGIN("memview");
|
DFHACK_PLUGIN("memview");
|
||||||
|
|
||||||
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
|
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
|
||||||
{
|
{
|
||||||
commands.push_back(PluginCommand("memview","Shows memory in real time. Params: adrr length refresh_rate. If addr==0 then stop viewing",memview));
|
commands.push_back(PluginCommand("memview","Shows memory in real time. Params: adrr length refresh_rate. If addr==0 then stop viewing",memview));
|
||||||
memdata.state=STATE_OFF;
|
memdata.state=STATE_OFF;
|
||||||
mymutex=new tthread::mutex;
|
mymutex=new tthread::mutex;
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
size_t convert(const std::string& p,bool ishex=false)
|
size_t convert(const std::string& p,bool ishex=false)
|
||||||
{
|
{
|
||||||
size_t ret;
|
size_t ret;
|
||||||
std::stringstream conv;
|
std::stringstream conv;
|
||||||
if(ishex)
|
if(ishex)
|
||||||
conv<<std::hex;
|
conv<<std::hex;
|
||||||
conv<<p;
|
conv<<p;
|
||||||
conv>>ret;
|
conv>>ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
bool isAddr(uint32_t *trg,vector<t_memrange> & ranges)
|
bool isAddr(uint32_t *trg,vector<t_memrange> & ranges)
|
||||||
{
|
{
|
||||||
if(trg[0]%4==0)
|
if(trg[0]%4==0)
|
||||||
for(size_t i=0;i<ranges.size();i++)
|
for(size_t i=0;i<ranges.size();i++)
|
||||||
if(ranges[i].isInRange((void *)trg[0]))
|
if(ranges[i].isInRange((void *)trg[0]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,color_ostream &con,vector<t_memrange> & ranges)
|
void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,color_ostream &con,vector<t_memrange> & ranges)
|
||||||
{
|
{
|
||||||
const size_t page_size=16;
|
const size_t page_size=16;
|
||||||
|
|
||||||
for(size_t i=0;i<len;i+=page_size)
|
for(size_t i=0;i<len;i+=page_size)
|
||||||
{
|
{
|
||||||
//con.gotoxy(1,i/page_size+1);
|
//con.gotoxy(1,i/page_size+1);
|
||||||
con.print("0x%08X ",i+start);
|
con.print("0x%08X ",i+start);
|
||||||
for(size_t j=0;(j<page_size) && (i+j<len);j++)
|
for(size_t j=0;(j<page_size) && (i+j<len);j++)
|
||||||
{
|
{
|
||||||
if(j%4==0)
|
if(j%4==0)
|
||||||
{
|
{
|
||||||
con.reset_color();
|
con.reset_color();
|
||||||
|
|
||||||
if(isAddr((uint32_t *)(buf+j+i),ranges))
|
if(isAddr((uint32_t *)(buf+j+i),ranges))
|
||||||
con.color(COLOR_LIGHTRED); //coloring in the middle does not work
|
con.color(COLOR_LIGHTRED); //coloring in the middle does not work
|
||||||
//TODO make something better?
|
//TODO make something better?
|
||||||
}
|
}
|
||||||
if(lbuf[j+i]!=buf[j+i])
|
if(lbuf[j+i]!=buf[j+i])
|
||||||
con.print("*%02X",buf[j+i]); //if modfied show a star
|
con.print("*%02X",buf[j+i]); //if modfied show a star
|
||||||
else
|
else
|
||||||
con.print(" %02X",buf[j+i]);
|
con.print(" %02X",buf[j+i]);
|
||||||
}
|
}
|
||||||
con.reset_color();
|
con.reset_color();
|
||||||
con.print(" | ");
|
con.print(" | ");
|
||||||
for(size_t j=0;(j<page_size) && (i+j<len);j++)
|
for(size_t j=0;(j<page_size) && (i+j<len);j++)
|
||||||
if((buf[j+i]>31)&&(buf[j+i]<128)) //only printable ascii
|
if((buf[j+i]>31)&&(buf[j+i]<128)) //only printable ascii
|
||||||
con.print("%c",buf[j+i]);
|
con.print("%c",buf[j+i]);
|
||||||
else
|
else
|
||||||
con.print(".");
|
con.print(".");
|
||||||
//con.print("\n");
|
//con.print("\n");
|
||||||
}
|
}
|
||||||
con.print("\n");
|
con.print("\n");
|
||||||
}
|
}
|
||||||
void Deinit()
|
void Deinit()
|
||||||
{
|
{
|
||||||
if(memdata.state==STATE_ON)
|
if(memdata.state==STATE_ON)
|
||||||
{
|
{
|
||||||
is_enabled = false;
|
is_enabled = false;
|
||||||
memdata.state=STATE_OFF;
|
memdata.state=STATE_OFF;
|
||||||
delete [] memdata.buf;
|
delete [] memdata.buf;
|
||||||
delete [] memdata.lbuf;
|
delete [] memdata.lbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DFhackCExport command_result plugin_onupdate (color_ostream &out)
|
DFhackCExport command_result plugin_onupdate (color_ostream &out)
|
||||||
{
|
{
|
||||||
|
|
||||||
mymutex->lock();
|
mymutex->lock();
|
||||||
if(memdata.state==STATE_OFF)
|
if(memdata.state==STATE_OFF)
|
||||||
{
|
{
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
//Console &con=out;
|
//Console &con=out;
|
||||||
uint64_t time2 = GetTimeMs64();
|
uint64_t time2 = GetTimeMs64();
|
||||||
uint64_t delta = time2-timeLast;
|
uint64_t delta = time2-timeLast;
|
||||||
|
|
||||||
if(memdata.refresh!=0)
|
if(memdata.refresh!=0)
|
||||||
if(delta<memdata.refresh)
|
if(delta<memdata.refresh)
|
||||||
{
|
{
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
timeLast = time2;
|
timeLast = time2;
|
||||||
|
|
||||||
Core::getInstance().p->read(memdata.addr,memdata.len,memdata.buf);
|
Core::getInstance().p->read(memdata.addr,memdata.len,memdata.buf);
|
||||||
outputHex(memdata.buf,memdata.lbuf,memdata.len,(size_t)memdata.addr,out,memdata.ranges);
|
outputHex(memdata.buf,memdata.lbuf,memdata.len,(size_t)memdata.addr,out,memdata.ranges);
|
||||||
memcpy(memdata.lbuf, memdata.buf, memdata.len);
|
memcpy(memdata.lbuf, memdata.buf, memdata.len);
|
||||||
if(memdata.refresh==0)
|
if(memdata.refresh==0)
|
||||||
Deinit();
|
Deinit();
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
command_result memview (color_ostream &out, vector <string> & parameters)
|
command_result memview (color_ostream &out, vector <string> & parameters)
|
||||||
{
|
{
|
||||||
mymutex->lock();
|
mymutex->lock();
|
||||||
Core::getInstance().p->getMemRanges(memdata.ranges);
|
Core::getInstance().p->getMemRanges(memdata.ranges);
|
||||||
memdata.addr=(void *)convert(parameters[0],true);
|
memdata.addr=(void *)convert(parameters[0],true);
|
||||||
if(memdata.addr==0)
|
if(memdata.addr==0)
|
||||||
{
|
{
|
||||||
Deinit();
|
Deinit();
|
||||||
memdata.state=STATE_OFF;
|
memdata.state=STATE_OFF;
|
||||||
is_enabled = false;
|
is_enabled = false;
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Deinit();
|
Deinit();
|
||||||
bool isValid=false;
|
bool isValid=false;
|
||||||
for(size_t i=0;i<memdata.ranges.size();i++)
|
for(size_t i=0;i<memdata.ranges.size();i++)
|
||||||
if(memdata.ranges[i].isInRange(memdata.addr))
|
if(memdata.ranges[i].isInRange(memdata.addr))
|
||||||
isValid=true;
|
isValid=true;
|
||||||
if(!isValid)
|
if(!isValid)
|
||||||
{
|
{
|
||||||
out.printerr("Invalid address:%x\n",memdata.addr);
|
out.printerr("Invalid address:%x\n",memdata.addr);
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
is_enabled = true;
|
is_enabled = true;
|
||||||
memdata.state=STATE_ON;
|
memdata.state=STATE_ON;
|
||||||
}
|
}
|
||||||
if(parameters.size()>1)
|
if(parameters.size()>1)
|
||||||
memdata.len=convert(parameters[1]);
|
memdata.len=convert(parameters[1]);
|
||||||
else
|
else
|
||||||
memdata.len=20*16;
|
memdata.len=20*16;
|
||||||
|
|
||||||
if(parameters.size()>2)
|
if(parameters.size()>2)
|
||||||
memdata.refresh=convert(parameters[2]);
|
memdata.refresh=convert(parameters[2]);
|
||||||
else
|
else
|
||||||
memdata.refresh=0;
|
memdata.refresh=0;
|
||||||
|
|
||||||
memdata.buf=new uint8_t[memdata.len];
|
memdata.buf=new uint8_t[memdata.len];
|
||||||
memdata.lbuf=new uint8_t[memdata.len];
|
memdata.lbuf=new uint8_t[memdata.len];
|
||||||
Core::getInstance().p->getMemRanges(memdata.ranges);
|
Core::getInstance().p->getMemRanges(memdata.ranges);
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
DFhackCExport command_result plugin_shutdown (color_ostream &out)
|
DFhackCExport command_result plugin_shutdown (color_ostream &out)
|
||||||
{
|
{
|
||||||
mymutex->lock();
|
mymutex->lock();
|
||||||
Deinit();
|
Deinit();
|
||||||
delete mymutex;
|
delete mymutex;
|
||||||
mymutex->unlock();
|
mymutex->unlock();
|
||||||
return CR_OK;
|
return CR_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit a80abe848e4886a210e7a5123192e9221dc85810
|
Subproject commit 5b167d2ba89b877d80e0609feae8771aeaef356d
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit 07750ad7f7ce7c2506e5198ffb80ca50a73e9c4e
|
Subproject commit 85dcde97197bdde1c1e97ccb536f2cc4cab6818f
|
||||||
@ -1,76 +1,76 @@
|
|||||||
package isoworldremote;
|
package isoworldremote;
|
||||||
|
|
||||||
//Describes a very basic material structure for the map embark
|
//Describes a very basic material structure for the map embark
|
||||||
option optimize_for = LITE_RUNTIME;
|
option optimize_for = LITE_RUNTIME;
|
||||||
|
|
||||||
enum BasicMaterial {
|
enum BasicMaterial {
|
||||||
AIR = 0;
|
AIR = 0;
|
||||||
OTHER = 1;
|
OTHER = 1;
|
||||||
INORGANIC = 2;
|
INORGANIC = 2;
|
||||||
LIQUID = 3;
|
LIQUID = 3;
|
||||||
PLANT = 4;
|
PLANT = 4;
|
||||||
WOOD = 5;
|
WOOD = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LiquidType {
|
enum LiquidType {
|
||||||
ICE = 0;
|
ICE = 0;
|
||||||
WATER = 1;
|
WATER = 1;
|
||||||
MAGMA = 2;
|
MAGMA = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BasicShape {
|
enum BasicShape {
|
||||||
NONE = 0;
|
NONE = 0;
|
||||||
OPEN = 1;
|
OPEN = 1;
|
||||||
WALL = 3;
|
WALL = 3;
|
||||||
FLOOR = 4;
|
FLOOR = 4;
|
||||||
RAMP_UP = 5;
|
RAMP_UP = 5;
|
||||||
RAMP_DOWN = 6;
|
RAMP_DOWN = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ColorDefinition {
|
message ColorDefinition {
|
||||||
required int32 red = 1;
|
required int32 red = 1;
|
||||||
required int32 green = 2;
|
required int32 green = 2;
|
||||||
required int32 blue = 3;
|
required int32 blue = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message EmbarkTileLayer {
|
message EmbarkTileLayer {
|
||||||
repeated BasicMaterial mat_type_table = 4 [packed=true];
|
repeated BasicMaterial mat_type_table = 4 [packed=true];
|
||||||
repeated int32 mat_subtype_table = 5 [packed=true];
|
repeated int32 mat_subtype_table = 5 [packed=true];
|
||||||
repeated BasicShape tile_shape_table = 6 [packed=true];
|
repeated BasicShape tile_shape_table = 6 [packed=true];
|
||||||
repeated ColorDefinition tile_color_table = 7;
|
repeated ColorDefinition tile_color_table = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message EmbarkTile {
|
message EmbarkTile {
|
||||||
required int32 world_x = 1;
|
required int32 world_x = 1;
|
||||||
required int32 world_y = 2;
|
required int32 world_y = 2;
|
||||||
required sint32 world_z = 3;
|
required sint32 world_z = 3;
|
||||||
repeated EmbarkTileLayer tile_layer = 4;
|
repeated EmbarkTileLayer tile_layer = 4;
|
||||||
optional int32 current_year = 5;
|
optional int32 current_year = 5;
|
||||||
optional int32 current_season = 6;
|
optional int32 current_season = 6;
|
||||||
optional bool is_valid = 7;
|
optional bool is_valid = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message TileRequest {
|
message TileRequest {
|
||||||
optional int32 want_x = 1;
|
optional int32 want_x = 1;
|
||||||
optional int32 want_y = 2;
|
optional int32 want_y = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message MapRequest {
|
message MapRequest {
|
||||||
optional string save_folder = 1;
|
optional string save_folder = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message MapReply {
|
message MapReply {
|
||||||
required bool available = 1;
|
required bool available = 1;
|
||||||
optional int32 region_x = 2;
|
optional int32 region_x = 2;
|
||||||
optional int32 region_y = 3;
|
optional int32 region_y = 3;
|
||||||
optional int32 region_size_x = 4;
|
optional int32 region_size_x = 4;
|
||||||
optional int32 region_size_y = 5;
|
optional int32 region_size_y = 5;
|
||||||
optional int32 current_year = 6;
|
optional int32 current_year = 6;
|
||||||
optional int32 current_season = 7;
|
optional int32 current_season = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RawNames {
|
message RawNames {
|
||||||
required bool available = 1;
|
required bool available = 1;
|
||||||
repeated string inorganic = 2;
|
repeated string inorganic = 2;
|
||||||
repeated string organic = 3;
|
repeated string organic = 3;
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue