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

Function PageInVClip

Descent3/vclip.cpp:283–404  ·  view source on GitHub ↗

Pages in a vclip if it needs to be

Source from the content-addressed store, hash-verified

281extern int Low_vidmem;
282// Pages in a vclip if it needs to be
283void PageInVClip(int vcnum) {
284 ASSERT(GameVClips[vcnum].used);
285 if (!(GameVClips[vcnum].flags & VCF_NOT_RESIDENT))
286 return;
287
288 int mipped = 0;
289 int texture_size = GameVClips[vcnum].target_size;
290 vclip *vc = &GameVClips[vcnum];
291 if (vc->flags & VCF_WANTS_MIPPED)
292 mipped = 1;
293
294 CFILE *infile = (CFILE *)cfopen(vc->name, "rb");
295 if (!infile) {
296 // due to a bug in some 3rd party tablefile editors, full paths might
297 // have been used when they shouldn't have been
298 char *end_ptr, *start_ptr;
299 start_ptr = vc->name;
300 end_ptr = start_ptr + strlen(start_ptr) - 1;
301 while ((end_ptr >= start_ptr) && (*end_ptr != '\\'))
302 end_ptr--;
303 if (end_ptr < start_ptr) {
304 mprintf(0, "Couldn't load vclip %s!\n", vc->name);
305 return;
306 }
307
308 ASSERT(*end_ptr == '\\');
309 end_ptr++;
310
311 infile = (CFILE *)cfopen(end_ptr, "rb");
312 if (!infile) {
313 mprintf(0, "Couldn't load vclip %s!\n", vc->name);
314 return;
315 }
316 }
317
318 mprintf(0, "Paging in vclip %s!\n", vc->name);
319
320 uint8_t start_val = cf_ReadByte(infile);
321 int version = 0;
322 if (start_val != 127) {
323 version = 0;
324 vc->num_frames = start_val;
325 cf_ReadFloat(infile);
326 vc->frame_time = cf_ReadFloat(infile);
327 cf_ReadInt(infile);
328 cf_ReadFloat(infile);
329 vc->frame_time = DEFAULT_FRAMETIME;
330 } else {
331 version = cf_ReadByte(infile);
332 vc->num_frames = cf_ReadByte(infile);
333 vc->frame_time = cf_ReadFloat(infile);
334 vc->frame_time = DEFAULT_FRAMETIME;
335 }
336
337 for (int i = 0; i < vc->num_frames; i++) {
338 int n = bm_AllocLoadBitmap(infile, mipped);
339
340 ASSERT(n > 0);

Callers 12

ObjInitWeaponFunction · 0.85
SaveVClipFunction · 0.85
AllocLoadVClipFunction · 0.85
LGSObjectsFunction · 0.85
FindTextureBitmapNameFunction · 0.85
GetTextureBitmapFunction · 0.85
CheckIfTextureIsTmap2Function · 0.85
TouchTextureFunction · 0.85
DrawFireballObjectFunction · 0.85
GetWeaponFireImageFunction · 0.85
RenderSmallWindowFunction · 0.85

Calls 11

cfopenFunction · 0.85
cf_ReadByteFunction · 0.85
cf_ReadFloatFunction · 0.85
cf_ReadIntFunction · 0.85
bm_AllocLoadBitmapFunction · 0.85
bm_wFunction · 0.85
bm_hFunction · 0.85
bm_AllocBitmapFunction · 0.85
bm_ScaleBitmapToBitmapFunction · 0.85
bm_FreeBitmapFunction · 0.85
cfcloseFunction · 0.85

Tested by

no test coverage detected