In all loops that iterate across a vector, use a size_t as the index

develop
Quietust 2012-01-31 10:55:38 -06:00
parent a82f4c9138
commit 9afcea3deb
34 changed files with 168 additions and 171 deletions

@ -101,7 +101,7 @@ void cheap_tokenise(string const& input, vector<string> &output)
{ {
string *cur = NULL; string *cur = NULL;
for (unsigned i = 0; i < input.size(); i++) { for (size_t i = 0; i < input.size(); i++) {
char c = input[i]; char c = input[i];
if (isspace(c)) { if (isspace(c)) {
cur = NULL; cur = NULL;
@ -223,7 +223,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
{ {
Plugin *plug = plug_mgr->getPluginByCommand(parts[0]); Plugin *plug = plug_mgr->getPluginByCommand(parts[0]);
if (plug) { if (plug) {
for (int j = 0; j < plug->size();j++) for (size_t j = 0; j < plug->size();j++)
{ {
const PluginCommand & pcmd = (plug->operator[](j)); const PluginCommand & pcmd = (plug->operator[](j));
if (pcmd.name != parts[0]) if (pcmd.name != parts[0])
@ -252,7 +252,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
string & plugname = parts[0]; string & plugname = parts[0];
if(plugname == "all") if(plugname == "all")
{ {
for(int i = 0; i < plug_mgr->size();i++) for(size_t i = 0; i < plug_mgr->size();i++)
{ {
Plugin * plug = (plug_mgr->operator[](i)); Plugin * plug = (plug_mgr->operator[](i));
plug->load(); plug->load();
@ -279,7 +279,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
string & plugname = parts[0]; string & plugname = parts[0];
if(plugname == "all") if(plugname == "all")
{ {
for(int i = 0; i < plug_mgr->size();i++) for(size_t i = 0; i < plug_mgr->size();i++)
{ {
Plugin * plug = (plug_mgr->operator[](i)); Plugin * plug = (plug_mgr->operator[](i));
plug->reload(); plug->reload();
@ -306,7 +306,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
string & plugname = parts[0]; string & plugname = parts[0];
if(plugname == "all") if(plugname == "all")
{ {
for(int i = 0; i < plug_mgr->size();i++) for(size_t i = 0; i < plug_mgr->size();i++)
{ {
Plugin * plug = (plug_mgr->operator[](i)); Plugin * plug = (plug_mgr->operator[](i));
plug->unload(); plug->unload();
@ -336,7 +336,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
{ {
con.printerr("There's no plugin called %s!\n",plugname.c_str()); con.printerr("There's no plugin called %s!\n",plugname.c_str());
} }
else for (int j = 0; j < plug->size();j++) else for (size_t j = 0; j < plug->size();j++)
{ {
const PluginCommand & pcmd = (plug->operator[](j)); const PluginCommand & pcmd = (plug->operator[](j));
if (pcmd.isHotkeyCommand()) if (pcmd.isHotkeyCommand())
@ -362,12 +362,12 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
"\n" "\n"
"plugins:\n" "plugins:\n"
); );
for(int i = 0; i < plug_mgr->size();i++) for(size_t i = 0; i < plug_mgr->size();i++)
{ {
const Plugin * plug = (plug_mgr->operator[](i)); const Plugin * plug = (plug_mgr->operator[](i));
if(!plug->size()) if(!plug->size())
continue; continue;
for (int j = 0; j < plug->size();j++) for (size_t j = 0; j < plug->size();j++)
{ {
const PluginCommand & pcmd = (plug->operator[](j)); const PluginCommand & pcmd = (plug->operator[](j));
if (pcmd.isHotkeyCommand()) if (pcmd.isHotkeyCommand())
@ -380,7 +380,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
} }
else if(first == "plug") else if(first == "plug")
{ {
for(int i = 0; i < plug_mgr->size();i++) for(size_t i = 0; i < plug_mgr->size();i++)
{ {
const Plugin * plug = (plug_mgr->operator[](i)); const Plugin * plug = (plug_mgr->operator[](i));
if(!plug->size()) if(!plug->size())
@ -405,7 +405,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
} }
else if (parts.size() >= 2 && parts[0] == "clear") else if (parts.size() >= 2 && parts[0] == "clear")
{ {
for (unsigned i = 1; i < parts.size(); i++) for (size_t i = 1; i < parts.size(); i++)
{ {
if (!core->ClearKeyBindings(parts[i])) { if (!core->ClearKeyBindings(parts[i])) {
con.printerr("Invalid key spec: %s\n", parts[i].c_str()); con.printerr("Invalid key spec: %s\n", parts[i].c_str());
@ -418,7 +418,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
std::vector<std::string> list = core->ListKeyBindings(parts[1]); std::vector<std::string> list = core->ListKeyBindings(parts[1]);
if (list.empty()) if (list.empty())
con << "No bindings." << endl; con << "No bindings." << endl;
for (unsigned i = 0; i < list.size(); i++) for (size_t i = 0; i < list.size(); i++)
con << " " << list[i] << endl; con << " " << list[i] << endl;
} }
else else
@ -819,7 +819,7 @@ int Core::Shutdown ( void )
plug_mgr = 0; plug_mgr = 0;
} }
// invalidate all modules // invalidate all modules
for(unsigned int i = 0 ; i < allModules.size(); i++) for(size_t i = 0 ; i < allModules.size(); i++)
{ {
delete allModules[i]; delete allModules[i];
} }

@ -125,7 +125,7 @@ Plugin::Plugin(Core * core, const std::string & filepath, const std::string & _f
filename = filepath; filename = filepath;
parent = pm; parent = pm;
name.reserve(_filename.size()); name.reserve(_filename.size());
for(int i = 0; i < _filename.size();i++) for(size_t i = 0; i < _filename.size();i++)
{ {
char ch = _filename[i]; char ch = _filename[i];
if(ch == '.') if(ch == '.')
@ -274,7 +274,7 @@ command_result Plugin::invoke( std::string & command, std::vector <std::string>
access->lock_add(); access->lock_add();
if(state == PS_LOADED) if(state == PS_LOADED)
{ {
for (int i = 0; i < commands.size();i++) for (size_t i = 0; i < commands.size();i++)
{ {
PluginCommand &cmd = commands[i]; PluginCommand &cmd = commands[i];
if(cmd.name == command) if(cmd.name == command)
@ -322,7 +322,7 @@ bool Plugin::can_invoke_hotkey( std::string & command, df::viewscreen *top )
access->lock_add(); access->lock_add();
if(state == PS_LOADED) if(state == PS_LOADED)
{ {
for (int i = 0; i < commands.size();i++) for (size_t i = 0; i < commands.size();i++)
{ {
PluginCommand &cmd = commands[i]; PluginCommand &cmd = commands[i];
if(cmd.name == command) if(cmd.name == command)
@ -384,7 +384,7 @@ PluginManager::PluginManager(Core * core)
cmdlist_mutex = new mutex(); cmdlist_mutex = new mutex();
vector <string> filez; vector <string> filez;
getdir(path, filez); getdir(path, filez);
for(int i = 0; i < filez.size();i++) for(size_t i = 0; i < filez.size();i++)
{ {
if(hasEnding(filez[i],searchstr)) if(hasEnding(filez[i],searchstr))
{ {
@ -398,7 +398,7 @@ PluginManager::PluginManager(Core * core)
PluginManager::~PluginManager() PluginManager::~PluginManager()
{ {
for(int i = 0; i < all_plugins.size();i++) for(size_t i = 0; i < all_plugins.size();i++)
{ {
delete all_plugins[i]; delete all_plugins[i];
} }
@ -408,7 +408,7 @@ PluginManager::~PluginManager()
Plugin *PluginManager::getPluginByName (const std::string & name) Plugin *PluginManager::getPluginByName (const std::string & name)
{ {
for(int i = 0; i < all_plugins.size(); i++) for(size_t i = 0; i < all_plugins.size(); i++)
{ {
if(name == all_plugins[i]->name) if(name == all_plugins[i]->name)
return all_plugins[i]; return all_plugins[i];
@ -441,7 +441,7 @@ bool PluginManager::CanInvokeHotkey(std::string &command, df::viewscreen *top)
void PluginManager::OnUpdate( void ) void PluginManager::OnUpdate( void )
{ {
for(int i = 0; i < all_plugins.size(); i++) for(size_t i = 0; i < all_plugins.size(); i++)
{ {
all_plugins[i]->on_update(); all_plugins[i]->on_update();
} }
@ -449,7 +449,7 @@ void PluginManager::OnUpdate( void )
void PluginManager::OnStateChange( state_change_event event ) void PluginManager::OnStateChange( state_change_event event )
{ {
for(int i = 0; i < all_plugins.size(); i++) for(size_t i = 0; i < all_plugins.size(); i++)
{ {
all_plugins[i]->on_state_change(event); all_plugins[i]->on_state_change(event);
} }
@ -460,7 +460,7 @@ void PluginManager::registerCommands( Plugin * p )
{ {
cmdlist_mutex->lock(); cmdlist_mutex->lock();
vector <PluginCommand> & cmds = p->commands; vector <PluginCommand> & cmds = p->commands;
for(int i = 0; i < cmds.size();i++) for(size_t i = 0; i < cmds.size();i++)
{ {
belongs[cmds[i].name] = p; belongs[cmds[i].name] = p;
} }
@ -472,7 +472,7 @@ void PluginManager::unregisterCommands( Plugin * p )
{ {
cmdlist_mutex->lock(); cmdlist_mutex->lock();
vector <PluginCommand> & cmds = p->commands; vector <PluginCommand> & cmds = p->commands;
for(int i = 0; i < cmds.size();i++) for(size_t i = 0; i < cmds.size();i++)
{ {
belongs.erase(cmds[i].name); belongs.erase(cmds[i].name);
} }

@ -83,7 +83,7 @@ namespace DFHack
vtable = old.vtable; vtable = old.vtable;
assign = old.assign; assign = old.assign;
type_offset = old.type_offset; type_offset = old.type_offset;
for(uint32_t i = 0; i < old.subs.size();i++) for(size_t i = 0; i < old.subs.size();i++)
{ {
t_type * t = new t_type (*old.subs[i]); t_type * t = new t_type (*old.subs[i]);
subs.push_back(t); subs.push_back(t);
@ -97,7 +97,7 @@ namespace DFHack
} }
~t_class() ~t_class()
{ {
for(uint32_t i = 0; i < subs.size();i++) for(size_t i = 0; i < subs.size();i++)
{ {
delete subs[i]; delete subs[i];
} }
@ -730,7 +730,7 @@ void VersionInfo::copy(const VersionInfo * old)
d->has_timestamp = old->d->has_timestamp; d->has_timestamp = old->d->has_timestamp;
d->base = old->d->base; d->base = old->d->base;
//d->classes = old.d->classes; //d->classes = old.d->classes;
for(uint32_t i = 0; i < old->d->classes.size(); i++) for(size_t i = 0; i < old->d->classes.size(); i++)
{ {
t_class * copy = new t_class(*old->d->classes[i]); t_class * copy = new t_class(*old->d->classes[i]);
d->classes.push_back(copy); d->classes.push_back(copy);
@ -757,7 +757,7 @@ void VersionInfo::setParentProcess(Process * _p)
VersionInfo::~VersionInfo() VersionInfo::~VersionInfo()
{ {
// delete the vtables // delete the vtables
for(uint32_t i = 0; i < d->classes.size();i++) for(size_t i = 0; i < d->classes.size();i++)
{ {
delete d->classes[i]; delete d->classes[i];
} }
@ -966,7 +966,7 @@ t_class * VersionInfo::setClass (const char * name, uint32_t vtable, uint32_t ty
{ {
if(name == 0) if(name == 0)
return 0; return 0;
for (uint32_t i=0; i<d->classes.size(); i++) for (size_t i=0; i<d->classes.size(); i++)
{ {
if(d->classes[i]->classname == name) if(d->classes[i]->classname == name)
{ {
@ -1000,7 +1000,7 @@ t_class * VersionInfo::setClass (const char * name, uint32_t vtable, uint32_t ty
void VersionInfo::setClassChild (t_class * parent, const char * name, const char * type) void VersionInfo::setClassChild (t_class * parent, const char * name, const char * type)
{ {
vector <t_type *>& vec = parent->subs; vector <t_type *>& vec = parent->subs;
for (uint32_t i=0; i<vec.size(); i++) for (size_t i=0; i<vec.size(); i++)
{ {
if(vec[i]->classname == name) if(vec[i]->classname == name)
{ {
@ -1054,7 +1054,7 @@ bool VersionInfo::resolveObjectToClassID(const char * address, int32_t & classid
uint32_t type = d->p->readWord(address + cl->type_offset); uint32_t type = d->p->readWord(address + cl->type_offset);
// return typed building if successful // return typed building if successful
//FIXME: the vector should map directly to the type IDs here, so we don't have to mess with O(n) search //FIXME: the vector should map directly to the type IDs here, so we don't have to mess with O(n) search
for (uint32_t k = 0; k < vec.size();k++) for (size_t k = 0; k < vec.size();k++)
{ {
if(vec[k]->type == type) if(vec[k]->type == type)
{ {
@ -1076,7 +1076,7 @@ bool VersionInfo::resolveObjectToClassID(const char * address, int32_t & classid
bool VersionInfo::resolveClassnameToVPtr(const string classname, void * & vptr) bool VersionInfo::resolveClassnameToVPtr(const string classname, void * & vptr)
{ {
// FIXME: another stupid search. // FIXME: another stupid search.
for(uint32_t i = 0;i< d->classes.size();i++) for(size_t i = 0;i< d->classes.size();i++)
{ {
//if(classes[i].) //if(classes[i].)
if(d->classes[i]->classname == classname) // got class if(d->classes[i]->classname == classname) // got class
@ -1094,7 +1094,7 @@ bool VersionInfo::resolveClassnameToClassID (const string classname, int32_t & c
{ {
// FIXME: another stupid search. // FIXME: another stupid search.
classID = -1; classID = -1;
for(uint32_t i = 0;i< d->classnames.size();i++) for(size_t i = 0;i< d->classnames.size();i++)
{ {
if(d->classnames[i] == classname) if(d->classnames[i] == classname)
{ {

@ -109,7 +109,7 @@ VersionInfoFactory::~VersionInfoFactory()
void VersionInfoFactory::clear(void) void VersionInfoFactory::clear(void)
{ {
// for each stored version, delete // for each stored version, delete
for(uint32_t i = 0; i < versions.size();i++) for(size_t i = 0; i < versions.size();i++)
{ {
delete versions[i]; delete versions[i];
} }
@ -121,7 +121,7 @@ void VersionInfoFactory::clear(void)
VersionInfo * VersionInfoFactory::getVersionInfoByMD5(string hash) VersionInfo * VersionInfoFactory::getVersionInfoByMD5(string hash)
{ {
VersionInfo * vinfo; VersionInfo * vinfo;
for(uint32_t i = 0; i < versions.size();i++) for(size_t i = 0; i < versions.size();i++)
{ {
vinfo = versions[i]; vinfo = versions[i];
string test_hash; string test_hash;
@ -137,7 +137,7 @@ VersionInfo * VersionInfoFactory::getVersionInfoByPETimestamp(uint32_t timestamp
{ {
VersionInfo * vinfo; VersionInfo * vinfo;
//cout << "lookup size:" << versions.size() << endl; //cout << "lookup size:" << versions.size() << endl;
for(uint32_t i = 0; i < versions.size();i++) for(size_t i = 0; i < versions.size();i++)
{ {
vinfo = versions[i]; vinfo = versions[i];
uint32_t test_PE; uint32_t test_PE;
@ -724,7 +724,7 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
// transform elements // transform elements
{ {
// trash existing list // trash existing list
for(uint32_t i = 0; i < versions.size(); i++) for(size_t i = 0; i < versions.size(); i++)
{ {
delete versions[i]; delete versions[i];
} }
@ -759,7 +759,7 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
} }
} }
// Parse the versions // Parse the versions
for(uint32_t i = 0; i< v_sEntries.size();i++) for(size_t i = 0; i< v_sEntries.size();i++)
{ {
//FIXME: add a set of entries processed in a step of this cycle, use it to check for infinite loops //FIXME: add a set of entries processed in a step of this cycle, use it to check for infinite loops
string & name = v_sEntries[i]; string & name = v_sEntries[i];

@ -188,7 +188,7 @@ bool ItemTypeInfo::find(const std::string &token)
switch (type) { switch (type) {
#define ITEM(type,vec,tclass) \ #define ITEM(type,vec,tclass) \
case type: \ case type: \
for (int i = 0; i < defs.vec.size(); i++) { \ for (size_t i = 0; i < defs.vec.size(); i++) { \
if (defs.vec[i]->id == items[1]) { \ if (defs.vec[i]->id == items[1]) { \
subtype = i; custom = defs.vec[i]; return true; \ subtype = i; custom = defs.vec[i]; return true; \
} \ } \
@ -427,7 +427,7 @@ bool Items::copyItem(df::item * itembase, DFHack::dfh_item &item)
int32_t Items::getItemOwnerID(const df::item * item) int32_t Items::getItemOwnerID(const df::item * item)
{ {
for (uint32_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::UNIT_ITEMOWNER) if (ref->getType() == general_ref_type::UNIT_ITEMOWNER)
@ -438,7 +438,7 @@ int32_t Items::getItemOwnerID(const df::item * item)
df::unit *Items::getItemOwner(const df::item * item) df::unit *Items::getItemOwner(const df::item * item)
{ {
for (uint32_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::UNIT_ITEMOWNER) if (ref->getType() == general_ref_type::UNIT_ITEMOWNER)
@ -449,7 +449,7 @@ df::unit *Items::getItemOwner(const df::item * item)
int32_t Items::getItemContainerID(const df::item * item) int32_t Items::getItemContainerID(const df::item * item)
{ {
for (uint32_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::CONTAINED_IN_ITEM) if (ref->getType() == general_ref_type::CONTAINED_IN_ITEM)
@ -460,7 +460,7 @@ int32_t Items::getItemContainerID(const df::item * item)
df::item *Items::getItemContainer(const df::item * item) df::item *Items::getItemContainer(const df::item * item)
{ {
for (uint32_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::CONTAINED_IN_ITEM) if (ref->getType() == general_ref_type::CONTAINED_IN_ITEM)
@ -478,7 +478,7 @@ bool Items::readItemRefs(const df::item * item, df::general_ref_type type, std::
{ {
values.clear(); values.clear();
for (uint32_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == type) if (ref->getType() == type)
@ -490,7 +490,7 @@ bool Items::readItemRefs(const df::item * item, df::general_ref_type type, std::
bool Items::removeItemOwner(df::item * item) bool Items::removeItemOwner(df::item * item)
{ {
for (uint32_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() != general_ref_type::UNIT_ITEMOWNER) if (ref->getType() != general_ref_type::UNIT_ITEMOWNER)

@ -210,13 +210,13 @@ void DFHack::printJobDetails(Core *c, df::job *job)
if (!job->reaction_name.empty()) if (!job->reaction_name.empty())
c->con << " reaction: " << job->reaction_name << endl; c->con << " reaction: " << job->reaction_name << endl;
for (unsigned i = 0; i < job->job_items.size(); i++) for (size_t i = 0; i < job->job_items.size(); i++)
print_job_item_details(c, job, i, job->job_items[i]); print_job_item_details(c, job, i, job->job_items[i]);
} }
df::building *DFHack::getJobHolder(df::job *job) df::building *DFHack::getJobHolder(df::job *job)
{ {
for (unsigned i = 0; i < job->references.size(); i++) for (size_t i = 0; i < job->references.size(); i++)
{ {
VIRTUAL_CAST_VAR(ref, df::general_ref_building_holderst, job->references[i]); VIRTUAL_CAST_VAR(ref, df::general_ref_building_holderst, job->references[i]);
if (ref) if (ref)

@ -494,9 +494,8 @@ bool Maps::SortBlockEvents(uint32_t x, uint32_t y, uint32_t z,
if (!block) if (!block)
return false; return false;
uint32_t size = block->block_events.size();
// read all events // read all events
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < block->block_events.size(); i++)
{ {
df::block_square_event *evt = block->block_events[i]; df::block_square_event *evt = block->block_events[i];
switch (evt->getType()) switch (evt->getType())
@ -531,7 +530,7 @@ bool Maps::RemoveBlockEvent(uint32_t x, uint32_t y, uint32_t z, df::block_square
df::map_block * block = getBlock(x,y,z); df::map_block * block = getBlock(x,y,z);
if (!block) if (!block)
return false; return false;
for (uint32_t i = 0; i < block->block_events.size(); i++) for (size_t i = 0; i < block->block_events.size(); i++)
{ {
if (block->block_events[i] == which) if (block->block_events[i] == which)
{ {
@ -581,7 +580,7 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
v_geology[i].reserve(geolayers.size()); v_geology[i].reserve(geolayers.size());
// finally, read the layer matgloss // finally, read the layer matgloss
for (uint32_t j = 0; j < geolayers.size(); j++) for (size_t j = 0; j < geolayers.size(); j++)
v_geology[i].push_back(geolayers[j]->mat_index); v_geology[i].push_back(geolayers[j]->mat_index);
} }

@ -220,7 +220,7 @@ bool MaterialInfo::findInorganic(const std::string &token)
} }
df::world_raws &raws = world->raws; df::world_raws &raws = world->raws;
for (unsigned i = 0; i < raws.inorganics.size(); i++) for (size_t i = 0; i < raws.inorganics.size(); i++)
{ {
df::inorganic_raw *p = raws.inorganics[i]; df::inorganic_raw *p = raws.inorganics[i];
if (p->id == token) if (p->id == token)
@ -234,7 +234,7 @@ bool MaterialInfo::findPlant(const std::string &token, const std::string &subtok
if (token.empty()) if (token.empty())
return decode(-1); return decode(-1);
df::world_raws &raws = world->raws; df::world_raws &raws = world->raws;
for (unsigned i = 0; i < raws.plants.all.size(); i++) for (size_t i = 0; i < raws.plants.all.size(); i++)
{ {
df::plant_raw *p = raws.plants.all[i]; df::plant_raw *p = raws.plants.all[i];
if (p->id != token) if (p->id != token)
@ -244,7 +244,7 @@ bool MaterialInfo::findPlant(const std::string &token, const std::string &subtok
if (subtoken.empty()) if (subtoken.empty())
return decode(p->material_defs.type_basic_mat, p->material_defs.idx_basic_mat); return decode(p->material_defs.type_basic_mat, p->material_defs.idx_basic_mat);
for (unsigned j = 0; j < p->material.size(); j++) for (size_t j = 0; j < p->material.size(); j++)
if (p->material[j]->id == subtoken) if (p->material[j]->id == subtoken)
return decode(PLANT_BASE+j, i); return decode(PLANT_BASE+j, i);
@ -258,13 +258,13 @@ bool MaterialInfo::findCreature(const std::string &token, const std::string &sub
if (token.empty() || subtoken.empty()) if (token.empty() || subtoken.empty())
return decode(-1); return decode(-1);
df::world_raws &raws = world->raws; df::world_raws &raws = world->raws;
for (unsigned i = 0; i < raws.creatures.all.size(); i++) for (size_t i = 0; i < raws.creatures.all.size(); i++)
{ {
df::creature_raw *p = raws.creatures.all[i]; df::creature_raw *p = raws.creatures.all[i];
if (p->creature_id != token) if (p->creature_id != token)
continue; continue;
for (unsigned j = 0; j < p->material.size(); j++) for (size_t j = 0; j < p->material.size(); j++)
if (p->material[j]->id == subtoken) if (p->material[j]->id == subtoken)
return decode(CREATURE_BASE+j, i); return decode(CREATURE_BASE+j, i);
@ -503,7 +503,7 @@ bool DFHack::parseJobMaterialCategory(df::job_material_category *cat, const std:
std::vector<std::string> items; std::vector<std::string> items;
split_string(&items, toLower(token), ",", true); split_string(&items, toLower(token), ",", true);
for (unsigned i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
{ {
int id = findBitfieldField(*cat, items[i]); int id = findBitfieldField(*cat, items[i]);
if (id < 0) if (id < 0)
@ -522,7 +522,7 @@ bool DFHack::parseJobMaterialCategory(df::dfhack_material_category *cat, const s
std::vector<std::string> items; std::vector<std::string> items;
split_string(&items, toLower(token), ",", true); split_string(&items, toLower(token), ",", true);
for (unsigned i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
{ {
int id = findBitfieldField(*cat, items[i]); int id = findBitfieldField(*cat, items[i]);
if (id < 0) if (id < 0)
@ -597,10 +597,10 @@ bool t_matglossInorganic::isGem()
bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorganic) bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorganic)
{ {
Process * p = d->owner; Process * p = d->owner;
uint32_t size = world->raws.inorganics.size(); size_t size = world->raws.inorganics.size();
inorganic.clear(); inorganic.clear();
inorganic.reserve (size); inorganic.reserve (size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
df::inorganic_raw *orig = world->raws.inorganics[i]; df::inorganic_raw *orig = world->raws.inorganics[i];
t_matglossInorganic mat; t_matglossInorganic mat;
@ -624,10 +624,10 @@ bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorg
bool Materials::CopyOrganicMaterials (std::vector<t_matgloss> & organic) bool Materials::CopyOrganicMaterials (std::vector<t_matgloss> & organic)
{ {
uint32_t size = world->raws.plants.all.size(); size_t size = world->raws.plants.all.size();
organic.clear(); organic.clear();
organic.reserve (size); organic.reserve (size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
t_matgloss mat; t_matgloss mat;
mat.id = world->raws.plants.all[i]->id; mat.id = world->raws.plants.all[i]->id;
@ -638,10 +638,10 @@ bool Materials::CopyOrganicMaterials (std::vector<t_matgloss> & organic)
bool Materials::CopyWoodMaterials (std::vector<t_matgloss> & tree) bool Materials::CopyWoodMaterials (std::vector<t_matgloss> & tree)
{ {
uint32_t size = world->raws.plants.trees.size(); size_t size = world->raws.plants.trees.size();
tree.clear(); tree.clear();
tree.reserve (size); tree.reserve (size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
t_matgloss mat; t_matgloss mat;
mat.id = world->raws.plants.trees[i]->id; mat.id = world->raws.plants.trees[i]->id;
@ -652,10 +652,10 @@ bool Materials::CopyWoodMaterials (std::vector<t_matgloss> & tree)
bool Materials::CopyPlantMaterials (std::vector<t_matgloss> & plant) bool Materials::CopyPlantMaterials (std::vector<t_matgloss> & plant)
{ {
uint32_t size = world->raws.plants.bushes.size(); size_t size = world->raws.plants.bushes.size();
plant.clear(); plant.clear();
plant.reserve (size); plant.reserve (size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
t_matgloss mat; t_matgloss mat;
mat.id = world->raws.plants.bushes[i]->id; mat.id = world->raws.plants.bushes[i]->id;
@ -666,10 +666,10 @@ bool Materials::CopyPlantMaterials (std::vector<t_matgloss> & plant)
bool Materials::ReadCreatureTypes (void) bool Materials::ReadCreatureTypes (void)
{ {
uint32_t size = world->raws.creatures.all.size(); size_t size = world->raws.creatures.all.size();
race.clear(); race.clear();
race.reserve (size); race.reserve (size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
t_matgloss mat; t_matgloss mat;
mat.id = world->raws.creatures.all[i]->creature_id; mat.id = world->raws.creatures.all[i]->creature_id;
@ -692,13 +692,13 @@ bool Materials::ReadOthers(void)
bool Materials::ReadDescriptorColors (void) bool Materials::ReadDescriptorColors (void)
{ {
uint32_t size = world->raws.language.colors.size(); size_t size = world->raws.language.colors.size();
color.clear(); color.clear();
if(size == 0) if(size == 0)
return false; return false;
color.reserve(size); color.reserve(size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
df::descriptor_color *c = world->raws.language.colors[i]; df::descriptor_color *c = world->raws.language.colors[i];
t_descriptor_color col; t_descriptor_color col;
@ -713,7 +713,7 @@ bool Materials::ReadDescriptorColors (void)
size = world->raws.language.patterns.size(); size = world->raws.language.patterns.size();
alldesc.clear(); alldesc.clear();
alldesc.reserve(size); alldesc.reserve(size);
for (uint32_t i = 0; i < size;i++) for (size_t i = 0; i < size;i++)
{ {
t_matgloss mat; t_matgloss mat;
mat.id = world->raws.language.patterns[i]->id; mat.id = world->raws.language.patterns[i]->id;
@ -724,10 +724,10 @@ bool Materials::ReadDescriptorColors (void)
bool Materials::ReadCreatureTypesEx (void) bool Materials::ReadCreatureTypesEx (void)
{ {
uint32_t size = world->raws.creatures.all.size(); size_t size = world->raws.creatures.all.size();
raceEx.clear(); raceEx.clear();
raceEx.reserve (size); raceEx.reserve (size);
for (uint32_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
df::creature_raw *cr = world->raws.creatures.all[i]; df::creature_raw *cr = world->raws.creatures.all[i];
t_creaturetype mat; t_creaturetype mat;
@ -737,8 +737,8 @@ bool Materials::ReadCreatureTypesEx (void)
mat.tilecolor.back = cr->color[1]; mat.tilecolor.back = cr->color[1];
mat.tilecolor.bright = cr->color[2]; mat.tilecolor.bright = cr->color[2];
uint32_t sizecas = cr->caste.size(); size_t sizecas = cr->caste.size();
for (uint32_t j = 0; j < sizecas;j++) for (size_t j = 0; j < sizecas;j++)
{ {
df::caste_raw *ca = cr->caste[j]; df::caste_raw *ca = cr->caste[j];
/* caste name */ /* caste name */
@ -751,15 +751,15 @@ bool Materials::ReadCreatureTypesEx (void)
// color mod reading // color mod reading
// Caste + offset > color mod vector // Caste + offset > color mod vector
auto & colorings = ca->color_modifiers; auto & colorings = ca->color_modifiers;
uint32_t sizecolormod = colorings.size(); size_t sizecolormod = colorings.size();
caste.ColorModifier.resize(sizecolormod); caste.ColorModifier.resize(sizecolormod);
for(uint32_t k = 0; k < sizecolormod;k++) for(size_t k = 0; k < sizecolormod;k++)
{ {
// color mod [0] -> color list // color mod [0] -> color list
auto & indexes = colorings[k]->color_indexes; auto & indexes = colorings[k]->color_indexes;
uint32_t sizecolorlist = indexes.size(); size_t sizecolorlist = indexes.size();
caste.ColorModifier[k].colorlist.resize(sizecolorlist); caste.ColorModifier[k].colorlist.resize(sizecolorlist);
for(uint32_t l = 0; l < sizecolorlist; l++) for(size_t l = 0; l < sizecolorlist; l++)
caste.ColorModifier[k].colorlist[l] = indexes[l]; caste.ColorModifier[k].colorlist[l] = indexes[l];
// color mod [color_modifier_part_offset] = string part // color mod [color_modifier_part_offset] = string part
caste.ColorModifier[k].part = colorings[k]->part; caste.ColorModifier[k].part = colorings[k]->part;
@ -769,8 +769,8 @@ bool Materials::ReadCreatureTypesEx (void)
// body parts // body parts
caste.bodypart.empty(); caste.bodypart.empty();
uint32_t sizebp = ca->body_info.body_parts.size(); size_t sizebp = ca->body_info.body_parts.size();
for (uint32_t k = 0; k < sizebp; k++) for (size_t k = 0; k < sizebp; k++)
{ {
df::body_part_raw *bp = ca->body_info.body_parts[k]; df::body_part_raw *bp = ca->body_info.body_parts[k];
t_bodypart part; t_bodypart part;
@ -804,7 +804,7 @@ bool Materials::ReadCreatureTypesEx (void)
} }
mat.castes.push_back(caste); mat.castes.push_back(caste);
} }
for (uint32_t j = 0; j < world->raws.creatures.all[i]->material.size(); j++) for (size_t j = 0; j < world->raws.creatures.all[i]->material.size(); j++)
{ {
t_creatureextract extract; t_creatureextract extract;
extract.id = world->raws.creatures.all[i]->material[j]->id; extract.id = world->raws.creatures.all[i]->material[j]->id;

@ -82,8 +82,8 @@ int32_t Units::GetCreatureInBox (int32_t index, df::unit ** furball,
if (!isValid()) if (!isValid())
return -1; return -1;
uint32_t size = world->units.all.size(); size_t size = world->units.all.size();
while (uint32_t(index) < size) while (size_t(index) < size)
{ {
// read pointer from vector at position // read pointer from vector at position
df::unit * temp = world->units.all[index]; df::unit * temp = world->units.all[index];
@ -482,7 +482,7 @@ bool Units::ReadInventoryByPtr(const df::unit * unit, std::vector<df::item *> &
if(!isValid()) return false; if(!isValid()) return false;
if(!unit) return false; if(!unit) return false;
items.clear(); items.clear();
for (uint32_t i = 0; i < unit->inventory.size(); i++) for (size_t i = 0; i < unit->inventory.size(); i++)
items.push_back(unit->inventory[i]->item); items.push_back(unit->inventory[i]->item);
return true; return true;
} }

@ -248,7 +248,7 @@ PersistentDataItem World::AddPersistentData(const std::string &key)
PersistentDataItem World::GetPersistentData(const std::string &key) PersistentDataItem World::GetPersistentData(const std::string &key)
{ {
std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector(); std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();
for (unsigned i = 0; i < hfvec.size(); i++) for (size_t i = 0; i < hfvec.size(); i++)
{ {
df::historical_figure *hfig = hfvec[i]; df::historical_figure *hfig = hfvec[i];
@ -265,7 +265,7 @@ PersistentDataItem World::GetPersistentData(const std::string &key)
void World::GetPersistentData(std::vector<PersistentDataItem> *vec, const std::string &key) void World::GetPersistentData(std::vector<PersistentDataItem> *vec, const std::string &key)
{ {
std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector(); std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();
for (unsigned i = 0; i < hfvec.size(); i++) for (size_t i = 0; i < hfvec.size(); i++)
{ {
df::historical_figure *hfig = hfvec[i]; df::historical_figure *hfig = hfvec[i];

@ -41,7 +41,7 @@ DFhackCExport const char * plugin_name ( void )
return "autodump"; return "autodump";
} }
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
@ -78,7 +78,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
typedef std::map <DFCoord, uint32_t> coordmap; typedef map <DFCoord, uint32_t> coordmap;
static command_result autodump_main(Core * c, vector <string> & parameters) static command_result autodump_main(Core * c, vector <string> & parameters)
{ {
@ -88,7 +88,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
bool need_visible = false; bool need_visible = false;
bool need_hidden = false; bool need_hidden = false;
bool need_forbidden = false; bool need_forbidden = false;
for (unsigned i = 0; i < parameters.size(); i++) for (size_t i = 0; i < parameters.size(); i++)
{ {
string & p = parameters[i]; string & p = parameters[i];
if(p == "destroy") if(p == "destroy")
@ -118,7 +118,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
c->con.printerr("Map is not available!\n"); c->con.printerr("Map is not available!\n");
return CR_FAILURE; return CR_FAILURE;
} }
std::size_t numItems = world->items.all.size(); size_t numItems = world->items.all.size();
MapCache MC; MapCache MC;
int i = 0; int i = 0;
@ -154,7 +154,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
} }
coordmap counts; coordmap counts;
// proceed with the dumpification operation // proceed with the dumpification operation
for(std::size_t i=0; i< numItems; i++) for(size_t i=0; i< numItems; i++)
{ {
df::item * itm = world->items.all[i]; df::item * itm = world->items.all[i];
DFCoord pos_item(itm->pos.x, itm->pos.y, itm->pos.z); DFCoord pos_item(itm->pos.x, itm->pos.y, itm->pos.z);
@ -163,7 +163,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
coordmap::iterator it = counts.find(pos_item); coordmap::iterator it = counts.find(pos_item);
if(it == counts.end()) if(it == counts.end())
{ {
std::pair< coordmap::iterator, bool > inserted = counts.insert(std::make_pair(pos_item,1)); pair< coordmap::iterator, bool > inserted = counts.insert(make_pair(pos_item,1));
it = inserted.first; it = inserted.first;
} }
else else
@ -211,7 +211,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
df::map_block * bl_tgt = Maps::getBlockAbs(cx, cy, cz); df::map_block * bl_tgt = Maps::getBlockAbs(cx, cy, cz);
if(bl_src) if(bl_src)
{ {
std::remove(bl_src->items.begin(), bl_src->items.end(),itm->id); remove(bl_src->items.begin(), bl_src->items.end(),itm->id);
} }
else else
{ {
@ -302,7 +302,7 @@ DFhackCExport command_result df_autodump_destroy_here(Core * c, vector <string>
return autodump_main(c, args); return autodump_main(c, args);
} }
static std::map<int, df::item_flags> pending_destroy; static map<int, df::item_flags> pending_destroy;
static int last_frame = 0; static int last_frame = 0;
DFhackCExport command_result df_autodump_destroy_item(Core * c, vector <string> & parameters) DFhackCExport command_result df_autodump_destroy_item(Core * c, vector <string> & parameters)
@ -349,7 +349,7 @@ DFhackCExport command_result df_autodump_destroy_item(Core * c, vector <string>
return CR_FAILURE; return CR_FAILURE;
} }
for (unsigned i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::UNIT_HOLDER) if (ref->getType() == general_ref_type::UNIT_HOLDER)

@ -38,7 +38,7 @@ command_result cleanmap (Core * c, bool snow, bool mud)
block->occupancy[x][y].bits.arrow_variant = 0; block->occupancy[x][y].bits.arrow_variant = 0;
} }
} }
for (int j = 0; j < block->block_events.size(); j++) for (size_t j = 0; j < block->block_events.size(); j++)
{ {
df::block_square_event *evt = block->block_events[j]; df::block_square_event *evt = block->block_events[j];
if (evt->getType() != block_square_event_type::material_spatter) if (evt->getType() != block_square_event_type::material_spatter)
@ -74,13 +74,13 @@ command_result cleanitems (Core * c)
{ {
// Invoked from clean(), already suspended // Invoked from clean(), already suspended
int cleaned_items = 0, cleaned_total = 0; int cleaned_items = 0, cleaned_total = 0;
for (int i = 0; i < world->items.all.size(); i++) for (size_t i = 0; i < world->items.all.size(); i++)
{ {
// currently, all item classes extend item_actual, so this should be safe // currently, all item classes extend item_actual, so this should be safe
df::item_actual *item = (df::item_actual *)world->items.all[i]; df::item_actual *item = (df::item_actual *)world->items.all[i];
if (item->contaminants && item->contaminants->size()) if (item->contaminants && item->contaminants->size())
{ {
for (int j = 0; j < item->contaminants->size(); j++) for (size_t j = 0; j < item->contaminants->size(); j++)
delete item->contaminants->at(j); delete item->contaminants->at(j);
cleaned_items++; cleaned_items++;
cleaned_total += item->contaminants->size(); cleaned_total += item->contaminants->size();
@ -95,14 +95,13 @@ command_result cleanitems (Core * c)
command_result cleanunits (Core * c) command_result cleanunits (Core * c)
{ {
// Invoked from clean(), already suspended // Invoked from clean(), already suspended
int num_units = world->units.all.size();
int cleaned_units = 0, cleaned_total = 0; int cleaned_units = 0, cleaned_total = 0;
for (int i = 0; i < num_units; i++) for (size_t i = 0; i < world->units.all.size(); i++)
{ {
df::unit *unit = world->units.all[i]; df::unit *unit = world->units.all[i];
if (unit->body.spatters.size()) if (unit->body.spatters.size())
{ {
for (int j = 0; j < unit->body.spatters.size(); j++) for (size_t j = 0; j < unit->body.spatters.size(); j++)
delete unit->body.spatters[j]; delete unit->body.spatters[j];
cleaned_units++; cleaned_units++;
cleaned_total += unit->body.spatters.size(); cleaned_total += unit->body.spatters.size();
@ -134,7 +133,7 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
for (int i = 0; i < block->block_events.size(); i++) for (size_t i = 0; i < block->block_events.size(); i++)
{ {
df::block_square_event *evt = block->block_events[i]; df::block_square_event *evt = block->block_events[i];
if (evt->getType() != block_square_event_type::material_spatter) if (evt->getType() != block_square_event_type::material_spatter)
@ -153,7 +152,7 @@ DFhackCExport command_result clean (Core * c, vector <string> & parameters)
bool mud = false; bool mud = false;
bool units = false; bool units = false;
bool items = false; bool items = false;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "map") if(parameters[i] == "map")
map = true; map = true;

@ -47,7 +47,7 @@ DFhackCExport command_result colonies (Core * c, vector <string> & parameters)
bool destroy = false; bool destroy = false;
bool convert = false; bool convert = false;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "kill") if(parameters[i] == "kill")
destroy = true; destroy = true;

@ -25,7 +25,7 @@ DFhackCExport command_result df_drybuckets (Core * c, vector <string> & paramete
CoreSuspender suspend(c); CoreSuspender suspend(c);
int dried_total = 0; int dried_total = 0;
for (int i = 0; i < world->items.all.size(); i++) for (size_t i = 0; i < world->items.all.size(); i++)
{ {
df::item *item = world->items.all[i]; df::item *item = world->items.all[i];
if ((item->getType() == item_type::LIQUID_MISC) && (item->getMaterial() == builtin_mats::WATER)) if ((item->getType() == item_type::LIQUID_MISC) && (item->getMaterial() == builtin_mats::WATER))

@ -35,7 +35,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
int32_t race = ui->race_id; int32_t race = ui->race_id;
int32_t civ = ui->civ_id; int32_t civ = ui->civ_id;
for (int i = 0; i < world->units.all.size(); i++) for (size_t i = 0; i < world->units.all.size(); i++)
{ {
df::unit *unit = world->units.all[i]; df::unit *unit = world->units.all[i];

@ -93,7 +93,7 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
bool checkbuilding = true; bool checkbuilding = true;
//Loop through parameters //Loop through parameters
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if (params[i] == "help" || params[i] == "?" || params[i].size() != 1) if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
@ -246,7 +246,7 @@ DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::strin
void (*proc)(DFHack::DFCoord, MapExtras::MapCache &) = allNormal; void (*proc)(DFHack::DFCoord, MapExtras::MapCache &) = allNormal;
//Loop through parameters //Loop through parameters
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if (params[i] == "help" || params[i] == "?" || params[i].size() != 1) if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;

@ -56,7 +56,7 @@ DFhackCExport command_result df_fixveins (Core * c, vector <string> & parameters
{ {
df::map_block *block = world->map.map_blocks[i]; df::map_block *block = world->map.map_blocks[i];
uint16_t has_mineral[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint16_t has_mineral[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for (int j = 0; j < block->block_events.size(); j++) for (size_t j = 0; j < block->block_events.size(); j++)
{ {
df::block_square_event *evt = block->block_events[j]; df::block_square_event *evt = block->block_events[j];
if (evt->getType() != block_square_event_type::mineral) if (evt->getType() != block_square_event_type::mineral)

@ -27,7 +27,7 @@ command_result df_fixwagons (Core *c, vector<string> &parameters)
CoreSuspender suspend(c); CoreSuspender suspend(c);
int32_t wagon_creature = -1, wagon_puller_creature = -1; int32_t wagon_creature = -1, wagon_puller_creature = -1;
df::creature_raw *wagon, *wagon_puller; df::creature_raw *wagon, *wagon_puller;
for (int i = 0; i < world->raws.creatures.all.size(); i++) for (size_t i = 0; i < world->raws.creatures.all.size(); i++)
{ {
df::creature_raw *cr = world->raws.creatures.all[i]; df::creature_raw *cr = world->raws.creatures.all[i];
if (cr->flags.is_set(creature_raw_flags::EQUIPMENT_WAGON) && (wagon_creature == -1)) if (cr->flags.is_set(creature_raw_flags::EQUIPMENT_WAGON) && (wagon_creature == -1))
@ -52,7 +52,7 @@ command_result df_fixwagons (Core *c, vector<string> &parameters)
return CR_FAILURE; return CR_FAILURE;
} }
int count = 0; int count = 0;
for (int i = 0; i < world->entities.all.size(); i++) for (size_t i = 0; i < world->entities.all.size(); i++)
{ {
bool updated = false; bool updated = false;
df::historical_entity *ent = world->entities.all[i]; df::historical_entity *ent = world->entities.all[i];
@ -61,7 +61,7 @@ command_result df_fixwagons (Core *c, vector<string> &parameters)
if (ent->resources.animals.wagon_races.size() == 0) if (ent->resources.animals.wagon_races.size() == 0)
{ {
updated = true; updated = true;
for (int j = 0; j < wagon->caste.size(); j++) for (size_t j = 0; j < wagon->caste.size(); j++)
{ {
ent->resources.animals.wagon_races.push_back(wagon_creature); ent->resources.animals.wagon_races.push_back(wagon_creature);
ent->resources.animals.wagon_castes.push_back(j); ent->resources.animals.wagon_castes.push_back(j);
@ -70,7 +70,7 @@ command_result df_fixwagons (Core *c, vector<string> &parameters)
if (ent->resources.animals.wagon_puller_races.size() == 0) if (ent->resources.animals.wagon_puller_races.size() == 0)
{ {
updated = true; updated = true;
for (int j = 0; j < wagon_puller->caste.size(); j++) for (size_t j = 0; j < wagon_puller->caste.size(); j++)
{ {
ent->resources.animals.wagon_puller_races.push_back(wagon_puller_creature); ent->resources.animals.wagon_puller_races.push_back(wagon_puller_creature);
ent->resources.animals.wagon_puller_castes.push_back(j); ent->resources.animals.wagon_puller_castes.push_back(j);

@ -24,7 +24,7 @@ DFhackCExport command_result df_flows (Core * c, vector <string> & parameters)
int flow1 = 0, flow2 = 0, flowboth = 0, water = 0, magma = 0; int flow1 = 0, flow2 = 0, flowboth = 0, water = 0, magma = 0;
c->con.print("Counting flows and liquids ...\n"); c->con.print("Counting flows and liquids ...\n");
for (int i = 0; i < world->map.map_blocks.size(); i++) for (size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block *cur = world->map.map_blocks[i]; df::map_block *cur = world->map.map_blocks[i];
if (cur->flags.is_set(block_flags::UpdateLiquid)) if (cur->flags.is_set(block_flags::UpdateLiquid))

@ -54,7 +54,7 @@ DFhackCExport command_result df_getplants (Core * c, vector <string> & parameter
CoreSuspender suspend(c); CoreSuspender suspend(c);
for (int i = 0; i < world->raws.plants.all.size(); i++) for (size_t i = 0; i < world->raws.plants.all.size(); i++)
{ {
df::plant_raw *plant = world->raws.plants.all[i]; df::plant_raw *plant = world->raws.plants.all[i];
if (plantNames.find(plant->id) != plantNames.end()) if (plantNames.find(plant->id) != plantNames.end())
@ -75,7 +75,7 @@ DFhackCExport command_result df_getplants (Core * c, vector <string> & parameter
if (plantIDs.size() == 0) if (plantIDs.size() == 0)
{ {
c->con.print("Valid plant IDs:\n"); c->con.print("Valid plant IDs:\n");
for (int i = 0; i < world->raws.plants.all.size(); i++) for (size_t i = 0; i < world->raws.plants.all.size(); i++)
{ {
df::plant_raw *plant = world->raws.plants.all[i]; df::plant_raw *plant = world->raws.plants.all[i];
if (plant->flags.is_set(plant_raw_flags::GRASS)) if (plant->flags.is_set(plant_raw_flags::GRASS))
@ -86,11 +86,11 @@ DFhackCExport command_result df_getplants (Core * c, vector <string> & parameter
} }
count = 0; count = 0;
for (int i = 0; i < world->map.map_blocks.size(); i++) for (size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block *cur = world->map.map_blocks[i]; df::map_block *cur = world->map.map_blocks[i];
bool dirty = false; bool dirty = false;
for (int j = 0; j < cur->plants.size(); j++) for (size_t j = 0; j < cur->plants.size(); j++)
{ {
const df::plant *plant = cur->plants[i]; const df::plant *plant = cur->plants[i];
int x = plant->pos.x % 16; int x = plant->pos.x % 16;

@ -154,7 +154,7 @@ static command_result job_material_in_job(Core *c, MaterialInfo &new_mat)
return CR_FAILURE; return CR_FAILURE;
} }
for (unsigned i = 0; i < job->job_items.size(); i++) for (size_t i = 0; i < job->job_items.size(); i++)
{ {
df::job_item *item = job->job_items[i]; df::job_item *item = job->job_items[i];
MaterialInfo item_mat(item); MaterialInfo item_mat(item);
@ -178,7 +178,7 @@ static command_result job_material_in_job(Core *c, MaterialInfo &new_mat)
job->mat_type = new_mat.type; job->mat_type = new_mat.type;
job->mat_index = new_mat.index; job->mat_index = new_mat.index;
for (unsigned i = 0; i < job->job_items.size(); i++) for (size_t i = 0; i < job->job_items.size(); i++)
{ {
df::job_item *item = job->job_items[i]; df::job_item *item = job->job_items[i];
item->mat_type = new_mat.type; item->mat_type = new_mat.type;
@ -224,10 +224,10 @@ static command_result job_material_in_build(Core *c, MaterialInfo &new_mat)
// Loop through matching choices // Loop through matching choices
bool matches = build_choice_matches(req, sel->choices[sel->sel_index], new_mat, true); bool matches = build_choice_matches(req, sel->choices[sel->sel_index], new_mat, true);
int size = sel->choices.size(); size_t size = sel->choices.size();
int base = (matches ? sel->sel_index + 1 : 0); int base = (matches ? sel->sel_index + 1 : 0);
for (unsigned i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
int idx = (base + i) % size; int idx = (base + i) % size;
@ -335,7 +335,7 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
df::building *selected = world->selected_building; df::building *selected = world->selected_building;
for (unsigned i = 0; i < selected->jobs.size(); i++) for (size_t i = 0; i < selected->jobs.size(); i++)
printJobDetails(c, selected->jobs[i]); printJobDetails(c, selected->jobs[i]);
} }
} }

@ -169,7 +169,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
int32_t x,y,z; int32_t x,y,z;
DFHack::Gui * Position; DFHack::Gui * Position;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ {

@ -37,7 +37,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters) DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters)
{ {
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ {

@ -51,7 +51,7 @@ enum do_what
static bool getoptions( vector <string> & parameters, bool & shrubs, bool & trees, bool & help) static bool getoptions( vector <string> & parameters, bool & shrubs, bool & trees, bool & help)
{ {
for(int i = 0;i < parameters.size();i++) for(size_t i = 0;i < parameters.size();i++)
{ {
if(parameters[i] == "shrubs") if(parameters[i] == "shrubs")
{ {
@ -192,7 +192,7 @@ DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameter
DFhackCExport command_result df_grow (Core * c, vector <string> & parameters) DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
{ {
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ {

@ -69,8 +69,7 @@ DFhackCExport command_result df_cprobe (Core * c, vector <string> & parameters)
} }
else else
{ {
uint32_t ncr = world->units.all.size(); for(size_t i = 0; i < world->units.all.size(); i++)
for(auto i = 0; i < ncr; i++)
{ {
df::unit * unit = world->units.all[i]; df::unit * unit = world->units.all[i];
if(unit->pos.x == cursorX && unit->pos.y == cursorY && unit->pos.z == cursorZ) if(unit->pos.x == cursorX && unit->pos.y == cursorY && unit->pos.z == cursorZ)

@ -205,7 +205,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
bool showValue = false; bool showValue = false;
bool showTube = false; bool showTube = false;
Console & con = c->con; Console & con = c->con;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if (parameters[i] == "all") if (parameters[i] == "all")
{ {

@ -25,7 +25,7 @@ DFhackCExport command_result df_regrass (Core * c, vector <string> & parameters)
CoreSuspender suspend(c); CoreSuspender suspend(c);
int count = 0; int count = 0;
for (int i = 0; i < world->map.map_blocks.size(); i++) for (size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block *cur = world->map.map_blocks[i]; df::map_block *cur = world->map.map_blocks[i];
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)

@ -128,7 +128,7 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
{ {
bool no_hell = true; bool no_hell = true;
bool pause = true; bool pause = true;
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i]=="hell") if(params[i]=="hell")
no_hell = false; no_hell = false;
@ -175,7 +175,7 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
Maps::getSize(x_max,y_max,z_max); Maps::getSize(x_max,y_max,z_max);
hidesaved.reserve(x_max * y_max * z_max); hidesaved.reserve(x_max * y_max * z_max);
for (uint32_t i = 0; i < world->map.map_blocks.size(); i++) for (size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block *block = world->map.map_blocks[i]; df::map_block *block = world->map.map_blocks[i];
// in 'no-hell'/'safe' mode, don't reveal blocks with hell and adamantine // in 'no-hell'/'safe' mode, don't reveal blocks with hell and adamantine
@ -218,7 +218,7 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> & params) DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> & params)
{ {
Console & con = c->con; Console & con = c->con;
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ {
@ -274,7 +274,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string>
DFhackCExport command_result revtoggle (DFHack::Core * c, std::vector<std::string> & params) DFhackCExport command_result revtoggle (DFHack::Core * c, std::vector<std::string> & params)
{ {
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ {
@ -294,7 +294,7 @@ DFhackCExport command_result revtoggle (DFHack::Core * c, std::vector<std::strin
DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> & params) DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> & params)
{ {
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ {
@ -348,7 +348,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
// hide all tiles, flush cache // hide all tiles, flush cache
Maps::getSize(x_max,y_max,z_max); Maps::getSize(x_max,y_max,z_max);
for(uint32_t i = 0; i < world->map.map_blocks.size(); i++) for(size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block * b = world->map.map_blocks[i]; df::map_block * b = world->map.map_blocks[i];
// change the hidden flag to 0 // change the hidden flag to 0

@ -49,7 +49,7 @@ DFhackCExport command_result df_showmood (Core * c, vector <string> & parameters
found = true; found = true;
df::unit *unit = NULL; df::unit *unit = NULL;
df::building *building = NULL; df::building *building = NULL;
for (int i = 0; i < job->references.size(); i++) for (size_t i = 0; i < job->references.size(); i++)
{ {
df::general_ref *ref = job->references[i]; df::general_ref *ref = job->references[i];
if (ref->getType() == general_ref_type::UNIT_WORKER) if (ref->getType() == general_ref_type::UNIT_WORKER)
@ -155,7 +155,7 @@ DFhackCExport command_result df_showmood (Core * c, vector <string> & parameters
else else
c->con.print(" and has not yet claimed a workshop\n"); c->con.print(" and has not yet claimed a workshop\n");
for (int i = 0; i < job->job_items.size(); i++) for (size_t i = 0; i < job->job_items.size(); i++)
{ {
df::job_item *item = job->job_items[i]; df::job_item *item = job->job_items[i];
c->con.print("Item %i: ", i + 1); c->con.print("Item %i: ", i + 1);

@ -643,7 +643,7 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
int32_t x = 0, y = 0, z = 0; int32_t x = 0, y = 0, z = 0;
DFHack::Gui *gui; DFHack::Gui *gui;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ {

@ -41,7 +41,7 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string>
{ {
uint64_t count = 0; uint64_t count = 0;
for(int i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ {
@ -59,7 +59,7 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string>
} }
// walk the map // walk the map
for (uint32_t i = 0; i < world->map.map_blocks.size(); i++) for (size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block *block = world->map.map_blocks[i]; df::map_block *block = world->map.map_blocks[i];
df::map_block *above = Maps::getBlockAbs(block->map_pos.x, block->map_pos.y, block->map_pos.z + 1); df::map_block *above = Maps::getBlockAbs(block->map_pos.x, block->map_pos.y, block->map_pos.z + 1);

@ -188,7 +188,7 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
static int diameter = 0; static int diameter = 0;
auto saved_d = diameter; auto saved_d = diameter;
bool force_help = false; bool force_help = false;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ {
@ -782,7 +782,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
bool force_help = false; bool force_help = false;
static explo_how how = EXPLO_NOTHING; static explo_how how = EXPLO_NOTHING;
static explo_what what = EXPLO_HIDDEN; static explo_what what = EXPLO_HIDDEN;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ {
@ -967,7 +967,7 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
// HOTKEY COMMAND: CORE ALREADY SUSPENDED // HOTKEY COMMAND: CORE ALREADY SUSPENDED
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;
bool updown = false; bool updown = false;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters.size() && parameters[0]=="x") if(parameters.size() && parameters[0]=="x")
updown = true; updown = true;

@ -48,7 +48,7 @@ DFhackCExport command_result weather (Core * c, vector <string> & parameters)
bool snow = false; bool snow = false;
bool rain = false; bool rain = false;
bool clear = false; bool clear = false;
for(int i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "rain") if(parameters[i] == "rain")
rain = true; rain = true;

@ -414,7 +414,7 @@ static void cleanup_state(Core *c)
stop_protect(c); stop_protect(c);
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
delete constraints[i]; delete constraints[i];
constraints.clear(); constraints.clear();
} }
@ -678,7 +678,7 @@ static ItemConstraint *get_constraint(Core *c, const std::string &str, Persisten
return NULL; return NULL;
} }
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
ItemConstraint *ct = constraints[i]; ItemConstraint *ct = constraints[i];
if (ct->item == item && ct->material == material && if (ct->item == item && ct->material == material &&
@ -724,7 +724,7 @@ static void link_job_constraint(ProtectedJob *pj, df::item_type itype, int16_t i
{ {
MaterialInfo mat(mat_type, mat_index); MaterialInfo mat(mat_type, mat_index);
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
ItemConstraint *ct = constraints[i]; ItemConstraint *ct = constraints[i];
@ -768,7 +768,7 @@ static void compute_custom_job(ProtectedJob *pj, df::job *job)
if (!r) if (!r)
return; return;
for (unsigned i = 0; i < r->products.size(); i++) for (size_t i = 0; i < r->products.size(); i++)
{ {
using namespace df::enums::reaction_product_item_flags; using namespace df::enums::reaction_product_item_flags;
@ -892,7 +892,7 @@ static void compute_job_outputs(Core *c, ProtectedJob *pj)
if (mat.inorganic) if (mat.inorganic)
{ {
std::vector<int16_t> &ores = mat.inorganic->metal_ore.mat_index; std::vector<int16_t> &ores = mat.inorganic->metal_ore.mat_index;
for (unsigned i = 0; i < ores.size(); i++) for (size_t i = 0; i < ores.size(); i++)
link_job_constraint(pj, item_type::BAR, -1, 0, 0, ores[i]); link_job_constraint(pj, item_type::BAR, -1, 0, 0, ores[i]);
} }
return; return;
@ -901,7 +901,7 @@ static void compute_job_outputs(Core *c, ProtectedJob *pj)
if (mat.inorganic) if (mat.inorganic)
{ {
std::vector<int16_t> &threads = mat.inorganic->thread_metal.mat_index; std::vector<int16_t> &threads = mat.inorganic->thread_metal.mat_index;
for (unsigned i = 0; i < threads.size(); i++) for (size_t i = 0; i < threads.size(); i++)
link_job_constraint(pj, item_type::THREAD, -1, 0, 0, threads[i]); link_job_constraint(pj, item_type::THREAD, -1, 0, 0, threads[i]);
} }
return; return;
@ -910,7 +910,7 @@ static void compute_job_outputs(Core *c, ProtectedJob *pj)
if (job->mat_type != -1) if (job->mat_type != -1)
{ {
std::vector<df::itemdef_foodst*> &food = df::itemdef_foodst::get_vector(); std::vector<df::itemdef_foodst*> &food = df::itemdef_foodst::get_vector();
for (unsigned i = 0; i < food.size(); i++) for (size_t i = 0; i < food.size(); i++)
if (food[i]->level == job->mat_type) if (food[i]->level == job->mat_type)
link_job_constraint(pj, item_type::FOOD, i, 0, -1, -1); link_job_constraint(pj, item_type::FOOD, i, 0, -1, -1);
return; return;
@ -953,7 +953,7 @@ static void map_job_constraints(Core *c)
{ {
melt_active = false; melt_active = false;
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
constraints[i]->jobs.clear(); constraints[i]->jobs.clear();
constraints[i]->is_active = false; constraints[i]->is_active = false;
@ -981,7 +981,7 @@ static void map_job_constraints(Core *c)
static void dryBucket(df::item *item) static void dryBucket(df::item *item)
{ {
for (unsigned i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::CONTAINS_ITEM) if (ref->getType() == general_ref_type::CONTAINS_ITEM)
@ -1003,7 +1003,7 @@ static bool itemBusy(df::item *item)
{ {
using namespace df::enums::item_type; using namespace df::enums::item_type;
for (unsigned i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::CONTAINS_ITEM) if (ref->getType() == general_ref_type::CONTAINS_ITEM)
@ -1051,7 +1051,7 @@ static bool itemInRealJob(df::item *item)
static void map_job_items(Core *c) static void map_job_items(Core *c)
{ {
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
constraints[i]->item_amount = 0; constraints[i]->item_amount = 0;
constraints[i]->item_count = 0; constraints[i]->item_count = 0;
@ -1074,7 +1074,7 @@ static void map_job_items(Core *c)
std::vector<df::item*> &items = world->items.other[items_other_id::ANY_FREE]; std::vector<df::item*> &items = world->items.other[items_other_id::ANY_FREE];
for (unsigned i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
{ {
df::item *item = items[i]; df::item *item = items[i];
@ -1112,7 +1112,7 @@ static void map_job_items(Core *c)
// Match to constraints // Match to constraints
TMaterialCache::key_type matkey(imattype, imatindex); TMaterialCache::key_type matkey(imattype, imatindex);
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
ItemConstraint *cv = constraints[i]; ItemConstraint *cv = constraints[i];
if (cv->item.type != itype || if (cv->item.type != itype ||
@ -1152,7 +1152,7 @@ static void map_job_items(Core *c)
} }
} }
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
constraints[i]->computeRequest(); constraints[i]->computeRequest();
} }
@ -1198,7 +1198,7 @@ static void update_jobs_by_constraints(Core *c)
int resume_weight = -1; int resume_weight = -1;
int suspend_weight = -1; int suspend_weight = -1;
for (unsigned i = 0; i < pj->constraints.size(); i++) for (size_t i = 0; i < pj->constraints.size(); i++)
{ {
if (pj->constraints[i]->request_resume) if (pj->constraints[i]->request_resume)
resume_weight = std::max(resume_weight, pj->constraints[i]->weight); resume_weight = std::max(resume_weight, pj->constraints[i]->weight);
@ -1216,12 +1216,12 @@ static void update_jobs_by_constraints(Core *c)
setJobResumed(c, pj, goal); setJobResumed(c, pj, goal);
} }
for (unsigned i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
ItemConstraint *ct = constraints[i]; ItemConstraint *ct = constraints[i];
bool is_running = false; bool is_running = false;
for (unsigned j = 0; j < ct->jobs.size(); j++) for (size_t j = 0; j < ct->jobs.size(); j++)
if (!!(is_running = ct->jobs[j]->isResumed())) if (!!(is_running = ct->jobs[j]->isResumed()))
break; break;
@ -1321,10 +1321,10 @@ static void print_constraint(Core *c, ItemConstraint *cv, bool no_job = false, s
std::vector<ProtectedJob*> unique_jobs; std::vector<ProtectedJob*> unique_jobs;
std::vector<int> unique_counts; std::vector<int> unique_counts;
for (int i = 0; i < cv->jobs.size(); i++) for (size_t i = 0; i < cv->jobs.size(); i++)
{ {
ProtectedJob *pj = cv->jobs[i]; ProtectedJob *pj = cv->jobs[i];
for (int j = 0; j < unique_jobs.size(); j++) for (size_t j = 0; j < unique_jobs.size(); j++)
{ {
if (unique_jobs[j]->building_id == pj->building_id && if (unique_jobs[j]->building_id == pj->building_id &&
*unique_jobs[j]->actual_job == *pj->actual_job) *unique_jobs[j]->actual_job == *pj->actual_job)
@ -1339,7 +1339,7 @@ static void print_constraint(Core *c, ItemConstraint *cv, bool no_job = false, s
next_job:; next_job:;
} }
for (int i = 0; i < unique_jobs.size(); i++) for (size_t i = 0; i < unique_jobs.size(); i++)
{ {
ProtectedJob *pj = unique_jobs[i]; ProtectedJob *pj = unique_jobs[i];
df::job *job = pj->actual_job; df::job *job = pj->actual_job;
@ -1394,7 +1394,7 @@ static void print_job(Core *c, ProtectedJob *pj)
c->con.reset_color(); c->con.reset_color();
} }
for (int i = 0; i < pj->constraints.size(); i++) for (size_t i = 0; i < pj->constraints.size(); i++)
print_constraint(c, pj->constraints[i], true, " "); print_constraint(c, pj->constraints[i], true, " ");
} }
@ -1447,7 +1447,7 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
for (unsigned i = 1; i < parameters.size(); i++) for (size_t i = 1; i < parameters.size(); i++)
{ {
if (parameters[i] == "drybuckets") if (parameters[i] == "drybuckets")
setOptionEnabled(CF_DRYBUCKETS, enable); setOptionEnabled(CF_DRYBUCKETS, enable);
@ -1482,7 +1482,7 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
{ {
if (workshop) if (workshop)
{ {
for (unsigned i = 0; i < workshop->jobs.size(); i++) for (size_t i = 0; i < workshop->jobs.size(); i++)
print_job(c, get_known(workshop->jobs[i]->id)); print_job(c, get_known(workshop->jobs[i]->id));
} }
else else
@ -1494,7 +1494,7 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
bool pending = false; bool pending = false;
for (unsigned i = 0; i < pending_recover.size(); i++) for (size_t i = 0; i < pending_recover.size(); i++)
{ {
if (!workshop || pending_recover[i]->holder == workshop) if (!workshop || pending_recover[i]->holder == workshop)
{ {
@ -1512,7 +1512,7 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
} }
else if (cmd == "list") else if (cmd == "list")
{ {
for (int i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
print_constraint(c, constraints[i]); print_constraint(c, constraints[i]);
return CR_OK; return CR_OK;
@ -1548,7 +1548,7 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
if (parameters.size() != 2) if (parameters.size() != 2)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
for (int i = 0; i < constraints.size(); i++) for (size_t i = 0; i < constraints.size(); i++)
{ {
if (constraints[i]->config.val() != parameters[1]) if (constraints[i]->config.val() != parameters[1])
continue; continue;