Author Topic: Mod Debugging Help... creating a new system  (Read 1119 times)

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Mod Debugging Help... creating a new system
« on: January 04, 2008, 11:16:43 PM »
I've been working on Genesis for over a week now and I've encountered a bug, For some reason when i create a new system (Currently The Mod Is tied into a Button not on auto as it will be)

The Game randomly crashes back to the desktop the console report (Frontiers console tracker) is empty nothing to indicate the course what i want to know is: is their a way to track this sort of error short of debugging every line of the 4000 odd lines of code... I think its something to do with model loading problem is 60 possible models it "Could" be it would be nice if i could just get some sort of clue as to what it is

Offline Nighthawk

  • |______[o]_|
  • Posts: 750
  • Cookies: 18
Re: Mod Debugging Help... creating a new system
« Reply #1 on: January 05, 2008, 01:33:32 AM »
start by narrowing your search to one model.
call always a single model so you can be sure it's not the loading procedure.
then, if it works, turn to the models to see if one is broken.


Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Mod Debugging Help... creating a new system
« Reply #2 on: January 05, 2008, 07:09:38 AM »
Add this little class to your file where you load your models:
Code: [Select]
# AOP stands for Aspect Oriented Programming, basicly, it's combining aspects
# For other scripters who want to use this, feel free to.
# But beware, the new function must take as it's first parameter the old function
# -MLeo
class AOP:
def __init__(self, oldFunc, newFunc):
self.oldFunc = oldFunc
self.newFunc = newFunc
def __call__(self, *args):
return apply(self.newFunc, (self.oldFunc,) + args)

And then add this:
Code: [Select]
def FuncPrinter(old, strTheModel, *args):
debug("Entering: " + getattr(old, "__name__", str(old)))
debug("Loading: '" + strTheModel + "'")
apply(old, (strTheModel,) + args)
debug("Exiting")

And then wrap your model loading function with the AOP class like this:
Code: [Select]
def oldFunc(....): ....
oldFunc = AOP(oldFunc, FuncPrinter)

The reason I use debug there, is because it's small, and perhaps even more importantly, it's crashproof because it always opens, writes to, and closes the output file.

Also, do note that this assumes that the first argument of the model loading function is the string defining the model path.

If it's a class that's doing the loading then do the following:
Code: [Select]
def MethWriter(old, other, strTheModel, *args):
debug("Entering: " + getattr(old, "__name__", str(old)))
debug("Loading: '" + strTheModel + "'")
apply(old, (other, strTheModel,) + args)
debug("Exiting")
ModelLoaderClass.loadingMethod = AOP(MethWriter, ModelLoaderClass.loadingMethod)
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Mod Debugging Help... creating a new system
« Reply #3 on: January 05, 2008, 09:57:48 AM »
Thanks loads MLeo that should help allot

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Mod Debugging Help... creating a new system
« Reply #4 on: January 05, 2008, 04:16:22 PM »
Mleo Thank you very much the problem was in fact a model loading error i had written the paths incorrectly for the Class L planets instead of ClassL1 it was ClassL2,ClassL3 etc

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Mod Debugging Help... creating a new system
« Reply #5 on: January 05, 2008, 06:04:15 PM »
Mleo Thank you very much the problem was in fact a model loading error i had written the paths incorrectly for the Class L planets instead of ClassL1 it was ClassL2,ClassL3 etc
While the overhead will be neglicable, I do suggest you remove the debugging code (just the one line ;) ) when you are done.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Mod Debugging Help... creating a new system
« Reply #6 on: January 06, 2008, 10:28:11 PM »
Mleo Thank you very much the problem was in fact a model loading error i had written the paths incorrectly for the Class L planets instead of ClassL1 it was ClassL2,ClassL3 etc
While the overhead will be neglicable, I do suggest you remove the debugging code (just the one line ;) ) when you are done.

Already done It thanks Again though MLeo Genesis is now complete....For Now...