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 built-in scarpet ai_tracker.sc failed if one player disconnect fr… #1810

Closed
wants to merge 1 commit into from
Closed

Conversation

sakurawald
Copy link

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');
);

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

Successfully merging this pull request may close these issues.

1 participant