More removing unneeded fixes.

develop
expwnent 2014-08-15 04:22:34 -04:00
parent 820839fa8d
commit ce4d1db5a0
4 changed files with 7 additions and 243 deletions

@ -129,20 +129,10 @@ tweak stable-cursor
# stop military from considering training as 'patrol duty'
tweak patrol-duty
# display creature weight in build plate menu as ??K, instead of (???df: Max
tweak readable-build-plate
# improve FPS by squashing endless item temperature update loops
# tweak stable-temp
# speed up items reaching temp equilibrium with environment by
# capping the rate to no less than 1 degree change per 500 frames
# Note: will also cause stuff to melt faster in magma etc
# tweak fast-heat 500
# stop stacked liquid/bar/thread/cloth items from lasting forever
# if used in reactions that use only a fraction of the dimension.
tweak fix-dimensions
# might be fixed by DF
# tweak fix-dimensions
# make reactions requiring containers usable in advmode - the issue is
# that the screen asks for those reagents to be selected directly
@ -160,9 +150,6 @@ tweak military-color-assigned
# remove inverse dependency of squad training speed on unit list size and use more sparring
# tweak military-training
# prevent crash if bees die in a hive with ungathered products by insta-gathering them
tweak hive-crash
# make crafted cloth items wear out with time like in old versions (bug 6003)
tweak craft-age-wear
@ -201,15 +188,6 @@ soundsense-season
# write identifying information about the fort to gamelog on world load
log-region
# patch the material objects in memory to fix cloth stockpiles
fix/cloth-stockpile enable
# civs don't bring blood
#:lua dfhack.onStateChange.onLoadBloodDel = function(state) if state == SC_WORLD_LOADED then dfhack.run_command('repeat -time 1 -timeUnits months -command fix/blood-del') end end
# run growth bug regularly
#:lua dfhack.onStateChange.onLoadGrowthBug = function(state) if state == SC_WORLD_LOADED then dfhack.run_command('repeat -time 1 -timeUnits months -command fix/growth-bug') end end
#######################################################
# Apply binary patches at runtime #
#######################################################

