Skip to content

Commit 40b9b13

Browse files
committed
Port: list every Spanish jump gate destination (#80)
The Spanish jump gate menus (map/f/f04/f04_5.stb twice and map/s/s30/s30_5.stb) put East and West on one line, "Puerta de salto Este -- Oeste", so they list one destination fewer than the script offers: the last choice is blank, and the choices after North take the player one destination further than they say. script_text gives the three menus one line per destination, as in the English menu, and names the time gate "Puerta del tiempo" as the Spanish text does elsewhere: Puerta de salto Norte Puerta de salto Este Puerta de salto Oeste Enfrente de la Puerta del tiempo Puente de Paznos (first f04 menu only) Tests check the line counts and widths, and the extracted scripts when DC2_DATA has them.
1 parent 3d57334 commit 40b9b13

4 files changed

Lines changed: 88 additions & 3 deletions

File tree

‎docs/PC.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,13 @@ Sphere turn black, a colour it never takes. The same file corrects those three
496496
lines by their exact text: "Tienes que acordarte de otra cosa más.", "De azul a
497497
rojo, de rojo a azul." and "...y cambiará el color.".
498498

499+
The Spanish jump gate menus in Gundorada (`map/f/f04/f04_5.stb` and
500+
`map/s/s30/s30_5.stb`) put East and West on one line, "Puerta de salto Este --
501+
Oeste", so they show one destination fewer than the script offers: the last
502+
choice is blank and the ones after North lead one destination further than they
503+
say. The same file gives the three menus the English menu's lines, with East and
504+
West apart and the time gate named "Puerta del tiempo".
505+
499506
### darkchronicle
500507

501508
```

‎port/src/script_text.cpp‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,35 @@ constexpr std::array<Line, 19> kS17Spanish{
6666
}
6767
};
6868

69+
// The Spanish jump gate menus (maps f04 and s30) put East and West on one line, "Puerta de salto Este --
70+
// Oeste", so they list one destination fewer than the script offers: the last choice is blank and the
71+
// ones after North take the player one destination further than they say. They get the English menu's
72+
// lines, with the time gate named as the Spanish text names it elsewhere.
73+
constexpr std::array<Line, 2> kF04Spanish{
74+
{
75+
{0x2CD20,
76+
"Selecciona Destino de la Puerta de salto\nPuerta de salto Norte\nPuerta de salto Este -- Oeste\nEnfrente de la Puerta de "
77+
"salto\nPuente de Paznos",
78+
"Selecciona Destino de la Puerta de salto\nPuerta de salto Norte\nPuerta de salto Este\nPuerta de salto Oeste\nEnfrente de "
79+
"la Puerta del tiempo\nPuente de Paznos"},
80+
{0x2CD98,
81+
"Selecciona Destino de la Puerta de salto\nPuerta de salto Norte\nPuerta de salto Este -- Oeste\nEnfrente de la Puerta de "
82+
"salto\n",
83+
"Selecciona Destino de la Puerta de salto\nPuerta de salto Norte\nPuerta de salto Este\nPuerta de salto Oeste\nEnfrente de "
84+
"la Puerta del tiempo"},
85+
}
86+
};
87+
88+
constexpr std::array<Line, 1> kS30Spanish{
89+
{
90+
{0x2FC94,
91+
"Selecciona Destino de la Puerta de salto\nPuerta de salto Norte\nPuerta de salto Este -- Oeste\nEnfrente de la Puerta de "
92+
"salto\n",
93+
"Selecciona Destino de la Puerta de salto\nPuerta de salto Norte\nPuerta de salto Este\nPuerta de salto Oeste\nEnfrente de "
94+
"la Puerta del tiempo"},
95+
}
96+
};
97+
6998
// The Spanish text of the Spheda lesson (event e314) says there is nothing more to remember right before
7099
// the colour rules, and gives a Sphere a black colour it never takes: it turns from blue to red and from
71100
// red to blue. The event files are Latin-1.
@@ -93,9 +122,11 @@ struct Script {
93122
std::span<const Line> lines;
94123
};
95124

96-
constexpr std::array<Script, 1> kScripts{
125+
constexpr std::array<Script, 3> kScripts{
97126
{
98127
{"map/s/s17/s17_5.stb", kS17Spanish},
128+
{"map/f/f04/f04_5.stb", kF04Spanish},
129+
{"map/s/s30/s30_5.stb", kS30Spanish},
99130
}
100131
};
101132

‎port/src/script_text.hpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// that shows it, the retail text it must find there and the text that replaces it. A replacement that
1212
// fits is written over the retail string; a longer one is appended after the script and the instruction
1313
// is pointed at it, so the file grows by Extra(key). A script that does not show every retail line is
14-
// left unchanged. The Spanish text of the Spheda lesson event (event/e300/e314/e314_5.txt) gets three
15-
// mistranslated lines corrected, each found by its exact text.
14+
// left unchanged. The Spanish jump gate menus of maps f04 and s30, which put East and West on one line
15+
// and so list a destination fewer than the script offers, get one line per destination the same way.
16+
// The Spanish text of the Spheda lesson event (event/e300/e314/e314_5.txt) gets three mistranslated
17+
// lines corrected, each found by its exact text.
1618

1719
namespace script_text {
1820

‎port/src/tests/script_text_test.cpp‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#include <gtest/gtest.h>
22

33
#include <algorithm>
4+
#include <array>
45
#include <cstdint>
56
#include <cstdlib>
67
#include <cstring>
78
#include <filesystem>
89
#include <fstream>
910
#include <iterator>
11+
#include <span>
1012
#include <string>
1113
#include <string_view>
14+
#include <utility>
1215
#include <vector>
1316

1417
#include "runscript.hpp"
@@ -138,6 +141,48 @@ TEST(ScriptText, ExtractedSpanishSphedaScriptMatches) {
138141
}
139142
}
140143

144+
TEST(ScriptText, SpanishJumpGateMenusListEveryDestination) {
145+
// The script offers five destinations in the first f04 menu and four in the others.
146+
const std::array<std::pair<std::string_view, std::size_t>, 3> menus{
147+
{{"map/f/f04/f04_5.stb", 5}, {"map/f/f04/f04_5.stb", 4}, {"map/s/s30/s30_5.stb", 4}}
148+
};
149+
const std::array<std::span<const script_text::Line>, 3> lines{
150+
script_text::Find(menus[0].first).first(1), script_text::Find(menus[1].first).subspan(1), script_text::Find(menus[2].first)};
151+
for (std::size_t i = 0; i < menus.size(); ++i) {
152+
ASSERT_EQ(lines[i].size(), 1u) << menus[i].first;
153+
const std::string_view text = lines[i].front().text;
154+
EXPECT_EQ(static_cast<std::size_t>(std::count(text.begin(), text.end(), '\n')), menus[i].second) << text;
155+
EXPECT_FALSE(text.ends_with('\n')) << text;
156+
EXPECT_LE(LongestLine(text), 40u) << text;
157+
}
158+
EXPECT_TRUE(script_text::Find("map/f/f04/f04_1.stb").empty());
159+
EXPECT_TRUE(script_text::Find("map/s/s30/s30_4.stb").empty());
160+
}
161+
162+
TEST(ScriptText, ExtractedSpanishJumpGateScriptsMatch) {
163+
const char *data = std::getenv("DC2_DATA");
164+
if (!data) {
165+
GTEST_SKIP() << "DC2_DATA supplies the extracted scripts";
166+
}
167+
for (const std::string_view key : {"map/f/f04/f04_5.stb", "map/s/s30/s30_5.stb"}) {
168+
const auto path = std::filesystem::path(data) / key;
169+
if (!std::filesystem::is_regular_file(path)) {
170+
GTEST_SKIP() << "DC2_DATA supplies the extracted scripts";
171+
}
172+
std::ifstream in(path, std::ios::binary);
173+
std::vector<unsigned char> bytes{std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>()};
174+
const std::size_t size = bytes.size();
175+
bytes.resize(size + script_text::Extra(key));
176+
177+
ASSERT_EQ(script_text::Patch(key, bytes.data(), size), bytes.size()) << key;
178+
const auto code = static_cast<std::size_t>(Read32(bytes, 8));
179+
for (const script_text::Line &line : script_text::Find(key)) {
180+
const std::size_t at = code + static_cast<std::size_t>(Read32(bytes, line.push + 8));
181+
EXPECT_EQ(std::string(reinterpret_cast<const char *>(bytes.data() + at)), line.text) << key;
182+
}
183+
}
184+
}
185+
141186
TEST(ScriptText, SpanishSphedaLessonTextIsCorrected) {
142187
constexpr std::string_view key = "event/e300/e314/e314_5.txt";
143188
std::string text = "@3140050\r\nNo tienes que acordarte de nada m\xe1s.\r\n@3140055\r\nDe azul a rojo, de negro a azul. "

0 commit comments

Comments
 (0)