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

Method OnChangeName

editor/WorldWeaponsDialog.cpp:1603–1659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1601}
1602
1603void CWorldWeaponsDialog::OnChangeName() {
1604 char name[PAGENAME_LEN];
1605 mngs_Pagelock pl;
1606 int n = D3EditState.current_weapon;
1607
1608 // Make sure we have this ship locked, if not reset name and bail
1609 int p = mng_FindTrackLock(Weapons[n].name, PAGETYPE_WEAPON);
1610 if (p == -1) {
1611 OutrageMessageBox("You must lock this weapon if you wish to change its name.");
1612 return;
1613 }
1614
1615 // Get new name
1616 strcpy(name, Weapons[n].name);
1617 if (!InputWeaponName(name, sizeof(name), "Weapon name", "Enter a new name for this weapon:", this))
1618 return;
1619
1620 if (!mng_MakeLocker())
1621 return;
1622
1623 // Check to see if this page exists on the network. If so, we have to
1624 // rename it so we can prevent havoc
1625 strcpy(pl.name, Weapons[n].name);
1626 pl.pagetype = PAGETYPE_WEAPON;
1627
1628 int ret = mng_CheckIfPageOwned(&pl, TableUser);
1629 if (ret < 0)
1630 OutrageMessageBox(ErrorString);
1631 else if (ret == 1)
1632 mng_RenamePage(Weapons[n].name, name, PAGETYPE_WEAPON);
1633 else if (ret == 2) {
1634 // This page has never been checked in, replace only local copy
1635
1636 char oldname[PAGENAME_LEN];
1637 strcpy(oldname, Weapons[n].name);
1638 strcpy(Weapons[n].name, name);
1639
1640 mng_ReplacePage(oldname, Weapons[n].name, n, PAGETYPE_WEAPON, 1);
1641 } else if (ret == 0) {
1642 OutrageMessageBox("You don't own this page. Get Jason now!");
1643 mng_FreeTrackLock(p);
1644 return;
1645 }
1646
1647 // Finally, copy our new name to the appropriate arrays
1648 strcpy(GlobalTrackLocks[p].name, name);
1649 strcpy(Weapons[n].name, name);
1650 mng_EraseLocker();
1651
1652 RemapWeapons();
1653
1654 // check to see if current has been remapped
1655 if (!Weapons[n].used)
1656 D3EditState.current_weapon = GetNextWeapon(n);
1657
1658 UpdateDialog();
1659}
1660

Callers

nothing calls this directly

Calls 11

mng_FindTrackLockFunction · 0.85
OutrageMessageBoxFunction · 0.85
InputWeaponNameFunction · 0.85
mng_MakeLockerFunction · 0.85
mng_CheckIfPageOwnedFunction · 0.85
mng_RenamePageFunction · 0.85
mng_ReplacePageFunction · 0.85
mng_FreeTrackLockFunction · 0.85
mng_EraseLockerFunction · 0.85
RemapWeaponsFunction · 0.85
GetNextWeaponFunction · 0.85

Tested by

no test coverage detected