-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathWrongWarp.Result.cs
254 lines (229 loc) · 9.99 KB
/
WrongWarp.Result.cs
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
using OcaBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OcaBase
{
partial class WrongWarp
{
public class Result
{
public enum Scene
{
Debug,
Unknown,
Normal
}
public enum Cutscene
{
Normal,
Pointer,
}
private Params WarpParams;
public EntranceStruct Start;
public EntranceStruct End;
public OcaBase.Scene FinalScene;
public Entrance FinalEntrance;
public bool ValidEntranceTableRecord = true;
public Scene SceneType = Scene.Unknown;
public bool ValidSetup = false;
public Cutscene CutsceneType = Cutscene.Pointer;
public bool ValidRoom = false;
public bool ValidEntranceId = false;
public bool Crashes = true;
public bool FaroresWindOnly = false;
public Result(Params warpParams)
{
Start = null;
End = null;
FinalEntrance = null;
WarpParams = warpParams;
}
public void SetResult()
{
//if the final entrance is not off the table
if (ValidEntranceTableRecord)
{
//Test scene existance
//if the scene does not exist in the commercial version
if (FinalScene.ID < 101)
SceneType = Scene.Normal;
//if it only exists in the debug version
else if (FinalScene.ID < 110)
SceneType = Scene.Debug;
else
SceneType = Scene.Unknown;
//scene exists
if (SceneType == Scene.Normal)
{
//if alternate headers command 0x18 exists,
//we'll wrong warp into a cutscene setup...
if (FinalScene.x18)
CutsceneType = Cutscene.Normal;
else
CutsceneType = Cutscene.Pointer;
//or if it doesn't exist, it will crash
if (FinalEntrance == null)
ValidSetup = false;
else
{
ValidSetup = true;
if (FinalEntrance.EntranceNum < FinalScene.EntranceNum)
ValidEntranceId = true;
else
ValidEntranceId = false;
//if the entrance record is sending you to a room that doesn't exist
if (FinalEntrance.Room >= FinalScene.Rooms)
ValidRoom = false;
else
ValidRoom = true;
}
}
}
FaroresWindOnly = (!ValidRoom || !ValidEntranceId);
}
#region PrintFunctions
public string PrintN64()
{
string resultString;
Result result = this;
if (!result.ValidEntranceTableRecord)
{
resultString = String.Format("Wrong warping with {0} cannot be calculated accurately due to version differences,"
+ " but will take you to either the Deku Tree, Dodongo's Cavern, Jabu Jabu, or the Forest Temple",
result.Start.GetShortDescription(false, true));
}
else
{
resultString = String.Format("{0} with cutscene {2} will wrong warp you to {1} (room {3})",
result.Start.GetShortDescription(false, true),
result.End.GetShortDescription(false, false),
WarpParams.CutsceneIndex,
(result.FinalEntrance != null) ? result.FinalEntrance.Room.ToString() : "null");
//What scene are we warping to?
switch (result.SceneType)
{
case WrongWarp.Result.Scene.Debug:
resultString += ", but will crash because the scene only exists on the Debug Rom."; break;
case WrongWarp.Result.Scene.Unknown:
resultString += ", but will crash because the scene doesn't exist."; break;
default: //Good Scene
resultString += GoodSceneBranch(WarpParams, result); break;
}
}
return resultString;
}
public string Print3dsDhww()
{
string result;
Result wwr = this;
if (!wwr.ValidEntranceTableRecord)
{
result = String.Format("Death hole wrong warping with {0} cannot be calculated, but in theory it should try to"
+ " take you to either the Deku Tree, Dodongo's Cavern, Jabu Jabu, or the Forest Temple",
wwr.Start.GetShortDescription(false, true));
}
else
{
//We know enough to say where the wrong warp will place us, so create that part of the output
result = String.Format("Death hole wrong warping with {0} will wrong warp you to {1}",
wwr.Start.GetShortDescription(false, true),
wwr.End.GetShortDescription(false, false));
//What scene are we warping to?
switch (wwr.SceneType)
{
case WrongWarp.Result.Scene.Debug:
result += ", but will crash because the scene only exists on the Debug Rom."; break;
case WrongWarp.Result.Scene.Unknown:
result += ", but will crash because the scene doesn't exist."; break;
default: //Good Scene
result += DhwwGoodSceneBranch(wwr);
break;
}
}
return result;
}
/// <summary>
/// Standard 64 good scene wrong warp branch result
/// </summary>
/// <param name="wwp"></param>
/// <param name="wwr"></param>
/// <returns></returns>
private string GoodSceneBranch(WrongWarp.Params wwp, WrongWarp.Result wwr)
{
SceneCutscene cutsceneRecord;
string result = "";
//Valid Setup?
if (!wwr.ValidSetup) //bad setup
return String.Format(" but will crash due to a bad scene setup ({0}).",
wwp.CutsceneIndex + 4);
//cutscene type
if (wwr.CutsceneType == WrongWarp.Result.Cutscene.Normal)
{
if (Queries.TryGetCutsceneRecord(wwr.FinalScene.ID, wwp.CutsceneIndex, out cutsceneRecord))
{
result += String.Format(" and play the {0} cutscene.",
cutsceneRecord.Description);
}
else
result += String.Format(" and play cutscene {0}.", wwp.CutsceneIndex);
}
else //cutscene pointer
{
result += " but is affected by the cutscene pointer.";
}
//Crash without Farore's Wind?
if (FaroresWindOnly)
result += PrintFaroresWindRequirement(wwr);
return result;
}
/// <summary>
/// Death Hole Wrong Warping good scene result branch
/// </summary>
/// <param name="wwr"></param>
/// <returns></returns>
private string DhwwGoodSceneBranch(WrongWarp.Result wwr)
{
SceneCutscene cutsceneRecord;
string result = "";
//Valid Setup?
if (!wwr.ValidSetup)
{
//bad setup
return ", but will crash due to a bad scene setup (4).";// break;
}
//cutscene type
if (wwr.CutsceneType == WrongWarp.Result.Cutscene.Normal)
{
if (Queries.TryGetCutsceneRecord(wwr.FinalScene.ID, 0, out cutsceneRecord))
{
result = String.Format(", with a black screen and the {0} scene setup loaded.",
cutsceneRecord.Description);
}
else //still valid, just possible that the record wasn't pulled/missing cs
result = ", with a black screen and cutscene 0 loaded.";
}
else
{
//cutscene pointer
}
//if room or entrance id aren't valid
if (FaroresWindOnly)
result += PrintFaroresWindRequirement(wwr);
return result;
}
private string PrintFaroresWindRequirement(WrongWarp.Result wwr)
{
return string.Format(
" HOWEVER, without Farore's Wind {0}{1}{2}.",
(!wwr.ValidRoom) ? String.Format("a crash will occur due to an invalid room id") : "",
(!wwr.ValidRoom && !wwr.ValidEntranceId) ? ", and " : "",
(!wwr.ValidEntranceId) ? "a softlock will occur due to a invalid starting position" : ""
);
}
#endregion
}
}
}