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

Comparing deliantra/server/server/main.C (file contents):
Revision 1.30 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.31 by root, Sun Sep 17 14:22:29 2006 UTC

106 new_draw_info (NDI_UNIQUE, 0, op, "Images and art:"); 106 new_draw_info (NDI_UNIQUE, 0, op, "Images and art:");
107 new_draw_info (NDI_UNIQUE, 0, op, "Peter Gardner"); 107 new_draw_info (NDI_UNIQUE, 0, op, "Peter Gardner");
108 new_draw_info (NDI_UNIQUE, 0, op, "David Gervais [david_eg@mail.com]"); 108 new_draw_info (NDI_UNIQUE, 0, op, "David Gervais [david_eg@mail.com]");
109 new_draw_info (NDI_UNIQUE, 0, op, "Mitsuhiro Itakura [ita@gold.koma.jaeri.go.jp]"); 109 new_draw_info (NDI_UNIQUE, 0, op, "Mitsuhiro Itakura [ita@gold.koma.jaeri.go.jp]");
110 new_draw_info (NDI_UNIQUE, 0, op, "Hansjoerg Malthaner [hansjoerg.malthaner@danet.de]"); 110 new_draw_info (NDI_UNIQUE, 0, op, "Hansjoerg Malthaner [hansjoerg.malthaner@danet.de]");
111 new_draw_info (NDI_UNIQUE, 0, op, "Mårten Woxberg [maxmc@telia.com]"); 111 new_draw_info (NDI_UNIQUE, 0, op, "MÃ¥rten Woxberg [maxmc@telia.com]");
112 new_draw_info (NDI_UNIQUE, 0, op, "And many more!"); 112 new_draw_info (NDI_UNIQUE, 0, op, "And many more!");
113} 113}
114 114
115void 115void
116info_keys (object *op) 116info_keys (object *op)
266 newmap->path, x, y, MAP_WIDTH (newmap), MAP_HEIGHT (newmap)); 266 newmap->path, x, y, MAP_WIDTH (newmap), MAP_HEIGHT (newmap));
267 new_draw_info (NDI_UNIQUE, 0, op, "The exit is closed"); 267 new_draw_info (NDI_UNIQUE, 0, op, "The exit is closed");
268 return; 268 return;
269 } 269 }
270 } 270 }
271
271 /* try to find a spot for the player */ 272 /* try to find a spot for the player */
272 if (ob_blocked (op, newmap, x, y)) 273 if (ob_blocked (op, newmap, x, y))
273 { /* First choice blocked */ 274 { /* First choice blocked */
274 /* We try to find a spot for the player, starting closest in. 275 /* We try to find a spot for the player, starting closest in.
275 * We could use find_first_free_spot, but that doesn't randomize it at all, 276 * We could use find_first_free_spot, but that doesn't randomize it at all,
284 { 285 {
285 i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE2 + 1); 286 i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE2 + 1);
286 if (i == -1) 287 if (i == -1)
287 i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE); 288 i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE);
288 } 289 }
290
289 if (i != -1) 291 if (i != -1)
290 { 292 {
291 x += freearr_x[i]; 293 x += freearr_x[i];
292 y += freearr_y[i]; 294 y += freearr_y[i];
293 } 295 }
297 LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", newmap->path, x, y); 299 LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", newmap->path, x, y);
298 } 300 }
299 } /* end if looking for free spot */ 301 } /* end if looking for free spot */
300 302
301 if (op->map != NULL) 303 if (op->map != NULL)
302 {
303 INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (op->map), ARG_MAP (newmap));
304 INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr)); 304 if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr)))
305 } 305 return;
306
307 if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y)))
308 return;
309
310 if (INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr), ARG_INT (x), ARG_INT (y)))
311 return;
306 312
307 /* If it is a player login, he has yet to be inserted anyplace. 313 /* If it is a player login, he has yet to be inserted anyplace.
308 * otherwise, we need to deal with removing the player here. 314 * otherwise, we need to deal with removing the player here.
309 */ 315 */
310 if (!QUERY_FLAG (op, FLAG_REMOVED))
311 remove_ob (op); 316 remove_ob (op);
312 317
313 /* remove_ob clears these so they must be reset after the remove_ob call */ 318 /* remove_ob clears these so they must be reset after the remove_ob call */
314 op->x = x; 319 op->x = x;
315 op->y = y; 320 op->y = y;
316 op->map = newmap; 321 op->map = newmap;
322
317 insert_ob_in_map (op, op->map, NULL, INS_NO_WALK_ON); 323 insert_ob_in_map (op, op->map, NULL, INS_NO_WALK_ON);
318
319 INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr));
320 324
321 if (!op->contr->hidden) 325 if (!op->contr->hidden)
322 newmap->players++; 326 newmap->players++;
323 327
324 newmap->timeout = 0; 328 newmap->timeout = 0;
335 { 339 {
336 int i = find_free_spot (op->contr->ranges[range_golem], newmap, 340 int i = find_free_spot (op->contr->ranges[range_golem], newmap,
337 x, y, 1, SIZEOFFREE); 341 x, y, 1, SIZEOFFREE);
338 342
339 remove_ob (op->contr->ranges[range_golem]); 343 remove_ob (op->contr->ranges[range_golem]);
344
340 if (i == -1) 345 if (i == -1)
341 { 346 {
342 remove_friendly_object (op->contr->ranges[range_golem]); 347 remove_friendly_object (op->contr->ranges[range_golem]);
343 free_object (op->contr->ranges[range_golem]); 348 free_object (op->contr->ranges[range_golem]);
344 op->contr->ranges[range_golem] = NULL; 349 op->contr->ranges[range_golem] = NULL;
345 op->contr->golem_count = 0; 350 op->contr->golem_count = 0;
346 } 351 }
347 else 352 else
348 { 353 {
349 object *tmp;
350
351 for (tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more) 354 for (object *tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more)
352 { 355 {
353 tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); 356 tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x);
354 tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); 357 tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
355 tmp->map = newmap; 358 tmp->map = newmap;
356 } 359 }
360
357 insert_ob_in_map (op->contr->ranges[range_golem], newmap, NULL, 0); 361 insert_ob_in_map (op->contr->ranges[range_golem], newmap, NULL, 0);
358 op->contr->ranges[range_golem]->direction = 362 op->contr->ranges[range_golem]->direction =
359 find_dir_2 (op->x - op->contr->ranges[range_golem]->x, op->y - op->contr->ranges[range_golem]->y); 363 find_dir_2 (op->x - op->contr->ranges[range_golem]->x, op->y - op->contr->ranges[range_golem]->y);
360 } 364 }
361 } 365 }
366
362 op->direction = 0; 367 op->direction = 0;
363 368
364 /* since the players map is already loaded, we don't need to worry 369 /* since the players map is already loaded, we don't need to worry
365 * about pending objects. 370 * about pending objects.
366 */ 371 */
390 /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is 395 /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is
391 * lower than the min value. 396 * lower than the min value.
392 */ 397 */
393# if MAP_MINTIMEOUT 398# if MAP_MINTIMEOUT
394 if (oldmap->timeout < MAP_MINTIMEOUT) 399 if (oldmap->timeout < MAP_MINTIMEOUT)
395 {
396 oldmap->timeout = MAP_MINTIMEOUT; 400 oldmap->timeout = MAP_MINTIMEOUT;
397 }
398# endif 401# endif
402
399 if (oldmap->timeout > MAP_MAXTIMEOUT) 403 if (oldmap->timeout > MAP_MAXTIMEOUT)
400 {
401 oldmap->timeout = MAP_MAXTIMEOUT; 404 oldmap->timeout = MAP_MAXTIMEOUT;
402 } 405
403#else 406#else
404 /* save out the map */ 407 /* save out the map */
405 swap_map (oldmap); 408 swap_map (oldmap);
406#endif /* MAP_MAXTIMEOUT */ 409#endif /* MAP_MAXTIMEOUT */
407} 410}
541 */ 544 */
542 LOG (llevError, "enter_fixed_template_map: Exit %s (%d,%d) on map %s has no source template.\n", 545 LOG (llevError, "enter_fixed_template_map: Exit %s (%d,%d) on map %s has no source template.\n",
543 &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); 546 &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path);
544 return; 547 return;
545 } 548 }
549
546 *sourcemap++ = '\0'; 550 *sourcemap++ = '\0';
547 551
548 /* If we are not coming from a template map, we can use relative directories 552 /* If we are not coming from a template map, we can use relative directories
549 * for the map to generate from. 553 * for the map to generate from.
550 */ 554 */
551 if (!exit_ob->map->templatemap) 555 if (!exit_ob->map->templatemap)
552 {
553 sourcemap = path_combine_and_normalize (exit_ob->map->path, sourcemap); 556 sourcemap = path_combine_and_normalize (exit_ob->map->path, sourcemap);
554 }
555 557
556 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord 558 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord
557 * of the exit, and the name of the map the exit is on, respectively. 559 * of the exit, and the name of the map the exit is on, respectively.
558 */ 560 */
559 sprintf (tmpnum, "%d", exit_ob->x); 561 sprintf (tmpnum, "%d", exit_ob->x);
568 570
569 /* If we are coming from another template map, use reletive paths unless 571 /* If we are coming from another template map, use reletive paths unless
570 * indicated otherwise. 572 * indicated otherwise.
571 */ 573 */
572 if (exit_ob->map->templatemap && (resultname[0] != '/')) 574 if (exit_ob->map->templatemap && (resultname[0] != '/'))
573 {
574 new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname); 575 new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname);
575 }
576 else 576 else
577 {
578 new_map_name = create_template_pathname (resultname); 577 new_map_name = create_template_pathname (resultname);
579 }
580 578
581 /* Attempt to load the map, if unable to, then 579 /* Attempt to load the map, if unable to, then
582 * create the map from the template. 580 * create the map from the template.
583 */ 581 */
584 new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE); 582 new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE);
605 */ 603 */
606 LOG (llevDebug, "enter_fixed_template_map: Exit %s (%d,%d) on map %s leads no where.\n", 604 LOG (llevDebug, "enter_fixed_template_map: Exit %s (%d,%d) on map %s leads no where.\n",
607 &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); 605 &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path);
608 } 606 }
609} 607}
610
611 608
612/* The player is trying to enter a randomly generated template map. In this 609/* The player is trying to enter a randomly generated template map. In this
613 * case, generate the map as needed. 610 * case, generate the map as needed.
614 */ 611 */
615 612

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines