commit
e9cc242322
@ -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
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,225 +1,225 @@
|
|||||||
--scroll down to the end for configuration
|
--scroll down to the end for configuration
|
||||||
ret={...}
|
ret={...}
|
||||||
ret=ret[1]
|
ret=ret[1]
|
||||||
ret.materials={}
|
ret.materials={}
|
||||||
ret.buildings={}
|
ret.buildings={}
|
||||||
ret.special={}
|
ret.special={}
|
||||||
ret.items={}
|
ret.items={}
|
||||||
ret.creatures={}
|
ret.creatures={}
|
||||||
for k,v in pairs(ret) do
|
for k,v in pairs(ret) do
|
||||||
_ENV[k]=v
|
_ENV[k]=v
|
||||||
end
|
end
|
||||||
-- add material by id (index,mat pair or token string or a type number), flags is a table of strings
|
-- add material by id (index,mat pair or token string or a type number), flags is a table of strings
|
||||||
-- supported flags (but not implemented):
|
-- supported flags (but not implemented):
|
||||||
-- flicker
|
-- flicker
|
||||||
function addMaterial(id,transparency,emitance,radius,flags)
|
function addMaterial(id,transparency,emitance,radius,flags)
|
||||||
local matinfo
|
local matinfo
|
||||||
if type(id)=="string" then
|
if type(id)=="string" then
|
||||||
matinfo=dfhack.matinfo.find(id)
|
matinfo=dfhack.matinfo.find(id)
|
||||||
elseif type(id)=="table" then
|
elseif type(id)=="table" then
|
||||||
matinfo=dfhack.matinfo.decode(id[1],id[2])
|
matinfo=dfhack.matinfo.decode(id[1],id[2])
|
||||||
else
|
else
|
||||||
matinfo=dfhack.matinfo.decode(id,0)
|
matinfo=dfhack.matinfo.decode(id,0)
|
||||||
end
|
end
|
||||||
if matinfo==nil then
|
if matinfo==nil then
|
||||||
error("Material not found")
|
error("Material not found")
|
||||||
end
|
end
|
||||||
materials[matinfo.type]=materials[matinfo.type] or {}
|
materials[matinfo.type]=materials[matinfo.type] or {}
|
||||||
materials[matinfo.type][matinfo.index]=makeMaterialDef(transparency,emitance,radius,flags)
|
materials[matinfo.type][matinfo.index]=makeMaterialDef(transparency,emitance,radius,flags)
|
||||||
end
|
end
|
||||||
function buildingLookUp(id)
|
function buildingLookUp(id)
|
||||||
local tokens={}
|
local tokens={}
|
||||||
local lookup={ Workshop=df.workshop_type,Furnace=df.furnace_type,Trap=df.trap_type,
|
local lookup={ Workshop=df.workshop_type,Furnace=df.furnace_type,Trap=df.trap_type,
|
||||||
SiegeEngine=df.siegeengine_type}
|
SiegeEngine=df.siegeengine_type}
|
||||||
for i in string.gmatch(id, "[^:]+") do
|
for i in string.gmatch(id, "[^:]+") do
|
||||||
table.insert(tokens,i)
|
table.insert(tokens,i)
|
||||||
end
|
end
|
||||||
local ret={}
|
local ret={}
|
||||||
ret.type=df.building_type[tokens[1]]
|
ret.type=df.building_type[tokens[1]]
|
||||||
if tokens[2] then
|
if tokens[2] then
|
||||||
local type_array=lookup[tokens[1]]
|
local type_array=lookup[tokens[1]]
|
||||||
if type_array then
|
if type_array then
|
||||||
ret.subtype=type_array[tokens[2]]
|
ret.subtype=type_array[tokens[2]]
|
||||||
end
|
end
|
||||||
if tokens[2]=="Custom" and tokens[3] then --TODO cache for faster lookup
|
if tokens[2]=="Custom" and tokens[3] then --TODO cache for faster lookup
|
||||||
if ret.type==df.building_type.Workshop then
|
if ret.type==df.building_type.Workshop then
|
||||||
for k,v in pairs(df.global.world.raws.buildings.workshops) do
|
for k,v in pairs(df.global.world.raws.buildings.workshops) do
|
||||||
if v.code==tokens[3] then
|
if v.code==tokens[3] then
|
||||||
ret.custom=v.id
|
ret.custom=v.id
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif ret.type==df.building_type.Furnace then
|
elseif ret.type==df.building_type.Furnace then
|
||||||
for k,v in pairs(df.global.world.raws.buildings.furnaces) do
|
for k,v in pairs(df.global.world.raws.buildings.furnaces) do
|
||||||
if v.code==tokens[3] then
|
if v.code==tokens[3] then
|
||||||
ret.custom=v.id
|
ret.custom=v.id
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
qerror("Invalid custom building:"..tokens[3])
|
qerror("Invalid custom building:"..tokens[3])
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
function itemLookup(id)
|
function itemLookup(id)
|
||||||
local ret={}
|
local ret={}
|
||||||
local tokens={}
|
local tokens={}
|
||||||
for i in string.gmatch(id, "[^:]+") do
|
for i in string.gmatch(id, "[^:]+") do
|
||||||
table.insert(tokens,i)
|
table.insert(tokens,i)
|
||||||
end
|
end
|
||||||
ret.type=df.item_type[tokens[1]]
|
ret.type=df.item_type[tokens[1]]
|
||||||
ret.subtype=-1
|
ret.subtype=-1
|
||||||
if tokens[2] then
|
if tokens[2] then
|
||||||
for k,v in ipairs(df.global.world.raws.itemdefs.all) do --todo lookup correct itemdef
|
for k,v in ipairs(df.global.world.raws.itemdefs.all) do --todo lookup correct itemdef
|
||||||
if v.id==tokens[2] then
|
if v.id==tokens[2] then
|
||||||
ret.subtype=v.subtype
|
ret.subtype=v.subtype
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
qerror("Failed item subtype lookup:"..tokens[2])
|
qerror("Failed item subtype lookup:"..tokens[2])
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
function creatureLookup(id)
|
function creatureLookup(id)
|
||||||
local ret={}
|
local ret={}
|
||||||
local tokens={}
|
local tokens={}
|
||||||
for i in string.gmatch(id, "[^:]+") do
|
for i in string.gmatch(id, "[^:]+") do
|
||||||
table.insert(tokens,i)
|
table.insert(tokens,i)
|
||||||
end
|
end
|
||||||
for k,v in ipairs(df.global.world.raws.creatures.all) do
|
for k,v in ipairs(df.global.world.raws.creatures.all) do
|
||||||
if v.creature_id==tokens[1] then
|
if v.creature_id==tokens[1] then
|
||||||
ret.type=k
|
ret.type=k
|
||||||
if tokens[2] then
|
if tokens[2] then
|
||||||
for k,v in ipairs(v.caste) do
|
for k,v in ipairs(v.caste) do
|
||||||
if v.caste_id==tokens[2] then
|
if v.caste_id==tokens[2] then
|
||||||
ret.subtype=k
|
ret.subtype=k
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ret.subtype==nil then
|
if ret.subtype==nil then
|
||||||
qerror("caste "..tokens[2].." for "..tokens[1].." not found")
|
qerror("caste "..tokens[2].." for "..tokens[1].." not found")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
qerror("Failed to find race:"..tokens[1])
|
qerror("Failed to find race:"..tokens[1])
|
||||||
end
|
end
|
||||||
-- add creature by id ("DWARF" or "DWARF:MALE")
|
-- add creature by id ("DWARF" or "DWARF:MALE")
|
||||||
-- supported flags:
|
-- supported flags:
|
||||||
function addCreature(id,transparency,emitance,radius,flags)
|
function addCreature(id,transparency,emitance,radius,flags)
|
||||||
local crId=creatureLookup(id)
|
local crId=creatureLookup(id)
|
||||||
local mat=makeMaterialDef(transparency,emitance,radius,flags)
|
local mat=makeMaterialDef(transparency,emitance,radius,flags)
|
||||||
table.insert(creatures,{race=crId.type,caste=crId.subtype or -1, light=mat})
|
table.insert(creatures,{race=crId.type,caste=crId.subtype or -1, light=mat})
|
||||||
end
|
end
|
||||||
-- add item by id ( "TOTEM" or "WEAPON:PICK" or "WEAPON" for all the weapon types)
|
-- add item by id ( "TOTEM" or "WEAPON:PICK" or "WEAPON" for all the weapon types)
|
||||||
-- supported flags:
|
-- supported flags:
|
||||||
-- hauling --active when hauled TODO::currently all mean same thing...
|
-- hauling --active when hauled TODO::currently all mean same thing...
|
||||||
-- equiped --active while equiped TODO::currently all mean same thing...
|
-- equiped --active while equiped TODO::currently all mean same thing...
|
||||||
-- inBuilding --active in building TODO::currently all mean same thing...
|
-- inBuilding --active in building TODO::currently all mean same thing...
|
||||||
-- contained --active in container TODO::currently all mean same thing...
|
-- contained --active in container TODO::currently all mean same thing...
|
||||||
-- onGround --active on ground
|
-- onGround --active on ground
|
||||||
-- useMaterial --uses material, but the defined things overwrite
|
-- useMaterial --uses material, but the defined things overwrite
|
||||||
function addItem(id,transparency,emitance,radius,flags)
|
function addItem(id,transparency,emitance,radius,flags)
|
||||||
local itemId=itemLookup(id)
|
local itemId=itemLookup(id)
|
||||||
local mat=makeMaterialDef(transparency,emitance,radius,flags)
|
local mat=makeMaterialDef(transparency,emitance,radius,flags)
|
||||||
table.insert(items,{["type"]=itemId.type,subtype=itemId.subtype,light=mat})
|
table.insert(items,{["type"]=itemId.type,subtype=itemId.subtype,light=mat})
|
||||||
end
|
end
|
||||||
-- add building by id (string e.g. "Statue" or "Workshop:Masons", flags is a table of strings
|
-- add building by id (string e.g. "Statue" or "Workshop:Masons", flags is a table of strings
|
||||||
-- supported flags:
|
-- supported flags:
|
||||||
-- useMaterial --uses material, but the defined things overwrite
|
-- useMaterial --uses material, but the defined things overwrite
|
||||||
-- poweredOnly --glow only when powered
|
-- poweredOnly --glow only when powered
|
||||||
function addBuilding(id,transparency,emitance,radius,flags,size,thickness)
|
function addBuilding(id,transparency,emitance,radius,flags,size,thickness)
|
||||||
size=size or 1
|
size=size or 1
|
||||||
thickness=thickness or 1
|
thickness=thickness or 1
|
||||||
local bld=buildingLookUp(id)
|
local bld=buildingLookUp(id)
|
||||||
local mat=makeMaterialDef(transparency,emitance,radius,flags)
|
local mat=makeMaterialDef(transparency,emitance,radius,flags)
|
||||||
mat.size=size
|
mat.size=size
|
||||||
mat.thickness=thickness
|
mat.thickness=thickness
|
||||||
buildings[bld.type]=buildings[bld.type] or {}
|
buildings[bld.type]=buildings[bld.type] or {}
|
||||||
if bld.subtype then
|
if bld.subtype then
|
||||||
if bld.custom then
|
if bld.custom then
|
||||||
buildings[bld.type][bld.subtype]=buildings[bld.type][bld.subtype] or {}
|
buildings[bld.type][bld.subtype]=buildings[bld.type][bld.subtype] or {}
|
||||||
buildings[bld.type][bld.subtype][bld.custom]=mat
|
buildings[bld.type][bld.subtype][bld.custom]=mat
|
||||||
else
|
else
|
||||||
buildings[bld.type][bld.subtype]={[-1]=mat}
|
buildings[bld.type][bld.subtype]={[-1]=mat}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
buildings[bld.type][-1]={[-1]=mat}
|
buildings[bld.type][-1]={[-1]=mat}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function makeMaterialDef(transparency,emitance,radius,flags)
|
function makeMaterialDef(transparency,emitance,radius,flags)
|
||||||
local flg
|
local flg
|
||||||
if flags then
|
if flags then
|
||||||
flg={}
|
flg={}
|
||||||
for k,v in ipairs(flags) do
|
for k,v in ipairs(flags) do
|
||||||
flg[v]=true
|
flg[v]=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return {tr=transparency,em=emitance,rad=radius,flags=flg}
|
return {tr=transparency,em=emitance,rad=radius,flags=flg}
|
||||||
end
|
end
|
||||||
function colorFrom16(col16)
|
function colorFrom16(col16)
|
||||||
local col=df.global.enabler.ccolor[col16]
|
local col=df.global.enabler.ccolor[col16]
|
||||||
return {col[0],col[1],col[2]}
|
return {col[0],col[1],col[2]}
|
||||||
end
|
end
|
||||||
function addGems()
|
function addGems()
|
||||||
for k,v in pairs(df.global.world.raws.inorganics) do
|
for k,v in pairs(df.global.world.raws.inorganics) do
|
||||||
if v.material.flags.IS_GEM then
|
if v.material.flags.IS_GEM then
|
||||||
addMaterial("INORGANIC:"..v.id,colorFrom16(v.material.tile_color[0]+v.material.tile_color[2]*8))
|
addMaterial("INORGANIC:"..v.id,colorFrom16(v.material.tile_color[0]+v.material.tile_color[2]*8))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
---------------- Configuration Starts Here -------------------------
|
---------------- Configuration Starts Here -------------------------
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
is_computer_quantum=false -- will enable more costly parts in the future
|
is_computer_quantum=false -- will enable more costly parts in the future
|
||||||
--special things
|
--special things
|
||||||
special.LAVA=makeMaterialDef({0.8,0.2,0.2},{0.8,0.2,0.2},5)
|
special.LAVA=makeMaterialDef({0.8,0.2,0.2},{0.8,0.2,0.2},5)
|
||||||
special.WATER=makeMaterialDef({0.5,0.5,0.8})
|
special.WATER=makeMaterialDef({0.5,0.5,0.8})
|
||||||
special.FROZEN_LIQUID=makeMaterialDef({0.2,0.7,0.9}) -- ice
|
special.FROZEN_LIQUID=makeMaterialDef({0.2,0.7,0.9}) -- ice
|
||||||
special.AMBIENT=makeMaterialDef({0.85,0.85,0.85}) --ambient fog
|
special.AMBIENT=makeMaterialDef({0.85,0.85,0.85}) --ambient fog
|
||||||
special.CURSOR=makeMaterialDef({1,1,1},{0.96,0.84,0.03},11, {"flicker"})
|
special.CURSOR=makeMaterialDef({1,1,1},{0.96,0.84,0.03},11, {"flicker"})
|
||||||
special.CITIZEN=makeMaterialDef(nil,{0.80,0.80,0.90},6)
|
special.CITIZEN=makeMaterialDef(nil,{0.80,0.80,0.90},6)
|
||||||
special.LevelDim=0.2 -- darkness. Do not set to 0
|
special.LevelDim=0.2 -- darkness. Do not set to 0
|
||||||
special.dayHour=-1 -- <0 cycle, else hour of the day
|
special.dayHour=-1 -- <0 cycle, else hour of the day
|
||||||
special.dayColors={ {0,0,0}, --dark at 0 hours
|
special.dayColors={ {0,0,0}, --dark at 0 hours
|
||||||
{0.6,0.5,0.5}, --reddish twilight
|
{0.6,0.5,0.5}, --reddish twilight
|
||||||
{1,1,1}, --fullbright at 12 hours
|
{1,1,1}, --fullbright at 12 hours
|
||||||
{0.5,0.5,0.5},
|
{0.5,0.5,0.5},
|
||||||
{0,0,0}} --dark at 24 hours
|
{0,0,0}} --dark at 24 hours
|
||||||
special.daySpeed=1 -- 1->1200 cur_year_ticks per day. 2->600 ticks
|
special.daySpeed=1 -- 1->1200 cur_year_ticks per day. 2->600 ticks
|
||||||
special.diffusionCount=1 -- split beam max 1 times to mimic diffuse lights
|
special.diffusionCount=1 -- split beam max 1 times to mimic diffuse lights
|
||||||
special.advMode=0 -- 1 or 0 different modes for adv mode. 0-> use df vision system,
|
special.advMode=0 -- 1 or 0 different modes for adv mode. 0-> use df vision system,
|
||||||
-- 1(does not work)->everything visible, let rendermax light do the work
|
-- 1(does not work)->everything visible, let rendermax light do the work
|
||||||
--TODO dragonfire
|
--TODO dragonfire
|
||||||
--materials
|
--materials
|
||||||
|
|
||||||
|
|
||||||
-- glasses
|
-- glasses
|
||||||
addMaterial("GLASS_GREEN",{0.1,0.9,0.5})
|
addMaterial("GLASS_GREEN",{0.1,0.9,0.5})
|
||||||
addMaterial("GLASS_CLEAR",{0.5,0.95,0.9})
|
addMaterial("GLASS_CLEAR",{0.5,0.95,0.9})
|
||||||
addMaterial("GLASS_CRYSTAL",{0.75,0.95,0.95})
|
addMaterial("GLASS_CRYSTAL",{0.75,0.95,0.95})
|
||||||
-- Plants
|
-- Plants
|
||||||
addMaterial("PLANT:TOWER_CAP",nil,{0.65,0.65,0.65},6)
|
addMaterial("PLANT:TOWER_CAP",nil,{0.65,0.65,0.65},6)
|
||||||
addMaterial("PLANT:MUSHROOM_CUP_DIMPLE",nil,{0.03,0.03,0.5},3)
|
addMaterial("PLANT:MUSHROOM_CUP_DIMPLE",nil,{0.03,0.03,0.5},3)
|
||||||
addMaterial("PLANT:CAVE MOSS",nil,{0.1,0.1,0.4},2)
|
addMaterial("PLANT:CAVE MOSS",nil,{0.1,0.1,0.4},2)
|
||||||
addMaterial("PLANT:MUSHROOM_HELMET_PLUMP",nil,{0.2,0.1,0.6},2)
|
addMaterial("PLANT:MUSHROOM_HELMET_PLUMP",nil,{0.2,0.1,0.6},2)
|
||||||
-- inorganics
|
-- inorganics
|
||||||
addMaterial("INORGANIC:ADAMANTINE",{0.1,0.3,0.3},{0.1,0.3,0.3},4)
|
addMaterial("INORGANIC:ADAMANTINE",{0.1,0.3,0.3},{0.1,0.3,0.3},4)
|
||||||
-- creature stuff
|
-- creature stuff
|
||||||
addMaterial("CREATURE:DRAGON:BLOOD",nil,{0.6,0.1,0.1},4)
|
addMaterial("CREATURE:DRAGON:BLOOD",nil,{0.6,0.1,0.1},4)
|
||||||
addGems()
|
addGems()
|
||||||
--buildings
|
--buildings
|
||||||
addBuilding("Statue",{1,1,1},{0.9,0.75,0.3},8)
|
addBuilding("Statue",{1,1,1},{0.9,0.75,0.3},8)
|
||||||
addBuilding("Bed",{1,1,1},{0.3,0.2,0.0},2)
|
addBuilding("Bed",{1,1,1},{0.3,0.2,0.0},2)
|
||||||
addBuilding("WindowGlass",nil,nil,0,{"useMaterial"})
|
addBuilding("WindowGlass",nil,nil,0,{"useMaterial"})
|
||||||
addBuilding("WindowGem",nil,nil,0,{"useMaterial"})
|
addBuilding("WindowGem",nil,nil,0,{"useMaterial"})
|
||||||
addBuilding("Door",nil,nil,0,{"useMaterial"}) -- special case, only closed door obstruct/emit light
|
addBuilding("Door",nil,nil,0,{"useMaterial"}) -- special case, only closed door obstruct/emit light
|
||||||
addBuilding("Floodgate",nil,nil,0,{"useMaterial"}) -- special case, only closed door obstruct/emit light
|
addBuilding("Floodgate",nil,nil,0,{"useMaterial"}) -- special case, only closed door obstruct/emit light
|
||||||
--creatures
|
--creatures
|
||||||
addCreature("ELEMENTMAN_MAGMA",{0.8,0.2,0.2},{0.8,0.2,0.2},5)
|
addCreature("ELEMENTMAN_MAGMA",{0.8,0.2,0.2},{0.8,0.2,0.2},5)
|
||||||
--items
|
--items
|
||||||
addItem("GEM",nil,nil,{"useMaterial","onGround"})
|
addItem("GEM",nil,nil,{"useMaterial","onGround"})
|
||||||
addItem("ROUGH",nil,nil,{"useMaterial","onGround"})
|
addItem("ROUGH",nil,nil,{"useMaterial","onGround"})
|
||||||
addItem("SMALLGEM",nil,nil,{"useMaterial","onGround"})
|
addItem("SMALLGEM",nil,nil,{"useMaterial","onGround"})
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue