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

Built-in scarpet ai_tracker.sc failed if one player disconnect from the server. #1809

Open
sakurawald opened this issue Sep 6, 2023 · 0 comments

Comments

@sakurawald
Copy link

sakurawald commented Sep 6, 2023

If any player disconnect from the server while his /ai_tracker function is on, then script will
throw an unhandled exception. And if the player re-connect the server again. He will not able to use /ai_tracker anymore (Because the script is failed then. You must unload and load the script again to make it work again.)

[19:32:54] [Server thread/INFO]: SakuraWald lost connection: Disconnected
[19:32:54] [Server thread/INFO]: SakuraWald left the game
[19:32:54] [Server thread/INFO]: [SakuraWald: Unhandled unknown_dimension exception: null in ai_tracker at line 529, pos 4]
[19:32:54] [Server thread/INFO]: [SakuraWald:    p = player();]
[19:32:54] [Server thread/INFO]: [SakuraWald:     HERE>> in_dimension(p,]
[19:32:54] [Server thread/INFO]: [SakuraWald:       for (entity_area('valid', p, global_range, global_range, global_range),]
[19:32:54] [Server thread/INFO]: [SakuraWald: Callback failed]

The original code is

__tick_tracker() ->
(
   if (!global_active_functions,
      global_tracker_running = false;
      return()
   );
   p = player();
   in_dimension(p,
      for (entity_area('valid', p, global_range, global_range, global_range),
         __handle_entity(_)
      )
   );
   schedule(global_interval, '__tick_tracker');
);

And the fixed code is

__tick_tracker() ->
(
   if (!global_active_functions,
      global_tracker_running = false;
      return()
   );
   p = player();
   if (p == null, (clear()), (
      in_dimension(p,
         for (entity_area('valid', p, global_range, global_range, global_range),
            __handle_entity(_)
         )
      );
   ));
   schedule(global_interval, '__tick_tracker');
);

pr at #1810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant