]> icculus.org git repositories - taylor/freespace2.git/blob - src/fred2/initialstatus.cpp
fix issue with looping audio streams
[taylor/freespace2.git] / src / fred2 / initialstatus.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 // InitialStatus.cpp : implementation file
10 //
11
12 #include "stdafx.h"
13 #include "fred.h"
14 #include "freddoc.h"
15 #include "initialstatus.h"
16 #include "management.h"
17 #include "linklist.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 // initial_status dialog
27
28 initial_status::initial_status(CWnd* pParent /*=NULL*/)
29         : CDialog(initial_status::IDD, pParent)
30 {
31         //{{AFX_DATA_INIT(initial_status)
32         m_damage = 0;
33         m_docked = -1;
34         m_shields = 0;
35         m_velocity = 0;
36         m_hull = 0;
37         m_dockee_point = -1;
38         m_docker_point = -1;
39         m_has_shields = FALSE;
40         m_locked = FALSE;
41         m_cargo_name = _T("");
42         //}}AFX_DATA_INIT
43         inited = 0;
44         cur_subsys = LB_ERR;
45         m_multi_edit = 0;
46 }
47
48 void initial_status::DoDataExchange(CDataExchange* pDX)
49 {
50         CString str;
51
52         CDialog::DoDataExchange(pDX);
53         //{{AFX_DATA_MAP(initial_status)
54         DDX_Control(pDX, IDC_HULL_SPIN, m_hull_spin);
55         DDX_Control(pDX, IDC_VELOCITY_SPIN, m_velocity_spin);
56         DDX_Control(pDX, IDC_SHIELDS_SPIN, m_shields_spin);
57         DDX_Control(pDX, IDC_DAMAGE_SPIN, m_damage_spin);
58         DDX_Text(pDX, IDC_DAMAGE, m_damage);
59         DDV_MinMaxInt(pDX, m_damage, 0, 100);
60         DDX_CBIndex(pDX, IDC_DOCKED, m_docked);
61         DDX_CBIndex(pDX, IDC_DOCKEE_POINT, m_dockee_point);
62         DDX_CBIndex(pDX, IDC_DOCKER_POINT, m_docker_point);
63         DDX_Check(pDX, IDC_HAS_SHIELDS, m_has_shields);
64         DDX_Check(pDX, IDC_LOCKED, m_locked);
65         DDX_Text(pDX, IDC_CARGO_NAME, m_cargo_name);
66         DDV_MaxChars(pDX, m_cargo_name, 20);
67         //}}AFX_DATA_MAP
68
69         if (pDX->m_bSaveAndValidate) {
70                 GetDlgItem(IDC_VELOCITY)->GetWindowText(str);
71                 m_velocity = atoi(str);
72                 if (m_velocity < 0)
73                         m_velocity = 0;
74                 if (m_velocity > 100)
75                         m_velocity = 100;
76
77                 GetDlgItem(IDC_SHIELDS)->GetWindowText(str);
78                 m_shields = atoi(str);
79                 if (m_shields < 0)
80                         m_shields = 0;
81                 if (m_shields > 100)
82                         m_shields = 100;
83
84                 GetDlgItem(IDC_HULL)->GetWindowText(str);
85                 m_hull = atoi(str);
86                 if (m_hull < 0)
87                         m_hull = 0;
88                 if (m_hull > 100)
89                         m_hull = 100;
90         }
91 }
92
93 BEGIN_MESSAGE_MAP(initial_status, CDialog)
94         //{{AFX_MSG_MAP(initial_status)
95         ON_LBN_SELCHANGE(IDC_SUBSYS, OnSelchangeSubsys)
96         ON_CBN_SELCHANGE(IDC_DOCKED, OnSelchangeDocked)
97         ON_CBN_SELCHANGE(IDC_DOCKER_POINT, OnSelchangeDockerPoint)
98         ON_BN_CLICKED(IDC_HAS_SHIELDS, OnHasShields)
99         ON_BN_CLICKED(IDC_LOCKED, OnLocked)
100         //}}AFX_MSG_MAP
101 END_MESSAGE_MAP()
102
103 /////////////////////////////////////////////////////////////////////////////
104 // initial_status message handlers
105
106 BOOL initial_status::OnInitDialog() 
107 {
108         int z, vflag, sflag, hflag, ship, type;
109         ship_subsys *ptr;
110         CComboBox *box;
111         CString str;
112         object *objp;
113
114         m_ship = cur_ship;
115         if (m_ship == -1) {
116                 SDL_assert((Objects[cur_object_index].type == OBJ_SHIP) || (Objects[cur_object_index].type == OBJ_START));
117                 m_ship = get_ship_from_obj(cur_object_index);
118                 SDL_assert(m_ship >= 0);
119         }
120
121         vflag = sflag = hflag = 0;
122         m_velocity = (int) Objects[cur_object_index].phys_info.speed;
123         m_shields = (int) Objects[cur_object_index].shields[0];
124         m_hull = (int) Objects[cur_object_index].hull_strength;
125         if (Objects[cur_object_index].flags & OF_NO_SHIELDS)
126                 m_has_shields = 0;
127         else
128                 m_has_shields = 1;
129
130         if (Ships[m_ship].flags & SF_LOCKED)
131                 m_locked = 1;
132         else
133                 m_locked = 0;
134
135         if (m_multi_edit) {
136                 objp = GET_FIRST(&obj_used_list);
137                 while (objp != END_OF_LIST(&obj_used_list)) {
138                         if (((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) && (objp->flags & OF_MARKED)) {
139                                 if (objp->phys_info.speed != m_velocity)
140                                         vflag = 1;
141                                 if ((int) objp->shields[0] != m_shields)
142                                         sflag = 1;
143                                 if ((int) objp->hull_strength != m_hull)
144                                         hflag = 1;
145                                 if (objp->flags & OF_NO_SHIELDS) {
146                                         if (m_has_shields)
147                                                 m_has_shields = 2;
148
149                                 } else {
150                                         if (!m_has_shields)
151                                                 m_has_shields = 2;
152                                 }
153
154                                 SDL_assert((objp->type == OBJ_SHIP) || (objp->type == OBJ_START));
155                                 if (Ships[get_ship_from_obj(objp)].flags & SF_LOCKED) {
156                                         if (!m_locked)
157                                                 m_locked = 2;
158
159                                 } else {
160                                         if (m_locked)
161                                                 m_locked = 2;
162                                 }
163                         }
164
165                         objp = GET_NEXT(objp);
166                 }
167         }
168
169         CDialog::OnInitDialog();
170         str.Format("%d", m_velocity);
171         GetDlgItem(IDC_VELOCITY)->SetWindowText(str);
172         str.Format("%d", m_shields);
173         GetDlgItem(IDC_SHIELDS)->SetWindowText(str);
174         str.Format("%d", m_hull);
175         GetDlgItem(IDC_HULL)->SetWindowText(str);
176
177         inited = 1;
178         box = (CComboBox *) GetDlgItem(IDC_DOCKED);
179         box->ResetContent();
180         if (!m_multi_edit) {
181                 z = box->AddString("Nothing");
182                 m_docked = 0;
183
184                 type = model_get_dock_types(Ships[m_ship].modelnum);
185                 objp = GET_FIRST(&obj_used_list);
186                 while (objp != END_OF_LIST(&obj_used_list)) {
187                         if ((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) {
188                                 ship = get_ship_from_obj(objp);
189                                 if ((ship != m_ship) && (ship_docking_valid(m_ship, ship) || ship_docking_valid(ship, m_ship))) {
190                                         if (model_get_dock_types(Ships[ship].modelnum) & type) {
191                                                 z = box->AddString(Ships[ship].ship_name);
192                                                 box->SetItemData(z, ship);
193                                         }
194                                 }
195                         }
196
197                         objp = GET_NEXT(objp);
198                 }
199
200                 m_docked_with = -1;
201                 z  = Ai_info[Ships[m_ship].ai_index].dock_objnum;
202                 if (z >= 0) {
203                         SDL_assert(Objects[z].type == OBJ_SHIP);
204                         z = m_docked_with = get_ship_from_obj(z);
205                         m_docked = box->FindStringExact(-1, Ships[z].ship_name);
206
207                         m_docker_index = Ai_info[Ships[m_ship].ai_index].dock_index;
208                         m_dockee_index = Ai_info[Ships[m_ship].ai_index].dockee_index;
209                         initialize_docker_points();
210                         initialize_dockee_points();
211
212                 } else {
213                         m_docker_index = m_dockee_index = m_docker_point = m_dockee_point = -1;
214                         GetDlgItem(IDC_DOCKER_POINT)->EnableWindow(FALSE);
215                         GetDlgItem(IDC_DOCKEE_POINT)->EnableWindow(FALSE);
216                 }
217
218                 ptr = GET_FIRST(&Ships[m_ship].subsys_list);
219                 while (ptr != END_OF_LIST(&Ships[m_ship].subsys_list)) {
220                         ((CListBox *) GetDlgItem(IDC_SUBSYS)) -> AddString(ptr->system_info->subobj_name);
221                         ptr = GET_NEXT(ptr);
222                 }
223
224         } else {
225                 GetDlgItem(IDC_DOCKED)->EnableWindow(FALSE);
226                 GetDlgItem(IDC_DOCKER_POINT)->EnableWindow(FALSE);
227                 GetDlgItem(IDC_DOCKEE_POINT)->EnableWindow(FALSE);
228                 GetDlgItem(IDC_SUBSYS)->EnableWindow(FALSE);
229                 GetDlgItem(IDC_DAMAGE)->EnableWindow(FALSE);
230         }
231
232         GetDlgItem(IDC_SHIELDS)->EnableWindow(m_has_shields ? TRUE : FALSE);
233         GetDlgItem(IDC_SHIELDS_SPIN)->EnableWindow(m_has_shields ? TRUE : FALSE);
234
235         m_velocity_spin.SetRange(0, 100);
236         m_hull_spin.SetRange(0, 100);
237         m_shields_spin.SetRange(0, 100);
238         m_damage_spin.SetRange(0, 100);
239         change_subsys();
240         UpdateData(FALSE);
241         if (vflag)
242                 GetDlgItem(IDC_VELOCITY)->SetWindowText("");
243         if (sflag)
244                 GetDlgItem(IDC_SHIELDS)->SetWindowText("");
245         if (hflag)
246                 GetDlgItem(IDC_HULL)->SetWindowText("");
247
248         return TRUE;
249 }
250
251 void initial_status::initialize_docker_points()
252 {
253         int i, type;
254         CComboBox *box;
255
256         box = (CComboBox *) GetDlgItem(IDC_DOCKER_POINT);
257         box->ResetContent();
258         if (m_docked_with < 0) {
259                 m_docker_index = m_docker_point = -1;
260                 return;
261         }
262
263         type = model_get_dock_types(Ships[m_docked_with].modelnum);
264         set_valid_dock_points(m_ship, type, box);
265         i = box->GetCount();
266         SDL_assert(i);  // this shouldn't happen.
267         while (i--)
268                 if ((int) box->GetItemData(i) == m_docker_index)
269                         break;
270
271         m_docker_point = i;
272         if (i < 0) {
273                 m_docker_point = 0;
274                 m_docker_index = box->GetItemData(0);
275         }
276 }
277
278 void initial_status::initialize_dockee_points()
279 {
280         int i, type;
281         CComboBox *box;
282
283         box = (CComboBox *) GetDlgItem(IDC_DOCKEE_POINT);
284         box->ResetContent();
285         if ((m_docked_with < 0) || (m_docker_index < 0)) {
286                 m_dockee_index = m_dockee_point = -1;
287                 return;
288         }
289
290         type = model_get_dock_index_type(Ships[m_ship].modelnum, m_docker_index);
291         set_valid_dock_points(m_docked_with, type, box);
292         i = box->GetCount();
293         SDL_assert(i);  // this shouldn't happen.
294         while (i--)
295                 if ((int) box->GetItemData(i) == m_dockee_index)
296                         break;
297
298         m_dockee_point = i;
299         if (i < 0) {
300                 m_dockee_point = 0;
301                 m_dockee_index = box->GetItemData(0);
302         }
303 }
304
305 void initial_status::change_subsys()
306 {
307         int z, cargo_index, enable = FALSE, enable_cargo_name = FALSE;
308         ship_subsys *ptr;
309
310         if (cur_subsys != LB_ERR) {
311                 ptr = GET_FIRST(&Ships[m_ship].subsys_list);
312                 while (cur_subsys--) {
313                         SDL_assert(ptr != END_OF_LIST(&Ships[m_ship].subsys_list));
314                         ptr = GET_NEXT(ptr);
315                 }
316
317                 MODIFY(ptr -> current_hits, 100.0f - (float) m_damage);
318
319                 // update cargo name
320                 if (strlen(m_cargo_name) > 0) {
321                         cargo_index = string_lookup(m_cargo_name, Cargo_names, Num_cargo);
322                         if (cargo_index == -1) {
323                                 if (Num_cargo < MAX_CARGO);
324                                 cargo_index = Num_cargo++;
325                                 strcpy(Cargo_names[cargo_index], m_cargo_name);
326                                 ptr->subsys_cargo_name = cargo_index;
327                         } else {
328                                 ptr->subsys_cargo_name = cargo_index;
329                         }
330                 } else {
331                         ptr->subsys_cargo_name = -1;
332                 }
333                 set_modified();
334         }
335
336         cur_subsys = z = ((CListBox *) GetDlgItem(IDC_SUBSYS)) -> GetCurSel();
337         if (z == LB_ERR) {
338                 m_damage = 100;
339
340         } else {
341                 ptr = GET_FIRST(&Ships[m_ship].subsys_list);
342                 while (z--) {
343                         SDL_assert(ptr != END_OF_LIST(&Ships[m_ship].subsys_list));
344                         ptr = GET_NEXT(ptr);
345                 }
346
347                 m_damage = 100 - (int) ptr -> current_hits;
348                 if ( (Ship_info[Ships[m_ship].ship_info_index].flags & SIF_HUGE_SHIP) && valid_cap_subsys_cargo_list(ptr->system_info->subobj_name) ) {
349                         enable_cargo_name = TRUE;
350                         if (ptr->subsys_cargo_name != -1) {
351                                 m_cargo_name = Cargo_names[ptr->subsys_cargo_name];
352                         } else {
353                                 m_cargo_name = _T("");
354                         }
355                 } else {
356                         m_cargo_name = _T("");
357                 }
358                 enable = TRUE;
359         }
360
361         GetDlgItem(IDC_DAMAGE) -> EnableWindow(enable);
362         GetDlgItem(IDC_DAMAGE_SPIN) -> EnableWindow(enable);
363         GetDlgItem(IDC_CARGO_NAME)->EnableWindow(enable && enable_cargo_name);
364         UpdateData(FALSE);
365 }
366
367 void initial_status::OnOK()
368 {
369         char buf[256];
370         int z, obj, vflag = 0, sflag = 0, hflag = 0;
371         object *o1, *o2, *objp;
372
373         if (GetDlgItem(IDC_VELOCITY)->GetWindowText(buf, 255))
374                 vflag = 1;
375         if (GetDlgItem(IDC_SHIELDS)->GetWindowText(buf, 255))
376                 sflag = 1;
377         if (GetDlgItem(IDC_HULL)->GetWindowText(buf, 255))
378                 hflag = 1;
379
380         UpdateData(TRUE);
381         UpdateData(TRUE);
382         change_subsys();
383         if (m_multi_edit) {
384                 objp = GET_FIRST(&obj_used_list);
385                 while (objp != END_OF_LIST(&obj_used_list)) {
386                         if (((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) && (objp->flags & OF_MARKED)) {
387                                 if (vflag)
388                                         MODIFY(objp->phys_info.speed, (float) m_velocity);
389
390                                 if (sflag)
391                                         MODIFY(objp->shields[0], (float) m_shields);
392
393                                 if (hflag)
394                                         MODIFY(objp->hull_strength, (float) m_hull);
395
396                                 if (m_has_shields == 1)
397                                         objp->flags &= ~OF_NO_SHIELDS;
398                                 else if (!m_has_shields)
399                                         objp->flags |= OF_NO_SHIELDS;
400
401                                 if (m_locked == 1)
402                                         Ships[get_ship_from_obj(objp)].flags |= SF_LOCKED;
403                                 else if (!m_has_shields)
404                                         Ships[get_ship_from_obj(objp)].flags &= ~SF_LOCKED;
405                         }
406
407                         objp = GET_NEXT(objp);
408                 }
409
410         } else {
411                 MODIFY(Objects[cur_object_index].phys_info.speed, (float) m_velocity);
412                 MODIFY(Objects[cur_object_index].shields[0], (float) m_shields);
413                 MODIFY(Objects[cur_object_index].hull_strength, (float) m_hull);
414                 if (m_has_shields)
415                         Objects[cur_object_index].flags &= ~OF_NO_SHIELDS;
416                 else
417                         Objects[cur_object_index].flags |= OF_NO_SHIELDS;
418
419                 if (m_locked == 1)
420                         Ships[m_ship].flags |= SF_LOCKED;
421                 else if (!m_locked)
422                         Ships[m_ship].flags &= ~SF_LOCKED;
423
424                 obj = -1;
425                 if (m_docked_with >= 0)
426                         obj = Ships[m_docked_with].objnum;
427
428                 z = Ai_info[Ships[m_ship].ai_index].dock_objnum;
429                 if (z >= 0) {
430                         int o;
431
432                         if (obj >= 0) {
433                                 o = Ai_info[Ships[get_ship_from_obj(obj)].ai_index].dock_objnum;
434                                 if (o >= 0)
435                                         undock(o);
436                         }
437
438                         undock(Ships[m_ship].objnum);
439                         Update_window = 1;
440                 }
441                 
442                 MODIFY(Ai_info[Ships[m_ship].ai_index].dock_objnum, obj);
443                 if (obj >= 0) {
444                         int s1type, s2type;
445
446                         // sets up the actual docking on the Fred screen.  After docking is done, use a loose
447                         // set of rules to possibly set an arrival cue to false
448                         o1 = &Objects[Ships[m_ship].objnum];
449                         o2 = &Objects[Ships[m_docked_with].objnum];
450                         m_docker_index = ((CComboBox *) GetDlgItem(IDC_DOCKER_POINT)) -> GetItemData(m_docker_point);
451                         MODIFY(Ai_info[Ships[m_ship].ai_index].dock_index, m_docker_index);
452                         m_dockee_index = ((CComboBox *) GetDlgItem(IDC_DOCKEE_POINT)) -> GetItemData(m_dockee_point);
453                         MODIFY(Ai_info[Ships[m_ship].ai_index].dockee_index, m_dockee_index);
454
455                         // based on the types of the two ships docked, set the arrival cue of the "smaller" ship
456                         // to false.
457                         s1type = Ship_info[Ships[m_ship].ship_info_index].flags;
458                         s2type = Ship_info[Ships[m_docked_with].ship_info_index].flags;
459
460                         if (ship_docking_valid(m_ship, m_docked_with)) {
461                                 ai_dock_with_object(o1, o2, 89, AIDO_DOCK_NOW, m_docker_index, m_dockee_index);
462                         } else {
463                                 ai_dock_with_object(o2, o1, 89, AIDO_DOCK_NOW, m_dockee_index, m_docker_index);
464                         }
465
466                         // based on the rules already defined for docking (see ship_docking_valid()), we can make
467                         // assumptions about what are "small" and "large" ships in this process.  Set the arrival
468                         // cue of the small ships to false so that they can properly arrive in the mission when
469                         // their parent does
470                         if ( (s2type & SIF_CARGO) || (s1type & SIF_BIG_SHIP) ) {
471                                 reset_arrival_to_false( m_docked_with );
472                         } else if ( (s1type & SIF_CARGO) || (s2type & SIF_BIG_SHIP) ) {
473                                 reset_arrival_to_false( m_ship );
474                         } else {
475                                 // default rule -- pick one!
476                                 reset_arrival_to_false( m_ship );
477                         }
478
479                         SDL_assert ( (Ships[m_ship].flags & SF_INITIALLY_DOCKED) || (Ships[m_docked_with].flags & SF_INITIALLY_DOCKED) );
480
481                         Update_window = 1;
482                 }
483
484                 if (Update_window)
485                         update_map_window();
486         }
487
488         CDialog::OnOK();
489 }
490
491 void initial_status::undock(int obj)
492 {
493         int o2;
494         vector v;
495         int ship_num, other_ship_num;
496
497         o2 = Ai_info[Ships[get_ship_from_obj(obj)].ai_index].dock_objnum;
498         if (o2 < 0)
499                 return;
500
501         vm_vec_sub(&v, &Objects[obj].pos, &Objects[o2].pos);
502         vm_vec_normalize(&v);
503         ship_num = get_ship_from_obj(obj);
504         other_ship_num = get_ship_from_obj(o2);
505
506         if (ship_docking_valid(ship_num, other_ship_num) )
507                 vm_vec_scale_add2(&Objects[obj].pos, &v, Objects[obj].radius * 2.0f);
508         else
509                 vm_vec_scale_add2(&Objects[o2].pos, &v, Objects[o2].radius * -2.0f);
510
511         Ai_info[Ships[ship_num].ai_index].dock_objnum = -1;
512         Ai_info[Ships[other_ship_num].ai_index].dock_objnum = -1;
513
514         // check to see if one of these ships has an arrival cue of false.  If so, then
515         // reset it back to default value of true.  be sure to correctly update before
516         // and after setting data.
517         Ship_editor_dialog.update_data(1);
518         if ( Ships[ship_num].arrival_cue == Locked_sexp_false ) {
519                 Ships[ship_num].arrival_cue = Locked_sexp_true;
520         } else if ( Ships[other_ship_num].arrival_cue == Locked_sexp_false ) {
521                 Ships[other_ship_num].arrival_cue = Locked_sexp_true;
522         }
523
524         // reset the initially docked flags on both ships (only one will be set, but this s
525         // just for safety!)
526         Ships[ship_num].flags &= ~(SF_INITIALLY_DOCKED);
527         Ships[other_ship_num].flags &= ~(SF_INITIALLY_DOCKED);
528         Ship_editor_dialog.initialize_data(1);
529
530 }
531
532 void initial_status::OnSelchangeSubsys() 
533 {
534         UpdateData(TRUE);
535         UpdateData(TRUE);
536         change_subsys();
537 }
538
539 void initial_status::OnSelchangeDocked() 
540 {
541         UpdateData(TRUE);
542         UpdateData(TRUE);
543         if (m_docked) {
544                 GetDlgItem(IDC_DOCKER_POINT)->EnableWindow(TRUE);
545                 GetDlgItem(IDC_DOCKEE_POINT)->EnableWindow(TRUE);
546
547                 m_docked_with = ((CComboBox *) GetDlgItem(IDC_DOCKED)) -> GetItemData(m_docked);
548                 initialize_docker_points();
549                 initialize_dockee_points();
550
551         } else {  // selected 'nothing' as being docked with
552                 m_docked_with = m_docker_index = m_dockee_index = m_docker_point = m_dockee_point = -1;
553                 GetDlgItem(IDC_DOCKER_POINT)->EnableWindow(FALSE);
554                 GetDlgItem(IDC_DOCKEE_POINT)->EnableWindow(FALSE);
555         }
556
557         UpdateData(FALSE);
558 }
559
560 void initial_status::OnSelchangeDockerPoint() 
561 {
562         UpdateData(TRUE);
563         UpdateData(TRUE);
564         initialize_dockee_points();
565         UpdateData(FALSE);
566 }
567
568 void initial_status::OnHasShields() 
569 {
570         if (m_has_shields == 1)
571                 m_has_shields = 0;
572         else
573                 m_has_shields = 1;
574
575         ((CButton *) GetDlgItem(IDC_HAS_SHIELDS))->SetCheck(m_has_shields);
576         GetDlgItem(IDC_SHIELDS)->EnableWindow(m_has_shields);
577         GetDlgItem(IDC_SHIELDS_SPIN)->EnableWindow(m_has_shields);
578 }
579
580 // function to set the arrival cue of a ship to false
581 void initial_status::reset_arrival_to_false( int shipnum )
582 {
583         char buf[256];
584
585         // if the cue is not false, make it false.  Be sure to all ship editor dialog functions
586         // to update date before and after we modify the cue.
587         if ( Ships[shipnum].arrival_cue != Locked_sexp_false ) {
588                 Ship_editor_dialog.update_data(1);
589                 free_sexp2(Ships[shipnum].arrival_cue);
590                 Ships[shipnum].arrival_cue = Locked_sexp_false;
591                 Ship_editor_dialog.initialize_data(1);
592                 sprintf(buf, "Setting arrival cue of ship %s\nto false for initial docking purposes.", Ships[shipnum].ship_name);
593                 MessageBox(buf, "", MB_OK | MB_ICONEXCLAMATION);
594         }
595
596         Ships[shipnum].flags |= SF_INITIALLY_DOCKED;
597 }
598
599 void initial_status::OnLocked() 
600 {
601         if (m_locked == 1)
602                 m_locked = 0;
603         else
604                 m_locked = 1;
605
606         ((CButton *) GetDlgItem(IDC_LOCKED))->SetCheck(m_locked);
607 }
608