object_definer.hh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_OBJECT_DEFINER_HH
  9. #define G1_OBJECT_DEFINER_HH
  10. #include "g1_object.hh"
  11. #include "objs/defaults.hh"
  12. // this can be used to generate a definition class for an object and automatically add it into
  13. // the game via it's global constructor, I think this will work with dlls as well because
  14. // their global constructors are called when a dll is loaded
  15. template <class T>
  16. class g1_object_definer : public g1_object_definition_class
  17. {
  18. public:
  19. g1_object_definer<T>(char *name,
  20. w32 type_flags=0,
  21. function_type _init = 0,
  22. function_type _uninit = 0)
  23. : g1_object_definition_class(name, type_flags ,_init, _uninit) {}
  24. virtual g1_object_class *create_object(g1_object_type id,
  25. g1_loader_class *fp)
  26. {
  27. T *o=new T(id, fp);
  28. o->init();
  29. return o;
  30. }
  31. };
  32. class li_object;
  33. class li_environment;
  34. // called from g1_load_level (level_load.cc) : creates and objects type from lisp token
  35. void g1_define_object(li_object *o, li_environment *env);
  36. #endif