aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-03-18 21:46:55 +0300
committerRblSb <msrblsb@gmail.com>2025-03-18 21:46:55 +0300
commitedbfe7962d970d91e993d8856d583298e09430a7 (patch)
treecd9987f5678e46a455a0d159deb8874498040d1b
parent0e2da0935ffb670475234f51d8d809ffa0a4add9 (diff)
Fix empty playlist clear crash
-rw-r--r--build/server.js30
-rw-r--r--src/server/Main.hx14
2 files changed, 24 insertions, 20 deletions
diff --git a/build/server.js b/build/server.js
index a6ab011..ef1de33 100644
--- a/build/server.js
+++ b/build/server.js
@@ -5283,9 +5283,11 @@ server_Main.prototype = {
if(!this.checkPermission(client,"removeVideo")) {
return;
}
- if(this.videoTimer.getTime() > 30) {
- var _this = this.videoList;
- this.saveFlashbackTime(_this.items[_this.pos]);
+ if(this.videoList.items.length != 0) {
+ if(this.videoTimer.getTime() > 30) {
+ var _this = this.videoList;
+ this.saveFlashbackTime(_this.items[_this.pos]);
+ }
}
this.videoTimer.stop();
var _this = this.videoList;
@@ -5370,10 +5372,10 @@ server_Main.prototype = {
this.send(client,{ type : "Dump", dump : { data : json}});
break;
case "Flashback":
- if(!this.checkPermission(client,"rewind")) {
+ if(this.videoList.items.length == 0) {
return;
}
- if(this.videoList.items.length == 0) {
+ if(!this.checkPermission(client,"rewind")) {
return;
}
var _this = this.videoList;
@@ -5547,13 +5549,13 @@ server_Main.prototype = {
case "Progress":
break;
case "RemoveVideo":
- if(this.isPlaylistLockedFor(client)) {
+ if(this.videoList.items.length == 0) {
return;
}
- if(!this.checkPermission(client,"removeVideo")) {
+ if(this.isPlaylistLockedFor(client)) {
return;
}
- if(this.videoList.items.length == 0) {
+ if(!this.checkPermission(client,"removeVideo")) {
return;
}
var url = data.removeVideo.url;
@@ -5576,10 +5578,10 @@ server_Main.prototype = {
}
break;
case "Rewind":
- if(!this.checkPermission(client,"rewind")) {
+ if(this.videoList.items.length == 0) {
return;
}
- if(this.videoList.items.length == 0) {
+ if(!this.checkPermission(client,"rewind")) {
return;
}
data.rewind.time += this.videoTimer.getTime();
@@ -5660,13 +5662,13 @@ server_Main.prototype = {
this.broadcastExcept(client,{ type : data.type, setTime : data.setTime});
break;
case "ShufflePlaylist":
- if(this.isPlaylistLockedFor(client)) {
+ if(this.videoList.items.length == 0) {
return;
}
- if(!this.checkPermission(client,"changeOrder")) {
+ if(this.isPlaylistLockedFor(client)) {
return;
}
- if(this.videoList.items.length == 0) {
+ if(!this.checkPermission(client,"changeOrder")) {
return;
}
this.videoList.shuffle();
@@ -5799,7 +5801,7 @@ server_Main.prototype = {
client.setGroupFlag(ClientGroup.Banned,!isOutdated);
if(isOutdated) {
HxOverrides.remove(this.userList.bans,ban);
- haxe_Log.trace("" + client.name + " ban removed",{ fileName : "src/server/Main.hx", lineNumber : 1056, className : "server.Main", methodName : "checkBan"});
+ haxe_Log.trace("" + client.name + " ban removed",{ fileName : "src/server/Main.hx", lineNumber : 1058, className : "server.Main", methodName : "checkBan"});
this.sendClientList();
}
break;
diff --git a/src/server/Main.hx b/src/server/Main.hx
index ebe456b..86e619e 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -705,9 +705,9 @@ class Main {
prepareVideoPlayback();
case RemoveVideo:
+ if (videoList.length == 0) return;
if (isPlaylistLockedFor(client)) return;
if (!checkPermission(client, RemoveVideoPerm)) return;
- if (videoList.length == 0) return;
final url = data.removeVideo.url;
final index = videoList.findIndex(item -> item.url == url);
if (index == -1) return;
@@ -804,8 +804,8 @@ class Main {
});
case Rewind:
- if (!checkPermission(client, RewindPerm)) return;
if (videoList.length == 0) return;
+ if (!checkPermission(client, RewindPerm)) return;
data.rewind.time += videoTimer.getTime();
if (data.rewind.time < 0) data.rewind.time = 0;
saveFlashbackTime(videoList.currentItem);
@@ -816,8 +816,8 @@ class Main {
});
case Flashback:
- if (!checkPermission(client, RewindPerm)) return;
if (videoList.length == 0) return;
+ if (!checkPermission(client, RewindPerm)) return;
loadFlashbackTime(videoList.currentItem);
broadcast({
type: Rewind,
@@ -890,17 +890,19 @@ class Main {
case ClearPlaylist:
if (isPlaylistLockedFor(client)) return;
if (!checkPermission(client, RemoveVideoPerm)) return;
- if (videoTimer.getTime() > FLASHBACK_DIST) {
- saveFlashbackTime(videoList.currentItem);
+ if (videoList.length != 0) {
+ if (videoTimer.getTime() > FLASHBACK_DIST) {
+ saveFlashbackTime(videoList.currentItem);
+ }
}
videoTimer.stop();
videoList.clear();
broadcast(data);
case ShufflePlaylist:
+ if (videoList.length == 0) return;
if (isPlaylistLockedFor(client)) return;
if (!checkPermission(client, ChangeOrderPerm)) return;
- if (videoList.length == 0) return;
videoList.shuffle();
broadcast({
type: UpdatePlaylist,
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage