Even more fixes for random crashes in some less common cases (DF in the menu, etc...)

develop
Petr Mrázek 2010-03-26 13:38:49 +01:00
parent 4d939363b5
commit 6522d0c498
11 changed files with 44 additions and 21 deletions

@ -109,6 +109,10 @@ int main (int argc,const char* argv[])
{ {
cout << "usage:" << endl; cout << "usage:" << endl;
cout << argv[0] << " object_name [number of lines]" << endl; cout << argv[0] << " object_name [number of lines]" << endl;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0; return 0;
} }
int lines = 16; int lines = 16;

@ -315,10 +315,25 @@ int main (void)
return 1; return 1;
} }
uint32_t numCreatures;
if(!DF.InitReadCreatures(numCreatures))
{
cerr << "Can't get creatures" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
if(!numCreatures)
{
cerr << "No creatures to print" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.ReadItemTypes(itemTypes); DF.ReadItemTypes(itemTypes);
DF.ReadPlantMatgloss(mat.plantMat); DF.ReadPlantMatgloss(mat.plantMat);
DF.ReadWoodMatgloss(mat.woodMat); DF.ReadWoodMatgloss(mat.woodMat);
DF.ReadStoneMatgloss(mat.stoneMat); DF.ReadStoneMatgloss(mat.stoneMat);
@ -338,12 +353,6 @@ int main (void)
cerr << "Can't get name tables" << endl; cerr << "Can't get name tables" << endl;
return 1; return 1;
} }
uint32_t numCreatures;
if(!DF.InitReadCreatures(numCreatures))
{
cerr << "Can't get creatures" << endl;
return 1;
}
DF.InitViewAndCursor(); DF.InitViewAndCursor();
for(uint32_t i = 0; i < numCreatures; i++) for(uint32_t i = 0; i < numCreatures; i++)
{ {

@ -24,6 +24,16 @@ int main (void)
return 1; return 1;
} }
if(!DF.InitMap())
{
cerr << "No map loaded, it would be unsafe to enumerate materials" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.DestroyMap();
vector <DFHack::t_matgloss> Woods; vector <DFHack::t_matgloss> Woods;
DF.ReadWoodMatgloss(Woods); DF.ReadWoodMatgloss(Woods);
@ -46,7 +56,7 @@ int main (void)
cout << "Creature: " << CreatureTypes[0].id << endl; cout << "Creature: " << CreatureTypes[0].id << endl;
cout << endl; cout << endl;
cout << "Dumping all stones!" << endl; cout << "Dumping all stones!" << endl;
for(int i = 0; i < Stones.size();i++) for(uint32_t i = 0; i < Stones.size();i++)
{ {
cout << Stones[i].id << "$" << endl;; cout << Stones[i].id << "$" << endl;;
} }

@ -450,7 +450,7 @@ start:
uint32_t nickname = mem->getOffset("creature_name") + mem->getOffset("name_nickname"); uint32_t nickname = mem->getOffset("creature_name") + mem->getOffset("name_nickname");
p->writeSTLString(toChange.origin+nickname,changeString); p->writeSTLString(toChange.origin+nickname,changeString);
} }
catch (DFHack::Error::MissingMemoryDefinition& e) catch (DFHack::Error::MissingMemoryDefinition&)
{ {
cerr << "Writing creature nicknames unsupported in this version!" << endl; cerr << "Writing creature nicknames unsupported in this version!" << endl;
} }
@ -462,7 +462,7 @@ start:
uint32_t custom_prof = mem->getOffset("creature_custom_profession"); uint32_t custom_prof = mem->getOffset("creature_custom_profession");
p->writeSTLString(toChange.origin+custom_prof,changeString); p->writeSTLString(toChange.origin+custom_prof,changeString);
} }
catch (DFHack::Error::MissingMemoryDefinition& e) catch (DFHack::Error::MissingMemoryDefinition&)
{ {
cerr << "Writing creature custom profession unsupported in this version!" << endl; cerr << "Writing creature custom profession unsupported in this version!" << endl;
} }

@ -259,7 +259,7 @@ bool API::InitMap()
off->y_count_offset = y_count_offset; off->y_count_offset = y_count_offset;
off->z_count_offset = z_count_offset; off->z_count_offset = z_count_offset;
full_barrier full_barrier
const uint32_t cmd = Maps::MAP_INIT + d->maps_module << 16; const uint32_t cmd = Maps::MAP_INIT + (d->maps_module << 16);
g_pProcess->SetAndWait(cmd); g_pProcess->SetAndWait(cmd);
//cerr << "Map acceleration enabled!" << endl; //cerr << "Map acceleration enabled!" << endl;
} }
@ -920,7 +920,7 @@ bool API::InitReadEffects ( uint32_t & numeffects )
return true; return true;
} }
bool API::ReadEffect(const int32_t index, t_effect_df40d & effect) bool API::ReadEffect(const uint32_t index, t_effect_df40d & effect)
{ {
if(!d->effectsInited) if(!d->effectsInited)
return false; return false;
@ -935,7 +935,7 @@ bool API::ReadEffect(const int32_t index, t_effect_df40d & effect)
} }
// use with care! // use with care!
bool API::WriteEffect(const int32_t index, const t_effect_df40d & effect) bool API::WriteEffect(const uint32_t index, const t_effect_df40d & effect)
{ {
if(!d->effectsInited) if(!d->effectsInited)
return false; return false;

@ -192,8 +192,8 @@ namespace DFHack
* Effects like mist, dragonfire or dust * Effects like mist, dragonfire or dust
*/ */
bool InitReadEffects ( uint32_t & numeffects ); bool InitReadEffects ( uint32_t & numeffects );
bool ReadEffect(const int32_t index, t_effect_df40d & effect); bool ReadEffect(const uint32_t index, t_effect_df40d & effect);
bool WriteEffect(const int32_t index, const t_effect_df40d & effect); bool WriteEffect(const uint32_t index, const t_effect_df40d & effect);
void FinishReadEffects(); void FinishReadEffects();
/* /*

@ -28,7 +28,7 @@ using namespace DFHack;
MemInfoManager::~MemInfoManager() MemInfoManager::~MemInfoManager()
{ {
// for each in std::vector<memory_info*> meminfo;, delete // for each in std::vector<memory_info*> meminfo;, delete
for(int i = 0; i < meminfo.size();i++) for(uint32_t i = 0; i < meminfo.size();i++)
{ {
delete meminfo[i]; delete meminfo[i];
} }
@ -248,7 +248,7 @@ bool MemInfoManager::loadFile(string path_to_xml)
// transform elements // transform elements
{ {
// trash existing list // trash existing list
for(int i = 0; i < meminfo.size(); i++) for(uint32_t i = 0; i < meminfo.size(); i++)
{ {
delete meminfo[i]; delete meminfo[i];
} }

@ -354,7 +354,7 @@ bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
{ {
pe_timestamp = (*it)->getHexValue("pe_timestamp"); pe_timestamp = (*it)->getHexValue("pe_timestamp");
} }
catch(Error::MissingMemoryDefinition& e) catch(Error::MissingMemoryDefinition&)
{ {
continue; continue;
} }

@ -97,7 +97,7 @@ NormalProcess::NormalProcess(uint32_t pid, vector <memory_info *> & known_versio
{ {
pe_timestamp = (*it)->getHexValue("pe_timestamp"); pe_timestamp = (*it)->getHexValue("pe_timestamp");
} }
catch(Error::MissingMemoryDefinition& e) catch(Error::MissingMemoryDefinition&)
{ {
continue; continue;
} }

Binary file not shown.

Binary file not shown.