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.20 by root, Fri May 2 21:01:53 2008 UTC vs.
Revision 1.21 by root, Sun May 4 14:12:37 2008 UTC

27 27
28#define NR_DECOR_OPTIONS 1 28#define NR_DECOR_OPTIONS 1
29 29
30/* return a simple count of objects in the map at x,y. */ 30/* return a simple count of objects in the map at x,y. */
31 31
32int 32static int
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; tmp = tmp->above) 38 for (tmp = map->at (x, y).bot; tmp; tmp = tmp->above)
39 count++; 39 ++count;
40 40
41 return count; 41 return count;
42} 42}
43 43
44/* 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. */
55 if (!decor_map) 55 if (!decor_map)
56 return; 56 return;
57 57
58 /* pick a random option, only 1 option right now. */ 58 /* pick a random option, only 1 option right now. */
59 if (decor_option == 0) 59 if (decor_option == 0)
60 decor_option = rndm (NR_DECOR_OPTIONS) + 1; 60 decor_option = rmg_rndm (NR_DECOR_OPTIONS) + 1;
61 61
62 switch (decor_option) 62 switch (decor_option)
63 { 63 {
64 case 0: 64 case 0:
65 break; 65 break;
66 66
67 case 1: 67 case 1:
68 { /* random placement of decor objects. */ 68 { /* random placement of decor objects. */
69 int number_to_place = rndm (RP->Xsize * RP->Ysize / 5); 69 int number_to_place = rmg_rndm (RP->Xsize * RP->Ysize / 5);
70 int failures = 0; 70 int failures = 0;
71 71
72 while (failures < 100 && number_to_place > 0) 72 while (failures < 100 && number_to_place > 0)
73 { 73 {
74 coroapi::cede_to_tick ();
75
74 int x = rndm (RP->Xsize - 2) + 1; 76 int x = rmg_rndm (RP->Xsize - 2) + 1;
75 int y = rndm (RP->Ysize - 2) + 1; 77 int y = rmg_rndm (RP->Ysize - 2) + 1;
76 78
77 if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) 79 if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2)
78 { 80 {
79 object *this_object = decor_map->pick_random_object ()->clone (); 81 object *this_object = decor_map->pick_random_object (rmg_rndm)->clone ();
80
81 this_object->x = x;
82 this_object->y = y;
83 /* it screws things up if decor can stop people */ 82 /* it screws things up if decor can stop people */
84 this_object->move_block = 0; 83 this_object->move_block = 0;
84 map->insert (this_object, x, y, 0, 0);
85 85
86 insert_ob_in_map (this_object, map, NULL, 0);
87 number_to_place--; 86 number_to_place--;
88 } 87 }
89 else 88 else
90 failures++; 89 failures++;
91 } 90 }
99 for (i = 1; i < RP->Xsize - 1; i++) 98 for (i = 1; i < RP->Xsize - 1; i++)
100 for (j = 1; j < RP->Ysize - 1; j++) 99 for (j = 1; j < RP->Ysize - 1; j++)
101 { 100 {
102 if (maze[i][j] == 0) 101 if (maze[i][j] == 0)
103 { 102 {
104 object *this_object = decor_map->pick_random_object ()->clone (); 103 object *this_object = decor_map->pick_random_object (rmg_rndm)->clone ();
105 104
106 this_object->x = i; 105 this_object->x = i;
107 this_object->y = j; 106 this_object->y = j;
108 /* it screws things up if decor can stop people */ 107 /* it screws things up if decor can stop people */
109 this_object->move_block = 0; 108 this_object->move_block = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines