diff --git a/library/include/dfhack/DFMiscUtils.h b/library/include/dfhack/DFMiscUtils.h index 7082bbdd4..e42e9166b 100644 --- a/library/include/dfhack/DFMiscUtils.h +++ b/library/include/dfhack/DFMiscUtils.h @@ -145,61 +145,42 @@ std::string PrintSplatterType (int16_t mat1, int32_t mat2, vector& ranges, DFHack::Context * DF) { _DF = DF; - for(int i = 0; i < ranges.size(); i++) + for(size_t i = 0; i < ranges.size(); i++) { segments.push_back(new SegmentFinder(ranges[i], DF, this)); } } ~SegmentedFinder() { - for(int i = 0; i < segments.size(); i++) + for(size_t i = 0; i < segments.size(); i++) { delete segments[i]; } } SegmentFinder * getSegmentForAddress (uint64_t addr) { - for(int i = 0; i < segments.size(); i++) + for(size_t i = 0; i < segments.size(); i++) { if(segments[i]->mr_.isInRange(addr)) { @@ -122,7 +122,7 @@ class SegmentedFinder bool Find (const needleType needle, const uint8_t increment, vector &found, comparator oper) { found.clear(); - for(int i = 0; i < segments.size(); i++) + for(size_t i = 0; i < segments.size(); i++) { segments[i]->Find(needle, increment, found, oper); } @@ -144,7 +144,7 @@ class SegmentedFinder bool Filter (const needleType needle, vector &found, comparator oper) { vector newfound; - for(int i = 0; i < segments.size(); i++) + for(size_t i = 0; i < segments.size(); i++) { segments[i]->Filter(needle, found, newfound, oper); } @@ -169,7 +169,7 @@ class SegmentedFinder template T * Translate(uint64_t address) { - for(int i = 0; i < segments.size(); i++) + for(size_t i = 0; i < segments.size(); i++) { if(segments[i]->mr_.isInRange(address)) { @@ -227,7 +227,6 @@ bool vectorLength (SegmentedFinder* s, vecTriplet *x, Needle &y) bool vectorString (SegmentedFinder* s, vecTriplet *x, const char *y) { uint32_t object_ptr; - uint32_t idx = x->start; // iterate over vector of pointers for(uint32_t idx = x->start; idx < x->finish; idx += sizeof(uint32_t)) { @@ -287,7 +286,6 @@ bool vectorAddrWithin (SegmentedFinder* s, vecTriplet *x, uint32_t address) bool vectorOfPtrWithin (SegmentedFinder* s, vecTriplet *x, uint32_t address) { uint32_t object_ptr; - uint32_t idx = x->start; for(uint32_t idx = x->start; idx < x->finish; idx += sizeof(uint32_t)) { if(!s->Read(idx,object_ptr)) @@ -405,7 +403,7 @@ std::ostream& operator<< ( std::ostream& out, Bytestream& bs ) if(bs.d->object) { out << "bytestream " << dec << bs.d->length << "/" << bs.d->allocated << " bytes" << endl; - for(int i = 0; i < bs.d->length; i++) + for(size_t i = 0; i < bs.d->length; i++) { out << hex << (int) ((uint8_t *) bs.d->object)[i] << " "; } @@ -535,4 +533,4 @@ bool findStrBuffer (SegmentedFinder* s, uint32_t *addr, const char * compare ) return false; } -#endif // SEGMENTED_FINDER_H \ No newline at end of file +#endif // SEGMENTED_FINDER_H diff --git a/tools/supported/autosearch.cpp b/tools/supported/autosearch.cpp index 6bdff90a3..824752d60 100644 --- a/tools/supported/autosearch.cpp +++ b/tools/supported/autosearch.cpp @@ -235,7 +235,7 @@ public: virtual bool LoadData(SegmentedFinder* s) { bool OK = true; - for(int i = 0; i < members.size() && OK; i++) + for(size_t i = 0; i < members.size() && OK; i++) OK &= members[i]->LoadData(s); return OK; }; @@ -333,7 +333,7 @@ bool getRanges(DFHack::Process * p, vector & selected_ranges selected_ranges.clear(); p->getMemRanges(ranges); cout << "Which range to search? (default is 1-4)" << endl; - for(int i = 0; i< ranges.size();i++) + for(size_t i = 0; i< ranges.size();i++) { cout << dec << "(" << i << ") "; printRange(&(ranges[i])); @@ -452,7 +452,7 @@ struct tilecolors void printFound(vector &found, const char * what) { cout << what << ":" << endl; - for(int i = 0; i < found.size();i++) + for(size_t i = 0; i < found.size();i++) { cout << hex << "0x" << found[i] << endl; } @@ -461,7 +461,7 @@ void printFound(vector &found, const char * what) void printFoundStrVec(vector &found, const char * what, SegmentedFinder & s) { cout << what << ":" << endl; - for(int i = 0; i < found.size();i++) + for(size_t i = 0; i < found.size();i++) { cout << hex << "0x" << found[i] << endl; cout << "--------------------------" << endl; @@ -534,8 +534,9 @@ String * TokenFactory::Build() case DFHack::OS_LINUX: case DFHack::OS_APPLE: return new LinuxString(); + case DFHack::OS_BAD: + return 0; } - return 0; }; template <> String * TokenFactory::Build(uint64_t offset) @@ -547,8 +548,9 @@ String * TokenFactory::Build(uint64_t offset) case DFHack::OS_LINUX: case DFHack::OS_APPLE: return new LinuxString(offset); + case DFHack::OS_BAD: + return 0; } - return 0; }; void autoSearch(DFHack::Context * DF, vector & ranges, DFHack::OSType platform) diff --git a/tools/supported/cleanmap.cpp b/tools/supported/cleanmap.cpp index efba907d4..b7ce35f0e 100644 --- a/tools/supported/cleanmap.cpp +++ b/tools/supported/cleanmap.cpp @@ -22,8 +22,6 @@ int main (int argc, char** argv) } uint32_t x_max,y_max,z_max; - uint32_t num_blocks = 0; - uint32_t bytes_read = 0; vector splatter; DFHack::ContextManager DFMgr("Memory.xml"); @@ -54,7 +52,7 @@ int main (int argc, char** argv) Mapz->getSize(x_max,y_max,z_max); - uint8_t zeroes [16][16] = {0}; + uint8_t zeroes [16][16] = {{0}}; DFHack::occupancies40d occ; // walk the map diff --git a/tools/supported/cleartask.cpp b/tools/supported/cleartask.cpp index 6ef34abac..b359c4be6 100644 --- a/tools/supported/cleartask.cpp +++ b/tools/supported/cleartask.cpp @@ -32,7 +32,6 @@ int main () return 1; } - DFHack::VersionInfo * mem = DF->getMemoryInfo(); p = DF->getProcess(); uint32_t item_vec_offset = 0; try @@ -70,4 +69,4 @@ int main () cin.ignore(); #endif return 0; -} \ No newline at end of file +} diff --git a/tools/supported/incrementalsearch.cpp b/tools/supported/incrementalsearch.cpp index f95fba34f..55fb769aa 100644 --- a/tools/supported/incrementalsearch.cpp +++ b/tools/supported/incrementalsearch.cpp @@ -33,7 +33,7 @@ bool getRanges(DFHack::Process * p, vector & selected_ranges selected_ranges.clear(); p->getMemRanges(ranges); cout << "Which range to search? (default is 1-4)" << endl; - for(int i = 0; i< ranges.size();i++) + for(size_t i = 0; i< ranges.size();i++) { cout << dec << "(" << i << ") "; printRange(&(ranges[i])); @@ -161,10 +161,10 @@ bool Incremental ( vector &found, const char * what, T& output, cout << ">>"; std::getline(cin, select); size_t num = 0; - if( sscanf(select.c_str(),"p %d", &num) && num > 0) + if( sscanf(select.c_str(),"p %zd", &num) && num > 0) { cout << "Found "<< plural <<":" << endl; - for(int i = 0; i < min(found.size(), num);i++) + for(size_t i = 0; i < min(found.size(), num);i++) { cout << hex << "0x" << found[i] << endl; } @@ -173,7 +173,7 @@ bool Incremental ( vector &found, const char * what, T& output, else if(select == "p") { cout << "Found "<< plural <<":" << endl; - for(int i = 0; i < found.size();i++) + for(size_t i = 0; i < found.size();i++) { cout << hex << "0x" << found[i] << endl; } @@ -424,10 +424,10 @@ bool TriggerIncremental ( vector &found ) cout << ">>"; std::getline(cin, select); size_t num = 0; - if( sscanf(select.c_str(),"p %d", &num) && num > 0) + if( sscanf(select.c_str(),"p %zd", &num) && num > 0) { cout << "Found coords:" << endl; - for(int i = 0; i < min(found.size(), num);i++) + for(size_t i = 0; i < min(found.size(), num);i++) { cout << hex << "0x" << found[i] << endl; } @@ -436,7 +436,7 @@ bool TriggerIncremental ( vector &found ) else if(select == "p") { cout << "Found coords:" << endl; - for(int i = 0; i < found.size();i++) + for(size_t i = 0; i < found.size();i++) { cout << hex << "0x" << found[i] << endl; } @@ -606,7 +606,7 @@ void DataPtrTrace(DFHack::ContextManager & DFMgr, vector & r void printFound(vector &found, const char * what) { cout << what << ":" << endl; - for(int i = 0; i < found.size();i++) + for(size_t i = 0; i < found.size();i++) { cout << hex << "0x" << found[i] << endl; } @@ -615,7 +615,7 @@ void printFound(vector &found, const char * what) void printFoundStrVec(vector &found, const char * what, SegmentedFinder & s) { cout << what << ":" << endl; - for(int i = 0; i < found.size();i++) + for(size_t i = 0; i < found.size();i++) { cout << hex << "0x" << found[i] << endl; cout << "--------------------------" << endl; @@ -719,7 +719,7 @@ void autoSearch(DFHack::Context * DF, vector & ranges) sf.Filter("DWARF",to_filter, vectorStringFirst); // verify - for(int i = 0; i < to_filter.size(); i++) + for(size_t i = 0; i < to_filter.size(); i++) { vecTriplet * vec = sf.Translate(to_filter[i]); if(((vec->finish - vec->start) / 4) == 4) // verified @@ -909,9 +909,6 @@ int main (void) vector selected_ranges; getRanges(p,selected_ranges); - DFHack::VersionInfo *minfo = DF->getMemoryInfo(); - DFHack::OSType os = minfo->getOS(); - string prompt = "Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n" " 4=string, 5=automated offset search, 6=vector by address in its array,\n" diff --git a/tools/supported/probe.cpp b/tools/supported/probe.cpp index eb4ec284c..1df70e2cb 100644 --- a/tools/supported/probe.cpp +++ b/tools/supported/probe.cpp @@ -18,7 +18,9 @@ int main (int numargs, const char ** args) DFHack::ContextManager DFMgr("Memory.xml"); DFHack::Context *DF = DFMgr.getSingleContext(); - BEGIN_PROBE: + #ifndef LINUX_BUILD + BEGIN_PROBE: + #endif try { DF->Attach(); @@ -39,17 +41,13 @@ int main (int numargs, const char ** args) DFHack::Process * p = DF->getProcess(); OffsetGroup *mapsg = mem->getGroup("Maps"); OffsetGroup *mapblockg = mapsg->getGroup("block"); - OffsetGroup *localfeatg = mapsg->getGroup("features")->getGroup("local"); uint32_t region_x_offset = mapsg->getAddress("region_x"); uint32_t region_y_offset = mapsg->getAddress("region_y"); uint32_t region_z_offset = mapsg->getAddress("region_z"); uint32_t designatus = mapblockg->getOffset("designation"); - uint32_t block_feature1 = mapblockg->getOffset("feature_local"); - uint32_t block_feature2 = mapblockg->getOffset("feature_global"); - uint32_t feature1_start_ptr = localfeatg->getAddress("start_ptr"); int32_t regionX, regionY, regionZ; // read position of the region inside DF world @@ -80,7 +78,6 @@ int main (int numargs, const char ** args) printf("block addr: 0x%x\n", block.origin); int16_t tiletype = block.tiletypes[tileX][tileY]; naked_designation &des = block.designation[tileX][tileY].bits; - uint32_t &desw = block.designation[tileX][tileY].whole; print_bits(block.designation[tileX][tileY].whole,std::cout); std::cout << endl; print_bits(block.occupancy[tileX][tileY].whole,std::cout); @@ -91,11 +88,11 @@ int main (int numargs, const char ** args) if(tileTypeTable[tiletype].name) std::cout << " = " << tileTypeTable[tiletype].name << std::endl; - printf("%-10s: %4d %s\n","Class",tileTypeTable[tiletype].c,TileClassString[ tileTypeTable[tiletype].c ] , 0); - printf("%-10s: %4d %s\n","Material",tileTypeTable[tiletype].c,TileMaterialString[ tileTypeTable[tiletype].m ] , 0); - printf("%-10s: %4d %s\n","Special",tileTypeTable[tiletype].c,TileSpecialString[ tileTypeTable[tiletype].s ] , 0); - printf("%-10s: %4d\n","Variant",tileTypeTable[tiletype].v , 0); - printf("%-10s: %s\n","Direction",tileTypeTable[tiletype].d.getStr() , 0); + printf("%-10s: %4d %s\n","Class",tileTypeTable[tiletype].c,TileClassString[ tileTypeTable[tiletype].c ]); + printf("%-10s: %4d %s\n","Material",tileTypeTable[tiletype].c,TileMaterialString[ tileTypeTable[tiletype].m ]); + printf("%-10s: %4d %s\n","Special",tileTypeTable[tiletype].c,TileSpecialString[ tileTypeTable[tiletype].s ]); + printf("%-10s: %4d\n","Variant",tileTypeTable[tiletype].v); + printf("%-10s: %s\n","Direction",tileTypeTable[tiletype].d.getStr()); std::cout << std::endl; diff --git a/tools/supported/prospector.cpp b/tools/supported/prospector.cpp index 4b036fb8d..0e3b7c195 100644 --- a/tools/supported/prospector.cpp +++ b/tools/supported/prospector.cpp @@ -309,7 +309,7 @@ int main (int argc, const char* argv[]) } } std::sort(matss.begin(), matss.end(), compare_pair_second<>()); - for(int i = 0; i < matss.size();i++) + for(size_t i = 0; i < matss.size();i++) { if(matss[i].first >= Mats->inorganic.size()) { diff --git a/tools/supported/reveal.cpp b/tools/supported/reveal.cpp index e2a1579b2..dc801bde3 100644 --- a/tools/supported/reveal.cpp +++ b/tools/supported/reveal.cpp @@ -119,7 +119,7 @@ int main (void) DF->Attach(); Maps = DF->getMaps(); Maps->Start(); - for(int i = 0; i < hidesaved.size();i++) + for(size_t i = 0; i < hidesaved.size();i++) { hideblock & hb = hidesaved[i]; Maps->ReadDesignations(hb.x,hb.y,hb.z, &designations); diff --git a/tools/supported/vdig.cpp b/tools/supported/vdig.cpp index 19cb037a5..04a59a044 100644 --- a/tools/supported/vdig.cpp +++ b/tools/supported/vdig.cpp @@ -306,7 +306,6 @@ int main (int argc, char* argv[]) uint32_t x_max,y_max,z_max; DFHack::Maps * Maps = DF->getMaps(); - DFHack::Materials * Mats = DF->getMaterials(); DFHack::Position * Pos = DF->getPosition(); // init the map diff --git a/tools/supported/veinlook.cpp b/tools/supported/veinlook.cpp index 624baae1e..643f416c6 100644 --- a/tools/supported/veinlook.cpp +++ b/tools/supported/veinlook.cpp @@ -50,13 +50,13 @@ int gotoxy(int x, int y) return 0; } -int putch(int x, int y, int znak, int color) +void putch(int x, int y, int znak, int color) { attron(COLOR_PAIR(color)); mvwaddch(stdscr, y, x, znak); attroff(COLOR_PAIR(color)); } -int putwch(int x, int y, int znak, int color) +void putwch(int x, int y, int znak, int color) { attron(COLOR_PAIR(color)); mvwaddch(stdscr, y, x, znak); @@ -88,7 +88,7 @@ int putwch(int x, int y, int znak, int color) PEBBLES };*/ -int puttile(int x, int y, int tiletype, int color) +void puttile(int x, int y, int tiletype, int color) { unsigned int znak; switch(tileTypeTable[tiletype].c) @@ -102,7 +102,7 @@ int puttile(int x, int y, int tiletype, int color) mvwaddwstr(stdscr, y, x, L"\u2593"); attroff(COLOR_PAIR(color)); //znak = ; - return 0; + return; case FORTIFICATION: znak = '#'; break; @@ -119,12 +119,12 @@ int puttile(int x, int y, int tiletype, int color) attron(COLOR_PAIR(color)); mvwaddwstr(stdscr, y, x, L"\u25B2"); attroff(COLOR_PAIR(color)); - return 0; + return; case RAMP_TOP: attron(COLOR_PAIR(color)); mvwaddwstr(stdscr, y, x, L"\u25BC"); attroff(COLOR_PAIR(color)); - return 0; + return; case FLOOR: znak = '.'; break; @@ -133,19 +133,19 @@ int puttile(int x, int y, int tiletype, int color) attron(COLOR_PAIR(color)); mvwaddwstr(stdscr, y, x, L"\u2663"); attroff(COLOR_PAIR(color)); - return 0; + return; case SAPLING_DEAD: case SAPLING_OK: attron(COLOR_PAIR(color)); mvwaddwstr(stdscr, y, x, L"\u03C4"); attroff(COLOR_PAIR(color)); - return 0; + return; case SHRUB_DEAD: case SHRUB_OK: attron(COLOR_PAIR(color)); mvwaddwstr(stdscr, y, x, L"\u2666"); attroff(COLOR_PAIR(color)); - return 0; + return; case BOULDER: case PEBBLES: znak= '*'; @@ -249,7 +249,7 @@ void hexdump (DFHack::Context* DF, uint32_t address, uint32_t length, int filenu myfile.open (name.c_str()); DF->ReadRaw(address, reallength, (uint8_t *) buf); - for (int i = 0; i < lines; i++) + for (size_t i = 0; i < lines; i++) { // leading offset myfile << "0x" << hex << setw(4) << i*16 << " "; @@ -483,7 +483,7 @@ void do_features(Context* DF, mapblock40d * block, uint32_t blockX, uint32_t blo } } -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { /* initialize your non-curses data structures here */ @@ -495,8 +495,6 @@ main(int argc, char *argv[]) cbreak(); /* take input chars one at a time, no wait for \n */ noecho(); /* don't echo input */ //nodelay(stdscr, true); - int wxMax = getmaxx(stdscr); - int wyMax = getmaxy(stdscr); keypad(stdscr, TRUE); scrollok(stdscr, TRUE); @@ -571,7 +569,6 @@ main(int argc, char *argv[]) hasmats = false; } - Process* p = DF->getProcess(); // init the map if(!Maps->Start()) { @@ -761,7 +758,6 @@ main(int argc, char *argv[]) Mats->ReadCreatureTypes(); } } - uint32_t effectnum; /* if(DF.InitReadEffects(effectnum)) { @@ -950,7 +946,6 @@ main(int argc, char *argv[]) else if(vein < mineralsize + icesize + splattersize) { realvein = vein - mineralsize - icesize; - t_spattervein &bloodmud = splatter[realvein]; for(uint32_t yyy = 0; yyy < 16; yyy++) { for(uint32_t xxx = 0; xxx < 16; xxx++) @@ -1127,4 +1122,4 @@ static void finish(int sig) cerr << error << endl; } exit(0); -} \ No newline at end of file +}