Crossfire Server, Trunk
object.h File Reference
#include "sstring.h"
#include "dialog.h"
+ Include dependency graph for object.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  archetype
 
struct  body_locations_struct
 
struct  key_value
 
struct  object
 
struct  objectlink
 
struct  oblinkpt
 

Macros

#define ARCH_DEPLETION   "depletion"
 
#define ARCH_DETECT_MAGIC   "detect_magic"
 
#define ARCH_PORTAL_FAILED   "town_portal_failed"
 
#define ARCH_SINGULARITY   "singularity"
 
#define ARCH_SPELL_BLOCKED   "spell_blocked"
 
#define ARCH_SPELL_BUNGLE   "spell_bungle"
 
#define ARCH_SYMPTOM   "symptom"
 
#define BODY_ARMS   1
 
#define CUSTOM_NAME_FIELD   "custom_name"
 
#define FREE_OBJ_DROP_ABOVE_FLOOR   4
 
#define FREE_OBJ_FREE_INVENTORY   1
 
#define FREE_OBJ_NO_DESTROY_CALLBACK   2
 
#define HEAD(op)   ((op)->head != NULL ? (op)->head : (op))
 
#define INS_ABOVE_FLOOR_ONLY   0x0002
 
#define INS_BELOW_ORIGINATOR   0x0010
 
#define INS_MAP_LOAD   0x0020
 
#define INS_NO_MERGE   0x0001
 
#define INS_NO_WALK_ON   0x0004
 
#define INS_ON_TOP   0x0008
 
#define LOOK_OBJ(ob)   (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)
 
#define MONSTER_EXCLUDE_FROM_READABLE_KEY   "exclude_from_readable"
 
#define NUM_BODY_LOCATIONS   13
 
#define OB_SPELL_TAG_HASH(op, count)   (op->spell_tags[count&0xf])
 
#define OB_SPELL_TAG_MATCH(op, count)   (op->spell_tags[count&0xf] == count)
 
#define object_was_destroyed(op, old_tag)   (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
 
#define SPELL_TAG_SIZE   16
 
#define UP_OBJ_CHANGE   3
 
#define UP_OBJ_FACE   4
 
#define UP_OBJ_INSERT   1
 
#define UP_OBJ_REMOVE   2
 
#define WILL_APPLY_DOOR   0x8
 
#define WILL_APPLY_EARTHWALL   0x4
 
#define WILL_APPLY_FOOD   0x10
 
#define WILL_APPLY_HANDLE   0x1
 
#define WILL_APPLY_TREASURE   0x2
 

Typedefs

typedef uint32_t ob_flags[4]
 
typedef uint32_t tag_t
 

Enumerations

