Ignore:
Timestamp:
Apr 17, 2011, 10:28:48 AM (11 years ago)
Author:
Sam Hocevar
Message:

lisp: miscellaneous work on type safety.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/objects.cpp

    r490 r491  
    483483  if (d)
    484484  {
    485     void    *am, *frm, *hx, *hy, *px, *py;
    486     game_object *o=current_object;
    487     current_object=this;
    488 
    489     void *m=mark_heap(TMP_SPACE);
    490 
    491     am=new_cons_cell();
    492     l_ptr_stack.push(&am);
    493 
    494     ((LispList *)am)->car=LispNumber::Create(amount);
    495 
    496     frm=new_cons_cell();
    497     l_ptr_stack.push(&frm);
    498 
    499     ((LispList *)frm)->car=new_lisp_pointer(from);
    500 
    501     hx=new_cons_cell();
    502     l_ptr_stack.push(&hx);
    503 
    504     ((LispList *)hx)->car=LispNumber::Create(hitx);
    505 
    506     hy=new_cons_cell();
    507     l_ptr_stack.push(&hy);
    508     ((LispList *)hy)->car=LispNumber::Create(hity);
    509 
    510     px=new_cons_cell();
    511     l_ptr_stack.push(&px);
    512     ((LispList *)px)->car=LispNumber::Create(push_xvel);
    513 
    514     py=new_cons_cell();
    515     l_ptr_stack.push(&py);
    516     ((LispList *)py)->car=LispNumber::Create(push_yvel);
    517 
    518 
    519     ((LispList *)am)->cdr = (LispObject *)frm;
    520     ((LispList *)frm)->cdr = (LispObject *)hx;
    521     ((LispList *)hx)->cdr = (LispObject *)hy;
    522     ((LispList *)hy)->cdr = (LispObject *)px;
    523     ((LispList *)px)->cdr = (LispObject *)py;
    524 
    525     time_marker *prof1=NULL;
     485    LispList *am, *frm, *hx, *hy, *px, *py;
     486    game_object *o = current_object;
     487    current_object = this;
     488
     489    void *m = mark_heap(TMP_SPACE);
     490
     491    am = LispList::Create();
     492    PtrRef r1(am);
     493    am->car = LispNumber::Create(amount);
     494
     495    frm = LispList::Create();
     496    PtrRef r2(frm);
     497    frm->car = new_lisp_pointer(from);
     498
     499    hx = LispList::Create();
     500    PtrRef r3(hx);
     501    hx->car = LispNumber::Create(hitx);
     502
     503    hy = LispList::Create();
     504    PtrRef r4(hy);
     505    hy->car = LispNumber::Create(hity);
     506
     507    px = LispList::Create();
     508    PtrRef r5(px);
     509    px->car = LispNumber::Create(push_xvel);
     510
     511    py = LispList::Create();
     512    PtrRef r6(py);
     513    py->car = LispNumber::Create(push_yvel);
     514
     515    px->cdr = py;
     516    hy->cdr = px;
     517    hx->cdr = hy;
     518    frm->cdr = hx;
     519    am->cdr = frm;
     520
     521    time_marker *prof1 = NULL;
    526522    if (profiling())
    527       prof1=new time_marker;
    528 
    529     eval_user_fun((LispSymbol *)d,am);
     523      prof1 = new time_marker;
     524
     525    eval_user_fun((LispSymbol *)d, am);
    530526    if (profiling())
    531527    {
    532528      time_marker now;
    533       profile_add_time(this->otype,now.diff_time(prof1));
     529      profile_add_time(this->otype, now.diff_time(prof1));
    534530      delete prof1;
    535531    }
    536532
    537 
    538     l_ptr_stack.pop(6);
    539 
    540     restore_heap(m,TMP_SPACE);
    541 
    542     current_object=o;
     533    restore_heap(m, TMP_SPACE);
     534
     535    current_object = o;
    543536  } else damage_fun(amount,from,hitx,hity,push_xvel,push_yvel);
    544537#ifdef SCADALISP
     
    902895
    903896      void *rlist=NULL;   // return list
    904       p_ref r1(rlist);
     897      PtrRef r1(rlist);
    905898
    906899      if (hit_object)
     
    12141207  if (figures[otype]->get_fun(OFUN_MOVER))      // is a lisp move function defined?
    12151208  {
    1216     void *lcx,*lcy,*lb;
     1209    LispList *lcx, *lcy, *lb;
    12171210
    12181211    game_object *o=current_object;
    12191212    current_object=this;
    12201213
    1221 
    12221214    // make a list of the parameters, and call the lisp function
    1223     lcx=new_cons_cell();
    1224     l_ptr_stack.push(&lcx);
    1225     ((LispList *)lcx)->car=LispNumber::Create(cx);
    1226 
    1227     lcy=new_cons_cell();
    1228     l_ptr_stack.push(&lcy);
    1229     ((LispList *)lcy)->car=LispNumber::Create(cy);
    1230 
    1231     lb=new_cons_cell();
    1232     l_ptr_stack.push(&lb);
    1233     ((LispList *)lb)->car=LispNumber::Create(button);
    1234 
    1235 
    1236     ((LispList *)lcx)->cdr = (LispObject *)lcy;
    1237     ((LispList *)lcy)->cdr = (LispObject *)lb;
    1238 
    1239     void *m=mark_heap(TMP_SPACE);
    1240 
    1241     time_marker *prof1=NULL;
     1215    lcx = LispList::Create();
     1216    PtrRef r1(lcx);
     1217    lcx->car = LispNumber::Create(cx);
     1218
     1219    lcy = LispList::Create();
     1220    PtrRef r2(lcy);
     1221    lcy->car = LispNumber::Create(cy);
     1222
     1223    lb = LispList::Create();
     1224    PtrRef r3(lb);
     1225    lb->car = LispNumber::Create(button);
     1226
     1227    lcx->cdr = lcy;
     1228    lcy->cdr = lb;
     1229
     1230    void *m = mark_heap(TMP_SPACE);
     1231
     1232    time_marker *prof1 = NULL;
    12421233    if (profiling())
    12431234      prof1=new time_marker;
     
    12541245    restore_heap(m,TMP_SPACE);
    12551246
    1256     l_ptr_stack.pop(3);
    12571247    if (item_type(r)!=L_NUMBER)
    12581248    {
    12591249      lprint(r);
    1260       lbreak("Object %s did not return a number from it's mover function!\n"
    1261          "It should return a number to indicate it's blocked status to the\n"
    1262          "ai function.",object_names[otype]);   
    1263     }
    1264     ret|=lnumber_value(r);
    1265     current_object=o;
    1266   }
    1267   else ret|=mover(cx,cy,button);
     1250      lbreak("Object %s did not return a number from its mover function!\n"
     1251         "It should return a number to indicate its blocked status to the\n"
     1252         "ai function.", object_names[otype]);
     1253    }
     1254    ret |= lnumber_value(r);
     1255    current_object = o;
     1256  }
     1257  else ret |= mover(cx, cy, button);
    12681258
    12691259  return ret;
Note: See TracChangeset for help on using the changeset viewer.