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

Function menutga_LoadHotSpotMap

Descent3/hotspotmap.cpp:670–801  ·  view source on GitHub ↗

Given a filename and a hotspotmap structure, it loads the hotspot map (.HSM)

Source from the content-addressed store, hash-verified

668
669// Given a filename and a hotspotmap structure, it loads the hotspot map (.HSM)
670void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hsmap, windowmap_t *wndmap) {
671 // start with a clean struct
672 if (hsmap->hs) {
673 FreeHotSpotMapInternals(hsmap);
674 }
675
676 mprintf(0, "Loading hotspotmap %s ", filename);
677
678 CFILE *infile;
679 infile = (CFILE *)cfopen(filename, "rb");
680 if (!infile) {
681 Int3(); // get Jeff
682 return;
683 }
684
685 hsmap->num_of_hotspots = cf_ReadByte(infile);
686
687 mprintf(0, "Contains: (%d hotspots) ", hsmap->num_of_hotspots);
688
689 int curr_hs, curr_sl, num_sl;
690
691 hsmap->hs = (hotspot *)mem_malloc(sizeof(hotspot) * hsmap->num_of_hotspots);
692 memset(hsmap->hs, 0, sizeof(hotspot) * hsmap->num_of_hotspots);
693 for (curr_hs = 0; curr_hs < hsmap->num_of_hotspots; curr_hs++) {
694 hsmap->hs[curr_hs].starting_y = cf_ReadInt(infile);
695 num_sl = hsmap->hs[curr_hs].scanlines = cf_ReadInt(infile);
696 if (num_sl) {
697 hsmap->hs[curr_hs].x = (scanline *)mem_malloc(sizeof(scanline) * hsmap->hs[curr_hs].scanlines);
698 memset(hsmap->hs[curr_hs].x, 0, sizeof(scanline) * hsmap->hs[curr_hs].scanlines);
699 for (curr_sl = 0; curr_sl < hsmap->hs[curr_hs].scanlines; curr_sl++) {
700 hsmap->hs[curr_hs].x[curr_sl].start = cf_ReadInt(infile);
701 hsmap->hs[curr_hs].x[curr_sl].end = cf_ReadInt(infile);
702 }
703 } else {
704 hsmap->hs[curr_hs].x = NULL;
705 }
706 }
707
708 int count, index, size;
709 wndmap->num_of_windows = cf_ReadInt(infile);
710 mprintf(0, "(%d Windows)\n", wndmap->num_of_windows);
711 wndmap->wm = (window_box *)mem_malloc(sizeof(window_box) * wndmap->num_of_windows);
712 for (count = 0; count < wndmap->num_of_windows; count++) {
713 wndmap->wm[count].x = cf_ReadInt(infile);
714 wndmap->wm[count].y = cf_ReadInt(infile);
715 wndmap->wm[count].width = cf_ReadInt(infile);
716 wndmap->wm[count].height = cf_ReadInt(infile);
717 wndmap->wm[count].l_start_x = cf_ReadInt(infile);
718 wndmap->wm[count].l_end_x = cf_ReadInt(infile);
719 wndmap->wm[count].r_start_x = cf_ReadInt(infile);
720 wndmap->wm[count].r_end_x = cf_ReadInt(infile);
721 wndmap->wm[count].t_top_y = cf_ReadInt(infile);
722 wndmap->wm[count].t_bottom_y = cf_ReadInt(infile);
723 wndmap->wm[count].b_top_y = cf_ReadInt(infile);
724 wndmap->wm[count].b_bottom_y = cf_ReadInt(infile);
725
726 if (wndmap->wm[count].t_top_y != -1) {
727 // left top

Callers 3

CBriefEditMethod · 0.85
TelComShowFunction · 0.85
LoadTelcomBitmapFunction · 0.85

Calls 7

FreeHotSpotMapInternalsFunction · 0.85
cfopenFunction · 0.85
cf_ReadByteFunction · 0.85
cf_ReadIntFunction · 0.85
cfcloseFunction · 0.85
bm_AllocBitmapFunction · 0.85
makecornerFunction · 0.85

Tested by

no test coverage detected