enum  object_type {
  PLAYER = 1, TRANSPORT = 2, ROD = 3, TREASURE = 4,
  POTION = 5, FOOD = 6, POISON = 7, BOOK = 8,
  CLOCK = 9, DRAGON_FOCUS = 10, ARROW = 13, BOW = 14,
  WEAPON = 15, ARMOUR = 16, PEDESTAL = 17, ALTAR = 18,
  LOCKED_DOOR = 20, SPECIAL_KEY = 21, MAP = 22, DOOR = 23,
  KEY = 24, TIMED_GATE = 26, TRIGGER = 27, GRIMREAPER = 28,
  MAGIC_EAR = 29, TRIGGER_BUTTON = 30, TRIGGER_ALTAR = 31, TRIGGER_PEDESTAL = 32,
  SHIELD = 33, HELMET = 34, MONEY = 36, CLASS = 37,
  AMULET = 39, PLAYERMOVER = 40, TELEPORTER = 41, CREATOR = 42,
  SKILL = 43, EARTHWALL = 45, GOLEM = 46, THROWN_OBJ = 48,
  BLINDNESS = 49, GOD = 50, DETECTOR = 51, TRIGGER_MARKER = 52,
  DEAD_OBJECT = 53, DRINK = 54, MARKER = 55, HOLY_ALTAR = 56,
  PLAYER_CHANGER = 57, BATTLEGROUND = 58, PEACEMAKER = 59, GEM = 60,
  FIREWALL = 62, CHECK_INV = 64, MOOD_FLOOR = 65, EXIT = 66,
  ENCOUNTER = 67, SHOP_FLOOR = 68, SHOP_MAT = 69, RING = 70,
  FLOOR = 71, FLESH = 72, INORGANIC = 73, SKILL_TOOL = 74,
  LIGHTER = 75, WALL = 77, MISC_OBJECT = 79, MONSTER = 80,
  LAMP = 82, DUPLICATOR = 83, SPELLBOOK = 85, CLOAK = 87,
  SPINNER = 90, GATE = 91, BUTTON = 92, CF_HANDLE = 93,
  HOLE = 94, TRAPDOOR = 95, SIGN = 98, BOOTS = 99,
  GLOVES = 100, SPELL = 101, SPELL_EFFECT = 102, CONVERTER = 103,
  BRACERS = 104, POISONING = 105, SAVEBED = 106, WAND = 109,
  SCROLL = 111, DIRECTOR = 112, GIRDLE = 113, FORCE = 114,
  POTION_RESIST_EFFECT = 115, EVENT_CONNECTOR = 116, CLOSE_CON = 121, CONTAINER = 122,
  ARMOUR_IMPROVER = 123, WEAPON_IMPROVER = 124, SKILLSCROLL = 130, DEEP_SWAMP = 138,
  IDENTIFY_ALTAR = 139, SHOP_INVENTORY = 150, RUNE = 154, TRAP = 155,
  POWER_CRYSTAL = 156, CORPSE = 157, DISEASE = 158, SYMPTOM = 159,
  BUILDER = 160, MATERIAL = 161, MIMIC = 162, LIGHTABLE = 163,
  OBJECT_TYPE_MAX = 164
}
 

Functions

objectadd_force (object *op, const char *name, int duration)
 
static bool CAN_PROBE (const object *ob)
 
static void clear_flag (object *op, int flag)
 
static void compare_flags (ob_flags *ret, const object *p, const object *q)
 
objectfind_force (object *op, const char *name)
 
static bool IS_PLAYER (object *op)
 
static uint32_t NROF (const object *const ob)
 
static int query_flag (const object *op, int flag)
 
static void set_flag (object *op, int flag)
 

Variables

objectactive_objects
 
body_locations_struct body_locations [NUM_BODY_LOCATIONS]
 
const char *const move_name []
 
int nrofallocobjects
 
int nroffreeobjects
 
objectobjects
 

Detailed Description

Object structure, the core of Crossfire.

Definition in file object.h.

Macro Definition Documentation

◆ ARCH_DEPLETION

#define ARCH_DEPLETION   "depletion"

Archetype for depletion.

Definition at line 588 of file object.h.

◆ ARCH_DETECT_MAGIC

#define ARCH_DETECT_MAGIC   "detect_magic"

Archetype for detect magic spell.

Definition at line 587 of file object.h.

◆ ARCH_PORTAL_FAILED

#define ARCH_PORTAL_FAILED   "town_portal_failed"

Archetype for town portal failure.

Definition at line 590 of file object.h.

◆ ARCH_SINGULARITY

#define ARCH_SINGULARITY   "singularity"

Archetype for singularity.

Definition at line 586 of file object.h.

◆ ARCH_SPELL_BLOCKED

#define ARCH_SPELL_BLOCKED   "spell_blocked"

Archetype when a spell is blocked (unholy ground or non magic).

Definition at line 591 of file object.h.

◆ ARCH_SPELL_BUNGLE

#define ARCH_SPELL_BUNGLE   "spell_bungle"

Archetype when player bungles a spell.

Definition at line 592 of file object.h.

◆ ARCH_SYMPTOM

#define ARCH_SYMPTOM   "symptom"

Archetype for disease symptom.

Definition at line 589 of file object.h.

◆ BODY_ARMS

#define BODY_ARMS   1

This should be the index of the arms.

Definition at line 16 of file object.h.

◆ CUSTOM_NAME_FIELD

#define CUSTOM_NAME_FIELD   "custom_name"

Key in an object for the player-assigned custom name.

Definition at line 98 of file object.h.

