1 | /* |
1 | /* |
2 | * static char *rcsid_object_c = |
2 | * static char *rcsid_object_c = |
3 | * "$Id: object.C,v 1.21 2006/09/09 21:48:28 root Exp $"; |
3 | * "$Id: object.C,v 1.22 2006/09/10 00:51:23 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 | |
… | |
… | |
843 | mortals.clear (); |
843 | mortals.clear (); |
844 | } |
844 | } |
845 | |
845 | |
846 | object::object () |
846 | object::object () |
847 | { |
847 | { |
848 | count = ++ob_count; |
|
|
849 | |
|
|
850 | prev = 0; |
|
|
851 | next = objects; |
|
|
852 | |
|
|
853 | if (objects) |
|
|
854 | objects->prev = this; |
|
|
855 | |
|
|
856 | objects = this; |
|
|
857 | |
|
|
858 | SET_FLAG (this, FLAG_REMOVED); |
848 | SET_FLAG (this, FLAG_REMOVED); |
859 | |
849 | |
860 | expmul = 1.0; |
850 | expmul = 1.0; |
861 | face = blank_face; |
851 | face = blank_face; |
862 | attacked_by_count = -1; |
852 | attacked_by_count = -1; |
863 | } |
853 | } |
864 | |
854 | |
865 | object::~object () |
855 | object::~object () |
866 | { |
856 | { |
|
|
857 | free_key_values (this); |
867 | } |
858 | } |
|
|
859 | |
|
|
860 | void |
|
|
861 | object::link () |
|
|
862 | { |
|
|
863 | count = ++ob_count; |
|
|
864 | |
|
|
865 | prev = 0; |
|
|
866 | next = objects; |
|
|
867 | |
|
|
868 | if (objects) |
|
|
869 | objects->prev = this; |
|
|
870 | |
|
|
871 | objects = this; |
|
|
872 | } |
|
|
873 | |
|
|
874 | void |
|
|
875 | object::unlink () |
|
|
876 | { |
|
|
877 | count = 0; |
|
|
878 | |
|
|
879 | /* Remove this object from the list of used objects */ |
|
|
880 | if (prev) prev->next = next; |
|
|
881 | if (next) next->prev = prev; |
|
|
882 | if (this == objects) objects = next; |
|
|
883 | } |
868 | |
884 | |
869 | object *object::create () |
885 | object *object::create () |
870 | { |
886 | { |
871 | return new object; |
887 | object *op = new object; |
|
|
888 | op->link (); |
|
|
889 | return op; |
872 | } |
890 | } |
873 | |
891 | |
874 | /* |
892 | /* |
875 | * free_object() frees everything allocated by an object, removes |
893 | * free_object() frees everything allocated by an object, removes |
876 | * it from the list of used objects, and puts it on the list of |
894 | * it from the list of used objects, and puts it on the list of |
… | |
… | |
959 | |
977 | |
960 | /* Remove object from the active list */ |
978 | /* Remove object from the active list */ |
961 | speed = 0; |
979 | speed = 0; |
962 | update_ob_speed (this); |
980 | update_ob_speed (this); |
963 | |
981 | |
|
|
982 | unlink (); |
|
|
983 | |
964 | SET_FLAG (this, FLAG_FREED); |
984 | SET_FLAG (this, FLAG_FREED); |
965 | |
|
|
966 | mortalise (); |
|
|
967 | } |
|
|
968 | |
|
|
969 | void |
|
|
970 | object::mortalise () |
|
|
971 | { |
|
|
972 | count = 0; |
|
|
973 | |
|
|
974 | /* Remove this object from the list of used objects */ |
|
|
975 | if (prev) prev->next = next; |
|
|
976 | if (next) next->prev = prev; |
|
|
977 | if (this == objects) objects = next; |
|
|
978 | |
|
|
979 | free_key_values (this); |
|
|
980 | |
985 | |
981 | mortals.push_back (this); |
986 | mortals.push_back (this); |
982 | } |
987 | } |
983 | |
988 | |
984 | /* |
989 | /* |