Skip to content

Commit

Permalink
fix formatting besides one weird cliipy error
Browse files Browse the repository at this point in the history
  • Loading branch information
ValorZard committed Sep 27, 2024
1 parent f89291e commit 4116339
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
12 changes: 7 additions & 5 deletions examples/multiplayer-lan/rust/src/multiplayer_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ impl MultiplayerController {
#[rpc(any_peer)]
fn send_player_information(&mut self, name: GString, network_id: NetworkId) {
// insert new player data with network_id if it doesn't already exist
self.player_database
.entry(network_id)
.or_insert(name);
self.player_database.entry(network_id).or_insert(name);

// print player information onto multiplayer log
let mut multiplayer_log = self
Expand All @@ -108,7 +106,11 @@ impl MultiplayerController {
#[rpc(any_peer, call_local, reliable)]
fn load_game(&mut self) {
// start up game scene
let mut scene = self.game_scene.as_mut().unwrap().instantiate_as::<SceneManager>();
let mut scene = self
.game_scene
.as_mut()
.unwrap()
.instantiate_as::<SceneManager>();
// have to put this into its own scope to avoid borrowing self as immutable when its already mutable
// note: you could also use drop(..) to drop reference to base
{
Expand Down Expand Up @@ -265,7 +267,7 @@ impl IControl for MultiplayerController {

// make clone to avoid following borrowing error:
// cannot move out of `self.multiplayer` which is behind a mutable reference
// move occurs because `self.multiplayer` has type `godot::prelude::OnReady<godot::prelude::Gd<MultiplayerApi>>`,
// move occurs because `self.multiplayer` has type `godot::prelude::OnReady<godot::prelude::Gd<MultiplayerApi>>`,
// which does not implement the `Copy` trait

let mut multiplayer = self.multiplayer.clone();
Expand Down
13 changes: 3 additions & 10 deletions examples/multiplayer-lan/rust/src/scene_manager.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
use std::collections::HashMap;

use godot::{
classes::RichTextLabel,
prelude::*,
};
use godot::{classes::RichTextLabel, prelude::*};

use crate::{
multiplayer_controller::MultiplayerController,
player::Player,
NetworkId,
};
use crate::{multiplayer_controller::MultiplayerController, player::Player, NetworkId};

#[derive(GodotClass)]
#[class(base=Node2D)]
Expand Down Expand Up @@ -142,7 +135,7 @@ impl INode2D for SceneManager {

fn process(&mut self, _delta: f64) {
let mut string = String::from("");
for player in self.player_list.values_mut() {
for player in self.player_list.values_mut() {
let player_bind = player.bind();
let username = &player_bind.username;
let position = player.get_global_position();
Expand Down

0 comments on commit 4116339

Please sign in to comment.