Prospector prints text again. Plugin lookup is better (ignores more non-library files)

develop
Petr Mrázek 2011-06-24 02:48:56 +02:00
parent 857decbcce
commit 0bb097296a
3 changed files with 28 additions and 24 deletions

@ -42,7 +42,7 @@ distribution.
using namespace DFHack; using namespace DFHack;
// FIXME: maybe make configurable with an ini option? // FIXME: maybe make configurable with an ini option?
#define MAX_CONSOLE_LINES 250; #define MAX_CONSOLE_LINES 999;
duthomhas::stdiostream dfout; duthomhas::stdiostream dfout;
FILE * dfout_C = 0; FILE * dfout_C = 0;

@ -73,10 +73,13 @@ static int getdir (string dir, vector<string> &files)
int fIOthread(void * _core) int fIOthread(void * _core)
{ {
Core * core = (Core *) _core; Core * core = (Core *) _core;
#ifdef LINUX_BUILD #ifdef LINUX_BUILD
string path = core->p->getPath() + "/plugins/"; string path = core->p->getPath() + "/plugins/";
const char * searchstr = ".plug.so";
#else #else
string path = core->p->getPath() + "\\plugins\\"; string path = core->p->getPath() + "\\plugins\\";
const char * searchstr = ".plug.dll";
#endif #endif
vector <string> filez; vector <string> filez;
@ -86,7 +89,7 @@ int fIOthread(void * _core)
int (*_PlugRun)(Core *) = 0; int (*_PlugRun)(Core *) = 0;
for(int i = 0; i < filez.size();i++) for(int i = 0; i < filez.size();i++)
{ {
if(strstr(filez[i].c_str(),".plug.")) if(strstr(filez[i].c_str(),searchstr))
{ {
string fullpath = path + filez[i]; string fullpath = path + filez[i];
DFLibrary * plug = OpenPlugin(fullpath.c_str()); DFLibrary * plug = OpenPlugin(fullpath.c_str());

@ -17,6 +17,7 @@ using namespace std;
#include <dfhack/extra/MapExtras.h> #include <dfhack/extra/MapExtras.h>
#include <dfhack/extra/termutil.h> #include <dfhack/extra/termutil.h>
#include <dfhack/Core.h> #include <dfhack/Core.h>
#include <dfhack/Console.h>
typedef std::map<int16_t, unsigned int> MatMap; typedef std::map<int16_t, unsigned int> MatMap;
typedef std::vector< pair<int16_t, unsigned int> > MatSorter; typedef std::vector< pair<int16_t, unsigned int> > MatSorter;
@ -92,15 +93,15 @@ void printMats(MatMap &mat, std::vector<DFHack::t_matgloss> &materials)
{ {
if(it->first >= materials.size()) if(it->first >= materials.size())
{ {
cerr << "Bad index: " << it->first << " out of " << materials.size() << endl; dfout << "Bad index: " << it->first << " out of " << materials.size() << endl;
continue; continue;
} }
DFHack::t_matgloss mat = materials[it->first]; DFHack::t_matgloss mat = materials[it->first];
std::cout << std::setw(25) << mat.id << " : " << it->second << std::endl; dfout << std::setw(25) << mat.id << " : " << it->second << std::endl;
total += it->second; total += it->second;
} }
std::cout << ">>> TOTAL = " << total << std::endl << std::endl; dfout << ">>> TOTAL = " << total << std::endl << std::endl;
} }
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
@ -125,7 +126,7 @@ DFhackCExport int plugin_run (DFHack::Core * c)
DFHack::Maps *maps = c->getMaps(); DFHack::Maps *maps = c->getMaps();
if (!maps->Start()) if (!maps->Start())
{ {
std::cerr << "Cannot get map info!" << std::endl; dfout << "Cannot get map info!" << std::endl;
c->Resume(); c->Resume();
return 1; return 1;
} }
@ -135,13 +136,13 @@ DFhackCExport int plugin_run (DFHack::Core * c)
DFHack::Materials *mats = c->getMaterials(); DFHack::Materials *mats = c->getMaterials();
if (!mats->ReadInorganicMaterials()) if (!mats->ReadInorganicMaterials())
{ {
std::cerr << "Unable to read inorganic material definitons!" << std::endl; dfout << "Unable to read inorganic material definitons!" << std::endl;
c->Resume(); c->Resume();
return 1; return 1;
} }
if (showPlants && !mats->ReadOrganicMaterials()) if (showPlants && !mats->ReadOrganicMaterials())
{ {
std::cerr << "Unable to read organic material definitons; plants won't be listed!" << std::endl; dfout << "Unable to read organic material definitons; plants won't be listed!" << std::endl;
showPlants = false; showPlants = false;
} }
@ -161,21 +162,21 @@ DFhackCExport int plugin_run (DFHack::Core * c)
if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures))) if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures)))
{ {
std::cerr << "Unable to read global features; slade won't be listed!" << std::endl; dfout << "Unable to read global features; slade won't be listed!" << std::endl;
} }
if (!maps->ReadLocalFeatures(localFeatures)) if (!maps->ReadLocalFeatures(localFeatures))
{ {
std::cerr << "Unable to read local features; adamantine " dfout << "Unable to read local features; adamantine "
<< (showTemple ? "and demon temples " : "") << (showTemple ? "and demon temples " : "")
<< "won't be listed!" << std::endl; << "won't be listed!" << std::endl;
} }
uint32_t vegCount = 0; uint32_t vegCount = 0;
DFHack::Vegetation *veg = c->getVegetation(); DFHack::Vegetation *veg = c->getVegetation();
if (showPlants && !veg->Start()) if (showPlants && !veg->Start())
{ {
std::cerr << "Unable to read vegetation; plants won't be listed!" << std::endl; dfout << "Unable to read vegetation; plants won't be listed!" << std::endl;
} }
for(uint32_t z = 0; z < z_max; z++) for(uint32_t z = 0; z < z_max; z++)
@ -244,7 +245,7 @@ DFhackCExport int plugin_run (DFHack::Core * c)
if (!info) if (!info)
{ {
std::cerr << "Bad type: " << type << std::endl; dfout << "Bad type: " << type << std::endl;
continue; continue;
} }
@ -333,39 +334,39 @@ DFhackCExport int plugin_run (DFHack::Core * c)
MatMap::const_iterator it; MatMap::const_iterator it;
std::cout << "Base materials:" << std::endl; dfout << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it) for (it = baseMats.begin(); it != baseMats.end(); ++it)
{ {
std::cout << std::setw(25) << DFHack::TileMaterialString[it->first] << " : " << it->second << std::endl; dfout << std::setw(25) << DFHack::TileMaterialString[it->first] << " : " << it->second << std::endl;
} }
std::cout << std::endl << "Layer materials:" << std::endl; dfout << std::endl << "Layer materials:" << std::endl;
printMats(layerMats, mats->inorganic); printMats(layerMats, mats->inorganic);
std::cout << "Vein materials:" << std::endl; dfout << "Vein materials:" << std::endl;
printMats(veinMats, mats->inorganic); printMats(veinMats, mats->inorganic);
if (showPlants) if (showPlants)
{ {
std::cout << "Shrubs:" << std::endl; dfout << "Shrubs:" << std::endl;
printMats(plantMats, mats->organic); printMats(plantMats, mats->organic);
std::cout << "Wood in trees:" << std::endl; dfout << "Wood in trees:" << std::endl;
printMats(treeMats, mats->organic); printMats(treeMats, mats->organic);
} }
if (hasAquifer) if (hasAquifer)
{ {
std::cout << "Has aquifer" << std::endl; dfout << "Has aquifer" << std::endl;
} }
if (hasDemonTemple) if (hasDemonTemple)
{ {
std::cout << "Has demon temple" << std::endl; dfout << "Has demon temple" << std::endl;
} }
if (hasLair) if (hasLair)
{ {
std::cout << "Has lair" << std::endl; dfout << "Has lair" << std::endl;
} }
// Cleanup // Cleanup
@ -376,6 +377,6 @@ DFhackCExport int plugin_run (DFHack::Core * c)
mats->Finish(); mats->Finish();
maps->Finish(); maps->Finish();
c->Resume(); c->Resume();
std::cout << std::endl; dfout << std::endl;
return 0; return 0;
} }