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

Function InitHUDItem

Descent3/hud.cpp:798–899  ·  view source on GitHub ↗

initializes items based off their type (information, etc.)

Source from the content-addressed store, hash-verified

796
797// initializes items based off their type (information, etc.)
798void InitHUDItem(int new_item, tHUDItem *item) {
799 ASSERT(new_item < MAX_HUD_ITEMS);
800 uint16_t stat = 0x0000;
801
802 item->id = new_item;
803
804 switch (item->type) {
805 case HUD_ITEM_PRIMARY:
806 stat = STAT_PRIMARYLOAD;
807 break;
808
809 case HUD_ITEM_SECONDARY:
810 stat = STAT_SECONDARYLOAD;
811 break;
812
813 case HUD_ITEM_SHIELD:
814 stat = STAT_SHIELDS;
815 break;
816
817 case HUD_ITEM_ENERGY:
818 stat = STAT_ENERGY;
819 break;
820
821 case HUD_ITEM_AFTERBURNER:
822 stat = STAT_AFTERBURN;
823 break;
824
825 case HUD_ITEM_INVENTORY:
826 stat = STAT_INVENTORY;
827 break;
828
829 case HUD_ITEM_SHIPSTATUS:
830 stat = STAT_SHIP;
831 break;
832
833 case HUD_ITEM_CNTRMEASURE:
834 stat = STAT_CNTRMEASURE;
835 break;
836
837 case HUD_ITEM_CUSTOMTEXT:
838 if (item->data.text) {
839 char *text = mem_strdup(item->data.text);
840 HUD_array[new_item].data.text = text;
841 }
842 stat = STAT_CUSTOM;
843 break;
844
845 case HUD_ITEM_CUSTOMTEXT2: // malloc buffer to be updated later
846 HUD_array[new_item].data.text = (char *)mem_malloc(item->buffer_size);
847 HUD_array[new_item].data.text[0] = 0;
848 HUD_array[new_item].buffer_size = item->buffer_size;
849 stat = STAT_CUSTOM;
850 break;
851
852 case HUD_ITEM_CUSTOMIMAGE:
853 stat = STAT_CUSTOM;
854 break;
855

Callers 1

AddHUDItemFunction · 0.85

Calls 1

resetMethod · 0.45

Tested by

no test coverage detected