Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorsoen
SRB2
Commits
cc4ef3b8
Commit
cc4ef3b8
authored
1 year ago
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Add a branch limit
Clarify why a script was terminated
parent
985a0be2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/acs/environment.cpp
+38
-1
38 additions, 1 deletion
src/acs/environment.cpp
with
38 additions
and
1 deletion
src/acs/environment.cpp
+
38
−
1
View file @
cc4ef3b8
...
@@ -48,6 +48,9 @@ Environment::Environment()
...
@@ -48,6 +48,9 @@ Environment::Environment()
// Not that we're adding any modules to it, though. :p
// Not that we're adding any modules to it, though. :p
global
->
active
=
true
;
global
->
active
=
true
;
// Set the branch limit (same as in ZDoom)
branchLimit
=
2000000
;
// Add the data & function pointers.
// Add the data & function pointers.
// Starting with raw ACS0 codes. I'm using this classic-style
// Starting with raw ACS0 codes. I'm using this classic-style
...
@@ -441,5 +444,39 @@ ACSVM::Word Environment::callSpecImpl
...
@@ -441,5 +444,39 @@ ACSVM::Word Environment::callSpecImpl
void
Environment
::
printKill
(
ACSVM
::
Thread
*
thread
,
ACSVM
::
Word
type
,
ACSVM
::
Word
data
)
void
Environment
::
printKill
(
ACSVM
::
Thread
*
thread
,
ACSVM
::
Word
type
,
ACSVM
::
Word
data
)
{
{
CONS_Alert
(
CONS_ERROR
,
"ACSVM ERROR: Kill %u:%d at %lu
\n
"
,
type
,
data
,
(
thread
->
codePtr
-
thread
->
module
->
codeV
.
data
()
-
1
));
std
::
string
scriptName
;
ACSVM
::
String
*
scriptNamePtr
=
(
thread
->
script
!=
nullptr
)
?
(
thread
->
script
->
name
.
s
)
:
nullptr
;
if
(
scriptNamePtr
&&
scriptNamePtr
->
len
)
scriptName
=
std
::
string
(
scriptNamePtr
->
str
);
else
scriptName
=
std
::
to_string
((
int
)
thread
->
script
->
name
.
i
);
ACSVM
::
KillType
killType
=
static_cast
<
ACSVM
::
KillType
>
(
type
);
if
(
killType
==
ACSVM
::
KillType
::
BranchLimit
)
{
CONS_Alert
(
CONS_ERROR
,
"Terminated runaway script %s
\n
"
,
scriptName
.
c_str
());
return
;
}
else
if
(
killType
==
ACSVM
::
KillType
::
UnknownCode
)
{
CONS_Alert
(
CONS_ERROR
,
"ACSVM ERROR: Unknown opcode %d in script %s
\n
"
,
data
,
scriptName
.
c_str
());
}
else
if
(
killType
==
ACSVM
::
KillType
::
UnknownFunc
)
{
CONS_Alert
(
CONS_ERROR
,
"ACSVM ERROR: Unknown function %d in script %s
\n
"
,
data
,
scriptName
.
c_str
());
}
else
if
(
killType
==
ACSVM
::
KillType
::
OutOfBounds
)
{
CONS_Alert
(
CONS_ERROR
,
"ACSVM ERROR: Jumped to out of bounds location %lu in script %s
\n
"
,
(
thread
->
codePtr
-
thread
->
module
->
codeV
.
data
()
-
1
),
scriptName
.
c_str
());
}
else
{
CONS_Alert
(
CONS_ERROR
,
"ACSVM ERROR: Kill %u:%d at %lu in script %s
\n
"
,
type
,
data
,
(
thread
->
codePtr
-
thread
->
module
->
codeV
.
data
()
-
1
),
scriptName
.
c_str
());
}
CONS_Printf
(
"Script terminated.
\n
"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment