Skyscraper 2.0
floors.cpp
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 Alpha - Script Processor - Floor 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 "floor.h"
27#include "wall.h"
28#include "model.h"
29#include "trigger.h"
30#include "shaft.h"
31#include "stairs.h"
32#include "control.h"
33#include "elevator.h"
34#include "elevatorcar.h"
35#include "sound.h"
36#include "reverb.h"
37#include "floorindicator.h"
38#include "door.h"
39#include "revolvingdoor.h"
40#include "directional.h"
41#include "escalator.h"
42#include "movingwalkway.h"
43#include "light.h"
44#include "controller.h"
45#include "callstation.h"
46#include "scriptproc.h"
47#include "section.h"
48
49using namespace SBS;
50
51namespace Skyscraper {
52
69
71{
72 FloorCheck = 0;
73 callbutton_controller = 0;
74}
75
77{
78 //process floors
79
81
82 //exit with error if floor is invalid
83 if (!floor)
84 {
85 std::string floornum;
86 floornum = ToString(config->Current);
87 return ScriptError("Invalid floor " + floornum);
88 }
89
90 //cache floor parameters
91 if (cache_current != config->Current || floorcache_firstrun == true)
92 {
93 cache_current = config->Current;
94 cache_current_s = ToString(cache_current);
95 }
96 if (cache_height != floor->Height || floorcache_firstrun == true)
97 {
98 cache_height = floor->Height;
99 cache_height_s = ToString(cache_height);
100 }
101 if (cache_fullheight != floor->FullHeight() || floorcache_firstrun == true)
102 {
103 cache_fullheight = floor->FullHeight();
104 cache_fullheight_s = ToString(cache_fullheight);
105 }
106 if (cache_interfloorheight != floor->InterfloorHeight || floorcache_firstrun == true)
107 {
108 cache_interfloorheight = floor->InterfloorHeight;
109 cache_interfloorheight_s = ToString(cache_interfloorheight);
110 }
111 if (cache_base != floor->GetBase() || floorcache_firstrun == true)
112 {
113 cache_base = floor->GetBase();
114 cache_base_s = ToString(cache_base);
115 }
116
117 floorcache_firstrun = false;
118
119 //replace variables with actual values
120 ReplaceAll(LineData, "%floor%", cache_current_s);
121 ReplaceAll(LineData, "%height%", cache_height_s);
122 ReplaceAll(LineData, "%fullheight%", cache_fullheight_s);
123 ReplaceAll(LineData, "%interfloorheight%", cache_interfloorheight_s);
124 ReplaceAll(LineData, "%base%", cache_base_s);
125 ReplaceAll(LineData, "%floorid%", floor->ID);
126 ReplaceAll(LineData, "%floornumberid%", floor->NumberID);
127 ReplaceAll(LineData, "%floorname%", floor->Name);
128 ReplaceAll(LineData, "%floortype%", floor->FloorType);
129 ReplaceAll(LineData, "%description%", floor->Description);
130
131 if (parent->getfloordata == true)
132 return sCheckFloors;
133
134 //IF/While statement stub (continue to global commands for processing)
135 if (StartsWithNoCase(LineData, "if") || StartsWithNoCase(LineData, "while"))
136 return sContinue;
137
138 //process math functions
139 if (MathFunctions(LineData) == sError)
140 return sError;
141
142 //process functions
143 if (parent->FunctionProc() == true)
144 return sNextLine;
145
146 //get text after equal sign
147 bool equals;
148 std::string value = GetAfterEquals(LineData, equals);
149
150 //parameters
151
152 //Height parameter
153 if (StartsWithNoCase(LineData, "height"))
154 {
155 if (equals == false)
156 return ScriptError("Syntax error");
157 std::string str = Calc(value);
158 if (!IsNumeric(str, floor->Height))
159 return ScriptError("Invalid value");
160 if (FloorCheck < 2)
161 FloorCheck = 1;
162 else
163 FloorCheck = 3;
164 }
165 //InterfloorHeight parameter
166 if (StartsWithNoCase(LineData, "interfloorheight"))
167 {
168 if (equals == false)
169 return ScriptError("Syntax error");
170 std::string str = Calc(value);
171 if (!IsNumeric(str, floor->InterfloorHeight))
172 return ScriptError("Invalid value");
173 if (FloorCheck == 0)
174 FloorCheck = 2;
175 else
176 FloorCheck = 3;
177 }
178 //Altitude parameter
179 if (StartsWithNoCase(LineData, "altitude"))
180 {
181 if (equals == false)
182 return ScriptError("Syntax error");
183 std::string str = Calc(value);
184 Real alt;
185 if (!IsNumeric(str, alt))
186 return ScriptError("Invalid value");
187 floor->SetAltitude(alt);
188 return sNextLine;
189 }
190 //ID parameter
191 if (StartsWithNoCase(LineData, "id"))
192 {
193 if (equals == false)
194 return ScriptError("Syntax error");
195 floor->ID = Calc(value);
196 return sNextLine;
197 }
198 //NumberID parameter
199 if (StartsWithNoCase(LineData, "numberid"))
200 {
201 if (equals == false)
202 return ScriptError("Syntax error");
203 floor->NumberID = Calc(value);
204 return sNextLine;
205 }
206 //Name parameter
207 if (StartsWithNoCase(LineData, "name"))
208 {
209 if (equals == false)
210 return ScriptError("Syntax error");
211 floor->Name = Calc(value);
212 return sNextLine;
213 }
214 //Type parameter
215 if (StartsWithNoCase(LineData, "type"))
216 {
217 if (equals == false)
218 return ScriptError("Syntax error");
219 floor->FloorType = value;
220 return sNextLine;
221 }
222 //Description parameter
223 if (StartsWithNoCase(LineData, "description"))
224 {
225 if (equals == false)
226 return ScriptError("Syntax error");
227 floor->Description = value;
228 return sNextLine;
229 }
230 //IndicatorTexture parameter
231 if (StartsWithNoCase(LineData, "indicatortexture"))
232 {
233 if (equals == false)
234 return ScriptError("Syntax error");
235 floor->IndicatorTexture = Calc(value);
236 return sNextLine;
237 }
238 //Group parameter
239 if (StartsWithNoCase(LineData, "group"))
240 {
241 //copy string listing of group floors into array
242
243 int params = SplitAfterEquals(LineData, false);
244 if (params < 1)
245 return ScriptError("Syntax Error");
246
247 for (int line = 0; line < params; line++)
248 {
249 int start, end;
250 if (GetRange(tempdata[line], start, end) == true)
251 {
252 for (int k = start; k <= end; k++)
253 floor->AddGroupFloor(k);
254 }
255 else
256 {
257 int data;
258 std::string str = Calc(tempdata[line]);
259 if (!IsNumeric(str, data))
260 return ScriptError("Invalid value");
261 floor->AddGroupFloor(data);
262 }
263 }
264 return sNextLine;
265 }
266
267 //calculate altitude
268 if (FloorCheck == 3)
269 {
270 FloorCheck = 0;
271 if (floor->CalculateAltitude() == false)
272 return ScriptError();
273 return sNextLine;
274 }
275
276 //Exit command
277 if (StartsWithNoCase(LineData, "exit"))
278 {
279 if (config->RangeL != config->RangeH)
280 LineData = "<endfloors>";
281 else
282 LineData = "<endfloor>";
283 }
284
285 //AddFloor command
286 if (StartsWithNoCase(LineData, "addfloor "))
287 {
288 //get data
289 int params = SplitData(LineData, 9);
290
291 if (params != 12 && params != 14)
292 return ScriptError("Incorrect number of parameters");
293
294 bool compat = false;
295 if (params == 12)
296 compat = true;
297
298 //check numeric values
299 if (compat == true)
300 {
301 for (int i = 2; i <= 10; i++)
302 {
303 if (!IsNumeric(tempdata[i]))
304 return ScriptError("Invalid value: " + tempdata[i]);
305 }
306 if (warn_deprecated == true)
307 ScriptWarning("Syntax deprecated");
308 }
309 else
310 {
311 for (int i = 2; i <= 12; i++)
312 {
313 if (i == 9)
314 i = 11;
315 if (!IsNumeric(tempdata[i]))
316 return ScriptError("Invalid value: " + tempdata[i]);
317 }
318 }
319
320 //stop here if in Check mode
321 if (config->CheckScript == true)
322 return sNextLine;
323
324 //create floor
325 if (compat == true)
326 StoreCommand(floor->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]), ToBool(tempdata[11]), true));
327 else
328 StoreCommand(floor->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]), ToBool(tempdata[13])));
329 return sNextLine;
330 }
331
332 //AddShaftFloor command
333 if (StartsWithNoCase(LineData, "addshaftfloor"))
334 {
335 //get data
336 int params = SplitData(LineData, 14);
337
338 if (params != 12 && params != 14)
339 return ScriptError("Incorrect number of parameters");
340
341 bool compat = false;
342 if (params == 12)
343 compat = true;
344
345 //check numeric values
346 if (compat == true)
347 {
348 for (int i = 3; i <= 11; i++)
349 {
350 if (i == 1)
351 i = 3; //skip non-numeric parameters
352 if (!IsNumeric(tempdata[i]))
353 return ScriptError("Invalid value: " + tempdata[i]);
354 }
355 if (warn_deprecated == true)
356 ScriptWarning("Syntax deprecated");
357 }
358 else
359 {
360 for (int i = 3; i <= 13; i++)
361 {
362 if (i == 1)
363 i = 3; //skip non-numeric parameters
364 if (i == 10)
365 i = 12;
366 if (!IsNumeric(tempdata[i]))
367 return ScriptError("Invalid value: " + tempdata[i]);
368 }
369 }
370
371 //create floor
372 if (Simcore->GetShaft(ToInt(tempdata[0])))
373 {
374 //stop here if in Check mode
375 if (config->CheckScript == true)
376 return sNextLine;
377
379
380 if (!level)
381 {
382 ScriptError("Invalid level " + ToString(config->Current) + " for shaft " + tempdata[0]);
383 return sNextLine;
384 }
385
386 if (compat == true)
387 StoreCommand(level->AddFloor(tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), config->ReverseAxis, false, ToFloat(tempdata[10]), ToFloat(tempdata[11]), true));
388 else
389 StoreCommand(level->AddFloor(tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToBool(tempdata[10]), ToBool(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13])));
390 }
391 else
392 return ScriptError("Invalid shaft " + tempdata[0]);
393 return sNextLine;
394 }
395
396 //AddStairsFloor command
397 if (StartsWithNoCase(LineData, "addstairsfloor"))
398 {
399 //get data
400 int params = SplitData(LineData, 14);
401
402 if (params != 12 && params != 14)
403 return ScriptError("Incorrect number of parameters");
404
405 bool compat = false;
406 if (params == 12)
407 compat = true;
408
409 //check numeric values
410 if (compat == true)
411 {
412 for (int i = 3; i <= 11; i++)
413 {
414 if (i == 1)
415 i = 3; //skip non-numeric parameters
416 if (!IsNumeric(tempdata[i]))
417 return ScriptError("Invalid value: " + tempdata[i]);
418 }
419 if (warn_deprecated == true)
420 ScriptWarning("Syntax deprecated");
421 }
422 else
423 {
424 for (int i = 3; i <= 13; i++)
425 {
426 if (i == 1)
427 i = 3; //skip non-numeric parameters
428 if (i == 10)
429 i = 12;
430 if (!IsNumeric(tempdata[i]))
431 return ScriptError("Invalid value: " + tempdata[i]);
432 }
433 }
434
435 //create floor
436 if (Simcore->GetStairwell(ToInt(tempdata[0])))
437 {
438 //stop here if in Check mode
439 if (config->CheckScript == true)
440 return sNextLine;
441
443
444 if (!level)
445 {
446 ScriptError("Invalid level " + ToString(config->Current) + " for stairwell " + tempdata[0]);
447 return sNextLine;
448 }
449
450 if (compat == true)
451 StoreCommand(level->AddFloor(tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), config->ReverseAxis, false, ToFloat(tempdata[10]), ToFloat(tempdata[11]), true));
452 else
453 StoreCommand(level->AddFloor(tempdata[1], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToBool(tempdata[10]), ToBool(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13])));
454 }
455 else
456 return ScriptError("Invalid stairwell " + tempdata[0]);
457 return sNextLine;
458 }
459
460 //AddInterFloorFloor command
461 if (StartsWithNoCase(LineData, "addinterfloorfloor"))
462 {
463 //get data
464 int params = SplitData(LineData, 19);
465
466 if (params != 11 && params != 13)
467 return ScriptError("Incorrect number of parameters");
468
469 bool compat = false;
470 if (params == 11)
471 compat = true;
472
473 //check numeric values
474 if (compat == true)
475 {
476 for (int i = 2; i <= 10; i++)
477 {
478 if (!IsNumeric(tempdata[i]))
479 return ScriptError("Invalid value: " + tempdata[i]);
480 }
481 if (warn_deprecated == true)
482 ScriptWarning("Syntax deprecated");
483 }
484 else
485 {
486 for (int i = 2; i <= 12; i++)
487 {
488 if (i == 9)
489 i = 11;
490 if (!IsNumeric(tempdata[i]))
491 return ScriptError("Invalid value: " + tempdata[i]);
492 }
493 }
494
495 //stop here if in Check mode
496 if (config->CheckScript == true)
497 return sNextLine;
498
499 //create floor
500 if (compat == true)
501 StoreCommand(floor->AddInterfloorFloor(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));
502 else
503 StoreCommand(floor->AddInterfloorFloor(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])));
504 return sNextLine;
505 }
506
507 //AddWall command
508 if (StartsWithNoCase(LineData, "addwall"))
509 {
510 //get data
511 int params = SplitData(LineData, 8);
512
513 if (params != 14)
514 return ScriptError("Incorrect number of parameters");
515
516 //check numeric values
517 for (int i = 2; i <= 12; i++)
518 {
519 if (!IsNumeric(tempdata[i]))
520 return ScriptError("Invalid value: " + tempdata[i]);
521 }
522
523 //stop here if in Check mode
524 if (config->CheckScript == true)
525 return sNextLine;
526
527 //create wall
528 StoreCommand(floor->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]), ToBool(tempdata[13])));
529 return sNextLine;
530 }
531
532 //AddShaftWall command
533 if (StartsWithNoCase(LineData, "addshaftwall"))
534 {
535 //get data
536 int params = SplitData(LineData, 13);
537
538 if (params != 14)
539 return ScriptError("Incorrect number of parameters");
540
541 //check numeric values
542 for (int i = 0; i <= 13; i++)
543 {
544 if (i == 1)
545 i = 3; //skip non-numeric parameters
546 if (!IsNumeric(tempdata[i]))
547 return ScriptError("Invalid value: " + tempdata[i]);
548 }
549
550 //create wall
551 if (Simcore->GetShaft(ToInt(tempdata[0])))
552 {
553 //stop here if in Check mode
554 if (config->CheckScript == true)
555 return sNextLine;
556
558
559 if (!level)
560 {
561 ScriptError("Invalid level " + ToString(config->Current) + " for shaft " + tempdata[0]);
562 return sNextLine;
563 }
564
565 StoreCommand(level->AddWall(tempdata[1], 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]), ToFloat(tempdata[13])));
566 }
567 else
568 return ScriptError("Invalid shaft " + tempdata[0]);
569 return sNextLine;
570 }
571
572 //AddStairsWall command
573 if (StartsWithNoCase(LineData, "addstairswall"))
574 {
575 //get data
576 int params = SplitData(LineData, 14);
577
578 if (params != 14)
579 return ScriptError("Incorrect number of parameters");
580
581 //check numeric values
582 for (int i = 0; i <= 13; i++)
583 {
584 if (i == 1)
585 i = 3; //skip non-numeric parameters
586 if (!IsNumeric(tempdata[i]))
587 return ScriptError("Invalid value: " + tempdata[i]);
588 }
589
590 //create wall
591 if (Simcore->GetStairwell(ToInt(tempdata[0])))
592 {
593 //stop here if in Check mode
594 if (config->CheckScript == true)
595 return sNextLine;
596
598
599 if (!level)
600 {
601 ScriptError("Invalid level " + ToString(config->Current) + " for stairwell " + tempdata[0]);
602 return sNextLine;
603 }
604
605 StoreCommand(level->AddWall(tempdata[1], 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]), ToFloat(tempdata[13])));
606 }
607 else
608 return ScriptError("Invalid stairwell " + tempdata[0]);
609 return sNextLine;
610 }
611
612 //AddInterFloorWall command
613 if (StartsWithNoCase(LineData, "addinterfloorwall"))
614 {
615 //get data
616 int params = SplitData(LineData, 18);
617
618 if (params != 13)
619 return ScriptError("Incorrect number of parameters");
620
621 //check numeric values
622 for (int i = 2; i <= 12; i++)
623 {
624 if (!IsNumeric(tempdata[i]))
625 return ScriptError("Invalid value: " + tempdata[i]);
626 }
627
628 //stop here if in Check mode
629 if (config->CheckScript == true)
630 return sNextLine;
631
632 //create wall
633 StoreCommand(floor->AddInterfloorWall(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])));
634 return sNextLine;
635 }
636
637 //ColumnWallBox command
638 if (StartsWithNoCase(LineData, "columnwallbox "))
639 {
640 //get data
641 int params = SplitData(LineData, 14);
642
643 if (params != 14)
644 return ScriptError("Incorrect number of parameters");
645
646 //check numeric values
647 for (int i = 2; i <= 9; i++)
648 {
649 if (!IsNumeric(tempdata[i]))
650 return ScriptError("Invalid value: " + tempdata[i]);
651 }
652
653 //stop here if in Check mode
654 if (config->CheckScript == true)
655 return sNextLine;
656
657 StoreCommand(floor->ColumnWallBox(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]), ToBool(tempdata[10]), ToBool(tempdata[11]), ToBool(tempdata[12]), ToBool(tempdata[13])));
658 return sNextLine;
659 }
660
661 //ColumnWallBox2 command
662 if (StartsWithNoCase(LineData, "columnwallbox2"))
663 {
664 //get data
665 int params = SplitData(LineData, 15);
666
667 if (params != 14)
668 return ScriptError("Incorrect number of parameters");
669
670 //check numeric values
671 for (int i = 2; i <= 9; i++)
672 {
673 if (!IsNumeric(tempdata[i]))
674 return ScriptError("Invalid value: " + tempdata[i]);
675 }
676
677 //stop here if in Check mode
678 if (config->CheckScript == true)
679 return sNextLine;
680
681 StoreCommand(floor->ColumnWallBox2(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]), ToBool(tempdata[10]), ToBool(tempdata[11]), ToBool(tempdata[12]), ToBool(tempdata[13])));
682 return sNextLine;
683 }
684
685 //CallButtonElevators command
686 if (StartsWithNoCase(LineData, "callbuttonelevators"))
687 {
688 //copy string listing of elevators into array
689 int params = SplitAfterEquals(LineData, false);
690 if (params < 1)
691 return ScriptError("Syntax Error");
692
693 std::vector<int> callbutton_elevators;
694
695 for (int line = 0; line < params; line++)
696 {
697 int start, end;
698 if (GetRange(tempdata[line], start, end))
699 {
700 for (int k = start; k <= end; k++)
701 {
702 if (k < 1 || k > Simcore->GetElevatorCount())
703 return ScriptError("Invalid elevator number");
704
705 callbutton_elevators.emplace_back(k);
706 }
707 }
708 else
709 {
710 std::string str = Calc(tempdata[line]);
711 int data;
712 if (!IsNumeric(str, data))
713 return ScriptError("Invalid elevator number");
714
715 if (data < 1 || data > Simcore->GetElevatorCount())
716 return ScriptError("Invalid elevator number");
717 callbutton_elevators.emplace_back(data);
718 }
719 }
720
721 //sort list
722 std::sort(callbutton_elevators.begin(), callbutton_elevators.end());
723
724 //find an existing controller that matches the list of elevators
725 DispatchController *controller = 0;
726 for (int i = 1; i <= Simcore->GetControllerCount(); i++)
727 {
728 if (Simcore->GetController(i)->SameElevators(callbutton_elevators) == true)
729 {
730 controller = Simcore->GetController(i);
731 break;
732 }
733 }
734
735 //otherwise create a new dispatch controller and add elevators to it
736 if (controller == 0)
737 {
738 controller = Simcore->NewController(Simcore->GetControllerCount() + 1);
739 controller->DestinationDispatch = false;
740 controller->Name = "Dispatch Controller " + ToString(Simcore->GetControllerCount());
741 for (size_t i = 0; i < callbutton_elevators.size(); i++)
742 controller->AddElevator(callbutton_elevators[i]);
743 }
744
745 callbutton_controller = controller->Number;
746
747 return sNextLine;
748 }
749
750 //CreateCallButtons command
751 if (StartsWithNoCase(LineData, "createcallbuttons"))
752 {
753 if (callbutton_controller == 0)
754 return ScriptError("No elevators specified");
755
756 //get data
757 int params = SplitData(LineData, 18);
758
759 int compat = 0;
760 if (params == 12)
761 compat = 1;
762 if (params == 14)
763 compat = 2;
764 if (params == 15)
765 compat = 3;
766
767 //check numeric values
768 if (compat == 1)
769 {
770 for (int i = 3; i <= 11; i++)
771 {
772 if (i == 6 || i == 9) //skip non-numeric parameters
773 i++;
774 if (!IsNumeric(tempdata[i]))
775 return ScriptError("Invalid value: " + tempdata[i]);
776 }
777 if (warn_deprecated == true)
778 ScriptWarning("Syntax deprecated");
779 }
780 else if (compat == 2)
781 {
782 for (int i = 5; i <= 13; i++)
783 {
784 if (i == 8 || i == 11) //skip non-numeric parameters
785 i++;
786 if (!IsNumeric(tempdata[i]))
787 return ScriptError("Invalid value: " + tempdata[i]);
788 }
789 if (warn_deprecated == true)
790 ScriptWarning("Syntax deprecated");
791 }
792 else if (compat == 3)
793 {
794 for (int i = 6; i <= 14; i++)
795 {
796 if (i == 9 || i == 12) //skip non-numeric parameters
797 i++;
798 if (!IsNumeric(tempdata[i]))
799 return ScriptError("Invalid value: " + tempdata[i]);
800 }
801 if (warn_deprecated == true)
802 ScriptWarning("Syntax deprecated");
803 }
804 else
805 {
806 if (params != 16)
807 return ScriptError("Incorrect number of parameters");
808
809 for (int i = 7; i <= 15; i++)
810 {
811 if (i == 10 || i == 13) //skip non-numeric parameters
812 i++;
813 if (!IsNumeric(tempdata[i]))
814 return ScriptError("Invalid value: " + tempdata[i]);
815 }
816 }
817
818 //stop here if in Check mode
819 if (config->CheckScript == true)
820 return sNextLine;
821
822 //create call button
823 CallStation* callstation = 0;
824 if (compat == 1)
825 callstation = floor->AddCallButtons(callbutton_controller, "", "", tempdata[0], tempdata[1], tempdata[1], tempdata[2], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), tempdata[6], ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToBool(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]));
826 else if (compat == 2)
827 callstation = floor->AddCallButtons(callbutton_controller, "", "", tempdata[0], tempdata[1], tempdata[2], tempdata[3], tempdata[4], ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), tempdata[8], ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToBool(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]));
828 else if (compat == 3)
829 callstation = floor->AddCallButtons(callbutton_controller, tempdata[0], tempdata[0], tempdata[1], tempdata[2], tempdata[3], tempdata[4], tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), tempdata[9], ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToBool(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]));
830 else
831 callstation = floor->AddCallButtons(callbutton_controller, tempdata[0], tempdata[1], tempdata[2], tempdata[3], tempdata[4], tempdata[5], tempdata[6], ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), tempdata[10], ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToBool(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]));
832
833 if (callstation)
834 {
835 if (config->lockvalue == 0)
836 callstation->SetLocked(false, config->keyvalue);
837 else
838 callstation->SetLocked(true, config->keyvalue);
839 }
840 StoreCommand(callstation);
841 return sNextLine;
842 }
843
844 //AddStairs command
845 if (StartsWithNoCase(LineData, "addstairs "))
846 {
847 //get data
848 int params = SplitData(LineData, 10);
849
850 if (params < 13 || params > 14)
851 return ScriptError("Incorrect number of parameters");
852
853 bool compat = false;
854 if (params == 13)
855 compat = true;
856
857 //check numeric values
858 if (params == 13)
859 {
860 for (int i = 0; i <= 12; i++)
861 {
862 if (i == 1)
863 i = 4; //skip non-numeric parameters
864 if (!IsNumeric(tempdata[i]))
865 return ScriptError("Invalid value: " + tempdata[i]);
866 }
867
868 if (warn_deprecated == true)
869 ScriptWarning("Syntax deprecated");
870 }
871 else
872 {
873 for (int i = 0; i <= 13; i++)
874 {
875 if (i == 1)
876 i = 5; //skip non-numeric parameters
877 if (!IsNumeric(tempdata[i]))
878 return ScriptError("Invalid value: " + tempdata[i]);
879 }
880 }
881
882 //create stairs
883 if (Simcore->GetStairwell(ToInt(tempdata[0])))
884 {
885 //stop here if in Check mode
886 if (config->CheckScript == true)
887 return sNextLine;
888
890
891 if (!level)
892 {
893 ScriptError("Invalid level " + ToString(config->Current) + " for stairwell " + tempdata[0]);
894 return sNextLine;
895 }
896
897 if (compat == true)
898 StoreCommand(level->AddStairs(tempdata[1], tempdata[2], tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToInt(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12])));
899 else
900 StoreCommand(level->AddStairs(tempdata[1], tempdata[2], tempdata[3], tempdata[4], ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToInt(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13])));
901 }
902 else
903 return ScriptError("Invalid stairwell " + tempdata[0]);
904 return sNextLine;
905 }
906
907 //AddDoor command
908 if (StartsWithNoCase(LineData, "adddoor "))
909 {
910 //get data
911 int params = SplitData(LineData, 8);
912
913 if (params < 10 || params == 11 || params == 15 || params == 16 || params > 17)
914 return ScriptError("Incorrect number of parameters");
915
916 int compat = 0;
917
918 //check numeric values
919 if (params == 10)
920 {
921 for (int i = 1; i <= 9; i++)
922 {
923 if (!IsNumeric(tempdata[i]))
924 return ScriptError("Invalid value: " + tempdata[i]);
925 }
926 compat = 1;
927 }
928 if (params == 12)
929 {
930 for (int i = 3; i <= 11; i++)
931 {
932 if (!IsNumeric(tempdata[i]))
933 return ScriptError("Invalid value: " + tempdata[i]);
934 }
935 compat = 2;
936 }
937 if (params == 13)
938 {
939 for (int i = 3; i <= 12; i++)
940 {
941 if (!IsNumeric(tempdata[i]))
942 return ScriptError("Invalid value: " + tempdata[i]);
943 }
944 compat = 3;
945 }
946 if (params == 14)
947 {
948 for (int i = 4; i <= 13; i++)
949 {
950 if (!IsNumeric(tempdata[i]))
951 return ScriptError("Invalid value: " + tempdata[i]);
952 }
953 compat = 4;
954 }
955 if (params == 17)
956 {
957 for (int i = 4; i <= 15; i++)
958 {
959 if (!IsNumeric(tempdata[i]))
960 return ScriptError("Invalid value: " + tempdata[i]);
961 }
962 }
963 //check to see if file exists
964 if (compat != 1)
965 {
966 parent->CheckFile("data/" + tempdata[0]);
967 parent->CheckFile("data/" + tempdata[1]);
968 }
969
970 if (compat > 0 && warn_deprecated == true)
971 ScriptWarning("Syntax deprecated");
972
973 //stop here if in Check mode
974 if (config->CheckScript == true)
975 return sNextLine;
976
977 //get directions
978 std::string face_direction;
979 std::string open_direction;
980 int direction = 0;
981 if (compat == 1)
982 direction = ToInt(tempdata[2]);
983 else if (compat > 1)
984 direction = ToInt(tempdata[4]);
985 else
986 direction = ToInt(tempdata[5]);
987 GetDirectionStrings(direction, face_direction, open_direction);
988
989 //create door
990 Door* door;
991
992 if (compat == 1)
993 door = floor->AddDoor("", "", "", false, tempdata[0], tempdata[0], ToFloat(tempdata[1]), face_direction, open_direction, true, 0, 0, ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), 0, 0);
994 if (compat == 2)
995 door = floor->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);
996 if (compat == 3)
997 door = floor->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);
998 if (compat == 4)
999 door = floor->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);
1000 if (compat == 0)
1001 door = floor->AddDoor(tempdata[16], 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]), ToFloat(tempdata[14]), ToFloat(tempdata[15]));
1002
1003 if (door)
1005
1006 StoreCommand(door);
1007 return sNextLine;
1008 }
1009
1010 //AddStairsDoor command
1011 if (StartsWithNoCase(LineData, "addstairsdoor "))
1012 {
1013 //get data
1014 int params = SplitData(LineData, 14);
1015
1016 if (params < 11 || params == 12 || params == 16 || params == 17 || params > 18)
1017 return ScriptError("Incorrect number of parameters");
1018
1019 int compat = 0;
1020
1021 //check numeric values
1022 if (params == 11)
1023 {
1024 for (int i = 0; i <= 10; i++)
1025 {
1026 if (i == 1)
1027 i = 2; //skip non-numeric parameters
1028 if (!IsNumeric(tempdata[i]))
1029 return ScriptError("Invalid value: " + tempdata[i]);
1030 }
1031 compat = 1;
1032 }
1033 if (params == 13)
1034 {
1035 for (int i = 0; i <= 12; i++)
1036 {
1037 if (i == 1)
1038 i = 4; //skip non-numeric parameters
1039 if (!IsNumeric(tempdata[i]))
1040 return ScriptError("Invalid value: " + tempdata[i]);
1041 }
1042 compat = 2;
1043 }
1044 if (params == 14)
1045 {
1046 for (int i = 0; i <= 13; i++)
1047 {
1048 if (i == 1)
1049 i = 4; //skip non-numeric parameters
1050 if (!IsNumeric(tempdata[i]))
1051 return ScriptError("Invalid value: " + tempdata[i]);
1052 }
1053 compat = 3;
1054 }
1055 if (params == 15)
1056 {
1057 for (int i = 0; i <= 14; i++)
1058 {
1059 if (i == 1)
1060 i = 5; //skip non-numeric parameters
1061 if (!IsNumeric(tempdata[i]))
1062 return ScriptError("Invalid value: " + tempdata[i]);
1063 }
1064 compat = 4;
1065 }
1066 if (params == 18)
1067 {
1068 for (int i = 0; i <= 16; i++)
1069 {
1070 if (i == 1)
1071 i = 5; //skip non-numeric parameters
1072 if (!IsNumeric(tempdata[i]))
1073 return ScriptError("Invalid value: " + tempdata[i]);
1074 }
1075 }
1076 //check to see if file exists
1077 if (compat != 1)
1078 {
1079 parent->CheckFile("data/" + tempdata[1]);
1080 parent->CheckFile("data/" + tempdata[2]);
1081 }
1082
1083 if (compat > 0 && warn_deprecated == true)
1084 ScriptWarning("Syntax deprecated");
1085
1086 //create door
1087 if (Simcore->GetStairwell(ToInt(tempdata[0])))
1088 {
1089 //stop here if in Check mode
1090 if (config->CheckScript == true)
1091 return sNextLine;
1092
1094
1095 if (!level)
1096 {
1097 ScriptError("Invalid level " + ToString(config->Current) + " for stairwell " + tempdata[0]);
1098 return sNextLine;
1099 }
1100
1101 //get directions
1102 std::string face_direction;
1103 std::string open_direction;
1104 int direction = 0;
1105 if (compat == 1)
1106 direction = ToInt(tempdata[3]);
1107 else if (compat == 2 || compat == 3)
1108 direction = ToInt(tempdata[5]);
1109 else
1110 direction = ToInt(tempdata[6]);
1111 GetDirectionStrings(direction, face_direction, open_direction);
1112
1113 Door* door = 0;
1114
1115 if (compat == 1)
1116 door = level->AddDoor("", "", "", false, tempdata[1], tempdata[1], ToFloat(tempdata[2]), face_direction, open_direction, true, 0, 0, ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), 0, 0);
1117 if (compat == 2)
1118 door = level->AddDoor("", tempdata[1], tempdata[2], false, tempdata[3], tempdata[3], ToFloat(tempdata[4]), face_direction, open_direction, true, 0, 0, ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), 0, 0);
1119 if (compat == 3)
1120 door = level->AddDoor("", tempdata[1], tempdata[2], false, 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);
1121 if (compat == 4)
1122 door = level->AddDoor("", tempdata[1], tempdata[2], ToBool(tempdata[3]), tempdata[4], tempdata[4], ToFloat(tempdata[5]), face_direction, open_direction, true, ToFloat(tempdata[7]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), 0, 0);
1123 if (compat == 0)
1124 door = level->AddDoor(tempdata[17], tempdata[1], tempdata[2], ToBool(tempdata[3]), tempdata[4], tempdata[4], ToFloat(tempdata[5]), face_direction, open_direction, true, ToFloat(tempdata[7]), 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]));
1125
1126 if (door)
1128
1129 StoreCommand(door);
1130 }
1131 else
1132 return ScriptError("Invalid stairwell " + tempdata[0]);
1133 return sNextLine;
1134 }
1135
1136 //AddShaftStdDoor command
1137 if (StartsWithNoCase(LineData, "addshaftstddoor "))
1138 {
1139 //get data
1140 int params = SplitData(LineData, 16);
1141
1142 if (params != 17 && params != 18)
1143 return ScriptError("Incorrect number of parameters");
1144
1145 //check numeric values
1146 for (int i = 0; i <= 16; i++)
1147 {
1148 if (i == 1)
1149 i = 5; //skip non-numeric parameters
1150 if (!IsNumeric(tempdata[i]))
1151 return ScriptError("Invalid value: " + tempdata[i]);
1152 }
1153
1154 //check to see if file exists
1155 parent->CheckFile("data/" + tempdata[1]);
1156 parent->CheckFile("data/" + tempdata[2]);
1157
1158 //create door
1159 if (Simcore->GetShaft(ToInt(tempdata[0])))
1160 {
1161 //stop here if in Check mode
1162 if (config->CheckScript == true)
1163 return sNextLine;
1164
1165 ::SBS::Shaft::Level *level = Simcore->GetShaft(ToInt(tempdata[0]))->GetLevel(config->Current);
1166
1167 if (!level)
1168 {
1169 ScriptError("Invalid level " + ToString(config->Current) + " for shaft " + tempdata[0]);
1170 return sNextLine;
1171 }
1172
1173 //get directions
1174 std::string face_direction;
1175 std::string open_direction;
1176 int direction = ToInt(tempdata[6]);
1177 GetDirectionStrings(direction, face_direction, open_direction);
1178
1179 Door* door;
1180 if (params == 17)
1181 door = level->AddDoor("", tempdata[1], tempdata[2], ToBool(tempdata[3]), tempdata[4], tempdata[4], ToFloat(tempdata[5]), face_direction, open_direction, true, ToFloat(tempdata[7]), 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]));
1182 else
1183 door = level->AddDoor(tempdata[17], tempdata[1], tempdata[2], ToBool(tempdata[3]), tempdata[4], tempdata[4], ToFloat(tempdata[5]), face_direction, open_direction, true, ToFloat(tempdata[7]), 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]));
1184
1185 if (door)
1187
1188 StoreCommand(door);
1189 }
1190 else
1191 return ScriptError("Invalid shaft " + tempdata[0]);
1192 return sNextLine;
1193 }
1194
1195 //AddExternalDoor command
1196 if (StartsWithNoCase(LineData, "addexternaldoor "))
1197 {
1198 //get data
1199 int params = SplitData(LineData, 16);
1200
1201 if (params != 14 && params != 17)
1202 return ScriptError("Incorrect number of parameters");
1203
1204 //check numeric values
1205 if (params == 14)
1206 {
1207 for (int i = 4; i <= 13; i++)
1208 {
1209 if (!IsNumeric(tempdata[i]))
1210 return ScriptError("Invalid value: " + tempdata[i]);
1211 }
1212 }
1213 else
1214 {
1215 for (int i = 4; i <= 15; i++)
1216 {
1217 if (!IsNumeric(tempdata[i]))
1218 return ScriptError("Invalid value: " + tempdata[i]);
1219 }
1220 }
1221
1222 //check to see if file exists
1223 parent->CheckFile("data/" + tempdata[0]);
1224 parent->CheckFile("data/" + tempdata[1]);
1225
1226 //stop here if in Check mode
1227 if (config->CheckScript == true)
1228 return sNextLine;
1229
1230 //get directions
1231 std::string face_direction;
1232 std::string open_direction;
1233 int direction = ToInt(tempdata[5]);
1234 GetDirectionStrings(direction, face_direction, open_direction);
1235
1236 //create door
1237 Door* door;
1238 if (params == 14)
1239 door = floor->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, true);
1240 else
1241 door = floor->AddDoor(tempdata[16], 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]), ToFloat(tempdata[14]), ToFloat(tempdata[15]), true);
1242
1243 if (door)
1245
1246 StoreCommand(door);
1247 return sNextLine;
1248 }
1249
1250 //AddDirectionalIndicator command
1251 if (StartsWithNoCase(LineData, "adddirectionalindicator"))
1252 {
1253 //get data
1254 int params = SplitData(LineData, 24);
1255
1256 if (params != 18 && params != 19)
1257 return ScriptError("Incorrect number of parameters");
1258
1259 bool compat = false;
1260
1261 //check numeric values
1262 if (params == 18)
1263 {
1264 for (int i = 9; i <= 17; i++)
1265 {
1266 if (i == 12)
1267 i = 13;
1268 if (i == 15)
1269 i = 16;
1270 if (!IsNumeric(tempdata[i]))
1271 return ScriptError("Invalid value: " + tempdata[i]);
1272 }
1273 compat = true;
1274 if (warn_deprecated == true)
1275 ScriptWarning("Syntax deprecated");
1276 }
1277 if (params == 19)
1278 {
1279 for (int i = 10; i <= 18; i++)
1280 {
1281 if (i == 13)
1282 i = 14;
1283 if (i == 16)
1284 i = 17;
1285 if (!IsNumeric(tempdata[i]))
1286 return ScriptError("Invalid value: " + tempdata[i]);
1287 }
1288 }
1289
1290 int elevator, car;
1291 if (!GetElevatorCar(tempdata[0], floor->Number, elevator, car))
1292 return sError;
1293
1294 //stop here if in Check mode
1295 if (config->CheckScript == true)
1296 return sNextLine;
1297
1298 if (compat == true)
1299 StoreCommand(floor->AddDirectionalIndicator(elevator, car, ToBool(tempdata[1]), false, 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])));
1300 else
1301 StoreCommand(floor->AddDirectionalIndicator(elevator, car, ToBool(tempdata[1]), ToBool(tempdata[2]), ToBool(tempdata[3]), ToBool(tempdata[4]), tempdata[5], tempdata[6], tempdata[7], tempdata[8], tempdata[9], ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), tempdata[13], ToFloat(tempdata[14]), ToFloat(tempdata[15]), ToBool(tempdata[16]), ToFloat(tempdata[17]), ToFloat(tempdata[18])));
1302 return sNextLine;
1303 }
1304
1305 //AddShaftDoor command
1306 if (StartsWithNoCase(LineData, "addshaftdoor "))
1307 {
1308 //get data
1309 int params = SplitData(LineData, 13);
1310
1311 if (params != 5 && params != 6 && params != 10)
1312 return ScriptError("Incorrect number of parameters");
1313
1314 int compat = 0;
1315 if (params == 5)
1316 compat = 1; //1.4 compatibility mode
1317 if (params == 6)
1318 compat = 2;
1319
1320 //exit if the SetShaftDoors command was never used
1321 if (compat > 0 && config->setshaftdoors == false)
1322 return ScriptError("SetShaftDoors must be used before AddShaftDoor");
1323
1324 //check numeric values
1325 if (compat == 0)
1326 {
1327 for (int i = 1; i <= 9; i++)
1328 {
1329 if (i == 2)
1330 i = 4;
1331 if (!IsNumeric(tempdata[i]))
1332 return ScriptError("Invalid value: " + tempdata[i]);
1333 }
1334 }
1335 if (compat == 1)
1336 {
1337 for (int i = 1; i <= 4; i++)
1338 {
1339 if (i == 2)
1340 i = 3;
1341 if (!IsNumeric(tempdata[i]))
1342 return ScriptError("Invalid value: " + tempdata[i]);
1343 }
1344 }
1345 if (compat == 2)
1346 {
1347 for (int i = 1; i <= 5; i++)
1348 {
1349 if (i == 2)
1350 i = 4;
1351 if (!IsNumeric(tempdata[i]))
1352 return ScriptError("Invalid value: " + tempdata[i]);
1353 }
1354 }
1355
1356 if (compat > 0 && warn_deprecated == true)
1357 ScriptWarning("Syntax deprecated");
1358
1359 int elevator, carnum;
1360 if (!GetElevatorCar(tempdata[0], floor->Number, elevator, carnum))
1361 return sError;
1362
1363 //stop here if in Check mode
1364 if (config->CheckScript == true)
1365 return sNextLine;
1366
1367 Elevator *elev = Simcore->GetElevator(elevator);
1368 ElevatorCar *car = elev->GetCar(carnum);
1369
1370 if (compat == 0)
1371 StoreCommand(car->AddShaftDoor(config->Current, ToInt(tempdata[1]), tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9])));
1372 if (compat == 1)
1373 StoreCommand(car->AddShaftDoor(config->Current, ToInt(tempdata[1]), tempdata[2], tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4])));
1374 if (compat == 2)
1375 StoreCommand(car->AddShaftDoor(config->Current, ToInt(tempdata[1]), tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5])));
1376 return sNextLine;
1377 }
1378
1379 //AddFloorIndicator command
1380 if (StartsWithNoCase(LineData, "addfloorindicator"))
1381 {
1382 //get data
1383 int params = SplitData(LineData, 18);
1384
1385 if (params < 8 && params > 10)
1386 return ScriptError("Incorrect number of parameters");
1387
1388 int compat = 0;
1389 if (params == 8)
1390 compat = 1; //1.4 compatibility mode
1391 if (params == 9)
1392 compat = 2;
1393
1394 //check numeric values
1395 if (compat == 1)
1396 {
1397 for (int i = 3; i <= 7; i++)
1398 {
1399 if (!IsNumeric(tempdata[i]))
1400 return ScriptError("Invalid value: " + tempdata[i]);
1401 }
1402 if (warn_deprecated == true)
1403 ScriptWarning("Syntax deprecated");
1404 }
1405 else if (compat == 2)
1406 {
1407 for (int i = 4; i <= 8; i++)
1408 {
1409 if (!IsNumeric(tempdata[i]))
1410 return ScriptError("Invalid value: " + tempdata[i]);
1411 }
1412 }
1413 else
1414 {
1415 for (int i = 5; i <= 9; i++)
1416 {
1417 if (!IsNumeric(tempdata[i]))
1418 return ScriptError("Invalid value: " + tempdata[i]);
1419 }
1420 }
1421
1422 int elevator, car;
1423 if (!GetElevatorCar(tempdata[0], floor->Number, elevator, car))
1424 return sError;
1425
1426 //stop here if in Check mode
1427 if (config->CheckScript == true)
1428 return sNextLine;
1429
1430 if (compat == 0)
1431 StoreCommand(floor->AddFloorIndicator(elevator, car, ToBool(tempdata[1]), tempdata[2], tempdata[3], tempdata[4], ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9])));
1432 else if (compat == 1)
1433 StoreCommand(floor->AddFloorIndicator(elevator, car, ToBool(tempdata[1]), "Button", "", tempdata[2], ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7])));
1434 else if (compat == 2)
1435 StoreCommand(floor->AddFloorIndicator(elevator, car, ToBool(tempdata[1]), tempdata[2], "", tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8])));
1436 return sNextLine;
1437 }
1438
1439 //AddFillerWalls command
1440 if (StartsWithNoCase(LineData, "addfillerwalls"))
1441 {
1442 //get data
1443 int params = SplitData(LineData, 15);
1444
1445 if (params < 10 || params > 11)
1446 return ScriptError("Incorrect number of parameters");
1447
1448 bool compat = false;
1449
1450 if (params == 10)
1451 compat = true;
1452
1453 //check numeric values
1454 for (int i = 1; i <= 9; i++)
1455 {
1456 if (i == 7)
1457 i = 8;
1458 if (!IsNumeric(tempdata[i]))
1459 return ScriptError("Invalid value: " + tempdata[i]);
1460 }
1461
1462 //stop here if in Check mode
1463 if (config->CheckScript == true)
1464 return sNextLine;
1465
1466 if (compat == true)
1467 floor->AddFillerWalls(tempdata[0], ToFloat(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]), false);
1468 else
1469 floor->AddFillerWalls(tempdata[0], ToFloat(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]), ToBool(tempdata[10]));
1470
1471 return sNextLine;
1472 }
1473
1474 //AddSound command
1475 if (StartsWithNoCase(LineData, "addsound"))
1476 {
1477 //get data
1478 int params = SplitData(LineData, 9);
1479
1480 if (params != 5 && params != 6 && params != 13 && params != 17)
1481 return ScriptError("Incorrect number of parameters");
1482
1483 bool partial = false;
1484 bool compat = false;
1485 if (params == 5 || params == 6)
1486 partial = true;
1487 if (params == 5 || params == 13)
1488 compat = true;
1489
1490 //check numeric values
1491 if (partial == true)
1492 {
1493 for (int i = 2; i <= 4; i++)
1494 {
1495 if (!IsNumeric(tempdata[i]))
1496 return ScriptError("Invalid value: " + tempdata[i]);
1497 }
1498 }
1499 else
1500 {
1501 if (compat == true)
1502 {
1503 for (int i = 2; i <= 12; i++)
1504 {
1505 if (!IsNumeric(tempdata[i]))
1506 return ScriptError("Invalid value: " + tempdata[i]);
1507 }
1508 if (warn_deprecated == true)
1509 ScriptWarning("Syntax deprecated");
1510 }
1511 else
1512 {
1513 for (int i = 2; i <= 16; i++)
1514 {
1515 if (i == 5)
1516 i = 6;
1517
1518 if (!IsNumeric(tempdata[i]))
1519 return ScriptError("Invalid value: " + tempdata[i]);
1520 }
1521 }
1522 }
1523
1524 //check to see if file exists
1525 parent->CheckFile("data/" + tempdata[1]);
1526
1527 //stop here if in Check mode
1528 if (config->CheckScript == true)
1529 return sNextLine;
1530
1531 if (compat == true)
1532 {
1533 if (partial == true)
1534 StoreCommand(floor->AddSound(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]))));
1535 else
1536 StoreCommand(floor->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]))));
1537 }
1538 else
1539 {
1540 if (partial == true)
1541 StoreCommand(floor->AddSound(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), ToBool(tempdata[5])));
1542 else
1543 StoreCommand(floor->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]))));
1544 }
1545 return sNextLine;
1546 }
1547
1548 //AddReverb command
1549 if (StartsWithNoCase(LineData, "addreverb"))
1550 {
1551 //get data
1552 int params = SplitData(LineData, 9);
1553
1554 if (params != 7)
1555 return ScriptError("Incorrect number of parameters");
1556
1557 //check numeric values
1558 for (int i = 2; i <= 6; i++)
1559 {
1560 if (!IsNumeric(tempdata[i]))
1561 return ScriptError("Invalid value: " + tempdata[i]);
1562 }
1563
1564 //stop here if in Check mode
1565 if (config->CheckScript == true)
1566 return sNextLine;
1567
1568 StoreCommand(floor->AddReverb(tempdata[0], tempdata[1], Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4])), ToFloat(tempdata[5]), ToFloat(tempdata[6])));
1569 return sNextLine;
1570 }
1571
1572 //AddShaftDoorComponent command
1573 if (StartsWithNoCase(LineData, "addshaftdoorcomponent"))
1574 {
1575 //get data
1576 int params = SplitData(LineData, 22);
1577
1578 if (params != 18 && params != 19)
1579 return ScriptError("Incorrect number of parameters");
1580
1581 //check numeric values
1582 bool compat = false;
1583 if (params == 18)
1584 {
1585 compat = true;
1586 if (warn_deprecated == true)
1587 ScriptWarning("Syntax deprecated");
1588 }
1589
1590 for (int i = 1; i <= params - 1; i++)
1591 {
1592 if (i == 2)
1593 i = 5;
1594 if (i == 6)
1595 i++;
1596 if (!IsNumeric(tempdata[i]))
1597 return ScriptError("Invalid value: " + tempdata[i]);
1598 }
1599
1600 int elevator, carnum;
1601 if (!GetElevatorCar(tempdata[0], floor->Number, elevator, carnum))
1602 return sError;
1603
1604 //stop here if in Check mode
1605 if (config->CheckScript == true)
1606 return sNextLine;
1607
1608 Elevator *elev = Simcore->GetElevator(elevator);
1609 ElevatorCar *car = elev->GetCar(carnum);
1610
1611 if (compat == true)
1612 StoreCommand(car->AddShaftDoorComponent(ToInt(tempdata[1]), config->Current, tempdata[2], tempdata[3], tempdata[4], ToFloat(tempdata[5]), tempdata[6], ToFloat(tempdata[7]), 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])));
1613 else
1614 StoreCommand(car->AddShaftDoorComponent(ToInt(tempdata[1]), config->Current, tempdata[2], tempdata[3], tempdata[4], ToFloat(tempdata[5]), 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]), ToFloat(tempdata[18])));
1615 return sNextLine;
1616 }
1617
1618 //FinishShaftDoor command
1619 if (StartsWithNoCase(LineData, "finishshaftdoor "))
1620 {
1621 //get data
1622 int params = SplitData(LineData, 16);
1623
1624 bool legacy = false;
1625
1626 if (params < 2)
1627 return ScriptError("Incorrect number of parameters");
1628
1629 if (params > 3)
1630 {
1631 if (IsNumeric(tempdata[2]) == true)
1632 {
1633 if (warn_deprecated == true)
1634 ScriptWarning("Syntax deprecated");
1635 legacy = true;
1636 }
1637 }
1638
1639 //check numeric values
1640 if (!IsNumeric(tempdata[1]))
1641 return ScriptError("Invalid value: " + tempdata[1]);
1642
1643 int elevator, carnum;
1644 if (!GetElevatorCar(tempdata[0], floor->Number, elevator, carnum))
1645 return sError;
1646
1647 //stop here if in Check mode
1648 if (config->CheckScript == true)
1649 return sNextLine;
1650
1651 Elevator *elev = Simcore->GetElevator(elevator);
1652 ElevatorCar *car = elev->GetCar(carnum);
1653
1654 if (params == 2 || legacy == true)
1655 StoreCommand(car->FinishShaftDoor(ToInt(tempdata[1]), config->Current));
1656 else if (params == 3)
1657 StoreCommand(car->FinishShaftDoor(ToInt(tempdata[1]), config->Current, ToBool(tempdata[2])));
1658 else
1659 StoreCommand(car->FinishShaftDoor(ToInt(tempdata[1]), config->Current, ToBool(tempdata[2]), ToBool(tempdata[3])));
1660 return sNextLine;
1661 }
1662
1663 //AddModel command
1664 if (StartsWithNoCase(LineData, "addmodel"))
1665 {
1666 if (parent->NoModels == true)
1667 return sNextLine;
1668
1669 //get data
1670 int params = SplitData(LineData, 9);
1671
1672 if (params != 14 && params != 15)
1673 return ScriptError("Incorrect number of parameters");
1674
1675 bool compat = false;
1676 if (params == 14)
1677 compat = true;
1678
1679 //check numeric values
1680 if (compat == true)
1681 {
1682 for (int i = 2; i <= 13; i++)
1683 {
1684 if (i == 10)
1685 i++;
1686 if (!IsNumeric(tempdata[i]))
1687 return ScriptError("Invalid value: " + tempdata[i]);
1688 }
1689 if (warn_deprecated == true)
1690 ScriptWarning("Syntax deprecated");
1691 }
1692 else
1693 {
1694 for (int i = 3; i <= 14; i++)
1695 {
1696 if (i == 11)
1697 i++;
1698 if (!IsNumeric(tempdata[i]))
1699 return ScriptError("Invalid value: " + tempdata[i]);
1700 }
1701 }
1702
1703 //check to see if file exists
1704 parent->CheckFile("data/" + tempdata[1]);
1705
1706 //stop here if in Check mode
1707 if (config->CheckScript == true)
1708 {
1709 config->setkey = false;
1710 return sNextLine;
1711 }
1712
1713 //create model
1714 Model *model;
1715 if (compat == true)
1716 model = floor->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]));
1717 else
1718 model = floor->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]));
1719
1720 if (config->setkey == true && model)
1721 model->SetKey(config->keyvalue);
1722 config->setkey = false;
1723
1724 StoreCommand(model);
1725 return sNextLine;
1726 }
1727
1728 //AddStairsModel command
1729 if (StartsWithNoCase(LineData, "addstairsmodel"))
1730 {
1731 if (parent->NoModels == true)
1732 return sNextLine;
1733
1734 //get data
1735 int params = SplitData(LineData, 15);
1736
1737 if (params != 15 && params != 16)
1738 return ScriptError("Incorrect number of parameters");
1739
1740 bool compat = false;
1741 if (params == 15)
1742 compat = true;
1743
1744 //check numeric values
1745 if (compat == true)
1746 {
1747 for (int i = 3; i <= 14; i++)
1748 {
1749 if (i == 11)
1750 i++;
1751 if (!IsNumeric(tempdata[i]))
1752 return ScriptError("Invalid value: " + tempdata[i]);
1753 }
1754 if (warn_deprecated == true)
1755 ScriptWarning("Syntax deprecated");
1756 }
1757 else
1758 {
1759 for (int i = 4; i <= 15; i++)
1760 {
1761 if (i == 12)
1762 i++;
1763 if (!IsNumeric(tempdata[i]))
1764 return ScriptError("Invalid value: " + tempdata[i]);
1765 }
1766 }
1767
1768 //check to see if file exists
1769 parent->CheckFile("data/" + tempdata[2]);
1770
1771 //create model
1772 if (Simcore->GetStairwell(ToInt(tempdata[0])))
1773 {
1774 //stop here if in Check mode
1775 if (config->CheckScript == true)
1776 {
1777 config->setkey = false;
1778 return sNextLine;
1779 }
1780
1782
1783 if (!level)
1784 {
1785 ScriptError("Invalid level " + ToString(config->Current) + " for stairwell " + tempdata[0]);
1786 return sNextLine;
1787 }
1788
1789 Model *model = 0;
1790
1791 if (compat == true)
1792 model = level->AddModel(tempdata[1], tempdata[2], false, 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]));
1793 else
1794 model = level->AddModel(tempdata[1], tempdata[2], ToBool(tempdata[3]), Vector3(ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6])), Vector3(ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9])), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToBool(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]));
1795
1796 if (config->setkey == true && model)
1797 model->SetKey(config->keyvalue);
1798 config->setkey = false;
1799
1800 StoreCommand(model);
1801 }
1802 else
1803 return ScriptError("Invalid stairwell " + tempdata[0]);
1804 return sNextLine;
1805 }
1806
1807 //AddShaftModel command
1808 if (StartsWithNoCase(LineData, "addshaftmodel"))
1809 {
1810 if (parent->NoModels == true)
1811 return sNextLine;
1812
1813 //get data
1814 int params = SplitData(LineData, 14);
1815
1816 if (params != 15 && params != 16)
1817 return ScriptError("Incorrect number of parameters");
1818
1819 bool compat = false;
1820 if (params == 15)
1821 compat = true;
1822
1823 //check numeric values
1824 if (compat == true)
1825 {
1826 for (int i = 3; i <= 14; i++)
1827 {
1828 if (i == 11)
1829 i++;
1830 if (!IsNumeric(tempdata[i]))
1831 return ScriptError("Invalid value: " + tempdata[i]);
1832 }
1833 if (warn_deprecated == true)
1834 ScriptWarning("Syntax deprecated");
1835 }
1836 else
1837 {
1838 for (int i = 4; i <= 15; i++)
1839 {
1840 if (i == 12)
1841 i++;
1842 if (!IsNumeric(tempdata[i]))
1843 return ScriptError("Invalid value: " + tempdata[i]);
1844 }
1845 }
1846
1847 //check to see if file exists
1848 parent->CheckFile("data/" + tempdata[2]);
1849
1850 //create model
1851 if (Simcore->GetShaft(ToInt(tempdata[0])))
1852 {
1853 //stop here if in Check mode
1854 if (config->CheckScript == true)
1855 {
1856 config->setkey = false;
1857 return sNextLine;
1858 }
1859
1860 ::SBS::Shaft::Level *level = Simcore->GetShaft(ToInt(tempdata[0]))->GetLevel(config->Current);
1861
1862 if (!level)
1863 {
1864 ScriptError("Invalid level " + ToString(config->Current) + " for shaft " + tempdata[0]);
1865 return sNextLine;
1866 }
1867
1868 Model *model;
1869 if (compat == true)
1870 model = level->AddModel(tempdata[1], tempdata[2], false, 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]));
1871 else
1872 model = level->AddModel(tempdata[1], tempdata[2], ToBool(tempdata[3]), Vector3(ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6])), Vector3(ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9])), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToBool(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15]));
1873
1874 if (config->setkey == true && model)
1875 model->SetKey(config->keyvalue);
1876 config->setkey = false;
1877
1878 StoreCommand(model);
1879 }
1880 else
1881 return ScriptError("Invalid shaft " + tempdata[0]);
1882 return sNextLine;
1883 }
1884
1885 //AddActionControl command
1886 if (StartsWithNoCase(LineData, "addactioncontrol"))
1887 {
1888 //get data
1889 int params = SplitData(LineData, 17);
1890
1891 if (params < 10)
1892 return ScriptError("Incorrect number of parameters");
1893
1894 //set backwards compatibility
1895 bool compat = false;
1896 if (IsNumeric(tempdata[8]) == false)
1897 {
1898 compat = true;
1899
1900 if (warn_deprecated == true)
1901 ScriptWarning("Syntax deprecated");
1902 }
1903
1904 int end = 8;
1905 if (compat == true)
1906 end = 7;
1907
1908 //check numeric values
1909 for (int i = 3; i <= end; i++)
1910 {
1911 if (!IsNumeric(tempdata[i]))
1912 return ScriptError("Invalid value: " + tempdata[i]);
1913 }
1914
1915 std::vector<std::string> action_array, tex_array;
1916 int slength, parameters;
1917
1918 //get number of action & texture parameters
1919 slength = (int)tempdata.size();
1920 parameters = slength - (end + 1); //strip off main parameters
1921
1922 //action & texture parameter number needs to be even
1923 if (IsEven(parameters) == false)
1924 return ScriptError("Incorrect number of parameters");
1925
1926 for (int i = (end + 1); i < slength - (parameters / 2); i++)
1927 action_array.emplace_back(tempdata[i]);
1928 for (int i = slength - (parameters / 2); i < slength; i++)
1929 tex_array.emplace_back(tempdata[i]);
1930
1931 //check to see if file exists
1932 parent->CheckFile("data/" + tempdata[1]);
1933
1934 //stop here if in Check mode
1935 if (config->CheckScript == true)
1936 return sNextLine;
1937
1938 Control* control = 0;
1939 if (compat == true)
1940 control = floor->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);
1941 else
1942 control = floor->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);
1943
1944 if (control)
1945 {
1946 if (config->lockvalue == 0)
1947 control->SetLocked(false, config->keyvalue);
1948 else
1949 control->SetLocked(true, config->keyvalue);
1950 }
1951 StoreCommand(control);
1952 return sNextLine;
1953 }
1954
1955 //AddShaftActionControl command
1956 if (StartsWithNoCase(LineData, "addshaftactioncontrol"))
1957 {
1958 //get data
1959 int params = SplitData(LineData, 21);
1960
1961 if (params < 11)
1962 return ScriptError("Incorrect number of parameters");
1963
1964 //set backwards compatibility
1965 bool compat = false;
1966 if (IsNumeric(tempdata[9]) == false)
1967 {
1968 compat = true;
1969
1970 if (warn_deprecated == true)
1971 ScriptWarning("Syntax deprecated");
1972 }
1973
1974 int end = 9;
1975 if (compat == true)
1976 end = 8;
1977
1978 //check numeric values
1979 for (int i = 0; i <= end; i++)
1980 {
1981 if (i == 1)
1982 i = 4;
1983 if (!IsNumeric(tempdata[i]))
1984 return ScriptError("Invalid value: " + tempdata[i]);
1985 }
1986
1987 std::vector<std::string> action_array, tex_array;
1988 int slength, parameters;
1989
1990 //get number of action & texture parameters
1991 slength = (int)tempdata.size();
1992 parameters = slength - (end + 1); //strip off main parameters
1993
1994 //action & texture parameter number needs to be even
1995 if (IsEven(parameters) == false)
1996 return ScriptError("Incorrect number of parameters");
1997
1998 for (int i = (end + 1); i < slength - (parameters / 2); i++)
1999 action_array.emplace_back(tempdata[i]);
2000 for (int i = slength - (parameters / 2); i < slength; i++)
2001 tex_array.emplace_back(tempdata[i]);
2002
2003 //check to see if file exists
2004 parent->CheckFile("data/" + tempdata[1]);
2005
2006 if (Simcore->GetShaft(ToInt(tempdata[0])))
2007 {
2008 //stop here if in Check mode
2009 if (config->CheckScript == true)
2010 return sNextLine;
2011
2012 ::SBS::Shaft::Level *level = Simcore->GetShaft(ToInt(tempdata[0]))->GetLevel(config->Current);
2013
2014 if (!level)
2015 {
2016 ScriptError("Invalid level " + ToString(config->Current) + " for shaft " + tempdata[0]);
2017 return sNextLine;
2018 }
2019
2020 Control* control = 0;
2021 if (compat == true)
2022 control = level->AddControl(tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), 1, action_array, tex_array);
2023 else
2024 control = level->AddControl(tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToInt(tempdata[9]), action_array, tex_array);
2025
2026 if (control)
2027 {
2028 if (config->lockvalue == 0)
2029 control->SetLocked(false, config->keyvalue);
2030 else
2031 control->SetLocked(true, config->keyvalue);
2032 }
2033 StoreCommand(control);
2034 }
2035 else
2036 return ScriptError("Invalid shaft " + tempdata[0]);
2037 return sNextLine;
2038 }
2039
2040 //AddStairsActionControl command
2041 if (StartsWithNoCase(LineData, "addstairsactioncontrol"))
2042 {
2043 //get data
2044 int params = SplitData(LineData, 21);
2045
2046 if (params < 11)
2047 return ScriptError("Incorrect number of parameters");
2048
2049 //set backwards compatibility
2050 bool compat = false;
2051 if (IsNumeric(tempdata[9]) == false)
2052 {
2053 compat = true;
2054
2055 if (warn_deprecated == true)
2056 ScriptWarning("Syntax deprecated");
2057 }
2058
2059 int end = 9;
2060 if (compat == true)
2061 end = 8;
2062
2063 //check numeric values
2064 for (int i = 0; i <= end; i++)
2065 {
2066 if (i == 1)
2067 i = 4;
2068 if (!IsNumeric(tempdata[i]))
2069 return ScriptError("Invalid value: " + tempdata[i]);
2070 }
2071
2072 std::vector<std::string> action_array, tex_array;
2073 int slength, parameters;
2074
2075 //get number of action & texture parameters
2076 slength = (int)tempdata.size();
2077 parameters = slength - (end + 1); //strip off main parameters
2078
2079 //action & texture parameter number needs to be even
2080 if (IsEven(parameters) == false)
2081 return ScriptError("Incorrect number of parameters");
2082
2083 for (int i = (end + 1); i < slength - (parameters / 2); i++)
2084 action_array.emplace_back(tempdata[i]);
2085 for (int i = slength - (parameters / 2); i < slength; i++)
2086 tex_array.emplace_back(tempdata[i]);
2087
2088 //check to see if file exists
2089 parent->CheckFile("data/" + tempdata[1]);
2090
2091 if (Simcore->GetStairwell(ToInt(tempdata[0])))
2092 {
2093 //stop here if in Check mode
2094 if (config->CheckScript == true)
2095 return sNextLine;
2096
2097 ::SBS::Stairwell::Level *level = Simcore->GetStairwell(ToInt(tempdata[0]))->GetLevel(config->Current);
2098
2099 if (!level)
2100 {
2101 ScriptError("Invalid level " + ToString(config->Current) + " for stairwell " + tempdata[0]);
2102 return sNextLine;
2103 }
2104
2105 Control* control = 0;
2106 if (compat == true)
2107 control = level->AddControl(tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), 1, action_array, tex_array);
2108 else
2109 control = level->AddControl(tempdata[1], tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToInt(tempdata[9]), action_array, tex_array);
2110
2111 if (control)
2112 {
2113 if (config->lockvalue == 0)
2114 control->SetLocked(false, config->keyvalue);
2115 else
2116 control->SetLocked(true, config->keyvalue);
2117 }
2118 StoreCommand(control);
2119 }
2120 else
2121 return ScriptError("Invalid stairwell " + tempdata[0]);
2122 return sNextLine;
2123 }
2124
2125 //AddTrigger command
2126 if (StartsWithNoCase(LineData, "addtrigger"))
2127 {
2128 //get data
2129 int params = SplitData(LineData, 11);
2130
2131 if (params < 9)
2132 return ScriptError("Incorrect number of parameters");
2133
2134 //check numeric values
2135 for (int i = 2; i <= 7; i++)
2136 {
2137 if (!IsNumeric(tempdata[i]))
2138 return ScriptError("Invalid value: " + tempdata[i]);
2139 }
2140
2141 std::vector<std::string> action_array;
2142
2143 //get number of action & texture parameters
2144 for (int i = 8; i < params; i++)
2145 action_array.emplace_back(tempdata[i]);
2146
2147 //check to see if file exists
2148 parent->CheckFile("data/" + tempdata[1]);
2149
2150 //stop here if in Check mode
2151 if (config->CheckScript == true)
2152 return sNextLine;
2153
2154 Vector3 min = Vector3(ToFloat(tempdata[2]), ToFloat(tempdata[3]), ToFloat(tempdata[4]));
2155 Vector3 max = Vector3(ToFloat(tempdata[5]), ToFloat(tempdata[6]), ToFloat(tempdata[7]));
2156 StoreCommand(floor->AddTrigger(tempdata[0], tempdata[1], min, max, action_array));
2157 return sNextLine;
2158 }
2159
2160 //AddShaftTrigger command
2161 if (StartsWithNoCase(LineData, "addshafttrigger"))
2162 {
2163 //get data
2164 int params = SplitData(LineData, 16);
2165
2166 if (params < 10)
2167 return ScriptError("Incorrect number of parameters");
2168
2169 //check numeric values
2170 for (int i = 0; i <= 8; i++)
2171 {
2172 if (i == 1)
2173 i = 3;
2174 if (!IsNumeric(tempdata[i]))
2175 return ScriptError("Invalid value: " + tempdata[i]);
2176 }
2177
2178 std::vector<std::string> action_array;
2179
2180 //get number of action & texture parameters
2181 for (int i = 9; i < params; i++)
2182 action_array.emplace_back(tempdata[i]);
2183
2184 //check to see if file exists
2185 parent->CheckFile("data/" + tempdata[2]);
2186
2187 //stop here if in Check mode
2188 if (config->CheckScript == true)
2189 return sNextLine;
2190
2191 Vector3 min = Vector3(ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]));
2192 Vector3 max = Vector3(ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]));
2193
2194 Shaft *shaft = Simcore->GetShaft(ToInt(tempdata[0]));
2195 if (!shaft)
2196 return ScriptError("Invalid shaft " + tempdata[0]);
2197
2198 Shaft::Level *level = shaft->GetLevel(config->Current);
2199 if (!level)
2200 return ScriptError("Invalid shaft level " + ToString(config->Current));
2201
2202 StoreCommand(level->AddTrigger(tempdata[1], tempdata[2], min, max, action_array));
2203 return sNextLine;
2204 }
2205
2206 //AddStairsTrigger command
2207 if (StartsWithNoCase(LineData, "addstairstrigger"))
2208 {
2209 //get data
2210 int params = SplitData(LineData, 16);
2211
2212 if (params < 10)
2213 return ScriptError("Incorrect number of parameters");
2214
2215 //check numeric values
2216 for (int i = 0; i <= 8; i++)
2217 {
2218 if (i == 1)
2219 i = 3;
2220 if (!IsNumeric(tempdata[i]))
2221 return ScriptError("Invalid value: " + tempdata[i]);
2222 }
2223
2224 std::vector<std::string> action_array;
2225
2226 //get number of action & texture parameters
2227 for (int i = 9; i < params; i++)
2228 action_array.emplace_back(tempdata[i]);
2229
2230 //check to see if file exists
2231 parent->CheckFile("data/" + tempdata[2]);
2232
2233 //stop here if in Check mode
2234 if (config->CheckScript == true)
2235 return sNextLine;
2236
2237 Vector3 min = Vector3(ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5]));
2238 Vector3 max = Vector3(ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]));
2239
2240 Stairwell *stairs = Simcore->GetStairwell(ToInt(tempdata[0]));
2241 if (!stairs)
2242 return ScriptError("Invalid stairwell " + tempdata[0]);
2243
2244 Stairwell::Level *level = stairs->GetLevel(config->Current);
2245 if (!level)
2246 return ScriptError("Invalid stairwell level " + ToString(config->Current));
2247
2248 StoreCommand(level->AddTrigger(tempdata[1], tempdata[2], min, max, action_array));
2249 return sNextLine;
2250 }
2251
2252 //Cut command
2253 if (StartsWithNoCase(LineData, "cut "))
2254 {
2255 //get data
2256 int params = SplitData(LineData, 4);
2257
2258 if (params != 8)
2259 return ScriptError("Incorrect number of parameters");
2260
2261 //check numeric values
2262 for (int i = 0; i <= 5; i++)
2263 {
2264 if (!IsNumeric(tempdata[i]))
2265 return ScriptError("Invalid value: " + tempdata[i]);
2266 }
2267
2268 //stop here if in Check mode
2269 if (config->CheckScript == true)
2270 return sNextLine;
2271
2272 //perform cut on floor
2273 floor->Cut(Vector3(ToFloat(tempdata[0]), ToFloat(tempdata[1]), ToFloat(tempdata[2])), Vector3(ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5])), ToBool(tempdata[6]), ToBool(tempdata[7]), false);
2274 return sNextLine;
2275 }
2276
2277 //CutAll command
2278 if (StartsWithNoCase(LineData, "cutall"))
2279 {
2280 //get data
2281 int params = SplitData(LineData, 7);
2282
2283 if (params != 8)
2284 return ScriptError("Incorrect number of parameters");
2285
2286 //check numeric values
2287 for (int i = 0; i <= 5; i++)
2288 {
2289 if (!IsNumeric(tempdata[i]))
2290 return ScriptError("Invalid value: " + tempdata[i]);
2291 }
2292
2293 //stop here if in Check mode
2294 if (config->CheckScript == true)
2295 return sNextLine;
2296
2297 //perform cut on all objects related to the current floor
2298 floor->CutAll(Vector3(ToFloat(tempdata[0]), ToFloat(tempdata[1]), ToFloat(tempdata[2])), Vector3(ToFloat(tempdata[3]), ToFloat(tempdata[4]), ToFloat(tempdata[5])), ToBool(tempdata[6]), ToBool(tempdata[7]));
2299 return sNextLine;
2300 }
2301
2302 //AddRevolvingDoor command
2303 if (StartsWithNoCase(LineData, "addrevolvingdoor "))
2304 {
2305 //get data
2306 int params = SplitData(LineData, 17);
2307
2308 if (params != 15 && params != 17)
2309 return ScriptError("Incorrect number of parameters");
2310
2311 bool compat = false;
2312 if (params == 15)
2313 compat = true;
2314
2315 //check numeric values
2316 if (compat == true)
2317 {
2318 for (int i = 2; i <= 13; i++)
2319 {
2320 if (i == 3)
2321 i++;
2322
2323 if (!IsNumeric(tempdata[i]))
2324 return ScriptError("Invalid value: " + tempdata[i]);
2325 }
2326
2327 //check to see if file exists
2328 parent->CheckFile("data/" + tempdata[0]);
2329 }
2330 else
2331 {
2332 for (int i = 4; i <= 15; i++)
2333 {
2334 if (i == 5)
2335 i++;
2336
2337 if (!IsNumeric(tempdata[i]))
2338 return ScriptError("Invalid value: " + tempdata[i]);
2339 }
2340
2341 //check to see if file exists
2342 parent->CheckFile("data/" + tempdata[2]);
2343 }
2344
2345 //stop here if in Check mode
2346 if (config->CheckScript == true)
2347 return sNextLine;
2348
2349 //create door
2350 RevolvingDoor* door = 0;
2351 if (compat == false)
2352 door = floor->AddRevolvingDoor(tempdata[0], ToBool(tempdata[1]), tempdata[2], tempdata[3], ToFloat(tempdata[4]), ToBool(tempdata[5]), ToInt(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]), ToBool(tempdata[16]));
2353 else
2354 door = floor->AddRevolvingDoor("", false, tempdata[0], tempdata[1], ToFloat(tempdata[2]), ToBool(tempdata[3]), ToInt(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]), ToFloat(tempdata[13]), ToBool(tempdata[14]));
2355
2356 if (door)
2357 {
2358 if (config->lockvalue == 0)
2359 door->SetLocked(false, config->keyvalue);
2360 else
2361 door->SetLocked(true, config->keyvalue);
2362 }
2363
2364 StoreCommand(door);
2365 return sNextLine;
2366 }
2367
2368 //AddEscalator command
2369 if (StartsWithNoCase(LineData, "addescalator "))
2370 {
2371 //get data
2372 int params = SplitData(LineData, 13);
2373
2374 if (params < 15 || params > 16)
2375 return ScriptError("Incorrect number of parameters");
2376
2377 bool compat = false;
2378 if (params == 15)
2379 compat = true;
2380
2381 if (params == 15)
2382 {
2383 //check numeric values
2384 for (int i = 1; i <= 14; i++)
2385 {
2386 if (i == 2)
2387 i = 6; //skip non-numeric parameters
2388 if (!IsNumeric(tempdata[i]))
2389 return ScriptError("Invalid value: " + tempdata[i]);
2390 }
2391
2392 if (warn_deprecated == true)
2393 ScriptWarning("Syntax deprecated");
2394 }
2395 else
2396 {
2397 //check numeric values
2398 for (int i = 1; i <= 15; i++)
2399 {
2400 if (i == 2)
2401 i = 7; //skip non-numeric parameters
2402 if (!IsNumeric(tempdata[i]))
2403 return ScriptError("Invalid value: " + tempdata[i]);
2404 }
2405 }
2406
2407 //create escalator
2408
2409 //stop here if in Check mode
2410 if (config->CheckScript == true)
2411 return sNextLine;
2412
2413 if (compat == true)
2414 StoreCommand(floor->AddEscalator(tempdata[0], ToInt(tempdata[1]), ToFloat(tempdata[2]), tempdata[3], tempdata[4], tempdata[4], tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToInt(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14])));
2415 else
2416 StoreCommand(floor->AddEscalator(tempdata[0], ToInt(tempdata[1]), ToFloat(tempdata[2]), tempdata[3], tempdata[4], tempdata[5], tempdata[6], ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToFloat(tempdata[10]), ToFloat(tempdata[11]), ToInt(tempdata[12]), ToFloat(tempdata[13]), ToFloat(tempdata[14]), ToFloat(tempdata[15])));
2417
2418 return sNextLine;
2419 }
2420
2421 //AddMovingWalkway command
2422 if (StartsWithNoCase(LineData, "addmovingwalkway "))
2423 {
2424 //get data
2425 int params = SplitData(LineData, 17);
2426
2427 if (params != 14)
2428 return ScriptError("Incorrect number of parameters");
2429
2430 //check numeric values
2431 for (int i = 1; i <= 13; i++)
2432 {
2433 if (i == 2)
2434 i = 6; //skip non-numeric parameters
2435 if (!IsNumeric(tempdata[i]))
2436 return ScriptError("Invalid value: " + tempdata[i]);
2437 }
2438
2439 //create escalator
2440
2441 //stop here if in Check mode
2442 if (config->CheckScript == true)
2443 return sNextLine;
2444
2445 StoreCommand(floor->AddMovingWalkway(tempdata[0], ToInt(tempdata[1]), ToFloat(tempdata[2]), tempdata[3], tempdata[4], tempdata[5], ToFloat(tempdata[6]), ToFloat(tempdata[7]), ToFloat(tempdata[8]), ToFloat(tempdata[9]), ToInt(tempdata[10]), ToFloat(tempdata[11]), ToFloat(tempdata[12]), ToFloat(tempdata[13])));
2446
2447 return sNextLine;
2448 }
2449
2450 //handle end of floor section
2451 if (StartsWithNoCase(LineData, "<endfloor>") && config->RangeL == config->RangeH)
2452 {
2453 //when finishing a floor, make sure the altitude is valid
2454 if (floor->AltitudeSet == false)
2455 return ScriptError("Floor altitude or height has not been set");
2456
2457 config->SectionNum = 0;
2458 config->Context = "None";
2459 engine->Report("Finished floor");
2460 return sNextLine;
2461 }
2462
2463 //handle floor range
2464 if (config->RangeL != config->RangeH && StartsWithNoCase(LineData, "<endfloor"))
2465 {
2466 //when finishing a floor, make sure the altitude is valid
2467 if (floor->AltitudeSet == false)
2468 return ScriptError("Floor altitude is invalid");
2469
2470 if (config->RangeL < config->RangeH)
2471 {
2472 if (config->Current < config->RangeH)
2473 {
2474 config->Current++;
2475 parent->line = config->RangeStart; //loop back
2476 return sNextLine;
2477 }
2478 else
2479 {
2480 config->SectionNum = 0; //break out of loop
2481 config->Context = "None";
2482 config->RangeL = 0;
2483 config->RangeH = 0;
2484 engine->Report("Finished floors");
2485 return sNextLine;
2486 }
2487 }
2488 else
2489 {
2490 if (config->Current > config->RangeH)
2491 {
2492 config->Current--;
2493 parent->line = config->RangeStart; //loop back
2494 return sNextLine;
2495 }
2496 else
2497 {
2498 config->SectionNum = 0; //break out of loop
2499 config->Context = "None";
2500 config->RangeL = 0;
2501 config->RangeH = 0;
2502 engine->Report("Finished floors");
2503 return sNextLine;
2504 }
2505 }
2506 }
2507
2508 return sContinue;
2509}
2510
2511}
bool AddElevator(int elevator)
bool SameElevators(const std::vector< int > &elevators)
void SetLocked(int side, int keyid)
Definition lock.cpp:91
DoorWrapper * FinishShaftDoor(int number, int floor, bool DoorWalls=true, bool TrackWalls=true)
DoorWrapper * AddShaftDoor(int floor, int number, const std::string &lefttexture, const std::string &righttexture, Real tw, Real th)
DoorWrapper * AddShaftDoorComponent(int number, int floor, 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)
ElevatorCar * GetCar(int number)
DirectionalIndicator * AddDirectionalIndicator(int elevator, int car, 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)
Definition floor.cpp:1167
void AddGroupFloor(int number)
Definition floor.cpp:685
CallStation * AddCallButtons(int controller, const std::string &sound_file_up, const std::string &sound_file_down, const std::string &BackTexture, const std::string &UpButtonTexture, const std::string &UpButtonTexture_Lit, const std::string &DownButtonTexture, const std::string &DownButtonTexture_Lit, Real CenterX, Real CenterZ, Real voffset, const std::string &direction, Real BackWidth, Real BackHeight, bool ShowBack, Real tw, Real th)
Definition floor.cpp:583
MovingWalkway * AddMovingWalkway(const std::string &name, int run, Real speed, const std::string &sound_file, const std::string &texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real treadsize, int num_steps, Real voffset, Real tw, Real th)
Definition floor.cpp:1646
std::string IndicatorTexture
Definition floor.h:42
void Cut(const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, bool fast, int checkwallnumber=0, bool prepare=false)
Definition floor.cpp:613
Wall * AddInterfloorFloor(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)
Definition floor.cpp:339
Reverb * AddReverb(const std::string &name, const std::string &type, const Vector3 &position, Real min_distance, Real max_distance)
Definition floor.cpp:1971
int Number
Definition floor.h:36
Wall * AddInterfloorWall(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height_in1, Real height_in2, Real voffset1, Real voffset2, Real tw, Real th)
Definition floor.cpp:369
Escalator * AddEscalator(const std::string &name, int run, Real speed, const std::string &sound_file, const std::string &riser_texture, const std::string &tread_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real risersize, Real treadsize, int num_steps, Real voffset, Real tw, Real th)
Definition floor.cpp:1638
std::string Name
Definition floor.h:37
Real FullHeight()
Definition floor.cpp:577
void SetAltitude(Real altitude)
Definition floor.cpp:1654
void AddFillerWalls(const std::string &texture, Real thickness, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, bool direction, Real tw, Real th, bool isexternal)
Definition floor.cpp:1019
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))
Definition floor.cpp:1090
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)
Definition floor.cpp:1611
std::string FloorType
Definition floor.h:40
Real GetBase(bool relative=false)
Definition floor.cpp:1146
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)
Definition floor.cpp:1525
FloorIndicator * AddFloorIndicator(int elevator, int car, bool relative, const std::string &texture_prefix, const std::string &blank_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset)
Definition floor.cpp:910
std::string ID
Definition floor.h:38
Real Height
Definition floor.h:44
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector< std::string > &action_names)
Definition floor.cpp:1621
void CutAll(const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, bool prepare=false)
Definition floor.cpp:642
bool CalculateAltitude()
Definition floor.cpp:845
Wall * ColumnWallBox2(const std::string &name, const std::string &texture, Real CenterX, Real CenterZ, Real WidthX, Real LengthZ, Real height_in, Real voffset, Real tw, Real th, bool inside, bool outside, bool top, bool bottom)
Definition floor.cpp:903
RevolvingDoor * AddRevolvingDoor(std::string name, bool run, const std::string &soundfile, const std::string &texture, Real thickness, bool clockwise, int segments, Real speed, Real rotation, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real tw, Real th, bool external)
Definition floor.cpp:1917
bool AltitudeSet
Definition floor.h:53
Wall * ColumnWallBox(const std::string &name, const std::string &texture, Real x1, Real x2, Real z1, Real z2, Real height_in, Real voffset, Real tw, Real th, bool inside, bool outside, bool top, bool bottom)
Definition floor.cpp:896
Real InterfloorHeight
Definition floor.h:45
Wall * AddWall(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height_in1, Real height_in2, Real voffset1, Real voffset2, Real tw, Real th, bool isexternal)
Definition floor.cpp:348
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 isexternal, bool legacy_behavior=false)
Definition floor.cpp:317
std::string NumberID
Definition floor.h:39
std::string Description
Definition floor.h:41
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, bool external=false)
Definition floor.cpp:785
void SetLocked(bool value, int keyid)
Definition lock.cpp:37
void SetKey(int keyid)
Definition model.cpp:110
Shaft * GetShaft(int number)
Definition sbs.cpp:1783
Elevator * GetElevator(int number)
Definition sbs.cpp:1776
DispatchController * GetController(int number)
Definition sbs.cpp:1804
DispatchController * NewController(int number)
Definition sbs.cpp:1726
int GetElevatorCount()
Definition sbs.cpp:1733
int GetControllerCount()
Definition sbs.cpp:1763
Floor * GetFloor(int number)
Definition sbs.cpp:1769
Stairwell * GetStairwell(int number)
Definition sbs.cpp:1790
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)
Definition shaft.cpp:1153
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)
Definition shaft.cpp:1075
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)
Definition shaft.cpp:790
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector< std::string > &action_names)
Definition shaft.cpp:1164
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)
Definition shaft.cpp:1235
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)
Definition shaft.cpp:813
Level * GetLevel(int floor)
Definition shaft.cpp:136
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)
Definition stairs.cpp:1161
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)
Definition stairs.cpp:840
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)
Definition stairs.cpp:733
Wall * AddStairs(const std::string &name, const std::string &riser_texture, const std::string &tread_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real risersize, Real treadsize, int num_stairs, Real voffset, Real tw, Real th)
Definition stairs.cpp:622
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)
Definition stairs.cpp:756
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector< std::string > &action_names)
Definition stairs.cpp:1172
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)
Definition stairs.cpp:1082
Level * GetLevel(int floor)
Definition stairs.cpp:113
void Report(const std::string &message)
FloorSection(ScriptProcessor *parent)
Definition floors.cpp:53
int Run(std::string &LineData)
Definition floors.cpp:76
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)
static const int sCheckFloors
Definition scriptproc.h:72
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)