1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
#include "gui/message.h"
#include "lab/lab.h"
#include "lab/stddefines.h"
#include "lab/labfun.h"
#include "lab/parsetypes.h"
#include "lab/parsefun.h"
#include "lab/resource.h"
#include "lab/diff.h"
#include "lab/interface.h"
namespace Lab {
/* Global parser data */
#define NOFILE "no file"
RoomData *_rooms;
InventoryData *Inventory;
uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
const char *NewFileName;
extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, LongWinInFront;
extern char diffcmap[256 * 3];
extern const char *CurFileName;
extern CloseDataPtr CPtr;
/*****************************************************************************/
/* Generates a random number. */
/*****************************************************************************/
uint16 getRandom(uint16 max) {
uint32 secs, micros;
g_lab->getTime(&secs, µs);
return ((micros + secs) % max);
}
/*****************************************************************************/
/* Checks whether all the conditions in a condition list are met. */
/*****************************************************************************/
static bool checkConditions(int16 *Condition) {
int16 Counter;
bool res;
if (Condition == NULL)
return true;
if (Condition[0] == 0)
return true;
Counter = 1;
res = g_lab->_conditions->in(Condition[0]);
while (Condition[Counter] && res) {
res = g_lab->_conditions->in(Condition[Counter]);
Counter++;
}
return res;
}
/*****************************************************************************/
/* Gets the current ViewDataPointer. */
/*****************************************************************************/
ViewData *getViewData(uint16 roomNum, uint16 direction) {
ViewData *view = NULL;
if (!_rooms[roomNum]._roomMsg)
g_lab->_resource->readViews(roomNum);
if (direction == NORTH)
view = _rooms[roomNum]._northView;
else if (direction == SOUTH)
view = _rooms[roomNum]._southView;
else if (direction == EAST)
view = _rooms[roomNum]._eastView;
else if (direction == WEST)
view = _rooms[roomNum]._westView;
do {
if (checkConditions(view->Condition))
break;
view = view->NextCondition;
} while (true);
return view;
}
/*****************************************************************************/
/* Gets an object, if any, from the user's click on the screen. */
/*****************************************************************************/
static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
ViewData *VPtr;
if (LCPtr == NULL) {
VPtr = getViewData(RoomNum, Direction);
LCPtr = VPtr->closeUps;
}
else
LCPtr = LCPtr->SubCloseUps;
while (LCPtr != NULL) {
if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
(x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)))
return LCPtr;
LCPtr = LCPtr->NextCloseUp;
}
return NULL;
}
/*****************************************************************************/
/* Goes through the list of closeups to find a match. */
/* NYI: Known bug here. If there are two objects that have closeups, and */
/* some of the closeups have the same hit boxes, then this returns the */
/* first occurence of the object with the same hit box. */
/*****************************************************************************/
static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
CloseDataPtr cptr;
while (List) {
if ((Main->x1 == List->x1) && (Main->x2 == List->x2) &&
(Main->y1 == List->y1) && (Main->y2 == List->y2) &&
(Main->depth == List->depth))
return List;
cptr = findCPtrMatch(Main, List->SubCloseUps);
if (cptr)
return cptr;
else
List = List->NextCloseUp;
}
return NULL;
}
/*****************************************************************************/
/* Returns the current picture name. */
/*****************************************************************************/
char *getPictName(CloseDataPtr *LCPtr) {
ViewData *ViewPtr = getViewData(RoomNum, Direction);
if (*LCPtr != NULL) {
*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
if (*LCPtr)
return (*LCPtr)->GraphicName;
}
return ViewPtr->GraphicName;
}
/*****************************************************************************/
/* Draws the current direction to the screen. */
/*****************************************************************************/
void LabEngine::drawDirection(CloseDataPtr LCPtr) {
if (LCPtr != NULL && LCPtr->Message) {
drawMessage(LCPtr->Message);
return;
}
Common::String message;
if (_rooms[RoomNum]._roomMsg) {
message += _rooms[RoomNum]._roomMsg;
message += ", ";
}
if (Direction == NORTH)
message += _resource->getStaticText(kTextFacingNorth);
else if (Direction == EAST)
message += _resource->getStaticText(kTextFacingEast);
else if (Direction == SOUTH)
message += _resource->getStaticText(kTextFacingSouth);
else if (Direction == WEST)
message += _resource->getStaticText(kTextFacingWest);
drawMessage(message.c_str());
}
/*****************************************************************************/
/* process a arrow gadget movement. */
/*****************************************************************************/
bool processArrow(uint16 *direction, uint16 Arrow) {
uint16 room = 1;
if (Arrow == 1) { /* Forward */
if (*direction == NORTH)
room = _rooms[RoomNum]._northDoor;
else if (*direction == SOUTH)
room = _rooms[RoomNum]._southDoor;
else if (*direction == EAST)
room = _rooms[RoomNum]._eastDoor;
else if (*direction == WEST)
room = _rooms[RoomNum]._westDoor;
if (room == 0)
return false;
else
RoomNum = room;
} else if (Arrow == 0) { /* Left */
if (*direction == NORTH)
*direction = WEST;
else if (*direction == WEST)
*direction = SOUTH;
else if (*direction == SOUTH)
*direction = EAST;
else
*direction = NORTH;
} else if (Arrow == 2) { /* Right */
if (*direction == NORTH)
*direction = EAST;
else if (*direction == EAST)
*direction = SOUTH;
else if (*direction == SOUTH)
*direction = WEST;
else
*direction = NORTH;
}
return true;
}
/*****************************************************************************/
/* Sets the current close up data. */
/*****************************************************************************/
void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) {
ViewData *VPtr;
CloseDataPtr LCPtr;
uint16 x1, y1, x2, y2;
if (*cptr == NULL) {
VPtr = getViewData(RoomNum, Direction);
LCPtr = VPtr->closeUps;
} else
LCPtr = (*cptr)->SubCloseUps;
while (LCPtr != NULL) {
if (!useAbsoluteCoords) {
x1 = LCPtr->x1;
y1 = LCPtr->y1;
x2 = LCPtr->x2;
y2 = LCPtr->y2;
} else {
x1 = scaleX(LCPtr->x1);
y1 = scaleY(LCPtr->y1);
x2 = scaleX(LCPtr->x2);
y2 = scaleY(LCPtr->y2);
}
if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && LCPtr->GraphicName) {
*cptr = LCPtr;
return;
}
LCPtr = LCPtr->NextCloseUp;
}
}
/*****************************************************************************/
/* Takes the currently selected item. */
/*****************************************************************************/
bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
ViewData *VPtr;
CloseDataPtr LCPtr;
if (*cptr == NULL) {
VPtr = getViewData(RoomNum, Direction);
LCPtr = VPtr->closeUps;
} else if ((*cptr)->CloseUpType < 0) {
g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
return true;
} else
LCPtr = (*cptr)->SubCloseUps;
while (LCPtr != NULL) {
if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
(x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
(LCPtr->CloseUpType < 0)) {
g_lab->_conditions->inclElement(abs(LCPtr->CloseUpType));
return true;
}
LCPtr = LCPtr->NextCloseUp;
}
return false;
}
/*****************************************************************************/
/* Processes the action list. */
/*****************************************************************************/
static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
CloseDataPtr TLCPtr;
bool FirstLoaded = true;
char **str, *Test;
uint32 StartSecs, StartMicros, CurSecs, CurMicros;
while (APtr) {
g_music->updateMusic();
switch (APtr->ActionType) {
case PLAYSOUND:
g_music->_loopSoundEffect = false;
g_music->_waitTillFinished = true;
readMusic((char *)APtr->Data, true);
g_music->_waitTillFinished = false;
break;
case PLAYSOUNDB:
g_music->_loopSoundEffect = false;
g_music->_waitTillFinished = false;
readMusic((char *)APtr->Data, false);
break;
case PLAYSOUNDCONT:
g_music->_doNotFilestopSoundEffect = true;
g_music->_loopSoundEffect = true;
readMusic((char *)APtr->Data, g_music->_waitTillFinished);
break;
case SHOWDIFF:
readPict((char *)APtr->Data, true);
break;
case SHOWDIFFCONT:
readPict((char *)APtr->Data, false);
break;
case LOADDIFF:
if (FirstLoaded) {
resetBuffer();
FirstLoaded = false;
}
if (APtr->Data)
g_music->newOpen((char *)APtr->Data); /* Puts a file into memory */
break;
case WIPECMD:
g_lab->doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
break;
case NOUPDATE:
noupdatediff = true;
DoBlack = false;
break;
case FORCEUPDATE:
CurFileName = " ";
break;
case SHOWCURPICT:
Test = getPictName(LCPtr);
if (strcmp(Test, CurFileName) != 0) {
CurFileName = Test;
readPict(CurFileName, true);
}
break;
case SETELEMENT:
g_lab->_conditions->inclElement(APtr->Param1);
break;
case UNSETELEMENT:
g_lab->_conditions->exclElement(APtr->Param1);
break;
case SHOWMESSAGE:
DoNotDrawMessage = false;
if (LongWinInFront)
g_lab->longDrawMessage((char *)APtr->Data);
else
g_lab->drawMessage((char *)APtr->Data);
DoNotDrawMessage = true;
break;
case CSHOWMESSAGE:
if (*LCPtr == NULL) {
DoNotDrawMessage = false;
g_lab->drawMessage((char *)APtr->Data);
DoNotDrawMessage = true;
}
break;
case SHOWMESSAGES:
str = (char **)APtr->Data;
DoNotDrawMessage = false;
g_lab->drawMessage(str[getRandom(APtr->Param1)]);
DoNotDrawMessage = true;
break;
case SETPOSITION:
if (APtr->Param1 & 0x8000) {
// This is a Wyrmkeep Windows trial version, thus stop at this
// point, since we can't check for game payment status
readPict(getPictName(LCPtr), true);
APtr = NULL;
GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
trialMessage.runModal();
continue;
}
RoomNum = APtr->Param1;
Direction = APtr->Param2 - 1;
*LCPtr = NULL;
DoBlack = true;
break;
case SETCLOSEUP:
TLCPtr = getObject(scaleX(APtr->Param1), scaleY(APtr->Param2), *LCPtr);
if (TLCPtr)
*LCPtr = TLCPtr;
break;
case MAINVIEW:
*LCPtr = NULL;
break;
case SUBINV:
if (Inventory[APtr->Param1].Many)
(Inventory[APtr->Param1].Many)--;
if (Inventory[APtr->Param1].Many == 0)
g_lab->_conditions->exclElement(APtr->Param1);
break;
case ADDINV:
(Inventory[APtr->Param1].Many) += APtr->Param2;
g_lab->_conditions->inclElement(APtr->Param1);
break;
case SHOWDIR:
DoNotDrawMessage = false;
break;
case WAITSECS:
g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
g_lab->WSDL_UpdateScreen();
while (1) {
g_music->updateMusic();
g_lab->diffNextFrame();
g_lab->getTime(&CurSecs, &CurMicros);
if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
(CurMicros >= StartMicros)))
break;
}
break;
case STOPMUSIC:
g_music->setMusic(false);
break;
case STARTMUSIC:
g_music->setMusic(true);
break;
case CHANGEMUSIC:
g_music->changeMusic((const char *)APtr->Data);
g_music->setMusicReset(false);
break;
case RESETMUSIC:
g_music->resetMusic();
g_music->setMusicReset(true);
break;
case FILLMUSIC:
g_music->updateMusic();
break;
case WAITSOUND:
while (g_music->isSoundEffectActive()) {
g_music->updateMusic();
g_lab->diffNextFrame();
g_lab->waitTOF();
}
break;
case CLEARSOUND:
if (g_music->_loopSoundEffect) {
g_music->_loopSoundEffect = false;
g_music->stopSoundEffect();
} else if (g_music->isSoundEffectActive())
g_music->stopSoundEffect();
break;
case WINMUSIC:
g_music->_winmusic = true;
g_music->freeMusic();
g_music->initMusic();
break;
case WINGAME:
QuitLab = true;
break;
case LOSTGAME:
QuitLab = true;
break;
case RESETBUFFER:
resetBuffer();
break;
case SPECIALCMD:
if (APtr->Param1 == 0)
DoBlack = true;
else if (APtr->Param1 == 1)
DoBlack = (CPtr == NULL);
else if (APtr->Param1 == 2)
DoBlack = (CPtr != NULL);
else if (APtr->Param1 == 5) { /* inverse the palette */
for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
diffcmap[idx] = 255 - diffcmap[idx];
g_lab->waitTOF();
g_lab->VGASetPal(diffcmap, 256);
g_lab->waitTOF();
g_lab->waitTOF();
} else if (APtr->Param1 == 4) { /* white the palette */
whiteScreen();
g_lab->waitTOF();
g_lab->waitTOF();
} else if (APtr->Param1 == 6) { /* Restore the palette */
g_lab->waitTOF();
g_lab->VGASetPal(diffcmap, 256);
g_lab->waitTOF();
g_lab->waitTOF();
} else if (APtr->Param1 == 7) { /* Quick pause */
g_lab->waitTOF();
g_lab->waitTOF();
g_lab->waitTOF();
}
break;
}
APtr = APtr->NextAction;
}
if (g_music->_loopSoundEffect) {
g_music->_loopSoundEffect = false;
g_music->stopSoundEffect();
} else {
while (g_music->isSoundEffectActive()) {
g_music->updateMusic();
g_lab->diffNextFrame();
g_lab->waitTOF();
}
}
g_music->_doNotFilestopSoundEffect = false;
}
/*****************************************************************************/
/* Does the work for doActionRule. */
/*****************************************************************************/
static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
action++;
if (LCPtr) {
RuleList *rules = _rooms[RoomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum);
rules = _rooms[roomNum]._rules;
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == ACTION) &&
(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && AllowDefaults))) {
if ((((*rule)->Param2 == LCPtr->CloseUpType) ||
(((*rule)->Param2 == 0) && AllowDefaults))
||
((action == 1) && ((*rule)->Param2 == (-LCPtr->CloseUpType)))) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, Set);
return true;
}
}
}
}
}
return false;
}
/*****************************************************************************/
/* Goes through the rules if an action is taken. */
/*****************************************************************************/
bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *LCPtr) {
CloseDataPtr TLCPtr;
if (roomNum)
NewFileName = NOFILE;
else
NewFileName = CurFileName;
TLCPtr = getObject(pos.x, pos.y, *LCPtr);
if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, false))
return true;
else if (doActionRuleSub(action, roomNum, *LCPtr, LCPtr, false))
return true;
else if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, true))
return true;
else if (doActionRuleSub(action, roomNum, *LCPtr, LCPtr, true))
return true;
return false;
}
/*****************************************************************************/
/* Does the work for doActionRule. */
/*****************************************************************************/
static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
if (LCPtr)
if (LCPtr->CloseUpType > 0) {
RuleList *rules = _rooms[roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum);
rules = _rooms[roomNum]._rules;
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == OPERATE) &&
(((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
(((*rule)->Param2 == LCPtr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, Set);
return true;
}
}
}
}
return false;
}
/*****************************************************************************/
/* Goes thru the rules if the user tries to operate an item on an object. */
/*****************************************************************************/
bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
CloseDataPtr TLCPtr;
NewFileName = NOFILE;
TLCPtr = getObject(x, y, *LCPtr);
if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, false))
return true;
else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, false))
return true;
else if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, true))
return true;
else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, true))
return true;
else {
NewFileName = CurFileName;
if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, false))
return true;
else if (doOperateRuleSub(ItemNum, 0, *LCPtr, LCPtr, false))
return true;
else if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, true))
return true;
else if (doOperateRuleSub(ItemNum, 0, *LCPtr, LCPtr, true))
return true;
}
return false;
}
/*****************************************************************************/
/* Goes thru the rules if the user tries to go forward. */
/*****************************************************************************/
bool doGoForward(CloseDataPtr *LCPtr) {
RuleList *rules = _rooms[RoomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, LCPtr);
return true;
}
}
}
return false;
}
/*****************************************************************************/
/* Goes thru the rules if the user tries to turn. */
/*****************************************************************************/
bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
from++;
to++;
RuleList *rules = _rooms[RoomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == TURN) ||
(((*rule)->RuleType == TURNFROMTO) &&
((*rule)->Param1 == from) && ((*rule)->Param2 == to))) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, LCPtr);
return true;
}
}
}
return false;
}
/*****************************************************************************/
/* Goes thru the rules if the user tries to go to the main view */
/*****************************************************************************/
bool doMainView(CloseDataPtr *LCPtr) {
RuleList *rules = _rooms[RoomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if ((*rule)->RuleType == GOMAINVIEW) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, LCPtr);
return true;
}
}
}
return false;
}
} // End of namespace Lab
|