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

Comparing deliantra/server/random_maps/exit.C (file contents):
Revision 1.12 by root, Sat Dec 30 10:16:11 2006 UTC vs.
Revision 1.15 by root, Sun Dec 31 17:17:23 2006 UTC

24#include <global.h> 24#include <global.h>
25#include <random_map.h> 25#include <random_map.h>
26#include <sproto.h> 26#include <sproto.h>
27#include <rproto.h> 27#include <rproto.h>
28 28
29
30/* find a character in the layout. fx and fy are pointers to 29/* find a character in the layout. fx and fy are pointers to
31 where to find the char. fx,fy = -1 if not found. */ 30 where to find the char. fx,fy = -1 if not found. */
32void 31void
33find_in_layout (int mode, char target, int *fx, int *fy, char **layout, RMParms * RP) 32find_in_layout (int mode, char target, int *fx, int *fy, char **layout, random_map_params * RP)
34{ 33{
35 int M; 34 int M;
36 int i, j; 35 int i, j;
37 36
38 *fx = -1; 37 *fx = -1;
115 4 means leftward 114 4 means leftward
116 5 means northward 115 5 means northward
117 6 means southward 116 6 means southward
118*/ 117*/
119void 118void
120place_exits (maptile *map, char **maze, char *exitstyle, int orientation, RMParms *RP) 119place_exits (maptile *map, char **maze, char *exitstyle, int orientation, random_map_params *RP)
121{ 120{
122 char styledirname[256]; 121 char styledirname[256];
123 maptile *style_map_down = 0; /* harder maze */ 122 maptile *style_map_down = 0; /* harder maze */
124 maptile *style_map_up = 0; /* easier maze */ 123 maptile *style_map_up = 0; /* easier maze */
125 object *the_exit_down; /* harder maze */ 124 object *the_exit_down; /* harder maze */
140 if (orientation == 0) 139 if (orientation == 0)
141 orientation = RANDOM () % 6 + 1; 140 orientation = RANDOM () % 6 + 1;
142 141
143 switch (orientation) 142 switch (orientation)
144 { 143 {
145 case 1: 144 case 1:
146 { 145 {
147 sprintf (styledirname, "/styles/exitstyles/up"); 146 sprintf (styledirname, "/styles/exitstyles/up");
148 style_map_up = find_style (styledirname, exitstyle, -1); 147 style_map_up = find_style (styledirname, exitstyle, -1);
149 sprintf (styledirname, "/styles/exitstyles/down"); 148 sprintf (styledirname, "/styles/exitstyles/down");
150 style_map_down = find_style (styledirname, exitstyle, -1); 149 style_map_down = find_style (styledirname, exitstyle, -1);
151 break; 150 break;
152 } 151 }
152
153 case 2: 153 case 2:
154 { 154 {
155 sprintf (styledirname, "/styles/exitstyles/down"); 155 sprintf (styledirname, "/styles/exitstyles/down");
156 style_map_up = find_style (styledirname, exitstyle, -1); 156 style_map_up = find_style (styledirname, exitstyle, -1);
157 sprintf (styledirname, "/styles/exitstyles/up"); 157 sprintf (styledirname, "/styles/exitstyles/up");
158 style_map_down = find_style (styledirname, exitstyle, -1); 158 style_map_down = find_style (styledirname, exitstyle, -1);
159 break; 159 break;
160 } 160 }
161
161 default: 162 default:
162 { 163 {
163 sprintf (styledirname, "/styles/exitstyles/generic"); 164 sprintf (styledirname, "/styles/exitstyles/generic");
164 style_map_up = find_style (styledirname, exitstyle, -1); 165 style_map_up = find_style (styledirname, exitstyle, -1);
165 style_map_down = style_map_up; 166 style_map_down = style_map_up;
166 break; 167 break;
167 } 168 }
168 } 169 }
170
169 if (style_map_up == 0) 171 if (style_map_up == 0)
170 the_exit_up = arch_to_object (archetype::find ("exit")); 172 the_exit_up = arch_to_object (archetype::find ("exit"));
171 else 173 else
172 { 174 {
173 object *tmp; 175 object *tmp;
191 the_exit_down = 0; 193 the_exit_down = 0;
192 194
193 /* set up the up exit */ 195 /* set up the up exit */
194 the_exit_up->stats.hp = RP->origin_x; 196 the_exit_up->stats.hp = RP->origin_x;
195 the_exit_up->stats.sp = RP->origin_y; 197 the_exit_up->stats.sp = RP->origin_y;
196 the_exit_up->slaying = RP->origin_map; 198 the_exit_up->slaying = RP->origin_map;
197 199
198 /* figure out where to put the entrance */ 200 /* figure out where to put the entrance */
199 /* begin a logical block */ 201 /* begin a logical block */
200 { 202 {
201 int i, j; 203 int i, j;
325 /* give the final map a name */ 327 /* give the final map a name */
326 sprintf (new_map_name, "%sfinal_map", RP->final_map); 328 sprintf (new_map_name, "%sfinal_map", RP->final_map);
327 /* set the exit down. */ 329 /* set the exit down. */
328#endif 330#endif
329 /* load it */ 331 /* load it */
330 if (!(new_map = maptile::find_map (RP->final_map, 0))) 332 if (!(new_map = maptile::load_map_sync (RP->final_map)))
331 return; 333 return;
332
333 new_map->load ();
334 334
335 the_exit_down->slaying = RP->final_map; 335 the_exit_down->slaying = RP->final_map;
336 336
337 for (tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above) 337 for (tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above)
338 /* Remove exit back to previous random map. There should only be one 338 /* Remove exit back to previous random map. There should only be one
355 the_exit_back->x = new_map->enter_x; 355 the_exit_back->x = new_map->enter_x;
356 the_exit_back->y = new_map->enter_y; 356 the_exit_back->y = new_map->enter_y;
357 357
358 insert_ob_in_map (the_exit_back, new_map, NULL, 0); 358 insert_ob_in_map (the_exit_back, new_map, NULL, 0);
359 } 359 }
360
361 set_map_timeout (new_map); /* So it gets swapped out */
362 } 360 }
363 else 361 else
364 the_exit_down->slaying = "/!"; 362 the_exit_down->slaying = "/!";
365 363
366 /* Block the exit so things don't get dumped on top of it. */ 364 /* Block the exit so things don't get dumped on top of it. */
374 372
375/* this function unblocks the exits. We blocked them to 373/* this function unblocks the exits. We blocked them to
376 keep things from being dumped on them during the other 374 keep things from being dumped on them during the other
377 phases of random map generation. */ 375 phases of random map generation. */
378void 376void
379unblock_exits (maptile *map, char **maze, RMParms * RP) 377unblock_exits (maptile *map, char **maze, random_map_params * RP)
380{ 378{
381 int i = 0, j = 0; 379 int i = 0, j = 0;
382 object *walk; 380 object *walk;
383 381
384 for (i = 0; i < RP->Xsize; i++) 382 for (i = 0; i < RP->Xsize; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines