source: golgotha/src/golg/object_definer.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.6 KB
Line 
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
9#ifndef G1_OBJECT_DEFINER_HH
10#define G1_OBJECT_DEFINER_HH
11
12#include "g1_object.hh"
13#include "objs/defaults.hh"
14
15// this can be used to generate a definition class for an object and automatically add it into
16// the game via it's global constructor, I think this will work with dlls as well because
17// their global constructors are called when a dll is loaded
18
19template <class T>
20class g1_object_definer : public g1_object_definition_class
21{
22public:
23  g1_object_definer<T>(char *name,
24                       w32 type_flags=0,
25                       function_type _init = 0,
26                       function_type _uninit = 0)
27    : g1_object_definition_class(name, type_flags ,_init, _uninit) {}
28
29  virtual g1_object_class *create_object(g1_object_type id,
30                                         g1_loader_class *fp)
31  {
32    T *o=new T(id, fp);
33    o->init();
34    return o;
35  }
36};
37
38class li_object;
39class li_environment;
40
41// called from g1_load_level (level_load.cc) : creates and objects type from lisp token
42void g1_define_object(li_object *o, li_environment *env);
43
44#endif
Note: See TracBrowser for help on using the repository browser.