修复节日日期写错

修正简洁模式场景栈搜索有未触发漏洞
整理代码
框架跟进
This commit is contained in:
MrZ_26
2022-11-03 15:11:12 +08:00
parent 9e882e6188
commit b2b5c99425
8 changed files with 29 additions and 33 deletions

View File

@@ -60,13 +60,13 @@ BGM.setMaxSources(5)
VOC.setDiversion(.62) VOC.setDiversion(.62)
WIDGET.setOnChange(function() WIDGET.setOnChange(function()
if SCN.current~='custom_field' then if SCN.cur~='custom_field' then
local colorList=THEME.getThemeColor() local colorList=THEME.getThemeColor()
if not colorList then return end if colorList then
local rnd=math.random for _,W in next,SCN.scenes[SCN.cur].widgetList do
for _,W in next,SCN.scenes[SCN.current].widgetList do if W.color then
if W.color then W.color=colorList[math.random(#colorList)]
W.color=colorList[rnd(#colorList)] end
end end
end end
end end
@@ -218,10 +218,10 @@ do-- Z.setOnFocus
TASK.new(task_autoSoundOn) TASK.new(task_autoSoundOn)
end end
else else
if SCN.current=='game' and SETTING.autoPause then if SCN.cur=='game' and SETTING.autoPause then
pauseGame() pauseGame()
end end
if SETTING.autoMute and SCN.current~='music' then if SETTING.autoMute and SCN.cur~='music' then
TASK.removeTask_code(task_autoSoundOn) TASK.removeTask_code(task_autoSoundOn)
TASK.new(task_autoSoundOff) TASK.new(task_autoSoundOff)
end end

View File

@@ -440,7 +440,7 @@ end
--Remove player when leave --Remove player when leave
local function _playerLeaveRoom(uid) local function _playerLeaveRoom(uid)
if SCN.current=='net_game' then if SCN.cur=='net_game' then
for i=1,#PLAYERS do if PLAYERS[i].uid==uid then table.remove(PLAYERS,i) break end end for i=1,#PLAYERS do if PLAYERS[i].uid==uid then table.remove(PLAYERS,i) break end end
for i=1,#PLY_ALIVE do if PLY_ALIVE[i].uid==uid then table.remove(PLY_ALIVE,i) break end end for i=1,#PLY_ALIVE do if PLY_ALIVE[i].uid==uid then table.remove(PLY_ALIVE,i) break end end
if uid==USER.uid then if uid==USER.uid then
@@ -586,7 +586,7 @@ function NET.wsCallBack.global_getOnlineCount(body)
NET.onlineCount=tonumber(body.data) or "_" NET.onlineCount=tonumber(body.data) or "_"
end end
function NET.wsCallBack.room_chat(body) function NET.wsCallBack.room_chat(body)
if SCN.current=='net_game' then if SCN.cur=='net_game' then
TASK.unlock('receiveMessage') TASK.unlock('receiveMessage')
TASK.lock('receiveMessage',1) TASK.lock('receiveMessage',1)
NET.textBox:push{ NET.textBox:push{
@@ -684,22 +684,22 @@ function NET.wsCallBack.room_fetch(body)
SCN.scenes.net_rooms.widgetList.roomList:setList(body.data) SCN.scenes.net_rooms.widgetList.roomList:setList(body.data)
end end
function NET.wsCallBack.room_setPW() function NET.wsCallBack.room_setPW()
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
MES.new(text.roomPasswordChanged) MES.new(text.roomPasswordChanged)
end end
function NET.wsCallBack.room_remove() function NET.wsCallBack.room_remove()
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
MES.new('info',text.roomRemoved) MES.new('info',text.roomRemoved)
_playerLeaveRoom(USER.uid) _playerLeaveRoom(USER.uid)
end end
function NET.wsCallBack.player_updateConf(body) function NET.wsCallBack.player_updateConf(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
if type(body.data)=='table' then if type(body.data)=='table' then
NETPLY.map[body.data.playerId].config=body.data.config NETPLY.map[body.data.playerId].config=body.data.config
end end
end end
function NET.wsCallBack.player_finish(body) function NET.wsCallBack.player_finish(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
for _,P in next,PLY_ALIVE do for _,P in next,PLY_ALIVE do
if P.uid==body.data.playerId then if P.uid==body.data.playerId then
P.loseTimer=26 P.loseTimer=26
@@ -709,11 +709,11 @@ function NET.wsCallBack.player_finish(body)
end end
end end
function NET.wsCallBack.player_joinGroup(body) function NET.wsCallBack.player_joinGroup(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
NETPLY.map[body.data.playerId].group=body.data.group NETPLY.map[body.data.playerId].group=body.data.group
end end
function NET.wsCallBack.player_setHost(body) function NET.wsCallBack.player_setHost(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
if body.data.role=='Admin' then if body.data.role=='Admin' then
MES.new('info',text.becomeHost:repD(_getFullName(body.data.playerId))) MES.new('info',text.becomeHost:repD(_getFullName(body.data.playerId)))
end end
@@ -722,21 +722,21 @@ end
function NET.wsCallBack.player_setState(body)-- not used function NET.wsCallBack.player_setState(body)-- not used
end end
function NET.wsCallBack.player_stream(body) function NET.wsCallBack.player_stream(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
_pumpStream(body.data) _pumpStream(body.data)
end end
function NET.wsCallBack.player_setPlayMode(body) function NET.wsCallBack.player_setPlayMode(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
NETPLY.map[body.data.playerId].playMode=body.data.type NETPLY.map[body.data.playerId].playMode=body.data.type
NET.freshRoomAllReady() NET.freshRoomAllReady()
end end
function NET.wsCallBack.player_setReadyMode(body) function NET.wsCallBack.player_setReadyMode(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
NETPLY.map[body.data.playerId].readyMode=body.data.isReady and 'Ready' or 'Standby' NETPLY.map[body.data.playerId].readyMode=body.data.isReady and 'Ready' or 'Standby'
NET.freshRoomAllReady() NET.freshRoomAllReady()
end end
function NET.wsCallBack.match_finish() function NET.wsCallBack.match_finish()
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
for _,P in next,PLAYERS do for _,P in next,PLAYERS do
NETPLY.setStat(P.uid,P.stat) NETPLY.setStat(P.uid,P.stat)
end end
@@ -748,7 +748,7 @@ end
function NET.wsCallBack.match_ready()-- not used function NET.wsCallBack.match_ready()-- not used
end end
function NET.wsCallBack.match_start(body) function NET.wsCallBack.match_start(body)
if SCN.current~='net_game' then return end if SCN.cur~='net_game' then return end
TASK.lock('netPlaying') TASK.lock('netPlaying')
NET.seed=body.data and body.data.seed NET.seed=body.data and body.data.seed
if not NET.seed then if not NET.seed then

View File

@@ -2192,7 +2192,7 @@ local function task_autoPause()
while true do while true do
yield() yield()
time=time+1 time=time+1
if SCN.current~='game' or PLAYERS[1].frameRun<180 then if SCN.cur~='game' or PLAYERS[1].frameRun<180 then
return return
elseif time==120 then elseif time==120 then
pauseGame() pauseGame()

View File

@@ -103,7 +103,7 @@ local loadingThread=coroutine.wrap(function()
SFX.play('enter',.8) SFX.play('enter',.8)
SFX.play('welcome') SFX.play('welcome')
VOC.play('welcome') VOC.play('welcome')
THEME.set(THEME.calculate(os.date('%Y'),os.date('%m'),os.date('%d'))) THEME.set(THEME.calculate())
LOADED=true LOADED=true
saveStats() saveStats()
Z.setPowerInfo(SETTING.powerInfo) Z.setPowerInfo(SETTING.powerInfo)

View File

@@ -22,7 +22,7 @@ function scene.sceneInit()
if THEME.cur=='halloween' then if THEME.cur=='halloween' then
TASK.new(function() TASK.new(function()
TEST.yieldT(.26) TEST.yieldT(.26)
while SCN.current=='main' do while SCN.cur=='main' do
flash=.355 flash=.355
SFX.play('clear_'..math.random(4,6),1,math.random()*2-1,-9-math.random()*3) SFX.play('clear_'..math.random(4,6),1,math.random()*2-1,-9-math.random()*3)
TEST.yieldT(.626+math.random()*6.26) TEST.yieldT(.626+math.random()*6.26)

View File

@@ -51,12 +51,8 @@ scene.widgetList={
WIDGET.newSwitch{name='simpMode', x=960, y=670, lim=480, disp=SETval('simpMode'), WIDGET.newSwitch{name='simpMode', x=960, y=670, lim=480, disp=SETval('simpMode'),
code=function() code=function()
SETTING.simpMode=not SETTING.simpMode SETTING.simpMode=not SETTING.simpMode
for i=1,#SCN.stack,2 do local p=TABLE.find(SCN.stack,'main') or TABLE.find(SCN.stack,'main_simple')
if SCN.stack[i]=='main' or SCN.stack[i]=='main_simple' then SCN.stack[p]=SETTING.simpMode and 'main_simple' or 'main'
SCN.stack[i]=SETTING.simpMode and 'main_simple' or 'main'
break
end
end
end}, end},
WIDGET.newButton{name='back', x=1140, y=640, w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene}, WIDGET.newButton{name='back', x=1140, y=640, w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
} }

View File

@@ -4,7 +4,7 @@ local THEME={
local themeColor={ local themeColor={
xmas={COLOR.lR,COLOR.Z,COLOR.lG}, xmas={COLOR.lR,COLOR.Z,COLOR.lG},
sprfes={COLOR.lR,COLOR.O,COLOR.lY}, sprfes={COLOR.lR,COLOR.O,COLOR.lY},
halloween={COLOR.lH,COLOR.O,{COLOR.hsv(0.76, 0.50, 0.42)},{COLOR.hsv(0.33, 0.80, 0.42)}}, halloween={COLOR.lH,COLOR.O,{COLOR.hsv(.76,.50,.42)},{COLOR.hsv(.33,.80,.42)}},
} }
function THEME.calculate(Y,M,D) function THEME.calculate(Y,M,D)
@@ -18,7 +18,7 @@ function THEME.calculate(Y,M,D)
'xmas' or 'xmas' or
-- Halloween -- Halloween
(M=='11' and D>='28' or M=='12' and D<='04') and (M=='10' and D>='28' or M=='11' and D<='04') and
'halloween' or 'halloween' or
-- Birthday -- Birthday