From c01109c483841d4c0e48cb27ac0d32992b47ace6 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 5 Apr 2012 19:49:30 +0000 Subject: [PATCH] m32script: fix some commands breaking too early in case of a failed validation. If one next instruction happened to be interpreted, madness would ensue, because the pointer wouldn't be aligned on the "opcode" part anymore. Also, with "seti", set current sprite index only after a successful validation. git-svn-id: https://svn.eduke32.com/eduke32@2591 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/samples/a.m32 | 4 ++-- polymer/eduke32/source/m32exec.c | 35 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/polymer/eduke32/samples/a.m32 b/polymer/eduke32/samples/a.m32 index 82c6a7e0f..018da9f12 100644 --- a/polymer/eduke32/samples/a.m32 +++ b/polymer/eduke32/samples/a.m32 @@ -287,8 +287,8 @@ defstate fiddlewithlights ifaimingsprite set k 1 else set k 0 ife k 1 ife sprite[searchwall].picnum SECTOREFFECTOR - ifge sprite[searchwall].lotag 49 ifle sprite[searchwall].lotag 50 - set k 0 + ifge sprite[searchwall].lotag 49 ifle sprite[searchwall].lotag 50 + set k 0 ife k 1 { diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 9ee563bfe..0b10761cd 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -2809,47 +2809,52 @@ dodefault: // vvv CURSPR case CON_SETI: + { + int32_t newcurspritei; + insptr++; - vm.g_i = Gv_GetVarX(*insptr++); - X_ERROR_INVALIDCI(); + newcurspritei = Gv_GetVarX(*insptr++); + X_ERROR_INVALIDSPRI(newcurspritei); + vm.g_i = newcurspritei; vm.g_sp = &sprite[vm.g_i]; continue; + } case CON_SIZEAT: - insptr++; + insptr += 3; X_ERROR_INVALIDSP(); - vm.g_sp->xrepeat = (uint8_t) Gv_GetVarX(*insptr++); - vm.g_sp->yrepeat = (uint8_t) Gv_GetVarX(*insptr++); + vm.g_sp->xrepeat = (uint8_t) Gv_GetVarX(*(insptr-2)); + vm.g_sp->yrepeat = (uint8_t) Gv_GetVarX(*(insptr-1)); continue; case CON_CSTAT: - insptr++; + insptr += 2; X_ERROR_INVALIDSP(); - vm.g_sp->cstat = (int16_t) *insptr++; + vm.g_sp->cstat = (int16_t) *(insptr-1); continue; case CON_CSTATOR: - insptr++; + insptr += 2; X_ERROR_INVALIDSP(); - vm.g_sp->cstat |= (int16_t) Gv_GetVarX(*insptr++); + vm.g_sp->cstat |= (int16_t) Gv_GetVarX(*(insptr-1)); continue; case CON_CLIPDIST: - insptr++; + insptr += 2; X_ERROR_INVALIDSP(); - vm.g_sp->clipdist = (int16_t) Gv_GetVarX(*insptr++); + vm.g_sp->clipdist = (uint8_t) Gv_GetVarX(*(insptr-1)); continue; case CON_SPRITEPAL: - insptr++; + insptr += 2; X_ERROR_INVALIDSP(); - vm.g_sp->pal = Gv_GetVarX(*insptr++); + vm.g_sp->pal = Gv_GetVarX(*(insptr-1)); continue; case CON_CACTOR: - insptr++; + insptr += 2; X_ERROR_INVALIDSP(); - vm.g_sp->picnum = Gv_GetVarX(*insptr++); + vm.g_sp->picnum = Gv_GetVarX(*(insptr-1)); continue; case CON_SPGETLOTAG: