diff --git a/CMakeLists.txt b/CMakeLists.txt index 02eb3240..66b3f4ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ cmake_minimum_required (VERSION 2.8) # set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Profile" CACHE STRING "" FORCE) set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) -set (BEHAVIAC_PACKAGE_VERSION 3.6.19) +set (BEHAVIAC_PACKAGE_VERSION 3.6.20) #option( BUILD_SHARED_LIBS "set to OFF to build static libraries" ON ) SET(BUILD_SHARED_LIBS ON CACHE BOOL "set to OFF to build static libraries") diff --git a/docs/behaviac.chm b/docs/behaviac.chm index c938b8f2..dafce831 100644 Binary files a/docs/behaviac.chm and b/docs/behaviac.chm differ diff --git a/history.txt b/history.txt index 864d2596..b9565de9 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,6 @@ +2017-2-24 3.6.20 + Fix a bug for renaming the agent and setting its base class. + 2017-2-23 3.6.19 Fix a bug for the CMakeList. Add the vcxproj.filters files for the C++ projects. diff --git a/inc/behaviac/common/_config.h b/inc/behaviac/common/_config.h index 7c6ae884..90b81700 100644 --- a/inc/behaviac/common/_config.h +++ b/inc/behaviac/common/_config.h @@ -11,5 +11,5 @@ #define BEHAVIAC_RELEASE 0 #endif -#define BEHAVIAC_VERSION_STRING "3.6.19" +#define BEHAVIAC_VERSION_STRING "3.6.20" diff --git a/inc/behaviac/common/member.h b/inc/behaviac/common/member.h index 678f590a..7d0caa39 100644 --- a/inc/behaviac/common/member.h +++ b/inc/behaviac/common/member.h @@ -755,7 +755,7 @@ namespace behaviac { const behaviac::vector& vec = *(const behaviac::vector*)pData; - return vec.size(); + return (int)vec.size(); } CInstanceMember(CInstanceMember& rhs) { @@ -1482,7 +1482,7 @@ namespace behaviac { virtual const void* GetValueElement(const behaviac::Agent* self, int index) const { const behaviac::vector& arrayValue = self->GetVariable >(_parentId); - int len = arrayValue.size(); + int len = (int)arrayValue.size(); BEHAVIAC_UNUSED_VAR(len); BEHAVIAC_ASSERT(len != 0); @@ -1533,7 +1533,7 @@ namespace behaviac { virtual const void* GetValueElement(const behaviac::Agent* self, int index) const { const behaviac::vector& arrayValue = self->GetVariable >(_parentId); - int len = arrayValue.size(); + int len = (int)arrayValue.size(); BEHAVIAC_UNUSED_VAR(len); BEHAVIAC_ASSERT(len != 0); diff --git a/inc/behaviac/common/rapidxml/rapidxml.hpp b/inc/behaviac/common/rapidxml/rapidxml.hpp index 4d22989c..66ceccb2 100644 --- a/inc/behaviac/common/rapidxml/rapidxml.hpp +++ b/inc/behaviac/common/rapidxml/rapidxml.hpp @@ -397,8 +397,8 @@ namespace behaviac public: //! \cond internal - typedef void* (alloc_func)(std::size_t); // Type of user-defined function used to allocate memory - typedef void (free_func)(void*); // Type of user-defined function used to free memory + typedef void* (alloc_func_behaviac)(std::size_t); // Type of user-defined function used to allocate memory + typedef void (free_func_behaviac)(void*); // Type of user-defined function used to free memory //! \endcond //! Constructs empty pool with default allocator functions. @@ -608,7 +608,7 @@ namespace behaviac //!
//! \param af Allocation function, or 0 to restore default function //! \param ff Free function, or 0 to restore default function - void set_allocator(alloc_func* af, free_func* ff) + void set_allocator(alloc_func_behaviac* af, free_func_behaviac* ff) { assert(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet m_alloc_func = af; @@ -702,8 +702,8 @@ namespace behaviac char* m_ptr; // First free byte in current pool char* m_end; // One past last available byte in current pool char m_static_memory[RAPIDXML_STATIC_POOL_SIZE]; // Static raw memory - alloc_func* m_alloc_func; // Allocator function, or 0 if default is to be used - free_func* m_free_func; // Free function, or 0 if default is to be used + alloc_func_behaviac* m_alloc_func; // Allocator function, or 0 if default is to be used + free_func_behaviac* m_free_func; // Free function, or 0 if default is to be used }; /////////////////////////////////////////////////////////////////////////// diff --git a/inc/behaviac/common/string/stringutils.h b/inc/behaviac/common/string/stringutils.h index 250ee8e3..5da6e3ab 100644 --- a/inc/behaviac/common/string/stringutils.h +++ b/inc/behaviac/common/string/stringutils.h @@ -63,7 +63,7 @@ namespace behaviac { ////////////////////////////////////////////////// inline void StringCopySafe(int destMax, char* dest, const char* src) { - int len = ::strlen(src); + int len = (int)::strlen(src); BEHAVIAC_ASSERT(len < destMax); strncpy(dest, src, len); dest[len] = 0; @@ -348,9 +348,9 @@ namespace behaviac { } if (bArrayType) { - int bracket0 = typeName.find('<'); - int bracket1 = typeName.find('>'); - int len = bracket1 - bracket0 - 1; + size_t bracket0 = typeName.find('<'); + size_t bracket1 = typeName.find('>'); + size_t len = bracket1 - bracket0 - 1; string elementTypeName = typeName.substr(bracket0 + 1, len); @@ -365,7 +365,7 @@ namespace behaviac { behaviac::string strFullPath; //if path hava / or \ in the end - int len = ::strlen(path); + size_t len = ::strlen(path); if (path[len - 1] == '/' || path[len - 1] == '\\') { strFullPath = path; @@ -526,13 +526,13 @@ namespace behaviac { //it returns true if 'str' starts with a count followed by ':' //3:{....} - inline bool IsArrayString(const behaviac::string& str, int posStart, behaviac::string::size_type& posEnd) { + inline bool IsArrayString(const behaviac::string& str, size_t posStart, behaviac::string::size_type& posEnd) { //begin of the count of an array? //int posStartOld = posStart; bool bIsDigit = false; - int strLen = (int)str.size(); + size_t strLen = str.size(); while (posStart < strLen) { char c = str[posStart++]; @@ -545,7 +545,7 @@ namespace behaviac { //skip array item which is possible a struct int depth = 0; - for (int posStart2 = posStart; posStart2 < strLen; posStart2++) { + for (size_t posStart2 = posStart; posStart2 < strLen; posStart2++) { char c1 = str[posStart2]; if (c1 == ';' && depth == 0) { @@ -657,7 +657,7 @@ namespace behaviac { bool bBeginIndex = false; - int strLen = ::strlen(str); + int strLen = (int)::strlen(str); while (i < strLen) { bool bFound = false; diff --git a/integration/demo_running/behaviac/version.txt b/integration/demo_running/behaviac/version.txt index 4fab9097..0e0cf259 100644 --- a/integration/demo_running/behaviac/version.txt +++ b/integration/demo_running/behaviac/version.txt @@ -1 +1 @@ -3.6.19 +3.6.20 diff --git a/integration/unity/Assets/Scripts/behaviac/runtime/version.txt b/integration/unity/Assets/Scripts/behaviac/runtime/version.txt index 4fab9097..0e0cf259 100644 --- a/integration/unity/Assets/Scripts/behaviac/runtime/version.txt +++ b/integration/unity/Assets/Scripts/behaviac/runtime/version.txt @@ -1 +1 @@ -3.6.19 +3.6.20 diff --git a/src/common/file/listfiles.cpp b/src/common/file/listfiles.cpp index 6235de6a..4fbd3eca 100644 --- a/src/common/file/listfiles.cpp +++ b/src/common/file/listfiles.cpp @@ -29,16 +29,16 @@ static void _listfiles_get_ext(listfiles_file_t* pFile); #define _LISTFILES_FREE(_ptr) BEHAVIAC_FREE(_ptr) -int listfiles_open(listfiles_dir_t* pDir, const _listfiles_char_t* szPath) { +int listfiles_open(listfiles_dir_t* pDir, const char* szPath) { #ifndef _MSC_VER #ifndef _LISTFILES_USE_READDIR int error; int size; #endif #else - _listfiles_char_t path_buf[_LISTFILES_PATH_MAX]; + char path_buf[_LISTFILES_PATH_MAX]; #endif - _listfiles_char_t* pathp; + char* pathp; if (pDir == NULL || szPath == NULL || _listfiles_strlen(szPath) == 0) { errno = EINVAL; @@ -259,12 +259,7 @@ int listfiles_readfile(const listfiles_dir_t* pDir, listfiles_file_t* pFile) { ); _listfiles_strcat(pFile->path, pFile->name); #ifndef _MSC_VER -#ifdef __MINGW32__ - - if (_tstat( -#else if (stat( -#endif pFile->path, &pFile->_s) == -1) { return -1; } @@ -297,7 +292,7 @@ int listfiles_readfile(const listfiles_dir_t* pDir, listfiles_file_t* pFile) { void _listfiles_get_ext(listfiles_file_t* pFile) { - _listfiles_char_t* period = _listfiles_strrchr(pFile->name, _LISTFILES_STRING('.')); + char* period = _listfiles_strrchr(pFile->name, _LISTFILES_STRING('.')); if (period == NULL) { pFile->extension = &(pFile->name[_listfiles_strlen(pFile->name)]); diff --git a/src/common/file/listfiles.h b/src/common/file/listfiles.h index d9779cd9..771bc49d 100644 --- a/src/common/file/listfiles.h +++ b/src/common/file/listfiles.h @@ -14,32 +14,20 @@ #ifndef _BEHAVIAC_COMMON_FILE_LISTFILES_H_ #define _BEHAVIAC_COMMON_FILE_LISTFILES_H_ -#if ((defined _UNICODE) && !(defined UNICODE)) -#define UNICODE -#endif - -#if ((defined UNICODE) && !(defined _UNICODE)) -#define _UNICODE -#endif - #include #include #include #ifdef _MSC_VER # define WIN32_LEAN_AND_MEAN # include -# include #else # include # include # include # include #endif -#ifdef __MINGW32__ -# include -#endif -#if (defined _MSC_VER || defined __MINGW32__) +#if (defined _MSC_VER) #include #define _LISTFILES_PATH_MAX MAX_PATH #elif defined __linux__ @@ -57,29 +45,17 @@ #define _LISTFILES_FILENAME_MAX 256 -#if (defined _MSC_VER || defined __MINGW32__) +#if (defined _MSC_VER) #define _LISTFILES_DRIVE_MAX 3 #endif -#if defined _MSC_VER || defined __MINGW32__ -#define _listfiles_char_t TCHAR -#define _LISTFILES_STRING(s) _TEXT(s) -#define _listfiles_strlen _tcslen -#define _listfiles_strcpy _tcscpy -#define _listfiles_strcat _tcscat -#define _listfiles_strcmp _tcscmp -#define _listfiles_strrchr _tcsrchr -#define _listfiles_strncmp _tcsncmp -#else -#define _listfiles_char_t char #define _LISTFILES_STRING(s) s #define _listfiles_strlen strlen -#define _listfiles_strcpy string_cpy -#define _listfiles_strcat string_cat +#define _listfiles_strcpy strcpy +#define _listfiles_strcat strcat #define _listfiles_strcmp strcmp #define _listfiles_strrchr strrchr #define _listfiles_strncmp strncmp -#endif #ifdef _LISTFILES_USE_READDIR_R // Use readdir by default @@ -89,39 +65,27 @@ // mingw32 has two versions of dirent, ASCII and UNICODE #ifndef _MSC_VER -#if (defined __MINGW32__) && (defined _UNICODE) -#define _LISTFILES_DIR _WDIR -#define _listfiles_dir_tent _wdirent -#define _listfiles_opendir _wopendir -#define _listfiles_readdir _wreaddir -#define _listfiles_closedir _wclosedir -#else #define _LISTFILES_DIR DIR #define _listfiles_dir_tent dirent #define _listfiles_opendir opendir #define _listfiles_readdir readdir #define _listfiles_closedir closedir #endif -#endif typedef struct listfiles_file_t { - _listfiles_char_t path[_LISTFILES_PATH_MAX]; - _listfiles_char_t name[_LISTFILES_FILENAME_MAX]; - _listfiles_char_t* extension; + char path[_LISTFILES_PATH_MAX]; + char name[_LISTFILES_FILENAME_MAX]; + char* extension; int is_dir; int is_reg; #ifndef _MSC_VER -#ifdef __MINGW32__ - struct _stat _s; -#else struct stat _s; #endif -#endif } listfiles_file_t; typedef struct listfiles_dir_t { - _listfiles_char_t path[_LISTFILES_PATH_MAX]; + char path[_LISTFILES_PATH_MAX]; int has_next; size_t n_files; @@ -139,7 +103,7 @@ typedef struct listfiles_dir_t { } listfiles_dir_t; -int listfiles_open(listfiles_dir_t* pDir, const _listfiles_char_t* szPath); +int listfiles_open(listfiles_dir_t* pDir, const char* szPath); void listfiles_close(listfiles_dir_t* pDir); int listfiles_readfile(const listfiles_dir_t* pDir, listfiles_file_t* pFile); diff --git a/src/common/meta.cpp b/src/common/meta.cpp index 71e47927..e8d6a9de 100644 --- a/src/common/meta.cpp +++ b/src/common/meta.cpp @@ -499,7 +499,7 @@ namespace behaviac { propStr = propStr.substr(pointIndex + 1); - int lastIndex = propStr.rfind("::"); + size_t lastIndex = propStr.rfind("::"); BEHAVIAC_ASSERT(lastIndex > 0); behaviac::string className = propStr.substr(0, lastIndex); @@ -624,9 +624,9 @@ namespace behaviac { } behaviac::vector AgentMeta::ParseForParams(const char* tsrc) { - int tsrcLen = strlen(tsrc); - int startIndex = 0; - int index = 0; + size_t tsrcLen = strlen(tsrc); + size_t startIndex = 0; + size_t index = 0; int quoteDepth = 0; behaviac::vector params_; @@ -642,7 +642,7 @@ namespace behaviac { } } else if (quoteDepth == 0 && tsrc[index] == ',') { //skip ',' inside quotes, like "count, count" - int lengthTemp = index - startIndex; + size_t lengthTemp = index - startIndex; //const char* strTemp = tsrc.Substring(startIndex, lengthTemp); char strTemp[1024] = { 0 }; strncpy(strTemp, tsrc + startIndex, lengthTemp); @@ -652,7 +652,7 @@ namespace behaviac { }//end for // the last param - int lengthTemp0 = index - startIndex; + size_t lengthTemp0 = index - startIndex; if (lengthTemp0 > 0) { //const char* strTemp = tsrc.Substring(startIndex, lengthTemp0) @@ -773,7 +773,7 @@ namespace behaviac { if (index == 0) { // array type // Get item type, i.e. vector - const int kVecLen = ::strlen("vector<"); + const size_t kVecLen = ::strlen("vector<"); typeNameStr = typeNameStr.substr(kVecLen, typeNameStr.length() - kVecLen - 1); // item type IProperty* arrayItemProp = AgentMeta::CreateCustomizedArrayItemProperty(typeNameStr, nameId, propName); string araryItemPropName = propName; diff --git a/src/common/socket/socketconnect_base.cpp b/src/common/socket/socketconnect_base.cpp index bf47e976..ff33af99 100644 --- a/src/common/socket/socketconnect_base.cpp +++ b/src/common/socket/socketconnect_base.cpp @@ -482,7 +482,7 @@ namespace behaviac { if (retIndex > 0) { #if BEHAVIAC_CCDEFINE_MSVC - TlsSetValue(t_packetBufferIndex, (PVOID)retIndex); + TlsSetValue(t_packetBufferIndex, (PVOID)(size_t)retIndex); #else t_packetBufferIndex = retIndex; #endif diff --git a/src/common/workspace.cpp b/src/common/workspace.cpp index 1d684045..e1ff4bbd 100644 --- a/src/common/workspace.cpp +++ b/src/common/workspace.cpp @@ -588,7 +588,7 @@ namespace behaviac { if (pBuffer >= fileBuffer.start && pBuffer < end) { BEHAVIAC_ASSERT(bufferSize < fileBuffer.length); - fileBuffer.offset = pBuffer - fileBuffer.start; + fileBuffer.offset = (int)(pBuffer - fileBuffer.start); //BEHAVIAC_ASSERT(fileBuffer.offset >= 0); return; diff --git a/src/htn/agentstate.cpp b/src/htn/agentstate.cpp index 04f48232..4ae7f6b4 100644 --- a/src/htn/agentstate.cpp +++ b/src/htn/agentstate.cpp @@ -101,7 +101,7 @@ namespace behaviac { } void AgentState::AddVariable(uint32_t varId, IInstantiatedVariable* pVar, int stackIndex) { - int array_len = this->state_stack.size(); + int array_len = (int)this->state_stack.size(); if (array_len > 0 && stackIndex > 0 && stackIndex < array_len) { @@ -114,7 +114,7 @@ namespace behaviac { IInstantiatedVariable* AgentState::GetVariable(uint32_t varId) const { if (this->state_stack.size() > 0) { - for (int i = this->state_stack.size() - 1; i >= 0; --i) { + for (size_t i = this->state_stack.size() - 1; i >= 0; --i) { AgentState* t = this->state_stack[i]; IInstantiatedVariable* pVar = t->GetVariable(varId); diff --git a/tools/designer/BehaviacDesigner/BehaviorTreeList.cs b/tools/designer/BehaviacDesigner/BehaviorTreeList.cs index e99890c7..30d18c30 100644 --- a/tools/designer/BehaviacDesigner/BehaviorTreeList.cs +++ b/tools/designer/BehaviacDesigner/BehaviorTreeList.cs @@ -1221,6 +1221,9 @@ private void refreshButton_Click(object sender, EventArgs e) { if (Workspace.Current != null) { + // Save the debug info. + DebugDataPool.Save(Workspace.Current.FileName); + MainWindow.Instance.SetWorkspace(Workspace.Current.FileName, false); } } diff --git a/tools/designer/BehaviacDesigner/MainWindow.cs b/tools/designer/BehaviacDesigner/MainWindow.cs index 4b3dde33..f98cb932 100644 --- a/tools/designer/BehaviacDesigner/MainWindow.cs +++ b/tools/designer/BehaviacDesigner/MainWindow.cs @@ -1014,6 +1014,8 @@ private bool Plugin_WorkspaceDelegateHandler(string workspacePath, bool bNew) if (bWorkspaceChanged) { + BehaviorTreeViewDock.LastOpenedBehaviors.Clear(); + bOk = this.SetWorkspace(workspacePath, bNew); } diff --git a/tools/designer/BehaviacDesigner/MetaStoreDock.cs b/tools/designer/BehaviacDesigner/MetaStoreDock.cs index 5c234b31..269fadef 100644 --- a/tools/designer/BehaviacDesigner/MetaStoreDock.cs +++ b/tools/designer/BehaviacDesigner/MetaStoreDock.cs @@ -375,7 +375,7 @@ private void CheckTypeName() { this.resetMembersInWorkspace(MetaOperations.RenameAgentType, agentType, null, null, null); - save(); + //save(); } else { @@ -396,7 +396,7 @@ private void CheckTypeName() { this.resetMembersInWorkspace(MetaOperations.RenameEnumType, null, enumType, null, null); - save(); + //save(); } else { @@ -417,7 +417,7 @@ private void CheckTypeName() { this.resetMembersInWorkspace(MetaOperations.RenameStructType, null, structType, null, null); - save(); + //save(); } else { @@ -1239,6 +1239,9 @@ private void addTypeButton_Click(object sender, EventArgs e) resetAllTypes(agentType.Name); _lastSelectedType = agentType.Name; + + // refresh the workspace to load the type + save(true); } else if (metaType == MetaTypePanel.MetaTypes.Enum) { @@ -1329,7 +1332,7 @@ private void editType(int typeSelectedIndex) CheckTypeName(); // refresh the workspace to load the type - //save(true); + save(true); } } diff --git a/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs b/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs index 29a3b610..a86a6db4 100644 --- a/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs +++ b/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.6.19")] -[assembly: AssemblyFileVersion("3.6.19")] +[assembly: AssemblyVersion("3.6.20")] +[assembly: AssemblyFileVersion("3.6.20")] diff --git a/tools/designer/BehaviacDesignerBase/Workspace.cs b/tools/designer/BehaviacDesignerBase/Workspace.cs index 22e06ba6..54eb6bb8 100644 --- a/tools/designer/BehaviacDesignerBase/Workspace.cs +++ b/tools/designer/BehaviacDesignerBase/Workspace.cs @@ -886,6 +886,11 @@ private string getSourceMetaPath(bool isSaving = false) metaFile = this.FileName.Replace(".workspace.xml", ".meta.xml"); string metaDir = Path.Combine(this.SourceFolder, "behaviac_meta"); + if (!File.Exists(metaFile) && !Directory.Exists(metaDir)) + { + Directory.CreateDirectory(metaDir); + } + string tmpMetaFile = Path.GetFileName(metaFile); tmpMetaFile = Path.Combine(metaDir, tmpMetaFile); @@ -905,10 +910,16 @@ private string getSourceMetaPath(bool isSaving = false) } else if (!File.Exists(metaFile)) { - metaFile = Path.Combine(this.SourceFolder, "behaviac.bb.xml"); + string bbFile = Path.Combine(this.SourceFolder, "behaviac.bb.xml"); + if (File.Exists(bbFile)) + { + metaFile = bbFile; + } + else + { + metaFile = tmpMetaFile; + } } - - Debug.Check(isSaving || File.Exists(metaFile)); } catch (Exception e) { diff --git a/tutorials/CsTutorials/behaviac/runtime/version.txt b/tutorials/CsTutorials/behaviac/runtime/version.txt index 4fab9097..0e0cf259 100644 --- a/tutorials/CsTutorials/behaviac/runtime/version.txt +++ b/tutorials/CsTutorials/behaviac/runtime/version.txt @@ -1 +1 @@ -3.6.19 +3.6.20 diff --git a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt index 4fab9097..0e0cf259 100644 --- a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt +++ b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt @@ -1 +1 @@ -3.6.19 +3.6.20 diff --git a/version.txt b/version.txt index 4fab9097..0e0cf259 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.6.19 +3.6.20