Game Development Community

DeactivatePackage doesn't work

by Ronald J Nelson · in Torque Game Engine · 09/29/2007 (1:18 pm) · 4 replies

I have setup different packages for my game's different modes of plat (I.E. CTF, Deathmatch,...). I wan't to beable to change them on the fly from a vaiable in the map.

I managed to modify the scriptobject code to have a required entrying for the missionInfo section of the .mis file. I also have no problem activating a package based upon that variable.

However, I cannot deactivate the package. Now here is a difference I noticed.

If I set it up to have the variable in the .mis file:
(By the way I am using a modified version of mission in the menu, that explains $mainMenu and MenuMission)

MapMissionType = "DeathMatchGame";

and in another .mis file:

MapMissionType = "RaceGame";


With this function, the packages activate, but don't deactivate.
function loadMission( %missionName, %isFirstMission ) 
{
   endMission();
   deactivatePackage($Game::activeGamePackage);

   $Game::activeGamePackage = "";

   %missionInfo = getMissionDisplayName(%missionName);

   if($mainMenu)
   {
      $Game::activeGamePackage = "MenuMission";
      $Game::MapEnvironmentType = %missionInfo.MapEnvironmentType;
   }
   else
   {
      $Game::activeGamePackage = %missionInfo.MapMissionType;
      $Game::MapEnvironmentType = %missionInfo.MapEnvironmentType;
   }

   activatePackage($Game::activeGamePackage);


I even tried this with no change, thinking it was a string quotes thing:

function loadMission( %missionName, %isFirstMission ) 
{
   endMission();
   //deactivatePackage($Game::activeGamePackage);

   //Game::activeGamePackage = "";

   %missionInfo = getMissionDisplayName(%missionName);

   if($mainMenu)
   {
      deactivatePackage(RaceGame);
      deactivatePackage(DeathMatchGame);

      $Game::activeGamePackage = "MenuMission";
      $Game::MapEnvironmentType = %missionInfo.MapEnvironmentType;
   }
   else if (%missionInfo.MapMissionType $= "RaceGame")
   {
      deactivatePackage(MenuMission);
      deactivatePackage(DeathMatchGame);

      $Game::activeGamePackage = %missionInfo.MapMissionType;
      $Game::MapEnvironmentType = %missionInfo.MapEnvironmentType;
   }
   else if (%missionInfo.MapMissionType $= "DeathMatchGame")
   {
      deactivatePackage(RaceGame);
      deactivatePackage(MenuMission);

      $Game::activeGamePackage = %missionInfo.MapMissionType;
      $Game::MapEnvironmentType = %missionInfo.MapEnvironmentType;
   }
   activatePackage($Game::activeGamePackage);

continued...

#1
09/29/2007 (1:37 pm)
Next I ran the following tests on the first version using my admin screen that loads the missions with this the loadMission function:

activatePackage($Game::activeGamePackage);
[b]
   if(isPackage(MenuMission))
   {
      echo("MenuMission Package is present");
   }
   if(isPackage(RaceGame))
   {
      echo("RaceGame Package is present");
   }
   if(isPackage(DeathMatchGame))
   {
      echo("DeathMatchGame Package is present");
   }
[/b]

I got this in my console log:

MenuMission Package is present
RaceGame Package is present
DeathMatchGame Package is present

Now the only two functions in these packages are startGame() and endGame() with the exception of
the MenuMission Package which startGame() was renamed to startMMGame().


So I can surmise that all of the packages are available. However since the startGame() function in the MenuMission Package was renamed, I am assuiming it is still present too.

This means at no time is are these packages being deactivated.

Now I have read that it could have something to do with the functions names. In other words if startGame() were named something like Something::startGame(), that it would properly replace it.

Is that true? If so what sort of class would you give to a function that is internal to the server itself like startGame() ?

Otherwise, there is is a bug here. Even what I read is true, it is still technically a bug pecause of the Parent requirement.
#2
09/29/2007 (4:33 pm)
Well it seems what I was told is definitely true. Adding the class does make the difference. How I tested this was I added the following to each of packages but the changed the name to the package name (RaceGame, MenuMission, DeathMatchGame).

function GameConnection::testMessage( %client)
   {
      echo("The current active package is RaceGame");
   }

In all cases, the correct package name came up. This poses a problem for me though, since so many of the server side missions have no class assigned to them.

Anyone have a way to get past this?
#3
09/30/2007 (12:24 am)
Give them a class.

If the problem is that startGame and endGame have no class then supply them with one...

Note: This is a rough draft!

function GameStyleClass::startGame() {
       // default
   }

   new ScriptClass(GameStyleClass);

   package MyPackage {
         function GameStyleClass::startGame() {
            //overriden
         }
   }

   // Then in GameConnection::onClientEnterGame() use:
   GameStyleClass::startGame();

I dunno if that'll really work or not but maybe its a starting point.
#4
09/30/2007 (12:28 am)
Its ironic that you should say that. I got exactly the same thing from Daniel Eden on ICQ. Yup it fixed it.