-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.bt
101 lines (95 loc) · 3.44 KB
/
event.bt
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
// Event classes.
// Note: only the event type names are official. Other names are merely
// more or less informed guesses.
typedef uint16 EventIndex <read=EventIndexToString>;
string EventIndexToString(uint16 idx) {
return idx != 0xffff ? EventToString(root.events.events[idx]) : "(END)";
}
struct EventSwitchCase {
uint32 value <format=hex>;
EventIndex event_idx;
uint16 padding <hidden=true>;
};
typedef struct {
POINTER<PascalString> name;
EventType type <format=hex>;
uchar x9_padding <hidden=true>;
switch (type) {
case EventType_kAction:
EventIndex next;
ActorIndex actor_index;
ActorActionIndex action_index(actor_index);
POINTER<Dictionary> action_params <bgcolor=0x0084ea>;
break;
case EventType_kSwitch:
uint16 num_cases;
ActorIndex actor_index;
ActorQueryIndex query_index(actor_index);
POINTER<Dictionary> query_params <bgcolor=0x0084ea>;
POINTER<EventSwitchCase[num_cases]> cases <bgcolor=0x013dc6>;
POINTER<uchar> unused <hidden=true>; // padding
Assert(unused_offset == 0);
break;
case EventType_kFork:
uint16 num_forks;
EventIndex join_idx;
uint16 xe <hidden=true>; // padding
Assert(xe == 0);
POINTER<EventIndex[num_forks]> fork <bgcolor=0x2222c1>;
break;
case EventType_kJoin:
EventIndex next;
uint16 xc <hidden=true>; // padding
uint16 xe <hidden=true>; // padding
Assert(xc == 0 && xe == 0);
POINTER<Dictionary> params; // padding
Assert(params_offset == 0);
break;
case EventType_kSubFlow:
EventIndex next;
uint16 xc <hidden=true>; // padding
uint16 xe <hidden=true>; // padding
Assert(xc == 0 && xe == 0);
POINTER<Dictionary> params <bgcolor=0x0084ea>;
break;
default:
Assert(false, "Unknown event type");
}
if (type != EventType_kSwitch) {
// If present, the game will check whether the name of the resource flowchart matches with this.
POINTER<PascalString> required_res_flowchart_name;
// If present, the game will check whether the name of the entry point matches with this.
POINTER<PascalString> required_entry_point_name;
if (type != EventType_kSubFlow) {
Assert(required_res_flowchart_name_offset == 0);
Assert(required_entry_point_name_offset == 0);
}
}
} Event <read=EventToString>;
string EventToString(const Event& event) {
string s = PascalStringToString(event.name) + " - " + EventTypeToString(event.type);
switch (event.type) {
case EventType_kAction:
s += " - " + ActorIndexToString(event.actor_index);
s += "::" + ActorActionIndexToString(event.action_index);
break;
case EventType_kSwitch:
s += " - " + ActorIndexToString(event.actor_index);
s += "::" + ActorQueryIndexToString(event.query_index);
string num_string; SPrintf(num_string, " - %u case(s)", event.num_cases); s += num_string;
break;
case EventType_kFork:
string num_string; SPrintf(num_string, " - %u fork(s)", event.num_forks);
s += num_string;
// Abusing this function as a way to delay asserts until parsing is done.
Assert(root.events.events[event.join_idx].type == EventType_kJoin);
break;
case EventType_kJoin:
break;
case EventType_kSubFlow:
s += " - " + PascalStringToString(event.required_res_flowchart_name);
s += "<" + PascalStringToString(event.required_entry_point_name) + ">";
break;
}
return s;
}