fixes #1103 game will close peacefully when running ticks from scarpet
This commit is contained in:
1 parent
0e1a8f20d4
commit
339633f1f0
1 file changed
+3
-1
@@ -683,6 +683,7 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("game_tick", -1, (c, t, lv) -> {
|
expression.addContextFunction("game_tick", -1, (c, t, lv) -> {
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerCommandSource s = cc.s;
|
ServerCommandSource s = cc.s;
|
||||||
|
if (CarpetServer.scriptServer == null) return Value.NULL;
|
||||||
if (!s.getServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads");
|
if (!s.getServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads");
|
||||||
if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that.");
|
if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that.");
|
||||||
try
|
try
|
||||||
@@ -710,9 +711,10 @@ public class Auxiliary {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
if (CarpetServer.scriptServer != null)
|
||||||
CarpetServer.scriptServer.tickDepth --;
|
CarpetServer.scriptServer.tickDepth --;
|
||||||
}
|
}
|
||||||
if(CarpetServer.scriptServer.stopAll)
|
if(CarpetServer.scriptServer != null && CarpetServer.scriptServer.stopAll)
|
||||||
throw new ExitStatement(Value.NULL);
|
throw new ExitStatement(Value.NULL);
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user