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.hh"
|
---|
10 |
|
---|
11 | #ifndef max
|
---|
12 | #define max(a,b) (((a)>(b))?(a):(b))
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | void g1_map_class::make_block_maps()
|
---|
16 | {
|
---|
17 | static i4_float grade_max[G1_GRADE_LEVELS] = { 10, 17, 30, 256 };
|
---|
18 | w32 grade, x,y;
|
---|
19 |
|
---|
20 | for (grade = 0; grade<G1_GRADE_LEVELS; grade++)
|
---|
21 | {
|
---|
22 | block[grade].init(width(),height());
|
---|
23 | block[grade].clear();
|
---|
24 |
|
---|
25 | for (x=0; x<width(); x++)
|
---|
26 | for (y=0; y<height(); y++)
|
---|
27 | {
|
---|
28 | if (x==0 || y==0 || x==width()-1 || y==height()-1 ||
|
---|
29 | (cell(x,y)->is_blocking() && grade<G1_GRADE_LEVELS-1))
|
---|
30 | block[grade].block(x,y, G1_NORTH|G1_SOUTH|G1_WEST|G1_EAST);
|
---|
31 | else
|
---|
32 | {
|
---|
33 | g1_object_chain_class *ch = cell(x,y)->get_solid_list();
|
---|
34 | while (ch &&
|
---|
35 | (!ch->object->get_flag(g1_object_class::BLOCKING) ||
|
---|
36 | g1_object_type_array[ch->object->id]->
|
---|
37 | get_flag(g1_object_definition_class::MOVABLE)))
|
---|
38 | ch = ch->next;
|
---|
39 |
|
---|
40 | if (ch)
|
---|
41 | block[grade].block(x,y, G1_NORTH|G1_SOUTH|G1_WEST|G1_EAST);
|
---|
42 | else
|
---|
43 | {
|
---|
44 | i4_float max_grade = grade_max[grade];
|
---|
45 | g1_map_vertex_class *v1, *v2, *v3, *v4;
|
---|
46 |
|
---|
47 | v1=verts + x + y * (w+1);
|
---|
48 | v2=v1+1;
|
---|
49 | v3=v1+w+1;
|
---|
50 | v4=v3+1;
|
---|
51 |
|
---|
52 | w8 h1=v1->height,
|
---|
53 | h2=v2->height,
|
---|
54 | h3=v3->height,
|
---|
55 | h4=v4->height;
|
---|
56 |
|
---|
57 | i4_float
|
---|
58 | grade_ns = max(h3-h1, h4-h2),
|
---|
59 | grade_ew = max(h2-h1, h4-h3),
|
---|
60 | grade_sn = max(h1-h3, h2-h4),
|
---|
61 | grade_we = max(h1-h2, h3-h4);
|
---|
62 |
|
---|
63 | if (grade_ns>max_grade || grade_sn>max_grade)
|
---|
64 | {
|
---|
65 | if (grade_ns>max_grade)
|
---|
66 | block[grade].block(x,y,G1_SOUTH);
|
---|
67 | if (grade_sn>max_grade)
|
---|
68 | block[grade].block(x,y,G1_NORTH);
|
---|
69 |
|
---|
70 | if (grade_ew>0)
|
---|
71 | block[grade].block(x,y,G1_WEST);
|
---|
72 | if (grade_we>0)
|
---|
73 | block[grade].block(x,y,G1_EAST);
|
---|
74 | }
|
---|
75 | if (grade_ew>max_grade || grade_we>max_grade)
|
---|
76 | {
|
---|
77 | if (grade_ew>max_grade)
|
---|
78 | block[grade].block(x,y,G1_WEST);
|
---|
79 | if (grade_we>max_grade)
|
---|
80 | block[grade].block(x,y,G1_EAST);
|
---|
81 |
|
---|
82 | if (grade_ns>0)
|
---|
83 | block[grade].block(x,y,G1_SOUTH);
|
---|
84 | if (grade_sn>0)
|
---|
85 | block[grade].block(x,y,G1_NORTH);
|
---|
86 | }
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|