diff --git a/doomsday/apps/plugins/common/src/game/g_game.cpp b/doomsday/apps/plugins/common/src/game/g_game.cpp index 533b718fc3..5fc143427a 100644 --- a/doomsday/apps/plugins/common/src/game/g_game.cpp +++ b/doomsday/apps/plugins/common/src/game/g_game.cpp @@ -466,15 +466,7 @@ void R_LoadColorPalettes() { if (i == numPerClass) break; // Not present. - String lumpName; - if (xlatNum < 10) - { - lumpName = String("TRANTBL%1").arg(xlatNum); - } - else - { - lumpName = String("TRANTBL%1").arg('A' + (xlatNum - 10)); - } + String lumpName = String::format("TRANTBL%X", xlatNum); xlatNum++; LOG_AS("R_LoadColorPalettes") @@ -3047,8 +3039,7 @@ static void registerGameStatusCVars() // Fourth-weapon pieces: for (int i = 0; i < WEAPON_FOURTH_PIECE_COUNT; ++i) { - Block const cvarName = String("player-weapon-piece%1").arg(i + 1).toUtf8(); - C_VAR_INT(cvarName.constData(), &gsvWPieces[i], READONLYCVAR, 0, 1); + C_VAR_INT(String::format("player-weapon-piece%i", i + 1), &gsvWPieces[i], READONLYCVAR, 0, 1); } C_VAR_INT("player-weapon-allpieces", &gsvWPieces[WEAPON_FOURTH_PIECE_COUNT], READONLYCVAR, 0, 1); #endif diff --git a/doomsday/apps/plugins/common/src/game/gamesession.cpp b/doomsday/apps/plugins/common/src/game/gamesession.cpp index 06d89865d9..09f9c308bd 100644 --- a/doomsday/apps/plugins/common/src/game/gamesession.cpp +++ b/doomsday/apps/plugins/common/src/game/gamesession.cpp @@ -103,7 +103,7 @@ namespace internal using namespace internal; -static String const internalSavePath = "/home/cache/internal.save"; +DE_STATIC_STRING(internalSavePath, "/home/cache/internal.save"); static GameSession theSession; DE_PIMPL(GameSession) @@ -130,13 +130,13 @@ DE_PIMPL(GameSession) void cleanupInternalSave() { // Ensure the internal save folder exists. - App::fileSystem().makeFolder(internalSavePath.fileNamePath()); + App::fileSystem().makeFolder(internalSavePath().fileNamePath()); // Ensure that any pre-existing internal save is destroyed. // This may happen if the game was not shutdown properly in the event of a crash. /// @todo It may be possible to recover this session if it was written successfully /// before the fatal error occurred. - AbstractSession::removeSaved(internalSavePath); + AbstractSession::removeSaved(internalSavePath()); } void resetStateForNewSession() @@ -532,19 +532,19 @@ DE_PIMPL(GameSession) self().setInProgress(false); - if (savePath.compareWithoutCase(internalSavePath)) + if (savePath.compareWithoutCase(internalSavePath())) { // Perform necessary prep. cleanupInternalSave(); // Copy the save to the internal savegame. - AbstractSession::copySaved(internalSavePath, savePath); + AbstractSession::copySaved(internalSavePath(), savePath); } // // GameStateFolder deserialization begins. // - auto const &saved = App::rootFolder().locate(internalSavePath); + auto const &saved = App::rootFolder().locate(internalSavePath()); GameStateMetadata const &metadata = saved.metadata(); // Ensure a complete game ruleset is available. @@ -693,7 +693,7 @@ DE_PIMPL(GameSession) #endif String const mapUriAsText = self().mapUri().compose(); - auto const &saved = App::rootFolder().locate(internalSavePath); + auto const &saved = App::rootFolder().locate(internalSavePath()); std::unique_ptr reader(makeMapStateReader(saved, mapUriAsText)); self().setThinkerMapping(reader.get()); reader->read(mapUriAsText); @@ -1054,7 +1054,7 @@ void GameSession::end() G_ResetViewEffects(); } - AbstractSession::removeSaved(internalSavePath); + AbstractSession::removeSaved(internalSavePath()); setInProgress(false); LOG_MSG("Game ended"); @@ -1123,7 +1123,7 @@ void GameSession::begin(GameRules const &newRules, String const &episodeId, d->reloadMap(); // Create the internal .save session package. - d->updateGameStateFolder(internalSavePath, metadata); + d->updateGameStateFolder(internalSavePath(), metadata); } void GameSession::reloadMap() @@ -1138,7 +1138,7 @@ void GameSession::reloadMap() { try { - d->loadSaved(internalSavePath); + d->loadSaved(internalSavePath()); return; } catch (Error const &er) @@ -1164,7 +1164,7 @@ void GameSession::reloadMap() d->reloadMap(); // Create the internal .save session package. - d->updateGameStateFolder(internalSavePath, d->metadata()); + d->updateGameStateFolder(internalSavePath(), d->metadata()); ::briefDisabled = oldBriefDisabled; } @@ -1202,7 +1202,7 @@ void GameSession::leaveMap(res::Uri const &nextMapUri, uint nextMapEntryPoint) GameStateFolder *saved = nullptr; if (!d->rules.values.deathmatch) // Never save in deathmatch. { - saved = &App::rootFolder().locate(internalSavePath); + saved = &App::rootFolder().locate(internalSavePath()); auto &mapsFolder = saved->locate("maps"); DE_ASSERT(saved->mode().testFlag(File::Write)); @@ -1323,7 +1323,7 @@ void GameSession::leaveMap(res::Uri const &nextMapUri, uint nextMapEntryPoint) String GameSession::userDescription() { if (!hasBegun()) return ""; - return App::rootFolder().locate(internalSavePath) + return App::rootFolder().locate(internalSavePath()) .metadata().gets("userDescription", ""); } @@ -1356,13 +1356,13 @@ void GameSession::save(String const &saveName, String const &userDescription) metadata.set("userDescription", chooseSaveDescription(savePath, userDescription)); // Update the existing internal .save package. - d->updateGameStateFolder(internalSavePath, metadata); + d->updateGameStateFolder(internalSavePath(), metadata); // In networked games the server tells the clients to save also. NetSv_SaveGame(metadata.getui("sessionId")); // Copy the internal saved session to the destination slot. - AbstractSession::copySaved(savePath, internalSavePath); + AbstractSession::copySaved(savePath, internalSavePath()); P_SetMessage(&players[CONSOLEPLAYER], TXT_GAMESAVED); diff --git a/doomsday/apps/plugins/common/src/game/saveslots.cpp b/doomsday/apps/plugins/common/src/game/saveslots.cpp index d4d4f71fa6..7558f2cc8c 100644 --- a/doomsday/apps/plugins/common/src/game/saveslots.cpp +++ b/doomsday/apps/plugins/common/src/game/saveslots.cpp @@ -201,7 +201,7 @@ void SaveSlots::Slot::setGameStateFolder(GameStateFolder *newSession) String statusText; if (d->session) { - statusText = String("associated with \"%1\"").arg(d->session->path()); + statusText = String::format("associated with \"%s\"", d->session->path().c_str()); } else { @@ -299,7 +299,7 @@ DE_PIMPL(SaveSlots) void setAllIndexedSaves() { auto const &index = SaveGames::get().saveIndex(); - foreach (File *file, index.files()) + for (File *file : index.files()) { fileAdded(*file, index); } diff --git a/doomsday/apps/plugins/common/src/hu_menu.cpp b/doomsday/apps/plugins/common/src/hu_menu.cpp index e361fa55c1..ecb9acab37 100644 --- a/doomsday/apps/plugins/common/src/hu_menu.cpp +++ b/doomsday/apps/plugins/common/src/hu_menu.cpp @@ -2188,7 +2188,7 @@ void Hu_MenuInitPlayerClassPage() btn->setFixedY(y); btn->setAction(Widget::Deactivated, Hu_MenuSelectPlayerClass); btn->setAction(Widget::FocusGained, Hu_MenuFocusOnPlayerClass); - btn->setUserValue2(int(info->plrClass)); + btn->setUserValue2(NumberValue(info->plrClass)); btn->setFont(MENU_FONT1); page->addWidget(btn); @@ -2197,11 +2197,11 @@ void Hu_MenuInitPlayerClassPage() // Random class button. String const labelText = GET_TXT(TXT_RANDOMPLAYERCLASS); - int const shortcut = iswlanum(labelText.first())? labelText.first() : 0; + int const shortcut = iswalnum(labelText.first())? labelText.first() : 0; page->addWidget(new ButtonWidget(labelText)) .setFixedY(y) .setShortcut(shortcut) - .setUserValue2(int(PCLASS_NONE)) + .setUserValue2(NumberValue(PCLASS_NONE)) .setFont(MENU_FONT1) .setColor(MENU_COLOR1) .setAction(Widget::Deactivated, Hu_MenuSelectPlayerClass) @@ -2957,7 +2957,7 @@ void Hu_MenuPlayerClassBackgroundTicker(Widget &wi) /// state through a focus action. if(Widget *mop = wi.page().focusWidget()) { - playerclass_t pClass = playerclass_t(mop->userValue2().toInt()); + playerclass_t pClass = playerclass_t(mop->userValue2().asInt()); if(pClass == PCLASS_NONE) { // Random class. @@ -2985,7 +2985,7 @@ void Hu_MenuPlayerClassPreviewTicker(Widget &wi) /// state through a focus action. if(Widget *mop = wi.page().focusWidget()) { - playerclass_t pClass = playerclass_t(mop->userValue2().toInt()); + playerclass_t pClass = playerclass_t(mop->userValue2().asInt()); if(pClass == PCLASS_NONE) { // Random class. @@ -3495,7 +3495,7 @@ void Hu_MenuSelectSaveGame(Widget & /*wi*/, Widget::Action action) void Hu_MenuSelectPlayerClass(Widget &wi, Widget::Action action) { Page &skillPage = Hu_MenuPage("Skill"); - int option = wi.userValue2().toInt(); + int option = wi.userValue2().asInt(); if(action != Widget::Deactivated) return; diff --git a/doomsday/apps/plugins/common/src/hud/widgets/chainwidget.cpp b/doomsday/apps/plugins/common/src/hud/widgets/chainwidget.cpp index 35d3a3de55..d9ab74fddc 100644 --- a/doomsday/apps/plugins/common/src/hud/widgets/chainwidget.cpp +++ b/doomsday/apps/plugins/common/src/hud/widgets/chainwidget.cpp @@ -409,21 +409,21 @@ void guidata_chain_t::prepareAssets() ::pGem[PCLASS_FIGHTER][0] = R_DeclarePatch("LIFEGEM"); for(dint i = 1; i < NUMTEAMS; ++i) { - ::pGem[PCLASS_FIGHTER][i] = R_DeclarePatch(String("LIFEGMF%1").arg(i + 1)); + ::pGem[PCLASS_FIGHTER][i] = R_DeclarePatch(String::format("LIFEGMF%i", i + 1)); } // Cleric: ::pChain[PCLASS_CLERIC] = R_DeclarePatch("CHAIN2"); for(dint i = 0; i < NUMTEAMS; ++i) { - ::pGem[PCLASS_CLERIC][i] = R_DeclarePatch(String("LIFEGMC%1").arg(i + 1)); + ::pGem[PCLASS_CLERIC][i] = R_DeclarePatch(String::format("LIFEGMC%i", i + 1)); } // Mage: ::pChain[PCLASS_MAGE] = R_DeclarePatch("CHAIN3"); for(dint i = 0; i < NUMTEAMS; ++i) { - ::pGem[PCLASS_MAGE][i] = R_DeclarePatch(String("LIFEGMM%1").arg(i + 1)); + ::pGem[PCLASS_MAGE][i] = R_DeclarePatch(String::format("LIFEGMM%i", i + 1)); } #endif } diff --git a/doomsday/apps/plugins/common/src/hud/widgets/flightwidget.cpp b/doomsday/apps/plugins/common/src/hud/widgets/flightwidget.cpp index e772247b98..395f08262f 100644 --- a/doomsday/apps/plugins/common/src/hud/widgets/flightwidget.cpp +++ b/doomsday/apps/plugins/common/src/hud/widgets/flightwidget.cpp @@ -150,7 +150,7 @@ void guidata_flight_t::prepareAssets() // static #if __JHERETIC__ || __JHEXEN__ for(dint i = 0; i < 16; ++i) { - ::pIcon[i] = R_DeclarePatch(String("SPFLY%1").arg(i)); + ::pIcon[i] = R_DeclarePatch(String::format("SPFLY%i", i)); } #endif } diff --git a/doomsday/apps/plugins/common/src/hud/widgets/itemswidget.cpp b/doomsday/apps/plugins/common/src/hud/widgets/itemswidget.cpp index e2a661b099..c3c6b002a2 100644 --- a/doomsday/apps/plugins/common/src/hud/widgets/itemswidget.cpp +++ b/doomsday/apps/plugins/common/src/hud/widgets/itemswidget.cpp @@ -120,14 +120,14 @@ void guidata_items_t::updateGeometry() String valueAsText("Items:"); if(cfg.common.hudShownCheatCounters & CCH_ITEMS) { - valueAsText += String(" %1/%2").arg(_value).arg(totalItems); + valueAsText += String::format(" %i/%i", _value, totalItems); } if(cfg.common.hudShownCheatCounters & CCH_ITEMS_PRCNT) { - valueAsText += String(" %1%2%%3") - .arg((::cfg.common.hudShownCheatCounters & CCH_ITEMS) ? "(" : "") - .arg(totalItems ? _value * 100 / totalItems : 100) - .arg((::cfg.common.hudShownCheatCounters & CCH_ITEMS) ? ")" : ""); + valueAsText += String::format(" %s%i%%%s", + (::cfg.common.hudShownCheatCounters & CCH_ITEMS) ? "(" : "", + totalItems ? _value * 100 / totalItems : 100, + (::cfg.common.hudShownCheatCounters & CCH_ITEMS) ? ")" : ""); } FR_SetFont(font()); diff --git a/doomsday/apps/plugins/common/src/hud/widgets/keyswidget.cpp b/doomsday/apps/plugins/common/src/hud/widgets/keyswidget.cpp index cf2ffda144..0e18c12905 100644 --- a/doomsday/apps/plugins/common/src/hud/widgets/keyswidget.cpp +++ b/doomsday/apps/plugins/common/src/hud/widgets/keyswidget.cpp @@ -361,7 +361,7 @@ void guidata_keys_t::prepareAssets() // static #elif __JHEXEN__ for(dint i = 0; i < NUM_KEY_TYPES; ++i) { - pKeys[i] = R_DeclarePatch(String("KEYSLOT%1").arg(i + 1, 0, 16).toUpper()); + pKeys[i] = R_DeclarePatch(String::format("KEYSLOT%X", i + 1)); } #endif } diff --git a/doomsday/apps/plugins/common/src/network/d_netsv.cpp b/doomsday/apps/plugins/common/src/network/d_netsv.cpp index be13d64ed5..e56a3aefc9 100644 --- a/doomsday/apps/plugins/common/src/network/d_netsv.cpp +++ b/doomsday/apps/plugins/common/src/network/d_netsv.cpp @@ -340,7 +340,7 @@ static res::Uri NetSv_ScanCycle(int index, maprule_t *rules = 0) { int tens = tmp[0] == '*' ? RNG_RandByte() % 10 : tmp[0] - '0'; int ones = tmp[1] == '*' ? RNG_RandByte() % 10 : tmp[1] - '0'; - map = de::String("%1%2").arg(tens).arg(ones).toInt(); + map = 10 * tens + ones; } #elif __JHERETIC__ episode = tmp[0] == '*' ? RNG_RandByte() % 9 : tmp[0] - '0'; @@ -349,7 +349,7 @@ static res::Uri NetSv_ScanCycle(int index, maprule_t *rules = 0) #else // __JHEXEN__ || __JDOOM64__ int tens = tmp[0] == '*' ? RNG_RandByte() % 10 : tmp[0] - '0'; int ones = tmp[1] == '*' ? RNG_RandByte() % 10 : tmp[1] - '0'; - map = de::String("%1%2").arg(tens).arg(ones).toInt(); + map = 10 * tens + ones; #endif #if __JHEXEN__ @@ -661,9 +661,9 @@ void NetSv_SendGameState(int flags, int to) { if(!IS_NETWORK_SERVER) return; - AutoStr *gameId = AutoStr_FromTextStd(gfw_GameId().toLatin1().constData()); - AutoStr *episodeId = AutoStr_FromTextStd(gfw_Session()->episodeId().toLatin1().constData()); - res::Uri mapUri = gfw_Session()->mapUri(); + AutoStr *gameId = AutoStr_FromTextStd(gfw_GameId()); + AutoStr *episodeId = AutoStr_FromTextStd(gfw_Session()->episodeId()); + res::Uri mapUri = gfw_Session()->mapUri(); // Print a short message that describes the game state. LOG_NET_NOTE("Sending game setup: %s %s %s %s") diff --git a/doomsday/apps/plugins/common/src/world/player.cpp b/doomsday/apps/plugins/common/src/world/player.cpp index 62cdf82d03..8625f330ff 100644 --- a/doomsday/apps/plugins/common/src/world/player.cpp +++ b/doomsday/apps/plugins/common/src/world/player.cpp @@ -1807,7 +1807,7 @@ String Player_WeaponId(player_t const *plr) } else { - value.append(QString::number(plr->readyWeapon)); + value.append(String::asText(plr->readyWeapon)); } #endif #if defined(__JDOOM__) || defined(__JDOOM64__) || defined(__JHEXEN__) @@ -1974,7 +1974,7 @@ void Player_UpdateStatusCVars(player_t const *player) #if __JHEXEN__ for(int i = 0; i < WEAPON_FOURTH_PIECE_COUNT; ++i) { - Path const varPath { String("player-weapon-piece%1").arg(i + 1), CVAR_DELIM }; + const Path varPath{String::format("player-weapon-piece%i", i + 1), CVAR_DELIM}; Con_SetVariable(varPath, (player->pieces & (1 << i))? 1 : 0, SVF_WRITE_OVERRIDE); } static Path const var_player_weapon_allpieces("player-weapon-allpieces", CVAR_DELIM);