object_base.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef OBJECT_BASE_H
00013 #define OBJECT_BASE_H
00014
00015 #include "core/pool_type.hpp"
00016 #include "object_type.h"
00017 #include "tilearea_type.h"
00018 #include "town_type.h"
00019 #include "date_type.h"
00020 #include "core/smallvec_type.hpp"
00021
00022 typedef Pool<Object, ObjectID, 64, 64000> ObjectPool;
00023 extern ObjectPool _object_pool;
00024
00026 struct Object : ObjectPool::PoolItem<&_object_pool> {
00027 Town *town;
00028 TileArea location;
00029 Date build_date;
00030 byte colour;
00031 byte view;
00032
00034 Object() {}
00036 ~Object() {}
00037
00043 static Object *GetByTile(TileIndex tile);
00044
00050 static inline void IncTypeCount(ObjectType type)
00051 {
00052 assert(type < NUM_OBJECTS);
00053 counts[type]++;
00054 }
00055
00061 static inline void DecTypeCount(ObjectType type)
00062 {
00063 assert(type < NUM_OBJECTS);
00064 counts[type]--;
00065 }
00066
00072 static inline uint16 GetTypeCount(ObjectType type)
00073 {
00074 assert(type < NUM_OBJECTS);
00075 return counts[type];
00076 }
00077
00079 static inline void ResetTypeCounts()
00080 {
00081 memset(&counts, 0, sizeof(counts));
00082 }
00083
00084 protected:
00085 static uint16 counts[NUM_OBJECTS];
00086 };
00087
00088 #define FOR_ALL_OBJECTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Object, object_index, var, start)
00089 #define FOR_ALL_OBJECTS(var) FOR_ALL_OBJECTS_FROM(var, 0)
00090
00094 struct ClearedObjectArea {
00095 TileIndex first_tile;
00096 TileArea area;
00097 };
00098
00099 ClearedObjectArea *FindClearedObject(TileIndex tile);
00100 extern SmallVector<ClearedObjectArea, 4> _cleared_object_areas;
00101
00102 #endif