From #t2scripters

|Rx|Diogenes
02-10-2003, 09:40 PM
I can't believe I'm posting a PJ quote without clowning on him, but alas it's important that other people see this too.

[18:21] <[AKA]PanamaJack> Warning to everyone... If you use the deactivatepackage function you MUST check to see if the package is active with the isActivePackage function. There is a BUG in the deactivatepackage function that will remove the FIRST package in the package list if it cannot find the package you are trying to deactivate.

[18:24] <[AKA]PanamaJack> If someone tries to deactivate a package that isn't there another package is deactivates and that could cause all kinds of problems from non-running scripts to complete UEs.

ie: Never ever use:
deactivatePackate(Foo);
Instead use:
if(isActivePackage(Foo)) deactivatePackage(Foo);

That is all.

Dirty Sanchez
02-10-2003, 09:44 PM
great tip, i have no idea what any of that means.

ragingbunny
02-10-2003, 09:56 PM
Originally posted by RoyaleWithCheese
great tip, i have no idea what any of that means.
nice

Kaiten Commande
02-11-2003, 02:23 AM
// z0dd - ZOD - Founder (founder@mechina.com), 10/23/02. Fixes bug where by
// parent functions are lost when packages are deactivated.
package PackageFix
{
function isActivePackage(%package)
{
for(%i = 0; %i < $TotalNumberOfPackages; %i++)
{
if($Package[%i] $= %package)
{
return true;
break;
}
}
return false;
}

function ActivatePackage(%this)
{
Parent::ActivatePackage(% this);
if($TotalNumberOfPackages $= "")
$TotalNumberOfPackages = 0;
else
{
// This package name is allready active, so lets not activate it again.
if(isActivePackage(%this) )
{
error("ActivatePackage called for a currently active package!");
return;
}
}
$Package[$TotalNumberOfPackages] = %this;
$TotalNumberOfPackages++;
}

function DeactivatePackage(%this)
{
%count = 0;
%counter = 0;
//find the index number of the package to deactivate
for(%i = 0; %i < $TotalNumberOfPackages; %i++)
{
if($Package[%i] $= %this)
%breakpoint = %i;
}
for(%j = 0; %j < $TotalNumberOfPackages; %j++)
{
if(%j < %breakpoint)
{
//go ahead and assign temp array, save code
%tempPackage[%count] = $Package[%j];
%count++;
}
else if(%j > %breakpoint)
{
%reactivate[%counter] = $Package[%j];
$Package[%j] = "";
%counter++;
}
}
//deactivate all the packagess from the last to the current one
for(%k = (%counter - 1); %k > -1; %k--)
Parent::DeactivatePackage (%reactivate[%k]);

//deactivate the package that started all this
Parent::DeactivatePackage (%this);

//don't forget this
$TotalNumberOfPackages = %breakpoint;

//reactivate all those other packages
for(%l = 0; %l < %counter; %l++)
ActivatePackage(%reactiva te[%l]);
}

function listPackages()
{
echo("Activated Packages:");
for(%i = 0; %i < $TotalNumberOfPackages; %i++)
echo($Package[%i]);
}
};
activatePackage(PackageFi x);

Can someone show me where this bug is?

Taken from console_start.cs

LouCypher
02-11-2003, 03:10 AM
Originally posted by Kaiten Commande
Can someone show me where this bug is?

Taken from console_start.cs
If %this = NULL, %j = 0, and $Package[0] gets deactivated instead. That's what I'm guessing from the looks of it. I guess $Package[0] might not be the one you really want to deactivate. I don't think it takes into consideration the fact the package might not exist. Which is why he says to check first.

[AKA]PanamaJack
02-11-2003, 05:23 PM
There is a small bug in the T2 Package system that can cause a potential problem with both servers and clients.

A simplified explanation of packages is this...

Packages in Tribes 2 is a way for scripters to add new abilities to existing routines. All of the gametypes and almost all client side scripts use packages to add more functionality to the game.

The package system was slightly patched with the new patch so it can retain all of the packages if some are removed. In the old system if you had 3 packages and deactivated the second one it effectively deactivated the third one as well. This was a very bad thing that caused all kinds of problems for scripters. The packaging system was patched to prevent this but a bug crept in.

If you try to deactivate a package that isn't there the first package in the package list is deleted. The package isn't deactivated but it is deleted from the list. If a script tries to deactive a package multiple times that doesn't exist it could remove all packages from the list. This is when problems arise.

Example...

MyPackage1
MyPackage2
MyPackage3

Say a script tries to deactivate a package called "Junk" two times. Since junk isn't in the list MyPackage1 and MyPackage2 are removed instead. Both of those packages are still active even though they are not in the list.

Now if another script deactivates MyPackage1 both MyPackage1 AND MyPackage2 will be deactivated as they are not in the list of active packages. MyPackage2 SHOULD be reactivated but it isn't since it isn't in the package list. This can cause things that need that deactivated package to stop working or a worst case cause T2 to UE.

Here is the fix for the problem.

This is for both Servers and Clients. For windows load console_start.cs, located in the gamedata directory, into a text editor like notepad. For linux load console_start.cs, located in the tribes2 directory, into a text editor.

Find a line that looks like this (line number 42/43)...

function DeactivatePackage(%this)
{

And add the following line right after it...

if(!isActivePackage(%this ))
return;

Save the script. You are fixed.

If you are only running as a Client and don't want to edit the above script just install the script below in your autoexec directory.

http://hope.oznet.com/pjBB/download.php?id=152

Peace Out...
PJ

PS: Surprise! :D

Kaiten Commande
02-11-2003, 05:37 PM
hmmm Did I just time warp there & see PJ posting here.. hmmm must have been seeing things.

:D

Ragnafrak
02-11-2003, 06:07 PM
so would this be the reason that most people get UEs when using your scripts?

ilys
02-11-2003, 07:17 PM
Originally posted by Ragnafrak
so would this be the reason that most people get UEs when using your scripts?
No, this is a bug that affects most T2 script. Its the fluff that makes his scripts UE.

Halide
02-11-2003, 11:09 PM
PanamaJack is UNBANNED!

·liquid·
02-11-2003, 11:16 PM
Originally posted by Halide
PanamaJack is UNBANNED!

He never was.

He just doesn't post here because of what happened between him and Rayn. :\

SupaKalel
02-11-2003, 11:25 PM
no i htink he was banned... cuz he is member.

Krobar
02-11-2003, 11:50 PM
no he wasn't banned, his account was deleted during the time that new registrations were closed, and he subsequently denounced all things TW and was not seen until now. (think I covered it all)