While I was readding some of the slic functions of the patch I noticed that this code gives more debug assertions regarding Diplomacy personalities strings:
But this code is fine:
The only difference Between these two pieces of code is that the line m_result.m_int = 0; is placed before the for loop in the second piece of code instead afterwards.
-Martin
Code:
SFN_ERROR Slic_TileHasImprovement::Call(SlicArgList *args)
{
if(args->m_numArgs != 2)
return SFN_ERROR_NUM_ARGS;
MapPoint pos;
if(!args->GetPos(0, pos))
return SFN_ERROR_TYPE_ARGS;
sint32 imp;
if(!args->GetInt(1, imp))
return SFN_ERROR_TYPE_ARGS;
m_result.m_int = 0;
Cell *cell = g_theWorld->GetCell(pos);
for(sint32 i = 0; i < cell->GetNumDBImprovements(); i++) {
if(imp == cell->GetDBImprovement(i)){
m_result.m_int = 1;
return SFN_ERROR_OK;
}
}
m_result.m_int = 0;
return SFN_ERROR_OK;
}
Code:
SFN_ERROR Slic_TileHasImprovement::Call(SlicArgList *args)
{
if(args->m_numArgs != 2)
return SFN_ERROR_NUM_ARGS;
MapPoint pos;
if(!args->GetPos(0, pos))
return SFN_ERROR_TYPE_ARGS;
sint32 imp;
if(!args->GetInt(1, imp))
return SFN_ERROR_TYPE_ARGS;
m_result.m_int = 0;
Cell *cell = g_theWorld->GetCell(pos);
for(sint32 i = 0; i < cell->GetNumDBImprovements(); i++) {
if(imp == cell->GetDBImprovement(i)){
m_result.m_int = 1;
return SFN_ERROR_OK;
}
}
return SFN_ERROR_OK;
}
-Martin
Comment