Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fire in player added #45

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions zap/src/output/luau/base.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions zap/src/output/luau/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl<'src> ClientOutput<'src> {
self.config.event_id_ty().size()
));
}

sasial-dev marked this conversation as resolved.
Show resolved Hide resolved
fn push_reliable_callback(&mut self, first: bool, ev: &EvDecl, id: usize) {
self.push_indent();

Expand Down
15 changes: 7 additions & 8 deletions zap/src/output/luau/server.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions zap/src/output/luau/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()"),
}

Expand Down Expand Up @@ -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)");
Expand Down Expand Up @@ -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)");
Expand All @@ -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();
Expand Down Expand Up @@ -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)");
Expand Down
Loading