[ZScript] Invalid Sprite Number when setting sprite directly

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ZScript] Invalid Sprite Number when setting sprite directly

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Graf Zahl » Tue May 09, 2017 10:37 am

You only need one state with the A frame. If a sprite gets referenced, all frames will be initialized, even if only one gets used.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Major Cooke » Tue May 09, 2017 7:32 am

Well the easiest way to combat this is to have a state where the actor never jumps to -- or a dummy actor -- which has all the sprites and frames, as Xaser and I discovered:

Code: Select all

Dummy:
ZOMB ABCDEFGHIJKLMNOPQRSTUVWXYZ 0;
ZOMC ABCDEFGHIJKLMNOPQRSTUVWXYZ 0;
That works well enough in the mean time, for anyone else who might be encountering this issue.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Graf Zahl » Thu Dec 08, 2016 2:06 pm

Yes. I made the change in GZDoom but didn't realize that the file contained modifications before pushing directly to the ZDoom repo.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Edward-san » Thu Dec 08, 2016 1:38 pm

Graf, this commit (related to this thread it seems) breaks compilation because of gl_InitModels not being defined anywhere. Accidental change?

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Xaser » Thu Dec 08, 2016 12:43 pm

Welp, sure enough. I need to commit "4294967295" to memory at some point.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Graf Zahl » Thu Dec 08, 2016 12:39 pm

It returns -1 if it can't find a sprite name in the list.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Xaser » Thu Dec 08, 2016 12:36 pm

Underastandable. Is there (or could we have) a reliable way to check if GetSpriteIndex returns something valid so we can safeguard it in-script?

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Graf Zahl » Thu Dec 08, 2016 12:16 pm

Currently the sprite setup works by walking through the list of used sprites and then collecting all data for each. The entire algorithm is designed to do this once at game start, so in its current state it cannot retroactively add new sprite names at run time.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Graf Zahl » Wed Dec 07, 2016 3:19 am

I have to check if adding new indices at runtime is feasible. It depends on how the initialization works.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Major Cooke » Wed Dec 07, 2016 12:04 am

Just like voxeldef then. Alright. Good to know.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Xaser » Tue Dec 06, 2016 10:40 pm

It works flawlessly if you have a BALX somewhere on some state (any actor, anywhere... so long as the wad's loaded of course :P ). Means this isn't a showstopper, fortunately, though crashes are no fun.

Re: [ZScript] Invalid Sprite Number when setting sprite dire

by Major Cooke » Tue Dec 06, 2016 9:21 pm

I disagree about it being a don't do that deal. Just seems like the sprite's not being buffered properly.

I'm curious, if you add a simple unused state with all the BALX sprites that's never reached, does it continue throwing feces at your log like an angry chimp?

I ask this because Voxeldef bitches whenever you don't have a sprite to pair it up to. I'm thinking that could be the same thing, in a manner of speaking.

[ZScript] Invalid Sprite Number when setting sprite directly

by Xaser » Tue Dec 06, 2016 8:25 pm

Stumbled across some undefined behavior while tinkering with this idea. If you directly actor's sprite property in a function (via passing a sprite name to GetSpriteIndex) to any sprite that isn't used somewhere on an actor state, GetSpriteIndex returns junk. This results in "invalid sprite number" console spam in the software renderer and a crash in GL.

A rather silly test:
setSpriteError.pk3
(814 Bytes) Downloaded 194 times
Summon "GoodSprite" and you'll see a Doom Imp ball. Summon "BadSprite" and you'll see "R_ProjectSprite: invalid sprite number 4294967295" spammed to the console (or a good ol' crash). The only difference between the two actors are the parameters to GetSpriteIndex -- "BAL1" on the former and "BALX" (a custom sprite included in the pk3, used nowhere else) on the latter.

Possibly a [Don't do that], but let's find out. :P

Top