diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 4b99b79..6aedb49 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -59,7 +59,7 @@ function _M.dailyBuyRpc(agent , data) return 3 end - if not role:costDiamond({count = cost * count}, {log = {desc = "dailyShop", int1 = id, int2 = count}}) then + if not role:costDiamond({count = cost * count, log = {desc = "dailyShop", int1 = id, int2 = count}}) then return 4 end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 3864173..740b40d 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -71,6 +71,10 @@ local commonRoleField = { rmbC = "integer", } +local function printError(info) + print(info) + print(debug.traceback()) +end local function checkType(logType, field, value, ctype) local typecheckfunc = { @@ -78,10 +82,10 @@ local function checkType(logType, field, value, ctype) --长度不超过256 if type(value) ~= "string" then value = tostring(value) - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [keyword], value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [keyword], value : %s", logType, field, value)) else if #value > 256 then - print(string.format("LOG ERROR: logType [%s] field [%s] [keyword] type to long. value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] [keyword] type to long. value : %s", logType, field, value)) end end return value @@ -89,26 +93,26 @@ local function checkType(logType, field, value, ctype) text = function() if type(value) ~= "string" then value = tostring(value) - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [text], value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [text], value : %s", logType, field, value)) end return value end, integer = function() if type(value) ~= "number" then value = tonumber(value) - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], value : %s", logType, field, value)) end if value then if math.type(value) ~= "integer" then local oldValue = value value = math.floor(value) if value ~= oldValue then - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], is float, value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], is float, value : %s", logType, field, value)) end end if -2147483648 > value or value > 2147483647 then + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], too big, value : %s", logType, field, value)) value = nil - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], too big, value : %s", logType, field, value)) end end return value @@ -116,20 +120,20 @@ local function checkType(logType, field, value, ctype) short = function() if type(value) ~= "number" then value = tonumber(value) - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], value : %s", logType, field, value)) end if value then if math.type(value) ~= "integer" then local oldValue = value value = math.floor(value) if value ~= oldValue then - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], is float, value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], is float, value : %s", logType, field, value)) end end if -32768 > value or value > 32768 then + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], too big, value : %s", logType, field, value)) value = nil - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], too big, value : %s", logType, field, value)) end end return value @@ -137,17 +141,17 @@ local function checkType(logType, field, value, ctype) long = function() if type(value) ~= "number" then value = tonumber(value) - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], value : %s", logType, field, value)) end if value then if math.type(value) ~= "integer" then local oldValue = value value = math.floor(value) if type(value) ~= "integer" then + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], too big, value : %s", logType, field, value)) value = nil - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], too big, value : %s", logType, field, value)) elseif value ~= oldValue then - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], is float, value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], is float, value : %s", logType, field, value)) end end end @@ -156,7 +160,7 @@ local function checkType(logType, field, value, ctype) float = function() if type(value) ~= "number" then value = tonumber(value) - print(string.format("LOG ERROR: logType [%s] field [%s] isn't [float], value : %s", logType, field, value)) + printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [float], value : %s", logType, field, value)) end return value end, @@ -165,7 +169,7 @@ local function checkType(logType, field, value, ctype) if typecheckfunc[ctype] then return typecheckfunc[ctype]() else - print(string.format("LOG ERROR: logType [%s] field [%s] have a new type [%s] need add check.", logType, field, ctype)) + printError(string.format("LOG ERROR: logType [%s] field [%s] have a new type [%s] need add check.", logType, field, ctype)) return nil end end @@ -176,13 +180,13 @@ function RoleLog.bind(Role) contents = contents or {} local _logType = LogType[logType] if not _logType then - print(string.format("LOG ERROR: new logType [%s] need Add Maping.", logType)) + printError(string.format("LOG ERROR: new logType [%s] need Add Maping.", logType)) return end local doc = {} for field, ctype in pairs(commonRoleField) do if contents[field] then - print(string.format("LOG ERROR: logType [%s] had field [%s] overwrite default.", logType, field)) + printError(string.format("LOG ERROR: logType [%s] had field [%s] overwrite default.", logType, field)) end doc[field] = checkType("commonRoleField", field, self:getProperty(field), ctype) end @@ -197,7 +201,7 @@ function RoleLog.bind(Role) if ftype then doc[field] = checkType(logType, field, value, ftype) else - print(string.format("LOG ERROR: logType [%s] have new field [%s] no type in mapping.", logType, field)) + printError(string.format("LOG ERROR: logType [%s] have new field [%s] no type in mapping.", logType, field)) end end if not logd then return end -- libgit2 0.21.2