Skip to content

Commit

Permalink
3.6.26
Browse files Browse the repository at this point in the history
  • Loading branch information
cainhuang committed Mar 23, 2017
1 parent 42062e1 commit 2714d14
Show file tree
Hide file tree
Showing 167 changed files with 3,174 additions and 3,063 deletions.
3 changes: 2 additions & 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.25)
set (BEHAVIAC_PACKAGE_VERSION 3.6.26)

#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 Expand Up @@ -410,3 +410,4 @@ add_subdirectory ("${PROJECT_SOURCE_DIR}/tutorials/tutorial_3/cpp")
add_subdirectory ("${PROJECT_SOURCE_DIR}/tutorials/tutorial_4/cpp")
add_subdirectory ("${PROJECT_SOURCE_DIR}/tutorials/tutorial_5/cpp")
add_subdirectory ("${PROJECT_SOURCE_DIR}/tutorials/tutorial_6/cpp")
add_subdirectory ("${PROJECT_SOURCE_DIR}/tutorials/tutorial_7/cpp")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/Tencent/behaviac/blob/master/license.txt)
[![Release Version](https://img.shields.io/badge/release-3.6.25-red.svg)](https://github.com/Tencent/behaviac/releases)
[![Release Version](https://img.shields.io/badge/release-3.6.26-red.svg)](https://github.com/Tencent/behaviac/releases)
[![Updates](https://img.shields.io/badge/Platform-iOS | Android | Windows | Linux | Unity -brightgreen.svg)](https://github.com/Tencent/behaviac/blob/master/history.txt)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/behaviac/pulls)

Expand Down
Binary file modified docs/behaviac.chm
Binary file not shown.
7 changes: 7 additions & 0 deletions history.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2017-3-23 3.6.26
Support renaming the types.
Do not send the update message when debugging.
Fix a bug for setting the var when debugging for C#.
Fix a bug for generating codes for Agent* as the return type of the method.
Fix a bug for renaming the method.

2017-3-16 3.6.25
Support renaming types.
Add the tutorial_6 projects.
Expand Down
2 changes: 2 additions & 0 deletions inc/behaviac/agent/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ namespace behaviac {
*/
void LogVariables(bool bForce);

void LogRunningNodes();

//static bool Invoke(Agent* pAgent, const char* methodName);

//template <typename P1>
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.25"
#define BEHAVIAC_VERSION_STRING "3.6.26"

2 changes: 1 addition & 1 deletion inc/behaviac/common/member.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ namespace behaviac {
const RealBaseType& currentValue = pAgent->GetVariable<RealBaseType>(name);

if (bForce || OperationUtils::Compare<RealBaseType>(currentValue, this->value, E_NOTEQUAL)) {
behaviac::string valueStr = StringUtils::ToString(this->value);
behaviac::string valueStr = StringUtils::ToString(currentValue);
behaviac::string typeName = GetClassTypeName((RealBaseType*)0);

LogManager::GetInstance()->Log(pAgent, typeName.c_str(), name, valueStr.c_str());
Expand Down
24 changes: 23 additions & 1 deletion integration/demo_running/behaviac/Agent/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void Awake()
Init_(this.m_contextId, this, this.m_priority);

#if !BEHAVIAC_RELEASE
this.SetName(this.name);
//this.SetName(this.name);
this._members.Clear();
#endif
}
Expand Down Expand Up @@ -1366,6 +1366,27 @@ public void LogVariables(bool bForce)
}
}

#endif
}

public void LogRunningNodes()
{
#if !BEHAVIAC_RELEASE
if (Config.IsLoggingOrSocketing && this.m_currentBT != null)
{
List<BehaviorTask> runningNodes = this.m_currentBT.GetRunningNodes(false);

foreach (BehaviorTask behaviorTask in runningNodes)
{
string btStr = BehaviorTask.GetTickInfo(this, behaviorTask, "enter");

//empty btStr is for internal BehaviorTreeTask
if (!string.IsNullOrEmpty(btStr))
{
LogManager.Instance.Log(this, btStr, EActionResult.EAR_success, LogMode.ELM_tick);
}
}
}
#endif
}

Expand All @@ -1382,6 +1403,7 @@ protected static void Init_(int contextId, Agent pAgent, int priority)
pAgent.m_contextId = contextId;
pAgent.m_id = ms_agent_index++;
pAgent.m_priority = priority;
pAgent.SetName(pAgent.name);

Context.AddAgent(pAgent);

Expand Down
2 changes: 2 additions & 0 deletions integration/demo_running/behaviac/Agent/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ private void LogCurrentState()
if (e.Current.IsMasked())
{
e.Current.LogVariables(true);

e.Current.LogRunningNodes();
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions integration/demo_running/behaviac/Base/LogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ public void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode
//[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:update [1]
int count = Workspace.Instance.UpdateActionCount(btMsg);

string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);
if (actionResultStr != "running")
{
string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

Output(pAgent, buffer);
Output(pAgent, buffer);
}
}
else if (mode == LogMode.ELM_jump)
{
Expand Down
73 changes: 41 additions & 32 deletions integration/demo_running/behaviac/Base/socketconnect_base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ public void AddPacket(Packet packet)
}
}

m_packetQueue.Enqueue(packet);
lock (m_packetQueue)
{
m_packetQueue.Enqueue(packet);
}
}
}

Expand All @@ -577,23 +580,11 @@ public bool CollectPackets(PacketCollection coll)
return true;
}