◆ FREE_OBJ_DROP_ABOVE_FLOOR

#define FREE_OBJ_DROP_ABOVE_FLOOR   4

If FREE_OBJ_FREE_INVENTORY is not set, drop inventory just above ground instead on top.

Definition at line 544 of file object.h.

◆ FREE_OBJ_FREE_INVENTORY

#define FREE_OBJ_FREE_INVENTORY   1

Free inventory objects; if not set, drop inventory.

Definition at line 542 of file object.h.

◆ FREE_OBJ_NO_DESTROY_CALLBACK

#define FREE_OBJ_NO_DESTROY_CALLBACK   2

Do not run the destroy callback.

Definition at line 543 of file object.h.

◆ HEAD

#define HEAD (   op)    ((op)->head != NULL ? (op)->head : (op))

Returns the head part of an object. For single-tile objects returns the object itself.

Parameters
opthe object
Returns
the head object

Definition at line 605 of file object.h.

◆ INS_ABOVE_FLOOR_ONLY

#define INS_ABOVE_FLOOR_ONLY   0x0002

Put object immediatly above the floor.

Definition at line 579 of file object.h.

◆ INS_BELOW_ORIGINATOR

#define INS_BELOW_ORIGINATOR   0x0010

Insert new object immediately below originator.

Definition at line 582 of file object.h.

◆ INS_MAP_LOAD

#define INS_MAP_LOAD   0x0020

Disable lots of checkings.

Definition at line 583 of file object.h.

◆ INS_NO_MERGE

#define INS_NO_MERGE   0x0001

Don't try to merge with other items.

Definition at line 578 of file object.h.

◆ INS_NO_WALK_ON

#define INS_NO_WALK_ON   0x0004

Don't call check_walk_on against the originator.

Definition at line 580 of file object.h.

◆ INS_ON_TOP

#define INS_ON_TOP   0x0008

Always put object on top.

Definition at line 581 of file object.h.

◆ LOOK_OBJ

#define LOOK_OBJ (   ob)    (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)

This returns TRUE if the object is something that should be displayed in the look window

Definition at line 519 of file object.h.

◆ MONSTER_EXCLUDE_FROM_READABLE_KEY

#define MONSTER_EXCLUDE_FROM_READABLE_KEY   "exclude_from_readable"

If set (any value), then monster is not listed in books.

Definition at line 594 of file object.h.

◆ NUM_BODY_LOCATIONS

#define NUM_BODY_LOCATIONS   13

Number of body locations.

Definition at line 15 of file object.h.

◆ OB_SPELL_TAG_HASH

#define OB_SPELL_TAG_HASH (   op,
  count 
)    (op->spell_tags[count&0xf])

Get the hash on an object for a specified count.

Parameters
opwhat to check.
countitem to check the hash for.

Definition at line 89 of file object.h.

◆ OB_SPELL_TAG_MATCH

#define OB_SPELL_TAG_MATCH (   op,
  count 
)    (op->spell_tags[count&0xf] == count)

Check whether a tag matches in the tags.

Parameters
opitem to check against.
counttag to check.

Definition at line 95 of file object.h.

◆ object_was_destroyed

#define object_was_destroyed (   op,
  old_tag 
)    (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))

Checks if an object still exists.

Parameters
opobject to check
old_tagold tag of the object.
Returns
true if the object was destroyed, 0 otherwise

Definition at line 70 of file object.h.

◆ SPELL_TAG_SIZE

#define SPELL_TAG_SIZE   16

Defines default size of the *spell_tags pointer. The OB_SPELL_TAG_HASH is a simple mechanism to get/set the spell tags based on a simple hash - it should change if the tag size also changes. Note that since count is used for this, this value is effectively random or at least fairly evenly distributed, at least in the low bits. And a size of 16 lets us do a very fast operation.

Definition at line 83 of file object.h.

◆ UP_OBJ_CHANGE

#define UP_OBJ_CHANGE   3

Object changed.

Definition at line 530 of file object.h.

◆ UP_OBJ_FACE

#define UP_OBJ_FACE   4

Only thing that changed was the face. In this case, we always update everything as that is easier than trying to look at what may have changed.

