Using the GetNearestWater function as advertised in the slic documentation you get wrong type of arguments errors. Take a look on the source and compare it with the GetNeighbor function:
Take a close look on the last lines of both functions. The GetNeighbor function returns SFN_ERROR_OK like most of the other functions do. But the GetNearestWater functions returns SFN_ERROR_TYPE_ARGS no idea why.
I would outcomment three of the last lines like:
Also in the GetNeigbor function you can't find this location check or what it should be. So I think modify it like this the function should work as advertized.
-Martin
Code:
SFN_ERROR Slic_GetNearestWater::Call(SlicArgList *args)
{
m_result.m_int = 0;
if(args->m_numArgs != 2)
return SFN_ERROR_NUM_ARGS;
MapPoint pos;
if(!args->GetPos(0, pos))
return SFN_ERROR_TYPE_ARGS;
sint32 x, y;
MapPoint nearest;
sint32 minDist = 0x7fffffff;
for(y = 0; y < g_theWorld->GetYHeight(); y++) {
for(x = 0; x < g_theWorld->GetXWidth(); x++) {
if(!g_theWorld->IsWater(x,y))
continue;
MapPoint chk(x,y);
sint32 dist = pos.NormalizedDistance(chk);
if(dist < minDist) {
minDist = dist;
nearest.Set(x,y);
}
}
}
if(minDist >= 0x7fffffff) {
return SFN_ERROR_OK;
}
if(args->m_argType[1] != SA_TYPE_INT_VAR) {
return SFN_ERROR_TYPE_ARGS;
}
SlicSymbolData *sym = args->m_argValue[1].m_symbol;
if(sym->GetType() == SLIC_SYM_LOCATION) {
m_result.m_int = minDist;
sym->SetPos(nearest);
return SFN_ERROR_OK;
}
return SFN_ERROR_TYPE_ARGS;
}
Code:
SFN_ERROR Slic_GetNeighbor::Call(SlicArgList *args)
{
m_result.m_int = 0;
if(args->m_numArgs != 3)
return SFN_ERROR_NUM_ARGS;
MapPoint posIn;
if(!args->GetPos(0, posIn))
return SFN_ERROR_TYPE_ARGS;
sint32 dir;
if(!args->GetInt(1, dir))
return SFN_ERROR_TYPE_ARGS;
MapPoint posOut;
if(args->m_argType[2] != SA_TYPE_INT_VAR)
return SFN_ERROR_TYPE_ARGS;
SlicSymbolData *sym = args->m_argValue[2].m_symbol;
m_result.m_int = posIn.GetNeighborPosition((WORLD_DIRECTION)dir, posOut);
sym->SetPos(posOut);
return SFN_ERROR_OK;
}
I would outcomment three of the last lines like:
Code:
SlicSymbolData *sym = args->m_argValue[1].m_symbol;
// if(sym->GetType() == SLIC_SYM_LOCATION) {
m_result.m_int = minDist;
sym->SetPos(nearest);
return SFN_ERROR_OK;
// }
// return SFN_ERROR_TYPE_ARGS;
}
-Martin
. Now if I can just make the thing compile...
. Glancing at the code for SetPos, I agree that it won't do anything to a non-location. It is set up to handle structs too, but I think that the structs are not implemented - I hope we are able to change that, because structs would be most useful
Comment