ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/decor.C
(Generate patch)

Comparing deliantra/server/random_maps/decor.C (file contents):
Revision 1.18 by root, Fri Apr 11 21:09:53 2008 UTC vs.
Revision 1.20 by root, Fri May 2 21:01:53 2008 UTC

33obj_count_in_map (maptile *map, int x, int y) 33obj_count_in_map (maptile *map, int x, int y)
34{ 34{
35 int count = 0; 35 int count = 0;
36 object *tmp; 36 object *tmp;
37 37
38 for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) 38 for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above)
39 count++; 39 count++;
40
40 return count; 41 return count;
41} 42}
42 43
43/* put the decor into the map. Right now, it's very primitive. */ 44/* put the decor into the map. Right now, it's very primitive. */
44 45
60 61
61 switch (decor_option) 62 switch (decor_option)
62 { 63 {
63 case 0: 64 case 0:
64 break; 65 break;
66
65 case 1: 67 case 1:
66 { /* random placement of decor objects. */ 68 { /* random placement of decor objects. */
67 int number_to_place = rndm (RP->Xsize * RP->Ysize / 5); 69 int number_to_place = rndm (RP->Xsize * RP->Ysize / 5);
68 int failures = 0; 70 int failures = 0;
69 object *new_decor_object;
70 71
71 while (failures < 100 && number_to_place > 0) 72 while (failures < 100 && number_to_place > 0)
72 { 73 {
73 int x, y; 74 int x = rndm (RP->Xsize - 2) + 1;
75 int y = rndm (RP->Ysize - 2) + 1;
74 76
75 x = rndm (RP->Xsize - 2) + 1;
76 y = rndm (RP->Ysize - 2) + 1;
77 if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) 77 if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2)
78 { /* empty */ 78 {
79 object *this_object; 79 object *this_object = decor_map->pick_random_object ()->clone ();
80 80
81 new_decor_object = decor_map->pick_random_object ();
82 this_object = arch_to_object (new_decor_object->arch);
83 new_decor_object->copy_to (this_object);
84 this_object->x = x; 81 this_object->x = x;
85 this_object->y = y; 82 this_object->y = y;
86 /* it screws things up if decor can stop people */ 83 /* it screws things up if decor can stop people */
87 this_object->move_block = 0; 84 this_object->move_block = 0;
85
88 insert_ob_in_map (this_object, map, NULL, 0); 86 insert_ob_in_map (this_object, map, NULL, 0);
89 number_to_place--; 87 number_to_place--;
90 } 88 }
91 else 89 else
92 failures++; 90 failures++;
93 } 91 }
94 break; 92 break;
95 } 93 }
94
96 default: 95 default:
97 { /* place decor objects everywhere: tile the map. */ 96 { /* place decor objects everywhere: tile the map. */
98 int i, j; 97 int i, j;
99 98
100 for (i = 1; i < RP->Xsize - 1; i++) 99 for (i = 1; i < RP->Xsize - 1; i++)
101 for (j = 1; j < RP->Ysize - 1; j++) 100 for (j = 1; j < RP->Ysize - 1; j++)
102 { 101 {
103 if (maze[i][j] == 0) 102 if (maze[i][j] == 0)
104 { 103 {
105 object *new_decor_object, *this_object; 104 object *this_object = decor_map->pick_random_object ()->clone ();
106 105
107 new_decor_object = decor_map->pick_random_object ();
108 this_object = arch_to_object (new_decor_object->arch);
109 new_decor_object->copy_to (this_object);
110 this_object->x = i; 106 this_object->x = i;
111 this_object->y = j; 107 this_object->y = j;
112 /* it screws things up if decor can stop people */ 108 /* it screws things up if decor can stop people */
113 this_object->move_block = 0; 109 this_object->move_block = 0;
110
114 insert_ob_in_map (this_object, map, NULL, 0); 111 insert_ob_in_map (this_object, map, NULL, 0);
115 } 112 }
116 } 113 }
117 break; 114 break;
118 } 115 }
119 } 116 }
120} 117}
118

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines