UFO:Alien Invasion

Development => Coding => Topic started by: Hoehrer on March 28, 2006, 07:40:07 pm

Title: How to loop trough types of buildings.
Post by: Hoehrer on March 28, 2006, 07:40:07 pm
As the title says. How do i loop/search trough all available types of buildings?

The global var ....
Code: [Select]
extern building_t    bmBuildings[MAX_BASES][MAX_BUILDINGS]; ... stores them seperated by bases (and thus probably duplicates).

I suspect that i can use the prev/next entries in building_t somehow ...
Code: [Select]
struct  building_s *prev;
struct  building_s *next;is a

.. but how do i know where to start/stop?

Werner
Title: How to loop trough types of buildings.
Post by: Mattn on March 28, 2006, 07:47:33 pm
the prev and next is currently not set:

Code: [Select]

building_t* entry;
for ( i = 0; i < numBuildings; i++ )
{
    entry = &bmBuildings[0][i];
}

numBuildings is the global building count
and bmBuildings[0] means that you use the buildings from the first base.

the main data is the same at each base - but there may be different workers assigned and so on. the dynamic stuff is handled in each base.
Title: How to loop trough types of buildings.
Post by: Hoehrer on March 28, 2006, 08:26:10 pm
Thanks, that helps alot :)

Now the only barrier i still need to break is the non-global numBuildings ... just need to find all the needed things.

Werner