1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
// CreateWingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "FRED.h"
#include "CreateWingDlg.h"
#include "object/object.h"
#include "object/waypoint.h"
#include "globalincs/linklist.h"
#include "parse/parselo.h"
#include "iff_defs/iff_defs.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// create_wing_dlg dialog
create_wing_dlg::create_wing_dlg(CWnd* pParent /*=NULL*/)
: CDialog(create_wing_dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(create_wing_dlg)
m_name = _T("");
//}}AFX_DATA_INIT
}
void create_wing_dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(create_wing_dlg)
DDX_Text(pDX, IDC_NAME, m_name);
//}}AFX_DATA_MAP
DDV_MaxChars(pDX, m_name, NAME_LENGTH - 4);
}
BEGIN_MESSAGE_MAP(create_wing_dlg, CDialog)
//{{AFX_MSG_MAP(create_wing_dlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// create_wing_dlg message handlers
void create_wing_dlg::OnOK()
{
CString msg;
int i;
object *ptr;
UpdateData(TRUE);
UpdateData(TRUE);
m_name = drop_white_space((char *)(LPCSTR) m_name);
if (m_name.IsEmpty()) {
MessageBox("You must give a name before you can continue.");
return;
}
for (i=0; i<MAX_WINGS; i++)
if (!stricmp(Wings[i].name, m_name) && Wings[i].wave_count) {
msg.Format("The name \"%s\" is already being used by another wing", static_cast<LPCTSTR>(m_name));
MessageBox(msg);
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;
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;
}
}
}
ptr = GET_NEXT(ptr);
}
// We don't need to check teams. "Unknown" is a valid name and also an IFF.
for ( i=0; i < (int)Ai_tp_list.size(); i++) {
if (!stricmp(m_name, Ai_tp_list[i].name)) {
msg.Format("The name \"%s\" is already being used by a target priority group", static_cast<LPCTSTR>(m_name));
MessageBox(msg);
return;
}
}
if (find_matching_waypoint_list((LPCSTR) m_name) != NULL)
{
MessageBox("This wing name is already being used by a waypoint path");
return;
}
if (!stricmp(m_name.Left(1), "<")) {
MessageBox("Wing names not allowed to begin with <");
return;
}
CDialog::OnOK();
}
|