File: detection.cpp

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (220 lines) | stat: -rw-r--r-- 7,369 bytes parent folder | download | duplicates (2)
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
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "base/plugins.h"
#include "engines/advancedDetector.h"

#include "common/config-manager.h"
#include "common/file.h"

#include "mtropolis/detection.h"

static const PlainGameDescriptor mTropolisGames[] = {
	{"obsidian", "Obsidian"},
	{"mti", "Muppet Treasure Island"},
	{"albert1", "Uncle Albert's Magical Album"},
	{"albert2", "Uncle Albert's Fabulous Voyage"},
	{"albert3", "Uncle Albert's Mysterious Island"},
	{"spqr", "SPQR: The Empire's Darkest Hour"},
	{"sttgs", "Star Trek: The Game Show"},
	{"unit", "Unit: Re-Booted"},
	{"mindgym", "Mind Gym"},
	{"architecture", "Fun With Architecture"},
	{"beatrix", "The Magic World of Beatrix Potter"},
	{"wtimpact", "Whitetail Impact"},
	{"worldbroke", "The Day The World Broke"},
	{"dilbert", "The Totally Techie World of Young Dilbert: Hi-Tech Hijinks"},
	{"freewilly", "Free Willy Activity Center"},
	{"hercules", "Hercules & Xena Learning Adventure: Quest for the Scrolls"},
	{"idino", "I Can Be a Dinosaur Finder"},
	{"idoctor", "I Can Be an Animal Doctor"},
	{"drawmarvelway", "How to Draw the Marvel Way"},
	{"ftts", "FairyTale: A True Story - Activity Center"},
	{"purplemoon", "Purple Moon Sampler"},
	{"chomp", "Chomp! The Video Game"},
	{"cyber24", "24 Hours in Cyberspace"},
	{"ivoclar", "IVOCLAR"},
	{"realwild", "Real Wild Child! Australian Rock Music 1950s-90s"},
	{"telemed", "How to Build a Telemedicine Program"},
	{"angelica", "Rugrats: Totally Angelica Boredom Buster"},
	{"babe", "Babe and Friends: Animated Early Reader"},
	{"biocellevo", "Biologia Cellulare Evoluzione E Variet\xc3\xa0 Della Vita"},
	{"easybake", "Easy-Bake Kitchen"},
	{"forgotten", "The Forgotten: It Begins"},
	{"greveholm2", "The Mystery at Greveholm 2: The Journey to Planutus"},
	{"itacante", "Itacante: La Cit\xc3\xa9 des Robots"},
	{"kingofdragonpass", "King of Dragon Pass"},
	{"ks1eng", "The Times Key Stage 1 English"},
	{"maisy", "Maisy's Playhouse"},
	{"msb_animal", "The Magic School Bus Explores the World of Animals"},
	{"msb_bugs", "The Magic School Bus Explores Bugs"},
	{"msb_concert", "The Magic School Bus In Concert"},
	{"msb_flight", "The Magic School Bus Discovers Flight"},
	{"msb_mars", "The Magic School Bus Lands on Mars"},
	{"msb_volcano", "The Magic School Bus Volcano Adventure"},
	{"msb_whales", "The Magic School Bus Whales & Dolphins"},
	{"mykropolis", "Mykropolis: Planet der Roboter"},
	{"notebook", "Your Notebook (with help from Amelia)"},
	{"pferdpony", "Pferd & Pony: Lass uns reiten"},
	{"mirodc10", "Pinnacle Systems miroVideo Studio DC10 Plus Tour"},
	{"poser3_sampler_zygote", "Poser 3 Zygote Sampler Disc"},
	{"poser3_zygote", "Poser 3 Zygote Promo"},
	{"wtextreme", "Whitetail Extreme"},
	{"c9sampler", "Cloud 9 CD Sampler Volume 2"},
	{"adobe24", "Adobe 24 Hours Tools Sampler"},
	{"byzantine", "Byzantine: The Betrayal"},


	{"mtropolis", "mTropolis Title"},
	{nullptr, nullptr}
};

#include "mtropolis/detection_tables.h"

