GetProcess issue

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
ThisIsMe
Distro Developer
Posts: 82
Joined: Sun Jul 17, 2016 1:29 am
Contact:

GetProcess issue

Post by ThisIsMe » Sat Sep 28, 2019 11:58 pm

So not sure where to put this but since it is a friendly advisory I thought I might post, if you are using GetProcess and running the core version built on or after 08-21-2019, there is an issue with GetProcess, I will splain.

Code: Select all

var pid := CInt(GetObjProperty(mobile, "#TimerControlPID"));
var process := GetProcess( pid );
In this example you have two variables, pid and process.

pid is looking to grab a cprop off the character, "#TimerControlPID" and using the CInt function will return the integer value of that cprop. Then you have process, which uses the GetProcess function to grab a script process using the pid variable. Simple and should work 100% of the time and it does, except what I can only speculate as unforeseen consequences have arisen!

In the event that in this case GetObjProperty does not find the "#TimerControlPID" property on the mobile and because it has been wrapped in the loving arms of CInt, the variable pid becomes equal to 0. When this is then passed onto GetProcess because pid is equal to 0, the GetProcess function returns the process id of the currently running script instead of an error or some other such nonsense.

I have written to Dev via Discord with the problem and while I am not too certain if my solution would be feasible, because GetProcess' default parameter of pid is equal to 0, in cases such as I describe above (and this was not a lone isolated instance mind you) instead of being equal to 0, it be changed equal to -1. This is generally what I do if I have a function with a default value on a parameter and I know the parameter would never be lesser than 0 and unfortunately or fortunately with the way CInt works, a failed conversion of an object returns 0, this could be something worth doing since CInt would be a much more laborious, tedious function to "fix" to change it's behavior. I am also speculating that a process id would or should never be lesser than 0 so at any rate, I leave you with this tale of woe and something new for the POL-Boffins to fix.

Yukiko
Distro Developer
Posts: 2688
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: GetProcess issue

Post by Yukiko » Sun Sep 29, 2019 9:21 am

This was an issue with a function in the timedScripts package in the Modern Distro which ThisIsMe found, and fixed. The timedScripts pkg is the core for all "buffs", for both the effects and the display of the icons.

I was trying to get poisoning to work property and I discovered that drinking a poison potion did nothing. After racking my brain trying to figure this out, I decided that a second set of eyes, and a second brain from a superior programmer would help. So I asked ThisIsMe for help. After finding the problem he was prompted to warn others by his post.

Nando
POL Developer
Posts: 261
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: GetProcess issue

Post by Nando » Mon Sep 30, 2019 1:50 pm

It should be fixed in the latest commit.

Yukiko
Distro Developer
Posts: 2688
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: GetProcess issue

Post by Yukiko » Mon Sep 30, 2019 5:34 pm

Thanks Nando!

DevGIB
Grandmaster Poster
Posts: 231
Joined: Mon Feb 06, 2006 6:12 am

Re: GetProcess issue

Post by DevGIB » Sat Oct 05, 2019 6:58 am

just as an idea aswell. the script should probably error check if the global prop exists.

Post Reply