From 8817307f23d0f995d7f14366d280f13e7f24d7a4 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 20 Nov 2016 23:12:01 +0000 Subject: [PATCH] Create duplicate powerups with movement MT_NONE zicodxx reported an assertion failure when powerup duplication was enabled. Local debugging shows that some levels give preplaced powerups a movement type of MT_NONE rather than MT_PHYSICS. Such powerups have undefined data in their mtype.phys_info branch, which confuses the physics simulation code. Powerups only need MT_PHYSICS to bounce away from their spawn site. Preplaced powerups never move. Add assertions that preplaced powerups are MT_NONE. Change the duplication call to create the duplicates with movement MT_NONE. Reported-by: zicodxx --- similar/main/multi.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index 15f00ee96..d2ec6c848 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -3253,11 +3253,12 @@ void update_item_state::process_powerup(const object &o, const powerup_type_t id const auto &seg_verts = segp->verts; for (uint_fast32_t i = count++; i; --i) { - const auto &&no = obj_create(OBJ_POWERUP, id, segp, vm_vec_avg(o.pos, Vertices[seg_verts[i % seg_verts.size()]]), &vmd_identity_matrix, o.size, CT_POWERUP, MT_PHYSICS, RT_POWERUP); + assert(o.movement_type == MT_NONE); + assert(o.render_type == RT_POWERUP); + const auto &&no = obj_create(OBJ_POWERUP, id, segp, vm_vec_avg(o.pos, Vertices[seg_verts[i % seg_verts.size()]]), &vmd_identity_matrix, o.size, CT_POWERUP, MT_NONE, RT_POWERUP); if (no == object_none) return; m_modified.set(no); - no->mtype.phys_info = o.mtype.phys_info; no->rtype.vclip_info = o.rtype.vclip_info; no->rtype.vclip_info.framenum = (o.rtype.vclip_info.framenum + (i * vc_num_frames) / count) % vc_num_frames; no->ctype.powerup_info = o.ctype.powerup_info;