]> icculus.org git repositories - taylor/freespace2.git/blob - src/fred2/createwingdlg.cpp
fix issue with looping audio streams
[taylor/freespace2.git] / src / fred2 / createwingdlg.cpp
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 // CreateWingDlg.cpp : implementation file
10 //
11
12 #include "stdafx.h"
13 #include "fred.h"
14 #include "createwingdlg.h"
15 #include "object.h"
16 #include "linklist.h"
17 #include "parselo.h"
18
19 #ifdef _DEBUG
20 #define new DEBUG_NEW
21 #undef THIS_FILE
22 static char THIS_FILE[] = __FILE__;
23 #endif
24
25 /////////////////////////////////////////////////////////////////////////////
26 // create_wing_dlg dialog
27
28 create_wing_dlg::create_wing_dlg(CWnd* pParent /*=NULL*/)
29         : CDialog(create_wing_dlg::IDD, pParent)
30 {
31         //{{AFX_DATA_INIT(create_wing_dlg)
32         m_name = _T("");
33         //}}AFX_DATA_INIT
34 }
35
36 void create_wing_dlg::DoDataExchange(CDataExchange* pDX)
37 {
38         CDialog::DoDataExchange(pDX);
39         //{{AFX_DATA_MAP(create_wing_dlg)
40         DDX_Text(pDX, IDC_NAME, m_name);
41         //}}AFX_DATA_MAP
42
43         DDV_MaxChars(pDX, m_name, NAME_LENGTH - 4);
44 }
45
46 BEGIN_MESSAGE_MAP(create_wing_dlg, CDialog)
47         //{{AFX_MSG_MAP(create_wing_dlg)
48                 // NOTE: the ClassWizard will add message map macros here
49         //}}AFX_MSG_MAP
50 END_MESSAGE_MAP()
51
52 /////////////////////////////////////////////////////////////////////////////
53 // create_wing_dlg message handlers
54
55 void create_wing_dlg::OnOK()
56 {
57         char msg[512];
58         int i;
59         object *ptr;
60
61         UpdateData(TRUE);
62         UpdateData(TRUE);
63         m_name = drop_white_space((char *)(LPCSTR) m_name);
64         if (m_name.IsEmpty()) {
65                 MessageBox("You must give a name before you can continue.");
66                 return;
67         }
68
69         if (!strnicmp(m_name, "player ", 7)) {
70                 MessageBox("Wing names can't start with the word 'player'");
71                 return;
72         }
73
74         for (i=0; i<MAX_WINGS; i++)
75                 if (!stricmp(Wings[i].name, m_name) && Wings[i].wave_count) {
76                         sprintf(msg, "The name \"%s\" is already being used by another wing", m_name);
77                         MessageBox(msg);
78                         return;
79                 }
80
81         ptr = GET_FIRST(&obj_used_list);
82         while (ptr != END_OF_LIST(&obj_used_list)) {
83                 if (ptr->type == OBJ_SHIP) {
84                         i = ptr->instance;
85                         if (!strnicmp(m_name, Ships[i].ship_name, strlen(m_name))) {
86                                 char *namep;
87
88                                 namep = Ships[i].ship_name + strlen(m_name);
89                                 if (*namep == ' ') {
90                                         namep++;
91                                         while (*namep) {
92                                                 if (!isdigit(*namep))
93                                                         break;
94
95                                                 namep++;
96                                         }
97                                 }
98
99                                 if (!*namep) {
100                                         MessageBox("This wing name is already being used by a ship");
101                                         return;
102                                 }
103                         }
104                 }
105
106                 ptr = GET_NEXT(ptr);
107         }
108
109         for (i=0; i<MAX_WAYPOINT_LISTS; i++)
110                 if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) {
111                         MessageBox("This wing name is already being used by a waypoint path");
112                         return;
113                 }
114
115         CDialog::OnOK();
116 }
117