Skip to content
Permalink
Browse files

GetProcess(-1) will now return the script pid. GetProcess(0) will not…

… find any script, as before. For this change, script pids had to be constrained to the range of valid signed ints. Please update your .em's and recompile.
  • Loading branch information...
frozenblit committed Sep 30, 2019
1 parent aa9bbd0 commit 818c06af969ee988bbf7ed79e2d5144aef095055
@@ -2,9 +2,15 @@
<ESCRIPT>
<header>
<topic>Latest Core Changes</topic>
<datemodified>09-26-2019</datemodified>
<datemodified>09-30-2019</datemodified>
</header>
<version name="POL100">
<entry>
<date>09-30-2019</date>
<author>Nando:</author>
<change type="Changed">Changed default of GetProcess(pid) from 0 to -1 due to compatibility issues with scripts using CInt()'s result directly.<br/>
PIDs are now enforced to never represent negative numbers. Please update your os.em and recompile your scripts.</change>
</entry>
<entry>
<date>09-26-2019</date>
<author>DevGIB:</author>
@@ -14,7 +14,7 @@
</fileheader>

<function name="GetProcess">
<prototype>GetProcess(pid := 0)</prototype>
<prototype>GetProcess(pid := -1)</prototype>
<parameter name="pid" value="Integer process ID of a script (optional)" />
<explain>Gets a script process object for the given script's PID.</explain>
<explain>If no PID is supplied uses PID of the current script.</explain>
@@ -1,4 +1,7 @@
-- POL100 --
09-30-2019 Nando:
Changed: Changed default of GetProcess(pid) from 0 to -1 due to compatibility issues with scripts using CInt()'s result directly.
PIDs are now enforced to never represent negative numbers. Please update your os.em and recompile your scripts.
09-26-2019 DevGIB:
Added: Script objects now have package member which returns a PackageRef. e.g. script.package.name = "GuildStone".
09-21-2019 Turley:
@@ -324,16 +324,18 @@ unsigned int ScriptScheduler::get_new_pid( UOExecutor* exec )
{
for ( ;; )
{
unsigned int newpid = next_pid++;
if ( newpid < PID_MIN )
newpid = PID_MIN;
unsigned int newpid = next_pid;

// increase next_pid and wrap so it's always within the positive values that fit an int
if ( next_pid == INT_MAX )
next_pid = PID_MIN;
else
++next_pid;

// NOTE: The code below is pessimistic, is there a way to avoid checking the pidlist every time?
// (Nando, 06-Nov-2016)

// newpid=0 should now never happen but leaving this
// check in place for extra code robustness
if ( newpid != 0 && ( pidlist.find( newpid ) == pidlist.end() ) )
if ( pidlist.find( newpid ) == pidlist.end() )
{
pidlist[newpid] = exec;
return newpid;
@@ -151,14 +151,16 @@ BObjectImp* OSExecutorModule::mf_debugger()

BObjectImp* OSExecutorModule::getprocess()
{
unsigned int pid;
int pid; // note that while pid's are unsigned, valid values are forced to fit within a signed
// range
if ( !getParam( 0, pid ) )
return new BError( "Invalid parameter type" );

if ( pid == 0 )
if ( pid == -1 )
{
pid = pid_;
pid = pid_; // get executor's own pid
}

Core::UOExecutor* uoexec;
if ( find_uoexec( pid, &uoexec ) )
return new Core::ScriptExObjImp( uoexec );
@@ -2,7 +2,7 @@ Create_Debug_Context();

// get a process scripting object by PID
// If no PID is supplied will use parent script pid.
GetProcess( pid := 0 );
GetProcess( pid := -1 );

// getpid: get this script's pid
GetPid();

0 comments on commit 818c06a

Please sign in to comment.
You can’t perform that action at this time.