Skip to content

Commit

Permalink
Fix sync functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ketasaja committed Aug 14, 2024
1 parent b3ec2c6 commit c8ffe5c
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions zap/src/output/luau/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,37 @@ impl<'a> ServerOutput<'a> {
// Avoid using upvalues as an optimization.
self.push_line("task.spawn(function(player_2, call_id_2, value_2)");
self.indent();
}

self.push_line(&format!("local rets = events[{id}](player_2, value_2)"));
self.push_line(&format!("local rets = events[{id}](player_2, value_2)"));

self.push_line("load_player(player_2)");
self.push_write_event_id(fndecl.id);
self.push_line("load_player(player_2)");
self.push_write_event_id(fndecl.id);

self.push_line("alloc(1)");
self.push_line("buffer.writeu8(outgoing_buff, outgoing_apos, call_id_2)");
self.push_line("alloc(1)");
self.push_line("buffer.writeu8(outgoing_buff, outgoing_apos, call_id_2)");

if let Some(ty) = &fndecl.rets {
self.push_stmts(&ser::gen(ty, "rets", self.config.write_checks));
}
if let Some(ty) = &fndecl.rets {
self.push_stmts(&ser::gen(ty, "rets", self.config.write_checks));
}

self.push_line("player_map[player_2] = save()");
self.push_line("player_map[player_2] = save()");

if fndecl.call == FnCall::Async {
self.dedent();
self.push_line("end, player, call_id, value)");
} else {
self.push_line(&format!("local rets = events[{id}](player, value)"));

self.push_line("load_player(player)");
self.push_write_event_id(fndecl.id);

self.push_line("alloc(1)");
self.push_line("buffer.writeu8(outgoing_buff, outgoing_apos, call_id)");

if let Some(ty) = &fndecl.rets {
self.push_stmts(&ser::gen(ty, "rets", self.config.write_checks));
}

self.push_line("player_map[player] = save()");
}

self.dedent();
Expand Down

0 comments on commit c8ffe5c

Please sign in to comment.