Attached Files |
-
name_checks.patch (6,762 bytes) 2009-11-30 05:23
Index: fred2/shipeditordlg.cpp
===================================================================
--- fred2/shipeditordlg.cpp (revision 5691)
+++ fred2/shipeditordlg.cpp (working copy)
@@ -1004,6 +1004,7 @@
char *str, old_name[255];
object *ptr;
int i, z, wing;
+ size_t t;
CSingleLock sync(&CS_cur_object_index), sync2(&CS_update);
nprintf(("Fred routing", "Ship dialog save\n"));
@@ -1069,7 +1070,39 @@
UpdateData(FALSE);
}
- for (i=0; i<MAX_WAYPOINT_LISTS; i++)
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_ship_name, Iff_info[i].iff_name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This ship name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_ship_name = _T(Wings[cur_wing].name);
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_ship_name, Ai_tp_list[t].name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This ship name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_ship_name = _T(Ships[single_ship].ship_name);
+ UpdateData(FALSE);
+ }
+
+ for (i=0; i<MAX_WAYPOINT_LISTS; i++)
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_ship_name)) {
if (bypass_errors)
return 0;
Index: fred2/waypointpathdlg.cpp
===================================================================
--- fred2/waypointpathdlg.cpp (revision 5691)
+++ fred2/waypointpathdlg.cpp (working copy)
@@ -21,6 +21,7 @@
#include "ai/aigoals.h"
#include "starfield/starfield.h"
#include "jumpnode/jumpnode.h"
+#include "iff_defs/iff_defs.h"
#define ID_JUMP_NODE_MENU 8000
#define ID_WAYPOINT_MENU 9000
@@ -147,6 +148,7 @@
char *str, old_name[255];
int i, z;
object *ptr;
+ size_t t;
if (!GetSafeHwnd())
return 0;
@@ -178,7 +180,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
if (!stricmp(m_name, Ships[ptr->instance].ship_name)) {
if (bypass_errors)
return 1;
@@ -198,6 +200,38 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_name, Iff_info[i].iff_name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This waypoint path name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(Waypoint_lists[cur_waypoint_list].name);
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_name, Ai_tp_list[t].name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This waypoint path name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(Waypoint_lists[cur_waypoint_list].name);
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
{
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name) && (i != cur_waypoint_list)) {
@@ -265,7 +299,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
if (!stricmp(m_name, Ships[ptr->instance].ship_name)) {
if (bypass_errors)
return 1;
@@ -285,6 +319,38 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_name, Iff_info[i].iff_name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This jump node name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(jnp->get_name_ptr());
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_name, Ai_tp_list[t].name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This jump node name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(jnp->get_name_ptr());
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
{
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) {
Index: fred2/wing_editor.cpp
===================================================================
--- fred2/wing_editor.cpp (revision 5691)
+++ fred2/wing_editor.cpp (working copy)
@@ -22,6 +22,7 @@
#include "jumpnode/jumpnode.h"
#include "cfile/cfile.h"
#include "restrictpaths.h"
+#include "iff_defs/iff_defs.h"
#define ID_WING_MENU 9000
@@ -538,6 +539,7 @@
{
char *str, old_name[255], buf[512];
int i, z;
+ size_t t;
object *ptr;
nprintf(("Fred routing", "Wing dialog save\n"));
@@ -569,7 +571,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
if (!stricmp(m_wing_name, Ships[ptr->instance].ship_name)) {
if (bypass_errors)
return 1;
@@ -589,6 +591,38 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_wing_name, Iff_info[i].iff_name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This wing name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_wing_name = _T(Wings[cur_wing].name);
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_wing_name, Ai_tp_list[t].name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This wing name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_wing_name = _T(Wings[cur_wing].name);
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_wing_name)) {
if (bypass_errors)
-
name_checks2.patch (11,752 bytes) 2009-11-30 23:19
Index: fred2/createwingdlg.cpp
===================================================================
--- fred2/createwingdlg.cpp (revision 5691)
+++ fred2/createwingdlg.cpp (working copy)
@@ -17,6 +17,7 @@
#include "object/waypoint.h"
#include "globalincs/linklist.h"
#include "parse/parselo.h"
+#include "iff_defs/iff_defs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -56,10 +57,11 @@
void create_wing_dlg::OnOK()
{
- CString msg;
+ CString msg, lft;
int i;
object *ptr;
-
+ size_t t;
+
UpdateData(TRUE);
UpdateData(TRUE);
m_name = drop_white_space((char *)(LPCSTR) m_name);
@@ -77,7 +79,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ 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;
@@ -103,11 +105,31 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_name, Iff_info[i].iff_name)) {
+ msg.Format("The name \"%s\" is already being used by a team", m_name);
+ MessageBox(msg);
+ return;
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_name, Ai_tp_list[t].name)) {
+ msg.Format("The name \"%s\" is already being used by a target priority group", m_name);
+ MessageBox(msg);
+ return;
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) {
MessageBox("This wing name is already being used by a waypoint path");
return;
}
-
+
+ lft = m_name.Left(1);
+ if (!stricmp(lft, "<")) {
+ MessageBox("Wing names not allowed to begine with <");
+ return;
+ }
+
CDialog::OnOK();
}
Index: fred2/shipeditordlg.cpp
===================================================================
--- fred2/shipeditordlg.cpp (revision 5691)
+++ fred2/shipeditordlg.cpp (working copy)
@@ -1002,8 +1002,10 @@
int CShipEditorDlg::update_data(int redraw)
{
char *str, old_name[255];
+ CString lft;
object *ptr;
int i, z, wing;
+ size_t t;
CSingleLock sync(&CS_cur_object_index), sync2(&CS_update);
nprintf(("Fred routing", "Ship dialog save\n"));
@@ -1069,6 +1071,39 @@
UpdateData(FALSE);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_ship_name, Iff_info[i].iff_name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This ship name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_ship_name = _T(Ships[single_ship].ship_name);
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_ship_name, Ai_tp_list[t].name))
+ {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This ship name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_ship_name = _T(Ships[single_ship].ship_name);
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_ship_name)) {
if (bypass_errors)
@@ -1085,7 +1120,7 @@
UpdateData(FALSE);
}
- if(jumpnode_get_by_name(m_ship_name) != NULL)
+ if(jumpnode_get_by_name(m_ship_name) != NULL)
{
if (bypass_errors)
return 1;
@@ -1101,7 +1136,23 @@
m_ship_name = _T(Ships[single_ship].ship_name);
UpdateData(FALSE);
}
+
+ lft = m_ship_name.Left(1);
+ if (!stricmp(lft, "<")) {
+ if (bypass_errors)
+ return 1;
+ bypass_errors = 1;
+ z = MessageBox("Ship names not allowed to begin with <\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_ship_name = _T(Ships[single_ship].ship_name);
+ UpdateData(FALSE);
+ }
+
wing = Ships[single_ship].wingnum;
if (wing >= 0) {
Assert((wing < MAX_WINGS) && Wings[wing].wave_count);
Index: fred2/waypointpathdlg.cpp
===================================================================
--- fred2/waypointpathdlg.cpp (revision 5691)
+++ fred2/waypointpathdlg.cpp (working copy)
@@ -21,6 +21,7 @@
#include "ai/aigoals.h"
#include "starfield/starfield.h"
#include "jumpnode/jumpnode.h"
+#include "iff_defs/iff_defs.h"
#define ID_JUMP_NODE_MENU 8000
#define ID_WAYPOINT_MENU 9000
@@ -147,6 +148,8 @@
char *str, old_name[255];
int i, z;
object *ptr;
+ size_t t;
+ CString lft;
if (!GetSafeHwnd())
return 0;
@@ -178,7 +181,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
if (!stricmp(m_name, Ships[ptr->instance].ship_name)) {
if (bypass_errors)
return 1;
@@ -198,9 +201,43 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_name, Iff_info[i].iff_name))
+ {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This waypoint path name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(Waypoint_lists[cur_waypoint_list].name);
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_name, Ai_tp_list[t].name))
+ {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This waypoint path name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(Waypoint_lists[cur_waypoint_list].name);
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
- {
- if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name) && (i != cur_waypoint_list)) {
+ if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name) && (i != cur_waypoint_list))
+ {
if (bypass_errors)
return 1;
@@ -214,7 +251,6 @@
m_name = _T(Waypoint_lists[cur_waypoint_list].name);
UpdateData(FALSE);
}
- }
if(jumpnode_get_by_name(m_name) != NULL)
{
@@ -232,6 +268,23 @@
UpdateData(FALSE);
}
+ lft = m_name.Left(1);
+ if (!stricmp(lft, "<")) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("Waypoint names not allowed to begin with <\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(Waypoint_lists[cur_waypoint_list].name);
+ UpdateData(FALSE);
+ }
+
+
strcpy_s(old_name, Waypoint_lists[cur_waypoint_list].name);
string_copy(Waypoint_lists[cur_waypoint_list].name, m_name, NAME_LENGTH, 1);
@@ -265,7 +318,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
if (!stricmp(m_name, Ships[ptr->instance].ship_name)) {
if (bypass_errors)
return 1;
@@ -285,6 +338,38 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_name, Iff_info[i].iff_name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This jump node name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(jnp->get_name_ptr());
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_name, Ai_tp_list[t].name)) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This jump node name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(jnp->get_name_ptr());
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
{
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) {
@@ -303,7 +388,22 @@
}
}
+ lft = m_name.Left(1);
+ if (!stricmp(lft, "<")) {
+ if (bypass_errors)
+ return 1;
+ bypass_errors = 1;
+ z = MessageBox("Jump node names not allowed to begin with <\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_name = _T(jnp->get_name_ptr());
+ UpdateData(FALSE);
+ }
+
strcpy_s(old_name, jnp->get_name_ptr());
string_copy(jnp->get_name_ptr(), m_name, NAME_LENGTH, 1);
Index: fred2/wing_editor.cpp
===================================================================
--- fred2/wing_editor.cpp (revision 5691)
+++ fred2/wing_editor.cpp (working copy)
@@ -22,6 +22,7 @@
#include "jumpnode/jumpnode.h"
#include "cfile/cfile.h"
#include "restrictpaths.h"
+#include "iff_defs/iff_defs.h"
#define ID_WING_MENU 9000
@@ -538,7 +539,9 @@
{
char *str, old_name[255], buf[512];
int i, z;
+ size_t t;
object *ptr;
+ CString lft;
nprintf(("Fred routing", "Wing dialog save\n"));
if (!GetSafeHwnd())
@@ -569,7 +572,7 @@
ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
- if (ptr->type == OBJ_SHIP) {
+ if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
if (!stricmp(m_wing_name, Ships[ptr->instance].ship_name)) {
if (bypass_errors)
return 1;
@@ -589,8 +592,43 @@
ptr = GET_NEXT(ptr);
}
+ for (i=0; i<Num_iffs; i++)
+ if (!stricmp(m_wing_name, Iff_info[i].iff_name))
+ {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This wing name is already being used by a team.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_wing_name = _T(Wings[cur_wing].name);
+ UpdateData(FALSE);
+ }
+
+ for ( t=0; t < Ai_tp_list.size(); t++)
+ if (!stricmp(m_wing_name, Ai_tp_list[t].name))
+ {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("This wing name is already being used by a target priority group.\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_wing_name = _T(Wings[cur_wing].name);
+ UpdateData(FALSE);
+ }
+
for (i=0; i<MAX_WAYPOINT_LISTS; i++)
- if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_wing_name)) {
+ if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_wing_name))
+ {
if (bypass_errors)
return 1;
@@ -605,7 +643,7 @@
UpdateData(FALSE);
}
- if(jumpnode_get_by_name(m_wing_name) != NULL)
+ if(jumpnode_get_by_name(m_wing_name) != NULL)
{
if (bypass_errors)
return 1;
@@ -619,8 +657,25 @@
m_wing_name = _T(Wings[cur_wing].name);
UpdateData(FALSE);
- }
+ }
+
+ lft = m_wing_name.Left(1);
+ if (!stricmp(lft, "<")) {
+ if (bypass_errors)
+ return 1;
+
+ bypass_errors = 1;
+ z = MessageBox("Wing names not allowed to begin with <\n"
+ "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL);
+
+ if (z == IDCANCEL)
+ return -1;
+
+ m_wing_name = _T(Wings[cur_wing].name);
+ UpdateData(FALSE);
+ }
+
strcpy_s(old_name, Wings[cur_wing].name);
string_copy(Wings[cur_wing].name, m_wing_name, NAME_LENGTH, 1);
update_data_safe();
|
---|