Beispiel #1
0
/* freeObject
   Frees an object, removing it from the object container.
*/
void
freeObject(Object *obj)
{
  extern ObjContainer the_objects;
  Bound *b;

  /* Free the object's boundaries */
  b = obj->bounds;
  while (b != NULL)
    {
      Bound *next_bound = b->next;
      free(b);
      b = next_bound;
    }

  /* Flush the signal queue */
  sig_flush(&obj->signals);

  /* The object has its own function for freeing attributes because within
     the atts structure, it may have allocated additional memory: */
  obj->free_atts(obj);

  removeObj(obj);
  free(obj);

  obj = NULL;
}
Beispiel #2
0
void CallbackQueue::removeSessionCb(LsiSession *pSession,
                                    CBQSessionHeader &header)
{
    CallbackLinkedObj *pObj = header.get();
    CallbackLinkedObj *pObjNext;

    logState("removeSessionCb()][header state", pObj);
    while (pObj && pObj != (CallbackLinkedObj *)m_callbackObjList.end())
    {
        pObjNext = (CallbackLinkedObj *)pObj->next();
        if (pObj->m_pSession == pSession)
            removeObj(pObj);
        else
            break;
        pObj = pObjNext;
    }
    header.set(NULL);
}
Beispiel #3
0
void EvtcbQue::removeSessionCb(evtcbhead_t *session)
{
    if (m_callbackObjList.size() == 0)
    {
        session->evtcb_head = NULL;
        return;
    }

    evtcbnode_s *pObj = session->evtcb_head;
    evtcbnode_s *pObjNext;

    logState("removeSessionCb()][header state", pObj);
    while (pObj && pObj != (evtcbnode_s *)m_callbackObjList.end())
    {
        pObjNext = (evtcbnode_s *)pObj->next();
        if (pObj->m_pSession == session)
            removeObj(pObj);
        else
            break;
        pObj = pObjNext;
    }
    session->evtcb_head = NULL;
}
Beispiel #4
0
/* obj_setObjPos
   sets the position of an object, making sure it is in the appropriate sector
*/
void
obj_setObjPos(Object *object_ptr, Point new_pos)
{
  /* Move it if the sector has changed: */
  if (obj_realToSectorX(new_pos.x) != obj_realToSectorX(object_ptr->pos.x)
      || obj_realToSectorY(new_pos.y) != obj_realToSectorY(object_ptr->pos.y))
    {
      
      /* Remove the object from its current sector: */
      removeObj(object_ptr);
      
      /* Actually update the position: */
      object_ptr->pos = new_pos;
      
      /* Insert the object into its new sector: */
      insertObj(object_ptr);
    }
  /* If it hasn't changed sectors just update the position: */
  else
    {
      object_ptr->pos = new_pos;
    }

}