Skip to content

Commit

Permalink
kbe升级到0.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxq committed Dec 19, 2016
1 parent 0bd3615 commit 30852f8
Show file tree
Hide file tree
Showing 25 changed files with 72 additions and 396 deletions.
2 changes: 1 addition & 1 deletion Assets/StriveGame/Lua/KbePlugins/Bundle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function KBEngineLua.Bundle:send()
if(networkInterface:valid()) then
for i = 1, #self.streamList, 1 do
self.stream = self.streamList[i];
networkInterface:send(self.stream:getbuffer());
networkInterface:send(self.stream);
end
else
log("Bundle::send: networkInterface invalid!");
Expand Down
56 changes: 28 additions & 28 deletions Assets/StriveGame/Lua/KbePlugins/KBEngine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ KBEngineLua._clientdatas = {};
KBEngineLua._encryptedKey = "";

-- 服务端与客户端的版本号以及协议MD5
KBEngineLua.clientVersion = "0.8.10";
KBEngineLua.clientVersion = "0.9.0";
KBEngineLua.clientScriptVersion = "0.1.0";
KBEngineLua.serverVersion = "";
KBEngineLua.serverScriptVersion = "";
Expand All @@ -81,7 +81,7 @@ KBEngineLua.entityIDAliasIDList = {};
KBEngineLua.bufferedCreateEntityMessage = {};

-- 持久化
KBEngineLua._persistentInofs = nil;
KBEngineLua._persistentInfos = nil;

-- 是否正在加载本地消息协议
KBEngineLua.loadingLocalMessages_ = false;
Expand Down Expand Up @@ -116,7 +116,7 @@ end
KBEngineLua.InitEngine = function()
this._networkInterface = KBEngine.NetworkInterface.New();
KBEngineLua.Message.bindFixedMessage();
this._persistentInofs = KBEngine.PersistentInofs.New(Util.DataPath);
this._persistentInfos = KBEngine.PersistentInofs.New(Util.DataPath);

FixedUpdateBeat:Add(this.process, this);
end
Expand Down Expand Up @@ -252,8 +252,8 @@ end
KBEngineLua.Client_onImportClientEntityDef = function(stream)
local datas = stream:getbuffer();
this.onImportClientEntityDef(stream);
if(this._persistentInofs ~= nil) then
this._persistentInofs:onImportClientEntityDef(datas);
if(this._persistentInfos ~= nil) then
this._persistentInfos:onImportClientEntityDef(datas);
end
end

Expand All @@ -262,19 +262,19 @@ KBEngineLua.onImportClientEntityDef = function(stream)

while(stream:length() > 0)
do
local scriptmethod_name = stream:readString();
local scriptmodule_name = stream:readString();
local scriptUtype = stream:readUint16();
local propertysize = stream:readUint16();
local methodsize = stream:readUint16();
local base_methodsize = stream:readUint16();
local cell_methodsize = stream:readUint16();

log("KBEngineApp::Client_onImportClientEntityDef: import(" .. scriptmethod_name .. "), propertys(" .. propertysize .. "), " ..
log("KBEngineApp::Client_onImportClientEntityDef: import(" .. scriptmodule_name .. "), propertys(" .. propertysize .. "), " ..
"clientMethods(" .. methodsize .. "), baseMethods(" .. base_methodsize .. "), cellMethods(" .. cell_methodsize .. ")~");

KBEngineLua.moduledefs[scriptmethod_name] = {};
local currModuleDefs = KBEngineLua.moduledefs[scriptmethod_name];
currModuleDefs["name"] = scriptmethod_name;
KBEngineLua.moduledefs[scriptmodule_name] = {};
local currModuleDefs = KBEngineLua.moduledefs[scriptmodule_name];
currModuleDefs["name"] = scriptmodule_name;
currModuleDefs["propertys"] = {};
currModuleDefs["methods"] = {};
currModuleDefs["base_methods"] = {};
Expand All @@ -286,7 +286,7 @@ KBEngineLua.onImportClientEntityDef = function(stream)
local self_base_methods = currModuleDefs["base_methods"];
local self_cell_methods= currModuleDefs["cell_methods"];

local Class = KBEngineLua[scriptmethod_name];
local Class = KBEngineLua[scriptmodule_name];

while(propertysize > 0)
do
Expand Down Expand Up @@ -314,7 +314,7 @@ KBEngineLua.onImportClientEntityDef = function(stream)
currModuleDefs["usePropertyDescrAlias"] = false;
end

log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), property(" .. name .. "/" .. properUtype .. ").");
log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), property(" .. name .. "/" .. properUtype .. ").");
end
while(methodsize > 0)
do
Expand Down Expand Up @@ -343,7 +343,7 @@ KBEngineLua.onImportClientEntityDef = function(stream)
currModuleDefs["useMethodDescrAlias"] = false;
end

log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), method(" .. name .. ").");
log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), method(" .. name .. ").");
end

while(base_methodsize > 0)
Expand All @@ -363,7 +363,7 @@ KBEngineLua.onImportClientEntityDef = function(stream)
end

self_base_methods[name] = {methodUtype, aliasID, name, args};
log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), base_method(" .. name .. ").");
log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), base_method(" .. name .. ").");
end

