handler.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef __HANDLER_H
  2. #define __HANDLER_H
  3. //*****************************************************************************
  4. //
  5. // handler.h
  6. //
  7. // this header contains definitions for all of the "handling" functions;
  8. // functions that move things from place to place. e.g. adding and removing
  9. // characters from rooms, as well as objects and the like.
  10. //
  11. //*****************************************************************************
  12. // when something needs to be removed from the game, it should NOT be deleted.
  13. // If it has an extraction function, it should be extracted. If it does not,
  14. // then its from_game function should be called, AND THEN it should be deleted.
  15. // When something needs to be put into the game, its to_game function should be
  16. // called AND THEN it should be added to the game (e.g. loading a character and
  17. // putting him into a room... call char_to_game first); exist functions are to
  18. // state that something is ready for interaction with but it is *not* ready to
  19. // be placed in the game yet. Conversely, unexist functions are to state that
  20. // something is no longer ready for interaction but was never part of the game
  21. // For instance, when a brand new character has been made for character
  22. // creation. Whenever something is put to_game, it is first make to exist.
  23. // Whenever something is remove from_game, it is also immediately unexisted.
  24. void char_exist (CHAR_DATA *ch);
  25. void char_unexist (CHAR_DATA *ch);
  26. bool char_exists (CHAR_DATA *ch);
  27. void char_to_game (CHAR_DATA *ch);
  28. void char_from_game (CHAR_DATA *ch);
  29. void obj_exist (OBJ_DATA *obj);
  30. void obj_unexist (OBJ_DATA *obj);
  31. bool obj_exists (OBJ_DATA *obj);
  32. void obj_to_game (OBJ_DATA *obj);
  33. void obj_from_game (OBJ_DATA *obj);
  34. void room_exist (ROOM_DATA *room);
  35. void room_unexist (ROOM_DATA *room);
  36. bool room_exists (ROOM_DATA *room);
  37. void room_to_game (ROOM_DATA *room);
  38. void room_from_game (ROOM_DATA *room);
  39. void exit_exist (EXIT_DATA *exit);
  40. void exit_unexist (EXIT_DATA *exit);
  41. bool exit_exists (EXIT_DATA *exit);
  42. void exit_to_game (EXIT_DATA *exit);
  43. void exit_from_game (EXIT_DATA *exit);
  44. // all of these things require that the character(s) and object(s) have
  45. // the right spatial relations to eachtoher (e.g. do_give requires the
  46. // object be in the char's inventory and the receiver to be in the same room
  47. // as the character, do_get requires the object be on the ground of the room
  48. // the character is in)
  49. void do_remove (CHAR_DATA *ch, OBJ_DATA *obj);
  50. void do_wear (CHAR_DATA *ch, OBJ_DATA *obj, const char *where);
  51. void do_drop (CHAR_DATA *ch, OBJ_DATA *obj);
  52. void do_give (CHAR_DATA *ch, CHAR_DATA *recv, OBJ_DATA *obj);
  53. void do_get (CHAR_DATA *ch, OBJ_DATA *obj, OBJ_DATA *container);
  54. void do_put (CHAR_DATA *ch, OBJ_DATA *obj, OBJ_DATA *container);
  55. void obj_from_char (OBJ_DATA *obj);
  56. void obj_from_obj (OBJ_DATA *obj);
  57. void obj_from_room (OBJ_DATA *obj);
  58. void obj_to_char (OBJ_DATA *obj, CHAR_DATA *ch);
  59. void obj_to_obj (OBJ_DATA *obj, OBJ_DATA *to);
  60. void obj_to_room (OBJ_DATA *obj, ROOM_DATA *room);
  61. void char_from_room (CHAR_DATA *ch);
  62. void char_to_room (CHAR_DATA *ch, ROOM_DATA *room);
  63. void char_from_furniture (CHAR_DATA *ch);
  64. void char_to_furniture (CHAR_DATA *ch, OBJ_DATA *furniture);
  65. bool do_equip (CHAR_DATA *ch, OBJ_DATA *obj, const char *pos,
  66. bool by_name);
  67. bool try_equip (CHAR_DATA *ch, OBJ_DATA *obj,
  68. const char *wanted_pos, const char *required_pos);
  69. bool try_unequip (CHAR_DATA *ch, OBJ_DATA *obj);
  70. bool do_unequip (CHAR_DATA *ch, OBJ_DATA *obj);
  71. void unequip_all (CHAR_DATA *ch);
  72. #define FOUND_NONE 0
  73. #define FOUND_EXIT 1
  74. #define FOUND_CHAR 2
  75. #define FOUND_OBJ 3
  76. #define FOUND_EDESC 4
  77. #define FOUND_ROOM 5
  78. #define FOUND_IN_OBJ 6 // useful for portals and containers
  79. #define FOUND_LIST 7 // returns a list of things ... may
  80. // occur when looking for all.XXX
  81. // will only be returned if there is only
  82. // FIND_TYPE to look for. The list must
  83. // be deleted afterwards
  84. #define FIND_TYPE_CHAR (1 << 0)
  85. #define FIND_TYPE_OBJ (1 << 1)
  86. #define FIND_TYPE_EXIT (1 << 2)
  87. #define FIND_TYPE_EDESC (1 << 3)
  88. #define FIND_TYPE_IN_OBJ (1 << 4)
  89. #define FIND_TYPE_ROOM (1 << 5)
  90. #define FIND_TYPE_ALL (FIND_TYPE_CHAR | FIND_TYPE_OBJ | \
  91. FIND_TYPE_ROOM | FIND_TYPE_EXIT | \
  92. FIND_TYPE_EDESC | FIND_TYPE_IN_OBJ)
  93. #define FIND_SCOPE_ROOM (1 << 10)
  94. #define FIND_SCOPE_INV (1 << 11)
  95. #define FIND_SCOPE_WORN (1 << 12)
  96. #define FIND_SCOPE_WORLD (1 << 13)
  97. #define FIND_SCOPE_VISIBLE (1 << 18)
  98. #define FIND_SCOPE_IMMEDIATE (FIND_SCOPE_ROOM | FIND_SCOPE_INV | \
  99. FIND_SCOPE_WORN | FIND_SCOPE_VISIBLE)
  100. #define FIND_SCOPE_ALL (FIND_SCOPE_ROOM | FIND_SCOPE_INV | \
  101. FIND_SCOPE_WORN | FIND_SCOPE_WORLD)
  102. //
  103. // Searches the looker's scope of vision for a thing in <find_types> with <arg>
  104. // as the target. Sets found_type to the type of item returned.
  105. // arg can be manipulated in various ways, such as adding an occurance number
  106. // to the start of arg (e.g. 2.woman) or specifying scopes of search
  107. // (e.g. woman in bed) or combinations of the two (e.g. 2.woman in 6.bed)
  108. // if all_ok is true, then it is possible to return a list of things
  109. // (all of one type) if someone uses something like all.woman
  110. //
  111. void *generic_find(CHAR_DATA *looker, const char *arg,
  112. bitvector_t find_types,
  113. bitvector_t find_scope,
  114. bool all_ok, int *found_type);
  115. void *find_specific(CHAR_DATA *looker,
  116. const char *at,
  117. const char *on,
  118. const char *in,
  119. bitvector_t find_types,
  120. bitvector_t find_scope,
  121. bool all_ok, int *found_type);
  122. #endif // __HANDLER_H