修复特殊情况下尝试显示用户头像时会报错
This commit is contained in:
@@ -29,10 +29,7 @@ end
|
|||||||
|
|
||||||
local db_img={}
|
local db_img={}
|
||||||
local db=setmetatable({},{__index=function(self,uid)
|
local db=setmetatable({},{__index=function(self,uid)
|
||||||
if not uid then
|
if not uid then return emptyUser end
|
||||||
db_img[uid]=defaultAvatar[1]
|
|
||||||
return emptyUser
|
|
||||||
end
|
|
||||||
local file="cache/user"..uid..".dat"
|
local file="cache/user"..uid..".dat"
|
||||||
local d=fs.getInfo(file)and JSON.decode(fs.read(file))or TABLE.copy(emptyUser)
|
local d=fs.getInfo(file)and JSON.decode(fs.read(file))or TABLE.copy(emptyUser)
|
||||||
rawset(self,uid,d)
|
rawset(self,uid,d)
|
||||||
@@ -65,11 +62,15 @@ function USERS.getUsername(uid)return db[uid].username end
|
|||||||
function USERS.getMotto(uid)return db[uid].motto end
|
function USERS.getMotto(uid)return db[uid].motto end
|
||||||
function USERS.getHash(uid)return db[uid].hash end
|
function USERS.getHash(uid)return db[uid].hash end
|
||||||
function USERS.getAvatar(uid)
|
function USERS.getAvatar(uid)
|
||||||
if not db[uid].new then
|
if uid then
|
||||||
NET.getUserInfo(uid)
|
if not db[uid].new then
|
||||||
db[uid].new=true
|
NET.getUserInfo(uid)
|
||||||
|
db[uid].new=true
|
||||||
|
end
|
||||||
|
return db_img[uid]
|
||||||
|
else
|
||||||
|
return defaultAvatar[1]
|
||||||
end
|
end
|
||||||
return db_img[uid]
|
|
||||||
end
|
end
|
||||||
function USERS.forceFreshAvatar()
|
function USERS.forceFreshAvatar()
|
||||||
for _,U in next,db do
|
for _,U in next,db do
|
||||||
|
|||||||
Reference in New Issue
Block a user