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

Method OnASPCheckIn

editor/AmbientSoundPattern.cpp:412–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412void CAmbientSoundPattern::OnASPCheckIn() {
413 // Write the updated data to the file
414 WriteAmbientData();
415
416 // Find where it is in the files index
417 int n = FindGamefileName(AMBIENT_FILE_NAME);
418
419 if (n == -1) {
420 Int3(); // Get Matt or Jason - AMBIENT file name is no longer in the table file!
421 return;
422 }
423
424 mngs_Pagelock temp_pl;
425 int r;
426
427 // Lock the network table file
428 if (!mng_MakeLocker())
429 return;
430
431 // Make sure we own this gamefile
432 strcpy(temp_pl.name, Gamefiles[n].name);
433 temp_pl.pagetype = PAGETYPE_GAMEFILE;
434
435 r = mng_CheckIfPageOwned(&temp_pl, TableUser);
436 if (r < 0)
437 OutrageMessageBox(ErrorString);
438 else if (r == 0)
439 OutrageMessageBox(InfoString);
440 else {
441 // Change the pagelock state to UNLOCKED
442 strcpy(temp_pl.holder, "UNLOCKED");
443 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
444 MessageBox(ErrorString, "Error!");
445 mng_EraseLocker();
446 return;
447 } else {
448 // Now actually replace the copy on the net with our local one
449
450 if (!mng_ReplacePage(Gamefiles[n].name, Gamefiles[n].name, n, PAGETYPE_GAMEFILE, 0))
451 OutrageMessageBox(ErrorString);
452 else {
453 // Save this gamefile file to the network for all
454
455 char destname[100], srcname[100];
456
457 ddio_MakePath(srcname, LocalD3Dir, "data", Gamefiles[n].dir_name, Gamefiles[n].name, NULL);
458 ddio_MakePath(destname, NetD3Dir, "data", Gamefiles[n].dir_name, Gamefiles[n].name, NULL);
459
460 cf_CopyFile(destname, srcname);
461
462 OutrageMessageBox("File checked in.");
463
464 // Delete it from local pagefile if its there
465 int dret = mng_DeletePage(Gamefiles[n].name, PAGETYPE_GAMEFILE, 1);
466 ASSERT(dret == 1);
467 mng_EraseLocker();
468
469 // Free the tracklock

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected