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

Function CheckInGamefile

editor/ScriptLevelInterface.cpp:1099–1162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1097}
1098
1099bool CheckInGamefile(char *tempbuffer, bool show_ok_confirmation) {
1100 mngs_Pagelock temp_pl;
1101 int r, n;
1102
1103 for (n = 0; n < MAX_GAMEFILES; n++) {
1104 if (Gamefiles[n].used && (!stricmp(Gamefiles[n].name, tempbuffer))) {
1105 break;
1106 }
1107 }
1108
1109 if (n == MAX_GAMEFILES)
1110 return false;
1111
1112 // Make sure we own this gamefile
1113 strcpy(temp_pl.name, Gamefiles[n].name);
1114 temp_pl.pagetype = PAGETYPE_GAMEFILE;
1115
1116 r = mng_CheckIfPageOwned(&temp_pl, TableUser);
1117 if (r < 0)
1118 OutrageMessageBox(ErrorString);
1119 else if (r == 0)
1120 OutrageMessageBox(InfoString);
1121 else {
1122 // Change the pagelock state to UNLOCKED
1123 strcpy(temp_pl.holder, "UNLOCKED");
1124 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
1125 AfxMessageBox(ErrorString, MB_OK);
1126 return false;
1127 } else {
1128 // Now actually replace the copy on the net with our local one
1129 if (!mng_ReplacePage(Gamefiles[n].name, Gamefiles[n].name, n, PAGETYPE_GAMEFILE, 0))
1130 OutrageMessageBox(ErrorString);
1131 else {
1132 // Save this gamefile file to the network for all
1133
1134 char destname[100], srcname[100];
1135
1136 ddio_MakePath(srcname, LocalD3Dir, "data", Gamefiles[n].dir_name, Gamefiles[n].name, NULL);
1137 ddio_MakePath(destname, NetD3Dir, "data", Gamefiles[n].dir_name, Gamefiles[n].name, NULL);
1138
1139 cf_CopyFile(destname, srcname);
1140
1141 // Delete it from local pagefile if its there
1142 int dret = mng_DeletePage(Gamefiles[n].name, PAGETYPE_GAMEFILE, 1);
1143 ASSERT(dret == 1);
1144
1145 // Free the tracklock
1146 int p = mng_FindTrackLock(Gamefiles[n].name, PAGETYPE_GAMEFILE);
1147 ASSERT(p != -1);
1148 mng_FreeTrackLock(p);
1149
1150 if (show_ok_confirmation)
1151 OutrageMessageBox("%s checked in.", tempbuffer);
1152
1153 // Make sure its checked in
1154 if (cf_Diff(destname, srcname)) {
1155 ASSERT(1); // Get Jason! File didn't check in correctly!
1156 cf_CopyFile(destname, srcname); // Do this so we can trace whats happening

Callers 5

OnCreatescriptMethod · 0.85
CheckInScriptsMethod · 0.85
CheckInLevelsMethod · 0.85
Step4Method · 0.85
OnAddMethod · 0.85

Calls 10

mng_CheckIfPageOwnedFunction · 0.85
OutrageMessageBoxFunction · 0.85
mng_ReplacePagelockFunction · 0.85
mng_ReplacePageFunction · 0.85
cf_CopyFileFunction · 0.85
mng_DeletePageFunction · 0.85
mng_FindTrackLockFunction · 0.85
mng_FreeTrackLockFunction · 0.85
cf_DiffFunction · 0.85
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected