diff --git a/library/Process-darwin.cpp b/library/Process-darwin.cpp index 30ed709b8..69ccefcea 100644 --- a/library/Process-darwin.cpp +++ b/library/Process-darwin.cpp @@ -222,7 +222,7 @@ void Process::getMemRanges( vector & ranges ) uintptr_t Process::getBase() { - return 0x1000000; + return 0x1000; } int Process::adjustOffset(int offset, bool /*to_file*/) diff --git a/library/VersionInfoFactory.cpp b/library/VersionInfoFactory.cpp index 7142233d8..1b66b583a 100644 --- a/library/VersionInfoFactory.cpp +++ b/library/VersionInfoFactory.cpp @@ -109,7 +109,7 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem) { mem->setOS(OS_APPLE); // this is wrong... I'm not going to do base image relocation on linux though. - mem->setBase(0x1000000); + mem->setBase(0x1000); } else { diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index 3cc98e882..e50cee995 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -83,7 +83,27 @@ dfhack.exception.__index = dfhack.exception -- 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) + -- 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] if pkg == nil then pkg = {} @@ -92,6 +112,7 @@ function mkmodule(module,env) error("Not a table in package.loaded["..module.."]") end end + -- Inject the plugin-exported functions when appropriate local plugname = string.match(module,'^plugins%.([%w%-]+)$') if plugname then dfhack.open_plugin(pkg,plugname) @@ -366,7 +387,7 @@ function dfhack.run_script(name,...) return f(...) end -function dfhack.run_command(...) +local function _run_command(...) args = {...} if type(args[1]) == 'table' then command = args[1] @@ -381,8 +402,12 @@ function dfhack.run_command(...) else error('Invalid arguments') end - result = internal.runCommand(command) - output = "" + return internal.runCommand(command) +end + +function dfhack.run_command_silent(...) + local result = _run_command(...) + local output = "" for i, f in pairs(result) do if type(f) == 'table' then output = output .. f[2] @@ -391,6 +416,17 @@ function dfhack.run_command(...) return output, result.status 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 function dfhack.getSavePath() diff --git a/library/xml b/library/xml index 36e0b203d..8c0d23090 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 36e0b203de64dbd57deb39ca849fffc66cad8f54 +Subproject commit 8c0d23090539be98bc9c67b9070cbe080383ae9f diff --git a/patches/v0.34.11 osx/hospital-overstocking.dif b/patches/v0.34.11 osx/hospital-overstocking.dif new file mode 100644 index 000000000..85aade42b --- /dev/null +++ b/patches/v0.34.11 osx/hospital-overstocking.dif @@ -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 diff --git a/plugins/embark-tools.cpp b/plugins/embark-tools.cpp index 2953f83f3..6c888ee7e 100644 --- a/plugins/embark-tools.cpp +++ b/plugins/embark-tools.cpp @@ -191,6 +191,11 @@ void sticky_save (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_max.x = sticky_pos[1]; screen->embark_pos_min.y = sticky_pos[2]; diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 4f22a44be..5d36dcd5b 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -26,6 +26,8 @@ #include "df/creature_graphics_role.h" #include "df/creature_raw.h" #include "df/caste_raw.h" +#include "df/historical_entity.h" +#include "df/entity_raw.h" using std::set; using std::vector; @@ -82,6 +84,14 @@ struct SkillColumn df::job_skill skill; // displayed rating char label[3]; // column header 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)) @@ -851,7 +861,7 @@ void viewscreen_unitlaborsst::feed(set *events) } 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; const SkillColumn &col = columns[input_column]; @@ -870,15 +880,17 @@ void viewscreen_unitlaborsst::feed(set *events) } 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; 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++) { if (columns[i].group != col.group) continue; + if (!columns[i].isValidLabor(ui->main.fortress_entity)) + continue; if (columns[i].special) { if (newstatus) @@ -912,7 +924,7 @@ void viewscreen_unitlaborsst::feed(set *events) std::sort(units.begin(), units.end(), sortByName); break; 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; case ALTSORT_HAPPINESS: 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; @@ -1213,7 +1225,7 @@ void viewscreen_unitlaborsst::render() OutputString(15, x, y, "Name"); break; case ALTSORT_PROFESSION_OR_SQUAD: - OutputString(15, x, y, show_squad ? "Squad" : "Profession"); + OutputString(15, x, y, show_squad ? "Squad" : "Profession"); break; case ALTSORT_HAPPINESS: OutputString(15, x, y, "Happiness");