Skip to content

Commit 96a60eb

Browse files
authored
Merge pull request scp-fs2open#7492 from Goober5000/fix/fred_ship_registry
fix ship registry updating in FRED
2 parents 8114a4c + 781bf0d commit 96a60eb

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

fred2/management.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,15 @@ int rename_ship(int ship, const char *name)
18201820
if (i >= 0)
18211821
strcpy_s(Reinforcements[i].name, name);
18221822

1823+
// keep the ship registry in sync
1824+
auto reg_it = Ship_registry_map.find(Ships[ship].ship_name);
1825+
if (reg_it != Ship_registry_map.end()) {
1826+
int reg_idx = reg_it->second;
1827+
Ship_registry_map.erase(reg_it);
1828+
strcpy_s(Ship_registry[reg_idx].name, name);
1829+
Ship_registry_map[name] = reg_idx;
1830+
}
1831+
18231832
strcpy_s(Ships[ship].ship_name, name);
18241833
if (ship == cur_ship)
18251834
Ship_editor_dialog.m_ship_name = _T(name);

qtfred/src/mission/Editor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,15 @@ int Editor::rename_ship(int ship, const char* name) {
14941494
if (i >= 0)
14951495
strcpy_s(Reinforcements[i].name, name);
14961496

1497+
// keep the ship registry in sync
1498+
auto reg_it = Ship_registry_map.find(Ships[ship].ship_name);
1499+
if (reg_it != Ship_registry_map.end()) {
1500+
int reg_idx = reg_it->second;
1501+
Ship_registry_map.erase(reg_it);
1502+
strcpy_s(Ship_registry[reg_idx].name, name);
1503+
Ship_registry_map[name] = reg_idx;
1504+
}
1505+
14971506
strcpy_s(Ships[ship].ship_name, name);
14981507

14991508
// if this name has a hash, create a default display name

0 commit comments

Comments
 (0)