static const char *const directoryGlobs[] = {
	"Obsidian",
	"RESOURCE",
	"mPlugins",
	"Saved Games",
	"MTPLAY32",
	"HIJINKS",
	"Albert",
	"DATA",
	"GAME",
	"Player",
	"mfx",
	"cdData",
	"Opal",
	"MSB",
	"System",
	"YN",
	"planutus",
	nullptr
};

class MTropolisMetaEngineDetection : public AdvancedMetaEngineDetection<MTropolis::MTropolisGameDescription> {
public:
	MTropolisMetaEngineDetection() : AdvancedMetaEngineDetection(MTropolis::gameDescriptions, mTropolisGames) {
		_guiOptions = GUIO3(GAMEOPTION_DYNAMIC_MIDI, GAMEOPTION_LAUNCH_DEBUG, GAMEOPTION_ENABLE_SHORT_TRANSITIONS);
		_maxScanDepth = 3;
		_directoryGlobs = directoryGlobs;
		_flags = kADFlagCanPlayUnknownVariants;
	}

	const char *getName() const override {
		return "mtropolis";
	}

	const char *getEngineName() const override {
		return "mTropolis";
	}

	const char *getOriginalCopyright() const override {
		return "mTropolis (C) mFactory/Quark";
	}
	
	ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **extra) const override;

	static MTropolis::MTropolisGameDescription _globalFallbackDesc;
};

ADDetectedGame MTropolisMetaEngineDetection::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **outExtra) const {
	const char *winBootFileName = MTROPOLIS_WIN_BOOT_SCRIPT_NAME;
	const char *macBootFileName = MTROPOLIS_MAC_BOOT_SCRIPT_NAME;

	FileMap::const_iterator macBootScriptIt = allFiles.find(macBootFileName);
	FileMap::const_iterator winBootScriptIt = allFiles.find(winBootFileName);

	bool foundMac = (macBootScriptIt != allFiles.end());
	bool foundWin = (winBootScriptIt != allFiles.end());

	if (foundMac && foundWin) {
		warning("Found both %s and %s, need exactly one or the other to boot a mTropolis project", winBootFileName, macBootFileName);
		return ADDetectedGame();
	}

	if (!foundMac && !foundWin)
		return ADDetectedGame();

	MTropolis::MTropolisGameDescription *desc = &_globalFallbackDesc;

	if (foundWin) {
		desc->desc.platform = Common::kPlatformWindows;
	} else if (foundMac) {
		desc->desc.platform = Common::kPlatformMacintosh;
	}

	if (outExtra) {
		const Common::FSNode *bootScriptFile = nullptr;

		if (foundMac)
			bootScriptFile = &macBootScriptIt->_value;
		if (foundWin)
			bootScriptFile = &winBootScriptIt->_value;

		Common::File f;
		if (bootScriptFile && f.open(*bootScriptFile)) {
			Common::String targetID = "mtropolis-fallback";
			Common::String gameName = foundWin ? "Windows mTropolis Title" : "Macintosh mTropolis Title";

			Common::String lineStr;
			while (!f.err() && !f.eos()) {
				lineStr = f.readString('\n');
				lineStr.trim();

				const char *targetIDPrefix = "//targetID:";
				const char *gameNamePrefix = "//gameName:";

				if (lineStr.hasPrefix(targetIDPrefix))
					targetID = lineStr.substr(strlen(targetIDPrefix));
				else if (lineStr.hasPrefix(gameNamePrefix))
					gameName = lineStr.substr(strlen(gameNamePrefix));
			}

			ADDetectedGameExtraInfo *extraInfo = new ADDetectedGameExtraInfo();
			extraInfo->gameName = gameName;
			extraInfo->targetID = targetID;

			*outExtra = extraInfo;
		}
	}

	return ADDetectedGame(&desc->desc);
}

MTropolis::MTropolisGameDescription MTropolisMetaEngineDetection::_globalFallbackDesc = {
	{
		"mtropolis",
		"",
		{
			AD_LISTEND
		},
		Common::UNK_LANG,
		Common::kPlatformWindows,
		ADGF_NO_FLAGS,
		GUIO0()
	},
	MTropolis::GID_GENERIC,
	0,
	MTropolis::MTBOOT_USE_BOOT_SCRIPT,
};

REGISTER_PLUGIN_STATIC(MTROPOLIS_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, MTropolisMetaEngineDetection);