Author Topic: Blockland crashes when schedule gets called [Solved]  (Read 1772 times)

I've been troubleshooting and debugging this issue for a while now and I've pinpointed it to the part where Blockland crashes. I have a couple functions that get called one after another that talk between the client and the server, but on the last clientCmd function, I schedule a call 2000 ms later to perform a function that sends a command to the server. When that function gets called, Blockland crashes.
I'll post the snips of code and what the console is saying at time of crash.

So the schedule that has the 2000 ms delay and calls "relayFunction" is what we're looking at. (The "UG_addItem" function says that it finishes up in the console, and the crash happens after the 2000 ms has passed, that's how I know it is the "relayFunction" function)
Code: [Select]
lilDebug("clientCmdUG_addItem: Checked spaces");
if(%check)
{
lilDebug("clientCmdUG_addItem: Space was found at ["@%x@","@%y@"]");
schedule(1000,0,"UG_addItem",%itemID,%x,%y);
lilDebug("Set schedule for relayFunction");
schedule(2000,0,"relayFunction");
}

Here is the relayFunction that gets called. (lilDebug is a simple function that echoes if a variable is true)
Code: [Select]
function relayFunction()
{
lilDebug("relayFunction called");
commandToServer("SayHi");
lilDebug("relayFunction ending");
}

The serverCmd that gets called. Extremely simple, nothing should go wrong.
Code: [Select]
function serverCmdSayHi(%client)
{
announce(%client.getPlayerName()@" says hi!");
}

Here is the console.log part just before crash:
Code: [Select]
Entering lilDebug(Set schedule for relayFunction)
      Set schedule for relayFunction
   Leaving lilDebug() - return
Leaving clientCmdUG_AddItem() - return
Entering UG_addItem(0:04:08, 1, 2)
   [This is unnecessary code within UG_addItem that will just clutter]
   Entering lilDebug(UG_addItem: Finishing up function)
      UG_addItem: Finishing up function
   Leaving lilDebug() - return
Leaving UG_addItem() - return
Entering relayFunction()
   Entering lilDebug(relayFunction called)
      relayFunction called
And that is where Blockland crashes. So the relay function gets called after the 2000 ms, but it never actually processes the serverCmd it should be calling.


So one thought that comes to mind, would be that it might be a Mac instability issue. My BL has been known to crash when many things happen at once or something similar, but those with the Windows version didn't. So maybe try running a similar script? Or maybe you see an issue my syntax? Or a blatant error I made? Thanks for any attempts at helping
« Last Edit: July 02, 2012, 02:18:56 AM by lilboarder32 »

It should be commandToServer('sayHi'); instead of commandToServer("sayHi");

It should be commandToServer('sayHi'); instead of commandToServer("sayHi");

That would be the entire issue.

That would be the entire issue.

Yes sir, it sure would be.

It should be commandToServer('sayHi'); instead of commandToServer("sayHi");
I love you.
That would be the entire issue.
And I love you.

That fixed everything. Wow, so simple

So what is exactly the difference between a tagged string and a regular string? Or maybe point me to a reference I can read about it?

It works a lot like Ruby's symbol system. Regular strings (using ") are just an array of character values and when they are sent (e.g. in commandToServer) the entire array of data is sent of each time. Tagged strings (using ') are assigned an unique ID and are only transferred once. In other words, commandToServer("sayHi"); sends the entire "sayHi" string each time whereas using a tagged string only sends it the first time.

As to why that crashes, I'm not sure.

Maybe a recursive loop or something.

I hate those things.

As to why that crashes, I'm not sure.

Torque * crashes when using a non-tagged string as a script command name. I don't know why, ask kompressor.

It works a lot like Ruby's symbol system. Regular strings (using ") are just an array of character values and when they are sent (e.g. in commandToServer) the entire array of data is sent of each time. Tagged strings (using ') are assigned an unique ID and are only transferred once. In other words, commandToServer("sayHi"); sends the entire "sayHi" string each time whereas using a tagged string only sends it the first time.

As to why that crashes, I'm not sure.
So if I call commandToServer('sayHi'), it sends the string "sayHi" once so that if I call that function again separately, it already has that string stored?
What does that look like in a script, or can do they benefit me in a way I can utilize?

It works a lot like Ruby's symbol system. Regular strings (using ") are just an array of character values and when they are sent (e.g. in commandToServer) the entire array of data is sent of each time. Tagged strings (using ') are assigned an unique ID and are only transferred once. In other words, commandToServer("sayHi"); sends the entire "sayHi" string each time whereas using a tagged string only sends it the first time.

As to why that crashes, I'm not sure.
Well, except for that Ruby hides the whole thing. I'd say it's more like Scala which has a special Symbol class; you make use symbols with 'mysymbol (the Ruby equivalent is :mysymbol and the TS tagged string equivalent is 'mysymbol').

So if I call commandToServer('sayHi'), it sends the string "sayHi" once so that if I call that function again separately, it already has that string stored?
Yes.
What does that look like in a script, or can do they benefit me in a way I can utilize?
They're pretty much pointless in Torque unless you're doing networking, or if you're storing large amounts of the same string.

Code: [Select]
for(%i = 0; %i < 1000; %i++)
    $blah[%i] = 'reallllyyyy long string that would take up a lot of space if there were lots of these in an array';

It would only store the string once and the rest would keep a reference to a unique ID, saving space. But you'd have to use `detag` in order to get the contents of the string.

Yes.They're pretty much pointless in Torque unless you're doing networking, or if you're storing large amounts of the same string.

Code: [Select]
for(%i = 0; %i < 1000; %i++)
    $blah[%i] = 'reallllyyyy long string that would take up a lot of space if there were lots of these in an array';

It would only store the string once and the rest would keep a reference to a unique ID, saving space. But you'd have to use `detag` in order to get the contents of the string.
Got it, thanks.