|
@@ -55,6 +55,7 @@ int Script::load(const char *file) {
|
55
|
55
|
f.seek(f.tell() + 32);
|
56
|
56
|
|
57
|
57
|
flags = f.readU16();
|
|
58
|
+ bool tag = (flags & S_UseSecurityTag) != 0;
|
58
|
59
|
|
59
|
60
|
// Filler 3 (6 bytes)
|
60
|
61
|
f.seek(f.tell() + 6);
|
|
@@ -67,48 +68,50 @@ int Script::load(const char *file) {
|
67
|
68
|
f.seek(f.tell() + 4);
|
68
|
69
|
|
69
|
70
|
// Strings
|
70
|
|
- readStringPackage(f, levelNames, numLevels);
|
71
|
|
- readStringPackage(f, pictureFilenames, numPictures);
|
72
|
|
- readStringPackage(f, titleFilenames, numTitles);
|
73
|
|
- readStringPackage(f, fmvFilenames, numFMVs);
|
74
|
|
- readStringPackage(f, levelFilenames, numLevels);
|
75
|
|
- readStringPackage(f, cutsceneFilenames, numCutscenes);
|
76
|
|
- readStringPackage(f, script, numLevels + 1);
|
|
71
|
+ readStringPackage(f, levelNames, numLevels, tag, 0);
|
|
72
|
+ readStringPackage(f, pictureFilenames, numPictures, tag, 0);
|
|
73
|
+ readStringPackage(f, titleFilenames, numTitles, tag, 0);
|
|
74
|
+ readStringPackage(f, fmvFilenames, numFMVs, tag, 0);
|
|
75
|
+ readStringPackage(f, levelFilenames, numLevels, tag, 0);
|
|
76
|
+ readStringPackage(f, cutsceneFilenames, numCutscenes, tag, 0);
|
|
77
|
+
|
|
78
|
+ // Offset definitely TR2 specific?!
|
|
79
|
+ readStringPackage(f, script, numLevels + 1, false, 6);
|
77
|
80
|
|
78
|
81
|
numGameStrings = f.readU16();
|
79
|
|
- numGameStrings = 89; // Ignored?
|
|
82
|
+ assert(numGameStrings == 89);
|
80
|
83
|
|
81
|
|
- readStringPackage(f, gameStrings, numGameStrings);
|
|
84
|
+ readStringPackage(f, gameStrings, numGameStrings, tag, 0);
|
82
|
85
|
|
83
|
|
- readStringPackage(f, pcStrings, 41);
|
|
86
|
+ readStringPackage(f, pcStrings, 41, tag, 0);
|
84
|
87
|
|
85
|
|
- readStringPackage(f, puzzles[0], numLevels);
|
86
|
|
- readStringPackage(f, puzzles[1], numLevels);
|
87
|
|
- readStringPackage(f, puzzles[2], numLevels);
|
88
|
|
- readStringPackage(f, puzzles[3], numLevels);
|
|
88
|
+ readStringPackage(f, puzzles[0], numLevels, tag, 0);
|
|
89
|
+ readStringPackage(f, puzzles[1], numLevels, tag, 0);
|
|
90
|
+ readStringPackage(f, puzzles[2], numLevels, tag, 0);
|
|
91
|
+ readStringPackage(f, puzzles[3], numLevels, tag, 0);
|
89
|
92
|
|
90
|
|
- readStringPackage(f, pickups[0], numLevels);
|
91
|
|
- readStringPackage(f, pickups[1], numLevels);
|
|
93
|
+ readStringPackage(f, pickups[0], numLevels, tag, 0);
|
|
94
|
+ readStringPackage(f, pickups[1], numLevels, tag, 0);
|
92
|
95
|
|
93
|
|
- readStringPackage(f, keys[0], numLevels);
|
94
|
|
- readStringPackage(f, keys[1], numLevels);
|
95
|
|
- readStringPackage(f, keys[2], numLevels);
|
96
|
|
- readStringPackage(f, keys[3], numLevels);
|
|
96
|
+ readStringPackage(f, keys[0], numLevels, tag, 0);
|
|
97
|
+ readStringPackage(f, keys[1], numLevels, tag, 0);
|
|
98
|
+ readStringPackage(f, keys[2], numLevels, tag, 0);
|
|
99
|
+ readStringPackage(f, keys[3], numLevels, tag, 0);
|
97
|
100
|
|
98
|
101
|
return 0;
|
99
|
102
|
}
|
100
|
103
|
|
101
|
|
-void Script::readStringPackage(BinaryFile &f, std::vector<std::string> &v, unsigned int n) {
|
|
104
|
+void Script::readStringPackage(BinaryFile &f, std::vector<std::string> &v, unsigned int n, bool tag, uint16_t off) {
|
102
|
105
|
uint16_t *offset = new uint16_t[n];
|
103
|
106
|
for (unsigned int i = 0; i < n; i++)
|
104
|
107
|
offset[i] = f.readU16();
|
105
|
108
|
|
106
|
|
- uint16_t numBytes = f.readU16();
|
|
109
|
+ uint16_t numBytes = f.readU16() + off;
|
107
|
110
|
|
108
|
111
|
char *list = new char[numBytes];
|
109
|
112
|
for (uint16_t i = 0; i < numBytes; i++) {
|
110
|
113
|
list[i] = f.read8();
|
111
|
|
- if (flags & S_UseSecurityTag) {
|
|
114
|
+ if (tag) {
|
112
|
115
|
list[i] ^= cypherCode;
|
113
|
116
|
}
|
114
|
117
|
}
|