Fix many warnings from MSVC builds.

develop
Petr Mrázek 2011-05-23 21:30:51 +02:00
parent 040b5be290
commit d2e01ec579
13 changed files with 36 additions and 37 deletions

@ -194,16 +194,14 @@ NormalProcess::NormalProcess(uint32_t pid, VersionInfoFactory * factory)
vector_start = my_descriptor->getGroup("vector")->getOffset("start"); vector_start = my_descriptor->getGroup("vector")->getOffset("start");
stl.init(this); 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); CloseHandle(my_handle);
my_handle = 0; my_handle = 0;
identified = false; identified = false;
return; 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]); HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, (DWORD) threads_ids[i]);
if(hThread) if(hThread)
@ -234,7 +232,7 @@ NormalProcess::~NormalProcess()
{ {
CloseHandle(my_handle); CloseHandle(my_handle);
} }
for(int i = 0; i < threads.size(); i++) for(size_t i = 0; i < threads.size(); i++)
CloseHandle(threads[i]); CloseHandle(threads[i]);
if(sections != NULL) if(sections != NULL)
free(sections); free(sections);
@ -277,7 +275,7 @@ bool NormalProcess::suspend()
{ {
return true; return true;
} }
for(int i = 0; i < threads.size(); i++) for(size_t i = 0; i < threads.size(); i++)
{ {
stoppedthreads.push_back(threads[i]); stoppedthreads.push_back(threads[i]);
SuspendThread(threads[i]); SuspendThread(threads[i]);
@ -290,7 +288,7 @@ bool NormalProcess::forceresume()
{ {
if(!attached) if(!attached)
return false; return false;
for(int i = 0; i < threads.size(); i++) for(size_t i = 0; i < threads.size(); i++)
while (ResumeThread(threads[i]) > 1); while (ResumeThread(threads[i]) > 1);
suspended = false; suspended = false;
return true; return true;
@ -305,7 +303,7 @@ bool NormalProcess::resume()
{ {
return true; return true;
} }
for(int i = 0; i < stoppedthreads.size(); i++) for(size_t i = 0; i < stoppedthreads.size(); i++)
ResumeThread(stoppedthreads[i]); ResumeThread(stoppedthreads[i]);
stoppedthreads.clear(); stoppedthreads.clear();
suspended = false; suspended = false;

@ -60,7 +60,7 @@ void hexdump (DFHack::Context *DF, uint32_t address, uint32_t length)
{ {
char *buf = new char[length]; char *buf = new char[length];
DF->ReadRaw(address, length, (uint8_t *) buf); DF->ReadRaw(address, length, (uint8_t *) buf);
int i = 0; uint32_t i = 0;
while (i < length) while (i < length)
{ {
// leading offset // leading offset

@ -37,7 +37,6 @@ int main (int argc, char *argv[])
DFHack::Process * p; DFHack::Process * p;
unsigned int i,j;
DFHack::ContextManager DFMgr("Memory.xml"); DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF; DFHack::Context * DF;
try try
@ -74,7 +73,7 @@ int main (int argc, char *argv[])
DFHack::OffsetGroup* itemGroup = mem->getGroup("Items"); DFHack::OffsetGroup* itemGroup = mem->getGroup("Items");
uint32_t ref_vector = itemGroup->getOffset("item_ref_vector"); 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; DFHack::dfh_item itm;
memset(&itm, 0, sizeof(DFHack::dfh_item)); memset(&itm, 0, sizeof(DFHack::dfh_item));
@ -107,7 +106,7 @@ int main (int argc, char *argv[])
if (print_refs) { if (print_refs) {
DFHack::DfVector<uint32_t> p_refs(p, itm.origin + ref_vector); DFHack::DfVector<uint32_t> 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 vptr = p->readDWord(p_refs[j]);
uint32_t val = p->readDWord(p_refs[j]+4); uint32_t val = p->readDWord(p_refs[j]+4);
printf("\t-> %d \t%s\n", int(val), p->readClassName(vptr).c_str()); printf("\t-> %d \t%s\n", int(val), p->readClassName(vptr).c_str());

@ -40,9 +40,12 @@ void sort(int32_t &a,int32_t &b)
} }
void printVecOfVec(ostream &out, vector<vector<vector<string> > >vec,char sep) void printVecOfVec(ostream &out, vector<vector<vector<string> > >vec,char sep)
{ {
for(int k=0;k<vec.size();k++){ for(size_t k=0;k<vec.size();k++)
for(int i =0;i<vec[k].size();i++){ {
for(int j=0;j<vec[k][i].size();j++){ for(size_t i =0;i<vec[k].size();i++)
{
for(size_t j=0;j<vec[k][i].size();j++)
{
out << vec[k][i][j]; out << vec[k][i][j];
if(j==vec[k][i].size()-1) if(j==vec[k][i].size()-1)
{ {

@ -64,6 +64,7 @@
#include <climits> #include <climits>
#include <string.h> #include <string.h>
#include <vector> #include <vector>
#include <locale>
#include <stdio.h> #include <stdio.h>
using namespace std; using namespace std;
@ -264,6 +265,7 @@ DFHack::Creatures * Creatures = NULL;
std::string toCaps(std::string s) std::string toCaps(std::string s)
{ {
const int length = s.length(); const int length = s.length();
std::locale loc("");
bool caps=true; bool caps=true;
if (length == 0) { if (length == 0) {
return s; return s;
@ -272,7 +274,7 @@ std::string toCaps(std::string s)
{ {
if (caps) if (caps)
{ {
s[i] = std::toupper(s[i]); s[i] = std::toupper(s[i],loc);
caps = false; caps = false;
} }
else if (s[i] == '_' || s[i] == ' ') else if (s[i] == '_' || s[i] == ' ')
@ -282,7 +284,7 @@ std::string toCaps(std::string s)
} }
else else
{ {
s[i] = std::tolower(s[i]); s[i] = std::tolower(s[i],loc);
} }
} }
return s; return s;
@ -309,7 +311,7 @@ bool is_in(int m, int set[], int set_size)
int * find_int(std::vector<int> v, int comp) int * find_int(std::vector<int> v, int comp)
{ {
for (int i=0; i<v.size(); i++) for (size_t i=0; i<v.size(); i++)
{ {
//fprintf(stderr, "Comparing %d with %d and returning %x...\n", v[i], comp, &v[i]); //fprintf(stderr, "Comparing %d with %d and returning %x...\n", v[i], comp, &v[i]);
if (v[i] == comp) if (v[i] == comp)
@ -470,7 +472,7 @@ void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature, in
{ {
laborname = mem->getLabor(i); laborname = mem->getLabor(i);
} }
catch(exception &e) catch(exception &)
{ {
laborname = "(Undefined)"; laborname = "(Undefined)";
} }
@ -841,7 +843,7 @@ int main (int argc, const char* argv[])
laborname = mem->getLabor(i); laborname = mem->getLabor(i);
cout << "Labor " << int(i) << ": " << laborname << endl; cout << "Labor " << int(i) << ": " << laborname << endl;
} }
catch (exception& e) { catch (exception&) {
if (verbose) if (verbose)
{ {
laborname = "Unknown"; laborname = "Unknown";

@ -49,7 +49,7 @@ bool splitvector(const vector<uint64_t> & in, vector<uint64_t> & out1, vector<ui
void printvector (const vector<uint64_t> &in) void printvector (const vector<uint64_t> &in)
{ {
cout << "[" << endl; cout << "[" << endl;
for(int i = 0; i < in.size(); i++) for(size_t i = 0; i < in.size(); i++)
{ {
cout << hex << in[i] << endl; cout << hex << in[i] << endl;
} }
@ -60,7 +60,7 @@ bool tryvals (DFHack::Context * DF, const vector<uint64_t> &in, uint8_t current,
{ {
DF->Suspend(); DF->Suspend();
DFHack::Process * p = DF->getProcess(); 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); p->writeByte(in[i],testing);
} }
@ -68,7 +68,7 @@ bool tryvals (DFHack::Context * DF, const vector<uint64_t> &in, uint8_t current,
int result; int result;
while (!getNumber("Is the change good? 0 for no, positive for yes.",result,0)); while (!getNumber("Is the change good? 0 for no, positive for yes.",result,0));
DF->Suspend(); DF->Suspend();
for(int i = 0; i < in.size(); i++) for(size_t i = 0; i < in.size(); i++)
{ {
p->writeByte(in[i],current); p->writeByte(in[i],current);
} }

@ -53,9 +53,6 @@ int main (int argc, char** argv)
uint8_t zeroes [16][16] = {{0}}; uint8_t zeroes [16][16] = {{0}};
DFHack::occupancies40d occ; DFHack::occupancies40d occ;
DFHack::t_temperatures tt1;
DFHack::t_temperatures tt2;
// walk the map // walk the map
for(uint32_t x = 0; x< x_max;x++) for(uint32_t x = 0; x< x_max;x++)
{ {

@ -51,7 +51,7 @@ int main (int argc, char *argv[])
} }
DFHack::Process * p; DFHack::Process * p;
unsigned int i,j; unsigned int i;
DFHack::ContextManager DFMgr("Memory.xml"); DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF; DFHack::Context * DF;
try try

@ -56,7 +56,7 @@ int main(int argc, char *argv[])
vector<DFHack::dfh_plant> alltrees; vector<DFHack::dfh_plant> alltrees;
if(maps->ReadVegetation(x/16,y/16,z,&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]; DFHack::dfh_plant & tree = alltrees[i];
if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z) if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z)
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
else else
{ {
int grown = 0; int grown = 0;
for(int i = 0 ; i < vegCount; i++) for(size_t i = 0 ; i < vegCount; i++)
{ {
DFHack::dfh_plant p; DFHack::dfh_plant p;
veg->Read(i,p); veg->Read(i,p);

@ -100,7 +100,7 @@ int main(int argc, char *argv[])
if(all_shrubs || all_trees) if(all_shrubs || all_trees)
{ {
int destroyed = 0; int destroyed = 0;
for(int i = 0 ; i < vegCount; i++) for(size_t i = 0 ; i < vegCount; i++)
{ {
DFHack::dfh_plant p; DFHack::dfh_plant p;
veg->Read(i,p); veg->Read(i,p);
@ -129,7 +129,7 @@ int main(int argc, char *argv[])
if(maps->ReadVegetation(x/16,y/16,z,&alltrees)) if(maps->ReadVegetation(x/16,y/16,z,&alltrees))
{ {
bool didit = false; 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]; DFHack::dfh_plant & tree = alltrees[i];
if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z) if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z)

@ -177,7 +177,7 @@ int main (int argc, char** argv)
string flowmode="f+"; string flowmode="f+";
string setmode ="s."; string setmode ="s.";
int amount = 7; unsigned int amount = 7;
int width = 1, height = 1, z_levels = 1; int width = 1, height = 1, z_levels = 1;
while(!end) while(!end)
{ {

@ -5,6 +5,8 @@
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <locale>
#include <functional>
using namespace std; using namespace std;
#include <DFHack.h> #include <DFHack.h>
@ -13,14 +15,12 @@ using namespace std;
void tolower(std::string &str) void tolower(std::string &str)
{ {
std::transform(str.begin(), str.end(), str.begin(), std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(&std::tolower<char>), std::locale("")));
(int(*)(int)) std::tolower);
} }
void toupper(std::string &str) void toupper(std::string &str)
{ {
std::transform(str.begin(), str.end(), str.begin(), std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(&std::toupper<char>), std::locale("")));
(int(*)(int)) std::toupper);
} }
int toint(const std::string &str, int failValue = 0) int toint(const std::string &str, int failValue = 0)

@ -563,7 +563,7 @@ int main(int argc, char *argv[])
{ {
Mats = DF->getMaterials(); Mats = DF->getMaterials();
} }
catch (exception& e) catch (exception&)
{ {
hasmats = false; hasmats = false;
} }