Definition at line 531 of file object.h.

◆ UP_OBJ_INSERT

#define UP_OBJ_INSERT   1

Object was inserted.

Definition at line 528 of file object.h.

◆ UP_OBJ_REMOVE

#define UP_OBJ_REMOVE   2

Object was removed.

Definition at line 529 of file object.h.

◆ WILL_APPLY_DOOR

#define WILL_APPLY_DOOR   0x8

Open non-locked doors.

Definition at line 57 of file object.h.

◆ WILL_APPLY_EARTHWALL

#define WILL_APPLY_EARTHWALL   0x4

Destroy earthwalls.

Definition at line 56 of file object.h.

◆ WILL_APPLY_FOOD

#define WILL_APPLY_FOOD   0x10

Eat food (not drinks).

Definition at line 58 of file object.h.

◆ WILL_APPLY_HANDLE

#define WILL_APPLY_HANDLE   0x1

Apply handles and triggers.

Definition at line 54 of file object.h.

◆ WILL_APPLY_TREASURE

#define WILL_APPLY_TREASURE   0x2

Open chests.

Definition at line 55 of file object.h.

Typedef Documentation

◆ ob_flags

typedef uint32_t ob_flags[4]

Definition at line 259 of file object.h.

◆ tag_t

typedef uint32_t tag_t

Object tag, unique during the whole game.

Definition at line 14 of file object.h.

Enumeration Type Documentation

◆ object_type

Only add new values to this list if somewhere in the program code, it is actually needed. Just because you add a new monster does not mean it has to have a type defined here. That only needs to happen if in some .c file, it needs to do certain special actions based on the monster type, that can not be handled by any of the numerous flags. Also, if you add new entries, try and fill up the holes in this list. Additionally, when you add a new entry, include it in the table in common/item.c

type 0 is undefined and indicates non-valid type information.

Enumerator
PLAYER 

See Player

TRANSPORT 

see doc/Developers/objects

See Transport

ROD 

See Rod

TREASURE 

See Treasure

POTION 

See Potion

FOOD 

See Food

POISON 

See Poison Food

BOOK 

See Book

CLOCK 

See Clock

DRAGON_FOCUS 

Used during character creation

ARROW 

See Projectile

BOW 

See Shooting Weapon

WEAPON 

See Weapon

ARMOUR 

See Breastplate Armor

PEDESTAL 

See Pedestal

ALTAR 

See Altar

LOCKED_DOOR 

See Locked Door

SPECIAL_KEY 

See Special Key

MAP 
DOOR 

See Door

KEY 
TIMED_GATE 

See Timed Gate

TRIGGER 

See Handle Trigger

GRIMREAPER 

See Monster (Grimreaper)

MAGIC_EAR 

See Magic Ear

TRIGGER_BUTTON 

See Button Trigger

TRIGGER_ALTAR 

See Altar Trigger

TRIGGER_PEDESTAL 
SHIELD 

See Shield

HELMET 

See Helmet

MONEY 

See Money

CLASS 

Object for applying character class modifications to someone

See Class Changer

AMULET 

See Amulet

PLAYERMOVER 

See Mover

TELEPORTER 

See Teleporter

CREATOR 

See Creator

SKILL 

Also see SKILL_TOOL (74) below

See Skill

EARTHWALL 
GOLEM 
THROWN_OBJ 
BLINDNESS 
GOD 
DETECTOR 

peterm: detector is an object which notices the presense of another object and is triggered like buttons.

See Detector

TRIGGER_MARKER 

inserts an invisible, weightless force into a player with a specified string WHEN TRIGGERED.

See Trigger Marker

DEAD_OBJECT 
DRINK 

See Drink

MARKER 

inserts an invisible, weightless force into a player with a specified string.

See Marker

HOLY_ALTAR 

See Holy Altar

PLAYER_CHANGER 

See Player Changer

BATTLEGROUND 

battleground, by Andreas Vogl

See Battleground

PEACEMAKER 

Object owned by a player which can convert a monster into a peaceful being incapable of attack.

GEM 

See Jewel

FIREWALL 

See Magic Wall

