Example #1
0
void CacheList::preload_cache_object(int type)
{
  if (type<0xffff)
  {
    if (!figures[type]->get_cflag(CFLAG_NEED_CACHE_IN))  // see if it's already marked
    {
      figures[type]->set_cflag(CFLAG_NEED_CACHE_IN,1);
      void *cache_fun=figures[type]->get_fun(OFUN_GET_CACHE_LIST);

      if (cache_fun)
      {
    LSpace *sp = LSpace::Current;
    LSpace::Current = &LSpace::Perm;

    void *call_with=NULL;
    push_onto_list(LNumber::Create(type),call_with);

    void *CacheList = ((LSymbol *)cache_fun)->EvalFunction(call_with);
    PtrRef r1(CacheList);

    if (CacheList && lcar(CacheList))
    {
      void *obj_list=lcar(CacheList);
      while (obj_list)
      {
        int t=lnumber_value(CAR(obj_list));
        if (t<0 || t>=total_objects)
          lbreak("Get cache list returned a bad object number %d\n",t);
        else
          preload_cache_object(t);
        obj_list=CDR(obj_list);
      }
    }
    if (CacheList && lcdr(CacheList))
    {
      void *id_list=lcar(lcdr(CacheList));
      while (id_list)
      {
        int id=lnumber_value(CAR(id_list));
        if (id<0 || id>=total)
          lbreak("Get cache list returned a bad id number %d\n",id);
        else if (list[id].last_access<0)
          list[id].last_access=-2;
        else list[id].last_access=2;

        id_list=CDR(id_list);
      }
    }
    LSpace::Current=sp;

      }
    }
  }
}
Example #2
0
static void fire_at_player(game_object *o, game_object *b)
{
  int32_t firex=o->x+(o->direction>0?15:-15),firey=o->y-15,
          playerx=b->x+b->xvel()*8,playery=b->y-15+b->yvel()*2;
  if (can_see(o,o->x,o->y,firex,firey) && can_see(o,firex,firey,playerx,playery))
  {
    int angle=lisp_atan2(firey-playery,playerx-firex);
    void *call_list=NULL;
    PtrRef r1(call_list);
    push_onto_list(LPointer::Create(b),call_list);
    push_onto_list(LNumber::Create(angle),call_list);
    push_onto_list(LNumber::Create(firey),call_list);
    push_onto_list(LNumber::Create(firex),call_list);
    push_onto_list(LNumber::Create(o->aitype()),call_list);
    push_onto_list(LPointer::Create(o),call_list);
    ((LSymbol *)l_fire_object)->EvalUserFunction((LList *)call_list);
    o->set_state((character_state)S_weapon_fire);
  }
}
Example #3
0
static void fire_at_player(game_object *o, game_object *b)
{
  long firex=o->x+(o->direction>0?15:-15),firey=o->y-15,
       playerx=b->x+b->xvel()*8,playery=b->y-15+b->yvel()*2;
  if (can_see(o,o->x,o->y,firex,firey) && can_see(o,firex,firey,playerx,playery))
  {
    int angle=lisp_atan2(firey-playery,playerx-firex);
    void *call_list=NULL;
    p_ref r1(call_list);
    push_onto_list(new_lisp_pointer(b),call_list);
    push_onto_list(new_lisp_number(angle),call_list);
    push_onto_list(new_lisp_number(firey),call_list);
    push_onto_list(new_lisp_number(firex),call_list);
    push_onto_list(new_lisp_number(o->aitype()),call_list);
    push_onto_list(new_lisp_pointer(o),call_list);
    eval_user_fun((lisp_symbol *)l_fire_object,call_list);
    o->set_state((character_state)S_weapon_fire);
  }
}