Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7dfacd

Browse files
committed
Fix warnings in supported plugins.
1 parent f3038fe commit a7dfacd

53 files changed

Lines changed: 246 additions & 277 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

plugins/Brushes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class ColumnBrush : public Brush
130130
while (mc.testCoord(start))
131131
{
132132
df::tiletype tt = mc.tiletypeAt(start);
133-
if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt))
133+
if(DFHack::LowPassable(tt) || (juststarted && DFHack::HighPassable(tt)))
134134
{
135135
v.push_back(start);
136136
juststarted = false;

plugins/autochop.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,8 @@ static bool skip_plant(const df::plant * plant, bool *restricted)
267267

268268
if (skip.food_trees || skip.cook_trees)
269269
{
270-
df::material * mat;
271-
for (int idx = 0; idx < plant_raw->material.size(); idx++)
270+
for (df::material * mat : plant_raw->material)
272271
{
273-
mat = plant_raw->material[idx];
274272
if (skip.food_trees && mat->flags.is_set(material_flags::EDIBLE_RAW))
275273
{
276274
if (restricted)

plugins/autohauler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static void init_state()
624624
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str());
625625

626626
// Ensure that the labor is defined in the existing list
627-
if (labor >= 0 && labor <= labor_infos.size())
627+
if (labor >= 0 && size_t(labor) <= labor_infos.size())
628628
{
629629
// Link the labor treatment with the associated persistent data item
630630
labor_infos[labor].set_config(*p);
@@ -635,7 +635,7 @@ static void init_state()
635635
}
636636

637637
// Add default labors for those not in save
638-
for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
638+
for (size_t i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
639639

640640
// Determine if the labor is already present. If so, exit the for loop
641641
if (labor_infos[i].config.isValid())
@@ -806,7 +806,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
806806
// Scan the world and look for any citizens in the player's civilization.
807807
// Add these to the list of dwarves.
808808
// xxx Does it need to be ++i?
809-
for (int i = 0; i < world->units.active.size(); ++i)
809+
for (size_t i = 0; i < world->units.active.size(); ++i)
810810
{
811811
df::unit* cre = world->units.active[i];
812812
if (Units::isCitizen(cre))
@@ -895,7 +895,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
895895
else
896896
{
897897
int job = dwarfs[dwarf]->job.current_job->job_type;
898-
if (job >= 0 && job < ARRAY_COUNT(dwarf_states))
898+
if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
899899
dwarf_info[dwarf].state = dwarf_states[job];
900900
else
901901
{
@@ -960,7 +960,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
960960
continue;
961961

962962
// For every dwarf...
963-
for(int dwarf = 0; dwarf < dwarfs.size(); dwarf++)
963+
for(size_t dwarf = 0; dwarf < dwarfs.size(); dwarf++)
964964
{
965965
if (!Units::isValidLabor(dwarfs[dwarf], labor))
966966
continue;
@@ -1138,7 +1138,7 @@ command_result autohauler (color_ostream &out, std::vector <std::string> & param
11381138
return CR_FAILURE;
11391139
}
11401140

1141-
for (int i = 0; i < labor_infos.size(); i++)
1141+
for (size_t i = 0; i < labor_infos.size(); i++)
11421142
{
11431143
reset_labor((df::unit_labor) i);
11441144
}

plugins/autolabor.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static void init_state()
606606
{
607607
string key = p->key();
608608
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str());
609-
if (labor >= 0 && labor <= labor_infos.size())
609+
if (labor >= 0 && size_t(labor) <= labor_infos.size())
610610
{
611611
labor_infos[labor].config = *p;
612612
labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive;
@@ -615,7 +615,7 @@ static void init_state()
615615
}
616616

617617
// Add default labors for those not in save
618-
for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
618+
for (size_t i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
619619
if (labor_infos[i].config.isValid())
620620
continue;
621621

@@ -960,7 +960,7 @@ static void assign_labor(unit_labor::unit_labor labor,
960960
* Military and children/nobles will not have labors assigned.
961961
* Dwarfs with the "health management" responsibility are always assigned DIAGNOSIS.
962962
*/
963-
for (int i = 0; i < candidates.size() && labor_infos[labor].active_dwarfs < max_dwarfs; i++)
963+
for (size_t i = 0; i < candidates.size() && labor_infos[labor].active_dwarfs < max_dwarfs; i++)
964964
{
965965
int dwarf = candidates[i];
966966

@@ -1048,7 +1048,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
10481048
bool has_fishery = false;
10491049
bool trader_requested = false;
10501050

1051-
for (int i = 0; i < world->buildings.all.size(); ++i)
1051+
for (size_t i = 0; i < world->buildings.all.size(); ++i)
10521052
{
10531053
df::building *build = world->buildings.all[i];
10541054
auto type = build->getType();
@@ -1074,7 +1074,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
10741074
}
10751075
}
10761076

1077-
for (int i = 0; i < world->units.active.size(); ++i)
1077+
for (size_t i = 0; i < world->units.active.size(); ++i)
10781078
{
10791079
df::unit* cre = world->units.active[i];
10801080
if (Units::isCitizen(cre))
@@ -1105,7 +1105,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
11051105

11061106
df::historical_figure* hf = df::historical_figure::find(dwarfs[dwarf]->hist_figure_id);
11071107
if(hf!=NULL) //can be NULL. E.g. script created citizens
1108-
for (int i = 0; i < hf->entity_links.size(); i++)
1108+
for (size_t i = 0; i < hf->entity_links.size(); i++)
11091109
{
11101110
df::histfig_entity_link* hfelink = hf->entity_links.at(i);
11111111
if (hfelink->getType() == df::histfig_entity_link_type::POSITION)
@@ -1140,7 +1140,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
11401140

11411141
// identify dwarfs who are needed for meetings and mark them for exclusion
11421142

1143-
for (int i = 0; i < ui->activities.size(); ++i)
1143+
for (size_t i = 0; i < ui->activities.size(); ++i)
11441144
{
11451145
df::activity_info *act = ui->activities[i];
11461146
if (!act) continue;
@@ -1230,7 +1230,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
12301230
else
12311231
{
12321232
int job = dwarfs[dwarf]->job.current_job->job_type;
1233-
if (job >= 0 && job < ARRAY_COUNT(dwarf_states))
1233+
if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
12341234
dwarf_info[dwarf].state = dwarf_states[job];
12351235
else
12361236
{
@@ -1341,7 +1341,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
13411341

13421342
for (int i = 0; i < num_haulers; i++)
13431343
{
1344-
assert(i < hauler_ids.size());
1344+
assert(size_t(i) < hauler_ids.size());
13451345

13461346
int dwarf = hauler_ids[i];
13471347

@@ -1357,7 +1357,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
13571357
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());
13581358
}
13591359

1360-
for (int i = num_haulers; i < hauler_ids.size(); i++)
1360+
for (size_t i = num_haulers; i < hauler_ids.size(); i++)
13611361
{
13621362
assert(i < hauler_ids.size());
13631363

@@ -1517,7 +1517,7 @@ command_result autolabor (color_ostream &out, std::vector <std::string> & parame
15171517
return CR_FAILURE;
15181518
}
15191519

1520-
for (int i = 0; i < labor_infos.size(); i++)
1520+
for (size_t i = 0; i < labor_infos.size(); i++)
15211521
{
15221522
reset_labor((df::unit_labor) i);
15231523
}

plugins/automaterial.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ struct MaterialDescriptor
6969
}
7070
};
7171

72-
73-
static command_result automaterial_cmd(color_ostream &out, vector <string> & parameters)
74-
{
75-
return CR_OK;
76-
}
77-
7872
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
7973
{
8074
return CR_OK;
@@ -1124,6 +1118,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
11241118
break;
11251119

11261120
case SELECT_SECOND:
1121+
{
11271122
OutputString(COLOR_GREEN, x, y, "Choose second corner", true, left_margin);
11281123

11291124
int32_t curr_x, curr_y, curr_z;
@@ -1137,6 +1132,11 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
11371132
int cx = box_first.x;
11381133
int cy = box_first.y;
11391134
OutputString(COLOR_BROWN, cx, cy, "X", false, 0, 0, true /* map */);
1135+
break;
1136+
}
1137+
1138+
default:
1139+
break;
11401140
}
11411141

11421142
OutputString(COLOR_BROWN, x, ++y, "Ignore Building Restrictions", true, left_margin);

plugins/blueprint.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
106106
{
107107
if (! b)
108108
return " ";
109-
bool at_nw_corner = x == b->x1 && y == b->y1;
110-
bool at_se_corner = x == b->x2 && y == b->y2;
111-
bool at_center = x == b->centerx && y == b->centery;
109+
bool at_nw_corner = int32_t(x) == b->x1 && int32_t(y) == b->y1;
110+
bool at_se_corner = int32_t(x) == b->x2 && int32_t(y) == b->y2;
111+
bool at_center = int32_t(x) == b->centerx && int32_t(y) == b->centery;
112112
pair<uint32_t, uint32_t> size = get_building_size(b);
113113
stringstream out;// = stringstream();
114114
switch(b->getType())
@@ -227,7 +227,10 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
227227
return "wy";
228228
case workshop_type::Dyers:
229229
return "wd";
230+
case workshop_type::Kennels:
231+
return "k";
230232
case workshop_type::Custom:
233+
case workshop_type::Tool:
231234
//can't do anything with custom workshop
232235
return "`";
233236
}
@@ -261,6 +264,8 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
261264
case building_type::Construction:
262265
switch (((df::building_constructionst*) b)->type)
263266
{
267+
case construction_type::NONE:
268+
return "`";
264269
case construction_type::Fortification:
265270
return "CF";
266271
case construction_type::Wall:
@@ -482,7 +487,7 @@ string get_tile_place(uint32_t x, uint32_t y, df::building* b)
482487
{
483488
if (! b || b->getType() != building_type::Stockpile)
484489
return " ";
485-
if (b->x1 != x || b->y1 != y)
490+
if (b->x1 != int32_t(x) || b->y1 != int32_t(y))
486491
return "`";
487492
pair<uint32_t, uint32_t> size = get_building_size(b);
488493
df::building_stockpilest* sp = (df::building_stockpilest*) b;

plugins/building-hacks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ struct work_hook : df::building_workshopst{
287287
}
288288
int w=db->x2-db->x1+1;
289289
std::vector<graphic_tile> &cur_frame=def->frames[frame];
290-
for(int i=0;i<cur_frame.size();i++)
290+
for(size_t i=0;i<cur_frame.size();i++)
291291
{
292292
if(cur_frame[i].tile>=0)
293293
{

plugins/buildingplan-lib.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void enable_quickfort_fn(pair<const df::building_type, bool>& pair) { pair.secon
1717
* Material Choice Screen
1818
*/
1919

20-
static std::string material_to_string_fn(DFHack::MaterialInfo m) { return m.toString(); }
20+
std::string material_to_string_fn(DFHack::MaterialInfo m) { return m.toString(); }
2121

2222
bool ItemFilter::matchesMask(DFHack::MaterialInfo &mat)
2323
{
@@ -131,7 +131,7 @@ void ItemFilter::clear()
131131
materials.clear();
132132
}
133133

134-
static DFHack::MaterialInfo &material_info_identity_fn(DFHack::MaterialInfo &m) { return m; }
134+
DFHack::MaterialInfo &material_info_identity_fn(DFHack::MaterialInfo &m) { return m; }
135135

136136
ViewscreenChooseMaterial::ViewscreenChooseMaterial(ItemFilter *filter)
137137
{
@@ -386,7 +386,7 @@ void RoomMonitor::reset(color_ostream &out)
386386
}
387387

388388

389-
static void delete_item_fn(df::job_item *x) { delete x; }
389+
void delete_item_fn(df::job_item *x) { delete x; }
390390

391391
// START Planning
392392

@@ -654,3 +654,12 @@ void Planner::cycleDefaultQuality(df::building_type type)
654654
if (*quality == item_quality::Artifact)
655655
(*quality) = item_quality::Ordinary;
656656
}
657+
658+
map<df::building_type, bool> planmode_enabled, saved_planmodes;
659+
660+
bool show_debugging = false;
661+
bool show_help = false;
662+
663+
Planner planner;
664+
665+
RoomMonitor roomMonitor;

plugins/buildingplan-lib.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct MaterialDescriptor
6565
#define MAX_MATERIAL 21
6666
#define SIDEBAR_WIDTH 30
6767

68-
static bool canReserveRoom(df::building *building)
68+
static inline bool canReserveRoom(df::building *building)
6969
{
7070
if (!building)
7171
return false;
@@ -76,7 +76,7 @@ static bool canReserveRoom(df::building *building)
7676
return building->is_room;
7777
}
7878

79-
static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
79+
static inline std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
8080
{
8181
std::vector<Units::NoblePosition> np;
8282
Units::getNoblePositions(&np, unit);
@@ -92,19 +92,19 @@ static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
9292
return np;
9393
}
9494

95-
static void delete_item_fn(df::job_item *x);
95+
void delete_item_fn(df::job_item *x);
9696

97-
static MaterialInfo &material_info_identity_fn(MaterialInfo &m);
97+
MaterialInfo &material_info_identity_fn(MaterialInfo &m);
9898

99-
static map<df::building_type, bool> planmode_enabled, saved_planmodes;
99+
extern map<df::building_type, bool> planmode_enabled, saved_planmodes;
100100

101101
void enable_quickfort_fn(pair<const df::building_type, bool>& pair);
102102

103103
void debug(const std::string &msg);
104-
static std::string material_to_string_fn(MaterialInfo m);
104+
std::string material_to_string_fn(MaterialInfo m);
105105

106-
static bool show_debugging = false;
107-
static bool show_help = false;
106+
extern bool show_debugging;
107+
extern bool show_help;
108108

109109
struct ItemFilter
110110
{
@@ -387,7 +387,7 @@ class Planner
387387
public:
388388
bool in_dummmy_screen;
389389

390-
Planner() : quickfort_mode(false), in_dummmy_screen(false) { }
390+
Planner() : in_dummmy_screen(false), quickfort_mode(false) { }
391391

392392
bool isPlanableBuilding(const df::building_type type) const
393393
{
@@ -491,8 +491,8 @@ class Planner
491491
}
492492
};
493493

494-
static Planner planner;
494+
extern Planner planner;
495495

496-
static RoomMonitor roomMonitor;
496+
extern RoomMonitor roomMonitor;
497497

498498
#endif

plugins/buildingplan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
194194
df::interface_key last_token = get_string_key(input);
195195
if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A058)
196196
{
197-
int selection = last_token - interface_key::STRING_A048;
197+
size_t selection = last_token - interface_key::STRING_A048;
198198
if (np.size() < selection)
199199
return false;
200200
roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code);
@@ -317,7 +317,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
317317
int y = 24;
318318
OutputString(COLOR_BROWN, x, y, "DFHack", true, left_margin);
319319
OutputString(COLOR_WHITE, x, y, "Auto-allocate to:", true, left_margin);
320-
for (int i = 0; i < np.size() && i < 9; i++)
320+
for (size_t i = 0; i < np.size() && i < 9; i++)
321321
{
322322
bool enabled = (roomMonitor.getReservedNobleCode(world->selected_building->id)
323323
== np[i].position->code);

0 commit comments

Comments
 (0)