- exported line_t's functions to the VM.

This commit is contained in:
Christoph Oelckers 2017-01-08 15:45:37 +01:00
parent cb89a1a81a
commit 1c74faea73
4 changed files with 53 additions and 5 deletions

View File

@ -1779,12 +1779,53 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
if (ndx >= level.sectors.Size())
{
// This qualifies as an array out of bounds exception. Normally it can only happen when a sector copy is concerned which scripts should not be able to create.
va_list ap;
throw CVMAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid sector", ap);
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid sector");
}
ACTION_RETURN_INT(ndx);
}
//===========================================================================
//
// line_t exports
//
//===========================================================================
DEFINE_ACTION_FUNCTION(_Line, isLinePortal)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_BOOL(self->isLinePortal());
}
DEFINE_ACTION_FUNCTION(_Line, isVisualPortal)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_BOOL(self->isVisualPortal());
}
DEFINE_ACTION_FUNCTION(_Line, getPortalDestination)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_POINTER(self->getPortalDestination());
}
DEFINE_ACTION_FUNCTION(_Line, getPortalAlignment)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_INT(self->getPortalAlignment());
}
DEFINE_ACTION_FUNCTION(_Line, Index)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
unsigned ndx = self->Index();
if (ndx >= level.lines.Size())
{
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid line");
}
ACTION_RETURN_INT(ndx);
}
//===========================================================================
//
//

View File

@ -209,6 +209,9 @@ public:
void MaybePrintMessage();
};
// This must be a separate function because the VC compiler would otherwise allocate memory on the stack for every separate instance of the exception object that may get thrown.
void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...);
enum EVMOpMode
{
MODE_ASHIFT = 0,

View File

@ -44,9 +44,7 @@
extern cycle_t VMCycles[10];
extern int VMCalls[10];
// This must be a separate function because the VC compiler would otherwise allocate memory on the stack for every separate instance of the exception object that may get thrown.
void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...);
// intentionally implemented in a different source file tp prevent inlining.
// intentionally implemented in a different source file to prevent inlining.
void ThrowVMException(VMException *x);
#define IMPLEMENT_VMEXEC

View File

@ -240,6 +240,12 @@ struct Line native
native int locknumber; // [Dusk] lock number for special
native readonly uint portalindex;
native readonly uint portaltransferred;
native bool isLinePortal();
native bool isVisualPortal();
native Line getPortalDestination();
native int getPortalAlignment();
native int Index();
}
struct SecPlane native