ChangeStation(); } bool Player::ChangeStation() { Con::printf("The Function was called.. "> SimSetIterator Code | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

SimSetIterator Code

by RedCore · in Torque Game Engine · 04/20/2004 (7:31 pm) · 5 replies

I'm trying to cycle through all my RadioData Datablocks.. i wrote this code..

ConsoleMethod( Player, ChangeStation, bool, 2, 2, "()")
{
return object->ChangeStation();
}

bool Player::ChangeStation()
{
Con::printf("The Function was called.. now what..");
// Find the Replicator Set.
SimSet *RadioList = dynamic_cast(Sim::findObject("RadioData"));

if (!RadioList)
{
// Console Warning.
Con::warnf("Radio Controler - Cannot locate the 'RadioData', this is bad!");
return false;
}

// Cycle through Object(s).
for (SimSetIterator itr(RadioList); *itr; ++itr)
{
// Fetch the Radio Datablock.
RadioData* Radio = static_cast(*itr);

if(Radio->Active)
{
CurrentStation = Radio->Station;
Con::printf("Current Station is %d", CurrentStation);

}
Con::printf("Is this Station Active? %d", Radio->Active);
Con::printf("What is this Stations type? %s", Radio->Type);
Con::printf("We Are looping through the Radio Datablocks..");
}

return true;
}


Everything works except getting the variables from the current radio datablock.. so Radio->Active is always 0 and the other variable arent set or something..

it *could* have to do with the class.. but i figured it has to do with this code..

thx for the help..

#1
04/21/2004 (12:48 am)
You should be doing dynamic casts. If you're not sure what the difference is consult a C++ reference guide.

Do you know that your pointers are valid?
#2
04/22/2004 (2:26 pm)
I corrected the static_cast problem.. but i think the pointers are still not valid.. they are not returning anything..
#3
04/22/2004 (3:56 pm)
Then the types are not compatible. Consult your memory for C++'s typecasting rules.
#4
04/22/2004 (4:02 pm)
If(Radio->Active)

*snicker* *snort* MUAHAHAHAHAHAHAHAHAHAHAHAHA
#5
04/22/2004 (9:06 pm)
Could it have anything to do with me using TypeS8 in my addfield()'s.. is that the right type to use for chars? eXoDus told me to use them.. hem..

I did a tree() in the game.. and saw that the char variables were not being stored in the engine.. but the F32 variables were.. but that stil doesnt make sense why Radio->active isnt true.. for atleast one of the datablocks..

@LabRat
Huh?