ソースを参照

Merge pull request #3693 from IvanSavenko/lobby_deploy

Preparation for lobby server deployment
Ivan Savenko 1 年間 前
コミット
19860de137
7 ファイル変更149 行追加145 行削除
  1. 40 23
      CMakeLists.txt
  2. 3 27
      config/schemas/settings.json
  3. 1 7
      debian/control
  4. 1 3
      debian/rules
  5. 101 84
      lib/CMakeLists.txt
  6. 2 0
      lib/json/JsonValidator.cpp
  7. 1 1
      lobby/EntryPoint.cpp

+ 40 - 23
CMakeLists.txt

@@ -38,11 +38,13 @@ endif()
 
 # Platform-independent options
 
+option(ENABLE_CLIENT "Enable compilation of game client" ON)
 option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
 option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
 option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
 option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
 option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
+option(ENABLE_MINIMAL_LIB "Build only core parts of vcmi library that are required for game lobby" OFF)
 
 # Compilation options
 
@@ -247,6 +249,10 @@ if(ENABLE_SINGLE_APP_BUILD)
 	add_definitions(-DENABLE_SINGLE_APP_BUILD)
 endif()
 
+if(ENABLE_MINIMAL_LIB)
+	add_definitions(-DENABLE_MINIMAL_LIB)
+endif()
+
 if(APPLE_IOS)
 	set(CMAKE_MACOSX_RPATH 1)
 	set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
@@ -450,12 +456,6 @@ if(TARGET zlib::zlib)
 	add_library(ZLIB::ZLIB ALIAS zlib::zlib)
 endif()
 
-set(FFMPEG_COMPONENTS avutil swscale avformat avcodec)
-if(APPLE_IOS AND NOT USING_CONAN)
-	list(APPEND FFMPEG_COMPONENTS swresample)
-endif()
-find_package(ffmpeg COMPONENTS ${FFMPEG_COMPONENTS})
-
 option(FORCE_BUNDLED_MINIZIP "Force bundled Minizip library" OFF)
 if(NOT FORCE_BUNDLED_MINIZIP)
 	find_package(minizip)
@@ -464,18 +464,26 @@ if(NOT FORCE_BUNDLED_MINIZIP)
 	endif()
 endif()
 
-find_package(SDL2 REQUIRED)
-find_package(SDL2_image REQUIRED)
-if(TARGET SDL2_image::SDL2_image)
-	add_library(SDL2::Image ALIAS SDL2_image::SDL2_image)
-endif()
-find_package(SDL2_mixer REQUIRED)
-if(TARGET SDL2_mixer::SDL2_mixer)
-	add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
-endif()
-find_package(SDL2_ttf REQUIRED)
-if(TARGET SDL2_ttf::SDL2_ttf)
-	add_library(SDL2::TTF ALIAS SDL2_ttf::SDL2_ttf)
+if (ENABLE_CLIENT)
+	set(FFMPEG_COMPONENTS avutil swscale avformat avcodec)
+	if(APPLE_IOS AND NOT USING_CONAN)
+		list(APPEND FFMPEG_COMPONENTS swresample)
+	endif()
+	find_package(ffmpeg COMPONENTS ${FFMPEG_COMPONENTS})
+
+	find_package(SDL2 REQUIRED)
+	find_package(SDL2_image REQUIRED)
+	if(TARGET SDL2_image::SDL2_image)
+		add_library(SDL2::Image ALIAS SDL2_image::SDL2_image)
+	endif()
+	find_package(SDL2_mixer REQUIRED)
+	if(TARGET SDL2_mixer::SDL2_mixer)
+		add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
+	endif()
+	find_package(SDL2_ttf REQUIRED)
+	if(TARGET SDL2_ttf::SDL2_ttf)
+		add_library(SDL2::TTF ALIAS SDL2_ttf::SDL2_ttf)
+	endif()
 endif()
 
 if(ENABLE_LOBBY)
@@ -493,7 +501,7 @@ if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
 	endif()
 endif()
 
-if(ENABLE_NULLKILLER_AI)
+if(ENABLE_NULLKILLER_AI AND ENABLE_CLIENT)
 	find_package(TBB REQUIRED)
 endif()
 
@@ -603,10 +611,15 @@ if(APPLE_IOS)
 	add_subdirectory(ios)
 endif()
 
-add_subdirectory_with_folder("AI" AI)
+if (ENABLE_CLIENT)
+	add_subdirectory_with_folder("AI" AI)
+endif()
 
 add_subdirectory(lib)