@ -65,7 +65,7 @@
#include "df/activity_event_individual_skill_drillst.h"
#include "df/activity_event_skill_demonstrationst.h"
#include "df/activity_event_sparringst.h"
#include "df/building_hivest.h"
//#include "df/building_hivest.h"
#include <stdlib.h>
@ -119,8 +119,6 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Causes 'Train' orders to no longer be considered 'patrol duty' so\n"
" soldiers will stop getting unhappy thoughts. Does NOT fix the problem\n"
" when soldiers go off-duty (i.e. civilian).\n"
" tweak readable-build-plate [disable]\n"
" Fixes rendering of creature weight limits in pressure plate build menu.\n"
" tweak confirm-embark [disable]\n"
" Asks for confirmation on the embark setup screen before embarking\n"
" tweak stable-temp [disable]\n"
@ -129,9 +127,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Further improves temperature updates by ensuring that 1 degree of\n"
" item temperature is crossed in no more than specified number of frames\n"
" when updating from the environment temperature. Use 0 to disable.\n"
" tweak fix-dimensions [disable]\n"
/*" tweak fix-dimensions [disable]\n"
" Fixes subtracting small amount of thread/cloth/liquid from a stack\n"
" by splitting the stack and subtracting from the remaining single item.\n"
" by splitting the stack and subtracting from the remaining single item.\n"*/
" tweak advmode-contained [disable]\n"
" Fixes custom reactions with container inputs in advmode. The issue is\n"
" that the screen tries to force you to select the contents separately\n"
@ -148,8 +146,6 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" to make them stand out more in the list.\n"
// " tweak military-training [disable]\n"
// " Speed up melee squad training, removing inverse dependency on unit count.\n"
" tweak hive-crash [disable]\n"
" Prevents crash if bees die in a hive with uncollected products (bug 6368).\n"
" tweak craft-age-wear [disable]\n"
" Makes cloth and leather items wear out at the correct rate (bug 6003).\n"
" tweak adamantine-cloth-wear [disable]\n"
@ -302,38 +298,6 @@ struct patrol_duty_hook : df::squad_order_trainst
IMPLEMENT_VMETHOD_INTERPOSE(patrol_duty_hook, isPatrol);
struct readable_build_plate_hook : df::viewscreen_dwarfmodest
{
typedef df::viewscreen_dwarfmodest interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, render, ())
{
INTERPOSE_NEXT(render)();
if (ui->main.mode == ui_sidebar_mode::Build &&
ui_build_selector->stage == 1 &&
ui_build_selector->building_type == building_type::Trap &&
ui_build_selector->building_subtype == trap_type::PressurePlate &&
ui_build_selector->plate_info.flags.bits.units)
{
auto dims = Gui::getDwarfmodeViewDims();
int x = dims.menu_x1;
Screen::Pen pen(' ',COLOR_WHITE);
int minv = ui_build_selector->plate_info.unit_min;
if ((minv % 1000) == 0)
Screen::paintString(pen, x+11, 14, stl_sprintf("%3dK ", minv/1000));
int maxv = ui_build_selector->plate_info.unit_max;
if (maxv < 200000 && (maxv % 1000) == 0)
Screen::paintString(pen, x+24, 14, stl_sprintf("%3dK ", maxv/1000));
}
}
};
IMPLEMENT_VMETHOD_INTERPOSE(readable_build_plate_hook, render);
enum confirm_embark_states
{
ECS_INACTIVE = 0,
@ -1043,47 +1007,6 @@ struct military_training_id_hook : df::activity_event_individual_skill_drillst {
IMPLEMENT_VMETHOD_INTERPOSE(military_training_id_hook, process);
*/
struct hive_crash_hook : df::building_hivest {
typedef df::building_hivest interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, updateAction, ())
{
bool any_bees = false;
for (size_t i = 0; i < contained_items.size(); i++)
{
if (contained_items[i]->item->getType() != item_type::VERMIN)
continue;
any_bees = true;
break;
}
if (!any_bees)
{
bool any_products = false;
for (size_t i = 0; i < contained_items.size(); i++)
{
if (contained_items[i]->use_mode != 0 ||
!contained_items[i]->item->flags.bits.in_building)
continue;
contained_items[i]->item->flags.bits.in_building = false;
any_products = true;
}
if (any_products)
{
color_ostream_proxy out(Core::getInstance().getConsole());
out.print("Bees died in hive with products at (%d,%d,%d); preventing crash.\n",
centerx, centery, z);
}
}
INTERPOSE_NEXT(updateAction)();
}
};
IMPLEMENT_VMETHOD_INTERPOSE(hive_crash_hook, updateAction);
struct craft_age_wear_hook : df::item_crafted {
typedef df::item_crafted interpose_base;
@ -1302,16 +1225,6 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
{
enable_hook(out, INTERPOSE_HOOK(patrol_duty_hook, isPatrol), parameters);
}
else if (cmd == "readable-build-plate")
{
if (!ui_build_selector || !ui_menu_width || !ui_area_map_width)
{
out.printerr("Necessary globals not known.\n");
return CR_FAILURE;
}
enable_hook(out, INTERPOSE_HOOK(readable_build_plate_hook, render), parameters);
}
else if (cmd == "confirm-embark")
{
enable_hook(out, INTERPOSE_HOOK(confirm_embark_hook, feed), parameters);
@ -1334,14 +1247,14 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
enable_hook(out, INTERPOSE_HOOK(fast_heat_hook, updateTemperature), parameters);
enable_hook(out, INTERPOSE_HOOK(fast_heat_hook, adjustTemperature), parameters);
}
else if (cmd == "fix-dimensions")
/*else if (cmd == "fix-dimensions")
{
enable_hook(out, INTERPOSE_HOOK(dimension_liquid_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_powder_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_bar_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_thread_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_cloth_hook, subtractDimension), parameters);
}
}*/
else if (cmd == "advmode-contained")
{
enable_hook(out, INTERPOSE_HOOK(advmode_contained_hook, feed), parameters);
@ -1367,10 +1280,6 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
enable_hook(out, INTERPOSE_HOOK(military_training_sp_hook, process), parameters);
enable_hook(out, INTERPOSE_HOOK(military_training_id_hook, process), parameters);
}*/
else if (cmd == "hive-crash")
{
enable_hook(out, INTERPOSE_HOOK(hive_crash_hook, updateAction), parameters);
}
else if (cmd == "craft-age-wear")
{
enable_hook(out, INTERPOSE_HOOK(craft_age_wear_hook, ageItem), parameters);

@ -1,88 +0,0 @@
-- Fixes cloth/thread stockpiles by correcting material object data.
local raws = df.global.world.raws
-- Cache references to vectors in lua tables for a speed-up
local organic_types = {}
for i,v in ipairs(raws.mat_table.organic_types) do
organic_types[i] = v
end
local organic_indexes = {}
for i,v in ipairs(raws.mat_table.organic_indexes) do
organic_indexes[i] = v
end
local function verify(category,idx,vtype,vidx)
if idx == -1 then
-- Purely for reporting reasons
return true
end
local tvec = organic_types[category]
if idx < 0 or idx >= #tvec or tvec[idx] ~= vtype then
return false
end
return organic_indexes[category][idx] == vidx
end
local patched_cnt = 0
local mat_cnt = 0
function patch_material(mat,mat_type,mat_index)
local idxarr = mat.food_mat_index
-- These refer to fish/eggs, i.e. castes and not materials
idxarr[1] = -1
idxarr[2] = -1
idxarr[3] = -1
for i = 0,#idxarr-1 do
if not verify(i,idxarr[i],mat_type,mat_index) then
idxarr[i] = -1
patched_cnt = patched_cnt+1
end
end
mat_cnt = mat_cnt + 1
end
function patch_materials()
patched_cnt = 0
mat_cnt = 0
print('Fixing cloth stockpile handling (bug 5739)...')
for i,v in ipairs(raws.inorganics) do
patch_material(v.material, 0, i)
end
for i,v in ipairs(raws.creatures.all) do
for j,m in ipairs(v.material) do
patch_material(m, 19+j, i)
end
end
for i,v in ipairs(raws.plants.all) do
for j,m in ipairs(v.material) do
patch_material(m, 419+j, i)
end
end
print('Patched '..patched_cnt..' bad references in '..mat_cnt..' materials.')
end
local args = {...}
if args[1] == 'enable' then
dfhack.onStateChange[_ENV] = function(sc)
if sc == SC_WORLD_LOADED then
patch_materials()
end
end
if dfhack.isWorldLoaded() then
patch_materials()
end
elseif args[1] == 'disable' then
dfhack.onStateChange[_ENV] = nil
else
patch_materials()
end

@ -1,35 +0,0 @@
--growth-bug.lua: units only grow when the current tick is 0 mod 10, so only 1/10 units will grow naturally. this script periodically sets the birth time of each unit so that it will grow
--to run periodically, use "repeat -time 2 months -command fix/growth-bug -now". see repeat.lua for details
--author expwnent
local utils = require 'utils'
validArgs = validArgs or utils.invert({
'help',
'now'
})
local args = utils.processArgs({...}, validArgs)
if args.help or not next(args) then
print("fix/growth-bug usage")
print(" fix/growth-bug")
print(" fix the growth bug for all units on the map")
print(" fix/growth-bug -help")
print(" print this help message")
print(" repeat -time [n] [years/months/ticks/days/etc] -command fix/growth-bug now")
print(" run this script every n time units")
print(" repeat -cancel fix/growth-bug")
print(" stop automatically running this script")
end
local count = 0
for _,unit in ipairs(df.global.world.units.all) do
local offset = unit.relations.birth_time % 10;
if offset ~= 0 then
unit.relations.birth_time = unit.relations.birth_time - offset
count = count+1
end
end
print("Fixed growth bug for "..count.." units.")