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

Method OnPshipDelete

editor/WorldObjectsPlayerDialog.cpp:346–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346void CWorldObjectsPlayerDialog::OnPshipDelete() {
347 int answer, tl;
348 mngs_Pagelock pl;
349 int n = D3EditState.current_ship;
350
351 if (Num_ships < 1)
352 return;
353
354 // Check to see if we even have it locked
355 if ((tl = mng_FindTrackLock(Ships[n].name, PAGETYPE_SHIP)) == -1) {
356 OutrageMessageBox("This ship is not yours to delete. Lock first.");
357 return;
358 }
359
360 // Make sure its to be deleted
361 answer = MessageBox("Are you sure you want to delete this ship?", Ships[n].name, MB_YESNO);
362 if (answer == IDNO)
363 return;
364
365 if (!mng_MakeLocker())
366 return;
367
368 strcpy(pl.name, Ships[n].name);
369 pl.pagetype = PAGETYPE_SHIP;
370
371 // Check to see if this is a local ship only. If so, only delete it locally
372 if (mng_CheckIfPageOwned(&pl, TableUser) != 1) {
373 mng_FreeTrackLock(tl);
374 if (!mng_DeletePage(Ships[n].name, PAGETYPE_SHIP, 1)) {
375 mprintf(0, ErrorString);
376 Int3();
377 }
378 } else // if its network, delete it from both the net and local drives
379 {
380
381 mng_FreeTrackLock(tl);
382
383 mng_DeletePage(Ships[n].name, PAGETYPE_SHIP, 0);
384 mng_DeletePage(Ships[n].name, PAGETYPE_SHIP, 1);
385
386 mng_DeletePagelock(Ships[n].name, PAGETYPE_SHIP);
387 }
388
389 // Advance to the next ship
390 D3EditState.current_ship = GetNextShip(n);
391
392 FreePolyModel(Ships[n].model_handle);
393 if (Ships[n].dying_model_handle != -1)
394 FreePolyModel(Ships[n].dying_model_handle);
395
396 FreeShip(n);
397
398 mng_EraseLocker();
399
400 OutrageMessageBox("Ship deleted.");
401
402 RemapShips();
403

Callers

nothing calls this directly

Calls 12

mng_FindTrackLockFunction · 0.85
OutrageMessageBoxFunction · 0.85
mng_MakeLockerFunction · 0.85
mng_CheckIfPageOwnedFunction · 0.85
mng_FreeTrackLockFunction · 0.85
mng_DeletePageFunction · 0.85
mng_DeletePagelockFunction · 0.85
GetNextShipFunction · 0.85
FreePolyModelFunction · 0.85
FreeShipFunction · 0.85
mng_EraseLockerFunction · 0.85
RemapShipsFunction · 0.85

Tested by

no test coverage detected