Skip to content

Commit 9bfb97e

Browse files
refactor: remove commented out code (#649)
1 parent 8c9e03a commit 9bfb97e

File tree

15 files changed

+1
-856
lines changed

15 files changed

+1
-856
lines changed

crates/bvh-region/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<T> Debug for BvhBuild<T> {
9898
unsafe impl<T: Send> Send for BvhBuild<T> {}
9999
unsafe impl<T: Sync> Sync for BvhBuild<T> {}
100100

101-
// get number of threads that is pow of 2
101+
/// get number of threads that is pow of 2
102102
fn thread_count_pow2() -> usize {
103103
let max_threads_tentative = rayon::current_num_threads();
104104
// let max

crates/hyperion-crafting/src/lib.rs

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -95,84 +95,13 @@ pub struct CraftingShapelessData {
9595
result: ItemStack,
9696
}
9797

98-
// /// Represents data for a shaped crafting recipe.
99-
// #[derive(Clone, Debug)]
100-
// pub struct CraftingShapedData<'a> {
101-
// /// The width of the crafting grid.
102-
// pub width: u32,
103-
// /// The height of the crafting grid.
104-
// pub height: u32,
105-
// /// Used to group similar recipes together in the recipe book.
106-
// pub group: Cow<'a, str>,
107-
// /// The category of the recipe.
108-
// pub category: CraftingCategory,
109-
// /// The ingredients for the recipe, indexed by x + (y * width).
110-
// pub ingredients: Cow<'a, [Ingredient<'a>]>,
111-
// /// The result of the crafting recipe.
112-
// pub result: ItemStack,
113-
// /// Whether to show a notification when the recipe is added.
114-
// pub show_notification: bool,
115-
// }
116-
//
11798
/// Represents data for special crafting recipes.
11899
#[derive(Clone, Debug)]
119100
pub struct CraftingSpecialData {
120101
/// The category of the special crafting recipe.
121102
pub category: CraftingCategory,
122103
}
123104

124-
// /// Represents data for smelting-type recipes (smelting, blasting, smoking, campfire cooking).
125-
// #[derive(Clone, Debug)]
126-
// pub struct SmeltingData<'a> {
127-
// /// Used to group similar recipes together in the recipe book.
128-
// pub group: Cow<'a, str>,
129-
// /// The category of the smelting recipe.
130-
// pub category: SmeltingCategory,
131-
// /// The ingredient for the smelting recipe.
132-
// pub ingredient: Ingredient<'a>,
133-
// /// The result of the smelting recipe.
134-
// pub result: ItemStack,
135-
// /// The amount of experience granted by this recipe.
136-
// pub experience: f32,
137-
// /// The time it takes to complete this recipe.
138-
// pub cooking_time: u32,
139-
// }
140-
//
141-
// /// Represents data for a stonecutting recipe.
142-
// #[derive(Clone, Debug)]
143-
// pub struct StonecuttingData<'a> {
144-
// /// Used to group similar recipes together in the recipe book.
145-
// pub group: Cow<'a, str>,
146-
// /// The ingredient for the stonecutting recipe.
147-
// pub ingredient: Ingredient<'a>,
148-
// /// The result of the stonecutting recipe.
149-
// pub result: ItemStack,
150-
// }
151-
//
152-
// /// Represents data for a smithing transform recipe.
153-
// #[derive(Clone, Debug)]
154-
// pub struct SmithingTransformData<'a> {
155-
// /// The smithing template.
156-
// pub template: Ingredient<'a>,
157-
// /// The base item.
158-
// pub base: Ingredient<'a>,
159-
// /// The additional ingredient.
160-
// pub addition: Ingredient<'a>,
161-
// /// The result of the smithing transform.
162-
// pub result: ItemStack,
163-
// }
164-
//
165-
// /// Represents data for a smithing trim recipe.
166-
// #[derive(Clone, Debug)]
167-
// pub struct SmithingTrimData<'a> {
168-
// /// The smithing template.
169-
// pub template: Ingredient<'a>,
170-
// /// The base item.
171-
// pub base: Ingredient<'a>,
172-
// /// The additional ingredient.
173-
// pub addition: Ingredient<'a>,
174-
// }
175-
176105
/// Represents the categories for crafting recipes.
177106
#[derive(Copy, Clone, PartialEq, Eq, Debug, Encode, Default)]
178107
pub enum CraftingCategory {
@@ -223,60 +152,12 @@ impl Encode for CraftingShapelessData {
223152
}
224153
}
225154

226-
// impl Encode for CraftingShapedData<'_> {
227-
// fn encode(&self, mut w: impl Write) -> anyhow::Result<()> {
228-
// self.width.encode(&mut w)?;
229-
// self.height.encode(&mut w)?;
230-
// self.group.encode(&mut w)?;
231-
// self.category.encode(&mut w)?;
232-
// self.ingredients.encode(&mut w)?;
233-
// self.result.encode(&mut w)?;
234-
// self.show_notification.encode(w)
235-
// }
236-
// }
237-
238155
impl Encode for CraftingSpecialData {
239156
fn encode(&self, w: impl Write) -> anyhow::Result<()> {
240157
self.category.encode(w)
241158
}
242159
}
243160

244-
// impl Encode for SmeltingData<'_> {
245-
// fn encode(&self, mut w: impl Write) -> anyhow::Result<()> {
246-
// self.group.encode(&mut w)?;
247-
// self.category.encode(&mut w)?;
248-
// self.ingredient.encode(&mut w)?;
249-
// self.result.encode(&mut w)?;
250-
// self.experience.encode(&mut w)?;
251-
// self.cooking_time.encode(w)
252-
// }
253-
// }
254-
//
255-
// impl Encode for StonecuttingData<'_> {
256-
// fn encode(&self, mut w: impl Write) -> anyhow::Result<()> {
257-
// self.group.encode(&mut w)?;
258-
// self.ingredient.encode(&mut w)?;
259-
// self.result.encode(w)
260-
// }
261-
// }
262-
//
263-
// impl Encode for SmithingTransformData<'_> {
264-
// fn encode(&self, mut w: impl Write) -> anyhow::Result<()> {
265-
// self.template.encode(&mut w)?;
266-
// self.base.encode(&mut w)?;
267-
// self.addition.encode(&mut w)?;
268-
// self.result.encode(w)
269-
// }
270-
// }
271-
//
272-
// impl Encode for SmithingTrimData<'_> {
273-
// fn encode(&self, mut w: impl Write) -> anyhow::Result<()> {
274-
// self.template.encode(&mut w)?;
275-
// self.base.encode(&mut w)?;
276-
// self.addition.encode(w)
277-
// }
278-
// }
279-
280161
#[derive(Debug, Encode, Packet)]
281162
pub struct UnlockRecipesS2c {
282163
pub action: Action,

crates/hyperion-inventory/src/lib.rs

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,6 @@ impl PlayerInventory {
249249
.cloned()
250250
.unwrap_or(ItemStack::EMPTY);
251251

252-
// if result.is_empty() {
253-
// return ItemStack::EMPTY;
254-
// }
255-
//
256-
// let new_count = 64.min(min_count as i32 * result.count as i32);
257-
//
258-
// result.count = new_count as i8;
259-
260252
result
261253
}
262254

@@ -372,118 +364,6 @@ pub fn slot_index_from_hand(hand_idx: u8) -> u16 {
372364
// todo: not sure if this is correct
373365
pub const OFFHAND_SLOT: u16 = 45;
374366

375-
// #[cfg(test)]
376-
// mod tests {
377-
// use valence_protocol::ItemKind;
378-
//
379-
// use super::*;
380-
//
381-
// #[test]
382-
// fn test_try_add_item_empty_inventory() {
383-
// let mut inventory = PlayerInventory::default();
384-
// let item = ItemStack::new(ItemKind::Stone, 64, None);
385-
// let result = inventory.try_add_item(item);
386-
//
387-
// assert_eq!(result.changed_slots, vec![36]);
388-
// assert!(result.remaining.is_none());
389-
// assert_eq!(inventory.get(36).unwrap().count, 64);
390-
// }
391-
//
392-
// #[test]
393-
// fn test_try_add_item_partially_filled_slot() {
394-
// let mut inventory = PlayerInventory::default();
395-
// inventory
396-
// .set(36, ItemStack::new(ItemKind::Stone, 32, None))
397-
// .unwrap();
398-
// let item = ItemStack::new(ItemKind::Stone, 64, None);
399-
// let result = inventory.try_add_item(item);
400-
//
401-
// assert_eq!(result.changed_slots, vec![36, 37]);
402-
// assert!(result.remaining.is_none());
403-
// assert_eq!(inventory.get(36).unwrap().count, 64);
404-
// assert_eq!(inventory.get(37).unwrap().count, 32);
405-
// }
406-
//
407-
// #[test]
408-
// fn test_try_add_item_full_inventory() {
409-
// let mut inventory = PlayerInventory::default();
410-
// for slot in 0..46 {
411-
// inventory
412-
// .set(slot, ItemStack::new(ItemKind::Stone, 64, None))
413-
// .unwrap();
414-
// }
415-
// let item = ItemStack::new(ItemKind::Stone, 64, None);
416-
// let result = inventory.try_add_item(item);
417-
//
418-
// assert!(result.changed_slots.is_empty());
419-
// assert_eq!(
420-
// result.remaining,
421-
// Some(ItemStack::new(ItemKind::Stone, 64, None))
422-
// );
423-
// }
424-
//
425-
// #[test]
426-
// fn test_try_add_item_different_items() {
427-
// let mut inventory = PlayerInventory::default();
428-
// inventory
429-
// .set(36, ItemStack::new(ItemKind::Stone, 64, None))
430-
// .unwrap();
431-
// let item = ItemStack::new(ItemKind::Dirt, 64, None);
432-
// let result = inventory.try_add_item(item);
433-
//
434-
// assert_eq!(result.changed_slots, vec![37]);
435-
// assert!(result.remaining.is_none());
436-
// assert_eq!(inventory.get(36).unwrap().item, ItemKind::Stone);
437-
// assert_eq!(inventory.get(37).unwrap().item, ItemKind::Dirt);
438-
// }
439-
//
440-
// #[test]
441-
// fn test_try_add_item_partial_stack() {
442-
// let mut inventory = PlayerInventory::default();
443-
// let item = ItemStack::new(ItemKind::Stone, 32, None);
444-
// let result = inventory.try_add_item(item);
445-
//
446-
// assert_eq!(result.changed_slots, vec![36]);
447-
// assert!(result.remaining.is_none());
448-
// assert_eq!(inventory.get(36).unwrap().count, 32);
449-
// }
450-
//
451-
// #[test]
452-
// fn test_try_add_item_multiple_partial_stacks() {
453-
// let mut inventory = PlayerInventory::default();
454-
// inventory
455-
// .set(36, ItemStack::new(ItemKind::Stone, 32, None))
456-
// .unwrap();
457-
// inventory
458-
// .set(37, ItemStack::new(ItemKind::Stone, 32, None))
459-
// .unwrap();
460-
// let item = ItemStack::new(ItemKind::Stone, 64, None);
461-
// let result = inventory.try_add_item(item);
462-
//
463-
// assert!(result.remaining.is_none());
464-
// assert_eq!(inventory.get(36).unwrap().count, 64);
465-
// assert_eq!(inventory.get(37).unwrap().count, 64);
466-
// assert_eq!(inventory.get(38).unwrap().count, 0);
467-
//
468-
// assert_eq!(result.changed_slots, vec![36, 37]);
469-
// }
470-
//
471-
// #[test]
472-
// fn test_try_add_item_overflow() {
473-
// let mut inventory = PlayerInventory::default();
474-
// inventory
475-
// .set(36, ItemStack::new(ItemKind::Stone, 63, None))
476-
// .unwrap();
477-
// let item = ItemStack::new(ItemKind::Stone, 64, None);
478-
// let result = inventory.try_add_item(item);
479-
//
480-
// assert_eq!(result.changed_slots, vec![36, 37]);
481-
// assert!(result.remaining.is_none());
482-
// assert_eq!(inventory.get(36).unwrap().count, 64);
483-
// assert_eq!(inventory.get(37).unwrap().count, 63);
484-
// }
485-
// }
486-
487367
#[derive(Component)]
488368
pub struct InventoryModule;
489369

crates/hyperion/benches/atomic.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ use hyperion::{
99
util::SendableRef,
1010
};
1111

12-
// chunks
13-
// [queue] for region
14-
//
15-
1612
const THREADS: &[usize] = &[1, 2, 4, 8];
1713

1814
fn main() {

crates/hyperion/src/common/config.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,6 @@ pub enum Radius {
3232
Euclidean,
3333
}
3434

35-
// impl Radius {
36-
// #[allow(clippy::cast_possible_truncation)]
37-
// pub fn get_random_2d(self) -> IVec2 {
38-
// match self {
39-
// Self::Chebyshev(radius) => {
40-
// let x = fastrand::i32(-radius..radius);
41-
// let z = fastrand::i32(-radius..radius);
42-
// IVec2::new(x, z)
43-
// }
44-
// Self::Euclidean(radius) => {
45-
// let r = fastrand::f32() * radius as f32;
46-
// let theta = fastrand::f32() * 2.0 * std::f32::consts::PI;
47-
//
48-
// let x = r * theta.cos();
49-
// let z = r * theta.sin();
50-
//
51-
// let x = x as i32;
52-
// let z = z as i32;
53-
//
54-
// IVec2::new(x, z)
55-
// }
56-
// }
57-
// }
58-
// }
59-
6035
impl Default for Config {
6136
fn default() -> Self {
6237
Self {

crates/hyperion/src/common/util/tracing_ext.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
use flecs_ecs::core::{ComponentId, EntityView, QueryTuple, SystemAPI, builder};
22
use tracing::Span;
3-
// SystemAPI<'a, P, T>: Builder<'a> + private::internal_SystemAPI<'a, P, T>
4-
// where
5-
// T: QueryTuple,
6-
// P: ComponentId,
7-
// {
83

94
pub trait TracingExt<'a, P, T>: SystemAPI<'a, P, T>
105
where

crates/hyperion/src/egress/player_join/mod.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -447,28 +447,6 @@ fn generate_cached_packet_bytes(
447447
},
448448
})?;
449449

450-
// if let Some(diameter) = config.border_diameter {
451-
// debug!("Setting world border to diameter {}", diameter);
452-
//
453-
// encoder.append_packet(&play::WorldBorderInitializeS2c {
454-
// x: f64::from(PLAYER_SPAWN_POSITION.x),
455-
// z: f64::from(PLAYER_SPAWN_POSITION.z),
456-
// old_diameter: diameter,
457-
// new_diameter: diameter,
458-
// duration_millis: 1.into(),
459-
// portal_teleport_boundary: 29_999_984.into(),
460-
// warning_blocks: 50.into(),
461-
// warning_time: 200.into(),
462-
// })?;
463-
//
464-
// encoder.append_packet(&play::WorldBorderSizeChangedS2c { diameter })?;
465-
//
466-
// encoder.append_packet(&play::WorldBorderCenterChangedS2c {
467-
// x_pos: f64::from(PLAYER_SPAWN_POSITION.x),
468-
// z_pos: f64::from(PLAYER_SPAWN_POSITION.z),
469-
// })?;
470-
// }
471-
472450
if let Some(pkt) = crafting_registry.packet() {
473451
encoder.append_packet(&pkt)?;
474452
}

0 commit comments

Comments
 (0)