Package problem
by Buzztime Entertainment Inc. · in Torque Game Engine · 08/19/2008 (4:48 pm) · 0 replies
Hi All,
I am using TGB to develop a game.
There is an old thread from 4 years ago that describes some problems with packages where function names don't seem to get resolved properly after deactivatePackage calls. I read through these threads, but didn't find that they have been resolved. I too am having problems and was wondering what the current status of these package issues is with the rest of you.
My problem has what may be a different twist. What I am finding is that functions that reference another function that is being overloaded by package changes, are not calling the correct version of the overridden function. Here is some sample code and resulting output to demonstrate what I'm talking about:
and the output:
Please note that I intensionally call the function when there should be no active function yet, before any packages are activated and after they have all been deactivated.
What is shown here is that the function indirectCallToFoo() starts out ok. At first it has no linkage to foo(), then once the first package is activated, its link is properly set. But after that it is no longer updated and remains pointing to PackageA::foo().
I don't believe that this could possibly be the intended behavior of the package system. But I'm also puzzled that here we are 4 years after the last posts on the matter and it's hard to believe that these problems still exist. Is no one else using the package feature?
I did try the script package replacement code posted in the previous thread about this problem, but saw the same results. That code focuses only on the management of the packages in the package stack, but not on the issue of updating the links of the code that calls these overridden functions.
Has anyone else seen this problem? Is there some updated engine code that fixes this?
If there is no fix, then I will change to a non-package approach. Easy enough.
Thanks,
Craig
I am using TGB to develop a game.
There is an old thread from 4 years ago that describes some problems with packages where function names don't seem to get resolved properly after deactivatePackage calls. I read through these threads, but didn't find that they have been resolved. I too am having problems and was wondering what the current status of these package issues is with the rest of you.
My problem has what may be a different twist. What I am finding is that functions that reference another function that is being overloaded by package changes, are not calling the correct version of the overridden function. Here is some sample code and resulting output to demonstrate what I'm talking about:
package PackageA
{
function foo(%str)
{
echo("\t" @ %str @ "PackageA::foo().");
}
};
package PackageB
{
function foo(%str)
{
echo("\t" @ %str @ "PackageB::foo().");
}
};
package PackageC
{
function foo(%str)
{
echo("\t" @ %str @ "PackageC::foo().");
}
};
function indirectCallToFoo()
{
foo("Indirectly called ");
}
function aPackage(%package)
{
echo("Activating package:" SPC %package);
activatePackage(%package);
}
function dPackage(%package)
{
echo("Deactivating package:" SPC %package);
deactivatePackage(%package);
}
foo("Directly called ");
indirectCallToFoo();
aPackage("PackageA");
foo("Directly called ");
indirectCallToFoo();
aPackage("PackageB");
foo("Directly called ");
indirectCallToFoo();
aPackage("PackageC");
foo("Directly called ");
indirectCallToFoo();
dPackage("PackageC");
foo("Directly called ");
indirectCallToFoo();
dPackage("PackageB");
foo("Directly called ");
indirectCallToFoo();
dPackage("PackageA");
foo("Directly called ");
indirectCallToFoo();and the output:
main.cs (46): Unable to find function foo main.cs (31): Unable to find function foo Activating package: PackageA Directly called PackageA::foo(). Indirectly called PackageA::foo(). Activating package: PackageB Directly called PackageB::foo(). Indirectly called PackageA::foo(). Activating package: PackageC Directly called PackageC::foo(). Indirectly called PackageA::foo(). Deactivating package: PackageC Directly called PackageB::foo(). Indirectly called PackageA::foo(). Deactivating package: PackageB Directly called PackageA::foo(). Indirectly called PackageA::foo(). Deactivating package: PackageA main.cs (64): Unable to find function foo Indirectly called PackageA::foo().
Please note that I intensionally call the function when there should be no active function yet, before any packages are activated and after they have all been deactivated.
What is shown here is that the function indirectCallToFoo() starts out ok. At first it has no linkage to foo(), then once the first package is activated, its link is properly set. But after that it is no longer updated and remains pointing to PackageA::foo().
I don't believe that this could possibly be the intended behavior of the package system. But I'm also puzzled that here we are 4 years after the last posts on the matter and it's hard to believe that these problems still exist. Is no one else using the package feature?
I did try the script package replacement code posted in the previous thread about this problem, but saw the same results. That code focuses only on the management of the packages in the package stack, but not on the issue of updating the links of the code that calls these overridden functions.
Has anyone else seen this problem? Is there some updated engine code that fixes this?
If there is no fix, then I will change to a non-package approach. Easy enough.
Thanks,
Craig
About the author