12 changes: 6 additions & 6 deletions plugins/command-prompt.cpp
Expand Up @@ -56,7 +56,7 @@ class viewscreen_commandpromptst : public dfhack_viewscreen {
df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); }

std::string getFocusString() { return "commandprompt"; }
viewscreen_commandpromptst(std::string entry):is_response(false), submitted(false)
viewscreen_commandpromptst(std::string entry):submitted(false), is_response(false)
{
show_fps=gps->display_frames;
gps->display_frames=0;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -243,7 +243,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *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;
}
Expand All @@ -260,7 +260,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *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))
Expand Down Expand Up @@ -294,10 +294,10 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *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();
Expand Down
2 changes: 1 addition & 1 deletion plugins/createitem.cpp
Expand Up @@ -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;
Expand Down
41 changes: 20 additions & 21 deletions plugins/dig.cpp
Expand Up @@ -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++)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -948,7 +948,7 @@ command_result digexp (color_ostream &out, vector <string> & 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],
Expand All @@ -961,7 +961,7 @@ command_result digexp (color_ostream &out, vector <string> & 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],
Expand All @@ -975,7 +975,7 @@ command_result digexp (color_ostream &out, vector <string> & 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);
Expand All @@ -985,7 +985,7 @@ command_result digexp (color_ostream &out, vector <string> & 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++)
Expand Down Expand Up @@ -1023,7 +1023,7 @@ command_result digexp (color_ostream &out, vector <string> & 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);
Expand Down Expand Up @@ -1075,7 +1075,7 @@ command_result digv (color_ostream &out, vector <string> & 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;
Expand Down Expand Up @@ -1136,10 +1136,10 @@ command_result digv (color_ostream &out, vector <string> & 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));
Expand All @@ -1153,7 +1153,7 @@ command_result digv (color_ostream &out, vector <string> & 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));
Expand All @@ -1178,7 +1178,7 @@ command_result digv (color_ostream &out, vector <string> & 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);

Expand Down Expand Up @@ -1262,7 +1262,7 @@ command_result digl (color_ostream &out, vector <string> & 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;
Expand Down Expand Up @@ -1320,10 +1320,10 @@ command_result digl (color_ostream &out, vector <string> & 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));
Expand All @@ -1337,7 +1337,7 @@ command_result digl (color_ostream &out, vector <string> & 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));
Expand Down Expand Up @@ -1389,7 +1389,7 @@ command_result digl (color_ostream &out, vector <string> & 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);

Expand Down Expand Up @@ -1438,7 +1438,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
return CR_FAILURE;
}

