From 8d84706dc9cc362b2cad3f5dc8ded6f877b20eab Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 23 Aug 2013 17:01:13 +0000 Subject: [PATCH] Mapster32: after auto-inserting inner sector, change sectnums for sprites now in it. (Auto-insertion of an inner sector from a loop happens either because the loop is created in an extended sector, or because it has been punched through a ceiling/floor into the upper/lower neighbor sector.) git-svn-id: https://svn.eduke32.com/eduke32@4033 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/build.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 38d00a4e8..76dcec86c 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -2917,6 +2917,21 @@ static int32_t vec2eq(const vec2_t *v1, const vec2_t *v2) return (v1->x==v2->x && v1->y==v2->y); } +#ifdef YAX_ENABLE +// After auto-creating inner sector in existing sector , we need to +// see if some sprites contained in need to change their sector. +static void CorrectSpriteSectnums(int32_t os, int32_t ns) +{ + int32_t i, ni; + + for (SPRITES_OF_SECT_SAFE(os, i, ni)) + { + if (inside(sprite[i].x, sprite[i].y, ns)==1) + changespritesect(i, ns); + } +} +#endif + // precondition: [numwalls, newnumwalls-1] form a new loop (may be of wrong orientation) // ret_ofirstwallofs: if != NULL, *ret_ofirstwallofs will contain the offset of the old // first wall from the new first wall of the sector k, and the automatic @@ -3006,6 +3021,8 @@ static int32_t AddLoopToSector(int32_t k, int32_t *ret_ofirstwallofs) numwalls = newnumwalls; newnumwalls = -1; numsectors++; + + CorrectSpriteSectnums(k, numsectors-1); } #endif if (ret_ofirstwallofs)