Development > Coding

How to loop trough types of buildings.


As the title says. How do i loop/search trough all available types of buildings?

The global var ....

--- Code: ---extern building_t    bmBuildings[MAX_BASES][MAX_BUILDINGS];
--- End code ---
... stores them seperated by bases (and thus probably duplicates).

I suspect that i can use the prev/next entries in building_t somehow ...

--- Code: ---struct  building_s *prev;
struct  building_s *next;is a
--- End code ---

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


the prev and next is currently not set:

--- Code: ---
building_t* entry;
for ( i = 0; i < numBuildings; i++ )
    entry = &bmBuildings[0][i];

--- End code ---

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.

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.



[0] Message Index

Go to full version