Skip to content

Commit

Permalink
更新到0.8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxq committed Jun 29, 2016
1 parent 4fd67d3 commit 2530560
Show file tree
Hide file tree
Showing 54 changed files with 391 additions and 162 deletions.
9 changes: 0 additions & 9 deletions Assets/IGSoft_Resources/Scripts/Unity.meta

This file was deleted.

9 changes: 0 additions & 9 deletions Assets/IGSoft_Resources/Scripts/User.meta

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
由于每个数据包都有最大上限, 向Bundle中写入大量数据将会在内部产生多个MemoryStream
在send时会全部发送出去
*/
public class Bundle
public class Bundle : ObjectPool<Bundle>
{
public MemoryStream stream = new MemoryStream();
public MemoryStream stream = MemoryStream.createObject();
public List<MemoryStream> streamList = new List<MemoryStream>();
public int numMessage = 0;
public int messageLength = 0;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void fini(bool issend)
writeMsgLength();

streamList.Add(stream);
stream = new MemoryStream();
stream = MemoryStream.createObject();
}

if(issend)
Expand Down Expand Up @@ -90,17 +90,29 @@ public void send(NetworkInterface networkInterface)
{
Dbg.ERROR_MSG("Bundle::send: networkInterface invalid!");
}


// 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗
for (int i = 0; i < streamList.Count; ++i)
{
streamList[i].reclaimObject();
}
streamList.Clear();
stream.clear();

// 我们认为,发送完成,就视为这个bundle不再使用了,
// 所以我们会把它放回对象池,以减少垃圾回收带来的消耗,
// 如果需要继续使用,应该重新Bundle.createObject(),
// 如果外面不重新createObject()而直接使用,就可能会出现莫名的问题,
// 仅以此备注,警示使用者。
Bundle.reclaimObject(this);
}

public void checkStream(int v)
{
if(v > stream.space())
{
streamList.Add(stream);
stream = new MemoryStream();
stream = MemoryStream.createObject();
++ _curMsgStreamIndex;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/
public class Entity
{
// 当前玩家最后一次同步到服务端的位置与朝向
// 这两个属性是给引擎KBEngine.cs用的,别的地方不要修改
public Vector3 _entityLastLocalPos = new Vector3(0f, 0f, 0f);
public Vector3 _entityLastLocalDir = new Vector3(0f, 0f, 0f);

public Int32 id = 0;
public string className = "";
public Vector3 position = new Vector3(0.0f, 0.0f, 0.0f);
Expand All @@ -26,6 +31,12 @@ public class Entity

// enterworld之后设置为true
public bool inWorld = false;

/// <summary>
/// 对于玩家自身来说,它表示是否自己被其它玩家控制了;
/// 对于其它entity来说,表示我本机是否控制了这个entity
/// </summary>
public bool isControlled = false;

// __init__调用之后设置为true
public bool inited = false;
Expand Down Expand Up @@ -368,6 +379,19 @@ public virtual void set_direction(object old)
if(inWorld)
Event.fireOut("set_direction", new object[]{this});
}

/// <summary>
/// This callback method is called when the local entity control by the client has been enabled or disabled.
/// See the Entity.controlledBy() method in the CellApp server code for more infomation.
/// </summary>
/// <param name="isControlled">
/// 对于玩家自身来说,它表示是否自己被其它玩家控制了;
/// 对于其它entity来说,表示我本机是否控制了这个entity
/// </param>
public virtual void onControlled(bool isControlled_)
{

}
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class EntityDef
{
// 所有的数据类型
public static Dictionary<string, Int32> datatype2id = new Dictionary<string, Int32>();
public static Dictionary<string, UInt16> datatype2id = new Dictionary<string, UInt16>();
public static Dictionary<string, KBEDATATYPE_BASE> datatypes = new Dictionary<string, KBEDATATYPE_BASE>();
public static Dictionary<UInt16, KBEDATATYPE_BASE> id2datatypes = new Dictionary<UInt16, KBEDATATYPE_BASE>();

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,17 @@ private static bool deregister(Dictionary<string, List<Pair>> events, object obj
{
monitor_Enter(events);

foreach(KeyValuePair<string, List<Pair>> e in events)
var iter = events.GetEnumerator();
while (iter.MoveNext())
{
List<Pair> lst = e.Value;
__RESTART_REMOVE:
for(int i=0; i<lst.Count; i++)
List<Pair> lst = iter.Current.Value;
// 从后往前遍历,以避免中途删除的问题
for (int i = lst.Count - 1; i >= 0; i--)
{
if(obj == lst[i].obj)
if (obj == lst[i].obj)
{
//Dbg.DEBUG_MSG("Event::deregister: event(" + e.Key + ":" + lst[i].funcname + ")!");
lst.RemoveAt(i);
goto __RESTART_REMOVE;
}
}
}
Expand Down Expand Up @@ -298,9 +298,10 @@ public static void processOutEvents()

if(firedEvents_out.Count > 0)
{
foreach(EventObj evt in firedEvents_out)
var iter = firedEvents_out.GetEnumerator();
while (iter.MoveNext())
{
doingEvents_out.AddLast(evt);
doingEvents_out.AddLast(iter.Current);
}

firedEvents_out.Clear();
Expand Down Expand Up @@ -338,9 +339,10 @@ public static void processInEvents()

if(firedEvents_in.Count > 0)
{
foreach(EventObj evt in firedEvents_in)
var iter = firedEvents_in.GetEnumerator();
while (iter.MoveNext())
{
doingEvents_in.AddLast(evt);
doingEvents_in.AddLast(iter.Current);
}

firedEvents_in.Clear();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2530560

Please sign in to comment.