Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer bounds in various places! Does the engine wrap or throw error on too-big family/genus/species/event numbers? And if wrapping, does anyone's code rely on that? #38

Open
PuppyPi opened this issue May 20, 2021 · 6 comments

Comments

@PuppyPi
Copy link

PuppyPi commented May 20, 2021

I'm pretty sure Family is a uint8_t, Genus is a uint8_t, Species is a uint16_t, and Event is a uint16_t, but I could be very wrong about that! Let's say checking those bounds is also part of the question :3

And also negative numbers. I assume those are never allowed, right?! That might even be a syntax error in some places (like SCRP)!

And all this applies to other values too! Like all integer variables with SETV, and storing extra data in ATTR or BHVR (even though only certain bits are actually used—are there more bits? is it okay if there were even more?), and "AVAR OWNR 100", and etc.!

(For clarity and posterity, uint8_t means [0, 255], uint16_t means [0, 65535], and uint32_t means [0, 4294967296], and int32_t means [-2147483648, 2147483647], all including both bounds and everything in between)

So if it doesn't wrap or if it does but wrapping is never relied on by anyone, we can just say "portable CAOS code never uses numbers out of range and never relies on them wrapping" ie "never relies on them being supported and never relies on them being unsupported either!" XD

And then an engine implementation can use bigger bounds (like a uint32_t or an int32_t for all three) if it wanted and still be "standards compliant" by a made-up standard we may or may not decide on XD

@Vermidia
Copy link
Member

I know Species wraps around, so I assume genus and family do too.
integer values for VAxx variables are int32_t, SETVing a variable to over 2147483647 wraps it around, ADDV does so, even SUBV.

Events in scrp also wrap around instead of erroring
AVAR OWNR 100 crashes DS :p
attr is also int32_t(Seems really unnecessary) and just wraps around

@Vermidia
Copy link
Member

Also negatives in Event just wrap around, (Like Event will wrap around if you give it a negative)

@PuppyPi
Copy link
Author

PuppyPi commented May 20, 2021

Awesome, thanks! :D

@ligfx
Copy link

ligfx commented May 21, 2021

Creatures Village has an agent with classifier 999 99 9 in pointer activate stimming norns.cos. It's invisible and listens for mouse down events, then makes the agent under the mouse say "look at me" to all norns in the area. Can anyone confirm if this actually happens? If not, maybe the engine just kills it for being an invalid family number..

Also in Creatures Village, a couple agents in desert flower.cos get created with plane 2147483700 — which is out of bounds for an int32_t. Can anyone check if they actually get created? There are three of them, positioned at (6420, 1925), (6420 1935), and (1852, 1938).

@PuppyPi
Copy link
Author

PuppyPi commented May 21, 2021

Oh great! :D
I always forget about CA/CV!

I wonder if plane is unsigned 32bit?

@Vermidia
Copy link
Member

plne wraps around to negative with that number, but it is signed in DS, so it's either a change or Someone just put a really big number for plane in CV.
Also for the given classifier in DS, it wraps around to 231 99 9, so it is valid, it will need to be tested to see if it does what it says it does though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants