Skip to content

Commit

Permalink
Merge pull request #146 from ferrumc-rs/fix/fixing-broken-shit
Browse files Browse the repository at this point in the history
fix/fixing-broken-shit
  • Loading branch information
Sweattypalms authored Dec 30, 2024
2 parents 2d60101 + 615d5e0 commit f279f65
Show file tree
Hide file tree
Showing 13 changed files with 374 additions and 173 deletions.
2 changes: 2 additions & 0 deletions .etc/example-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ map_size = 1_000
cache_ttl = 60
# How big the cache can be in kb.
cache_capacity = 20_000

whitelist = false
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ our [Discord server](https://discord.gg/qT5J8EMjwk) for help or to discuss the p
<h4>📝 Custom made network, NBT and Anvil encoding systems to allow for minimal I/O lag</h4>
</li>
<li>
<h4>💾 Multiple database options to finetune the server to your needs</h4>
<h4>💾 Crazy fast K/V database </h4>
<i>32 render distance*</i>
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/chunk_loading.gif?raw=true" alt="Chunk Loading DEMO">
</li>
Expand All @@ -94,7 +94,7 @@ our [Discord server](https://discord.gg/qT5J8EMjwk) for help or to discuss the p
<h4>Optimizations</h4>
</li>
<li>
<h4>Plugin support (JVM currently, other languages will be considered later)</h4>
<h4>Plugin support (FFI currently, other languages will be considered later)</h4>
</li>
</ul>

Expand Down Expand Up @@ -148,9 +148,23 @@ cargo build --release

## 🖥️ Usage

```plaintext
Usage: ferrumc.exe [OPTIONS] [COMMAND]
Commands:
setup Sets up the config
import Import the world data
run Start the server (default, if no command is given)
help Print this message or the help of the given subcommand(s)
Options:
--log <LOG> [default: debug] [possible values: trace, debug, info, warn, error]
-h, --help Print help
```

1. Move the FerrumC binary (`ferrumc.exe` or `ferrumc` depending on the OS) to your desired server directory
2. Open a terminal in that directory
3. (Optional) Generate a config file: `./ferrumc --setup`
3. (Optional) Generate a config file: `./ferrumc setup`
- Edit the generated `config.toml` file to customize your server settings
4. Import an existing world: Either copy your world files to the server directory or specify the path to the world files
in the `config.toml` file. This should be the root directory of your world files, containing the `region` directory
Expand Down Expand Up @@ -218,10 +232,9 @@ with the vanilla server, but we do plan on implementing some sort of terrain gen
### Will there be plugins? And how?
We do very much plan to have a plugin system and as of right now, our plan is to leverage the
JVM to allow for plugins to be written in Kotlin, Java, or any other JVM language. We are also considering other
languages
such as Rust, JavaScript and possibly other native languages, but that is a fair way off for now.
We do very much plan to have a plugin system and as of right now we are planning to use
some kind of ffi (foreign function interface) to allow for plugins to be written in other languages.
Not confirmed yet.
### What does 'FerrumC' mean?
Expand Down
2 changes: 1 addition & 1 deletion scripts/new_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def to_camel_case(string) -> str:
else:
f.write(outgoing_template.replace("++name++", to_camel_case(packet_name)).replace("++id++", packet_id))
with open(f"{packets_dir}/outgoing/mod.rs", "a") as modfile:
modfile.write(f"\npub mod {to_snake_case(packet_name)};")
modfile.write(f"\npub mod {to_snake_case(packet_name)};")
6 changes: 3 additions & 3 deletions src/bin/src/systems/chunk_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::collections::HashMap;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use tokio::task::JoinSet;
use tracing::{error, info, trace};
use tracing::{debug, info, trace};

pub struct ChunkFetcher {
stop: AtomicBool,
Expand Down Expand Up @@ -70,11 +70,11 @@ impl System for ChunkFetcher {
match result {
Ok(task_res) => {
if let Err(e) = task_res {
error!("Error fetching chunk: {:?}", e);
debug!("Error fetching chunk: {:?}", e);
}
}
Err(e) => {
error!("Error fetching chunk: {:?}", e);
debug!("Error fetching chunk: {:?}", e);
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/bin/src/systems/ticking_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use tokio::time::Instant;
use tracing::{debug, info};
use tracing::{debug, info, trace};
pub struct TickingSystem;

static KILLED: AtomicBool = AtomicBool::new(false);
Expand All @@ -19,12 +19,18 @@ impl System for TickingSystem {
let mut tick = 0;
while !KILLED.load(Ordering::Relaxed) {
let required_end = Instant::now() + Duration::from_millis(50);
// TODO handle error
let res = TickEvent::trigger(TickEvent::new(tick), state.clone()).await;
let res = {
let start = Instant::now();
let res = TickEvent::trigger(TickEvent::new(tick), state.clone()).await;
trace!("Tick took {:?}", Instant::now() - start);

res
};
if res.is_err() {
debug!("error handling tick event: {:?}", res);
}
let now = Instant::now();

if required_end > now {
tokio::time::sleep(required_end - now).await;
} else {
Expand Down
Loading

0 comments on commit f279f65

Please sign in to comment.