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.25 by root, Sat Apr 10 01:54:07 2010 UTC vs.
Revision 1.26 by root, Tue Apr 13 02:39:53 2010 UTC

32 32
33static int 33static int
34obj_count_in_map (maptile *map, int x, int y) 34obj_count_in_map (maptile *map, int x, int y)
35{ 35{
36 int count = 0; 36 int count = 0;
37 object *tmp;
38 37
39 for (tmp = map->at (x, y).bot; tmp; tmp = tmp->above) 38 for (object *tmp = map->at (x, y).bot; tmp; tmp = tmp->above)
40 ++count; 39 ++count;
41 40
42 return count; 41 return count;
43} 42}
44 43
45/* 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. */
46 45
47void 46void
48put_decor (maptile *map, char **maze, char *decorstyle, int decor_option, random_map_params *RP) 47put_decor (maptile *map, char **maze, char *decorstyle, int decor_option, random_map_params *RP)
49{ 48{
50 maptile *decor_map;
51 char style_name[1024];
52
53 sprintf (style_name, "/styles/decorstyles");
54
55 decor_map = find_style (style_name, decorstyle, RP->difficulty); 49 maptile *decor_map = find_style ("/styles/decorstyles", decorstyle, RP->difficulty);
56 if (!decor_map) 50 if (!decor_map)
57 return; 51 return;
58 52
59 /* pick a random option, only 1 option right now. */ 53 /* pick a random option, only 1 option right now. */
60 if (decor_option == 0) 54 if (decor_option == 0)
70 int number_to_place = rmg_rndm (RP->Xsize * RP->Ysize / 5); 64 int number_to_place = rmg_rndm (RP->Xsize * RP->Ysize / 5);
71 int failures = 0; 65 int failures = 0;
72 66
73 while (failures < 100 && number_to_place > 0) 67 while (failures < 100 && number_to_place > 0)
74 { 68 {
75 coroapi::cede_to_tick (); 69 //coroapi::cede_to_tick ();
76 70
77 int x = rmg_rndm (RP->Xsize - 2) + 1; 71 int x = rmg_rndm (RP->Xsize - 2) + 1;
78 int y = rmg_rndm (RP->Ysize - 2) + 1; 72 int y = rmg_rndm (RP->Ysize - 2) + 1;
79 73
80 if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) 74 if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2)
91 } 85 }
92 break; 86 break;
93 } 87 }
94 88
95 default: 89 default:
90 {
96 { /* place decor objects everywhere: tile the map. */ 91 /* place decor objects everywhere: tile the map. */
97 int i, j;
98
99 for (i = 1; i < RP->Xsize - 1; i++) 92 for (int i = 1; i < RP->Xsize - 1; i++)
100 for (j = 1; j < RP->Ysize - 1; j++) 93 for (int j = 1; j < RP->Ysize - 1; j++)
101 { 94 {
102 if (maze[i][j] == 0) 95 if (maze[i][j] == 0)
103 { 96 {
104 object *this_object = decor_map->pick_random_object (rmg_rndm)->clone (); 97 object *this_object = decor_map->pick_random_object (rmg_rndm)->clone ();
105 98
106 this_object->x = i; 99 this_object->x = i;
107 this_object->y = j; 100 this_object->y = j;
108 /* it screws things up if decor can stop people */ 101 /* it screws things up if decor can stop people */
109 this_object->move_block = 0; 102 this_object->move_block = 0;
110 103
111 insert_ob_in_map (this_object, map, NULL, 0); 104 insert_ob_in_map (this_object, map, 0, 0);
112 } 105 }
113 } 106 }
107
114 break; 108 break;
115 } 109 }
116 } 110 }
117} 111}
118 112

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines