Skip to content

Commit

Permalink
3.6.20
Browse files Browse the repository at this point in the history
  • Loading branch information
cainhuang committed Feb 24, 2017
1 parent df7c66c commit b892bc3
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 98 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Binary file modified docs/behaviac.chm
Binary file not shown.
3 changes: 3 additions & 0 deletions history.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion inc/behaviac/common/_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#define BEHAVIAC_RELEASE 0
#endif

#define BEHAVIAC_VERSION_STRING "3.6.19"
#define BEHAVIAC_VERSION_STRING "3.6.20"

6 changes: 3 additions & 3 deletions inc/behaviac/common/member.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ namespace behaviac {

const behaviac::vector<ElementType>& vec = *(const behaviac::vector<ElementType>*)pData;

return vec.size();
return (int)vec.size();
}

CInstanceMember(CInstanceMember& rhs) {
Expand Down Expand Up @@ -1482,7 +1482,7 @@ namespace behaviac {

virtual const void* GetValueElement(const behaviac::Agent* self, int index) const {
const behaviac::vector<T>& arrayValue = self->GetVariable<behaviac::vector<T> >(_parentId);
int len = arrayValue.size();
int len = (int)arrayValue.size();
BEHAVIAC_UNUSED_VAR(len);

BEHAVIAC_ASSERT(len != 0);
Expand Down Expand Up @@ -1533,7 +1533,7 @@ namespace behaviac {

virtual const void* GetValueElement(const behaviac::Agent* self, int index) const {
const behaviac::vector<bool>& arrayValue = self->GetVariable<behaviac::vector<bool> >(_parentId);
int len = arrayValue.size();
int len = (int)arrayValue.size();
BEHAVIAC_UNUSED_VAR(len);

BEHAVIAC_ASSERT(len != 0);
Expand Down
10 changes: 5 additions & 5 deletions inc/behaviac/common/rapidxml/rapidxml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -608,7 +608,7 @@ namespace behaviac
//! </code><br>
//! \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;
Expand Down Expand Up @@ -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
};

///////////////////////////////////////////////////////////////////////////
Expand Down
18 changes: 9 additions & 9 deletions inc/behaviac/common/string/stringutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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++];
Expand All @@ -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) {
Expand Down Expand Up @@ -657,7 +657,7 @@ namespace behaviac {

bool bBeginIndex = false;

int strLen = ::strlen(str);
int strLen = (int)::strlen(str);

while (i < strLen) {
bool bFound = false;
Expand Down
2 changes: 1 addition & 1 deletion integration/demo_running/behaviac/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.19
3.6.20
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.19
3.6.20
13 changes: 4 additions & 9 deletions src/common/file/listfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)]);
Expand Down
54 changes: 9 additions & 45 deletions src/common/file/listfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <errno.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <tchar.h>
#else
# include <dirent.h>
# include <libgen.h>
# include <sys/stat.h>
# include <stddef.h>
#endif
#ifdef __MINGW32__
# include <tchar.h>
#endif

#if (defined _MSC_VER || defined __MINGW32__)
#if (defined _MSC_VER)
#include <windows.h>
#define _LISTFILES_PATH_MAX MAX_PATH
#elif defined __linux__
Expand All @@ -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
Expand All @@ -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;

Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/common/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -624,9 +624,9 @@ namespace behaviac {
}

behaviac::vector<behaviac::string> 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<behaviac::string> params_;
Expand All @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -773,7 +773,7 @@ namespace behaviac {

if (index == 0) { // array type
// Get item type, i.e. vector<int>
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;
Expand Down
2 changes: 1 addition & 1 deletion src/common/socket/socketconnect_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/htn/agentstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
Loading

0 comments on commit b892bc3

Please sign in to comment.