UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: Scobalula on November 22, 2015, 09:47:12 am

Title: Script Stack Overflow.
Post by: Scobalula on November 22, 2015, 09:47:12 am
Started a new map recently, and I am that type of person that wants to remove those SRE's even in developer (as you got from my last thread about this lol), since my knowledge has increased I can fix most them no problem, but this one is bugging me.

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FiKi8xMh.jpg&hash=0bec122a3799bb0b44ddfc0fc65b17b2dc0c200a)


Here's the part of the logfile about it:

http://hastebin.com/loresebece.md (http://hastebin.com/loresebece.md)

If you want the script it's a stock _zombiemode_spawner.gsc, mine did have modifications by me for Harry perks, but they made no difference, since a stock file does the same thing.

From what I've gathered overflow = too much? I would appreciate help, as I do need developer 1/2 for other debugging, etc. :P
Title: Re: Script Stack Overflow.
Post by: DidUknowiPwn on November 22, 2015, 05:53:31 pm
Function is stuck there and it keeps repeating that function.
Title: Re: Script Stack Overflow.
Post by: daedra descent on November 22, 2015, 06:23:16 pm
Was going to tell you to post your code but the function but then i looked at the function and realised that Treyarch called the same function inside itself.  :poker:

Code Snippet
Plaintext
is_spawner_targeted_by_blocker( ent )
{
if( IsDefined( ent.targetname ) )
{
targeters = GetEntArray( ent.targetname, "target" );

for( i = 0; i < targeters.size; i++ )
{
if( targeters[i].targetname == "zombie_door" || targeters[i].targetname == "zombie_debris" )
{
return true;
}

result = is_spawner_targeted_by_blocker( targeters[i] );
if( result )
{
return true;
}
}
}

return false;
}

That logic. Holy crap.  :o
Title: Re: Script Stack Overflow.
Post by: DidUknowiPwn on November 22, 2015, 06:26:46 pm
You can do that.
This method is called recursive functions:
http://pages.cs.wisc.edu/~calvin/cs110/RECURSION.html (http://pages.cs.wisc.edu/~calvin/cs110/RECURSION.html)
Title: Re: Script Stack Overflow.
Post by: daedra descent on November 22, 2015, 06:32:13 pm
You can do that.
This method is called recursive functions: http://pages.cs.wisc.edu/~calvin/cs110/RECURSION.html (http://pages.cs.wisc.edu/~calvin/cs110/RECURSION.html)

Can? Sure. Should they have in this instance? No, because it doesn't help in any shape or form. If the spawner isn't targeted by a blocker then it won't magically be true when you call the function again.

I recommend complete removing this:

Code Snippet
Plaintext
			result = is_spawner_targeted_by_blocker( targeters[i] );
if( result )
{
return true;
}

Edit: just to clarify, the reason this is happening all of a sudden is probably because a spawner is being targeted by an entity that isn't a blocker.
Title: Re: Script Stack Overflow.
Post by: DidUknowiPwn on November 22, 2015, 06:35:04 pm
DO NOT REMOVE IT.

It's necessary, fix your funky code.

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FnVu6JKo.png&hash=df55ce3c0ca1b043e7df542380fa989a603a0022)
That's bo2's as you can see it's recursive.
Title: Re: Script Stack Overflow.
Post by: daedra descent on November 22, 2015, 06:46:02 pm
Quote
DO NOT REMOVE IT.

That is the issue. Its a bad recursive call because of Treyarch's shitty logic. The function knows that the spawner is being targeted by something but it isn't a blocker so it does a recursive call, which then repeats again and again until it causes a runtime error.

Script instance 1(first call):
Spawner is targeted by something, not a debris, run logic again(recursive call)

Script instance 2:
Spawner is targeted by something, not a debris, run logic again(recursive call)

Script instance 3:
Spawner is targeted by something, not a debris, run logic again(recursive call)

Script instance 4:
Spawner is targeted by something, not a debris, run logic again(recursive call)

etc. Its a never ending spiral of shitty logic by Treyarch.
Title: Re: Script Stack Overflow.
Post by: Soy-Yo on November 22, 2015, 07:19:33 pm
That is the issue. Its a bad recursive call because of Treyarch's shitty logic. The function knows that the spawner is being targeted by something but it isn't a blocker so it does a recursive call, which then repeats again and again until it causes a runtime error.

Script instance 1(first call):
Spawner is targeted by something, not a debris, run logic again(recursive call)

Script instance 2:
Spawner is targeted by something, not a debris, run logic again(recursive call)

Script instance 3:
Spawner is targeted by something, not a debris, run logic again(recursive call)

Script instance 4:
Spawner is targeted by something, not a debris, run logic again(recursive call)

etc. Its a never ending spiral of shitty logic by Treyarch.
The function is not called on the same entity every time. The first call is on the entity; the second, on one of the entity targeters; the third, on one of the targeters' targerters; etc.
Title: Re: Script Stack Overflow.
Post by: daedra descent on November 22, 2015, 07:26:02 pm
The function is not called on the same entity every time. The first call is on the entity; the second, on one of the entity targeters; the third, on one of the targeters' targerters; etc.

Nope. The targetname, how the function gets the array of entities, of the ent would be the same, so its actually getting the same array of entities every time.   :poker:

Title: Re: Script Stack Overflow.
Post by: Scobalula on November 22, 2015, 07:36:44 pm
I'll try removing that, in the off chance it works, however if it doesn't work, how much of an effect would this have on the map? Like I said I only get that error with developer 1/2 enabled, but if it doesn't effect normal game (which I haven't seen a major effect, but I don't want to release only for there to be issues) then I can debug any other scripts in another small map which doesn't give the error.
Title: Re: Script Stack Overflow.
Post by: Soy-Yo on November 22, 2015, 07:40:08 pm
Nope. The targetname, how the function gets the array of entities, of the ent would be the same, so its actually getting the same array of entities every time.   :poker:
Code Snippet
Plaintext
targeters = GetEntArray( ent.targetname, "target" );
Let's say the initial ent has targetname - A, so in this line targeters is getting the array of entities that are targeting "A". I mean, it's getting all the ents with the KVP target - A because "A" is the targetname of the first entity.
Then, unless one entity is targeting itself, it should be aright.
Hope I explained it clearly. :D