Skip to content

Commit

Permalink
Made plugins init for pool instead of each player
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanpoland committed Nov 10, 2024
1 parent e742ff5 commit 201348d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl PluginManager {
self.plugins
}

pub fn load_all(self, socket: SocketRef, players: Arc<RwLock<Vec<horizon_data_types::Player>>>) {
pub fn load_all(&self) {
let plugins = plugin_imports::load_plugins();

let my_test_plugin = get_plugin!(test_plugin, plugins);
Expand Down
12 changes: 5 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ impl HorizonServer {
logger: logger.clone(),
});

// Load all plugins for this pool
let my_manager = plugin_test_api::PluginManager::new();
my_manager.load_all();

let pool_clone = pool.clone();
thread::spawn(move || {
let rt = Runtime::new().unwrap();
Expand Down Expand Up @@ -100,16 +104,10 @@ impl HorizonServer {
socket.id.as_str());

let id = socket.id.as_str();
let player = Player::new(socket.clone(), Uuid::new_v4());
let player: Player = Player::new(socket.clone(), Uuid::new_v4());

players::init(socket.clone(), pool.players.clone());

// Load all plugins in a new manager for this player
// (TODO: Change this to a per-thread instance of manager and
// per player socket event listeners)
let my_manager = plugin_test_api::PluginManager::new();
my_manager.load_all(socket.clone(), pool.players.clone());

pool.players.write().unwrap().push(player.clone());

log_debug!(pool.logger, "PLAYER", "Player {} (UUID: {}) added to pool",
Expand Down

0 comments on commit 201348d

Please sign in to comment.