-add_subdirectory(server)
+
+if (ENABLE_CLIENT OR ENABLE_SERVER)
+	add_subdirectory(server)
+endif()
 
 if(ENABLE_ERM)
 	add_subdirectory(scripting/erm)
@@ -633,7 +646,9 @@ if(ENABLE_LOBBY)
 	add_subdirectory(lobby)
 endif()
 
-add_subdirectory(client)
+if (ENABLE_CLIENT)
+	add_subdirectory(client)
+endif()
 
 if(ENABLE_SERVER)
 	add_subdirectory(serverapp)
@@ -677,7 +692,9 @@ if(ANDROID)
 	")
 else()
 	install(DIRECTORY config DESTINATION ${DATA_DIR})
-	install(DIRECTORY Mods DESTINATION ${DATA_DIR})
+	if (ENABLE_CLIENT OR ENABLE_SERVER)
+		install(DIRECTORY Mods DESTINATION ${DATA_DIR})
+	endif()
 endif()
 if(ENABLE_LUA)
 	install(DIRECTORY scripts DESTINATION ${DATA_DIR})

+ 3 - 27
config/schemas/settings.json

@@ -501,11 +501,7 @@
 				"enableInstalledMods", 
 				"autoCheckRepositories", 
 				"updateOnStartup", 
-				"updateConfigUrl", 
-				"lobbyUrl", 
-				"lobbyPort", 
-				"lobbyUsername", 
-				"connectionTimeout"
+				"updateConfigUrl"
 			],
 			"properties" : {
 				"defaultRepositoryEnabled" : {
@@ -543,26 +539,6 @@
 				"updateConfigUrl" : {
 					"type" : "string",
 					"default" : "https://raw.githubusercontent.com/vcmi/vcmi-updates/master/vcmi-updates.json"
-				},
-				"lobbyUrl" : {
-					"type" : "string",
-					"description" : "ip address or web link to remote proxy server",
-					"default" : "beholder.vcmi.eu"
-				},
-				"lobbyPort" : {
-					"type" : "number",
-					"description" : "connection port for remote proxy server",
-					"default" : 5002
-				},
-				"lobbyUsername" : {
-					"type" : "string",
-					"description" : "username for the client on the remote proxy server",
-					"default" : ""
-				},
-				"connectionTimeout" : {
-					"type" : "number",
-					"description" : "maximum time in ms, should be enough to establish socket connection to remote proxy server.",
-					"default" : 2000
 				}
 			}
 		},
@@ -590,11 +566,11 @@
 				},
 				"hostname" : {
 					"type" : "string",
-					"default" : "127.0.0.1"
+					"default" : "beholder.vcmi.eu"
 				},
 				"port" : {
 					"type" : "number",
-					"default" : 30303
+					"default" : 3031
 				},
 				"roomPlayerLimit" : {
 					"type" : "number",

+ 1 - 7
debian/control

@@ -2,7 +2,7 @@ Source: vcmi
 Section: games
 Priority: optional
 Maintainer: Ivan Savenko <[email protected]>
-Build-Depends: debhelper (>= 8), cmake, libsdl2-dev, libsdl2-image-dev, libsdl2-ttf-dev, libsdl2-mixer-dev, zlib1g-dev, libavformat-dev, libswscale-dev, libboost-dev (>=1.48), libboost-program-options-dev (>=1.48), libboost-filesystem-dev (>=1.48), libboost-system-dev (>=1.48), libboost-locale-dev (>=1.48), libboost-thread-dev (>=1.48), qtbase5-dev, libtbb2-dev, libfuzzylite-dev, libminizip-dev, libluajit-5.1-dev, qttools5-dev
+Build-Depends: debhelper (>= 8), cmake, libsdl2-dev, libsdl2-image-dev, libsdl2-ttf-dev, libsdl2-mixer-dev, zlib1g-dev, libavformat-dev, libswscale-dev, libboost-dev (>=1.48), libboost-program-options-dev (>=1.48), libboost-filesystem-dev (>=1.48), libboost-system-dev (>=1.48), libboost-locale-dev (>=1.48), libboost-thread-dev (>=1.48), qtbase5-dev, libtbb-dev, libfuzzylite-dev, libminizip-dev, libluajit-5.1-dev, qttools5-dev
 Standards-Version: 3.9.1
 Homepage: http://vcmi.eu
 Vcs-Git: git://github.com/vcmi/vcmi.git
@@ -19,9 +19,3 @@ Description: Rewrite of the Heroes of Might and Magic 3 engine
  .
  In its current state it already supports maps of any sizes, higher
  resolutions and extended engine limits.
-
-Package: vcmi-dbg
-Architecture: any
-Section: debug
-Depends: vcmi (= ${binary:Version}),    ${misc:Depends} 
-Description: Debug symbols for vcmi package

+ 1 - 3
debian/rules

@@ -8,14 +8,12 @@ override_dh_auto_configure:
 	dh_auto_configure -- \
 		-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
 		-DCMAKE_INSTALL_RPATH=/usr/lib/$(DEB_HOST_MULTIARCH)/vcmi \
-		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_BUILD_TYPE=Release \
 		-DENABLE_GITVERSION=OFF \
 		-DBIN_DIR=games \
 		-DFORCE_BUNDLED_FL=OFF \
 		-DENABLE_TEST=0
 
-override_dh_strip:
-	dh_strip --dbg-package=vcmi-dbg
 override_dh_auto_install:
 	dh_auto_install --destdir=debian/vcmi
 override_dh_installdocs:

+ 101 - 84
lib/CMakeLists.txt

@@ -1,6 +1,48 @@
 set(lib_SRCS
 	StdInc.cpp
 
+	filesystem/AdapterLoaders.cpp
+	filesystem/CArchiveLoader.cpp
+	filesystem/CBinaryReader.cpp
+	filesystem/CCompressedStream.cpp
+	filesystem/CFileInputStream.cpp
+	filesystem/CFilesystemLoader.cpp
+	filesystem/CMemoryBuffer.cpp
+	filesystem/CMemoryStream.cpp
+	filesystem/CZipLoader.cpp
+	filesystem/CZipSaver.cpp
+	filesystem/FileInfo.cpp
+	filesystem/Filesystem.cpp
+	filesystem/MinizipExtensions.cpp
+	filesystem/ResourcePath.cpp
+
+	json/JsonNode.cpp
+	json/JsonParser.cpp
+	json/JsonRandom.cpp
+	json/JsonUtils.cpp
+	json/JsonValidator.cpp
+	json/JsonWriter.cpp
+
+	logging/CBasicLogConfigurator.cpp
+	logging/CLogger.cpp
+	logging/VisualLogger.cpp
+
+	network/NetworkConnection.cpp
+	network/NetworkHandler.cpp
+	network/NetworkServer.cpp
+
+	vstd/DateUtils.cpp
+	vstd/StringUtils.cpp
+
+	CConfigHandler.cpp
+	CConsoleHandler.cpp
+	CThreadHelper.cpp
+	TextOperations.cpp
+	VCMIDirs.cpp
+)
+
+set(lib_MAIN_SRCS
+
 	battle/AccessibilityInfo.cpp
 	battle/BattleAction.cpp
 	battle/BattleAttackInfo.cpp
@@ -46,38 +88,13 @@ set(lib_SRCS
 	events/PlayerGotTurn.cpp
 	events/TurnStarted.cpp
 
-	filesystem/AdapterLoaders.cpp
-	filesystem/CArchiveLoader.cpp
-	filesystem/CBinaryReader.cpp
-	filesystem/CCompressedStream.cpp
-	filesystem/CFileInputStream.cpp
-	filesystem/CFilesystemLoader.cpp
-	filesystem/CMemoryBuffer.cpp
-	filesystem/CMemoryStream.cpp
-	filesystem/CZipLoader.cpp
-	filesystem/CZipSaver.cpp
-	filesystem/FileInfo.cpp
-	filesystem/Filesystem.cpp
-	filesystem/MinizipExtensions.cpp
-	filesystem/ResourcePath.cpp
-
 	json/JsonBonus.cpp
-	json/JsonNode.cpp
-	json/JsonParser.cpp
-	json/JsonRandom.cpp
-	json/JsonUtils.cpp
-	json/JsonValidator.cpp
-	json/JsonWriter.cpp
 
 	gameState/CGameState.cpp
 	gameState/CGameStateCampaign.cpp
 	gameState/InfoAboutArmy.cpp
 	gameState/TavernHeroesPool.cpp
 
-	logging/CBasicLogConfigurator.cpp
-	logging/CLogger.cpp
-	logging/VisualLogger.cpp
-
 	mapObjectConstructors/AObjectTypeHandler.cpp
 	mapObjectConstructors/CBankInstanceConstructor.cpp
 	mapObjectConstructors/CObjectClassesHandler.cpp
@@ -128,10 +145,6 @@ set(lib_SRCS
 	modding/IdentifierStorage.cpp
 	modding/ModUtility.cpp
 
-	network/NetworkConnection.cpp
-	network/NetworkHandler.cpp
-	network/NetworkServer.cpp
-
 	networkPacks/NetPacksLib.cpp
 
 	pathfinder/CGPathNode.cpp
@@ -225,9 +238,6 @@ set(lib_SRCS
 	spells/effects/RemoveObstacle.cpp
 	spells/effects/Sacrifice.cpp
 
-	vstd/DateUtils.cpp
-	vstd/StringUtils.cpp
-
 	ArtifactUtils.cpp
 	BasicTypes.cpp
 	BattleFieldHandler.cpp
@@ -236,8 +246,6 @@ set(lib_SRCS
 	CArtifactInstance.cpp
 	CBonusTypeHandler.cpp
 	CBuildingHandler.cpp
-	CConfigHandler.cpp
-	CConsoleHandler.cpp
 	CCreatureHandler.cpp
 	CCreatureSet.cpp
 	CGameInfoCallback.cpp
@@ -249,7 +257,6 @@ set(lib_SRCS
 	CScriptingModule.cpp
 	CSkillHandler.cpp
 	CStack.cpp
-	CThreadHelper.cpp
 	CTownHandler.cpp
 	GameSettings.cpp
 	IGameCallback.cpp
@@ -264,12 +271,14 @@ set(lib_SRCS
 	RoadHandler.cpp
 	ScriptHandler.cpp
 	TerrainHandler.cpp
-	TextOperations.cpp
 	TurnTimerInfo.cpp
-	VCMIDirs.cpp
 	VCMI_Lib.cpp
 )
 
+if (NOT ENABLE_MINIMAL_LIB)
+	list(APPEND lib_SRCS ${lib_MAIN_SRCS})
+endif()
+
 # Version.cpp is a generated file
 if(ENABLE_GITVERSION)
 	list(APPEND lib_SRCS ${CMAKE_BINARY_DIR}/Version.cpp)
@@ -280,14 +289,61 @@ endif()
 
 set(lib_HEADERS
 	../include/vstd/CLoggerBase.h
+	../include/vstd/DateUtils.h
+	../include/vstd/StringUtils.h
 	../Global.h
 	../AUTHORS.h
 	StdInc.h
 
+	filesystem/AdapterLoaders.h
+	filesystem/CArchiveLoader.h
+	filesystem/CBinaryReader.h
+	filesystem/CCompressedStream.h
+	filesystem/CFileInputStream.h
+	filesystem/CFilesystemLoader.h
+	filesystem/CInputOutputStream.h
+	filesystem/CInputStream.h
+	filesystem/CMemoryBuffer.h
+	filesystem/CMemoryStream.h
+	filesystem/COutputStream.h
+	filesystem/CStream.h
+	filesystem/CZipLoader.h
+	filesystem/CZipSaver.h
+	filesystem/FileInfo.h
+	filesystem/Filesystem.h
+	filesystem/ISimpleResourceLoader.h
+	filesystem/MinizipExtensions.h
+	filesystem/ResourcePath.h
+
+	json/JsonBonus.h
+	json/JsonFormatException.h
+	json/JsonNode.h
+	json/JsonParser.h
+	json/JsonRandom.h
+	json/JsonUtils.h
+	json/JsonValidator.h
+	json/JsonWriter.h
+
+	logging/CBasicLogConfigurator.h
+	logging/CLogger.h
+	logging/VisualLogger.h
+
+	network/NetworkConnection.h
+	network/NetworkDefines.h
+	network/NetworkHandler.h
+	network/NetworkInterface.h
+	network/NetworkServer.h
+
+	CConfigHandler.h
+	CConsoleHandler.h
+	CThreadHelper.h
+	TextOperations.h
+	VCMIDirs.h
+)
+
+set(lib_MAIN_HEADERS
 	../include/vstd/ContainerUtils.h
 	../include/vstd/RNG.h
-	../include/vstd/DateUtils.h
-	../include/vstd/StringUtils.h
 
 	../include/vcmi/events/AdventureEvents.h
 	../include/vcmi/events/ApplyDamage.h
@@ -385,35 +441,6 @@ set(lib_HEADERS
 	events/PlayerGotTurn.h
 	events/TurnStarted.h
 
-	filesystem/AdapterLoaders.h
-	filesystem/CArchiveLoader.h
-	filesystem/CBinaryReader.h
-	filesystem/CCompressedStream.h
-	filesystem/CFileInputStream.h
-	filesystem/CFilesystemLoader.h
-	filesystem/CInputOutputStream.h
-	filesystem/CInputStream.h
-	filesystem/CMemoryBuffer.h
-	filesystem/CMemoryStream.h
-	filesystem/COutputStream.h
-	filesystem/CStream.h
-	filesystem/CZipLoader.h
-	filesystem/CZipSaver.h
-	filesystem/FileInfo.h
-	filesystem/Filesystem.h
-	filesystem/ISimpleResourceLoader.h
-	filesystem/MinizipExtensions.h
-	filesystem/ResourcePath.h
-
-	json/JsonBonus.h
-	json/JsonFormatException.h
-	json/JsonNode.h
-	json/JsonParser.h
-	json/JsonRandom.h
-	json/JsonUtils.h
-	json/JsonValidator.h
-	json/JsonWriter.h
-
 	gameState/CGameState.h
 	gameState/CGameStateCampaign.h
 	gameState/EVictoryLossCheckResult.h
@@ -423,10 +450,6 @@ set(lib_HEADERS
 	gameState/TavernSlot.h
 	gameState/QuestInfo.h
 
-	logging/CBasicLogConfigurator.h
-	logging/CLogger.h
-	logging/VisualLogger.h
-
 	mapObjectConstructors/AObjectTypeHandler.h
 	mapObjectConstructors/CBankInstanceConstructor.h
 	mapObjectConstructors/CDefaultObjectTypeHandler.h
@@ -487,12 +510,6 @@ set(lib_HEADERS
 	modding/ModUtility.h
 	modding/ModVerificationInfo.h
 
-	network/NetworkConnection.h
-	network/NetworkDefines.h
-	network/NetworkHandler.h
-	network/NetworkInterface.h
-	network/NetworkServer.h
-
 	networkPacks/ArtifactLocation.h
 	networkPacks/BattleChanges.h
 	networkPacks/Component.h
@@ -622,8 +639,6 @@ set(lib_HEADERS
 	CArtifactInstance.h
 	CBonusTypeHandler.h
 	CBuildingHandler.h
-	CConfigHandler.h
-	CConsoleHandler.h
 	CCreatureHandler.h
 	CCreatureSet.h
 	CGameInfoCallback.h
@@ -640,7 +655,6 @@ set(lib_HEADERS
 	CSoundBase.h
 	CStack.h
 	CStopWatch.h
-	CThreadHelper.h
 	CTownHandler.h
 	ExtraOptionsInfo.h
 	FunctionList.h
@@ -667,14 +681,16 @@ set(lib_HEADERS
 	ScopeGuard.h
 	StartInfo.h
 	TerrainHandler.h
-	TextOperations.h
 	TurnTimerInfo.h
 	UnlockGuard.h
-	VCMIDirs.h
 	vcmi_endian.h
 	VCMI_Lib.h
 )
 
+if (NOT ENABLE_MINIMAL_LIB)
+	list(APPEND lib_HEADERS ${lib_MAIN_HEADERS})
+endif()
+
 assign_source_group(${lib_SRCS} ${lib_HEADERS})
 
 if(ENABLE_STATIC_LIBS)
@@ -682,13 +698,14 @@ if(ENABLE_STATIC_LIBS)
 else()
 	add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS})
 endif()
+
 set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1")
 target_link_libraries(vcmi PUBLIC
 	minizip::minizip ZLIB::ZLIB
 	${SYSTEM_LIBS} Boost::boost Boost::thread Boost::filesystem Boost::program_options Boost::locale Boost::date_time
 )
 
-if(ENABLE_STATIC_LIBS)
+if(ENABLE_STATIC_LIBS AND ENABLE_CLIENT)
 	target_compile_definitions(vcmi PRIVATE STATIC_AI)
 	target_link_libraries(vcmi PRIVATE
 		BattleAI

+ 2 - 0
lib/json/JsonValidator.cpp

@@ -422,6 +422,7 @@ static std::string additionalPropertiesCheck(JsonValidator & validator, const Js
 
 static bool testFilePresence(const std::string & scope, const ResourcePath & resource)
 {
+#ifndef ENABLE_MINIMAL_LIB
 	std::set<std::string> allowedScopes;
 	if(scope != ModScope::scopeBuiltin() && !scope.empty()) // all real mods may have dependencies
 	{
@@ -441,6 +442,7 @@ static bool testFilePresence(const std::string & scope, const ResourcePath & res
 		if (CResourceHandler::get(entry)->existsResource(resource))
 			return true;
 	}
+#endif
 	return false;
 }
 

+ 1 - 1
lobby/EntryPoint.cpp

@@ -16,7 +16,7 @@
 #include "../lib/filesystem/Filesystem.h"
 #include "../lib/VCMIDirs.h"
 
-static const int LISTENING_PORT = 30303;
+static const int LISTENING_PORT = 3031;
 
 int main(int argc, const char * argv[])
 {