コード例 #1
0
ファイル: smn_sorting.cpp プロジェクト: asceth/synapi
int sort2d_amx_custom(const void *elem1, const void *elem2)
{
    cell_t c1 = *(cell_t *)elem1;
    cell_t c2 = *(cell_t *)elem2;

    cell_t c1_addr = g_SortInfo.array_addr + (c1 * sizeof(cell_t)) + g_SortInfo.array_remap[c1];
    cell_t c2_addr = g_SortInfo.array_addr + (c2 * sizeof(cell_t)) + g_SortInfo.array_remap[c2];

    IPluginContext *pContext = g_SortInfo.pFunc->GetParentContext();
    cell_t *c1_r, *c2_r;
    pContext->LocalToPhysAddr(c1_addr, &c1_r);
    pContext->LocalToPhysAddr(c2_addr, &c2_r);

    cell_t result = 0;
    g_SortInfo.pFunc->PushCell(c1_addr);
    g_SortInfo.pFunc->PushCell(c2_addr);
    g_SortInfo.pFunc->PushCell(g_SortInfo.array_addr);
    g_SortInfo.pFunc->PushCell(g_SortInfo.hndl);
    g_SortInfo.pFunc->Execute(&result);

    return result;
}