Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/scripting/StarWorldLuaBindings.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-04-02 13:11:42 +1100
committerGitHub <noreply@github.com>2024-04-02 13:11:42 +1100
commit40698751e79d119e1ae37ea605b320961d6b597a (patch)
tree9f1322f2f1f0588fe28dba62a0a4488855bfb0bd /source/game/scripting/StarWorldLuaBindings.cpp
parent14506b1014aa2e5cbc041ff7b6907c5f499a0e10 (diff)
parentcf93c2e9d40a87408e02a0c78ee4d38159e9e133 (diff)
Merge pull request #55 from ErodeesFleurs/sp
fixed the deadlock problem of universe.sendPacket and added world.sendPacket function
Diffstat (limited to 'source/game/scripting/StarWorldLuaBindings.cpp')
-rw-r--r--source/game/scripting/StarWorldLuaBindings.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/game/scripting/StarWorldLuaBindings.cpp b/source/game/scripting/StarWorldLuaBindings.cpp
index cc91ec2..8287903 100644
--- a/source/game/scripting/StarWorldLuaBindings.cpp
+++ b/source/game/scripting/StarWorldLuaBindings.cpp
@@ -390,6 +390,7 @@ namespace LuaBindings {
callbacks.registerCallbackWithSignature<List<EntityId>>("players", bind(ServerWorldCallbacks::players, world));
callbacks.registerCallbackWithSignature<LuaString, LuaEngine&>("fidelity", bind(ServerWorldCallbacks::fidelity, world, _1));
callbacks.registerCallbackWithSignature<Maybe<LuaValue>, String, String, LuaVariadic<LuaValue>>("callScriptContext", bind(ServerWorldCallbacks::callScriptContext, world, _1, _2, _3));
+ callbacks.registerCallbackWithSignature<void, ConnectionId, String, Json>("sendPacket", bind(ServerWorldCallbacks::sendPacket, serverWorld, _1, _2, _3));
callbacks.registerCallbackWithSignature<double>("skyTime", [serverWorld]() {
return serverWorld->sky()->epochTime();
@@ -1186,6 +1187,12 @@ namespace LuaBindings {
return context->invoke(function, args);
}
+ void ServerWorldCallbacks::sendPacket(WorldServer* world, ConnectionId clientId, String const& packetType, Json const& packetData) {
+ PacketType type = PacketTypeNames.getLeft(packetType);
+ auto packet = createPacket(type, packetData);
+ world->sendPacket(clientId, packet);
+ }
+
void WorldDebugCallbacks::debugPoint(Vec2F const& arg1, Color const& arg2) {
SpatialLogger::logPoint("world", arg1, arg2.toRgba());
}