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 | #include "map_man.hh"
|
---|
10 | #include "map.hh"
|
---|
11 | #include "lisp/li_init.hh"
|
---|
12 | #include "lisp/lisp.hh"
|
---|
13 | #include "objs/map_piece.hh"
|
---|
14 |
|
---|
15 |
|
---|
16 | li_object *g1_drop_selected(li_object *o, li_environment *env)
|
---|
17 | {
|
---|
18 | if (!g1_map_is_loaded())
|
---|
19 | return 0;
|
---|
20 |
|
---|
21 | li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
|
---|
22 |
|
---|
23 | g1_object_class *olist[G1_MAX_OBJECTS];
|
---|
24 | sw32 t=g1_get_map()->make_object_list(olist, G1_MAX_OBJECTS);
|
---|
25 |
|
---|
26 | for (int i=0; i<t; i++)
|
---|
27 | {
|
---|
28 | if (olist[i]->selected())
|
---|
29 | {
|
---|
30 | olist[i]->unoccupy_location();
|
---|
31 | olist[i]->h=olist[i]->lh=g1_get_map()->terrain_height(olist[i]->x, olist[i]->y);
|
---|
32 | olist[i]->occupy_location();
|
---|
33 | }
|
---|
34 | }
|
---|
35 | li_call("redraw");
|
---|
36 |
|
---|
37 | return 0;
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | li_object *g1_floor_selected(li_object *o, li_environment *env)
|
---|
43 | {
|
---|
44 | li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
|
---|
45 |
|
---|
46 | g1_object_class *olist[G1_MAX_OBJECTS];
|
---|
47 | int t=g1_get_map()->make_object_list(olist, G1_MAX_OBJECTS),i;
|
---|
48 |
|
---|
49 | float lowest=1000;
|
---|
50 | for (i=0; i<t; i++)
|
---|
51 | if (olist[i]->selected())
|
---|
52 | if (olist[i]->h<lowest)
|
---|
53 | lowest=olist[i]->h;
|
---|
54 |
|
---|
55 | for (i=0; i<t; i++)
|
---|
56 | if (olist[i]->selected())
|
---|
57 | {
|
---|
58 | olist[i]->h=lowest;
|
---|
59 | olist[i]->grab_old();
|
---|
60 | }
|
---|
61 |
|
---|
62 | li_call("redraw");
|
---|
63 |
|
---|
64 | return 0;
|
---|
65 | }
|
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 | li_object *g1_ceil_selected(li_object *o, li_environment *env)
|
---|
70 | {
|
---|
71 | li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
|
---|
72 |
|
---|
73 | g1_object_class *olist[G1_MAX_OBJECTS];
|
---|
74 | int t=g1_get_map()->make_object_list(olist, G1_MAX_OBJECTS),i;
|
---|
75 |
|
---|
76 | float heighest=0;
|
---|
77 | for (i=0; i<t; i++)
|
---|
78 | if (olist[i]->selected())
|
---|
79 | if (olist[i]->h>heighest)
|
---|
80 | heighest=olist[i]->h;
|
---|
81 |
|
---|
82 | for (i=0; i<t; i++)
|
---|
83 | if (olist[i]->selected())
|
---|
84 | {
|
---|
85 | olist[i]->h=heighest;
|
---|
86 | olist[i]->grab_old();
|
---|
87 | }
|
---|
88 |
|
---|
89 | li_call("redraw");
|
---|
90 |
|
---|
91 | return 0;
|
---|
92 | }
|
---|
93 |
|
---|
94 | li_object *g1_select_game_pieces(li_object *o, li_environment *env)
|
---|
95 | {
|
---|
96 | li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
|
---|
97 |
|
---|
98 | g1_object_class *olist[G1_MAX_OBJECTS];
|
---|
99 | int t=g1_get_map()->make_object_list(olist, G1_MAX_OBJECTS),i;
|
---|
100 | for (i=0; i<t; i++)
|
---|
101 | if (g1_map_piece_class::cast(olist[i]))
|
---|
102 | olist[i]->set_flag(g1_object_class::SELECTED,1);
|
---|
103 | else
|
---|
104 | olist[i]->set_flag(g1_object_class::SELECTED,0);
|
---|
105 |
|
---|
106 | li_call("redraw");
|
---|
107 |
|
---|
108 | return 0;
|
---|
109 | }
|
---|
110 |
|
---|
111 |
|
---|
112 | li_object *g1_select_similar(li_object *o, li_environment *env)
|
---|
113 | {
|
---|
114 | li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
|
---|
115 |
|
---|
116 | g1_object_class *olist[G1_MAX_OBJECTS];
|
---|
117 | int t=g1_get_map()->make_object_list(olist, G1_MAX_OBJECTS),i;
|
---|
118 |
|
---|
119 | w8 *sel_types=(w8 *)i4_malloc(g1_last_object_type,"");
|
---|
120 | memset(sel_types, 0, g1_last_object_type);
|
---|
121 | for (i=0; i<t; i++)
|
---|
122 | if (olist[i]->get_flag(g1_object_class::SELECTED))
|
---|
123 | sel_types[olist[i]->id]=1;
|
---|
124 |
|
---|
125 | for (i=0; i<t; i++)
|
---|
126 | if (sel_types[olist[i]->id])
|
---|
127 | olist[i]->set_flag(g1_object_class::SELECTED,1);
|
---|
128 |
|
---|
129 | i4_free(sel_types);
|
---|
130 |
|
---|
131 | li_call("redraw");
|
---|
132 |
|
---|
133 | return 0;
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | li_automatic_add_function(g1_drop_selected, "Objects/Drop Selected");
|
---|
138 | li_automatic_add_function(g1_select_similar, "Objects/Select Similar");
|
---|
139 | li_automatic_add_function(g1_select_game_pieces, "Objects/Select Game Pieces");
|
---|
140 | li_automatic_add_function(g1_floor_selected, "Map/Floor Selected");
|
---|
141 | li_automatic_add_function(g1_ceil_selected, "Map/Ceil Selected");
|
---|