CHECK_INV 

b.t. thoma.nosp@m.s@no.nosp@m.mad.a.nosp@m.stro.nosp@m..psu..nosp@m.edu

See Inventory Checker

MOOD_FLOOR 

b.t. thoma.nosp@m.s@no.nosp@m.mad.a.nosp@m.stro.nosp@m..psu..nosp@m.edu values of last_sp set how to change: 0 = furious, all monsters become aggressive 1 = angry, all but friendly become aggressive 2 = calm, all aggressive monsters calm down 3 = sleep, all monsters fall asleep 4 = charm, monsters become pets

See Mood Floor

EXIT 

See Exit

ENCOUNTER 

See Floor (Encounter)

SHOP_FLOOR 

See Shop Floor

SHOP_MAT 

See Shop Mat

RING 

See Ring

FLOOR 

Floor tile -> native layer 0

FLESH 

animal 'body parts' -b.t.

See Flesh

INORGANIC 

metals, minerals, dragon scales

See Inorganic

SKILL_TOOL 

Allows the use of a skill

LIGHTER 
WALL 

Wall. Put it always in layer 1 if not set is_floor

MISC_OBJECT 

misc. objects are for objects without a function in the engine. Like statues, clocks, chairs... If perhaps we create a function where we can sit on chairs, we create a new type and remove all chairs from here.

MONSTER 

A real, living creature

LAMP 

Lamp

DUPLICATOR 

Duplicator/multiplier object

See Duplicator

SPELLBOOK 

See Spellbook

CLOAK 

See Cloak

SPINNER 

See Spinner

GATE 

See Gate

BUTTON 

See Button

CF_HANDLE 

See Handle

HOLE 

See Pit

TRAPDOOR 

See Trapdoor

SIGN 

See Sign & Magic Mouth

BOOTS 

See Boots

GLOVES 

See Gloves

SPELL 

See Spell

SPELL_EFFECT 
CONVERTER 

See Converter

BRACERS 

See Bracers

POISONING 
SAVEBED 

See Savebed

WAND 

See Wand & Staff

SCROLL 

See Scroll

DIRECTOR 

See Director

GIRDLE 

See Girdle

FORCE 
POTION_RESIST_EFFECT 

A force, holding the effect of a resistance potion

EVENT_CONNECTOR 

Lauwenmark: an invisible object holding a plugin event hook

See Event

CLOSE_CON 

Eneq((at)csd.uu.se): Id for close_container archetype.

CONTAINER 

See Container

ARMOUR_IMPROVER 
WEAPON_IMPROVER 
SKILLSCROLL 

can add a skill to player's inventory -bt.

See Skill Scroll

DEEP_SWAMP 

See Swamp

IDENTIFY_ALTAR 
SHOP_INVENTORY 

Mark Wedel (mark@.nosp@m.pyra.nosp@m.mid.c.nosp@m.om) Shop inventories

RUNE 

See Rune

TRAP 

See Trap

POWER_CRYSTAL 

See Power Crystal

CORPSE 
DISEASE 

See Disease

SYMPTOM 
BUILDER 

Generic item builder, see subtypes below

See Builder

MATERIAL 

Material for building

See Building material

MIMIC 
LIGHTABLE 
OBJECT_TYPE_MAX 

Try to find a fire/heat source to light this when applied Update if you add new types

Definition at line 111 of file object.h.

Function Documentation

◆ add_force()

object* add_force ( object op,
const char *  name,
int  duration 
)

Add or return an existing force inside 'op' with the given 'name' and 'duration' in units of 100 ticks (12 seconds under default settings). If 'duration' is zero, the force will not expire by itself.

Definition at line 5421 of file object.cpp.

References add_string(), create_archetype(), find_force(), dragon_attune::force, FORCE_NAME, give::name, object_insert_in_ob(), object_update_speed(), and give::op.

Referenced by commit_crime(), and move_marker().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CAN_PROBE()

static bool CAN_PROBE ( const object ob)
inlinestatic

Determine whether the given object can have an HP bar.

Definition at line 614 of file object.h.

References FLAG_ALIVE, FLAG_MONSTER, guildjoin::ob, PLAYER, and QUERY_FLAG.

