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

Function LGSObjects

Descent3/loadstate.cpp:833–1442  ·  view source on GitHub ↗

loads in and sets these objects

Source from the content-addressed store, hash-verified

831extern int Marker_message;
832// loads in and sets these objects
833int LGSObjects(CFILE *fp, int version) {
834
835 inreadobj = 1;
836 int retval = LGS_OK;
837 vector pos, last_pos;
838 int roomnum;
839 int i, j, highest_index;
840 int max_terr;
841
842 matrix *objmat = (matrix *)mem_malloc(sizeof(*objmat) * MAX_OBJECTS);
843
844 Osiris_DisableCreateEvents();
845 // we must reset some data before continuing.
846 InitBigObjects();
847
848 START_VERIFY_SAVEFILE(fp);
849 Marker_message = cf_ReadInt(fp);
850 int num_marker_msgs = cf_ReadShort(fp);
851 for (i = 0; i < num_marker_msgs; i++) {
852 int msg_len = cf_ReadShort(fp);
853 cf_ReadBytes((uint8_t *)MarkerMessages[i], msg_len, fp);
854 }
855
856 highest_index = (int)cf_ReadShort(fp);
857
858 // load what objects are stuck to each other
859 int max_num_linked = cf_ReadInt(fp);
860 Physics_NumLinked = cf_ReadInt(fp);
861 for (i = 0; i < max_num_linked; i++) {
862 PhysicsLinkList[i] = cf_ReadInt(fp);
863 }
864
865 // load AI information
866 //////////////////////////////////
867 int num_read_max_dynamic_paths = cf_ReadInt(fp);
868 int num_read_max_nodes = cf_ReadInt(fp);
869
870 int num_dp_to_read = std::min(MAX_DYNAMIC_PATHS, num_read_max_dynamic_paths);
871 int num_dp_to_skip =
872 (MAX_DYNAMIC_PATHS < num_read_max_dynamic_paths) ? num_read_max_dynamic_paths - MAX_DYNAMIC_PATHS : 0;
873
874 int num_n_to_read = std::min(MAX_NODES, num_read_max_nodes);
875 int num_n_to_skip = (MAX_NODES < num_read_max_nodes) ? num_read_max_nodes - MAX_NODES : 0;
876
877 int s;
878 for (i = 0; i < num_dp_to_read; i++) {
879 AIDynamicPath[i].num_nodes = cf_ReadShort(fp);
880 AIDynamicPath[i].use_count = cf_ReadShort(fp);
881 AIDynamicPath[i].owner_handle = cf_ReadInt(fp);
882
883 for (s = 0; s < num_n_to_read; s++) {
884 AIDynamicPath[i].pos[s].x = cf_ReadFloat(fp);
885 AIDynamicPath[i].pos[s].y = cf_ReadFloat(fp);
886 AIDynamicPath[i].pos[s].z = cf_ReadFloat(fp);
887 AIDynamicPath[i].roomnum[s] = cf_ReadInt(fp);
888 }
889
890 for (s = 0; s < num_n_to_skip; s++) {

Callers 2

LoadGameStateFunction · 0.85
DemoReadHeaderFunction · 0.85

Calls 15

InitBigObjectsFunction · 0.85
cf_ReadIntFunction · 0.85
cf_ReadShortFunction · 0.85
cf_ReadBytesFunction · 0.85
cf_ReadFloatFunction · 0.85
Osiris_DisableEventsFunction · 0.85
ObjDeleteFunction · 0.85
ObjUnlinkFunction · 0.85
Osiris_EnableEventsFunction · 0.85
ErrorFunction · 0.85
FreeObjectScriptsFunction · 0.85

Tested by

no test coverage detected