Ok, its not really a bug, but it's a pain in the arse which looks like it can be fixed quite easily. HasAdvance( ) takes the advance argument as a string, which makes it a pain for coding loops and stuff where a database number would be handy.
To fix it seems to me to be somewhat easy to fix since the builtin C function HasAdvance takes an int, which is looked up by this SLIC function. slicfunc.cpp.
To make it back compatible, it would need to accept strings and ints, but that shouldn't be a problem should it?
To fix it seems to me to be somewhat easy to fix since the builtin C function HasAdvance takes an int, which is looked up by this SLIC function. slicfunc.cpp.
Code:
SFN_ERROR Slic_HasAdvance::Call(SlicArgList *args) { if(args->m_numArgs != 2) return SFN_ERROR_NUM_ARGS; sint32 player; if(!args->GetPlayer(0, player)) return SFN_ERROR_TYPE_ARGS; if(args->m_argType[1] != SA_TYPE_STRING) return SFN_ERROR_TYPE_ARGS; sint32 adv; for(adv = 0; adv < g_theAdvanceDB->NumRecords(); adv++) { if(g_theAdvanceDB->Get(adv)->m_name == args->m_argValue[1].m_int) break; } if(adv >= g_theAdvanceDB->NumRecords()) { return SFN_ERROR_NOT_ADVANCE; } if(player < 0 || player >= k_MAX_PLAYERS) return SFN_ERROR_OUT_OF_RANGE; if(!g_player[player]) { return SFN_ERROR_DEAD_PLAYER; } m_result.m_int = g_player[player]->HasAdvance(adv); DPRINTF(k_DBG_SLIC, ("Slic_HasAdvance: %d\n", m_result.m_int)); return SFN_ERROR_OK; }
Code:
SFN_ERROR Slic_HasAdvance::Call(SlicArgList *args) { if(args->m_numArgs != 2) return SFN_ERROR_NUM_ARGS; sint32 player; if(!args->GetPlayer(0, player)) return SFN_ERROR_TYPE_ARGS; sint32 s; bool res; s = 2; // 2 == string if(args->m_argType[1] != SA_TYPE_STRING){ res = args->GetInt(1, type); if(!res) { return SFN_ERROR_TYPE_ARGS; s = 0; // neither int or string } else { s = 1; // 1 == int } } sint32 adv; if(s == 2){ // string. look up the DB reference for(adv = 0; adv < g_theAdvanceDB->NumRecords(); adv++) { if(g_theAdvanceDB->Get(adv)->m_name == args->m_argValue[1].m_int) break; } } else { if(s == 1) // DB reference, contine as normal adv = m_argType[1]; } if(adv >= g_theAdvanceDB->NumRecords()) { return SFN_ERROR_NOT_ADVANCE; } if(player < 0 || player >= k_MAX_PLAYERS) return SFN_ERROR_OUT_OF_RANGE; if(!g_player[player]) { return SFN_ERROR_DEAD_PLAYER; } m_result.m_int = g_player[player]->HasAdvance(adv); DPRINTF(k_DBG_SLIC, ("Slic_HasAdvance: %d\n", m_result.m_int)); return SFN_ERROR_OK; }
Comment