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

Function VisEffectCreate

Descent3/viseffect.cpp:567–627  ·  view source on GitHub ↗

initialize a new viseffect. adds to the list for the given room returns the vis number

Source from the content-addressed store, hash-verified

565// initialize a new viseffect. adds to the list for the given room
566// returns the vis number
567int VisEffectCreate(uint8_t type, uint8_t id, int roomnum, vector *pos) {
568 int visnum;
569 vis_effect *vis;
570
571 if ((Game_mode & GM_MULTI) && Dedicated_server)
572 return -1; // Dedicated servers don't need to create vis effects
573
574 if (ROOMNUM_OUTSIDE(roomnum)) {
575 if (CELLNUM(roomnum) > TERRAIN_WIDTH * TERRAIN_DEPTH)
576 return -1;
577 if (CELLNUM(roomnum) < 0)
578 return -1;
579
580 if (Gametime - Last_terrain_render_time > 5.0)
581 return -1;
582 } else {
583 ASSERT(roomnum >= 0 && roomnum <= Highest_room_index && Rooms[roomnum].used);
584
585 // Don't create viseffects in rooms we haven't seen in a while
586 if (Gametime - Rooms[roomnum].last_render_time > 5.0)
587 return -1;
588 }
589
590 // Find next free object
591 visnum = VisEffectAllocate();
592
593 if (visnum == -1) // no free objects
594 return -1;
595
596 ASSERT(VisEffects[visnum].type == VIS_NONE); // make sure unused
597
598 vis = &VisEffects[visnum];
599
600 ASSERT(vis->roomnum == -1);
601
602 memset(vis, 0, sizeof(vis_effect));
603
604 // Fill in fields
605 vis->type = VIS_FIREBALL;
606 vis->id = id;
607 vis->pos = *pos;
608 vis->flags = 0;
609 vis->phys_flags = 0;
610 vis->roomnum = roomnum;
611 vis->movement_type = MT_NONE;
612 vis->attach_info.end_vertnum = -1;
613 vis->next = -1;
614 vis->prev = -1;
615 vis->lighting_color = 0;
616
617 ASSERT(roomnum != -1);
618
619 vis->creation_time = Gametime;
620
621 // Initialize all the type-specific info
622 VisEffectInitType(vis);
623
624 VisEffectLink(visnum, roomnum);

Callers 15

DoWallEffectsFunction · 0.85
msafe_CallFunctionFunction · 0.85
DrawPowerupSparklesFunction · 0.85
DrawVirusLightningFunction · 0.85
MultiAnnounceEffectFunction · 0.85
CreateFireballFunction · 0.85
CreateElectricalBoltsFunction · 0.85
DoGravityFieldEffectFunction · 0.85
DoRainEffectFunction · 0.85
DoSnowEffectFunction · 0.85
WeaponDoFrameFunction · 0.85

Calls 3

VisEffectAllocateFunction · 0.85
VisEffectInitTypeFunction · 0.85
VisEffectLinkFunction · 0.85

Tested by

no test coverage detected