MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SpewCreate

Function SpewCreate

Descent3/spew.cpp:169–263  ·  view source on GitHub ↗

Creates a Spew effect spew -> Pointer to spewinfo structure (that is filled out)...may be deleted after function call returns a handle to the spew effect

Source from the content-addressed store, hash-verified

167// spew -> Pointer to spewinfo structure (that is filled out)...may be deleted after function call
168// returns a handle to the spew effect
169int SpewCreate(spewinfo *spew) {
170 int count;
171 spewinfo *veffect;
172
173 ASSERT(spew);
174
175 if (spew->drag < 0)
176 spew->drag = 0;
177 if (spew->effect_type < 0 || spew->effect_type >= NUM_FIREBALLS)
178 return -1;
179 if (spew->lifetime < 0)
180 spew->lifetime = 0;
181 if (spew->longevity < 0)
182 spew->longevity = 0;
183 if (spew->mass < 0)
184 spew->mass = 0;
185 if (spew->size < 1)
186 spew->size = 1;
187 if (spew->speed < 0)
188 spew->speed = 0;
189 if (spew->time_int <= 0)
190 spew->time_int = 0.001f;
191 if (spew->use_gunpoint) {
192 // make sure all the object data is valid
193 object *obj = ObjGet(spew->gp.obj_handle);
194 if (!obj)
195 return -1;
196
197 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
198 if (spew->gp.gunpoint < 0 || spew->gp.gunpoint >= pm->n_guns)
199 return -1;
200 }
201
202 for (count = 0; count < MAX_SPEW_EFFECTS; count++) {
203 if (SpewEffects[count].inuse == false) {
204 spew_count++;
205 // we found an open handle
206 veffect = &SpewEffects[count];
207
208 // fill in the info
209 veffect->inuse = true;
210 veffect->random = spew->random;
211 veffect->use_gunpoint = spew->use_gunpoint;
212 veffect->real_obj = spew->real_obj;
213 veffect->flags = 0;
214
215 if (veffect->use_gunpoint) {
216 veffect->gp.obj_handle = spew->gp.obj_handle;
217
218 // WHAT IS THIS? it used to be "if(veffect->gp.obj_handle==NULL)"
219 if (veffect->gp.obj_handle == OBJECT_HANDLE_NONE) {
220 SpewClearEvent(count, false);
221 return -1;
222 }
223 veffect->gp.gunpoint = spew->gp.gunpoint;
224 veffect->flags |= SF_FORCEUPDATE; // force an update so it has some values
225
226 object *obj = ObjGet(spew->gp.obj_handle);

Callers 3

msafe_CallFunctionFunction · 0.85
MultiDoWorldStatesFunction · 0.85
CreateObjectSmokeSpewerFunction · 0.85

Calls 4

ObjGetFunction · 0.85
SpewClearEventFunction · 0.85
FORM_HANDLEFunction · 0.70

Tested by

no test coverage detected