Skip to content

Commit 470f87d

Browse files
committed
Merge remote-tracking branch 'origin/rewrite/v3' into rewrite/v3
2 parents 9500e7e + 3aa1f59 commit 470f87d

File tree

7 files changed

+33
-38
lines changed

7 files changed

+33
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**/target
22
.idea
3+
.vscode
34
/crates/lib/dummy_lib/Cargo.lock
45

56
Cargo.lock

Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@ FROM rust:alpine3.20 AS build-stage
55

66
WORKDIR /app
77
COPY . /app
8-
RUN cargo build --release
8+
RUN apk add --no-cache musl-dev gcc
9+
RUN cargo build --release -j 10
10+
RUN strip target/release/ferrumc
911
# Stage 2: Runtime environment
1012
FROM alpine:3.20 AS final-stage
1113
WORKDIR /app
1214

1315
WORKDIR /app
1416
RUN apk add --no-cache wget
1517
COPY --from=build-stage /app/target/release/ferrumc /app/
18+
19+
# leaving this out for now since we dont have world loading
1620
# Once we get the website working, we should put the file on our own server, instead of a contributors side project.
17-
RUN wget --progress=dot:giga https://aboleth.ai/static/ferumc-121-exampleworld.tar.gz -P /app
18-
RUN mkdir -p /app/import && \
19-
tar -xzvf /app/ferumc-121-exampleworld.tar.gz -C /app/import
20-
RUN ./ferrumc --import
21-
RUN rm /app/ferumc-121-exampleworld.tar.gz && \
22-
rm -rf /app/import
21+
# RUN wget --progress=dot:giga https://aboleth.ai/static/ferumc-121-exampleworld.tar.gz -P /app
22+
# RUN mkdir -p /app/import && \
23+
# tar -xzvf /app/ferumc-121-exampleworld.tar.gz -C /app/import
24+
# RUN ./ferrumc --import
25+
# RUN rm /app/ferumc-121-exampleworld.tar.gz && \
26+
# rm -rf /app/import
2327

2428
EXPOSE 25565
25-
CMD ["./ferrumc"]
29+
CMD ["./ferrumc"]

src/bin/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Security or something like that
22
#![forbid(unsafe_code)]
33

4-
use std::sync::Arc;
4+
use std::sync::{atomic::AtomicBool, Arc};
55
use tracing::{error, info};
66
use ferrumc_ecs::Universe;
77
use ferrumc_net::ServerState;
@@ -28,7 +28,7 @@ async fn main() {
2828
async fn entry() -> Result<()> {
2929
let listener = ferrumc_net::server::create_server_listener().await?;
3030

31-
let state = ServerState::new(Universe::new());
31+
let state = ServerState::new(Universe::new(),AtomicBool::new(false));
3232

3333
ferrumc_net::server::listen(Arc::new(state), listener).await?;
3434

src/bin/src/packet_handlers/login_process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async fn handle_login_start(
2929

3030
let uuid = login_start_event.login_start_packet.uuid;
3131
let username = login_start_event.login_start_packet.username.clone();
32-
trace!("Received login start from user with username {}", username);
32+
info!("Received login start from user with username {}", username);
3333

3434
//Send a Login Success Response to further the login sequence
3535
let response = LoginSuccessPacket::new(uuid, username);

src/lib/net/src/connection.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ pub async fn handle_connection(state: Arc<ServerState>, tcp_stream: TcpStream) -
9696
break 'recv;
9797
};
9898

99-
trace!("Received packet: {:?}", packet_skele);
99+
if state.log_packets.load(std::sync::atomic::Ordering::Relaxed){
100+
trace!("Received packet: {:?}", packet_skele);
101+
}
100102

101103
let conn_state = state.universe.get::<ConnectionState>(entity)?.clone();
102104
if let Err(e) = handle_packet(

src/lib/net/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
use std::sync::Arc;
21
use ferrumc_ecs::Universe;
32
use ferrumc_macros::bake_packet_registry;
3+
use std::sync::{atomic::AtomicBool, Arc};
44

5+
pub mod connection;
56
pub mod errors;
67
pub mod packets;
7-
pub mod connection;
88
pub mod server;
99
pub mod utils;
1010
pub type NetResult<T> = Result<T, errors::NetError>;
1111

12-
1312
pub struct ServerState {
14-
pub universe: Universe
13+
pub universe: Universe,
14+
pub log_packets: AtomicBool,
1515
}
1616

1717
pub type GlobalState = Arc<ServerState>;
1818

1919
impl ServerState {
20-
pub fn new(universe: Universe) -> Self {
20+
pub fn new(universe: Universe, log_packets: AtomicBool) -> Self {
2121
Self {
22-
universe
22+
universe,
23+
log_packets,
2324
}
2425
}
2526
}
2627

27-
28-
bake_packet_registry!("\\src\\packets\\incoming");
28+
bake_packet_registry!("\\src\\packets\\incoming");

src/lib/utils/config/src/server_config.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::errors::ConfigError;
66
use crate::statics::{get_global_config, set_global_config};
77
use ferrumc_general_purpose::paths::get_root_path;
88
use serde_derive::{Deserialize, Serialize};
9-
use tracing::{error, info};
9+
use tracing::{error, info, warn};
1010

1111
/// The server configuration struct.
1212
///
@@ -135,29 +135,17 @@ impl ServerConfig {
135135
));
136136
}
137137
// Config could not be read. Prompt the user to create a new one from ServerConfig::Default.
138-
error!(
138+
warn!(
139139
"Could not read configuration file \"{}\" : {}",
140140
path.to_string_lossy().to_string(),
141141
e
142142
);
143-
error!("Would you like to create a new config file? (y/N): ");
144-
145-
let user_input = {
146-
let mut input = String::new();
147-
std::io::stdin().read_line(&mut input)?;
148-
input.trim().to_ascii_lowercase()
149-
};
143+
info!("creating new config file!");
150144

151-
if user_input == "y" {
152-
// Create a new config file
153-
std::fs::write(&path, DEFAULT_CONFIG)?;
145+
// Create a new config file
146+
std::fs::write(&path, DEFAULT_CONFIG)?;
154147

155-
DEFAULT_CONFIG
156-
} else {
157-
return Err(ConfigError::ConfigLoadError(
158-
path.to_string_lossy().to_string(),
159-
));
160-
}
148+
DEFAULT_CONFIG
161149
}
162150
};
163151

0 commit comments

Comments
 (0)