2009-09-12 23:03:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2010-05-25 10:56:00 +00:00
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
This file is part of EDuke32.
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-09-12 23:03:15 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2017-06-27 11:01:12 +00:00
|
|
|
// This object is shared by the editors of *all* Build games!
|
|
|
|
|
2017-02-25 08:15:36 +00:00
|
|
|
#include "compat.h"
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
#include "m32script.h"
|
|
|
|
#include "m32def.h"
|
2011-03-17 23:37:38 +00:00
|
|
|
|
2009-11-01 20:30:09 +00:00
|
|
|
#include "sounds_mapster32.h"
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
#include "osd.h"
|
2009-09-16 22:24:24 +00:00
|
|
|
#include "keys.h"
|
2012-11-29 12:49:38 +00:00
|
|
|
#include "common.h"
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2015-09-27 21:17:59 +00:00
|
|
|
#include "colmatch.h"
|
|
|
|
|
2011-03-17 23:37:38 +00:00
|
|
|
// from macros.h
|
|
|
|
#define rnd(X) ((krand()>>8)>=(255-(X)))
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
vmstate_t vm;
|
|
|
|
vmstate_t vm_default =
|
|
|
|
{
|
2011-08-03 17:22:25 +00:00
|
|
|
-1, // g_i
|
|
|
|
0, // g_st
|
|
|
|
NULL, // g_sp
|
|
|
|
0, // flags
|
|
|
|
0, // miscflags
|
2009-09-12 23:03:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int32_t g_errorLineNum, g_tw;
|
|
|
|
|
|
|
|
uint8_t aEventEnabled[MAXEVENTS];
|
|
|
|
|
2009-09-16 22:24:24 +00:00
|
|
|
uint32_t m32_drawlinepat=0xffffffff;
|
2010-08-12 13:38:37 +00:00
|
|
|
int32_t m32_script_expertmode = 0;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
instype *insptr;
|
2018-10-16 06:08:50 +00:00
|
|
|
|
2009-09-17 22:08:37 +00:00
|
|
|
static instype *x_sortingstateptr;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2017-02-01 10:20:54 +00:00
|
|
|
//#include "m32structures.cpp"
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2010-08-18 23:21:19 +00:00
|
|
|
#ifdef DEBUGGINGAIDS
|
2009-09-18 21:44:46 +00:00
|
|
|
void X_Disasm(ofstype beg, int32_t size)
|
|
|
|
{
|
|
|
|
instype *p;
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
if (!apScript) return;
|
2009-09-18 21:44:46 +00:00
|
|
|
if (beg<0 || beg+size>g_scriptSize) return;
|
|
|
|
|
|
|
|
initprintf("beg=%d, size=%d: ", beg, size);
|
2016-08-27 01:40:35 +00:00
|
|
|
for (p=apScript+beg; p<apScript+beg+size; p++)
|
2009-09-18 21:44:46 +00:00
|
|
|
{
|
|
|
|
if (*p>>12 && (*p&0xFFF)<CON_END)
|
|
|
|
initprintf("%s ", keyw[*p&0xFFF]);
|
|
|
|
else
|
|
|
|
initprintf("%d ", *p);
|
|
|
|
}
|
|
|
|
initprintf("\n");
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
#endif
|
2009-09-18 21:44:46 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
void VM_ScriptInfo(void)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (apScript)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
instype *p;
|
|
|
|
if (insptr)
|
2016-08-27 01:40:35 +00:00
|
|
|
for (p=max(insptr-20,apScript); p<min(insptr+20, apScript+g_scriptSize); p++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
if (p==insptr) initprintf("<<");
|
|
|
|
|
|
|
|
if (*p>>12 && (*p&0xFFF)<CON_END)
|
2016-08-27 01:40:35 +00:00
|
|
|
initprintf("\n%5d: L%5d: %s ",(int32_t)(p-apScript),(int32_t)(*p>>12),keyw[*p&0xFFF]);
|
2009-09-12 23:03:15 +00:00
|
|
|
else initprintf(" %d",*p);
|
|
|
|
|
|
|
|
if (p==insptr) initprintf(">>");
|
|
|
|
}
|
|
|
|
initprintf(" \n");
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum >= 0)
|
|
|
|
initprintf("current sprite: %d\n",vm.spriteNum);
|
2009-09-12 23:03:15 +00:00
|
|
|
if (g_tw>=0 && g_tw<CON_END)
|
|
|
|
initprintf("g_errorLineNum: %d, g_tw: %s\n",g_errorLineNum,keyw[g_tw]);
|
|
|
|
else
|
|
|
|
initprintf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
void M32_PostScriptExec(void)
|
|
|
|
{
|
|
|
|
if (vm.miscflags&VMFLAG_MISC_UPDATEHL)
|
|
|
|
{
|
|
|
|
update_highlight();
|
|
|
|
vm.miscflags &= ~VMFLAG_MISC_UPDATEHL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vm.miscflags&VMFLAG_MISC_UPDATEHLSECT)
|
|
|
|
{
|
|
|
|
update_highlightsector();
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode())
|
2011-08-03 17:22:25 +00:00
|
|
|
ovh_whiteoutgrab(1);
|
|
|
|
vm.miscflags &= ~VMFLAG_MISC_UPDATEHLSECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-05 10:05:29 +00:00
|
|
|
void VM_OnEvent(int32_t iEventID, int32_t spriteNum)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
if (iEventID < 0 || iEventID >= MAXEVENTS)
|
|
|
|
{
|
2010-06-25 23:01:54 +00:00
|
|
|
M32_PRINTERROR("Invalid event ID");
|
2009-09-12 23:03:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aEventOffsets[iEventID] < 0 || !aEventEnabled[iEventID])
|
|
|
|
{
|
|
|
|
//Bsprintf(g_szBuf,"No event found for %d",iEventID);
|
|
|
|
//AddLog(g_szBuf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
instype *const oinsptr=insptr;
|
2009-09-12 23:03:15 +00:00
|
|
|
vmstate_t vm_backup;
|
2014-12-06 19:09:50 +00:00
|
|
|
void *const olocalvars = aGameArrays[M32_LOCAL_ARRAY_ID].vals;
|
2010-08-12 13:38:37 +00:00
|
|
|
#ifdef M32_LOCALS_VARARRAY
|
|
|
|
int32_t localvars[aEventNumLocals[iEventID]];
|
|
|
|
#else
|
|
|
|
int32_t localvars[M32_LOCALS_FIXEDNUM];
|
|
|
|
#endif
|
2010-08-11 22:37:45 +00:00
|
|
|
|
2014-02-28 20:33:47 +00:00
|
|
|
// Initialize 'state'-local variables to 0.
|
2010-08-11 22:37:45 +00:00
|
|
|
if (aEventNumLocals[iEventID] > 0)
|
2010-08-14 21:32:28 +00:00
|
|
|
Bmemset(localvars, 0, aEventNumLocals[iEventID]*sizeof(int32_t));
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
Bmemcpy(&vm_backup, &vm, sizeof(vmstate_t));
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = spriteNum; // current sprite ID
|
|
|
|
if (vm.spriteNum >= 0)
|
|
|
|
vm.pSprite = &sprite[vm.spriteNum];
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
vm.g_st = 1+iEventID;
|
|
|
|
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags = 0;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
insptr = apScript + aEventOffsets[iEventID];
|
2010-08-11 22:37:45 +00:00
|
|
|
|
|
|
|
aGameArrays[M32_LOCAL_ARRAY_ID].vals = localvars;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(0);
|
2010-08-11 22:37:45 +00:00
|
|
|
aGameArrays[M32_LOCAL_ARRAY_ID].vals = olocalvars;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2009-10-11 15:52:16 +00:00
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
2009-09-17 22:08:37 +00:00
|
|
|
{
|
2009-09-12 23:03:15 +00:00
|
|
|
aEventEnabled[iEventID] = 0;
|
2009-09-17 22:08:37 +00:00
|
|
|
message("ERROR executing %s. Event disabled.", label+(iEventID*MAXLABELLEN));
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
M32_PostScriptExec();
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
// restore old values...
|
|
|
|
Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t));
|
|
|
|
insptr = oinsptr;
|
|
|
|
|
|
|
|
//AddLog("End of Execution");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t G_GetAngleDelta(int32_t a,int32_t na)
|
|
|
|
{
|
|
|
|
a &= 2047;
|
|
|
|
na &= 2047;
|
|
|
|
|
|
|
|
if (klabs(a-na) < 1024)
|
|
|
|
{
|
|
|
|
// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a);
|
2016-06-21 00:34:41 +00:00
|
|
|
return na-a;
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (na > 1024) na -= 2048;
|
|
|
|
if (a > 1024) a -= 2048;
|
|
|
|
|
|
|
|
// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a);
|
2016-06-21 00:34:41 +00:00
|
|
|
return na-a;
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
2017-06-05 10:05:29 +00:00
|
|
|
static inline void __fastcall VM_DoConditional(int32_t condition)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
if (condition)
|
|
|
|
{
|
|
|
|
// skip 'else' pointer.. and...
|
|
|
|
insptr+=2;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
insptr++;
|
|
|
|
insptr += *insptr;
|
|
|
|
if (((*insptr)&0xFFF) == CON_ELSE)
|
|
|
|
{
|
|
|
|
// else...
|
|
|
|
// skip 'else' and...
|
|
|
|
insptr+=2;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-21 13:38:44 +00:00
|
|
|
static int X_DoSortDefault(const void *lv, const void *rv)
|
2009-09-17 22:08:37 +00:00
|
|
|
{
|
2016-01-11 05:05:38 +00:00
|
|
|
return *(int32_t const *)rv - *(int32_t const *)lv;
|
2009-09-17 22:08:37 +00:00
|
|
|
}
|
|
|
|
|
2013-09-21 13:38:44 +00:00
|
|
|
static int X_DoSort(const void *lv, const void *rv)
|
2009-09-17 22:08:37 +00:00
|
|
|
{
|
2016-01-11 05:05:38 +00:00
|
|
|
m32_sortvar1 = *(int32_t const *)lv;
|
|
|
|
m32_sortvar2 = *(int32_t const *)rv;
|
2009-09-17 22:08:37 +00:00
|
|
|
insptr = x_sortingstateptr;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(0);
|
2009-09-17 22:08:37 +00:00
|
|
|
return g_iReturnVar;
|
|
|
|
}
|
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
// in interactive execution, allow the current sprite index to be the aimed-at sprite (in 3d mode)
|
2016-08-27 01:40:35 +00:00
|
|
|
#define X_ERROR_INVALIDCI() \
|
|
|
|
if ((vm.spriteNum < 0 || vm.spriteNum >= MAXSPRITES) && \
|
|
|
|
(vm.g_st != 0 || searchstat != 3 || (vm.spriteNum = searchwall, vm.pSprite = &sprite[vm.spriteNum], 0))) \
|
|
|
|
{ \
|
|
|
|
M32_ERROR("Current sprite index invalid!"); \
|
|
|
|
continue; \
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
#define X_ERROR_INVALIDSPRI(dasprite) \
|
|
|
|
if (dasprite < 0 || dasprite >= MAXSPRITES) \
|
|
|
|
{ \
|
|
|
|
M32_ERROR("Invalid sprite index %d!", dasprite); \
|
|
|
|
continue; \
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
#define X_ERROR_INVALIDSECT(dasect) \
|
|
|
|
if (dasect < 0 || dasect >= numsectors) \
|
|
|
|
{ \
|
|
|
|
M32_ERROR("Invalid sector index %d!", dasect); \
|
|
|
|
continue; \
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
#define X_ERROR_INVALIDSP() \
|
|
|
|
if (!vm.pSprite && (vm.g_st != 0 || searchstat != 3 || (vm.pSprite = &sprite[searchwall], 0))) \
|
|
|
|
{ \
|
|
|
|
M32_ERROR("Current sprite invalid!"); \
|
|
|
|
continue; \
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
#define X_ERROR_INVALIDQUOTE(q, array) \
|
|
|
|
if (q < 0 || q >= MAXQUOTES) \
|
|
|
|
{ \
|
|
|
|
M32_ERROR("Invalid quote number %d!", q); \
|
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
else if (array[q] == NULL) \
|
|
|
|
{ \
|
|
|
|
M32_ERROR("Null quote %d!", q); \
|
|
|
|
continue; \
|
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
|
|
|
|
static char *GetMaybeInlineQuote(int32_t quotei)
|
|
|
|
{
|
|
|
|
char *quotetext;
|
|
|
|
if (quotei==-1)
|
|
|
|
{
|
|
|
|
quotetext = (char *)insptr;
|
|
|
|
while (*insptr++) /* skip the string */;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
quotei = Gv_GetVarX(quotei);
|
2016-08-27 01:40:35 +00:00
|
|
|
do { X_ERROR_INVALIDQUOTE(quotei, apStrings) } while (0);
|
2010-08-11 22:37:45 +00:00
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
return NULL;
|
2016-08-27 01:40:35 +00:00
|
|
|
quotetext = apStrings[quotei];
|
2010-08-11 22:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return quotetext;
|
|
|
|
}
|
2014-12-06 19:09:50 +00:00
|
|
|
|
|
|
|
static int CheckArray(int aidx)
|
|
|
|
{
|
|
|
|
if (!(aidx >= 0 && aidx < g_gameArrayCount))
|
|
|
|
M32_ERROR("Invalid array %d!", aidx);
|
|
|
|
|
|
|
|
return (vm.flags&VMFLAG_ERROR);
|
|
|
|
}
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
int32_t VM_Execute(int32_t once)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2017-06-05 10:05:29 +00:00
|
|
|
int32_t tw = *insptr;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
// jump directly into the loop, saving us from the checks during the first iteration
|
|
|
|
goto skip_check;
|
|
|
|
|
|
|
|
while (!once)
|
|
|
|
{
|
2009-10-11 15:52:16 +00:00
|
|
|
if (vm.flags)
|
2009-09-12 23:03:15 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
tw = *insptr;
|
|
|
|
|
|
|
|
skip_check:
|
|
|
|
// Bsprintf(g_szBuf,"Parsing: %d",*insptr);
|
|
|
|
// AddLog(g_szBuf);
|
|
|
|
|
|
|
|
g_errorLineNum = tw>>12;
|
|
|
|
g_tw = (tw &= 0xFFF);
|
|
|
|
|
|
|
|
switch (tw)
|
|
|
|
{
|
|
|
|
// *** basic commands
|
|
|
|
case CON_NULLOP:
|
|
|
|
insptr++;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_STATE:
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
instype *const tempscrptr = insptr+2;
|
|
|
|
const int32_t stateidx = *(insptr+1), o_g_st = vm.g_st, oret=vm.flags&VMFLAG_RETURN;
|
|
|
|
void *const olocalvars = aGameArrays[M32_LOCAL_ARRAY_ID].vals;
|
2010-08-12 13:38:37 +00:00
|
|
|
#ifdef M32_LOCALS_VARARRAY
|
|
|
|
int32_t localvars[statesinfo[stateidx].numlocals];
|
|
|
|
#else
|
|
|
|
int32_t localvars[M32_LOCALS_FIXEDNUM];
|
|
|
|
#endif
|
2010-08-11 22:37:45 +00:00
|
|
|
|
|
|
|
// needed since any read access before initialization would cause undefined behaviour
|
|
|
|
if (statesinfo[stateidx].numlocals > 0)
|
2010-08-14 21:32:28 +00:00
|
|
|
Bmemset(localvars, 0, statesinfo[stateidx].numlocals*sizeof(int32_t));
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
insptr = apScript + statesinfo[stateidx].ofs;
|
2009-09-12 23:03:15 +00:00
|
|
|
vm.g_st = 1+MAXEVENTS+stateidx;
|
2010-08-11 22:37:45 +00:00
|
|
|
aGameArrays[M32_LOCAL_ARRAY_ID].vals = localvars;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(0);
|
2010-08-11 22:37:45 +00:00
|
|
|
aGameArrays[M32_LOCAL_ARRAY_ID].vals = olocalvars;
|
2009-09-12 23:03:15 +00:00
|
|
|
vm.g_st = o_g_st;
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags &= ~VMFLAG_RETURN;
|
|
|
|
vm.flags |= oret;
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr = tempscrptr;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_RETURN:
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags |= VMFLAG_RETURN;
|
|
|
|
return 1;
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_BREAK:
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags |= VMFLAG_BREAK;
|
2015-01-06 19:56:41 +00:00
|
|
|
// XXX: may not be cleared subsequently?
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_ENDS:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case CON_ELSE:
|
|
|
|
insptr++;
|
|
|
|
insptr += *insptr;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ENDSWITCH:
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_ENDEVENT:
|
|
|
|
insptr++;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case CON_SWITCH:
|
|
|
|
insptr++; // p-code
|
|
|
|
{
|
|
|
|
// command format:
|
|
|
|
// variable ID to check
|
|
|
|
// script offset to 'end'
|
|
|
|
// count of case statements
|
|
|
|
// script offset to default case (null if none)
|
|
|
|
// For each case: value, ptr to code
|
|
|
|
//AddLog("Processing Switch...");
|
|
|
|
int32_t lValue=Gv_GetVarX(*insptr++), lEnd=*insptr++, lCases=*insptr++;
|
|
|
|
instype *lpDefault=insptr++, *lpCases=insptr, *lCodeInsPtr;
|
|
|
|
int32_t bMatched=0, lCheckCase;
|
|
|
|
int32_t left,right;
|
|
|
|
|
|
|
|
insptr += lCases*2;
|
|
|
|
lCodeInsPtr = insptr;
|
2010-01-23 22:12:02 +00:00
|
|
|
//Bsprintf(g_szBuf,"lEnd= %d *lpDefault=%d",lEnd,*lpDefault); AddLog(g_szBuf);
|
|
|
|
//Bsprintf(g_szBuf,"Checking %d cases for %d",lCases, lValue); AddLog(g_szBuf);
|
2009-09-12 23:03:15 +00:00
|
|
|
left = 0;
|
|
|
|
right = lCases-1;
|
|
|
|
while (!bMatched)
|
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
//Bsprintf(g_szBuf,"Checking #%d Value= %d",lCheckCase, lpCases[lCheckCase*2]); AddLog(g_szBuf);
|
2009-09-12 23:03:15 +00:00
|
|
|
lCheckCase=(left+right)/2;
|
2010-01-23 22:12:02 +00:00
|
|
|
// initprintf("(%2d..%2d..%2d) [%2d..%2d..%2d]==%2d\n",left,lCheckCase,right,lpCases[left*2],lpCases[lCheckCase*2],lpCases[right*2],lValue);
|
2009-09-12 23:03:15 +00:00
|
|
|
if (lpCases[lCheckCase*2] > lValue)
|
|
|
|
right = lCheckCase-1;
|
|
|
|
else if (lpCases[lCheckCase*2] < lValue)
|
|
|
|
left = lCheckCase+1;
|
|
|
|
else if (lpCases[lCheckCase*2] == lValue)
|
|
|
|
{
|
|
|
|
//AddLog("Found Case Match");
|
2010-01-23 22:12:02 +00:00
|
|
|
//Bsprintf(g_szBuf,"insptr=%d. lCheckCase=%d, offset=%d, &script[0]=%d", (int32_t)insptr,(int32_t)lCheckCase,lpCases[lCheckCase*2+1],(int32_t)&script[0]); AddLog(g_szBuf);
|
2009-09-12 23:03:15 +00:00
|
|
|
// fake a 2-d Array
|
|
|
|
insptr = lCodeInsPtr + lpCases[lCheckCase*2+1];
|
2010-01-23 22:12:02 +00:00
|
|
|
//Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(0);
|
2009-09-12 23:03:15 +00:00
|
|
|
//AddLog("Done Executing Case");
|
|
|
|
bMatched=1;
|
|
|
|
}
|
2011-02-21 23:08:21 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
if (right-left < 0)
|
|
|
|
break;
|
|
|
|
}
|
2011-02-21 23:08:21 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
if (!bMatched)
|
|
|
|
{
|
|
|
|
if (*lpDefault >= 0)
|
|
|
|
{
|
|
|
|
//AddLog("No Matching Case: Using Default");
|
|
|
|
insptr = lCodeInsPtr + *lpDefault;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(0);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// //AddLog("No Matching Case: No Default to use");
|
|
|
|
// }
|
|
|
|
}
|
2009-09-17 22:08:37 +00:00
|
|
|
insptr = (instype *)(lCodeInsPtr + lEnd);
|
2011-08-03 17:22:25 +00:00
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
2010-01-23 22:12:02 +00:00
|
|
|
//Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf);
|
2009-09-12 23:03:15 +00:00
|
|
|
//AddLog("Done Processing Switch");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_GETCURRADDRESS:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(j, insptr-apScript);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_JUMP:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
2016-08-27 01:40:35 +00:00
|
|
|
if (j<0 || j>=(g_scriptPtr-apScript))
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("script index out of bounds (%d)", j);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-27 01:40:35 +00:00
|
|
|
insptr = (instype *)(j+apScript);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_RIGHTBRACE:
|
|
|
|
insptr++;
|
|
|
|
return 1;
|
|
|
|
case CON_LEFTBRACE:
|
|
|
|
insptr++;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(0);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// *** arrays
|
|
|
|
case CON_SETARRAY:
|
|
|
|
insptr++;
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t j=*insptr++;
|
|
|
|
const int32_t index = Gv_GetVarX(*insptr++);
|
|
|
|
const int32_t value = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
CheckArray(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
if (aGameArrays[j].dwFlags & GAMEARRAY_READONLY)
|
2014-12-06 19:09:50 +00:00
|
|
|
M32_ERROR("Tried to set on read-only array `%s'", aGameArrays[j].szLabel);
|
|
|
|
|
|
|
|
if (!(index >= 0 && index < aGameArrays[j].size))
|
|
|
|
M32_ERROR("Array index %d out of bounds", index);
|
|
|
|
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// NOTE: Other array types not implemented, since they're read-only.
|
|
|
|
((int32_t *)aGameArrays[j].vals)[index] = value;
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_GETARRAYSIZE:
|
|
|
|
insptr++;
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t j=*insptr++;
|
|
|
|
|
|
|
|
if (CheckArray(j))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Gv_SetVarX(*insptr++, Gv_GetArraySize(j));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_RESIZEARRAY:
|
|
|
|
insptr++;
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t j=*insptr++;
|
|
|
|
const int32_t asize = Gv_GetVarX(*insptr++);
|
2009-09-17 22:08:37 +00:00
|
|
|
|
2014-12-06 19:09:50 +00:00
|
|
|
CheckArray(j);
|
|
|
|
|
|
|
|
if (aGameArrays[j].dwFlags & GAMEARRAY_READONLY)
|
|
|
|
M32_ERROR("Tried to resize read-only array `%s'", aGameArrays[j].szLabel);
|
|
|
|
|
|
|
|
if (!(asize >= 1 && asize <= 65536))
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid array size %d (must be between 1 and 65536)", asize);
|
2014-12-06 19:09:50 +00:00
|
|
|
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
2009-10-11 15:52:16 +00:00
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
// OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize);
|
2014-05-30 00:02:19 +00:00
|
|
|
aGameArrays[j].vals = Xrealloc(aGameArrays[j].vals, sizeof(int32_t) * asize);
|
2009-09-12 23:03:15 +00:00
|
|
|
aGameArrays[j].size = asize;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_COPY:
|
|
|
|
insptr++;
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t si=*insptr++;
|
|
|
|
int32_t sidx = Gv_GetVarX(*insptr++);
|
|
|
|
const int32_t di=*insptr++;
|
2009-09-12 23:03:15 +00:00
|
|
|
int32_t didx = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t numelts = Gv_GetVarX(*insptr++);
|
|
|
|
|
2014-12-06 19:09:50 +00:00
|
|
|
CheckArray(si);
|
|
|
|
CheckArray(di);
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
if (aGameArrays[di].dwFlags & GAMEARRAY_READONLY)
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Array %d is read-only!", di);
|
2014-12-06 19:09:50 +00:00
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t ssiz = Gv_GetArraySize(si);
|
|
|
|
const int32_t dsiz = Gv_GetArraySize(di);
|
|
|
|
|
2014-12-06 19:09:53 +00:00
|
|
|
if ((uint32_t)sidx >= (uint32_t)ssiz)
|
|
|
|
M32_ERROR("Invalid source index %d", sidx);
|
|
|
|
if ((uint32_t)didx >= (uint32_t)dsiz)
|
|
|
|
M32_ERROR("Invalid destination index %d", didx);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
2014-12-06 19:09:50 +00:00
|
|
|
continue;
|
2014-12-06 19:09:53 +00:00
|
|
|
|
2014-12-06 19:09:50 +00:00
|
|
|
if (numelts > ssiz-sidx)
|
|
|
|
numelts = ssiz-sidx;
|
|
|
|
if (numelts > dsiz-didx)
|
|
|
|
numelts = dsiz-didx;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2014-12-06 19:09:53 +00:00
|
|
|
const gamearray_t *const sar = &aGameArrays[si];
|
|
|
|
gamearray_t *const dar = &aGameArrays[di];
|
|
|
|
|
|
|
|
switch (sar->dwFlags & GAMEARRAY_TYPE_MASK)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2017-07-08 05:18:43 +00:00
|
|
|
case GAMEARRAY_INT32:
|
2014-12-06 19:09:53 +00:00
|
|
|
if (sar->dwFlags & GAMEARRAY_STRIDE2)
|
|
|
|
{
|
|
|
|
for (; numelts>0; numelts--, sidx += 2)
|
|
|
|
((int32_t *)dar->vals)[didx++] = ((int32_t *)sar->vals)[sidx];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Bmemcpy((int32_t *)dar->vals + didx, (int32_t *)sar->vals + sidx,
|
|
|
|
numelts * sizeof(int32_t));
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
2017-07-08 05:18:43 +00:00
|
|
|
case GAMEARRAY_INT16:
|
2009-09-12 23:03:15 +00:00
|
|
|
for (; numelts>0; numelts--)
|
2014-12-06 19:09:53 +00:00
|
|
|
((int32_t *)dar->vals)[didx++] = ((int16_t *)sar->vals)[sidx++];
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
2017-07-08 05:18:43 +00:00
|
|
|
case GAMEARRAY_UINT8:
|
2009-09-12 23:03:15 +00:00
|
|
|
for (; numelts>0; numelts--)
|
2014-12-06 19:09:53 +00:00
|
|
|
((int32_t *)dar->vals)[didx++] = ((uint8_t *)sar->vals)[sidx++];
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// *** var & varvar ops
|
|
|
|
case CON_RANDVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, mulscale16(krand(), *(insptr+1)+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DISPLAYRANDVAR:
|
|
|
|
insptr++;
|
2011-11-05 12:13:50 +00:00
|
|
|
Gv_SetVarX(*insptr, mulscale15(system_15bit_rand(), *(insptr+1)+1));
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SETVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SETVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_MULVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, Gv_GetVarX(*insptr) * *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DIVVAR:
|
|
|
|
insptr++;
|
|
|
|
if (*(insptr+1) == 0)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Divide by zero.");
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Gv_SetVarX(*insptr, Gv_GetVarX(*insptr) / *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_MODVAR:
|
|
|
|
insptr++;
|
|
|
|
if (*(insptr+1) == 0)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Mod by zero.");
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Gv_SetVarX(*insptr,Gv_GetVarX(*insptr)%*(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ANDVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr,Gv_GetVarX(*insptr) & *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ORVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr,Gv_GetVarX(*insptr) | *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_XORVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr,Gv_GetVarX(*insptr) ^ *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_RANDVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
2011-11-05 12:13:50 +00:00
|
|
|
Gv_SetVarX(j,mulscale16(krand(), Gv_GetVarX(*insptr++)+1));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DISPLAYRANDVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
2011-11-05 12:13:50 +00:00
|
|
|
Gv_SetVarX(j,mulscale15(system_15bit_rand(), Gv_GetVarX(*insptr++)+1));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_MULVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j)*Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DIVVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
int32_t l2=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
if (l2==0)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Divide by zero.");
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j)/l2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_MODVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
int32_t l2=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
if (l2==0)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Mod by zero.");
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) % l2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_ANDVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) & Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_XORVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) ^ Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ORVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) | Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SUBVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, Gv_GetVarX(*insptr) - *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SUBVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) - Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ADDVAR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, Gv_GetVarX(*insptr) + *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ADDVARVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) + Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SHIFTVARL:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, Gv_GetVarX(*insptr) << *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
case CON_SHIFTVARVARL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) << Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_SHIFTVARR:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, Gv_GetVarX(*insptr) >> *(insptr+1));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
case CON_SHIFTVARVARR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
|
|
|
Gv_SetVarX(j, Gv_GetVarX(j) >> Gv_GetVarX(*insptr++));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_SIN:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, sintable[Gv_GetVarX(*(insptr+1))&2047]);
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_COS:
|
|
|
|
insptr++;
|
|
|
|
Gv_SetVarX(*insptr, sintable[(Gv_GetVarX(*(insptr+1))+512)&2047]);
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DISPLAYRAND:
|
|
|
|
insptr++;
|
2011-11-05 12:13:50 +00:00
|
|
|
Gv_SetVarX(*insptr++, system_15bit_rand());
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// *** other math
|
2010-05-18 05:14:17 +00:00
|
|
|
case CON_FTOI:
|
|
|
|
insptr++;
|
|
|
|
{
|
2018-11-18 18:13:33 +00:00
|
|
|
union { int32_t ival; float fval; };
|
|
|
|
|
|
|
|
ival=Gv_GetVarX(*insptr);
|
|
|
|
int32_t const scale=*(insptr+1);
|
2010-08-16 13:56:49 +00:00
|
|
|
// rounding must absolutely be!
|
|
|
|
//OSD_Printf("ftoi: bits:%8x, scale=%d, fval=%f, (int32_t)(fval*scale)=%d\n", bits, scale, fval, (int32_t)(fval*scale));
|
2014-10-25 03:29:21 +00:00
|
|
|
Gv_SetVarX(*insptr, (int32_t)Blrintf(fval * scale));
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_ITOF:
|
|
|
|
insptr++;
|
|
|
|
{
|
2018-11-18 18:13:33 +00:00
|
|
|
union { int32_t ival; float fval; };
|
|
|
|
|
|
|
|
ival=Gv_GetVarX(*insptr);
|
|
|
|
int32_t const scale=*(insptr+1);
|
|
|
|
fval = (float)ival/(float)scale;
|
|
|
|
Gv_SetVarX(*insptr, ival);
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
2009-10-03 13:20:31 +00:00
|
|
|
case CON_CLAMP:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t var=*insptr++, min=Gv_GetVarX(*insptr++), max=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t val=Gv_GetVarX(var);
|
|
|
|
|
|
|
|
if (val<min) Gv_SetVarX(var, min);
|
|
|
|
else if (val>max) Gv_SetVarX(var, max);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_INV:
|
|
|
|
Gv_SetVarX(*(insptr+1), -Gv_GetVarX(*(insptr+1)));
|
|
|
|
insptr += 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SQRT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
// syntax sqrt <invar> <outvar>
|
|
|
|
int32_t lInVarID=*insptr++, lOutVarID=*insptr++;
|
|
|
|
|
2012-07-01 22:11:14 +00:00
|
|
|
Gv_SetVarX(lOutVarID, ksqrt((uint32_t)Gv_GetVarX(lInVarID)));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_LDIST:
|
|
|
|
case CON_DIST:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t distvar = *insptr++, xvar = Gv_GetVarX(*insptr++), yvar = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
if (xvar < 0 || xvar >= MAXSPRITES || sprite[xvar].statnum==MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("invalid sprite %d", xvar);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
if (yvar < 0 || yvar >= MAXSPRITES || sprite[yvar].statnum==MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("invalid sprite %d", yvar);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2009-10-11 15:52:16 +00:00
|
|
|
if (vm.flags&VMFLAG_ERROR) continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
if (tw==CON_DIST)
|
|
|
|
Gv_SetVarX(distvar, dist(&sprite[xvar],&sprite[yvar]));
|
|
|
|
else
|
|
|
|
Gv_SetVarX(distvar, ldist(&sprite[xvar],&sprite[yvar]));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_GETANGLE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t angvar = *insptr++;
|
|
|
|
int32_t xvar = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t yvar = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
Gv_SetVarX(angvar, getangle(xvar,yvar));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_GETINCANGLE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t angvar = *insptr++;
|
|
|
|
int32_t xvar = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t yvar = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
Gv_SetVarX(angvar, G_GetAngleDelta(xvar,yvar));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
case CON_A2XY:
|
|
|
|
case CON_AH2XYZ:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t ang=Gv_GetVarX(*insptr++), horiz=(tw==CON_A2XY)?100:Gv_GetVarX(*insptr++);
|
|
|
|
int32_t xvar=*insptr++, yvar=*insptr++;
|
|
|
|
|
|
|
|
int32_t x = sintable[(ang+512)&2047];
|
|
|
|
int32_t y = sintable[ang&2047];
|
|
|
|
|
|
|
|
if (tw==CON_AH2XYZ)
|
|
|
|
{
|
|
|
|
int32_t zvar=*insptr++, z=0;
|
|
|
|
|
|
|
|
horiz -= 100;
|
|
|
|
if (horiz)
|
|
|
|
{
|
|
|
|
int32_t veclen = ksqrt(200*200 + horiz*horiz);
|
|
|
|
int32_t dacos = divscale14(200, veclen);
|
|
|
|
|
|
|
|
x = mulscale14(x, dacos);
|
|
|
|
y = mulscale14(y, dacos);
|
2010-08-18 23:21:19 +00:00
|
|
|
z = divscale14(-horiz, veclen);
|
2010-08-17 20:00:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Gv_SetVarX(zvar, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
Gv_SetVarX(xvar, x);
|
|
|
|
Gv_SetVarX(yvar, y);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_MULSCALE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t var1 = *insptr++, var2 = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t var3 = Gv_GetVarX(*insptr++), var4 = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
Gv_SetVarX(var1, mulscale(var2, var3, var4));
|
|
|
|
continue;
|
|
|
|
}
|
2010-08-03 22:21:13 +00:00
|
|
|
case CON_DIVSCALE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t var1 = *insptr++, var2 = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t var3 = Gv_GetVarX(*insptr++), var4 = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
Gv_SetVarX(var1, divscale(var2, var3, var4));
|
|
|
|
continue;
|
|
|
|
}
|
2016-10-20 06:26:10 +00:00
|
|
|
case CON_SCALEVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t var1 = *insptr++, var2 = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t var3 = Gv_GetVarX(*insptr++), var4 = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
Gv_SetVarX(var1, scale(var2, var3, var4));
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
// *** if & while
|
|
|
|
case CON_IFVARVARAND:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j &= Gv_GetVarX(*insptr++);
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVAROR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j |= Gv_GetVarX(*insptr++);
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARXOR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j ^= Gv_GetVarX(*insptr++);
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVAREITHER:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t l = Gv_GetVarX(*insptr++);
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j || l);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARBOTH:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t l = Gv_GetVarX(*insptr++);
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j && l);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARN:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = (j != Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = (j == Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARG:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = (j > Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARGE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = (j >= Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = (j < Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARLE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = (j <= Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2018-01-31 05:23:48 +00:00
|
|
|
case CON_IFVARVARA:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = ((uint32_t)j > (uint32_t)Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
|
|
|
VM_DoConditional(j);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARAE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = ((uint32_t)j >= (uint32_t)Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
|
|
|
VM_DoConditional(j);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARB:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = ((uint32_t)j < (uint32_t)Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
|
|
|
VM_DoConditional(j);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARVARBE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
j = ((uint32_t)j <= (uint32_t)Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
|
|
|
VM_DoConditional(j);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_IFVARE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j == *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARN:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j != *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_WHILEVARN:
|
|
|
|
{
|
|
|
|
instype *savedinsptr=insptr+2;
|
|
|
|
int32_t j;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
insptr=savedinsptr;
|
|
|
|
j = (Gv_GetVarX(*(insptr-1)) != *insptr);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2009-10-11 15:52:16 +00:00
|
|
|
while (j && !vm.flags);
|
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_WHILEVARL:
|
|
|
|
{
|
|
|
|
instype *savedinsptr=insptr+2;
|
|
|
|
int32_t j;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
insptr=savedinsptr;
|
|
|
|
j = (Gv_GetVarX(*(insptr-1)) < *insptr);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2009-10-11 15:52:16 +00:00
|
|
|
while (j && !vm.flags);
|
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_WHILEVARVARN:
|
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
instype *savedinsptr=insptr+2;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
insptr=savedinsptr;
|
|
|
|
j = Gv_GetVarX(*(insptr-1));
|
|
|
|
j = (j != Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2009-10-11 15:52:16 +00:00
|
|
|
while (j && !vm.flags);
|
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_WHILEVARVARL:
|
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
instype *savedinsptr=insptr+2;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
insptr=savedinsptr;
|
|
|
|
j = Gv_GetVarX(*(insptr-1));
|
|
|
|
j = (j < Gv_GetVarX(*insptr++));
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2009-10-11 15:52:16 +00:00
|
|
|
while (j && !vm.flags);
|
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
case CON_COLLECTSECTORS:
|
|
|
|
insptr++;
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t aridx=*insptr++, startsectnum=Gv_GetVarX(*insptr++);
|
|
|
|
const int32_t numsectsVar=*insptr++, state=*insptr++;
|
|
|
|
|
|
|
|
if (CheckArray(aridx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gamearray_t *const gar = &aGameArrays[aridx];
|
|
|
|
Bassert((gar->dwFlags & (GAMEARRAY_READONLY|GAMEARRAY_VARSIZE)) == 0);
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t o_g_st=vm.g_st, arsize = gar->size;
|
|
|
|
instype *const end=insptr;
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
int32_t sectcnt, numsects=0;
|
2014-12-06 19:09:50 +00:00
|
|
|
|
|
|
|
// XXX: relies on -fno-strict-aliasing
|
|
|
|
int16_t *const sectlist = (int16_t *)gar->vals; // actually an int32_t array
|
|
|
|
int32_t *const sectlist32 = (int32_t *)sectlist;
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
int32_t j, startwall, endwall, ns;
|
|
|
|
static uint8_t sectbitmap[MAXSECTORS>>3];
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(startsectnum);
|
|
|
|
if (arsize < numsectors)
|
|
|
|
{
|
|
|
|
M32_ERROR("Array size must be at least numsectors (=%d) for collecting!",
|
|
|
|
numsectors);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// collect!
|
|
|
|
bfirst_search_init(sectlist, sectbitmap, &numsects, MAXSECTORS, startsectnum);
|
|
|
|
|
|
|
|
for (sectcnt=0; sectcnt<numsects; sectcnt++)
|
|
|
|
for (WALLS_OF_SECTOR(sectlist[sectcnt], j))
|
|
|
|
if ((ns=wall[j].nextsector) >= 0 && wall[j].nextsector<numsectors)
|
|
|
|
{
|
|
|
|
if (sectbitmap[ns>>3]&(1<<(ns&7)))
|
|
|
|
continue;
|
|
|
|
vm.g_st = 1+MAXEVENTS+state;
|
2016-08-27 01:40:35 +00:00
|
|
|
insptr = apScript + statesinfo[state].ofs;
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
g_iReturnVar = ns;
|
|
|
|
VM_Execute(0);
|
|
|
|
if (g_iReturnVar)
|
|
|
|
bfirst_search_try(sectlist, sectbitmap, &numsects, wall[j].nextsector);
|
|
|
|
}
|
|
|
|
|
|
|
|
// short->int sector list
|
|
|
|
for (j=numsects-1; j>=0; j--)
|
|
|
|
sectlist32[j] = sectlist[j];
|
|
|
|
|
|
|
|
Gv_SetVarX(numsectsVar, numsects);
|
|
|
|
g_iReturnVar = 0;
|
|
|
|
|
|
|
|
// restore some VM state
|
|
|
|
vm.g_st = o_g_st;
|
|
|
|
insptr = end;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-17 22:08:37 +00:00
|
|
|
case CON_SORT:
|
|
|
|
insptr++;
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
const int32_t aridx=*insptr++, count=Gv_GetVarX(*insptr++), state=*insptr++;
|
|
|
|
const int32_t o_g_st = vm.g_st;
|
|
|
|
instype *const end = insptr;
|
|
|
|
|
|
|
|
if (CheckArray(aridx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (count <= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gamearray_t *const gar = &aGameArrays[aridx];
|
|
|
|
Bassert((gar->dwFlags & (GAMEARRAY_READONLY|GAMEARRAY_VARSIZE)) == 0);
|
2009-09-17 22:08:37 +00:00
|
|
|
|
2014-12-06 19:09:50 +00:00
|
|
|
if (count > gar->size)
|
2009-09-17 22:08:37 +00:00
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
M32_ERROR("Count of elements to sort (%d) exceeds array size (%d)!",
|
|
|
|
count, gar->size);
|
2009-09-17 22:08:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state < 0)
|
|
|
|
{
|
2014-12-06 19:09:50 +00:00
|
|
|
qsort(gar->vals, count, sizeof(int32_t), X_DoSortDefault);
|
2009-09-17 22:08:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
x_sortingstateptr = apScript + statesinfo[state].ofs;
|
2009-09-17 22:08:37 +00:00
|
|
|
vm.g_st = 1+MAXEVENTS+state;
|
2014-12-06 19:09:50 +00:00
|
|
|
qsort(gar->vals, count, sizeof(int32_t), X_DoSort);
|
2009-09-17 22:08:37 +00:00
|
|
|
vm.g_st = o_g_st;
|
|
|
|
insptr = end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_FOR: // special-purpose iteration
|
|
|
|
insptr++;
|
|
|
|
{
|
2015-02-19 17:41:56 +00:00
|
|
|
const int32_t var = *insptr++, how = *insptr++;
|
|
|
|
const int32_t parm2 = how<=ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++);
|
|
|
|
instype *const end = insptr + *insptr, *const beg = ++insptr;
|
2016-08-27 01:40:35 +00:00
|
|
|
const int32_t vm_i_bak = vm.spriteNum;
|
|
|
|
uspritetype *const vm_sp_bak = vm.pUSprite;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2015-02-19 17:41:56 +00:00
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
switch (how)
|
|
|
|
{
|
|
|
|
case ITER_ALLSPRITES:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=0; jj<MAXSPRITES && !vm.flags; jj++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
if (sprite[jj].statnum == MAXSTATUS)
|
|
|
|
continue;
|
|
|
|
Gv_SetVarX(var, jj);
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = jj;
|
|
|
|
vm.pSprite = &sprite[jj];
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITER_ALLSECTORS:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=0; jj<numsectors && !vm.flags; jj++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITER_ALLWALLS:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=0; jj<numwalls && !vm.flags; jj++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
2011-05-07 18:23:34 +00:00
|
|
|
case ITER_ACTIVELIGHTS:
|
|
|
|
#ifdef POLYMER
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=0; jj<PR_MAXLIGHTS; jj++)
|
2011-05-07 18:23:34 +00:00
|
|
|
{
|
|
|
|
if (!prlights[jj].flags.active)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
|
|
|
VM_Execute(1);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
M32_ERROR("Polymer not compiled in, iteration over lights forbidden.");
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case ITER_SELSPRITES:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t ii=0; ii<highlightcnt && !vm.flags; ii++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2015-02-19 17:41:56 +00:00
|
|
|
int jj = highlight[ii];
|
2009-09-12 23:03:15 +00:00
|
|
|
if (jj&0xc000)
|
|
|
|
{
|
|
|
|
jj &= (MAXSPRITES-1);
|
|
|
|
Gv_SetVarX(var, jj);
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = jj;
|
|
|
|
vm.pSprite = &sprite[jj];
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITER_SELSECTORS:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t ii=0; ii<highlightsectorcnt && !vm.flags; ii++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2015-02-19 17:41:56 +00:00
|
|
|
int jj=highlightsector[ii];
|
2009-09-12 23:03:15 +00:00
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITER_SELWALLS:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t ii=0; ii<highlightcnt && !vm.flags; ii++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2015-02-19 17:41:56 +00:00
|
|
|
int jj=highlight[ii];
|
2009-09-12 23:03:15 +00:00
|
|
|
if (jj&0xc000)
|
|
|
|
continue;
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITER_DRAWNSPRITES:
|
2015-02-19 17:41:57 +00:00
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
uspritetype lastSpriteBackup;
|
|
|
|
uspritetype *const lastSpritePtr = (uspritetype *)&sprite[MAXSPRITES-1];
|
2015-02-19 17:41:57 +00:00
|
|
|
|
|
|
|
// Back up sprite MAXSPRITES-1.
|
2016-06-21 00:33:58 +00:00
|
|
|
Bmemcpy(&lastSpriteBackup, lastSpritePtr, sizeof(uspritetype));
|
2015-02-19 17:41:57 +00:00
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t ii=0; ii<spritesortcnt && !vm.flags; ii++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pUSprite = lastSpritePtr;
|
2016-06-21 00:33:58 +00:00
|
|
|
Bmemcpy(lastSpritePtr, &tsprite[ii], sizeof(uspritetype));
|
2015-02-19 17:41:57 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
Gv_SetVarX(var, ii);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2015-02-19 17:41:57 +00:00
|
|
|
|
|
|
|
// Copy over potentially altered tsprite.
|
2016-06-21 00:33:58 +00:00
|
|
|
Bmemcpy(&tsprite[ii], lastSpritePtr, sizeof(uspritetype));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2015-02-19 17:41:57 +00:00
|
|
|
|
|
|
|
// Restore sprite MAXSPRITES-1.
|
2016-06-21 00:33:58 +00:00
|
|
|
Bmemcpy(lastSpritePtr, &lastSpriteBackup, sizeof(uspritetype));
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
2015-02-19 17:41:57 +00:00
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
case ITER_SPRITESOFSECTOR:
|
|
|
|
if (parm2 < 0 || parm2 >= MAXSECTORS)
|
|
|
|
goto badindex;
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=headspritesect[parm2]; jj>=0 && !vm.flags; jj=nextspritesect[jj])
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
Gv_SetVarX(var, jj);
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = jj;
|
|
|
|
vm.pSprite = &sprite[jj];
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITER_WALLSOFSECTOR:
|
|
|
|
if (parm2 < 0 || parm2 >= MAXSECTORS)
|
|
|
|
goto badindex;
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=sector[parm2].wallptr, endwall=jj+sector[parm2].wallnum-1;
|
2010-01-23 22:12:02 +00:00
|
|
|
jj<=endwall && !vm.flags; jj++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-09-18 21:44:46 +00:00
|
|
|
case ITER_LOOPOFWALL:
|
|
|
|
if (parm2 < 0 || parm2 >= numwalls)
|
|
|
|
goto badindex;
|
|
|
|
{
|
2015-02-19 17:41:56 +00:00
|
|
|
int jj = parm2;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
|
|
|
VM_Execute(1);
|
|
|
|
jj = wall[jj].point2;
|
|
|
|
}
|
|
|
|
while (jj != parm2 && !vm.flags);
|
2010-01-23 22:12:02 +00:00
|
|
|
}
|
2009-09-18 21:44:46 +00:00
|
|
|
break;
|
2009-09-12 23:03:15 +00:00
|
|
|
case ITER_RANGE:
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t jj=0; jj<parm2 && !vm.flags; jj++)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
Gv_SetVarX(var, jj);
|
|
|
|
insptr = beg;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_Execute(1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Unknown iteration type %d!", how);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
badindex:
|
2017-06-27 02:24:14 +00:00
|
|
|
OSD_Printf("%sLine %d, %s %s: index %d out of range!\n", osd->draw.highlight,
|
|
|
|
g_errorLineNum,keyw[g_tw], iter_tokens[how].token, parm2);
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags |= VMFLAG_ERROR;
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = vm_i_bak;
|
|
|
|
vm.pUSprite = vm_sp_bak;
|
|
|
|
vm.flags &= ~VMFLAG_BREAK;
|
|
|
|
insptr = end;
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARAND:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j & *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVAROR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j | *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARXOR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j ^ *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVAREITHER:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j || *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARBOTH:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j && *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARG:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j > *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARGE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j >= *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j < *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARLE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j <= *insptr);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2018-01-31 05:23:48 +00:00
|
|
|
case CON_IFVARA:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
VM_DoConditional((uint32_t)j > (uint32_t)*insptr);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARAE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
VM_DoConditional((uint32_t)j >= (uint32_t)*insptr);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARB:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
VM_DoConditional((uint32_t)j < (uint32_t)*insptr);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFVARBE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
VM_DoConditional((uint32_t)j <= (uint32_t)*insptr);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_IFRND:
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(rnd(Gv_GetVarX(*(++insptr))));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
2009-09-17 22:08:37 +00:00
|
|
|
case CON_IFHITKEY:
|
|
|
|
case CON_IFHOLDKEY:
|
2009-10-03 13:20:31 +00:00
|
|
|
case CON_RESETKEY:
|
2011-11-25 09:51:06 +00:00
|
|
|
case CON_SETKEY:
|
2009-09-16 22:24:24 +00:00
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t key=Gv_GetVarX(*insptr);
|
2014-03-22 09:25:15 +00:00
|
|
|
if (key<0 || key >= (int32_t)ARRAY_SIZE(keystatus))
|
2009-09-16 22:24:24 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid key %d!", key);
|
2009-09-16 22:24:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-11-25 09:51:06 +00:00
|
|
|
if (tw == CON_IFHITKEY || tw == CON_IFHOLDKEY)
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(keystatus[key]);
|
2009-10-03 13:20:31 +00:00
|
|
|
else
|
|
|
|
insptr++;
|
|
|
|
|
|
|
|
if (tw != CON_IFHOLDKEY)
|
2009-09-17 22:08:37 +00:00
|
|
|
{
|
|
|
|
if (!(key==0 || key==KEYSC_ESC || key==KEYSC_TILDE || key==KEYSC_gENTER ||
|
2010-01-23 22:12:02 +00:00
|
|
|
key==KEYSC_LALT || key==KEYSC_RALT || key==KEYSC_LCTRL || key==KEYSC_RCTRL ||
|
|
|
|
key==KEYSC_LSHIFT || key==KEYSC_RSHIFT))
|
2011-11-25 09:51:06 +00:00
|
|
|
keystatus[key] = (tw==CON_SETKEY);
|
2009-09-17 22:08:37 +00:00
|
|
|
}
|
2009-09-16 22:24:24 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFEITHERALT:
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(keystatus[KEYSC_LALT]||keystatus[KEYSC_RALT]);
|
2009-09-16 22:24:24 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFEITHERCTRL:
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(keystatus[KEYSC_LCTRL]||keystatus[KEYSC_RCTRL]);
|
2009-09-16 22:24:24 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFEITHERSHIFT:
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(keystatus[KEYSC_LSHIFT]||keystatus[KEYSC_RSHIFT]);
|
2009-09-16 22:24:24 +00:00
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
// vvv CURSPR
|
|
|
|
case CON_IFSPRITEPAL:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(vm.pSprite->pal == Gv_GetVarX(*insptr));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
case CON_IFHIGHLIGHTED:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t id=*insptr++, index=Gv_GetVarX(*insptr);
|
|
|
|
|
|
|
|
if (index<0 || (id==M32_SPRITE_VAR_ID && index>=MAXSPRITES) || (id==M32_WALL_VAR_ID && index>=numwalls))
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("%s index %d out of range!", id==M32_SPRITE_VAR_ID?"Sprite":"Wall", index);
|
2010-09-30 23:05:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id==M32_SPRITE_VAR_ID)
|
|
|
|
VM_DoConditional(show2dsprite[index>>3]&(1<<(index&7)));
|
|
|
|
else
|
|
|
|
VM_DoConditional(show2dwall[index>>3]&(1<<(index&7)));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_IFANGDIFFL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
j = klabs(G_GetAngleDelta(ang, vm.pSprite->ang));
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j <= Gv_GetVarX(*insptr));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFAWAYFROMWALL:
|
|
|
|
{
|
|
|
|
int16_t s1;
|
|
|
|
int32_t j = 0;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
s1 = vm.pSprite->sectnum;
|
|
|
|
updatesector(vm.pSprite->x+108,vm.pSprite->y+108,&s1);
|
|
|
|
if (s1 == vm.pSprite->sectnum)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
updatesector(vm.pSprite->x-108,vm.pSprite->y-108,&s1);
|
|
|
|
if (s1 == vm.pSprite->sectnum)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
updatesector(vm.pSprite->x+108,vm.pSprite->y-108,&s1);
|
|
|
|
if (s1 == vm.pSprite->sectnum)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
updatesector(vm.pSprite->x-108,vm.pSprite->y+108,&s1);
|
|
|
|
if (s1 == vm.pSprite->sectnum)
|
2009-09-12 23:03:15 +00:00
|
|
|
j = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFCANSEE:
|
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
j = cansee(vm.pSprite->x,vm.pSprite->y,vm.pSprite->z/*-((krand()&41)<<8)*/,vm.pSprite->sectnum,
|
2010-01-23 22:12:02 +00:00
|
|
|
pos.x, pos.y, pos.z /*-((krand()&41)<<8)*/, cursectnum);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(j);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFONWATER:
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(sector[vm.pSprite->sectnum].lotag == 1 && klabs(vm.pSprite->z-sector[vm.pSprite->sectnum].floorz) < (32<<8));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFINWATER:
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(sector[vm.pSprite->sectnum].lotag == 2);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFACTOR:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(vm.pSprite->picnum == Gv_GetVarX(*insptr));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFINSIDE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), sectnum=Gv_GetVarX(*insptr++), res;
|
|
|
|
|
|
|
|
res = inside(x, y, sectnum);
|
|
|
|
if (res == -1)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Sector index %d out of range!", sectnum);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
insptr--;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_DoConditional(res);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFOUTSIDE:
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(sector[vm.pSprite->sectnum].ceilingstat&1);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFPDISTL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(dist((spritetype *)&pos, vm.pSprite) < Gv_GetVarX(*insptr));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFPDISTG:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(dist((spritetype *)&pos, vm.pSprite) > Gv_GetVarX(*insptr));
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
// ^^^
|
|
|
|
|
|
|
|
// *** BUILD functions
|
|
|
|
case CON_INSERTSPRITE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t dasectnum = Gv_GetVarX(*insptr++), ret;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(dasectnum);
|
2012-03-14 22:30:24 +00:00
|
|
|
if (Numsprites >= MAXSPRITES)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Maximum number of sprites reached.");
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = insertsprite(dasectnum, 0);
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = ret;
|
|
|
|
vm.pSprite = &sprite[ret];
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DUPSPRITE:
|
2009-10-25 23:25:38 +00:00
|
|
|
case CON_TDUPSPRITE:
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t ospritenum = Gv_GetVarX(*insptr++), nspritenum;
|
|
|
|
|
|
|
|
if (ospritenum<0 || ospritenum>=MAXSPRITES || sprite[ospritenum].statnum==MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Tried to duplicate nonexistent sprite %d", ospritenum);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2012-03-14 22:30:24 +00:00
|
|
|
if ((tw==CON_DUPSPRITE && Numsprites >= MAXSPRITES) ||
|
2017-07-08 19:42:11 +00:00
|
|
|
(tw==CON_DUPSPRITE && spritesortcnt >= maxspritesonscreen))
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Maximum number of sprites reached.");
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2012-03-18 23:18:12 +00:00
|
|
|
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2009-10-25 23:25:38 +00:00
|
|
|
if (tw==CON_DUPSPRITE)
|
|
|
|
{
|
|
|
|
nspritenum = insertsprite(sprite[ospritenum].sectnum, sprite[ospritenum].statnum);
|
|
|
|
|
|
|
|
if (nspritenum < 0)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Internal error.");
|
2009-10-25 23:25:38 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2009-10-25 23:25:38 +00:00
|
|
|
Bmemcpy(&sprite[nspritenum], &sprite[ospritenum], sizeof(spritetype));
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = nspritenum;
|
|
|
|
vm.pSprite = &sprite[nspritenum];
|
2009-10-25 23:25:38 +00:00
|
|
|
}
|
|
|
|
else
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2009-10-25 23:25:38 +00:00
|
|
|
Bmemcpy(&tsprite[spritesortcnt], &sprite[ospritenum], sizeof(spritetype));
|
|
|
|
tsprite[spritesortcnt].owner = ospritenum;
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = -1;
|
|
|
|
vm.pUSprite = &tsprite[spritesortcnt];
|
2009-10-25 23:25:38 +00:00
|
|
|
spritesortcnt++;
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_DELETESPRITE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t daspritenum = Gv_GetVarX(*insptr++), ret;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(daspritenum);
|
|
|
|
ret = deletesprite(daspritenum);
|
2009-09-20 15:43:09 +00:00
|
|
|
g_iReturnVar = ret;
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2012-04-05 19:49:12 +00:00
|
|
|
case CON_GETSPRITELINKTYPE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t spritenum=Gv_GetVarX(*insptr++), resvar = *insptr++;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(spritenum);
|
|
|
|
Gv_SetVarX(resvar, taglab_linktags(1, spritenum));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_LASTWALL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t dapoint = Gv_GetVarX(*insptr++), resvar=*insptr++;
|
|
|
|
|
|
|
|
if (dapoint<0 || dapoint>=numwalls)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid wall %d", dapoint);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gv_SetVarX(resvar, lastwall(dapoint));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_GETZRANGE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
vec3_t vect;
|
|
|
|
|
|
|
|
vect.x = Gv_GetVarX(*insptr++);
|
|
|
|
vect.y = Gv_GetVarX(*insptr++);
|
|
|
|
vect.z = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
{
|
|
|
|
int32_t sectnum=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t ceilzvar=*insptr++, ceilhitvar=*insptr++, florzvar=*insptr++, florhitvar=*insptr++;
|
|
|
|
int32_t walldist=Gv_GetVarX(*insptr++), clipmask=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t ceilz, ceilhit, florz, florhit;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(sectnum);
|
|
|
|
getzrange(&vect, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask);
|
|
|
|
Gv_SetVarX(ceilzvar, ceilz);
|
|
|
|
Gv_SetVarX(ceilhitvar, ceilhit);
|
|
|
|
Gv_SetVarX(florzvar, florz);
|
|
|
|
Gv_SetVarX(florhitvar, florhit);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-09-27 21:52:04 +00:00
|
|
|
case CON_CALCHYPOTENUSE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t retvar=*insptr++;
|
|
|
|
int64_t dax=Gv_GetVarX(*insptr++), day=Gv_GetVarX(*insptr++);
|
|
|
|
int64_t hypsq = dax*dax + day*day;
|
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
if (hypsq > (int64_t)INT32_MAX)
|
2010-09-27 21:52:04 +00:00
|
|
|
Gv_SetVarX(retvar, (int32_t)sqrt((double)hypsq));
|
|
|
|
else
|
2012-07-01 22:11:14 +00:00
|
|
|
Gv_SetVarX(retvar, ksqrt((uint32_t)hypsq));
|
2010-09-27 21:52:04 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_LINEINTERSECT:
|
|
|
|
case CON_RAYINTERSECT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x1=Gv_GetVarX(*insptr++), y1=Gv_GetVarX(*insptr++), z1=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++), z2=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t x3=Gv_GetVarX(*insptr++), y3=Gv_GetVarX(*insptr++), x4=Gv_GetVarX(*insptr++), y4=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t intxvar=*insptr++, intyvar=*insptr++, intzvar=*insptr++, retvar=*insptr++;
|
|
|
|
int32_t intx, inty, intz, ret;
|
|
|
|
|
|
|
|
if (tw==CON_LINEINTERSECT)
|
2015-01-11 04:56:38 +00:00
|
|
|
ret = lintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz);
|
2010-09-27 21:52:04 +00:00
|
|
|
else
|
|
|
|
ret = rayintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz);
|
|
|
|
|
|
|
|
Gv_SetVarX(retvar, ret);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
Gv_SetVarX(intxvar, intx);
|
|
|
|
Gv_SetVarX(intyvar, inty);
|
|
|
|
Gv_SetVarX(intzvar, intz);
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_CLIPMOVE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
vec3_t vect;
|
|
|
|
int32_t retvar=*insptr++, xvar=*insptr++, yvar=*insptr++, z=Gv_GetVarX(*insptr++), sectnumvar=*insptr++;
|
|
|
|
int32_t xvect=Gv_GetVarX(*insptr++), yvect=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t walldist=Gv_GetVarX(*insptr++), floordist=Gv_GetVarX(*insptr++), ceildist=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t clipmask=Gv_GetVarX(*insptr++);
|
|
|
|
int16_t sectnum;
|
|
|
|
|
|
|
|
vect.x = Gv_GetVarX(xvar);
|
|
|
|
vect.y = Gv_GetVarX(yvar);
|
|
|
|
vect.z = z;
|
|
|
|
sectnum = Gv_GetVarX(sectnumvar);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(sectnum);
|
|
|
|
|
|
|
|
Gv_SetVarX(retvar, clipmove(&vect, §num, xvect, yvect, walldist, floordist, ceildist, clipmask));
|
|
|
|
Gv_SetVarX(sectnumvar, sectnum);
|
|
|
|
Gv_SetVarX(xvar, vect.x);
|
|
|
|
Gv_SetVarX(yvar, vect.y);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_HITSCAN:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
vec3_t vect;
|
2012-08-10 19:12:01 +00:00
|
|
|
hitdata_t hit;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
vect.x = Gv_GetVarX(*insptr++);
|
|
|
|
vect.y = Gv_GetVarX(*insptr++);
|
|
|
|
vect.z = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
{
|
|
|
|
int32_t sectnum=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t vx=Gv_GetVarX(*insptr++), vy=Gv_GetVarX(*insptr++), vz=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t hitsectvar=*insptr++, hitwallvar=*insptr++, hitspritevar=*insptr++;
|
|
|
|
int32_t hitxvar=*insptr++, hityvar=*insptr++, hitzvar=*insptr++, cliptype=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(sectnum);
|
2012-08-10 19:12:01 +00:00
|
|
|
hitscan((const vec3_t *)&vect, sectnum, vx, vy, vz, &hit, cliptype);
|
|
|
|
Gv_SetVarX(hitsectvar, hit.sect);
|
|
|
|
Gv_SetVarX(hitwallvar, hit.wall);
|
|
|
|
Gv_SetVarX(hitspritevar, hit.sprite);
|
|
|
|
Gv_SetVarX(hitxvar, hit.pos.x);
|
|
|
|
Gv_SetVarX(hityvar, hit.pos.y);
|
|
|
|
Gv_SetVarX(hitzvar, hit.pos.z);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_CANSEE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x1=Gv_GetVarX(*insptr++), y1=Gv_GetVarX(*insptr++), z1=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t sect1=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++), z2=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t sect2=Gv_GetVarX(*insptr++), rvar=*insptr++;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(sect1);
|
|
|
|
X_ERROR_INVALIDSECT(sect2);
|
|
|
|
|
|
|
|
Gv_SetVarX(rvar, cansee(x1,y1,z1,sect1,x2,y2,z2,sect2));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_ROTATEPOINT:
|
|
|
|
insptr++;
|
|
|
|
{
|
2015-06-06 15:04:13 +00:00
|
|
|
vec2_t pivot = { Gv_GetVarX(*insptr), Gv_GetVarX(*(insptr+1)) };
|
|
|
|
vec2_t p = { Gv_GetVarX(*(insptr+2)), Gv_GetVarX(*(insptr+3)) };
|
|
|
|
insptr += 4;
|
2015-05-26 00:47:54 +00:00
|
|
|
int32_t daang=Gv_GetVarX(*insptr++);
|
2009-09-12 23:03:15 +00:00
|
|
|
int32_t x2var=*insptr++, y2var=*insptr++;
|
2015-05-26 00:47:54 +00:00
|
|
|
vec2_t p2;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
rotatepoint(pivot,p,daang,&p2);
|
|
|
|
Gv_SetVarX(x2var, p2.x);
|
|
|
|
Gv_SetVarX(y2var, p2.y);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_NEARTAG:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
// neartag(int32_t x, int32_t y, int32_t z, short sectnum, short ang, //Starting position & angle
|
|
|
|
// short *neartagsector, //Returns near sector if sector[].tag != 0
|
|
|
|
// short *neartagwall, //Returns near wall if wall[].tag != 0
|
|
|
|
// short *neartagsprite, //Returns near sprite if sprite[].tag != 0
|
|
|
|
// int32_t *neartaghitdist, //Returns actual distance to object (scale: 1024=largest grid size)
|
|
|
|
// int32_t neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size)
|
|
|
|
// char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag
|
|
|
|
|
|
|
|
int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), z=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t sectnum=Gv_GetVarX(*insptr++), ang=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t neartagsectorvar=*insptr++, neartagwallvar=*insptr++, neartagspritevar=*insptr++, neartaghitdistvar=*insptr++;
|
|
|
|
int32_t neartagrange=Gv_GetVarX(*insptr++), tagsearch=Gv_GetVarX(*insptr++);
|
|
|
|
|
2009-09-16 22:24:24 +00:00
|
|
|
int16_t neartagsector, neartagwall, neartagsprite;
|
|
|
|
int32_t neartaghitdist;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSECT(sectnum);
|
2012-02-20 19:54:24 +00:00
|
|
|
neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite,
|
|
|
|
&neartaghitdist, neartagrange, tagsearch, NULL);
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
Gv_SetVarX(neartagsectorvar, neartagsector);
|
|
|
|
Gv_SetVarX(neartagwallvar, neartagwall);
|
|
|
|
Gv_SetVarX(neartagspritevar, neartagsprite);
|
|
|
|
Gv_SetVarX(neartaghitdistvar, neartaghitdist);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_BSETSPRITE: // was CON_SETSPRITE
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t spritenum = Gv_GetVarX(*insptr++);
|
|
|
|
vec3_t davector;
|
|
|
|
|
|
|
|
davector.x = Gv_GetVarX(*insptr++);
|
|
|
|
davector.y = Gv_GetVarX(*insptr++);
|
|
|
|
davector.z = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(spritenum);
|
|
|
|
setsprite(spritenum, &davector);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_GETFLORZOFSLOPE:
|
|
|
|
case CON_GETCEILZOFSLOPE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t sectnum = Gv_GetVarX(*insptr++), x = Gv_GetVarX(*insptr++), y = Gv_GetVarX(*insptr++);
|
2009-09-18 21:44:46 +00:00
|
|
|
int32_t var=*insptr++;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2009-09-18 21:44:46 +00:00
|
|
|
X_ERROR_INVALIDSECT(sectnum);
|
2009-09-12 23:03:15 +00:00
|
|
|
if (tw == CON_GETFLORZOFSLOPE)
|
2009-09-18 21:44:46 +00:00
|
|
|
Gv_SetVarX(var, getflorzofslope(sectnum,x,y));
|
|
|
|
else
|
|
|
|
Gv_SetVarX(var, getceilzofslope(sectnum,x,y));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_ALIGNFLORSLOPE:
|
|
|
|
case CON_ALIGNCEILSLOPE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t sectnum = Gv_GetVarX(*insptr++), x = Gv_GetVarX(*insptr++), y = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t z=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(sectnum);
|
|
|
|
if (tw == CON_ALIGNFLORSLOPE)
|
|
|
|
alignflorslope(sectnum, x,y,z);
|
|
|
|
else
|
|
|
|
alignceilslope(sectnum, x,y,z);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CURSPR
|
2009-09-17 22:08:37 +00:00
|
|
|
case CON_SETFIRSTWALL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t sect=Gv_GetVarX(*insptr++), wal=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(sect);
|
|
|
|
setfirstwall(sect, wal);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_UPDATECURSECTNUM:
|
|
|
|
insptr++;
|
|
|
|
updatesectorz(pos.x, pos.y, pos.z, &cursectnum);
|
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_UPDATESECTOR:
|
|
|
|
case CON_UPDATESECTORZ:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t z=(tw==CON_UPDATESECTORZ)?Gv_GetVarX(*insptr++):0;
|
|
|
|
int32_t var=*insptr++;
|
|
|
|
int16_t w;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDCI();
|
2016-08-27 01:40:35 +00:00
|
|
|
w=sprite[vm.spriteNum].sectnum;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
if (tw==CON_UPDATESECTOR) updatesector(x,y,&w);
|
|
|
|
else updatesectorz(x,y,z,&w);
|
|
|
|
|
|
|
|
Gv_SetVarX(var, w);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_HEADSPRITESTAT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i=*insptr++;
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
if (j < 0 || j > MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("invalid status list %d", j);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Gv_SetVarX(i,headspritestat[j]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_PREVSPRITESTAT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i=*insptr++;
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(j);
|
|
|
|
Gv_SetVarX(i,prevspritestat[j]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_NEXTSPRITESTAT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i=*insptr++;
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(j);
|
|
|
|
Gv_SetVarX(i,nextspritestat[j]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_HEADSPRITESECT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i=*insptr++;
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(j);
|
|
|
|
Gv_SetVarX(i,headspritesect[j]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_PREVSPRITESECT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i=*insptr++;
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(j);
|
|
|
|
Gv_SetVarX(i,prevspritesect[j]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_NEXTSPRITESECT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i=*insptr++;
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(j);
|
|
|
|
Gv_SetVarX(i,nextspritesect[j]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_CANSEESPR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t lVar1 = Gv_GetVarX(*insptr++), lVar2 = Gv_GetVarX(*insptr++), res;
|
|
|
|
|
|
|
|
if (lVar1<0 || lVar1>=MAXSPRITES || sprite[lVar1].statnum==MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid sprite %d", lVar1);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
if (lVar2<0 || lVar2>=MAXSPRITES || sprite[lVar2].statnum==MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid sprite %d", lVar2);
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
2009-10-11 15:52:16 +00:00
|
|
|
if (vm.flags&VMFLAG_ERROR) res=0;
|
2009-09-12 23:03:15 +00:00
|
|
|
else res=cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum,
|
|
|
|
sprite[lVar2].x,sprite[lVar2].y,sprite[lVar2].z,sprite[lVar2].sectnum);
|
|
|
|
|
|
|
|
Gv_SetVarX(*insptr++, res);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_CHANGESPRITESTAT:
|
|
|
|
case CON_CHANGESPRITESECT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t j = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSPRI(i);
|
|
|
|
if (j<0 || j >= (tw==CON_CHANGESPRITESTAT?MAXSTATUS:numsectors))
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid %s: %d", tw==CON_CHANGESPRITESTAT?"statnum":"sector", j);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tw == CON_CHANGESPRITESTAT)
|
|
|
|
{
|
|
|
|
if (sprite[i].statnum == j) continue;
|
|
|
|
changespritestat(i,j);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sprite[i].sectnum == j) continue;
|
|
|
|
changespritesect(i,j);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_DRAGPOINT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t wallnum = Gv_GetVarX(*insptr++), newx = Gv_GetVarX(*insptr++), newy = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
if (wallnum<0 || wallnum>=numwalls)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid wall %d", wallnum);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-01-16 20:38:41 +00:00
|
|
|
dragpoint(wallnum,newx,newy,0);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_SECTOROFWALL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j = *insptr++;
|
|
|
|
Gv_SetVarX(j, sectorofwall(Gv_GetVarX(*insptr++)));
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2010-01-04 14:38:29 +00:00
|
|
|
case CON_FIXREPEATS:
|
|
|
|
insptr++;
|
2011-05-15 22:37:24 +00:00
|
|
|
fixrepeats(Gv_GetVarX(*insptr++));
|
2010-01-04 14:38:29 +00:00
|
|
|
continue;
|
|
|
|
|
2010-08-03 22:21:13 +00:00
|
|
|
case CON_GETCLOSESTCOL:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t r = Gv_GetVarX(*insptr++), g = Gv_GetVarX(*insptr++), b = Gv_GetVarX(*insptr++);
|
2018-04-12 21:03:47 +00:00
|
|
|
Gv_SetVarX(*insptr++, paletteGetClosestColor(r, g, b));
|
2010-08-03 22:21:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-09-30 23:05:40 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
// *** stuff
|
2010-09-30 23:05:40 +00:00
|
|
|
case CON_UPDATEHIGHLIGHT:
|
|
|
|
insptr++;
|
|
|
|
update_highlight();
|
|
|
|
continue;
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
case CON_UPDATEHIGHLIGHTSECTOR:
|
|
|
|
insptr++;
|
|
|
|
update_highlightsector();
|
|
|
|
continue;
|
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
case CON_SETHIGHLIGHT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t what=Gv_GetVarX(*insptr++), index=Gv_GetVarX(*insptr++), doset = Gv_GetVarX(*insptr++);
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
if (highlightsectorcnt >= 0)
|
|
|
|
{
|
|
|
|
M32_ERROR("sector highlight active or pending, cannot highlight sprites/walls");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
if (what&16384)
|
|
|
|
{
|
|
|
|
index &= ~16384;
|
|
|
|
if (index < 0 || index>=MAXSPRITES || sprite[index].statnum==MAXSTATUS)
|
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid sprite index %d", index);
|
2010-09-30 23:05:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doset)
|
|
|
|
show2dsprite[index>>3] |= (1<<(index&7));
|
|
|
|
else
|
|
|
|
show2dsprite[index>>3] &= ~(1<<(index&7));
|
|
|
|
}
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
else
|
2010-09-30 23:05:40 +00:00
|
|
|
{
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
if (index < 0 || index>=numwalls)
|
|
|
|
{
|
|
|
|
M32_ERROR("Invalid wall index %d", index);
|
|
|
|
continue;
|
|
|
|
}
|
2010-09-30 23:05:40 +00:00
|
|
|
|
|
|
|
if (doset)
|
|
|
|
show2dwall[index>>3] |= (1<<(index&7));
|
|
|
|
else
|
|
|
|
show2dwall[index>>3] &= ~(1<<(index&7));
|
|
|
|
}
|
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
vm.miscflags |= VMFLAG_MISC_UPDATEHL;
|
2010-09-30 23:05:40 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
case CON_SETHIGHLIGHTSECTOR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t index=Gv_GetVarX(*insptr++), doset = Gv_GetVarX(*insptr++);
|
|
|
|
|
|
|
|
if (highlightcnt >= 0)
|
|
|
|
{
|
|
|
|
M32_ERROR("sprite/wall highlight active or pending, cannot highlight sectors");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
X_ERROR_INVALIDSECT(index);
|
|
|
|
|
|
|
|
if (doset)
|
|
|
|
hlsectorbitmap[index>>3] |= (1<<(index&7));
|
|
|
|
else
|
|
|
|
hlsectorbitmap[index>>3] &= ~(1<<(index&7));
|
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
vm.miscflags |= VMFLAG_MISC_UPDATEHLSECT;
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_GETTIMEDATE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t v1=*insptr++,v2=*insptr++,v3=*insptr++,v4=*insptr++,v5=*insptr++,v6=*insptr++,v7=*insptr++,v8=*insptr++;
|
|
|
|
time_t rawtime;
|
2010-08-02 08:13:51 +00:00
|
|
|
struct tm *ti;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
time(&rawtime);
|
|
|
|
ti = localtime(&rawtime);
|
|
|
|
// initprintf("Time&date: %s\n",asctime (ti));
|
|
|
|
|
|
|
|
Gv_SetVarX(v1, ti->tm_sec);
|
|
|
|
Gv_SetVarX(v2, ti->tm_min);
|
|
|
|
Gv_SetVarX(v3, ti->tm_hour);
|
|
|
|
Gv_SetVarX(v4, ti->tm_mday);
|
|
|
|
Gv_SetVarX(v5, ti->tm_mon);
|
|
|
|
Gv_SetVarX(v6, ti->tm_year+1900);
|
|
|
|
Gv_SetVarX(v7, ti->tm_wday);
|
|
|
|
Gv_SetVarX(v8, ti->tm_yday);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_ADDLOG:
|
|
|
|
{
|
|
|
|
insptr++;
|
|
|
|
|
|
|
|
OSD_Printf("L=%d\n", g_errorLineNum);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_ADDLOGVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
char buf[80] = "", buf2[80] = "";
|
|
|
|
int32_t code = (int32_t)*insptr, val = Gv_GetVarX(code);
|
2010-05-22 23:41:18 +00:00
|
|
|
int32_t negate=code&M32_FLAG_NEGATE;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
if (code & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
if ((code&M32_VARTYPE_MASK)==M32_FLAG_ARRAY || (code&M32_VARTYPE_MASK)==M32_FLAG_STRUCT)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
if (code&M32_FLAG_CONSTANT)
|
2009-09-12 23:03:15 +00:00
|
|
|
Bsprintf(buf2, "%d", (code>>16)&0xffff);
|
|
|
|
else
|
2010-08-11 22:37:45 +00:00
|
|
|
{
|
|
|
|
char *label = aGameVars[(code>>16)&(MAXGAMEVARS-1)].szLabel;
|
|
|
|
Bsprintf(buf2, "%s", label?label:"???");
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
else if ((code&M32_VARTYPE_MASK)==M32_FLAG_LOCAL)
|
|
|
|
Bsprintf(buf2, "%d", code&(MAXGAMEVARS-1));
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2010-08-11 22:37:45 +00:00
|
|
|
if ((code&0x0000FFFC) == M32_FLAG_CONSTANT) // addlogvar for a constant.. why not? :P
|
2009-09-14 22:11:37 +00:00
|
|
|
{
|
|
|
|
switch (code&3)
|
|
|
|
{
|
|
|
|
case 0: Bsprintf(buf, "(immediate constant)"); break;
|
|
|
|
case 1: Bsprintf(buf, "(indirect constant)"); break;
|
|
|
|
case 2: Bsprintf(buf, "(label constant)"); break;
|
|
|
|
default: Bsprintf(buf, "(??? constant)"); break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
else
|
2010-08-11 22:37:45 +00:00
|
|
|
{
|
|
|
|
switch (code&M32_VARTYPE_MASK)
|
|
|
|
{
|
|
|
|
case M32_FLAG_ARRAY:
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(buf, sizeof(buf), "%s[%s]", aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel
|
|
|
|
? aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel : "???", buf2);
|
2010-08-11 22:37:45 +00:00
|
|
|
break;
|
|
|
|
case M32_FLAG_STRUCT:
|
2011-05-07 18:23:34 +00:00
|
|
|
{
|
|
|
|
int32_t memberid=(code>>2)&63, lightp = (memberid >= LIGHT_X);
|
|
|
|
const char *pp1[4] = {"sprite","sector","wall","tsprite"};
|
|
|
|
const memberlabel_t *pp2[4] = {SpriteLabels, SectorLabels, WallLabels, SpriteLabels};
|
|
|
|
if (lightp)
|
|
|
|
{
|
|
|
|
pp1[3] = "light";
|
|
|
|
pp2[3] = LightLabels;
|
|
|
|
memberid -= LIGHT_X;
|
|
|
|
}
|
|
|
|
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(buf, sizeof(buf), "%s[%s].%s", pp1[code&3], buf2, pp2[code&3][memberid].name);
|
2011-05-07 18:23:34 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-08-11 22:37:45 +00:00
|
|
|
case M32_FLAG_VAR:
|
2018-07-23 02:55:59 +00:00
|
|
|
Bstrcpy(buf, "???");
|
2010-08-11 22:37:45 +00:00
|
|
|
break;
|
|
|
|
case M32_FLAG_LOCAL:
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(buf, sizeof(buf), ".local[%s]", buf2);
|
2010-08-11 22:37:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (aGameVars[code].dwFlags & GAMEVAR_PERBLOCK)
|
|
|
|
{
|
|
|
|
Bsprintf(buf2, "(%s", vm.g_st==0? "top-level) " : vm.g_st<=MAXEVENTS? "event" : "state");
|
|
|
|
if (vm.g_st >= 1+MAXEVENTS && vm.g_st <1+MAXEVENTS+g_stateCount)
|
|
|
|
Bsprintf(buf, " `%s') ", statesinfo[vm.g_st-1-MAXEVENTS].name);
|
|
|
|
else if (vm.g_st > 0)
|
|
|
|
Bsprintf(buf, " %d) ", vm.g_st-1);
|
|
|
|
Bstrcat(buf2, buf);
|
|
|
|
}
|
|
|
|
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(buf, sizeof(buf), "%s%s", buf2, aGameVars[code].szLabel ? aGameVars[code].szLabel : "???");
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OSD_Printf("L%d: %s%s=%d\n", g_errorLineNum, negate?"-":"", buf, val);
|
|
|
|
|
|
|
|
insptr++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_DEBUG:
|
|
|
|
insptr++;
|
|
|
|
initprintf("%d\n",*insptr++);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// *** strings
|
|
|
|
case CON_REDEFINEQUOTE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t q = *insptr++, i = *insptr++;
|
2016-08-27 01:40:35 +00:00
|
|
|
X_ERROR_INVALIDQUOTE(q, apStrings);
|
|
|
|
X_ERROR_INVALIDQUOTE(i, apXStrings);
|
|
|
|
Bstrcpy(apStrings[q],apXStrings[i]);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
case CON_GETNUMBER16: /* deprecated */
|
|
|
|
case CON_GETNUMBER256: /* deprecated */
|
|
|
|
case CON_GETNUMBERFROMUSER:
|
2009-09-16 22:24:24 +00:00
|
|
|
insptr++;
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t var=*insptr++, quote=*insptr++;
|
|
|
|
const char *quotetext = GetMaybeInlineQuote(quote);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
{
|
2011-08-03 17:22:25 +00:00
|
|
|
int32_t max=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t sign = (tw==CON_GETNUMBERFROMUSER) ? Gv_GetVarX(*insptr++) : (max<=0);
|
2010-08-11 22:37:45 +00:00
|
|
|
char buf[64]; // buffers in getnumber* are 80 bytes long
|
2009-09-16 22:24:24 +00:00
|
|
|
|
2012-03-28 19:43:21 +00:00
|
|
|
Bstrncpyz(buf, quotetext, sizeof(buf));
|
2009-09-16 22:24:24 +00:00
|
|
|
|
2010-08-16 13:56:49 +00:00
|
|
|
if (max==0)
|
2011-08-03 17:22:25 +00:00
|
|
|
max = INT32_MAX;
|
2013-12-11 21:23:47 +00:00
|
|
|
else
|
|
|
|
max = klabs(max);
|
2010-08-16 13:56:49 +00:00
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
//OSD_Printf("max:%d, sign:%d\n", max, sign);
|
2011-08-03 17:22:25 +00:00
|
|
|
if (tw==CON_GETNUMBERFROMUSER)
|
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
Gv_SetVarX(var, in3dmode() ?
|
2011-08-03 17:22:25 +00:00
|
|
|
getnumber256(quotetext, Gv_GetVarX(var), max, sign) :
|
|
|
|
getnumber16(quotetext, Gv_GetVarX(var), max, sign));
|
|
|
|
}
|
|
|
|
else if (tw==CON_GETNUMBER16)
|
2010-08-11 22:37:45 +00:00
|
|
|
Gv_SetVarX(var, getnumber16(quotetext, Gv_GetVarX(var), max, sign));
|
|
|
|
else
|
|
|
|
Gv_SetVarX(var, getnumber256(quotetext, Gv_GetVarX(var), max, sign));
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2009-10-03 13:20:31 +00:00
|
|
|
case CON_PRINT:
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_QUOTE:
|
|
|
|
case CON_ERRORINS:
|
|
|
|
case CON_PRINTMESSAGE16:
|
|
|
|
case CON_PRINTMESSAGE256:
|
|
|
|
case CON_PRINTEXT256:
|
2009-09-16 22:24:24 +00:00
|
|
|
case CON_PRINTEXT16:
|
2011-03-07 16:30:06 +00:00
|
|
|
case CON_DRAWLABEL:
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr++;
|
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t i=*insptr++;
|
|
|
|
const char *quotetext = GetMaybeInlineQuote(i);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-16 22:24:24 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t x=(tw>=CON_PRINTMESSAGE256)?Gv_GetVarX(*insptr++):0;
|
|
|
|
int32_t y=(tw>=CON_PRINTMESSAGE256)?Gv_GetVarX(*insptr++):0;
|
2011-03-07 16:30:06 +00:00
|
|
|
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t col=(tw>=CON_PRINTEXT256)?Gv_GetVarX(*insptr++):0;
|
|
|
|
int32_t backcol=(tw>=CON_PRINTEXT256)?Gv_GetVarX(*insptr++):0;
|
|
|
|
int32_t fontsize=(tw>=CON_PRINTEXT256)?Gv_GetVarX(*insptr++):0;
|
|
|
|
|
|
|
|
if (tw==CON_PRINT || tw==CON_ERRORINS)
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
OSD_Printf("%s\n", quotetext);
|
2011-03-07 16:30:06 +00:00
|
|
|
if (tw==CON_ERRORINS)
|
|
|
|
vm.flags |= VMFLAG_ERROR;
|
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
else if (tw==CON_QUOTE)
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
message("%s", quotetext);
|
2011-03-07 16:30:06 +00:00
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
else if (tw==CON_PRINTMESSAGE16)
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode())
|
2011-03-07 16:30:06 +00:00
|
|
|
printmessage16("%s", quotetext);
|
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
else if (tw==CON_PRINTMESSAGE256)
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (in3dmode())
|
2011-03-07 16:30:06 +00:00
|
|
|
printmessage256(x, y, quotetext);
|
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
else if (tw==CON_PRINTEXT256)
|
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (in3dmode())
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
2012-07-08 21:47:16 +00:00
|
|
|
if (col>=256)
|
|
|
|
col=0;
|
|
|
|
else if (col < 0 && col >= -255)
|
|
|
|
col = editorcolors[-col];
|
|
|
|
|
|
|
|
if (backcol<0 || backcol>=256)
|
|
|
|
backcol=-1;
|
|
|
|
|
2011-03-07 16:30:06 +00:00
|
|
|
printext256(x, y, col, backcol, quotetext, fontsize);
|
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
}
|
|
|
|
else if (tw==CON_PRINTEXT16)
|
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode())
|
2011-03-07 16:30:06 +00:00
|
|
|
printext16(x, y, editorcolors[col&255], backcol<0 ? -1 : editorcolors[backcol&255],
|
|
|
|
quotetext, fontsize);
|
|
|
|
}
|
|
|
|
else if (tw==CON_DRAWLABEL)
|
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode())
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
|
|
|
drawsmallabel(quotetext,
|
|
|
|
editorcolors[backcol&255], // col
|
2015-07-10 07:56:48 +00:00
|
|
|
fontsize < 0 ? -1 : editorcolors[fontsize&255], editorcolors[fontsize&255] - 3, // backcol
|
2011-03-07 16:30:06 +00:00
|
|
|
x, y, col); // x y z
|
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
}
|
2009-09-16 22:24:24 +00:00
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_QSTRLEN:
|
|
|
|
insptr++;
|
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t i=*insptr++, quote=*insptr++;
|
|
|
|
const char *quotetext = GetMaybeInlineQuote(quote);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-16 22:24:24 +00:00
|
|
|
|
2010-08-11 22:37:45 +00:00
|
|
|
Gv_SetVarX(i, Bstrlen(quotetext));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_QSUBSTR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t q1 = Gv_GetVarX(*insptr++);
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t q2 = *insptr++;
|
|
|
|
const char *q2text = GetMaybeInlineQuote(q2);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
X_ERROR_INVALIDQUOTE(q1, apStrings);
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t st = Gv_GetVarX(*insptr++);
|
|
|
|
int32_t ln = Gv_GetVarX(*insptr++);
|
2016-08-27 01:40:35 +00:00
|
|
|
char *s1 = apStrings[q1];
|
2010-08-11 22:37:45 +00:00
|
|
|
const char *s2 = q2text;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
while (*s2 && st--) s2++;
|
|
|
|
while ((*s1 = *s2) && ln--)
|
|
|
|
{
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
*s1=0;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_QSTRNCAT:
|
|
|
|
case CON_QSTRCAT:
|
|
|
|
case CON_QSTRCPY:
|
|
|
|
/// case CON_QGETSYSSTR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t i = Gv_GetVarX(*insptr++);
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t j = *insptr++;
|
|
|
|
|
|
|
|
const char *quotetext = GetMaybeInlineQuote(j);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
X_ERROR_INVALIDQUOTE(i, apStrings);
|
2009-09-16 22:24:24 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
switch (tw)
|
|
|
|
{
|
|
|
|
case CON_QSTRCAT:
|
2016-08-27 01:40:35 +00:00
|
|
|
Bstrncat(apStrings[i], quotetext, (MAXQUOTELEN-1)-Bstrlen(apStrings[i]));
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
|
|
|
case CON_QSTRNCAT:
|
2016-08-27 01:40:35 +00:00
|
|
|
Bstrncat(apStrings[i], quotetext, Gv_GetVarX(*insptr++));
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
|
|
|
case CON_QSTRCPY:
|
2016-08-27 01:40:35 +00:00
|
|
|
Bstrcpy(apStrings[i], quotetext);
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_QSPRINTF:
|
|
|
|
insptr++;
|
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t dq=Gv_GetVarX(*insptr++), sq=*insptr++;
|
|
|
|
const char *sourcetext = GetMaybeInlineQuote(sq);
|
|
|
|
if (vm.flags&VMFLAG_ERROR)
|
|
|
|
continue;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
X_ERROR_INVALIDQUOTE(dq, apStrings);
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
{
|
2009-09-16 22:24:24 +00:00
|
|
|
int32_t arg[32], numvals=0, i=0, j=0, k=0;
|
2010-08-11 22:37:45 +00:00
|
|
|
int32_t len = Bstrlen(sourcetext);
|
2009-09-16 22:24:24 +00:00
|
|
|
char tmpbuf[MAXQUOTELEN<<1];
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2009-09-18 21:44:46 +00:00
|
|
|
while (*insptr != -1 && numvals < 32)
|
2009-09-16 22:24:24 +00:00
|
|
|
arg[numvals++] = Gv_GetVarX(*insptr++);
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr++; // skip the NOP
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
2010-08-11 22:37:45 +00:00
|
|
|
while (k < len && j < MAXQUOTELEN && sourcetext[k] != '%')
|
|
|
|
tmpbuf[j++] = sourcetext[k++];
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2010-08-11 22:37:45 +00:00
|
|
|
if (sourcetext[k] == '%')
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
k++;
|
2009-09-16 22:24:24 +00:00
|
|
|
|
|
|
|
if (i>=numvals) goto dodefault;
|
|
|
|
|
2010-08-11 22:37:45 +00:00
|
|
|
switch (sourcetext[k])
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
case 'l':
|
2010-08-11 22:37:45 +00:00
|
|
|
if (sourcetext[k+1] != 'd')
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
// write the % and l
|
2010-08-11 22:37:45 +00:00
|
|
|
tmpbuf[j++] = sourcetext[k-1];
|
|
|
|
tmpbuf[j++] = sourcetext[k++];
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
k++;
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2009-09-12 23:03:15 +00:00
|
|
|
case 'd':
|
|
|
|
{
|
|
|
|
char buf[16];
|
|
|
|
int32_t ii = 0;
|
|
|
|
|
|
|
|
Bsprintf(buf, "%d", arg[i++]);
|
|
|
|
|
|
|
|
ii = Bstrlen(buf);
|
2010-05-22 14:04:47 +00:00
|
|
|
Bmemcpy(&tmpbuf[j], buf, ii);
|
|
|
|
j += ii;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
int32_t ii = 0;
|
2018-11-18 18:13:33 +00:00
|
|
|
union { int32_t ival; float fval; };
|
|
|
|
ival = arg[i++];
|
2010-05-22 14:04:47 +00:00
|
|
|
|
2018-11-18 18:13:33 +00:00
|
|
|
Bsprintf(buf, "%f", fval);
|
2010-05-22 14:04:47 +00:00
|
|
|
|
|
|
|
ii = Bstrlen(buf);
|
2009-09-12 23:03:15 +00:00
|
|
|
Bmemcpy(&tmpbuf[j], buf, ii);
|
|
|
|
j += ii;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (arg[i]>=0 && arg[i]<MAXQUOTES && apStrings[arg[i]])
|
2009-09-16 22:24:24 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
int32_t ii = Bstrlen(apStrings[arg[i]]);
|
|
|
|
Bmemcpy(&tmpbuf[j], apStrings[arg[i]], ii);
|
2009-09-16 22:24:24 +00:00
|
|
|
j += ii;
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
k++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-16 22:24:24 +00:00
|
|
|
dodefault:
|
2009-09-12 23:03:15 +00:00
|
|
|
default:
|
2010-08-11 22:37:45 +00:00
|
|
|
tmpbuf[j++] = sourcetext[k-1];
|
2009-09-12 23:03:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (k < len && j < MAXQUOTELEN);
|
|
|
|
|
|
|
|
tmpbuf[j] = '\0';
|
2016-08-27 01:40:35 +00:00
|
|
|
Bmemcpy(apStrings[dq], tmpbuf, MAXQUOTELEN);
|
|
|
|
apStrings[dq][MAXQUOTELEN-1] = '\0';
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// *** findnear*
|
|
|
|
// CURSPR vvv
|
|
|
|
case CON_FINDNEARSPRITE:
|
|
|
|
case CON_FINDNEARSPRITE3D:
|
|
|
|
case CON_FINDNEARSPRITEVAR:
|
|
|
|
case CON_FINDNEARSPRITE3DVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
// syntax findnearactor(var) <type> <maxdist(var)> <getvar>
|
|
|
|
// gets the sprite ID of the nearest actor within max dist
|
|
|
|
// that is of <type> into <getvar>
|
|
|
|
// -1 for none found
|
|
|
|
// <type> <maxdist(varid)> <varid>
|
|
|
|
int32_t lType=*insptr++;
|
|
|
|
int32_t lMaxDist = (tw==CON_FINDNEARSPRITE || tw==CON_FINDNEARSPRITE3D)?
|
2010-01-23 22:12:02 +00:00
|
|
|
*insptr++ : Gv_GetVarX(*insptr++);
|
2009-09-12 23:03:15 +00:00
|
|
|
int32_t lVarID=*insptr++;
|
|
|
|
int32_t lFound=-1, j, k = MAXSTATUS-1;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDCI();
|
|
|
|
do
|
|
|
|
{
|
|
|
|
j=headspritestat[k]; // all sprites
|
|
|
|
if (tw==CON_FINDNEARSPRITE3D || tw==CON_FINDNEARSPRITE3DVAR)
|
|
|
|
{
|
|
|
|
while (j>=0)
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (sprite[j].picnum == lType && j != vm.spriteNum && dist(&sprite[vm.spriteNum], &sprite[j]) < lMaxDist)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
lFound=j;
|
|
|
|
j = MAXSPRITES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
if (j == MAXSPRITES)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (j>=0)
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (sprite[j].picnum == lType && j != vm.spriteNum && ldist(&sprite[vm.spriteNum], &sprite[j]) < lMaxDist)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
|
|
|
lFound=j;
|
|
|
|
j = MAXSPRITES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j == MAXSPRITES)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
while (k--);
|
|
|
|
Gv_SetVarX(lVarID, lFound);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_FINDNEARSPRITEZVAR:
|
|
|
|
case CON_FINDNEARSPRITEZ:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
// syntax findnearactor(var) <type> <maxdist(var)> <getvar>
|
|
|
|
// gets the sprite ID of the nearest actor within max dist
|
|
|
|
// that is of <type> into <getvar>
|
|
|
|
// -1 for none found
|
|
|
|
// <type> <maxdist(varid)> <varid>
|
|
|
|
int32_t lType=*insptr++;
|
|
|
|
int32_t lMaxDist = (tw==CON_FINDNEARSPRITEZVAR) ? Gv_GetVarX(*insptr++) : *insptr++;
|
|
|
|
int32_t lMaxZDist = (tw==CON_FINDNEARSPRITEZVAR) ? Gv_GetVarX(*insptr++) : *insptr++;
|
|
|
|
int32_t lVarID=*insptr++;
|
|
|
|
int32_t lFound=-1, lTemp, lTemp2, j, k=MAXSTATUS-1;
|
|
|
|
|
|
|
|
X_ERROR_INVALIDCI();
|
|
|
|
do
|
|
|
|
{
|
|
|
|
j=headspritestat[k]; // all sprites
|
|
|
|
if (j == -1) continue;
|
|
|
|
do
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (sprite[j].picnum == lType && j != vm.spriteNum)
|
2009-09-12 23:03:15 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
lTemp=ldist(&sprite[vm.spriteNum], &sprite[j]);
|
2009-09-12 23:03:15 +00:00
|
|
|
if (lTemp < lMaxDist)
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
lTemp2=klabs(sprite[vm.spriteNum].z-sprite[j].z);
|
2009-09-12 23:03:15 +00:00
|
|
|
if (lTemp2 < lMaxZDist)
|
|
|
|
{
|
|
|
|
lFound=j;
|
|
|
|
j = MAXSPRITES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
while (j>=0);
|
|
|
|
if (j == MAXSPRITES)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
while (k--);
|
|
|
|
Gv_SetVarX(lVarID, lFound);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// ^^^
|
|
|
|
|
|
|
|
case CON_GETTICKS:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=*insptr++;
|
2018-04-12 21:02:51 +00:00
|
|
|
Gv_SetVarX(j, timerGetTicks());
|
2009-09-12 23:03:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SETASPECT:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t daxrange = Gv_GetVarX(*insptr++), dayxaspect = Gv_GetVarX(*insptr++);
|
|
|
|
if (daxrange < (1<<12)) daxrange = (1<<12);
|
|
|
|
if (daxrange > (1<<20)) daxrange = (1<<20);
|
|
|
|
if (dayxaspect < (1<<12)) dayxaspect = (1<<12);
|
|
|
|
if (dayxaspect > (1<<20)) dayxaspect = (1<<20);
|
2018-04-12 21:03:47 +00:00
|
|
|
renderSetAspect(daxrange, dayxaspect);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// vvv CURSPR
|
|
|
|
case CON_SETI:
|
2012-04-05 19:49:30 +00:00
|
|
|
{
|
|
|
|
int32_t newcurspritei;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
insptr++;
|
2012-04-05 19:49:30 +00:00
|
|
|
newcurspritei = Gv_GetVarX(*insptr++);
|
|
|
|
X_ERROR_INVALIDSPRI(newcurspritei);
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.spriteNum = newcurspritei;
|
|
|
|
vm.pSprite = &sprite[vm.spriteNum];
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
2012-04-05 19:49:30 +00:00
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
case CON_SIZEAT:
|
2012-04-05 19:49:30 +00:00
|
|
|
insptr += 3;
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pSprite->xrepeat = (uint8_t) Gv_GetVarX(*(insptr-2));
|
|
|
|
vm.pSprite->yrepeat = (uint8_t) Gv_GetVarX(*(insptr-1));
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_CSTAT:
|
2012-04-05 19:49:30 +00:00
|
|
|
insptr += 2;
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pSprite->cstat = (int16_t) *(insptr-1);
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_CSTATOR:
|
2012-04-05 19:49:30 +00:00
|
|
|
insptr += 2;
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pSprite->cstat |= (int16_t) Gv_GetVarX(*(insptr-1));
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_CLIPDIST:
|
2012-04-05 19:49:30 +00:00
|
|
|
insptr += 2;
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pSprite->clipdist = (uint8_t) Gv_GetVarX(*(insptr-1));
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SPRITEPAL:
|
2012-04-05 19:49:30 +00:00
|
|
|
insptr += 2;
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pSprite->pal = Gv_GetVarX(*(insptr-1));
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_CACTOR:
|
2012-04-05 19:49:30 +00:00
|
|
|
insptr += 2;
|
2009-09-12 23:03:15 +00:00
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
vm.pSprite->picnum = Gv_GetVarX(*(insptr-1));
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2016-08-27 01:40:35 +00:00
|
|
|
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SPGETLOTAG:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(M32_LOTAG_VAR_ID, vm.pSprite->lotag);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SPGETHITAG:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(M32_HITAG_VAR_ID, vm.pSprite->hitag);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SECTGETLOTAG:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(M32_LOTAG_VAR_ID, sector[vm.pSprite->sectnum].lotag);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SECTGETHITAG:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(M32_HITAG_VAR_ID, sector[vm.pSprite->sectnum].hitag);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_GETTEXTUREFLOOR:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.pSprite->sectnum].floorpicnum);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_GETTEXTURECEILING:
|
|
|
|
insptr++;
|
|
|
|
X_ERROR_INVALIDSP();
|
2016-08-27 01:40:35 +00:00
|
|
|
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.pSprite->sectnum].ceilingpicnum);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
// ^^^
|
2009-09-16 22:24:24 +00:00
|
|
|
case CON_DRAWLINE16:
|
|
|
|
case CON_DRAWLINE16B:
|
2010-11-27 22:12:24 +00:00
|
|
|
case CON_DRAWLINE16Z:
|
2009-09-16 22:24:24 +00:00
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x1=Gv_GetVarX(*insptr++), y1=Gv_GetVarX(*insptr++);
|
2010-11-27 22:12:24 +00:00
|
|
|
int32_t z1=tw==CON_DRAWLINE16Z?Gv_GetVarX(*insptr++):0;
|
2009-09-16 22:24:24 +00:00
|
|
|
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++);
|
2010-11-27 22:12:24 +00:00
|
|
|
int32_t z2=tw==CON_DRAWLINE16Z?Gv_GetVarX(*insptr++):0;
|
2009-09-16 22:24:24 +00:00
|
|
|
int32_t col=Gv_GetVarX(*insptr++), odrawlinepat=drawlinepat;
|
|
|
|
int32_t xofs=0, yofs=0;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (tw==CON_DRAWLINE16B || tw==CON_DRAWLINE16Z)
|
2009-09-16 22:24:24 +00:00
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&x1,&y1, x1-pos.x,y1-pos.y, zoom);
|
|
|
|
editorGet2dScreenCoordinates(&x2,&y2, x2-pos.x,y2-pos.y, zoom);
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
if (tw==CON_DRAWLINE16Z && m32_sideview)
|
|
|
|
{
|
|
|
|
y1 += getscreenvdisp(z1-pos.z,zoom);
|
|
|
|
y2 += getscreenvdisp(z2-pos.z,zoom);
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:24:24 +00:00
|
|
|
xofs = halfxdim16;
|
|
|
|
yofs = midydim16;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawlinepat = m32_drawlinepat;
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(xofs+x1,yofs+y1, xofs+x2,yofs+y2, col>=0?editorcolors[col&15]:((-col)&255));
|
2009-09-16 22:24:24 +00:00
|
|
|
drawlinepat = odrawlinepat;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_DRAWCIRCLE16:
|
|
|
|
case CON_DRAWCIRCLE16B:
|
2010-11-27 22:12:24 +00:00
|
|
|
case CON_DRAWCIRCLE16Z:
|
2009-09-16 22:24:24 +00:00
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x1=Gv_GetVarX(*insptr++), y1=Gv_GetVarX(*insptr++);
|
2010-11-27 22:12:24 +00:00
|
|
|
int32_t z1 = tw==CON_DRAWCIRCLE16Z ? Gv_GetVarX(*insptr++) : 0;
|
2009-09-16 22:24:24 +00:00
|
|
|
int32_t r=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t col=Gv_GetVarX(*insptr++), odrawlinepat=drawlinepat;
|
2010-11-27 22:12:24 +00:00
|
|
|
int32_t xofs=0, yofs=0, eccen=16384;
|
2009-09-16 22:24:24 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
if (tw==CON_DRAWCIRCLE16B || tw==CON_DRAWCIRCLE16Z)
|
2009-09-16 22:24:24 +00:00
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&x1,&y1, x1-pos.x,y1-pos.y, zoom);
|
2010-11-27 22:12:24 +00:00
|
|
|
if (m32_sideview)
|
2011-02-13 23:26:54 +00:00
|
|
|
y1 += getscreenvdisp(z1-pos.z, zoom);
|
2009-09-16 22:24:24 +00:00
|
|
|
r = mulscale14(r,zoom);
|
2010-11-27 22:12:24 +00:00
|
|
|
eccen = scalescreeny(eccen);
|
2009-09-16 22:24:24 +00:00
|
|
|
xofs = halfxdim16;
|
|
|
|
yofs = midydim16;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawlinepat = m32_drawlinepat;
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dCircle(xofs+x1, yofs+y1, r, eccen, col>=0?editorcolors[col&15]:((-col)&255));
|
2009-09-16 22:24:24 +00:00
|
|
|
drawlinepat = odrawlinepat;
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2013-03-25 04:33:03 +00:00
|
|
|
case CON_ROTATESPRITEA:
|
2009-09-12 23:03:15 +00:00
|
|
|
case CON_ROTATESPRITE16:
|
|
|
|
case CON_ROTATESPRITE:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), z=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t a=Gv_GetVarX(*insptr++), tilenum=Gv_GetVarX(*insptr++), shade=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t pal=Gv_GetVarX(*insptr++), orientation=Gv_GetVarX(*insptr++);
|
2013-03-25 04:33:03 +00:00
|
|
|
int32_t alpha = (tw == CON_ROTATESPRITEA) ? Gv_GetVarX(*insptr++) : 0;
|
2009-09-12 23:03:15 +00:00
|
|
|
int32_t x1=Gv_GetVarX(*insptr++), y1=Gv_GetVarX(*insptr++);
|
|
|
|
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++);
|
|
|
|
|
2013-05-12 18:51:28 +00:00
|
|
|
if (tw != CON_ROTATESPRITE16 && !(orientation&ROTATESPRITE_FULL16))
|
|
|
|
{
|
|
|
|
x<<=16;
|
|
|
|
y<<=16;
|
|
|
|
}
|
|
|
|
|
|
|
|
orientation &= (ROTATESPRITE_MAX-1);
|
|
|
|
|
2014-03-05 21:12:54 +00:00
|
|
|
rotatesprite_(x,y,z,a,tilenum,shade,pal,2|orientation,alpha,0,x1,y1,x2,y2);
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CON_SETGAMEPALETTE:
|
|
|
|
insptr++;
|
2014-07-28 06:44:14 +00:00
|
|
|
SetGamePalette(Gv_GetVarX(*insptr++));
|
2009-09-12 23:03:15 +00:00
|
|
|
continue;
|
|
|
|
|
2009-11-01 20:30:09 +00:00
|
|
|
// *** sounds
|
|
|
|
case CON_IFSOUND:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr);
|
2014-07-28 06:45:18 +00:00
|
|
|
if (S_InvalidSound(j))
|
2009-11-01 20:30:09 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid sound %d", j);
|
2009-11-01 20:30:09 +00:00
|
|
|
insptr++;
|
|
|
|
continue;
|
|
|
|
}
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(S_CheckSoundPlaying(vm.spriteNum,j));
|
2009-11-01 20:30:09 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_IFNOSOUNDS:
|
2016-08-27 01:40:35 +00:00
|
|
|
VM_DoConditional(S_SoundsPlaying(vm.spriteNum) < 0);
|
2009-11-01 20:30:09 +00:00
|
|
|
continue;
|
|
|
|
|
2010-09-30 23:05:40 +00:00
|
|
|
case CON_IFIN3DMODE:
|
2013-05-30 09:13:32 +00:00
|
|
|
VM_DoConditional(in3dmode());
|
2010-09-30 23:05:40 +00:00
|
|
|
continue;
|
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
// ifaimingsprite and -wall also work in 2d mode, but you must "and" with 16383 yourself
|
2010-08-16 13:56:49 +00:00
|
|
|
case CON_IFAIMINGSPRITE:
|
2013-05-30 09:13:32 +00:00
|
|
|
VM_DoConditional(AIMING_AT_SPRITE || (!in3dmode() && pointhighlight>=16384));
|
2010-08-16 13:56:49 +00:00
|
|
|
continue;
|
|
|
|
case CON_IFAIMINGWALL:
|
2013-05-30 09:13:32 +00:00
|
|
|
VM_DoConditional(AIMING_AT_WALL_OR_MASK || (!in3dmode() && linehighlight>=0));
|
2010-08-16 13:56:49 +00:00
|
|
|
continue;
|
|
|
|
case CON_IFAIMINGSECTOR:
|
|
|
|
VM_DoConditional(AIMING_AT_CEILING_OR_FLOOR);
|
|
|
|
continue;
|
2011-08-03 17:22:25 +00:00
|
|
|
case CON_IFINTERACTIVE:
|
|
|
|
VM_DoConditional(vm.miscflags&VMFLAG_MISC_INTERACTIVE);
|
|
|
|
continue;
|
2010-08-16 13:56:49 +00:00
|
|
|
|
2009-11-01 20:30:09 +00:00
|
|
|
case CON_GETSOUNDFLAGS:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++), var=*insptr++;
|
2014-07-28 06:45:18 +00:00
|
|
|
if (S_InvalidSound(j))
|
2009-11-01 20:30:09 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid sound %d", j);
|
2009-11-01 20:30:09 +00:00
|
|
|
insptr++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-07-28 06:45:18 +00:00
|
|
|
Gv_SetVarX(var, S_SoundFlags(j));
|
2009-11-01 20:30:09 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_SOUNDVAR:
|
|
|
|
case CON_STOPSOUNDVAR:
|
|
|
|
case CON_SOUNDONCEVAR:
|
|
|
|
case CON_GLOBALSOUNDVAR:
|
|
|
|
insptr++;
|
|
|
|
{
|
|
|
|
int32_t j=Gv_GetVarX(*insptr++);
|
|
|
|
|
2014-07-28 06:45:18 +00:00
|
|
|
if (S_InvalidSound(j))
|
2009-11-01 20:30:09 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
M32_ERROR("Invalid sound %d", j);
|
2009-11-01 20:30:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (tw)
|
|
|
|
{
|
|
|
|
case CON_SOUNDONCEVAR:
|
2016-08-27 01:40:35 +00:00
|
|
|
if (!S_CheckSoundPlaying(vm.spriteNum,j))
|
|
|
|
A_PlaySound((int16_t)j,vm.spriteNum);
|
2009-11-01 20:30:09 +00:00
|
|
|
break;
|
|
|
|
case CON_GLOBALSOUNDVAR:
|
|
|
|
A_PlaySound((int16_t)j,-1);
|
|
|
|
break;
|
|
|
|
case CON_STOPSOUNDVAR:
|
2016-08-27 01:40:35 +00:00
|
|
|
if (S_CheckSoundPlaying(vm.spriteNum,j))
|
2009-11-01 20:30:09 +00:00
|
|
|
S_StopSound((int16_t)j);
|
|
|
|
break;
|
|
|
|
case CON_SOUNDVAR:
|
2016-08-27 01:40:35 +00:00
|
|
|
A_PlaySound((int16_t)j,vm.spriteNum);
|
2009-11-01 20:30:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case CON_STOPALLSOUNDS:
|
|
|
|
insptr++;
|
2017-01-05 05:29:25 +00:00
|
|
|
S_StopAllSounds();
|
2009-11-01 20:30:09 +00:00
|
|
|
continue;
|
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
default:
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_ScriptInfo();
|
2009-09-12 23:03:15 +00:00
|
|
|
|
|
|
|
OSD_Printf("\nAn error has occurred in the Mapster32 virtual machine.\n\n"
|
|
|
|
"Please e-mail the file mapster32.log along with every M32 file\n"
|
|
|
|
"you're using and instructions how to reproduce this error to\n"
|
2018-03-22 04:48:36 +00:00
|
|
|
"development@voidpoint.com.\n\n"
|
2011-12-04 21:20:48 +00:00
|
|
|
"Thank you!\n");
|
2009-10-11 15:52:16 +00:00
|
|
|
vm.flags |= VMFLAG_ERROR;
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfflush(NULL);
|
2009-09-12 23:03:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|