Referenced by check_probe(), and probe().

+ Here is the caller graph for this function:

◆ clear_flag()

static void clear_flag ( object op,
int  flag 
)
inlinestatic

Definition at line 507 of file object.h.

References give::op.

◆ compare_flags()

static void compare_flags ( ob_flags ret,
const object p,
const object q 
)
inlinestatic

Definition at line 497 of file object.h.

References object::flags, and item::q.

Referenced by get_ob_diff().

+ Here is the caller graph for this function:

◆ find_force()

object* find_force ( object op,
const char *  name 
)

Find a force with the given 'name' in the slaying field. These forces are used as markers that may expire, for example, in the marker type. This is a thin wrapper around object_find_by_type_and_slaying().

Definition at line 5416 of file object.cpp.

References FORCE, give::name, object_find_by_type_and_slaying(), and give::op.

Referenced by add_force(), is_criminal(), and move_marker().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IS_PLAYER()

static bool IS_PLAYER ( object op)
inlinestatic

Definition at line 607 of file object.h.

References give::op, and PLAYER.

Referenced by apply_map_builder(), check_spell_expiry(), command_use(), do_harvest(), and move_aura().

+ Here is the caller graph for this function:

◆ NROF()

static uint32_t NROF ( const object *const  ob)
inlinestatic

Returns ob->nrof, unless it is 0, in which case return 1. Most of the code assumes that nrof=0 is the same as nrof=1.

Definition at line 623 of file object.h.

References guildjoin::ob.

Referenced by check_altar_sacrifice(), check_trigger(), content_recipe_value(), detect_curse_on_item(), detect_magic_on_item(), identify_object_with_skill(), make_item_from_recipe(), object_split(), object_sum_weight(), pick_up_object(), price_base(), query_weight(), shop_price_sell(), trapdoor_type_move_on(), and update_button().

+ Here is the caller graph for this function:

◆ query_flag()

static int query_flag ( const object op,
int  flag 
)
inlinestatic

Definition at line 503 of file object.h.

References give::op.

Referenced by do_follow().

+ Here is the caller graph for this function:

◆ set_flag()

static void set_flag ( object op,
int  flag 
)
inlinestatic

Definition at line 511 of file object.h.

References give::op.

Variable Documentation

◆ active_objects

object* active_objects

List of active objects that need to be processed

Definition at line 296 of file object.cpp.

Referenced by init_objects(), object_count_active(), object_remove_from_active_list(), object_update_speed(), and process_events().

◆ body_locations

The ordering of this is actually doesn't make a difference However, for ease of use, new entries should go at the end so those people that debug the code that get used to something being in the location 4 don't get confused.

The ordering in save_name, use_name, nonuse_name. save_name is the name used to load/save it from files. It should match that of the doc/Developers/objects. The only real limitation is that it shouldn't have spaces or other characters that may mess up the match code. It must also start with body_ use_name is how we describe the location if we can use it. nonuse_name is how we describe it if we can't use it. I think the values below will make it pretty clear how those work out They are basically there to make life a little easier - if a character examines an item and it says it goes on 'your arm', its pretty clear they can use it. See the last sample (commented out) for a dragon Note that using the term 'human' may not be very accurate, humanoid may be better. Basically, for the use/nonuse, the code does something like: "This item goes %s\n", with the use/nonuse values filling in the s

Definition at line 55 of file item.cpp.

Referenced by command_body(), examine(), get_ob_diff(), and set_body_info().

◆ move_name

const char* const move_name[]

Maps the MOVE_* values to names

Definition at line 4828 of file object.cpp.

Referenced by get_string_move_type(), and set_move().

◆ nrofallocobjects

int nrofallocobjects

How many OBs allocated (free + used)

Definition at line 291 of file object.cpp.

Referenced by expand_objects(), malloc_info(), and object_free_all_data().

◆ nroffreeobjects

int nroffreeobjects

How many OBs allocated and free (free)

Definition at line 290 of file object.cpp.

Referenced by expand_objects(), malloc_info(), object_free(), object_free_all_data(), and object_new().

◆ objects