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

Function SaveGroup

editor/Group.cpp:684–723  ·  view source on GitHub ↗

Saves a group to disk in the given filename

Source from the content-addressed store, hash-verified

682
683// Saves a group to disk in the given filename
684void SaveGroup(char *filename, group *g) {
685 CFILE *ifile;
686 int i;
687
688 ifile = cfopen(filename, "wb");
689
690 if (!ifile)
691 return;
692
693 // Write tag & version number
694 cf_WriteBytes((uint8_t *)GROUP_FILE_TAG, 4, ifile);
695 cf_WriteInt(ifile, GROUP_FILE_VERSION);
696 cf_WriteInt(ifile, LEVEL_FILE_VERSION);
697
698 // Write the current list of textures
699 WriteTextureList(ifile);
700
701 // Write group info
702 cf_WriteInt(ifile, g->nrooms);
703 cf_WriteInt(ifile, g->attachroom);
704 cf_WriteInt(ifile, g->attachface);
705 cf_WriteInt(ifile, g->nobjects);
706 cf_WriteInt(ifile, g->ndoors);
707 cf_WriteInt(ifile, g->ntriggers);
708
709 // Write rooms
710 for (i = 0; i < g->nrooms; i++)
711 WriteRoom(ifile, &g->rooms[i]);
712
713 // Write objects
714 for (i = 0; i < g->nobjects; i++)
715 WriteGroupObject(ifile, &g->objects[i]);
716
717 // Write triggers
718 for (i = 0; i < g->ntriggers; i++)
719 WriteGroupTrigger(ifile, &g->triggers[i]);
720
721 // Close the file
722 cfclose(ifile);
723}
724
725// Reads an object for a group
726void ReadGroupObject(CFILE *ifile, object *objp) {

Callers 1

OnEditSaveScrapMethod · 0.85

Calls 7

cfopenFunction · 0.85
cf_WriteBytesFunction · 0.85
cf_WriteIntFunction · 0.85
WriteRoomFunction · 0.85
WriteGroupObjectFunction · 0.85
WriteGroupTriggerFunction · 0.85
cfcloseFunction · 0.85

Tested by

no test coverage detected