diff --git a/zap/src/output/luau/base.luau b/zap/src/output/luau/base.luau index b9293538..b71d5f33 100644 --- a/zap/src/output/luau/base.luau +++ b/zap/src/output/luau/base.luau @@ -26,18 +26,18 @@ local CFrameSpecialCases = { CFrame.Angles(0, math.rad(-90), 0), CFrame.Angles(math.rad(90), math.rad(-90), 0), CFrame.Angles(0, math.rad(90), math.rad(180)), - CFrame.Angles(0, math.rad(-90), math.rad(180)), - CFrame.Angles(0, math.rad(180), math.rad(0)), - CFrame.Angles(math.rad(-90), math.rad(-180), math.rad(0)), - CFrame.Angles(0, math.rad(0), math.rad(180)), - CFrame.Angles(math.rad(90), math.rad(180), math.rad(0)), - CFrame.Angles(0, math.rad(0), math.rad(-90)), - CFrame.Angles(0, math.rad(-90), math.rad(-90)), - CFrame.Angles(0, math.rad(-180), math.rad(-90)), - CFrame.Angles(0, math.rad(90), math.rad(-90)), - CFrame.Angles(math.rad(90), math.rad(90), 0), - CFrame.Angles(0, math.rad(90), 0), - CFrame.Angles(math.rad(-90), math.rad(90), 0), + CFrame.Angles(0, math.rad(-90), math.rad(180)), + CFrame.Angles(0, math.rad(180), math.rad(0)), + CFrame.Angles(math.rad(-90), math.rad(-180), math.rad(0)), + CFrame.Angles(0, math.rad(0), math.rad(180)), + CFrame.Angles(math.rad(90), math.rad(180), math.rad(0)), + CFrame.Angles(0, math.rad(0), math.rad(-90)), + CFrame.Angles(0, math.rad(-90), math.rad(-90)), + CFrame.Angles(0, math.rad(-180), math.rad(-90)), + CFrame.Angles(0, math.rad(90), math.rad(-90)), + CFrame.Angles(math.rad(90), math.rad(90), 0), + CFrame.Angles(0, math.rad(90), 0), + CFrame.Angles(math.rad(-90), math.rad(90), 0), } local function alloc(len: number) diff --git a/zap/src/output/luau/client.rs b/zap/src/output/luau/client.rs index c985ca8b..75822bd4 100644 --- a/zap/src/output/luau/client.rs +++ b/zap/src/output/luau/client.rs @@ -89,6 +89,7 @@ impl<'src> ClientOutput<'src> { self.config.event_id_ty().size() )); } + fn push_reliable_callback(&mut self, first: bool, ev: &EvDecl, id: usize) { self.push_indent(); diff --git a/zap/src/output/luau/server.luau b/zap/src/output/luau/server.luau index 357eb465..751435f1 100644 --- a/zap/src/output/luau/server.luau +++ b/zap/src/output/luau/server.luau @@ -20,14 +20,13 @@ end local player_map = {} -Players.PlayerAdded:Connect(function(player) - player_map[player] = { - buff = buffer.create(64), - used = 0, - size = 64, - inst = {}, - } -end) +local function load_player(player: Player) + if player_map[player] then + load(player_map[player]) + else + load_empty() + end +end Players.PlayerRemoving:Connect(function(player) player_map[player] = nil diff --git a/zap/src/output/luau/server.rs b/zap/src/output/luau/server.rs index aa379b86..90dd729b 100644 --- a/zap/src/output/luau/server.rs +++ b/zap/src/output/luau/server.rs @@ -285,7 +285,7 @@ impl<'a> ServerOutput<'a> { self.indent(); match ev.evty { - EvType::Reliable => self.push_line(&format!("load(player_map[{player}])")), + EvType::Reliable => self.push_line(&format!("load_player({player})")), EvType::Unreliable => self.push_line("load_empty()"), } @@ -327,9 +327,9 @@ impl<'a> ServerOutput<'a> { match ev.evty { EvType::Reliable => { self.push_line("local buff, used, inst = outgoing_buff, outgoing_used, outgoing_inst"); - self.push_line("for player, outgoing in player_map do"); + self.push_line("for _, player in Players:GetPlayers() do"); self.indent(); - self.push_line("load(outgoing)"); + self.push_line("load_player(player)"); self.push_line("alloc(used)"); self.push_line("buffer.copy(outgoing_buff, outgoing_apos, buff, 0, used)"); self.push_line("table.move(inst, 1, #inst, #outgoing_inst + 1, outgoing_inst)"); @@ -371,11 +371,11 @@ impl<'a> ServerOutput<'a> { match ev.evty { EvType::Reliable => { self.push_line("local buff, used, inst = outgoing_buff, outgoing_used, outgoing_inst"); - self.push_line("for player, outgoing in player_map do"); + self.push_line("for _, player in Players:GetPlayers() do"); self.indent(); self.push_line(&format!("if player ~= {except} then")); self.indent(); - self.push_line("load(outgoing)"); + self.push_line("load_player(player)"); self.push_line("alloc(used)"); self.push_line("buffer.copy(outgoing_buff, outgoing_apos, buff, 0, used)"); self.push_line("table.move(inst, 1, #inst, #outgoing_inst + 1, outgoing_inst)"); @@ -389,7 +389,7 @@ impl<'a> ServerOutput<'a> { EvType::Unreliable => { self.push_line("local buff = buffer.create(outgoing_used)"); self.push_line("buffer.copy(buff, 0, outgoing_buff, 0, outgoing_used)"); - self.push_line("for player in player_map do"); + self.push_line("for _, player in Players:GetPlayers() do"); self.indent(); self.push_line(&format!("if player ~= {except} then")); self.indent(); @@ -429,7 +429,7 @@ impl<'a> ServerOutput<'a> { self.push_line("local buff, used, inst = outgoing_buff, outgoing_used, outgoing_inst"); self.push_line(&format!("for _, player in {list} do")); self.indent(); - self.push_line("load(player_map[player])"); + self.push_line("load_player(player)"); self.push_line("alloc(used)"); self.push_line("buffer.copy(outgoing_buff, outgoing_apos, buff, 0, used)"); self.push_line("table.move(inst, 1, #inst, #outgoing_inst + 1, outgoing_inst)");