2012-03-05 08:47:06 -07:00
|
|
|
// A container for random minor tweaks that don't fit anywhere else,
|
|
|
|
// in order to avoid creating lots of plugins and polluting the namespace.
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
|
|
|
#include "modules/Gui.h"
|
2012-08-30 10:48:06 -06:00
|
|
|
#include "modules/Screen.h"
|
2012-04-11 13:07:54 -06:00
|
|
|
#include "modules/Units.h"
|
|
|
|
#include "modules/Items.h"
|
2012-10-28 11:13:28 -06:00
|
|
|
#include "modules/Job.h"
|
2014-05-08 13:22:45 -06:00
|
|
|
#include "modules/Materials.h"
|
2012-03-05 08:47:06 -07:00
|
|
|
|
2012-04-12 06:40:39 -06:00
|
|
|
#include "MiscUtils.h"
|
|
|
|
|
2012-03-05 08:47:06 -07:00
|
|
|
#include "DataDefs.h"
|
2012-08-26 11:19:56 -06:00
|
|
|
#include <VTableInterpose.h>
|
2012-03-05 08:47:06 -07:00
|
|
|
#include "df/ui.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/squad.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
#include "df/unit_soul.h"
|
|
|
|
#include "df/historical_entity.h"
|
|
|
|
#include "df/historical_figure.h"
|
|
|
|
#include "df/historical_figure_info.h"
|
2014-07-29 15:30:22 -06:00
|
|
|
#include "df/identity.h"
|
2012-03-05 08:47:06 -07:00
|
|
|
#include "df/language_name.h"
|
2014-07-29 15:26:14 -06:00
|
|
|
#include "df/incident.h"
|
2014-07-29 15:27:16 -06:00
|
|
|
#include "df/crime.h"
|
2012-04-11 13:07:54 -06:00
|
|
|
#include "df/unit_inventory_item.h"
|
2012-08-26 11:19:56 -06:00
|
|
|
#include "df/viewscreen_dwarfmodest.h"
|
2012-09-18 07:39:37 -06:00
|
|
|
#include "df/viewscreen_layer_unit_actionst.h"
|
2012-08-27 13:06:10 -06:00
|
|
|
#include "df/squad_order_trainst.h"
|
2012-08-30 10:48:06 -06:00
|
|
|
#include "df/ui_build_selector.h"
|
|
|
|
#include "df/building_trapst.h"
|
2012-09-03 11:11:35 -06:00
|
|
|
#include "df/item_actual.h"
|
2014-05-08 13:22:45 -06:00
|
|
|
#include "df/item_crafted.h"
|
|
|
|
#include "df/item_armorst.h"
|
|
|
|
#include "df/item_helmst.h"
|
|
|
|
#include "df/item_glovesst.h"
|
|
|
|
#include "df/item_shoesst.h"
|
|
|
|
#include "df/item_pantsst.h"
|
2012-10-10 08:22:01 -06:00
|
|
|
#include "df/item_liquid_miscst.h"
|
|
|
|
#include "df/item_powder_miscst.h"
|
2012-09-17 07:19:24 -06:00
|
|
|
#include "df/item_barst.h"
|
|
|
|
#include "df/item_threadst.h"
|
|
|
|
#include "df/item_clothst.h"
|
2012-09-03 11:11:35 -06:00
|
|
|
#include "df/contaminant.h"
|
2012-09-18 07:39:37 -06:00
|
|
|
#include "df/layer_object.h"
|
|
|
|
#include "df/reaction.h"
|
|
|
|
#include "df/reaction_reagent_itemst.h"
|
|
|
|
#include "df/reaction_reagent_flags.h"
|
2014-06-03 16:29:13 -06:00
|
|
|
#include "df/viewscreen_setupdwarfgamest.h"
|
2012-09-28 03:32:41 -06:00
|
|
|
#include "df/viewscreen_layer_assigntradest.h"
|
|
|
|
#include "df/viewscreen_tradegoodsst.h"
|
2012-09-28 08:01:17 -06:00
|
|
|
#include "df/viewscreen_layer_militaryst.h"
|
2012-10-26 13:30:44 -06:00
|
|
|
#include "df/squad_position.h"
|
2012-10-28 11:13:28 -06:00
|
|
|
#include "df/job.h"
|
|
|
|
#include "df/general_ref_building_holderst.h"
|
2012-11-16 11:51:07 -07:00
|
|
|
#include "df/unit_health_info.h"
|
|
|
|
#include "df/activity_entry.h"
|
|
|
|
#include "df/activity_event_combat_trainingst.h"
|
|
|
|
#include "df/activity_event_individual_skill_drillst.h"
|
|
|
|
#include "df/activity_event_skill_demonstrationst.h"
|
|
|
|
#include "df/activity_event_sparringst.h"
|
2014-08-15 02:22:34 -06:00
|
|
|
//#include "df/building_hivest.h"
|
2012-03-05 08:47:06 -07:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-10-08 07:41:49 -06:00
|
|
|
using std::set;
|
2012-03-05 08:47:06 -07:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using std::endl;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
|
|
|
|
using df::global::ui;
|
|
|
|
using df::global::world;
|
2012-08-30 10:48:06 -06:00
|
|
|
using df::global::ui_build_selector;
|
|
|
|
using df::global::ui_menu_width;
|
|
|
|
using df::global::ui_area_map_width;
|
2012-03-05 08:47:06 -07:00
|
|
|
|
|
|
|
using namespace DFHack::Gui;
|
2012-09-28 08:01:17 -06:00
|
|
|
using Screen::Pen;
|
2012-03-05 08:47:06 -07:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
static command_result tweak(color_ostream &out, vector <string> & parameters);
|
2012-03-05 08:47:06 -07:00
|
|
|
|
|
|
|
DFHACK_PLUGIN("tweak");
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
|
2012-03-05 08:47:06 -07:00
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"tweak", "Various tweaks for minor bugs.", tweak, false,
|
|
|
|
" tweak clear-missing\n"
|
|
|
|
" Remove the missing status from the selected unit.\n"
|
2012-03-22 09:30:15 -06:00
|
|
|
" tweak clear-ghostly\n"
|
|
|
|
" Remove the ghostly status from the selected unit.\n"
|
|
|
|
" Intended to fix the case where you can't engrave memorials for ghosts.\n"
|
|
|
|
" Note that this is very dirty and possibly dangerous!\n"
|
|
|
|
" Most probably does not have the positive effect of a proper burial.\n"
|
2012-04-11 14:29:56 -06:00
|
|
|
" tweak fixmigrant\n"
|
2012-04-17 20:12:11 -06:00
|
|
|
" Remove the resident/merchant flag from the selected unit.\n"
|
|
|
|
" Intended to fix bugged migrants/traders who stay at the\n"
|
|
|
|
" map edge and don't enter your fort. Only works for\n"
|
|
|
|
" dwarves (or generally the player's race in modded games).\n"
|
|
|
|
" tweak makeown\n"
|
|
|
|
" Force selected unit to become a member of your fort.\n"
|
|
|
|
" Can be abused to grab caravan merchants and escorts, even if\n"
|
|
|
|
" they don't belong to the player's race. Foreign sentients\n"
|
|
|
|
" (humans, elves) can be put to work, but you can't assign rooms\n"
|
|
|
|
" to them and they don't show up in DwarfTherapist because the\n"
|
|
|
|
" game treats them like pets.\n"
|
2012-08-26 11:19:56 -06:00
|
|
|
" tweak stable-cursor [disable]\n"
|
|
|
|
" Keeps exact position of dwarfmode cursor during exits to main menu.\n"
|
|
|
|
" E.g. allows switching between t/q/k/d without losing position.\n"
|
2012-08-27 13:06:10 -06:00
|
|
|
" tweak patrol-duty [disable]\n"
|
|
|
|
" 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"
|
2014-06-03 16:29:13 -06:00
|
|
|
" tweak confirm-embark [disable]\n"
|
|
|
|
" Asks for confirmation on the embark setup screen before embarking\n"
|
2012-09-03 11:11:35 -06:00
|
|
|
" tweak stable-temp [disable]\n"
|
|
|
|
" Fixes performance bug 6012 by squashing jitter in temperature updates.\n"
|
2012-09-14 02:35:55 -06:00
|
|
|
" tweak fast-heat <max-ticks>\n"
|
2012-09-14 02:14:36 -06:00
|
|
|
" Further improves temperature updates by ensuring that 1 degree of\n"
|
|
|
|
" item temperature is crossed in no more than specified number of frames\n"
|
2012-09-14 02:35:55 -06:00
|
|
|
" when updating from the environment temperature. Use 0 to disable.\n"
|
2014-08-15 02:22:34 -06:00
|
|
|
/*" tweak fix-dimensions [disable]\n"
|
2012-09-17 07:19:24 -06:00
|
|
|
" Fixes subtracting small amount of thread/cloth/liquid from a stack\n"
|
2014-08-15 02:22:34 -06:00
|
|
|
" by splitting the stack and subtracting from the remaining single item.\n"*/
|
2012-09-18 07:39:37 -06:00
|
|
|
" 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"
|
|
|
|
" from the container. This forcefully skips child reagents.\n"
|
2012-09-28 03:32:41 -06:00
|
|
|
" tweak fast-trade [disable]\n"
|
|
|
|
" Makes Shift-Enter in the Move Goods to Depot and Trade screens select\n"
|
|
|
|
" the current item (fully, in case of a stack), and scroll down one line.\n"
|
2012-09-28 08:01:17 -06:00
|
|
|
" tweak military-stable-assign [disable]\n"
|
|
|
|
" Preserve list order and cursor position when assigning to squad,\n"
|
|
|
|
" i.e. stop the rightmost list of the Positions page of the military\n"
|
|
|
|
" screen from constantly jumping to the top.\n"
|
|
|
|
" tweak military-color-assigned [disable]\n"
|
|
|
|
" Color squad candidates already assigned to other squads in brown/green\n"
|
|
|
|
" to make them stand out more in the list.\n"
|
2014-08-15 01:03:25 -06:00
|
|
|
// " tweak military-training [disable]\n"
|
|
|
|
// " Speed up melee squad training, removing inverse dependency on unit count.\n"
|
2014-05-08 13:22:45 -06:00
|
|
|
" 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"
|
|
|
|
" Stops adamantine clothing from wearing out while being worn (bug 6481).\n"
|
2012-03-05 08:47:06 -07:00
|
|
|
));
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown (color_ostream &out)
|
2012-03-05 08:47:06 -07:00
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-03-10 04:55:42 -07:00
|
|
|
|
2012-04-12 06:40:39 -06:00
|
|
|
// to be called by tweak-fixmigrant
|
2012-04-11 13:07:54 -06:00
|
|
|
// units forced into the fort by removing the flags do not own their clothes
|
|
|
|
// which has the result that they drop all their clothes and become unhappy because they are naked
|
2012-04-12 06:40:39 -06:00
|
|
|
// so we need to make them own their clothes and add them to their uniform
|
2012-04-11 13:07:54 -06:00
|
|
|
command_result fix_clothing_ownership(color_ostream &out, df::unit* unit)
|
|
|
|
{
|
|
|
|
// first, find one owned item to initialize the vtable
|
|
|
|
bool vt_initialized = false;
|
|
|
|
size_t numItems = world->items.all.size();
|
|
|
|
for(size_t i=0; i< numItems; i++)
|
|
|
|
{
|
|
|
|
df::item * item = world->items.all[i];
|
|
|
|
if(Items::getOwner(item))
|
|
|
|
{
|
|
|
|
vt_initialized = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!vt_initialized)
|
|
|
|
{
|
|
|
|
out << "fix_clothing_ownership: could not initialize vtable!" << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fixcount = 0;
|
|
|
|
for(size_t j=0; j<unit->inventory.size(); j++)
|
|
|
|
{
|
|
|
|
df::unit_inventory_item* inv_item = unit->inventory[j];
|
|
|
|
df::item* item = inv_item->item;
|
2012-04-14 05:36:22 -06:00
|
|
|
// unforbid items (for the case of kidnapping caravan escorts who have their stuff forbidden by default)
|
|
|
|
inv_item->item->flags.bits.forbid = 0;
|
2012-04-11 13:07:54 -06:00
|
|
|
if(inv_item->mode == df::unit_inventory_item::T_mode::Worn)
|
|
|
|
{
|
|
|
|
// ignore armor?
|
|
|
|
// it could be leather boots, for example, in which case it would not be nice to forbid ownership
|
|
|
|
//if(item->getEffectiveArmorLevel() != 0)
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
if(!Items::getOwner(item))
|
|
|
|
{
|
|
|
|
if(Items::setOwner(item, unit))
|
2012-04-12 06:40:39 -06:00
|
|
|
{
|
|
|
|
// add to uniform, so they know they should wear their clothes
|
|
|
|
insert_into_vector(unit->military.uniforms[0], item->id);
|
2012-04-11 13:07:54 -06:00
|
|
|
fixcount++;
|
2012-04-12 06:40:39 -06:00
|
|
|
}
|
2012-04-11 13:07:54 -06:00
|
|
|
else
|
|
|
|
out << "could not change ownership for item!" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-04-12 06:40:39 -06:00
|
|
|
// clear uniform_drop (without this they would drop their clothes and pick them up some time later)
|
|
|
|
unit->military.uniform_drop.clear();
|
2012-04-11 13:07:54 -06:00
|
|
|
out << "ownership for " << fixcount << " clothes fixed" << endl;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-26 11:19:56 -06:00
|
|
|
/*
|
|
|
|
* Save or restore cursor position on change to/from main dwarfmode menu.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static df::coord last_view, last_cursor;
|
|
|
|
|
|
|
|
struct stable_cursor_hook : df::viewscreen_dwarfmodest
|
|
|
|
{
|
|
|
|
typedef df::viewscreen_dwarfmodest interpose_base;
|
|
|
|
|
2012-11-22 09:08:47 -07:00
|
|
|
bool check_default()
|
|
|
|
{
|
|
|
|
switch (ui->main.mode) {
|
|
|
|
case ui_sidebar_mode::Default:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case ui_sidebar_mode::Build:
|
|
|
|
return ui_build_selector &&
|
|
|
|
(ui_build_selector->building_type < 0 ||
|
|
|
|
ui_build_selector->stage < 1);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-26 11:19:56 -06:00
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
|
|
|
|
{
|
2012-11-22 09:08:47 -07:00
|
|
|
bool was_default = check_default();
|
2012-08-26 11:19:56 -06:00
|
|
|
df::coord view = Gui::getViewportPos();
|
|
|
|
df::coord cursor = Gui::getCursorPos();
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
|
2012-11-22 09:08:47 -07:00
|
|
|
bool is_default = check_default();
|
2012-08-26 11:19:56 -06:00
|
|
|
df::coord cur_cursor = Gui::getCursorPos();
|
|
|
|
|
|
|
|
if (is_default && !was_default)
|
|
|
|
{
|
|
|
|
last_view = view; last_cursor = cursor;
|
|
|
|
}
|
|
|
|
else if (!is_default && was_default &&
|
|
|
|
Gui::getViewportPos() == last_view &&
|
|
|
|
last_cursor.isValid() && cur_cursor.isValid())
|
|
|
|
{
|
|
|
|
Gui::setCursorCoords(last_cursor.x, last_cursor.y, last_cursor.z);
|
|
|
|
|
|
|
|
// Force update of ui state
|
|
|
|
set<df::interface_key> tmp;
|
2013-02-21 07:26:35 -07:00
|
|
|
if (last_cursor.z < 2)
|
|
|
|
tmp.insert(interface_key::CURSOR_UP_Z);
|
|
|
|
else
|
|
|
|
tmp.insert(interface_key::CURSOR_DOWN_Z);
|
2012-08-26 11:19:56 -06:00
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
tmp.clear();
|
2013-02-21 07:26:35 -07:00
|
|
|
if (last_cursor.z < 2)
|
|
|
|
tmp.insert(interface_key::CURSOR_DOWN_Z);
|
|
|
|
else
|
|
|
|
tmp.insert(interface_key::CURSOR_UP_Z);
|
2012-08-26 11:19:56 -06:00
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
}
|
2012-11-22 09:08:47 -07:00
|
|
|
else if (!is_default && cur_cursor.isValid())
|
2012-08-26 11:19:56 -06:00
|
|
|
{
|
|
|
|
last_cursor = df::coord();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-30 10:48:06 -06:00
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(stable_cursor_hook, feed);
|
|
|
|
|
2012-08-27 13:06:10 -06:00
|
|
|
struct patrol_duty_hook : df::squad_order_trainst
|
|
|
|
{
|
|
|
|
typedef df::squad_order_trainst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, isPatrol, ())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(patrol_duty_hook, isPatrol);
|
2012-08-26 11:19:56 -06:00
|
|
|
|
2014-06-03 16:29:13 -06:00
|
|
|
enum confirm_embark_states
|
|
|
|
{
|
|
|
|
ECS_INACTIVE = 0,
|
|
|
|
ECS_CONFIRM,
|
|
|
|
ECS_ACCEPTED
|
|
|
|
};
|
|
|
|
static confirm_embark_states confirm_embark_state = ECS_INACTIVE;
|
|
|
|
|
|
|
|
struct confirm_embark_hook : df::viewscreen_setupdwarfgamest
|
|
|
|
{
|
|
|
|
typedef df::viewscreen_setupdwarfgamest interpose_base;
|
|
|
|
|
2014-06-04 12:41:35 -06:00
|
|
|
void OutputString(int8_t fg, int &x, int y, std::string text)
|
|
|
|
{
|
|
|
|
Screen::paintString(Screen::Pen(' ', fg, COLOR_BLACK), x, y, text);
|
|
|
|
x += text.length();
|
|
|
|
}
|
|
|
|
|
2014-06-03 16:29:13 -06:00
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
|
|
|
|
{
|
|
|
|
bool intercept = false;
|
2014-06-10 15:30:02 -06:00
|
|
|
if (this->show_play_now == 0)
|
2014-06-03 16:29:13 -06:00
|
|
|
{
|
2014-06-10 10:48:46 -06:00
|
|
|
if (confirm_embark_state == ECS_INACTIVE)
|
2014-06-03 16:29:13 -06:00
|
|
|
{
|
2014-06-10 10:48:46 -06:00
|
|
|
if (input->count(df::interface_key::SETUP_EMBARK))
|
2014-06-03 16:29:13 -06:00
|
|
|
{
|
2014-06-10 10:48:46 -06:00
|
|
|
confirm_embark_state = ECS_CONFIRM;
|
2014-06-03 16:29:13 -06:00
|
|
|
intercept = true;
|
|
|
|
}
|
|
|
|
}
|
2014-06-10 10:48:46 -06:00
|
|
|
else if (confirm_embark_state == ECS_CONFIRM)
|
|
|
|
{
|
|
|
|
intercept = true;
|
|
|
|
if (input->count(df::interface_key::MENU_CONFIRM))
|
|
|
|
confirm_embark_state = ECS_ACCEPTED;
|
|
|
|
else if (input->size())
|
|
|
|
confirm_embark_state = ECS_INACTIVE;
|
|
|
|
}
|
2014-06-03 16:29:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!intercept)
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
}
|
|
|
|
|
2014-06-04 12:41:35 -06:00
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, key_conflict, (df::interface_key key))
|
|
|
|
{
|
2014-06-04 21:18:19 -06:00
|
|
|
if (confirm_embark_state == ECS_CONFIRM)
|
|
|
|
{
|
|
|
|
if (key == df::interface_key::OPTIONS)
|
|
|
|
return true;
|
|
|
|
}
|
2014-06-06 12:59:23 -06:00
|
|
|
return INTERPOSE_NEXT(key_conflict)(key);
|
2014-06-04 12:41:35 -06:00
|
|
|
}
|
|
|
|
|
2014-06-03 16:29:13 -06:00
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, render, ())
|
|
|
|
{
|
|
|
|
INTERPOSE_NEXT(render)();
|
|
|
|
auto dim = Screen::getWindowSize();
|
2014-06-04 12:41:35 -06:00
|
|
|
int x = 0, y = 0;
|
2014-06-03 16:29:13 -06:00
|
|
|
if (confirm_embark_state != ECS_INACTIVE)
|
|
|
|
{
|
|
|
|
Screen::fillRect(Screen::Pen(' ', COLOR_BLACK, COLOR_BLACK), 0, 0, dim.x - 1, dim.y - 1);
|
|
|
|
}
|
|
|
|
if (confirm_embark_state == ECS_CONFIRM)
|
|
|
|
{
|
2014-06-04 12:41:35 -06:00
|
|
|
x = 2, y = 2;
|
|
|
|
OutputString(COLOR_WHITE, x, y, "Really embark? (");
|
|
|
|
OutputString(COLOR_LIGHTGREEN, x, y, Screen::getKeyDisplay(df::interface_key::MENU_CONFIRM));
|
|
|
|
OutputString(COLOR_WHITE, x, y, " = yes, other = no)");
|
|
|
|
x = 2, y = 4;
|
2014-06-10 15:30:02 -06:00
|
|
|
int32_t points = this->points_remaining;
|
2014-06-04 12:41:35 -06:00
|
|
|
OutputString(COLOR_WHITE, x, y, "Points left: ");
|
2014-06-19 20:32:02 -06:00
|
|
|
OutputString((points ? COLOR_YELLOW : COLOR_LIGHTGREEN), x, y, std::to_string((unsigned long long/*won't compile on windows otherwise*/)points));
|
2014-06-04 12:41:35 -06:00
|
|
|
x = dim.x - 10, y = dim.y - 1;
|
|
|
|
OutputString(COLOR_WHITE, x, y, "DFHack");
|
2014-06-03 16:29:13 -06:00
|
|
|
}
|
|
|
|
else if (confirm_embark_state == ECS_ACCEPTED)
|
|
|
|
{
|
|
|
|
std::set<df::interface_key> input;
|
|
|
|
input.insert(df::interface_key::SETUP_EMBARK);
|
2014-06-10 10:48:46 -06:00
|
|
|
this->feed(&input);
|
2014-06-03 16:29:13 -06:00
|
|
|
confirm_embark_state = ECS_INACTIVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(confirm_embark_hook, feed);
|
2014-06-04 12:41:35 -06:00
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(confirm_embark_hook, key_conflict);
|
2014-06-03 16:29:13 -06:00
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(confirm_embark_hook, render);
|
|
|
|
|
2012-09-03 11:11:35 -06:00
|
|
|
struct stable_temp_hook : df::item_actual {
|
|
|
|
typedef df::item_actual interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, adjustTemperature, (uint16_t temp, int32_t rate_mult))
|
|
|
|
{
|
2012-11-12 10:54:21 -07:00
|
|
|
if (temperature.whole != temp)
|
2012-09-03 11:11:35 -06:00
|
|
|
{
|
|
|
|
// Bug 6012 is caused by fixed-point precision mismatch jitter
|
|
|
|
// when an item is being pushed by two sources at N and N+1.
|
|
|
|
// This check suppresses it altogether.
|
2012-11-12 10:54:21 -07:00
|
|
|
if (temp == temperature.whole+1 ||
|
|
|
|
(temp == temperature.whole-1 && temperature.fraction == 0))
|
|
|
|
temp = temperature.whole;
|
2012-09-03 11:11:35 -06:00
|
|
|
// When SPEC_HEAT is NONE, the original function seems to not
|
|
|
|
// change the temperature, yet return true, which is silly.
|
|
|
|
else if (getSpecHeat() == 60001)
|
2012-11-12 10:54:21 -07:00
|
|
|
temp = temperature.whole;
|
2012-09-03 11:11:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return INTERPOSE_NEXT(adjustTemperature)(temp, rate_mult);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, updateContaminants, ())
|
|
|
|
{
|
|
|
|
if (contaminants)
|
|
|
|
{
|
|
|
|
// Force 1-degree difference in contaminant temperature to 0
|
|
|
|
for (size_t i = 0; i < contaminants->size(); i++)
|
|
|
|
{
|
|
|
|
auto obj = (*contaminants)[i];
|
|
|
|
|
2012-11-12 10:54:21 -07:00
|
|
|
if (abs(obj->temperature.whole - temperature.whole) == 1)
|
2012-09-03 11:11:35 -06:00
|
|
|
{
|
2012-11-12 10:54:21 -07:00
|
|
|
obj->temperature.whole = temperature.whole;
|
|
|
|
obj->temperature.fraction = temperature.fraction;
|
2012-09-03 11:11:35 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return INTERPOSE_NEXT(updateContaminants)();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(stable_temp_hook, adjustTemperature);
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(stable_temp_hook, updateContaminants);
|
|
|
|
|
2012-09-14 02:14:36 -06:00
|
|
|
static int map_temp_mult = -1;
|
|
|
|
static int max_heat_ticks = 0;
|
|
|
|
|
|
|
|
struct fast_heat_hook : df::item_actual {
|
|
|
|
typedef df::item_actual interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(
|
|
|
|
bool, updateTempFromMap,
|
|
|
|
(bool local, bool contained, bool adjust, int32_t rate_mult)
|
|
|
|
) {
|
|
|
|
int cmult = map_temp_mult;
|
|
|
|
map_temp_mult = rate_mult;
|
|
|
|
|
|
|
|
bool rv = INTERPOSE_NEXT(updateTempFromMap)(local, contained, adjust, rate_mult);
|
|
|
|
map_temp_mult = cmult;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(
|
|
|
|
bool, updateTemperature,
|
|
|
|
(uint16_t temp, bool local, bool contained, bool adjust, int32_t rate_mult)
|
|
|
|
) {
|
|
|
|
// Some items take ages to cross the last degree, so speed them up
|
2012-11-12 10:54:21 -07:00
|
|
|
if (map_temp_mult > 0 && temp != temperature.whole && max_heat_ticks > 0)
|
2012-09-14 02:14:36 -06:00
|
|
|
{
|
|
|
|
int spec = getSpecHeat();
|
|
|
|
if (spec != 60001)
|
2012-11-12 10:54:21 -07:00
|
|
|
rate_mult = std::max(map_temp_mult, spec/max_heat_ticks/abs(temp - temperature.whole));
|
2012-09-14 02:14:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return INTERPOSE_NEXT(updateTemperature)(temp, local, contained, adjust, rate_mult);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, adjustTemperature, (uint16_t temp, int32_t rate_mult))
|
|
|
|
{
|
|
|
|
if (map_temp_mult > 0)
|
|
|
|
rate_mult = map_temp_mult;
|
|
|
|
|
|
|
|
return INTERPOSE_NEXT(adjustTemperature)(temp, rate_mult);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(fast_heat_hook, updateTempFromMap);
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(fast_heat_hook, updateTemperature);
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(fast_heat_hook, adjustTemperature);
|
|
|
|
|
2012-09-17 07:19:24 -06:00
|
|
|
static void correct_dimension(df::item_actual *self, int32_t &delta, int32_t dim)
|
|
|
|
{
|
|
|
|
// Zero dimension or remainder?
|
|
|
|
if (dim <= 0 || self->stack_size <= 1) return;
|
|
|
|
int rem = delta % dim;
|
|
|
|
if (rem == 0) return;
|
|
|
|
// If destroys, pass through
|
|
|
|
int intv = delta / dim;
|
|
|
|
if (intv >= self->stack_size) return;
|
|
|
|
// Subtract int part
|
|
|
|
delta = rem;
|
|
|
|
self->stack_size -= intv;
|
|
|
|
if (self->stack_size <= 1) return;
|
|
|
|
|
|
|
|
// If kills the item or cannot split, round up.
|
|
|
|
if (!self->flags.bits.in_inventory || !Items::getContainer(self))
|
|
|
|
{
|
|
|
|
delta = dim;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise split the stack
|
|
|
|
color_ostream_proxy out(Core::getInstance().getConsole());
|
|
|
|
out.print("fix-dimensions: splitting stack #%d for delta %d.\n", self->id, delta);
|
|
|
|
|
|
|
|
auto copy = self->splitStack(self->stack_size-1, true);
|
|
|
|
if (copy) copy->categorize(true);
|
|
|
|
}
|
|
|
|
|
2012-10-10 08:22:01 -06:00
|
|
|
struct dimension_liquid_hook : df::item_liquid_miscst {
|
|
|
|
typedef df::item_liquid_miscst interpose_base;
|
2012-09-17 07:19:24 -06:00
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
|
|
|
|
{
|
|
|
|
correct_dimension(this, delta, dimension);
|
|
|
|
return INTERPOSE_NEXT(subtractDimension)(delta);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-10 08:22:01 -06:00
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(dimension_liquid_hook, subtractDimension);
|
|
|
|
|
|
|
|
struct dimension_powder_hook : df::item_powder_miscst {
|
|
|
|
typedef df::item_powder_miscst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
|
|
|
|
{
|
|
|
|
correct_dimension(this, delta, dimension);
|
|
|
|
return INTERPOSE_NEXT(subtractDimension)(delta);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(dimension_powder_hook, subtractDimension);
|
2012-09-17 07:19:24 -06:00
|
|
|
|
|
|
|
struct dimension_bar_hook : df::item_barst {
|
|
|
|
typedef df::item_barst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
|
|
|
|
{
|
|
|
|
correct_dimension(this, delta, dimension);
|
|
|
|
return INTERPOSE_NEXT(subtractDimension)(delta);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(dimension_bar_hook, subtractDimension);
|
|
|
|
|
|
|
|
struct dimension_thread_hook : df::item_threadst {
|
|
|
|
typedef df::item_threadst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
|
|
|
|
{
|
|
|
|
correct_dimension(this, delta, dimension);
|
|
|
|
return INTERPOSE_NEXT(subtractDimension)(delta);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(dimension_thread_hook, subtractDimension);
|
|
|
|
|
|
|
|
struct dimension_cloth_hook : df::item_clothst {
|
|
|
|
typedef df::item_clothst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
|
|
|
|
{
|
|
|
|
correct_dimension(this, delta, dimension);
|
|
|
|
return INTERPOSE_NEXT(subtractDimension)(delta);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(dimension_cloth_hook, subtractDimension);
|
|
|
|
|
2012-09-18 07:39:37 -06:00
|
|
|
struct advmode_contained_hook : df::viewscreen_layer_unit_actionst {
|
|
|
|
typedef df::viewscreen_layer_unit_actionst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
|
|
|
|
{
|
|
|
|
auto old_reaction = cur_reaction;
|
|
|
|
auto old_reagent = reagent;
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
|
|
|
|
if (cur_reaction && (cur_reaction != old_reaction || reagent != old_reagent))
|
|
|
|
{
|
|
|
|
old_reagent = reagent;
|
|
|
|
|
|
|
|
// Skip reagents already contained by others
|
|
|
|
while (reagent < (int)cur_reaction->reagents.size()-1)
|
|
|
|
{
|
|
|
|
if (!cur_reaction->reagents[reagent]->flags.bits.IN_CONTAINER)
|
|
|
|
break;
|
|
|
|
reagent++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old_reagent != reagent)
|
|
|
|
{
|
|
|
|
// Reproduces a tiny part of the orginal screen code
|
|
|
|
choice_items.clear();
|
|
|
|
|
|
|
|
auto preagent = cur_reaction->reagents[reagent];
|
|
|
|
reagent_amnt_left = preagent->quantity;
|
|
|
|
|
|
|
|
for (int i = held_items.size()-1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (!preagent->matchesRoot(held_items[i], cur_reaction->index))
|
|
|
|
continue;
|
|
|
|
if (linear_index(sel_items, held_items[i]) >= 0)
|
|
|
|
continue;
|
|
|
|
choice_items.push_back(held_items[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
layer_objects[6]->setListLength(choice_items.size());
|
|
|
|
|
|
|
|
if (!choice_items.empty())
|
|
|
|
{
|
|
|
|
layer_objects[4]->active = layer_objects[5]->active = false;
|
|
|
|
layer_objects[6]->active = true;
|
|
|
|
}
|
|
|
|
else if (layer_objects[6]->active)
|
|
|
|
{
|
|
|
|
layer_objects[6]->active = false;
|
|
|
|
layer_objects[5]->active = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(advmode_contained_hook, feed);
|
|
|
|
|
2012-09-28 03:32:41 -06:00
|
|
|
struct fast_trade_assign_hook : df::viewscreen_layer_assigntradest {
|
|
|
|
typedef df::viewscreen_layer_assigntradest interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
|
|
|
|
{
|
|
|
|
if (layer_objects[1]->active && input->count(interface_key::SELECT_ALL))
|
|
|
|
{
|
|
|
|
set<df::interface_key> tmp; tmp.insert(interface_key::SELECT);
|
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
tmp.clear(); tmp.insert(interface_key::STANDARDSCROLL_DOWN);
|
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(fast_trade_assign_hook, feed);
|
|
|
|
|
|
|
|
struct fast_trade_select_hook : df::viewscreen_tradegoodsst {
|
|
|
|
typedef df::viewscreen_tradegoodsst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
|
|
|
|
{
|
|
|
|
if (!(is_unloading || !has_traders || in_edit_count)
|
|
|
|
&& input->count(interface_key::SELECT_ALL))
|
|
|
|
{
|
|
|
|
set<df::interface_key> tmp; tmp.insert(interface_key::SELECT);
|
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
if (in_edit_count)
|
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
tmp.clear(); tmp.insert(interface_key::STANDARDSCROLL_DOWN);
|
|
|
|
INTERPOSE_NEXT(feed)(&tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(fast_trade_select_hook, feed);
|
|
|
|
|
2012-09-28 08:01:17 -06:00
|
|
|
struct military_assign_hook : df::viewscreen_layer_militaryst {
|
|
|
|
typedef df::viewscreen_layer_militaryst interpose_base;
|
|
|
|
|
|
|
|
inline bool inPositionsMode() {
|
|
|
|
return page == Positions && !(in_create_squad || in_new_squad);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
|
|
|
|
{
|
|
|
|
if (inPositionsMode() && !layer_objects[0]->active)
|
|
|
|
{
|
|
|
|
auto pos_list = layer_objects[1];
|
|
|
|
auto plist = layer_objects[2];
|
|
|
|
auto &cand = positions.candidates;
|
|
|
|
|
|
|
|
// Save the candidate list and cursors
|
|
|
|
std::vector<df::unit*> copy = cand;
|
|
|
|
int cursor = plist->getListCursor();
|
|
|
|
int pos_cursor = pos_list->getListCursor();
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
|
|
|
|
if (inPositionsMode() && !layer_objects[0]->active)
|
|
|
|
{
|
|
|
|
bool is_select = input->count(interface_key::SELECT);
|
|
|
|
|
|
|
|
// Resort the candidate list and restore cursor
|
|
|
|
// on add to squad OR scroll in the position list.
|
|
|
|
if (!plist->active || is_select)
|
|
|
|
{
|
|
|
|
// Since we don't know the actual sorting order, preserve
|
|
|
|
// the ordering of the items in the list before keypress.
|
|
|
|
// This does the right thing even if the list was sorted
|
|
|
|
// with sort-units.
|
|
|
|
std::set<df::unit*> prev, next;
|
|
|
|
prev.insert(copy.begin(), copy.end());
|
|
|
|
next.insert(cand.begin(), cand.end());
|
|
|
|
std::vector<df::unit*> out;
|
|
|
|
|
|
|
|
// (old-before-cursor) (new) |cursor| (old-after-cursor)
|
|
|
|
for (int i = 0; i < cursor && i < (int)copy.size(); i++)
|
|
|
|
if (next.count(copy[i])) out.push_back(copy[i]);
|
|
|
|
for (size_t i = 0; i < cand.size(); i++)
|
|
|
|
if (!prev.count(cand[i])) out.push_back(cand[i]);
|
|
|
|
int new_cursor = out.size();
|
|
|
|
for (int i = cursor; i < (int)copy.size(); i++)
|
|
|
|
if (next.count(copy[i])) out.push_back(copy[i]);
|
|
|
|
|
|
|
|
cand.swap(out);
|
|
|
|
plist->setListLength(cand.size());
|
|
|
|
if (new_cursor < (int)cand.size())
|
|
|
|
plist->setListCursor(new_cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Preserve the position list index on remove from squad
|
|
|
|
if (pos_list->active && is_select)
|
|
|
|
pos_list->setListCursor(pos_cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, render, ())
|
|
|
|
{
|
|
|
|
INTERPOSE_NEXT(render)();
|
|
|
|
|
|
|
|
if (inPositionsMode())
|
|
|
|
{
|
|
|
|
auto plist = layer_objects[2];
|
|
|
|
int x1 = plist->getX1(), y1 = plist->getY1();
|
|
|
|
int x2 = plist->getX2(), y2 = plist->getY2();
|
|
|
|
int i1 = plist->getFirstVisible(), i2 = plist->getLastVisible();
|
2012-09-28 08:50:01 -06:00
|
|
|
int si = plist->getListCursor();
|
2012-09-28 08:01:17 -06:00
|
|
|
|
|
|
|
for (int y = y1, i = i1; i <= i2; i++, y++)
|
|
|
|
{
|
|
|
|
auto unit = vector_get(positions.candidates, i);
|
2012-10-20 14:35:39 -06:00
|
|
|
if (!unit || unit->military.squad_id < 0)
|
2012-09-28 08:01:17 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
for (int x = x1; x <= x2; x++)
|
|
|
|
{
|
|
|
|
Pen cur_tile = Screen::readTile(x, y);
|
|
|
|
if (!cur_tile.valid()) continue;
|
2012-09-28 08:50:01 -06:00
|
|
|
cur_tile.fg = (i == si) ? COLOR_BROWN : COLOR_GREEN;
|
2012-09-28 08:01:17 -06:00
|
|
|
Screen::paintTile(cur_tile, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(military_assign_hook, feed);
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(military_assign_hook, render);
|
|
|
|
|
2012-11-16 11:51:07 -07:00
|
|
|
// Unit updates are executed based on an action divisor variable,
|
|
|
|
// which is computed from the alive unit count and has range 10-100.
|
|
|
|
static int adjust_unit_divisor(int value) {
|
|
|
|
return value*10/DF_GLOBAL_FIELD(ui, unit_action_divisor, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool can_spar(df::unit *unit) {
|
|
|
|
return unit->counters2.exhaustion <= 2000 && // actually 4000, but leave a gap
|
2012-12-10 14:50:33 -07:00
|
|
|
(unit->status2.limbs_grasp_count > 0 || unit->status2.limbs_grasp_max == 0) &&
|
2012-11-16 11:51:07 -07:00
|
|
|
(!unit->health || (unit->health->flags.whole&0x7FF) == 0) &&
|
2013-04-01 09:42:02 -06:00
|
|
|
(!unit->job.current_job || unit->job.current_job->job_type != job_type::Rest);
|
2012-11-16 11:51:07 -07:00
|
|
|
}
|
|
|
|
|
2012-11-18 02:02:49 -07:00
|
|
|
static bool has_spar_inventory(df::unit *unit, df::job_skill skill)
|
|
|
|
{
|
|
|
|
using namespace df::enums::job_skill;
|
|
|
|
|
|
|
|
auto type = ENUM_ATTR(job_skill, type, skill);
|
|
|
|
|
|
|
|
if (type == job_skill_class::MilitaryWeapon)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < unit->inventory.size(); i++)
|
|
|
|
{
|
|
|
|
auto item = unit->inventory[i];
|
|
|
|
if (item->mode == df::unit_inventory_item::Weapon &&
|
|
|
|
item->item->getMeleeSkill() == skill)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (skill) {
|
|
|
|
case THROW:
|
|
|
|
case RANGED_COMBAT:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case SHIELD:
|
|
|
|
for (size_t i = 0; i < unit->inventory.size(); i++)
|
|
|
|
{
|
|
|
|
auto item = unit->inventory[i];
|
|
|
|
if (item->mode == df::unit_inventory_item::Weapon &&
|
|
|
|
item->item->getType() == item_type::SHIELD)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case ARMOR:
|
|
|
|
for (size_t i = 0; i < unit->inventory.size(); i++)
|
|
|
|
{
|
|
|
|
auto item = unit->inventory[i];
|
|
|
|
if (item->mode == df::unit_inventory_item::Worn &&
|
|
|
|
item->item->isArmorNotClothing())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-16 11:51:07 -07:00
|
|
|
struct military_training_ct_hook : df::activity_event_combat_trainingst {
|
|
|
|
typedef df::activity_event_combat_trainingst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, process, (df::unit *unit))
|
|
|
|
{
|
|
|
|
auto act = df::activity_entry::find(activity_id);
|
|
|
|
int cur_neid = act ? act->next_event_id : 0;
|
|
|
|
int cur_oc = organize_counter;
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(process)(unit);
|
|
|
|
|
|
|
|
// Shorten the time it takes to organize stuff, so that in
|
|
|
|
// reality it remains the same instead of growing proportionally
|
|
|
|
// to the unit count.
|
|
|
|
if (organize_counter > cur_oc && organize_counter > 0)
|
|
|
|
organize_counter = adjust_unit_divisor(organize_counter);
|
|
|
|
|
|
|
|
if (act && act->next_event_id > cur_neid)
|
|
|
|
{
|
|
|
|
// New events were added. Check them.
|
|
|
|
for (size_t i = 0; i < act->events.size(); i++)
|
|
|
|
{
|
|
|
|
auto event = act->events[i];
|
|
|
|
if (event->flags.bits.dismissed || event->event_id < cur_neid)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (auto sp = strict_virtual_cast<df::activity_event_sparringst>(event))
|
|
|
|
{
|
|
|
|
// Sparring has a problem in that all of its participants decrement
|
|
|
|
// the countdown variable. Fix this by multiplying it by the member count.
|
2012-11-17 05:43:29 -07:00
|
|
|
sp->countdown = sp->countdown * sp->participants.units.size();
|
2012-11-16 11:51:07 -07:00
|
|
|
}
|
|
|
|
else if (auto sd = strict_virtual_cast<df::activity_event_skill_demonstrationst>(event))
|
|
|
|
{
|
|
|
|
// Adjust initial counter values
|
|
|
|
sd->train_countdown = adjust_unit_divisor(sd->train_countdown);
|
|
|
|
sd->wait_countdown = adjust_unit_divisor(sd->wait_countdown);
|
|
|
|
|
|
|
|
// Check if the game selected the most skilled unit as the teacher
|
2012-11-17 05:43:29 -07:00
|
|
|
auto &units = sd->participants.units;
|
2012-11-16 11:51:07 -07:00
|
|
|
int maxv = -1, cur_xp = -1, minv = 0;
|
|
|
|
int best = -1;
|
|
|
|
size_t spar = 0;
|
|
|
|
|
|
|
|
for (size_t j = 0; j < units.size(); j++)
|
|
|
|
{
|
|
|
|
auto unit = df::unit::find(units[j]);
|
|
|
|
if (!unit) continue;
|
|
|
|
int xp = Units::getExperience(unit, sd->skill, true);
|
|
|
|
if (units[j] == sd->unit_id)
|
|
|
|
cur_xp = xp;
|
|
|
|
if (j == 0 || xp < minv)
|
|
|
|
minv = xp;
|
|
|
|
if (xp > maxv) {
|
|
|
|
maxv = xp;
|
|
|
|
best = j;
|
|
|
|
}
|
2012-11-18 02:02:49 -07:00
|
|
|
if (can_spar(unit) && has_spar_inventory(unit, sd->skill))
|
2012-11-16 11:51:07 -07:00
|
|
|
spar++;
|
|
|
|
}
|
|
|
|
|
2013-02-26 01:29:02 -07:00
|
|
|
#if 0
|
2012-11-16 11:51:07 -07:00
|
|
|
color_ostream_proxy out(Core::getInstance().getConsole());
|
2013-02-26 01:29:02 -07:00
|
|
|
#endif
|
2012-11-16 11:51:07 -07:00
|
|
|
|
|
|
|
// If the xp gap is low, sometimes replace with sparring
|
|
|
|
if ((maxv - minv) < 64*15 && spar == units.size() &&
|
2012-11-18 11:06:47 -07:00
|
|
|
random_int(45) >= 30 + (maxv-minv)/64)
|
2012-11-16 11:51:07 -07:00
|
|
|
{
|
2013-02-26 01:29:02 -07:00
|
|
|
#if 0
|
2012-11-18 11:06:47 -07:00
|
|
|
out.print("Replacing %s demonstration (xp %d-%d, gap %d) with sparring.\n",
|
|
|
|
ENUM_KEY_STR(job_skill, sd->skill).c_str(), minv, maxv, maxv-minv);
|
2013-02-26 01:29:02 -07:00
|
|
|
#endif
|
2012-11-16 11:51:07 -07:00
|
|
|
|
|
|
|
if (auto spar = df::allocate<df::activity_event_sparringst>())
|
|
|
|
{
|
|
|
|
spar->event_id = sd->event_id;
|
|
|
|
spar->activity_id = sd->activity_id;
|
|
|
|
spar->parent_event_id = sd->parent_event_id;
|
|
|
|
spar->flags = sd->flags;
|
|
|
|
spar->participants = sd->participants;
|
|
|
|
spar->building_id = sd->building_id;
|
|
|
|
spar->countdown = 300*units.size();
|
|
|
|
|
|
|
|
delete sd;
|
|
|
|
act->events[i] = spar;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the teacher has less xp than somebody else, switch
|
|
|
|
if (best >= 0 && maxv > cur_xp)
|
|
|
|
{
|
2013-02-26 01:29:02 -07:00
|
|
|
#if 0
|
2012-11-18 11:06:47 -07:00
|
|
|
out.print("Replacing %s teacher %d (%d xp) with %d (%d xp); xp gap %d.\n",
|
2012-11-18 02:02:49 -07:00
|
|
|
ENUM_KEY_STR(job_skill, sd->skill).c_str(),
|
2012-11-18 11:06:47 -07:00
|
|
|
sd->unit_id, cur_xp, units[best], maxv, maxv-minv);
|
2013-02-26 01:29:02 -07:00
|
|
|
#endif
|
2012-11-16 11:51:07 -07:00
|
|
|
|
2012-11-17 05:43:29 -07:00
|
|
|
sd->hist_figure_id = sd->participants.histfigs[best];
|
2012-11-16 11:51:07 -07:00
|
|
|
sd->unit_id = units[best];
|
|
|
|
}
|
2012-11-18 11:06:47 -07:00
|
|
|
else
|
|
|
|
{
|
2013-02-26 01:29:02 -07:00
|
|
|
#if 0
|
2012-11-18 11:06:47 -07:00
|
|
|
out.print("Not changing %s demonstration (xp %d-%d, gap %d).\n",
|
|
|
|
ENUM_KEY_STR(job_skill, sd->skill).c_str(),
|
|
|
|
minv, maxv, maxv-minv);
|
2013-02-26 01:29:02 -07:00
|
|
|
#endif
|
2012-11-18 11:06:47 -07:00
|
|
|
}
|
2012-11-16 11:51:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-21 12:18:29 -06:00
|
|
|
/*
|
2012-11-16 11:51:07 -07:00
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(military_training_ct_hook, process);
|
|
|
|
|
|
|
|
struct military_training_sd_hook : df::activity_event_skill_demonstrationst {
|
|
|
|
typedef df::activity_event_skill_demonstrationst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, process, (df::unit *unit))
|
|
|
|
{
|
|
|
|
int cur_oc = organize_counter;
|
|
|
|
int cur_tc = train_countdown;
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(process)(unit);
|
|
|
|
|
|
|
|
// Shorten the counters if they changed
|
|
|
|
if (organize_counter > cur_oc && organize_counter > 0)
|
|
|
|
organize_counter = adjust_unit_divisor(organize_counter);
|
|
|
|
if (train_countdown > cur_tc)
|
|
|
|
train_countdown = adjust_unit_divisor(train_countdown);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(military_training_sd_hook, process);
|
|
|
|
|
2012-11-17 05:43:29 -07:00
|
|
|
template<class T>
|
|
|
|
bool is_done(T *event, df::unit *unit)
|
2012-11-16 11:51:07 -07:00
|
|
|
{
|
|
|
|
return event->flags.bits.dismissed ||
|
2012-11-17 05:43:29 -07:00
|
|
|
binsearch_index(event->participants.units, unit->id) < 0;
|
2012-11-16 11:51:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct military_training_sp_hook : df::activity_event_sparringst {
|
|
|
|
typedef df::activity_event_sparringst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, process, (df::unit *unit))
|
|
|
|
{
|
|
|
|
INTERPOSE_NEXT(process)(unit);
|
|
|
|
|
|
|
|
// Since there are no counters to fix, repeat the call
|
|
|
|
int cnt = (DF_GLOBAL_FIELD(ui, unit_action_divisor, 10)+5) / 10;
|
|
|
|
for (int i = 1; i < cnt && !is_done(this, unit); i++)
|
|
|
|
INTERPOSE_NEXT(process)(unit);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(military_training_sp_hook, process);
|
|
|
|
|
|
|
|
struct military_training_id_hook : df::activity_event_individual_skill_drillst {
|
|
|
|
typedef df::activity_event_individual_skill_drillst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, process, (df::unit *unit))
|
|
|
|
{
|
|
|
|
INTERPOSE_NEXT(process)(unit);
|
|
|
|
|
|
|
|
// Since there are no counters to fix, repeat the call
|
|
|
|
int cnt = (DF_GLOBAL_FIELD(ui, unit_action_divisor, 10)+5) / 10;
|
|
|
|
for (int i = 1; i < cnt && !is_done(this, unit); i++)
|
|
|
|
INTERPOSE_NEXT(process)(unit);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(military_training_id_hook, process);
|
2014-07-21 12:18:29 -06:00
|
|
|
*/
|
2012-11-16 11:51:07 -07:00
|
|
|
|
2014-05-08 13:22:45 -06:00
|
|
|
struct craft_age_wear_hook : df::item_crafted {
|
|
|
|
typedef df::item_crafted interpose_base;
|
|
|
|
|
2014-08-15 07:13:15 -06:00
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, ageItem, (int amount))
|
2014-05-08 13:22:45 -06:00
|
|
|
{
|
|
|
|
int orig_age = age;
|
|
|
|
age += amount;
|
|
|
|
if (age > 200000000)
|
|
|
|
age = 200000000;
|
|
|
|
if (age == orig_age)
|
2014-08-15 07:13:15 -06:00
|
|
|
return false;
|
2014-05-08 13:22:45 -06:00
|
|
|
|
|
|
|
MaterialInfo mat(mat_type, mat_index);
|
|
|
|
if (!mat.isValid())
|
2014-08-15 07:13:15 -06:00
|
|
|
return false;
|
2014-05-08 13:22:45 -06:00
|
|
|
int wear = 0;
|
|
|
|
|
|
|
|
if (mat.material->flags.is_set(material_flags::WOOD))
|
|
|
|
wear = 5;
|
|
|
|
else if (mat.material->flags.is_set(material_flags::LEATHER) ||
|
|
|
|
mat.material->flags.is_set(material_flags::THREAD_PLANT) ||
|
|
|
|
mat.material->flags.is_set(material_flags::SILK) ||
|
|
|
|
mat.material->flags.is_set(material_flags::YARN))
|
|
|
|
wear = 1;
|
|
|
|
else
|
2014-08-15 07:13:15 -06:00
|
|
|
return false;
|
2014-05-08 13:22:45 -06:00
|
|
|
wear = ((orig_age % wear) + (age - orig_age)) / wear;
|
|
|
|
if (wear > 0)
|
2014-08-15 07:13:15 -06:00
|
|
|
return incWearTimer(wear);
|
|
|
|
else
|
|
|
|
return false;
|
2014-05-08 13:22:45 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(craft_age_wear_hook, ageItem);
|
|
|
|
|
|
|
|
static bool inc_wear_timer (df::item_constructed *item, int amount)
|
|
|
|
{
|
|
|
|
if (item->flags.bits.artifact)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
MaterialInfo mat(item->mat_type, item->mat_index);
|
|
|
|
if (mat.isInorganic() && mat.inorganic->flags.is_set(inorganic_flags::DEEP_SPECIAL))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
item->wear_timer += amount;
|
|
|
|
return (item->wear_timer > 806400);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct adamantine_cloth_wear_armor_hook : df::item_armorst {
|
|
|
|
typedef df::item_armorst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, incWearTimer, (int amount))
|
|
|
|
{
|
|
|
|
return inc_wear_timer(this, amount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(adamantine_cloth_wear_armor_hook, incWearTimer);
|
|
|
|
|
|
|
|
struct adamantine_cloth_wear_helm_hook : df::item_helmst {
|
|
|
|
typedef df::item_helmst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, incWearTimer, (int amount))
|
|
|
|
{
|
|
|
|
return inc_wear_timer(this, amount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(adamantine_cloth_wear_helm_hook, incWearTimer);
|
|
|
|
|
|
|
|
struct adamantine_cloth_wear_gloves_hook : df::item_glovesst {
|
|
|
|
typedef df::item_glovesst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, incWearTimer, (int amount))
|
|
|
|
{
|
|
|
|
return inc_wear_timer(this, amount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(adamantine_cloth_wear_gloves_hook, incWearTimer);
|
|
|
|
|
|
|
|
struct adamantine_cloth_wear_shoes_hook : df::item_shoesst {
|
|
|
|
typedef df::item_shoesst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, incWearTimer, (int amount))
|
|
|
|
{
|
|
|
|
return inc_wear_timer(this, amount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(adamantine_cloth_wear_shoes_hook, incWearTimer);
|
|
|
|
|
|
|
|
struct adamantine_cloth_wear_pants_hook : df::item_pantsst {
|
|
|
|
typedef df::item_pantsst interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(bool, incWearTimer, (int amount))
|
|
|
|
{
|
|
|
|
return inc_wear_timer(this, amount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(adamantine_cloth_wear_pants_hook, incWearTimer);
|
|
|
|
|
2012-08-30 10:48:06 -06:00
|
|
|
static void enable_hook(color_ostream &out, VMethodInterposeLinkBase &hook, vector <string> ¶meters)
|
|
|
|
{
|
|
|
|
if (vector_get(parameters, 1) == "disable")
|
|
|
|
{
|
|
|
|
hook.remove();
|
2013-08-22 02:14:45 -06:00
|
|
|
out.print("Disabled tweak %s (%s)\n", parameters[0].c_str(), hook.name());
|
2012-08-30 10:48:06 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hook.apply())
|
2013-08-22 02:14:45 -06:00
|
|
|
out.print("Enabled tweak %s (%s)\n", parameters[0].c_str(), hook.name());
|
2012-08-30 10:48:06 -06:00
|
|
|
else
|
2013-08-22 02:14:45 -06:00
|
|
|
out.printerr("Could not activate tweak %s (%s)\n", parameters[0].c_str(), hook.name());
|
2012-08-30 10:48:06 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
static command_result tweak(color_ostream &out, vector <string> ¶meters)
|
2012-03-05 08:47:06 -07:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2012-03-05 08:47:06 -07:00
|
|
|
|
|
|
|
if (parameters.empty())
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
|
|
|
string cmd = parameters[0];
|
|
|
|
|
|
|
|
if (cmd == "clear-missing")
|
|
|
|
{
|
2012-04-17 08:57:41 -06:00
|
|
|
df::unit *unit = getSelectedUnit(out, true);
|
2012-03-05 08:47:06 -07:00
|
|
|
if (!unit)
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
2014-07-29 15:26:14 -06:00
|
|
|
auto death = df::incident::find(unit->counters.death_id);
|
2012-03-05 08:47:06 -07:00
|
|
|
|
|
|
|
if (death)
|
|
|
|
{
|
|
|
|
death->flags.bits.discovered = true;
|
|
|
|
|
2014-07-29 15:27:16 -06:00
|
|
|
auto crime = df::crime::find(death->crime_id);
|
2012-03-05 08:47:06 -07:00
|
|
|
if (crime)
|
|
|
|
crime->flags.bits.discovered = true;
|
|
|
|
}
|
|
|
|
}
|
2012-03-22 09:30:15 -06:00
|
|
|
else if (cmd == "clear-ghostly")
|
|
|
|
{
|
2012-04-17 08:57:41 -06:00
|
|
|
df::unit *unit = getSelectedUnit(out, true);
|
2012-03-22 09:30:15 -06:00
|
|
|
if (!unit)
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
|
|
|
// don't accidentally kill non-ghosts!
|
|
|
|
if (unit->flags3.bits.ghostly)
|
|
|
|
{
|
|
|
|
// remove ghostly, set to dead instead
|
|
|
|
unit->flags3.bits.ghostly = 0;
|
|
|
|
unit->flags1.bits.dead = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out.print("That's not a ghost!\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2012-04-11 14:29:56 -06:00
|
|
|
else if (cmd == "fixmigrant")
|
2012-04-09 16:22:38 -06:00
|
|
|
{
|
2012-04-17 08:57:41 -06:00
|
|
|
df::unit *unit = getSelectedUnit(out, true);
|
2012-04-11 14:29:56 -06:00
|
|
|
if (!unit)
|
|
|
|
return CR_FAILURE;
|
2014-06-03 16:29:13 -06:00
|
|
|
|
2014-08-11 14:07:52 -06:00
|
|
|
if(unit->race != ui->race_id)
|
2012-04-09 16:22:38 -06:00
|
|
|
{
|
2012-04-11 14:29:56 -06:00
|
|
|
out << "Selected unit does not belong to your race!" << endl;
|
2012-04-09 16:22:38 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-04-12 06:40:39 -06:00
|
|
|
// case #1: migrants who have the resident flag set
|
|
|
|
// see http://dffd.wimbli.com/file.php?id=6139 for a save
|
2012-04-11 14:29:56 -06:00
|
|
|
if (unit->flags2.bits.resident)
|
|
|
|
unit->flags2.bits.resident = 0;
|
2014-06-03 16:29:13 -06:00
|
|
|
|
2012-04-12 06:40:39 -06:00
|
|
|
// case #2: migrants who have the merchant flag
|
|
|
|
// happens on almost all maps after a few migrant waves
|
2012-04-11 14:29:56 -06:00
|
|
|
if(unit->flags1.bits.merchant)
|
2012-04-09 16:22:38 -06:00
|
|
|
unit->flags1.bits.merchant = 0;
|
2012-04-11 14:29:56 -06:00
|
|
|
|
2014-06-03 16:29:13 -06:00
|
|
|
// this one is a cheat, but bugged migrants usually have the same civ_id
|
2012-04-12 06:40:39 -06:00
|
|
|
// so it should not be triggered in most cases
|
2014-06-03 16:29:13 -06:00
|
|
|
// if it happens that the player has 'foreign' units of the same race
|
2012-04-12 06:40:39 -06:00
|
|
|
// (vanilla df: dwarves not from mountainhome) on his map, just grab them
|
2014-08-11 14:07:52 -06:00
|
|
|
if(unit->civ_id != ui->civ_id)
|
|
|
|
unit->civ_id = ui->civ_id;
|
2012-04-11 14:29:56 -06:00
|
|
|
|
|
|
|
return fix_clothing_ownership(out, unit);
|
2012-04-09 16:22:38 -06:00
|
|
|
}
|
2012-04-14 05:36:22 -06:00
|
|
|
else if (cmd == "makeown")
|
|
|
|
{
|
|
|
|
// force a unit into your fort, regardless of civ or race
|
|
|
|
// allows to "steal" caravan guards etc
|
2012-04-17 08:57:41 -06:00
|
|
|
df::unit *unit = getSelectedUnit(out, true);
|
2012-04-14 05:36:22 -06:00
|
|
|
if (!unit)
|
|
|
|
return CR_FAILURE;
|
2012-04-17 08:57:41 -06:00
|
|
|
|
2012-04-14 05:36:22 -06:00
|
|
|
if (unit->flags2.bits.resident)
|
|
|
|
unit->flags2.bits.resident = 0;
|
|
|
|
if(unit->flags1.bits.merchant)
|
|
|
|
unit->flags1.bits.merchant = 0;
|
|
|
|
if(unit->flags1.bits.forest)
|
|
|
|
unit->flags1.bits.forest = 0;
|
2014-08-11 14:07:52 -06:00
|
|
|
if(unit->civ_id != ui->civ_id)
|
|
|
|
unit->civ_id = ui->civ_id;
|
2012-04-14 11:06:03 -06:00
|
|
|
if(unit->profession == df::profession::MERCHANT)
|
|
|
|
unit->profession = df::profession::TRADER;
|
|
|
|
if(unit->profession2 == df::profession::MERCHANT)
|
|
|
|
unit->profession2 = df::profession::TRADER;
|
2012-04-14 05:36:22 -06:00
|
|
|
return fix_clothing_ownership(out, unit);
|
|
|
|
}
|
2012-08-26 11:19:56 -06:00
|
|
|
else if (cmd == "stable-cursor")
|
|
|
|
{
|
2012-08-30 10:48:06 -06:00
|
|
|
enable_hook(out, INTERPOSE_HOOK(stable_cursor_hook, feed), parameters);
|
2012-08-26 11:19:56 -06:00
|
|
|
}
|
2012-08-27 13:06:10 -06:00
|
|
|
else if (cmd == "patrol-duty")
|
|
|
|
{
|
2012-08-30 10:48:06 -06:00
|
|
|
enable_hook(out, INTERPOSE_HOOK(patrol_duty_hook, isPatrol), parameters);
|
|
|
|
}
|
2014-06-03 16:29:13 -06:00
|
|
|
else if (cmd == "confirm-embark")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(confirm_embark_hook, feed), parameters);
|
2014-06-04 12:41:35 -06:00
|
|
|
enable_hook(out, INTERPOSE_HOOK(confirm_embark_hook, key_conflict), parameters);
|
2014-06-03 16:29:13 -06:00
|
|
|
enable_hook(out, INTERPOSE_HOOK(confirm_embark_hook, render), parameters);
|
|
|
|
}
|
2012-09-03 11:11:35 -06:00
|
|
|
else if (cmd == "stable-temp")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(stable_temp_hook, adjustTemperature), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(stable_temp_hook, updateContaminants), parameters);
|
|
|
|
}
|
2012-09-14 02:14:36 -06:00
|
|
|
else if (cmd == "fast-heat")
|
|
|
|
{
|
|
|
|
if (parameters.size() < 2)
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
max_heat_ticks = atoi(parameters[1].c_str());
|
|
|
|
if (max_heat_ticks <= 0)
|
|
|
|
parameters[1] = "disable";
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(fast_heat_hook, updateTempFromMap), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(fast_heat_hook, updateTemperature), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(fast_heat_hook, adjustTemperature), parameters);
|
|
|
|
}
|
2014-08-15 02:22:34 -06:00
|
|
|
/*else if (cmd == "fix-dimensions")
|
2012-09-17 07:19:24 -06:00
|
|
|
{
|
2012-10-10 08:22:01 -06:00
|
|
|
enable_hook(out, INTERPOSE_HOOK(dimension_liquid_hook, subtractDimension), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(dimension_powder_hook, subtractDimension), parameters);
|
2012-09-17 07:19:24 -06:00
|
|
|
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);
|
2014-08-15 02:22:34 -06:00
|
|
|
}*/
|
2012-09-18 07:39:37 -06:00
|
|
|
else if (cmd == "advmode-contained")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(advmode_contained_hook, feed), parameters);
|
|
|
|
}
|
2012-09-28 03:32:41 -06:00
|
|
|
else if (cmd == "fast-trade")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(fast_trade_assign_hook, feed), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(fast_trade_select_hook, feed), parameters);
|
|
|
|
}
|
2012-09-28 08:01:17 -06:00
|
|
|
else if (cmd == "military-stable-assign")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(military_assign_hook, feed), parameters);
|
|
|
|
}
|
|
|
|
else if (cmd == "military-color-assigned")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(military_assign_hook, render), parameters);
|
|
|
|
}
|
2014-07-21 12:18:29 -06:00
|
|
|
/*
|
2012-11-16 11:51:07 -07:00
|
|
|
else if (cmd == "military-training")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(military_training_ct_hook, process), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(military_training_sd_hook, process), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(military_training_sp_hook, process), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(military_training_id_hook, process), parameters);
|
2014-07-21 12:18:29 -06:00
|
|
|
}*/
|
2014-05-08 13:22:45 -06:00
|
|
|
else if (cmd == "craft-age-wear")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(craft_age_wear_hook, ageItem), parameters);
|
|
|
|
}
|
|
|
|
else if (cmd == "adamantine-cloth-wear")
|
|
|
|
{
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(adamantine_cloth_wear_armor_hook, incWearTimer), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(adamantine_cloth_wear_helm_hook, incWearTimer), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(adamantine_cloth_wear_gloves_hook, incWearTimer), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(adamantine_cloth_wear_shoes_hook, incWearTimer), parameters);
|
|
|
|
enable_hook(out, INTERPOSE_HOOK(adamantine_cloth_wear_pants_hook, incWearTimer), parameters);
|
|
|
|
}
|
2014-06-03 16:29:13 -06:00
|
|
|
else
|
2012-04-11 14:29:56 -06:00
|
|
|
return CR_WRONG_USAGE;
|
2012-03-05 08:47:06 -07:00
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|