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

Method OnDeleteWeapon

editor/WorldWeaponsDialog.cpp:561–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561void CWorldWeaponsDialog::OnDeleteWeapon() {
562 int answer, tl;
563 mngs_Pagelock pl;
564 int n = D3EditState.current_weapon;
565
566 if (Num_weapons < 1)
567 return;
568
569 // Check to see if we even have it locked
570 if ((tl = mng_FindTrackLock(Weapons[n].name, PAGETYPE_WEAPON)) == -1) {
571 OutrageMessageBox("This weapon is not yours to delete. Lock first.");
572 return;
573 }
574
575 // Make sure its to be deleted
576 answer = MessageBox("Are you sure you want to delete this weapon?", Weapons[n].name, MB_YESNO);
577 if (answer == IDNO)
578 return;
579
580 if (!mng_MakeLocker())
581 return;
582
583 strcpy(pl.name, Weapons[n].name);
584 pl.pagetype = PAGETYPE_WEAPON;
585
586 // Check to see if this is a local weapon only. If so, only delete it locally
587 if (mng_CheckIfPageOwned(&pl, TableUser) != 1) {
588 mng_FreeTrackLock(tl);
589 if (!mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 1)) {
590 mprintf(0, ErrorString);
591 Int3();
592 }
593 } else // if its network, delete it from both the net and local drives
594 {
595
596 mng_FreeTrackLock(tl);
597 mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 1);
598 mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 0);
599 mng_DeletePagelock(Weapons[n].name, PAGETYPE_WEAPON);
600 }
601
602 // Advance to the next weapon
603 D3EditState.current_weapon = GetNextWeapon(n);
604
605 // Free weapon images
606 if (Weapons[n].flags & WF_HUD_ANIMATED)
607 FreeVClip(Weapons[n].hud_image_handle);
608 else
609 bm_FreeBitmap(Weapons[n].hud_image_handle);
610
611 if (Weapons[n].fire_image_handle != -1) {
612 if (Weapons[n].flags & WF_IMAGE_BITMAP)
613 bm_FreeBitmap(Weapons[n].fire_image_handle);
614 else if (Weapons[n].flags & WF_IMAGE_VCLIP)
615 FreeVClip(Weapons[n].fire_image_handle);
616 else
617 FreePolyModel(Weapons[n].fire_image_handle);
618 }

Callers

nothing calls this directly

Calls 14

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
GetNextWeaponFunction · 0.85
FreeVClipFunction · 0.85
bm_FreeBitmapFunction · 0.85
FreePolyModelFunction · 0.85
FreeWeaponFunction · 0.85

Tested by

no test coverage detected