Skip to content

Commit

Permalink
fix:enchanted sword crashed[skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jun 24, 2024
1 parent 376bfc2 commit bd22c40
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
3 changes: 1 addition & 2 deletions gdrust/server/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::io::Cursor;

use anyhow::anyhow;
use bytes::BytesMut;
use prost::Message;
use proto::{connect, ProtoRequest};
use std::io::Cursor;
use tokio::{io::AsyncReadExt, net::TcpStream, sync::broadcast};

pub struct Connection {
Expand Down
18 changes: 6 additions & 12 deletions gdrust/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
mod cfg;
mod connection;

use anyhow::anyhow;
use bytes::BytesMut;
use cfg::{DEFAULT_IP, DEFAULT_PORT};
use clap::Parser;
use connection::Connection;
use prost::Message;
use proto::{connect::Join, ProtoRequest};
use std::{
error::Error,
io::{Cursor, Write},
process::exit,
};
use std::{collections::HashMap, error::Error, io::Write, process::exit};
use tokio::{
io::{self, AsyncBufReadExt, AsyncReadExt, BufReader},
net::{TcpListener, TcpStream},
io::{self, AsyncBufReadExt, BufReader},
net::TcpListener,
select,
sync::broadcast,
};
Expand All @@ -26,6 +18,7 @@ struct Server {
port: usize,
bind_addr: String,
tcplistener: TcpListener,
connections: HashMap<usize, Connection>,
}

impl Server {
Expand All @@ -45,6 +38,7 @@ impl Server {
port,
bind_addr,
tcplistener,
connections: HashMap::new(),
})
}

Expand All @@ -60,7 +54,7 @@ impl Server {
Ok((socket, _)) => {
let shutdown = shutdown_sender.subscribe();
log::info!("Connected to a socket");
tokio::spawn(async move {
tokio::spawn(async {
let mut connection = Connection::new(shutdown, socket);
if let Err(e) = connection.start().await {
log::error!("When processing a request:{}", e)
Expand Down
3 changes: 1 addition & 2 deletions gdrust/src/multi.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::{get_multi_single, get_tokio_runtime, MultiSingle};
use crate::get_tokio_runtime;
use ::proto::ProtoRequest;
use anyhow::anyhow;
use bytes::{Bytes, BytesMut};
use godot::classes::{INode, Node};
use godot::prelude::*;
use prost::Message;
use proto::connect::Join;
use std::mem::swap;
use std::process::{Child, Command};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
Expand Down
3 changes: 3 additions & 0 deletions gdrust/src/ui/multi_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ impl MultiSetup {
impl Drop for MultiSetup {
fn drop(&mut self) {
let tmp = self.receiver.take();
if tmp.is_none() {
return;
}
get_multi_single()
.lock()
.unwrap()
Expand Down
7 changes: 3 additions & 4 deletions scenes/fight.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ texture = ExtResource("3_2spkb")

[node name="StarWrath" parent="." instance=ExtResource("4_8ipx5")]

[node name="EnchantedSword" parent="." instance=ExtResource("13_1n0f0")]
rotation = 0.710345

[node name="Player" type="Player" parent="."]
position = Vector2(570, 414)
scale = Vector2(0.2, 0.2)
Expand Down Expand Up @@ -205,10 +208,6 @@ position = Vector2(500, 530)
scale = Vector2(1.2, 1.2)
texture = ExtResource("12_sm4t8")

[node name="EnchantedSword" parent="." instance=ExtResource("13_1n0f0")]
rotation = 0.710345
enchanted_beam = null

[node name="CategoryPanel" type="Sprite2D" parent="."]
position = Vector2(41, 35)
texture = ExtResource("14_miw1s")
Expand Down

0 comments on commit bd22c40

Please sign in to comment.