int id_unlink(ID *id, int test) { Main *mainlib= G.main; ListBase *lb; switch(GS(id->name)) { case ID_TXT: if(test) return 1; unlink_text(mainlib, (Text*)id); break; case ID_GR: if(test) return 1; unlink_group((Group*)id); break; case ID_OB: if(test) return 1; unlink_object((Object*)id); break; } if(id->us == 0) { if(test) return 1; lb= which_libbase(mainlib, GS(id->name)); free_libblock(lb, id); return 1; } return 0; }
void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { if(ID_REAL_USERS(object) <= 0) { unlink_object(object); /* needed or ID pointers to this are not cleared */ free_libblock(&bmain->object, object); } else { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, ID_REAL_USERS(object)); } }
int event_cportal(EVENT_DATA *event) { char buf[MAX_STRING_LENGTH]; OBJECT_DATA *obj = event->owner.obj; destroy_obj_events(obj, EVENT_ALL); strlcpy(buf, "A #Rred#n portal closes with a pop.\n", MAX_STRING_LENGTH); put_sense_area(obj->x, obj->y, obj->plane, SENSE_SIGHT, buf); unlink_object(obj); free_object(obj); return 1; }
void free_libblock_us(ListBase *lb, void *idv) /* test users */ { ID *id= idv; id->us--; if(id->us<0) { if(id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us); else printf("ERROR block %s users %d\n", id->name, id->us); } if(id->us==0) { if( GS(id->name)==ID_OB ) unlink_object((Object *)id); free_libblock(lb, id); } }
int event_destroy(EVENT_DATA *event) { char buf[MAX_STRING_LENGTH]; OBJECT_DATA *obj = event->owner.obj; destroy_obj_events(obj, EVENT_ALL); strlcpy(buf, obj->shortdesc, MAX_STRING_LENGTH); buf[0] = UPPER(buf[0]); strlcat(buf, " vanishes with a pop.\n", MAX_STRING_LENGTH); put_sense_area(obj->x, obj->y, obj->plane, SENSE_SIGHT, buf); unlink_object(obj); free_object(obj); return 1; }
void wipe_character(CHAR_DATA *ch) { OBJECT_DATA *obj, *tempobj; destroy_all_events(ch, EVENT_ALL); obj = ch->obj; while (obj) { tempobj = obj->next_local; destroy_obj_events(obj, EVENT_ALL); unlink_object(obj); free_object(obj); obj = tempobj; } ch->acc->ch = NULL; unlink_character(ch); free_character(ch); }