The main entry point for all the multisafe functions Pass the type of function you want, and then fill in the relevant fields of the mstruct
| 1299 | // Pass the type of function you want, and then fill in the relevant fields |
| 1300 | // of the mstruct |
| 1301 | void msafe_CallFunction(uint8_t type, msafe_struct *mstruct) { |
| 1302 | if ((Demo_flags == DF_PLAYBACK) && (!Demo_call_ok)) |
| 1303 | return; |
| 1304 | uint8_t send_it = 1; |
| 1305 | switch (type) { |
| 1306 | case MSAFE_WEATHER_RAIN: |
| 1307 | SetRainState(mstruct->state, mstruct->scalar); |
| 1308 | break; |
| 1309 | case MSAFE_WEATHER_SNOW: |
| 1310 | SetSnowState(mstruct->state, mstruct->scalar); |
| 1311 | break; |
| 1312 | case MSAFE_WEATHER_LIGHTNING: |
| 1313 | SetLightningState(mstruct->state, mstruct->scalar, mstruct->randval); |
| 1314 | break; |
| 1315 | case MSAFE_WEATHER_LIGHTNING_BOLT: { |
| 1316 | if (mstruct->texnum == -1) { |
| 1317 | mprintf(0, "Failing bolt because texnum is -1\n"); |
| 1318 | return; |
| 1319 | } |
| 1320 | |
| 1321 | if (mstruct->flags) { |
| 1322 | if (!VALIDATE_OBJECT(mstruct->objhandle)) |
| 1323 | return; |
| 1324 | } else { |
| 1325 | if (!VALIDATE_OBJECT(mstruct->objhandle)) |
| 1326 | return; |
| 1327 | if (!VALIDATE_OBJECT(mstruct->ithandle)) |
| 1328 | return; |
| 1329 | } |
| 1330 | int visnum = VisEffectCreate(VIS_FIREBALL, THICK_LIGHTNING_INDEX, mstruct->roomnum, &mstruct->pos); |
| 1331 | if (visnum >= 0) { |
| 1332 | vis_effect *vis = &VisEffects[visnum]; |
| 1333 | vis->lifeleft = mstruct->lifetime; |
| 1334 | vis->lifetime = mstruct->lifetime; |
| 1335 | vis->end_pos = mstruct->pos2; |
| 1336 | |
| 1337 | vis->custom_handle = mstruct->texnum; |
| 1338 | |
| 1339 | vis->lighting_color = mstruct->color; |
| 1340 | vis->billboard_info.width = mstruct->size; |
| 1341 | vis->billboard_info.texture = mstruct->state; |
| 1342 | vis->velocity.x = mstruct->count; |
| 1343 | vis->velocity.y = mstruct->interval; |
| 1344 | vis->velocity.z = mstruct->index; |
| 1345 | |
| 1346 | vis->flags = VF_USES_LIFELEFT | VF_WINDSHIELD_EFFECT | VF_LINK_TO_VIEWER; |
| 1347 | vis->size = vm_VectorDistanceQuick(&vis->pos, &vis->end_pos); |
| 1348 | if (mstruct->flags) // Do attached lightning effect |
| 1349 | { |
| 1350 | vis->flags |= VF_ATTACHED; |
| 1351 | vis->attach_info.obj_handle = MOBJ->handle; |
| 1352 | vis->attach_info.modelnum = MOBJ->rtype.pobj_info.model_num; |
| 1353 | vis->attach_info.vertnum = mstruct->g1; |
| 1354 | vis->attach_info.end_vertnum = mstruct->g2; |
| 1355 | WeaponCalcGun(&vis->pos, NULL, MOBJ, vis->attach_info.vertnum); |
| 1356 | WeaponCalcGun(&vis->end_pos, NULL, MOBJ, vis->attach_info.end_vertnum); |
| 1357 | } else { |
| 1358 | vis->flags |= VF_ATTACHED | VF_PLANAR; |
no test coverage detected