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
00038 static Object *GetByTile(TileIndex tile);
00039
00045 static inline void IncTypeCount(ObjectType type)
00046 {
00047 assert(type < NUM_OBJECTS);
00048 counts[type]++;
00049 }
00050
00056 static inline void DecTypeCount(ObjectType type)
00057 {
00058 assert(type < NUM_OBJECTS);
00059 counts[type]--;
00060 }
00061
00067 static inline uint16 GetTypeCount(ObjectType type)
00068 {
00069 assert(type < NUM_OBJECTS);
00070 return counts[type];
00071 }
00072
00074 static inline void ResetTypeCounts()
00075 {
00076 memset(&counts, 0, sizeof(counts));
00077 }
00078
00079 protected:
00080 static uint16 counts[NUM_OBJECTS];
00081 };
00082
00083 #define FOR_ALL_OBJECTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Object, object_index, var, start)
00084 #define FOR_ALL_OBJECTS(var) FOR_ALL_OBJECTS_FROM(var, 0)
00085
00089 struct ClearedObjectArea {
00090 TileIndex first_tile;
00091 TileArea area;
00092 };
00093
00094 ClearedObjectArea *FindClearedObject(TileIndex tile);
00095 extern SmallVector<ClearedObjectArea, 4> _cleared_object_areas;
00096
00097 #endif