Merged patches from Rainer Keller

develop
Petr Mrázek 2010-11-17 20:50:50 +01:00
parent 88e076c507
commit ac91f46b6c
17 changed files with 1049 additions and 1075 deletions

@ -86,6 +86,7 @@ VersionInfo.cpp
VersionInfoFactory.cpp
DFContextManager.cpp
DFContext.cpp
DFTileTypes.cpp
DFProcessEnumerator.cpp
ContextShared.cpp

@ -31,7 +31,7 @@ DFContextShared::DFContextShared()
DFContextShared::~DFContextShared()
{
// invalidate all modules
for(int i = 0 ; i < allModules.size(); i++)
for(unsigned int i = 0 ; i < allModules.size(); i++)
{
delete allModules[i];
}

@ -93,7 +93,7 @@ bool Context::Detach()
}
d->shm_start = 0;
// invalidate all modules
for(int i = 0 ; i < d->allModules.size(); i++)
for(unsigned int i = 0 ; i < d->allModules.size(); i++)
{
delete d->allModules[i];
}
@ -174,7 +174,7 @@ bool Context::AsyncSuspend()
bool Context::Resume()
{
for(int i = 0 ; i < d->allModules.size(); i++)
for(unsigned int i = 0 ; i < d->allModules.size(); i++)
{
d->allModules[i]->OnResume();
}

@ -69,7 +69,7 @@ BadContexts::~BadContexts()
bool BadContexts::Contains(Process* p)
{
for(int i = 0; i < d->bad.size(); i++)
for(unsigned int i = 0; i < d->bad.size(); i++)
{
if((d->bad[i])->getProcess() == p)
return true;
@ -79,7 +79,7 @@ bool BadContexts::Contains(Process* p)
bool BadContexts::Contains(Context* c)
{
for(int i = 0; i < d->bad.size(); i++)
for(unsigned int i = 0; i < d->bad.size(); i++)
{
if(d->bad[i] == c)
return true;
@ -94,7 +94,7 @@ uint32_t BadContexts::size()
void BadContexts::clear()
{
for(int i = 0; i < d->bad.size(); i++)
for(unsigned int i = 0; i < d->bad.size(); i++)
{
// delete both Process and Context!
// process has to be deleted after context, because Context does some
@ -227,7 +227,7 @@ Context * ContextManager::getSingleContext()
{
Refresh();
}
for(int i = 0; i < d->contexts.size();i++)
for(unsigned int i = 0; i < d->contexts.size();i++)
{
if(d->contexts[i]->isValid())
{
@ -239,8 +239,8 @@ Context * ContextManager::getSingleContext()
void ContextManager::purge(void)
{
for(int i = 0; i < d->contexts.size();i++)
for(unsigned int i = 0; i < d->contexts.size();i++)
delete d->contexts[i];
d->contexts.clear();
d->pEnum->purge();
}
}

@ -63,7 +63,7 @@ BadProcesses::~BadProcesses()
bool BadProcesses::Contains(Process* p)
{
for(int i = 0; i < d->bad.size(); i++)
for(unsigned int i = 0; i < d->bad.size(); i++)
{
if(d->bad[i] == p)
return true;
@ -96,7 +96,7 @@ uint32_t BadProcesses::size()
void BadProcesses::clear()
{
for(int i = 0; i < d->bad.size(); i++)
for(unsigned int i = 0; i < d->bad.size(); i++)
{
delete d->bad[i];
}

@ -276,7 +276,7 @@ int CreatureCasteConvert(t_creaturecaste* src, c_creaturecaste* dest)
((*alloc_creaturecaste_callback)(dest, src->rawname, src->singular, src->plural, src->adjective, src->ColorModifier.size(), src->bodypart.size()));
for(int i = 0; i < dest->colorModifierLength; i++)
for(unsigned int i = 0; i < dest->colorModifierLength; i++)
ColorListConvert(&src->ColorModifier[i], &dest->ColorModifier[i]);
copy(src->bodypart.begin(), src->bodypart.end(), dest->bodypart);
@ -291,7 +291,7 @@ int CreatureTypeConvert(t_creaturetype* src, c_creaturetype* dest)
((*alloc_creaturetype_callback)(dest, src->rawname, src->castes.size(), src->extract.size(), src->tile_character, src->tilecolor.fore, src->tilecolor.back, src->tilecolor.bright));
for(int i = 0; i < dest->castesCount; i++)
for(unsigned int i = 0; i < dest->castesCount; i++)
CreatureCasteConvert(&src->castes[i], &dest->castes[i]);
copy(src->extract.begin(), src->extract.end(), dest->extract);

@ -683,7 +683,6 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
if(name)
{
string str_name = name;
VersionInfo *base = new VersionInfo();
mem = new VersionInfo();
ParseBase( pMemInfo , mem );
knownVersions[str_name] = v_descr (pMemInfo, mem);

File diff suppressed because it is too large Load Diff

@ -74,7 +74,7 @@ t_customWorkshop* Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr)
if(b_Ptr != NULL)
{
int i;
t_customWorkshop* cw_Ptr;
t_customWorkshop* cw_Ptr = NULL;
std::map<uint32_t, string> bTypes;
map<uint32_t, string>::iterator bIter;

@ -69,7 +69,7 @@ Creatures::Creatures(DFContextShared* _d)
{
d = new Private;
d->d = _d;
Process * p = d->owner = _d->p;
d->owner = _d->p;
d->Inited = false;
d->Started = false;
d->d->InitReadNames(); // throws on error
@ -183,7 +183,6 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
}
*/
// non-SHM slow path
VersionInfo * minfo = d->d->offset_descriptor;
// read pointer from vector at position
uint32_t temp = d->p_cre->at (index);
@ -471,6 +470,8 @@ bool Creatures::WriteSex(const uint32_t index, const uint8_t sex)
uint32_t temp = d->p_cre->at (index);
Process * p = d->owner;
p->writeByte (temp + d->creatures.sex_offset, sex);
return true;
}
bool Creatures::WriteTraits(const uint32_t index, const t_soul &soul)
@ -596,7 +597,6 @@ bool Creatures::ReadJob(const t_creature * furball, vector<t_material> & mat)
if(!d->Inited) return false;
if(!furball->current_job.active) return false;
Process * p = d->owner;
VersionInfo * minfo = d->d->offset_descriptor;
DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + d->OG_jobs->getOffset("materials_vector"));
mat.resize(cmats.size());
@ -614,7 +614,6 @@ bool Creatures::ReadJob(const t_creature * furball, vector<t_material> & mat)
bool Creatures::ReadInventoryIdx(const uint32_t index, std::vector<uint32_t> & item)
{
if(!d->Started) return false;
Process * p = d->owner;
uint32_t temp = d->p_cre->at (index);
return this->ReadInventoryPtr(temp, item);
}

@ -84,7 +84,7 @@ t_material* Creatures_ReadJob(DFHackObject* cPtr, const t_creature* furball)
if(mat.size() <= 0)
return NULL;
t_material* buf;
t_material* buf = NULL;
(*alloc_t_material_buffer_callback)(buf, mat.size());
@ -115,7 +115,7 @@ uint32_t* Creatures_ReadInventoryIdx(DFHackObject* cPtr, const uint32_t index)
if(item.size() <= 0)
return NULL;
uint32_t* buf;
uint32_t* buf = NULL;
(*alloc_uint_buffer_callback)(buf, item.size());
@ -144,7 +144,7 @@ uint32_t* Creatures_ReadInventoryPtr(DFHackObject* cPtr, const uint32_t index)
if(item.size() <= 0)
return NULL;
uint32_t* buf;
uint32_t* buf = NULL;
(*alloc_uint_buffer_callback)(buf, item.size());

@ -58,7 +58,7 @@ char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObje
if(desc.size() > 0)
{
char* buf;
char* buf = NULL;
(*alloc_char_buffer_callback)(buf,desc.size());
if(buf != NULL)
@ -86,7 +86,7 @@ char* Items_getItemClass(DFHackObject* items, int32_t index)
if(iclass.size() > 0)
{
char* buf;
char* buf = NULL;
(*alloc_char_buffer_callback)(buf, iclass.size());
if(buf != NULL)
{

@ -661,7 +661,6 @@ __int16 __userpurge GetGeologicalRegion<ax>(__int16 block_X<cx>, int X<ebx>, __i
bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
{
MAPS_GUARD
VersionInfo * minfo = d->d->offset_descriptor;
Process *p = d->owner;
// get needed addresses and offsets. Now this is what I call crazy.
uint16_t worldSizeX, worldSizeY;
@ -736,7 +735,6 @@ bool Maps::ReadLocalFeatures( std::map <planecoord, std::vector<t_feature *> > &
return false;
Process * p = d->owner;
VersionInfo * mem = p->getDescriptor();
// deref pointer to the humongo-structure
uint32_t base = p->readDWord(d->OG_local_features->getAddress("start_ptr"));
if(!base)

@ -62,12 +62,12 @@ uint16_t* Maps_ReadGeology(DFHackObject* maps)
if(((DFHack::Maps*)maps)->ReadGeology(geology))
{
uint16_t* buf;
uint16_t* buf = NULL;
uint32_t geoLength = 0;
for(int i = 0; i < geology.size(); i++)
for(unsigned int i = 0; i < geology.size(); i++)
{
for(int j = 0; j < geology[i].size(); j++)
for(unsigned int j = 0; j < geology[i].size(); j++)
{
geoLength += geology[i].size();
}
@ -79,7 +79,7 @@ uint16_t* Maps_ReadGeology(DFHackObject* maps)
{
uint16_t* bufCopyPtr = buf;
for(int i = 0; i < geology.size(); i++)
for(unsigned int i = 0; i < geology.size(); i++)
{
copy(geology[i].begin(), geology[i].end(), bufCopyPtr);
@ -107,7 +107,7 @@ t_feature* Maps_ReadGlobalFeatures(DFHackObject* maps)
if(featureVec.size() <= 0)
return NULL;
t_feature* buf;
t_feature* buf = NULL;
(*alloc_t_feature_buffer_callback)(buf, featureVec.size());
@ -297,6 +297,8 @@ int Maps_WriteEmptyLocalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint
{
return ((DFHack::Maps*)maps)->WriteLocalFeature(x, y, z, -1);
}
return -1;
}
int Maps_WriteGlobalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t local)
@ -315,6 +317,8 @@ int Maps_WriteEmptyGlobalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uin
{
return ((DFHack::Maps*)maps)->WriteGlobalFeature(x, y, z, -1);
}
return -1;
}
int Maps_ReadBlockFlags(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_blockflags* blockflags)

@ -232,7 +232,7 @@ t_matgloss* Materials_getInorganic(DFHackObject* mat)
if(materials->inorganic.size() > 0)
{
t_matgloss* buf;
t_matgloss* buf = NULL;
((*alloc_matgloss_buffer_callback)(buf, materials->inorganic.size()));
@ -256,7 +256,7 @@ t_matgloss* Materials_getOrganic(DFHackObject* mat)
if(materials->organic.size() > 0)
{
t_matgloss* buf;
t_matgloss* buf = NULL;
((*alloc_matgloss_buffer_callback)(buf, materials->organic.size()));
@ -280,7 +280,7 @@ t_matgloss* Materials_getTree(DFHackObject* mat)
if(materials->tree.size() > 0)
{
t_matgloss* buf;
t_matgloss* buf = NULL;
((*alloc_matgloss_buffer_callback)(buf, materials->tree.size()));
@ -304,7 +304,7 @@ t_matgloss* Materials_getPlant(DFHackObject* mat)
if(materials->plant.size() > 0)
{
t_matgloss* buf;
t_matgloss* buf = NULL;
((*alloc_matgloss_buffer_callback)(buf, materials->plant.size()));
@ -328,7 +328,7 @@ t_matgloss* Materials_getRace(DFHackObject* mat)
if(materials->race.size() > 0)
{
t_matgloss* buf;
t_matgloss* buf = NULL;
((*alloc_matgloss_buffer_callback)(buf, materials->race.size()));
@ -354,7 +354,7 @@ c_creaturetype* Materials_getRaceEx(DFHackObject* mat)
if(matSize > 0)
{
c_creaturetype* buf;
c_creaturetype* buf = NULL;
((*alloc_creaturetype_buffer_callback)(buf, matSize));
@ -379,7 +379,7 @@ t_descriptor_color* Materials_getColor(DFHackObject* mat)
if(materials->color.size() > 0)
{
t_descriptor_color* buf;
t_descriptor_color* buf = NULL;
((*alloc_descriptor_buffer_callback)(buf, materials->color.size()));
@ -403,7 +403,7 @@ t_matglossOther* Materials_getOther(DFHackObject* mat)
if(materials->other.size() > 0)
{
t_matglossOther* buf;
t_matglossOther* buf = NULL;
((*alloc_matgloss_other_buffer_callback)(buf, materials->other.size()));
@ -427,7 +427,7 @@ t_matgloss* Materials_getAllDesc(DFHackObject* mat)
if(materials->alldesc.size() > 0)
{
t_matgloss* buf;
t_matgloss* buf = NULL;
((*alloc_matgloss_buffer_callback)(buf, materials->alldesc.size()));

@ -102,7 +102,7 @@ t_hotkey* Position_ReadHotkeys(DFHackObject* pos)
{
if(pos != NULL)
{
t_hotkey* buf;
t_hotkey* buf = NULL;
(*alloc_t_hotkey_buffer_callback)(buf, NUM_HOTKEYS);
@ -144,7 +144,7 @@ t_screen* Position_getScreenTiles(DFHackObject* pos, int32_t width, int32_t heig
{
if(pos != NULL)
{
t_screen* buf;
t_screen* buf = NULL;
(*alloc_t_screen_buffer_callback)(buf, width * height);

@ -124,7 +124,7 @@ char* Translation_TranslateNameEnglish(DFHackObject* trans, const DFHack::t_name
if(nameTrans.size() > 0)
{
char* buf;
char* buf = NULL;
(*alloc_char_buffer_callback)(buf, nameTrans.size());
@ -155,7 +155,7 @@ char* Translation_TranslateNameNonEnglish(DFHackObject* trans, const DFHack::t_n
if(nameTrans.size() > 0)
{
char* buf;
char* buf = NULL;
(*alloc_char_buffer_callback)(buf, nameTrans.size());