1
0
Selaa lähdekoodia

Remove multi-instance code

Clément Wolf 4 kuukautta sitten
vanhempi
commit
633a8ed263

+ 0 - 7
src/App/Osu/BanchoNetworking.cpp

@@ -130,13 +130,6 @@ void disconnect() {
 }
 
 void reconnect() {
-    if(bancho.osu->m_iInstanceID > 0) {
-        // XXX: To handle multiple instances you would have to do some complex IPC
-        //      Would be great to be able to use neosu as tournament spectator client...
-        //      But that's not in scope right now.
-        return;
-    }
-
     disconnect();
 
     // Disable autologin, in case there's an error while logging in

+ 2 - 19
src/App/Osu/Beatmap.cpp

@@ -1644,16 +1644,7 @@ bool Beatmap::canDraw() {
     return true;
 }
 
-bool Beatmap::canUpdate() {
-    if(!m_bIsPlaying && !m_bIsPaused && !m_bContinueScheduled) return false;
-
-    if(m_osu->getInstanceID() > 1) {
-        m_music = engine->getResourceManager()->getSound("OSU_BEATMAP_MUSIC");
-        if(m_music == NULL) return false;
-    }
-
-    return true;
-}
+bool Beatmap::canUpdate() { return m_bIsPlaying || m_bIsPaused || m_bContinueScheduled; }
 
 void Beatmap::handlePreviewPlay() {
     if(m_music == nullptr) return;
@@ -1698,11 +1689,6 @@ void Beatmap::handlePreviewPlay() {
 }
 
 void Beatmap::loadMusic(bool stream, bool prescan) {
-    if(m_osu->getInstanceID() > 1) {
-        m_music = engine->getResourceManager()->getSound("OSU_BEATMAP_MUSIC");
-        return;
-    }
-
     stream = stream || m_bForceStreamPlayback;
     m_iResourceLoadUpdateDelayHack = 0;
 
@@ -1726,10 +1712,7 @@ void Beatmap::loadMusic(bool stream, bool prescan) {
 }
 
 void Beatmap::unloadMusic() {
-    if(m_osu->getInstanceID() < 2) {
-        engine->getResourceManager()->destroyResource(m_music);
-    }
-
+    engine->getResourceManager()->destroyResource(m_music);
     m_music = nullptr;
 }
 

+ 0 - 8
src/App/Osu/MainMenu.cpp

@@ -1353,8 +1353,6 @@ void MainMenu::onPlayButtonPressed() {
     m_bMainMenuAnimFadeToFriendForNextAnim = false;
     m_bMainMenuAnimFriendScheduled = false;
 
-    if(m_osu->getInstanceID() > 1) return;
-
     m_osu->toggleSongBrowser();
 }
 
@@ -1379,8 +1377,6 @@ void MainMenu::onExitButtonPressed() {
 }
 
 void MainMenu::onPausePressed() {
-    if(m_osu->getInstanceID() > 1) return;
-
     if(m_osu->getSelectedBeatmap()->isPreviewMusicPlaying()) {
         m_osu->getSelectedBeatmap()->pausePreviewMusic();
     } else {
@@ -1392,8 +1388,6 @@ void MainMenu::onPausePressed() {
 }
 
 void MainMenu::onUpdatePressed() {
-    if(m_osu->getInstanceID() > 1) return;
-
     if(m_osu->getUpdateHandler()->getStatus() == UpdateHandler::STATUS::STATUS_SUCCESS_INSTALLATION)
         engine->restart();
     else if(m_osu->getUpdateHandler()->getStatus() == UpdateHandler::STATUS::STATUS_ERROR)
@@ -1401,8 +1395,6 @@ void MainMenu::onUpdatePressed() {
 }
 
 void MainMenu::onVersionPressed() {
-    if(m_osu->getInstanceID() > 1) return;
-
     m_bDrawVersionNotificationArrow = false;
     writeVersionFile();
     m_osu->toggleChangelog();

+ 1 - 5
src/App/Osu/OptionsMenu.cpp

@@ -2438,11 +2438,7 @@ void OptionsMenu::onSkinSelect() {
 }
 
 void OptionsMenu::onSkinSelect2(UString skinName, int id) {
-    if(m_osu->getInstanceID() < 1)
-        m_osu_skin_ref->setValue(skinName);
-    else
-        m_osu->setSkin(skinName);
-
+    m_osu_skin_ref->setValue(skinName);
     updateSkinNameLabel();
 }
 

+ 35 - 94
src/App/Osu/Osu.cpp

@@ -171,15 +171,13 @@ Vector2 Osu::osuBaseResolution = Vector2(640.0f, 480.0f);
 
 Shader *flashlight_shader = nullptr;
 
-Osu::Osu(int instanceID) {
+Osu::Osu() {
     srand(time(NULL));
 
     bancho.neosu_version = UString::format("%.2f-" NEOSU_STREAM, osu_version.getFloat());
     bancho.user_agent =
         UString::format("Mozilla/5.0 (compatible; neosu/%s; +" NEOSU_UPDATE_URL "/)", bancho.neosu_version.toUtf8());
 
-    m_iInstanceID = instanceID;
-
     // convar refs
     m_osu_folder_ref = convar->getConVarByName("osu_folder");
     m_osu_folder_sub_skins_ref = convar->getConVarByName("osu_folder_sub_skins");
@@ -235,7 +233,7 @@ Osu::Osu(int instanceID) {
     env->setCursorVisible(false);
 
     engine->getConsoleBox()->setRequireShiftToActivate(true);
-    if(m_iInstanceID < 2) engine->getMouse()->addListener(this);
+    engine->getMouse()->addListener(this);
 
     convar->getConVarByName("vsync")->setValue(0.0f);
     convar->getConVarByName("fps_max")->setValue(420.0f);
@@ -367,11 +365,9 @@ Osu::Osu(int instanceID) {
     m_updateHandler = new UpdateHandler();
 
     // exec the main config file (this must be right here!)
-    if(m_iInstanceID < 2) {
-        Console::execConfigFile("underride");  // same as override, but for defaults
-        Console::execConfigFile("osu");
-        Console::execConfigFile("override");  // used for quickfixing live builds without redeploying/recompiling
-    }
+    Console::execConfigFile("underride");  // same as override, but for defaults
+    Console::execConfigFile("osu");
+    Console::execConfigFile("override");  // used for quickfixing live builds without redeploying/recompiling
 
     // Initialize sound here so we can load the preferred device from config
     // Avoids initializing the sound device twice, which can take a while depending on the driver
@@ -551,9 +547,8 @@ void Osu::draw(Graphics *g) {
         return;
     }
 
-    // if we are not using the native window resolution, or in vr mode, or multiple instances are active,
-    // draw into the buffer
-    const bool isBufferedDraw = osu_resolution_enabled.getBool() || m_iInstanceID > 0;
+    // if we are not using the native window resolution, draw into the buffer
+    const bool isBufferedDraw = osu_resolution_enabled.getBool();
 
     if(isBufferedDraw) m_backBuffer->enable();
 
@@ -686,50 +681,8 @@ void Osu::draw(Graphics *g) {
         // draw a scaled version from the buffer to the screen
         m_backBuffer->disable();
 
-        // TODO: move this shit to Osu2
         Vector2 offset = Vector2(engine->getGraphics()->getResolution().x / 2 - g_vInternalResolution.x / 2,
                                  engine->getGraphics()->getResolution().y / 2 - g_vInternalResolution.y / 2);
-        if(m_iInstanceID > 0) {
-            const int numHorizontalInstances = 2;
-            const int numVerticalInstances = 1;
-
-            float emptySpaceX =
-                engine->getGraphics()->getResolution().x - numHorizontalInstances * g_vInternalResolution.x;
-            float emptySpaceY =
-                engine->getGraphics()->getResolution().y - numVerticalInstances * g_vInternalResolution.y;
-
-            switch(m_iInstanceID) {
-                case 1:
-                    offset.x = emptySpaceX / 2.0f / numHorizontalInstances;
-                    offset.y = emptySpaceY / 2.0f / numVerticalInstances;
-                    break;
-                case 2:
-                    offset.x = emptySpaceX / 2.0f / numHorizontalInstances;
-                    offset.y = emptySpaceY / 2.0f / numVerticalInstances + engine->getGraphics()->getResolution().y / 2;
-                    break;
-                case 3:
-                    offset.x =
-                        emptySpaceX / 2.0f / numHorizontalInstances + engine->getGraphics()->getResolution().x / 2;
-                    offset.y = emptySpaceY / 2.0f / numVerticalInstances;
-                    break;
-                case 4:
-                    offset.x =
-                        emptySpaceX / 2.0f / numHorizontalInstances + engine->getGraphics()->getResolution().x / 2;
-                    offset.y = emptySpaceY / 2.0f / numVerticalInstances + engine->getGraphics()->getResolution().y / 2;
-                    break;
-                case 5:
-                    offset.x =
-                        emptySpaceX / 2.0f / numHorizontalInstances + engine->getGraphics()->getResolution().x / 2;
-                    offset.y = emptySpaceY / 2.0f / numVerticalInstances + engine->getGraphics()->getResolution().y / 2;
-                    break;
-                case 6:
-                    offset.x =
-                        emptySpaceX / 2.0f / numHorizontalInstances + engine->getGraphics()->getResolution().x / 2;
-                    offset.y = emptySpaceY / 2.0f / numVerticalInstances + engine->getGraphics()->getResolution().y / 2;
-                    break;
-            }
-        }
-
         g->setBlending(false);
         if(osu_letterboxing.getBool()) {
             m_backBuffer->draw(g, offset.x * (1.0f + osu_letterboxing_offset_x.getFloat()),
@@ -932,12 +885,9 @@ void Osu::update() {
     }
     if(m_bToggleUserStatsScreenScheduled) {
         m_bToggleUserStatsScreenScheduled = false;
+        m_userStatsScreen->setVisible(true);
 
-        if(m_iInstanceID < 2) {
-            m_userStatsScreen->setVisible(true);
-
-            if(m_songBrowser2 != NULL && m_songBrowser2->isVisible()) m_songBrowser2->setVisible(false);
-        }
+        if(m_songBrowser2 != NULL && m_songBrowser2->isVisible()) m_songBrowser2->setVisible(false);
     }
     if(m_bToggleChangelogScheduled) {
         m_bToggleChangelogScheduled = false;
@@ -954,7 +904,7 @@ void Osu::update() {
     // handle cursor visibility if outside of internal resolution
     // TODO: not a critical bug, but the real cursor gets visible way too early if sensitivity is > 1.0f, due to this
     // using scaled/offset getMouse()->getPos()
-    if(osu_resolution_enabled.getBool() && m_iInstanceID < 1) {
+    if(osu_resolution_enabled.getBool()) {
         McRect internalWindow = McRect(0, 0, g_vInternalResolution.x, g_vInternalResolution.y);
         bool cursorVisible = env->isCursorVisible();
         if(!internalWindow.contains(engine->getMouse()->getPos())) {
@@ -1739,11 +1689,7 @@ void Osu::onPlayEnd(bool quit, bool aborted) {
     // When playing in multiplayer, screens are toggled in Room
     if(!bancho.is_playing_a_multi_map()) {
         if(quit) {
-            if(m_iInstanceID < 2) {
-                toggleSongBrowser();
-            } else {
-                m_mainMenu->setVisible(true);
-            }
+            toggleSongBrowser();
         } else {
             m_rankingScreen->setVisible(true);
         }
@@ -1851,33 +1797,30 @@ void Osu::onResolutionChanged(Vector2 newResolution) {
 
     const float prevUIScale = getUIScale(this);
 
-    if(m_iInstanceID < 1) {
-        if(!osu_resolution_enabled.getBool())
-            g_vInternalResolution = newResolution;
-        else if(!engine->isMinimized())  // if we just got minimized, ignore the resolution change (for the internal
+    if(!osu_resolution_enabled.getBool()) {
+        g_vInternalResolution = newResolution;
+    } else if(!engine->isMinimized()) {  // if we just got minimized, ignore the resolution change (for the internal
                                          // stuff)
-        {
-            // clamp upwards to internal resolution (osu_resolution)
-            if(g_vInternalResolution.x < m_vInternalResolution.x) g_vInternalResolution.x = m_vInternalResolution.x;
-            if(g_vInternalResolution.y < m_vInternalResolution.y) g_vInternalResolution.y = m_vInternalResolution.y;
-
-            // clamp downwards to engine resolution
-            if(newResolution.x < g_vInternalResolution.x) g_vInternalResolution.x = newResolution.x;
-            if(newResolution.y < g_vInternalResolution.y) g_vInternalResolution.y = newResolution.y;
-
-            // disable internal resolution on specific conditions
-            bool windowsBorderlessHackCondition =
-                (env->getOS() == Environment::OS::OS_WINDOWS && env->isFullscreen() &&
-                 env->isFullscreenWindowedBorderless() &&
-                 (int)g_vInternalResolution.y == (int)env->getNativeScreenSize().y);  // HACKHACK
-            if(((int)g_vInternalResolution.x == engine->getScreenWidth() &&
-                (int)g_vInternalResolution.y == engine->getScreenHeight()) ||
-               !env->isFullscreen() || windowsBorderlessHackCondition) {
-                debugLog("Internal resolution == Engine resolution || !Fullscreen, disabling resampler (%i, %i)\n",
-                         (int)(g_vInternalResolution == engine->getScreenSize()), (int)(!env->isFullscreen()));
-                osu_resolution_enabled.setValue(0.0f);
-                g_vInternalResolution = engine->getScreenSize();
-            }
+        // clamp upwards to internal resolution (osu_resolution)
+        if(g_vInternalResolution.x < m_vInternalResolution.x) g_vInternalResolution.x = m_vInternalResolution.x;
+        if(g_vInternalResolution.y < m_vInternalResolution.y) g_vInternalResolution.y = m_vInternalResolution.y;
+
+        // clamp downwards to engine resolution
+        if(newResolution.x < g_vInternalResolution.x) g_vInternalResolution.x = newResolution.x;
+        if(newResolution.y < g_vInternalResolution.y) g_vInternalResolution.y = newResolution.y;
+
+        // disable internal resolution on specific conditions
+        bool windowsBorderlessHackCondition =
+            (env->getOS() == Environment::OS::OS_WINDOWS && env->isFullscreen() &&
+             env->isFullscreenWindowedBorderless() &&
+             (int)g_vInternalResolution.y == (int)env->getNativeScreenSize().y);  // HACKHACK
+        if(((int)g_vInternalResolution.x == engine->getScreenWidth() &&
+            (int)g_vInternalResolution.y == engine->getScreenHeight()) ||
+           !env->isFullscreen() || windowsBorderlessHackCondition) {
+            debugLog("Internal resolution == Engine resolution || !Fullscreen, disabling resampler (%i, %i)\n",
+                     (int)(g_vInternalResolution == engine->getScreenSize()), (int)(!env->isFullscreen()));
+            osu_resolution_enabled.setValue(0.0f);
+            g_vInternalResolution = engine->getScreenSize();
         }
     }
 
@@ -1916,7 +1859,7 @@ void Osu::onDPIChanged() {
 }
 
 void Osu::rebuildRenderTargets() {
-    debugLog("Osu(%i)::rebuildRenderTargets: %fx%f\n", m_iInstanceID, g_vInternalResolution.x, g_vInternalResolution.y);
+    debugLog("Osu::rebuildRenderTargets: %fx%f\n", g_vInternalResolution.x, g_vInternalResolution.y);
 
     m_backBuffer->rebuild(0, 0, g_vInternalResolution.x, g_vInternalResolution.y);
 
@@ -2189,8 +2132,6 @@ void Osu::onLetterboxingChange(UString oldValue, UString newValue) {
 void Osu::updateConfineCursor() {
     if(debug->getBool()) debugLog("Osu::updateConfineCursor()\n");
 
-    if(m_iInstanceID > 0) return;
-
     if((osu_confine_cursor_fullscreen.getBool() && env->isFullscreen()) ||
        (osu_confine_cursor_windowed.getBool() && !env->isFullscreen()) ||
        (isInPlayMode() && !m_pauseMenu->isVisible() && !getModAuto() && !getModAutopilot() &&

+ 1 - 4
src/App/Osu/Osu.h

@@ -64,7 +64,7 @@ class Osu : public App, public MouseListener {
 
     static bool findIgnoreCase(const std::string &haystack, const std::string &needle);
 
-    Osu(int instanceID = 0);
+    Osu();
     virtual ~Osu();
 
     virtual void draw(Graphics *g);
@@ -106,8 +106,6 @@ class Osu : public App, public MouseListener {
     void setSkin(UString skin) { onSkinChange("", skin); }
     void reloadSkin() { onSkinReload(); }
 
-    inline int getInstanceID() const { return m_iInstanceID; }
-
     inline Vector2 getScreenSize() const { return g_vInternalResolution; }
     inline int getScreenWidth() const { return (int)g_vInternalResolution.x; }
     inline int getScreenHeight() const { return (int)g_vInternalResolution.y; }
@@ -361,7 +359,6 @@ class Osu : public App, public MouseListener {
     // custom
     bool m_bScheduleEndlessModNextBeatmap;
     int m_iMultiplayerClientNumEscPresses;
-    int m_iInstanceID;
     bool m_bWasBossKeyPaused;
     bool m_bSkinLoadScheduled;
     bool m_bSkinLoadWasReload;

+ 2 - 2
src/App/Osu/RankingScreen.cpp

@@ -644,8 +644,8 @@ void RankingScreen::onBack() {
         engine->getSound()->stop(m_osu->getSkin()->getApplause());
 
     setVisible(false);
-    if(!bancho.is_in_a_multi_room()) {
-        if(m_osu->m_songBrowser2 != NULL && m_osu->m_iInstanceID < 2) m_osu->m_songBrowser2->setVisible(true);
+    if(!bancho.is_in_a_multi_room() && m_osu->m_songBrowser2 != NULL) {
+        m_osu->m_songBrowser2->setVisible(true);
     }
 }
 

+ 18 - 18
src/App/Osu/Skin.cpp

@@ -1153,14 +1153,16 @@ Color Skin::getComboColorForCounter(int i, int offset) {
 void Skin::setBeatmapComboColors(std::vector<Color> colors) { m_beatmapComboColors = colors; }
 
 void Skin::playHitCircleSound(int sampleType, float pan) {
-    if(m_iSampleVolume <= 0 || (m_osu->getInstanceID() > 0 && m_osu->getInstanceID() != osu2_sound_source_id.getInt()))
+    if(m_iSampleVolume <= 0) {
         return;
+    }
 
     if(!osu_sound_panning.getBool() || (m_osu_mod_fposu_ref->getBool() && !osu_mod_fposu_sound_panning.getBool()) ||
-       (GameRules::osu_mod_fps.getBool() && !osu_mod_fps_sound_panning.getBool()))
+       (GameRules::osu_mod_fps.getBool() && !osu_mod_fps_sound_panning.getBool())) {
         pan = 0.0f;
-    else
+    } else {
         pan *= osu_sound_panning_multiplier.getFloat();
+    }
 
     int actualSampleSet = m_iSampleSet;
     if(osu_skin_force_hitsound_sample_set.getInt() > 0) actualSampleSet = osu_skin_force_hitsound_sample_set.getInt();
@@ -1191,14 +1193,14 @@ void Skin::playHitCircleSound(int sampleType, float pan) {
 }
 
 void Skin::playSliderTickSound(float pan) {
-    if(m_iSampleVolume <= 0 || (m_osu->getInstanceID() > 0 && m_osu->getInstanceID() != osu2_sound_source_id.getInt()))
-        return;
+    if(m_iSampleVolume <= 0) return;
 
     if(!osu_sound_panning.getBool() || (m_osu_mod_fposu_ref->getBool() && !osu_mod_fposu_sound_panning.getBool()) ||
-       (GameRules::osu_mod_fps.getBool() && !osu_mod_fps_sound_panning.getBool()))
+       (GameRules::osu_mod_fps.getBool() && !osu_mod_fps_sound_panning.getBool())) {
         pan = 0.0f;
-    else
+    } else {
         pan *= osu_sound_panning_multiplier.getFloat();
+    }
 
     switch(m_iSampleSet) {
         case 3:
@@ -1214,13 +1216,12 @@ void Skin::playSliderTickSound(float pan) {
 }
 
 void Skin::playSliderSlideSound(float pan) {
-    if((m_osu->getInstanceID() > 0 && m_osu->getInstanceID() != osu2_sound_source_id.getInt())) return;
-
     if(!osu_sound_panning.getBool() || (m_osu_mod_fposu_ref->getBool() && !osu_mod_fposu_sound_panning.getBool()) ||
-       (GameRules::osu_mod_fps.getBool() && !osu_mod_fps_sound_panning.getBool()))
+       (GameRules::osu_mod_fps.getBool() && !osu_mod_fps_sound_panning.getBool())) {
         pan = 0.0f;
-    else
+    } else {
         pan *= osu_sound_panning_multiplier.getFloat();
+    }
 
     switch(m_iSampleSet) {
         case 3:
@@ -1254,16 +1255,15 @@ void Skin::playSliderSlideSound(float pan) {
 }
 
 void Skin::playSpinnerSpinSound() {
-    if((m_osu->getInstanceID() > 0 && m_osu->getInstanceID() != osu2_sound_source_id.getInt())) return;
-
-    if(!m_spinnerSpinSound->isPlaying()) engine->getSound()->play(m_spinnerSpinSound);
+    if(!m_spinnerSpinSound->isPlaying()) {
+        engine->getSound()->play(m_spinnerSpinSound);
+    }
 }
 
 void Skin::playSpinnerBonusSound() {
-    if(m_iSampleVolume <= 0 || (m_osu->getInstanceID() > 0 && m_osu->getInstanceID() != osu2_sound_source_id.getInt()))
-        return;
-
-    engine->getSound()->play(m_spinnerBonus);
+    if(m_iSampleVolume > 0) {
+        engine->getSound()->play(m_spinnerBonus);
+    }
 }
 
 void Skin::stopSliderSlideSound(int sampleSet) {