From f490a8361b3ef855b67341d51c20b028e66eabe2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 19 Feb 2014 00:40:04 +0100 Subject: [PATCH] Add AIS sheets to shard sheets packer tool --- code/ryzom/server/src/ai_service/commands.cpp | 29 ----------- .../server/src/ai_service/commands_mlf.cpp | 52 +++++++++++++++++++ code/ryzom/server/src/ai_service/sheets.cpp | 17 ++++-- code/ryzom/server/src/ai_service/sheets.h | 1 + .../tools/sheets_packer_shard/CMakeLists.txt | 8 ++- .../sheets_packer_shard.cpp | 8 +++ 6 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 code/ryzom/server/src/ai_service/commands_mlf.cpp diff --git a/code/ryzom/server/src/ai_service/commands.cpp b/code/ryzom/server/src/ai_service/commands.cpp index 07e9023bf..d257d0492 100644 --- a/code/ryzom/server/src/ai_service/commands.cpp +++ b/code/ryzom/server/src/ai_service/commands.cpp @@ -2889,35 +2889,6 @@ NLMISC_COMMAND(unloadPrimitiveFile,"unload a primitive file","") return true; } -////////////////////////////////////////////////////////////////////////////// -// MULTI_LINE_FORMATER // -////////////////////////////////////////////////////////////////////////////// - -static int const MULTI_LINE_FORMATER_maxn = 78; -void MULTI_LINE_FORMATER::pushTitle(std::vector& container, std::string const& text) -{ - const sint maxn = MULTI_LINE_FORMATER_maxn; - sint n = maxn - (sint)text.length() - 4; - container.push_back(" _/"); - container.back() += text; - container.back() += "\\" + std::string(n, '_'); - container.push_back("/"); - container.back() += std::string(maxn - 1, ' '); -} - -void MULTI_LINE_FORMATER::pushEntry(std::vector& container, std::string const& text) -{ - container.push_back("| "); - container.back() += text; -} - -void MULTI_LINE_FORMATER::pushFooter(std::vector& container) -{ - int const maxn = MULTI_LINE_FORMATER_maxn; - container.push_back("\\"); - container.back() += std::string(maxn - 1, '_'); -} - ////////////////////////////////////////////////////////////////////////////// // Bug simulation // ////////////////////////////////////////////////////////////////////////////// diff --git a/code/ryzom/server/src/ai_service/commands_mlf.cpp b/code/ryzom/server/src/ai_service/commands_mlf.cpp new file mode 100644 index 000000000..6437100cf --- /dev/null +++ b/code/ryzom/server/src/ai_service/commands_mlf.cpp @@ -0,0 +1,52 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#include "stdpch.h" + +using namespace NLMISC; +using namespace NLNET; +using namespace std; + +////////////////////////////////////////////////////////////////////////////// +// MULTI_LINE_FORMATER // +////////////////////////////////////////////////////////////////////////////// + +static int const MULTI_LINE_FORMATER_maxn = 78; +void MULTI_LINE_FORMATER::pushTitle(std::vector& container, std::string const& text) +{ + const sint maxn = MULTI_LINE_FORMATER_maxn; + sint n = maxn - (sint)text.length() - 4; + container.push_back(" _/"); + container.back() += text; + container.back() += "\\" + std::string(n, '_'); + container.push_back("/"); + container.back() += std::string(maxn - 1, ' '); +} + +void MULTI_LINE_FORMATER::pushEntry(std::vector& container, std::string const& text) +{ + container.push_back("| "); + container.back() += text; +} + +void MULTI_LINE_FORMATER::pushFooter(std::vector& container) +{ + int const maxn = MULTI_LINE_FORMATER_maxn; + container.push_back("\\"); + container.back() += std::string(maxn - 1, '_'); +} diff --git a/code/ryzom/server/src/ai_service/sheets.cpp b/code/ryzom/server/src/ai_service/sheets.cpp index aa92fe3d4..bc7ece4fa 100644 --- a/code/ryzom/server/src/ai_service/sheets.cpp +++ b/code/ryzom/server/src/ai_service/sheets.cpp @@ -625,7 +625,7 @@ void AISHEETS::CCreature::readGeorges(NLMISC::CSmartPtr const& { std::string scriptCompStr; scriptCompNode->getArrayValue(scriptCompStr, arrayIndex); - +#ifndef NO_AI_COMP CFightScriptComp* scriptComp; try { @@ -636,6 +636,7 @@ void AISHEETS::CCreature::readGeorges(NLMISC::CSmartPtr const& { nlwarning("script read error (ignored): %s", ex.what()); } +#endif } } // Creature race @@ -763,6 +764,7 @@ void AISHEETS::CCreature::serial(NLMISC::IStream &s) string scriptCompStr; s.serial(scriptCompStr); +#ifndef NO_AI_COMP CFightScriptComp* scriptComp; try { @@ -773,6 +775,7 @@ void AISHEETS::CCreature::serial(NLMISC::IStream &s) { nlwarning("script read error (ignored): %s", ex.what()); } +#endif } } else @@ -881,8 +884,14 @@ void AISHEETS::CSheets::init() nlassert(_PlayerGroupIndex!=~0); #endif - CConfigFile::CVar *varPtr=IService::getInstance()->ConfigFile.getVarPtr(std::string("GeorgePaths")); - const std::string writeFilesDirectoryName=IService::getInstance()->WriteFilesDirectory.toString(); + packSheets(IService::getInstance()->WriteFilesDirectory.toString()); + + _Initialised=true; +} + +void AISHEETS::CSheets::packSheets(const std::string &writeFilesDirectoryName) +{ + CConfigFile::CVar *varPtr = IService::isServiceInitialized() ? IService::getInstance()->ConfigFile.getVarPtr(std::string("GeorgePaths")) : NULL; // if config file variable 'GeorgePaths' exists then only do a minimal loadForms otherwise do the full works if (varPtr!=NULL) @@ -947,8 +956,6 @@ void AISHEETS::CSheets::init() loadForm2("creature", writeFilesDirectoryName+AISPackedSheetsFilename, _Sheets, true); loadForm2("race_stats", writeFilesDirectoryName+AISPackedRaceStatsSheetsFilename, _RaceStatsSheets, true); } - - _Initialised=true; } void AISHEETS::CSheets::release() diff --git a/code/ryzom/server/src/ai_service/sheets.h b/code/ryzom/server/src/ai_service/sheets.h index 77605cae1..efa4d0c10 100644 --- a/code/ryzom/server/src/ai_service/sheets.h +++ b/code/ryzom/server/src/ai_service/sheets.h @@ -689,6 +689,7 @@ public: public: // load the creature data from the george files void init(); + void packSheets(const std::string &writeFilesDirectoryName); // display the creature data for all known creature types void display(NLMISC::CSmartPtr stringWriter, uint infoSelect = 0); diff --git a/code/ryzom/tools/sheets_packer_shard/CMakeLists.txt b/code/ryzom/tools/sheets_packer_shard/CMakeLists.txt index 87172f439..3e9f2a17f 100644 --- a/code/ryzom/tools/sheets_packer_shard/CMakeLists.txt +++ b/code/ryzom/tools/sheets_packer_shard/CMakeLists.txt @@ -7,7 +7,10 @@ ADD_EXECUTABLE(sheets_packer_shard ${SRC} ${EGSSHEETS} ${CMAKE_SOURCE_DIR}/ryzom/server/src/gpm_service/sheets.cpp ${CMAKE_SOURCE_DIR}/ryzom/server/src/gpm_service/sheets.h ${CMAKE_SOURCE_DIR}/ryzom/server/src/entities_game_service/entity_structure/resists.cpp - ${CMAKE_SOURCE_DIR}/ryzom/server/src/entities_game_service/entity_structure/resists.h) + ${CMAKE_SOURCE_DIR}/ryzom/server/src/entities_game_service/entity_structure/resists.h + ${CMAKE_SOURCE_DIR}/ryzom/server/src/ai_service/sheets.cpp + ${CMAKE_SOURCE_DIR}/ryzom/server/src/ai_service/sheets.h + ${CMAKE_SOURCE_DIR}/ryzom/server/src/ai_service/commands_mlf.cpp) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/ryzom/common/src ${CMAKE_SOURCE_DIR}/ryzom/server/src ${CMAKE_SOURCE_DIR}/ryzom/tools/sheets_packer_shard ${CMAKE_SOURCE_DIR}/ryzom/server/src/entities_game_service) TARGET_LINK_LIBRARIES(sheets_packer_shard @@ -25,6 +28,7 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) NL_DEFAULT_PROPS(sheets_packer_shard "Ryzom, Tools: Sheets Packer Shard") NL_ADD_RUNTIME_FLAGS(sheets_packer_shard) -SET_TARGET_PROPERTIES(sheets_packer_shard PROPERTIES COMPILE_FLAGS -DNO_EGS_VARS) +ADD_DEFINITIONS(-DNO_EGS_VARS) +ADD_DEFINITIONS(-DNO_AI_COMP) INSTALL(TARGETS sheets_packer_shard RUNTIME DESTINATION ${RYZOM_BIN_PREFIX} COMPONENT tools) diff --git a/code/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp b/code/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp index eb735e02e..9c2212efa 100644 --- a/code/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp +++ b/code/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include // Project includes // ... @@ -160,6 +162,12 @@ int main(int nNbArg, char **ppArgs) { CTimeDateSeasonManager::packSheets(s_WriteDirectory); } + + // AIS + { + AISHEETS::CSheets::getInstance()->packSheets(s_WriteDirectory); + AISHEETS::CSheets::destroyInstance(); + } // and that's all folks return EXIT_SUCCESS;