Quietust 2012-11-16 21:15:38 -06:00
commit 1ab48aa2de
5 changed files with 25 additions and 10 deletions

@ -12,6 +12,7 @@ DFHack future
- removebadthoughts: add --dry-run option - removebadthoughts: add --dry-run option
New tweaks: New tweaks:
- tweak military-training: speed up melee squad training up to 10x (depends on unit count). - tweak military-training: speed up melee squad training up to 10x (depends on unit count).
- superdwarf: work in adventure mode too
New scripts: New scripts:
- binpatch: the same as the stand-alone binpatch.exe, but works at runtime. - binpatch: the same as the stand-alone binpatch.exe, but works at runtime.
- region-pops: displays animal populations of the region and allows tweaking them. - region-pops: displays animal populations of the region and allows tweaking them.

@ -484,28 +484,28 @@ void* Process::memAlloc(const int length)
return ret; return ret;
} }
int Process::memDealloc(const void *ptr, const int length) int Process::memDealloc(void *ptr, const int length)
{ {
// can only free the whole region at once // can only free the whole region at once
// vfree returns 0 on error // vfree returns 0 on error
return !VirtualFree(ptr, 0, MEM_RELEASE) return !VirtualFree(ptr, 0, MEM_RELEASE);
} }
int Process::memProtect(const void *ptr, const int length, const int prot) int Process::memProtect(void *ptr, const int length, const int prot)
{ {
int prot_native = 0; int prot_native = 0;
int old_prot = 0; DWORD old_prot = 0;
// only support a few constant combinations // only support a few constant combinations
if (prot == 0) if (prot == 0)
prot_native = PAGE_NOACCESS; prot_native = PAGE_NOACCESS;
else if (prot == Process::MemProt::READ) else if (prot == Process::MemProt::READ)
prot_native = PAGE_READONLY; prot_native = PAGE_READONLY;
else if (prot == Process::MemProt::READ | Process::MemProt::WRITE) else if (prot == (Process::MemProt::READ | Process::MemProt::WRITE))
prot_native = PAGE_READWRITE; prot_native = PAGE_READWRITE;
else if (prot == Process::MemProt::READ | Process::MemProt::WRITE | Process::MemProt::EXECUTE) else if (prot == (Process::MemProt::READ | Process::MemProt::WRITE | Process::MemProt::EXEC))
prot_native = PAGE_EXECUTE_READWRITE; prot_native = PAGE_EXECUTE_READWRITE;
else if (prot == Process::MemProt::READ | Process::MemProt::EXECUTE) else if (prot == (Process::MemProt::READ | Process::MemProt::EXEC))
prot_native = PAGE_EXECUTE_READ; prot_native = PAGE_EXECUTE_READ;
else else
return -1; return -1;

@ -964,7 +964,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else if (building_type::TradeDepot == type) else if (building_type::TradeDepot == type)
{ {
df::building_tradedepotst* depot = (df::building_tradedepotst*) build; df::building_tradedepotst* depot = (df::building_tradedepotst*) build;
trader_requested = depot->trade_flags.bits.trader_requested; trader_requested = trader_requested || depot->trade_flags.bits.trader_requested;
if (print_debug) if (print_debug)
{ {
if (trader_requested) if (trader_requested)

@ -21,7 +21,7 @@ module DFHack
when :SelectTrainer when :SelectTrainer
v.trainer_unit[v.trainer_cursor] v.trainer_unit[v.trainer_cursor]
end end
else when :viewscreen_dwarfmodest
case ui.main.mode case ui.main.mode
when :ViewUnits when :ViewUnits
# nobody selected => idx == 0 # nobody selected => idx == 0
@ -33,6 +33,15 @@ module DFHack
else else
ui.follow_unit_tg if ui.follow_unit != -1 ui.follow_unit_tg if ui.follow_unit != -1
end end
when :viewscreen_dungeonmodest
case ui_advmode.menu
when :Default
world.units.active[0]
else
unit_find(cursor) # XXX
end
when :viewscreen_dungeon_monsterstatusst
curview.unit
end end
elsif what.kind_of?(Integer) elsif what.kind_of?(Integer)
# search by id # search by id

@ -8,7 +8,12 @@ when 'add'
if u = df.unit_find if u = df.unit_find
$superdwarf_ids |= [u.id] $superdwarf_ids |= [u.id]
$superdwarf_onupdate ||= df.onupdate_register(1) { if df.gamemode == :ADVENTURE
onupdate_delay = nil
else
onupdate_delay = 1
end
$superdwarf_onupdate ||= df.onupdate_register(onupdate_delay) {
if $superdwarf_ids.empty? if $superdwarf_ids.empty?
df.onupdate_unregister($superdwarf_onupdate) df.onupdate_unregister($superdwarf_onupdate)
$superdwarf_onupdate = nil $superdwarf_onupdate = nil