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

Function InitVisEffects

Descent3/viseffect.cpp:489–517  ·  view source on GitHub ↗

Goes through our array and clears the slots out

Source from the content-addressed store, hash-verified

487
488// Goes through our array and clears the slots out
489void InitVisEffects() {
490 static uint16_t old_max_vis = 0;
491 max_vis_effects = MAX_VIS_EFFECTS; // always peg to max on PC
492
493 if (old_max_vis == max_vis_effects)
494 return;
495
496 if (VisEffects != NULL) {
497 VisEffects = (vis_effect *)mem_realloc(VisEffects, sizeof(vis_effect) * max_vis_effects);
498 VisDeadList = (uint16_t *)mem_realloc(VisDeadList, sizeof(uint16_t) * max_vis_effects);
499 Vis_free_list = (int16_t *)mem_realloc(Vis_free_list, sizeof(int16_t) * max_vis_effects);
500 } else if (VisEffects == NULL) {
501 VisEffects = (vis_effect *)mem_malloc(sizeof(vis_effect) * max_vis_effects);
502 VisDeadList = (uint16_t *)mem_malloc(sizeof(uint16_t) * max_vis_effects);
503 Vis_free_list = (int16_t *)mem_malloc(sizeof(int16_t) * max_vis_effects);
504 }
505 for (int i = 0; i < max_vis_effects; i++) {
506 VisEffects[i].type = VIS_NONE;
507 VisEffects[i].roomnum = -1;
508 VisEffects[i].prev = -1;
509 VisEffects[i].next = -1;
510 Vis_free_list[i] = i;
511 }
512 old_max_vis = max_vis_effects;
513 Num_vis_effects = 0;
514 Highest_vis_effect_index = 0;
515
516 atexit(ShutdownVisEffects);
517}
518
519// Returns the next free viseffect
520int VisEffectAllocate() {

Callers 1

InitObjectsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected