1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-22 00:27:58 +02:00

Add AI configuration validation

This commit is contained in:
Ivan Savenko
2025-11-23 22:36:08 +02:00
parent a5816b0fe4
commit fb41b48787
3 changed files with 35 additions and 14 deletions

View File

@@ -589,22 +589,27 @@
}, },
"playerAI" : { "playerAI" : {
"type" : "string", "type" : "string",
"enum" : [ "EmptyAI", "Nullkiller", "Nullkiller2" ],
"default" : "Nullkiller2" "default" : "Nullkiller2"
}, },
"alliedAI" : { "alliedAI" : {
"type" : "string", "type" : "string",
"enum" : [ "EmptyAI", "Nullkiller", "Nullkiller2" ],
"default" : "Nullkiller2" "default" : "Nullkiller2"
}, },
"friendlyAI" : { "friendlyAI" : {
"type" : "string", "type" : "string",
"enum" : [ "EmptyAI", "StupidAI", "BattleAI" ],
"default" : "BattleAI" "default" : "BattleAI"
}, },
"neutralAI" : { "neutralAI" : {
"type" : "string", "type" : "string",
"enum" : [ "EmptyAI", "StupidAI", "BattleAI" ],
"default" : "BattleAI" "default" : "BattleAI"
}, },
"enemyAI" : { "enemyAI" : {
"type" : "string", "type" : "string",
"enum" : [ "EmptyAI", "StupidAI", "BattleAI" ],
"default" : "BattleAI" "default" : "BattleAI"
} }
} }

View File

@@ -841,7 +841,7 @@ if(ENABLE_STATIC_LIBS AND ENABLE_CLIENT)
endif() endif()
if(ENABLE_NULLKILLER2_AI) if(ENABLE_NULLKILLER2_AI)
target_link_libraries(vcmi PRIVATE Nullkiller) target_link_libraries(vcmi PRIVATE Nullkiller2)
endif() endif()
if(ENABLE_STUPID_AI) if(ENABLE_STUPID_AI)

View File

@@ -15,10 +15,18 @@
#include "../VCMIDirs.h" #include "../VCMIDirs.h"
#ifdef STATIC_AI #ifdef STATIC_AI
# ifdef ENABLE_NULLKILLER_AI
# include "../../AI/Nullkiller/AIGateway.h" # include "../../AI/Nullkiller/AIGateway.h"
# endif
# ifdef ENABLE_NULLKILLER2_AI
# include "../../AI/Nullkiller2/AIGateway.h" # include "../../AI/Nullkiller2/AIGateway.h"
# endif
# ifdef ENABLE_BATTLE_AI
# include "../../AI/BattleAI/BattleAI.h" # include "../../AI/BattleAI/BattleAI.h"
# endif
# ifdef ENABLE_STUPID_AI
# include "../../AI/StupidAI/StupidAI.h" # include "../../AI/StupidAI/StupidAI.h"
# endif
# include "../../AI/EmptyAI/CEmptyAI.h" # include "../../AI/EmptyAI/CEmptyAI.h"
#else #else
# ifdef VCMI_WINDOWS # ifdef VCMI_WINDOWS
@@ -106,24 +114,32 @@ VCMI_LIB_NAMESPACE_BEGIN
template<> template<>
std::shared_ptr<CGlobalAI> createAny(const boost::filesystem::path & libpath, const std::string & methodName) std::shared_ptr<CGlobalAI> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
{ {
if(libpath.stem() == "libNullkiller2") { #ifdef ENABLE_NULLKILLER2_AI
if(libpath.stem() == "libNullkiller2")
return std::make_shared<NK2AI::AIGateway>(); return std::make_shared<NK2AI::AIGateway>();
} #endif
else if(libpath.stem() == "libNullkiller") {
#ifdef ENABLE_NULLKILLER_AI
if(libpath.stem() == "libNullkiller")
return std::make_shared<NKAI::AIGateway>(); return std::make_shared<NKAI::AIGateway>();
} #endif
else{
return std::make_shared<CEmptyAI>(); return std::make_shared<CEmptyAI>();
}
} }
template<> template<>
std::shared_ptr<CBattleGameInterface> createAny(const boost::filesystem::path & libpath, const std::string & methodName) std::shared_ptr<CBattleGameInterface> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
{ {
#ifdef ENABLE_BATTLE_AI
if(libpath.stem() == "libBattleAI") if(libpath.stem() == "libBattleAI")
return std::make_shared<CBattleAI>(); return std::make_shared<CBattleAI>();
else if(libpath.stem() == "libStupidAI") #endif
#ifdef ENABLE_STUPID_AI
if(libpath.stem() == "libStupidAI")
return std::make_shared<CStupidAI>(); return std::make_shared<CStupidAI>();
#endif
return std::make_shared<CEmptyAI>(); return std::make_shared<CEmptyAI>();
} }