Skyscraper 2.0
elevatorcars.cpp
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 Alpha - Script Processor - Elevator Car Section
3 Copyright (C)2003-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23#include "globals.h"
24#include "sbs.h"
25#include "enginecontext.h"
26#include "elevator.h"
27#include "elevatorcar.h"
28#include "elevatordoor.h"
29#include "trigger.h"
30#include "control.h"
31#include "door.h"
32#include "buttonpanel.h"
33#include "directional.h"
34#include "floorindicator.h"
35#include "model.h"
36#include "sound.h"
37#include "reverb.h"
38#include "wall.h"
39#include "scriptproc.h"
40#include "section.h"
41#include "indicator.h"
42
43using namespace SBS;
44
45namespace Skyscraper {
46
51
53{
54 //Process elevator cars
55
56 //get car object
57 ElevatorCar *car = 0;
58 Elevator *elev = 0;
59 if (config->SectionNum == 6)
60 {
62 if (elev)
63 car = elev->GetCar(config->Current);
64 }
65 else
66 {
67 //get default car if not in a separate car section
69 if (elev)
70 car = elev->GetCar(1);
71 }
72
73 if (!elev)
74 return sError;
75
76 //create car if not created already
77 if (!car)
78 car = elev->AddCar();
79
80 if (!car)
81 return sError;
82
83 //replace variables with actual values
84 if (config->SectionNum == 6) //only run if not being called from elevator function
85 {
88
89 //IF/While statement stub (continue to global commands for processing)
90 if (StartsWithNoCase(LineData, "if") || StartsWithNoCase(LineData, "while"))
91 return sContinue;
92
93 //process math functions
94 if (MathFunctions(LineData) == sError)
95 return sError;
96
97 //process functions
98 if (parent->FunctionProc() == true)
99 return sNextLine;
100 }
101
102 //get text after equal sign
103 bool equals;
104 std::string value = GetAfterEquals(LineData, equals);
105
106 //parameters
107
108 //Name parameter
109 if (StartsWithNoCase(LineData, "name"))
110 {
111 if (equals == false)
112 return ScriptError("Syntax error");
113 car->Name = value;
114 return sNextLine;
115 }
116 //OpenSpeed parameter
117 if (StartsWithNoCase(LineData, "openspeed"))
118 {
119 if (equals == false)
120 return ScriptError("Syntax error");
121 if (elev->Created == false)
122 return ScriptError("Elevator not created yet");
123 if (car->Created == false)
124 return ScriptError("Car not created yet");
125 std::string str = GetBeforeEquals(LineData);
126 int door = 0;
127 if (!IsNumeric(str, door))
128 return ScriptError("No door specified");
129 if (door == 0 || door > car->NumDoors)
130 return ScriptError("Invalid door number");
131 std::string str2 = Calc(value);
132 if (!IsNumeric(str2, car->GetDoor(door)->OpenSpeed))
133 return ScriptError("Invalid value");
134 return sNextLine;
135 }
136 //Doors parameter
137 if (StartsWithNoCase(LineData, "doors "))
138 {
139 if (equals == false)
140 return ScriptError("Syntax error");
141 std::string str = Calc(value);
142 if (!IsNumeric(str, car->NumDoors))
143 return ScriptError("Invalid value");
144 return sNextLine;
145 }
146 //ServicedFloors parameter
147 if (StartsWithNoCase(LineData, "servicedfloors"))
148 {
149 //copy string listing of serviced floors into array
150 int params = SplitAfterEquals(LineData, false);
151 if (params < 1)
152 return ScriptError("Syntax Error");
153
154 for (int line = 0; line < params; line++)
155 {
156 int start, end;
157 if (GetRange(tempdata[line], start, end) == true)
158 {
159 for (int k = start; k <= end; k++)
160 {
161 if (!car->AddServicedFloor(k))
162 return ScriptError();
163 }
164 }
165 else
166 {
167 int data;
168 std::string str = Calc(tempdata[line]);
169 if (!IsNumeric(str, data))
170 return ScriptError("Invalid value");
171
172 if (!car->AddServicedFloor(data))
173 return ScriptError();
174 }
175 }
176 return sNextLine;
177 }
178 //DisplayFloors parameter
179 if (StartsWithNoCase(LineData, "displayfloors"))
180 {
181 //copy string listing of serviced floors into array
182 int params = SplitAfterEquals(LineData, false);
183 if (params < 1)
184 return ScriptError("Syntax Error");
185
186 for (int line = 0; line < params; line++)
187 {
188 int start, end;
189 if (GetRange(tempdata[line], start, end) == true)
190 {
191 for (int k = start; k <= end; k++)
192 {
193 car->AddDisplayFloor(k);
194 }
195 }
196 else
197 {
198 int data;
199 if (!IsNumeric(tempdata[line], data))
200 return ScriptError("Invalid value");
201 car->AddDisplayFloor(data);
202 }
203 }
204 return sNextLine;
205 }
206 //DoorTimer parameter
207 if (StartsWithNoCase(LineData, "doortimer"))
208 {
209 if (equals == false)
210 return ScriptError("Syntax error");
211 if (elev->Created == false)
212 return ScriptError("Elevator not created yet");
213 if (car->Created == false)
214 return ScriptError("Car not created yet");
215 std::string str = GetBeforeEquals(LineData);
216 int door = 0;
217 if (!IsNumeric(str, door))
218 return ScriptError("No door specified");
219 if (door == 0 || door > car->NumDoors)
220 return ScriptError("Invalid door number");
221 std::string str2 = Calc(value);
222 if (!IsNumeric(str2, car->GetDoor(door)->DoorTimer))
223 return ScriptError("Invalid value");
224 return sNextLine;
225 }
226 //QuickClose parameter
227 if (StartsWithNoCase(LineData, "quickclose"))
228 {
229 if (equals == false)
230 return ScriptError("Syntax error");
231 if (elev->Created == false)
232 return ScriptError("Elevator not created yet");
233 if (car->Created == false)
234 return ScriptError("Car not created yet");
235 std::string str = GetBeforeEquals(LineData);
236 int door = 0;
237 if (!IsNumeric(str, door))
238 return ScriptError("No door specified");
239 if (door == 0 || door > car->NumDoors)
240 return ScriptError("Invalid door number");
241 std::string str2 = Calc(value);
242 if (!IsNumeric(str2, car->GetDoor(door)->QuickClose))
243 return ScriptError("Invalid value");
244 return sNextLine;
245 }
246 //NudgeTimer parameter
247 if (StartsWithNoCase(LineData, "nudgetimer"))
248 {
249 if (equals == false)
250 return ScriptError("Syntax error");
251 if (elev->Created == false)
252 return ScriptError("Elevator not created yet");
253 if (car->Created == false)
254 return ScriptError("Car not created yet");
255 std::string str = GetBeforeEquals(LineData);
256 int door = 0;
257 if (!IsNumeric(str, door))
258 return ScriptError("No door specified");
259 if (door == 0 || door > car->NumDoors)
260 return ScriptError("Invalid door number");
261 std::string str2 = Calc(value);
262 if (!IsNumeric(str2, car->GetDoor(door)->NudgeTimer))
263 return ScriptError("Invalid value");
264 return sNextLine;
265 }
266 //SlowSpeed parameter
267 if (StartsWithNoCase(LineData, "slowspeed"))
268 {
269 if (equals == false)
270 return ScriptError("Syntax error");
271 if (elev->Created == false)
272 return ScriptError("Elevator not created yet");
273 if (car->Created == false)
274 return ScriptError("Car not created yet");
275 std::string str = GetBeforeEquals(LineData);
276 int door = 0;
277 if (!IsNumeric(str, door))
278 return ScriptError("No door specified");
279 if (door == 0 || door > car->NumDoors)
280 return ScriptError("Invalid door number");
281 std::string str2 = Calc(value);
282 if (!IsNumeric(str2, car->GetDoor(door)->SlowSpeed))
283 return ScriptError("Invalid value");
284 return sNextLine;
285 }
286 //ManualSpeed parameter
287 if (StartsWithNoCase(LineData, "manualspeed"))
288 {
289 if (equals == false)
290 return ScriptError("Syntax error");
291 if (elev->Created == false)
292 return ScriptError("Elevator not created yet");
293 if (car->Created == false)
294 return ScriptError("Car not created yet");
295 std::string str = GetBeforeEquals(LineData);
296 int door = 0;
297 if (!IsNumeric(str, door))
298 return ScriptError("No door specified");
299 if (door == 0 || door > car->NumDoors)
300 return ScriptError("Invalid door number");
301 std::string str2 = Calc(value);
302 if (!IsNumeric(str2, car->GetDoor(door)->ManualSpeed))
303 return ScriptError("Invalid value");
304 return sNextLine;
305 }
306 //OpenSound parameter
307 if (StartsWithNoCase(LineData, "opensound"))
308 {
309 if (equals == false)
310 return ScriptError("Syntax error");
311 if (elev->Created == false)
312 return ScriptError("Elevator not created yet");
313 if (car->Created == false)
314 return ScriptError("Car not created yet");
315 std::string str = GetBeforeEquals(LineData);
316 int door = 0;
317 if (!IsNumeric(str, door))
318 return ScriptError("No door specified");
319 if (door == 0 || door > car->NumDoors)
320 return ScriptError("Invalid door number");
321
322 //check to see if file exists
323 parent->CheckFile("data/" + value);
324
325 car->GetDoor(door)->OpenSound = value;
326 return sNextLine;
327 }
328 //CloseSound parameter
329 if (StartsWithNoCase(LineData, "closesound"))
330 {
331 if (equals == false)
332 return ScriptError("Syntax error");
333 if (elev->Created == false)
334 return ScriptError("Elevator not created yet");
335 if (car->Created == false)
336 return ScriptError("Car not created yet");
337 std::string str = GetBeforeEquals(LineData);
338 int door = 0;
339 if (!IsNumeric(str, door))
340 return ScriptError("No door specified");
341 if (door == 0 || door > car->NumDoors)
342 return ScriptError("Invalid door number");
343
344 //check to see if file exists
345 parent->CheckFile("data/" + value);
346
347 car->GetDoor(door)->CloseSound = value;
348 return sNextLine;
349 }
350 //NudgeSound parameter
351 if (StartsWithNoCase(LineData, "nudgesound"))
352 {
353 if (equals == false)
354 return ScriptError("Syntax error");
355 if (elev->Created == false)
356 return ScriptError("Elevator not created yet");
357 if (car->Created == false)
358 return ScriptError("Car not created yet");
359 std::string str = GetBeforeEquals(LineData);
360 int door = 0;
361 if (!IsNumeric(str, door))
362 return ScriptError("No door specified");
363 if (door == 0 || door > car->NumDoors)
364 return ScriptError("Invalid door number");
365
366 //check to see if file exists
367 parent->CheckFile("data/" + value);
368
369 car->GetDoor(door)->NudgeSound = value;
370 return sNextLine;
371 }
372 //StartSound parameter
373 if (StartsWithNoCase(LineData, "startsound"))
374 {
375 //backwards compatibility
376 if (equals == false)
377 return ScriptError("Syntax error");
378
379 if (warn_deprecated == true)
380 ScriptWarning("Command deprecated");
381
382 //check to see if file exists
383 parent->CheckFile("data/" + value);
384
385 car->UpStartSound = value;
386 car->DownStartSound = value;
387
388 //turn off motor sounds
389 elev->MotorUpStartSound = "";
390 elev->MotorDownStartSound = "";
391 elev->MotorUpRunSound = "";
392 elev->MotorDownRunSound = "";
393 elev->MotorUpStopSound = "";
394 elev->MotorDownStopSound = "";
395 elev->MotorIdleSound = "";
396 return sNextLine;
397 }
398 //MoveSound parameter
399 if (StartsWithNoCase(LineData, "movesound"))
400 {
401 //backwards compatibility
402 if (equals == false)
403 return ScriptError("Syntax error");
404
405 if (warn_deprecated == true)
406 ScriptWarning("Command deprecated");
407
408 //check to see if file exists
409 parent->CheckFile("data/" + value);
410
411 car->UpMoveSound = value;
412 car->DownMoveSound = value;
413
414 //turn off motor sounds
415 elev->MotorUpStartSound = "";
416 elev->MotorDownStartSound = "";
417 elev->MotorUpRunSound = "";
418 elev->MotorDownRunSound = "";
419 elev->MotorUpStopSound = "";
420 elev->MotorDownStopSound = "";
421 elev->MotorIdleSound = "";
422 return sNextLine;
423 }
424 //StopSound parameter
425 if (StartsWithNoCase(LineData, "stopsound"))
426 {
427 //backwards compatibility
428 if (equals == false)
429 return ScriptError("Syntax error");
430
431 if (warn_deprecated == true)
432 ScriptWarning("Command deprecated");
433
434 //check to see if file exists
435 parent->CheckFile("data/" + value);
436
437 car->UpStopSound = value;
438 car->DownStopSound = value;
439
440 //turn off motor sounds
441 elev->MotorUpStartSound = "";
442 elev->MotorDownStartSound = "";
443 elev->MotorUpRunSound = "";
444 elev->MotorDownRunSound = "";
445 elev->MotorUpStopSound = "";
446 elev->MotorDownStopSound = "";
447 elev->MotorIdleSound = "";
448 return sNextLine;
449 }
450 //IdleSound parameter
451 if (StartsWithNoCase(LineData, "idlesound"))
452 {
453 //backwards compatibility
454 if (equals == false)
455 return ScriptError("Syntax error");
456
457 if (warn_deprecated == true)
458 ScriptWarning("Command deprecated");
459
460 //check to see if file exists
461 parent->CheckFile("data/" + value);
462
463 car->IdleSound = value;
464
465 //turn off motor sounds
466 elev->MotorUpStartSound = "";
467 elev->MotorDownStartSound = "";
468 elev->MotorUpRunSound = "";
469 elev->MotorDownRunSound = "";
470 elev->MotorUpStopSound = "";
471 elev->MotorDownStopSound = "";
472 elev->MotorIdleSound = "";
473 return sNextLine;
474 }
475 //CarStartSound parameter
476 if (StartsWithNoCase(LineData, "carstartsound"))
477 {
478 if (equals == false)
479 return ScriptError("Syntax error");
480
481 //check to see if file exists
482 parent->CheckFile("data/" + value);
483
484 car->UpStartSound = value;
485 car->DownStartSound = value;
486 return sNextLine;
487 }
488 //CarUpStartSound parameter
489 if (StartsWithNoCase(LineData, "carupstartsound"))
490 {
491 if (equals == false)
492 return ScriptError("Syntax error");
493
494 //check to see if file exists
495 parent->CheckFile("data/" + value);
496
497 car->UpStartSound = value;
498 return sNextLine;
499 }
500 //CarDownStartSound parameter
501 if (StartsWithNoCase(LineData, "cardownstartsound"))
502 {
503 if (equals == false)
504 return ScriptError("Syntax error");
505
506 //check to see if file exists
507 parent->CheckFile("data/" + value);
508
509 car->DownStartSound = value;
510 return sNextLine;
511 }
512 //CarMoveSound parameter
513 if (StartsWithNoCase(LineData, "carmovesound"))
514 {
515 if (equals == false)
516 return ScriptError("Syntax error");
517
518 //check to see if file exists
519 parent->CheckFile("data/" + value);
520
521 car->UpMoveSound = value;
522 car->DownMoveSound = value;
523 return sNextLine;
524 }
525 //CarUpMoveSound parameter
526 if (StartsWithNoCase(LineData, "carupmovesound"))
527 {
528 if (equals == false)
529 return ScriptError("Syntax error");
530
531 //check to see if file exists
532 parent->CheckFile("data/" + value);
533
534 car->UpMoveSound = value;
535 return sNextLine;
536 }
537 //CarDownMoveSound parameter
538 if (StartsWithNoCase(LineData, "cardownmovesound"))
539 {
540 if (equals == false)
541 return ScriptError("Syntax error");
542
543 //check to see if file exists
544 parent->CheckFile("data/" + value);
545
546 car->DownMoveSound = value;
547 return sNextLine;
548 }
549 //CarStopSound parameter
550 if (StartsWithNoCase(LineData, "carstopsound"))
551 {
552 if (equals == false)
553 return ScriptError("Syntax error");
554
555 //check to see if file exists
556 parent->CheckFile("data/" + value);
557
558 car->UpStopSound = value;
559 car->DownStopSound = value;
560 return sNextLine;
561 }
562 //CarUpStopSound parameter
563 if (StartsWithNoCase(LineData, "carupstopsound"))
564 {
565 if (equals == false)
566 return ScriptError("Syntax error");
567
568 //check to see if file exists
569 parent->CheckFile("data/" + value);
570
571 car->UpStopSound = value;
572 return sNextLine;
573 }
574 //CarDownStopSound parameter
575 if (StartsWithNoCase(LineData, "cardownstopsound"))
576 {
577 if (equals == false)
578 return ScriptError("Syntax error");
579
580 //check to see if file exists
581 parent->CheckFile("data/" + value);
582
583 car->DownStopSound = value;
584 return sNextLine;
585 }
586 //CarIdleSound parameter
587 if (StartsWithNoCase(LineData, "caridlesound"))
588 {
589 if (equals == false)
590 return ScriptError("Syntax error");
591
592 //check to see if file exists
593 parent->CheckFile("data/" + value);
594
595 car->IdleSound = value;
596 return sNextLine;
597 }
598 //ChimeSound parameter
599 if (StartsWithNoCase(LineData, "chimesound"))
600 {
601 if (equals == false)
602 return ScriptError("Syntax error");
603 if (elev->Created == false)
604 return ScriptError("Elevator not created yet");
605 if (car->Created == false)
606 return ScriptError("Car not created yet");
607 std::string str = GetBeforeEquals(LineData);
608 int door = 0;
609 if (!IsNumeric(str, door))
610 return ScriptError("No door specified");
611 if (door == 0 || door > car->NumDoors)
612 return ScriptError("Invalid door number");
613
614 //check to see if file exists
615 parent->CheckFile("data/" + value);
616
617 car->GetDoor(door)->UpChimeSound = value;
618 car->GetDoor(door)->DownChimeSound = value;
619 return sNextLine;
620 }
621 //UpChimeSound parameter
622 if (StartsWithNoCase(LineData, "upchimesound"))
623 {
624 if (equals == false)
625 return ScriptError("Syntax error");
626 if (elev->Created == false)
627 return ScriptError("Elevator not created yet");
628 if (car->Created == false)
629 return ScriptError("Car not created yet");
630 std::string str = GetBeforeEquals(LineData);
631 int door = 0;
632 if (!IsNumeric(str, door))
633 return ScriptError("No door specified");
634 if (door == 0 || door > car->NumDoors)
635 return ScriptError("Invalid door number");
636
637 //check to see if file exists
638 parent->CheckFile("data/" + value);
639
640 car->GetDoor(door)->UpChimeSound = value;
641 return sNextLine;
642 }
643 //DownChimeSound parameter
644 if (StartsWithNoCase(LineData, "downchimesound"))
645 {
646 if (equals == false)
647 return ScriptError("Syntax error");
648 if (elev->Created == false)
649 return ScriptError("Elevator not created yet");
650 if (car->Created == false)
651 return ScriptError("Car not created yet");
652 std::string str = GetBeforeEquals(LineData);
653 int door = 0;
654 if (!IsNumeric(str, door))
655 return ScriptError("No door specified");
656 if (door == 0 || door > car->NumDoors)
657 return ScriptError("Invalid door number");
658
659 //check to see if file exists
660 parent->CheckFile("data/" + value);
661
662 car->GetDoor(door)->DownChimeSound = value;
663 return sNextLine;
664 }
665 //EarlyUpChimeSound parameter
666 if (StartsWithNoCase(LineData, "earlyupchimesound"))
667 {
668 if (equals == false)
669 return ScriptError("Syntax error");
670 if (elev->Created == false)
671 return ScriptError("Elevator not created yet");
672 if (car->Created == false)
673 return ScriptError("Car not created yet");
674 std::string str = GetBeforeEquals(LineData);
675 int door = 0;
676 if (!IsNumeric(str, door))
677 return ScriptError("No door specified");
678 if (door == 0 || door > car->NumDoors)
679 return ScriptError("Invalid door number");
680
681 //check to see if file exists
682 parent->CheckFile("data/" + value);
683
684 car->GetDoor(door)->EarlyUpChimeSound = value;
685 car->GetDoor(door)->EarlyUpSet = true;
686 return sNextLine;
687 }
688 //EarlyDownChimeSound parameter
689 if (StartsWithNoCase(LineData, "earlydownchimesound"))
690 {
691 if (equals == false)
692 return ScriptError("Syntax error");
693 if (elev->Created == false)
694 return ScriptError("Elevator not created yet");
695 if (car->Created == false)
696 return ScriptError("Car not created yet");
697 std::string str = GetBeforeEquals(LineData);
698 int door = 0;
699 if (!IsNumeric(str, door))
700 return ScriptError("No door specified");
701 if (door == 0 || door > car->NumDoors)
702 return ScriptError("Invalid door number");
703
704 //check to see if file exists
705 parent->CheckFile("data/" + value);
706
707 car->GetDoor(door)->EarlyDownChimeSound = value;
708 car->GetDoor(door)->EarlyDownSet = true;
709 return sNextLine;
710 }
711 //AlarmSoundStop parameter
712 if (StartsWithNoCase(LineData, "alarmsoundstop"))
713 {
714 if (equals == false)
715 return ScriptError("Syntax error");
716
717 //check to see if file exists
718 parent->CheckFile("data/" + value);
719
720 car->AlarmSoundStop = value;
721 return sNextLine;
722 }
723 //AlarmSound parameter
724 if (StartsWithNoCase(LineData, "alarmsound"))
725 {
726 if (equals == false)
727 return ScriptError("Syntax error");
728
729 //check to see if file exists
730 parent->CheckFile("data/" + value);
731
732 car->AlarmSound = value;
733 return sNextLine;
734 }
735 //BeepSound parameter
736 if (StartsWithNoCase(LineData, "beepsound"))
737 {
738 if (equals == false)
739 return ScriptError("Syntax error");
740
741 //check to see if file exists
742 parent->CheckFile("data/" + value);
743
744 car->SetBeepSound(value);
745 return sNextLine;
746 }
747 //FloorSound parameter
748 if (StartsWithNoCase(LineData, "floorsound"))
749 {
750 if (equals == false)
751 return ScriptError("Syntax error");
752
753 //check to see if file exists
754 parent->CheckFile("data/" + value);
755
756 car->SetFloorSound(value);
757 return sNextLine;
758 }
759 //UpMessage parameter
760 if (StartsWithNoCase(LineData, "upmessage"))
761 {
762 if (equals == false)
763 return ScriptError("Syntax error");
764
765 //check to see if file exists
766 parent->CheckFile("data/" + value);
767
768 car->SetMessageSound(true, true, value);
769 return sNextLine;
770 }
771 //DownMessage parameter
772 if (StartsWithNoCase(LineData, "downmessage"))
773 {
774 if (equals == false)
775 return ScriptError("Syntax error");
776
777 //check to see if file exists
778 parent->CheckFile("data/" + value);
779
780 car->SetMessageSound(true, false, value);
781 return sNextLine;
782 }
783 //MessageOnMove parameter
784 if (StartsWithNoCase(LineData, "messageonmove"))
785 {
786 if (equals == false)
787 return ScriptError("Syntax error");
788
789 car->MessageOnMove = ToBool(value);
790 return sNextLine;
791 }
792 //MessageOnStart parameter
793 if (StartsWithNoCase(LineData, "messageonstart"))
794 {
795 if (equals == false)
796 return ScriptError("Syntax error");
797
798 car->MessageOnStart = ToBool(value);
799 return sNextLine;
800 }
801 //MessageOnClose parameter
802 if (StartsWithNoCase(LineData, "messageonclose"))
803 {
804 if (equals == false)
805 return ScriptError("Syntax error");
806
807 car->MessageOnClose = ToBool(value);
808 return sNextLine;
809 }
810 //OpenMessage parameter
811 if (StartsWithNoCase(LineData, "openmessage"))
812 {
813 if (equals == false)
814 return ScriptError("Syntax error");
815
816 //check to see if file exists
817 parent->CheckFile("data/" + value);
818
819 car->SetMessageSound(false, true, value);
820 return sNextLine;
821 }
822 //CloseMessage parameter
823 if (StartsWithNoCase(LineData, "closemessage"))
824 {
825 if (equals == false)
826 return ScriptError("Syntax error");
827
828 //check to see if file exists
829 parent->CheckFile("data/" + value);
830
831 car->SetMessageSound(false, false, value);
832 return sNextLine;
833 }
834 //Music parameter
835 if (StartsWithNoCase(LineData, "music "))
836 {
837 if (equals == false)
838 return ScriptError("Syntax error");
839
840 //check to see if file exists
841 parent->CheckFile("data/" + value);
842
843 car->MusicUp = value;
844 car->MusicDown = value;
845 return sNextLine;
846 }
847 //MusicUp parameter
848 if (StartsWithNoCase(LineData, "musicup"))
849 {
850 if (equals == false)
851 return ScriptError("Syntax error");
852
853 //check to see if file exists
854 parent->CheckFile("data/" + value);
855
856 car->MusicUp = value;
857 return sNextLine;
858 }
859 //MusicDown parameter
860 if (StartsWithNoCase(LineData, "musicdown"))
861 {
862 if (equals == false)
863 return ScriptError("Syntax error");
864
865 //check to see if file exists
866 parent->CheckFile("data/" + value);
867
868 car->MusicDown = value;
869 return sNextLine;
870 }
871 //MusicOn parameter
872 if (StartsWithNoCase(LineData, "musicon "))
873 {
874 if (equals == false)
875 return ScriptError("Syntax error");
876
877 car->MusicOn = ToBool(value);
878 return sNextLine;
879 }
880 //MusicAlwaysOn parameter
881 if (StartsWithNoCase(LineData, "musicalwayson"))
882 {
883 if (equals == false)
884 return ScriptError("Syntax error");
885
886 car->MusicAlwaysOn = ToBool(value);
887 return sNextLine;
888 }
889 //MusicOnMove parameter
890 if (StartsWithNoCase(LineData, "musiconmove"))
891 {
892 if (equals == false)
893 return ScriptError("Syntax error");
894
895 car->MusicOnMove = ToBool(value);
896 }
897 //MusicPosition parameter
898 if (StartsWithNoCase(LineData, "musicposition"))
899 {
900 int params = SplitAfterEquals(LineData);
901 if (params != 3)
902 return ScriptError("Incorrect number of parameters");
903
904 //check numeric values
905 for (int i = 0; i <= 2; i++)
906 {
907 if (!IsNumeric(tempdata[i]))
908 return ScriptError("Invalid value: " + tempdata[i]);
909 }
910
911 car->MusicPosition = Vector3(ToFloat(tempdata[0]), ToFloat(tempdata[1]), ToFloat(tempdata[2]));
912 return sNextLine;
913 }
914 //InvalidInput parameter
915 if (StartsWithNoCase(LineData, "invalidinput"))
916 {
917 //copy string listing of elevators into array
918 int params = SplitAfterEquals(LineData);
919 if (params < 1)
920 return ScriptError("Syntax Error");
921
922 std::vector<std::string> inputs;
923
924 for (int line = 0; line < params; line++)
925 inputs.emplace_back(tempdata[line]);
926
927 car->InvalidInput = inputs;
928
929 return sNextLine;
930 }
931 //TimerDelay parameter
932 if (StartsWithNoCase(LineData, "timerdelay"))
933 {
934 if (equals == false)
935 return ScriptError("Syntax error");
936 std::string str = Calc(value);
937 float num = 0;
938 if (!IsNumeric(str, num))
939 return ScriptError("Invalid value");
940 car->TimerDelay = num;
941 return sNextLine;
942 }
943 //AutoEnable parameter
944 if (StartsWithNoCase(LineData, "autoenable"))
945 {
946 if (equals == false)
947 return ScriptError("Syntax error");
948
949 car->AutoEnable = ToBool(value);
950 return sNextLine;
951 }
952 //DoorSensor parameter
953 if (StartsWithNoCase(LineData, "doorsensor"))
954 {
955 if (equals == false)
956 return ScriptError("Syntax error");
957
958 if (elev->Created == false)
959 return ScriptError("Elevator not created yet");
960 if (car->Created == false)
961 return ScriptError("Car not created yet");
962
963 std::string str = GetBeforeEquals(LineData);
964 int door = 0;
965 if (!IsNumeric(str, door))
966 return ScriptError("No door specified");
967 if (door == 0 || door > car->NumDoors)
968 return ScriptError("Invalid door number");
969
970 int params = SplitAfterEquals(LineData);
971 if (params < 1 || params > 2)
972 return ScriptError("Incorrect number of parameters");
973
974 car->GetDoor(door)->EnableSensor(ToBool(tempdata[0]));
975 if (params == 2)
976 {
977 //check to see if file exists
978 parent->CheckFile("data/" + tempdata[1]);
979 //set door sound
980 car->GetDoor(door)->SensorSound = tempdata[1];
981 }
982 return sNextLine;
983 }
984 //CarEmergencyStopSound parameter
985 if (StartsWithNoCase(LineData, "caremergencystopsound"))
986 {
987 if (equals == false)
988 return ScriptError("Syntax error");
989
990 //check to see if file exists
991 parent->CheckFile("data/" + value);
992
993 car->EmergencyStopSound = value;
994 return sNextLine;
995 }
996 //IndependentService parameter
997 if (StartsWithNoCase(LineData, "independentservice"))
998 {
999 if (equals == false)
1000 return ScriptError("Syntax error");
1001 elev->IndependentService = ToBool(value);
1002 elev->IndependentServiceCar = car->Number;
1003 return sNextLine;
1004 }
1005 //FireService2 parameter
1006 if (StartsWithNoCase(LineData, "fireservice2"))
1007 {
1008 if (equals == false)
1009 return ScriptError("Syntax error");
1010
1011 std::string str = Calc(value);
1012 int mode;
1013 if (!IsNumeric(str, mode))
1014 return ScriptError("Invalid value: " + str);
1015
1016 elev->FireServicePhase2 = mode;
1017 elev->FireServicePhase2Car = car->Number;
1018 return sNextLine;
1019 }
1020
1021 //AddFloor command
1022 if (StartsWithNoCase(LineData, "addfloor "))
1023 {
1024 //get data
1025 int params = SplitData(LineData, 9);
1026
1027 if (params != 11 && params != 13)
1028 return ScriptError("Incorrect number of parameters");
1029
1030 bool compat = false;
1031 if (params == 11)
1032 compat = true;
1033
1034 //check numeric values
1035 if (compat == true)
1036 {
1037 for (int i = 2; i <= 10; i++)
1038 {
1039 if (!IsNumeric(tempdata[i]))
1040 return ScriptError("Invalid value: " + tempdata[i]);
1041 }
1042 if (warn_deprecated == true)
1043 ScriptWarning("Syntax deprecated");
1044 }
1045 else
1046 {
1047 for (int i = 2; i <= 12; i++)
1048 {
1049 if (i == 9)
1050 i = 11;
1051 if (!IsNumeric(tempdata[i]))
1052 return ScriptError("Invalid value: " + tempdata[i]);
1053 }
1054 }
1055
1056 //stop here if in Check mode
1057 if (config->CheckScript == true)
1058 return sNextLine;
1059
1060 //create floor
1061 if (compat == true)
1062 StoreCommand(car->AddFloor(tempdata[0], tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), config->ReverseAxis, false, ToFloat(tempdata[9]), ToFloat(tempdata[10]), true));
1063 else
1064 StoreCommand(car->AddFloor(tempdata[0], tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToBool(tempdata[9]), ToBool(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12])));
1065 return sNextLine;
1066 }
1067
1068 //AddWall command
1069 if (StartsWithNoCase(LineData, "addwall"))
1070 {
1071 //get data
1072 int params = SplitData(LineData, 8);
1073
1074 if (params != 13)
1075 return ScriptError("Incorrect number of parameters");
1076
1077 //check numeric values
1078 for (int i = 2; i <= 12; i++)
1079 {
1080 if (!IsNumeric(tempdata[i]))
1081 return ScriptError("Invalid value: " + tempdata[i]);
1082 }
1083
1084 //stop here if in Check mode
1085 if (config->CheckScript == true)
1086 return sNextLine;
1087
1088 //create wall
1089 StoreCommand(car->AddWall(tempdata[0], tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12])));
1090 return sNextLine;
1091 }
1092
1093 //AddDoors command
1094 if (StartsWithNoCase(LineData, "adddoors"))
1095 {
1096 //get data
1097 int params = SplitData(LineData, 9);
1098
1099 if (params != 10 && params != 11)
1100 return ScriptError("Incorrect number of parameters");
1101
1102 bool compat = false;
1103 if (params == 10)
1104 compat = true; //1.4 compatibility mode
1105
1106 //check numeric values
1107 if (compat == true)
1108 {
1109 for (int i = 0; i <= 9; i++)
1110 {
1111 if (i == 1)
1112 i = 2;
1113 if (i == 7)
1114 i = 8;
1115 if (!IsNumeric(tempdata[i]))
1116 return ScriptError("Invalid value: " + tempdata[i]);
1117 }
1118 if (warn_deprecated == true)
1119 ScriptWarning("Syntax deprecated");
1120 }
1121 else
1122 {
1123 for (int i = 0; i <= 10; i++)
1124 {
1125 if (i == 1)
1126 i = 3;
1127 if (i == 8)
1128 i = 9;
1129 if (!IsNumeric(tempdata[i]))
1130 return ScriptError("Invalid value: " + tempdata[i]);
1131 }
1132 }
1133
1134 //stop here if in Check mode
1135 if (config->CheckScript == true)
1136 return sNextLine;
1137
1138 if (compat == false)
1139 StoreCommand(car->AddDoors(ToInt(tempdata[0]), tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToBool(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10])));
1140 else
1141 StoreCommand(car->AddDoors(ToInt(tempdata[0]), tempdata[1], tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToBool(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9])));
1142 return sNextLine;
1143 }
1144
1145 //SetShaftDoors command
1146 if (StartsWithNoCase(LineData, "setshaftdoors"))
1147 {
1148 //backwards compatibility
1149 if (warn_deprecated == true)
1150 ScriptWarning("Command deprecated");
1151
1152 //get data
1153 int params = SplitData(LineData, 14);
1154
1155 if (params != 4)
1156 return ScriptError("Incorrect number of parameters");
1157
1158 //check numeric values
1159 for (int i = 0; i <= 3; i++)
1160 {
1161 if (!IsNumeric(tempdata[i]))
1162 return ScriptError("Invalid value: " + tempdata[i]);
1163 }
1164
1165 config->setshaftdoors = true;
1166
1167 //stop here if in Check mode
1168 if (config->CheckScript == true)
1169 return sNextLine;
1170
1171 car->SetShaftDoors(ToInt(tempdata[0]), ToFloat(tempdata[1]), ToFloat(tempdata[2]), ToFloat(tempdata[3]));
1172 return sNextLine;
1173 }
1174
1175 //AddShaftDoors command
1176 if (StartsWithNoCase(LineData, "addshaftdoors "))
1177 {
1178 //get data
1179 int params = SplitData(LineData, 14);
1180
1181 if (params < 7 || params > 9)
1182 return ScriptError("Incorrect number of parameters");
1183
1184 int compat = 0;
1185 if (params == 7)
1186 compat = 1; //1.4 compatibility mode
1187 if (params == 8)
1188 compat = 2;
1189
1190 //check numeric values
1191 if (compat == 0)
1192 {
1193 for (int i = 0; i <= 8; i++)
1194 {
1195 if (i == 1)
1196 i = 3;
1197 if (!IsNumeric(tempdata[i]))
1198 return ScriptError("Invalid value: " + tempdata[i]);
1199 }
1200 }
1201 if (compat == 1)
1202 {
1203 for (int i = 0; i <= 6; i++)
1204 {
1205 if (i == 1)
1206 i = 2;
1207 if (!IsNumeric(tempdata[i]))
1208 return ScriptError("Invalid value: " + tempdata[i]);
1209 }
1210 }
1211 if (compat == 2)
1212 {
1213 for (int i = 0; i <= 7; i++)
1214 {
1215 if (i == 1)
1216 i = 3;
1217 if (!IsNumeric(tempdata[i]))
1218 return ScriptError("Invalid value: " + tempdata[i]);
1219 }
1220 }
1221
1222 if (compat > 0 && warn_deprecated == true)
1223 ScriptWarning("Syntax deprecated");
1224
1225 //stop here if in Check mode
1226 if (config->CheckScript == true)
1227 return sNextLine;
1228
1229 bool result;
1230 if (compat == 0)
1231 result = car->AddShaftDoors(ToInt(tempdata[0]), tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]));
1232 if (compat == 1)
1233 result = car->AddShaftDoors(ToInt(tempdata[0]), tempdata[1], tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), 0, ToFloat(tempdata[5]), ToFloat(tempdata[6]));
1234 if (compat == 2)
1235 result = car->AddShaftDoors(ToInt(tempdata[0]), tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), 0, ToFloat(tempdata[6]), ToFloat(tempdata[7]));
1236
1237 if (result == false)
1238 return ScriptError();
1239 return sNextLine;
1240 }
1241
1242 //CreatePanel command
1243 if (StartsWithNoCase(LineData, "createpanel"))
1244 {
1245 //get data
1246 int params = SplitData(LineData, 12);
1247
1248 if (params != 13)
1249 return ScriptError("Incorrect number of parameters");
1250
1251 //check numeric values
1252 for (int i = 1; i <= 12; i++)
1253 {
1254 if (i == 3)
1255 i = 4;
1256 if (!IsNumeric(tempdata[i]))
1257 return ScriptError("Invalid value: " + tempdata[i]);
1258 }
1259
1260 StoreCommand(car->CreateButtonPanel(tempdata[0], ToInt(tempdata[1]), ToInt(tempdata[2]), tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12])));
1261 return sNextLine;
1262 }
1263
1264 //AddFloorButton command
1265 if (StartsWithNoCase(LineData, "addfloorbutton"))
1266 {
1267 //get data
1268 int params = SplitData(LineData, 15);
1269
1270 if (params < 7 || params > 11)
1271 return ScriptError("Incorrect number of parameters");
1272
1273 Real hoffset = 0, voffset = 0;
1274 int compat = 0;
1275
1276 //check numeric values
1277 if (params == 7)
1278 {
1279 //1.4 compatibility mode
1280 for (int i = 0; i <= 6; i++)
1281 {
1282 if (i == 1)
1283 i = 2;
1284 if (!IsNumeric(tempdata[i]))
1285 return ScriptError("Invalid value: " + tempdata[i]);
1286 }
1287 compat = 1;
1288 }
1289 if (params == 9)
1290 {
1291 if (IsNumeric(tempdata[2]) == true)
1292 {
1293 //1.5 compatibility mode
1294 for (int i = 0; i <= 8; i++)
1295 {
1296 if (i == 1 || i == 4)
1297 i++;
1298
1299 if (!IsNumeric(tempdata[i]))
1300 return ScriptError("Invalid value: " + tempdata[i]);
1301 }
1302 hoffset = ToFloat(tempdata[7]);
1303 voffset = ToFloat(tempdata[8]);
1304 compat = 1;
1305 }
1306 }
1307 if (params == 8 || params == 10)
1308 {
1309 //pre-Alpha 6 compatibility
1310 for (int i = 0; i <= 7; i++)
1311 {
1312 if (i == 1)
1313 i = 3;
1314 if (i == 5)
1315 i++;
1316 if (!IsNumeric(tempdata[i]))
1317 return ScriptError("Invalid value: " + tempdata[i]);
1318 }
1319 if (params == 10)
1320 {
1321 hoffset = ToFloat(tempdata[8]);
1322 voffset = ToFloat(tempdata[9]);
1323 }
1324 compat = 2;
1325 }
1326 if (params == 9 || params == 11)
1327 {
1328 for (int i = 0; i <= 8; i++)
1329 {
1330 if (i == 1)
1331 i = 4;
1332 if (i == 6)
1333 i++;
1334 if (!IsNumeric(tempdata[i]))
1335 return ScriptError("Invalid value: " + tempdata[i]);
1336 }
1337 if (params == 11)
1338 {
1339 hoffset = ToFloat(tempdata[9]);
1340 voffset = ToFloat(tempdata[10]);
1341 }
1342 }
1343
1344 if (!car->GetPanel(ToInt(tempdata[0])))
1345 return ScriptError("Invalid panel number");
1346
1347 if (compat > 0 && warn_deprecated == true)
1348 ScriptWarning("Syntax deprecated");
1349
1350 if (compat == 0)
1351 parent->CheckFile("data/" + tempdata[1]);
1352
1353 //stop here if in Check mode
1354 if (config->CheckScript == true)
1355 return sNextLine;
1356
1357 Control* control;
1358
1359 if (compat == 0)
1360 control = car->GetPanel(ToInt(tempdata[0]))->AddButton(tempdata[1], tempdata[2], tempdata[3], ToInt(tempdata[4]), ToInt(tempdata[5]), tempdata[6], ToFloat(tempdata[7]), ToFloat(tempdata[8]), hoffset, voffset);
1361 if (compat == 1)
1362 control = car->GetPanel(ToInt(tempdata[0]))->AddButton("", tempdata[1], tempdata[1], ToInt(tempdata[2]), ToInt(tempdata[3]), tempdata[4], ToFloat(tempdata[5]), ToFloat(tempdata[6]), hoffset, voffset);
1363 if (compat == 2)
1364 control = car->GetPanel(ToInt(tempdata[0]))->AddButton("", tempdata[1], tempdata[2], ToInt(tempdata[3]), ToInt(tempdata[4]), tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), hoffset, voffset);
1365
1366 if (control)
1367 {
1368 if (config->lockvalue == 0)
1369 control->SetLocked(false, config->keyvalue);
1370 else
1371 control->SetLocked(true, config->keyvalue);
1372 }
1373 StoreCommand(control);
1374 return sNextLine;
1375 }
1376
1377 //AddControlButton command
1378 if (StartsWithNoCase(LineData, "addcontrolbutton"))
1379 {
1380 //get data
1381 int params = SplitData(LineData, 17);
1382
1383 if (params < 7 || params > 11)
1384 return ScriptError("Incorrect number of parameters");
1385
1386 Real hoffset = 0, voffset = 0;
1387 int compat = 0;
1388
1389 //check numeric values
1390 if (params == 7)
1391 {
1392 //1.4 compatibility mode
1393 for (int i = 1; i <= 6; i++)
1394 {
1395 if (i == 1 || i == 4)
1396 i++;
1397 if (!IsNumeric(tempdata[i]))
1398 return ScriptError("Invalid value: " + tempdata[i]);
1399 }
1400 compat = 1;
1401 }
1402 if (params == 9)
1403 {
1404 if (IsNumeric(tempdata[2]) == true)
1405 {
1406 //1.5 compatibility mode
1407 for (int i = 1; i <= 8; i++)
1408 {
1409 if (i == 1 || i == 4)
1410 i++;
1411 if (!IsNumeric(tempdata[i]))
1412 return ScriptError("Invalid value: " + tempdata[i]);
1413 }
1414 hoffset = ToFloat(tempdata[7]);
1415 voffset = ToFloat(tempdata[8]);
1416 compat = 1;
1417 }
1418 }
1419 if (params == 8 || params == 10)
1420 {
1421 //pre-Alpha 6 compatibility
1422 for (int i = 1; i <= 7; i++)
1423 {
1424 if (i == 1)
1425 i = 3;
1426 if (i == 5)
1427 i++;
1428 if (!IsNumeric(tempdata[i]))
1429 return ScriptError("Invalid value: " + tempdata[i]);
1430 }
1431 if (params == 10)
1432 {
1433 hoffset = ToFloat(tempdata[8]);
1434 voffset = ToFloat(tempdata[9]);
1435 }
1436 compat = 2;
1437 }
1438 if (params == 9 || params == 11)
1439 {
1440 for (int i = 1; i <= 8; i++)
1441 {
1442 if (i == 1)
1443 i = 4;
1444 if (i == 6)
1445 i++;
1446 if (!IsNumeric(tempdata[i]))
1447 return ScriptError("Invalid value: " + tempdata[i]);
1448 }
1449 if (params == 11)
1450 {
1451 hoffset = ToFloat(tempdata[9]);
1452 voffset = ToFloat(tempdata[10]);
1453 }
1454 }
1455
1456 if (!car->GetPanel(ToInt(tempdata[0])))
1457 return ScriptError("Invalid panel number");
1458
1459 if (compat > 0 && warn_deprecated == true)
1460 ScriptWarning("Syntax deprecated");
1461
1462 if (compat == 0)
1463 parent->CheckFile("data/" + tempdata[1]);
1464
1465 //stop here if in Check mode
1466 if (config->CheckScript == true)
1467 return sNextLine;
1468
1469 Control* control;
1470
1471 if (compat == 0)
1472 control = car->GetPanel(ToInt(tempdata[0]))->AddButton(tempdata[1], tempdata[2], tempdata[3], ToInt(tempdata[4]), ToInt(tempdata[5]), tempdata[6], ToFloat(tempdata[7]), ToFloat(tempdata[8]), hoffset, voffset);
1473 if (compat == 1)
1474 control = car->GetPanel(ToInt(tempdata[0]))->AddButton("", tempdata[1], tempdata[1], ToInt(tempdata[2]), ToInt(tempdata[3]), tempdata[4], ToFloat(tempdata[5]), ToFloat(tempdata[6]), hoffset, voffset);
1475 if (compat == 2)
1476 control = car->GetPanel(ToInt(tempdata[0]))->AddButton("", tempdata[1], tempdata[2], ToInt(tempdata[3]), ToInt(tempdata[4]), tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), hoffset, voffset);
1477
1478 if (control)
1479 {
1480 if (config->lockvalue == 0)
1481 control->SetLocked(false, config->keyvalue);
1482 else
1483 control->SetLocked(true, config->keyvalue);
1484 }
1485 StoreCommand(control);
1486 return sNextLine;
1487 }
1488
1489 //AddButton command
1490 if (StartsWithNoCase(LineData, "addbutton "))
1491 {
1492 //get data
1493 int params = SplitData(LineData, 10);
1494
1495 if (params != 9 && params != 11)
1496 return ScriptError("Incorrect number of parameters");
1497
1498 Real hoffset = 0, voffset = 0;
1499
1500 //check numeric values
1501 for (int i = 1; i <= 8; i++)
1502 {
1503 if (i == 1)
1504 i = 4;
1505 if (i == 6)
1506 i++;
1507 if (!IsNumeric(tempdata[i]))
1508 return ScriptError("Invalid value: " + tempdata[i]);
1509 }
1510 if (params == 11)
1511 {
1512 hoffset = ToFloat(tempdata[9]);
1513 voffset = ToFloat(tempdata[10]);
1514 }
1515
1516 if (!car->GetPanel(ToInt(tempdata[0])))
1517 return ScriptError("Invalid panel number");
1518
1519 //check to see if file exists
1520 parent->CheckFile("data/" + tempdata[1]);
1521
1522 //stop here if in Check mode
1523 if (config->CheckScript == true)
1524 return sNextLine;
1525
1526 Control* control = car->GetPanel(ToInt(tempdata[0]))->AddButton(tempdata[1], tempdata[2], tempdata[3], ToInt(tempdata[4]), ToInt(tempdata[5]), tempdata[6], ToFloat(tempdata[7]), ToFloat(tempdata[8]), hoffset, voffset);
1527
1528 if (control)
1529 {
1530 if (config->lockvalue == 0)
1531 control->SetLocked(false, config->keyvalue);
1532 else
1533 control->SetLocked(true, config->keyvalue);
1534 }
1535 StoreCommand(control);
1536 return sNextLine;
1537 }
1538
1539 //AddControl command
1540 if (StartsWithNoCase(LineData, "addcontrol "))
1541 {
1542 //get data
1543 int params = SplitData(LineData, 11);
1544
1545 if (params < 10)
1546 return ScriptError("Incorrect number of parameters");
1547
1548 //set backwards compatibility
1549 bool compat = false;
1550 if (IsNumeric(tempdata[8]) == false)
1551 compat = true;
1552
1553 int end = 8;
1554 if (compat == true)
1555 {
1556 end = 7;
1557
1558 if (warn_deprecated == true)
1559 ScriptWarning("Syntax deprecated");
1560 }
1561
1562 //check numeric values
1563 for (int i = 1; i <= end; i++)
1564 {
1565 if (i == 1)
1566 i++;
1567 if (!IsNumeric(tempdata[i]))
1568 return ScriptError("Invalid value: " + tempdata[i]);
1569 }
1570
1571 if (!car->GetPanel(ToInt(tempdata[0])))
1572 return ScriptError("Invalid panel number");
1573
1574 std::vector<std::string> action_array, tex_array;
1575 int slength, parameters;
1576
1577 //get number of action & texture parameters
1578 slength = (int)tempdata.size();
1579 parameters = slength - (end + 1); //strip off main parameters
1580
1581 //action & texture parameter number needs to be even
1582 if (IsEven(parameters) == false)
1583 return ScriptError("Incorrect number of parameters");
1584
1585 for (int i = (end + 1); i < slength - (parameters / 2); i++)
1586 action_array.emplace_back(tempdata[i]);
1587 for (int i = slength - (parameters / 2); i < slength; i++)
1588 tex_array.emplace_back(tempdata[i]);
1589
1590 //check to see if file exists
1591 parent->CheckFile("data/" + tempdata[1]);
1592
1593 //stop here if in Check mode
1594 if (config->CheckScript == true)
1595 return sNextLine;
1596
1597 Control* control = 0;
1598 if (compat == true)
1599 control = car->GetPanel(ToInt(tempdata[0]))->AddControl(tempdata[1], ToInt(tempdata[2]), ToInt(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), 1, action_array, tex_array);
1600 else
1601 control = car->GetPanel(ToInt(tempdata[0]))->AddControl(tempdata[1], ToInt(tempdata[2]), ToInt(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToInt(tempdata[8]), action_array, tex_array);
1602
1603 if (control)
1604 {
1605 if (config->lockvalue == 0)
1606 control->SetLocked(false, config->keyvalue);
1607 else
1608 control->SetLocked(true, config->keyvalue);
1609 }
1610 StoreCommand(control);
1611 return sNextLine;
1612 }
1613
1614 //AddFloorIndicator command
1615 if (StartsWithNoCase(LineData, "addfloorindicator"))
1616 {
1617 //get data
1618 int params = SplitData(LineData, 18);
1619
1620 if (params < 6 && params > 8)
1621 return ScriptError("Incorrect number of parameters");
1622
1623 int compat = 0;
1624 if (params == 6)
1625 compat = 1; //1.4 compatibility mode
1626 if (params == 7)
1627 compat = 2;
1628
1629 //check numeric values
1630 if (compat == 1)
1631 {
1632 for (int i = 1; i <= 5; i++)
1633 {
1634 if (!IsNumeric(tempdata[i]))
1635 return ScriptError("Invalid value: " + tempdata[i]);
1636 }
1637 if (warn_deprecated == true)
1638 ScriptWarning("Syntax deprecated");
1639 }
1640 else if (compat == 2)
1641 {
1642 for (int i = 2; i <= 6; i++)
1643 {
1644 if (!IsNumeric(tempdata[i]))
1645 return ScriptError("Invalid value: " + tempdata[i]);
1646 }
1647 }
1648 else
1649 {
1650 for (int i = 3; i <= 7; i++)
1651 {
1652 if (!IsNumeric(tempdata[i]))
1653 return ScriptError("Invalid value: " + tempdata[i]);
1654 }
1655 }
1656
1657 //stop here if in Check mode
1658 if (config->CheckScript == true)
1659 return sNextLine;
1660
1661 if (compat == 0)
1662 StoreCommand(car->AddFloorIndicator(tempdata[0], tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7])));
1663 else if (compat == 1)
1664 StoreCommand(car->AddFloorIndicator("Button", "", tempdata[0], ToFloat(tempdata[1]), ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5])));
1665 else if (compat == 2)
1666 StoreCommand(car->AddFloorIndicator(tempdata[0], "", tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6])));
1667 return sNextLine;
1668 }
1669
1670 //AddDisplay command
1671 if (StartsWithNoCase(LineData, "addkeypadindicator"))
1672 {
1673 //get data
1674 int params = SplitData(LineData, 19);
1675
1676 if (params != 10)
1677 return ScriptError("Incorrect number of parameters");
1678
1679 //check numeric values
1680 for (int i = 4; i <= 9; i++)
1681 {
1682 if (!IsNumeric(tempdata[i]))
1683 return ScriptError("Invalid value: " + tempdata[i]);
1684 }
1685
1686 StoreCommand(car->AddKeypadIndicator(tempdata[0], tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9])));
1687 return sNextLine;
1688 }
1689
1690 //AddDirectionalIndicators command
1691 if (StartsWithNoCase(LineData, "adddirectionalindicators"))
1692 {
1693 //get data
1694 int params = SplitData(LineData, 25);
1695
1696 if (params != 17 && params != 18)
1697 return ScriptError("Incorrect number of parameters");
1698
1699 //check numeric values
1700 bool compat = false;
1701 if (params == 17)
1702 {
1703 for (int i = 8; i <= 16; i++)
1704 {
1705 if (i == 11 || i == 14)
1706 i++;
1707 if (!IsNumeric(tempdata[i]))
1708 return ScriptError("Invalid value: " + tempdata[i]);
1709 }
1710 compat = true;
1711 if (warn_deprecated == true)
1712 ScriptWarning("Syntax deprecated");
1713 }
1714 else
1715 {
1716 for (int i = 9; i <= 17; i++)
1717 {
1718 if (i == 12 || i == 15)
1719 i++;
1720 if (!IsNumeric(tempdata[i]))
1721 return ScriptError("Invalid value: " + tempdata[i]);
1722 }
1723 }
1724
1725 //stop here if in Check mode
1726 if (config->CheckScript == true)
1727 return sNextLine;
1728
1729 if (compat == false)
1730 car->AddDirectionalIndicators(ToBool(tempdata[0]), ToBool(tempdata[1]), ToBool(tempdata[2]), ToBool(tempdata[3]), tempdata[4], tempdata[5], tempdata[6], tempdata[7], tempdata[8], ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), tempdata[12], ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToBool(tempdata[15]), ToFloat(tempdata[16]), ToFloat(tempdata[17]));
1731 else
1732 car->AddDirectionalIndicators(ToBool(tempdata[0]), false, ToBool(tempdata[1]), ToBool(tempdata[2]), tempdata[3], tempdata[4], tempdata[5], tempdata[6], tempdata[7], ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), tempdata[11], ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToBool(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16]));
1733 return sNextLine;
1734 }
1735
1736 //AddFloorSigns command
1737 if (StartsWithNoCase(LineData, "addfloorsigns"))
1738 {
1739 //get data
1740 int params = SplitData(LineData, 14);
1741
1742 if (params < 7 || params > 9)
1743 return ScriptError("Incorrect number of parameters");
1744
1745 int compat = 0;
1746 if (params == 7)
1747 compat = 1; //1.4 compatibility mode
1748 if (params == 8)
1749 compat = 2; //1.5 compatibility mode
1750
1751 //check numeric values
1752 if (compat == 0)
1753 {
1754 for (int i = 0; i <= 8; i++)
1755 {
1756 if (i == 1)
1757 i = 4;
1758 if (!IsNumeric(tempdata[i]))
1759 return ScriptError("Invalid value: " + tempdata[i]);
1760 }
1761 }
1762 else if (compat == 1)
1763 {
1764 for (int i = 2; i <= 6; i++)
1765 {
1766 if (!IsNumeric(tempdata[i]))
1767 return ScriptError("Invalid value: " + tempdata[i]);
1768 }
1769 }
1770 else if (compat == 2)
1771 {
1772 for (int i = 3; i <= 7; i++)
1773 {
1774 if (!IsNumeric(tempdata[i]))
1775 return ScriptError("Invalid value: " + tempdata[i]);
1776 }
1777 }
1778
1779 if (compat > 0 && warn_deprecated == true)
1780 ScriptWarning("Syntax deprecated");
1781
1782 if (compat == 0)
1783 {
1784 bool result;
1785 result = car->AddFloorSigns(ToInt(tempdata[0]), ToBool(tempdata[1]), tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]));
1786 if (result == false)
1787 return ScriptError();
1788 }
1789 else if (compat == 1)
1790 car->AddFloorSigns(0, ToBool(tempdata[0]), "Button", tempdata[1], ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]));
1791 else if (compat == 2)
1792 car->AddFloorSigns(0, ToBool(tempdata[0]), tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]));
1793 return sNextLine;
1794 }
1795
1796 //AddSound command
1797 if (StartsWithNoCase(LineData, "addsound"))
1798 {
1799 //get data
1800 int params = SplitData(LineData, 9);
1801
1802 if (params != 5 && params != 6 && params != 13 && params != 17)
1803 return ScriptError("Incorrect number of parameters");
1804
1805 bool partial = false;
1806 bool compat = false;
1807 if (params == 5 || params == 6)
1808 partial = true;
1809 if (params == 5 || params == 13)
1810 compat = true;
1811
1812 //check numeric values
1813 if (partial == true)
1814 {
1815 for (int i = 2; i <= 4; i++)
1816 {
1817 if (!IsNumeric(tempdata[i]))
1818 return ScriptError("Invalid value: " + tempdata[i]);
1819 }
1820 }
1821 else
1822 {
1823 if (compat == true)
1824 {
1825 for (int i = 2; i <= 12; i++)
1826 {
1827 if (!IsNumeric(tempdata[i]))
1828 return ScriptError("Invalid value: " + tempdata[i]);
1829 }
1830 if (warn_deprecated == true)
1831 ScriptWarning("Syntax deprecated");
1832 }
1833 else
1834 {
1835 for (int i = 2; i <= 16; i++)
1836 {
1837 if (i == 5)
1838 i = 6;
1839
1840 if (!IsNumeric(tempdata[i]))
1841 return ScriptError("Invalid value: " + tempdata[i]);
1842 }
1843 }
1844 }
1845
1846 //check to see if file exists
1847 parent->CheckFile("data/" + tempdata[1]);
1848
1849 //stop here if in Check mode
1850 if (config->CheckScript == true)
1851 return sNextLine;
1852
1853 if (compat == true)
1854 {
1855 if (partial == true)
1856 StoreCommand(car->AddSound(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]))));
1857 else
1858 StoreCommand(car->AddSound(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), true, ToFloat(tempdata[5]), ToInt(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), 0.0, 360, 360, 1.0, Vector3(ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]))));
1859 }
1860 else
1861 {
1862 if (partial == true)
1863 StoreCommand(car->AddSound(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), ToBool(tempdata[5])));
1864 else
1865 StoreCommand(car->AddSound(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), ToBool(tempdata[5]), ToFloat(tempdata[6]), ToInt(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), Vector3(ToFloat(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16]))));
1866 }
1867 return sNextLine;
1868 }
1869
1870 //AddReverb command
1871 if (StartsWithNoCase(LineData, "addreverb"))
1872 {
1873 if (car->GetReverb())
1874 return ScriptError("Cannot create more than one reverb in an elevator car");
1875
1876 //get data
1877 int params = SplitData(LineData, 9);
1878
1879 if (params != 7)
1880 return ScriptError("Incorrect number of parameters");
1881
1882 //check numeric values
1883 for (int i = 2; i <= 6; i++)
1884 {
1885 if (!IsNumeric(tempdata[i]))
1886 return ScriptError("Invalid value: " + tempdata[i]);
1887 }
1888
1889 //stop here if in Check mode
1890 if (config->CheckScript == true)
1891 return sNextLine;
1892
1893 StoreCommand(car->AddReverb(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), ToFloat(tempdata[5]), ToFloat(tempdata[6])));
1894 return sNextLine;
1895 }
1896
1897 //AddDoorComponent command
1898 if (StartsWithNoCase(LineData, "adddoorcomponent"))
1899 {
1900 //get data
1901 int params = SplitData(LineData, 17);
1902
1903 if (params != 17 && params != 18)
1904 return ScriptError("Incorrect number of parameters");
1905
1906 //check numeric values
1907 bool compat = false;
1908 if (params == 17)
1909 {
1910 compat = true;
1911 if (warn_deprecated == true)
1912 ScriptWarning("Syntax deprecated");
1913 }
1914
1915 for (int i = 0; i <= params - 1; i++)
1916 {
1917 if (i == 1)
1918 i = 4;
1919 if (i == 5)
1920 i++;
1921 if (!IsNumeric(tempdata[i]))
1922 return ScriptError("Invalid value: " + tempdata[i]);
1923 }
1924
1925 //stop here if in Check mode
1926 if (config->CheckScript == true)
1927 return sNextLine;
1928
1929 if (compat == true)
1930 StoreCommand(car->AddDoorComponent(ToInt(tempdata[0]), tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16])));
1931 else
1932 StoreCommand(car->AddDoorComponent(ToInt(tempdata[0]), tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16]), ToFloat(tempdata[17])));
1933 return sNextLine;
1934 }
1935
1936 //AddShaftDoorsComponent command
1937 if (StartsWithNoCase(LineData, "addshaftdoorscomponent"))
1938 {
1939 //get data
1940 int params = SplitData(LineData, 23);
1941
1942 if (params != 17 && params != 18)
1943 return ScriptError("Incorrect number of parameters");
1944
1945 //check numeric values
1946 bool compat = false;
1947 if (params == 17)
1948 {
1949 compat = true;
1950 if (warn_deprecated == true)
1951 ScriptWarning("Syntax deprecated");
1952 }
1953
1954 for (int i = 0; i <= params - 1; i++)
1955 {
1956 if (i == 1)
1957 i = 4;
1958 if (i == 5)
1959 i++;
1960 if (!IsNumeric(tempdata[i]))
1961 return ScriptError("Invalid value: " + tempdata[i]);
1962 }
1963
1964 //stop here if in Check mode
1965 if (config->CheckScript == true)
1966 return sNextLine;
1967
1968 if (compat == true)
1969 car->AddShaftDoorsComponent(ToInt(tempdata[0]), tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16]));
1970 else
1971 car->AddShaftDoorsComponent(ToInt(tempdata[0]), tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16]), ToFloat(tempdata[17]));
1972 return sNextLine;
1973 }
1974
1975 //FinishDoors command
1976 if (StartsWithNoCase(LineData, "finishdoors"))
1977 {
1978 //get data
1979 int params = SplitData(LineData, 12);
1980
1981 bool legacy = false;
1982
1983 if (params < 1)
1984 return ScriptError("Incorrect number of parameters");
1985
1986 if (params > 2)
1987 {
1988 if (IsNumeric(tempdata[1]) == true)
1989 {
1990 if (warn_deprecated == true)
1991 ScriptWarning("Syntax deprecated");
1992 legacy = true;
1993 }
1994 }
1995
1996 //check numeric values
1997 if (!IsNumeric(tempdata[0]))
1998 return ScriptError("Invalid value: " + tempdata[0]);
1999
2000 //stop here if in Check mode
2001 if (config->CheckScript == true)
2002 return sNextLine;
2003
2004 DoorWrapper *wrapper = 0;
2005
2006 if (params == 1 || legacy == true)
2007 wrapper = car->FinishDoors(ToInt(tempdata[0]));
2008 else if (params == 2)
2009 wrapper = car->FinishDoors(ToInt(tempdata[0]), ToBool(tempdata[1]));
2010 else
2011 wrapper = car->FinishDoors(ToInt(tempdata[0]), ToBool(tempdata[1]), ToBool(tempdata[2]));
2012
2013 if (!wrapper)
2014 return ScriptError();
2015
2016 StoreCommand(wrapper);
2017 return sNextLine;
2018 }
2019
2020 //FinishShaftDoors command
2021 if (StartsWithNoCase(LineData, "finishshaftdoors"))
2022 {
2023 //get data
2024 int params = SplitData(LineData, 17);
2025
2026 bool legacy = false;
2027
2028 if (params < 1)
2029 return ScriptError("Incorrect number of parameters");
2030
2031 if (params > 2)
2032 {
2033 if (IsNumeric(tempdata[1]) == true)
2034 {
2035 if (warn_deprecated == true)
2036 ScriptWarning("Syntax deprecated");
2037 legacy = true;
2038 }
2039 }
2040
2041 //check numeric values
2042 if (!IsNumeric(tempdata[0]))
2043 return ScriptError("Invalid value: " + tempdata[0]);
2044
2045 //stop here if in Check mode
2046 if (config->CheckScript == true)
2047 return sNextLine;
2048
2049 //stop here if in Check mode
2050 if (config->CheckScript == true)
2051 return sNextLine;
2052
2053 bool result;
2054 if (params == 1 || legacy == true)
2055 result = car->FinishShaftDoors(ToInt(tempdata[0]));
2056 else if (params == 2)
2057 result = car->FinishShaftDoors(ToInt(tempdata[0]), ToBool(tempdata[1]));
2058 else
2059 result = car->FinishShaftDoors(ToInt(tempdata[0]), ToBool(tempdata[1]), ToBool(tempdata[2]));
2060
2061 if (result == false)
2062 return ScriptError();
2063 return sNextLine;
2064 }
2065
2066 //AddDirectionalIndicator command
2067 if (StartsWithNoCase(LineData, "adddirectionalindicator "))
2068 {
2069 //get data
2070 int params = SplitData(LineData, 24);
2071
2072 if (params != 17)
2073 return ScriptError("Incorrect number of parameters");
2074
2075 //check numeric values
2076 for (int i = 8; i <= 16; i++)
2077 {
2078 if (i == 11 || i == 14)
2079 i++;
2080 if (!IsNumeric(tempdata[i]))
2081 return ScriptError("Invalid value: " + tempdata[i]);
2082 }
2083
2084 //stop here if in Check mode
2085 if (config->CheckScript == true)
2086 return sNextLine;
2087
2088 StoreCommand(car->AddDirectionalIndicator(ToBool(tempdata[0]), ToBool(tempdata[1]), ToBool(tempdata[2]), tempdata[3], tempdata[4], tempdata[5], tempdata[6], tempdata[7], ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), tempdata[11], ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToBool(tempdata[14]), ToFloat(tempdata[15]), ToFloat(tempdata[16])));
2089 return sNextLine;
2090 }
2091
2092 //AddDoor command
2093 if (StartsWithNoCase(LineData, "adddoor "))
2094 {
2095 //get data
2096 int params = SplitData(LineData, 8);
2097
2098 if (params < 12 || params > 14)
2099 return ScriptError("Incorrect number of parameters");
2100
2101 int compat = 0;
2102
2103 //check numeric values
2104 if (params == 12)
2105 {
2106 for (int i = 3; i <= 11; i++)
2107 {
2108 if (!IsNumeric(tempdata[i]))
2109 return ScriptError("Invalid value: " + tempdata[i]);
2110 }
2111 compat = 1;
2112 }
2113 if (params == 13)
2114 {
2115 for (int i = 3; i <= 12; i++)
2116 {
2117 if (!IsNumeric(tempdata[i]))
2118 return ScriptError("Invalid value: " + tempdata[i]);
2119 }
2120 compat = 2;
2121 }
2122 if (params == 14)
2123 {
2124 for (int i = 4; i <= 13; i++)
2125 {
2126 if (!IsNumeric(tempdata[i]))
2127 return ScriptError("Invalid value: " + tempdata[i]);
2128 }
2129 }
2130
2131 parent->CheckFile("data/" + tempdata[0]);
2132 parent->CheckFile("data/" + tempdata[1]);
2133
2134 if (compat > 0 && warn_deprecated == true)
2135 ScriptWarning("Syntax deprecated");
2136
2137 //stop here if in Check mode
2138 if (config->CheckScript == true)
2139 return sNextLine;
2140
2141 //get directions
2142 std::string face_direction;
2143 std::string open_direction;
2144 int direction = 0;
2145 if (compat >= 1)
2146 direction = ToInt(tempdata[4]);
2147 else
2148 direction = ToInt(tempdata[5]);
2149 GetDirectionStrings(direction, face_direction, open_direction);
2150
2151 //create door
2152 Door* door;
2153
2154 if (compat == 1)
2155 door = car->AddDoor("", tempdata[0], tempdata[1], false, tempdata[2], tempdata[2], ToFloat(tempdata[3]), face_direction, open_direction, true, 0, 0, ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), 0, 0);
2156 else if (compat == 2)
2157 door = car->AddDoor("", tempdata[0], tempdata[1], false, tempdata[2], tempdata[2], ToFloat(tempdata[3]), face_direction, open_direction, true, ToFloat(tempdata[5]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), 0, 0);
2158 else
2159 door = car->AddDoor("", tempdata[0], tempdata[1], ToBool(tempdata[2]), tempdata[3], tempdata[3], ToFloat(tempdata[4]), face_direction, open_direction, true, ToFloat(tempdata[6]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), 0, 0);
2160
2161 if (door)
2163
2164 StoreCommand(door);
2165 return sNextLine;
2166 }
2167
2168 //AddModel command
2169 if (StartsWithNoCase(LineData, "addmodel"))
2170 {
2171 if (parent->NoModels == true)
2172 return sNextLine;
2173
2174 //get data
2175 int params = SplitData(LineData, 9);
2176
2177 if (params != 14 && params != 15)
2178 return ScriptError("Incorrect number of parameters");
2179
2180 bool compat = false;
2181 if (params == 14)
2182 compat = true;
2183
2184 //check numeric values
2185 if (compat == true)
2186 {
2187 for (int i = 2; i <= 13; i++)
2188 {
2189 if (i == 10)
2190 i++;
2191 if (!IsNumeric(tempdata[i]))
2192 return ScriptError("Invalid value: " + tempdata[i]);
2193 }
2194 if (warn_deprecated == true)
2195 ScriptWarning("Syntax deprecated");
2196 }
2197 else
2198 {
2199 for (int i = 3; i <= 14; i++)
2200 {
2201 if (i == 11)
2202 i++;
2203 if (!IsNumeric(tempdata[i]))
2204 return ScriptError("Invalid value: " + tempdata[i]);
2205 }
2206 }
2207
2208 //check to see if file exists
2209 parent->CheckFile("data/" + tempdata[1]);
2210
2211 //stop here if in Check mode
2212 if (config->CheckScript == true)
2213 {
2214 config->setkey = false;
2215 return sNextLine;
2216 }
2217
2218 //create model
2219 Model *model;
2220 if (compat == true)
2221 model = car->AddModel(tempdata[0], tempdata[1], false, Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), Vector3(ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7])), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToBool(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]));
2222 else
2223 model = car->AddModel(tempdata[0], tempdata[1], ToBool(tempdata[2]), Vector3(ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5])), Vector3(ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8])), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToBool(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]));
2224
2225 if (config->setkey == true && model)
2226 model->SetKey(config->keyvalue);
2227 config->setkey = false;
2228
2229 StoreCommand(model);
2230 return sNextLine;
2231 }
2232
2233 //AddActionControl command
2234 if (StartsWithNoCase(LineData, "addactioncontrol"))
2235 {
2236 //get data
2237 int params = SplitData(LineData, 17);
2238
2239 if (params < 10)
2240 return ScriptError("Incorrect number of parameters");
2241
2242 //set backwards compatibility
2243 bool compat = false;
2244 if (IsNumeric(tempdata[8]) == false)
2245 compat = true;
2246
2247 int end = 8;
2248 if (compat == true)
2249 {
2250 end = 7;
2251
2252 if (warn_deprecated == true)
2253 ScriptWarning("Syntax deprecated");
2254 }
2255
2256 //check numeric values
2257 for (int i = 3; i <= end; i++)
2258 {
2259 if (!IsNumeric(tempdata[i]))
2260 return ScriptError("Invalid value: " + tempdata[i]);
2261 }
2262
2263 std::vector<std::string> action_array, tex_array;
2264 int slength, parameters;
2265
2266 //get number of action & texture parameters
2267 slength = (int)tempdata.size();
2268 parameters = slength - (end + 1); //strip off main parameters
2269
2270 //action & texture parameter number needs to be even
2271 if (IsEven(parameters) == false)
2272 return ScriptError("Incorrect number of parameters");
2273
2274 for (int i = (end + 1); i < slength - (parameters / 2); i++)
2275 action_array.emplace_back(tempdata[i]);
2276 for (int i = slength - (parameters / 2); i < slength; i++)
2277 tex_array.emplace_back(tempdata[i]);
2278
2279 //check to see if file exists
2280 parent->CheckFile("data/" + tempdata[1]);
2281
2282 //stop here if in Check mode
2283 if (config->CheckScript == true)
2284 return sNextLine;
2285
2286 Control* control = 0;
2287 if (compat == true)
2288 control = car->AddControl(tempdata[0], tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), 1, action_array, tex_array);
2289 else
2290 control = car->AddControl(tempdata[0], tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToInt(tempdata[8]), action_array, tex_array);
2291
2292 if (control)
2293 {
2294 if (config->lockvalue == 0)
2295 control->SetLocked(false, config->keyvalue);
2296 else
2297 control->SetLocked(true, config->keyvalue);
2298 }
2299 StoreCommand(control);
2300 return sNextLine;
2301 }
2302
2303 //AddTrigger command
2304 if (StartsWithNoCase(LineData, "addtrigger"))
2305 {
2306 //get data
2307 int params = SplitData(LineData, 11);
2308
2309 if (params < 9)
2310 return ScriptError("Incorrect number of parameters");
2311
2312 //check numeric values
2313 for (int i = 2; i <= 7; i++)
2314 {
2315 if (!IsNumeric(tempdata[i]))
2316 return ScriptError("Invalid value: " + tempdata[i]);
2317 }
2318
2319 std::vector<std::string> action_array;
2320
2321 //get number of action & texture parameters
2322 for (int i = 8; i < params; i++)
2323 action_array.emplace_back(tempdata[i]);
2324
2325 //check to see if file exists
2326 parent->CheckFile("data/" + tempdata[1]);
2327
2328 //stop here if in Check mode
2329 if (config->CheckScript == true)
2330 return sNextLine;
2331
2332 Vector3 min = Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]));
2333 Vector3 max = Vector3(ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]));
2334 StoreCommand(car->AddTrigger(tempdata[0], tempdata[1], min, max, action_array));
2335 return sNextLine;
2336 }
2337
2338 //CreateCar command
2339 if (StartsWithNoCase(LineData, "createcar"))
2340 {
2341 //get data
2342 int params = SplitData(LineData, 10);
2343
2344 if (params != 1)
2345 return ScriptError("Incorrect number of parameters");
2346
2347 bool result = car->CreateCar(ToInt(tempdata[0]));
2348 if (result == false)
2349 return ScriptError();
2350
2351 StoreCommand(car);
2352 return sNextLine;
2353 }
2354
2355 //AddElevatorIDSigns command
2356 if (StartsWithNoCase(LineData, "addelevatoridsigns"))
2357 {
2358 //get data
2359 int params = SplitData(LineData, 19);
2360
2361 if (params != 9)
2362 return ScriptError("Incorrect number of parameters");
2363
2364 //check numeric values
2365 for (int i = 0; i <= 8; i++)
2366 {
2367 if (i == 1)
2368 i = 4;
2369 if (!IsNumeric(tempdata[i]))
2370 return ScriptError("Invalid value: " + tempdata[i]);
2371 }
2372
2373 bool result = car->AddElevatorIDSigns(ToInt(tempdata[0]), ToBool(tempdata[1]), tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]));
2374
2375 if (result == false)
2376 return ScriptError();
2377 return sNextLine;
2378 }
2379
2380 //handle end of car section
2381 if (StartsWithNoCase(LineData, "<endcar>") == true && config->RangeL == config->RangeH)
2382 {
2383 //return to elevator section
2384 config->SectionNum = 4;
2390
2391 engine->Report("Finished car");
2392 return sNextLine;
2393 }
2394
2395 //handle car range
2396 if (config->RangeL != config->RangeH && StartsWithNoCase(LineData, "<endcar"))
2397 {
2398 if (config->Current < config->RangeH)
2399 {
2400 config->Current++;
2401 parent->line = config->RangeStart; //loop back
2402 return sNextLine;
2403 }
2404 else
2405 {
2406 config->SectionNum = 4; //break out of loop
2412 engine->Report("Finished cars");
2413 return sNextLine;
2414 }
2415 }
2416
2417 return sContinue;
2418}
2419
2420}
Control * AddButton(const std::string &sound, const std::string &texture, const std::string &texture_lit, int row, int column, const std::string &type, Real width, Real height, Real hoffset=0, Real voffset=0)
void SetLocked(int side, int keyid)
Definition lock.cpp:91
Door * AddDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool open_state, const std::string &texture, const std::string &side_texture, Real thickness, const std::string &face_direction, const std::string &open_direction, bool rotate, Real open_speed, Real close_speed, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th)
FloorIndicator * AddFloorIndicator(const std::string &texture_prefix, const std::string &blank_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset)
std::string UpMoveSound
Definition elevatorcar.h:49
bool AddShaftDoors(int number, const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real voffset, Real tw, Real th)
bool FinishShaftDoors(int number, bool DoorWalls=true, bool TrackWalls=true)
std::string DownMoveSound
Definition elevatorcar.h:50
bool AddFloorSigns(int door_number, bool relative, const std::string &texture_prefix, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset)
void SetMessageSound(bool type, bool direction, const std::string &filename)
Wall * AddWall(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height1, Real height2, Real voffset1, Real voffset2, Real tw, Real th)
std::string MusicDown
Definition elevatorcar.h:63
ButtonPanel * CreateButtonPanel(const std::string &texture, int rows, int columns, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real spacingX, Real spacingY, Real tw, Real th)
Wall * AddFloor(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real voffset1, Real voffset2, bool reverse_axis, bool texture_direction, Real tw, Real th, bool legacy_behavior=false)
std::string AlarmSound
Definition elevatorcar.h:54
std::string UpStartSound
Definition elevatorcar.h:47
Indicator * AddKeypadIndicator(const std::string &sound, const std::string &texture_prefix, const std::string &blank_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real timer_duration)
void AddDirectionalIndicators(bool relative, bool active_direction, bool single, bool vertical, const std::string &BackTexture, const std::string &uptexture, const std::string &uptexture_lit, const std::string &downtexture, const std::string &downtexture_lit, Real CenterX, Real CenterZ, Real voffset, const std::string &direction, Real BackWidth, Real BackHeight, bool ShowBack, Real tw, Real th)
std::string MusicUp
Definition elevatorcar.h:62
bool CreateCar(int floor)
void AddDisplayFloor(int floor)
Vector3 MusicPosition
Definition elevatorcar.h:43
ButtonPanel * GetPanel(int index)
bool AddElevatorIDSigns(int door_number, bool relative, const std::string &texture_prefix, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset)
DirectionalIndicator * AddDirectionalIndicator(bool active_direction, bool single, bool vertical, const std::string &BackTexture, const std::string &uptexture, const std::string &uptexture_lit, const std::string &downtexture, const std::string &downtexture_lit, Real CenterX, Real CenterZ, Real voffset, const std::string &direction, Real BackWidth, Real BackHeight, bool ShowBack, Real tw, Real th)
void SetFloorSound(const std::string &prefix)
std::vector< std::string > InvalidInput
Model * AddModel(const std::string &name, const std::string &filename, bool center, Vector3 position, Vector3 rotation, Real max_render_distance=0, Real scale_multiplier=1, bool enable_physics=false, Real restitution=0, Real friction=0, Real mass=0)
Sound * AddSound(const std::string &name, const std::string &filename, Vector3 position, bool loop=true, Real volume=1.0, int speed=100, Real min_distance=1.0, Real max_distance=-1.0, Real doppler_level=0.0, Real cone_inside_angle=360, Real cone_outside_angle=360, Real cone_outside_volume=1.0, Vector3 direction=Vector3(0, 0, 0))
DoorWrapper * AddDoors(int number, const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real width, Real height, bool direction, Real tw, Real th)
std::string EmergencyStopSound
Definition elevatorcar.h:64
bool AddServicedFloor(int number, bool create_shaft_door=true)
Control * AddControl(const std::string &name, const std::string &sound, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, int selection_position, std::vector< std::string > &action_names, std::vector< std::string > &textures)
void SetShaftDoors(int number, Real thickness, Real CenterX, Real CenterZ)
void AddShaftDoorsComponent(int number, const std::string &name, const std::string &texture, const std::string &sidetexture, Real thickness, const std::string &direction, Real OpenSpeed, Real CloseSpeed, Real x1, Real z1, Real x2, Real z2, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th)
std::string UpStopSound
Definition elevatorcar.h:51
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector< std::string > &action_names)
DoorWrapper * AddDoorComponent(int number, const std::string &name, const std::string &texture, const std::string &sidetexture, Real thickness, const std::string &direction, Real OpenSpeed, Real CloseSpeed, Real x1, Real z1, Real x2, Real z2, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th)
std::string AlarmSoundStop
Definition elevatorcar.h:55
std::string DownStopSound
Definition elevatorcar.h:52
Reverb * AddReverb(const std::string &name, const std::string &type, const Vector3 &position, Real min_distance, Real max_distance)
DoorWrapper * FinishDoors(int number, bool DoorWalls=true, bool TrackWalls=true)
std::string DownStartSound
Definition elevatorcar.h:48
void SetBeepSound(const std::string &filename)
std::string IdleSound
Definition elevatorcar.h:53
std::string Name
Definition elevatorcar.h:37
ElevatorDoor * GetDoor(int number)
void EnableSensor(bool value, bool persistent=true)
std::string OpenSound
std::string DownChimeSound
std::string SensorSound
std::string EarlyUpChimeSound
std::string UpChimeSound
std::string EarlyDownChimeSound
std::string NudgeSound
std::string CloseSound
std::string MotorUpRunSound
Definition elevator.h:62
ElevatorCar * AddCar()
std::string MotorDownStartSound
Definition elevator.h:64
ElevatorCar * GetCar(int number)
std::string MotorDownRunSound
Definition elevator.h:65
int FireServicePhase2Car
Definition elevator.h:79
bool IndependentService
Definition elevator.h:74
std::string MotorUpStopSound
Definition elevator.h:63
std::string MotorIdleSound
Definition elevator.h:67
std::string MotorUpStartSound
Definition elevator.h:61
int FireServicePhase2
Definition elevator.h:78
int IndependentServiceCar
Definition elevator.h:75
std::string MotorDownStopSound
Definition elevator.h:66
void SetLocked(bool value, int keyid)
Definition lock.cpp:37
void SetKey(int keyid)
Definition model.cpp:110
Elevator * GetElevator(int number)
Definition sbs.cpp:1746
void Report(const std::string &message)
static const int sNextLine
Definition scriptproc.h:70
static const int sContinue
Definition scriptproc.h:69
static const int sError
Definition scriptproc.h:71
int ScriptWarning(std::string message)
void StoreCommand(::SBS::Object *object)
std::string Calc(const std::string &expression)
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
bool StartsWithNoCase(const std::string &string, const std::string &check_string)
Definition globals.cpp:237
void ReplaceAll(std::string &string, const std::string &original, const std::string &replacement)
Definition globals.cpp:201
int ToInt(const std::string &string)
Definition globals.cpp:402
std::string ToString(int number)
Definition globals.cpp:279
Real ToFloat(const std::string &string)
Definition globals.cpp:397
bool ToBool(std::string string)
Definition globals.cpp:407
bool IsEven(int Number)
Definition globals.cpp:37
bool IsNumeric(const wxString &string)