Crossfire Server, Branches 1.12  R18729
check_object.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_check_object_c =
3  * "$Id: check_object.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  * CrossFire, A Multiplayer game for X-windows
8  *
9  * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10  * Copyright (C) 1992 Frank Tore Johansen
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  *
26  * The authors can be reached via e-mail at crossfire-devel@real-time.com
27  */
28 
29 /*
30  * This is the unit tests file for common/object.c
31  */
32 
33 #include <global.h>
34 #include <stdlib.h>
35 #include <check.h>
36 #include <loader.h>
37 #include <toolkit_common.h>
38 
39 #include "stringbuffer.h"
40 
41 void setup(void) {
42  cctk_setdatadir(BUILD_ROOT "lib");
43  cctk_setlog(LOGDIR "/unit/common/object.out");
44  printf("set log to %s\n", LOGDIR"/unit/common/object.out");
46 }
47 
48 void teardown(void) {
49  /* put any cleanup steps here, they will be run after each testcase */
50 }
51 
52 /*
53  * Things to check
54  * update_turn_face
55  * update_ob_speed
56  * remove_from_active_list
57  * update_object
58  * free_object
59  * count_free
60  * count_used
61  * count_active
62  * sub_weight
63  * remove_ob
64  * merge_ob
65  * insert_ob_in_map_at
66  * insert_ob_in_map
67  * replace_insert_ob_in_map
68  * get_split_ob
69  * decrease_ob_nr
70  * add_weight
71  * insert_ob_in_ob
72  * check_move_on
73  * present_arch
74  * present
75  * present_in_ob
76  * present_in_ob_by_name
77  * present_arch_in_ob
78  * flag_inv
79  * unflag_inv
80  * set_cheat
81  * find_free_spot
82  * find_first_free_spot
83  * get_search_arr
84  * find_dir
85  * distance
86  * find_dir_2
87  * absdir
88  * dirdiff
89  * can_see_monsterP
90  * can_pick
91  * object_create_clone
92  * was_destroyed
93  * find_obj_by_type_subtype
94  * get_ob_key_link
95  * get_ob_key_value
96  * set_ob_key_value
97  * item_matched_string
98  */
102 START_TEST(test_can_merge) {
103  object *ob1;
104  object *ob2;
105 
106  ob1 = cctk_create_game_object(NULL);
107  ob2 = cctk_create_game_object(NULL);
108  fail_unless(can_merge(ob1, ob2), "Should be able to merge 2 same object");
109  ob2->name = add_string("Not same name");
110  fail_unless(!can_merge(ob1, ob2), "Should not be able to merge 2 object with different names");
111  ob2 = cctk_create_game_object(NULL);
112  ob2->type++;
113  fail_unless(!can_merge(ob1, ob2), "Should not be able to merge 2 object with different types");
114  ob2 = cctk_create_game_object(NULL);
115  ob1->nrof = (1UL<<31)-1;
116  ob2->nrof = 1;
117  fail_unless(!can_merge(ob1, ob2), "Should not be able to merge 2 object if result nrof goes to 1<<31 or higher");
118  /*TESTME*/
119 }
120 END_TEST
121 
125 START_TEST(test_sum_weight) {
126  object *ob1;
127  object *ob2;
128  object *ob3;
129  object *ob4;
130  unsigned long sum;
131 
132  ob1 = cctk_create_game_object(NULL);
133  ob2 = cctk_create_game_object(NULL);
134  ob3 = cctk_create_game_object(NULL);
135  ob4 = cctk_create_game_object(NULL);
136  ob1->weight = 10; /*This should not be taken into account by sum_weight*/
137  ob1->type = CONTAINER;
138  ob1->stats.Str = 40; /*40% reduction of weight*/
139  ob2->weight = 6;
140  ob2->nrof = 10;
141  ob3->weight = 7;
142  ob4->weight = 8;
143  insert_ob_in_ob(ob2, ob1);
144  insert_ob_in_ob(ob3, ob1);
145  insert_ob_in_ob(ob4, ob1);
146  sum = sum_weight(ob1);
147  fail_unless(sum == 45, "Sum of object's inventory should be 45 ((6*10+7+8)*.6) but was %lu.", sum);
148 }
149 END_TEST
150 
154 START_TEST(test_object_get_env_recursive) {
155  object *ob1;
156  object *ob2;
157  object *ob3;
158  object *ob4;
159  object *result;
160 
161  ob1 = cctk_create_game_object(NULL);
162  ob2 = cctk_create_game_object(NULL);
163  ob3 = cctk_create_game_object(NULL);
164  ob4 = cctk_create_game_object(NULL);
165  insert_ob_in_ob(ob2, ob1);
166  insert_ob_in_ob(ob3, ob2);
167  insert_ob_in_ob(ob4, ob3);
168  result = object_get_env_recursive(ob4);
169  fail_unless(result == ob1, "Getting top level container for ob4(%p) should bring ob1(%p) but brought %p.", ob4, ob1, result);
170 }
171 END_TEST
172 
176 START_TEST(test_get_player_container) {
177  object *ob1;
178  object *ob2;
179  object *ob3;
180  object *ob4;
181  object *result;
182 
183  ob1 = cctk_create_game_object(NULL);
184  ob2 = cctk_create_game_object(NULL);
185  ob3 = cctk_create_game_object(NULL);
186  ob4 = cctk_create_game_object(NULL);
187  insert_ob_in_ob(ob2, ob1);
188  insert_ob_in_ob(ob3, ob2);
189  insert_ob_in_ob(ob4, ob3);
190  result = get_player_container(ob4);
191  fail_unless(result == NULL, "Getting containing player for ob4(%p) should bring NULL but brought %p while not contained in a player.", ob4, result);
192  ob1->type = PLAYER;
193  result = get_player_container(ob4);
194  fail_unless(result == ob1, "Getting containing player for ob4(%p) should bring ob1(%p) but brought %p while ob1 is player.", ob4, ob1, result);
195 }
196 END_TEST
197 
201 START_TEST(test_dump_object) {
202  object *ob1;
203  object *ob2;
204  object *ob3;
205  StringBuffer *sb;
206  char *result;
207 
208  ob1 = cctk_create_game_object(NULL);
209  ob2 = cctk_create_game_object(NULL);
210  ob3 = cctk_create_game_object(NULL);
211  insert_ob_in_ob(ob2, ob1);
212  insert_ob_in_ob(ob3, ob2);
213  sb = stringbuffer_new();
214  dump_object(ob1, sb);
215  result = stringbuffer_finish(sb);
216  fail_unless(strstr(result, "arch") != NULL, "The object dump should contain 'arch' but was %s", sb);
217  free(result);
218 }
219 END_TEST
220 
224 START_TEST(test_dump_all_objects) {
225  object *ob1;
226  object *ob2;
227  object *ob3;
228 
229  ob1 = cctk_create_game_object(NULL);
230  ob2 = cctk_create_game_object(NULL);
231  ob3 = cctk_create_game_object(NULL);
232  dump_all_objects(); /*Should not crash, that all i can test*/
233 }
234 END_TEST
235 
239 START_TEST(test_find_object) {
240  object *ob1;
241  object *result;
242 
243  ob1 = cctk_create_game_object(NULL);
244  ob1 = cctk_create_game_object(NULL);
245  ob1 = cctk_create_game_object(NULL);
246  result = find_object(ob1->count);
247  fail_unless(result == ob1, "Should find ob1(%p) while search for item %d but got %p", ob1, ob1->count, result);
248 }
249 END_TEST
250 
254 START_TEST(test_find_object_name) {
255  object *ob1;
256  object *result;
257 
258  ob1 = cctk_create_game_object(NULL);
259  ob1->name = add_string("This is a name");
260  ob1 = cctk_create_game_object(NULL);
261  ob1->name = add_string("This is another name");
262  ob1 = cctk_create_game_object(NULL);
263  ob1->name = add_string("This is the key name");
264  result = find_object_name(add_string("This is the key name"));
265  fail_unless(result == ob1, "Searching for object with name 'This is the key name' returned %p(%s) instead of ob1(%p)", result, result ? result->name : "null", ob1);
266 }
267 END_TEST
268 
272 START_TEST(test_free_all_object_data) {
273  /*TESTME*/
274 }
275 END_TEST
276 
280 START_TEST(test_get_owner) {
281  object *ob1;
282  object *ob2;
283 
284  ob1 = cctk_create_game_object(NULL);
285  ob2 = cctk_create_game_object(NULL);
286  set_owner(ob2, ob1);
287  CLEAR_FLAG(ob1, FLAG_REMOVED);
288  CLEAR_FLAG(ob2, FLAG_REMOVED);
289  fail_unless(get_owner(ob2) == ob1, "Owner of ob2(%p) shoud be ob1(%p) but was %p", ob2, ob1, get_owner(ob2));
290 }
291 END_TEST
292 
296 START_TEST(test_clear_owner) {
297  object *ob1;
298  object *ob2;
299 
300  ob1 = cctk_create_game_object(NULL);
301  ob2 = cctk_create_game_object(NULL);
302  set_owner(ob2, ob1);
303  fail_unless(ob2->owner != NULL, "Prior to testing clear_owner, owner of ob2 was wrongly initialized");
304  clear_owner(ob2);
305  fail_unless(ob2->owner == NULL, "After clear_owner ob2 still had an owner");
306 }
307 END_TEST
308 
312 START_TEST(test_set_owner) {
313  object *ob1;
314  object *ob2;
315 
316  ob1 = cctk_create_game_object(NULL);
317  ob2 = cctk_create_game_object(NULL);
318  set_owner(ob2, ob1);
319  fail_unless(ob2->owner == ob1, "After set_owner ob2(%p) owner should be ob1(%p) but was (%p)", ob2, ob1, ob2->owner);
320 }
321 END_TEST
322 
326 START_TEST(test_copy_owner) {
327  object *ob1;
328  object *ob2;
329  object *ob3;
330 
331  ob1 = cctk_create_game_object(NULL);
332  ob2 = cctk_create_game_object(NULL);
333  ob3 = cctk_create_game_object(NULL);
334  set_owner(ob2, ob1);
335  copy_owner(ob3, ob2);
336  fail_unless(get_owner(ob2) == get_owner(ob3), "After copy_owner, ob3 and ob2 should have same owner (ob1=%p) but got %p and %p", get_owner(ob3), get_owner(ob2));
337 }
338 END_TEST
339 
343 START_TEST(test_reset_object) {
344  object *ob1;
345 
346  ob1 = cctk_create_game_object(NULL);
347  reset_object(ob1);
348  fail_unless(ob1->name == NULL, "Field name of ob1 was not NULLified by reset_object");
349  fail_unless(ob1->name_pl == NULL, "Field name_pl of ob1 was not NULLified by reset_object");
350  fail_unless(ob1->title == NULL, "Field title of ob1 was not NULLified by reset_object");
351  fail_unless(ob1->race == NULL, "Field race of ob1 was not NULLified by reset_object");
352  fail_unless(ob1->slaying == NULL, "Field slaying of ob1 was not NULLified by reset_object");
353  fail_unless(ob1->skill == NULL, "Field skill of ob1 was not NULLified by reset_object");
354  fail_unless(ob1->msg == NULL, "Field msg of ob1 was not NULLified by reset_object");
355  fail_unless(ob1->materialname == NULL, "Field materialname of ob1 was not NULLified by reset_object");
356  fail_unless(ob1->lore == NULL, "Field lore of ob1 was not NULLified by reset_object");
357 }
358 END_TEST
359 
363 START_TEST(test_clear_object) {
364  object *ob1;
365  const char *reference;
366 
367  ob1 = cctk_create_game_object(NULL);
368  cctk_set_object_strings(ob1, "This is a test String");
369  reference = add_string("This is a test String");
370  clear_object(ob1);
371  fail_unless(ob1->name == NULL, "Field name of ob1 was not cleaned by clear_object");
372  fail_unless(ob1->name_pl == NULL, "Field name_pl of ob1 was not cleaned by clear_object");
373  fail_unless(ob1->title == NULL, "Field title of ob1 was not cleaned by clear_object");
374  fail_unless(ob1->race == NULL, "Field race of ob1 was not cleaned by clear_object");
375  fail_unless(ob1->slaying == NULL, "Field slaying of ob1 was not cleaned by clear_object");
376  fail_unless(ob1->skill == NULL, "Field skill of ob1 was not cleaned by clear_object");
377  fail_unless(ob1->msg == NULL, "Field msg of ob1 was not cleaned by clear_object");
378  fail_unless(ob1->materialname == NULL, "Field materialname of ob1 was not cleaned by clear_object");
379  fail_unless(ob1->lore == NULL, "Field lore of ob1 was not cleaned by clear_object");
380  fail_unless(query_refcount(reference) == 1, "The number of references to string should drop back to 1 but was %d", query_refcount(reference));
381 }
382 END_TEST
383 
387 START_TEST(test_copy_object) {
388  object *ob1;
389  object *ob2;
390  const char *reference;
391 
392  ob1 = cctk_create_game_object(NULL);
393  ob2 = cctk_create_game_object(NULL);
394  cctk_set_object_strings(ob1, "test String1");
395  cctk_set_object_strings(ob2, "test String2");
396  reference = add_string("test String2");
397  copy_object(ob1, ob2);
398  fail_unless(ob1->name == ob2->name, "Field name of ob1 should match ob2");
399  fail_unless(ob1->name_pl == ob2->name_pl, "Field name_pl of ob1 should match ob2");
400  fail_unless(ob1->title == ob2->title, "Field title of ob1 should match ob2");
401  fail_unless(ob1->race == ob2->race, "Field race of ob1 should match ob2");
402  fail_unless(ob1->slaying == ob2->slaying, "Field slaying of ob1 should match ob2");
403  fail_unless(ob1->skill == ob2->skill, "Field skill of ob1 should match ob2");
404  fail_unless(ob1->msg == ob2->msg, "Field msg of ob1 should match ob2");
405  fail_unless(ob1->materialname == ob2->materialname, "Field materialname of ob1 should match ob2");
406  fail_unless(ob1->lore == ob2->lore, "Field lore of ob1 should match ob2");
407  fail_unless(query_refcount(reference) == 1, "refcount of marker string is not dropped to 1 after copy object, some string field were not cleaned. refcount: %d", query_refcount(reference));
408 }
409 END_TEST
410 
415 START_TEST(test_get_object) {
416  object *ob;
417  long int i;
418 
419  ob = get_object();
420  fail_unless(ob != NULL, "Should get an object after calling get_object()");
421  fail_unless(ob->name == NULL, "Field name has not been nullified by get_object()");
422  fail_unless(ob->name_pl == NULL, "Field name_pl has not been nullified by get_object()");
423  fail_unless(ob->title == NULL, "Field title has not been nullified by get_object()");
424  fail_unless(ob->race == NULL, "Field race has not been nullified by get_object()");
425  fail_unless(ob->slaying == NULL, "Field slaying has not been nullified by get_object()");
426  fail_unless(ob->skill == NULL, "Field skill has not been nullified by get_object()");
427  fail_unless(ob->lore == NULL, "Field lore has not been nullified by get_object()");
428  fail_unless(ob->msg == NULL, "Field msg has not been nullified by get_object()");
429  fail_unless(ob->materialname == NULL, "Field materialname has not been nullified by get_object()");
430  fail_unless(ob->prev == NULL, "Field prev has not been nullified by get_object()");
431  fail_unless(ob->active_next == NULL, "Field active_next has not been nullified by get_object()");
432  fail_unless(ob->active_prev == NULL, "Field active_prev has not been nullified by get_object()");
433  /* did you really thing i'll go with only one object? */
434  /* let's go for about 2M allocations in a row, let's test roughness */
435  for (i = 0; i < 1U<<17; i++) {
436  ob = get_object();
437  fail_unless(ob != NULL, "Should get an object after calling get_object() (iteration %l)", i);
438  if (!(i&((1<<13)-1)))
439  LOG(llevDebug, "%ldk items created with get_object\n", i>>10);
440  }
441 }
442 END_TEST
443 
447 START_TEST(test_update_turn_face) {
448  object *ob1;
449  New_Face *face1;
450  New_Face *face2;
451 
452  ob1 = cctk_create_game_object("xan");
453  ob1->direction = 1;
454  update_turn_face(ob1);
455  face1 = ob1->face;
456  ob1->direction = 0;
457  update_turn_face(ob1);
458  face2 = ob1->face;
459  fail_unless(face2 != face1, "2 opposite direction should provide different faces after update_turn_face");
460 }
461 END_TEST
462 
463 #define IS_OBJECT_ACTIVE(op) (op->active_next || op->active_prev || op == active_objects)
464 
467 START_TEST(test_update_ob_speed) {
468  object *ob1;
469  object *ob2;
470  object *ob3;
471  object *ob4;
472 
473  ob1 = cctk_create_game_object(NULL);
474  ob2 = cctk_create_game_object(NULL);
475  ob3 = cctk_create_game_object(NULL);
476  ob4 = cctk_create_game_object(NULL);
477  ob1->speed = MIN_ACTIVE_SPEED;
478  update_ob_speed(ob1);
479  fail_unless(!IS_OBJECT_ACTIVE(ob1), "Object with absolute speed <=MIN_ACTIVE_SPEED(%f) should not be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
480  ob1->speed = -MIN_ACTIVE_SPEED;
481  update_ob_speed(ob1);
482  fail_unless(!IS_OBJECT_ACTIVE(ob1), "Object with absolute speed <=MIN_ACTIVE_SPEED(%f) should not be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
483  ob1->speed = MIN_ACTIVE_SPEED*2;
484  update_ob_speed(ob1);
485  fail_unless(IS_OBJECT_ACTIVE(ob1), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
486  ob2->speed = -MIN_ACTIVE_SPEED*2;
487  update_ob_speed(ob2);
488  fail_unless(IS_OBJECT_ACTIVE(ob2), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob2->speed);
489  ob4->speed = ob3->speed = ob2->speed;
490  update_ob_speed(ob3);
491  update_ob_speed(ob4);
492  fail_unless(IS_OBJECT_ACTIVE(ob3), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob3->speed);
493  fail_unless(IS_OBJECT_ACTIVE(ob4), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob4->speed);
494  ob1->speed = 0.0;
495  ob2->speed = 0.0;
496  ob3->speed = 0.0;
497  ob4->speed = 0.0;
498  update_ob_speed(ob1);
499  update_ob_speed(ob2);
500  update_ob_speed(ob3);
501  update_ob_speed(ob4);
502  fail_unless(!IS_OBJECT_ACTIVE(ob1), "Object with absolute speed 0.0 should be inactivated", ob1->speed);
503  fail_unless(!IS_OBJECT_ACTIVE(ob2), "Object with absolute speed 0.0 should be inactivated", ob2->speed);
504  fail_unless(!IS_OBJECT_ACTIVE(ob3), "Object with absolute speed 0.0 should be inactivated", ob3->speed);
505  fail_unless(!IS_OBJECT_ACTIVE(ob4), "Object with absolute speed 0.0 should be inactivated", ob4->speed);
506 }
507 END_TEST
508 
512 START_TEST(test_remove_from_active_list) {
513  object *ob1;
514 
515  ob1 = cctk_create_game_object(NULL);
516  ob1->speed = MIN_ACTIVE_SPEED*2;
517  update_ob_speed(ob1);
518  fail_unless(IS_OBJECT_ACTIVE(ob1), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
520  fail_unless(!IS_OBJECT_ACTIVE(ob1), "After call to remove_from_active_list, object should be made inactive");
521 }
522 END_TEST
523 #undef IS_OBJECT_ACTIVE
524 
528 START_TEST(test_update_object) {
529  /*TESTME (this one need a map loading, left for later*/
530 }
531 END_TEST
532 
536 START_TEST(test_free_object) {
537  object *ob1;
538  object *ob2;
539 
540  ob1 = cctk_create_game_object(NULL);
541  ob2 = cctk_create_game_object(NULL);
542  insert_ob_in_ob(ob2, ob1);
543  free_object(ob1);
544  fail_unless(QUERY_FLAG(ob1, FLAG_FREED), "Freeing ob1 should mark it freed");
545  fail_unless(QUERY_FLAG(ob2, FLAG_FREED), "Freeing ob1 should mark it's content freed");
546 }
547 END_TEST
548 
552 START_TEST(test_count_free) {
553  object *ob1;
554  int free1, free2;
555 
556  ob1 = cctk_create_game_object(NULL);
557  free1 = count_free();
558  ob1 = cctk_create_game_object(NULL);
559  free2 = count_free();
560  /* Behaviour under MEMORY_DEBUG is to allocate each object separately so
561  * both will be 0. Allow test suite to pass with this option.
562  */
563 #ifdef MEMORY_DEBUG
564  fail_unless(((free2 == 0) && (free1 == 0)), "after creating an object, the count_free() should return 0 (compiled with MEMORY_DEBUG)", free1-1, free2);
565 #else
566  fail_unless((free2 == free1-1), "after creating an object, the count_free() should return one less (%d) but returned %d", free1-1, free2);
567 #endif
568 }
569 END_TEST
570 
574 START_TEST(test_count_used) {
575  object *ob1;
576  int used1, used2;
577 
578  ob1 = cctk_create_game_object(NULL);
579  used1 = count_used();
580  ob1 = cctk_create_game_object(NULL);
581  used2 = count_used();
582  fail_unless((used2 == used1+1), "after creating an object, the count_used() should return one more (%d) but returned %d", used1-1, used2);
583 }
584 END_TEST
585 
589 START_TEST(test_count_active) {
590  object *ob1;
591  int active1, active2;
592 
593  ob1 = cctk_create_game_object(NULL);
594  ob1->speed = MIN_ACTIVE_SPEED*2;
595  update_ob_speed(ob1);
596  active1 = count_active();
597  ob1 = cctk_create_game_object(NULL);
598  ob1->speed = MIN_ACTIVE_SPEED*2;
599  update_ob_speed(ob1);
600  active2 = count_active();
601  fail_unless((active2 == active1+1), "after activating an additional object, count_active should return one less %d but returned %d", active1-1, active2);
602 }
603 END_TEST
604 
608 START_TEST(test_sub_weight) {
609  object *ob1;
610  object *ob2;
611  object *ob3;
612  object *ob4;
613  unsigned long sum;
614 
615  ob1 = cctk_create_game_object(NULL);
616  ob2 = cctk_create_game_object(NULL);
617  ob3 = cctk_create_game_object(NULL);
618  ob4 = cctk_create_game_object(NULL);
619  ob1->weight = 10; /*This should not be taken into account by sum_weight*/
620  ob1->type = CONTAINER;
621  ob2->type = CONTAINER;
622  ob3->type = CONTAINER;
623  ob1->stats.Str = 40; /*40% reduction of weight*/
624  ob2->weight = 10;
625  ob3->weight = 10;
626  ob4->weight = 10;
627  insert_ob_in_ob(ob2, ob1);
628  insert_ob_in_ob(ob3, ob2);
629  insert_ob_in_ob(ob4, ob3);
630  sum = sum_weight(ob1);
631  fail_unless(sum == 18, "Sum of object's inventory should be 18 (30*0.6+10) but was %lu.", sum);
632  sub_weight(ob4, 10);
633  fail_unless(ob1->carrying == 12, "after call to sub_weight, carrying of ob1 should be 22 but was %d", ob1->carrying);
634 }
635 END_TEST
636 
640 START_TEST(test_remove_ob) {
641  /*TESTME test those
642  * ob with more
643  * player inv
644  * remove from map
645  */
646 }
647 END_TEST
648 
652 START_TEST(test_merge_ob) {
653  object *ob1;
654  object *ob2;
655  object *ob3;
656  object *ob4;
657  object *op;
658 
659  ob1 = cctk_create_game_object(NULL);
660  ob2 = cctk_create_game_object(NULL);
661  ob3 = cctk_create_game_object(NULL);
662  ob4 = cctk_create_game_object(NULL);
663  op = cctk_create_game_object(NULL);
664  ob1->below = ob2;
665  ob2->below = ob3;
666  ob3->below = ob4;
667  ob2->above = ob1;
668  ob3->above = ob2;
669  ob4->above = ob3;
670  ob1->name = add_string("test");
671  ob2->name = add_string("test2");
672  ob3->name = add_string("test3");
673 }
674 END_TEST
675 
679 START_TEST(test_insert_ob_in_map_at) {
680  mapstruct *map;
681  object *first = NULL;
682  object *got = NULL;
683 
684  map = get_empty_map(5, 5);
685  fail_unless(map != NULL, "get_empty_map returned NULL.");
686 
687  /* Single tile object */
688  first = cctk_create_game_object("barrel");
689  fail_unless(first != NULL, "create barrel failed");
690 
691  got = insert_ob_in_map_at(first, map, NULL, 0, 0, 0);
692  fail_unless(got == first, "item shouldn't be destroyed");
693 
694  first = cctk_create_game_object("dragon");
695  fail_unless(first != NULL, "create dragon failed");
696  fail_unless(first->more != NULL, "no other body part");
697 
698  got = insert_ob_in_map_at(first, map, NULL, 0, 1, 1);
699  fail_unless(got == first, "item shouldn't be destroyed");
700 
701  fail_unless(GET_MAP_OB(map, 1, 1) == first, "item isn't on 1,1");
702  fail_unless(GET_MAP_OB(map, 2, 1) != NULL, "no item on 2,1");
703  fail_unless(GET_MAP_OB(map, 2, 1)->head == first, "head of 2,1 isn't 1,1");
704 }
705 END_TEST
706 
710 START_TEST(test_insert_ob_in_map) {
711  mapstruct *map;
712  object *first = NULL;
713  object *second = NULL;
714  object *third = NULL;
715  object *floor = NULL;
716  object *got = NULL;
717 
718  map = get_empty_map(5, 5);
719  fail_unless(map != NULL, "get_empty_map returned NULL.");
720 
721  /* First, simple tests for insertion. */
722  floor = cctk_create_game_object("woodfloor");
723  fail_unless(floor != NULL, "create woodfloor failed");
724  floor->x = 3;
725  floor->y = 3;
726 
727  got = insert_ob_in_map(floor, map, NULL, 0);
728  fail_unless(got == floor, "woodfloor shouldn't disappear");
729  fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should be first object");
730 
731  first = cctk_create_game_object("barrel");
732  fail_unless(first != NULL, "create barrel failed");
733  first->x = 3;
734  first->y = 3;
735 
736  got = insert_ob_in_map(first, map, NULL, 0);
737  fail_unless(got == first, "barrel shouldn't disappear");
738  fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should still be first object");
739  fail_unless(floor->above == first, "barrel should be above floor");
740 
741  second = cctk_create_game_object("gem");
742  fail_unless(second != NULL, "create gem failed");
743  second->nrof = 1;
744  second->x = 3;
745  second->y = 3;
746 
747  got = insert_ob_in_map(second, map, NULL, INS_ABOVE_FLOOR_ONLY);
748  fail_unless(got == second, "gem shouldn't disappear");
749  fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should still be first object");
750  fail_unless(floor->above == second, "gem should be above floor");
751  fail_unless(second->above == first, "barrel should be above gem");
752 
753  third = cctk_create_game_object("bed_1");
754  fail_unless(third != NULL, "create bed_1 failed");
755  third->nrof = 1;
756  third->x = 3;
757  third->y = 3;
758 
759  got = insert_ob_in_map(third, map, first, INS_BELOW_ORIGINATOR);
760  fail_unless(got == third, "bed_1 shouldn't disappear");
761  fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should still be first object");
762  fail_unless(third->above == first, "bed should be below barrel");
763  fail_unless(third->below == second, "bed should be above gem");
764 
765  /* Merging tests. */
766  third = cctk_create_game_object("gem");
767  fail_unless(third != NULL, "create gem failed");
768  third->nrof = 1;
769  third->x = 3;
770  third->y = 3;
771 
772  got = insert_ob_in_map(third, map, NULL, 0);
773  fail_unless(got == third, "gem shouldn't disappear");
774  fail_unless(QUERY_FLAG(second, FLAG_FREED), "first gem should have been removed.");
775  fail_unless(third->nrof == 2, "second gem should have nrof 2");
776 
777  second = cctk_create_game_object("gem");
778  fail_unless(second != NULL, "create gem failed");
779  second->nrof = 1;
780  second->x = 3;
781  second->y = 3;
782  second->value = 1;
783 
784  got = insert_ob_in_map(second, map, NULL, 0);
785  fail_unless(got == second, "modified gem shouldn't disappear");
786  fail_unless(second->nrof == 1, "modified gem should have nrof 1");
787 
788  /* Now check sacrificing, on another spot.
789  * Can't work here, as altar logic is in server.
790  * -> move that there.
791  */
792 /*
793  first = cctk_create_game_object("altar");
794  fail_unless(first != NULL, "create altar failed");
795  first->x = 2;
796  first->y = 2;
797  first->stats.food = 5;
798  first->value = 0;
799  fail_unless(insert_ob_in_map(first, map, NULL, 0) == first, "altar shouldn't disappear");
800  fail_unless(GET_MAP_MOVE_ON(map, 2, 2)&MOVE_WALK == MOVE_WALK, "floor should have MOVE_WALK set");
801 
802  second = cctk_create_game_object("food");
803  fail_unless(second != NULL, "create food failed");
804  second->nrof = 5;
805  second->x = 2;
806  second->y = 2;
807  got = insert_ob_in_map(second, map, NULL, 0);
808  fail_unless(got == NULL, "insert_ob_in_map(food) should have returned NULL");
809  fail_unless(QUERY_FLAG(second, FLAG_FREED), "food should have been freed");
810 */
811 }
812 END_TEST
813 
814 
818 START_TEST(test_replace_insert_ob_in_map) {
819  mapstruct *map;
820  object *first = NULL, *second = NULL, *third = NULL;
821  tag_t tag_first, tag_second, tag_third;
822  object *got = NULL;
823 
824  map = get_empty_map(5, 5);
825  fail_unless(map != NULL, "get_empty_map returned NULL.");
826 
827  /* Single tile object */
828  first = cctk_create_game_object("barrel");
829  fail_unless(first != NULL, "create barrel failed");
830  tag_first = first->count;
831 
832  got = insert_ob_in_map_at(first, map, NULL, 0, 0, 0);
833  fail_unless(got == first, "item shouldn't be destroyed");
834 
835  second = cctk_create_game_object("table");
836  fail_unless(second != NULL, "create table failed");
837 
838  got = insert_ob_in_map_at(second, map, NULL, 0, 0, 0);
839  fail_unless(got == second, "second item shouldn't be destroyed");
840  tag_second = second->count;
841 
842  third = cctk_create_game_object("barrel");
843  fail_unless(third != NULL, "create 2nd barrel failed");
844  got = insert_ob_in_map_at(third, map, NULL, 0, 0, 0);
845  fail_unless(got == third, "second barrel shouldn't be destroyed");
846  tag_third = third->count;
847 
848  fail_unless(GET_MAP_OB(map, 0, 0) == first, "item at 0,0 isn't barrel");
849  fail_unless(GET_MAP_OB(map, 0, 0)->above == second, "second item at 0,0 isn't table");
850  fail_unless(GET_MAP_OB(map, 0, 0)->above->above == third, "third item at 0,0 isn't barrel");
851 
852  replace_insert_ob_in_map("barrel", second);
853 
854  fail_unless(GET_MAP_OB(map, 0, 0) != first, "item at 0, 0 is still first?");
855  fail_unless(was_destroyed(first, tag_first), "1st barrel should be destroyed");
856  fail_unless(!was_destroyed(second, tag_second), "table shouldn't be destroyed");
857  fail_unless(was_destroyed(third, tag_third), "2nd barrel should be destroyed");
858 
859  fail_unless(GET_MAP_OB(map, 0, 0) != NULL, "no item at 0,0 after replace_insert_ob_in_map");
860  fail_unless(GET_MAP_OB(map, 0, 0) != second, "second at bottom at 0,0 after replace_insert_ob_in_map");
861  fail_unless(GET_MAP_OB(map, 0, 0)->above == second, "table isn't above new barrel");
862  fail_unless(strcmp(GET_MAP_OB(map, 0, 0)->arch->name, "barrel") == 0, "item at 0,0 is not a barrel after replace_insert_ob_in_map");
863 }
864 END_TEST
865 
869 START_TEST(test_get_split_ob) {
870  object *first = NULL;
871  object *second = NULL;
872  char err[50];
873 
874  first = cctk_create_game_object("gem");
875  fail_unless(first != NULL, "create gem failed");
876  first->nrof = 5;
877 
878  second = get_split_ob(first, 2, err, sizeof(err));
879  fail_unless(second != NULL, "should return an item");
880  fail_unless(second->nrof == 2, "2 expected to split");
881  fail_unless(first->nrof == 3, "3 should be left");
882 
883  second = get_split_ob(first, 3, err, sizeof(err));
884  fail_unless(second != NULL, "should return an item");
885  fail_unless(QUERY_FLAG(first, FLAG_FREED), "first should be freed");
886 
887  first = get_split_ob(second, 10, err, sizeof(err));
888  fail_unless(first == NULL, "should return NULL");
889  fail_unless(second->nrof == 3, "3 should be left");
890 }
891 END_TEST
892 
896 START_TEST(test_decrease_ob_nr) {
897  object *first = NULL;
898  object *second = NULL;
899 
900  first = cctk_create_game_object("gem");
901  fail_unless(first != NULL, "create gem failed");
902  first->nrof = 5;
903 
904  second = decrease_ob_nr(first, 3);
905  fail_unless(second == first, "gem shouldn't be destroyed");
906 
907  second = decrease_ob_nr(first, 2);
908  fail_unless(second == NULL, "decrease_ob_nr should return NULL");
909  fail_unless(QUERY_FLAG(first, FLAG_FREED), "gem should have been freed");
910 }
911 END_TEST
912 
916 START_TEST(test_add_weight) {
917  /*TESTME*/
918 }
919 END_TEST
920 
924 START_TEST(test_insert_ob_in_ob) {
925  object *container = NULL;
926  object *item = NULL;
927 
928  item = cctk_create_game_object("gem");
929  fail_unless(item != NULL, "create gem failed");
930  item->weight = 50;
931 
932  /* Bookshelves have no weight reduction. */
933  container = cctk_create_game_object("bookshelf");
934  fail_unless(container != NULL, "create bookshelf failed");
935 
936  insert_ob_in_ob(item, container);
937  fail_unless(container->inv == item, "item not inserted");
938  fail_unless(container->carrying == 50, "container should carry 50 and not %d", container->carrying);
939 
940  remove_ob(item);
941  fail_unless(container->carrying == 0, "container should carry 0 and not %d", container->carrying);
942 
943  /* Sacks have a Str of 10, so will reduce the weight. */
944  container = cctk_create_game_object("sack");
945  fail_unless(container != NULL, "create sack failed");
946 
947  insert_ob_in_ob(item, container);
948  fail_unless(container->inv == item, "item not inserted");
949  fail_unless(container->carrying == 45, "container should carry 45 and not %d", container->carrying);
950 }
951 END_TEST
952 
956 START_TEST(test_check_move_on) {
957  /*TESTME*/
958 }
959 END_TEST
960 
964 START_TEST(test_present_arch) {
965  /*TESTME*/
966 }
967 END_TEST
968 
972 START_TEST(test_present) {
973  /*TESTME*/
974 }
975 END_TEST
976 
980 START_TEST(test_present_in_ob) {
981  /*TESTME*/
982 }
983 END_TEST
984 
988 START_TEST(test_present_in_ob_by_name) {
989  /*TESTME*/
990 }
991 END_TEST
992 
996 START_TEST(test_present_arch_in_ob) {
997  /*TESTME*/
998 }
999 END_TEST
1000 
1005 START_TEST(test_flag_inv) {
1006  /*TESTME*/
1007 }
1008 END_TEST
1009 
1013 START_TEST(test_unflag_inv) {
1014  /*TESTME*/
1015 }
1016 END_TEST
1017 
1021 START_TEST(test_set_cheat) {
1022  /*TESTME*/
1023 }
1024 END_TEST
1025 
1029 START_TEST(test_find_free_spot) {
1030  /*TESTME*/
1031 }
1032 END_TEST
1033 
1037 START_TEST(test_find_first_free_spot) {
1038  /*TESTME*/
1039 }
1040 END_TEST
1041 
1045 START_TEST(test_get_search_arr) {
1046  /*TESTME*/
1047 }
1048 END_TEST
1049 
1053 START_TEST(test_find_dir) {
1054  /*TESTME*/
1055 }
1056 END_TEST
1057 
1061 START_TEST(test_distance) {
1062  /*TESTME*/
1063 }
1064 END_TEST
1065 
1069 START_TEST(test_find_dir_2) {
1070  /*TESTME*/
1071 }
1072 END_TEST
1073 
1077 START_TEST(test_absdir) {
1078  /*TESTME*/
1079 }
1080 END_TEST
1081 
1085 START_TEST(test_dirdiff) {
1086  /*TESTME*/
1087 }
1088 END_TEST
1089 
1093 START_TEST(test_can_see_monsterP) {
1094  /*TESTME*/
1095 }
1096 END_TEST
1097 
1101 START_TEST(test_can_pick) {
1102  /*TESTME*/
1103 }
1104 END_TEST
1105 
1109 START_TEST(test_object_create_clone) {
1110  /*TESTME*/
1111 }
1112 END_TEST
1113 
1117 START_TEST(test_was_destroyed) {
1118  /*TESTME*/
1119 }
1120 END_TEST
1121 
1125 START_TEST(test_find_obj_by_type_subtype) {
1126  /*TESTME*/
1127 }
1128 END_TEST
1129 
1133 START_TEST(test_get_ob_key_link) {
1134  /*TESTME*/
1135 }
1136 END_TEST
1137 
1141 START_TEST(test_get_ob_key_value) {
1142  /*TESTME*/
1143 }
1144 END_TEST
1145 
1149 START_TEST(test_set_ob_key_value) {
1150  /*TESTME*/
1151 }
1152 END_TEST
1153 
1157 START_TEST(test_item_matched_string) {
1158  object *pl;
1159  object *o1, *o2;
1160  int val;
1161 
1162  pl = cctk_create_game_object("kobold");
1163  fail_unless(pl != NULL, "couldn't create kobold");
1164  pl->contr = (player *)calloc(1, sizeof(player));
1165  fail_unless(pl->contr != NULL, "couldn't alloc contr");
1166 
1167  o1 = cctk_create_game_object("cloak");
1168  fail_unless(o1 != NULL, "couldn't find cloak archetype");
1169  o1->title = add_string("of Gorokh");
1171 
1172  val = item_matched_string(pl, o1, "all");
1173  fail_unless(val == 1, "all didn't match cloak");
1174  val = item_matched_string(pl, o1, "Gorokh");
1175  fail_unless(val == 0, "unidentified cloak matched title with value %d", val);
1176  val = item_matched_string(pl, o1, "random");
1177  fail_unless(val == 0, "unidentified cloak matched random value with value %d", val);
1178 
1180  val = item_matched_string(pl, o1, "Gorokh");
1181  fail_unless(val != 0, "identified cloak didn't match title with value %d", val);
1182 
1183  o2 = cctk_create_game_object("cloak");
1184  SET_FLAG(o2, FLAG_UNPAID);
1185  val = item_matched_string(pl, o2, "unpaid");
1186  fail_unless(val == 2, "unpaid cloak didn't match unpaid");
1187  val = item_matched_string(pl, o2, "cloak");
1188  fail_unless(val != 0, "unpaid cloak didn't match cloak with %d", val);
1189  val = item_matched_string(pl, o2, "wrong");
1190  fail_unless(val == 0, "unpaid cloak matched wrong name %d", val);
1191 }
1192 END_TEST
1193 
1194 Suite *object_suite(void) {
1195  Suite *s = suite_create("object");
1196  TCase *tc_core = tcase_create("Core");
1197 
1198  /*setup and teardown will be called before each test in testcase 'tc_core' */
1199  tcase_add_unchecked_fixture(tc_core, setup, teardown);
1200 
1201  suite_add_tcase(s, tc_core);
1202  tcase_add_test(tc_core, test_can_merge);
1203  tcase_add_test(tc_core, test_sum_weight);
1204  tcase_add_test(tc_core, test_object_get_env_recursive);
1205  tcase_add_test(tc_core, test_get_player_container);
1206  tcase_add_test(tc_core, test_dump_object);
1207  tcase_add_test(tc_core, test_dump_all_objects);
1208  tcase_add_test(tc_core, test_find_object);
1209  tcase_add_test(tc_core, test_find_object_name);
1210  tcase_add_test(tc_core, test_free_all_object_data);
1211  tcase_add_test(tc_core, test_get_owner);
1212  tcase_add_test(tc_core, test_clear_owner);
1213  tcase_add_test(tc_core, test_set_owner);
1214  tcase_add_test(tc_core, test_copy_owner);
1215  tcase_add_test(tc_core, test_reset_object);
1216  tcase_add_test(tc_core, test_clear_object);
1217  tcase_add_test(tc_core, test_copy_object);
1218  tcase_add_test(tc_core, test_get_object);
1219  tcase_add_test(tc_core, test_update_turn_face);
1220  tcase_add_test(tc_core, test_update_ob_speed);
1221  tcase_add_test(tc_core, test_remove_from_active_list);
1222  tcase_add_test(tc_core, test_update_object);
1223  tcase_add_test(tc_core, test_free_object);
1224  tcase_add_test(tc_core, test_count_free);
1225  tcase_add_test(tc_core, test_count_used);
1226  tcase_add_test(tc_core, test_count_active);
1227  tcase_add_test(tc_core, test_sub_weight);
1228  tcase_add_test(tc_core, test_remove_ob);
1229  tcase_add_test(tc_core, test_merge_ob);
1230  tcase_add_test(tc_core, test_insert_ob_in_map_at);
1231  tcase_add_test(tc_core, test_insert_ob_in_map);
1232  tcase_add_test(tc_core, test_replace_insert_ob_in_map);
1233  tcase_add_test(tc_core, test_get_split_ob);
1234  tcase_add_test(tc_core, test_decrease_ob_nr);
1235  tcase_add_test(tc_core, test_add_weight);
1236  tcase_add_test(tc_core, test_insert_ob_in_ob);
1237  tcase_add_test(tc_core, test_check_move_on);
1238  tcase_add_test(tc_core, test_present_arch);
1239  tcase_add_test(tc_core, test_present);
1240  tcase_add_test(tc_core, test_present_in_ob);
1241  tcase_add_test(tc_core, test_present_in_ob_by_name);
1242  tcase_add_test(tc_core, test_present_arch_in_ob);
1243  tcase_add_test(tc_core, test_flag_inv);
1244  tcase_add_test(tc_core, test_unflag_inv);
1245  tcase_add_test(tc_core, test_set_cheat);
1246  tcase_add_test(tc_core, test_find_free_spot);
1247  tcase_add_test(tc_core, test_find_first_free_spot);
1248  tcase_add_test(tc_core, test_get_search_arr);
1249  tcase_add_test(tc_core, test_find_dir);
1250  tcase_add_test(tc_core, test_distance);
1251  tcase_add_test(tc_core, test_find_dir_2);
1252  tcase_add_test(tc_core, test_absdir);
1253  tcase_add_test(tc_core, test_dirdiff);
1254  tcase_add_test(tc_core, test_can_see_monsterP);
1255  tcase_add_test(tc_core, test_can_pick);
1256  tcase_add_test(tc_core, test_object_create_clone);
1257  tcase_add_test(tc_core, test_was_destroyed);
1258  tcase_add_test(tc_core, test_find_obj_by_type_subtype);
1259  tcase_add_test(tc_core, test_get_ob_key_link);
1260  tcase_add_test(tc_core, test_get_ob_key_value);
1261  tcase_add_test(tc_core, test_set_ob_key_value);
1262  tcase_add_test(tc_core, test_item_matched_string);
1263 
1264  return s;
1265 }
1266 
1267 int main(void) {
1268  int nf;
1269  SRunner *sr;
1270  Suite *s = object_suite();
1271 
1272  sr = srunner_create(s);
1273  srunner_set_xml(sr, LOGDIR "/unit/common/object.xml");
1274 /* if you wish to debug, uncomment the following line. */
1275 /* srunner_set_fork_status(sr, CK_NOFORK);*/
1276 
1277  srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
1278  nf = srunner_ntests_failed(sr);
1279  srunner_free(sr);
1280  return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
1281 }
Definition: player.h:146
#define FLAG_UNPAID
Definition: define.h:532
#define INS_BELOW_ORIGINATOR
Definition: object.h:398
int count_free(void)
Definition: object.c:1433
const char * race
Definition: object.h:171
void set_owner(object *op, object *owner)
Definition: object.c:564
int count_active(void)
Definition: object.c:1465
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.c:884
#define SET_FLAG(xyz, p)
Definition: define.h:510
object * cctk_create_game_object(char *archname)
void teardown(void)
Definition: check_object.c:48
object * object_get_env_recursive(object *op)
Definition: object.c:339
void remove_from_active_list(object *op)
Definition: object.c:1070
object * insert_ob_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:1761
int query_refcount(sstring str)
Definition: shstr.c:216
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:64
object * find_object_name(const char *str)
Definition: object.c:459
int item_matched_string(object *pl, object *op, const char *name)
Definition: object.c:3901
void setup(void)
Definition: check_object.c:41
struct obj * prev
Definition: object.h:136
const char * slaying
Definition: object.h:172
struct obj * above
Definition: object.h:146
sint16 x
Definition: object.h:179
signed long sum_weight(object *op)
Definition: object.c:317
object * find_object(tag_t i)
Definition: object.c:439
END_TEST Suite * object_suite(void)
#define PLAYER
Definition: define.h:113
#define FLAG_REMOVED
Definition: define.h:528
const char * lore
Definition: object.h:176
uint32 tag_t
Definition: object.h:40
const char * title
Definition: object.h:170
void remove_ob(object *op)
Definition: object.c:1515
void clear_owner(object *op)
Definition: object.c:544
const char * name_pl
Definition: object.h:168
object * get_player_container(object *op)
Definition: object.c:356
const char * materialname
Definition: object.h:197
sint32 weight
Definition: object.h:216
void cctk_set_object_strings(object *op, char *string)
struct obj * active_prev
Definition: object.h:141
void dump_object(object *op, StringBuffer *sb)
Definition: object.c:372
#define FLAG_IDENTIFIED
Definition: define.h:557
int count_used(void)
Definition: object.c:1449
sint32 carrying
Definition: object.h:218
const char * name
Definition: object.h:167
int can_merge(object *ob1, object *ob2)
Definition: object.c:178
object * get_owner(object *op)
Definition: object.c:524
struct obj * below
Definition: object.h:145
uint32 nrof
Definition: object.h:184
sint16 y
Definition: object.h:179
struct pl * contr
Definition: object.h:134
float speed
Definition: object.h:181
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
#define CLEAR_FLAG(xyz, p)
Definition: define.h:512
#define INS_ABOVE_FLOOR_ONLY
Definition: object.h:395
object * insert_ob_in_ob(object *op, object *where)
Definition: object.c:2510
struct obj * active_next
Definition: object.h:137
object * get_object(void)
Definition: object.c:921
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
Definition: object.c:1992
const char * skill
Definition: object.h:174
void copy_owner(object *op, object *clone)
Definition: object.c:614
sint8 Str
Definition: living.h:78
sint8 direction
Definition: object.h:185
#define CONTAINER
Definition: define.h:306
struct obj * owner
Definition: object.h:228
void update_turn_face(object *op)
Definition: object.c:990
tag_t count
Definition: object.h:157
living stats
Definition: object.h:219
object * decrease_ob_nr(object *op, uint32 i)
Definition: object.c:2345
void reset_object(object *op)
Definition: object.c:639
void dump_all_objects(void)
Definition: object.c:416
const char * msg
Definition: object.h:175
void update_ob_speed(object *op)
Definition: object.c:1008
START_TEST(test_can_merge)
Definition: check_object.c:102
sstring add_string(const char *str)
Definition: shstr.c:116
void cctk_setlog(char *logfile)
#define MIN_ACTIVE_SPEED
Definition: define.h:1063
#define GET_MAP_OB(M, X, Y)
Definition: map.h:193
void clear_object(object *op)
Definition: object.c:688
struct obj * inv
Definition: object.h:148
void cctk_init_std_archetypes(void)
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:63
object * get_split_ob(object *orig_ob, uint32 nr, char *err, size_t size)
Definition: object.c:2313
void cctk_setdatadir(char *datadir)
void sub_weight(object *op, signed long weight)
Definition: object.c:1489
#define was_destroyed(op, old_tag)
Definition: object.h:94
void copy_object(object *op2, object *op)
Definition: object.c:758
void free_object(object *ob)
Definition: object.c:1238
Definition: map.h:346
New_Face * face
Definition: object.h:183
void replace_insert_ob_in_map(const char *arch_string, object *op)
Definition: object.c:2271
struct obj * more
Definition: object.h:153
sint32 value
Definition: object.h:201
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:78
#define IS_OBJECT_ACTIVE(op)
Definition: check_object.c:463
uint8 type
Definition: object.h:189
int main(void)
#define FLAG_FREED
Definition: define.h:529