uint32_t targetDigType;
int32_t targetDigType;
if ( parameters.size() == 1 )
{
string parameter = parameters[0];
Expand Down Expand Up @@ -1526,7 +1526,6 @@ command_result digtype (color_ostream &out, vector <string> & 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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/digFlood.cpp
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions plugins/diggingInvaders/assignJob.cpp
Expand Up @@ -68,8 +68,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
}
//out.print("first important edge: (%d,%d,%d) -> (%d,%d,%d)\n", pt1.x,pt1.y,pt1.z, pt2.x,pt2.y,pt2.z);

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];
Expand Down Expand Up @@ -111,7 +109,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
building->jobs.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);
Expand All @@ -136,7 +133,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
firstInvader->job.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 )
Expand Down Expand Up @@ -204,7 +200,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
firstInvader->path.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
Expand Down
2 changes: 1 addition & 1 deletion plugins/diggingInvaders/edgeCost.cpp
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/dwarfvet.cpp
Expand Up @@ -370,7 +370,7 @@ void AnimalHospital::processPatients(color_ostream &out) {
// Where the magic happens
for (vector<Patient*>::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;
Expand 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;
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 5 additions & 4 deletions plugins/embark-assistant/finder_ui.cpp
Expand Up @@ -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<int8_t>(i));
fclose(infile);
return;
Expand Down Expand Up @@ -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] == ':') {
Expand Down
1 change: 0 additions & 1 deletion plugins/embark-assistant/help_ui.cpp
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions plugins/embark-assistant/matcher.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1285,7 +1282,7 @@ uint16_t embark_assist::matcher::find(embark_assist::defs::match_iterators *iter
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
uint16_t x_end;
uint16_t y_end;
bool turn;
bool turn = false;
uint16_t count;
uint16_t preliminary_matches;

Expand Down
2 changes: 1 addition & 1 deletion plugins/embark-assistant/survey.cpp
Expand Up @@ -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<df::viewscreen_choose_start_sitest>(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;
Expand Down
4 changes: 3 additions & 1 deletion plugins/embark-tools.cpp
Expand Up @@ -268,6 +268,8 @@ class StablePosition : public EmbarkTool
case df::interface_key::CURSOR_DOWNRIGHT_FAST:
is_motion = true;
break;
default:
break;
}
if (is_motion && !moved_position)
{
Expand Down Expand Up @@ -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("...");
Expand Down
21 changes: 5 additions & 16 deletions plugins/eventful.cpp
Expand Up @@ -78,17 +78,6 @@ struct ReactionInfo {
static std::map<std::string, ReactionInfo> reactions;
static std::map<df::reaction_product*, ProductInfo*> products;

static ReactionInfo *find_reaction(const std::string &name)
{
auto it = reactions.find(name);
return (it != reactions.end()) ? &it->second : NULL;
}

static bool is_lua_hook(const std::string &name)
{
return name.size() > 9 && memcmp(name.data(), "LUA_HOOK_", 9) == 0;
}

/*
* Hooks
*/
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions plugins/fastdwarf.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/filltraffic.cpp
Expand Up @@ -215,15 +215,15 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & 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));
}
if (xy.y > 0)
{
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));
}
Expand All @@ -234,7 +234,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{
flood.push(DFCoord(xy.x, xy.y, xy.z - 1));
}
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));
}
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 1 addition & 14 deletions plugins/fix-unit-occupancy.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions plugins/follow.cpp
Expand Up @@ -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!
Expand Down
24 changes: 13 additions & 11 deletions plugins/forceequip.cpp
Expand Up @@ -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];
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -415,6 +414,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
// The "here" option is hardcoded to true, because the plugin currently doesn't support
// 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.
Expand Down Expand Up @@ -512,7 +512,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & 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++)
{
Expand All @@ -522,19 +522,21 @@ command_result df_forceequip(color_ostream &out, vector <string> & 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.

// 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);
Expand Down
10 changes: 5 additions & 5 deletions plugins/generated-creature-renamer.cpp
Expand Up @@ -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))
Expand Down Expand Up @@ -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] = '_';
Expand Down Expand Up @@ -194,7 +194,7 @@ command_result list_creatures(color_ostream &out, std::vector <std::string> & 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))
Expand Down Expand Up @@ -223,7 +223,7 @@ command_result save_generated_raw(color_ostream &out, std::vector <std::string>
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);

