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

Function LGSRooms

Descent3/loadstate.cpp:542–616  ·  view source on GitHub ↗

initializes rooms

Source from the content-addressed store, hash-verified

540
541// initializes rooms
542int LGSRooms(CFILE *fp) {
543 int retval = LGS_OK;
544 int16_t i, p, highest_index;
545
546 gs_ReadShort(fp, highest_index);
547 if (highest_index != (int16_t)Highest_room_index) {
548 Int3();
549 return LGS_CORRUPTLEVEL;
550 }
551
552 int16_t num_rooms;
553 gs_ReadShort(fp, num_rooms);
554
555 for (i = 0; i < num_rooms; i++) {
556 gs_ReadByte(fp, AutomapVisMap[i]);
557 }
558
559 for (i = 0; i <= highest_index; i++) {
560 uint8_t used;
561 gs_ReadByte(fp, used);
562 if (used) {
563 // reset lists
564 Rooms[i].objects = -1;
565 Rooms[i].vis_effects = -1;
566
567 // we need to save some room info out.
568 gs_ReadInt(fp, Rooms[i].flags);
569 gs_ReadByte(fp, Rooms[i].pulse_time);
570 gs_ReadByte(fp, Rooms[i].pulse_offset);
571 gs_ReadVector(fp, Rooms[i].wind);
572 gs_ReadFloat(fp, Rooms[i].last_render_time);
573 gs_ReadFloat(fp, Rooms[i].fog_depth);
574 gs_ReadFloat(fp, Rooms[i].fog_r);
575 gs_ReadFloat(fp, Rooms[i].fog_g);
576 gs_ReadFloat(fp, Rooms[i].fog_b);
577 gs_ReadFloat(fp, Rooms[i].damage);
578 // gs_ReadInt(fp, Rooms[i].objects);
579 //?? gs_WriteFloat(fp, Rooms[i].ambient_sound); // need to save an index of sounds.
580
581 // Find out about texture changes
582 // if (Gamesave_read_version>=1)
583 //{
584 int num_changed = cf_ReadShort(fp);
585
586 for (int t = 0; t < num_changed; t++) {
587 int facenum = cf_ReadShort(fp);
588 Rooms[i].faces[facenum].tmap = gs_Xlates->tex_handles[cf_ReadShort(fp)];
589 Rooms[i].faces[facenum].flags |= FF_TEXTURE_CHANGED;
590 }
591 //}
592 for (p = 0; p < Rooms[i].num_portals; p++) {
593 gs_ReadInt(fp, Rooms[i].portals[p].flags);
594 }
595
596 // load doorway info
597 if (Rooms[i].flags & RF_DOOR) {
598 doorway *dp = Rooms[i].doorway_data;
599 ASSERT(dp != NULL);

Callers 2

LoadGameStateFunction · 0.85
DemoReadHeaderFunction · 0.85

Calls 1

cf_ReadShortFunction · 0.85

Tested by

no test coverage detected