Skip to content

Commit

Permalink
Make ROOM_AREA public and move to extra constants (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden authored Jul 18, 2024
1 parent b73f67b commit 82d742a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Unreleased
==========

### Misc:

- Move crate constant `ROOM_AREA` to extra constants module and make public

0.21.1 (2024-06-28)
===================

Expand Down
5 changes: 5 additions & 0 deletions src/constants/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ pub const ROOM_VISUAL_PER_ROOM_SIZE_LIMIT: u32 = 500 * 1024;
/// [`Room`]: crate::objects::Room
pub const ROOM_SIZE: u8 = 50;

/// The number of total tiles in each [`Room`] in the game
///
/// [`Room`]: crate::objects::Room
pub const ROOM_AREA: usize = (ROOM_SIZE as usize) * (ROOM_SIZE as usize);

/// Owner username of hostile non-player structures and creeps which occupy
/// sector center rooms.
pub const SOURCE_KEEPER_USERNAME: &str = "Source Keeper";
Expand Down
3 changes: 2 additions & 1 deletion src/local/cost_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use std::ops::{Index, IndexMut};
use serde::{Deserialize, Serialize};

use crate::{
constants::ROOM_AREA,
objects::CostMatrix,
traits::{CostMatrixGet, CostMatrixSet},
};

use super::{linear_index_to_xy, xy_to_linear_index, Position, RoomXY, ROOM_AREA};
use super::{linear_index_to_xy, xy_to_linear_index, Position, RoomXY};

/// A matrix of pathing costs for a room, stored in Rust memory.
///
Expand Down
4 changes: 1 addition & 3 deletions src/local/room_xy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ use std::{cmp::Ordering, fmt};
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};

use super::room_coordinate::{OutOfBoundsError, RoomCoordinate};
use crate::constants::{Direction, ROOM_SIZE};
use crate::constants::{Direction, ROOM_AREA, ROOM_SIZE};

mod approximate_offsets;
mod extra_math;
mod game_math;

pub(crate) const ROOM_AREA: usize = (ROOM_SIZE as usize) * (ROOM_SIZE as usize);

/// Converts a [`RoomXY`] coordinate pair to a linear index appropriate for use
/// with the internal representation of a [`CostMatrix`] or [`LocalCostMatrix`].
///
Expand Down
7 changes: 5 additions & 2 deletions src/local/terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ use std::mem::MaybeUninit;

use js_sys::Uint8Array;

use crate::{constants::Terrain, objects::RoomTerrain};
use crate::{
constants::{Terrain, ROOM_AREA},
objects::RoomTerrain,
};

use super::{xy_to_terrain_index, RoomXY, ROOM_AREA};
use super::{xy_to_terrain_index, RoomXY};

#[derive(Debug, Clone)]
pub struct LocalRoomTerrain {
Expand Down

0 comments on commit 82d742a

Please sign in to comment.