void ObjectManager::flush_destruction_queue() { typedef DestructionQueue::Element Elt; DestructionQueue& q = m_destructionQueue; while(!q.empty()) { Elt& e = q.top(); ObjectID id = e.id(); bool& predestroyFlag = e.data(); if(predestroyFlag) { // The pre-destroy message has already been sent for this object. destroy_object(id); q.pop(); } else { // Note: The flag must be set before sending the pre-destroy message, which may result in queue changes. predestroyFlag = true; broadcast_message(Message_CPtr(new MsgObjectPredestroyed(id))); } } }
int hassign(struct object *o, handle_t h) { int rc; if (h > HTABSIZE / sizeof(handle_t)) return -EBADF; while (htabsize <= h) { rc = expand_htab(); if (rc < 0) return rc; } if (!HUSED(htab[h])) { // Not allocated, remove from freelist rc = remove_from_freelist(h); if (rc < 0) return rc; } else { // Handle already allocated, free handle struct object *oo = HOBJ(htab[h]); if (HPROT(htab[h])) return -EACCES; if (--oo->handle_count == 0) { rc = close_object(oo); if (oo->lock_count == 0) destroy_object(oo); if (rc < 0) return rc; } } // Assign handle to object htab[h] = (handle_t) o; o->handle_count++; return 0; }
struct Thing *create_crate_in_workshop(struct Room *room, ThingModel cratngmodel, MapSubtlCoord stl_x, MapSubtlCoord stl_y) { struct Coord3d pos; struct Thing *cratetng; if (!room_role_matches(room->kind, RoRoF_CratesStorage)) { SYNCDBG(4,"Crate %s cannot be created in a %s owned by player %d, wrong room",object_code_name(cratngmodel),room_code_name(room->kind),(int)room->owner); return INVALID_THING; } pos.x.val = subtile_coord_center(stl_x); pos.y.val = subtile_coord_center(stl_y); pos.z.val = 0; cratetng = create_object(&pos, cratngmodel, room->owner, -1); if (thing_is_invalid(cratetng)) { return INVALID_THING; } // Neutral thing do not need any more processing if (is_neutral_thing(cratetng) || !player_exists(get_player(room->owner))) { return cratetng; } if (!add_workshop_object_to_workshop(room, cratetng)) { ERRORLOG("Could not fit %s in %s index %d", thing_model_name(cratetng),room_code_name(room->kind),(int)room->index); //remove_item_from_room_capacity(room); -- no need, it was not added destroy_object(cratetng); return INVALID_THING; } ThingClass tngclass; ThingModel tngmodel; tngclass = crate_thing_to_workshop_item_class(cratetng); tngmodel = crate_thing_to_workshop_item_model(cratetng); add_workshop_item_to_amounts(cratetng->owner, tngclass, tngmodel); return cratetng; }
int orel(object_t hobj) { struct object *o = (struct object *) hobj; if (--o->lock_count == 0 && o->handle_count == 0) { return destroy_object(o); } else { return 0; } }
/** * Free a player structure. Takes care of removing this player from the * list of players, and frees the socket for this player. * @param pl The player structure to free. */ void free_player(player *pl) { if (pl->ob) { SET_FLAG(pl->ob, FLAG_NO_FIX_PLAYER); if (!QUERY_FLAG(pl->ob, FLAG_REMOVED)) { remove_ob(pl->ob); check_walk_off(pl->ob, NULL, MOVE_APPLY_VANISHED); } } /* Free command permissions. */ if (pl->cmd_permissions) { int i; for (i = 0; i < pl->num_cmd_permissions; i++) { if (pl->cmd_permissions[i]) { free(pl->cmd_permissions[i]); } } free(pl->cmd_permissions); } /* Now remove from list of players. */ if (pl->prev) { pl->prev->next = pl->next; } else { first_player = pl->next; } if (pl->next) { pl->next->prev = pl->prev; } else { last_player = pl->prev; } free_newsocket(&pl->socket); if (pl->ob) { destroy_object(pl->ob); } }
dmz::Boolean dmz::RenderModuleCoreOSGBasic::destroy_dynamic_object (const Handle ObjectHandle) { static const UUID Empty; Boolean result = (_objectTable.lookup (ObjectHandle) ? True : False); destroy_object (Empty, ObjectHandle); return result; }
void dmz::RenderPluginObjectLoaderOSG::remove_object_attribute ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Mask &AttrMask) { if (AttributeHandle == _modelAttrHandle) { destroy_object (Identity, ObjectHandle); } }
static inline void destroy_container(JsonContainer container) { switch (container->type) { case JSON_OBJECT: destroy_object(container->via.object); break; case JSON_ARRAY: destroy_array(container->via.array); break; case JSON_TOP_LEVEL: destroy_value(container->via.top_level.value); break; } pfree(container); }
int hfree(handle_t h) { struct object *o; int rc; o = hlookup(h); if (!o) return -EBADF; if (HPROT(htab[h])) return -EACCES; htab[h] = hfreelist; hfreelist = h; if (--o->handle_count > 0) return 0; rc = close_object(o); if (o->lock_count == 0) destroy_object(o); return rc; }
TbBool remove_workshop_object_from_player(PlayerNumber owner, ThingModel objmodel) { struct Thing *cratetng; struct Room *room; cratetng = get_workshop_box_thing(owner, objmodel); if (thing_is_invalid(cratetng)) { WARNLOG("Crate %s could not be found",object_code_name(objmodel)); return false; } room = get_room_thing_is_on(cratetng); if (room_exists(room)) { remove_workshop_object_from_workshop(room,cratetng); } else { WARNLOG("Crate thing index %d isn't placed existing room; removing anyway",(int)cratetng->index); } create_effect(&cratetng->mappos, imp_spangle_effects[cratetng->owner], cratetng->owner); destroy_object(cratetng); return true; }
void CTeleWhirlwindObject:: release () { if (!object ||object->getDestroy() ||!object->m_pPhysicsShell || !object->m_pPhysicsShell->isActive()) return; Fvector dir_inv; dir_inv.sub(object->Position(),m_telekinesis->Center()); float magnitude = dir_inv.magnitude(); // включить гравитацию //Fvector zer;zer.set(0,0,0); //object->m_pPhysicsShell->set_LinearVel(zer); object->m_pPhysicsShell->set_ApplyByGravity(TRUE); ///////////////////////////////////// float impulse=0.f; if(magnitude>0.2f) { dir_inv.mul(1.f/magnitude); impulse=throw_power/magnitude/magnitude; } else { dir_inv.random_dir(); impulse=throw_power*100.f; } ///////////////////////////////////////////////// bool b_destroyed=false; if(magnitude<2.f*object->Radius()) { b_destroyed=destroy_object(dir_inv,throw_power*100.f); } if(!b_destroyed)object->m_pPhysicsShell->applyImpulse(dir_inv,impulse); switch_state(TS_None); }
void destroy_player_assets(){ destroy_object(ski_player.actor); }
TbBool create_workshop_object_in_workshop_room(PlayerNumber plyr_idx, ThingClass tngclass, ThingModel tngmodel) { struct Coord3d pos; struct Thing *cratetng; struct Room *room; struct Dungeon *dungeon; SYNCDBG(7,"Making player %d new %s",(int)plyr_idx,thing_class_code_name(tngclass)); pos.x.val = 0; pos.y.val = 0; pos.z.val = 0; switch (tngclass) { case TCls_Trap: cratetng = create_object(&pos, trap_crate_object_model(tngmodel), plyr_idx, -1); break; case TCls_Door: cratetng = create_object(&pos, door_crate_object_model(tngmodel), plyr_idx, -1); break; default: cratetng = INVALID_THING; ERRORLOG("No known workshop crate can represent %s model %d",thing_class_code_name(tngclass),(int)tngmodel); break; } if (thing_is_invalid(cratetng)) { ERRORLOG("Could not create workshop crate thing for %s",thing_class_code_name(tngclass)); return false; } room = find_random_room_for_thing_with_spare_room_item_capacity(cratetng, plyr_idx, RoK_WORKSHOP, 0); if (room_is_invalid(room)) { ERRORLOG("No %s room found which would accept %s crate",room_code_name(RoK_WORKSHOP),thing_class_code_name(tngclass)); destroy_object(cratetng); return false; } if (!find_random_valid_position_for_thing_in_room_avoiding_object(cratetng, room, &pos)) { ERRORLOG("Could not find a place in %s index %d for the new %s crate", room_code_name(room->kind),(int)room->index,thing_class_code_name(tngclass)); destroy_object(cratetng); return false; } pos.z.val = get_thing_height_at(cratetng, &pos); move_thing_in_map(cratetng, &pos); if (!add_workshop_object_to_workshop(room, cratetng)) { ERRORLOG("Could not fit %s crate in %s index %d", thing_class_code_name(tngclass),room_code_name(room->kind),(int)room->index); destroy_object(cratetng); return false; } dungeon = get_players_num_dungeon(plyr_idx); switch (tngclass) { case TCls_Trap: if ((dungeon->trap_build_flags[tngmodel] & MnfBldF_Built) == 0) { event_create_event(cratetng->mappos.x.val, cratetng->mappos.y.val, EvKind_NewTrap, plyr_idx, tngmodel); } break; case TCls_Door: if ((dungeon->door_build_flags[tngmodel] & MnfBldF_Built) == 0) { event_create_event(cratetng->mappos.x.val, cratetng->mappos.y.val, EvKind_NewDoor, plyr_idx, tngmodel); } break; default: break; } create_effect(&pos, TngEff_Unknown56, cratetng->owner); thing_play_sample(cratetng, 89, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS); return true; }