From d2e01ec579b093175f790ad7a27a34b860fb2445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 23 May 2011 21:30:51 +0200 Subject: [PATCH] Fix many warnings from MSVC builds. --- library/DFProcess-windows.cpp | 14 ++++++-------- library/include/dfhack/DFMiscUtils.h | 2 +- tools/examples/dfitemdump.cpp | 5 ++--- tools/playground/copypaste.cpp | 9 ++++++--- tools/playground/creaturemanager.cpp | 12 +++++++----- tools/playground/dftry.cpp | 6 +++--- tools/supported/cleanmap.cpp | 3 --- tools/supported/cleanowned.cpp | 2 +- tools/supported/grow.cpp | 4 ++-- tools/supported/immolate.cpp | 4 ++-- tools/supported/liquids.cpp | 2 +- tools/supported/tiletypes.cpp | 8 ++++---- tools/supported/veinlook.cpp | 2 +- 13 files changed, 36 insertions(+), 37 deletions(-) diff --git a/library/DFProcess-windows.cpp b/library/DFProcess-windows.cpp index cb651e3af..8a8cd45fa 100644 --- a/library/DFProcess-windows.cpp +++ b/library/DFProcess-windows.cpp @@ -194,16 +194,14 @@ NormalProcess::NormalProcess(uint32_t pid, VersionInfoFactory * factory) vector_start = my_descriptor->getGroup("vector")->getOffset("start"); stl.init(this); } - catch (DFHack::Error::UnsetMemoryDefinition & e) + catch (DFHack::Error::UnsetMemoryDefinition &) { - //cout << "WHAT THE FUCK WINE?" << endl; - //cout << "PID:" << pid << endl; CloseHandle(my_handle); my_handle = 0; identified = false; return; } - for(int i = 0; i < threads_ids.size();i++) + for(size_t i = 0; i < threads_ids.size();i++) { HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, (DWORD) threads_ids[i]); if(hThread) @@ -234,7 +232,7 @@ NormalProcess::~NormalProcess() { CloseHandle(my_handle); } - for(int i = 0; i < threads.size(); i++) + for(size_t i = 0; i < threads.size(); i++) CloseHandle(threads[i]); if(sections != NULL) free(sections); @@ -277,7 +275,7 @@ bool NormalProcess::suspend() { return true; } - for(int i = 0; i < threads.size(); i++) + for(size_t i = 0; i < threads.size(); i++) { stoppedthreads.push_back(threads[i]); SuspendThread(threads[i]); @@ -290,7 +288,7 @@ bool NormalProcess::forceresume() { if(!attached) return false; - for(int i = 0; i < threads.size(); i++) + for(size_t i = 0; i < threads.size(); i++) while (ResumeThread(threads[i]) > 1); suspended = false; return true; @@ -305,7 +303,7 @@ bool NormalProcess::resume() { return true; } - for(int i = 0; i < stoppedthreads.size(); i++) + for(size_t i = 0; i < stoppedthreads.size(); i++) ResumeThread(stoppedthreads[i]); stoppedthreads.clear(); suspended = false; diff --git a/library/include/dfhack/DFMiscUtils.h b/library/include/dfhack/DFMiscUtils.h index 230e6f530..e1561e42b 100644 --- a/library/include/dfhack/DFMiscUtils.h +++ b/library/include/dfhack/DFMiscUtils.h @@ -60,7 +60,7 @@ void hexdump (DFHack::Context *DF, uint32_t address, uint32_t length) { char *buf = new char[length]; DF->ReadRaw(address, length, (uint8_t *) buf); - int i = 0; + uint32_t i = 0; while (i < length) { // leading offset diff --git a/tools/examples/dfitemdump.cpp b/tools/examples/dfitemdump.cpp index acad786c5..0c8eceddc 100644 --- a/tools/examples/dfitemdump.cpp +++ b/tools/examples/dfitemdump.cpp @@ -37,7 +37,6 @@ int main (int argc, char *argv[]) DFHack::Process * p; - unsigned int i,j; DFHack::ContextManager DFMgr("Memory.xml"); DFHack::Context * DF; try @@ -74,7 +73,7 @@ int main (int argc, char *argv[]) DFHack::OffsetGroup* itemGroup = mem->getGroup("Items"); uint32_t ref_vector = itemGroup->getOffset("item_ref_vector"); - for(int i = 0; i < size; i++) + for(size_t i = 0; i < size; i++) { DFHack::dfh_item itm; memset(&itm, 0, sizeof(DFHack::dfh_item)); @@ -107,7 +106,7 @@ int main (int argc, char *argv[]) if (print_refs) { DFHack::DfVector p_refs(p, itm.origin + ref_vector); - for (int j = 0; j < p_refs.size(); j++) { + for (size_t j = 0; j < p_refs.size(); j++) { uint32_t vptr = p->readDWord(p_refs[j]); uint32_t val = p->readDWord(p_refs[j]+4); printf("\t-> %d \t%s\n", int(val), p->readClassName(vptr).c_str()); diff --git a/tools/playground/copypaste.cpp b/tools/playground/copypaste.cpp index bb9c3f43f..cc32c872f 100644 --- a/tools/playground/copypaste.cpp +++ b/tools/playground/copypaste.cpp @@ -40,9 +40,12 @@ void sort(int32_t &a,int32_t &b) } void printVecOfVec(ostream &out, vector > >vec,char sep) { - for(int k=0;k #include #include +#include #include using namespace std; @@ -264,6 +265,7 @@ DFHack::Creatures * Creatures = NULL; std::string toCaps(std::string s) { const int length = s.length(); + std::locale loc(""); bool caps=true; if (length == 0) { return s; @@ -272,7 +274,7 @@ std::string toCaps(std::string s) { if (caps) { - s[i] = std::toupper(s[i]); + s[i] = std::toupper(s[i],loc); caps = false; } else if (s[i] == '_' || s[i] == ' ') @@ -282,7 +284,7 @@ std::string toCaps(std::string s) } else { - s[i] = std::tolower(s[i]); + s[i] = std::tolower(s[i],loc); } } return s; @@ -309,7 +311,7 @@ bool is_in(int m, int set[], int set_size) int * find_int(std::vector v, int comp) { - for (int i=0; igetLabor(i); } - catch(exception &e) + catch(exception &) { laborname = "(Undefined)"; } @@ -841,7 +843,7 @@ int main (int argc, const char* argv[]) laborname = mem->getLabor(i); cout << "Labor " << int(i) << ": " << laborname << endl; } - catch (exception& e) { + catch (exception&) { if (verbose) { laborname = "Unknown"; diff --git a/tools/playground/dftry.cpp b/tools/playground/dftry.cpp index c6b159926..d7693ae8b 100644 --- a/tools/playground/dftry.cpp +++ b/tools/playground/dftry.cpp @@ -49,7 +49,7 @@ bool splitvector(const vector & in, vector & out1, vector &in) { cout << "[" << endl; - for(int i = 0; i < in.size(); i++) + for(size_t i = 0; i < in.size(); i++) { cout << hex << in[i] << endl; } @@ -60,7 +60,7 @@ bool tryvals (DFHack::Context * DF, const vector &in, uint8_t current, { DF->Suspend(); DFHack::Process * p = DF->getProcess(); - for(int i = 0; i < in.size(); i++) + for(size_t i = 0; i < in.size(); i++) { p->writeByte(in[i],testing); } @@ -68,7 +68,7 @@ bool tryvals (DFHack::Context * DF, const vector &in, uint8_t current, int result; while (!getNumber("Is the change good? 0 for no, positive for yes.",result,0)); DF->Suspend(); - for(int i = 0; i < in.size(); i++) + for(size_t i = 0; i < in.size(); i++) { p->writeByte(in[i],current); } diff --git a/tools/supported/cleanmap.cpp b/tools/supported/cleanmap.cpp index fb689dc1b..35490bf8b 100644 --- a/tools/supported/cleanmap.cpp +++ b/tools/supported/cleanmap.cpp @@ -53,9 +53,6 @@ int main (int argc, char** argv) uint8_t zeroes [16][16] = {{0}}; DFHack::occupancies40d occ; - DFHack::t_temperatures tt1; - DFHack::t_temperatures tt2; - // walk the map for(uint32_t x = 0; x< x_max;x++) { diff --git a/tools/supported/cleanowned.cpp b/tools/supported/cleanowned.cpp index d2742af5c..f54d3999a 100644 --- a/tools/supported/cleanowned.cpp +++ b/tools/supported/cleanowned.cpp @@ -51,7 +51,7 @@ int main (int argc, char *argv[]) } DFHack::Process * p; - unsigned int i,j; + unsigned int i; DFHack::ContextManager DFMgr("Memory.xml"); DFHack::Context * DF; try diff --git a/tools/supported/grow.cpp b/tools/supported/grow.cpp index a5d0deb1c..cd5daba6f 100644 --- a/tools/supported/grow.cpp +++ b/tools/supported/grow.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) vector alltrees; if(maps->ReadVegetation(x/16,y/16,z,&alltrees)) { - for(int i = 0 ; i < alltrees.size(); i++) + for(size_t i = 0 ; i < alltrees.size(); i++) { DFHack::dfh_plant & tree = alltrees[i]; if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z) @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) else { int grown = 0; - for(int i = 0 ; i < vegCount; i++) + for(size_t i = 0 ; i < vegCount; i++) { DFHack::dfh_plant p; veg->Read(i,p); diff --git a/tools/supported/immolate.cpp b/tools/supported/immolate.cpp index 99f68a900..2c8cd6f3b 100644 --- a/tools/supported/immolate.cpp +++ b/tools/supported/immolate.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) if(all_shrubs || all_trees) { int destroyed = 0; - for(int i = 0 ; i < vegCount; i++) + for(size_t i = 0 ; i < vegCount; i++) { DFHack::dfh_plant p; veg->Read(i,p); @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) if(maps->ReadVegetation(x/16,y/16,z,&alltrees)) { bool didit = false; - for(int i = 0 ; i < alltrees.size(); i++) + for(size_t i = 0 ; i < alltrees.size(); i++) { DFHack::dfh_plant & tree = alltrees[i]; if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z) diff --git a/tools/supported/liquids.cpp b/tools/supported/liquids.cpp index dfdc7d96d..6a34d2fab 100644 --- a/tools/supported/liquids.cpp +++ b/tools/supported/liquids.cpp @@ -177,7 +177,7 @@ int main (int argc, char** argv) string flowmode="f+"; string setmode ="s."; - int amount = 7; + unsigned int amount = 7; int width = 1, height = 1, z_levels = 1; while(!end) { diff --git a/tools/supported/tiletypes.cpp b/tools/supported/tiletypes.cpp index 4a46f60b2..8d8fd625a 100644 --- a/tools/supported/tiletypes.cpp +++ b/tools/supported/tiletypes.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include using namespace std; #include @@ -13,14 +15,12 @@ using namespace std; void tolower(std::string &str) { - std::transform(str.begin(), str.end(), str.begin(), - (int(*)(int)) std::tolower); + std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(&std::tolower), std::locale(""))); } void toupper(std::string &str) { - std::transform(str.begin(), str.end(), str.begin(), - (int(*)(int)) std::toupper); + std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(&std::toupper), std::locale(""))); } int toint(const std::string &str, int failValue = 0) diff --git a/tools/supported/veinlook.cpp b/tools/supported/veinlook.cpp index 83f595f2b..c5837a25c 100644 --- a/tools/supported/veinlook.cpp +++ b/tools/supported/veinlook.cpp @@ -563,7 +563,7 @@ int main(int argc, char *argv[]) { Mats = DF->getMaterials(); } - catch (exception& e) + catch (exception&) { hasmats = false; }