source: abuse/trunk/src/extend.cpp @ 18

Last change on this file since 18 was 17, checked in by Sam Hocevar, 17 years ago
  • absolute shitloads of 64 bit fixes.
File size: 2.6 KB
Line 
1/*
2
3
4
5  Simple object             (power ups, non-moving objects)
6    int32_t x,y;
7    int8_t direction;
8    uint16_t otype,state
9    uint16_t current_frame;
10    extension *
11
12
13  Moving object             (simple lisp controlled characters)
14     uint8_t flags;
15     int32_t xvel,yvel,xacel,yacel;
16     uint8_t fx,fy,fxvel,fyvel,fxacel,fyacel,aitype;
17     uint16_t aistate,aistate_time;
18     uint16_t hp,mp,
19     extension *
20
21
22  Complex objects          (can controll lights, other characters, and have a neural net ai)
23    uint8_t tobjs,tlights;
24    object_list *                       
25    light_list *
26    nnet_info *
27    int8_t fade_dir, frame_dir;       
28    uint8_t fade_count,fade_max;
29    morph_char *morph_status;
30
31
32*/
33#include "extend.hpp"
34#include "view.hpp"
35#include "objects.hpp"
36#include "lisp.hpp"
37
38
39void simple_object::add_light(light_source *ls)
40{
41  if (!ls) return ;
42  ls->known=1;
43  for (int i=0;i<tlights;i++) if (lights[i]==ls) return;
44  tlights++;
45  lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"Light list");
46  lights[tlights-1]=ls;
47}
48
49void simple_object::add_object(game_object *o)
50{
51  if (!o) return ;
52  for (int i=0;i<tobjs;i++) if (objs[i]==o) return;
53  o->set_flags(o->flags()|KNOWN_FLAG);
54  tobjs++;
55  objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"Object list");
56  objs[tobjs-1]=o;
57}
58
59
60void simple_object::remove_light(light_source *ls)
61{
62  for (int i=0;i<tlights;i++)
63  {
64    if (lights[i]==ls)
65    {
66      tlights--;
67      for (int j=i;j<tlights;j++)     // don't even think about it :)
68        lights[j]=lights[j+1];
69      lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"object's lights");
70      return ;
71    }
72  }
73}
74
75void simple_object::remove_object(game_object *o)
76{
77  for (int i=0;i<tobjs;i++)
78  {
79    if (objs[i]==o)
80    {
81      tobjs--;
82      for (int j=i;j<tobjs;j++)     // don't even think about it :)
83        objs[j]=objs[j+1];
84      objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"object's lights");
85      return ;
86    }
87  }
88}
89
90
91simple_object::simple_object()
92{
93 
94  x=y=0;
95  direction=1;
96  otype=0;
97  state=stopped;
98  current_frame=0;
99
100  Fade_dir=0;
101  Fade_count=0;
102  Fade_max=16;
103
104
105  tobjs=tlights=0;
106  objs=NULL;
107  lights=NULL;
108  Frame_dir=1;
109  mc=NULL;
110  Controller=NULL;
111
112  Flags=0;
113  Xvel=Yvel=Xacel=Yacel=0;
114  Fx=Fy=Fxvel=Fyvel=Fxacel=Fyacel=Aitype=0;
115  Aistate=Aistate_time=0;
116  Hp=Mp=Fmp=0;
117  grav_on=1;
118  targetable_on=1;
119}
120
121
122
123void simple_object::set_morph_status(morph_char *Mc)
124{
125  mc=Mc;
126}
127
128void simple_object::clean_up()
129{
130  if (tlights) jfree(lights);
131  if (tobjs)   jfree(objs);
132  if (Controller)
133    Controller->focus=NULL;
134}
135
136
137simple_object default_simple;
138
139
Note: See TracBrowser for help on using the repository browser.