1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
233 | |
233 | |
234 | /* Returns TRUE if every key_values in wants has a partner with the same value in has. */ |
234 | /* Returns TRUE if every key_values in wants has a partner with the same value in has. */ |
235 | static bool |
235 | static bool |
236 | compare_ob_value_lists_one (const object *wants, const object *has) |
236 | compare_ob_value_lists_one (const object *wants, const object *has) |
237 | { |
237 | { |
238 | /* n-squared behaviour (see kv_get), but I'm hoping both |
238 | /* n-squared behaviour (see kv.get), but I'm hoping both |
239 | * objects with lists are rare, and lists stay short. If not, use a |
239 | * objects with lists are rare, and lists stay short. If not, use a |
240 | * different structure or at least keep the lists sorted... |
240 | * different structure or at least keep the lists sorted... |
241 | */ |
241 | */ |
242 | |
242 | |
243 | /* For each field in wants, */ |
243 | /* For each field in wants, */ |
244 | for (key_value *kv = wants->key_values; kv; kv = kv->next) |
244 | for (key_value *kv = wants->kv.first; kv; kv = kv->next) |
245 | if (has->kv_get (kv->key) != kv->value) |
245 | if (has->kv.get (kv->key) != kv->value) |
246 | return false; |
246 | return false; |
247 | |
247 | |
248 | /* If we get here, every field in wants has a matching field in has. */ |
248 | /* If we get here, every field in wants has a matching field in has. */ |
249 | return true; |
249 | return true; |
250 | } |
250 | } |
… | |
… | |
274 | */ |
274 | */ |
275 | bool object::can_merge_slow (object *ob1, object *ob2) |
275 | bool object::can_merge_slow (object *ob1, object *ob2) |
276 | { |
276 | { |
277 | /* A couple quick sanity checks */ |
277 | /* A couple quick sanity checks */ |
278 | if (ob1 == ob2 |
278 | if (ob1 == ob2 |
279 | || ob1->type != ob2->type |
279 | || ob1->type != ob2->type |
280 | || ob1->value != ob2->value |
280 | || ob1->value != ob2->value |
281 | || ob1->name != ob2->name |
281 | || ob1->name != ob2->name |
|
|
282 | || ob1->custom_name != ob2->custom_name |
282 | || fabs (ob1->speed - ob2->speed) >= MIN_ACTIVE_SPEED) |
283 | || fabs (ob1->speed - ob2->speed) >= MIN_ACTIVE_SPEED) |
283 | return 0; |
284 | return 0; |
284 | |
285 | |
285 | /* Do not merge objects if nrof would overflow, assume nrof |
286 | /* Do not merge objects if nrof would overflow, assume nrof |
286 | * is always 0 .. 2**31-1 */ |
287 | * is always 0 .. 2**31-1 */ |
… | |
… | |
372 | if (ob1->level != ob2->level) |
373 | if (ob1->level != ob2->level) |
373 | return 0; |
374 | return 0; |
374 | break; |
375 | break; |
375 | } |
376 | } |
376 | |
377 | |
377 | if (ob1->key_values || ob2->key_values) |
378 | if (!ob1->kv.empty () || !ob2->kv.empty ()) |
378 | { |
379 | { |
379 | /* At least one of these has key_values. */ |
380 | /* At least one of these has key_values. */ |
380 | if ((!ob1->key_values) != (!ob2->key_values)) |
381 | if (ob1->kv.empty () != ob2->kv.empty ()) |
381 | return 0; /* One has fields, but the other one doesn't. */ |
382 | return 0; /* One has fields, but the other one doesn't. */ |
382 | |
383 | |
383 | if (!compare_ob_value_lists (ob1, ob2)) |
384 | if (!compare_ob_value_lists (ob1, ob2)) |
384 | return 0; |
385 | return 0; |
385 | } |
386 | } |
… | |
… | |
598 | } |
599 | } |
599 | |
600 | |
600 | this->owner = owner; |
601 | this->owner = owner; |
601 | } |
602 | } |
602 | |
603 | |
603 | /* Zero the key_values on op, decrementing the shared-string |
|
|
604 | * refcounts and freeing the links. |
|
|
605 | */ |
|
|
606 | static void |
|
|
607 | free_key_values (object *op) |
|
|
608 | { |
|
|
609 | for (key_value *i = op->key_values; i; ) |
|
|
610 | { |
|
|
611 | key_value *next = i->next; |
|
|
612 | delete i; |
|
|
613 | |
|
|
614 | i = next; |
|
|
615 | } |
|
|
616 | |
|
|
617 | op->key_values = 0; |
|
|
618 | } |
|
|
619 | |
|
|
620 | /* |
604 | /* |
621 | * copy_to first frees everything allocated by the dst object, |
605 | * copy_to first frees everything allocated by the dst object, |
622 | * and then copies the contents of itself into the second |
606 | * and then copies the contents of itself into the second |
623 | * object, allocating what needs to be allocated. Basically, any |
607 | * object, allocating what needs to be allocated. Basically, any |
624 | * data that is malloc'd needs to be re-malloc/copied. Otherwise, |
608 | * data that is malloc'd needs to be re-malloc/copied. Otherwise, |
… | |
… | |
628 | void |
612 | void |
629 | object::copy_to (object *dst) |
613 | object::copy_to (object *dst) |
630 | { |
614 | { |
631 | dst->remove (); |
615 | dst->remove (); |
632 | *(object_copy *)dst = *this; |
616 | *(object_copy *)dst = *this; |
|
|
617 | |
|
|
618 | // maybe move to object_copy? |
|
|
619 | dst->kv = kv; |
|
|
620 | |
633 | dst->flag [FLAG_REMOVED] = true; |
621 | dst->flag [FLAG_REMOVED] = true; |
634 | |
|
|
635 | /* Copy over key_values, if any. */ |
|
|
636 | if (key_values) |
|
|
637 | { |
|
|
638 | key_value *tail = 0; |
|
|
639 | dst->key_values = 0; |
|
|
640 | |
|
|
641 | for (key_value *i = key_values; i; i = i->next) |
|
|
642 | { |
|
|
643 | key_value *new_link = new key_value; |
|
|
644 | |
|
|
645 | new_link->next = 0; |
|
|
646 | new_link->key = i->key; |
|
|
647 | new_link->value = i->value; |
|
|
648 | |
|
|
649 | /* Try and be clever here, too. */ |
|
|
650 | if (!dst->key_values) |
|
|
651 | { |
|
|
652 | dst->key_values = new_link; |
|
|
653 | tail = new_link; |
|
|
654 | } |
|
|
655 | else |
|
|
656 | { |
|
|
657 | tail->next = new_link; |
|
|
658 | tail = new_link; |
|
|
659 | } |
|
|
660 | } |
|
|
661 | } |
|
|
662 | |
|
|
663 | dst->activate (); |
622 | dst->activate (); |
664 | } |
623 | } |
665 | |
624 | |
666 | void |
625 | void |
667 | object::instantiate () |
626 | object::instantiate () |
… | |
… | |
778 | } |
737 | } |
779 | |
738 | |
780 | mapspace &m = op->ms (); |
739 | mapspace &m = op->ms (); |
781 | |
740 | |
782 | if (!(m.flags_ & P_UPTODATE)) |
741 | if (!(m.flags_ & P_UPTODATE)) |
783 | /* nop */; |
742 | m.update_up (); // nothing to do except copy up |
784 | else if (action == UP_OBJ_INSERT) |
743 | else if (action == UP_OBJ_INSERT) |
785 | { |
744 | { |
786 | #if 0 |
745 | #if 0 |
787 | // this is likely overkill, TODO: revisit (schmorp) |
746 | // this is likely overkill, TODO: revisit (schmorp) |
788 | if ((op->flag [FLAG_BLOCKSVIEW] && !(m.flags_ & P_BLOCKSVIEW)) |
747 | if ((op->flag [FLAG_BLOCKSVIEW] && !(m.flags_ & P_BLOCKSVIEW)) |
… | |
… | |
809 | * that is being removed. |
768 | * that is being removed. |
810 | */ |
769 | */ |
811 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
770 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
812 | m.invalidate (); |
771 | m.invalidate (); |
813 | else if (action == UP_OBJ_FACE) |
772 | else if (action == UP_OBJ_FACE) |
814 | /* Nothing to do for that case */ ; |
773 | m.update_up (); // nothing to do for that case, except copy up |
815 | else |
774 | else |
816 | LOG (llevError, "update_object called with invalid action: %d\n", action); |
775 | LOG (llevError, "update_object called with invalid action: %d\n", action); |
817 | |
776 | |
818 | if (op->more) |
777 | if (op->more) |
819 | update_object (op->more, action); |
778 | update_object (op->more, action); |
… | |
… | |
830 | |
789 | |
831 | object::~object () |
790 | object::~object () |
832 | { |
791 | { |
833 | unlink (); |
792 | unlink (); |
834 | |
793 | |
835 | free_key_values (this); |
794 | kv.clear (); |
836 | } |
795 | } |
837 | |
796 | |
838 | void object::link () |
797 | void object::link () |
839 | { |
798 | { |
840 | assert (!index);//D |
799 | assert (!index);//D |
… | |
… | |
939 | * if some form of movement is allowed, let objects |
898 | * if some form of movement is allowed, let objects |
940 | * drop on that space. |
899 | * drop on that space. |
941 | */ |
900 | */ |
942 | if (!drop_to_ground |
901 | if (!drop_to_ground |
943 | || !map |
902 | || !map |
944 | || map->in_memory != MAP_ACTIVE |
903 | || !map->linkable () |
945 | || map->no_drop |
904 | || map->no_drop |
946 | || ms ().move_block == MOVE_ALL) |
905 | || ms ().move_block == MOVE_ALL) |
947 | { |
906 | { |
948 | while (inv) |
907 | while (inv) |
949 | inv->destroy (); |
908 | inv->destroy (); |
… | |
… | |
1045 | li->count = count; |
1004 | li->count = count; |
1046 | |
1005 | |
1047 | freelist = li; |
1006 | freelist = li; |
1048 | ++free_count; |
1007 | ++free_count; |
1049 | } |
1008 | } |
1050 | |
|
|
1051 | static struct freed_map : maptile |
|
|
1052 | { |
|
|
1053 | freed_map () |
|
|
1054 | : maptile (3, 3) |
|
|
1055 | { |
|
|
1056 | path = "<freed objects map>"; |
|
|
1057 | name = "/internal/freed_objects_map"; |
|
|
1058 | no_drop = 1; |
|
|
1059 | no_reset = 1; |
|
|
1060 | |
|
|
1061 | in_memory = MAP_ACTIVE; |
|
|
1062 | } |
|
|
1063 | |
|
|
1064 | ~freed_map () |
|
|
1065 | { |
|
|
1066 | destroy (); |
|
|
1067 | } |
|
|
1068 | } freed_map; // freed objects are moved here to avoid crashes |
|
|
1069 | |
1009 | |
1070 | void |
1010 | void |
1071 | object::do_destroy () |
1011 | object::do_destroy () |
1072 | { |
1012 | { |
1073 | if (flag [FLAG_IS_LINKED]) |
1013 | if (flag [FLAG_IS_LINKED]) |
… | |
… | |
1239 | |
1179 | |
1240 | above = 0; |
1180 | above = 0; |
1241 | below = 0; |
1181 | below = 0; |
1242 | |
1182 | |
1243 | ms.invalidate (); |
1183 | ms.invalidate (); |
1244 | |
|
|
1245 | if (map->in_memory == MAP_SAVING) |
|
|
1246 | return; |
|
|
1247 | |
1184 | |
1248 | int check_walk_off = !flag [FLAG_NO_APPLY]; |
1185 | int check_walk_off = !flag [FLAG_NO_APPLY]; |
1249 | |
1186 | |
1250 | if (object *pl = ms.player ()) |
1187 | if (object *pl = ms.player ()) |
1251 | { |
1188 | { |
… | |
… | |
1386 | { |
1323 | { |
1387 | op->remove (); |
1324 | op->remove (); |
1388 | |
1325 | |
1389 | if (m == &freed_map)//D TODO: remove soon |
1326 | if (m == &freed_map)//D TODO: remove soon |
1390 | {//D |
1327 | {//D |
1391 | LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D |
1328 | LOG (llevError | logBacktrace, "tries to insert object on freed objects map: %s", op->debug_desc ());//D |
1392 | }//D |
1329 | }//D |
1393 | |
1330 | |
1394 | /* Ideally, the caller figures this out. However, it complicates a lot |
1331 | /* Ideally, the caller figures this out. However, it complicates a lot |
1395 | * of areas of callers (eg, anything that uses find_free_spot would now |
1332 | * of areas of callers (eg, anything that uses find_free_spot would now |
1396 | * need extra work |
1333 | * need extra work |
… | |
… | |
2071 | */ |
2008 | */ |
2072 | int |
2009 | int |
2073 | find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
2010 | find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
2074 | { |
2011 | { |
2075 | int altern[SIZEOFFREE]; |
2012 | int altern[SIZEOFFREE]; |
2076 | int index = 0, flag; |
2013 | int index = 0; |
2077 | |
2014 | |
2078 | for (int i = start; i < stop; i++) |
2015 | for (int i = start; i < stop; i++) |
2079 | { |
2016 | { |
2080 | mapxy pos (m, x, y); pos.move (i); |
2017 | mapxy pos (m, x, y); pos.move (i); |
2081 | |
2018 | |
… | |
… | |
2193 | * there is capable of. |
2130 | * there is capable of. |
2194 | */ |
2131 | */ |
2195 | int |
2132 | int |
2196 | find_dir (maptile *m, int x, int y, object *exclude) |
2133 | find_dir (maptile *m, int x, int y, object *exclude) |
2197 | { |
2134 | { |
2198 | int max = SIZEOFFREE, mflags; |
2135 | int max = SIZEOFFREE; |
2199 | MoveType move_type; |
2136 | MoveType move_type; |
2200 | |
2137 | |
2201 | if (exclude && exclude->head_ () != exclude) |
2138 | if (exclude && exclude->head_ () != exclude) |
2202 | { |
2139 | { |
2203 | exclude = exclude->head; |
2140 | exclude = exclude->head; |
… | |
… | |
2454 | return /*who->flag [FLAG_WIZ]|| */ |
2391 | return /*who->flag [FLAG_WIZ]|| */ |
2455 | (item->weight > 0 && !item->flag [FLAG_NO_PICK] && |
2392 | (item->weight > 0 && !item->flag [FLAG_NO_PICK] && |
2456 | !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); |
2393 | !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); |
2457 | } |
2394 | } |
2458 | |
2395 | |
|
|
2396 | //-GPL |
|
|
2397 | |
2459 | /* |
2398 | /* |
2460 | * create clone from object to another |
2399 | * create clone from object to another |
2461 | */ |
2400 | */ |
2462 | object * |
2401 | object * |
2463 | object::deep_clone () |
2402 | object::deep_clone () |
… | |
… | |
2493 | return tmp; |
2432 | return tmp; |
2494 | |
2433 | |
2495 | return 0; |
2434 | return 0; |
2496 | } |
2435 | } |
2497 | |
2436 | |
|
|
2437 | /* Zero the key_values on op, decrementing the shared-string |
|
|
2438 | * refcounts and freeing the links. |
|
|
2439 | */ |
|
|
2440 | void |
|
|
2441 | key_values::clear () |
|
|
2442 | { |
|
|
2443 | for (key_value *kvp = first; kvp; ) |
|
|
2444 | { |
|
|
2445 | key_value *next = kvp->next; |
|
|
2446 | delete kvp; |
|
|
2447 | kvp = next; |
|
|
2448 | } |
|
|
2449 | |
|
|
2450 | first = 0; |
|
|
2451 | } |
|
|
2452 | |
2498 | shstr_tmp |
2453 | shstr_tmp |
2499 | object::kv_get (shstr_tmp key) const |
2454 | key_values::get (shstr_tmp key) const |
2500 | { |
2455 | { |
2501 | for (key_value *kv = key_values; kv; kv = kv->next) |
2456 | for (key_value *kv = first; kv; kv = kv->next) |
2502 | if (kv->key == key) |
2457 | if (kv->key == key) |
2503 | return kv->value; |
2458 | return kv->value; |
2504 | |
2459 | |
2505 | return shstr (); |
2460 | return shstr (); |
2506 | } |
2461 | } |
2507 | |
2462 | |
2508 | void |
2463 | void |
|
|
2464 | key_values::add (shstr_tmp key, shstr_tmp value) |
|
|
2465 | { |
|
|
2466 | key_value *kv = new key_value; |
|
|
2467 | |
|
|
2468 | kv->next = first; |
|
|
2469 | kv->key = key; |
|
|
2470 | kv->value = value; |
|
|
2471 | |
|
|
2472 | first = kv; |
|
|
2473 | } |
|
|
2474 | |
|
|
2475 | void |
2509 | object::kv_set (shstr_tmp key, shstr_tmp value) |
2476 | key_values::set (shstr_tmp key, shstr_tmp value) |
2510 | { |
2477 | { |
2511 | for (key_value *kv = key_values; kv; kv = kv->next) |
2478 | for (key_value *kv = first; kv; kv = kv->next) |
2512 | if (kv->key == key) |
2479 | if (kv->key == key) |
2513 | { |
2480 | { |
2514 | kv->value = value; |
2481 | kv->value = value; |
2515 | return; |
2482 | return; |
2516 | } |
2483 | } |
2517 | |
2484 | |
2518 | key_value *kv = new key_value; |
2485 | add (key, value); |
2519 | |
|
|
2520 | kv->next = key_values; |
|
|
2521 | kv->key = key; |
|
|
2522 | kv->value = value; |
|
|
2523 | |
|
|
2524 | key_values = kv; |
|
|
2525 | } |
2486 | } |
2526 | |
2487 | |
2527 | void |
2488 | void |
2528 | object::kv_del (shstr_tmp key) |
2489 | key_values::del (shstr_tmp key) |
2529 | { |
2490 | { |
2530 | for (key_value **kvp = &key_values; *kvp; kvp = &(*kvp)->next) |
2491 | for (key_value **kvp = &first; *kvp; kvp = &(*kvp)->next) |
2531 | if ((*kvp)->key == key) |
2492 | if ((*kvp)->key == key) |
2532 | { |
2493 | { |
2533 | key_value *kv = *kvp; |
2494 | key_value *kv = *kvp; |
2534 | *kvp = (*kvp)->next; |
2495 | *kvp = (*kvp)->next; |
2535 | delete kv; |
2496 | delete kv; |
2536 | return; |
2497 | return; |
2537 | } |
2498 | } |
|
|
2499 | } |
|
|
2500 | |
|
|
2501 | void |
|
|
2502 | key_values::reverse () |
|
|
2503 | { |
|
|
2504 | key_value *prev = 0; |
|
|
2505 | key_value *head = first; |
|
|
2506 | |
|
|
2507 | while (head) |
|
|
2508 | { |
|
|
2509 | key_value *node = head; |
|
|
2510 | head = head->next; |
|
|
2511 | node->next = prev; |
|
|
2512 | prev = node; |
|
|
2513 | } |
|
|
2514 | |
|
|
2515 | first = prev; |
|
|
2516 | } |
|
|
2517 | |
|
|
2518 | key_values & |
|
|
2519 | key_values::operator =(const key_values &kv) |
|
|
2520 | { |
|
|
2521 | clear (); |
|
|
2522 | |
|
|
2523 | for (key_value *kvp = kv.first; kvp; kvp = kvp->next) |
|
|
2524 | add (kvp->key, kvp->value); |
|
|
2525 | |
|
|
2526 | reverse (); |
2538 | } |
2527 | } |
2539 | |
2528 | |
2540 | object::depth_iterator::depth_iterator (object *container) |
2529 | object::depth_iterator::depth_iterator (object *container) |
2541 | : iterator_base (container) |
2530 | : iterator_base (container) |
2542 | { |
2531 | { |
… | |
… | |
2625 | object::region () const |
2614 | object::region () const |
2626 | { |
2615 | { |
2627 | return map ? map->region (x, y) |
2616 | return map ? map->region (x, y) |
2628 | : region::default_region (); |
2617 | : region::default_region (); |
2629 | } |
2618 | } |
|
|
2619 | |
|
|
2620 | //+GPL |
2630 | |
2621 | |
2631 | void |
2622 | void |
2632 | object::open_container (object *new_container) |
2623 | object::open_container (object *new_container) |
2633 | { |
2624 | { |
2634 | if (container == new_container) |
2625 | if (container == new_container) |
… | |
… | |
2692 | } |
2683 | } |
2693 | // else if (!old_container->env && contr && contr->ns) |
2684 | // else if (!old_container->env && contr && contr->ns) |
2694 | // contr->ns->floorbox_reset (); |
2685 | // contr->ns->floorbox_reset (); |
2695 | } |
2686 | } |
2696 | |
2687 | |
|
|
2688 | //-GPL |
|
|
2689 | |
|
|
2690 | // prefetch some flat area around the player |
|
|
2691 | static void |
|
|
2692 | prefetch_surrounding_area (object *op, maptile *map, int range) |
|
|
2693 | { |
|
|
2694 | for (maprect *rect = map->split_to_tiles (mapwalk_buf, |
|
|
2695 | op->x - range , op->y - range , |
|
|
2696 | op->x + range + 1, op->y + range + 1); |
|
|
2697 | rect->m; |
|
|
2698 | ++rect) |
|
|
2699 | { |
|
|
2700 | rect->m->touch (); |
|
|
2701 | rect->m->activate (); |
|
|
2702 | } |
|
|
2703 | } |
|
|
2704 | |
|
|
2705 | // prefetch a generous area around the player, also up and down |
|
|
2706 | void |
|
|
2707 | object::prefetch_surrounding_maps () |
|
|
2708 | { |
|
|
2709 | prefetch_surrounding_area (this, map, 40); |
|
|
2710 | |
|
|
2711 | if (maptile *m = map->tile_available (TILE_DOWN)) |
|
|
2712 | prefetch_surrounding_area (this, m, 20); |
|
|
2713 | |
|
|
2714 | if (maptile *m = map->tile_available (TILE_UP)) |
|
|
2715 | prefetch_surrounding_area (this, m, 20); |
|
|
2716 | } |
|
|
2717 | |
|
|
2718 | //+GPL |
|
|
2719 | |
2697 | object * |
2720 | object * |
2698 | object::force_find (shstr_tmp name) |
2721 | object::force_find (shstr_tmp name) |
2699 | { |
2722 | { |
2700 | /* cycle through his inventory to look for the MARK we want to |
2723 | /* cycle through his inventory to look for the MARK we want to |
2701 | * place |
2724 | * place |
… | |
… | |
2705 | return splay (tmp); |
2728 | return splay (tmp); |
2706 | |
2729 | |
2707 | return 0; |
2730 | return 0; |
2708 | } |
2731 | } |
2709 | |
2732 | |
2710 | //-GPL |
|
|
2711 | |
|
|
2712 | void |
2733 | void |
2713 | object::force_set_timer (int duration) |
2734 | object::force_set_timer (int duration) |
2714 | { |
2735 | { |
2715 | this->duration = 1; |
2736 | this->duration = 1; |
2716 | this->speed_left = -1.f; |
2737 | this->speed_left = -1.f; |
… | |
… | |
2722 | object::force_add (shstr_tmp name, int duration) |
2743 | object::force_add (shstr_tmp name, int duration) |
2723 | { |
2744 | { |
2724 | if (object *force = force_find (name)) |
2745 | if (object *force = force_find (name)) |
2725 | force->destroy (); |
2746 | force->destroy (); |
2726 | |
2747 | |
2727 | object *force = get_archetype (FORCE_NAME); |
2748 | object *force = archetype::get (FORCE_NAME); |
2728 | |
2749 | |
2729 | force->slaying = name; |
2750 | force->slaying = name; |
2730 | force->force_set_timer (duration); |
2751 | force->force_set_timer (duration); |
2731 | force->flag [FLAG_APPLIED] = true; |
2752 | force->flag [FLAG_APPLIED] = true; |
2732 | |
2753 | |