1 | /* |
1 | /* |
2 | * static char *rcsid_object_c = |
2 | * static char *rcsid_object_c = |
3 | * "$Id: object.C,v 1.10 2006/08/31 17:54:14 root Exp $"; |
3 | * "$Id: object.C,v 1.20 2006/09/08 18:26:22 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
37 | #endif /* win32 */ |
37 | #endif /* win32 */ |
38 | #include <object.h> |
38 | #include <object.h> |
39 | #include <funcpoint.h> |
39 | #include <funcpoint.h> |
40 | #include <skills.h> |
40 | #include <skills.h> |
41 | #include <loader.h> |
41 | #include <loader.h> |
42 | #ifdef MEMORY_DEBUG |
|
|
43 | int nroffreeobjects = 0; |
|
|
44 | int nrofallocobjects = 0; |
42 | int nrofallocobjects = 0; |
45 | #undef OBJ_EXPAND |
|
|
46 | #define OBJ_EXPAND 1 |
|
|
47 | #else |
|
|
48 | object objarray[STARTMAX]; /* All objects, allocated this way at first */ |
|
|
49 | int nroffreeobjects = STARTMAX; /* How many OBs allocated and free (free) */ |
|
|
50 | int nrofallocobjects = STARTMAX; /* How many OBs allocated (free + used) */ |
|
|
51 | #endif |
|
|
52 | |
43 | |
53 | object *objects; /* Pointer to the list of used objects */ |
44 | object *objects; /* Pointer to the list of used objects */ |
54 | object *free_objects; /* Pointer to the list of unused objects */ |
|
|
55 | object *active_objects; /* List of active objects that need to be processed */ |
45 | object *active_objects; /* List of active objects that need to be processed */ |
56 | |
46 | |
57 | short freearr_x[SIZEOFFREE]= |
47 | short freearr_x[SIZEOFFREE]= |
58 | {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1, |
48 | {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1, |
59 | 0,1,2,3,3,3,3,3,3,3,2,1,0,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1}; |
49 | 0,1,2,3,3,3,3,3,3,3,2,1,0,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1}; |
60 | short freearr_y[SIZEOFFREE]= |
50 | short freearr_y[SIZEOFFREE]= |
… | |
… | |
121 | * |
111 | * |
122 | * Improvements made with merge: Better checking on potion, and also |
112 | * Improvements made with merge: Better checking on potion, and also |
123 | * check weight |
113 | * check weight |
124 | */ |
114 | */ |
125 | |
115 | |
126 | int CAN_MERGE(object *ob1, object *ob2) { |
116 | bool |
127 | |
117 | object::can_merge (object *ob1, object *ob2) |
|
|
118 | { |
128 | /* A couple quicksanity checks */ |
119 | /* A couple quicksanity checks */ |
129 | if ((ob1 == ob2) || (ob1->type != ob2->type)) return 0; |
120 | if ((ob1 == ob2) || (ob1->type != ob2->type)) |
130 | |
|
|
131 | if (ob1->speed != ob2->speed) return 0; |
|
|
132 | /* Note sure why the following is the case - either the object has to |
|
|
133 | * be animated or have a very low speed. Is this an attempted monster |
|
|
134 | * check? |
|
|
135 | */ |
|
|
136 | if (!QUERY_FLAG(ob1,FLAG_ANIMATE) && FABS((ob1)->speed) > MIN_ACTIVE_SPEED) |
|
|
137 | return 0; |
121 | return 0; |
138 | |
122 | |
|
|
123 | if (ob1->speed != ob2->speed) |
|
|
124 | return 0; |
|
|
125 | |
139 | /* Do not merge objects if nrof would overflow. We use 1UL<<31 since that |
126 | /* Do not merge objects if nrof would overflow. We use 1UL<<31 since that |
140 | * value could not be stored in a sint32 (which unfortunately sometimes is |
127 | * value could not be stored in a sint32 (which unfortunately sometimes is |
141 | * used to store nrof). |
128 | * used to store nrof). |
142 | */ |
129 | */ |
143 | if (ob1->nrof+ob2->nrof >= 1UL<<31) |
130 | if (ob1->nrof + ob2->nrof >= 1UL << 31) |
144 | return 0; |
131 | return 0; |
145 | |
132 | |
|
|
133 | /* If the objects have been identified, set the BEEN_APPLIED flag. |
|
|
134 | * This is to the comparison of the flags below will be OK. We |
|
|
135 | * just can't ignore the been applied or identified flags, as they |
|
|
136 | * are not equal - just if it has been identified, the been_applied |
|
|
137 | * flags lose any meaning. |
|
|
138 | */ |
|
|
139 | if (QUERY_FLAG (ob1, FLAG_IDENTIFIED)) |
|
|
140 | SET_FLAG (ob1, FLAG_BEEN_APPLIED); |
|
|
141 | |
|
|
142 | if (QUERY_FLAG (ob2, FLAG_IDENTIFIED)) |
|
|
143 | SET_FLAG (ob2, FLAG_BEEN_APPLIED); |
|
|
144 | |
|
|
145 | |
|
|
146 | /* the 0x400000 on flags2 is FLAG_INV_LOCK. I don't think something |
|
|
147 | * being locked in inventory should prevent merging. |
|
|
148 | * 0x4 in flags3 is CLIENT_SENT |
|
|
149 | */ |
|
|
150 | if ((ob1->arch != ob2->arch) || |
|
|
151 | (ob1->flags[0] != ob2->flags[0]) || |
|
|
152 | (ob1->flags[1] != ob2->flags[1]) || |
|
|
153 | ((ob1->flags[2] & ~0x400000) != (ob2->flags[2] & ~0x400000)) || |
|
|
154 | ((ob1->flags[3] & ~0x4) != (ob2->flags[3] & ~0x4)) || |
|
|
155 | (ob1->name != ob2->name) || |
|
|
156 | (ob1->title != ob2->title) || |
|
|
157 | (ob1->msg != ob2->msg) || |
|
|
158 | (ob1->weight != ob2->weight) || |
|
|
159 | (memcmp (&ob1->resist, &ob2->resist, sizeof (ob1->resist)) != 0) || |
|
|
160 | (memcmp (&ob1->stats, &ob2->stats, sizeof (ob1->stats)) != 0) || |
|
|
161 | (ob1->attacktype != ob2->attacktype) || |
|
|
162 | (ob1->magic != ob2->magic) || |
|
|
163 | (ob1->slaying != ob2->slaying) || |
|
|
164 | (ob1->skill != ob2->skill) || |
|
|
165 | (ob1->value != ob2->value) || |
|
|
166 | (ob1->animation_id != ob2->animation_id) || |
|
|
167 | (ob1->client_type != ob2->client_type) || |
|
|
168 | (ob1->materialname != ob2->materialname) || |
|
|
169 | (ob1->lore != ob2->lore) || |
|
|
170 | (ob1->subtype != ob2->subtype) || |
|
|
171 | (ob1->move_type != ob2->move_type) || |
|
|
172 | (ob1->move_block != ob2->move_block) || |
|
|
173 | (ob1->move_allow != ob2->move_allow) || |
|
|
174 | (ob1->move_on != ob2->move_on) || |
|
|
175 | (ob1->move_off != ob2->move_off) || |
|
|
176 | (ob1->move_slow != ob2->move_slow) || |
|
|
177 | (ob1->move_slow_penalty != ob2->move_slow_penalty)) |
|
|
178 | return 0; |
|
|
179 | |
146 | /* This is really a spellbook check - really, we should |
180 | /* This is really a spellbook check - really, we should |
147 | * check all objects in the inventory. |
181 | * check all objects in the inventory. |
148 | */ |
182 | */ |
149 | if (ob1->inv || ob2->inv) { |
183 | if (ob1->inv || ob2->inv) |
|
|
184 | { |
150 | /* if one object has inventory but the other doesn't, not equiv */ |
185 | /* if one object has inventory but the other doesn't, not equiv */ |
151 | if ((ob1->inv && !ob2->inv) || (ob2->inv && !ob1->inv)) return 0; |
186 | if ((ob1->inv && !ob2->inv) || (ob2->inv && !ob1->inv)) |
|
|
187 | return 0; |
152 | |
188 | |
153 | /* Now check to see if the two inventory objects could merge */ |
189 | /* Now check to see if the two inventory objects could merge */ |
154 | if (!CAN_MERGE(ob1->inv, ob2->inv)) return 0; |
190 | if (!CAN_MERGE (ob1->inv, ob2->inv)) |
|
|
191 | return 0; |
155 | |
192 | |
156 | /* inventory ok - still need to check rest of this object to see |
193 | /* inventory ok - still need to check rest of this object to see |
157 | * if it is valid. |
194 | * if it is valid. |
158 | */ |
195 | */ |
159 | } |
196 | } |
160 | |
197 | |
161 | /* If the objects have been identified, set the BEEN_APPLIED flag. |
|
|
162 | * This is to the comparison of the flags below will be OK. We |
|
|
163 | * just can't ignore the been applied or identified flags, as they |
|
|
164 | * are not equal - just if it has been identified, the been_applied |
|
|
165 | * flags lose any meaning. |
|
|
166 | */ |
|
|
167 | if (QUERY_FLAG(ob1, FLAG_IDENTIFIED)) |
|
|
168 | SET_FLAG(ob1, FLAG_BEEN_APPLIED); |
|
|
169 | |
|
|
170 | if (QUERY_FLAG(ob2, FLAG_IDENTIFIED)) |
|
|
171 | SET_FLAG(ob2, FLAG_BEEN_APPLIED); |
|
|
172 | |
|
|
173 | |
|
|
174 | /* the 0x400000 on flags2 is FLAG_INV_LOCK. I don't think something |
|
|
175 | * being locked in inventory should prevent merging. |
|
|
176 | * 0x4 in flags3 is CLIENT_SENT |
|
|
177 | */ |
|
|
178 | if ((ob1->arch != ob2->arch) || |
|
|
179 | (ob1->flags[0] != ob2->flags[0]) || |
|
|
180 | (ob1->flags[1] != ob2->flags[1]) || |
|
|
181 | ((ob1->flags[2] & ~0x400000) != (ob2->flags[2] & ~ 0x400000)) || |
|
|
182 | ((ob1->flags[3] & ~0x4) != (ob2->flags[3] & ~0x4)) || |
|
|
183 | (ob1->name != ob2->name) || |
|
|
184 | (ob1->title != ob2->title) || |
|
|
185 | (ob1->msg != ob2->msg) || |
|
|
186 | (ob1->weight != ob2->weight) || |
|
|
187 | (memcmp(&ob1->resist, &ob2->resist, sizeof(ob1->resist))!=0) || |
|
|
188 | (memcmp(&ob1->stats, &ob2->stats, sizeof(ob1->stats))!=0) || |
|
|
189 | (ob1->attacktype != ob2->attacktype) || |
|
|
190 | (ob1->magic != ob2->magic) || |
|
|
191 | (ob1->slaying != ob2->slaying) || |
|
|
192 | (ob1->skill != ob2->skill) || |
|
|
193 | (ob1->value != ob2->value) || |
|
|
194 | (ob1->animation_id != ob2->animation_id) || |
|
|
195 | (ob1->client_type != ob2->client_type) || |
|
|
196 | (ob1->materialname != ob2->materialname) || |
|
|
197 | (ob1->lore != ob2->lore) || |
|
|
198 | (ob1->subtype != ob2->subtype) || |
|
|
199 | (ob1->move_type != ob2->move_type) || |
|
|
200 | (ob1->move_block != ob2->move_block) || |
|
|
201 | (ob1->move_allow != ob2->move_allow) || |
|
|
202 | (ob1->move_on != ob2->move_on) || |
|
|
203 | (ob1->move_off != ob2->move_off) || |
|
|
204 | (ob1->move_slow != ob2->move_slow) || |
|
|
205 | (ob1->move_slow_penalty != ob2->move_slow_penalty) |
|
|
206 | ) |
|
|
207 | return 0; |
|
|
208 | |
|
|
209 | /* Don't merge objects that are applied. With the new 'body' code, |
198 | /* Don't merge objects that are applied. With the new 'body' code, |
210 | * it is possible for most any character to have more than one of |
199 | * it is possible for most any character to have more than one of |
211 | * some items equipped, and we don't want those to merge. |
200 | * some items equipped, and we don't want those to merge. |
212 | */ |
201 | */ |
213 | if (QUERY_FLAG(ob1, FLAG_APPLIED) || QUERY_FLAG(ob2, FLAG_APPLIED)) |
202 | if (QUERY_FLAG (ob1, FLAG_APPLIED) || QUERY_FLAG (ob2, FLAG_APPLIED)) |
214 | return 0; |
203 | return 0; |
215 | |
204 | |
|
|
205 | /* Note sure why the following is the case - either the object has to |
|
|
206 | * be animated or have a very low speed. Is this an attempted monster |
|
|
207 | * check? |
|
|
208 | */ |
|
|
209 | if (!QUERY_FLAG (ob1, FLAG_ANIMATE) |
|
|
210 | && FABS ((ob1)->speed) > MIN_ACTIVE_SPEED) |
|
|
211 | return 0; |
|
|
212 | |
216 | switch (ob1->type) { |
213 | switch (ob1->type) |
|
|
214 | { |
217 | case SCROLL: |
215 | case SCROLL: |
218 | if (ob1->level != ob2->level) return 0; |
216 | if (ob1->level != ob2->level) |
|
|
217 | return 0; |
219 | break; |
218 | break; |
220 | |
|
|
221 | } |
219 | } |
|
|
220 | |
222 | if (ob1->key_values != NULL || ob2->key_values != NULL) { |
221 | if (ob1->key_values != NULL || ob2->key_values != NULL) |
|
|
222 | { |
223 | /* At least one of these has key_values. */ |
223 | /* At least one of these has key_values. */ |
224 | if ((ob1->key_values == NULL) != (ob2->key_values == NULL)) { |
224 | if ((ob1->key_values == NULL) != (ob2->key_values == NULL)) |
225 | /* One has fields, but the other one doesn't. */ |
225 | /* One has fields, but the other one doesn't. */ |
226 | return 0; |
226 | return 0; |
227 | } else if (!compare_ob_value_lists(ob1, ob2)) { |
227 | else if (!compare_ob_value_lists (ob1, ob2)) |
228 | return 0; |
228 | return 0; |
229 | } |
229 | } |
|
|
230 | |
|
|
231 | //TODO: generate an event or call into perl for additional checks |
|
|
232 | if (ob1->self || ob2->self) |
230 | } |
233 | { |
|
|
234 | ob1->optimise (); |
|
|
235 | ob2->optimise (); |
231 | |
236 | |
|
|
237 | if (ob1->self || ob2->self) |
|
|
238 | return 0; |
|
|
239 | } |
|
|
240 | |
232 | /* Everything passes, must be OK. */ |
241 | /* Everything passes, must be OK. */ |
233 | return 1; |
242 | return 1; |
234 | } |
243 | } |
235 | |
|
|
236 | /* |
244 | /* |
237 | * sum_weight() is a recursive function which calculates the weight |
245 | * sum_weight() is a recursive function which calculates the weight |
238 | * an object is carrying. It goes through in figures out how much |
246 | * an object is carrying. It goes through in figures out how much |
239 | * containers are carrying, and sums it up. |
247 | * containers are carrying, and sums it up. |
240 | */ |
248 | */ |
… | |
… | |
276 | return op; |
284 | return op; |
277 | } |
285 | } |
278 | |
286 | |
279 | /* |
287 | /* |
280 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
288 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
281 | * Some error messages. |
289 | * Some error messages. |
282 | * The result of the dump is stored in the static global errmsg array. |
290 | * The result of the dump is stored in the static global errmsg array. |
283 | */ |
291 | */ |
284 | |
292 | |
285 | void dump_object2(object *op) { |
293 | void dump_object2(object *op) { |
286 | errmsg[0] = 0; |
294 | errmsg[0] = 0; |
… | |
… | |
379 | * Used only by the patch command, but not all that useful. |
387 | * Used only by the patch command, but not all that useful. |
380 | * Enables features like "patch <name-of-other-player> food 999" |
388 | * Enables features like "patch <name-of-other-player> food 999" |
381 | */ |
389 | */ |
382 | |
390 | |
383 | object *find_object_name(const char *str) { |
391 | object *find_object_name(const char *str) { |
384 | const char *name=add_string(str); |
392 | const char *name = shstr::find (str); |
385 | object *op; |
393 | object *op; |
386 | for(op=objects;op!=NULL;op=op->next) |
394 | for(op=objects;op!=NULL;op=op->next) |
387 | if(op->name==name) |
395 | if(&op->name == name) |
388 | break; |
396 | break; |
389 | free_string(name); |
397 | |
390 | return op; |
398 | return op; |
391 | } |
399 | } |
392 | |
400 | |
393 | void free_all_object_data(void) { |
401 | void free_all_object_data () |
394 | #ifdef MEMORY_DEBUG |
402 | { |
395 | object *op, *next; |
403 | LOG (llevDebug, "%d allocated objects\n", nrofallocobjects); |
396 | |
|
|
397 | for (op=free_objects; op!=NULL; ) { |
|
|
398 | next=op->next; |
|
|
399 | free(op); |
|
|
400 | nrofallocobjects--; |
|
|
401 | nroffreeobjects--; |
|
|
402 | op=next; |
|
|
403 | } |
|
|
404 | #endif |
|
|
405 | LOG(llevDebug,"%d allocated objects, %d free objects, STARMAX=%d\n", |
|
|
406 | nrofallocobjects, nroffreeobjects,STARTMAX); |
|
|
407 | } |
404 | } |
408 | |
405 | |
409 | /* |
406 | /* |
410 | * Returns the object which this object marks as being the owner. |
407 | * Returns the object which this object marks as being the owner. |
411 | * A id-scheme is used to avoid pointing to objects which have been |
408 | * A id-scheme is used to avoid pointing to objects which have been |
… | |
… | |
438 | op->owner->refcount--; |
435 | op->owner->refcount--; |
439 | |
436 | |
440 | op->owner = NULL; |
437 | op->owner = NULL; |
441 | op->ownercount = 0; |
438 | op->ownercount = 0; |
442 | } |
439 | } |
443 | |
|
|
444 | |
|
|
445 | |
440 | |
446 | /* |
441 | /* |
447 | * Sets the owner and sets the skill and exp pointers to owner's current |
442 | * Sets the owner and sets the skill and exp pointers to owner's current |
448 | * skill and experience objects. |
443 | * skill and experience objects. |
449 | */ |
444 | */ |
… | |
… | |
496 | } |
491 | } |
497 | set_owner(op, owner); |
492 | set_owner(op, owner); |
498 | |
493 | |
499 | } |
494 | } |
500 | |
495 | |
501 | /* |
|
|
502 | * Resets vital variables in an object |
|
|
503 | */ |
|
|
504 | |
|
|
505 | void reset_object(object *op) { |
|
|
506 | |
|
|
507 | op->name = NULL; |
|
|
508 | op->name_pl = NULL; |
|
|
509 | op->title = NULL; |
|
|
510 | op->race = NULL; |
|
|
511 | op->slaying = NULL; |
|
|
512 | op->skill = NULL; |
|
|
513 | op->msg = NULL; |
|
|
514 | op->materialname = NULL; |
|
|
515 | op->lore = NULL; |
|
|
516 | clear_object(op); |
|
|
517 | } |
|
|
518 | |
|
|
519 | /* Zero the key_values on op, decrementing the shared-string |
496 | /* Zero the key_values on op, decrementing the shared-string |
520 | * refcounts and freeing the links. |
497 | * refcounts and freeing the links. |
521 | */ |
498 | */ |
522 | static void free_key_values(object * op) { |
499 | static void free_key_values(object * op) |
523 | key_value * i; |
500 | { |
524 | key_value * next = NULL; |
501 | for (key_value *i = op->key_values; i != 0; ) |
525 | |
502 | { |
526 | if (op->key_values == NULL) return; |
503 | key_value *next = i->next; |
|
|
504 | delete i; |
|
|
505 | i = next; |
527 | |
506 | } |
528 | for (i = op->key_values; i != NULL; i = next) { |
507 | |
529 | /* Store next *first*. */ |
|
|
530 | next = i->next; |
|
|
531 | |
|
|
532 | if (i->key) FREE_AND_CLEAR_STR(i->key); |
|
|
533 | if (i->value) FREE_AND_CLEAR_STR(i->value); |
|
|
534 | i->next = NULL; |
|
|
535 | free(i); |
|
|
536 | } |
|
|
537 | |
|
|
538 | op->key_values = NULL; |
508 | op->key_values = 0; |
539 | } |
509 | } |
540 | |
510 | |
|
|
511 | void object::clear () |
|
|
512 | { |
|
|
513 | attachable_base::clear (); |
|
|
514 | |
|
|
515 | free_key_values (this); |
|
|
516 | |
|
|
517 | name = 0; |
|
|
518 | name_pl = 0; |
|
|
519 | title = 0; |
|
|
520 | race = 0; |
|
|
521 | slaying = 0; |
|
|
522 | skill = 0; |
|
|
523 | msg = 0; |
|
|
524 | lore = 0; |
|
|
525 | custom_name = 0; |
|
|
526 | materialname = 0; |
|
|
527 | |
|
|
528 | memset (static_cast<object_pod *>(this), 0, sizeof (object_pod)); |
|
|
529 | |
|
|
530 | SET_FLAG (this, FLAG_REMOVED); |
|
|
531 | } |
|
|
532 | |
|
|
533 | void object::clone (object *destination) |
|
|
534 | { |
|
|
535 | *(object_copy *)destination = *(object_copy *)this; |
|
|
536 | *(object_pod *)destination = *(object_pod *)this; |
|
|
537 | |
|
|
538 | if (self || cb) |
|
|
539 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); |
|
|
540 | } |
541 | |
541 | |
542 | /* |
542 | /* |
543 | * clear_object() frees everything allocated by an object, and also |
543 | * clear_object() frees everything allocated by an object, and also |
544 | * clears all variables and flags to default settings. |
544 | * clears all variables and flags to default settings. |
545 | */ |
545 | */ |
546 | |
546 | |
547 | void clear_object(object *op) { |
547 | void clear_object (object *op) |
|
|
548 | { |
548 | op->clear (); |
549 | op->clear (); |
549 | |
550 | |
550 | event *evt; |
|
|
551 | event *evt2; |
|
|
552 | |
|
|
553 | /* redo this to be simpler/more efficient. Was also seeing |
|
|
554 | * crashes in the old code. Move this to the top - am |
|
|
555 | * seeing periodic crashes in this code, and would like to have |
|
|
556 | * as much info available as possible (eg, object name). |
|
|
557 | */ |
|
|
558 | for (evt = op->events; evt; evt=evt2) { |
|
|
559 | evt2 = evt->next; |
|
|
560 | |
|
|
561 | if (evt->hook != NULL) FREE_AND_CLEAR_STR(evt->hook); |
|
|
562 | if (evt->plugin != NULL) FREE_AND_CLEAR_STR(evt->plugin); |
|
|
563 | if (evt->options != NULL) FREE_AND_CLEAR_STR(evt->options); |
|
|
564 | |
|
|
565 | free(evt); |
|
|
566 | } |
|
|
567 | op->events = NULL; |
|
|
568 | |
|
|
569 | free_key_values(op); |
|
|
570 | |
|
|
571 | /* the memset will clear all these values for us, but we need |
|
|
572 | * to reduce the refcount on them. |
|
|
573 | */ |
|
|
574 | if (op->name!=NULL) FREE_AND_CLEAR_STR(op->name); |
|
|
575 | if (op->name_pl!=NULL) FREE_AND_CLEAR_STR(op->name_pl); |
|
|
576 | if (op->title != NULL) FREE_AND_CLEAR_STR(op->title); |
|
|
577 | if (op->race!=NULL) FREE_AND_CLEAR_STR(op->race); |
|
|
578 | if (op->slaying!=NULL) FREE_AND_CLEAR_STR(op->slaying); |
|
|
579 | if (op->skill!=NULL) FREE_AND_CLEAR_STR(op->skill); |
|
|
580 | if (op->msg!=NULL) FREE_AND_CLEAR_STR(op->msg); |
|
|
581 | if (op->lore!=NULL) FREE_AND_CLEAR_STR(op->lore); |
|
|
582 | if (op->materialname!= NULL) FREE_AND_CLEAR_STR(op->materialname); |
|
|
583 | |
|
|
584 | |
|
|
585 | memset((void*)op, 0, sizeof (object_special)); |
|
|
586 | /* Below here, we clear things that are not done by the memset, |
|
|
587 | * or set default values that are not zero. |
|
|
588 | */ |
|
|
589 | /* This is more or less true */ |
|
|
590 | SET_FLAG(op, FLAG_REMOVED); |
|
|
591 | |
|
|
592 | |
|
|
593 | op->contr = NULL; |
551 | op->contr = NULL; |
594 | op->below=NULL; |
552 | op->below = NULL; |
595 | op->above=NULL; |
553 | op->above = NULL; |
596 | op->inv=NULL; |
554 | op->inv = NULL; |
597 | op->events=NULL; |
|
|
598 | op->container=NULL; |
555 | op->container=NULL; |
599 | op->env=NULL; |
556 | op->env=NULL; |
600 | op->more=NULL; |
557 | op->more=NULL; |
601 | op->head=NULL; |
558 | op->head=NULL; |
602 | op->map=NULL; |
559 | op->map=NULL; |
603 | op->refcount=0; |
560 | op->refcount=0; |
604 | op->active_next = NULL; |
561 | op->active_next = NULL; |
605 | op->active_prev = NULL; |
562 | op->active_prev = NULL; |
606 | /* What is not cleared is next, prev, and count */ |
563 | /* What is not cleared is next, prev, and count */ |
607 | |
564 | |
608 | op->expmul=1.0; |
565 | op->expmul = 1.0; |
609 | op->face = blank_face; |
566 | op->face = blank_face; |
610 | op->attacked_by_count = (tag_t) -1; |
567 | op->attacked_by_count = -1; |
|
|
568 | |
611 | if (settings.casting_time) |
569 | if (settings.casting_time) |
612 | op->casting_time = -1; |
570 | op->casting_time = -1; |
613 | |
|
|
614 | } |
571 | } |
615 | |
572 | |
616 | /* |
573 | /* |
617 | * copy object first frees everything allocated by the second object, |
574 | * copy object first frees everything allocated by the second object, |
618 | * and then copies the contends of the first object into the second |
575 | * and then copies the contends of the first object into the second |
… | |
… | |
620 | * data that is malloc'd needs to be re-malloc/copied. Otherwise, |
577 | * data that is malloc'd needs to be re-malloc/copied. Otherwise, |
621 | * if the first object is freed, the pointers in the new object |
578 | * if the first object is freed, the pointers in the new object |
622 | * will point at garbage. |
579 | * will point at garbage. |
623 | */ |
580 | */ |
624 | |
581 | |
625 | void copy_object(object *op2, object *op) { |
582 | void copy_object (object *op2, object *op) |
626 | int is_freed=QUERY_FLAG(op,FLAG_FREED),is_removed=QUERY_FLAG(op,FLAG_REMOVED); |
583 | { |
627 | event *evt, *evt2, *evt_new; |
584 | bool is_freed = QUERY_FLAG (op, FLAG_FREED); |
|
|
585 | bool is_removed = QUERY_FLAG (op, FLAG_REMOVED); |
628 | |
586 | |
629 | op->clear (); |
|
|
630 | |
|
|
631 | /* Decrement the refcounts, but don't bother zeroing the fields; |
|
|
632 | they'll be overwritten by memcpy. */ |
|
|
633 | if(op->name!=NULL) free_string(op->name); |
|
|
634 | if(op->name_pl!=NULL) free_string(op->name_pl); |
|
|
635 | if(op->title!=NULL) free_string(op->title); |
|
|
636 | if(op->race!=NULL) free_string(op->race); |
|
|
637 | if(op->slaying!=NULL) free_string(op->slaying); |
|
|
638 | if(op->skill!=NULL) free_string(op->skill); |
|
|
639 | if(op->msg!=NULL) free_string(op->msg); |
|
|
640 | if(op->lore!=NULL) free_string(op->lore); |
|
|
641 | if(op->materialname != NULL) free_string(op->materialname); |
|
|
642 | if(op->custom_name != NULL) free_string(op->custom_name); |
|
|
643 | |
|
|
644 | /* Basically, same code as from clear_object() */ |
|
|
645 | for (evt = op->events; evt; evt=evt2) { |
|
|
646 | evt2 = evt->next; |
|
|
647 | |
|
|
648 | if (evt->hook != NULL) FREE_AND_CLEAR_STR(evt->hook); |
|
|
649 | if (evt->plugin != NULL) FREE_AND_CLEAR_STR(evt->plugin); |
|
|
650 | if (evt->options != NULL) FREE_AND_CLEAR_STR(evt->options); |
|
|
651 | |
|
|
652 | free(evt); |
|
|
653 | } |
|
|
654 | op->events = NULL; |
|
|
655 | |
|
|
656 | free_key_values(op); |
|
|
657 | |
|
|
658 | *(object_special *)op = *(object_special *)op2; |
|
|
659 | op2->clone (op); |
587 | op2->clone (op); |
660 | |
588 | |
661 | if(is_freed) SET_FLAG(op,FLAG_FREED); |
589 | if (is_freed) SET_FLAG (op, FLAG_FREED); |
662 | if(is_removed) SET_FLAG(op,FLAG_REMOVED); |
590 | if (is_removed) SET_FLAG (op, FLAG_REMOVED); |
663 | if(op->name!=NULL) add_refcount(op->name); |
|
|
664 | if(op->name_pl!=NULL) add_refcount(op->name_pl); |
|
|
665 | if(op->title!=NULL) add_refcount(op->title); |
|
|
666 | if(op->race!=NULL) add_refcount(op->race); |
|
|
667 | if(op->slaying!=NULL) add_refcount(op->slaying); |
|
|
668 | if(op->skill!=NULL) add_refcount(op->skill); |
|
|
669 | if(op->lore!=NULL) add_refcount(op->lore); |
|
|
670 | if(op->msg!=NULL) add_refcount(op->msg); |
|
|
671 | if(op->custom_name!=NULL) add_refcount(op->custom_name); |
|
|
672 | if (op->materialname != NULL) add_refcount(op->materialname); |
|
|
673 | |
591 | |
674 | if((op2->speed<0) && !editor) |
592 | if (op2->speed < 0) |
675 | op->speed_left=op2->speed_left-RANDOM()%200/100.0; |
593 | op->speed_left = op2->speed_left - RANDOM() % 200 / 100.0; |
676 | |
594 | |
677 | /* Copy over event information */ |
|
|
678 | evt2 = NULL; |
|
|
679 | for (evt = op2->events; evt; evt=evt->next) { |
|
|
680 | evt_new = (event *) malloc(sizeof(event)); |
|
|
681 | memcpy(evt_new, evt, sizeof(event)); |
|
|
682 | if (evt_new->hook) add_refcount(evt_new->hook); |
|
|
683 | if (evt_new->plugin) add_refcount(evt_new->plugin); |
|
|
684 | if (evt_new->options) add_refcount(evt_new->options); |
|
|
685 | evt_new->next = NULL; |
|
|
686 | |
|
|
687 | /* Try to be a little clever here, and store away the |
|
|
688 | * last event we copied, so that its simpler to update the |
|
|
689 | * pointer. |
|
|
690 | */ |
|
|
691 | if (evt2) |
|
|
692 | evt2->next = evt_new; |
|
|
693 | else |
|
|
694 | op->events = evt_new; |
|
|
695 | |
|
|
696 | evt2 = evt_new; |
|
|
697 | } |
|
|
698 | /* Copy over key_values, if any. */ |
595 | /* Copy over key_values, if any. */ |
699 | if (op2->key_values != NULL) { |
596 | if (op2->key_values != NULL) |
|
|
597 | { |
700 | key_value * tail = NULL; |
598 | key_value *tail = NULL; |
701 | key_value * i; |
599 | key_value *i; |
702 | |
600 | |
703 | op->key_values = NULL; |
601 | op->key_values = NULL; |
704 | |
602 | |
705 | for (i = op2->key_values; i != NULL; i = i->next) { |
603 | for (i = op2->key_values; i != NULL; i = i->next) |
706 | key_value * new_link = (key_value *) malloc(sizeof(key_value)); |
604 | { |
|
|
605 | key_value *new_link = new key_value; |
707 | |
606 | |
708 | new_link->next = NULL; |
607 | new_link->next = NULL; |
709 | new_link->key = add_refcount(i->key); |
608 | new_link->key = i->key; |
710 | if (i->value) |
|
|
711 | new_link->value = add_refcount(i->value); |
609 | new_link->value = i->value; |
712 | else |
|
|
713 | new_link->value = NULL; |
|
|
714 | |
610 | |
715 | /* Try and be clever here, too. */ |
611 | /* Try and be clever here, too. */ |
716 | if (op->key_values == NULL) { |
612 | if (op->key_values == NULL) |
|
|
613 | { |
717 | op->key_values = new_link; |
614 | op->key_values = new_link; |
718 | tail = new_link; |
615 | tail = new_link; |
|
|
616 | } |
719 | } else { |
617 | else |
|
|
618 | { |
720 | tail->next = new_link; |
619 | tail->next = new_link; |
721 | tail = new_link; |
620 | tail = new_link; |
722 | } |
621 | } |
723 | } |
622 | } |
724 | } |
623 | } |
725 | |
624 | |
726 | update_ob_speed(op); |
625 | update_ob_speed (op); |
727 | } |
626 | } |
728 | |
627 | |
729 | /* |
628 | object::object () |
730 | * expand_objects() allocates more objects for the list of unused objects. |
629 | { |
731 | * It is called from get_object() if the unused list is empty. |
|
|
732 | */ |
|
|
733 | |
|
|
734 | void expand_objects(void) { |
|
|
735 | int i; |
|
|
736 | object *obj; |
|
|
737 | obj = (object *) CALLOC(OBJ_EXPAND,sizeof(object)); |
|
|
738 | |
|
|
739 | if(obj==NULL) |
|
|
740 | fatal(OUT_OF_MEMORY); |
|
|
741 | free_objects=obj; |
|
|
742 | obj[0].prev=NULL; |
|
|
743 | obj[0].next= &obj[1], |
|
|
744 | SET_FLAG(&(obj[0]), FLAG_REMOVED); |
|
|
745 | SET_FLAG(&(obj[0]), FLAG_FREED); |
|
|
746 | |
|
|
747 | for(i=1;i<OBJ_EXPAND-1;i++) { |
|
|
748 | obj[i].next= &obj[i+1], |
|
|
749 | obj[i].prev= &obj[i-1], |
|
|
750 | SET_FLAG(&(obj[i]), FLAG_REMOVED); |
|
|
751 | SET_FLAG(&(obj[i]), FLAG_FREED); |
|
|
752 | } |
|
|
753 | obj[OBJ_EXPAND-1].prev= &obj[OBJ_EXPAND-2], |
|
|
754 | obj[OBJ_EXPAND-1].next=NULL, |
|
|
755 | SET_FLAG(&(obj[OBJ_EXPAND-1]), FLAG_REMOVED); |
|
|
756 | SET_FLAG(&(obj[OBJ_EXPAND-1]), FLAG_FREED); |
|
|
757 | |
|
|
758 | nrofallocobjects += OBJ_EXPAND; |
|
|
759 | nroffreeobjects += OBJ_EXPAND; |
|
|
760 | } |
|
|
761 | |
|
|
762 | /* |
|
|
763 | * get_object() grabs an object from the list of unused objects, makes |
|
|
764 | * sure it is initialised, and returns it. |
|
|
765 | * If there are no free objects, expand_objects() is called to get more. |
|
|
766 | */ |
|
|
767 | |
|
|
768 | object *get_object(void) { |
|
|
769 | object *op; |
|
|
770 | |
|
|
771 | if(free_objects==NULL) { |
|
|
772 | expand_objects(); |
|
|
773 | } |
|
|
774 | op=free_objects; |
|
|
775 | #ifdef MEMORY_DEBUG |
|
|
776 | /* The idea is hopefully by doing a realloc, the memory |
|
|
777 | * debugging program will now use the current stack trace to |
|
|
778 | * report leaks. |
|
|
779 | */ |
|
|
780 | op = realloc(op, sizeof(object)); |
|
|
781 | SET_FLAG(op, FLAG_REMOVED); |
|
|
782 | SET_FLAG(op, FLAG_FREED); |
|
|
783 | #endif |
|
|
784 | |
|
|
785 | if(!QUERY_FLAG(op,FLAG_FREED)) { |
|
|
786 | LOG(llevError,"Fatal: Getting busy object.\n"); |
|
|
787 | } |
|
|
788 | free_objects=op->next; |
|
|
789 | if(free_objects!=NULL) |
|
|
790 | free_objects->prev=NULL; |
|
|
791 | op->count= ++ob_count; |
630 | count = ++ob_count; |
792 | op->name=NULL; |
631 | |
793 | op->name_pl=NULL; |
|
|
794 | op->title=NULL; |
|
|
795 | op->race=NULL; |
|
|
796 | op->slaying=NULL; |
|
|
797 | op->skill = NULL; |
|
|
798 | op->lore=NULL; |
|
|
799 | op->msg=NULL; |
|
|
800 | op->materialname=NULL; |
|
|
801 | op->next=objects; |
632 | next = objects; |
802 | op->prev=NULL; |
633 | |
803 | op->active_next = NULL; |
|
|
804 | op->active_prev = NULL; |
|
|
805 | if(objects!=NULL) |
634 | if (objects) |
806 | objects->prev=op; |
635 | objects->prev = this; |
807 | objects=op; |
636 | |
808 | clear_object(op); |
637 | objects = this; |
|
|
638 | |
809 | SET_FLAG(op,FLAG_REMOVED); |
639 | SET_FLAG (this, FLAG_REMOVED); |
810 | nroffreeobjects--; |
640 | |
811 | return op; |
641 | expmul = 1.0; |
|
|
642 | face = blank_face; |
|
|
643 | attacked_by_count = -1; |
|
|
644 | } |
|
|
645 | |
|
|
646 | object::~object () |
|
|
647 | { |
812 | } |
648 | } |
813 | |
649 | |
814 | /* |
650 | /* |
815 | * If an object with the IS_TURNABLE() flag needs to be turned due |
651 | * If an object with the IS_TURNABLE() flag needs to be turned due |
816 | * to the closest player being on the other side, this function can |
652 | * to the closest player being on the other side, this function can |
… | |
… | |
836 | /* No reason putting the archetypes objects on the speed list, |
672 | /* No reason putting the archetypes objects on the speed list, |
837 | * since they never really need to be updated. |
673 | * since they never really need to be updated. |
838 | */ |
674 | */ |
839 | |
675 | |
840 | if (QUERY_FLAG(op, FLAG_FREED) && op->speed) { |
676 | if (QUERY_FLAG(op, FLAG_FREED) && op->speed) { |
841 | LOG(llevError,"Object %s is freed but has speed.\n", op->name); |
677 | LOG(llevError,"Object %s is freed but has speed.\n", &op->name); |
842 | #ifdef MANY_CORES |
678 | #ifdef MANY_CORES |
843 | abort(); |
679 | abort(); |
844 | #else |
680 | #else |
845 | op->speed = 0; |
681 | op->speed = 0; |
846 | #endif |
682 | #endif |
… | |
… | |
930 | * UP_OBJ_FACE: only the objects face has changed. |
766 | * UP_OBJ_FACE: only the objects face has changed. |
931 | */ |
767 | */ |
932 | |
768 | |
933 | void update_object(object *op, int action) { |
769 | void update_object(object *op, int action) { |
934 | int update_now=0, flags; |
770 | int update_now=0, flags; |
935 | MoveType move_on, move_off, move_block, move_slow; |
771 | MoveType move_on, move_off, move_block, move_slow; |
936 | |
772 | |
937 | if (op == NULL) { |
773 | if (op == NULL) { |
938 | /* this should never happen */ |
774 | /* this should never happen */ |
939 | LOG(llevDebug,"update_object() called for NULL object.\n"); |
775 | LOG(llevDebug,"update_object() called for NULL object.\n"); |
940 | return; |
776 | return; |
… | |
… | |
980 | update_now=1; |
816 | update_now=1; |
981 | |
817 | |
982 | if (QUERY_FLAG(op, FLAG_ALIVE) && !(flags & P_IS_ALIVE)) |
818 | if (QUERY_FLAG(op, FLAG_ALIVE) && !(flags & P_IS_ALIVE)) |
983 | update_now=1; |
819 | update_now=1; |
984 | |
820 | |
|
|
821 | if (op->type == SAFE_GROUND && !(flags & P_SAFE)) |
|
|
822 | update_now=1; |
|
|
823 | |
985 | if ((move_on | op->move_on) != move_on) update_now=1; |
824 | if ((move_on | op->move_on) != move_on) update_now=1; |
|
|
825 | |
986 | if ((move_off | op->move_off) != move_off) update_now=1; |
826 | if ((move_off | op->move_off) != move_off) update_now=1; |
|
|
827 | |
987 | /* This isn't perfect, but I don't expect a lot of objects to |
828 | /* This isn't perfect, but I don't expect a lot of objects to |
988 | * to have move_allow right now. |
829 | * to have move_allow right now. |
989 | */ |
830 | */ |
990 | if (((move_block | op->move_block) & ~op->move_allow) != move_block) |
831 | if (((move_block | op->move_block) & ~op->move_allow) != move_block) |
991 | update_now=1; |
832 | update_now=1; |
|
|
833 | |
992 | if ((move_slow | op->move_slow) != move_slow) update_now=1; |
834 | if ((move_slow | op->move_slow) != move_slow) |
|
|
835 | update_now=1; |
993 | } |
836 | } |
994 | /* if the object is being removed, we can't make intelligent |
837 | /* if the object is being removed, we can't make intelligent |
995 | * decisions, because remove_ob can't really pass the object |
838 | * decisions, because remove_ob can't really pass the object |
996 | * that is being removed. |
839 | * that is being removed. |
997 | */ |
840 | */ |
… | |
… | |
1023 | * |
866 | * |
1024 | * If free_inventory is set, free inventory as well. Else drop items in |
867 | * If free_inventory is set, free inventory as well. Else drop items in |
1025 | * inventory to the ground. |
868 | * inventory to the ground. |
1026 | */ |
869 | */ |
1027 | |
870 | |
|
|
871 | void |
1028 | void free_object(object *ob) { |
872 | free_object (object * ob) |
|
|
873 | { |
1029 | free_object2(ob, 0); |
874 | free_object2 (ob, 0); |
1030 | } |
875 | } |
|
|
876 | |
|
|
877 | void |
1031 | void free_object2(object *ob, int free_inventory) { |
878 | free_object2 (object * ob, int free_inventory) |
|
|
879 | { |
1032 | object *tmp,*op; |
880 | object *tmp, *op; |
1033 | |
881 | |
1034 | ob->clear (); |
|
|
1035 | |
|
|
1036 | if (!QUERY_FLAG(ob,FLAG_REMOVED)) { |
882 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
883 | { |
1037 | LOG(llevDebug,"Free object called with non removed object\n"); |
884 | LOG (llevDebug, "Free object called with non removed object\n"); |
1038 | dump_object(ob); |
885 | dump_object (ob); |
1039 | #ifdef MANY_CORES |
886 | #ifdef MANY_CORES |
1040 | abort(); |
887 | abort (); |
1041 | #endif |
888 | #endif |
1042 | } |
889 | } |
|
|
890 | |
1043 | if(QUERY_FLAG(ob,FLAG_FRIENDLY)) { |
891 | if (QUERY_FLAG (ob, FLAG_FRIENDLY)) |
|
|
892 | { |
1044 | LOG(llevMonster,"Warning: tried to free friendly object.\n"); |
893 | LOG (llevMonster, "Warning: tried to free friendly object.\n"); |
1045 | remove_friendly_object(ob); |
894 | remove_friendly_object (ob); |
1046 | } |
895 | } |
|
|
896 | |
1047 | if(QUERY_FLAG(ob,FLAG_FREED)) { |
897 | if (QUERY_FLAG (ob, FLAG_FREED)) |
|
|
898 | { |
1048 | dump_object(ob); |
899 | dump_object (ob); |
1049 | LOG(llevError,"Trying to free freed object.\n%s\n",errmsg); |
900 | LOG (llevError, "Trying to free freed object.\n%s\n", errmsg); |
1050 | return; |
901 | return; |
1051 | } |
902 | } |
|
|
903 | |
1052 | if(ob->more!=NULL) { |
904 | if (ob->more != NULL) |
|
|
905 | { |
1053 | free_object2(ob->more, free_inventory); |
906 | free_object2 (ob->more, free_inventory); |
1054 | ob->more=NULL; |
907 | ob->more = NULL; |
1055 | } |
908 | } |
|
|
909 | |
1056 | if (ob->inv) { |
910 | if (ob->inv) |
|
|
911 | { |
1057 | /* Only if the space blocks everything do we not process - |
912 | /* Only if the space blocks everything do we not process - |
1058 | * if some form of movemnt is allowed, let objects |
913 | * if some form of movement is allowed, let objects |
1059 | * drop on that space. |
914 | * drop on that space. |
1060 | */ |
915 | */ |
1061 | if (free_inventory || ob->map==NULL || ob->map->in_memory!=MAP_IN_MEMORY || |
916 | if (free_inventory || ob->map == NULL |
|
|
917 | || ob->map->in_memory != MAP_IN_MEMORY |
1062 | (GET_MAP_MOVE_BLOCK(ob->map, ob->x, ob->y) == MOVE_ALL)) |
918 | || (GET_MAP_MOVE_BLOCK (ob->map, ob->x, ob->y) == MOVE_ALL)) |
1063 | { |
919 | { |
1064 | op=ob->inv; |
920 | op = ob->inv; |
1065 | while(op!=NULL) { |
921 | |
|
|
922 | while (op != NULL) |
|
|
923 | { |
1066 | tmp=op->below; |
924 | tmp = op->below; |
1067 | remove_ob(op); |
925 | remove_ob (op); |
1068 | free_object2(op, free_inventory); |
926 | free_object2 (op, free_inventory); |
1069 | op=tmp; |
927 | op = tmp; |
1070 | } |
|
|
1071 | } |
|
|
1072 | else { /* Put objects in inventory onto this space */ |
|
|
1073 | op=ob->inv; |
|
|
1074 | while(op!=NULL) { |
|
|
1075 | tmp=op->below; |
|
|
1076 | remove_ob(op); |
|
|
1077 | if(QUERY_FLAG(op,FLAG_STARTEQUIP)||QUERY_FLAG(op,FLAG_NO_DROP) || |
|
|
1078 | op->type==RUNE || op->type==TRAP || QUERY_FLAG(op,FLAG_IS_A_TEMPLATE)) |
|
|
1079 | free_object(op); |
|
|
1080 | else { |
|
|
1081 | op->x=ob->x; |
|
|
1082 | op->y=ob->y; |
|
|
1083 | insert_ob_in_map(op,ob->map,NULL,0); /* Insert in same map as the envir */ |
|
|
1084 | } |
|
|
1085 | op=tmp; |
|
|
1086 | } |
|
|
1087 | } |
|
|
1088 | } |
928 | } |
|
|
929 | } |
|
|
930 | else |
|
|
931 | { /* Put objects in inventory onto this space */ |
|
|
932 | op = ob->inv; |
|
|
933 | |
|
|
934 | while (op != NULL) |
|
|
935 | { |
|
|
936 | tmp = op->below; |
|
|
937 | remove_ob (op); |
|
|
938 | |
|
|
939 | if (QUERY_FLAG (op, FLAG_STARTEQUIP) |
|
|
940 | || QUERY_FLAG (op, FLAG_NO_DROP) || op->type == RUNE |
|
|
941 | || op->type == TRAP || QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
|
|
942 | free_object (op); |
|
|
943 | else |
|
|
944 | { |
|
|
945 | op->x = ob->x; |
|
|
946 | op->y = ob->y; |
|
|
947 | insert_ob_in_map (op, ob->map, NULL, 0); /* Insert in same map as the envir */ |
|
|
948 | } |
|
|
949 | |
|
|
950 | op = tmp; |
|
|
951 | } |
|
|
952 | } |
|
|
953 | } |
|
|
954 | |
1089 | /* Remove object from the active list */ |
955 | /* Remove object from the active list */ |
1090 | ob->speed = 0; |
956 | ob->speed = 0; |
1091 | update_ob_speed(ob); |
957 | update_ob_speed (ob); |
1092 | |
958 | |
1093 | SET_FLAG(ob, FLAG_FREED); |
959 | SET_FLAG (ob, FLAG_FREED); |
1094 | ob->count = 0; |
960 | ob->count = 0; |
1095 | |
961 | |
1096 | /* Remove this object from the list of used objects */ |
962 | /* Remove this object from the list of used objects */ |
1097 | if(ob->prev==NULL) { |
963 | if (ob->prev == NULL) |
|
|
964 | { |
1098 | objects=ob->next; |
965 | objects = ob->next; |
|
|
966 | |
1099 | if(objects!=NULL) |
967 | if (objects != NULL) |
1100 | objects->prev=NULL; |
968 | objects->prev = NULL; |
|
|
969 | } |
|
|
970 | else |
1101 | } |
971 | { |
1102 | else { |
|
|
1103 | ob->prev->next=ob->next; |
972 | ob->prev->next = ob->next; |
|
|
973 | |
1104 | if(ob->next!=NULL) |
974 | if (ob->next != NULL) |
1105 | ob->next->prev=ob->prev; |
975 | ob->next->prev = ob->prev; |
1106 | } |
|
|
1107 | |
|
|
1108 | if(ob->name!=NULL) FREE_AND_CLEAR_STR(ob->name); |
|
|
1109 | if(ob->name_pl!=NULL) FREE_AND_CLEAR_STR(ob->name_pl); |
|
|
1110 | if(ob->title!=NULL) FREE_AND_CLEAR_STR(ob->title); |
|
|
1111 | if(ob->race!=NULL) FREE_AND_CLEAR_STR(ob->race); |
|
|
1112 | if(ob->slaying!=NULL) FREE_AND_CLEAR_STR(ob->slaying); |
|
|
1113 | if(ob->skill!=NULL) FREE_AND_CLEAR_STR(ob->skill); |
|
|
1114 | if(ob->lore!=NULL) FREE_AND_CLEAR_STR(ob->lore); |
|
|
1115 | if(ob->msg!=NULL) FREE_AND_CLEAR_STR(ob->msg); |
|
|
1116 | if(ob->materialname!=NULL) FREE_AND_CLEAR_STR(ob->materialname); |
|
|
1117 | |
|
|
1118 | |
976 | } |
1119 | /* Why aren't events freed? */ |
977 | |
1120 | free_key_values(ob); |
978 | free_key_values (ob); |
1121 | |
979 | |
1122 | #if 0 /* MEMORY_DEBUG*/ |
|
|
1123 | /* This is a nice idea. Unfortunately, a lot of the code in crossfire |
|
|
1124 | * presumes the freed_object will stick around for at least a little |
|
|
1125 | * bit |
|
|
1126 | */ |
|
|
1127 | /* this is necessary so that memory debugging programs will |
|
|
1128 | * be able to accurately report source of malloc. If we recycle |
|
|
1129 | * objects, then some other area may be doing the get_object |
|
|
1130 | * and not freeing it, but the original one that malloc'd the |
|
|
1131 | * object will get the blame. |
|
|
1132 | */ |
|
|
1133 | free(ob); |
|
|
1134 | #else |
|
|
1135 | |
|
|
1136 | /* Now link it with the free_objects list: */ |
980 | /* Now link it with the free_objects list: */ |
1137 | ob->prev=NULL; |
981 | ob->prev = 0; |
1138 | ob->next=free_objects; |
982 | ob->next = 0; |
1139 | if(free_objects!=NULL) |
|
|
1140 | free_objects->prev=ob; |
|
|
1141 | free_objects=ob; |
|
|
1142 | nroffreeobjects++; |
|
|
1143 | #endif |
|
|
1144 | } |
|
|
1145 | |
983 | |
1146 | /* |
984 | delete ob; |
1147 | * count_free() returns the number of objects on the list of free objects. |
|
|
1148 | */ |
|
|
1149 | |
|
|
1150 | int count_free(void) { |
|
|
1151 | int i=0; |
|
|
1152 | object *tmp=free_objects; |
|
|
1153 | while(tmp!=NULL) |
|
|
1154 | tmp=tmp->next, i++; |
|
|
1155 | return i; |
|
|
1156 | } |
|
|
1157 | |
|
|
1158 | /* |
|
|
1159 | * count_used() returns the number of objects on the list of used objects. |
|
|
1160 | */ |
|
|
1161 | |
|
|
1162 | int count_used(void) { |
|
|
1163 | int i=0; |
|
|
1164 | object *tmp=objects; |
|
|
1165 | while(tmp!=NULL) |
|
|
1166 | tmp=tmp->next, i++; |
|
|
1167 | return i; |
|
|
1168 | } |
|
|
1169 | |
|
|
1170 | /* |
|
|
1171 | * count_active() returns the number of objects on the list of active objects. |
|
|
1172 | */ |
|
|
1173 | |
|
|
1174 | int count_active(void) { |
|
|
1175 | int i=0; |
|
|
1176 | object *tmp=active_objects; |
|
|
1177 | while(tmp!=NULL) |
|
|
1178 | tmp=tmp->active_next, i++; |
|
|
1179 | return i; |
|
|
1180 | } |
985 | } |
1181 | |
986 | |
1182 | /* |
987 | /* |
1183 | * sub_weight() recursively (outwards) subtracts a number from the |
988 | * sub_weight() recursively (outwards) subtracts a number from the |
1184 | * weight of an object (and what is carried by it's environment(s)). |
989 | * weight of an object (and what is carried by it's environment(s)). |
… | |
… | |
1262 | /* we set up values so that it could be inserted into |
1067 | /* we set up values so that it could be inserted into |
1263 | * the map, but we don't actually do that - it is up |
1068 | * the map, but we don't actually do that - it is up |
1264 | * to the caller to decide what we want to do. |
1069 | * to the caller to decide what we want to do. |
1265 | */ |
1070 | */ |
1266 | op->x=op->env->x,op->y=op->env->y; |
1071 | op->x=op->env->x,op->y=op->env->y; |
1267 | op->ox=op->x,op->oy=op->y; |
|
|
1268 | op->map=op->env->map; |
1072 | op->map=op->env->map; |
1269 | op->above=NULL,op->below=NULL; |
1073 | op->above=NULL,op->below=NULL; |
1270 | op->env=NULL; |
1074 | op->env=NULL; |
1271 | return; |
1075 | return; |
1272 | } |
1076 | } |
… | |
… | |
1347 | (op->move_type & ~tmp->move_off & ~tmp->move_block)==0)) { |
1151 | (op->move_type & ~tmp->move_off & ~tmp->move_block)==0)) { |
1348 | |
1152 | |
1349 | move_apply(tmp, op, NULL); |
1153 | move_apply(tmp, op, NULL); |
1350 | if (was_destroyed (op, tag)) { |
1154 | if (was_destroyed (op, tag)) { |
1351 | LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " |
1155 | LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " |
1352 | "leaving object\n", tmp->name, tmp->arch->name); |
1156 | "leaving object\n", &tmp->name, &tmp->arch->name); |
1353 | } |
1157 | } |
1354 | } |
1158 | } |
1355 | |
1159 | |
1356 | /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ |
1160 | /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ |
1357 | |
1161 | |
… | |
… | |
1483 | * we set the map, that doesn't work if the location is within |
1287 | * we set the map, that doesn't work if the location is within |
1484 | * a map and this is straddling an edge. So only if coordinate |
1288 | * a map and this is straddling an edge. So only if coordinate |
1485 | * is clear wrong do we normalize it. |
1289 | * is clear wrong do we normalize it. |
1486 | */ |
1290 | */ |
1487 | if (OUT_OF_REAL_MAP(more->map, more->x, more->y)) { |
1291 | if (OUT_OF_REAL_MAP(more->map, more->x, more->y)) { |
1488 | /* Debugging information so you can see the last coordinates this object had */ |
|
|
1489 | more->ox = more->x; |
|
|
1490 | more->oy = more->y; |
|
|
1491 | more->map = get_map_from_coord(m, &more->x, &more->y); |
1292 | more->map = get_map_from_coord(m, &more->x, &more->y); |
1492 | } else if (!more->map) { |
1293 | } else if (!more->map) { |
1493 | /* For backwards compatibility - when not dealing with tiled maps, |
1294 | /* For backwards compatibility - when not dealing with tiled maps, |
1494 | * more->map should always point to the parent. |
1295 | * more->map should always point to the parent. |
1495 | */ |
1296 | */ |
… | |
… | |
1501 | LOG (llevError, "BUG: insert_ob_in_map(): inserting op->more killed op\n"); |
1302 | LOG (llevError, "BUG: insert_ob_in_map(): inserting op->more killed op\n"); |
1502 | return NULL; |
1303 | return NULL; |
1503 | } |
1304 | } |
1504 | } |
1305 | } |
1505 | CLEAR_FLAG(op,FLAG_REMOVED); |
1306 | CLEAR_FLAG(op,FLAG_REMOVED); |
1506 | |
|
|
1507 | /* Debugging information so you can see the last coordinates this object had */ |
|
|
1508 | op->ox=op->x; |
|
|
1509 | op->oy=op->y; |
|
|
1510 | |
1307 | |
1511 | /* Ideally, the caller figures this out. However, it complicates a lot |
1308 | /* Ideally, the caller figures this out. However, it complicates a lot |
1512 | * of areas of callers (eg, anything that uses find_free_spot would now |
1309 | * of areas of callers (eg, anything that uses find_free_spot would now |
1513 | * need extra work |
1310 | * need extra work |
1514 | */ |
1311 | */ |
… | |
… | |
1582 | * looks like instead of lots of conditions here. |
1379 | * looks like instead of lots of conditions here. |
1583 | * makes things faster, and effectively the same result. |
1380 | * makes things faster, and effectively the same result. |
1584 | */ |
1381 | */ |
1585 | |
1382 | |
1586 | /* Have object 'fall below' other objects that block view. |
1383 | /* Have object 'fall below' other objects that block view. |
1587 | * Unless those objects are exits, type 66 |
1384 | * Unless those objects are exits, type 66 |
1588 | * If INS_ON_TOP is used, don't do this processing |
1385 | * If INS_ON_TOP is used, don't do this processing |
1589 | * Need to find the object that in fact blocks view, otherwise |
1386 | * Need to find the object that in fact blocks view, otherwise |
1590 | * stacking is a bit odd. |
1387 | * stacking is a bit odd. |
1591 | */ |
1388 | */ |
1592 | if (!(flag & INS_ON_TOP) && |
1389 | if (!(flag & INS_ON_TOP) && |
1593 | (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && |
1390 | (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && |
1594 | (op->face && !op->face->visibility)) { |
1391 | (op->face && !op->face->visibility)) { |
1595 | for (last=top; last != floor; last=last->below) |
1392 | for (last=top; last != floor; last=last->below) |
1596 | if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; |
1393 | if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; |
1597 | /* Check to see if we found the object that blocks view, |
1394 | /* Check to see if we found the object that blocks view, |
1598 | * and make sure we have a below pointer for it so that |
1395 | * and make sure we have a below pointer for it so that |
1599 | * we can get inserted below this one, which requires we |
1396 | * we can get inserted below this one, which requires we |
1600 | * set top to the object below us. |
1397 | * set top to the object below us. |
1601 | */ |
1398 | */ |
… | |
… | |
1630 | |
1427 | |
1631 | /* If we have a floor, we know the player, if any, will be above |
1428 | /* If we have a floor, we know the player, if any, will be above |
1632 | * it, so save a few ticks and start from there. |
1429 | * it, so save a few ticks and start from there. |
1633 | */ |
1430 | */ |
1634 | if (!(flag & INS_MAP_LOAD)) |
1431 | if (!(flag & INS_MAP_LOAD)) |
1635 | for(tmp=floor?floor:GET_MAP_OB(op->map,op->x,op->y);tmp!=NULL;tmp=tmp->above) { |
1432 | for(tmp=floor?floor:GET_MAP_OB(op->map,op->x,op->y);tmp!=NULL;tmp=tmp->above) { |
1636 | if (tmp->type == PLAYER) |
1433 | if (tmp->type == PLAYER) |
1637 | tmp->contr->socket.update_look=1; |
1434 | tmp->contr->socket.update_look=1; |
1638 | } |
1435 | } |
1639 | |
1436 | |
1640 | /* If this object glows, it may affect lighting conditions that are |
1437 | /* If this object glows, it may affect lighting conditions that are |
1641 | * visible to others on this map. But update_all_los is really |
1438 | * visible to others on this map. But update_all_los is really |
1642 | * an inefficient way to do this, as it means los for all players |
1439 | * an inefficient way to do this, as it means los for all players |
1643 | * on the map will get recalculated. The players could very well |
1440 | * on the map will get recalculated. The players could very well |
… | |
… | |
1715 | object *newob; |
1512 | object *newob; |
1716 | int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); |
1513 | int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); |
1717 | |
1514 | |
1718 | if(orig_ob->nrof<nr) { |
1515 | if(orig_ob->nrof<nr) { |
1719 | sprintf(errmsg,"There are only %d %ss.", |
1516 | sprintf(errmsg,"There are only %d %ss.", |
1720 | orig_ob->nrof?orig_ob->nrof:1, orig_ob->name); |
1517 | orig_ob->nrof?orig_ob->nrof:1, &orig_ob->name); |
1721 | return NULL; |
1518 | return NULL; |
1722 | } |
1519 | } |
1723 | newob = object_create_clone(orig_ob); |
1520 | newob = object_create_clone(orig_ob); |
1724 | if((orig_ob->nrof-=nr)<1) { |
1521 | if((orig_ob->nrof-=nr)<1) { |
1725 | if ( ! is_removed) |
1522 | if ( ! is_removed) |
… | |
… | |
1872 | "Warning: Tried to insert object wrong part of multipart object.\n"); |
1669 | "Warning: Tried to insert object wrong part of multipart object.\n"); |
1873 | where = where->head; |
1670 | where = where->head; |
1874 | } |
1671 | } |
1875 | if (op->more) { |
1672 | if (op->more) { |
1876 | LOG(llevError, "Tried to insert multipart object %s (%d)\n", |
1673 | LOG(llevError, "Tried to insert multipart object %s (%d)\n", |
1877 | op->name, op->count); |
1674 | &op->name, op->count); |
1878 | return op; |
1675 | return op; |
1879 | } |
1676 | } |
1880 | CLEAR_FLAG(op, FLAG_OBJ_ORIGINAL); |
1677 | CLEAR_FLAG(op, FLAG_OBJ_ORIGINAL); |
1881 | CLEAR_FLAG(op, FLAG_REMOVED); |
1678 | CLEAR_FLAG(op, FLAG_REMOVED); |
1882 | if(op->nrof) { |
1679 | if(op->nrof) { |
… | |
… | |
1916 | op->map=NULL; |
1713 | op->map=NULL; |
1917 | op->env=where; |
1714 | op->env=where; |
1918 | op->above=NULL; |
1715 | op->above=NULL; |
1919 | op->below=NULL; |
1716 | op->below=NULL; |
1920 | op->x=0,op->y=0; |
1717 | op->x=0,op->y=0; |
1921 | op->ox=0,op->oy=0; |
|
|
1922 | |
1718 | |
1923 | /* reset the light list and los of the players on the map */ |
1719 | /* reset the light list and los of the players on the map */ |
1924 | if((op->glow_radius!=0)&&where->map) |
1720 | if((op->glow_radius!=0)&&where->map) |
1925 | { |
1721 | { |
1926 | #ifdef DEBUG_LIGHTS |
1722 | #ifdef DEBUG_LIGHTS |
… | |
… | |
1968 | { |
1764 | { |
1969 | object *tmp; |
1765 | object *tmp; |
1970 | tag_t tag; |
1766 | tag_t tag; |
1971 | mapstruct *m=op->map; |
1767 | mapstruct *m=op->map; |
1972 | int x=op->x, y=op->y; |
1768 | int x=op->x, y=op->y; |
1973 | MoveType move_on, move_slow, move_block; |
1769 | MoveType move_on, move_slow, move_block; |
1974 | |
1770 | |
1975 | if(QUERY_FLAG(op,FLAG_NO_APPLY)) |
1771 | if(QUERY_FLAG(op,FLAG_NO_APPLY)) |
1976 | return 0; |
1772 | return 0; |
1977 | |
1773 | |
1978 | tag = op->count; |
1774 | tag = op->count; |
… | |
… | |
2296 | int find_dir(mapstruct *m, int x, int y, object *exclude) { |
2092 | int find_dir(mapstruct *m, int x, int y, object *exclude) { |
2297 | int i,max=SIZEOFFREE, mflags; |
2093 | int i,max=SIZEOFFREE, mflags; |
2298 | sint16 nx, ny; |
2094 | sint16 nx, ny; |
2299 | object *tmp; |
2095 | object *tmp; |
2300 | mapstruct *mp; |
2096 | mapstruct *mp; |
2301 | MoveType blocked, move_type; |
2097 | MoveType blocked, move_type; |
2302 | |
2098 | |
2303 | if (exclude && exclude->head) { |
2099 | if (exclude && exclude->head) { |
2304 | exclude = exclude->head; |
2100 | exclude = exclude->head; |
2305 | move_type = exclude->move_type; |
2101 | move_type = exclude->move_type; |
2306 | } else { |
2102 | } else { |
… | |
… | |
2598 | fclose(tempfile); |
2394 | fclose(tempfile); |
2599 | |
2395 | |
2600 | op=get_object(); |
2396 | op=get_object(); |
2601 | |
2397 | |
2602 | object_thawer thawer (filename); |
2398 | object_thawer thawer (filename); |
|
|
2399 | |
2603 | if (thawer) |
2400 | if (thawer) |
2604 | load_object(thawer,op,LO_NEWFILE,0); |
2401 | load_object(thawer,op,0); |
|
|
2402 | |
2605 | LOG(llevDebug," load str completed, object=%s\n",op->name); |
2403 | LOG(llevDebug," load str completed, object=%s\n", &op->name); |
2606 | CLEAR_FLAG(op,FLAG_REMOVED); |
2404 | CLEAR_FLAG(op,FLAG_REMOVED); |
2607 | |
2405 | |
2608 | return op; |
2406 | return op; |
2609 | } |
2407 | } |
2610 | |
2408 | |
… | |
… | |
2649 | */ |
2447 | */ |
2650 | const char * get_ob_key_value(const object * op, const char * const key) { |
2448 | const char * get_ob_key_value(const object * op, const char * const key) { |
2651 | key_value * link; |
2449 | key_value * link; |
2652 | const char * canonical_key; |
2450 | const char * canonical_key; |
2653 | |
2451 | |
2654 | canonical_key = find_string(key); |
2452 | canonical_key = shstr::find (key); |
2655 | |
2453 | |
2656 | if (canonical_key == NULL) { |
2454 | if (canonical_key == NULL) { |
2657 | /* 1. There being a field named key on any object |
2455 | /* 1. There being a field named key on any object |
2658 | * implies there'd be a shared string to find. |
2456 | * implies there'd be a shared string to find. |
2659 | * 2. Since there isn't, no object has this field. |
2457 | * 2. Since there isn't, no object has this field. |
… | |
… | |
2682 | * Unless add_key is TRUE, it won't add fields, only change the value of existing |
2480 | * Unless add_key is TRUE, it won't add fields, only change the value of existing |
2683 | * keys. |
2481 | * keys. |
2684 | * |
2482 | * |
2685 | * Returns TRUE on success. |
2483 | * Returns TRUE on success. |
2686 | */ |
2484 | */ |
2687 | int set_ob_key_value_s(object * op, const char * canonical_key, const char * value, int add_key) { |
2485 | int set_ob_key_value_s(object * op, const shstr &canonical_key, const char * value, int add_key) { |
2688 | key_value * field = NULL, *last=NULL; |
2486 | key_value * field = NULL, *last=NULL; |
2689 | |
2487 | |
2690 | for (field=op->key_values; field != NULL; field=field->next) { |
2488 | for (field=op->key_values; field != NULL; field=field->next) { |
2691 | if (field->key != canonical_key) { |
2489 | if (field->key != canonical_key) { |
2692 | last = field; |
2490 | last = field; |
2693 | continue; |
2491 | continue; |
2694 | } |
2492 | } |
2695 | |
2493 | |
2696 | if (field->value) FREE_AND_CLEAR_STR(field->value); |
|
|
2697 | if (value) |
2494 | if (value) |
2698 | field->value = add_string(value); |
2495 | field->value = value; |
2699 | else { |
2496 | else { |
2700 | /* Basically, if the archetype has this key set, |
2497 | /* Basically, if the archetype has this key set, |
2701 | * we need to store the null value so when we save |
2498 | * we need to store the null value so when we save |
2702 | * it, we save the empty value so that when we load, |
2499 | * it, we save the empty value so that when we load, |
2703 | * we get this value back again. |
2500 | * we get this value back again. |
2704 | */ |
2501 | */ |
2705 | if (get_ob_key_link(&op->arch->clone, canonical_key)) |
2502 | if (get_ob_key_link (&op->arch->clone, canonical_key)) |
2706 | field->value = NULL; |
2503 | field->value = 0; |
2707 | else { |
2504 | else |
2708 | /* Delete this link */ |
2505 | { |
2709 | if (field->key) FREE_AND_CLEAR_STR(field->key); |
|
|
2710 | if (field->value) FREE_AND_CLEAR_STR(field->value); |
|
|
2711 | if (last) last->next = field->next; |
2506 | if (last) last->next = field->next; |
2712 | else op->key_values = field->next; |
2507 | else op->key_values = field->next; |
|
|
2508 | |
2713 | free(field); |
2509 | delete field; |
2714 | } |
2510 | } |
2715 | } |
2511 | } |
2716 | return TRUE; |
2512 | return TRUE; |
2717 | } |
2513 | } |
2718 | /* IF we get here, key doesn't exist */ |
2514 | /* IF we get here, key doesn't exist */ |
2719 | |
2515 | |
… | |
… | |
2728 | * be here. If user wants to store empty strings, |
2524 | * be here. If user wants to store empty strings, |
2729 | * should pass in "" |
2525 | * should pass in "" |
2730 | */ |
2526 | */ |
2731 | if (value == NULL) return TRUE; |
2527 | if (value == NULL) return TRUE; |
2732 | |
2528 | |
2733 | field = (key_value *) malloc(sizeof(key_value)); |
2529 | field = new key_value; |
2734 | |
2530 | |
2735 | field->key = add_refcount(canonical_key); |
2531 | field->key = canonical_key; |
2736 | field->value = add_string(value); |
2532 | field->value = value; |
2737 | /* Usual prepend-addition. */ |
2533 | /* Usual prepend-addition. */ |
2738 | field->next = op->key_values; |
2534 | field->next = op->key_values; |
2739 | op->key_values = field; |
2535 | op->key_values = field; |
2740 | |
2536 | |
2741 | return TRUE; |
2537 | return TRUE; |
… | |
… | |
2748 | * and not add new ones. |
2544 | * and not add new ones. |
2749 | * In general, should be little reason FALSE is ever passed in for add_key |
2545 | * In general, should be little reason FALSE is ever passed in for add_key |
2750 | * |
2546 | * |
2751 | * Returns TRUE on success. |
2547 | * Returns TRUE on success. |
2752 | */ |
2548 | */ |
2753 | int set_ob_key_value(object * op, const char * key, const char * value, int add_key) { |
2549 | int set_ob_key_value(object * op, const char *key, const char * value, int add_key) |
2754 | const char * canonical_key = NULL; |
2550 | { |
2755 | int floating_ref = FALSE; |
2551 | shstr key_ (key); |
2756 | int ret; |
|
|
2757 | |
|
|
2758 | /* HACK This mess is to make sure set_ob_value() passes a shared string |
|
|
2759 | * to get_ob_key_link(), without leaving a leaked refcount. |
|
|
2760 | */ |
|
|
2761 | |
|
|
2762 | canonical_key = find_string(key); |
|
|
2763 | if (canonical_key == NULL) { |
|
|
2764 | canonical_key = add_string(key); |
|
|
2765 | floating_ref = TRUE; |
|
|
2766 | } |
|
|
2767 | |
|
|
2768 | ret = set_ob_key_value_s(op, canonical_key, value, add_key); |
2552 | return set_ob_key_value_s (op, key_, value, add_key); |
2769 | |
|
|
2770 | if (floating_ref) { |
|
|
2771 | free_string(canonical_key); |
|
|
2772 | } |
|
|
2773 | |
|
|
2774 | return ret; |
|
|
2775 | } |
2553 | } |