Fix warnings in supported plugins.

develop
Ben Lubar 2018-04-06 01:18:15 -05:00
parent f3038fef09
commit a7dfacd1c5
No known key found for this signature in database
GPG Key ID: 018BAB45DB2D2B24
53 changed files with 246 additions and 277 deletions

@ -130,7 +130,7 @@ public:
while (mc.testCoord(start)) while (mc.testCoord(start))
{ {
df::tiletype tt = mc.tiletypeAt(start); df::tiletype tt = mc.tiletypeAt(start);
if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt)) if(DFHack::LowPassable(tt) || (juststarted && DFHack::HighPassable(tt)))
{ {
v.push_back(start); v.push_back(start);
juststarted = false; juststarted = false;

@ -267,10 +267,8 @@ static bool skip_plant(const df::plant * plant, bool *restricted)
if (skip.food_trees || skip.cook_trees) if (skip.food_trees || skip.cook_trees)
{ {
df::material * mat; for (df::material * mat : plant_raw->material)
for (int idx = 0; idx < plant_raw->material.size(); idx++)
{ {
mat = plant_raw->material[idx];
if (skip.food_trees && mat->flags.is_set(material_flags::EDIBLE_RAW)) if (skip.food_trees && mat->flags.is_set(material_flags::EDIBLE_RAW))
{ {
if (restricted) if (restricted)

@ -624,7 +624,7 @@ static void init_state()
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str());
// Ensure that the labor is defined in the existing list // Ensure that the labor is defined in the existing list
if (labor >= 0 && labor <= labor_infos.size()) if (labor >= 0 && size_t(labor) <= labor_infos.size())
{ {
// Link the labor treatment with the associated persistent data item // Link the labor treatment with the associated persistent data item
labor_infos[labor].set_config(*p); labor_infos[labor].set_config(*p);
@ -635,7 +635,7 @@ static void init_state()
} }
// Add default labors for those not in save // Add default labors for those not in save
for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) { for (size_t i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
// Determine if the labor is already present. If so, exit the for loop // Determine if the labor is already present. If so, exit the for loop
if (labor_infos[i].config.isValid()) if (labor_infos[i].config.isValid())
@ -806,7 +806,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
// Scan the world and look for any citizens in the player's civilization. // Scan the world and look for any citizens in the player's civilization.
// Add these to the list of dwarves. // Add these to the list of dwarves.
// xxx Does it need to be ++i? // xxx Does it need to be ++i?
for (int i = 0; i < world->units.active.size(); ++i) for (size_t i = 0; i < world->units.active.size(); ++i)
{ {
df::unit* cre = world->units.active[i]; df::unit* cre = world->units.active[i];
if (Units::isCitizen(cre)) if (Units::isCitizen(cre))
@ -895,7 +895,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else else
{ {
int job = dwarfs[dwarf]->job.current_job->job_type; int job = dwarfs[dwarf]->job.current_job->job_type;
if (job >= 0 && job < ARRAY_COUNT(dwarf_states)) if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
dwarf_info[dwarf].state = dwarf_states[job]; dwarf_info[dwarf].state = dwarf_states[job];
else else
{ {
@ -960,7 +960,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
continue; continue;
// For every dwarf... // For every dwarf...
for(int dwarf = 0; dwarf < dwarfs.size(); dwarf++) for(size_t dwarf = 0; dwarf < dwarfs.size(); dwarf++)
{ {
if (!Units::isValidLabor(dwarfs[dwarf], labor)) if (!Units::isValidLabor(dwarfs[dwarf], labor))
continue; continue;
@ -1138,7 +1138,7 @@ command_result autohauler (color_ostream &out, std::vector <std::string> & param
return CR_FAILURE; return CR_FAILURE;
} }
for (int i = 0; i < labor_infos.size(); i++) for (size_t i = 0; i < labor_infos.size(); i++)
{ {
reset_labor((df::unit_labor) i); reset_labor((df::unit_labor) i);
} }

@ -606,7 +606,7 @@ static void init_state()
{ {
string key = p->key(); string key = p->key();
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str());
if (labor >= 0 && labor <= labor_infos.size()) if (labor >= 0 && size_t(labor) <= labor_infos.size())
{ {
labor_infos[labor].config = *p; labor_infos[labor].config = *p;
labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive; labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive;
@ -615,7 +615,7 @@ static void init_state()
} }
// Add default labors for those not in save // Add default labors for those not in save
for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) { for (size_t i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
if (labor_infos[i].config.isValid()) if (labor_infos[i].config.isValid())
continue; continue;
@ -960,7 +960,7 @@ static void assign_labor(unit_labor::unit_labor labor,
* Military and children/nobles will not have labors assigned. * Military and children/nobles will not have labors assigned.
* Dwarfs with the "health management" responsibility are always assigned DIAGNOSIS. * Dwarfs with the "health management" responsibility are always assigned DIAGNOSIS.
*/ */
for (int i = 0; i < candidates.size() && labor_infos[labor].active_dwarfs < max_dwarfs; i++) for (size_t i = 0; i < candidates.size() && labor_infos[labor].active_dwarfs < max_dwarfs; i++)
{ {
int dwarf = candidates[i]; int dwarf = candidates[i];
@ -1048,7 +1048,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
bool has_fishery = false; bool has_fishery = false;
bool trader_requested = false; bool trader_requested = false;
for (int i = 0; i < world->buildings.all.size(); ++i) for (size_t i = 0; i < world->buildings.all.size(); ++i)
{ {
df::building *build = world->buildings.all[i]; df::building *build = world->buildings.all[i];
auto type = build->getType(); auto type = build->getType();
@ -1074,7 +1074,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
} }
} }
for (int i = 0; i < world->units.active.size(); ++i) for (size_t i = 0; i < world->units.active.size(); ++i)
{ {
df::unit* cre = world->units.active[i]; df::unit* cre = world->units.active[i];
if (Units::isCitizen(cre)) if (Units::isCitizen(cre))
@ -1105,7 +1105,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
df::historical_figure* hf = df::historical_figure::find(dwarfs[dwarf]->hist_figure_id); df::historical_figure* hf = df::historical_figure::find(dwarfs[dwarf]->hist_figure_id);
if(hf!=NULL) //can be NULL. E.g. script created citizens if(hf!=NULL) //can be NULL. E.g. script created citizens
for (int i = 0; i < hf->entity_links.size(); i++) for (size_t i = 0; i < hf->entity_links.size(); i++)
{ {
df::histfig_entity_link* hfelink = hf->entity_links.at(i); df::histfig_entity_link* hfelink = hf->entity_links.at(i);
if (hfelink->getType() == df::histfig_entity_link_type::POSITION) if (hfelink->getType() == df::histfig_entity_link_type::POSITION)
@ -1140,7 +1140,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
// identify dwarfs who are needed for meetings and mark them for exclusion // identify dwarfs who are needed for meetings and mark them for exclusion
for (int i = 0; i < ui->activities.size(); ++i) for (size_t i = 0; i < ui->activities.size(); ++i)
{ {
df::activity_info *act = ui->activities[i]; df::activity_info *act = ui->activities[i];
if (!act) continue; if (!act) continue;
@ -1230,7 +1230,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else else
{ {
int job = dwarfs[dwarf]->job.current_job->job_type; int job = dwarfs[dwarf]->job.current_job->job_type;
if (job >= 0 && job < ARRAY_COUNT(dwarf_states)) if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
dwarf_info[dwarf].state = dwarf_states[job]; dwarf_info[dwarf].state = dwarf_states[job];
else else
{ {
@ -1341,7 +1341,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
for (int i = 0; i < num_haulers; i++) for (int i = 0; i < num_haulers; i++)
{ {
assert(i < hauler_ids.size()); assert(size_t(i) < hauler_ids.size());
int dwarf = hauler_ids[i]; int dwarf = hauler_ids[i];
@ -1357,7 +1357,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
out.print("Dwarf %i \"%s\" assigned %s: hauler\n", dwarf, dwarfs[dwarf]->name.first_name.c_str(), ENUM_KEY_STR(unit_labor, labor).c_str()); out.print("Dwarf %i \"%s\" assigned %s: hauler\n", dwarf, dwarfs[dwarf]->name.first_name.c_str(), ENUM_KEY_STR(unit_labor, labor).c_str());
} }
for (int i = num_haulers; i < hauler_ids.size(); i++) for (size_t i = num_haulers; i < hauler_ids.size(); i++)
{ {
assert(i < hauler_ids.size()); assert(i < hauler_ids.size());
@ -1517,7 +1517,7 @@ command_result autolabor (color_ostream &out, std::vector <std::string> & parame
return CR_FAILURE; return CR_FAILURE;
} }
for (int i = 0; i < labor_infos.size(); i++) for (size_t i = 0; i < labor_infos.size(); i++)
{ {
reset_labor((df::unit_labor) i); reset_labor((df::unit_labor) i);
} }

@ -69,12 +69,6 @@ struct MaterialDescriptor
} }
}; };
static command_result automaterial_cmd(color_ostream &out, vector <string> & parameters)
{
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( color_ostream &out ) DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{ {
return CR_OK; return CR_OK;
@ -1124,6 +1118,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
break; break;
case SELECT_SECOND: case SELECT_SECOND:
{
OutputString(COLOR_GREEN, x, y, "Choose second corner", true, left_margin); OutputString(COLOR_GREEN, x, y, "Choose second corner", true, left_margin);
int32_t curr_x, curr_y, curr_z; int32_t curr_x, curr_y, curr_z;
@ -1137,6 +1132,11 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
int cx = box_first.x; int cx = box_first.x;
int cy = box_first.y; int cy = box_first.y;
OutputString(COLOR_BROWN, cx, cy, "X", false, 0, 0, true /* map */); OutputString(COLOR_BROWN, cx, cy, "X", false, 0, 0, true /* map */);
break;
}
default:
break;
} }
OutputString(COLOR_BROWN, x, ++y, "Ignore Building Restrictions", true, left_margin); OutputString(COLOR_BROWN, x, ++y, "Ignore Building Restrictions", true, left_margin);

@ -106,9 +106,9 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
{ {
if (! b) if (! b)
return " "; return " ";
bool at_nw_corner = x == b->x1 && y == b->y1; bool at_nw_corner = int32_t(x) == b->x1 && int32_t(y) == b->y1;
bool at_se_corner = x == b->x2 && y == b->y2; bool at_se_corner = int32_t(x) == b->x2 && int32_t(y) == b->y2;
bool at_center = x == b->centerx && y == b->centery; bool at_center = int32_t(x) == b->centerx && int32_t(y) == b->centery;
pair<uint32_t, uint32_t> size = get_building_size(b); pair<uint32_t, uint32_t> size = get_building_size(b);
stringstream out;// = stringstream(); stringstream out;// = stringstream();
switch(b->getType()) switch(b->getType())
@ -227,7 +227,10 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
return "wy"; return "wy";
case workshop_type::Dyers: case workshop_type::Dyers:
return "wd"; return "wd";
case workshop_type::Kennels:
return "k";
case workshop_type::Custom: case workshop_type::Custom:
case workshop_type::Tool:
//can't do anything with custom workshop //can't do anything with custom workshop
return "`"; return "`";
} }
@ -261,6 +264,8 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
case building_type::Construction: case building_type::Construction:
switch (((df::building_constructionst*) b)->type) switch (((df::building_constructionst*) b)->type)
{ {
case construction_type::NONE:
return "`";
case construction_type::Fortification: case construction_type::Fortification:
return "CF"; return "CF";
case construction_type::Wall: case construction_type::Wall:
@ -482,7 +487,7 @@ string get_tile_place(uint32_t x, uint32_t y, df::building* b)
{ {
if (! b || b->getType() != building_type::Stockpile) if (! b || b->getType() != building_type::Stockpile)
return " "; return " ";
if (b->x1 != x || b->y1 != y) if (b->x1 != int32_t(x) || b->y1 != int32_t(y))
return "`"; return "`";
pair<uint32_t, uint32_t> size = get_building_size(b); pair<uint32_t, uint32_t> size = get_building_size(b);
df::building_stockpilest* sp = (df::building_stockpilest*) b; df::building_stockpilest* sp = (df::building_stockpilest*) b;

@ -287,7 +287,7 @@ struct work_hook : df::building_workshopst{
} }
int w=db->x2-db->x1+1; int w=db->x2-db->x1+1;
std::vector<graphic_tile> &cur_frame=def->frames[frame]; std::vector<graphic_tile> &cur_frame=def->frames[frame];
for(int i=0;i<cur_frame.size();i++) for(size_t i=0;i<cur_frame.size();i++)
{ {
if(cur_frame[i].tile>=0) if(cur_frame[i].tile>=0)
{ {

@ -17,7 +17,7 @@ void enable_quickfort_fn(pair<const df::building_type, bool>& pair) { pair.secon
* Material Choice Screen * Material Choice Screen
*/ */
static std::string material_to_string_fn(DFHack::MaterialInfo m) { return m.toString(); } std::string material_to_string_fn(DFHack::MaterialInfo m) { return m.toString(); }
bool ItemFilter::matchesMask(DFHack::MaterialInfo &mat) bool ItemFilter::matchesMask(DFHack::MaterialInfo &mat)
{ {
@ -131,7 +131,7 @@ void ItemFilter::clear()
materials.clear(); materials.clear();
} }
static DFHack::MaterialInfo &material_info_identity_fn(DFHack::MaterialInfo &m) { return m; } DFHack::MaterialInfo &material_info_identity_fn(DFHack::MaterialInfo &m) { return m; }
ViewscreenChooseMaterial::ViewscreenChooseMaterial(ItemFilter *filter) ViewscreenChooseMaterial::ViewscreenChooseMaterial(ItemFilter *filter)
{ {
@ -386,7 +386,7 @@ void RoomMonitor::reset(color_ostream &out)
} }
static void delete_item_fn(df::job_item *x) { delete x; } void delete_item_fn(df::job_item *x) { delete x; }
// START Planning // START Planning
@ -654,3 +654,12 @@ void Planner::cycleDefaultQuality(df::building_type type)
if (*quality == item_quality::Artifact) if (*quality == item_quality::Artifact)
(*quality) = item_quality::Ordinary; (*quality) = item_quality::Ordinary;
} }
map<df::building_type, bool> planmode_enabled, saved_planmodes;
bool show_debugging = false;
bool show_help = false;
Planner planner;
RoomMonitor roomMonitor;

@ -65,7 +65,7 @@ struct MaterialDescriptor
#define MAX_MATERIAL 21 #define MAX_MATERIAL 21
#define SIDEBAR_WIDTH 30 #define SIDEBAR_WIDTH 30
static bool canReserveRoom(df::building *building) static inline bool canReserveRoom(df::building *building)
{ {
if (!building) if (!building)
return false; return false;
@ -76,7 +76,7 @@ static bool canReserveRoom(df::building *building)
return building->is_room; return building->is_room;
} }
static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit) static inline std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
{ {
std::vector<Units::NoblePosition> np; std::vector<Units::NoblePosition> np;
Units::getNoblePositions(&np, unit); Units::getNoblePositions(&np, unit);
@ -92,19 +92,19 @@ static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
return np; return np;
} }
static void delete_item_fn(df::job_item *x); void delete_item_fn(df::job_item *x);
static MaterialInfo &material_info_identity_fn(MaterialInfo &m); MaterialInfo &material_info_identity_fn(MaterialInfo &m);
static map<df::building_type, bool> planmode_enabled, saved_planmodes; extern map<df::building_type, bool> planmode_enabled, saved_planmodes;
void enable_quickfort_fn(pair<const df::building_type, bool>& pair); void enable_quickfort_fn(pair<const df::building_type, bool>& pair);
void debug(const std::string &msg); void debug(const std::string &msg);
static std::string material_to_string_fn(MaterialInfo m); std::string material_to_string_fn(MaterialInfo m);
static bool show_debugging = false; extern bool show_debugging;
static bool show_help = false; extern bool show_help;
struct ItemFilter struct ItemFilter
{ {
@ -387,7 +387,7 @@ class Planner
public: public:
bool in_dummmy_screen; bool in_dummmy_screen;
Planner() : quickfort_mode(false), in_dummmy_screen(false) { } Planner() : in_dummmy_screen(false), quickfort_mode(false) { }
bool isPlanableBuilding(const df::building_type type) const bool isPlanableBuilding(const df::building_type type) const
{ {
@ -491,8 +491,8 @@ private:
} }
}; };
static Planner planner; extern Planner planner;
static RoomMonitor roomMonitor; extern RoomMonitor roomMonitor;
#endif #endif

@ -194,7 +194,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
df::interface_key last_token = get_string_key(input); df::interface_key last_token = get_string_key(input);
if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A058) if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A058)
{ {
int selection = last_token - interface_key::STRING_A048; size_t selection = last_token - interface_key::STRING_A048;
if (np.size() < selection) if (np.size() < selection)
return false; return false;
roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code); roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code);
@ -317,7 +317,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
int y = 24; int y = 24;
OutputString(COLOR_BROWN, x, y, "DFHack", true, left_margin); OutputString(COLOR_BROWN, x, y, "DFHack", true, left_margin);
OutputString(COLOR_WHITE, x, y, "Auto-allocate to:", true, left_margin); OutputString(COLOR_WHITE, x, y, "Auto-allocate to:", true, left_margin);
for (int i = 0; i < np.size() && i < 9; i++) for (size_t i = 0; i < np.size() && i < 9; i++)
{ {
bool enabled = (roomMonitor.getReservedNobleCode(world->selected_building->id) bool enabled = (roomMonitor.getReservedNobleCode(world->selected_building->id)
== np[i].position->code); == np[i].position->code);

@ -227,7 +227,7 @@ command_result changelayer (color_ostream &out, std::vector <std::string> & para
{ {
if(verbose) if(verbose)
out << "---Biome: " << i; out << "---Biome: " << i;
if(!all_biomes && i!=biome) if(!all_biomes && uint32_t(i)!=biome)
{ {
if(verbose) if(verbose)
out << "-skipping" << endl; out << "-skipping" << endl;
@ -257,7 +257,7 @@ command_result changelayer (color_ostream &out, std::vector <std::string> & para
out << "geoindex: " << geoindex << endl; out << "geoindex: " << geoindex << endl;
bool skip = false; bool skip = false;
for(int g=0; g<v_geoprocessed.size(); g++) for(int g=0; size_t(g)<v_geoprocessed.size(); g++)
{ {
if(v_geoprocessed.at(g)==geoindex) if(v_geoprocessed.at(g)==geoindex)
{ {

@ -56,7 +56,7 @@ public:
df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); } df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); }
std::string getFocusString() { return "commandprompt"; } std::string getFocusString() { return "commandprompt"; }
viewscreen_commandpromptst(std::string entry):is_response(false), submitted(false) viewscreen_commandpromptst(std::string entry):submitted(false), is_response(false)
{ {
show_fps=gps->display_frames; show_fps=gps->display_frames;
gps->display_frames=0; gps->display_frames=0;
@ -172,7 +172,7 @@ void viewscreen_commandpromptst::render()
if(cursor_pos < (dim.x - 10)) if(cursor_pos < (dim.x - 10))
{ {
Screen::paintString(Screen::Pen(' ', 7, 0), 10,0 , entry); Screen::paintString(Screen::Pen(' ', 7, 0), 10,0 , entry);
if (entry.size() > dim.x - 10) if (int16_t(entry.size()) > dim.x - 10)
Screen::paintTile(Screen::Pen('\032', 7, 0), dim.x - 1, 0); Screen::paintTile(Screen::Pen('\032', 7, 0), dim.x - 1, 0);
if (cursor != " ") if (cursor != " ")
Screen::paintString(Screen::Pen(' ', 10, 0), 10 + cursor_pos, 0, cursor); Screen::paintString(Screen::Pen(' ', 10, 0), 10 + cursor_pos, 0, cursor);
@ -243,7 +243,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
entry.erase(cursor_pos - 1, 1); entry.erase(cursor_pos - 1, 1);
cursor_pos--; cursor_pos--;
} }
if(cursor_pos > entry.size()) if(size_t(cursor_pos) > entry.size())
cursor_pos = entry.size(); cursor_pos = entry.size();
continue; continue;
} }
@ -260,7 +260,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
if(events->count(interface_key::CURSOR_RIGHT)) if(events->count(interface_key::CURSOR_RIGHT))
{ {
cursor_pos++; cursor_pos++;
if (cursor_pos > entry.size()) if (size_t(cursor_pos) > entry.size())
cursor_pos = entry.size(); cursor_pos = entry.size();
} }
else if(events->count(interface_key::CURSOR_LEFT)) else if(events->count(interface_key::CURSOR_LEFT))
@ -294,10 +294,10 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
} }
else if(events->count(interface_key::CURSOR_DOWN)) else if(events->count(interface_key::CURSOR_DOWN))
{ {
if (history_idx < command_history.size() - 1) if (size_t(history_idx) < command_history.size() - 1)
{ {
history_idx++; history_idx++;
if (history_idx >= command_history.size()) if (size_t(history_idx) >= command_history.size())
history_idx = command_history.size() - 1; history_idx = command_history.size() - 1;
entry = get_entry(); entry = get_entry();
cursor_pos = entry.size(); cursor_pos = entry.size();

@ -92,7 +92,7 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it
return false; return false;
// if we asked to make shoes and we got twice as many as we asked, then we're okay // if we asked to make shoes and we got twice as many as we asked, then we're okay
// otherwise, make a second set because shoes are normally made in pairs // otherwise, make a second set because shoes are normally made in pairs
if (is_shoes && out_items.size() == prod->count * 2) if (is_shoes && out_items.size() == size_t(prod->count * 2))
is_shoes = false; is_shoes = false;
MapExtras::MapCache mc; MapExtras::MapCache mc;

@ -812,14 +812,14 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
int x = 0,mx = 16; int x = 0,mx = 16;
if(bx == 0) if(bx == 0)
x = 1; x = 1;
if(bx == x_max - 1) if(int(bx) == x_max - 1)
mx = 15; mx = 15;
for(; x < mx; x++) for(; x < mx; x++)
{ {
int y = 0,my = 16; int y = 0,my = 16;
if(by == 0) if(by == 0)
y = 1; y = 1;
if(by == y_max - 1) if(int(by) == y_max - 1)
my = 15; my = 15;
for(; y < my; y++) for(; y < my; y++)
{ {
@ -838,8 +838,8 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
if(dm[y][x]) if(dm[y][x])
{ {
if(what == EXPLO_ALL if(what == EXPLO_ALL
|| des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED || (des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED)
|| des.bits.hidden && what == EXPLO_HIDDEN) || (des.bits.hidden && what == EXPLO_HIDDEN))
{ {
des.bits.dig = tile_dig_designation::Default; des.bits.dig = tile_dig_designation::Default;
} }
@ -948,7 +948,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
int which; int which;
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
{ {
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
which = (4*x + y) % 5; which = (4*x + y) % 5;
stamp_pattern(x,y_max - 1 - y, z_level, diag5[which], stamp_pattern(x,y_max - 1 - y, z_level, diag5[which],
@ -961,7 +961,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
int which; int which;
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
{ {
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
which = (4*x + 1000-y) % 5; which = (4*x + 1000-y) % 5;
stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which], stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which],
@ -975,7 +975,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
{ {
which = x % 3; which = x % 3;
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
stamp_pattern(x, y, z_level, ladder[which], stamp_pattern(x, y, z_level, ladder[which],
how, what, x_max, y_max); how, what, x_max, y_max);
@ -985,7 +985,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
else if(how == EXPLO_LADDERR) else if(how == EXPLO_LADDERR)
{ {
int which; int which;
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
which = y % 3; which = y % 3;
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
@ -1023,7 +1023,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
} }
else for(uint32_t x = 0; x < x_max; x++) else for(uint32_t x = 0; x < x_max; x++)
{ {
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
stamp_pattern(x, y, z_level, all_tiles, stamp_pattern(x, y, z_level, all_tiles,
how, what, x_max, y_max); how, what, x_max, y_max);
@ -1075,7 +1075,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1) if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1)
{ {
con.printerr("I won't dig the borders. That would be cheating!\n"); con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE; return CR_FAILURE;
@ -1136,10 +1136,10 @@ command_result digv (color_ostream &out, vector <string> & parameters)
{ {
MCache->setTagAt(current, 1); MCache->setTagAt(current, 1);
if(current.x < tx_max - 2) if(current.x < int32_t(tx_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
@ -1153,7 +1153,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
if(current.x > 1) if(current.x > 1)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
@ -1178,7 +1178,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
des.bits.dig = tile_dig_designation::DownStair; des.bits.dig = tile_dig_designation::DownStair;
} }
if(current.z < z_max - 1 && above && vmat_plus == vmat2) if(current.z < int32_t(z_max) - 1 && above && vmat_plus == vmat2)
{ {
flood.push(current+ 1); flood.push(current+ 1);
@ -1262,7 +1262,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1) if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1)
{ {
con.printerr("I won't dig the borders. That would be cheating!\n"); con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE; return CR_FAILURE;
@ -1320,10 +1320,10 @@ command_result digl (color_ostream &out, vector <string> & parameters)
if(MCache->testCoord(current)) if(MCache->testCoord(current))
{ {
MCache->setTagAt(current, 1); MCache->setTagAt(current, 1);
if(current.x < tx_max - 2) if(current.x < int32_t(tx_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y + 1, current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z));
@ -1337,7 +1337,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
if(current.x > 1) if(current.x > 1)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y, current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y, current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y + 1, current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z));
@ -1389,7 +1389,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
des.bits.dig = tile_dig_designation::DownStair; des.bits.dig = tile_dig_designation::DownStair;
} }
if(current.z < z_max - 1 && above && vmat_plus == -1 && bmat_plus == basemat) if(current.z < int32_t(z_max) - 1 && above && vmat_plus == -1 && bmat_plus == basemat)
{ {
flood.push(current+ 1); flood.push(current+ 1);
@ -1438,7 +1438,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
uint32_t targetDigType; int32_t targetDigType;
if ( parameters.size() == 1 ) if ( parameters.size() == 1 )
{ {
string parameter = parameters[0]; string parameter = parameters[0];
@ -1526,7 +1526,6 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
continue; continue;
//designate it for digging //designate it for digging
df::tile_designation des = mCache->designationAt(current);
if ( !mCache->testCoord(current) ) if ( !mCache->testCoord(current) )
{ {
out.printerr("testCoord failed at (%d,%d,%d)\n", x, y, z); out.printerr("testCoord failed at (%d,%d,%d)\n", x, y, z);

@ -137,7 +137,7 @@ void maybeExplore(color_ostream& out, MapExtras::MapCache& cache, df::coord pt,
uint32_t xMax,yMax,zMax; uint32_t xMax,yMax,zMax;
Maps::getSize(xMax,yMax,zMax); Maps::getSize(xMax,yMax,zMax);
if ( pt.x == 0 || pt.y == 0 || pt.x+1 == xMax*16 || pt.y+1 == yMax*16 ) if ( pt.x == 0 || pt.y == 0 || pt.x+1 == int32_t(xMax)*16 || pt.y+1 == int32_t(yMax)*16 )
return; return;
if ( jobLocations.find(pt) != jobLocations.end() ) { if ( jobLocations.find(pt) != jobLocations.end() ) {
return; return;

@ -68,8 +68,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
} }
//out.print("first important edge: (%d,%d,%d) -> (%d,%d,%d)\n", pt1.x,pt1.y,pt1.z, pt2.x,pt2.y,pt2.z); //out.print("first important edge: (%d,%d,%d) -> (%d,%d,%d)\n", pt1.x,pt1.y,pt1.z, pt2.x,pt2.y,pt2.z);
int32_t jobId = -1;
df::map_block* block1 = Maps::getTileBlock(pt1); df::map_block* block1 = Maps::getTileBlock(pt1);
df::map_block* block2 = Maps::getTileBlock(pt2); df::map_block* block2 = Maps::getTileBlock(pt2);
bool passable1 = block1->walkable[pt1.x&0xF][pt1.y&0xF]; bool passable1 = block1->walkable[pt1.x&0xF][pt1.y&0xF];
@ -111,7 +109,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
building->jobs.clear(); building->jobs.clear();
building->jobs.push_back(job); building->jobs.push_back(job);
Job::linkIntoWorld(job); Job::linkIntoWorld(job);
jobId = job->id;
job->completion_timer = abilities.jobDelay[CostDimension::DestroyBuilding]; job->completion_timer = abilities.jobDelay[CostDimension::DestroyBuilding];
} else { } else {
df::tiletype* type1 = Maps::getTileType(pt1); df::tiletype* type1 = Maps::getTileType(pt1);
@ -136,7 +133,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
firstInvader->job.hunt_target = NULL; firstInvader->job.hunt_target = NULL;
firstInvader->job.destroy_target = NULL; firstInvader->job.destroy_target = NULL;
Job::linkIntoWorld(job); Job::linkIntoWorld(job);
jobId = job->id;
df::construction* constr = df::construction::find(pt2); df::construction* constr = df::construction::find(pt2);
bool smooth = constr != NULL && constr->item_type != df::enums::item_type::BOULDER; bool smooth = constr != NULL && constr->item_type != df::enums::item_type::BOULDER;
if ( smooth ) if ( smooth )
@ -204,7 +200,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
firstInvader->path.path.y.clear(); firstInvader->path.path.y.clear();
firstInvader->path.path.z.clear(); firstInvader->path.path.z.clear();
Job::linkIntoWorld(job); Job::linkIntoWorld(job);
jobId = job->id;
job->completion_timer = abilities.jobDelay[CostDimension::Dig]; job->completion_timer = abilities.jobDelay[CostDimension::Dig];
//TODO: test if he already has a pick //TODO: test if he already has a pick

@ -246,7 +246,7 @@ cost_t getEdgeCost(color_ostream& out, df::coord pt1, df::coord pt2, DigAbilitie
bool forbidden = false; bool forbidden = false;
if ( building1 && building1->getType() == df::building_type::Hatch ) { if ( building1 && building1->getType() == df::building_type::Hatch ) {
df::building_hatchst* hatch = (df::building_hatchst*)building1; df::building_hatchst* hatch = (df::building_hatchst*)building1;
if ( hatch->door_flags.bits.forbidden || hatch->door_flags.bits.closed && hatch->door_flags.bits.operated_by_mechanisms ) if ( hatch->door_flags.bits.forbidden || ( hatch->door_flags.bits.closed && hatch->door_flags.bits.operated_by_mechanisms ) )
forbidden = true; forbidden = true;
} }

@ -370,7 +370,7 @@ void AnimalHospital::processPatients(color_ostream &out) {
// Where the magic happens // Where the magic happens
for (vector<Patient*>::iterator patient = this->accepted_patients.begin(); patient != this->accepted_patients.end(); patient++) { for (vector<Patient*>::iterator patient = this->accepted_patients.begin(); patient != this->accepted_patients.end(); patient++) {
int id = (*patient)->getID(); int id = (*patient)->getID();
df::unit * real_unit; df::unit * real_unit = nullptr;
// Appears the health bits can get freed/realloced too -_-;, Find the unit from the main // Appears the health bits can get freed/realloced too -_-;, Find the unit from the main
// index and check it there. // index and check it there.
auto units = world->units.all; auto units = world->units.all;
@ -383,7 +383,7 @@ void AnimalHospital::processPatients(color_ostream &out) {
} }
// Check to make sure the unit hasn't expired before assigning a job, or if they've been healed // Check to make sure the unit hasn't expired before assigning a job, or if they've been healed
if (real_unit->flags1.bits.dead || !real_unit->health->flags.bits.needs_healthcare) { if (!real_unit || real_unit->flags1.bits.dead || !real_unit->health->flags.bits.needs_healthcare) {
// discharge the patient from the hospital // discharge the patient from the hospital
this->dischargePatient(*patient, out); this->dischargePatient(*patient, out);
return; return;
@ -459,7 +459,7 @@ bool compareAnimalHospitalZones(df::building * hospital1, df::building * hospita
hospital1->x2 == hospital2->x2 && hospital1->x2 == hospital2->x2 &&
hospital1->y1 == hospital2->y1 && hospital1->y1 == hospital2->y1 &&
hospital1->y2 == hospital2->y2 && hospital1->y2 == hospital2->y2 &&
hospital1->z == hospital1->z) { hospital1->z == hospital2->z) {
return true; return true;
} }

@ -185,9 +185,7 @@ namespace embark_assist {
bool found; bool found;
while (true) { while (true) {
if (!fgets(line, count, infile) || line[0] != '[') {
fgets(line, count, infile);
if (line[0] != '[') {
out.printerr("Failed to find token start '[' at line %i\n", static_cast<int8_t>(i)); out.printerr("Failed to find token start '[' at line %i\n", static_cast<int8_t>(i));
fclose(infile); fclose(infile);
return; return;
@ -251,7 +249,10 @@ namespace embark_assist {
i = first_fields; i = first_fields;
while (true) { while (true) {
fgets(line, count, infile); if (!fgets(line, count, infile))
{
break;
}
for (int k = 1; k < count; k++) { for (int k = 1; k < count; k++) {
if (line[k] == ':') { if (line[k] == ':') {

@ -89,7 +89,6 @@ namespace embark_assist{
void ViewscreenHelpUi::render() { void ViewscreenHelpUi::render() {
color_ostream_proxy out(Core::getInstance().getConsole()); color_ostream_proxy out(Core::getInstance().getConsole());
auto screen_size = DFHack::Screen::getWindowSize();
Screen::Pen pen(' ', COLOR_WHITE); Screen::Pen pen(' ', COLOR_WHITE);
Screen::Pen site_pen = Screen::Pen(' ', COLOR_YELLOW, COLOR_BLACK, false); Screen::Pen site_pen = Screen::Pen(' ', COLOR_YELLOW, COLOR_BLACK, false);
Screen::Pen pen_lr(' ', COLOR_LIGHTRED); Screen::Pen pen_lr(' ', COLOR_LIGHTRED);

@ -41,7 +41,7 @@ namespace embark_assist {
uint16_t aquifer_count = 0; uint16_t aquifer_count = 0;
bool river_found = false; bool river_found = false;
bool waterfall_found = false; bool waterfall_found = false;
uint16_t river_elevation; uint16_t river_elevation = 0xffff;
uint16_t elevation = mlt->at(start_x).at(start_y).elevation; uint16_t elevation = mlt->at(start_x).at(start_y).elevation;
bool clay_found = false; bool clay_found = false;
bool sand_found = false; bool sand_found = false;
@ -394,7 +394,6 @@ namespace embark_assist {
df::world_data *world_data = world->world_data; df::world_data *world_data = world->world_data;
embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y); embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y);
const uint16_t embark_size = finder->x_dim * finder->y_dim; const uint16_t embark_size = finder->x_dim * finder->y_dim;
uint16_t count;
bool found; bool found;
if (tile->surveyed) { if (tile->surveyed) {
@ -750,7 +749,6 @@ namespace embark_assist {
finder->mineral_1 != -1 || finder->mineral_1 != -1 ||
finder->mineral_2 != -1 || finder->mineral_2 != -1 ||
finder->mineral_3 != -1) { finder->mineral_3 != -1) {
count = 0;
bool metal_1 = finder->metal_1 == -1; bool metal_1 = finder->metal_1 == -1;
bool metal_2 = finder->metal_2 == -1; bool metal_2 = finder->metal_2 == -1;
bool metal_3 = finder->metal_3 == -1; bool metal_3 = finder->metal_3 == -1;
@ -1104,7 +1102,6 @@ namespace embark_assist {
finder->mineral_1 != -1 || finder->mineral_1 != -1 ||
finder->mineral_2 != -1 || finder->mineral_2 != -1 ||
finder->mineral_3 != -1) { finder->mineral_3 != -1) {
count = 0;
bool metal_1 = finder->metal_1 == -1; bool metal_1 = finder->metal_1 == -1;
bool metal_2 = finder->metal_2 == -1; bool metal_2 = finder->metal_2 == -1;
bool metal_3 = finder->metal_3 == -1; bool metal_3 = finder->metal_3 == -1;
@ -1285,7 +1282,7 @@ uint16_t embark_assist::matcher::find(embark_assist::defs::match_iterators *iter
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
uint16_t x_end; uint16_t x_end;
uint16_t y_end; uint16_t y_end;
bool turn; bool turn = false;
uint16_t count; uint16_t count;
uint16_t preliminary_matches; uint16_t preliminary_matches;

@ -1002,7 +1002,7 @@ void embark_assist::survey::survey_embark(embark_assist::defs::mid_level_tiles *
// color_ostream_proxy out(Core::getInstance().getConsole()); // color_ostream_proxy out(Core::getInstance().getConsole());
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
int16_t elevation; int16_t elevation = 0;
uint16_t x = screen->location.region_pos.x; uint16_t x = screen->location.region_pos.x;
uint16_t y = screen->location.region_pos.y; uint16_t y = screen->location.region_pos.y;
bool river_found = false; bool river_found = false;

@ -268,6 +268,8 @@ public:
case df::interface_key::CURSOR_DOWNRIGHT_FAST: case df::interface_key::CURSOR_DOWNRIGHT_FAST:
is_motion = true; is_motion = true;
break; break;
default:
break;
} }
if (is_motion && !moved_position) if (is_motion && !moved_position)
{ {
@ -681,7 +683,7 @@ struct choose_start_site_hook : df::viewscreen_choose_start_sitest
if (parts.size()) if (parts.size())
{ {
std::string label = join_strings(", ", parts); std::string label = join_strings(", ", parts);
if (label.size() > dim.x - x - 1) if (int16_t(label.size()) > dim.x - x - 1)
{ {
label.resize(dim.x - x - 1 - 3); label.resize(dim.x - x - 1 - 3);
label.append("..."); label.append("...");

@ -78,17 +78,6 @@ struct ReactionInfo {
static std::map<std::string, ReactionInfo> reactions; static std::map<std::string, ReactionInfo> reactions;
static std::map<df::reaction_product*, ProductInfo*> products; static std::map<df::reaction_product*, ProductInfo*> products;
static ReactionInfo *find_reaction(const std::string &name)
{
auto it = reactions.find(name);
return (it != reactions.end()) ? &it->second : NULL;
}
static bool is_lua_hook(const std::string &name)
{
return name.size() > 9 && memcmp(name.data(), "LUA_HOOK_", 9) == 0;
}
/* /*
* Hooks * Hooks
*/ */
@ -158,12 +147,12 @@ void ev_mng_jobCompleted(color_ostream& out, void* job)
} }
void ev_mng_unitDeath(color_ostream& out, void* ptr) void ev_mng_unitDeath(color_ostream& out, void* ptr)
{ {
int32_t myId=*(int32_t*)&ptr; int32_t myId=(int32_t)(intptr_t)ptr;
onUnitDeath(out,myId); onUnitDeath(out,myId);
} }
void ev_mng_itemCreate(color_ostream& out, void* ptr) void ev_mng_itemCreate(color_ostream& out, void* ptr)
{ {
int32_t myId=*(int32_t*)&ptr; int32_t myId=(int32_t)(intptr_t)ptr;
onItemCreated(out,myId); onItemCreated(out,myId);
} }
void ev_mng_construction(color_ostream& out, void* ptr) void ev_mng_construction(color_ostream& out, void* ptr)
@ -178,12 +167,12 @@ void ev_mng_syndrome(color_ostream& out, void* ptr)
} }
void ev_mng_invasion(color_ostream& out, void* ptr) void ev_mng_invasion(color_ostream& out, void* ptr)
{ {
int32_t myId=*(int32_t*)&ptr; int32_t myId=(int32_t)(intptr_t)ptr;
onInvasion(out,myId); onInvasion(out,myId);
} }
static void ev_mng_building(color_ostream& out, void* ptr) static void ev_mng_building(color_ostream& out, void* ptr)
{ {
int32_t id = *((int32_t*)ptr); int32_t id=(int32_t)(intptr_t)ptr;
onBuildingCreatedDestroyed(out, id); onBuildingCreatedDestroyed(out, id);
} }
static void ev_mng_inventory(color_ostream& out, void* ptr) static void ev_mng_inventory(color_ostream& out, void* ptr)
@ -204,7 +193,7 @@ static void ev_mng_inventory(color_ostream& out, void* ptr)
onInventoryChange(out,unitId,itemId,item_old,item_new); onInventoryChange(out,unitId,itemId,item_old,item_new);
} }
static void ev_mng_report(color_ostream& out, void* ptr) { static void ev_mng_report(color_ostream& out, void* ptr) {
onReport(out,*(int32_t*)&ptr); onReport(out,(int32_t)(intptr_t)ptr);
} }
static void ev_mng_unitAttack(color_ostream& out, void* ptr) { static void ev_mng_unitAttack(color_ostream& out, void* ptr) {
EventManager::UnitAttackData* data = (EventManager::UnitAttackData*)ptr; EventManager::UnitAttackData* data = (EventManager::UnitAttackData*)ptr;

@ -120,6 +120,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
df::unit_action *action = unit->actions[i]; df::unit_action *action = unit->actions[i];
switch (action->type) switch (action->type)
{ {
case unit_action_type::None:
break;
case unit_action_type::Move: case unit_action_type::Move:
action->data.move.timer = 1; action->data.move.timer = 1;
break; break;
@ -171,6 +173,13 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
case unit_action_type::SuckBlood: case unit_action_type::SuckBlood:
action->data.suckblood.timer = 1; action->data.suckblood.timer = 1;
break; break;
case unit_action_type::Jump:
case unit_action_type::ReleaseTerrain:
case unit_action_type::Parry:
case unit_action_type::Block:
case unit_action_type::HoldItem:
case unit_action_type::ReleaseItem:
break;
} }
} }
} }

@ -215,7 +215,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{ {
flood.push(DFCoord(xy.x - 1, xy.y, xy.z)); flood.push(DFCoord(xy.x - 1, xy.y, xy.z));
} }
if (xy.x < tx_max - 1) if (xy.x < int32_t(tx_max) - 1)
{ {
flood.push(DFCoord(xy.x + 1, xy.y, xy.z)); flood.push(DFCoord(xy.x + 1, xy.y, xy.z));
} }
@ -223,7 +223,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{ {
flood.push(DFCoord(xy.x, xy.y - 1, xy.z)); flood.push(DFCoord(xy.x, xy.y - 1, xy.z));
} }
if (xy.y < ty_max - 1) if (xy.y < int32_t(ty_max) - 1)
{ {
flood.push(DFCoord(xy.x, xy.y + 1, xy.z)); flood.push(DFCoord(xy.x, xy.y + 1, xy.z));
} }
@ -234,7 +234,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{ {
flood.push(DFCoord(xy.x, xy.y, xy.z - 1)); flood.push(DFCoord(xy.x, xy.y, xy.z - 1));
} }
if (xy.z < z_max && HighPassable(tt)) if (xy.z < int32_t(z_max) && HighPassable(tt))
{ {
flood.push(DFCoord(xy.x, xy.y, xy.z + 1)); flood.push(DFCoord(xy.x, xy.y, xy.z + 1));
} }
@ -337,11 +337,11 @@ command_result setAllMatching(color_ostream &out, checkTile checkProc,
out.print("Setting traffic...\n"); out.print("Setting traffic...\n");
//Loop through every single tile //Loop through every single tile
for(uint32_t x = minCoord.x; x <= maxCoord.x; x++) for(int32_t x = minCoord.x; x <= maxCoord.x; x++)
{ {
for(uint32_t y = minCoord.y; y <= maxCoord.y; y++) for(int32_t y = minCoord.y; y <= maxCoord.y; y++)
{ {
for(uint32_t z = minCoord.z; z <= maxCoord.z; z++) for(int32_t z = minCoord.z; z <= maxCoord.z; z++)
{ {
DFCoord tile = DFCoord(x, y, z); DFCoord tile = DFCoord(x, y, z);
checkProc(tile, MCache); checkProc(tile, MCache);

@ -21,26 +21,13 @@ DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(cursor); REQUIRE_GLOBAL(cursor);
REQUIRE_GLOBAL(world); REQUIRE_GLOBAL(world);
static int run_interval = 1200; // daily static unsigned run_interval = 1200; // daily
inline float getClock() inline float getClock()
{ {
return (float)clock() / (float)CLOCKS_PER_SEC; return (float)clock() / (float)CLOCKS_PER_SEC;
} }
static std::string get_unit_description(df::unit *unit)
{
if (!unit)
return "";
std::string desc;
auto name = Units::getVisibleName(unit);
if (name->has_name)
desc = Translation::TranslateName(name, false);
desc += (desc.size() ? ", " : "") + Units::getProfessionName(unit); // Check animal type too
return desc;
}
struct uo_buf { struct uo_buf {
uint32_t dim_x, dim_y, dim_z; uint32_t dim_x, dim_y, dim_z;
size_t size; size_t size;

@ -116,8 +116,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
y_max *= 16; y_max *= 16;
//Calculate a new screen position centered on the selected unit //Calculate a new screen position centered on the selected unit
x = unitPos.x + w/2 >= x_max ? x_max-w : (unitPos.x >= w/2 ? unitPos.x - w/2 : 0); x = unitPos.x + w/2 >= int32_t(x_max) ? x_max-w : (unitPos.x >= w/2 ? unitPos.x - w/2 : 0);
y = unitPos.y + h/2 >= y_max ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/2 : 0); y = unitPos.y + h/2 >= int32_t(y_max) ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/2 : 0);
z = unitPos.z; z = unitPos.z;
//Set the new screen position! //Set the new screen position!

@ -274,7 +274,7 @@ static bool moveToInventory(MapExtras::MapCache &mc, df::item *item, df::unit *u
// Step 2: Try to find a bodypart which is eligible to receive equipment AND which is appropriate for the specified item // Step 2: Try to find a bodypart which is eligible to receive equipment AND which is appropriate for the specified item
df::body_part_raw * confirmedBodyPart = NULL; df::body_part_raw * confirmedBodyPart = NULL;
int bpIndex; size_t bpIndex;
for(bpIndex = 0; bpIndex < unit->body.body_plan->body_parts.size(); bpIndex++) for(bpIndex = 0; bpIndex < unit->body.body_plan->body_parts.size(); bpIndex++)
{ {
df::body_part_raw * currPart = unit->body.body_plan->body_parts[bpIndex]; df::body_part_raw * currPart = unit->body.body_plan->body_parts[bpIndex];
@ -358,10 +358,9 @@ static bool moveToInventory(MapExtras::MapCache &mc, df::item *item, df::unit *u
{ {
confirmedBodyPart = currPart; // Assume that the bodypart is valid; we'll invalidate it if we detect too many collisions while looping confirmedBodyPart = currPart; // Assume that the bodypart is valid; we'll invalidate it if we detect too many collisions while looping
int collisions = 0; int collisions = 0;
for (int inventoryID=0; inventoryID < unit->inventory.size(); inventoryID++) for (df::unit_inventory_item * currInvItem : unit->inventory)
{ {
df::unit_inventory_item * currInvItem = unit->inventory[inventoryID]; if (currInvItem->body_part_id == int32_t(bpIndex))
if (currInvItem->body_part_id == bpIndex)
{ {
// Collision detected; have we reached the limit? // Collision detected; have we reached the limit?
if (++collisions >= multiEquipLimit) if (++collisions >= multiEquipLimit)
@ -415,6 +414,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
// The "here" option is hardcoded to true, because the plugin currently doesn't support // The "here" option is hardcoded to true, because the plugin currently doesn't support
// equip-at-a-distance (e.g. grab items within 10 squares of the targeted unit) // equip-at-a-distance (e.g. grab items within 10 squares of the targeted unit)
bool here = true; bool here = true;
(void)here;
// For balance (anti-cheating) reasons, the plugin applies a limit on the number of // For balance (anti-cheating) reasons, the plugin applies a limit on the number of
// item that can be equipped on any bodypart. This limit defaults to 1 but can be // item that can be equipped on any bodypart. This limit defaults to 1 but can be
// overridden with cmdline switches. // overridden with cmdline switches.
@ -512,7 +512,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
pos_cursor = DFCoord(cx,cy,cz); pos_cursor = DFCoord(cx,cy,cz);
// Iterate over all units, process the first one whose pos == pos_cursor // Iterate over all units, process the first one whose pos == pos_cursor
df::unit * targetUnit; df::unit * targetUnit = nullptr;
size_t numUnits = world->units.all.size(); size_t numUnits = world->units.all.size();
for(size_t i=0; i< numUnits; i++) for(size_t i=0; i< numUnits; i++)
{ {
@ -522,11 +522,13 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
if (pos_unit == pos_cursor) if (pos_unit == pos_cursor)
break; break;
if (i + 1 == numUnits) targetUnit = nullptr;
{ }
out.printerr("No unit found at cursor!\n");
return CR_FAILURE; if (!targetUnit)
} {
out.printerr("No unit found at cursor!\n");
return CR_FAILURE;
} }
// Assert: unit found. // Assert: unit found.
@ -534,7 +536,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
// If a specific bodypart was included in the command arguments, then search for it now // If a specific bodypart was included in the command arguments, then search for it now
df::body_part_raw * targetBodyPart = NULL; df::body_part_raw * targetBodyPart = NULL;
if (targetBodyPartCode.size() > 0) { if (targetBodyPartCode.size() > 0) {
for (int bpIndex = 0; bpIndex < targetUnit->body.body_plan->body_parts.size(); bpIndex ++) for (size_t bpIndex = 0; bpIndex < targetUnit->body.body_plan->body_parts.size(); bpIndex ++)
{ {
// Tentatively assume that the part is a match // Tentatively assume that the part is a match
targetBodyPart = targetUnit->body.body_plan->body_parts.at(bpIndex); targetBodyPart = targetUnit->body.body_plan->body_parts.at(bpIndex);

@ -115,7 +115,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
int creatureCount = 0; int creatureCount = 0;
for (int i = 0; i < world->raws.creatures.all.size(); i++) for (size_t i = 0; i < world->raws.creatures.all.size(); i++)
{ {
auto creatureRaw = world->raws.creatures.all[i]; auto creatureRaw = world->raws.creatures.all[i];
if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED)) if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED))
@ -150,7 +150,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
auto descriptor = descriptors[foundIndex]; auto descriptor = descriptors[foundIndex];
for (int j = 0; j < descriptor.size(); j++) for (size_t j = 0; j < descriptor.size(); j++)
{ {
if (descriptor[j] == ' ') if (descriptor[j] == ' ')
descriptor[j] = '_'; descriptor[j] = '_';
@ -194,7 +194,7 @@ command_result list_creatures(color_ostream &out, std::vector <std::string> & pa
} }
CoreSuspender suspend; CoreSuspender suspend;
for (int i = 0; i < world->raws.creatures.all.size(); i++) for (size_t i = 0; i < world->raws.creatures.all.size(); i++)
{ {
auto creatureRaw = world->raws.creatures.all[i]; auto creatureRaw = world->raws.creatures.all[i];
if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED)) if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED))
@ -223,7 +223,7 @@ command_result save_generated_raw(color_ostream &out, std::vector <std::string>
int tileHeight = 24; int tileHeight = 24;
std::string fileName = "graphics_procedural_creatures"; std::string fileName = "graphics_procedural_creatures";
std::string pageName = "PROCEDURAL_FRIENDLY"; std::string pageName = "PROCEDURAL_FRIENDLY";
int repeats = 128; size_t repeats = 128;
std::ofstream outputFile(fileName + ".txt", std::ios::out | std::ios::trunc); std::ofstream outputFile(fileName + ".txt", std::ios::out | std::ios::trunc);
@ -244,7 +244,7 @@ command_result save_generated_raw(color_ostream &out, std::vector <std::string>
{ {
auto descriptor = descriptors[descIndex]; auto descriptor = descriptors[descIndex];
for (int j = 0; j < descriptor.size(); j++) for (size_t j = 0; j < descriptor.size(); j++)
{ {
if (descriptor[j] == ' ') if (descriptor[j] == ' ')
descriptor[j] = '_'; descriptor[j] = '_';

@ -17,13 +17,6 @@ static map<string, string> current_bindings;
static vector<string> sorted_keys; static vector<string> sorted_keys;
static bool show_usage = false; static bool show_usage = false;
static void send_key(const df::interface_key &key)
{
set< df::interface_key > keys;
keys.insert(key);
Gui::getCurViewscreen(true)->feed(&keys);
}
static bool can_invoke(string cmdline, df::viewscreen *screen) static bool can_invoke(string cmdline, df::viewscreen *screen)
{ {
vector<string> cmd_parts; vector<string> cmd_parts;
@ -116,7 +109,7 @@ static bool close_hotkeys_screen()
} }
static void invoke_command(const int index) static void invoke_command(const size_t index)
{ {
if (sorted_keys.size() <= index) if (sorted_keys.size() <= index)
return; return;
@ -147,12 +140,12 @@ public:
{ {
hotkeys_column.clear(); hotkeys_column.clear();
int max_key_length = 0; size_t max_key_length = 0;
for_each_(sorted_keys, [&] (const string &sym) for_each_(sorted_keys, [&] (const string &sym)
{ if (sym.length() > max_key_length) { max_key_length = sym.length(); } }); { if (sym.length() > max_key_length) { max_key_length = sym.length(); } });
int padding = max_key_length + 2; int padding = max_key_length + 2;
for (int i = 0; i < sorted_keys.size(); i++) for (size_t i = 0; i < sorted_keys.size(); i++)
{ {
string text = pad_string(sorted_keys[i], padding, false); string text = pad_string(sorted_keys[i], padding, false);
text += current_bindings[sorted_keys[i]]; text += current_bindings[sorted_keys[i]];
@ -230,7 +223,7 @@ public:
Plugin *plugin = Core::getInstance().getPluginManager()->getPluginByCommand(first); Plugin *plugin = Core::getInstance().getPluginManager()->getPluginByCommand(first);
if (plugin) if (plugin)
{ {
for (auto i = 0; i < plugin->size(); i++) for (size_t i = 0; i < plugin->size(); i++)
{ {
auto pc = plugin->operator[](i); auto pc = plugin->operator[](i);
if (pc.name == first) if (pc.name == first)
@ -278,7 +271,7 @@ private:
{ {
vector<string> result; vector<string> result;
string excess; string excess;
if (str.length() > width) if (int(str.length()) > width)
{ {
auto cut_space = str.rfind(' ', width-1); auto cut_space = str.rfind(' ', width-1);
int excess_start; int excess_start;

@ -225,7 +225,7 @@ bool gather_embark_tile(int EmbX, int EmbY, EmbarkTile * tile, MapExtras::MapCac
tile->set_current_year(*cur_year); tile->set_current_year(*cur_year);
tile->set_current_season(*cur_season); tile->set_current_season(*cur_season);
int num_valid_layers = 0; int num_valid_layers = 0;
for(int z = 0; z < MP->maxZ(); z++) for(uint32_t z = 0; z < MP->maxZ(); z++)
{ {
EmbarkTileLayer * tile_layer = tile->add_tile_layer(); EmbarkTileLayer * tile_layer = tile->add_tile_layer();
num_valid_layers += gather_embark_tile_layer(EmbX, EmbY, z, tile_layer, MP); num_valid_layers += gather_embark_tile_layer(EmbX, EmbY, z, tile_layer, MP);
@ -351,11 +351,11 @@ static command_result GetRawNames(color_ostream &stream, const MapRequest *in, R
} }
} }
out->set_available(true); out->set_available(true);
for(int i = 0; i < world->raws.inorganics.size(); i++){ for(size_t i = 0; i < world->raws.inorganics.size(); i++){
out->add_inorganic(world->raws.inorganics[i]->id); out->add_inorganic(world->raws.inorganics[i]->id);
} }
for(int i = 0; i < world->raws.plants.all.size(); i++){ for(size_t i = 0; i < world->raws.plants.all.size(); i++){
out->add_organic(world->raws.plants.all[i]->id); out->add_organic(world->raws.plants.all[i]->id);
} }
return CR_OK; return CR_OK;

@ -210,8 +210,8 @@ static df::unit_labor construction_build_labor(df::building_actual* b)
df::item* i = 0; df::item* i = 0;
for (auto p = b->contained_items.begin(); p != b->contained_items.end(); p++) for (auto p = b->contained_items.begin(); p != b->contained_items.end(); p++)
if (b->construction_stage > 0 && (*p)->use_mode == 2 || if ((b->construction_stage > 0 && (*p)->use_mode == 2) ||
b->construction_stage == 0 && (*p)->use_mode == 0) (b->construction_stage == 0 && (*p)->use_mode == 0))
i = (*p)->item; i = (*p)->item;
MaterialInfo matinfo; MaterialInfo matinfo;

@ -1147,7 +1147,7 @@ private:
tool_count[TOOL_AXE]++; tool_count[TOOL_AXE]++;
else if (weaponsk == df::job_skill::MINING) else if (weaponsk == df::job_skill::MINING)
tool_count[TOOL_PICK]++; tool_count[TOOL_PICK]++;
else if (weaponsk2 = df::job_skill::CROSSBOW) else if (weaponsk2 == df::job_skill::CROSSBOW)
tool_count[TOOL_CROSSBOW]++; tool_count[TOOL_CROSSBOW]++;
} }
@ -1493,10 +1493,12 @@ private:
if (labor != df::unit_labor::NONE) if (labor != df::unit_labor::NONE)
{ {
if (d->dwarf->status.labors[labor]) if (d->dwarf->status.labors[labor])
{
if (labor == df::unit_labor::OPERATE_PUMP) if (labor == df::unit_labor::OPERATE_PUMP)
score += 50000; score += 50000;
else else
score += 25000; score += 25000;
}
if (default_labor_infos[labor].tool != TOOL_NONE && if (default_labor_infos[labor].tool != TOOL_NONE &&
d->has_tool[default_labor_infos[labor].tool]) d->has_tool[default_labor_infos[labor].tool])
score += 10000000; score += 10000000;
@ -2088,7 +2090,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
DFhackCExport command_result plugin_onupdate(color_ostream &out) DFhackCExport command_result plugin_onupdate(color_ostream &out)
{ {
static int step_count = 0; // static int step_count = 0;
// check run conditions // check run conditions
if (!initialized || !world || !world->map.block_index || !enable_labormanager) if (!initialized || !world || !world->map.block_index || !enable_labormanager)
{ {
@ -2102,7 +2104,7 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out)
if (*df::global::process_jobs) if (*df::global::process_jobs)
return CR_OK; return CR_OK;
step_count = 0; // step_count = 0;
debug_stream = &out; debug_stream = &out;
AutoLaborManager alm(out); AutoLaborManager alm(out);
@ -2263,7 +2265,7 @@ command_result labormanager(color_ostream &out, std::vector <std::string> & para
out << "All labors reset." << endl; out << "All labors reset." << endl;
return CR_OK; return CR_OK;
} }
else if (parameters.size() == 1 && parameters[0] == "list" || parameters[0] == "status") else if (parameters.size() == 1 && (parameters[0] == "list" || parameters[0] == "status"))
{ {
if (!enable_labormanager) if (!enable_labormanager)
{ {

@ -16,7 +16,7 @@ public:
UIColor color; UIColor color;
ListEntry(const string text, const T elem, const string keywords = "", const UIColor color = COLOR_UNSELECTED) : ListEntry(const string text, const T elem, const string keywords = "", const UIColor color = COLOR_UNSELECTED) :
elem(elem), text(text), selected(false), keywords(keywords), color(color) elem(elem), text(text), keywords(keywords), selected(false), color(color)
{ {
} }
}; };
@ -73,14 +73,14 @@ public:
void add(const ListEntry<T> &entry) void add(const ListEntry<T> &entry)
{ {
list.push_back(entry); list.push_back(entry);
if (entry.text.length() > max_item_width) if (entry.text.length() > size_t(max_item_width))
max_item_width = entry.text.length(); max_item_width = entry.text.length();
} }
void add(const string &text, const T &elem) void add(const string &text, const T &elem)
{ {
list.push_back(ListEntry<T>(text, elem)); list.push_back(ListEntry<T>(text, elem));
if (text.length() > max_item_width) if (text.length() > size_t(max_item_width))
max_item_width = text.length(); max_item_width = text.length();
} }
@ -110,7 +110,7 @@ public:
paint_text(COLOR_TITLE, left_margin, y, title); paint_text(COLOR_TITLE, left_margin, y, title);
int last_index_able_to_display = display_start_offset + display_max_rows; int last_index_able_to_display = display_start_offset + display_max_rows;
for (int i = display_start_offset; i < display_list.size() && i < last_index_able_to_display; i++) for (int i = display_start_offset; size_t(i) < display_list.size() && i < last_index_able_to_display; i++)
{ {
++y; ++y;
UIColor fg_color = (is_selected_column && display_list[i]->selected) ? COLOR_SELECTED : display_list[i]->color; UIColor fg_color = (is_selected_column && display_list[i]->selected) ? COLOR_SELECTED : display_list[i]->color;
@ -336,8 +336,7 @@ public:
void selectItem(const T elem) void selectItem(const T elem)
{ {
int i = 0; for (size_t i = 0; i < display_list.size(); i++)
for (; i < display_list.size(); i++)
{ {
if (display_list[i]->elem == elem) if (display_list[i]->elem == elem)
{ {
@ -447,7 +446,7 @@ public:
gps->mouse_x >= left_margin && gps->mouse_x < left_margin + max_item_width) gps->mouse_x >= left_margin && gps->mouse_x < left_margin + max_item_width)
{ {
int new_index = display_start_offset + gps->mouse_y - 3; int new_index = display_start_offset + gps->mouse_y - 3;
if (new_index < display_list.size()) if (size_t(new_index) < display_list.size())
{ {
setHighlight(new_index); setHighlight(new_index);
feed_mouse_set_highlight = true; feed_mouse_set_highlight = true;
@ -472,7 +471,7 @@ public:
void setTitle(const string t) void setTitle(const string t)
{ {
title = t; title = t;
if (title.length() > max_item_width) if (title.length() > size_t(max_item_width))
max_item_width = title.length(); max_item_width = title.length();
} }

@ -223,7 +223,7 @@ static void lua_client_send(int server_id,int client_id,std::string data)
throw std::runtime_error("Client does with this id not exist"); throw std::runtime_error("Client does with this id not exist");
} }
CActiveSocket *sock=(*target)[client_id]; CActiveSocket *sock=(*target)[client_id];
if(sock->Send((const uint8_t*)data.c_str(),data.size())!=data.size()) if(size_t(sock->Send((const uint8_t*)data.c_str(),data.size()))!=data.size())
{ {
throw std::runtime_error(sock->DescribeError()); throw std::runtime_error(sock->DescribeError());
} }

@ -596,7 +596,7 @@ namespace unit_ops {
} }
string get_short_profname(UnitInfo *u) string get_short_profname(UnitInfo *u)
{ {
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (columns[i].profession == u->unit->profession) if (columns[i].profession == u->unit->profession)
return string(columns[i].label); return string(columns[i].label);
@ -657,7 +657,7 @@ struct ProfessionTemplate
continue; continue;
} }
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (line == ENUM_KEY_STR(unit_labor, columns[i].labor)) if (line == ENUM_KEY_STR(unit_labor, columns[i].labor))
{ {
@ -678,7 +678,7 @@ struct ProfessionTemplate
if (mask) if (mask)
outfile << "MASK" << std::endl; outfile << "MASK" << std::endl;
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (hasLabor(columns[i].labor)) if (hasLabor(columns[i].labor))
{ {
@ -696,7 +696,7 @@ struct ProfessionTemplate
if (!mask && name.size() > 0) if (!mask && name.size() > 0)
unit_ops::set_profname(u, name); unit_ops::set_profname(u, name);
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
df::unit_labor labor = columns[i].labor; df::unit_labor labor = columns[i].labor;
bool status = hasLabor(labor); bool status = hasLabor(labor);
@ -709,7 +709,7 @@ struct ProfessionTemplate
void fromUnit(UnitInfo* u) void fromUnit(UnitInfo* u)
{ {
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (u->unit->status.labors[columns[i].labor]) if (u->unit->status.labors[columns[i].labor])
labors.push_back(columns[i].labor); labors.push_back(columns[i].labor);
@ -899,7 +899,7 @@ public:
} }
OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size())); OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size()));
OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: "); OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: ");
int max_x = gps->dimx - 2; size_t max_x = gps->dimx - 2;
size_t i = 0; size_t i = 0;
for ( ; i < units.size(); i++) for ( ; i < units.size(); i++)
{ {
@ -1046,7 +1046,7 @@ public:
menu_options.display(true); menu_options.display(true);
OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size())); OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size()));
OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: "); OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: ");
int max_x = gps->dimx - 2; size_t max_x = gps->dimx - 2;
size_t i = 0; size_t i = 0;
for ( ; i < units.size(); i++) for ( ; i < units.size(); i++)
{ {
@ -1138,7 +1138,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cur
df::unit *unit = src[i]; df::unit *unit = src[i];
if (!unit) if (!unit)
{ {
if (cursor_pos > i) if (cursor_pos > int(i))
cursor_pos--; cursor_pos--;
continue; continue;
} }
@ -1192,7 +1192,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cur
if (first_row > sel_row) if (first_row > sel_row)
first_row = sel_row - num_rows + 1; first_row = sel_row - num_rows + 1;
// don't scroll beyond the end // don't scroll beyond the end
if (first_row > units.size() - num_rows) if (first_row > int(units.size()) - num_rows)
first_row = units.size() - num_rows; first_row = units.size() - num_rows;
last_selection = -1; last_selection = -1;
@ -1207,7 +1207,7 @@ void viewscreen_unitlaborsst::calcIDs()
if (!initialized) if (!initialized)
{ {
initialized = true; initialized = true;
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
group_map.insert(std::pair<df::profession, int>(columns[i].profession, columns[i].group)); group_map.insert(std::pair<df::profession, int>(columns[i].profession, columns[i].group));
} }
memset(list_prof_ids, 0, sizeof(list_prof_ids)); memset(list_prof_ids, 0, sizeof(list_prof_ids));
@ -1267,7 +1267,7 @@ void viewscreen_unitlaborsst::calcSize()
auto dim = Screen::getWindowSize(); auto dim = Screen::getWindowSize();
num_rows = dim.y - 11; num_rows = dim.y - 11;
if (num_rows > units.size()) if (num_rows > int(units.size()))
num_rows = units.size(); num_rows = units.size();
int num_columns = dim.x - DISP_COLUMN_MAX - 1; int num_columns = dim.x - DISP_COLUMN_MAX - 1;
@ -1289,7 +1289,7 @@ void viewscreen_unitlaborsst::calcSize()
// get max_name/max_prof from strings length // get max_name/max_prof from strings length
for (size_t i = 0; i < units.size(); i++) for (size_t i = 0; i < units.size(); i++)
{ {
if (col_maxwidth[DISP_COLUMN_NAME] < units[i]->name.size()) if (size_t(col_maxwidth[DISP_COLUMN_NAME]) < units[i]->name.size())
col_maxwidth[DISP_COLUMN_NAME] = units[i]->name.size(); col_maxwidth[DISP_COLUMN_NAME] = units[i]->name.size();
size_t detail_cmp; size_t detail_cmp;
@ -1300,7 +1300,7 @@ void viewscreen_unitlaborsst::calcSize()
} else { } else {
detail_cmp = units[i]->profession.size(); detail_cmp = units[i]->profession.size();
} }
if (col_maxwidth[DISP_COLUMN_DETAIL] < detail_cmp) if (size_t(col_maxwidth[DISP_COLUMN_DETAIL]) < detail_cmp)
col_maxwidth[DISP_COLUMN_DETAIL] = detail_cmp; col_maxwidth[DISP_COLUMN_DETAIL] = detail_cmp;
} }
@ -1383,7 +1383,7 @@ void viewscreen_unitlaborsst::calcSize()
return; return;
// if the window grows vertically, scroll upward to eliminate blank rows from the bottom // if the window grows vertically, scroll upward to eliminate blank rows from the bottom
if (first_row > units.size() - num_rows) if (first_row > int(units.size()) - num_rows)
first_row = units.size() - num_rows; first_row = units.size() - num_rows;
// if it shrinks vertically, scroll downward to keep the cursor visible // if it shrinks vertically, scroll downward to keep the cursor visible
@ -1391,7 +1391,7 @@ void viewscreen_unitlaborsst::calcSize()
first_row = sel_row - num_rows + 1; first_row = sel_row - num_rows + 1;
// if the window grows horizontally, scroll to the left to eliminate blank columns from the right // if the window grows horizontally, scroll to the left to eliminate blank columns from the right
if (first_column > NUM_COLUMNS - col_widths[DISP_COLUMN_LABORS]) if (first_column > int(NUM_COLUMNS) - col_widths[DISP_COLUMN_LABORS])
first_column = NUM_COLUMNS - col_widths[DISP_COLUMN_LABORS]; first_column = NUM_COLUMNS - col_widths[DISP_COLUMN_LABORS];
// if it shrinks horizontally, scroll to the right to keep the cursor visible // if it shrinks horizontally, scroll to the right to keep the cursor visible
@ -1437,7 +1437,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
sel_row = 0; sel_row = 0;
} }
if ((sel_row < units.size()-1) && events->count(interface_key::CURSOR_DOWN_Z_AUX)) if ((size_t(sel_row) < units.size()-1) && events->count(interface_key::CURSOR_DOWN_Z_AUX))
{ {
sel_row = units.size()-1; sel_row = units.size()-1;
} }
@ -1450,9 +1450,9 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
sel_row = 0; sel_row = 0;
} }
if (sel_row > units.size() - 1) if (size_t(sel_row) > units.size() - 1)
{ {
if (old_sel_row == units.size()-1 && events->count(interface_key::CURSOR_DOWN)) if (size_t(old_sel_row) == units.size()-1 && events->count(interface_key::CURSOR_DOWN))
sel_row = 0; sel_row = 0;
else else
sel_row = units.size() - 1; sel_row = units.size() - 1;
@ -1487,7 +1487,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
// go to beginning of next group // go to beginning of next group
int cur = columns[sel_column].group; int cur = columns[sel_column].group;
int next = sel_column+1; size_t next = sel_column+1;
while ((next < NUM_COLUMNS) && (columns[next].group == cur)) while ((next < NUM_COLUMNS) && (columns[next].group == cur))
next++; next++;
if ((next < NUM_COLUMNS) && (columns[next].group != cur)) if ((next < NUM_COLUMNS) && (columns[next].group != cur))
@ -1499,14 +1499,14 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
if (sel_column < 0) if (sel_column < 0)
sel_column = 0; sel_column = 0;
if (sel_column > NUM_COLUMNS - 1) if (size_t(sel_column) > NUM_COLUMNS - 1)
sel_column = NUM_COLUMNS - 1; sel_column = NUM_COLUMNS - 1;
if (events->count(interface_key::CURSOR_DOWN_Z) || events->count(interface_key::CURSOR_UP_Z)) if (events->count(interface_key::CURSOR_DOWN_Z) || events->count(interface_key::CURSOR_UP_Z))
{ {
// when moving by group, ensure the whole group is shown onscreen // when moving by group, ensure the whole group is shown onscreen
int endgroup_column = sel_column; int endgroup_column = sel_column;
while ((endgroup_column < NUM_COLUMNS-1) && columns[endgroup_column+1].group == columns[sel_column].group) while ((size_t(endgroup_column) < NUM_COLUMNS-1) && columns[endgroup_column+1].group == columns[sel_column].group)
endgroup_column++; endgroup_column++;
if (first_column < endgroup_column - col_widths[DISP_COLUMN_LABORS] + 1) if (first_column < endgroup_column - col_widths[DISP_COLUMN_LABORS] + 1)
@ -1674,7 +1674,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
if (newstatus) if (newstatus)
{ {
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if ((columns[i].labor != unit_labor::NONE) && columns[i].special) if ((columns[i].labor != unit_labor::NONE) && columns[i].special)
unit->status.labors[columns[i].labor] = false; unit->status.labors[columns[i].labor] = false;
@ -1688,7 +1688,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
const SkillColumn &col = columns[input_column]; const SkillColumn &col = columns[input_column];
bool newstatus = !unit->status.labors[col.labor]; bool newstatus = !unit->status.labors[col.labor];
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (columns[i].group != col.group) if (columns[i].group != col.group)
continue; continue;
@ -1698,7 +1698,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
if (newstatus) if (newstatus)
{ {
for (int j = 0; j < NUM_COLUMNS; j++) for (size_t j = 0; j < NUM_COLUMNS; j++)
{ {
if ((columns[j].labor != unit_labor::NONE) && columns[j].special) if ((columns[j].labor != unit_labor::NONE) && columns[j].special)
unit->status.labors[columns[j].labor] = false; unit->status.labors[columns[j].labor] = false;
@ -1767,6 +1767,8 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
case ALTSORT_ARRIVAL: case ALTSORT_ARRIVAL:
altsort = ALTSORT_NAME; altsort = ALTSORT_NAME;
break; break;
case ALTSORT_MAX:
break;
} }
} }
if (events->count(interface_key::OPTION20)) if (events->count(interface_key::OPTION20))
@ -1847,7 +1849,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
if (events->count(interface_key::UNITJOB_VIEW_UNIT) || events->count(interface_key::UNITJOB_ZOOM_CRE)) if (events->count(interface_key::UNITJOB_VIEW_UNIT) || events->count(interface_key::UNITJOB_ZOOM_CRE))
{ {
for (int i = 0; i < unitlist->units[unitlist->page].size(); i++) for (size_t i = 0; i < unitlist->units[unitlist->page].size(); i++)
{ {
if (unitlist->units[unitlist->page][i] == units[input_row]->unit) if (unitlist->units[unitlist->page][i] == units[input_row]->unit)
{ {
@ -1893,7 +1895,7 @@ void viewscreen_unitlaborsst::render()
for (int col = 0; col < col_widths[DISP_COLUMN_LABORS]; col++) for (int col = 0; col < col_widths[DISP_COLUMN_LABORS]; col++)
{ {
int col_offset = col + first_column; int col_offset = col + first_column;
if (col_offset >= NUM_COLUMNS) if (size_t(col_offset) >= NUM_COLUMNS)
break; break;
int8_t fg = columns[col_offset].color; int8_t fg = columns[col_offset].color;
@ -1922,7 +1924,7 @@ void viewscreen_unitlaborsst::render()
for (int row = 0; row < num_rows; row++) for (int row = 0; row < num_rows; row++)
{ {
int row_offset = row + first_row; int row_offset = row + first_row;
if (row_offset >= units.size()) if (size_t(row_offset) >= units.size())
break; break;
UnitInfo *cur = units[row_offset]; UnitInfo *cur = units[row_offset];
@ -1998,7 +2000,7 @@ void viewscreen_unitlaborsst::render()
skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[col_offset].skill); skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[col_offset].skill);
if ((skill != NULL) && (skill->rating || skill->experience)) if ((skill != NULL) && (skill->rating || skill->experience))
{ {
int level = skill->rating; size_t level = skill->rating;
if (level > NUM_SKILL_LEVELS - 1) if (level > NUM_SKILL_LEVELS - 1)
level = NUM_SKILL_LEVELS - 1; level = NUM_SKILL_LEVELS - 1;
c = skill_levels[level].abbrev; c = skill_levels[level].abbrev;
@ -2060,7 +2062,7 @@ void viewscreen_unitlaborsst::render()
skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[sel_column].skill); skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[sel_column].skill);
if (skill) if (skill)
{ {
int level = skill->rating; size_t level = skill->rating;
if (level > NUM_SKILL_LEVELS - 1) if (level > NUM_SKILL_LEVELS - 1)
level = NUM_SKILL_LEVELS - 1; level = NUM_SKILL_LEVELS - 1;
str = stl_sprintf("%s %s", skill_levels[level].name, ENUM_ATTR_STR(job_skill, caption_noun, columns[sel_column].skill)); str = stl_sprintf("%s %s", skill_levels[level].name, ENUM_ATTR_STR(job_skill, caption_noun, columns[sel_column].skill));

@ -46,7 +46,7 @@ static bool live_view = true;
static bool skip_tracking_once = false; static bool skip_tracking_once = false;
static bool mouse_moved = false; static bool mouse_moved = false;
static int scroll_delay = 100; static uint32_t scroll_delay = 100;
static df::coord get_mouse_pos(int32_t &mx, int32_t &my) static df::coord get_mouse_pos(int32_t &mx, int32_t &my)
{ {
@ -231,9 +231,10 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
case Burrows: case Burrows:
return ui->burrows.in_define_mode; return ui->burrows.in_define_mode;
};
return false; default:
return false;
}
} }
bool isInTrackableMode() bool isInTrackableMode()

@ -401,9 +401,9 @@ command_result df_bprobe (color_ostream &out, vector <string> & parameters)
Buildings::t_building building; Buildings::t_building building;
if (!Buildings::Read(i, building)) if (!Buildings::Read(i, building))
continue; continue;
if (!(building.x1 <= cursor->x && cursor->x <= building.x2 && if (int32_t(building.x1) > cursor->x || cursor->x > int32_t(building.x2) ||
building.y1 <= cursor->y && cursor->y <= building.y2 && int32_t(building.y1) > cursor->y || cursor->y > int32_t(building.y2) ||
building.z == cursor->z)) int32_t(building.z) != cursor->z)
continue; continue;
string name; string name;
building.origin->getName(&name); building.origin->getName(&name);

@ -152,7 +152,7 @@ void printMats(color_ostream &con, MatMap &mat, std::vector<T*> &materials, bool
for (MatSorter::const_iterator it = sorting_vector.begin(); for (MatSorter::const_iterator it = sorting_vector.begin();
it != sorting_vector.end(); ++it) it != sorting_vector.end(); ++it)
{ {
if(it->first >= materials.size()) if(size_t(it->first) >= materials.size())
{ {
con << "Bad index: " << it->first << " out of " con << "Bad index: " << it->first << " out of "
<< materials.size() << endl; << materials.size() << endl;
@ -747,7 +747,7 @@ command_result prospector (color_ostream &con, vector <string> & parameters)
for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++) for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++)
{ {
const df::plant & plant = *(*it); const df::plant & plant = *(*it);
if (plant.pos.z != z) if (uint32_t(plant.pos.z) != z)
continue; continue;
df::coord2d loc(plant.pos.x, plant.pos.y); df::coord2d loc(plant.pos.x, plant.pos.y);
loc = loc % 16; loc = loc % 16;

@ -737,7 +737,6 @@ bool IsBuildingChanged(DFCoord pos)
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
DFCoord localPos = DFCoord(pos.x * 16 + x, pos.y * 16 + y, pos.z);
auto bld = block->occupancy[x][y].bits.building; auto bld = block->occupancy[x][y].bits.building;
if (buildingHashes[pos] != bld) if (buildingHashes[pos] != bld)
{ {
@ -1517,7 +1516,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
bool spatterChanged = IsspatterChanged(pos); bool spatterChanged = IsspatterChanged(pos);
bool itemsChanged = block->items.size() > 0; bool itemsChanged = block->items.size() > 0;
bool flows = block->flows.size() > 0; bool flows = block->flows.size() > 0;
RemoteFortressReader::MapBlock *net_block; RemoteFortressReader::MapBlock *net_block = nullptr;
if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows) if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows)
net_block = out->add_map_blocks(); net_block = out->add_map_blocks();
if (tileChanged) if (tileChanged)
@ -2813,13 +2812,10 @@ static command_result GetPartialPlantRaws(color_ostream &stream, const ListReque
df::world * world = df::global::world; df::world * world = df::global::world;
int list_start = 0; int list_start = 0;
int list_end = world->raws.plants.all.size();
if (in != nullptr) if (in != nullptr)
{ {
list_start = in->list_start(); list_start = in->list_start();
if (in->list_end() < list_end)
list_end = in->list_end();
} }
for (int i = 0; i < world->raws.plants.all.size(); i++) for (int i = 0; i < world->raws.plants.all.size(); i++)

@ -335,7 +335,6 @@ void lightingEngineViewscreen::fixAdvMode(int mode)
int window_x=*df::global::window_x; int window_x=*df::global::window_x;
int window_y=*df::global::window_y; int window_y=*df::global::window_y;
int window_z=*df::global::window_z; int window_z=*df::global::window_z;
coord2d vpSize=rect_size(vp);
//mode 0-> make dark non-visible parts //mode 0-> make dark non-visible parts
if(mode==0) if(mode==0)
{ {
@ -939,14 +938,14 @@ matLightDef lua_parseMatDef(lua_State* L)
matLightDef ret; matLightDef ret;
lua_getfield(L,-1,"tr"); lua_getfield(L,-1,"tr");
if(ret.isTransparent=!lua_isnil(L,-1)) if((ret.isTransparent=!lua_isnil(L,-1)))
{ {
ret.transparency=lua_parseLightCell(L); ret.transparency=lua_parseLightCell(L);
} }
lua_pop(L,1); lua_pop(L,1);
lua_getfield(L,-1,"em"); lua_getfield(L,-1,"em");
if(ret.isEmiting=!lua_isnil(L,-1)) if((ret.isEmiting=!lua_isnil(L,-1)))
{ {
ret.emitColor=lua_parseLightCell(L); ret.emitColor=lua_parseLightCell(L);
lua_pop(L,1); lua_pop(L,1);

@ -418,6 +418,8 @@ command_result revflood(color_ostream &out, vector<string> & params)
case tiletype_shape::STAIR_DOWN: case tiletype_shape::STAIR_DOWN:
tt = ctt; tt = ctt;
break; break;
default:
break;
} }
bool below = 0; bool below = 0;
@ -433,6 +435,7 @@ command_result revflood(color_ostream &out, vector<string> & params)
unhide = 0; unhide = 0;
break; break;
// air/free space // air/free space
case tiletype_shape::NONE:
case tiletype_shape::EMPTY: case tiletype_shape::EMPTY:
case tiletype_shape::RAMP_TOP: case tiletype_shape::RAMP_TOP:
case tiletype_shape::STAIR_UPDOWN: case tiletype_shape::STAIR_UPDOWN:

@ -1459,12 +1459,12 @@ public:
// About to make an assignment, so restore original list (it will be changed by the game) // About to make an assignment, so restore original list (it will be changed by the game)
int32_t *cursor = get_viewscreen_cursor(); int32_t *cursor = get_viewscreen_cursor();
auto list = get_primary_list(); auto list = get_primary_list();
if (*cursor >= list->size()) if (size_t(*cursor) >= list->size())
return false; return false;
df::unit *selected_unit = list->at(*cursor); df::unit *selected_unit = list->at(*cursor);
clear_search(); clear_search();
for (*cursor = 0; *cursor < list->size(); (*cursor)++) for (*cursor = 0; size_t(*cursor) < list->size(); (*cursor)++)
{ {
if (list->at(*cursor) == selected_unit) if (list->at(*cursor) == selected_unit)
break; break;

@ -98,6 +98,8 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
case mood_type::Possessed: case mood_type::Possessed:
out.print("possessed"); out.print("possessed");
break; break;
default:
break;
} }
out.print(" with intent to "); out.print(" with intent to ");
switch (job->job_type) switch (job->job_type)
@ -275,7 +277,7 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
int count_got = 0; int count_got = 0;
for (size_t j = 0; j < job->items.size(); j++) for (size_t j = 0; j < job->items.size(); j++)
{ {
if(job->items[j]->job_item_idx == i) if(job->items[j]->job_item_idx == int32_t(i))
{ {
if (item->item_type == item_type::BAR || item->item_type == item_type::CLOTH) if (item->item_type == item_type::BAR || item->item_type == item_type::CLOTH)
count_got += job->items[j]->item->getTotalDimension(); count_got += job->items[j]->item->getTotalDimension();

@ -14,31 +14,10 @@ SET(PROJECT_SRCS
) )
SET(PROJECT_PROTOS SET(PROJECT_PROTOS
${CMAKE_CURRENT_SOURCE_DIR}/proto/stockpiles.proto stockpiles.proto
) )
#Create new lists of what sources and headers protoc will output after we invoke it
STRING(REPLACE ".proto" ".pb.cc;" PROJECT_PROTO_SRCS ${PROJECT_PROTOS})
STRING(REPLACE ".proto" ".pb.h;" PROJECT_PROTO_HDRS ${PROJECT_PROTOS})
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_PROTO_HDRS} PROPERTIES GENERATED TRUE)
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_PROTO_SRCS} PROPERTIES GENERATED TRUE)
LIST(APPEND PROJECT_HDRS ${PROJECT_PROTO_HDRS})
LIST(APPEND PROJECT_SRCS ${PROJECT_PROTO_SRCS})
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
#Generate sources from our proto files and store them in the source tree DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} PROTOBUFS ${PROJECT_PROTOS} LINK_LIBRARIES protobuf-lite lua)
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
DEPENDS protoc-bin ${PROJECT_PROTOS}
)
IF(WIN32)
DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES protobuf-lite lua)
ELSE()
DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES protobuf-lite lua)
ENDIF()

@ -42,17 +42,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
#define MAX_NAME 30 #define MAX_NAME 30
#define SIDEBAR_WIDTH 30 #define SIDEBAR_WIDTH 30
static bool show_debugging = false;
static void debug(const string &msg)
{
if (!show_debugging)
return;
color_ostream_proxy out(Core::getInstance().getConsole());
out << "DEBUG (stocks): " << msg << endl;
}
/* /*
* Utility * Utility

@ -106,6 +106,8 @@ df::job_skill getMoodSkill (df::unit *unit)
if (skill->rating == level) if (skill->rating == level)
skills.push_back(skill->id); skills.push_back(skill->id);
break; break;
default:
break;
} }
} }
if (!skills.size() && civ) if (!skills.size() && civ)
@ -175,7 +177,7 @@ void generateName(df::language_name &output, int language, int mode, const df::l
int32_t word; df::enum_field<df::part_of_speech,int16_t> part; int32_t word; df::enum_field<df::part_of_speech,int16_t> part;
output.first_name.clear(); output.first_name.clear();
selectWord(table1, word, part, 2); selectWord(table1, word, part, 2);
if (word >= 0 && word < world->raws.language.words.size()) if (word >= 0 && size_t(word) < world->raws.language.words.size())
output.first_name = *world->raws.language.translations[language]->words[word]; output.first_name = *world->raws.language.translations[language]->words[word];
} }
if (mode != 10) if (mode != 10)
@ -616,6 +618,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
for (int j = 0; j < 15; j++) for (int j = 0; j < 15; j++)
tickets.push_back(i); tickets.push_back(i);
break; break;
default:
break;
} }
} }
if (!tickets.size()) if (!tickets.size())
@ -765,6 +769,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::MECHANICS: case job_skill::MECHANICS:
job->job_type = job_type::StrangeMoodMechanics; job->job_type = job_type::StrangeMoodMechanics;
break; break;
default:
break;
} }
} }
// Check which types of glass are available - we'll need this information later // Check which types of glass are available - we'll need this information later
@ -1111,6 +1117,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
} }
item->quantity = base_item_count; item->quantity = base_item_count;
break; break;
default:
break;
} }
} }
@ -1157,8 +1165,10 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::GLASSMAKER: case job_skill::GLASSMAKER:
avoid_glass = 1; avoid_glass = 1;
break; break;
default:
break;
} }
for (size_t i = 0; i < extra_items; i++) for (int i = 0; i < extra_items; i++)
{ {
if ((job->job_type == job_type::StrangeMoodBrooding) && (rng.df_trandom(2))) if ((job->job_type == job_type::StrangeMoodBrooding) && (rng.df_trandom(2)))
{ {

@ -78,7 +78,7 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
void help( color_ostream & out, std::vector<std::string> &commands, int start, int end) void help( color_ostream & out, std::vector<std::string> &commands, int start, int end)
{ {
std::string option = commands.size() > start ? commands[start] : ""; std::string option = commands.size() > size_t(start) ? commands[start] : "";
if (option.empty()) if (option.empty())
{ {
out << "Commands:" << std::endl out << "Commands:" << std::endl
@ -812,7 +812,7 @@ command_result executePaintJob(color_ostream &out)
*/ */
// Remove direction from directionless tiles // Remove direction from directionless tiles
DFHack::TileDirection direction = tileDirection(source); DFHack::TileDirection direction = tileDirection(source);
if (!(material == tiletype_material::RIVER || shape == tiletype_shape::BROOK_BED || special == tiletype_special::TRACK || shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))) if (!(material == tiletype_material::RIVER || shape == tiletype_shape::BROOK_BED || special == tiletype_special::TRACK || (shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))))
{ {
direction.whole = 0; direction.whole = 0;
} }
@ -894,7 +894,7 @@ command_result executePaintJob(color_ostream &out)
command_result processCommand(color_ostream &out, std::vector<std::string> &commands, int start, int end, bool & endLoop, bool hasConsole = false) command_result processCommand(color_ostream &out, std::vector<std::string> &commands, int start, int end, bool & endLoop, bool hasConsole = false)
{ {
if (commands.size() == start) if (commands.size() == size_t(start))
{ {
return executePaintJob(out); return executePaintJob(out);
} }

@ -45,7 +45,6 @@ struct max_wheelbarrow_hook : df::viewscreen_dwarfmodest {
bool handled = false; bool handled = false;
if (stockpile) if (stockpile)
{ {
auto dims = Gui::getDwarfmodeViewDims();
handled = true; handled = true;
if (!in_wheelbarrow_entry && if (!in_wheelbarrow_entry &&
input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW)) input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW))

@ -195,7 +195,7 @@ inline void paint_text(const UIColor color, const int &x, const int &y, const st
static inline string pad_string(string text, const int size, const bool front = true, const bool trim = false) static inline string pad_string(string text, const int size, const bool front = true, const bool trim = false)
{ {
if (text.length() > size) if (text.length() > size_t(size))
{ {
if (trim && size > 10) if (trim && size > 10)
{ {
@ -318,6 +318,8 @@ static inline bool can_melt(df::item* item)
} }
} }
break; break;
default:
break;
} }
} }
@ -334,12 +336,13 @@ static inline bool can_melt(df::item* item)
class StockpileInfo { class StockpileInfo {
public: public:
StockpileInfo() : id(0), sp(nullptr) StockpileInfo() : id(0), sp(nullptr), x1(-30000), x2(-30000), y1(-30000), y2(-30000), z(-30000)
{ {
} }
StockpileInfo(df::building_stockpilest *sp_) : sp(sp_) StockpileInfo(df::building_stockpilest *sp_) : StockpileInfo()
{ {
sp = sp_;
readBuilding(); readBuilding();
} }

@ -438,7 +438,7 @@ static int fix_job_postings (color_ostream *out, bool dry_run)
for (size_t i = 0; i < world->jobs.postings.size(); ++i) for (size_t i = 0; i < world->jobs.postings.size(); ++i)
{ {
df::job_handler::T_postings *posting = world->jobs.postings[i]; df::job_handler::T_postings *posting = world->jobs.postings[i];
if (posting->job == job && i != job->posting_index && !posting->flags.bits.dead) if (posting->job == job && i != size_t(job->posting_index) && !posting->flags.bits.dead)
{ {
++count; ++count;
if (out) if (out)

@ -2073,7 +2073,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
if(target_count > 0) if(target_count > 0)
{ {
vector <df::unit*> units_for_cagezone; vector <df::unit*> units_for_cagezone;
size_t count = 0; int count = 0;
for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it) for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it)
{ {
df::unit *unit = *unit_it; df::unit *unit = *unit_it;