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_MODEL_ID_HH
|
---|
10 | #define G1_MODEL_ID_HH
|
---|
11 |
|
---|
12 | #include "arch.hh"
|
---|
13 | #include "g1_limits.hh"
|
---|
14 | #include "memory/growheap.hh"
|
---|
15 | #include "init/init.hh"
|
---|
16 | #include "error/error.hh"
|
---|
17 | #include "memory/array.hh"
|
---|
18 |
|
---|
19 | class i4_str;
|
---|
20 | class g1_quad_object_class;
|
---|
21 | class r1_render_api_class;
|
---|
22 | class r1_texture_manager_class;
|
---|
23 |
|
---|
24 | typedef w16 g1_model_id_type;
|
---|
25 |
|
---|
26 | // G3d model repository for the game
|
---|
27 | class g1_model_list_class : public i4_init_class
|
---|
28 | {
|
---|
29 | friend g1_model_info_compare(const void *a, const void *b);
|
---|
30 | struct model_info
|
---|
31 | {
|
---|
32 | g1_quad_object_class *model;
|
---|
33 | char *name_start;
|
---|
34 | } *array;
|
---|
35 |
|
---|
36 |
|
---|
37 | i4_grow_heap_class *name_buffer;
|
---|
38 | int total_models;
|
---|
39 |
|
---|
40 | virtual void init();
|
---|
41 | virtual void uninit();
|
---|
42 |
|
---|
43 | public:
|
---|
44 | void reset(i4_array<i4_str *> &model_names, r1_texture_manager_class *tmap);
|
---|
45 |
|
---|
46 |
|
---|
47 | g1_quad_object_class *get_model(w16 handle) const
|
---|
48 | {
|
---|
49 | if (handle>=total_models)
|
---|
50 | i4_error("get_model : bad handle");
|
---|
51 |
|
---|
52 | return array[handle].model;
|
---|
53 | }
|
---|
54 |
|
---|
55 | g1_model_id_type find_handle(const char *name) const;
|
---|
56 | void cleanup();
|
---|
57 |
|
---|
58 | char *get_model_name(w16 handle) const
|
---|
59 | {
|
---|
60 | return array[handle].name_start;
|
---|
61 | }
|
---|
62 | };
|
---|
63 |
|
---|
64 | extern g1_model_list_class g1_model_list_man;
|
---|
65 |
|
---|
66 |
|
---|
67 | class g1_model_ref
|
---|
68 | {
|
---|
69 | public:
|
---|
70 | char *name;
|
---|
71 | g1_model_id_type value;
|
---|
72 | g1_model_ref *next;
|
---|
73 |
|
---|
74 | g1_model_ref(char *name=0); // assumes name is a static value (it is not copied)
|
---|
75 | void set_name(char *name);
|
---|
76 | ~g1_model_ref();
|
---|
77 |
|
---|
78 | g1_model_id_type id() const { return value; }
|
---|
79 | g1_quad_object_class *get() const { return g1_model_list_man.get_model(value); }
|
---|
80 | g1_quad_object_class *operator()() const { return g1_model_list_man.get_model(value); }
|
---|
81 | };
|
---|
82 |
|
---|
83 | #endif
|
---|