mirror of
https://github.com/scummvm/scummvm.git
synced 2026-05-21 05:40:43 +00:00
TEENAGENT: Use custom language IDs for teenagent.dat
We were using the Common::Language value to identify language blocks
in the teenagent.dat file. But that meant that modifying the enum
would cause the dat file to become obsolete and the engine to fail
to find some language block. This recently happened with commit
13b659b that added Canadian French to Common::Language.
This commit introduces custom language IDs that match the
Common::Language values at the time teenagent.dat was last
generated, This means we do not need to generate it again with
those changes.
This fixes bug #16568.
This commit is contained in:
@@ -42,7 +42,7 @@ void writeStringsBlock(FILE *fd, const char **stringArr, uint size) {
|
||||
}
|
||||
}
|
||||
|
||||
void writeCombinations(FILE *fd, Common::Language language) {
|
||||
void writeCombinations(FILE *fd, Language language) {
|
||||
const char **combineMessages = englishCombineMessages;
|
||||
if (language == CS_CZE)
|
||||
combineMessages = czechCombineMessages;
|
||||
@@ -64,7 +64,7 @@ void writeCombinations(FILE *fd, Common::Language language) {
|
||||
}
|
||||
}
|
||||
|
||||
void writeDialogStacks(FILE *fd, Common::Language language) {
|
||||
void writeDialogStacks(FILE *fd, Language language) {
|
||||
const char ***dialogs = englishDialogs;
|
||||
if (language == CS_CZE)
|
||||
dialogs = czechDialogs;
|
||||
@@ -108,7 +108,7 @@ void writeDialogStacks(FILE *fd, Common::Language language) {
|
||||
}
|
||||
}
|
||||
|
||||
void writeDialogs(FILE *fd, Common::Language language) {
|
||||
void writeDialogs(FILE *fd, Language language) {
|
||||
const char ***dialogs = englishDialogs;
|
||||
if (language == CS_CZE)
|
||||
dialogs = czechDialogs;
|
||||
@@ -153,7 +153,7 @@ void writeDialogs(FILE *fd, Common::Language language) {
|
||||
}
|
||||
}
|
||||
|
||||
void writeItems(FILE *fd, Common::Language language) {
|
||||
void writeItems(FILE *fd, Language language) {
|
||||
const char ***items = englishItems;
|
||||
if (language == CS_CZE)
|
||||
items = czechItems;
|
||||
@@ -195,7 +195,7 @@ void writeItems(FILE *fd, Common::Language language) {
|
||||
}
|
||||
}
|
||||
|
||||
void writeSceneObjects(FILE *fd, Common::Language language) {
|
||||
void writeSceneObjects(FILE *fd, Language language) {
|
||||
Common::Array<Common::Array<ObjectNameDesc>> *objNamesDescs = &englishSceneObjectNamesDescs;
|
||||
SettableObjectName *settableSceneObjects = englishSettableObjectNames;
|
||||
|
||||
@@ -311,7 +311,7 @@ void writeSceneObjects(FILE *fd, Common::Language language) {
|
||||
fseek(fd, pos, SEEK_SET);
|
||||
}
|
||||
|
||||
uint32 writeResource(FILE *fd, ResourceType resType, Common::Language language) {
|
||||
uint32 writeResource(FILE *fd, ResourceType resType, Language language) {
|
||||
uint prevFilePos = ftell(fd);
|
||||
|
||||
switch (resType) {
|
||||
@@ -401,7 +401,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
writeUint32LE(fout, 0);
|
||||
}
|
||||
writeByte(fout, (byte)Common::Language::UNK_LANG);
|
||||
writeByte(fout, (byte)0xff);
|
||||
|
||||
for (uint lang = 0; lang < NUM_LANGS; lang++) {
|
||||
// Write offset to data
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#ifndef CREATE_TEENAGENT_H
|
||||
#define CREATE_TEENAGENT_H
|
||||
|
||||
#include "common/language.h"
|
||||
#include "util.h"
|
||||
|
||||
#define TEENAGENT_DAT_VERSION 6
|
||||
@@ -46,7 +45,17 @@ struct ResourceInfo {
|
||||
#define NUM_RESOURCES 7
|
||||
#define NUM_LANGS 4
|
||||
|
||||
const Common::Language supportedLanguages[NUM_LANGS] = {
|
||||
// If you are adding a new language here, make sure to sync with teenagent/resources.h
|
||||
// enum in DataLanguage around line 1165
|
||||
|
||||
enum Language : byte {
|
||||
CS_CZE = 3,
|
||||
EN_ANY = 7,
|
||||
PL_POL = 27,
|
||||
RU_RUS = 30,
|
||||
};
|
||||
|
||||
const Language supportedLanguages[NUM_LANGS] = {
|
||||
CS_CZE,
|
||||
EN_ANY,
|
||||
PL_POL,
|
||||
|
||||
@@ -347,6 +347,14 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
|
||||
|
||||
// Locate the correct language block
|
||||
bool found = false;
|
||||
byte datLang = 0;
|
||||
switch (gd->language) {
|
||||
case Common::CS_CZE: datLang = DataLanguage::CS_CZE; break;
|
||||
case Common::EN_ANY: datLang = DataLanguage::EN_ANY; break;
|
||||
case Common::PL_POL: datLang = DataLanguage::PL_POL; break;
|
||||
case Common::RU_RUS: datLang = DataLanguage::RU_RUS; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
while (!found) {
|
||||
dat->read(tempBuffer, 5);
|
||||
@@ -354,7 +362,7 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
|
||||
error("Could not locate correct language block");
|
||||
}
|
||||
|
||||
if (gd->language == tempBuffer[0]) {
|
||||
if (datLang == tempBuffer[0]) {
|
||||
found = true;
|
||||
uint32 dataOffset = READ_LE_UINT32(&tempBuffer[1]);
|
||||
dat->seek(dataOffset);
|
||||
|
||||
@@ -1162,6 +1162,17 @@ const uint16 dsAddr_finalCredits7 = 0xe488; // "programming..."
|
||||
|
||||
const byte kNumDialogStacks = 26;
|
||||
|
||||
// Values in the enum below should match those defined in the Language enum
|
||||
// in create_teenagent.h
|
||||
namespace DataLanguage {
|
||||
enum : byte {
|
||||
CS_CZE = 3,
|
||||
EN_ANY = 7,
|
||||
PL_POL = 27,
|
||||
RU_RUS = 30,
|
||||
};
|
||||
}
|
||||
|
||||
enum MessageType{
|
||||
kRejectMsg0 = 0,
|
||||
kRejectMsg1,
|
||||
|
||||
Reference in New Issue
Block a user