Merge remote-tracking branch 'lethosor/lua-runcommand2' into scriptOrganization

develop
expwnent 2014-07-01 02:05:14 -04:00
commit d765de4546
7 changed files with 85 additions and 12 deletions

@ -222,7 +222,7 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
uintptr_t Process::getBase() uintptr_t Process::getBase()
{ {
return 0x1000000; return 0x1000;
} }
int Process::adjustOffset(int offset, bool /*to_file*/) int Process::adjustOffset(int offset, bool /*to_file*/)

@ -109,7 +109,7 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
{ {
mem->setOS(OS_APPLE); mem->setOS(OS_APPLE);
// this is wrong... I'm not going to do base image relocation on linux though. // this is wrong... I'm not going to do base image relocation on linux though.
mem->setBase(0x1000000); mem->setBase(0x1000);
} }
else else
{ {

@ -83,7 +83,27 @@ dfhack.exception.__index = dfhack.exception
-- Module loading -- Module loading
local function find_required_module_arg()
-- require -> module code -> mkmodule -> find_...
if debug.getinfo(4,'f').func == require then
return debug.getlocal(4, 1)
end
-- reload -> dofile -> module code -> mkmodule -> find_...
if debug.getinfo(5,'f').func == reload then
return debug.getlocal(5, 1)
end
end
function mkmodule(module,env) function mkmodule(module,env)
-- Verify that the module name is correct
local _, rq_modname = find_required_module_arg()
if not rq_modname then
error('The mkmodule function must be used at the start of a module')
end
if rq_modname ~= module then
error('Found module '..module..' during require '..rq_modname)
end
-- Reuse the already loaded module table
local pkg = package.loaded[module] local pkg = package.loaded[module]
if pkg == nil then if pkg == nil then
pkg = {} pkg = {}
@ -92,6 +112,7 @@ function mkmodule(module,env)
error("Not a table in package.loaded["..module.."]") error("Not a table in package.loaded["..module.."]")
end end
end end
-- Inject the plugin-exported functions when appropriate
local plugname = string.match(module,'^plugins%.([%w%-]+)$') local plugname = string.match(module,'^plugins%.([%w%-]+)$')
if plugname then if plugname then
dfhack.open_plugin(pkg,plugname) dfhack.open_plugin(pkg,plugname)
@ -366,7 +387,7 @@ function dfhack.run_script(name,...)
return f(...) return f(...)
end end
function dfhack.run_command(...) local function _run_command(...)
args = {...} args = {...}
if type(args[1]) == 'table' then if type(args[1]) == 'table' then
command = args[1] command = args[1]
@ -381,8 +402,12 @@ function dfhack.run_command(...)
else else
error('Invalid arguments') error('Invalid arguments')
end end
result = internal.runCommand(command) return internal.runCommand(command)
output = "" end
function dfhack.run_command_silent(...)
local result = _run_command(...)
local output = ""
for i, f in pairs(result) do for i, f in pairs(result) do
if type(f) == 'table' then if type(f) == 'table' then
output = output .. f[2] output = output .. f[2]
@ -391,6 +416,17 @@ function dfhack.run_command(...)
return output, result.status return output, result.status
end end
function dfhack.run_command(...)
local output, status = _run_command(...)
for i, fragment in pairs(output) do
if type(fragment) == 'table' then
dfhack.color(fragment[1])
dfhack.print(fragment[2])
end
end
dfhack.color(COLOR_RESET)
end
-- Per-save init file -- Per-save init file
function dfhack.getSavePath() function dfhack.getSavePath()

@ -1 +1 @@
Subproject commit 36e0b203de64dbd57deb39ca849fffc66cad8f54 Subproject commit 8c0d23090539be98bc9c67b9070cbe080383ae9f

@ -0,0 +1,20 @@
see linux patch for info
- .text:00111776 jnz loc_111750
+ .text:00111776 nop
+ .text:00111777 nop
sub_660360
osx stores pointer in edi instead of ebx
- .text:006612C3 mov eax, [eax+edx*4]
+ .text:006612C3 mov edi, [eax+edx*4]
- .text:006612CD mov eax, [eax+74h]
+ .text:006612CD mov eax, [edi+74h]
---8<---
Dwarf_Fortress
00110776: 75 90
00110777: D8 90
006602C4: 04 3C
006602CE: 40 47

@ -191,6 +191,11 @@ void sticky_save (df::viewscreen_choose_start_sitest * screen)
void sticky_apply (df::viewscreen_choose_start_sitest * screen) void sticky_apply (df::viewscreen_choose_start_sitest * screen)
{ {
if (screen->finder.finder_state != -1)
{
// Site finder is active - don't override default local position
return;
}
screen->embark_pos_min.x = sticky_pos[0]; screen->embark_pos_min.x = sticky_pos[0];
screen->embark_pos_max.x = sticky_pos[1]; screen->embark_pos_max.x = sticky_pos[1];
screen->embark_pos_min.y = sticky_pos[2]; screen->embark_pos_min.y = sticky_pos[2];

@ -26,6 +26,8 @@
#include "df/creature_graphics_role.h" #include "df/creature_graphics_role.h"
#include "df/creature_raw.h" #include "df/creature_raw.h"
#include "df/caste_raw.h" #include "df/caste_raw.h"
#include "df/historical_entity.h"
#include "df/entity_raw.h"
using std::set; using std::set;
using std::vector; using std::vector;
@ -82,6 +84,14 @@ struct SkillColumn
df::job_skill skill; // displayed rating df::job_skill skill; // displayed rating
char label[3]; // column header char label[3]; // column header
bool special; // specified labor is mutually exclusive with all other special labors bool special; // specified labor is mutually exclusive with all other special labors
bool isValidLabor (df::historical_entity *entity = NULL) const
{
if (labor == unit_labor::NONE)
return false;
if (entity && entity->entity_raw && !entity->entity_raw->jobs.permitted_labor[labor])
return false;
return true;
}
}; };
#define NUM_COLUMNS (sizeof(columns) / sizeof(SkillColumn)) #define NUM_COLUMNS (sizeof(columns) / sizeof(SkillColumn))
@ -851,7 +861,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
} }
UnitInfo *cur = units[input_row]; UnitInfo *cur = units[input_row];
if (events->count(interface_key::SELECT) && (cur->allowEdit) && (columns[input_column].labor != unit_labor::NONE)) if (events->count(interface_key::SELECT) && (cur->allowEdit) && columns[input_column].isValidLabor(ui->main.fortress_entity))
{ {
df::unit *unit = cur->unit; df::unit *unit = cur->unit;
const SkillColumn &col = columns[input_column]; const SkillColumn &col = columns[input_column];
@ -870,15 +880,17 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
} }
unit->status.labors[col.labor] = newstatus; unit->status.labors[col.labor] = newstatus;
} }
if (events->count(interface_key::SELECT_ALL) && (cur->allowEdit)) if (events->count(interface_key::SELECT_ALL) && (cur->allowEdit) && columns[input_column].isValidLabor(ui->main.fortress_entity))
{ {
df::unit *unit = cur->unit; df::unit *unit = cur->unit;
const SkillColumn &col = columns[input_column]; const SkillColumn &col = columns[input_column];
bool newstatus = (col.labor == unit_labor::NONE) ? true : !unit->status.labors[col.labor]; bool newstatus = !unit->status.labors[col.labor];
for (int i = 0; i < NUM_COLUMNS; i++) for (int i = 0; i < NUM_COLUMNS; i++)
{ {
if (columns[i].group != col.group) if (columns[i].group != col.group)
continue; continue;
if (!columns[i].isValidLabor(ui->main.fortress_entity))
continue;
if (columns[i].special) if (columns[i].special)
{ {
if (newstatus) if (newstatus)
@ -912,7 +924,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
std::sort(units.begin(), units.end(), sortByName); std::sort(units.begin(), units.end(), sortByName);
break; break;
case ALTSORT_PROFESSION_OR_SQUAD: case ALTSORT_PROFESSION_OR_SQUAD:
std::sort(units.begin(), units.end(), show_squad ? sortBySquad : sortByProfession); std::sort(units.begin(), units.end(), show_squad ? sortBySquad : sortByProfession);
break; break;
case ALTSORT_HAPPINESS: case ALTSORT_HAPPINESS:
std::sort(units.begin(), units.end(), sortByHappiness); std::sort(units.begin(), units.end(), sortByHappiness);
@ -1175,7 +1187,7 @@ void viewscreen_unitlaborsst::render()
} }
canToggle = (cur->allowEdit) && (columns[sel_column].labor != unit_labor::NONE); canToggle = (cur->allowEdit) && columns[sel_column].isValidLabor(ui->main.fortress_entity);
} }
int x = 2, y = dim.y - 3; int x = 2, y = dim.y - 3;
@ -1213,7 +1225,7 @@ void viewscreen_unitlaborsst::render()
OutputString(15, x, y, "Name"); OutputString(15, x, y, "Name");
break; break;
case ALTSORT_PROFESSION_OR_SQUAD: case ALTSORT_PROFESSION_OR_SQUAD:
OutputString(15, x, y, show_squad ? "Squad" : "Profession"); OutputString(15, x, y, show_squad ? "Squad" : "Profession");
break; break;
case ALTSORT_HAPPINESS: case ALTSORT_HAPPINESS:
OutputString(15, x, y, "Happiness"); OutputString(15, x, y, "Happiness");