Home | History | Annotate | Line # | Download | only in warp
object.c revision 1.1
      1 /* $Header: /tank/opengrok/rsync2/NetBSD/src/games/warp/object.c,v 1.1 2020/11/09 23:37:05 kamil Exp $ */
      2 
      3 /* $Log: object.c,v $
      4 /* Revision 1.1  2020/11/09 23:37:05  kamil
      5 /* Add Warp Kit, Version 7.0 by Larry Wall
      6 /*
      7 /* Warp is a real-time space war game that doesn't get boring very quickly.
      8 /* Read warp.doc and the manual page for more information.
      9 /*
     10 /* games/warp originally distributed with 4.3BSD-Reno, is back to the BSD
     11 /* world via NetBSD. Its remnants were still mentioned in games/Makefile.
     12 /*
     13 /* Larry Wall, the original author and the copyright holder, generously
     14 /* donated the game and copyright to The NetBSD Foundation, Inc.
     15 /*
     16 /* Import the game sources as-is from 4.3BSD-Reno, with the cession
     17 /* of the copyright and license to BSD-2-clause NetBSD-style.
     18 /*
     19 /* Signed-off-by: Larry Wall <larry (at) wall.org>
     20 /* Signed-off-by: Kamil Rytarowski <kamil (at) netbsd.org>
     21 /*
     22  * Revision 7.0  86/10/08  15:12:55  lwall
     23  * Split into separate files.  Added amoebas and pirates.
     24  *
     25  */
     26 
     27 #include "EXTERN.h"
     28 #include "warp.h"
     29 #include "INTERN.h"
     30 #include "object.h"
     31 
     32 void
     33 object_init()
     34 {
     35     ;
     36 }
     37 
     38 OBJECT *
     39 make_object(typ, img, py, px, vy, vx, energ, mas, where)
     40 char typ;
     41 char img;
     42 int px, py, vx, vy;
     43 long energ, mas;
     44 OBJECT *where;
     45 {
     46     Reg1 OBJECT *obj;
     47 
     48     if (free_root.next == &free_root)
     49 #ifndef lint
     50 	obj = (OBJECT *) malloc(sizeof root);
     51 #else
     52 	obj = Null(OBJECT*);
     53 #endif
     54     else {
     55 	obj = free_root.next;
     56 	free_root.next = obj->next;
     57 	obj->next->prev = &free_root;
     58     }
     59     obj->type = typ;
     60     obj->image = img;
     61     obj->next = where;
     62     obj->prev = where->prev;
     63     where->prev = obj;
     64     obj->prev->next = obj;
     65     obj->velx = vx;
     66     obj->vely = vy;
     67     obj->contend = 0;
     68     obj->strategy = 0;
     69     obj->flags = 0;
     70     obj->posx = px;
     71     obj->posy = py;
     72     if (typ != Torp && typ != Web) {
     73 	occupant[py][px] = obj;
     74     }
     75     obj->energy = energ;
     76     obj->mass = mas;
     77     return(obj);
     78 }
     79 
     80 void
     81 unmake_object(curobj)
     82 Reg1 OBJECT *curobj;
     83 {
     84     curobj->prev->next = curobj->next;
     85     curobj->next->prev = curobj->prev;
     86     if (curobj == movers) {
     87 	movers = curobj->next;
     88     }
     89     free_object(curobj);
     90 }
     91 
     92 void
     93 free_object(curobj)
     94 Reg1 OBJECT *curobj;
     95 {
     96     curobj->next = free_root.next;
     97     curobj->prev = &free_root;
     98     free_root.next->prev = curobj;
     99     free_root.next = curobj;
    100 }
    101