Command Stack usage in GMS
#21
Posted 21 May 2012 - 11:56 PM
#22
Posted 25 May 2012 - 04:08 PM
>>Until you can give a succinct example that exhibits the problem I cannot wade through all this code.
Basically they are asking us to debug their problem for them. In a way, they don't really have a choice in the matter. However I would have liked for them to have said something like
>>We ran it on all the machines we have and it works fine so like you said it's a difficult problem to resolve
A little less "Not our problem" slap in the face.
So it's up to the people that have the problem to try to pin point what the cause is.
I suggest you do what I said in post 11
and for all the user commands, like PatrolTo, you simply do a
show_debug_message("ScriptName"); return 1;
this will at least eliminate any user code problems from the equation. You said the problem is in CommandsPerform. so if you could narrow it dow by putting more show_debug message...
show_debug_message("CommandsPerform ENTER")
show_debug_message("CommandsPerform CHECK1")
if(m_cmdstkscripts = -100) return 0;
if(m_cmdstkdata = -100) return 0;
if(m_cmdlstscripts = -100) return 0;
if(m_cmdlstdata = -100) return 0;
//Call this in your step event
//you may check the return code
//wich will be 0 when all commands have run
//in oder to re-add the default behaviour of your AI.
//if(!CommandsPerform())
//{
// CommandListAdd(PatrolToXY,...);
//}
show_debug_message("CommandsPerform CHECK2")
if(!ds_stack_size(m_cmdstkscripts))
{
show_debug_message("CommandsPerform CHECK2.1")
if(!ds_list_size(m_cmdlstscripts)) return 0;
show_debug_message("CommandsPerform CHECK2.2")
if(!ds_list_size(m_cmdlstdata)) return 0;
show_debug_message("CommandsPerform CHECK2.3")
ds_stack_push(m_cmdstkscripts,ds_list_find_value(m_cmdlstscripts,0));
show_debug_message("CommandsPerform CHECK2.4")
ds_stack_push(m_cmdstkdata,ds_list_find_value(m_cmdlstdata,0));
show_debug_message("CommandsPerform CHECK2.5")
if(ds_list_size(m_cmdlstscripts))
ds_list_delete(m_cmdlstscripts,0);
show_debug_message("CommandsPerform CHECK2.6")
if(ds_list_size(m_cmdlstdata))
ds_list_delete(m_cmdlstdata,0);
}
var data;
show_debug_message("CommandsPerform CHECK3")
if(!ds_stack_size(m_cmdstkdata)) return 0;
show_debug_message("CommandsPerform CHECK4")
if(!ds_stack_size(m_cmdstkscripts)) return 0;
show_debug_message("CommandsPerform CHECK5")
data = ds_stack_top(m_cmdstkdata);
var res;
show_debug_message("CommandsPerform CHECK6" + script_get_name(ds_stack_top(m_cmdstkscripts)))
res = script_execute(ds_stack_top(m_cmdstkscripts), data)
data.action = 3;
if (res = 0) return 1;
show_debug_message("CommandsPerform CHECK6")
CommandStackPop();
show_debug_message("CommandsPerform CHECK7")
if(res = -1) return CommandsPerform();
show_debug_message("CommandsPerform EXIT")
return 1;
#23
Posted 25 May 2012 - 08:47 PM
Perhaps we should compare environments/setups between with working/non working users. I have two main PC's (A laptop and a desktop) Both are win7-x64 (one ultimate/one premium) Both have the latest Dx and VB runtimes installed for game usage. Both are nvidia based graphically. This run on neither machine.
I'm going to start adding the debug lines to the stock version of Commandstack since I don't want any problems with my projects diluting the results.
#24
Posted 25 May 2012 - 09:07 PM
"
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6DriveToXY
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6DriveToXY"
rinse and repeat
#25
Posted 25 May 2012 - 09:13 PM
We've said before, this is a new runner, and the order of things have changed. This means old stuff may not work. This is not a bug. It's just the way things now work.
However... if you can point to a specific place, with a specific bug, we'll happily fix it. But asking us to debug a large system simply isn't going to happen, and I'm amazed you think it would.
We're not saying there's no bug, we're saying there's too much code for use to debug in a reasonable time frame. The elements listed are used by us and MANY others properly, so we have no reason to believe they are fault. That said, edge cases can ALWAYS happen, but for this to be found, you need specific cases, not a general "this doesn't work". Find the edge case, and we'll fix it.
#26
Posted 25 May 2012 - 10:55 PM
I can only assume since it was deemed 'no example, not reproducible' that the code works as described in your systems. The very fact that the same code does NOT behave identically with a given runner on different systems should be a major red flag. Were this a question of one system or user having this occur the course of action would be so much simpler.
Edited by lordvtp, 25 May 2012 - 10:56 PM.
#27
Posted 25 May 2012 - 11:00 PM
Perhaps you can peruse discretely as I remote debug this thing. See what someone with 20+ years experience in debugging can do....
@lordvtp. OK, I'm doing this drunk so bare with me...
Your output is promising, at least it shows it's not locked and it's actually doing something and that is good. This shows the program at least finds a script to run (MoveToXY)... And since you say the AIs don't move then at least we are almost on the verge to finding the problem
The problem must be arround this code or in MoveToXY itself
data = ds_stack_top(m_cmdstkdata);
show_debug_message("CommandsPerform CHECK6" + script_get_name(ds_stack_top(m_cmdstkscripts)))
IT GOT THIS FARadd this right after
show_debug_message("CommandsPerform CHECK6.2 data is" + string(data))
but did it execute THIS!??
res = script_execute(ds_stack_top(m_cmdstkscripts), data)add right after
show_debug_message("CommandsPerform CHECK7 " + script_get_name(ds_stack_top(m_cmdstkscripts)) + " returns " + string(res))
to see if the code proceeds on after the call and to see if res is set to the return specified by the call
I assume you did not put
show_debug_message("MoveToXY ENTER")
at the top of the MoveToXY script as I said in my other post, because we should see a
MoveToXY ENTER entry in the debug output... If you did add it then the problem is definitely on the
res = script_execute(ds_stack_top(m_cmdstkscripts), data)line.
Anyway, for now, here is the movetoXY debug version...
show_debug_message(" MoveToXY ENTER")
//CommandStackPush (MoveToXY, destx, desty, speed)
//This command will move to the destination point,
//it will slow down when it gets close to the destination if
//the speed would make it jump over the destiantion and then stop
//data.arg1 = x;
//data.adr2 = y;
//data.arg3 = speed;
//return 0 when not done, 1 when done, -1 when done and hurge to proceed with the next event right away
//A data objects is provided to store your information for the command
var data;
data = argument0;
//A flag tells you if you are initializing,
//starting the action,
//continuing the action
//or done with the command
if(data.action = 0) //pushed (added to stack)
{
show_debug_message(" MoveToXY Push, data is : " + string(data))
//init vars/create stuff
data.TargetX = data.arg1;
data.TargetY = data.arg2;
data.MoveSpeed = data.arg3;
show_debug_message(" MoveToXY Push EXIT with 1"))
return 1;
}
else if(data.action = 1) //poped (removed from stack)
{
//done... free stuff
show_debug_message(" MoveToXY Pop EXIT with 1"))
return 1;// done
}
else if(data.action = 2) //first actual "perform the action" call
{
//start performing
show_debug_message(" MoveToXY Start Perform Command"))
}
else if(data.action = 3) //subsequent call
{
//keep performing
show_debug_message(" MoveToXY Still Perform Command"))
}
//start/keep performing it is then...
pd = point_distance(x,y,data.TargetX,data.TargetY);
show_debug_message(" MoveToXY Distance is " + string(pd)))
if(pd = 0)
{
speed = 0;
show_debug_message(" MoveToXY Distance Reached, EXIT return -1")
return -1;
}
show_debug_message(" MoveToXY move_towards_point at speed " + string(min(data.MoveSpeed,pd)))
move_towards_point(data.TargetX,data.TargetY, min(data.MoveSpeed,pd));
show_debug_message(" MoveToXY EXIT return 0")
return 0;// not done
Please report back with the new output. This should show if script execute is working, if the data instance is valid, if the arguments are passed, if the return is passed on, if the point_distance is working....
I appreciate your help on this
#28
Posted 25 May 2012 - 11:16 PM
Output is identical to before! none of the new debug msgs show up!
#29
Posted 26 May 2012 - 04:01 AM
OK, now double check by calling the script directly...
change
res = script_execute(ds_stack_top(m_cmdstkscripts), data)
to
res = MoveToXY(data);
then to
res = script_execute(MoveToXY,data);
See if one of them works calling the MoveToXY
I'm starting to suspect script_execute a little....
data could also be the cause...
If I'm right you should see the debug messages in the first change but not after the second change
[edit] typos and code changes
#30
Posted 26 May 2012 - 04:13 AM
When Doing res = MoveToXY(data);
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6PatrolToXY"
MoveToXY ENTER
MoveToXYStill Perfom Command
MoveToXY Distance is 390.61
MoveToXY move_towards_point at speed 0
MoveToXY EXIT return 0
When Doing - res = script_execute(data);
ERROR in
action number 1
of Step Event0
for object EnemyAIObj:
Trying to execute non-existing script.
I state again that I have changed no other code or scripts then you have specified!
#31
Posted 26 May 2012 - 04:23 AM
2nd change
res = script_execute(MoveToXY,data);
#32
Posted 26 May 2012 - 04:36 AM
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6PatrolToXY"
MoveToXY ENTER
MoveToXYStill Perfom Command
MoveToXY Distance is 390.61
MoveToXY move_towards_point at speed 0
MoveToXY EXIT return 0
When Doing - res = script_execute(MoveToXY,data);
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6PatrolToXY"
MoveToXY ENTER
MoveToXYStill Perfom Command
MoveToXY Distance is 390.61
MoveToXY move_towards_point at speed 0
MoveToXY EXIT return 0
As you see now both now have same effect (and still no motion lol)
BTW I should note that you are a saint for doing this!
#33
Posted 26 May 2012 - 05:11 AM
OK, well still a few things to eliminate.
We know MoveToXY is called, though it's odd it was not called before. If you remember you got the name from script on the stack from seeing
CommandsPerform CHECK6PatrolToXY
Yet is was not called at that point. But calling it directly works, calling it with script_execute worked. but why the hell not from
res = script_execute(ds_stack_top(m_cmdstkscripts), data)
change
var res;
show_debug_message("CommandsPerform CHECK6" + script_get_name(ds_stack_top(m_cmdstkscripts)))
res = script_execute(ds_stack_top(m_cmdstkscripts), data)
show_debug_message("CommandsPerform CHECK7 " + script_get_name(ds_stack_top(m_cmdstkscripts)) + " returns " + string(res))
to
var fn; fn = ds_stack_top(m_cmdstkscripts);
var res;
show_debug_message("CommandsPerform CHECK6" + script_get_name(fn))
res = script_execute(fn, data)
show_debug_message("CommandsPerform CHECK7 " + script_get_name(fn) + " returns " + string(res))
then to
var fn; fn = MoveToXY;
var res;
show_debug_message("CommandsPerform CHECK6" + script_get_name(fn))
res = script_execute(fn, data)
show_debug_message("CommandsPerform CHECK7 " + script_get_name(fn) + " returns " + string(res))
I mean it's really screwy...
Also you AI should have moved, you see, data holds the speed as an argument inside 2 data instance variable to travel and seeing "at speed 0" tells me data is wrong.
Hey, wait, I though there was debug messages for data in bot the CommandPerform and the MovetoXY!?
Post 27, add
show_debug_message("CommandsPerform CHECK6.2.2 data is" + string(data))
right before the
res = script_execute
call
change
show_debug_message(" MoveToXY Enter" + string(data))
to
show_debug_message(" MoveToXY Enter" + string(data))
show_debug_message(" MoveToXY Push, data is : " + string(data))
There are other functions involved in the system. Eh, wait a minute.... The demo is on demo room0... it uses EnemyAI and SimpleAI objects. they use DriveToXY, not MoveToXY... so why is MoveToXY even Called?
This is familiar problems when having stack faults....
Add this in CommandStackPush script
show_debug_message("CommandStackPush ScriptIndex: " + string(argument0));
show_debug_message("CommandStackPush ScriptIndex: " + script_get_name(argument0));
and this int CommandsPerform
before the script_execute call
show_debug_message("CommandsPerform ScriptIndex: " + string(ds_stack_top(m_cmdstkscripts)));
show_debug_message("CommandsPerform ScriptIndex: " + script_get_name(ds_stack_top(m_cmdstkscripts)));
the 2 new debug entries should display the same script value
the 2 new entries should display the same script index and the same script name...
#34
Posted 26 May 2012 - 05:44 AM
var fn; fn = ds_stack_top(m_cmdstkscripts);
var res;
show_debug_message("CommandsPerform CHECK6" + script_get_name(fn))
res = script_execute(fn, data)
show_debug_message("CommandsPerform CHECK7 " + script_get_name(fn) + " returns " + string(res))
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6PatrolToXY
CommandsPerform CHECK7PatrolToXY returns 0
When
var fn; fn = MoveToXY;
var res;
show_debug_message("CommandsPerform CHECK6" + script_get_name(fn))
res = script_execute(fn, data)
show_debug_message("CommandsPerform CHECK7 " + script_get_name(fn) + " returns " + string(res))
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6PatrolToXY"
MoveToXY ENTER
MoveToXYStill Perfom Command
MoveToXY Distance is 390.61
MoveToXY move_towards_point at speed 0
MoveToXY EXIT return 0
CommandsPerform CHECK7PatrolToXY returns 0
Changes as per post 27 are in effect in, no debug msg from data there...
And when ALL the changes you listed are made
FATAL ERROR in
action number 1
of Step Event0
for object EnemyAIObj:
############################################################################################
VMError!! Occurred - Push :: Execution Error - Variable Get data
at gml_Script_MoveToXY (line 0) - show_debug_message(" MoveToXY Enter" + string(data))
############################################################################################
Self Variables :
100008( m_cmdstkscripts ) = 16.000000
100009( m_cmdstkdata ) = 17.000000
100010( m_cmdlstscripts ) = 16.000000
100011( m_cmdlstdata ) = 17.000000
#35
Posted 27 May 2012 - 01:27 AM
can you do a
show_debug_message(string(MoveToXY))
show_debug_message(string(PatrolToXY))
they may be the same value. which means the script loading in GM Studio screwed up setting the script_index for both script as the same value....
#36
Posted 27 May 2012 - 05:11 AM
CommandsPerform ENTER
CommandsPerform CHECK1
CommandsPerform CHECK2
CommandsPerform CHECK3
CommandsPerform CHECK4
CommandsPerform CHECK5
CommandsPerform CHECK6MoveToXY
CommandsPerformCHECK6.2.2 data is100064
CommandsPerform ScriptIndex: 17
CommandsPerform ScriptIndex: PatrolToXY
15
MoveToXY ENTER100064
MoveToXY Push,data is :100064
MoveToXYStill Perfom Command
MoveToXY Distance is 390.61
MoveToXY move_towards_point at speed 0
MoveToXY EXIT return 0
CommandsPerform CHECK7MoveToXY returns 0
So I gota ask, If distance > 0 as per -
pd = point_distance(x,y,data.TargetX,data.TargetY);
show_debug_message(" MoveToXY Distance is " + string(pd))
if(pd = 0)
{
speed = 0;
return -1;
}
Why do I see - MoveToXY move_towards_point at speed 0 ?
#37
Posted 27 May 2012 - 05:16 AM
data.MoveSpeed = 5;
near the end of MoveToXY and sure enough the onscreen objects now moved! (at 5 lol); therefore....
why isnt "data.MoveSpeed = data.arg3;" working as desired?
#38
Posted 27 May 2012 - 05:39 AM
#39
Posted 27 May 2012 - 03:53 PM
#40
Posted 28 May 2012 - 02:57 AM
http://www.host-a.net/u/icuurd12b42/commandstackdebug.gmk
Import it in Studio, run it, say 1 when it asks for the number of AIS
You will have 2 instances running, the red and the blue. Here is the expected output...
100001 IN CommandsCreate 100001 OUT CommandsCreate 100015 IN CommandsCreate 100015 OUT CommandsCreate 100001 IN CommandsPerform 100001 OUT CommandsPerform 100001 IN CommandStackPush 100001 IN PatrolToXY 100001 OUT PatrolToXY 100001 OUT CommandStackPush 100015 IN CommandsPerform 100015 OUT CommandsPerform 100015 IN CommandStackPush 100015 IN DriveToXY 100015 OUT DriveToXY 100015 OUT CommandStackPush 100001 IN CommandsPerform 100001 IN PatrolToXY 100001 OUT PatrolToXY 100001 OUT CommandsPerform 100015 IN CommandsPerform 100015 IN DriveToXY 100015 OUT DriveToXY 100015 OUT CommandsPerform 100001 IN CommandsPerform 100001 IN PatrolToXY 100001 OUT PatrolToXY 100001 OUT CommandsPerform
and on and on
I will update the gmk with new debug info when you report back
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











