mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add command for debugging ways.
This commit is contained in:
parent
08a50afd9f
commit
372ffe45d7
@ -252,6 +252,7 @@ pub enum ServerChatCommand {
|
||||
BuildAreaRemove,
|
||||
Campfire,
|
||||
DebugColumn,
|
||||
DebugWays,
|
||||
DisconnectAllPlayers,
|
||||
DropAll,
|
||||
Dummy,
|
||||
@ -411,6 +412,11 @@ impl ServerChatCommand {
|
||||
"Prints some debug information about a column",
|
||||
Some(Moderator),
|
||||
),
|
||||
ServerChatCommand::DebugWays => cmd(
|
||||
vec![Integer("x", 15000, Required), Integer("y", 15000, Required)],
|
||||
"Prints some debug information about a column's ways",
|
||||
Some(Moderator),
|
||||
),
|
||||
ServerChatCommand::DisconnectAllPlayers => cmd(
|
||||
vec![Any("confirm", Required)],
|
||||
"Disconnects all players from the server",
|
||||
@ -738,6 +744,7 @@ impl ServerChatCommand {
|
||||
ServerChatCommand::BuildAreaRemove => "build_area_remove",
|
||||
ServerChatCommand::Campfire => "campfire",
|
||||
ServerChatCommand::DebugColumn => "debug_column",
|
||||
ServerChatCommand::DebugWays => "debug_ways",
|
||||
ServerChatCommand::DisconnectAllPlayers => "disconnect_all_players",
|
||||
ServerChatCommand::DropAll => "dropall",
|
||||
ServerChatCommand::Dummy => "dummy",
|
||||
|
@ -61,10 +61,10 @@ use rand::{thread_rng, Rng};
|
||||
use specs::{
|
||||
saveload::MarkerAllocator, storage::StorageEntry, Builder, Entity as EcsEntity, Join, WorldExt,
|
||||
};
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
use std::{str::FromStr, fmt::Write, sync::Arc};
|
||||
use vek::*;
|
||||
use wiring::{Circuit, Wire, WireNode, WiringAction, WiringActionEffect, WiringElement};
|
||||
use world::util::Sampler;
|
||||
use world::util::{Sampler, LOCALITY};
|
||||
|
||||
use common::comp::Alignment;
|
||||
use tracing::{error, info, warn};
|
||||
@ -136,6 +136,7 @@ fn do_command(
|
||||
ServerChatCommand::BuildAreaRemove => handle_build_area_remove,
|
||||
ServerChatCommand::Campfire => handle_spawn_campfire,
|
||||
ServerChatCommand::DebugColumn => handle_debug_column,
|
||||
ServerChatCommand::DebugWays => handle_debug_ways,
|
||||
ServerChatCommand::DisconnectAllPlayers => handle_disconnect_all_players,
|
||||
ServerChatCommand::DropAll => handle_drop_all,
|
||||
ServerChatCommand::Dummy => handle_spawn_training_dummy,
|
||||
@ -2836,6 +2837,51 @@ path {:?} "#,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "worldgen"))]
|
||||
fn handle_debug_ways(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
target: EcsEntity,
|
||||
_args: Vec<String>,
|
||||
_action: &ServerChatCommand,
|
||||
) -> CmdResult<()> {
|
||||
Err("Unsupported without worldgen enabled".into())
|
||||
}
|
||||
|
||||
#[cfg(feature = "worldgen")]
|
||||
fn handle_debug_ways(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
target: EcsEntity,
|
||||
args: Vec<String>,
|
||||
_action: &ServerChatCommand,
|
||||
) -> CmdResult<()> {
|
||||
let sim = server.world.sim();
|
||||
let wpos = if let (Some(x), Some(y)) = parse_cmd_args!(args, i32, i32) {
|
||||
Vec2::new(x, y)
|
||||
} else {
|
||||
let pos = position(server, target, "target")?;
|
||||
// FIXME: Deal with overflow, if needed.
|
||||
pos.0.xy().map(|x| x as i32)
|
||||
};
|
||||
let msg_generator = || {
|
||||
let chunk_pos = wpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| e / sz as i32);
|
||||
let mut ret = String::new();
|
||||
for delta in LOCALITY {
|
||||
let pos = chunk_pos + delta;
|
||||
let chunk = sim.get(pos)?;
|
||||
writeln!(ret, "{:?}: {:?}", pos, chunk.path).ok()?;
|
||||
}
|
||||
Some(ret)
|
||||
};
|
||||
if let Some(s) = msg_generator() {
|
||||
server.notify_client(client, ServerGeneral::server_msg(ChatType::CommandInfo, s));
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Not a pre-generated chunk.".into())
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_disconnect_all_players(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
|
@ -222,6 +222,13 @@ impl<'a> Widget for Chat<'a> {
|
||||
|
||||
// Maintain scrolling //
|
||||
if !self.new_messages.is_empty() {
|
||||
for message in self.new_messages.iter() {
|
||||
// Log the output of commands since the ingame terminal doesn't support copying the
|
||||
// output to the clipboard
|
||||
if let ChatType::CommandInfo = message.chat_type {
|
||||
tracing::info!("{}", message.message);
|
||||
}
|
||||
}
|
||||
//new messages - update chat w/ them & scroll down if at bottom of chat
|
||||
state.update(|s| s.messages.extend(self.new_messages.drain(..)));
|
||||
// Prevent automatic scroll upon new messages if not already scrolled to bottom
|
||||
|
Loading…
Reference in New Issue
Block a user