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

develop
Robert Heinrich 2012-04-12 14:40:39 +02:00
parent 2caf3fb064
commit 7331485b46
1 changed files with 18 additions and 4 deletions

@ -10,6 +10,8 @@
#include "modules/Units.h" #include "modules/Units.h"
#include "modules/Items.h" #include "modules/Items.h"
#include "MiscUtils.h"
#include "DataDefs.h" #include "DataDefs.h"
#include "df/ui.h" #include "df/ui.h"
#include "df/world.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); 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 // 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 // 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) command_result fix_clothing_ownership(color_ostream &out, df::unit* unit)
{ {
// first, find one owned item to initialize the vtable // 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::getOwner(item))
{ {
if(Items::setOwner(item, unit)) 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++; fixcount++;
}
else else
out << "could not change ownership for item!" << endl; 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; out << "ownership for " << fixcount << " clothes fixed" << endl;
return CR_OK; return CR_OK;
} }
@ -180,15 +189,20 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
return CR_FAILURE; 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) if (unit->flags2.bits.resident)
unit->flags2.bits.resident = 0; 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) if(unit->flags1.bits.merchant)
unit->flags1.bits.merchant = 0; unit->flags1.bits.merchant = 0;
// this one is a cheat, but bugged migrants usually have the same civ_id // 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 // so it should not be triggered in most cases
// (dwarves not from moutainhome in vanilla df) on his map, just grab them // 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) if(unit->civ_id != df::global::ui->civ_id)
unit->civ_id = df::global::ui->civ_id; unit->civ_id = df::global::ui->civ_id;