Skip to content

Commit

Permalink
discordRPC和FMOD使用更安全的log方式
Browse files Browse the repository at this point in the history
框架跟进
  • Loading branch information
MrZ626 committed Nov 18, 2024
1 parent 4be046c commit aeb98b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Zenitha
Submodule Zenitha updated 4 files
+12 −2 init.lua
+14 −0 message.lua
+7 −0 stringExtend.lua
+0 −0 sysRequire.lua
6 changes: 3 additions & 3 deletions assets/discordRPC.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ if SYSTEM=='Windows' then
local suc
suc,Cname=pcall(ffi.load,"discord-rpc")
if not (suc and Cname) then
LOG("Error in Loading Discord-RPC lib: "..Cname)
MSG.errorLog("Loading Discord-RPC lib: "..Cname)
Cname=nil
end
elseif MOBILE then
LOG("No Discord-RPC for mobile devices yet")
LOG(STRING.repD("No Discord-RPC for current platform ($1)",SYSTEM))
else
LOG("Waiting Discord-RPC for other platforms")
MSG.warnLog(STRING.repD("Waiting Discord-RPC for current platform ($1)",SYSTEM))
end

if Cname then
Expand Down
21 changes: 10 additions & 11 deletions assets/fmod20221/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Skip FMOD on web for now
if SYSTEM=='Web' then
local NOLL={}
setmetatable(NOLL,{__call=NULL,__index=function() return NOLL end})
Expand All @@ -20,11 +21,11 @@ require'cdef'
local M=require'master'
M.banks={}

-- (Old method) search for fmod shared libraries in package.cpath
-- --(Old method) search for fmod shared libraries in package.cpath
-- local fmodPath=package.searchpath('fmod',package.cpath)
-- local fmodstudioPath=package.searchpath('fmodstudio',package.cpath)
-- -- pretend to load libfmod through Lua (it's going to fail but not raise any errors) so that its location is known when loading libfmodstudio through ffi
-- -- package.loadlib(fmodPath,"")
-- --pretend to load libfmod through Lua (it's going to fail but not raise any errors) so that its location is known when loading libfmodstudio through ffi
-- package.loadlib(fmodPath,"")
-- M.C=ffi.load(fmodPath)
-- M.C2=ffi.load(fmodstudioPath)

Expand All @@ -36,18 +37,18 @@ do -- Load library
local suc
suc,M.C=pcall(ffi.load,STRING.repD(path,'fmod'))
if not suc then
MSG.new('error',"Loading FMOD lib:"..M.C)
MSG.errorLog("Loading FMOD lib:"..M.C)
M.C=nil
elseif not M.C then
MSG.new('error',"Error in Loading FMOD lib")
MSG.errorLog("Loaded an empty FMOD lib")
end

suc,M.C2=pcall(ffi.load,STRING.repD(path,'fmodstudio'))
if not suc then
MSG.new('error',"Loading FMODstudio lib:"..M.C2)
MSG.errorLog("Loading FMODstudio lib:"..M.C2)
M.C2=nil
elseif not M.C2 then
MSG.new('error',"Error in Loading FMODstudio lib")
MSG.errorLog("Loaded an empty FMODstudio lib")
end
end

Expand Down Expand Up @@ -100,8 +101,7 @@ function M.loadBank(path,flag)
if not studio then return end
local bank,res=studio:loadBankFile(path,flag or M.FMOD_STUDIO_LOAD_BANK_NORMAL)
if res~=M.FMOD_OK then
LOG("FMOD loadBank error: "..M.errorString[res])
MSG.new('warn',"FMOD loadBank error: "..M.errorString[res])
MSG.errorLog("FMOD loadBank error: "..M.errorString[res])
return
end
M.banks[path]=bank
Expand All @@ -123,8 +123,7 @@ function M.loadBank2(path,flag)
local bank,res=studio:loadBankMemory(data:getPointer(),size,0,flag or M.FMOD_STUDIO_LOAD_BANK_NORMAL)
file:close(); file:release(); data:release()
if res~=M.FMOD_OK then
LOG("FMOD loadBankMemory error: "..M.errorString[res])
MSG.new('warn',"FMOD loadBankMemory error: "..M.errorString[res])
MSG.errorLog("FMOD loadBankMemory error: "..M.errorString[res])
return
end
M.banks[path]=bank
Expand Down

0 comments on commit aeb98b2

Please sign in to comment.