Skip to content

Commit

Permalink
fix egg projectile, fix a crash from last 3 commits, fix a proxy cras…
Browse files Browse the repository at this point in the history
…h from a while ago, sync telekensis objects if they dont exist, remove item dedup option since its not implemented with des
  • Loading branch information
bgkillas committed Jan 23, 2025
1 parent be5717e commit fae052b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 37 deletions.
10 changes: 8 additions & 2 deletions ewext/src/modules/entity_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ impl EntitySync {
pub fn iter_peers(&self, player_map: BiHashMap<PeerId, EntityID>) -> Vec<(bool, PeerId)> {
player_map
.left_values()
.map(|p| (self.interest_tracker.contains(*p), *p))
.filter_map(|p| {
if *p != my_peer_id() {
Some((self.interest_tracker.contains(*p), *p))
} else {
None
}
})
.collect::<Vec<(bool, PeerId)>>()
}
fn should_be_tracked(&mut self, entity: EntityID) -> eyre::Result<bool> {
Expand Down Expand Up @@ -439,7 +445,7 @@ impl Module for EntitySync {
)?;
}
for peer in ctx.player_map.clone().left_values() {
if !self.interest_tracker.contains(*peer) {
if !self.interest_tracker.contains(*peer) && *peer != my_peer_id() {
send_remotedes(
ctx,
true,
Expand Down
10 changes: 5 additions & 5 deletions noita-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct GameSettings {
world_num: u16,
debug_mode: Option<bool>,
use_constant_seed: bool,
item_dedup: Option<bool>,
// item_dedup: Option<bool>, TODO
enemy_hp_mult: Option<f32>,
game_mode: Option<GameMode>,
friendly_fire: Option<bool>,
Expand Down Expand Up @@ -236,15 +236,15 @@ impl GameSettings {
ui.add(DragValue::new(&mut game_settings.seed));
}
});
{
/*{
let mut temp = game_settings.item_dedup.unwrap_or(def.item_dedup);
if ui
.checkbox(&mut temp, tr("connect_settings_item_dedup"))
.changed()
{
game_settings.item_dedup = Some(temp)
}
}
}TODO*/
{
let mut temp = game_settings
.nice_terraforming
Expand Down Expand Up @@ -340,7 +340,7 @@ impl GameSettings {
}
pub struct DefaultSettings {
debug_mode: bool,
item_dedup: bool,
//item_dedup: bool,
enemy_hp_mult: f32,
game_mode: GameMode,
friendly_fire: bool,
Expand All @@ -361,7 +361,7 @@ impl Default for DefaultSettings {
fn default() -> Self {
DefaultSettings {
debug_mode: false,
item_dedup: true,
//item_dedup: true,
randomize_perks: true,
enemy_hp_mult: 1.0,
game_mode: GameMode::LocalHealth(LocalHealthMode::Normal),
Expand Down
2 changes: 1 addition & 1 deletion noita-proxy/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ impl NetManager {
settings.same_loadout.unwrap_or(def.same_loadout),
);
state.try_ws_write_option("debug", settings.debug_mode.unwrap_or(def.debug_mode));
state.try_ws_write_option("item_dedup", settings.item_dedup.unwrap_or(def.item_dedup));
// state.try_ws_write_option("item_dedup", settings.item_dedup.unwrap_or(def.item_dedup)); TODO
state.try_ws_write_option(
"randomize_perks",
settings.randomize_perks.unwrap_or(def.randomize_perks),
Expand Down
16 changes: 8 additions & 8 deletions noita-proxy/src/net/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,15 +1782,15 @@ impl WorldManager {
let atan: Vec<f32> = compute_atans(chunk_start_x, chunk_start_y, rays as f32, x, y);
for icx in 0..CHUNK_SIZE as i32 {
let cx = chunk_start_x + icx;
let dx = cx - x;
let dx = cx.abs_diff(x) as u64;
let dd = dx * dx;
for icy in 0..CHUNK_SIZE as i32 {
let cy = chunk_start_y + icy;
let dy = cy - y;
let dy = cy.abs_diff(y) as u64;
let px = icy as usize * CHUNK_SIZE + icx as usize;
if (dx == 0 && dy == 0) || {
let i = (atan[px] % rays as f32) as usize;
dd as u64 + dy.unsigned_abs() as u64 * dy.unsigned_abs() as u64
dd + dy * dy
<= list[i].0
} {
if self
Expand Down Expand Up @@ -2007,13 +2007,13 @@ impl WorldManager {
mat,
prob,
} = ex;
let dx = cx - x;
let dy = cy - y;
let dx = cx.abs_diff(x) as u64;
let dy = cy.abs_diff(y) as u64;
if ((dx == 0 && dy == 0) || {
let rays = get_ray(r);
let j = (atan[px] % rays as f32) as usize;
let dd = dx.unsigned_abs() as u64 * dx.unsigned_abs() as u64
+ dy.unsigned_abs() as u64 * dy.unsigned_abs() as u64;
let dd = dx * dx
+ dy * dy;
data.iter().any(|(i, r)| j == *i && dd <= *r)
}) && self
.materials
Expand Down Expand Up @@ -3248,4 +3248,4 @@ fn test_cut_perf() {
total += timer.elapsed().as_micros();
}
println!("total micros: {}", total / iters);
}
}
41 changes: 24 additions & 17 deletions quant.ew/files/system/telekenisis/telekenisis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ local function body_to_ent(id)
end
end

local sent_track_req = {}

function tele.on_world_update()
local n = EntitiesGetMaxID()
for ent = last + 1, n do
Expand All @@ -78,24 +80,29 @@ function tele.on_world_update()
if ComponentGetValue2(com, "mState") ~= 0 then
local body = ComponentGetValue(com, "mBodyID")
local ent, num = body_to_ent(tonumber(body))
local gid
for _, v in ipairs(EntityGetComponent(ent, "VariableStorageComponent") or {}) do
if ComponentGetValue2(v, "name") == "ew_gid_lid" then
gid = v
break
if ent ~= nil then
local gid
for _, v in ipairs(EntityGetComponent(ent, "VariableStorageComponent") or {}) do
if ComponentGetValue2(v, "name") == "ew_gid_lid" then
gid = v
break
end
end
if gid ~= nil then
has_tele = true
rpc.send_tele(
ComponentGetValue2(gid, "value_string"),
num,
ComponentGetValue2(com, "mStartBodyMaxExtent"),
ComponentGetValue2(com, "mStartAimAngle"),
ComponentGetValue2(com, "mStartBodyAngle"),
ComponentGetValue2(com, "mStartBodyDistance"),
ComponentGetValue2(com, "mMinBodyDistance")
)
elseif not table.contains(sent_track_req, ent) then
table.insert(sent_track_req, ent)
ewext.track(ent)
end
end
if gid ~= nil then
has_tele = true
rpc.send_tele(
ComponentGetValue2(gid, "value_string"),
num,
ComponentGetValue2(com, "mStartBodyMaxExtent"),
ComponentGetValue2(com, "mStartAimAngle"),
ComponentGetValue2(com, "mStartBodyAngle"),
ComponentGetValue2(com, "mStartBodyDistance"),
ComponentGetValue2(com, "mMinBodyDistance")
)
end
elseif has_tele then
has_tele = false
Expand Down
8 changes: 4 additions & 4 deletions quant.ew/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ local function load_modules()
ctx.load_system("essence_sync")
ctx.load_system("spectate")
ctx.load_system("effect_data_sync")
if ctx.proxy_opt.item_dedup then
-- ctx.load_system("gen_sync")
end
-- if ctx.proxy_opt.item_dedup then
-- ctx.load_system("gen_sync")
-- end
ctx.load_system("karl")
ctx.load_system("remove_wand_sound")
if ctx.proxy_opt.randomize_perks then
Expand Down Expand Up @@ -270,7 +270,7 @@ function OnProjectileFired(
or n == "data/entities/projectiles/deck/black_hole_giga.xml"
or n == "data/entities/projectiles/deck/white_hole.xml"
or n == "data/entities/projectiles/deck/white_hole_giga.xml"
or string.sub(n, 31) == "data/entities/items/pickup/egg_"
or string.sub(n, 1, 31) == "data/entities/items/pickup/egg_"
or EntityHasTag(projectile_id, "ew_projectile_position_sync")
then
local body = EntityGetFirstComponentIncludingDisabled(projectile_id, "PhysicsBody2Component")
Expand Down

0 comments on commit fae052b

Please sign in to comment.