Packet packet = m_packetQueue.Peek();

while (packet == null)
lock (m_packetQueue)
{
m_packetQueue.Dequeue();

if (m_packetQueue.Count == 0)
{
break;
}

packet = m_packetQueue.Peek();
}
Packet packet = m_packetQueue.Peek();

while (packet != null)
{
if (coll.Add(packet))
while (packet == null)
{
m_packetQueue.Dequeue();

Expand All @@ -604,9 +595,24 @@ public bool CollectPackets(PacketCollection coll)

packet = m_packetQueue.Peek();
}
else

while (packet != null)
{
return false;
if (coll.Add(packet))
{
m_packetQueue.Dequeue();

if (m_packetQueue.Count == 0)
{
break;
}

packet = m_packetQueue.Peek();
}
else
{
return false;
}
}
}

Expand All @@ -617,24 +623,27 @@ public bool CollectPackets(PacketCollection coll)

private void SendPackets(Socket h)
{
Packet packet = m_packetQueue.Peek();

while (packet != null)
lock (m_packetQueue)
{
int bytesWritten = (0);
bool success = SocketBase.Write(h, packet.GetData(), ref bytesWritten);
Packet packet = m_packetQueue.Peek();

// Failed to send data. Most probably sending too much, break and
// hope for the best next time
if (!success)
while (packet != null)
{
Debug.Check(false);
behaviac.Debug.LogWarning("A packet is not correctly sent...\n");
break;
}
int bytesWritten = (0);
bool success = SocketBase.Write(h, packet.GetData(), ref bytesWritten);

// Failed to send data. Most probably sending too much, break and
// hope for the best next time
if (!success)
{
Debug.Check(false);
behaviac.Debug.LogWarning("A packet is not correctly sent...\n");
break;
}

m_packetQueue.Dequeue(); // 'Commit' pop if data sent.
packet = m_packetQueue.Peek();
m_packetQueue.Dequeue(); // 'Commit' pop if data sent.
packet = m_packetQueue.Peek();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public static string GetTickInfo(Agent pAgent, BehaviorNode n, string action)

if (Config.IsLoggingOrSocketing)
{
if (pAgent != null && pAgent.IsMasked())
if (!System.Object.ReferenceEquals(pAgent, null) && pAgent.IsMasked())
{
//BEHAVIAC_PROFILE("GetTickInfo", true);

Expand Down
4 changes: 3 additions & 1 deletion integration/demo_running/behaviac/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,13 +1217,15 @@ private void ParseProperty(string[] tokens)
#endif
}

private int m_frame = 0;

protected void LogFrames()
{
#if !BEHAVIAC_RELEASE

if (Config.IsLoggingOrSocketing)
{
LogManager.Instance.Log("[frame]{0}\n", this.FrameSinceStartup);
LogManager.Instance.Log("[frame]{0}\n", (this.FrameSinceStartup >= 0) ? this.FrameSinceStartup : (this.m_frame++));
}

#endif
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.25
3.6.26
24 changes: 23 additions & 1 deletion integration/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void Awake()
Init_(this.m_contextId, this, this.m_priority);

#if !BEHAVIAC_RELEASE
this.SetName(this.name);
//this.SetName(this.name);
this._members.Clear();
#endif
}
Expand Down Expand Up @@ -1366,6 +1366,27 @@ public void LogVariables(bool bForce)
}
}

#endif
}

public void LogRunningNodes()
{
#if !BEHAVIAC_RELEASE
if (Config.IsLoggingOrSocketing && this.m_currentBT != null)
{
List<BehaviorTask> runningNodes = this.m_currentBT.GetRunningNodes(false);

foreach (BehaviorTask behaviorTask in runningNodes)
{
string btStr = BehaviorTask.GetTickInfo(this, behaviorTask, "enter");

//empty btStr is for internal BehaviorTreeTask
if (!string.IsNullOrEmpty(btStr))
{
LogManager.Instance.Log(this, btStr, EActionResult.EAR_success, LogMode.ELM_tick);
}
}
}
#endif
}

Expand All @@ -1382,6 +1403,7 @@ protected static void Init_(int contextId, Agent pAgent, int priority)
pAgent.m_contextId = contextId;
pAgent.m_id = ms_agent_index++;
pAgent.m_priority = priority;
pAgent.SetName(pAgent.name);

Context.AddAgent(pAgent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ private void LogCurrentState()
if (e.Current.IsMasked())
{
e.Current.LogVariables(true);

e.Current.LogRunningNodes();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ public void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode
//[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:update [1]
int count = Workspace.Instance.UpdateActionCount(btMsg);

string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);
if (actionResultStr != "running")
{
string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

Output(pAgent, buffer);
Output(pAgent, buffer);
}
}
else if (mode == LogMode.ELM_jump)
{
Expand Down
Loading

0 comments on commit 2714d14

Please sign in to comment.