mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
address review comments
This commit is contained in:
parent
10c47128ce
commit
5e8de39fd0
@ -534,7 +534,7 @@ impl ServerChatCommand {
|
|||||||
),
|
),
|
||||||
ServerChatCommand::Campfire => cmd(vec![], "Spawns a campfire", Some(Admin)),
|
ServerChatCommand::Campfire => cmd(vec![], "Spawns a campfire", Some(Admin)),
|
||||||
ServerChatCommand::ClearPersistedTerrain => cmd(
|
ServerChatCommand::ClearPersistedTerrain => cmd(
|
||||||
vec![Integer("radius", 6, Required)],
|
vec![Integer("chunk_radius", 6, Required)],
|
||||||
"Clears nearby persisted terrain",
|
"Clears nearby persisted terrain",
|
||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
@ -723,7 +723,7 @@ impl ServerChatCommand {
|
|||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
ServerChatCommand::ReloadChunks => cmd(
|
ServerChatCommand::ReloadChunks => cmd(
|
||||||
vec![Integer("radius", 6, Optional)],
|
vec![Integer("chunk_radius", 6, Optional)],
|
||||||
"Reloads chunks loaded on the server",
|
"Reloads chunks loaded on the server",
|
||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
|
@ -2023,7 +2023,8 @@ fn handle_clear_persisted_terrain(
|
|||||||
let Some(radius) = parse_cmd_args!(args, i32) else {
|
let Some(radius) = parse_cmd_args!(args, i32) else {
|
||||||
return Err(Content::Plain(action.help_string()));
|
return Err(Content::Plain(action.help_string()));
|
||||||
};
|
};
|
||||||
let radius = radius.min(64);
|
// Clamp the radius to prevent accidentally passing too large radiuses
|
||||||
|
let radius = radius.clamp(0, 64);
|
||||||
|
|
||||||
let pos = position(server, target, "target")?;
|
let pos = position(server, target, "target")?;
|
||||||
let chunk_key = server.state.terrain().pos_key(pos.0.as_());
|
let chunk_key = server.state.terrain().pos_key(pos.0.as_());
|
||||||
@ -3742,7 +3743,7 @@ fn handle_reload_chunks(
|
|||||||
let radius = parse_cmd_args!(args, i32);
|
let radius = parse_cmd_args!(args, i32);
|
||||||
|
|
||||||
let pos = position(server, target, "target")?.0;
|
let pos = position(server, target, "target")?.0;
|
||||||
let removed = reload_chunks_inner(server, pos, radius.map(|radius| radius.min(64)));
|
let removed = reload_chunks_inner(server, pos, radius.map(|radius| radius.clamp(0, 64)));
|
||||||
|
|
||||||
server.notify_client(
|
server.notify_client(
|
||||||
client,
|
client,
|
||||||
|
@ -246,9 +246,6 @@ impl Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// LRU limiter that limits by the number of blocks
|
/// LRU limiter that limits by the number of blocks
|
||||||
///
|
|
||||||
/// > **Warning**: Make sure to call [`add_block`] and [`remove_block`] when
|
|
||||||
/// > performing direct mutations to a chunk
|
|
||||||
struct ByBlockLimiter {
|
struct ByBlockLimiter {
|
||||||
/// Maximum number of blocks that can be contained
|
/// Maximum number of blocks that can be contained
|
||||||
block_limit: usize,
|
block_limit: usize,
|
||||||
@ -288,7 +285,9 @@ impl Limiter<Vec2<i32>, Chunk> for ByBlockLimiter {
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
let old_size = old_chunk.len() as isize; // I assume chunks are never larger than a few thousand blocks anyways, cast should be OK
|
let old_size = old_chunk.len() as isize; // I assume chunks are never larger than a few thousand blocks anyways, cast should be OK
|
||||||
let new_size = new_chunk.len() as isize;
|
let new_size = new_chunk.len() as isize;
|
||||||
let new_total = self.counted_blocks.wrapping_add_signed(new_size - old_size);
|
let new_total = self
|
||||||
|
.counted_blocks
|
||||||
|
.saturating_add_signed(new_size - old_size);
|
||||||
|
|
||||||
if new_total > self.block_limit {
|
if new_total > self.block_limit {
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user