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

Method OnUnlock

editor/ScriptWizard.cpp:427–487  ·  view source on GitHub ↗

Uses gamefile unlocking code!

Source from the content-addressed store, hash-verified

425
426// Uses gamefile unlocking code!
427void CScriptWizard::OnUnlock() {
428 int n, r;
429 mngs_Pagelock temp_pl;
430
431 n = FindGamefileName(ScriptFileName);
432 if (n == -1) {
433 OutrageMessageBox("Unable to find script file page in the table file.\nOperation can't be completed.");
434 return;
435 }
436
437 if (!mng_MakeLocker())
438 return;
439
440 // Make sure we own this gamefile
441 strcpy(temp_pl.name, Gamefiles[n].name);
442 temp_pl.pagetype = PAGETYPE_GAMEFILE;
443
444 r = mng_CheckIfPageOwned(&temp_pl, TableUser);
445 if (r < 0)
446 OutrageMessageBox(ErrorString);
447 else if (r == 0)
448 OutrageMessageBox(InfoString);
449 else {
450 // Change the pagelock state to UNLOCKED
451 strcpy(temp_pl.holder, "UNLOCKED");
452 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
453 MessageBox(ErrorString, "Error!");
454 mng_EraseLocker();
455 return;
456 } else {
457 // Now actually replace the copy on the net with our local one
458 if (!mng_ReplacePage(Gamefiles[n].name, Gamefiles[n].name, n, PAGETYPE_GAMEFILE, 0))
459 OutrageMessageBox(ErrorString);
460 else {
461 // Save this gamefile file to the network for all
462 // Force the save of the current script file so this actually works
463 char destname[100], srcname[100];
464
465 SaveScript(ScriptFileName, m_ScriptSource);
466
467 ddio_MakePath(srcname, LocalD3Dir, "data", Gamefiles[n].dir_name, Gamefiles[n].name, NULL);
468 ddio_MakePath(destname, NetD3Dir, "data", Gamefiles[n].dir_name, Gamefiles[n].name, NULL);
469
470 cf_CopyFile(destname, srcname);
471
472 OutrageMessageBox("Script checked in.");
473
474 // Delete it from local pagefile if its there
475 int dret = mng_DeletePage(Gamefiles[n].name, PAGETYPE_GAMEFILE, 1);
476 ASSERT(dret == 1);
477 mng_EraseLocker();
478
479 // Free the tracklock
480 int p = mng_FindTrackLock(Gamefiles[n].name, PAGETYPE_GAMEFILE);
481 ASSERT(p != -1);
482 mng_FreeTrackLock(p);
483 UpdateDialogButtons();
484 }

Callers

nothing calls this directly

Calls 13

FindGamefileNameFunction · 0.85
OutrageMessageBoxFunction · 0.85
mng_MakeLockerFunction · 0.85
mng_CheckIfPageOwnedFunction · 0.85
mng_ReplacePagelockFunction · 0.85
mng_EraseLockerFunction · 0.85
mng_ReplacePageFunction · 0.85
SaveScriptFunction · 0.85
cf_CopyFileFunction · 0.85
mng_DeletePageFunction · 0.85
mng_FindTrackLockFunction · 0.85
mng_FreeTrackLockFunction · 0.85

Tested by

no test coverage detected