diff --git a/plugins/Brushes.h b/plugins/Brushes.h index eaf4240ea..6095a03da 100644 --- a/plugins/Brushes.h +++ b/plugins/Brushes.h @@ -130,7 +130,7 @@ public: 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; diff --git a/plugins/autochop.cpp b/plugins/autochop.cpp index a2a863540..858989a97 100644 --- a/plugins/autochop.cpp +++ b/plugins/autochop.cpp @@ -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) diff --git a/plugins/autohauler.cpp b/plugins/autohauler.cpp index 62914c784..e222a9702 100644 --- a/plugins/autohauler.cpp +++ b/plugins/autohauler.cpp @@ -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); @@ -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()) @@ -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)) @@ -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 { @@ -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; @@ -1138,7 +1138,7 @@ command_result autohauler (color_ostream &out, std::vector & 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); } diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index a894a2891..6ca0a2658 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -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; @@ -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; @@ -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]; @@ -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(); @@ -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)) @@ -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) @@ -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; @@ -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 { @@ -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]; @@ -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()); @@ -1517,7 +1517,7 @@ command_result autolabor (color_ostream &out, std::vector & 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); } diff --git a/plugins/automaterial.cpp b/plugins/automaterial.cpp index cfbc95ae7..40dc2bb48 100644 --- a/plugins/automaterial.cpp +++ b/plugins/automaterial.cpp @@ -69,12 +69,6 @@ struct MaterialDescriptor } }; - -static command_result automaterial_cmd(color_ostream &out, vector & parameters) -{ - return CR_OK; -} - DFhackCExport command_result plugin_shutdown ( color_ostream &out ) { return CR_OK; @@ -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; @@ -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); diff --git a/plugins/blueprint.cpp b/plugins/blueprint.cpp index badc094c9..6ef56722a 100644 --- a/plugins/blueprint.cpp +++ b/plugins/blueprint.cpp @@ -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 size = get_building_size(b); stringstream out;// = stringstream(); switch(b->getType()) @@ -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 "`"; } @@ -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: @@ -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 size = get_building_size(b); df::building_stockpilest* sp = (df::building_stockpilest*) b; diff --git a/plugins/building-hacks.cpp b/plugins/building-hacks.cpp index bc989df30..17390cd5a 100644 --- a/plugins/building-hacks.cpp +++ b/plugins/building-hacks.cpp @@ -287,7 +287,7 @@ struct work_hook : df::building_workshopst{ } int w=db->x2-db->x1+1; std::vector &cur_frame=def->frames[frame]; - for(int i=0;i=0) { diff --git a/plugins/buildingplan-lib.cpp b/plugins/buildingplan-lib.cpp index 93efd60f6..f6023d2d7 100644 --- a/plugins/buildingplan-lib.cpp +++ b/plugins/buildingplan-lib.cpp @@ -17,7 +17,7 @@ void enable_quickfort_fn(pair& 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) { @@ -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) { @@ -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 @@ -654,3 +654,12 @@ void Planner::cycleDefaultQuality(df::building_type type) if (*quality == item_quality::Artifact) (*quality) = item_quality::Ordinary; } + +map planmode_enabled, saved_planmodes; + +bool show_debugging = false; +bool show_help = false; + +Planner planner; + +RoomMonitor roomMonitor; diff --git a/plugins/buildingplan-lib.h b/plugins/buildingplan-lib.h index 6975960d2..9720d5421 100644 --- a/plugins/buildingplan-lib.h +++ b/plugins/buildingplan-lib.h @@ -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; @@ -76,7 +76,7 @@ static bool canReserveRoom(df::building *building) return building->is_room; } -static std::vector getUniqueNoblePositions(df::unit *unit) +static inline std::vector getUniqueNoblePositions(df::unit *unit) { std::vector np; Units::getNoblePositions(&np, unit); @@ -92,19 +92,19 @@ static std::vector 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 planmode_enabled, saved_planmodes; +extern map planmode_enabled, saved_planmodes; void enable_quickfort_fn(pair& 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 { @@ -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 { @@ -491,8 +491,8 @@ private: } }; -static Planner planner; +extern Planner planner; -static RoomMonitor roomMonitor; +extern RoomMonitor roomMonitor; #endif diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index 747e5cfb7..eb6d2a661 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -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); @@ -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); diff --git a/plugins/changelayer.cpp b/plugins/changelayer.cpp index 27e4c12e6..cf7d4fdbc 100644 --- a/plugins/changelayer.cpp +++ b/plugins/changelayer.cpp @@ -227,7 +227,7 @@ command_result changelayer (color_ostream &out, std::vector & para { if(verbose) out << "---Biome: " << i; - if(!all_biomes && i!=biome) + if(!all_biomes && uint32_t(i)!=biome) { if(verbose) out << "-skipping" << endl; @@ -257,7 +257,7 @@ command_result changelayer (color_ostream &out, std::vector & para out << "geoindex: " << geoindex << endl; bool skip = false; - for(int g=0; gdisplay_frames; gps->display_frames=0; @@ -172,7 +172,7 @@ void viewscreen_commandpromptst::render() if(cursor_pos < (dim.x - 10)) { 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); if (cursor != " ") Screen::paintString(Screen::Pen(' ', 10, 0), 10 + cursor_pos, 0, cursor); @@ -243,7 +243,7 @@ void viewscreen_commandpromptst::feed(std::set *events) entry.erase(cursor_pos - 1, 1); cursor_pos--; } - if(cursor_pos > entry.size()) + if(size_t(cursor_pos) > entry.size()) cursor_pos = entry.size(); continue; } @@ -260,7 +260,7 @@ void viewscreen_commandpromptst::feed(std::set *events) if(events->count(interface_key::CURSOR_RIGHT)) { cursor_pos++; - if (cursor_pos > entry.size()) + if (size_t(cursor_pos) > entry.size()) cursor_pos = entry.size(); } else if(events->count(interface_key::CURSOR_LEFT)) @@ -294,10 +294,10 @@ void viewscreen_commandpromptst::feed(std::set *events) } 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++; - if (history_idx >= command_history.size()) + if (size_t(history_idx) >= command_history.size()) history_idx = command_history.size() - 1; entry = get_entry(); cursor_pos = entry.size(); diff --git a/plugins/createitem.cpp b/plugins/createitem.cpp index 1f2e8a5c4..70794e38c 100644 --- a/plugins/createitem.cpp +++ b/plugins/createitem.cpp @@ -92,7 +92,7 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it return false; // 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 - if (is_shoes && out_items.size() == prod->count * 2) + if (is_shoes && out_items.size() == size_t(prod->count * 2)) is_shoes = false; MapExtras::MapCache mc; diff --git a/plugins/dig.cpp b/plugins/dig.cpp index d18176f5a..83ca2ef2d 100644 --- a/plugins/dig.cpp +++ b/plugins/dig.cpp @@ -812,14 +812,14 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level, int x = 0,mx = 16; if(bx == 0) x = 1; - if(bx == x_max - 1) + if(int(bx) == x_max - 1) mx = 15; for(; x < mx; x++) { int y = 0,my = 16; if(by == 0) y = 1; - if(by == y_max - 1) + if(int(by) == y_max - 1) my = 15; 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(what == EXPLO_ALL - || des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED - || des.bits.hidden && what == EXPLO_HIDDEN) + || (des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED) + || (des.bits.hidden && what == EXPLO_HIDDEN)) { des.bits.dig = tile_dig_designation::Default; } @@ -948,7 +948,7 @@ command_result digexp (color_ostream &out, vector & parameters) int which; 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; stamp_pattern(x,y_max - 1 - y, z_level, diag5[which], @@ -961,7 +961,7 @@ command_result digexp (color_ostream &out, vector & parameters) int which; 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; stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which], @@ -975,7 +975,7 @@ command_result digexp (color_ostream &out, vector & parameters) for(uint32_t x = 0; x < x_max; x++) { 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], how, what, x_max, y_max); @@ -985,7 +985,7 @@ command_result digexp (color_ostream &out, vector & parameters) else if(how == EXPLO_LADDERR) { int which; - for(int32_t y = 0 ; y < y_max; y++) + for(uint32_t y = 0 ; y < y_max; y++) { which = y % 3; for(uint32_t x = 0; x < x_max; x++) @@ -1023,7 +1023,7 @@ command_result digexp (color_ostream &out, vector & parameters) } 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, how, what, x_max, y_max); @@ -1075,7 +1075,7 @@ command_result digv (color_ostream &out, vector & parameters) return CR_FAILURE; } 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"); return CR_FAILURE; @@ -1136,10 +1136,10 @@ command_result digv (color_ostream &out, vector & parameters) { 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)); - 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, current.y + 1,current.z)); @@ -1153,7 +1153,7 @@ command_result digv (color_ostream &out, vector & parameters) if(current.x > 1) { 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, current.y + 1,current.z)); @@ -1178,7 +1178,7 @@ command_result digv (color_ostream &out, vector & parameters) 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); @@ -1262,7 +1262,7 @@ command_result digl (color_ostream &out, vector & parameters) return CR_FAILURE; } 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"); return CR_FAILURE; @@ -1320,10 +1320,10 @@ command_result digl (color_ostream &out, vector & parameters) if(MCache->testCoord(current)) { 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)); - 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, current.y + 1, current.z)); @@ -1337,7 +1337,7 @@ command_result digl (color_ostream &out, vector & parameters) if(current.x > 1) { 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, current.y + 1, current.z)); @@ -1389,7 +1389,7 @@ command_result digl (color_ostream &out, vector & parameters) 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); @@ -1438,7 +1438,7 @@ command_result digtype (color_ostream &out, vector & parameters) return CR_FAILURE; } - uint32_t targetDigType; + int32_t targetDigType; if ( parameters.size() == 1 ) { string parameter = parameters[0]; @@ -1526,7 +1526,6 @@ command_result digtype (color_ostream &out, vector & parameters) continue; //designate it for digging - df::tile_designation des = mCache->designationAt(current); if ( !mCache->testCoord(current) ) { out.printerr("testCoord failed at (%d,%d,%d)\n", x, y, z); diff --git a/plugins/digFlood.cpp b/plugins/digFlood.cpp index ada6213a6..2556d25ac 100644 --- a/plugins/digFlood.cpp +++ b/plugins/digFlood.cpp @@ -137,7 +137,7 @@ void maybeExplore(color_ostream& out, MapExtras::MapCache& cache, df::coord pt, uint32_t 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; if ( jobLocations.find(pt) != jobLocations.end() ) { return; diff --git a/plugins/diggingInvaders/assignJob.cpp b/plugins/diggingInvaders/assignJob.cpp index cdd3e6fc5..2b780bd63 100644 --- a/plugins/diggingInvaders/assignJob.cpp +++ b/plugins/diggingInvaders/assignJob.cpp @@ -68,8 +68,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map (%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* block2 = Maps::getTileBlock(pt2); bool passable1 = block1->walkable[pt1.x&0xF][pt1.y&0xF]; @@ -111,7 +109,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_mapjobs.clear(); building->jobs.push_back(job); Job::linkIntoWorld(job); - jobId = job->id; job->completion_timer = abilities.jobDelay[CostDimension::DestroyBuilding]; } else { df::tiletype* type1 = Maps::getTileType(pt1); @@ -136,7 +133,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_mapjob.hunt_target = NULL; firstInvader->job.destroy_target = NULL; Job::linkIntoWorld(job); - jobId = job->id; df::construction* constr = df::construction::find(pt2); bool smooth = constr != NULL && constr->item_type != df::enums::item_type::BOULDER; if ( smooth ) @@ -204,7 +200,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_mappath.path.y.clear(); firstInvader->path.path.z.clear(); Job::linkIntoWorld(job); - jobId = job->id; job->completion_timer = abilities.jobDelay[CostDimension::Dig]; //TODO: test if he already has a pick diff --git a/plugins/diggingInvaders/edgeCost.cpp b/plugins/diggingInvaders/edgeCost.cpp index b08227d94..cd52f4e17 100644 --- a/plugins/diggingInvaders/edgeCost.cpp +++ b/plugins/diggingInvaders/edgeCost.cpp @@ -246,7 +246,7 @@ cost_t getEdgeCost(color_ostream& out, df::coord pt1, df::coord pt2, DigAbilitie bool forbidden = false; if ( building1 && building1->getType() == df::building_type::Hatch ) { 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; } diff --git a/plugins/dwarfvet.cpp b/plugins/dwarfvet.cpp index a98777b91..19f00e888 100644 --- a/plugins/dwarfvet.cpp +++ b/plugins/dwarfvet.cpp @@ -370,7 +370,7 @@ void AnimalHospital::processPatients(color_ostream &out) { // Where the magic happens for (vector::iterator patient = this->accepted_patients.begin(); patient != this->accepted_patients.end(); patient++) { 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 // index and check it there. 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 - 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 this->dischargePatient(*patient, out); return; @@ -459,7 +459,7 @@ bool compareAnimalHospitalZones(df::building * hospital1, df::building * hospita hospital1->x2 == hospital2->x2 && hospital1->y1 == hospital2->y1 && hospital1->y2 == hospital2->y2 && - hospital1->z == hospital1->z) { + hospital1->z == hospital2->z) { return true; } diff --git a/plugins/embark-assistant/finder_ui.cpp b/plugins/embark-assistant/finder_ui.cpp index 80380ca60..a6a5005bd 100644 --- a/plugins/embark-assistant/finder_ui.cpp +++ b/plugins/embark-assistant/finder_ui.cpp @@ -185,9 +185,7 @@ namespace embark_assist { bool found; while (true) { - - fgets(line, count, infile); - if (line[0] != '[') { + if (!fgets(line, count, infile) || line[0] != '[') { out.printerr("Failed to find token start '[' at line %i\n", static_cast(i)); fclose(infile); return; @@ -251,7 +249,10 @@ namespace embark_assist { i = first_fields; while (true) { - fgets(line, count, infile); + if (!fgets(line, count, infile)) + { + break; + } for (int k = 1; k < count; k++) { if (line[k] == ':') { diff --git a/plugins/embark-assistant/help_ui.cpp b/plugins/embark-assistant/help_ui.cpp index fb5d05969..32fb28dbb 100644 --- a/plugins/embark-assistant/help_ui.cpp +++ b/plugins/embark-assistant/help_ui.cpp @@ -89,7 +89,6 @@ namespace embark_assist{ void ViewscreenHelpUi::render() { color_ostream_proxy out(Core::getInstance().getConsole()); - auto screen_size = DFHack::Screen::getWindowSize(); Screen::Pen pen(' ', COLOR_WHITE); Screen::Pen site_pen = Screen::Pen(' ', COLOR_YELLOW, COLOR_BLACK, false); Screen::Pen pen_lr(' ', COLOR_LIGHTRED); diff --git a/plugins/embark-assistant/matcher.cpp b/plugins/embark-assistant/matcher.cpp index eb73eda2c..d4a2f8ee3 100644 --- a/plugins/embark-assistant/matcher.cpp +++ b/plugins/embark-assistant/matcher.cpp @@ -41,7 +41,7 @@ namespace embark_assist { uint16_t aquifer_count = 0; bool river_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; bool clay_found = false; bool sand_found = false; @@ -394,7 +394,6 @@ namespace embark_assist { df::world_data *world_data = world->world_data; embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y); const uint16_t embark_size = finder->x_dim * finder->y_dim; - uint16_t count; bool found; if (tile->surveyed) { @@ -750,7 +749,6 @@ namespace embark_assist { finder->mineral_1 != -1 || finder->mineral_2 != -1 || finder->mineral_3 != -1) { - count = 0; bool metal_1 = finder->metal_1 == -1; bool metal_2 = finder->metal_2 == -1; bool metal_3 = finder->metal_3 == -1; @@ -1104,7 +1102,6 @@ namespace embark_assist { finder->mineral_1 != -1 || finder->mineral_2 != -1 || finder->mineral_3 != -1) { - count = 0; bool metal_1 = finder->metal_1 == -1; bool metal_2 = finder->metal_2 == -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(0); uint16_t x_end; uint16_t y_end; - bool turn; + bool turn = false; uint16_t count; uint16_t preliminary_matches; diff --git a/plugins/embark-assistant/survey.cpp b/plugins/embark-assistant/survey.cpp index 9de42e57f..4b0d883e3 100644 --- a/plugins/embark-assistant/survey.cpp +++ b/plugins/embark-assistant/survey.cpp @@ -1002,7 +1002,7 @@ void embark_assist::survey::survey_embark(embark_assist::defs::mid_level_tiles * // color_ostream_proxy out(Core::getInstance().getConsole()); auto screen = Gui::getViewscreenByType(0); - int16_t elevation; + int16_t elevation = 0; uint16_t x = screen->location.region_pos.x; uint16_t y = screen->location.region_pos.y; bool river_found = false; diff --git a/plugins/embark-tools.cpp b/plugins/embark-tools.cpp index 81f7dd6cd..2358bf95f 100644 --- a/plugins/embark-tools.cpp +++ b/plugins/embark-tools.cpp @@ -268,6 +268,8 @@ public: case df::interface_key::CURSOR_DOWNRIGHT_FAST: is_motion = true; break; + default: + break; } if (is_motion && !moved_position) { @@ -681,7 +683,7 @@ struct choose_start_site_hook : df::viewscreen_choose_start_sitest if (parts.size()) { 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.append("..."); diff --git a/plugins/eventful.cpp b/plugins/eventful.cpp index f4056a3d5..5d8dfdb59 100644 --- a/plugins/eventful.cpp +++ b/plugins/eventful.cpp @@ -78,17 +78,6 @@ struct ReactionInfo { static std::map reactions; static std::map 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 */ @@ -158,12 +147,12 @@ void ev_mng_jobCompleted(color_ostream& out, void* job) } 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); } 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); } 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) { - int32_t myId=*(int32_t*)&ptr; + int32_t myId=(int32_t)(intptr_t)ptr; onInvasion(out,myId); } 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); } 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); } 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) { EventManager::UnitAttackData* data = (EventManager::UnitAttackData*)ptr; diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp index e8ae85c99..09d831e26 100644 --- a/plugins/fastdwarf.cpp +++ b/plugins/fastdwarf.cpp @@ -120,6 +120,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) df::unit_action *action = unit->actions[i]; switch (action->type) { + case unit_action_type::None: + break; case unit_action_type::Move: action->data.move.timer = 1; break; @@ -171,6 +173,13 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) case unit_action_type::SuckBlood: action->data.suckblood.timer = 1; 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; } } } diff --git a/plugins/filltraffic.cpp b/plugins/filltraffic.cpp index 0f9a7bb6f..ddb5ef877 100644 --- a/plugins/filltraffic.cpp +++ b/plugins/filltraffic.cpp @@ -215,7 +215,7 @@ command_result filltraffic(color_ostream &out, std::vector & params { 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)); } @@ -223,7 +223,7 @@ command_result filltraffic(color_ostream &out, std::vector & params { 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)); } @@ -234,7 +234,7 @@ command_result filltraffic(color_ostream &out, std::vector & params { 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)); } @@ -337,11 +337,11 @@ command_result setAllMatching(color_ostream &out, checkTile checkProc, out.print("Setting traffic...\n"); //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); checkProc(tile, MCache); diff --git a/plugins/fix-unit-occupancy.cpp b/plugins/fix-unit-occupancy.cpp index 8b7be0c0f..b3cac47c5 100644 --- a/plugins/fix-unit-occupancy.cpp +++ b/plugins/fix-unit-occupancy.cpp @@ -21,26 +21,13 @@ DFHACK_PLUGIN_IS_ENABLED(is_enabled); REQUIRE_GLOBAL(cursor); REQUIRE_GLOBAL(world); -static int run_interval = 1200; // daily +static unsigned run_interval = 1200; // daily inline float getClock() { 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 { uint32_t dim_x, dim_y, dim_z; size_t size; diff --git a/plugins/follow.cpp b/plugins/follow.cpp index 7a17f89d0..21a297bd1 100644 --- a/plugins/follow.cpp +++ b/plugins/follow.cpp @@ -116,8 +116,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) y_max *= 16; //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); - y = unitPos.y + h/2 >= y_max ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/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 >= int32_t(y_max) ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/2 : 0); z = unitPos.z; //Set the new screen position! diff --git a/plugins/forceequip.cpp b/plugins/forceequip.cpp index da6f1aff4..19c1202d6 100644 --- a/plugins/forceequip.cpp +++ b/plugins/forceequip.cpp @@ -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 df::body_part_raw * confirmedBodyPart = NULL; - int bpIndex; + size_t 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]; @@ -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 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 == bpIndex) + if (currInvItem->body_part_id == int32_t(bpIndex)) { // Collision detected; have we reached the limit? if (++collisions >= multiEquipLimit) @@ -415,6 +414,7 @@ command_result df_forceequip(color_ostream &out, vector & parameters) // 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) bool here = true; + (void)here; // 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 // overridden with cmdline switches. @@ -512,7 +512,7 @@ command_result df_forceequip(color_ostream &out, vector & parameters) pos_cursor = DFCoord(cx,cy,cz); // 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(); for(size_t i=0; i< numUnits; i++) { @@ -522,11 +522,13 @@ command_result df_forceequip(color_ostream &out, vector & parameters) if (pos_unit == pos_cursor) break; - if (i + 1 == numUnits) - { - out.printerr("No unit found at cursor!\n"); - return CR_FAILURE; - } + targetUnit = nullptr; + } + + if (!targetUnit) + { + out.printerr("No unit found at cursor!\n"); + return CR_FAILURE; } // Assert: unit found. @@ -534,7 +536,7 @@ command_result df_forceequip(color_ostream &out, vector & parameters) // If a specific bodypart was included in the command arguments, then search for it now df::body_part_raw * targetBodyPart = NULL; 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 targetBodyPart = targetUnit->body.body_plan->body_parts.at(bpIndex); diff --git a/plugins/generated-creature-renamer.cpp b/plugins/generated-creature-renamer.cpp index 49444eaf4..e70324dd2 100644 --- a/plugins/generated-creature-renamer.cpp +++ b/plugins/generated-creature-renamer.cpp @@ -115,7 +115,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan 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]; 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]; - for (int j = 0; j < descriptor.size(); j++) + for (size_t j = 0; j < descriptor.size(); j++) { if (descriptor[j] == ' ') descriptor[j] = '_'; @@ -194,7 +194,7 @@ command_result list_creatures(color_ostream &out, std::vector & pa } 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]; 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 int tileHeight = 24; std::string fileName = "graphics_procedural_creatures"; std::string pageName = "PROCEDURAL_FRIENDLY"; - int repeats = 128; + size_t repeats = 128; 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 { auto descriptor = descriptors[descIndex]; - for (int j = 0; j < descriptor.size(); j++) + for (size_t j = 0; j < descriptor.size(); j++) { if (descriptor[j] == ' ') descriptor[j] = '_'; diff --git a/plugins/hotkeys.cpp b/plugins/hotkeys.cpp index 6ec281143..d3ee600e3 100644 --- a/plugins/hotkeys.cpp +++ b/plugins/hotkeys.cpp @@ -17,13 +17,6 @@ static map current_bindings; static vector sorted_keys; 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) { vector 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) return; @@ -147,12 +140,12 @@ public: { hotkeys_column.clear(); - int max_key_length = 0; + size_t max_key_length = 0; for_each_(sorted_keys, [&] (const string &sym) { if (sym.length() > max_key_length) { max_key_length = sym.length(); } }); 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); text += current_bindings[sorted_keys[i]]; @@ -230,7 +223,7 @@ public: Plugin *plugin = Core::getInstance().getPluginManager()->getPluginByCommand(first); if (plugin) { - for (auto i = 0; i < plugin->size(); i++) + for (size_t i = 0; i < plugin->size(); i++) { auto pc = plugin->operator[](i); if (pc.name == first) @@ -278,7 +271,7 @@ private: { vector result; string excess; - if (str.length() > width) + if (int(str.length()) > width) { auto cut_space = str.rfind(' ', width-1); int excess_start; diff --git a/plugins/isoworldremote.cpp b/plugins/isoworldremote.cpp index 017fb45f6..651f89700 100644 --- a/plugins/isoworldremote.cpp +++ b/plugins/isoworldremote.cpp @@ -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_season(*cur_season); 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(); 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); - 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); } - 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); } return CR_OK; diff --git a/plugins/labormanager/joblabormapper.cpp b/plugins/labormanager/joblabormapper.cpp index 4f0124e93..becddeed3 100644 --- a/plugins/labormanager/joblabormapper.cpp +++ b/plugins/labormanager/joblabormapper.cpp @@ -210,8 +210,8 @@ static df::unit_labor construction_build_labor(df::building_actual* b) df::item* i = 0; for (auto p = b->contained_items.begin(); p != b->contained_items.end(); p++) - if (b->construction_stage > 0 && (*p)->use_mode == 2 || - b->construction_stage == 0 && (*p)->use_mode == 0) + if ((b->construction_stage > 0 && (*p)->use_mode == 2) || + (b->construction_stage == 0 && (*p)->use_mode == 0)) i = (*p)->item; MaterialInfo matinfo; diff --git a/plugins/labormanager/labormanager.cpp b/plugins/labormanager/labormanager.cpp index 3ef1808a2..5c408c354 100644 --- a/plugins/labormanager/labormanager.cpp +++ b/plugins/labormanager/labormanager.cpp @@ -1147,7 +1147,7 @@ private: tool_count[TOOL_AXE]++; else if (weaponsk == df::job_skill::MINING) tool_count[TOOL_PICK]++; - else if (weaponsk2 = df::job_skill::CROSSBOW) + else if (weaponsk2 == df::job_skill::CROSSBOW) tool_count[TOOL_CROSSBOW]++; } @@ -1493,10 +1493,12 @@ private: if (labor != df::unit_labor::NONE) { if (d->dwarf->status.labors[labor]) + { if (labor == df::unit_labor::OPERATE_PUMP) score += 50000; else score += 25000; + } if (default_labor_infos[labor].tool != TOOL_NONE && d->has_tool[default_labor_infos[labor].tool]) score += 10000000; @@ -2088,7 +2090,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan DFhackCExport command_result plugin_onupdate(color_ostream &out) { - static int step_count = 0; + // static int step_count = 0; // check run conditions 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) return CR_OK; - step_count = 0; + // step_count = 0; debug_stream = &out; AutoLaborManager alm(out); @@ -2263,7 +2265,7 @@ command_result labormanager(color_ostream &out, std::vector & para out << "All labors reset." << endl; 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) { diff --git a/plugins/listcolumn.h b/plugins/listcolumn.h index f7747d96d..0abe07b9d 100644 --- a/plugins/listcolumn.h +++ b/plugins/listcolumn.h @@ -16,7 +16,7 @@ public: UIColor color; 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 &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(); } void add(const string &text, const T &elem) { list.push_back(ListEntry(text, elem)); - if (text.length() > max_item_width) + if (text.length() > size_t(max_item_width)) max_item_width = text.length(); } @@ -110,7 +110,7 @@ public: paint_text(COLOR_TITLE, left_margin, y, title); 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; 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) { - int i = 0; - for (; i < display_list.size(); i++) + for (size_t i = 0; i < display_list.size(); i++) { if (display_list[i]->elem == elem) { @@ -447,7 +446,7 @@ public: gps->mouse_x >= left_margin && gps->mouse_x < left_margin + max_item_width) { 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); feed_mouse_set_highlight = true; @@ -472,7 +471,7 @@ public: void setTitle(const string t) { title = t; - if (title.length() > max_item_width) + if (title.length() > size_t(max_item_width)) max_item_width = title.length(); } diff --git a/plugins/luasocket.cpp b/plugins/luasocket.cpp index 0259c562f..2903616e7 100644 --- a/plugins/luasocket.cpp +++ b/plugins/luasocket.cpp @@ -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"); } 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()); } diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 2940b493b..5dab2ab09 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -596,7 +596,7 @@ namespace unit_ops { } 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) return string(columns[i].label); @@ -657,7 +657,7 @@ struct ProfessionTemplate 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)) { @@ -678,7 +678,7 @@ struct ProfessionTemplate if (mask) 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)) { @@ -696,7 +696,7 @@ struct ProfessionTemplate if (!mask && name.size() > 0) 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; bool status = hasLabor(labor); @@ -709,7 +709,7 @@ struct ProfessionTemplate 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]) labors.push_back(columns[i].labor); @@ -899,7 +899,7 @@ public: } OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size())); 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; for ( ; i < units.size(); i++) { @@ -1046,7 +1046,7 @@ public: menu_options.display(true); OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size())); 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; for ( ; i < units.size(); i++) { @@ -1138,7 +1138,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur df::unit *unit = src[i]; if (!unit) { - if (cursor_pos > i) + if (cursor_pos > int(i)) cursor_pos--; continue; } @@ -1192,7 +1192,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur if (first_row > sel_row) first_row = sel_row - num_rows + 1; // 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; last_selection = -1; @@ -1207,7 +1207,7 @@ void viewscreen_unitlaborsst::calcIDs() if (!initialized) { initialized = true; - for (int i = 0; i < NUM_COLUMNS; i++) + for (size_t i = 0; i < NUM_COLUMNS; i++) group_map.insert(std::pair(columns[i].profession, columns[i].group)); } memset(list_prof_ids, 0, sizeof(list_prof_ids)); @@ -1267,7 +1267,7 @@ void viewscreen_unitlaborsst::calcSize() auto dim = Screen::getWindowSize(); num_rows = dim.y - 11; - if (num_rows > units.size()) + if (num_rows > int(units.size())) num_rows = units.size(); 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 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(); size_t detail_cmp; @@ -1300,7 +1300,7 @@ void viewscreen_unitlaborsst::calcSize() } else { 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; } @@ -1383,7 +1383,7 @@ void viewscreen_unitlaborsst::calcSize() return; // 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; // 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; // 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]; // if it shrinks horizontally, scroll to the right to keep the cursor visible @@ -1437,7 +1437,7 @@ void viewscreen_unitlaborsst::feed(set *events) { 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; } @@ -1450,9 +1450,9 @@ void viewscreen_unitlaborsst::feed(set *events) 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; else sel_row = units.size() - 1; @@ -1487,7 +1487,7 @@ void viewscreen_unitlaborsst::feed(set *events) { // go to beginning of next 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)) next++; if ((next < NUM_COLUMNS) && (columns[next].group != cur)) @@ -1499,14 +1499,14 @@ void viewscreen_unitlaborsst::feed(set *events) if (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; 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 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++; if (first_column < endgroup_column - col_widths[DISP_COLUMN_LABORS] + 1) @@ -1674,7 +1674,7 @@ void viewscreen_unitlaborsst::feed(set *events) { 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) unit->status.labors[columns[i].labor] = false; @@ -1688,7 +1688,7 @@ void viewscreen_unitlaborsst::feed(set *events) { const SkillColumn &col = columns[input_column]; 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) continue; @@ -1698,7 +1698,7 @@ void viewscreen_unitlaborsst::feed(set *events) { 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) unit->status.labors[columns[j].labor] = false; @@ -1767,6 +1767,8 @@ void viewscreen_unitlaborsst::feed(set *events) case ALTSORT_ARRIVAL: altsort = ALTSORT_NAME; break; + case ALTSORT_MAX: + break; } } if (events->count(interface_key::OPTION20)) @@ -1847,7 +1849,7 @@ void viewscreen_unitlaborsst::feed(set *events) { 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) { @@ -1893,7 +1895,7 @@ void viewscreen_unitlaborsst::render() for (int col = 0; col < col_widths[DISP_COLUMN_LABORS]; col++) { int col_offset = col + first_column; - if (col_offset >= NUM_COLUMNS) + if (size_t(col_offset) >= NUM_COLUMNS) break; int8_t fg = columns[col_offset].color; @@ -1922,7 +1924,7 @@ void viewscreen_unitlaborsst::render() for (int row = 0; row < num_rows; row++) { int row_offset = row + first_row; - if (row_offset >= units.size()) + if (size_t(row_offset) >= units.size()) break; UnitInfo *cur = units[row_offset]; @@ -1998,7 +2000,7 @@ void viewscreen_unitlaborsst::render() skill = binsearch_in_vector(unit->status.current_soul->skills, &df::unit_skill::id, columns[col_offset].skill); if ((skill != NULL) && (skill->rating || skill->experience)) { - int level = skill->rating; + size_t level = skill->rating; if (level > NUM_SKILL_LEVELS - 1) level = NUM_SKILL_LEVELS - 1; c = skill_levels[level].abbrev; @@ -2060,7 +2062,7 @@ void viewscreen_unitlaborsst::render() skill = binsearch_in_vector(unit->status.current_soul->skills, &df::unit_skill::id, columns[sel_column].skill); if (skill) { - int level = skill->rating; + size_t level = skill->rating; if (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)); diff --git a/plugins/mousequery.cpp b/plugins/mousequery.cpp index 7a70f29c4..4e0143fb6 100644 --- a/plugins/mousequery.cpp +++ b/plugins/mousequery.cpp @@ -46,7 +46,7 @@ static bool live_view = true; static bool skip_tracking_once = 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) { @@ -231,9 +231,10 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest case Burrows: return ui->burrows.in_define_mode; - }; - return false; + default: + return false; + } } bool isInTrackableMode() diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 63acfe3da..5f4a59ceb 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -401,9 +401,9 @@ command_result df_bprobe (color_ostream &out, vector & parameters) Buildings::t_building building; if (!Buildings::Read(i, building)) continue; - if (!(building.x1 <= cursor->x && cursor->x <= building.x2 && - building.y1 <= cursor->y && cursor->y <= building.y2 && - building.z == cursor->z)) + if (int32_t(building.x1) > cursor->x || cursor->x > int32_t(building.x2) || + int32_t(building.y1) > cursor->y || cursor->y > int32_t(building.y2) || + int32_t(building.z) != cursor->z) continue; string name; building.origin->getName(&name); diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index 32e360a3a..18efeac98 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -152,7 +152,7 @@ void printMats(color_ostream &con, MatMap &mat, std::vector &materials, bool for (MatSorter::const_iterator it = sorting_vector.begin(); it != sorting_vector.end(); ++it) { - if(it->first >= materials.size()) + if(size_t(it->first) >= materials.size()) { con << "Bad index: " << it->first << " out of " << materials.size() << endl; @@ -747,7 +747,7 @@ command_result prospector (color_ostream &con, vector & parameters) for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++) { const df::plant & plant = *(*it); - if (plant.pos.z != z) + if (uint32_t(plant.pos.z) != z) continue; df::coord2d loc(plant.pos.x, plant.pos.y); loc = loc % 16; diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index e1282d600..f1645a84f 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -737,7 +737,6 @@ bool IsBuildingChanged(DFCoord pos) for (int x = 0; x < 16; x++) 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; if (buildingHashes[pos] != bld) { @@ -1517,7 +1516,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in bool spatterChanged = IsspatterChanged(pos); bool itemsChanged = block->items.size() > 0; bool flows = block->flows.size() > 0; - RemoteFortressReader::MapBlock *net_block; + RemoteFortressReader::MapBlock *net_block = nullptr; if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows) net_block = out->add_map_blocks(); if (tileChanged) @@ -2813,13 +2812,10 @@ static command_result GetPartialPlantRaws(color_ostream &stream, const ListReque df::world * world = df::global::world; int list_start = 0; - int list_end = world->raws.plants.all.size(); if (in != nullptr) { 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++) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 199e174af..fa2f18d5c 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -335,7 +335,6 @@ void lightingEngineViewscreen::fixAdvMode(int mode) int window_x=*df::global::window_x; int window_y=*df::global::window_y; int window_z=*df::global::window_z; - coord2d vpSize=rect_size(vp); //mode 0-> make dark non-visible parts if(mode==0) { @@ -939,14 +938,14 @@ matLightDef lua_parseMatDef(lua_State* L) matLightDef ret; lua_getfield(L,-1,"tr"); - if(ret.isTransparent=!lua_isnil(L,-1)) + if((ret.isTransparent=!lua_isnil(L,-1))) { ret.transparency=lua_parseLightCell(L); } lua_pop(L,1); lua_getfield(L,-1,"em"); - if(ret.isEmiting=!lua_isnil(L,-1)) + if((ret.isEmiting=!lua_isnil(L,-1))) { ret.emitColor=lua_parseLightCell(L); lua_pop(L,1); diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index c2479bedc..6908225ea 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -418,6 +418,8 @@ command_result revflood(color_ostream &out, vector & params) case tiletype_shape::STAIR_DOWN: tt = ctt; break; + default: + break; } bool below = 0; @@ -433,6 +435,7 @@ command_result revflood(color_ostream &out, vector & params) unhide = 0; break; // air/free space + case tiletype_shape::NONE: case tiletype_shape::EMPTY: case tiletype_shape::RAMP_TOP: case tiletype_shape::STAIR_UPDOWN: diff --git a/plugins/search.cpp b/plugins/search.cpp index 1e919572b..ed8934a0c 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -1459,12 +1459,12 @@ public: // About to make an assignment, so restore original list (it will be changed by the game) int32_t *cursor = get_viewscreen_cursor(); auto list = get_primary_list(); - if (*cursor >= list->size()) + if (size_t(*cursor) >= list->size()) return false; df::unit *selected_unit = list->at(*cursor); clear_search(); - for (*cursor = 0; *cursor < list->size(); (*cursor)++) + for (*cursor = 0; size_t(*cursor) < list->size(); (*cursor)++) { if (list->at(*cursor) == selected_unit) break; diff --git a/plugins/showmood.cpp b/plugins/showmood.cpp index d2ae73f08..9e3fa7ff7 100644 --- a/plugins/showmood.cpp +++ b/plugins/showmood.cpp @@ -98,6 +98,8 @@ command_result df_showmood (color_ostream &out, vector & parameters) case mood_type::Possessed: out.print("possessed"); break; + default: + break; } out.print(" with intent to "); switch (job->job_type) @@ -275,7 +277,7 @@ command_result df_showmood (color_ostream &out, vector & parameters) int count_got = 0; 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) count_got += job->items[j]->item->getTotalDimension(); diff --git a/plugins/stockpiles/CMakeLists.txt b/plugins/stockpiles/CMakeLists.txt index 713c3d6d1..7d5cce921 100644 --- a/plugins/stockpiles/CMakeLists.txt +++ b/plugins/stockpiles/CMakeLists.txt @@ -14,31 +14,10 @@ SET(PROJECT_SRCS ) 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) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) -#Generate sources from our proto files and store them in the source tree -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() +DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} PROTOBUFS ${PROJECT_PROTOS} LINK_LIBRARIES protobuf-lite lua) diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index a5b84672d..154a58dc3 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -42,17 +42,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) #define MAX_NAME 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 diff --git a/plugins/strangemood.cpp b/plugins/strangemood.cpp index 7d967b006..9a7f7f5fb 100644 --- a/plugins/strangemood.cpp +++ b/plugins/strangemood.cpp @@ -106,6 +106,8 @@ df::job_skill getMoodSkill (df::unit *unit) if (skill->rating == level) skills.push_back(skill->id); break; + default: + break; } } 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 part; output.first_name.clear(); 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]; } if (mode != 10) @@ -616,6 +618,8 @@ command_result df_strangemood (color_ostream &out, vector & parameters) for (int j = 0; j < 15; j++) tickets.push_back(i); break; + default: + break; } } if (!tickets.size()) @@ -765,6 +769,8 @@ command_result df_strangemood (color_ostream &out, vector & parameters) case job_skill::MECHANICS: job->job_type = job_type::StrangeMoodMechanics; break; + default: + break; } } // 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 & parameters) } item->quantity = base_item_count; break; + default: + break; } } @@ -1157,8 +1165,10 @@ command_result df_strangemood (color_ostream &out, vector & parameters) case job_skill::GLASSMAKER: avoid_glass = 1; 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))) { diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index 76da1df3e..36bde1ac7 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -78,7 +78,7 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) void help( color_ostream & out, std::vector &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()) { out << "Commands:" << std::endl @@ -812,7 +812,7 @@ command_result executePaintJob(color_ostream &out) */ // Remove direction from directionless tiles 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; } @@ -894,7 +894,7 @@ command_result executePaintJob(color_ostream &out) command_result processCommand(color_ostream &out, std::vector &commands, int start, int end, bool & endLoop, bool hasConsole = false) { - if (commands.size() == start) + if (commands.size() == size_t(start)) { return executePaintJob(out); } diff --git a/plugins/tweak/tweaks/max-wheelbarrow.h b/plugins/tweak/tweaks/max-wheelbarrow.h index 37f292d6b..4df02abd2 100644 --- a/plugins/tweak/tweaks/max-wheelbarrow.h +++ b/plugins/tweak/tweaks/max-wheelbarrow.h @@ -45,7 +45,6 @@ struct max_wheelbarrow_hook : df::viewscreen_dwarfmodest { bool handled = false; if (stockpile) { - auto dims = Gui::getDwarfmodeViewDims(); handled = true; if (!in_wheelbarrow_entry && input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW)) diff --git a/plugins/uicommon.h b/plugins/uicommon.h index a9a4a0ea8..17fcd18bd 100644 --- a/plugins/uicommon.h +++ b/plugins/uicommon.h @@ -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) { - if (text.length() > size) + if (text.length() > size_t(size)) { if (trim && size > 10) { @@ -318,6 +318,8 @@ static inline bool can_melt(df::item* item) } } break; + default: + break; } } @@ -334,12 +336,13 @@ static inline bool can_melt(df::item* item) class StockpileInfo { 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(); } diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index cc3ac8cd7..bfc4b639f 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -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) { 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; if (out) diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 608216092..c67c5b051 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -2073,7 +2073,7 @@ command_result df_zone (color_ostream &out, vector & parameters) if(target_count > 0) { vector 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) { df::unit *unit = *unit_it;