aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe/messages.h
blob: 0ae11ff24471a61ade217b971e591943dbec6d47 (plain)
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
/* 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.
 *
 */

#ifndef FULLPIPE_MESSAGEQUEUE_H
#define FULLPIPE_MESSAGEQUEUE_H

#include "fullpipe/utils.h"
#include "fullpipe/inventory.h"
#include "fullpipe/gfx.h"
#include "fullpipe/sound.h"
#include "fullpipe/scene.h"

namespace Fullpipe {

class Message : public CObject {
 public:
	int _messageKind;
	int16 _parentId;
	int _x;
	int _y;
	int _field_14;
	int _sceneClickX;
	int _sceneClickY;
	int _field_20;
	int _field_24;
	int _param28;
	int _field_2C;
	int _field_30;
	int _field_34;

 public:
	Message();
	Message(Message *src);
	Message(int16 parentId, int messageKind, int x, int y, int a6, int a7, int sceneClickX, int sceneClickY, int a10);
};

class ExCommand : public Message {
	friend class CGameLoader;
	friend class MessageQueue;

	int _messageNum;
	int _field_3C;
	int _excFlags;
	int _parId;

 public:
	ExCommand();
	ExCommand(ExCommand *src);
	ExCommand(int16 parentId, int messageKind, int messageNum, int x, int y, int a7, int a8, int sceneClickX, int sceneClickY, int a11);
	virtual ~ExCommand() {}

	virtual bool load(MfcArchive &file);

	void handleMessage();
};

class CObjstateCommand : public CObject {
	ExCommand _cmd;
	char *_objCommandName;
	int _value;

 public:
	CObjstateCommand();
	virtual bool load(MfcArchive &file);
};

class MessageQueue : public CObject {
	friend class GlobalMessageQueueList;
	friend class CGameLoader;
	friend class Scene;

  protected:
	int _id;
	int _flags;
	char *_queueName;
	int16 _dataId;
	int16 _field_12;
	int _field_14;
	CPtrList _exCommands;
	int _counter;
	int _field_38;
	int _isFinished;
	int _parId;
	int _flag1;

 public:
	MessageQueue();
	MessageQueue(MessageQueue *src, int parId, int field_38);
	virtual bool load(MfcArchive &file);

	int getFlags() { return _flags; }
	void setFlags(int flags) { _flags = flags; }

	bool chain(StaticANIObject *ani);
};

class GlobalMessageQueueList : public CPtrList {
  public:
	MessageQueue *getMessageQueueById(int id);
	void deleteQueueById(int id);
	void disableQueueById(int id);
	void addMessageQueue(MessageQueue *msg);

	int compact();
};

struct MessageHandler {
	int (*callback)(ExCommand *cmd);
	int16 id;
	int16 field_6;
	int index;
	MessageHandler *nextItem;
};

bool removeMessageHandler(int16 id, int pos);
void updateMessageHandlerIndex(MessageHandler *msg, int offset);
void addMessageHandler(int (*callback)(ExCommand *), int16 id);
MessageHandler *getMessageHandlerById(int16 id);
bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index);
int getMessageHandlersCount();
bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id);
bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id);
void clearMessageHandlers();
void postMessage(ExCommand *ex);
void processMessages();

} // End of namespace Fullpipe

#endif /* FULLPIPE_MESSAGEQUEUE_H */