static void on_resource_downloaded (const char* res_name, int status, void *context, char *last_modified){ int i; for (i = 0; i < MAX_ADD_ONS; i++) { if (gBonusTable.bonus[i] && !strcmp(res_name, gBonusTable.bonus[i]->pIconName)) onBonusAdd(gBonusTable.bonus[i]); } }
BOOL RealtimeBonus_Add (RTBonus *pbonus) { int index; int i; if (!roadmap_map_settings_road_goodies() && !pbonus->bIsCustomeBonus) return TRUE; // Full? if (MAX_ADD_ONS == gBonusTable.iCount){ roadmap_log( ROADMAP_ERROR, "RealtimeBonus_Add() - Failed (Table is full)"); return FALSE; } if ((pbonus->bIsCustomeBonus) && (g_CustomIndex != -1)) return TRUE; if ((pbonus->bIsCustomeBonus) && !custom_bonus_feature_enabled()){ Realtime_CollectCustomBonus(pbonus->iID, FALSE, FALSE); editor_points_add_new_points (pbonus->iNumPoints); return TRUE; } if (RealtimeBonus_Exists (pbonus->iID)) RealtimeBonus_Delete(pbonus->iID); for (i = 0; i < MAX_ADD_ONS; i++) { if (gBonusTable.bonus[i] == NULL) { index = i; break; } } gBonusTable.bonus[index] = calloc (1, sizeof(RTBonus)); RealtimeBonus_Record_Init (gBonusTable.bonus[index]); gBonusTable.bonus[index]->iID = pbonus->iID; gBonusTable.bonus[index]->iType = pbonus->iType; gBonusTable.bonus[index]->iNumPoints = pbonus->iNumPoints; gBonusTable.bonus[index]->iToken = pbonus->iToken; gBonusTable.bonus[index]->iRadius = pbonus->iRadius; gBonusTable.bonus[index]->position.latitude = pbonus->position.latitude; gBonusTable.bonus[index]->position.longitude = pbonus->position.longitude; gBonusTable.bonus[index]->pIconName = strdup (pbonus->pIconName); if (pbonus->pBonusText) gBonusTable.bonus[index]->pBonusText = strdup (pbonus->pBonusText); if (pbonus->pCollectText) gBonusTable.bonus[index]->pCollectText = strdup (pbonus->pCollectText); if (pbonus->pCollectTitle) gBonusTable.bonus[index]->pCollectTitle = strdup (pbonus->pCollectTitle); if (pbonus->pCollectIcon) gBonusTable.bonus[index]->pCollectIcon = strdup (pbonus->pCollectIcon); gBonusTable.bonus[index]->bIsCustomeBonus = pbonus->bIsCustomeBonus; gBonusTable.bonus[index]->collected = FALSE; RealtimeBonus_CreateGUIID (gBonusTable.bonus[index]); gBonusTable.iCount++; if (gBonusTable.bonus[index]->bIsCustomeBonus){ if (gBonusTable.bonus[index]->iNumPoints != 0) gBonusTable.bonus[index]->iType = BONUS_TYPE_POINTS; gBonusTable.bonus[index]->iRadius = get_custom_bonus_radius(); g_CustomIndex = index; } if (roadmap_res_get(RES_BITMAP,RES_SKIN, gBonusTable.bonus[index]->pIconName) == NULL){ if (pbonus->bIsCustomeBonus) printf("download custom %s",gBonusTable.bonus[index]->pIconName); roadmap_res_download(RES_DOWNLOAD_IMAGE, gBonusTable.bonus[index]->pIconName,NULL, "",FALSE,0, on_resource_downloaded, NULL ); } else { if (pbonus->bIsCustomeBonus) printf("add custom %s",gBonusTable.bonus[index]->pIconName); onBonusAdd (gBonusTable.bonus[index]); } return TRUE; }