|
|
@ -67,6 +67,7 @@ using namespace std;
|
|
|
|
#include "df/general_ref_building_civzone_assignedst.h"
|
|
|
|
#include "df/general_ref_building_civzone_assignedst.h"
|
|
|
|
#include <df/creature_raw.h>
|
|
|
|
#include <df/creature_raw.h>
|
|
|
|
#include <df/caste_raw.h>
|
|
|
|
#include <df/caste_raw.h>
|
|
|
|
|
|
|
|
#include "df/unit_soul.h"
|
|
|
|
#include "df/viewscreen_dwarfmodest.h"
|
|
|
|
#include "df/viewscreen_dwarfmodest.h"
|
|
|
|
#include "modules/Translation.h"
|
|
|
|
#include "modules/Translation.h"
|
|
|
|
|
|
|
|
|
|
|
@ -345,6 +346,7 @@ bool isHunter(df::unit* unit);
|
|
|
|
bool isOwnCiv(df::unit* unit);
|
|
|
|
bool isOwnCiv(df::unit* unit);
|
|
|
|
bool isMerchant(df::unit* unit);
|
|
|
|
bool isMerchant(df::unit* unit);
|
|
|
|
bool isForest(df::unit* unit);
|
|
|
|
bool isForest(df::unit* unit);
|
|
|
|
|
|
|
|
bool isGay(df::unit* unit);
|
|
|
|
|
|
|
|
|
|
|
|
bool isActivityZone(df::building * building);
|
|
|
|
bool isActivityZone(df::building * building);
|
|
|
|
bool isPenPasture(df::building * building);
|
|
|
|
bool isPenPasture(df::building * building);
|
|
|
@ -705,6 +707,13 @@ int getUnitIndexFromId(df::unit* unit_)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isGay(df::unit* unit)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
df::orientation_flags orientation = unit->status.current_soul->orientation_flags;
|
|
|
|
|
|
|
|
return isFemale(unit) && ! (orientation.whole & (orientation.mask_marry_male | orientation.mask_romance_male))
|
|
|
|
|
|
|
|
|| ! isFemale(unit) && ! (orientation.whole & (orientation.mask_marry_female | orientation.mask_romance_female));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// dump some unit info
|
|
|
|
// dump some unit info
|
|
|
|
void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
|
|
|
|
void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2796,13 +2805,18 @@ public:
|
|
|
|
int mk_prot;
|
|
|
|
int mk_prot;
|
|
|
|
int ma_prot;
|
|
|
|
int ma_prot;
|
|
|
|
|
|
|
|
|
|
|
|
// bah, this should better be an array of 4 vectors
|
|
|
|
// butcherable units
|
|
|
|
// that way there's no need for the 4 ugly process methods
|
|
|
|
|
|
|
|
vector <df::unit*> fk_ptr;
|
|
|
|
vector <df::unit*> fk_ptr;
|
|
|
|
vector <df::unit*> mk_ptr;
|
|
|
|
vector <df::unit*> mk_ptr;
|
|
|
|
vector <df::unit*> fa_ptr;
|
|
|
|
vector <df::unit*> fa_ptr;
|
|
|
|
vector <df::unit*> ma_ptr;
|
|
|
|
vector <df::unit*> ma_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// priority butcherable units
|
|
|
|
|
|
|
|
vector <df::unit*> fk_pri_ptr;
|
|
|
|
|
|
|
|
vector <df::unit*> mk_pri_ptr;
|
|
|
|
|
|
|
|
vector <df::unit*> fa_pri_ptr;
|
|
|
|
|
|
|
|
vector <df::unit*> ma_pri_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
WatchedRace(bool watch, int id, int _fk, int _mk, int _fa, int _ma)
|
|
|
|
WatchedRace(bool watch, int id, int _fk, int _mk, int _fa, int _ma)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
isWatched = watch;
|
|
|
|
isWatched = watch;
|
|
|
@ -2856,6 +2870,10 @@ public:
|
|
|
|
sort(mk_ptr.begin(), mk_ptr.end(), compareUnitAgesOlder);
|
|
|
|
sort(mk_ptr.begin(), mk_ptr.end(), compareUnitAgesOlder);
|
|
|
|
sort(fa_ptr.begin(), fa_ptr.end(), compareUnitAgesYounger);
|
|
|
|
sort(fa_ptr.begin(), fa_ptr.end(), compareUnitAgesYounger);
|
|
|
|
sort(ma_ptr.begin(), ma_ptr.end(), compareUnitAgesYounger);
|
|
|
|
sort(ma_ptr.begin(), ma_ptr.end(), compareUnitAgesYounger);
|
|
|
|
|
|
|
|
sort(fk_pri_ptr.begin(), fk_pri_ptr.end(), compareUnitAgesOlder);
|
|
|
|
|
|
|
|
sort(mk_pri_ptr.begin(), mk_pri_ptr.end(), compareUnitAgesOlder);
|
|
|
|
|
|
|
|
sort(fa_pri_ptr.begin(), fa_pri_ptr.end(), compareUnitAgesYounger);
|
|
|
|
|
|
|
|
sort(ma_pri_ptr.begin(), ma_pri_ptr.end(), compareUnitAgesYounger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PushUnit(df::unit * unit)
|
|
|
|
void PushUnit(df::unit * unit)
|
|
|
@ -2876,6 +2894,24 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PushPriorityUnit(df::unit * unit)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(isFemale(unit))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(isBaby(unit) || isChild(unit))
|
|
|
|
|
|
|
|
fk_pri_ptr.push_back(unit);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
fa_pri_ptr.push_back(unit);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(isBaby(unit) || isChild(unit))
|
|
|
|
|
|
|
|
mk_pri_ptr.push_back(unit);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ma_pri_ptr.push_back(unit);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PushProtectedUnit(df::unit * unit)
|
|
|
|
void PushProtectedUnit(df::unit * unit)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(isFemale(unit))
|
|
|
|
if(isFemale(unit))
|
|
|
@ -2901,55 +2937,27 @@ public:
|
|
|
|
mk_ptr.clear();
|
|
|
|
mk_ptr.clear();
|
|
|
|
fa_ptr.clear();
|
|
|
|
fa_ptr.clear();
|
|
|
|
ma_ptr.clear();
|
|
|
|
ma_ptr.clear();
|
|
|
|
|
|
|
|
fk_pri_ptr.clear();
|
|
|
|
|
|
|
|
mk_pri_ptr.clear();
|
|
|
|
|
|
|
|
fa_pri_ptr.clear();
|
|
|
|
|
|
|
|
ma_pri_ptr.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ProcessUnits_fk()
|
|
|
|
int ProcessUnits(vector<df::unit*>& unit_ptr, vector<df::unit*>& unit_pri_ptr, int prot, int goal)
|
|
|
|
{
|
|
|
|
|
|
|
|
int subcount = 0;
|
|
|
|
|
|
|
|
while(fk_ptr.size() && (fk_ptr.size() + fk_prot > fk) )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
df::unit* unit = fk_ptr.back();
|
|
|
|
|
|
|
|
doMarkForSlaughter(unit);
|
|
|
|
|
|
|
|
fk_ptr.pop_back();
|
|
|
|
|
|
|
|
subcount++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return subcount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ProcessUnits_mk()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int subcount = 0;
|
|
|
|
|
|
|
|
while(mk_ptr.size() && (mk_ptr.size() + mk_prot > mk) )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
df::unit* unit = mk_ptr.back();
|
|
|
|
|
|
|
|
doMarkForSlaughter(unit);
|
|
|
|
|
|
|
|
mk_ptr.pop_back();
|
|
|
|
|
|
|
|
subcount++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return subcount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ProcessUnits_fa()
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int subcount = 0;
|
|
|
|
int subcount = 0;
|
|
|
|
while(fa_ptr.size() && (fa_ptr.size() + fa_prot > fa) )
|
|
|
|
while(unit_pri_ptr.size() && (unit_ptr.size() + unit_pri_ptr.size() + prot > goal) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
df::unit* unit = fa_ptr.back();
|
|
|
|
df::unit* unit = unit_pri_ptr.back();
|
|
|
|
doMarkForSlaughter(unit);
|
|
|
|
doMarkForSlaughter(unit);
|
|
|
|
fa_ptr.pop_back();
|
|
|
|
unit_pri_ptr.pop_back();
|
|
|
|
subcount++;
|
|
|
|
subcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return subcount;
|
|
|
|
while(unit_ptr.size() && (unit_ptr.size() + prot > goal) )
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ProcessUnits_ma()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int subcount = 0;
|
|
|
|
|
|
|
|
while(ma_ptr.size() && (ma_ptr.size() + ma_prot > ma) )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
df::unit* unit = ma_ptr.back();
|
|
|
|
df::unit* unit = unit_ptr.back();
|
|
|
|
doMarkForSlaughter(unit);
|
|
|
|
doMarkForSlaughter(unit);
|
|
|
|
ma_ptr.pop_back();
|
|
|
|
unit_ptr.pop_back();
|
|
|
|
subcount++;
|
|
|
|
subcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return subcount;
|
|
|
|
return subcount;
|
|
|
@ -2959,10 +2967,10 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SortUnitsByAge();
|
|
|
|
SortUnitsByAge();
|
|
|
|
int slaughter_count = 0;
|
|
|
|
int slaughter_count = 0;
|
|
|
|
slaughter_count += ProcessUnits_fk();
|
|
|
|
slaughter_count += ProcessUnits(fk_ptr, fk_pri_ptr, fk_prot, fk);
|
|
|
|
slaughter_count += ProcessUnits_mk();
|
|
|
|
slaughter_count += ProcessUnits(mk_ptr, mk_pri_ptr, mk_prot, mk);
|
|
|
|
slaughter_count += ProcessUnits_fa();
|
|
|
|
slaughter_count += ProcessUnits(fa_ptr, fa_pri_ptr, fa_prot, fa);
|
|
|
|
slaughter_count += ProcessUnits_ma();
|
|
|
|
slaughter_count += ProcessUnits(ma_ptr, ma_pri_ptr, ma_prot, ma);
|
|
|
|
ClearUnits();
|
|
|
|
ClearUnits();
|
|
|
|
return slaughter_count;
|
|
|
|
return slaughter_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3473,6 +3481,8 @@ command_result autoButcher( color_ostream &out, bool verbose = false )
|
|
|
|
|| isAvailableForAdoption(unit)
|
|
|
|
|| isAvailableForAdoption(unit)
|
|
|
|
|| unit->name.has_name )
|
|
|
|
|| unit->name.has_name )
|
|
|
|
w->PushProtectedUnit(unit);
|
|
|
|
w->PushProtectedUnit(unit);
|
|
|
|
|
|
|
|
else if (isGay(unit))
|
|
|
|
|
|
|
|
w->PushPriorityUnit(unit);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
w->PushUnit(unit);
|
|
|
|
w->PushUnit(unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|