--- deliantra/server/common/object.C 2006/09/11 01:16:20 1.25 +++ deliantra/server/common/object.C 2006/09/11 12:10:21 1.28 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_object_c = - * "$Id: object.C,v 1.25 2006/09/11 01:16:20 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -31,15 +25,14 @@ sub/add_weight will transcend the environment updating the carrying variable. */ #include -#ifndef WIN32 /* ---win32 exclude headers */ -# include -# include -# include -#endif /* win32 */ +#include +#include +#include #include #include #include #include + int nrofallocobjects = 0; object *objects; /* Pointer to the list of used objects */ @@ -251,10 +244,10 @@ * an object is carrying. It goes through in figures out how much * containers are carrying, and sums it up. */ -signed long +long sum_weight (object *op) { - signed long sum; + long sum; object *inv; for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) @@ -893,17 +886,11 @@ * that is being removed. */ else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) - { - update_now = 1; - } + update_now = 1; else if (action == UP_OBJ_FACE) - { - /* Nothing to do for that case */ - } + /* Nothing to do for that case */; else - { - LOG (llevError, "update_object called with invalid action: %d\n", action); - } + LOG (llevError, "update_object called with invalid action: %d\n", action); if (update_now) { @@ -1128,21 +1115,14 @@ void remove_ob (object *op) { - object * - tmp, * - last = NULL; - object * - otmp; - tag_t - tag; - int - check_walk_off; - mapstruct * - m; - sint16 - x, - y; + object *tmp, *last = NULL; + object *otmp; + tag_t tag; + int check_walk_off; + mapstruct *m; + + sint16 x, y; if (QUERY_FLAG (op, FLAG_REMOVED)) { @@ -1161,6 +1141,7 @@ */ abort (); } + if (op->more != NULL) remove_ob (op->more); @@ -1239,9 +1220,7 @@ /* Relink the object below us, if there is one */ if (op->below) - { - op->below->above = op->above; - } + op->below->above = op->above; else { /* Nothing below, which means we need to relink map object for this space @@ -1256,8 +1235,10 @@ dump_object (GET_MAP_OB (m, x, y)); LOG (llevError, "%s\n", errmsg); } + SET_MAP_OB (m, x, y, op->above); /* goes on above it. */ } + op->above = NULL; op->below = NULL; @@ -1266,6 +1247,7 @@ tag = op->count; check_walk_off = !QUERY_FLAG (op, FLAG_NO_APPLY); + for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) { /* No point updating the players look faces if he is the object @@ -1283,13 +1265,14 @@ CLEAR_FLAG (op, FLAG_APPLIED); tmp->container = NULL; } + tmp->contr->socket.update_look = 1; } /* See if player moving off should effect something */ if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0)) { - move_apply (tmp, op, NULL); + if (was_destroyed (op, tag)) { LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name); @@ -1300,8 +1283,10 @@ if (tmp->above == tmp) tmp->above = NULL; + last = tmp; } + /* last == NULL of there are no objects on this space */ if (last == NULL) { @@ -1318,7 +1303,6 @@ if (QUERY_FLAG (op, FLAG_BLOCKSVIEW) || (op->glow_radius != 0)) update_all_los (op->map, op->x, op->y); - } /* @@ -1440,8 +1424,7 @@ { /* The part may be on a different map. */ - object * - more = op->more; + object *more = op->more; /* We really need the caller to normalize coordinates - if * we set the map, that doesn't work if the location is within @@ -1449,9 +1432,7 @@ * is clear wrong do we normalize it. */ if (OUT_OF_REAL_MAP (more->map, more->x, more->y)) - { - more->map = get_map_from_coord (m, &more->x, &more->y); - } + more->map = get_map_from_coord (m, &more->x, &more->y); else if (!more->map) { /* For backwards compatibility - when not dealing with tiled maps, @@ -1464,6 +1445,7 @@ { if (!op->head) LOG (llevError, "BUG: insert_ob_in_map(): inserting op->more killed op\n"); + return NULL; } } @@ -1538,15 +1520,18 @@ { if (QUERY_FLAG (top, FLAG_IS_FLOOR) || QUERY_FLAG (top, FLAG_OVERLAY_FLOOR)) floor = top; + if (QUERY_FLAG (top, FLAG_NO_PICK) && (top->move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH)) && !QUERY_FLAG (top, FLAG_IS_FLOOR)) { /* We insert above top, so we want this object below this */ top = top->below; break; } + last = top; top = top->above; } + /* Don't want top to be NULL, so set it to the last valid object */ top = last; @@ -1635,11 +1620,9 @@ if (MAP_DARKNESS (op->map) && (op->glow_radius != 0)) update_all_los (op->map, op->x, op->y); - /* updates flags (blocked, alive, no magic, etc) for this map space */ update_object (op, UP_OBJ_INSERT); - /* Don't know if moving this to the end will break anything. However, * we want to have update_look set above before calling this. * @@ -1998,18 +1981,12 @@ int check_move_on (object *op, object *originator) { - object * - tmp; - tag_t - tag; - mapstruct * - m = op->map; - int - x = op->x, y = op->y; - MoveType - move_on, - move_slow, - move_block; + object *tmp; + tag_t tag; + mapstruct *m = op->map; + int x = op->x, y = op->y; + + MoveType move_on, move_slow, move_block; if (QUERY_FLAG (op, FLAG_NO_APPLY)) return 0; @@ -2049,7 +2026,8 @@ if ((tmp->move_type & MOVE_FLY_LOW) && QUERY_FLAG (tmp, FLAG_NO_PICK)) break; } - for (; tmp != NULL; tmp = tmp->below) + + for (; tmp; tmp = tmp->below) { if (tmp == op) continue; /* Can't apply yourself */ @@ -2066,18 +2044,13 @@ ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) { - float - diff; + float diff = tmp->move_slow_penalty * FABS (op->speed); - diff = tmp->move_slow_penalty * FABS (op->speed); if (op->type == PLAYER) - { - if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || - (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN))) - { - diff /= 4.0; - } - } + if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || + (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN))) + diff /= 4.0; + op->speed_left -= diff; } } @@ -2086,8 +2059,8 @@ if ((!op->move_type && tmp->move_on & MOVE_WALK) || ((op->move_type & tmp->move_on) && (op->move_type & ~tmp->move_on & ~tmp->move_block) == 0)) { - move_apply (tmp, op, originator); + if (was_destroyed (op, tag)) return 1; @@ -2099,6 +2072,7 @@ return 0; } } + return 0; }