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

Comparing deliantra/server/common/map.C (file contents):
Revision 1.88 by root, Fri Feb 16 19:43:40 2007 UTC vs.
Revision 1.93 by root, Sun Mar 11 02:12:44 2007 UTC

354{ 354{
355 if (!spaces) 355 if (!spaces)
356 return; 356 return;
357 357
358 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 358 for (mapspace *ms = spaces + size (); ms-- > spaces; )
359 for (object *tmp = ms->bot; tmp; ) 359 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
360 { 360 {
361 object *above = tmp->above;
362
363 /* already multipart - don't do anything more */ 361 /* already multipart - don't do anything more */
364 if (!tmp->head && !tmp->more) 362 if (!tmp->head && !tmp->more)
365 { 363 {
366 /* If there is nothing more to this object, this for loop 364 /* If there is nothing more to this object, this for loop
367 * won't do anything. 365 * won't do anything.
389 * the coding is simpler to just to it here with each part. 387 * the coding is simpler to just to it here with each part.
390 */ 388 */
391 insert_ob_in_map (op, op->map, tmp, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON); 389 insert_ob_in_map (op, op->map, tmp, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON);
392 } 390 }
393 } 391 }
394
395 tmp = above;
396 } 392 }
397} 393}
398 394
399/* 395/*
400 * Loads (ands parses) the objects into a given map from the specified 396 * Loads (ands parses) the objects into a given map from the specified
408 coroapi::cede_every (1000); // cede once in a while 404 coroapi::cede_every (1000); // cede once in a while
409 405
410 switch (f.kw) 406 switch (f.kw)
411 { 407 {
412 case KW_arch: 408 case KW_arch:
413 if (object *op = object::read (f)) 409 if (object *op = object::read (f, this))
414 { 410 {
415 if (op->inv) 411 if (op->inv)
416 sum_weight (op); 412 sum_weight (op);
417 413
418 insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); 414 insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD);
1079void 1075void
1080mapspace::update_ () 1076mapspace::update_ ()
1081{ 1077{
1082 object *tmp, *last = 0; 1078 object *tmp, *last = 0;
1083 uint8 flags = P_UPTODATE, light = 0, anywhere = 0; 1079 uint8 flags = P_UPTODATE, light = 0, anywhere = 0;
1084 facetile *top, *floor, *middle; 1080 faceidx top, floor, middle;
1085 object *top_obj, *floor_obj, *middle_obj; 1081 object *top_obj, *floor_obj, *middle_obj;
1086 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; 1082 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
1087 1083
1088 middle = blank_face; 1084 middle = blank_face;
1089 top = blank_face; 1085 top = blank_face;
1138 } 1134 }
1139 /* Find the highest visible face around. If equal 1135 /* Find the highest visible face around. If equal
1140 * visibilities, we still want the one nearer to the 1136 * visibilities, we still want the one nearer to the
1141 * top 1137 * top
1142 */ 1138 */
1143 else if (middle == blank_face || (tmp->face->visibility > middle->visibility && !anywhere)) 1139 else if (middle == blank_face || (::faces [tmp->face].visibility > ::faces [middle].visibility && !anywhere))
1144 { 1140 {
1145 middle = tmp->face; 1141 middle = tmp->face;
1146 middle_obj = tmp; 1142 middle_obj = tmp;
1147 } 1143 }
1148 } 1144 }
1673 return default_region; 1669 return default_region;
1674 1670
1675 return ::region::default_region (); 1671 return ::region::default_region ();
1676} 1672}
1677 1673
1674/* picks a random object from a style map.
1675 * Redone by MSW so it should be faster and not use static
1676 * variables to generate tables.
1677 */
1678object *
1679maptile::pick_random_object () const
1680{
1681 /* while returning a null object will result in a crash, that
1682 * is actually preferable to an infinite loop. That is because
1683 * most servers will automatically restart in case of crash.
1684 * Change the logic on getting the random space - shouldn't make
1685 * any difference, but this seems clearer to me.
1686 */
1687 for (int i = 1000; --i;)
1688 {
1689 object *pick = at (rndm (width), rndm (height)).bot;
1678 1690
1691 // do not prefer big monsters just because they are big.
1692 if (pick && pick->head_ () == pick)
1693 return pick->head_ ();
1694 }
1695
1696 // instead of crashing in the unlikely(?) case, try to return *something*
1697 return get_archetype ("blocked");
1698}
1699

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines