summaryrefslogtreecommitdiff
path: root/plugins/tweak.cpp
diff options
context:
space:
mode:
authorRobert Heinrich2012-04-12 14:40:39 +0200
committerRobert Heinrich2012-04-12 14:40:39 +0200
commit7331485b46636b4c2916d72290812bad97761ae9 (patch)
tree38aff2f8d24b01617acb1c7856482e4808b9960b /plugins/tweak.cpp
parent2caf3fb0643a30decd8d13c981e8c378ccfd1aa1 (diff)
downloaddfhack-7331485b46636b4c2916d72290812bad97761ae9.tar.gz
dfhack-7331485b46636b4c2916d72290812bad97761ae9.tar.bz2
dfhack-7331485b46636b4c2916d72290812bad97761ae9.tar.xz
removed tweak-merchant and tweak-resident, combined both commands into tweak-migrant. added worn items to their uniform so they don't drop their clothes instantly
Diffstat (limited to 'plugins/tweak.cpp')
-rw-r--r--plugins/tweak.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp
index 5f65fe27..a1197a34 100644
--- a/plugins/tweak.cpp
+++ b/plugins/tweak.cpp
@@ -10,6 +10,8 @@
#include "modules/Units.h"
#include "modules/Items.h"
+#include "MiscUtils.h"
+
#include "DataDefs.h"
#include "df/ui.h"
#include "df/world.h"
@@ -71,9 +73,10 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out)
static command_result lair(color_ostream &out, std::vector<std::string> & params);
-// to be called by tweak-merchant and tweak-resident
+// to be called by tweak-fixmigrant
// 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
+// so we need to make them own their clothes and add them to their uniform
command_result fix_clothing_ownership(color_ostream &out, df::unit* unit)
{
// first, find one owned item to initialize the vtable
@@ -109,12 +112,18 @@ command_result fix_clothing_ownership(color_ostream &out, df::unit* unit)
if(!Items::getOwner(item))
{
if(Items::setOwner(item, unit))
+ {
+ // add to uniform, so they know they should wear their clothes
+ insert_into_vector(unit->military.uniforms[0], item->id);
fixcount++;
+ }
else
out << "could not change ownership for item!" << endl;
}
}
}
+ // clear uniform_drop (without this they would drop their clothes and pick them up some time later)
+ unit->military.uniform_drop.clear();
out << "ownership for " << fixcount << " clothes fixed" << endl;
return CR_OK;
}
@@ -180,15 +189,20 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
return CR_FAILURE;
}
+ // case #1: migrants who have the resident flag set
+ // see http://dffd.wimbli.com/file.php?id=6139 for a save
if (unit->flags2.bits.resident)
unit->flags2.bits.resident = 0;
+ // case #2: migrants who have the merchant flag
+ // happens on almost all maps after a few migrant waves
if(unit->flags1.bits.merchant)
unit->flags1.bits.merchant = 0;
- // this one is a cheat, but bugged migrants usually have the same civ_id
- // but if it happens that the player has 'foreign' units of the same race
- // (dwarves not from moutainhome in vanilla df) on his map, just grab them
+ // this one is a cheat, but bugged migrants usually have the same civ_id
+ // so it should not be triggered in most cases
+ // if it happens that the player has 'foreign' units of the same race
+ // (vanilla df: dwarves not from mountainhome) on his map, just grab them
if(unit->civ_id != df::global::ui->civ_id)
unit->civ_id = df::global::ui->civ_id;