1 // ------------------------------------------------------------------
3 // System for handling level backgrounds
4 // ------------------------------------------------------------------
5 // By Kronoman - In loving memory of my father
6 // Copyright (c) 2004, Kronoman
7 // ------------------------------------------------------------------
13 CBackground::CBackground()
21 CBackground::~CBackground()
25 if (bmp_default
!= NULL
)
26 destroy_bitmap(bmp_default
);
29 BITMAP
*CBackground::get_background(char *filename
, int index
)
32 DATAFILE
*data
= NULL
;
33 char tmp_file_buf
[2048];
35 where_is_the_filename(tmp_file_buf
, filename
);
37 // use the cache if it is present
38 if (index
== index_loaded
)
40 if (ustrcmp(tmp_file_buf
, file_loaded
) == 0)
46 usprintf(str
, "B%d_BMP", index
);
47 data
= load_datafile_object(tmp_file_buf
, str
);
51 usprintf(file_loaded
, "%s", tmp_file_buf
);
55 bmp_in_ram
= (BITMAP
*)data
->dat
;
63 void CBackground::free_memory()
65 if (data_loaded
!= NULL
)
66 unload_datafile_object(data_loaded
);
72 if (bmp_default
!= NULL
)
73 destroy_bitmap(bmp_default
);
75 bmp_default
= create_bitmap(16, 16);
77 if (bmp_default
== NULL
)
78 raise_error("* FATAL ERROR * \nCBackgrounds::free_memory()\n\tCan't create default bitmap!");
82 file_loaded
[0] = '\0';