Skip to content

Commit

Permalink
Merge pull request #11 from shekohex/improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shekohex committed Jun 2, 2023
2 parents 9547ace + ab265af commit 289fd41
Show file tree
Hide file tree
Showing 35 changed files with 820 additions and 392 deletions.
78 changes: 75 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/codec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tq-codec"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion core/crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tq-crypto"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
Expand Down
8 changes: 4 additions & 4 deletions core/crypto/src/rc5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl crate::Cipher for TQRC5 {
dst.copy_from_slice(src);
// Decrypt the buffer
for word in 0..src_len {
let mut chunk_a = &dst[8 * word as usize..];
let mut chunk_b = &dst[(8 * word + 4) as usize..];
let mut chunk_a = &dst[8 * word..];
let mut chunk_b = &dst[(8 * word + 4)..];
let mut a = chunk_a.get_u32_le();
let mut b = chunk_b.get_u32_le();
let rounds = self.rounds;
Expand All @@ -106,13 +106,13 @@ impl crate::Cipher for TQRC5 {
a = (a.wrapping_sub(sub[(2 * round) as usize])).rotate_right(b)
^ b;
}
let chunk_a = &mut dst[(8 * word as usize)..];
let chunk_a = &mut dst[(8 * word)..];
let mut wtr_a = vec![];
wtr_a.put_u32_le(a.wrapping_sub(sub[0]));
for (i, b) in wtr_a.iter().enumerate() {
chunk_a[i] = *b;
}
let chunk_b = &mut dst[(8 * word + 4) as usize..];
let chunk_b = &mut dst[(8 * word + 4)..];
let mut wtr_b = vec![];
wtr_b.put_u32_le(b.wrapping_sub(sub[1]));

Expand Down
2 changes: 1 addition & 1 deletion core/math/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tq-math"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
2 changes: 1 addition & 1 deletion core/network/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tq-network"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "primitives"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion core/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct Size<I: PrimInt> {
}

impl<I: PrimInt> Size<I> {
pub fn new(width: I, height: I) -> Self { Self { width, height } }
pub const fn new(width: I, height: I) -> Self { Self { width, height } }

pub fn area(&self) -> I { self.width * self.height }
}
Expand Down
2 changes: 1 addition & 1 deletion core/serde/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tq-serde"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion macros/derive-packethandler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "derive-packethandler"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion macros/derive-packetid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "derive-packetid"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion server/auth/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "auth-server"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion server/auth/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl State {

/// Get access to the global state.
pub fn global() -> Result<&'static Self, Error> {
STATE.get().ok_or({
STATE.get().ok_or_else(|| {
Error::State(
"State is uninialized, did you forget to call State::init()!",
)
Expand Down
6 changes: 4 additions & 2 deletions server/game/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "game-server"
version = "0.1.0"
authors = ["Shady Khalifa <[email protected]>"]
authors = ["Shady Khalifa <[email protected]>"]
edition = "2018"


Expand All @@ -18,11 +18,13 @@ tracing = "0.1"
tracing-futures = "0.2"
dotenv = "0.15"
once_cell = "1.4"
fastrand = "1.3"
encoding = "0.2"
bitflags = "1.2"
argh = "0.1"
tokio-stream = "0.1.8"
rand = "0.8"
fastrand = "1.8"
chrono = "0.4"

# Utils
num_enum = { version = "0.5.1", default-features = false }
Expand Down
14 changes: 10 additions & 4 deletions server/game/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bytes::Bytes;
use thiserror::Error;
use tokio::sync::mpsc::error::SendError;
use tokio::sync::{mpsc, oneshot};
use tq_network::{ErrorPacket, PacketEncode};

#[derive(Debug, Error)]
Expand All @@ -17,8 +17,10 @@ pub enum Error {
Db(#[from] sqlx::Error),
#[error("State Error: {}", _0)]
State(&'static str),
#[error("Actor State Send Error!")]
#[error("Channel Send Error!")]
SendError,
#[error("Channel Recv Error!")]
RecvError,
#[error(transparent)]
ParseInt(#[from] std::num::ParseIntError),
#[error(transparent)]
Expand All @@ -29,8 +31,12 @@ pub enum Error {
Msg(u16, Bytes),
}

impl<T> From<SendError<T>> for Error {
fn from(_: SendError<T>) -> Self { Self::SendError }
impl<T> From<mpsc::error::SendError<T>> for Error {
fn from(_: mpsc::error::SendError<T>) -> Self { Self::SendError }
}

impl From<oneshot::error::RecvError> for Error {
fn from(_: oneshot::error::RecvError) -> Self { Self::RecvError }
}

impl<T: PacketEncode> From<ErrorPacket<T>> for Error {
Expand Down
3 changes: 3 additions & 0 deletions server/game/src/packets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ pub use msg_player::MsgPlayer;

mod msg_item_info;
pub use msg_item_info::*;

mod msg_data;
pub use msg_data::MsgData;
Loading

0 comments on commit 289fd41

Please sign in to comment.