BURIED: Rewrite the AI comment info data into an array

This cleans up the code and allows us to reuse this data
This commit is contained in:
Filippos Karapetis 2022-01-02 05:23:16 +02:00
parent d2b3bbd968
commit 660ce11b10
2 changed files with 36 additions and 144 deletions

View File

@ -2037,153 +2037,16 @@ bool SceneViewWindow::playAICommentFromData(const AIComment &commentData) {
Common::String commentFileName = "BITDATA/";
switch (commentData.location.timeZone) {
case 1: // Castle
commentFileName += "CASTLE/";
switch (commentData.location.environment) {
case 1:
commentFileName += "CGTT";
for (const AICommentInfo *info = s_aiCommentInfo; info->timeZone; ++info) {
if (info->timeZone == commentData.location.timeZone && info->environment == commentData.location.environment) {
commentFileName += info->filePath;
break;
case 2:
commentFileName += "CGTS";
break;
case 3:
commentFileName += "CGMW";
break;
case 4:
commentFileName += "CGMB";
break;
case 5:
commentFileName += "CGBS";
break;
case 6:
commentFileName += "CGKC";
break;
case 7:
commentFileName += "CGST";
break;
case 8:
commentFileName += "CGKS";
break;
case 9:
commentFileName += "CGSR";
break;
case 10:
commentFileName += "CGTR";
break;
default:
return false;
}
break;
case 2: // Mayan
commentFileName += "MAYAN/";
switch (commentData.location.environment) {
case 1:
commentFileName += "MYTP";
break;
case 2:
commentFileName += "MYMC";
break;
case 3:
commentFileName += "MYWG";
break;
case 4:
commentFileName += "MYWT";
break;
case 5:
commentFileName += "MYAG";
break;
case 6:
commentFileName += "MYDG";
break;
default:
return false;
}
break;
case 4: // Future Apartment
commentFileName += "FUTAPT/";
switch (commentData.location.environment) {
case 1:
commentFileName += "FAKI";
break;
case 2:
commentFileName += "FAER";
break;
case 3:
commentFileName += "FAMN";
break;
default:
return false;
}
break;
case 5: // Da Vinci
commentFileName += "DAVINCI/";
switch (commentData.location.environment) {
case 1:
commentFileName += "DSPT";
break;
case 2:
commentFileName += "DSCT";
break;
case 3:
commentFileName += "DSGD";
break;
case 4:
commentFileName += "DSWS";
break;
case 5:
commentFileName += "DSCY";
break;
default:
return false;
}
break;
case 6: // Space Station
commentFileName += "AILAB/";
switch (commentData.location.environment) {
case 1:
commentFileName += "AIHW";
break;
case 2:
commentFileName += "AICR";
break;
case 3:
commentFileName += "AIDB";
break;
case 4:
commentFileName += "AISC";
break;
case 5:
commentFileName += "AINX";
break;
case 6:
commentFileName += "AIIC";
break;
case 7:
commentFileName += "AISW";
break;
case 8:
commentFileName += "AIMR";
break;
case 9:
// There is no 9.
return false;
case 10:
commentFileName += "AIHW";
break;
default:
return false;
}
break;
default:
return false;
}
if (commentFileName == "BITDATA/")
return false;
commentFileName += "_";
if (commentData.commentFlags & AI_COMMENT_TYPE_INFORMATION)

View File

@ -162,6 +162,8 @@ public:
const SceneBase *getCurrentScene() const { return _currentScene; }
Common::Array<AIComment> getAICommentDatabase(int timeZone, int environment);
private:
Graphics::Surface *_preBuffer;
SceneBase *_currentScene;
@ -205,7 +207,6 @@ private:
SceneBase *constructSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation);
Common::Array<AnimEvent> getAnimationDatabase(int timeZone, int environment);
Common::Array<AIComment> getAICommentDatabase(int timeZone, int environment);
bool moveToDestination(const DestinationScene &destinationData, int navFrame);
@ -248,6 +249,34 @@ private:
SceneBase *constructAlienSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation);
};
struct AICommentInfo {
byte timeZone;
byte environment;
const char *filePath;
};
// timeZone, environment, filePath
static const AICommentInfo s_aiCommentInfo[] {
// Castle
{ 1, 1, "CASTLE/CGTT" }, { 1, 2, "CASTLE/CGTS" }, { 1, 3, "CASTLE/CGMW" },
{ 1, 4, "CASTLE/CGMB" }, { 1, 5, "CASTLE/CGBS" }, { 1, 6, "CASTLE/CGKC" },
{ 1, 7, "CASTLE/CGST" }, { 1, 8, "CASTLE/CGKS" }, { 1, 9, "CASTLE/CGSR" },
{ 1, 10, "CASTLE/CGTR" },
// Mayan
{ 2, 1, "MAYAN/MYTP" }, { 2, 2, "MAYAN/MYMC" }, { 2, 3, "MAYAN/MYWG" },
{ 2, 4, "MAYAN/MYWT" }, { 2, 5, "MAYAN/MYAG" }, { 2, 6, "MAYAN/MYDG" },
// Future Apartment
{ 4, 1, "FUTAPT/FAKI" }, { 4, 2, "FUTAPT/FAER" }, { 4, 3, "FUTAPT/FAMN" },
// Da Vinci
{ 5, 1, "DAVINCI/DSPT" }, { 5, 2, "DAVINCI/DSCT" }, { 5, 3, "DAVINCI/DSGD" },
{ 5, 4, "DAVINCI/DSWS" }, { 5, 5, "DAVINCI/DSCY" },
// Space Station
{ 6, 1, "AILAB/AIHW" }, { 6, 2, "AILAB/AICR" }, { 6, 3, "AILAB/AIDB" },
{ 6, 4, "AILAB/AISC" }, { 6, 5, "AILAB/AINX" }, { 6, 6, "AILAB/AIIC" },
{ 6, 7, "AILAB/AISW" }, { 6, 8, "AILAB/AIMR" }, { 6, 10, "AILAB/AIHW" }, // there is no 9
{ 0, 0, "" }
};
} // End of namespace Buried
#endif