| 1162 | } |
| 1163 | |
| 1164 | bool CheckOutGamefile(char *tempbuffer, bool show_ok_confirmation, bool report_who_has_locked) { |
| 1165 | int n; |
| 1166 | mngs_Pagelock temp_pl; |
| 1167 | mngs_gamefile_page gamefilepage; |
| 1168 | int r; |
| 1169 | |
| 1170 | for (n = 0; n < MAX_GAMEFILES; n++) { |
| 1171 | if (Gamefiles[n].used && (!stricmp(Gamefiles[n].name, tempbuffer))) { |
| 1172 | break; |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | if (n == MAX_GAMEFILES) |
| 1177 | return false; |
| 1178 | |
| 1179 | // Make sure it can be locked |
| 1180 | strcpy(temp_pl.name, Gamefiles[n].name); |
| 1181 | temp_pl.pagetype = PAGETYPE_GAMEFILE; |
| 1182 | |
| 1183 | r = mng_CheckIfPageLocked(&temp_pl); |
| 1184 | if (r == 2) { |
| 1185 | int answer; |
| 1186 | answer = OutrageMessageBox(MBOX_YESNO, "This page is not even in the table file, or the database maybe corrupt. " |
| 1187 | "Override to 'Unlocked'? (Select NO if you don't know what you're doing)"); |
| 1188 | if (answer == IDYES) { |
| 1189 | strcpy(temp_pl.holder, "UNLOCKED"); |
| 1190 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) |
| 1191 | AfxMessageBox(ErrorString, MB_OK); |
| 1192 | } |
| 1193 | } else if (r < 0) |
| 1194 | OutrageMessageBox(ErrorString); |
| 1195 | else if (r == 1) { |
| 1196 | if (report_who_has_locked) |
| 1197 | OutrageMessageBox(InfoString); |
| 1198 | } else { |
| 1199 | |
| 1200 | // Everything is ok. Tell the network we're locking it and get a copy to |
| 1201 | // our local drive |
| 1202 | strcpy(temp_pl.holder, TableUser); |
| 1203 | |
| 1204 | // Search thru the net pagefile and get a new copy in RAM in case anyone |
| 1205 | // changed it since we started the editor |
| 1206 | if (mng_FindSpecificGamefilePage(temp_pl.name, &gamefilepage, 0)) { |
| 1207 | if (mng_AssignGamefilePageToGamefile(&gamefilepage, n)) { |
| 1208 | if (!mng_ReplacePage(Gamefiles[n].name, Gamefiles[n].name, n, PAGETYPE_GAMEFILE, 1)) { |
| 1209 | OutrageMessageBox("There was problem writing that page(%s) locally!", tempbuffer); |
| 1210 | return false; |
| 1211 | } else { |
| 1212 | |
| 1213 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) { |
| 1214 | AfxMessageBox(ErrorString, MB_OK); |
| 1215 | return false; |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | if (show_ok_confirmation) |
| 1220 | OutrageMessageBox("%s locked.", tempbuffer); |
| 1221 | } else |
no test coverage detected