Uses gamefile locking code! This is taken from FilePageDialog.cpp, with some modifications to the outputted text, but uses the GameFile page scheme, emulating a script page.
| 358 | // This is taken from FilePageDialog.cpp, with some modifications to the outputted text, but uses the GameFile |
| 359 | // page scheme, emulating a script page. |
| 360 | void CScriptWizard::OnLock() { |
| 361 | int n, r; |
| 362 | mngs_Pagelock temp_pl; |
| 363 | mngs_gamefile_page gamefilepage; |
| 364 | |
| 365 | n = FindGamefileName(ScriptFileName); |
| 366 | if (n == -1) { |
| 367 | OutrageMessageBox("Unable to find script file page in the table file.\nOperation can't be completed."); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | // start the really involved locking process. |
| 372 | if (!mng_MakeLocker()) |
| 373 | return; |
| 374 | |
| 375 | // Make sure it can be locked |
| 376 | strcpy(temp_pl.name, Gamefiles[n].name); |
| 377 | temp_pl.pagetype = PAGETYPE_GAMEFILE; |
| 378 | |
| 379 | r = mng_CheckIfPageLocked(&temp_pl); |
| 380 | if (r == 2) { |
| 381 | int answer = |
| 382 | OutrageMessageBox(MBOX_YESNO, "This script is not even in the table file, or the database maybe corrupt. " |
| 383 | "Override to 'Unlocked'? (Select NO if you don't know what you're doing)"); |
| 384 | if (answer == IDYES) { |
| 385 | strcpy(temp_pl.holder, "UNLOCKED"); |
| 386 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) |
| 387 | MessageBox(ErrorString, "Error!"); |
| 388 | } |
| 389 | } else if (r < 0) |
| 390 | OutrageMessageBox(ErrorString); |
| 391 | else if (r == 1) |
| 392 | OutrageMessageBox(InfoString); |
| 393 | else { |
| 394 | // Everything is ok. Tell the network we're locking it and get a copy to |
| 395 | // our local drive |
| 396 | |
| 397 | strcpy(temp_pl.holder, TableUser); |
| 398 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) { |
| 399 | MessageBox(ErrorString, "Error!"); |
| 400 | mng_EraseLocker(); |
| 401 | return; |
| 402 | } else { |
| 403 | // Search thru the net pagefile and get a new copy in RAM in case anyone |
| 404 | // changed it since we started the editor |
| 405 | if (mng_FindSpecificGamefilePage(temp_pl.name, &gamefilepage, 0)) { |
| 406 | if (mng_AssignGamefilePageToGamefile(&gamefilepage, n)) { |
| 407 | if (!mng_ReplacePage(Gamefiles[n].name, Gamefiles[n].name, n, PAGETYPE_GAMEFILE, 1)) { |
| 408 | OutrageMessageBox("There was problem writing that page locally!"); |
| 409 | mng_EraseLocker(); |
| 410 | return; |
| 411 | } |
| 412 | OutrageMessageBox("Script locked."); |
| 413 | } else |
| 414 | OutrageMessageBox( |
| 415 | "There was a problem loading this script. You might encounter problems in dealing with it. Good luck!"); |
| 416 | |
| 417 | mng_AllocTrackLock(Gamefiles[n].name, PAGETYPE_GAMEFILE); |
nothing calls this directly
no test coverage detected