1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "glk/alan3/actor.h"
24 #include "glk/alan3/instance.h"
25 #include "glk/alan3/memory.h"
26 #include "glk/alan3/lists.h"
27 #include "glk/alan3/inter.h"
28 #include "glk/alan3/msg.h"
29 #include "glk/alan3/container.h"
30 
31 namespace Glk {
32 namespace Alan3 {
33 
34 /*======================================================================*/
scriptOf(int actor)35 ScriptEntry *scriptOf(int actor) {
36 	ScriptEntry *scr;
37 
38 	if (admin[actor].script != 0) {
39 		for (scr = (ScriptEntry *) pointerTo(header->scriptTableAddress); !isEndOfArray(scr); scr++)
40 			if (scr->code == admin[actor].script)
41 				break;
42 		if (!isEndOfArray(scr))
43 			return scr;
44 	}
45 	return NULL;
46 }
47 
48 
49 /*======================================================================*/
stepOf(int actor)50 StepEntry *stepOf(int actor) {
51 	StepEntry *step;
52 	ScriptEntry *scr = scriptOf(actor);
53 
54 	if (scr == NULL) return NULL;
55 
56 	step = (StepEntry *)pointerTo(scr->steps);
57 	step = &step[admin[actor].step];
58 
59 	return step;
60 }
61 
62 
63 /*======================================================================*/
describeActor(CONTEXT,int actor)64 void describeActor(CONTEXT, int actor) {
65 	ScriptEntry *script = scriptOf(actor);
66 
67 	if (script != NULL && script->description != 0) {
68 		CALL1(interpret, script->description)
69 	} else if (hasDescription(actor)) {
70 		CALL1(describeAnything, actor)
71 	} else {
72 		printMessageWithInstanceParameter(M_SEE_START, actor);
73 		printMessage(M_SEE_END);
74 
75 		if (instances[actor].container != 0)
76 			CALL1(describeContainer, actor)
77 	}
78 	admin[actor].alreadyDescribed = TRUE;
79 }
80 
81 } // End of namespace Alan3
82 } // End of namespace Glk
83