rendered paste body#if !defined MAX_ICONS #define MAX_ICONS (128)#endif#define NO_ICON (-1)#define MAX_DISP_ICONS (32)#define ICON_LOOP_GRANULARITY 1enum e_ICON_BITS (<<= 1){ e_ICON_BITS_NONE, e_ICON_BITS_ACTIVE = 1, e_ICON_BITS_LONG}enum E_ICON_DATA{ e_ICON_BITS:E_ICON_DATA_DATA Float:E_ICON_DATA_X, Float:E_ICON_DATA_Y, Float:E_ICON_DATA_Z, E_ICON_DATA_TYPE, E_ICON_DATA_COLOR, Bit:E_ICON_DATA_PLAYERS[PLAYER_BIT_ARRAY]}enum E_ICON_LIST{ E_ICON_LIST_NEXT, E_ICON_LIST_LAST, Float:E_ICON_LIST_DIST, E_ICON_LIST_SLOT}static YSI_g_sIcons[MAX_ICONS][E_ICON_DATA], YSI_g_sPlayerIcons[MAX_PLAYERS][MAX_ICONS];Icon_Icon(){ static timer; if (!timer) { for (new i = 0; i < MAX_PLAYERS; i++) { for (new j = 0; j < MAX_ICONS; j++) { YSI_g_sPlayerIcons[i][j] = -1; } } timer = Timer_Add("Icon_Loop", ICON_LOOP_GRANULARITY); }}stock AddIcon(Float:x, Float:y, Float:z, type, color, long = 0){ new i; for (i = 0; i < MAX_ICONS && (YSI_g_sIcons[i][E_ICON_DATA_DATA] & e_ICON_BITS_ACTIVE); i++) {} if (i == MAX_ICONS) { return NO_ICON; } YSI_g_sIcons[i][E_ICON_DATA_DATA] = e_ICON_BITS_ACTIVE | (long ? (e_ICON_BITS_LONG) : (e_ICON_BITS_NONE)); YSI_g_sIcons[i][E_ICON_DATA_X] = x; YSI_g_sIcons[i][E_ICON_DATA_Y] = y; YSI_g_sIcons[i][E_ICON_DATA_Z] = z; YSI_g_sIcons[i][E_ICON_DATA_TYPE] = type; YSI_g_sIcons[i][E_ICON_DATA_COLOR] = color; Bit_SetAll(YSI_g_sIcons[i][E_ICON_DATA_PLAYERS], 1, PLAYER_BIT_ARRAY); return i;}public Icon_Loop(){ static sIcons[MAX_DISP_ICONS][E_ICON_LIST], Bit:sIconBits[MAX_PLAYERS][MAX_ICONS]; new slot, done, start, end; foreach (Player, i) { slot = 0; done = 0; start = -1; end = -1; new Float:x, Float:y, Float:z, Float:dist; GetPlayerPos(playerid, x, y, z); for (new icon = 0; icon < MAX_ICONS; icon++) { if (Bit_Get(YSI_g_sIcons[icon][E_ICON_DATA_PLAYERS], i)) { dist = ((YSI_g_sIcons[icon][E_ICON_DATA_X] - x) * (YSI_g_sIcons[icon][E_ICON_DATA_X] - x)) + ((YSI_g_sIcons[icon][E_ICON_DATA_Y] - y) * (YSI_g_sIcons[icon][E_ICON_DATA_Y] - y)); if (done < MAX_DISP_ICONS) { slot = done++; } else { if (dist >= sIcons[end][E_ICON_LIST_DIST]) { if (YSI_g_sPlayerIcons[i][icon] != -1) { RemovePlayerMapIcon(i, YSI_g_sPlayerIcons[i][icon]); YSI_g_sPlayerIcons[i][icon] = -1; } } slot = -1; } new next = start, last = -1; while (next != -1 && sIcons[next][E_ICON_LIST_DIST] < dist) { last = next; next = sIcons[next][E_ICON_LIST_NEXT]; } if (slot == -1) { slot = end; } if (next == slot) { sIcons[slot][E_ICON_LIST_NEXT] = -1; } else { sIcons[slot][E_ICON_LIST_NEXT] = next; end = sIcons[slot][E_ICON_LIST_LAST]; } sIcons[slot][E_ICON_LIST_DIST] = dist; sIcons[slot][E_ICON_LIST_LAST] = last; sIcons[slot][E_ICON_LIST_SLOT] = icon; if (last == -1) { start = slot; } else { sIcons[last][E_ICON_LIST_NEXT] = slot; } if (next == -1) { end = slot; } else { sIcons[next][E_ICON_LIST_LAST] = slot; } } } slot = 0; new next = start, last = -1, icon; while (next != -1) { icon = sIcons[next][E_ICON_LIST_SLOT]; if (YSI_g_sPlayerIcons[i][icon] == -1) { SetPlayerMapIcon(i, slot, YSI_g_sIcons[icon][E_ICON_DATA_X], YSI_g_sIcons[icon][E_ICON_DATA_Y], YSI_g_sIcons[icon][E_ICON_DATA_Z], YSI_g_sIcons[icon][E_ICON_DATA_TYPE], YSI_g_sIcons[icon][E_ICON_DATA_COLOR]); YSI_g_sPlayerIcons[i][icon] = slot; } last = next; next = sIcons[next][E_ICON_LIST_NEXT]; slot++; } }}