mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
Clean up CON_FOR a little
git-svn-id: https://svn.eduke32.com/eduke32@8395 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
949d2f311e
commit
a2fd43da2f
1 changed files with 38 additions and 71 deletions
|
@ -2614,6 +2614,14 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
|
||||||
dispatch();
|
dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CON_FOR_ITERATION() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
Gv_SetVar(returnVar, jj); \
|
||||||
|
insptr = pNext; \
|
||||||
|
VM_Execute(); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
vInstruction(CON_FOR): // special-purpose iteration
|
vInstruction(CON_FOR): // special-purpose iteration
|
||||||
insptr++;
|
insptr++;
|
||||||
{
|
{
|
||||||
|
@ -2631,113 +2639,76 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
|
||||||
{
|
{
|
||||||
if (sprite[jj].statnum == MAXSTATUS)
|
if (sprite[jj].statnum == MAXSTATUS)
|
||||||
continue;
|
continue;
|
||||||
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_ALLSPRITESBYSTAT:
|
case ITER_ALLSPRITESBYSTAT:
|
||||||
for (native_t statNum = 0; statNum < MAXSTATUS; ++statNum)
|
for (native_t statNum = 0; statNum < MAXSTATUS; ++statNum)
|
||||||
{
|
{
|
||||||
for (native_t jj = headspritestat[statNum]; jj >= 0;)
|
for (native_t jj = headspritestat[statNum], kk = nextspritestat[jj]; jj >= 0; jj = kk, kk = nextspritestat[jj])
|
||||||
{
|
CON_FOR_ITERATION();
|
||||||
int const kk = nextspritestat[jj];
|
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
jj = kk;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_ALLSPRITESBYSECT:
|
case ITER_ALLSPRITESBYSECT:
|
||||||
for (native_t sectNum = 0; sectNum < numsectors; ++sectNum)
|
for (native_t sectNum = 0; sectNum < numsectors; ++sectNum)
|
||||||
{
|
{
|
||||||
for (native_t jj = headspritesect[sectNum]; jj >= 0;)
|
for (native_t jj = headspritesect[sectNum], kk = nextspritesect[jj]; jj >= 0; jj = kk, kk = nextspritesect[jj])
|
||||||
{
|
CON_FOR_ITERATION();
|
||||||
int const kk = nextspritesect[jj];
|
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
jj = kk;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_ALLSECTORS:
|
case ITER_ALLSECTORS:
|
||||||
for (native_t jj = 0; jj < numsectors; ++jj)
|
for (native_t jj = 0; jj < numsectors; ++jj)
|
||||||
{
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_ALLWALLS:
|
case ITER_ALLWALLS:
|
||||||
for (native_t jj = 0; jj < numwalls; ++jj)
|
for (native_t jj = 0; jj < numwalls; ++jj)
|
||||||
{
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_ACTIVELIGHTS:
|
case ITER_ACTIVELIGHTS:
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
for (native_t jj = 0; jj < PR_MAXLIGHTS; ++jj)
|
for (native_t jj = 0; jj < PR_MAXLIGHTS; ++jj)
|
||||||
{
|
{
|
||||||
if (!prlights[jj].flags.active)
|
if (!prlights[jj].flags.active)
|
||||||
continue;
|
continue;
|
||||||
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_DRAWNSPRITES:
|
case ITER_DRAWNSPRITES:
|
||||||
{
|
for (native_t jj = 0; jj < spritesortcnt; jj++)
|
||||||
for (native_t ii = 0; ii < spritesortcnt; ii++)
|
CON_FOR_ITERATION();
|
||||||
{
|
|
||||||
Gv_SetVar(returnVar, ii);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case ITER_SPRITESOFSECTOR:
|
case ITER_SPRITESOFSECTOR:
|
||||||
if ((unsigned)nIndex >= MAXSECTORS)
|
if ((unsigned)nIndex >= MAXSECTORS)
|
||||||
goto badindex;
|
goto badindex;
|
||||||
for (native_t jj = headspritesect[nIndex]; jj >= 0;)
|
|
||||||
{
|
for (native_t jj = headspritesect[nIndex], kk = nextspritesect[jj]; jj >= 0; jj = kk, kk = nextspritesect[jj])
|
||||||
int const kk = nextspritesect[jj];
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
jj = kk;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_SPRITESOFSTATUS:
|
case ITER_SPRITESOFSTATUS:
|
||||||
if ((unsigned)nIndex >= MAXSTATUS)
|
if ((unsigned)nIndex >= MAXSTATUS)
|
||||||
goto badindex;
|
goto badindex;
|
||||||
for (native_t jj = headspritestat[nIndex]; jj >= 0;)
|
|
||||||
{
|
for (native_t jj = headspritestat[nIndex], kk = nextspritestat[jj]; jj >= 0; jj = kk, kk = nextspritestat[jj])
|
||||||
int const kk = nextspritestat[jj];
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
jj = kk;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_WALLSOFSECTOR:
|
case ITER_WALLSOFSECTOR:
|
||||||
if ((unsigned)nIndex >= MAXSECTORS)
|
if ((unsigned)nIndex >= MAXSECTORS)
|
||||||
goto badindex;
|
goto badindex;
|
||||||
|
|
||||||
for (native_t jj = sector[nIndex].wallptr, endwall = jj + sector[nIndex].wallnum - 1; jj <= endwall; jj++)
|
for (native_t jj = sector[nIndex].wallptr, endwall = jj + sector[nIndex].wallnum - 1; jj <= endwall; jj++)
|
||||||
{
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_LOOPOFWALL:
|
case ITER_LOOPOFWALL:
|
||||||
if ((unsigned)nIndex >= (unsigned)numwalls)
|
if ((unsigned)nIndex >= (unsigned)numwalls)
|
||||||
goto badindex;
|
goto badindex;
|
||||||
|
@ -2745,20 +2716,15 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
|
||||||
int jj = nIndex;
|
int jj = nIndex;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Gv_SetVar(returnVar, jj);
|
CON_FOR_ITERATION();
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
jj = wall[jj].point2;
|
jj = wall[jj].point2;
|
||||||
} while (jj != nIndex);
|
} while (jj != nIndex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITER_RANGE:
|
case ITER_RANGE:
|
||||||
for (native_t jj = 0; jj < nIndex; jj++)
|
for (native_t jj = 0; jj < nIndex; jj++)
|
||||||
{
|
CON_FOR_ITERATION();
|
||||||
Gv_SetVar(returnVar, jj);
|
|
||||||
insptr = pNext;
|
|
||||||
VM_Execute();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
badindex:
|
badindex:
|
||||||
OSD_Printf(OSD_ERROR "Line %d, for %s: index %d out of range!\n", VM_DECODE_LINE_NUMBER(g_tw), iter_tokens[iterType].token, nIndex);
|
OSD_Printf(OSD_ERROR "Line %d, for %s: index %d out of range!\n", VM_DECODE_LINE_NUMBER(g_tw), iter_tokens[iterType].token, nIndex);
|
||||||
|
@ -2768,6 +2734,7 @@ badindex:
|
||||||
insptr = pEnd;
|
insptr = pEnd;
|
||||||
}
|
}
|
||||||
dispatch();
|
dispatch();
|
||||||
|
#undef CON_FOR_ITERATION
|
||||||
|
|
||||||
vInstruction(CON_REDEFINEQUOTE):
|
vInstruction(CON_REDEFINEQUOTE):
|
||||||
insptr++;
|
insptr++;
|
||||||
|
|
Loading…
Reference in a new issue