mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
fix wing creation dialog
When forming a wing, if there is a name conflict but the ship will actually be used in the wing, don't report the conflict. Fixes #6572.
This commit is contained in:
1 parent
5f73220cd1
commit
3d1fce99ac
6 files changed
+71
-55
No files matched your search
+28
-24
@@ -57,7 +57,6 @@ void create_wing_dlg::OnOK()
|
||||
{
|
||||
CString msg;
|
||||
int i;
|
||||
object *ptr;
|
||||
|
||||
UpdateData(TRUE);
|
||||
UpdateData(TRUE);
|
||||
@@ -74,32 +73,37 @@ void create_wing_dlg::OnOK()
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = GET_FIRST(&obj_used_list);
|
||||
while (ptr != END_OF_LIST(&obj_used_list)) {
|
||||
if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)){
|
||||
i = ptr->instance;
|
||||
if (!strnicmp(m_name, Ships[i].ship_name, strlen(m_name))) {
|
||||
char *namep;
|
||||
auto len = strlen(m_name);
|
||||
for (auto ptr: list_range(&obj_used_list)) {
|
||||
if ((ptr->type != OBJ_SHIP) && (ptr->type != OBJ_START))
|
||||
continue;
|
||||
i = ptr->instance;
|
||||
|
||||
namep = Ships[i].ship_name + strlen(m_name);
|
||||
if (*namep == ' ') {
|
||||
namep++;
|
||||
while (*namep) {
|
||||
if (!isdigit(*namep))
|
||||
break;
|
||||
|
||||
namep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*namep) {
|
||||
MessageBox("This wing name is already being used by a ship");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if this ship is actually going to be in the wing, and if it *can* be in a wing
|
||||
// (i.e. it will not be taken out later), then skip the name check
|
||||
if (ptr->flags[Object::Object_Flags::Marked]) {
|
||||
int ship_type = ship_query_general_type(i);
|
||||
if (ship_type >= 0 && Ship_types[ship_type].flags[Ship::Type_Info_Flags::AI_can_form_wing])
|
||||
continue;
|
||||
}
|
||||
|
||||
ptr = GET_NEXT(ptr);
|
||||
// see if this ship name matches what a ship in the wing would be
|
||||
if (!strnicmp(m_name, Ships[i].ship_name, len)) {
|
||||
auto namep = Ships[i].ship_name + len;
|
||||
if (*namep == ' ') {
|
||||
namep++;
|
||||
while (*namep) {
|
||||
if (!isdigit(*namep))
|
||||
break;
|
||||
namep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*namep) {
|
||||
MessageBox("This wing name is already being used by a ship");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need to check teams. "Unknown" is a valid name and also an IFF.
|
||||
|
||||
@@ -1700,13 +1700,17 @@ int get_docking_list(int model_index)
|
||||
}
|
||||
|
||||
// DA 1/7/99 These ship names are not variables
|
||||
int rename_ship(int ship, char *name)
|
||||
int rename_ship(int ship, const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert(ship >= 0);
|
||||
Assert(strlen(name) < NAME_LENGTH);
|
||||
|
||||
// we may not need to rename it
|
||||
if (strcmp(Ships[ship].ship_name, name) == 0)
|
||||
return 0;
|
||||
|
||||
update_sexp_references(Ships[ship].ship_name, name);
|
||||
ai_update_goal_references(sexp_ref_type::SHIP, Ships[ship].ship_name, name);
|
||||
update_texture_replacements(Ships[ship].ship_name, name);
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ int query_initial_orders_conflict(int wing);
|
||||
int query_initial_orders_empty(ai_goal* ai_goals);
|
||||
int set_reinforcement(char* name, int state);
|
||||
int get_docking_list(int model_index);
|
||||
int rename_ship(int ship, char* name);
|
||||
int rename_ship(int ship, const char* name);
|
||||
void fix_ship_name(int ship);
|
||||
int internal_integrity_check();
|
||||
void correct_marking();
|
||||
|
||||
@@ -1543,12 +1543,16 @@ void Editor::update_texture_replacements(const char* old_name, const char* new_n
|
||||
strcpy_s(ii->ship_name, new_name);
|
||||
}
|
||||
}
|
||||
int Editor::rename_ship(int ship, char* name) {
|
||||
int Editor::rename_ship(int ship, const char* name) {
|
||||
int i;
|
||||
|
||||
Assert(ship >= 0);
|
||||
Assert(strlen(name) < NAME_LENGTH);
|
||||
|
||||
// we may not need to rename it
|
||||
if (strcmp(Ships[ship].ship_name, name) == 0)
|
||||
return 0;
|
||||
|
||||
update_sexp_references(Ships[ship].ship_name, name);
|
||||
ai_update_goal_references(sexp_ref_type::SHIP, Ships[ship].ship_name, name);
|
||||
update_texture_replacements(Ships[ship].ship_name, name);
|
||||
|
||||
@@ -236,7 +236,7 @@ class Editor : public QObject {
|
||||
int invalidate_references(const char* name, sexp_ref_type type);
|
||||
|
||||
// DA 1/7/99 These ship names are not variables
|
||||
int rename_ship(int ship, char* name);
|
||||
int rename_ship(int ship, const char* name);
|
||||
|
||||
void delete_reinforcement(int num);
|
||||
|
||||
|
||||
@@ -38,36 +38,40 @@ bool FormWingDialogModel::apply() {
|
||||
}
|
||||
}
|
||||
|
||||
auto ptr = GET_FIRST(&obj_used_list);
|
||||
while (ptr != END_OF_LIST(&obj_used_list)) {
|
||||
if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
|
||||
auto i = ptr->instance;
|
||||
if (!strnicmp(_name.c_str(), Ships[i].ship_name, _name.size())) {
|
||||
char* namep;
|
||||
auto len = _name.length();
|
||||
for (auto ptr : list_range(&obj_used_list)) {
|
||||
if ((ptr->type != OBJ_SHIP) && (ptr->type != OBJ_START))
|
||||
continue;
|
||||
int i = ptr->instance;
|
||||
|
||||
namep = Ships[i].ship_name + _name.size();
|
||||
if (*namep == ' ') {
|
||||
namep++;
|
||||
while (*namep) {
|
||||
if (!isdigit(*namep)) {
|
||||
break;
|
||||
}
|
||||
|
||||
namep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*namep) {
|
||||
_viewport->dialogProvider->showButtonDialog(DialogType::Error,
|
||||
"Error",
|
||||
"This wing name is already being used by a ship",
|
||||
{ DialogButton::Ok });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if this ship is actually going to be in the wing, and if it *can* be in a wing
|
||||
// (i.e. it will not be taken out later), then skip the name check
|
||||
if (ptr->flags[Object::Object_Flags::Marked]) {
|
||||
int ship_type = ship_query_general_type(i);
|
||||
if (ship_type >= 0 && Ship_types[ship_type].flags[Ship::Type_Info_Flags::AI_can_form_wing])
|
||||
continue;
|
||||
}
|
||||
|
||||
ptr = GET_NEXT(ptr);
|
||||
// see if this ship name matches what a ship in the wing would be
|
||||
if (!strnicmp(_name.c_str(), Ships[i].ship_name, len)) {
|
||||
auto namep = Ships[i].ship_name + len;
|
||||
if (*namep == ' ') {
|
||||
namep++;
|
||||
while (*namep) {
|
||||
if (!isdigit(*namep))
|
||||
break;
|
||||
namep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*namep) {
|
||||
_viewport->dialogProvider->showButtonDialog(DialogType::Error,
|
||||
"Error",
|
||||
"This wing name is already being used by a ship",
|
||||
{ DialogButton::Ok });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need to check teams. "Unknown" is a valid name and also an IFF.
|
||||
|
||||
Reference in new issue
Block a user