try to fix the weird errors that happen / make them more debuggable

This commit is contained in:
bgkillas 2025-06-22 08:10:49 -04:00
parent e93db76c77
commit b288cebf02
3 changed files with 10 additions and 5 deletions

View file

@ -705,9 +705,9 @@ pub mod raw {
av: ret.5,
}))
}
Err(err) => {
Err(_) => {
lua.pop_last_n(6);
Err(err)
Ok(None)
}
}
}

View file

@ -1,12 +1,15 @@
use crate::lua::{LuaGetValue, LuaPutValue, LuaState};
use crate::{AbilityComponent, EntityID};
use eyre::{Context, OptionExt};
use std::backtrace::Backtrace;
pub fn serialize_entity(entity: EntityID) -> eyre::Result<Vec<u8>> {
let lua = LuaState::current()?;
lua.get_global(c"EwextSerialize");
entity.put(lua);
lua.call(1, 1i32)
.wrap_err("Failed to call EwextSerialize")?;
lua.call(1, 1i32).wrap_err(format!(
"Failed to call EwextSerialize\n{}",
Backtrace::force_capture()
))?;
let res = lua.to_raw_string(-1);
lua.pop_last_n(1i32);
res

View file

@ -282,7 +282,9 @@ function OnProjectileFired(
local proj = EntityGetFirstComponentIncludingDisabled(projectile_id, "ProjectileComponent")
local life = EntityGetFirstComponentIncludingDisabled(projectile_id, "LifetimeComponent")
if proj == nil or ComponentGetValue2(proj, "lifetime") > 4 or ComponentGetValue2(life, "lifetime") > 4 then
ewext.sync_projectile(projectile_id, shooter_player_data.peer_id, rng)
if EntityGetIsAlive(projectile_id) then
ewext.sync_projectile(projectile_id, shooter_player_data.peer_id, rng)
end
end
if shooter_player_data.peer_id ~= ctx.my_id then
if proj ~= nil then