浏览代码

Merge pull request #4532 from IvanSavenko/bugfixing

Fixes for recent regressions
Ivan Savenko 1 年之前
父节点
当前提交
9a5bee1eaf
共有 4 个文件被更改,包括 22 次插入8 次删除
  1. 6 1
      client/eventsSDL/InputSourceMouse.cpp
  2. 7 6
      client/mainmenu/CMainMenu.cpp
  3. 8 1
      lib/gameState/CGameState.cpp
  4. 1 0
      lib/gameState/CGameState.h

+ 6 - 1
client/eventsSDL/InputSourceMouse.cpp

@@ -23,6 +23,7 @@
 
 
 #include <SDL_events.h>
 #include <SDL_events.h>
 #include <SDL_hints.h>
 #include <SDL_hints.h>
+#include <SDL_version.h>
 
 
 InputSourceMouse::InputSourceMouse()
 InputSourceMouse::InputSourceMouse()
 	:mouseToleranceDistance(settings["input"]["mouseToleranceDistance"].Integer())
 	:mouseToleranceDistance(settings["input"]["mouseToleranceDistance"].Integer())
@@ -69,7 +70,11 @@ void InputSourceMouse::handleEventMouseButtonDown(const SDL_MouseButtonEvent & b
 
 
 void InputSourceMouse::handleEventMouseWheel(const SDL_MouseWheelEvent & wheel)
 void InputSourceMouse::handleEventMouseWheel(const SDL_MouseWheelEvent & wheel)
 {
 {
-	GH.events().dispatchMouseScrolled(Point(wheel.x, wheel.y) / GH.screenHandler().getScalingFactor(), GH.getCursorPosition());
+#if SDL_VERSION_ATLEAST(2,26,0)
+	GH.events().dispatchMouseScrolled(Point(wheel.x, wheel.y), Point(wheel.mouseX, wheel.mouseY) / GH.screenHandler().getScalingFactor());
+#else
+	GH.events().dispatchMouseScrolled(Point(wheel.x, wheel.y), GH.getCursorPosition());
+#endif
 }
 }
 
 
 void InputSourceMouse::handleEventMouseButtonUp(const SDL_MouseButtonEvent & button)
 void InputSourceMouse::handleEventMouseButtonUp(const SDL_MouseButtonEvent & button)

+ 7 - 6
client/mainmenu/CMainMenu.cpp

@@ -80,6 +80,12 @@ CMenuScreen::CMenuScreen(const JsonNode & configNode)
 
 
 	pos = background->center();
 	pos = background->center();
 
 
+	if(!config["video"].isNull())
+	{
+		Point videoPosition(config["video"]["x"].Integer(), config["video"]["y"].Integer());
+		videoPlayer = std::make_shared<VideoWidget>(videoPosition, VideoPath::fromJson(config["video"]["name"]), false);
+	}
+
 	for(const JsonNode & node : config["items"].Vector())
 	for(const JsonNode & node : config["items"].Vector())
 		menuNameToEntry.push_back(node["name"].String());
 		menuNameToEntry.push_back(node["name"].String());
 
 
@@ -90,12 +96,7 @@ CMenuScreen::CMenuScreen(const JsonNode & configNode)
 	menuNameToEntry.push_back("credits");
 	menuNameToEntry.push_back("credits");
 
 
 	tabs = std::make_shared<CTabbedInt>(std::bind(&CMenuScreen::createTab, this, _1));
 	tabs = std::make_shared<CTabbedInt>(std::bind(&CMenuScreen::createTab, this, _1));
-	if(!config["video"].isNull())
-	{
-		Point videoPosition(config["video"]["x"].Integer(), config["video"]["y"].Integer());
-		videoPlayer = std::make_shared<VideoWidget>(videoPosition, VideoPath::fromJson(config["video"]["name"]), false);
-	}
-	else
+	if(config["video"].isNull())
 		tabs->setRedrawParent(true);
 		tabs->setRedrawParent(true);
 
 
 }
 }

+ 8 - 1
lib/gameState/CGameState.cpp

@@ -194,6 +194,7 @@ void CGameState::init(const IMapService * mapService, StartInfo * si, Load::Prog
 	initRandomFactionsForPlayers();
 	initRandomFactionsForPlayers();
 	randomizeMapObjects();
 	randomizeMapObjects();
 	placeStartingHeroes();
 	placeStartingHeroes();
+	initOwnedObjects();
 	initDifficulty();
 	initDifficulty();
 	initHeroes();
 	initHeroes();
 	initStartingBonus();
 	initStartingBonus();
@@ -492,8 +493,14 @@ void CGameState::randomizeMapObjects()
 				}
 				}
 			}
 			}
 		}
 		}
+	}
+}
 
 
-		if (object->getOwner().isValidPlayer())
+void CGameState::initOwnedObjects()
+{
+	for(CGObjectInstance *object : map->objects)
+	{
+		if (object && object->getOwner().isValidPlayer())
 			getPlayerState(object->getOwner())->addOwnedObject(object);
 			getPlayerState(object->getOwner())->addOwnedObject(object);
 	}
 	}
 }
 }

+ 1 - 0
lib/gameState/CGameState.h

@@ -181,6 +181,7 @@ private:
 	void initGlobalBonuses();
 	void initGlobalBonuses();
 	void initGrailPosition();
 	void initGrailPosition();
 	void initRandomFactionsForPlayers();
 	void initRandomFactionsForPlayers();
+	void initOwnedObjects();
 	void randomizeMapObjects();
 	void randomizeMapObjects();
 	void initPlayerStates();
 	void initPlayerStates();
 	void placeStartingHeroes();
 	void placeStartingHeroes();