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

Function AddBlinkingHUDMessage

Descent3/hudmessage.cpp:638–682  ·  view source on GitHub ↗

Adds a blinking message to the HUD message list. If the list is already full, punt the top one and move the others up Returns true if message added, or false if message not (because the previous message was the same)

Source from the content-addressed store, hash-verified

636// top one and move the others up
637// Returns true if message added, or false if message not (because the previous message was the same)
638bool AddBlinkingHUDMessage(const char *format, ...) {
639 std::va_list args;
640 char *message = NULL;
641 char *last_message = NULL;
642 char temp_message[HUD_MESSAGE_LENGTH * 2];
643
644 va_start(args, format);
645 std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args);
646 va_end(args);
647
648 if (Demo_flags == DF_RECORDING) {
649 DemoWriteHudMessage(0, true, temp_message);
650 }
651
652 CorrectHudMessage(temp_message);
653
654 if (Num_hud_messages > 0 && !strcmp(temp_message, HUD_messages[Num_hud_messages - 1]))
655 return 0; // this is the same message as before, don't print it twice!
656
657 if (Num_hud_messages == MAX_HUD_MESSAGES) {
658 // Get rid of top message
659
660 for (int i = 1; i < MAX_HUD_MESSAGES; i++) {
661 strcpy(HUD_messages[i - 1], HUD_messages[i]);
662 HUD_message_type[i - 1] = HUD_message_type[i];
663 }
664
665 Num_hud_messages--;
666
667 Hud_scroll_offset = 0;
668
669 if (!Hud_messages_paused)
670 Hud_timer = Gametime;
671 }
672
673 if (Num_hud_messages == 0 && !Hud_messages_paused)
674 Hud_timer = Gametime;
675
676 strcpy(HUD_messages[Num_hud_messages], temp_message);
677 HUD_message_type[Num_hud_messages] = HUD_MESSAGE_BLINKING;
678
679 Num_hud_messages++;
680
681 return 1;
682}
683
684// This function takes a HUD messages, ensures it isn't too long, and if it is, it correctly fixes it
685void CorrectHudMessage(char *str) {

Callers 4

MultiDoChangeRankFunction · 0.85
DemoToggleRecordingFunction · 0.85
DemoReadHudMessageFunction · 0.85
Cinematic_StartCineFunction · 0.85

Calls 2

DemoWriteHudMessageFunction · 0.85
CorrectHudMessageFunction · 0.85

Tested by

no test coverage detected