Skip to content

Commit 6ed0f13

Browse files
committed
fix death notify
1 parent 0b9218a commit 6ed0f13

File tree

5 files changed

+13
-29
lines changed

5 files changed

+13
-29
lines changed

ewext/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,9 @@ pub unsafe extern "C" fn luaopen_ewext1(lua: *mut lua_State) -> c_int {
517517
.as_mut()
518518
.ok_or_eyre("No entity sync module loaded")?;
519519
#[allow(clippy::type_complexity)]
520-
let (entity_killed, wait_on_kill, drops_gold, x, y, file, entity_responsible): (
520+
let (entity_killed, wait_on_kill, x, y, file, entity_responsible): (
521521
Option<EntityID>,
522522
Option<bool>,
523-
Option<bool>,
524523
Option<f64>,
525524
Option<f64>,
526525
Option<Cow<'_, str>>,
@@ -530,14 +529,12 @@ pub unsafe extern "C" fn luaopen_ewext1(lua: *mut lua_State) -> c_int {
530529
entity_killed.ok_or_eyre("Expected to have a valid entity_killed")?;
531530
let file = file.ok_or_eyre("Expected to have a valid file")?;
532531
let wait_on_kill = wait_on_kill.ok_or_eyre("Expected to have a valid pos")?;
533-
let drops_gold = drops_gold.ok_or_eyre("Expected to have a valid pos")?;
534532
let x = x.ok_or_eyre("Expected to have a valid pos")?;
535533
let y = y.ok_or_eyre("Expected to have a valid pos")?;
536534
let pos = WorldPos::from_f64(x, y);
537535
entity_sync.cross_death_notify(
538536
entity_killed,
539537
wait_on_kill,
540-
drops_gold,
541538
pos,
542539
file.to_string(),
543540
entity_responsible,

ewext/src/modules/entity_sync.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,13 @@ impl EntitySync {
292292
&mut self,
293293
entity_killed: EntityID,
294294
wait_on_kill: bool,
295-
drops_gold: bool,
296295
pos: WorldPos,
297296
file: String,
298297
entity_responsible: Option<EntityID>,
299298
) -> eyre::Result<()> {
300299
self.local_diff_model.death_notify(
301300
entity_killed,
302301
wait_on_kill,
303-
drops_gold,
304302
pos,
305303
file,
306304
entity_responsible,

ewext/src/modules/entity_sync/diff_model.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct LocalDiffModelTracker {
4141
pending_authority: Vec<FullEntityData>,
4242
pending_localize: Vec<(Lid, PeerId)>,
4343
/// Stores pairs of entity killed and optionally the responsible entity.
44-
pending_death_notify: Vec<(EntityID, bool, bool, WorldPos, String, Option<EntityID>)>,
44+
pending_death_notify: Vec<(EntityID, bool, WorldPos, String, Option<EntityID>)>,
4545
authority_radius: f32,
4646
global_entities: FxHashSet<EntityID>,
4747
}
@@ -164,7 +164,7 @@ impl LocalDiffModelTracker {
164164
&& self
165165
.pending_death_notify
166166
.iter()
167-
.all(|(e, _, _, _, _, _)| *e != entity)
167+
.all(|(e, _, _, _, _)| *e != entity)
168168
{
169169
self.pending_removal.push(lid);
170170
ctx.net.send(&NoitaOutbound::DesToProxy(
@@ -917,7 +917,7 @@ impl LocalDiffModel {
917917
}
918918

919919
let mut dead = Vec::new();
920-
for (killed, wait_on_kill, drops_gold, pos, file, responsible) in
920+
for (killed, wait_on_kill, pos, file, responsible) in
921921
self.tracker.pending_death_notify.drain(..)
922922
{
923923
let responsible_peer = responsible
@@ -926,6 +926,11 @@ impl LocalDiffModel {
926926
let Some(lid) = self.tracker.tracked.get_by_right(&killed).copied() else {
927927
continue;
928928
};
929+
let drops_gold = if let Some(info) = self.entity_entries.get(&lid) {
930+
info.current.drops_gold
931+
} else {
932+
false
933+
};
929934
res.push(EntityUpdate::KillEntity {
930935
lid,
931936
wait_on_kill,
@@ -994,15 +999,13 @@ impl LocalDiffModel {
994999
&mut self,
9951000
entity_killed: EntityID,
9961001
wait_on_kill: bool,
997-
drops_gold: bool,
9981002
pos: WorldPos,
9991003
file: String,
10001004
entity_responsible: Option<EntityID>,
10011005
) {
10021006
self.tracker.pending_death_notify.push((
10031007
entity_killed,
10041008
wait_on_kill,
1005-
drops_gold,
10061009
pos,
10071010
file,
10081011
entity_responsible,

quant.ew/files/system/entity_sync_helper/death_notify.lua

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,5 @@ function death(damage_type_bit_field, damage_message, entity_thats_responsible,
66
if damage ~= nil then
77
wait_on_kill = ComponentGetValue2(damage, "wait_for_kill_flag_on_death")
88
end
9-
local drops_gold = false
10-
for _, lua in ipairs(EntityGetComponent(ent, "LuaComponent") or {}) do
11-
local s = ComponentGetValue2(lua, "script_death")
12-
if
13-
s == "data/scripts/items/drop_money.lua"
14-
or (EntityHasTag(ent, "boss_dragon") and s == "data/scripts/animals/boss_dragon_death.lua")
15-
then
16-
drops_gold = true
17-
break
18-
end
19-
end
20-
if EntityGetFirstComponentIncludingDisabled(ent, "VariableStorageComponent", "no_gold_drop") ~= nil then
21-
drops_gold = false
22-
end
23-
CrossCall("ew_death_notify", ent, wait_on_kill, drops_gold, x, y, EntityGetFilename(ent), entity_thats_responsible)
9+
CrossCall("ew_death_notify", ent, wait_on_kill, x, y, EntityGetFilename(ent), entity_thats_responsible)
2410
end

quant.ew/files/system/entity_sync_helper/entity_sync_helper.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ util.add_cross_call("ew_thrown", function(thrown_item)
4141
end
4242
end)
4343

44-
util.add_cross_call("ew_death_notify", function(entity, wait_on_kill, drops_gold, x, y, file, responsible)
45-
table.insert(dead, { entity, wait_on_kill, drops_gold, x, y, file, responsible })
44+
util.add_cross_call("ew_death_notify", function(entity, wait_on_kill, x, y, file, responsible)
45+
table.insert(dead, { entity, wait_on_kill, x, y, file, responsible })
4646
end)
4747

4848
util.add_cross_call("ew_chest_opened", function(x, y, rx, ry, file, entity, dont)
@@ -86,7 +86,7 @@ function mod.on_world_update_post()
8686
end
8787
end
8888
for _, data in ipairs(dead) do
89-
ewext.des_death_notify(data[1], data[2], data[3], data[4], data[5], data[6], data[7])
89+
ewext.des_death_notify(data[1], data[2], data[3], data[4], data[5], data[6])
9090
end
9191
for _, data in ipairs(chest) do
9292
ewext.des_chest_opened(data[1], data[2], data[3], data[4], data[5], data[6])

0 commit comments

Comments
 (0)