def_buildable.hh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #ifndef G1_DEF_BUILDABLE_HH
  9. #define G1_DEF_BUILDABLE_HH
  10. #include "g1_object.hh"
  11. #include "objs/defaults.hh"
  12. //#include "objs/factory.hh"
  13. class g1_factory_class;
  14. template <class T>
  15. class g1_buildable_object_definer : public g1_object_definition_class
  16. {
  17. public:
  18. g1_object_defaults_struct *defaults;
  19. g1_object_build_info build_info;
  20. g1_buildable_object_definer<T>
  21. (char *name,
  22. char *factory_name,
  23. w32 type_flags,
  24. function_type _init = 0,
  25. function_type _uninit = 0)
  26. : g1_object_definition_class(name, type_flags, _init, _uninit)
  27. {
  28. build_info.factory_name = factory_name;
  29. }
  30. virtual g1_object_class *create_object(g1_object_type id,
  31. g1_loader_class *fp)
  32. {
  33. T *o=new T(id, fp);
  34. o->defaults=defaults;
  35. o->init();
  36. return o;
  37. }
  38. virtual void init()
  39. {
  40. defaults=g1_get_object_defaults(_name);
  41. build_info.cost=defaults->cost;
  42. g1_object_definition_class::init();
  43. }
  44. g1_object_build_info *get_build_info() { return &build_info; }
  45. };
  46. #ifndef G1_SELECTABLE_ENUM
  47. enum { UNSELECTABLE = i4_F, SELECTABLE = i4_T };
  48. #endif
  49. #endif