project-navigation
Personal tools

Author Topic: How to loop trough types of buildings.  (Read 4383 times)

Hoehrer

  • Guest
How to loop trough types of buildings.
« 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

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
How to loop trough types of buildings.
« Reply #1 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.

Hoehrer

  • Guest
How to loop trough types of buildings.
« Reply #2 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