Game Development Community

Required Functions?

by Matt "Mr. Pig" Razza · in Torque Game Engine · 05/22/2007 (6:05 pm) · 14 replies

Does anyone have a list of the functions invoked by the engine (in script) because I keep getting an ": Unknown Command." error. That or a way to find a way to see which command is missing.

Thanks.

#1
05/22/2007 (6:35 pm)
I recommend implementing the getConsoleScopeName() resource
and then changing the function "execute()" in console.cc so that it looks like this:
const char *execute(S32 argc, const char *argv[])
{
   Namespace::Entry *ent;
   StringTableEntry funcName = StringTable->insert(argv[0]);
   ent = Namespace::global()->lookup(funcName);

   if(!ent)
   {
      char nsbuf1[512];
      char nsbuf2[512];
      getConsoleScopeName(nsbuf1, sizeof(nsbuf1), 0);
      getConsoleScopeName(nsbuf2, sizeof(nsbuf2), 1);
      warnf(ConsoleLogEntry::Script, "%s: Unknown command. %s <- %s", argv[0], nsbuf1, nsbuf2);
      return "";
   }
   return ent->execute(argc, argv, &gEvalState);
}

this will give you the last couple script stack frames around the call so you have some context for tracking it down.

you might also want to search for "Unknown command %s" in compiledEval.cc and make it look similar.
#2
05/22/2007 (6:53 pm)
: Unknown command. (no scope) <- (no scope)
: Unknown command. (no scope) <- (no scope)
: Unknown command. (no scope) <- (no scope)
: Unknown command. (no scope) <- (no scope)
: Unknown command. (no scope) <- (no scope)
: Unknown command. (no scope) <- (no scope)
: Unknown command. (no scope) <- (no scope)

Wrrr... doesn't seem to help.

And for those that care (1.5.2 code):
const char *execute(S32 argc, const char *argv[])
{
#ifdef TORQUE_MULTITHREAD
   if(isMainThread())
   {
#endif
   Namespace::Entry *ent;
   StringTableEntry funcName = StringTable->insert(argv[0]);
   ent = Namespace::global()->lookup(funcName);

   if(!ent)
   {
      char nsbuf1[512];
      char nsbuf2[512];
	  Namespace::getScopeName(nsbuf1, sizeof(nsbuf1), 0);
	  Namespace::getScopeName(nsbuf2, sizeof(nsbuf2), 1);
      warnf(ConsoleLogEntry::Script, "%s: Unknown command. %s <- %s", argv[0], nsbuf1, nsbuf2);
      return "";
   }
   return ent->execute(argc, argv, &gEvalState);
#ifdef TORQUE_MULTITHREAD
   }
   else
   {
      SimConsoleThreadExecCallback cb;
      SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(argc, argv, false, &cb);
      Sim::postEvent(Sim::getRootGroup(), evt, Sim::getCurrentTime());
      
      return cb.waitForResult();
   }
#endif
}
#3
05/22/2007 (6:59 pm)
Hm.
it's possible you're exec()ing an empty string ?
#4
05/22/2007 (7:00 pm)
Ps thanks for the 1.5 version.
#5
05/22/2007 (7:03 pm)
I guess it's possible - but I have no idea where it could be.

The error is coming from the const char *execute(S32 argc, const char *argv[]) function and not from compiledEval.cc
#6
05/22/2007 (7:08 pm)
Grep your codebase for "exec(" in all *.cs files.
- a good find-in-files utility is invaluable.
my favorite is visual studio, but there's plenty of others, such as winGrep.
#7
05/22/2007 (7:11 pm)
I was going to say... I'm not running linux :P

I will but general question. Is it possible to exec nothing. I tried it in the console and it said no input file found. I then tried eval as well and it just didn't do anything.
#8
05/22/2007 (8:07 pm)
Good point. i meant eval(), not exec(), and even then you're right that doesn't seem to be a likely culprit.
hmm. well, in that case i'd make a debug build and try breakpointing on the error line.
#9
05/23/2007 (9:54 am)
Why don't you list the TorqueScript section that's getting the error? Hard for us to tell you what's wrong if we don't see what you've typed :)
#10
05/23/2007 (12:21 pm)
@Stephen: That's the problem. I have no idea where the error is coming from. If I knew that, I could fix it. So what me and Orion have been trying to do is find where the error came from.

This idea popped into my head today and I have yet to test it:
There seems to be some correlation between objects/schedules and the error. I think that it's (a) a schedule function is running a command on an object that has been deleted or (b) a schedule function is running an invalid command.

Any ideas on how we could find what schedule/object could be causing the problem?

Functions called by a schedule have no call stack (like I'm seeing with ": Unknown command. (no scope) <- (no scope)").
#11
05/23/2007 (12:32 pm)
Good thinkin Mr Pig. that looks like a real good candidate:
[5/23/07 12:25:53][Inf][General] ==>schedule(100, 0, "echo", "hey");
[5/23/07 12:25:53][Inf][General] hey
[5/23/07 12:25:59][Inf][General] ==>schedule(100, 0, "", "hey");
[5/23/07 12:25:59][Wrn][Script ] : Unknown command. (no scope) <- (no scope)

i'd suggest modifying the schedule console function to include a section like this:
if (argv[3][0] == '[[60c21424a29f9]]')
   {
      char nsbuf1[512];
      char nsbuf2[512];
      getConsoleScopeName(nsbuf1, sizeof(nsbuf1), 0);
      getConsoleScopeName(nsbuf2, sizeof(nsbuf2), 1);
      Con::errorf(ConsoleLogEntry::General,"Schedule: no command. %s <- %s", nsbuf1, nsbuf2);
      return 0;
   }
#12
05/23/2007 (2:14 pm)
Alright! Thanks for testing it for me.
#13
05/23/2007 (6:07 pm)
Thanks much! I got it removed, it was a schedule problem and you're callback code helped me pin-point it.

Great work!
#14
05/23/2007 (7:33 pm)
Sweet.