Skip to content

Commit

Permalink
Fix warnings in supported plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLubar committed Apr 6, 2018
1 parent f3038fe commit a7dfacd
Show file tree
Hide file tree
Showing 53 changed files with 246 additions and 277 deletions.
2 changes: 1 addition & 1 deletion plugins/Brushes.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ColumnBrush : public Brush
while (mc.testCoord(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);
juststarted = false;
Expand Down
4 changes: 1 addition & 3 deletions plugins/autochop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ static bool skip_plant(const df::plant * plant, bool *restricted)

if (skip.food_trees || skip.cook_trees)
{
df::material * mat;
for (int idx = 0; idx < plant_raw->material.size(); idx++)
for (df::material * mat : plant_raw->material)
{
mat = plant_raw->material[idx];
if (skip.food_trees && mat->flags.is_set(material_flags::EDIBLE_RAW))
{
if (restricted)
Expand Down
12 changes: 6 additions & 6 deletions plugins/autohauler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ static void init_state()
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
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
labor_infos[labor].set_config(*p);
Expand All @@ -635,7 +635,7 @@ static void init_state()
}

// 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
if (labor_infos[i].config.isValid())
Expand Down Expand Up @@ -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.
// Add these to the list of dwarves.
// 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];
if (Units::isCitizen(cre))
Expand Down Expand Up @@ -895,7 +895,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else
{
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];
else
{
Expand Down Expand Up @@ -960,7 +960,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
continue;

// 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))
continue;
Expand Down Expand Up @@ -1138,7 +1138,7 @@ command_result autohauler (color_ostream &out, std::vector <std::string> & param
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);
}
Expand Down
22 changes: 11 additions & 11 deletions plugins/autolabor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ static void init_state()
{
string key = p->key();
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].is_exclusive = default_labor_infos[labor].is_exclusive;
Expand All @@ -615,7 +615,7 @@ static void init_state()
}

// 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())
continue;

Expand Down Expand Up @@ -960,7 +960,7 @@ static void assign_labor(unit_labor::unit_labor labor,
* Military and children/nobles will not have labors assigned.
* 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];

Expand Down Expand Up @@ -1048,7 +1048,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
bool has_fishery = 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];
auto type = build->getType();
Expand All @@ -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];
if (Units::isCitizen(cre))
Expand Down Expand Up @@ -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);
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);
if (hfelink->getType() == df::histfig_entity_link_type::POSITION)
Expand Down Expand Up @@ -1140,7 +1140,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )

// 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];
if (!act) continue;
Expand Down Expand Up @@ -1230,7 +1230,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else
{
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];
else
{
Expand Down Expand Up @@ -1341,7 +1341,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )

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];

Expand All @@ -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());
}

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());

Expand Down Expand Up @@ -1517,7 +1517,7 @@ command_result autolabor (color_ostream &out, std::vector <std::string> & parame
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);
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/automaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
return CR_OK;
Expand Down Expand Up @@ -1124,6 +1118,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
break;

case SELECT_SECOND:
{
OutputString(COLOR_GREEN, x, y, "Choose second corner", true, left_margin);

int32_t curr_x, curr_y, curr_z;
Expand All @@ -1137,6 +1132,11 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
int cx = box_first.x;
int cy = box_first.y;
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);
Expand Down
13 changes: 9 additions & 4 deletions plugins/blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
{
if (! b)
return " ";
bool at_nw_corner = x == b->x1 && y == b->y1;
bool at_se_corner = x == b->x2 && y == b->y2;
bool at_center = x == b->centerx && y == b->centery;
bool at_nw_corner = int32_t(x) == b->x1 && int32_t(y) == b->y1;
bool at_se_corner = int32_t(x) == b->x2 && int32_t(y) == b->y2;
bool at_center = int32_t(x) == b->centerx && int32_t(y) == b->centery;
pair<uint32_t, uint32_t> size = get_building_size(b);
stringstream out;// = stringstream();
switch(b->getType())
Expand Down Expand Up @@ -227,7 +227,10 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
return "wy";
case workshop_type::Dyers:
return "wd";
case workshop_type::Kennels:
return "k";
case workshop_type::Custom:
case workshop_type::Tool:
//can't do anything with custom workshop
return "`";
}
Expand Down Expand Up @@ -261,6 +264,8 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
case building_type::Construction:
switch (((df::building_constructionst*) b)->type)
{
case construction_type::NONE:
return "`";
case construction_type::Fortification:
return "CF";
case construction_type::Wall:
Expand Down Expand Up @@ -482,7 +487,7 @@ string get_tile_place(uint32_t x, uint32_t y, df::building* b)
{
if (! b || b->getType() != building_type::Stockpile)
return " ";
if (b->x1 != x || b->y1 != y)
if (b->x1 != int32_t(x) || b->y1 != int32_t(y))
return "`";
pair<uint32_t, uint32_t> size = get_building_size(b);
df::building_stockpilest* sp = (df::building_stockpilest*) b;
Expand Down
2 changes: 1 addition & 1 deletion plugins/building-hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ struct work_hook : df::building_workshopst{
}
int w=db->x2-db->x1+1;
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)
{
Expand Down
15 changes: 12 additions & 3 deletions plugins/buildingplan-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void enable_quickfort_fn(pair<const df::building_type, bool>& pair) { pair.secon
* 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)
{
Expand Down Expand Up @@ -131,7 +131,7 @@ void ItemFilter::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)
{
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -654,3 +654,12 @@ void Planner::cycleDefaultQuality(df::building_type type)
if (*quality == item_quality::Artifact)
(*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;
22 changes: 11 additions & 11 deletions plugins/buildingplan-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct MaterialDescriptor
#define MAX_MATERIAL 21
#define SIDEBAR_WIDTH 30

static bool canReserveRoom(df::building *building)
static inline bool canReserveRoom(df::building *building)
{
if (!building)
return false;
Expand All @@ -76,7 +76,7 @@ static bool canReserveRoom(df::building *building)
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;
Units::getNoblePositions(&np, unit);
Expand All @@ -92,19 +92,19 @@ static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
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 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;
static bool show_help = false;
extern bool show_debugging;
extern bool show_help;

struct ItemFilter
{
Expand Down Expand Up @@ -387,7 +387,7 @@ class Planner
public:
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
{
Expand Down Expand Up @@ -491,8 +491,8 @@ class Planner
}
};

static Planner planner;
extern Planner planner;

static RoomMonitor roomMonitor;
extern RoomMonitor roomMonitor;

#endif
4 changes: 2 additions & 2 deletions plugins/buildingplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
df::interface_key last_token = get_string_key(input);
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)
return false;
roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code);
Expand Down Expand Up @@ -317,7 +317,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
int y = 24;
OutputString(COLOR_BROWN, x, y, "DFHack", 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)
== np[i].position->code);
Expand Down
4 changes: 2 additions & 2 deletions plugins/changelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ command_result changelayer (color_ostream &out, std::vector <std::string> & para
{
if(verbose)
out << "---Biome: " << i;
if(!all_biomes && i!=biome)
if(!all_biomes && uint32_t(i)!=biome)
{
if(verbose)
out << "-skipping" << endl;
Expand Down Expand Up @@ -257,7 +257,7 @@ command_result changelayer (color_ostream &out, std::vector <std::string> & para
out << "geoindex: " << geoindex << endl;

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)
{
Expand Down
Loading

0 comments on commit a7dfacd

Please sign in to comment.