while(cell_methodsize > 0)
Expand All @@ -383,12 +383,12 @@ KBEngineLua.onImportClientEntityDef = function(stream)
end

self_cell_methods[name] = {methodUtype, aliasID, name, args};
log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), cell_method(" .. name .. ").");
log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), cell_method(" .. name .. ").");
end

defmethod = KBEngineLua[scriptmethod_name];
defmethod = KBEngineLua[scriptmodule_name];
if defmethod == nil then
log("KBEngineApp::Client_onImportClientEntityDef: module(" .. scriptmethod_name .. ") not found~");
log("KBEngineApp::Client_onImportClientEntityDef: module(" .. scriptmodule_name .. ") not found~");
end

for k, value in pairs(currModuleDefs.propertys) do
Expand All @@ -412,7 +412,7 @@ KBEngineLua.onImportClientEntityDef = function(stream)
local args = infos[4];

if(defmethod ~= nil and defmethod[name] == nil) then
log(scriptmethod_name .. ":: method(" .. name .. ") no implement~");
log(scriptmodule_name .. ":: method(" .. name .. ") no implement~");
end
end
end
Expand All @@ -423,8 +423,8 @@ KBEngineLua.Client_onImportClientMessages = function( stream )
local datas = stream:getbuffer();
this.onImportClientMessages (stream);

if(this._persistentInofs ~= nil) then
this._persistentInofs:onImportClientMessages(this.currserver, datas);
if(this._persistentInfos ~= nil) then
this._persistentInfos:onImportClientMessages(this.currserver, datas);
end
end

Expand Down Expand Up @@ -480,8 +480,8 @@ KBEngineLua.Client_onImportServerErrorsDescr = function(stream)
local datas = stream:getbuffer();
this.onImportServerErrorsDescr(stream);

if(this._persistentInofs ~= nil) then
this._persistentInofs:onImportServerErrorsDescr(datas);
if(this._persistentInfos ~= nil) then
this._persistentInfos:onImportServerErrorsDescr(datas);
end
end

Expand Down Expand Up @@ -1486,8 +1486,8 @@ KBEngineLua.Client_onHelloCB = function( stream )
end

KBEngineLua.onServerDigest = function()
if this._persistentInofs ~= nil then
this._persistentInofs:onServerDigest(this.currserver, this.serverProtocolMD5, this.serverEntitydefMD5);
if this._persistentInfos ~= nil then
this._persistentInfos:onServerDigest(this.currserver, this.serverProtocolMD5, this.serverEntitydefMD5);
end
end

Expand Down Expand Up @@ -1752,8 +1752,8 @@ KBEngineLua.Client_onVersionNotMatch = function(stream)
log("Client_onVersionNotMatch: verInfo=" .. this.clientVersion .. "(server: " .. this.serverVersion .. ")");
--Event.fireAll("onVersionNotMatch", new object[]{clientVersion, serverVersion});

if(this._persistentInofs ~= nil) then
this._persistentInofs:onVersionNotMatch(this.clientVersion, this.serverVersion);
if(this._persistentInfos ~= nil) then
this._persistentInfos:onVersionNotMatch(this.clientVersion, this.serverVersion);
end
end

Expand All @@ -1765,8 +1765,8 @@ KBEngineLua.Client_onScriptVersionNotMatch = function(stream)
log("Client_onScriptVersionNotMatch: verInfo=" .. this.clientScriptVersion .. "(server: " .. this.serverScriptVersion .. ")");
--Event.fireAll("onScriptVersionNotMatch", new object[]{clientScriptVersion, this.serverScriptVersion});

if(_persistentInofs ~= nil) then
_persistentInofs.onScriptVersionNotMatch(this.clientScriptVersion, this.serverScriptVersion);
if(_persistentInfos ~= nil) then
_persistentInfos.onScriptVersionNotMatch(this.clientScriptVersion, this.serverScriptVersion);
end
end

Expand Down
7 changes: 6 additions & 1 deletion Assets/StriveGame/Lua/KbePlugins/Message.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ function KBEngineLua.MessageReader.process(datas, offset, length)
if(msg.msglen == -1) then
reader.state = KBEngineLua.READ_STATE_MSGLEN;
reader.expectSize = 2;
else
elseif(msg.msglen == 0) then
-- 如果是0个参数的消息,那么没有后续内容可读了,处理本条消息并且直接跳到下一条消息
msg:handleMessage(stream);
state = KBEngineLua.READ_STATE_MSGID;
expectSize = 2;
else
reader.expectSize = msg.msglen;
reader.state = KBEngineLua.READ_STATE_BODY;
end
Expand Down
2 changes: 1 addition & 1 deletion Assets/StriveGame/Scripts/Common/LuaLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public LuaLoader() {
public void AddBundle(string bundleName) {
string url = Util.DataPath + bundleName.ToLower();
if (File.Exists(url)) {
AssetBundle bundle = AssetBundle.CreateFromFile(url);
AssetBundle bundle = AssetBundle.LoadFromFile(url);
if (bundle != null)
{
bundleName = bundleName.Replace("lua/", "").Replace(".unity3d", "");
Expand Down
Loading

0 comments on commit 30852f8

Please sign in to comment.