Expand All @@ -244,7 +244,7 @@ command_result save_generated_raw(color_ostream &out, std::vector <std::string>
{
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] = '_';
Expand Down
17 changes: 5 additions & 12 deletions plugins/hotkeys.cpp
Expand Up @@ -17,13 +17,6 @@ static map<string, string> current_bindings;
static vector<string> 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<string> cmd_parts;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -147,12 +140,12 @@ class ViewscreenHotkeys : public dfhack_viewscreen
{
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]];
Expand Down Expand Up @@ -230,7 +223,7 @@ class ViewscreenHotkeys : public dfhack_viewscreen
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)
Expand Down Expand Up @@ -278,7 +271,7 @@ class ViewscreenHotkeys : public dfhack_viewscreen
{
vector<string> result;
string excess;
if (str.length() > width)
if (int(str.length()) > width)
{
auto cut_space = str.rfind(' ', width-1);
int excess_start;
Expand Down
6 changes: 3 additions & 3 deletions plugins/isoworldremote.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions plugins/labormanager/joblabormapper.cpp
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions plugins/labormanager/labormanager.cpp
Expand Up @@ -1147,7 +1147,7 @@ class AutoLaborManager {
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]++;
}

Expand Down Expand Up @@ -1493,10 +1493,12 @@ class AutoLaborManager {
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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -2263,7 +2265,7 @@ command_result labormanager(color_ostream &out, std::vector <std::string> & 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)
{
Expand Down
15 changes: 7 additions & 8 deletions plugins/listcolumn.h
Expand Up @@ -16,7 +16,7 @@ class ListEntry
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)
{
}
};
Expand Down Expand Up @@ -73,14 +73,14 @@ class ListColumn
void add(const ListEntry<T> &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<T>(text, elem));
if (text.length() > max_item_width)
if (text.length() > size_t(max_item_width))
max_item_width = text.length();
}

Expand Down Expand Up @@ -110,7 +110,7 @@ class ListColumn
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;
Expand Down Expand Up @@ -336,8 +336,7 @@ class ListColumn

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)
{
Expand Down Expand Up @@ -447,7 +446,7 @@ class ListColumn
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;
Expand All @@ -472,7 +471,7 @@ class ListColumn
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();
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/luasocket.cpp
Expand Up @@ -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());
}
Expand Down
60 changes: 31 additions & 29 deletions plugins/manipulator.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
{
Expand All @@ -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))
{
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -899,7 +899,7 @@ class viewscreen_unitbatchopst : public dfhack_viewscreen {
}
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++)
{
Expand Down Expand Up @@ -1046,7 +1046,7 @@ class viewscreen_unitprofessionset : public dfhack_viewscreen {
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++)
{
Expand Down Expand Up @@ -1138,7 +1138,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cur
df::unit *unit = src[i];
if (!unit)
{
if (cursor_pos > i)
if (cursor_pos > int(i))
cursor_pos--;
continue;
}
Expand Down Expand Up @@ -1192,7 +1192,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &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;
Expand All @@ -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<df::profession, int>(columns[i].profession, columns[i].group));
}
memset(list_prof_ids, 0, sizeof(list_prof_ids));
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -1383,15 +1383,15 @@ 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
if (first_row < sel_row - num_rows + 1)
first_row = sel_row - num_rows + 1;

// if the window grows horizontally, scroll to the left to eliminate blank columns from the right
if (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
Expand Down Expand Up @@ -1437,7 +1437,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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;
}
Expand All @@ -1450,9 +1450,9 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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;
Expand Down Expand Up @@ -1487,7 +1487,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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))
Expand All @@ -1499,14 +1499,14 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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)
Expand Down Expand Up @@ -1674,7 +1674,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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;
Expand All @@ -1688,7 +1688,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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;
Expand All @@ -1698,7 +1698,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *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;
Expand Down Expand Up @@ -1767,6 +1767,8 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
case ALTSORT_ARRIVAL:
altsort = ALTSORT_NAME;
break;
case ALTSORT_MAX:
break;
}
}
if (events->count(interface_key::OPTION20))
Expand Down Expand Up @@ -1847,7 +1849,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{
if (events->count(interface_key::UNITJOB_VIEW_UNIT) || events->count(interface_key::UNITJOB_ZOOM_CRE))
{
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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -1998,7 +2000,7 @@ void viewscreen_unitlaborsst::render()
skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[col_offset].skill);
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;
Expand Down Expand Up @@ -2060,7 +2062,7 @@ void viewscreen_unitlaborsst::render()
skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[sel_column].skill);
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));
Expand Down
7 changes: 4 additions & 3 deletions plugins/mousequery.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions plugins/probe.cpp
Expand Up @@ -401,9 +401,9 @@ command_result df_bprobe (color_ostream &out, vector <string> & 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);
Expand Down
4 changes: 2 additions & 2 deletions plugins/prospector.cpp
Expand Up @@ -152,7 +152,7 @@ void printMats(color_ostream &con, MatMap &mat, std::vector<T*> &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;
Expand Down Expand Up @@ -747,7 +747,7 @@ command_result prospector (color_ostream &con, vector <string> & 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;
Expand Down
6 changes: 1 addition & 5 deletions plugins/remotefortressreader/remotefortressreader.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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++)
Expand Down
5 changes: 2 additions & 3 deletions plugins/rendermax/renderer_light.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions plugins/reveal.cpp
Expand Up @@ -418,6 +418,8 @@ command_result revflood(color_ostream &out, vector<string> & params)
case tiletype_shape::STAIR_DOWN:
tt = ctt;
break;
default:
break;
}

