-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterp.h
More file actions
101 lines (84 loc) · 1.61 KB
/
interp.h
File metadata and controls
101 lines (84 loc) · 1.61 KB
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
#ifndef twf_interp_h
#define twf_interp_h
extern room_data *cmd_room;
class Command_Data
{
public:
const char *string;
const bool ordered;
Command_Data *next;
room_data *room; // Used by speed command.
Command_Data( const char *msg, bool bit )
: ordered(bit), next(0), room(0)
{
string = alloc_string( msg, MEM_PLAYER );
}
~Command_Data( ) {
free_string( string, MEM_PLAYER );
}
};
class Command_Queue
{
private:
int size;
command_data *list;
command_data *last;
public:
Command_Queue( )
: size(0), list(0), last(0)
{}
~Command_Queue( )
{
clear();
}
int entries( ) const
{
return size;
}
command_data *pop( )
{
if( !list )
return 0;
command_data *cmd = list;
list = list->next;
if( !list )
last = 0;
--size;
// cmd->next = 0;
return cmd;
}
command_data *push( const char *string, bool ordered )
{
command_data *cmd = new command_data( string, ordered );
if( !last ) {
list = cmd;
} else {
last->next = cmd;
}
last = cmd;
++size;
return cmd;
}
command_data *shift( const char *string, bool ordered )
{
command_data *cmd = new command_data( string, ordered );
if( !last ) {
last = cmd;
} else {
cmd->next = list;
}
list = cmd;
++size;
return cmd;
}
void clear( )
{
while( Command_Data *cmd = list ) {
list = list->next;
delete cmd;
}
size = 0;
list = last = 0;
}
};
#endif // twf_interp_h