a.m32: add states 'uniformceiling' and 'uniformfloor'.

Given highlighted sectors, these take the arithmetic mean of their ceiling's
or floor's (respectively) z, removing the slope bit from all, and setting the
new z to the mean one, rounded down to 1024 Build z units (one PGUP/PGDN).

BUILD_LUNATIC.

git-svn-id: https://svn.eduke32.com/eduke32@4357 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-02-28 20:33:47 +00:00
parent ea8c081084
commit a399bd5717
2 changed files with 48 additions and 1 deletions

View file

@ -1563,6 +1563,53 @@ defstate sanitize_underwater_sprites
printmessage16 "Set xvel=1 on highlighted wall/floor sprites"
ends
define BZ_MAX 8388608
defstate uniformceil
var avgz n
for i selsectors
{
ifand sector[i].ceilingstat 2 xor sector[i].ceilingstat 2
add avgz sector[i].ceilingz
add n 1
}
ife n 0 break
div avgz n
and avgz 0xfffffc00 // round to one PGUP/PNDN unit (1024 z units)
ifvarge avgz -BZ_MAX ifvarle avgz BZ_MAX nullop
else quote "ERROR: average z value outside [-8388608 .. 8388608]" // BZ_MAX
for i selsectors
set sector[i].ceilingz avgz
ends
// XXX: CODEDUP
defstate uniformfloor
var avgz n
for i selsectors
{
ifand sector[i].floorstat 2 xor sector[i].floorstat 2
add avgz sector[i].floorz
add n 1
}
ife n 0 break
div avgz n
and avgz 0xfffffc00 // round to one PGUP/PNDN unit (1024 z units)
ifvarge avgz -BZ_MAX ifvarle avgz BZ_MAX nullop
else quote "ERROR: average z value outside [-8388608 .. 8388608]" // BZ_MAX
for i selsectors
set sector[i].floorz avgz
ends
// This must be *compiled* with script_expertmode
/*
defstate setstartpos

View file

@ -149,7 +149,7 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor)
int32_t localvars[M32_LOCALS_FIXEDNUM];
#endif
// needed since any read access before initialization would cause undefined behaviour
// Initialize 'state'-local variables to 0.
if (aEventNumLocals[iEventID] > 0)
Bmemset(localvars, 0, aEventNumLocals[iEventID]*sizeof(int32_t));