bool below = 0;
Expand All @@ -433,6 +435,7 @@ command_result revflood(color_ostream &out, vector<string> & 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:
Expand Down
4 changes: 2 additions & 2 deletions plugins/search.cpp
Expand Up @@ -1459,12 +1459,12 @@ class military_search : public military_search_base
// 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;
Expand Down
4 changes: 3 additions & 1 deletion plugins/showmood.cpp
Expand Up @@ -98,6 +98,8 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
case mood_type::Possessed:
out.print("possessed");
break;
default:
break;
}
out.print(" with intent to ");
switch (job->job_type)
Expand Down Expand Up @@ -275,7 +277,7 @@ command_result df_showmood (color_ostream &out, vector <string> & 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();
Expand Down
25 changes: 2 additions & 23 deletions plugins/stockpiles/CMakeLists.txt
Expand Up @@ -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)
11 changes: 0 additions & 11 deletions plugins/stocks.cpp
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions plugins/strangemood.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -175,7 +177,7 @@ void generateName(df::language_name &output, int language, int mode, const df::l
int32_t word; df::enum_field<df::part_of_speech,int16_t> part;
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)
Expand Down Expand Up @@ -616,6 +618,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
for (int j = 0; j < 15; j++)
tickets.push_back(i);
break;
default:
break;
}
}
if (!tickets.size())
Expand Down Expand Up @@ -765,6 +769,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & 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
Expand Down Expand Up @@ -1111,6 +1117,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
}
item->quantity = base_item_count;
break;
default:
break;
}
}

Expand Down Expand Up @@ -1157,8 +1165,10 @@ command_result df_strangemood (color_ostream &out, vector <string> & 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)))
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/tiletypes.cpp
Expand Up @@ -78,7 +78,7 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )

void help( color_ostream & out, std::vector<std::string> &commands, int start, int end)
{
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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -894,7 +894,7 @@ command_result executePaintJob(color_ostream &out)

command_result processCommand(color_ostream &out, std::vector<std::string> &commands, int start, int end, bool & endLoop, bool hasConsole = false)
{
if (commands.size() == start)
if (commands.size() == size_t(start))
{
return executePaintJob(out);
}
Expand Down
1 change: 0 additions & 1 deletion plugins/tweak/tweaks/max-wheelbarrow.h
Expand Up @@ -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))
Expand Down
9 changes: 6 additions & 3 deletions plugins/uicommon.h
Expand Up @@ -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)
{
Expand Down Expand Up @@ -318,6 +318,8 @@ static inline bool can_melt(df::item* item)
}
}
break;
default:
break;
}
}

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

Expand Down
2 changes: 1 addition & 1 deletion plugins/workflow.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/zone.cpp
Expand Up @@ -2073,7 +2073,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
if(target_count > 0)
{
vector <df::unit*> units_for_cagezone;
size_t count = 0;
int count = 0;
for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it)
{
df::unit *unit = *unit_it;
Expand Down