#include <global.h>#include <stdio.h>#include <sys/types.h>#include <sys/uio.h>#include <skillist.h>#include <loader.h>#include <sproto.h>Go to the source code of this file.
Defines | |
| #define | NUM_MATERIALS_REAL NROFMATERIALS * NROFMATERIALS_REAL + 1 |
Functions | |
| static void | sub_weight (object *op, sint32 weight) |
| static void | remove_ob_inv (object *op) |
| static void | add_weight (object *op, sint32 weight) |
| void | init_materials () |
| void | mark_object_removed (object *ob) |
| void | object_gc () |
| static int | compare_ob_value_lists_one (const object *wants, const object *has) |
| static int | compare_ob_value_lists (const object *ob1, const object *ob2) |
| int | CAN_MERGE (object *ob1, object *ob2) |
| object * | merge_ob (object *op, object *top) |
| signed long | sum_weight (object *op) |
| object * | is_player_inv (object *op) |
| void | dump_object (object *op, StringBuffer *sb) |
| void | free_all_object_data () |
| object * | get_owner (object *op) |
| void | clear_owner (object *op) |
| static void | set_owner_simple (object *op, object *owner) |
| static void | set_skill_pointers (object *op, object *chosen_skill, object *exp_obj) |
| void | set_owner (object *op, object *owner) |
| void | copy_owner (object *op, object *clone) |
| void | initialize_object (object *op) |
| void | copy_object (object *op2, object *op) |
| void | copy_object_data (object *op2, object *op) |
| object * | get_object () |
| void | update_turn_face (object *op) |
| void | update_ob_speed (object *op) |
| void | update_object (object *op, int action) |
| void | drop_ob_inv (object *ob) |
| void | destroy_object (object *ob) |
| void | destruct_ob (object *op) |
| void | remove_ob (object *op) |
| object * | insert_ob_in_map (object *op, mapstruct *m, object *originator, int flag) |
| void | replace_insert_ob_in_map (char *arch_string, object *op) |
| object * | get_split_ob (object *orig_ob, int nr, char *err, size_t size) |
| object * | decrease_ob_nr (object *op, uint32 i) |
| object * | insert_ob_in_ob (object *op, object *where) |
| int | check_walk_on (object *op, object *originator, int flags) |
| int | check_walk_off (object *op, object *originator, int flags) |
| object * | present_arch (archetype *at, mapstruct *m, int x, int y) |
| object * | present (uint8 type, mapstruct *m, int x, int y) |
| object * | present_in_ob (uint8 type, object *op) |
| object * | present_arch_in_ob (archetype *at, object *op) |
| int | find_free_spot (archetype *at, object *op, mapstruct *m, int x, int y, int start, int stop) |
| int | find_first_free_spot (archetype *at, object *op, mapstruct *m, int x, int y) |
| int | find_first_free_spot2 (archetype *at, mapstruct *m, int x, int y, int start, int range) |
| static void | permute (int *arr, int begin, int end) |
| void | get_search_arr (int *search_arr) |
| int | find_dir (mapstruct *m, int x, int y, object *exclude) |
| int | find_dir_2 (int x, int y) |
| int | absdir (int d) |
| int | dirdiff (int dir1, int dir2) |
| int | get_dir_to_target (object *op, object *target, rv_vector *range_vector) |
| int | can_pick (object *who, object *item) |
| object * | object_create_clone (object *asrc) |
| int | was_destroyed (object *op, tag_t old_tag) |
| object * | load_object_str (char *obstr) |
| int | auto_apply (object *op) |
| int | can_see_monsterP (mapstruct *m, int x, int y, int dir) |
| void | free_key_values (object *op) |
| key_value * | object_get_key_link (const object *ob, const char *key) |
| const char * | object_get_value (const object *op, const char *const key) |
| static int | object_set_value_s (object *op, const char *canonical_key, const char *value, int add_key) |
| int | object_set_value (object *op, const char *key, const char *value, int add_key) |
| void | init_object_initializers () |
Variables | |
| struct mempool_chunk * | removed_objects |
| object * | active_objects |
| static int | static_walk_semaphore = 0 |
| object | void_container |
| static const int | reduction_dir [SIZEOFFREE][3] |
| materialtype | material [NROFMATERIALS] |
| material_real_struct | material_real [NUM_MATERIALS_REAL] |
| int | freearr_x [SIZEOFFREE] |
| int | freearr_y [SIZEOFFREE] |
| int | maxfree [SIZEOFFREE] |
| int | freedir [SIZEOFFREE] |
Object related code.
Definition in file object.c.
| int absdir | ( | int | d | ) |
| static void add_weight | ( | object * | op, | |
| sint32 | weight | |||
| ) | [static] |
| int auto_apply | ( | object * | op | ) |
Process object with FLAG_AUTO_APPLY.
Basically creates treasure for objects like shop floors and treasures.
| op | The object to process. |
Moved this out of define.h and in here, since this is the only file it is used in. Also, make it an inline function for cleaner design.
Examines two objects given to, and returns 1 if they can be merged together.
Check nrof variable before calling this.
Improvements made with merge: Better checking on potion, and also check weight
| ob1 | The first object | |
| ob2 | The second object |
| int can_see_monsterP | ( | mapstruct * | m, | |
| int | x, | |||
| int | y, | |||
| int | dir | |||
| ) |
| void clear_owner | ( | object * | op | ) |
Same as copy_object(), but not touching the active list.
| op2 | ||
| op |
Set the owner to clone's current owner and set the skill and experience objects to clone's objects (typically those objects that where the owner's current skill and experience objects at the time when clone's owner was set - not the owner's current skill and experience objects).
Use this function if player created an object (e.g. fire bullet, swarm spell), and this object creates further objects whose kills should be accounted for the player's original skill, even if player has changed skills meanwhile.
| op | The object. | |
| clone | The clone. |
Decreases a specified number from the amount of an object. If the amount reaches 0, the object is subsequently removed and freed.
This function will send an update to client if op is in a player inventory.
| op | Object to decrease. | |
| i | Number to remove. |
| void destroy_object | ( | object * | ob | ) |
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects. This function is called automatically to free unused objects (it is called from return_poolchunk() during garbage collection in object_gc() ).
The object must have been removed by remove_ob() first for this function to succeed.
| ob | The object to destroy. |
| void destruct_ob | ( | object * | op | ) |
| int dirdiff | ( | int | dir1, | |
| int | dir2 | |||
| ) |
| void drop_ob_inv | ( | object * | ob | ) |
| void dump_object | ( | object * | op, | |
| StringBuffer * | sb | |||
| ) |
Searches some close squares in the given map at the given coordinates for alive objects.
| m | Map. | |
| x | X position on map. | |
| y | Y position on map. | |
| exclude | An object that will be ignored. Can be NULL. |
| int find_dir_2 | ( | int | x, | |
| int | y | |||
| ) |
Works like find_free_spot(), but it will search max number of squares.
It will return the first available spot, not a random choice.
| int find_free_spot | ( | archetype * | at, | |
| object * | op, | |||
| mapstruct * | m, | |||
| int | x, | |||
| int | y, | |||
| int | start, | |||
| int | stop | |||
| ) |
Will search for a spot at the given map and coordinates which will be able to contain the given archetype. start and stop specifies how many squares to search (see the freearr_x/y[] definition).
It returns a random choice among the alternatives found. start and stop are where to start relative to the free_arr array (1,9 does all 4 immediate directions). This returns the index into the array of the free spot, -1 if no spot available (dir 0 = x,y)
| void free_all_object_data | ( | ) |
| void free_key_values | ( | object * | op | ) |
Get direction from one object to another.
If the first object is a player, this will set the player's facing direction to the returned direction.
| op | The first object | |
| target | The target object | |
| range_vector | Range vector pointer to use |
| object* get_object | ( | ) |
Returns the object which this object marks as being the owner.
An ID scheme is used to avoid pointing to objects which have been freed and are now reused. If this is detected, the owner is set to NULL, and NULL is returned.
(This scheme should be changed to a refcount scheme in the future)
| op | The object to get owner for |
| void get_search_arr | ( | int * | search_arr | ) |
New function to make monster searching more efficient, and effective! This basically returns a randomized array (in the passed pointer) of the spaces to find monsters. In this way, it won't always look for monsters to the north first. However, the size of the array passed covers all the spaces, so within that size, all the spaces within the 3x3 area will be searched, just not in a predictable order.
| search_arr | Array that will be initialized. Must contain at least SIZEOFFREE elements. |
Splits up ob into two parts. The part which is returned contains nr objects, and the remaining parts contains the rest (or is removed and freed if that number is 0).
| orig_ob | Object from which to split. | |
| nr | Number of elements to split. | |
| err | Buffer that will contain failure reason if NULL is returned. Can be NULL. | |
| size | err's size. |
| void init_object_initializers | ( | ) |
| void initialize_object | ( | object * | op | ) |
This function inserts the object op in the linked list inside the object environment.
| op | Object to insert. Must be removed and not NULL. Must not be multipart. May become invalid after return, so use return value of the function. | |
| where | Object to insert into. Must not be NULL. Should be the head part. |
| object* load_object_str | ( | char * | obstr | ) |
| void mark_object_removed | ( | object * | ob | ) |
| void object_gc | ( | ) |
| const char* object_get_value | ( | const object * | op, | |
| const char *const | key | |||
| ) |
| int object_set_value | ( | object * | op, | |
| const char * | key, | |||
| const char * | value, | |||
| int | add_key | |||
| ) |
Updates the key in op to value.
| op | Object we're considering. | |
| key | Key to set or update. Doesn't need to be a shared string. | |
| value | Value to set. Doesn't need to be a shared string. | |
| add_key | If 0, will not add the key if it doesn't exist in op. |
| static int object_set_value_s | ( | object * | op, | |
| const char * | canonical_key, | |||
| const char * | value, | |||
| int | add_key | |||
| ) | [static] |
Updates or sets a key value.
| op | Object we're considering. | |
| canonical_key | Key to set or update. Must be a shared string. | |
| value | Value to set. Doesn't need to be a shared string. | |
| add_key | If 0, will not add the key if it doesn't exist in op. |
| static void permute | ( | int * | arr, | |
| int | begin, | |||
| int | end | |||
| ) | [static] |
| void remove_ob | ( | object * | op | ) |
This function removes the object op from the linked list of objects which it is currently tied to. When this function is done, the object will have no environment. If the object previously had an environment, the x and y coordinates will be updated to the previous environment.
| op | Object to remove. |
| static void remove_ob_inv | ( | object * | op | ) | [static] |
| void replace_insert_ob_in_map | ( | char * | arch_string, | |
| object * | op | |||
| ) |
Sets the owner of the first object to the second object.
Also checkpoints a backup id scheme which detects freeing (and reusage) of the owner object.
| op | The object to set the owner for | |
| owner | The owner |
| static void sub_weight | ( | object * | op, | |
| sint32 | weight | |||
| ) | [static] |
| signed long sum_weight | ( | object * | op | ) |
| void update_ob_speed | ( | object * | op | ) |
| void update_object | ( | object * | op, | |
| int | action | |||
| ) |
Updates the array which represents the map.
It takes into account invisible objects (and represent squares covered by invisible objects by whatever is below them (unless it's another invisible object, etc).
If the object being updated is beneath a player, the below window of that player is updated.
| op | Object to update | |
| action | Hint of what the caller believes need to be done. One of Object update flags values. |
| void update_turn_face | ( | object * | op | ) |
| int was_destroyed | ( | object * | op, | |
| tag_t | old_tag | |||
| ) |
| int freearr_x[SIZEOFFREE] |
| int freearr_y[SIZEOFFREE] |
| int freedir[SIZEOFFREE] |
| materialtype material[NROFMATERIALS] |
{
{"paper", {15, 10, 17, 9, 5, 7,13, 0, 20, 15, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0}},
{"metal", {2, 12, 3, 12, 2,10, 7, 0, 20, 15, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0}},
{"crystal", {14, 11, 8, 3, 10, 5, 1, 0, 20, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{"leather", {5, 10, 10, 3, 3, 10,10, 0, 20, 15, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0}},
{"wood", {10, 11, 13, 2, 2, 10, 9, 0, 20, 15, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0}},
{"organics", {3, 12, 9, 11, 3, 10, 9, 0, 20, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{"stone", {2, 5, 2, 2, 2, 2, 1, 0, 20, 15, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0}},
{"cloth", {14, 11, 13, 4, 4, 5, 10, 0, 20, 15, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0}},
{"magic material", {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{"liquid", {0, 8, 9, 6, 17, 0, 15, 0, 20, 15, 12, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0}},
{"soft metal", {6, 12, 6, 14, 2, 10, 1, 0, 20, 15, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0}},
{"bone", {10, 9, 4, 5, 3, 10, 10, 0, 20, 15, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0}},
{"ice", {14, 11, 16, 5, 0, 5, 6, 0, 20, 15, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0}}
}
Material types
| material_real_struct material_real[NUM_MATERIALS_REAL] |
Real material types. This array is initialized by init_materials().
| int maxfree[SIZEOFFREE] |
{
0, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 27, 30, 31, 32, 33, 36, 37, 39, 39, 42, 43, 44, 45,
48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
}
Number of spots around a location, including that location (except for 0)
const int reduction_dir[SIZEOFFREE][3] [static] |
| struct mempool_chunk* removed_objects |
1.6.2