source: golgotha/src/golg/def_buildable.hh

Last change on this file was 80, checked in by Sam Hocevar, 12 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_DEF_BUILDABLE_HH
10#define G1_DEF_BUILDABLE_HH
11
12#include "g1_object.hh"
13#include "objs/defaults.hh"
14//#include "objs/factory.hh"
15
16class g1_factory_class;
17
18template <class T>
19class g1_buildable_object_definer : public g1_object_definition_class
20{
21public:
22  g1_object_defaults_struct *defaults;
23  g1_object_build_info      build_info;
24 
25  g1_buildable_object_definer<T>
26  (char *name,
27   char *factory_name,
28   w32 type_flags,
29   function_type _init = 0,
30   function_type _uninit = 0)
31    : g1_object_definition_class(name, type_flags, _init, _uninit)
32  {
33    build_info.factory_name = factory_name;
34  }
35
36  virtual g1_object_class *create_object(g1_object_type id,
37                                         g1_loader_class *fp)
38  {
39    T *o=new T(id, fp);
40    o->defaults=defaults;
41    o->init();
42    return o;
43  }
44
45  virtual void init()
46  {
47    defaults=g1_get_object_defaults(_name);
48    build_info.cost=defaults->cost;
49
50    g1_object_definition_class::init();
51  }
52  g1_object_build_info *get_build_info() { return &build_info; }
53};
54
55#ifndef G1_SELECTABLE_ENUM
56enum { UNSELECTABLE = i4_F, SELECTABLE = i4_T };
57#endif
58
59#endif
Note: See TracBrowser for help on using the repository browser.