Bridge Commander Central

BC Forums => BC Technical Support => Solved Problems => Topic started by: Rob Archer on January 04, 2008, 11:16:43 PM

Title: Mod Debugging Help... creating a new system
Post by: Rob Archer 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
Title: Re: Mod Debugging Help... creating a new system
Post by: Nighthawk 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.

Title: Re: Mod Debugging Help... creating a new system
Post by: MLeo 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)
Title: Re: Mod Debugging Help... creating a new system
Post by: Rob Archer on January 05, 2008, 09:57:48 AM
Thanks loads MLeo that should help allot
Title: Re: Mod Debugging Help... creating a new system
Post by: Rob Archer 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
Title: Re: Mod Debugging Help... creating a new system
Post by: MLeo 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.
Title: Re: Mod Debugging Help... creating a new system
Post by: Rob Archer 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...