@@ -49,30 +49,6 @@ QString CPlayError::deriveSecondary() const { return mSpecific; }
4949// Public:
5050CPlay::CPlay (Core& coreRef, const QStringList& commandLine) : TitleCommand(coreRef, commandLine) {}
5151
52- // -Class Functions---------------------------------------------------------------
53- // Private:
54- Fp::AddApp CPlay::buildAdditionalApp (const Fp::Db::QueryBuffer& addAppResult)
55- {
56- // Ensure query result is additional app
57- assert (addAppResult.source == Fp::Db::Table_Add_App::NAME);
58-
59- /* Form additional app from record
60- *
61- * Most of the descriptive fields here are not required for this app, but include them anyway in case it's later
62- * desired to use them for something like logging.
63- */
64- Fp::AddApp::Builder fpAab;
65- fpAab.wId (addAppResult.result .value (Fp::Db::Table_Add_App::COL_ID).toString ());
66- fpAab.wAppPath (addAppResult.result .value (Fp::Db::Table_Add_App::COL_APP_PATH).toString ());
67- fpAab.wAutorunBefore (addAppResult.result .value (Fp::Db::Table_Add_App::COL_AUTORUN).toString ());
68- fpAab.wLaunchCommand (addAppResult.result .value (Fp::Db::Table_Add_App::COL_LAUNCH_COMMAND).toString ());
69- fpAab.wName (addAppResult.result .value (Fp::Db::Table_Add_App::COL_NAME).toString ().remove (Qx::RegularExpression::LINE_BREAKS));
70- fpAab.wWaitExit (addAppResult.result .value (Fp::Db::Table_Add_App::COL_WAIT_EXIT).toString ());
71- fpAab.wParentId (addAppResult.result .value (Fp::Db::Table_Add_App::COL_PARENT_ID).toString ());
72-
73- return fpAab.build ();
74- }
75-
7652// -Instance Functions-------------------------------------------------------------
7753// Private:
7854void CPlay::addExtraExecParameters (TExec* execTask, Task::Stage taskStage)
@@ -122,7 +98,7 @@ void CPlay::addExtraExecParameters(TExec* execTask, Task::Stage taskStage)
12298
12399QString CPlay::getServerOverride (const Fp::GameData& gd)
124100{
125- QString override = gd.isNull () ? QString () : gd.parameters ().server ();
101+ QString override = gd.isNull () ? QString () : gd.parsedParameters ().server ();
126102 if (!override .isNull ())
127103 logEvent (LOG_EVENT_SERVER_OVERRIDE.arg (override ));
128104
@@ -192,33 +168,23 @@ Qx::Error CPlay::handleEntry(const Fp::Game& game)
192168 }
193169
194170 // Get game's additional apps
195- Fp::Db::EntryFilter addAppFilter{.type = Fp::Db::EntryType::AddApp, .parent = game.id ()};
196-
197- Fp::DbError addAppSearchError;
198- Fp::Db::QueryBuffer addAppSearchResult;
199-
200- addAppSearchError = db->queryEntrys (addAppSearchResult, addAppFilter);
201- if (addAppSearchError.isValid ())
171+ Fp::Db::AddAppFilter aaf{.parent = game.id ()};
172+ QList<Fp::AddApp> addAppSearchResult;
173+ if (auto err = db->searchAddApps (addAppSearchResult, aaf); err.isValid ())
202174 {
203- postDirective<DError>(addAppSearchError );
204- return addAppSearchError ;
175+ postDirective<DError>(err );
176+ return err ;
205177 }
206178
207179 // Enqueue auto-run before apps
208- for (int i = 0 ; i < addAppSearchResult. size ; i++ )
180+ for (const auto & aa : std::as_const ( addAppSearchResult) )
209181 {
210- // Go to next record
211- addAppSearchResult.result .next ();
212-
213- // Build
214- Fp::AddApp addApp = buildAdditionalApp (addAppSearchResult);
215-
216182 // Enqueue if auto-run before
217- if (addApp .isAutorunBefore ())
183+ if (aa .isAutorunBefore ())
218184 {
219- logEvent (LOG_EVENT_FOUND_AUTORUN.arg (addApp .name ()));
185+ logEvent (LOG_EVENT_FOUND_AUTORUN.arg (aa .name ()));
220186
221- if (sError = enqueueAdditionalApp (addApp , game, Task::Stage::Auxiliary); sError .isValid ())
187+ if (sError = enqueueAdditionalApp (aa , game, Task::Stage::Auxiliary); sError .isValid ())
222188 return sError ;
223189 }
224190 }
@@ -237,24 +203,21 @@ Qx::Error CPlay::handleEntry(const Fp::Game& game)
237203Qx::Error CPlay::handleEntry (const Fp::AddApp& addApp)
238204{
239205 logEvent (LOG_EVENT_ID_MATCH_ADDAPP.arg (addApp.name (),
240- addApp.parentId ().toString (QUuid::WithoutBraces)));
206+ addApp.parentGameId ().toString (QUuid::WithoutBraces)));
241207
242208 Qx::Error sError ;
243209 Fp::Db* db = mCore .fpInstall ().database ();
244210
245211 // Get parent info
246- QUuid parentId = addApp.parentId ();
247- Fp::Entry parentEntry;
212+ QUuid parentId = addApp.parentGameId ();
248213 Fp::Game parentGame;
249214 Fp::GameData parentGameData;
250215
251- if (Fp::DbError gdErr = db->getEntry (parentEntry , parentId); gdErr.isValid ())
216+ if (Fp::DbError gdErr = db->getGame (parentGame , parentId); gdErr.isValid ())
252217 {
253218 postDirective<DError>(gdErr);
254219 return gdErr;
255220 }
256- Q_ASSERT (std::holds_alternative<Fp::Game>(parentEntry));
257- parentGame = std::get<Fp::Game>(parentEntry);
258221
259222 if (Fp::DbError gdErr = db->getGameData (parentGameData, parentId); gdErr.isValid ())
260223 {
@@ -269,8 +232,7 @@ Qx::Error CPlay::handleEntry(const Fp::AddApp& addApp)
269232 QString serverOverride = getServerOverride (parentGameData);
270233
271234 // Enqueue services if needed
272- bool needsServices = addApp.appPath () != Fp::Db::Table_Add_App::ENTRY_MESSAGE && addApp.appPath () != Fp::Db::Table_Add_App::ENTRY_EXTRAS;
273- if (needsServices && (sError = mCore .enqueueStartupTasks (serverOverride)).isValid ())
235+ if (addApp.isPlayable () && (sError = mCore .enqueueStartupTasks (serverOverride)).isValid ())
274236 return sError ;
275237
276238 // Handle datapack tasks
@@ -288,24 +250,24 @@ Qx::Error CPlay::handleEntry(const Fp::AddApp& addApp)
288250 return sError ;
289251
290252 // Enqueue service shutdown if needed
291- if (needsServices )
253+ if (addApp. isPlayable () )
292254 mCore .enqueueShutdownTasks ();
293255
294256 return Qx::Error ();
295257}
296258
297259Qx::Error CPlay::enqueueAdditionalApp (const Fp::AddApp& addApp, const Fp::Game& parent, Task::Stage taskStage)
298260{
299- if (addApp.appPath () == Fp::Db::Table_Add_App::ENTRY_MESSAGE )
261+ if (addApp.isMessage () )
300262 {
301263 TMessage* messageTask = new TMessage (mCore );
302264 messageTask->setStage (taskStage);
303265 messageTask->setText (addApp.launchCommand ());
304- messageTask->setBlocking (addApp.isWaitExit ());
266+ messageTask->setBlocking (addApp.isWaitForExit ());
305267
306268 mCore .enqueueSingleTask (messageTask);
307269 }
308- else if (addApp.appPath () == Fp::Db::Table_Add_App::ENTRY_EXTRAS )
270+ else if (addApp.isExtra () )
309271 {
310272 TExtra* extraTask = new TExtra (mCore );
311273 extraTask->setStage (taskStage);
@@ -351,7 +313,7 @@ Qx::Error CPlay::enqueueGame(const Fp::Game& game, const Fp::GameData& gameData,
351313
352314TExec* CPlay::createStdGameExecTask (const Fp::Game& game, const Fp::GameData& gameData, Task::Stage taskStage)
353315{
354- QString gamePath = mCore .resolveFullAppPath (!gameData.isNull () ? gameData.appPath () : game.appPath (),
316+ QString gamePath = mCore .resolveFullAppPath (!gameData.isNull () ? gameData.applicationPath () : game.applicationPath (),
355317 game.platformName ());
356318 QFileInfo gamePathInfo (gamePath);
357319 QString param = !gameData.isNull () ? gameData.launchCommand () : game.launchCommand ();
@@ -370,7 +332,7 @@ TExec* CPlay::createStdGameExecTask(const Fp::Game& game, const Fp::GameData& ga
370332
371333TExec* CPlay::createStdAddAppExecTask (const Fp::AddApp& addApp, const Fp::Game& parent, Task::Stage taskStage)
372334{
373- QString addAppPath = mCore .resolveFullAppPath (addApp.appPath (), parent.platformName ());
335+ QString addAppPath = mCore .resolveFullAppPath (addApp.applicationPath (), parent.platformName ());
374336 QFileInfo addAppPathInfo (addAppPath);
375337 QString param = addApp.launchCommand ();
376338
@@ -381,7 +343,7 @@ TExec* CPlay::createStdAddAppExecTask(const Fp::AddApp& addApp, const Fp::Game&
381343 addAppTask->setDirectory (addAppPathInfo.absoluteDir ());
382344 addAppTask->setParameters (param);
383345 addAppTask->setEnvironment (mCore .childTitleProcessEnvironment ());
384- addAppTask->setProcessType (addApp.isWaitExit () || taskStage == Task::Stage::Primary ? TExec::ProcessType::Blocking : TExec::ProcessType::Deferred);
346+ addAppTask->setProcessType (addApp.isWaitForExit () || taskStage == Task::Stage::Primary ? TExec::ProcessType::Blocking : TExec::ProcessType::Deferred);
385347
386348 return addAppTask;
387349}
@@ -475,7 +437,7 @@ Qx::Error CPlay::perform()
475437 }
476438
477439 // Handle entry
478- return std:: visit ([this ](auto arg) { return this ->handleEntry (arg); }, entry );
440+ return entry. visit ([this ](auto arg) { return this ->handleEntry (arg); });
479441}
480442
481443// Public:
0 commit comments