source: golgotha/src/golg/editor/commands/map_misc.cc @ 80

Last change on this file since 80 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: 3.9 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#include "map_cell.hh"
10#include "map_vert.hh"
11#include "map_man.hh"
12#include "lisp/lisp.hh"
13#include "lisp/li_init.hh"
14#include "map.hh"
15#include "objs/path_object.hh"
16
17
18li_object *g1_fog_map(li_object *, li_environment *env)
19
20  li_call("add_undo", li_make_list(new li_int(G1_MAP_CELLS | G1_MAP_VERTS)));
21  g1_map_cell_class *c=g1_cells;
22  int t=g1_map_width * g1_map_height, i;
23
24  for (i=0; i<t; i++, c++)
25    c->flags |= g1_map_cell_class::FOGGED;
26 
27
28  g1_map_vertex_class *v=g1_verts;
29  t=(g1_map_width+1) * (g1_map_height+1);
30
31  for (i=0; i<t; i++, v++)
32    v->flags |= g1_map_vertex_class::FOGGED;
33
34
35  li_call("redraw");
36  return 0;
37}
38
39
40li_object *g1_unfog_map(li_object *, li_environment *env)
41
42  li_call("add_undo", li_make_list(new li_int(G1_MAP_CELLS | G1_MAP_VERTS)));
43  g1_map_cell_class *c=g1_cells;
44  int t=g1_map_width * g1_map_height, i;
45
46  for (i=0; i<t; i++, c++)
47    c->flags &= ~g1_map_cell_class::FOGGED;
48 
49
50  g1_map_vertex_class *v=g1_verts;
51  t=(g1_map_width+1) * (g1_map_height+1);
52
53  for (i=0; i<t; i++, v++)
54    v->flags &= ~g1_map_vertex_class::FOGGED;
55
56
57  li_call("redraw");
58  return 0;
59}
60
61static void select_rest(g1_path_object_class *p, g1_team_type team)
62{
63  li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
64
65  if (p && !p->get_flag(g1_object_class::SCRATCH_BIT))
66  {
67    p->set_flag(g1_object_class::SCRATCH_BIT | g1_object_class::SELECTED, 1);
68   
69    int t=p->total_links(team);
70    for (int j=0; j<t; j++)
71      select_rest(p->get_link(team, j), team);
72
73    p->set_flag(g1_object_class::SCRATCH_BIT, 0);
74  }
75}
76
77li_object *g1_select_restof_path(li_object *o, li_environment *env)
78{
79  li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
80
81  for (g1_path_object_class *p=g1_path_object_list.first(); p; p=p->next)
82  {
83    if (p->get_flag(g1_object_class::SELECTED))
84    {
85      p->set_flag(g1_object_class::SCRATCH_BIT, 1);
86
87      for (g1_team_type team=G1_ALLY; team<G1_MAX_TEAMS; team=(g1_team_type)(team+1))
88      {
89        int t=p->total_links(team);
90        for (int j=0; j<t; j++)
91          select_rest(p->get_link(team, j), team);
92      }
93
94      p->set_flag(g1_object_class::SCRATCH_BIT, 0);
95    }
96  }
97
98  return 0;
99}
100
101li_object *g1_add_cloud_shadow(li_object *o, li_environment *env)
102{
103  li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
104
105  g1_object_class *c=g1_create_object(g1_get_object_type("cloud_shadow"));
106  c->x=g1_map_width/2;
107  c->y=g1_map_height/2;
108  c->h=g1_get_map()->terrain_height(c->x, c->y)+0.1;
109  c->occupy_location();
110
111  li_call("redraw");
112  return 0;
113}
114
115li_object *g1_remove_cloud_shadow(li_object *o, li_environment *env)
116{
117  li_call("add_undo", li_make_list(new li_int(G1_MAP_OBJECTS)));
118 
119  int type=g1_get_object_type("cloud_shadow");
120  g1_object_class *olist[G1_MAX_OBJECTS];
121  sw32 t=g1_get_map()->make_object_list(olist, G1_MAX_OBJECTS);
122  for (int i=0; i<t; i++)
123  {
124    if (olist[i]->id==type)
125    {
126      olist[i]->unoccupy_location();
127      olist[i]->request_remove();     
128    }
129  }
130
131  li_call("redraw");
132  return 0;
133}
134
135
136
137li_automatic_add_function(g1_fog_map, "fog_map");
138li_automatic_add_function(g1_unfog_map, "unfog_map");
139li_automatic_add_function(g1_select_restof_path, "select_restof_path");
140
141li_automatic_add_function(g1_add_cloud_shadow, "add_cloud_shadow");
142li_automatic_add_function(g1_remove_cloud_shadow, "remove_cloud_shadow");
Note: See TracBrowser for help on using the repository browser.