version 1.130 | | version 1.131 |
---|
| | |
/* | | /* |
* static char *rcsid_object_c = | | * static char *rcsid_object_c = |
* "$Id: object.c,v 1.130 2006/06/07 07:10:46 mwedel Exp $"; | | * "$Id: object.c,v 1.131 2006/06/07 21:44:05 tchize Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* be animated or have a very low speed. Is this an attempted monster | | * be animated or have a very low speed. Is this an attempted monster |
* check? | | * check? |
*/ | | */ |
| | /*TODO is this check really needed?*/ |
if (!QUERY_FLAG(ob1,FLAG_ANIMATE) && FABS((ob1)->speed) > MIN_ACTIVE_SPEED) | | if (!QUERY_FLAG(ob1,FLAG_ANIMATE) && FABS((ob1)->speed) > MIN_ACTIVE_SPEED) |
return 0; | | return 0; |
| | |
| | |
/* This is really a spellbook check - really, we should | | /* This is really a spellbook check - really, we should |
* check all objects in the inventory. | | * check all objects in the inventory. |
*/ | | */ |
| | /*TODO is this check really needed?*/ |
if (ob1->inv || ob2->inv) { | | if (ob1->inv || ob2->inv) { |
/* if one object has inventory but the other doesn't, not equiv */ | | /* if one object has inventory but the other doesn't, not equiv */ |
if ((ob1->inv && !ob2->inv) || (ob2->inv && !ob1->inv)) return 0; | | if ((ob1->inv && !ob2->inv) || (ob2->inv && !ob1->inv)) return 0; |
| | |
* are not equal - just if it has been identified, the been_applied | | * are not equal - just if it has been identified, the been_applied |
* flags lose any meaning. | | * flags lose any meaning. |
*/ | | */ |
| | |
| | /*TODO is this hack on BEEN_APPLIED really needed? */ |
if (QUERY_FLAG(ob1, FLAG_IDENTIFIED)) | | if (QUERY_FLAG(ob1, FLAG_IDENTIFIED)) |
SET_FLAG(ob1, FLAG_BEEN_APPLIED); | | SET_FLAG(ob1, FLAG_BEEN_APPLIED); |
| | |
| | |
} | | } |
} | | } |
| | |
| | /*TODO should this really be limited to scrolls?*/ |
switch (ob1->type) { | | switch (ob1->type) { |
case SCROLL: | | case SCROLL: |
if (ob1->level != ob2->level) return 0; | | if (ob1->level != ob2->level) return 0; |
| | |
* an object is carrying. It goes through in figures out how much | | * an object is carrying. It goes through in figures out how much |
* containers are carrying, and sums it up. | | * containers are carrying, and sums it up. |
*/ | | */ |
| | /* TODO should check call this this are made a place where we really need reevaluaton of whole tree */ |
signed long sum_weight(object *op) { | | signed long sum_weight(object *op) { |
signed long sum; | | signed long sum; |
object *inv; | | object *inv; |
| | |
} | | } |
if (op->type == CONTAINER && op->stats.Str) | | if (op->type == CONTAINER && op->stats.Str) |
sum = (sum * (100 - op->stats.Str))/100; | | sum = (sum * (100 - op->stats.Str))/100; |
if(op->carrying != sum) | | |
op->carrying = sum; | | op->carrying = sum; |
return sum; | | return sum; |
} | | } |
| | |
* a better check. We basically keeping traversing up until we can't | | * a better check. We basically keeping traversing up until we can't |
* or find a player. | | * or find a player. |
*/ | | */ |
| | /*TODO this function is badly named*/ |
object *is_player_inv (object *op) { | | object *is_player_inv (object *op) { |
for (;op!=NULL&&op->type!=PLAYER; op=op->env) | | for (;op!=NULL&&op->type!=PLAYER; op=op->env) |
| | /*TODO this is patching the structure on the flight as side effect. Shoudln't be needed in clean code */ |
if (op->env==op) | | if (op->env==op) |
op->env = NULL; | | op->env = NULL; |
return op; | | return op; |
| | |
* anything - once an object is removed, it is basically dead anyways. | | * anything - once an object is removed, it is basically dead anyways. |
*/ | | */ |
| | |
| | /* TODO a side effect of this function is to clean owner chain for not existing anymore owner. |
| | * This is not the place to do such a cleaning |
| | */ |
object *get_owner(object *op) { | | object *get_owner(object *op) { |
if(op->owner==NULL) | | if(op->owner==NULL) |
return NULL; | | return NULL; |
| | |
if (!QUERY_FLAG(op->owner,FLAG_FREED) && !QUERY_FLAG(op->owner, FLAG_REMOVED) && | | if (!QUERY_FLAG(op->owner,FLAG_FREED) && !QUERY_FLAG(op->owner, FLAG_REMOVED) && |
op->owner->count==op->ownercount) | | op->owner->count==op->ownercount) |
return op->owner; | | return op->owner; |
| | LOG(llevError,"I had to clean an owner when in get_owner, this isn't my job.\n"); |
op->owner=NULL; | | op->owner=NULL; |
op->ownercount=0; | | op->ownercount=0; |
return NULL; | | return NULL; |
| | |
/* IF the owner still has an owner, we did not resolve to a final owner. | | /* IF the owner still has an owner, we did not resolve to a final owner. |
* so lets not add to that. | | * so lets not add to that. |
*/ | | */ |
if (owner->owner) return; | | if (owner->owner){ |
| | LOG(llevError,"owner id %d could not be resolved to a parent owner sin set_owner(). This is bad!" |
| | "owner=%p owner->owner=%p owner->ownercount=%d owner->owner->count=%d ", |
| | owner,owner->owner,owner->ownercount, owner->owner->count); |
| | return; |
| | } |
| | |
op->owner=owner; | | op->owner=owner; |
| | |
| | |
/* players don't have owners - they own themselves. Update | | /* players don't have owners - they own themselves. Update |
* as appropriate. | | * as appropriate. |
*/ | | */ |
| | /*TODO owner=self is dangerous and should be avoided*/ |
if (clone->type == PLAYER) owner=clone; | | if (clone->type == PLAYER) owner=clone; |
else return; | | else return; |
} | | } |
| | |
event *evt; | | event *evt; |
event *evt2; | | event *evt2; |
| | |
| | /*TODO this comment must be investigated*/ |
/* redo this to be simpler/more efficient. Was also seeing | | /* redo this to be simpler/more efficient. Was also seeing |
* crashes in the old code. Move this to the top - am | | * crashes in the old code. Move this to the top - am |
* seeing periodic crashes in this code, and would like to have | | * seeing periodic crashes in this code, and would like to have |