Go to the documentation of this file.
69 #define TAG_START "[color=#ff6611]"
70 #define TAG_END "[/color]"
178 dot = strchr(
value,
':');
185 index = atoi(dot + 1);
186 dot = strchr(dot + 1,
':');
223 if (strcmp(rec->
title,
"NONE"))
226 if (
arch->clone.title != NULL) {
256 if (strcmp(rec->
title,
"NONE"))
259 if (
arch->clone.title != NULL) {
270 snprintf(
name,
sizeof(
name),
"an unknown place");
273 rec->
diff >= 10 && rec->
diff < 15 ?
"n" :
"",
320 while ((*
name) !=
'\0' && (isdigit(*
name) || (*
name) ==
' '))
330 if (strcmp(rec->
title,
"NONE"))
333 if (
arch->clone.title != NULL) {
355 object *cauldron = NULL, *
inv;
356 object *ingredients[50];
358 uint32_t
count, counts[50];
371 LOG(
llevError,
"knowledge: recipe %s has more than 50 ingredients!",
item->item);
377 for (cauldron =
pl->ob->below; cauldron; cauldron = cauldron->
below) {
382 if (cauldron == NULL) {
387 cauldron_tag = cauldron->
count;
391 ingredients[
index] = NULL;
398 if (
inv->title == NULL)
404 for (ing = rp->
ingred; ing != NULL; ing = ing->
next) {
406 if (ingredients[
index] != NULL) {
413 while (isdigit(*ingname)) {
419 while (*ingname ==
' ')
435 for (ing = rp->
ingred; ing != NULL; ing = ing->
next) {
436 if (ingredients[
index] == NULL) {
445 if (
pl->ob->container != cauldron) {
447 if (
pl->ob->container != cauldron) {
454 while (cauldron->
inv != NULL) {
457 if (cauldron->
inv ==
inv) {
496 while (cauldron->
inv) {
503 pl->ob->speed_left -= 1.0;
518 LOG(
llevError,
"knowledge: couldn't find recipe for %s", code);
534 for (i = 0; i <
current->item_count; i++) {
535 if (strcmp(kt->
type,
current->items[i]->handler->type) == 0 && strcmp(
item,
current->items[i]->item) == 0) {
626 char *pos, *first = dup;
630 pos = strchr(first,
':');
634 first = pos ? pos + 1 : NULL;
689 what = atoi(pos + 1);
729 char *dup =
strdup_local(
item), *pos =
const_cast<char *
>(strchr(dup,
':'));
741 what = atoi(pos + 1);
743 for (i = 0; i <
current->item_count; i++) {
748 if (strncmp(
check->item, dup, strlen(dup)) == 0) {
751 pos =
const_cast<char *
>(strchr(
check->item,
':'));
752 known = atoi(pos + 1);
780 letter = strlen(
buf);
782 for (; letter < strlen(
buf); letter++) {
783 if (
buf[letter] ==
':') {
790 if (altar_arch == NULL)
854 {
"alchemy",
knowledge_alchemy_summary,
knowledge_alchemy_detail,
knowledge_alchemy_validate,
knowledge_add,
"recipes",
knowledge_alchemy_can_use_item,
knowledge_alchemy_attempt,
"knowledge_recipes.111",
knowledge_alchemy_face },
855 {
"monster",
knowledge_monster_summary,
knowledge_monster_detail,
knowledge_monster_validate,
knowledge_monster_add,
"monsters", NULL, NULL,
"knowledge_monsters.111",
knowledge_monster_face },
856 {
"god",
knowledge_god_summary,
knowledge_god_detail,
knowledge_god_validate,
knowledge_god_add,
"gods", NULL, NULL,
"knowledge_gods.111",
knowledge_god_face },
857 {
"message",
knowledge_message_summary,
knowledge_message_detail,
knowledge_message_validate,
knowledge_add,
"messages", NULL, NULL,
"knowledge_messages.111",
knowledge_message_face },
858 { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
899 fprintf(
file,
"%s:%s\n",
item->handler->type,
item->item);
921 file = fopen(
final,
"r");
927 while (fgets(read,
sizeof(read),
file) != NULL) {
928 if (strlen(read) > 0)
929 read[strlen(read) - 1] =
'\0';
931 dot = strchr(read,
':');
933 LOG(
llevError,
"knowledge: invalid line in file %s\n",
final);
941 LOG(
llevError,
"knowledge: invalid type %s in file %s\n", read,
final);
944 if (!
type->validate(dot + 1)) {
945 LOG(
llevDebug,
"knowledge: ignoring now invalid %s in file %s\n", read,
final);
985 if (
pl->socket->notifications < 2)
997 char *copy, *code, *dot;
1003 dot =
const_cast<char *
>(strchr(marker,
':'));
1007 copy = strdup(marker);
1011 dot =
const_cast<char *
>(strchr(copy,
':'));
1017 LOG(
llevError,
"knowledge: invalid marker type %s in %s\n", copy, book == NULL ?
"(null)" : book->
name);
1022 none = (
current->items == NULL);
1025 while (code && code[0] !=
'\0') {
1026 dot = strchr(code,
'/');
1031 if (
type->validate(code)) {
1047 if (
pl->has_directory)
1075 assert(search == NULL || search[0] !=
'\0');
1083 item->handler->summary(
item->item, summary);
1086 if (show_only != NULL &&
item->handler != show_only) {
1089 if (search != NULL && search[0] !=
'\0') {
1090 if (strstr(
final, search) == NULL) {
1093 item->handler->detail(
item->item, detail);
1095 if (strstr(fd, search) == NULL)
1105 else if (show_only != NULL)
1121 else if (show_only != NULL)
1146 if (show_only == NULL) {
1201 if (
item->handler->attempt_alchemy == NULL) {
1204 item->handler->attempt_alchemy(
pl->contr,
item);
1216 LOG(
llevError,
"command_knowledge: called for %s not a player!\n",
pl->name);
1225 if (strncmp(
params,
"list", 4) == 0) {
1230 if (strncmp(
params,
"search ", 7) == 0) {
1235 if (strncmp(
params,
"show ", 5) == 0) {
1240 if (strncmp(
params,
"attempt ", 8) == 0) {
1309 pos = strchr(copy,
':');
1347 if (
item->title != NULL) {
1348 snprintf(item_name,
sizeof(item_name),
"%s %s",
item->name,
item->title);
1406 if (
pl->socket->notifications < 2)
1489 if (
item->handler->item_face != NULL)
1490 face =
item->handler->item_face(
item->item);
1495 size = 4 + (2 + strlen(
item->handler->type)) + (2 + strlen(
title)) + 4;
1532 if (
op->contr == NULL)
#define object_was_destroyed(op, old_tag)
static void knowledge_alchemy_attempt(player *pl, const knowledge_item *item)
void SockList_AddInt(SockList *sl, uint32_t data)
void knowledge_send_info(socket_struct *ns)
static int knowledge_monster_add(struct knowledge_player *current, const char *item, const struct knowledge_type *type)
recipelist * get_formulalist(int i)
void LOG(LogLevel logLevel, const char *format,...)
int of_close(OutputFile *of)
int use_alchemy(object *op)
#define MONSTER_EXCLUDE_FROM_READABLE_KEY
static int knowledge_god_validate(const char *item)
FILE * of_open(OutputFile *of, const char *fname)
#define QUERY_FLAG(xyz, p)
void free_knowledge(void)
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
void knowledge_add_probe_monster(object *op, object *mon)
static StringBuffer * knowledge_alchemy_can_use_item(sstring code, const char *item, StringBuffer *buf, int index)
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
static int knowledge_god_add(struct knowledge_player *current, const char *item, const struct knowledge_type *type)
StringBuffer * stringbuffer_new(void)
void SockList_AddString(SockList *sl, const char *data)
static void knowledge_display(object *pl, const char *params)
const typedef Face *(* knowledge_face)(sstring code)
knowledge_attempt attempt_alchemy
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
knowledge
DIALOGCHECK MINARGS 1 MAXARGS 1
int(* knowledge_is_valid_item)(const char *code)
#define MSG_TYPE_COMMAND_EXAMINE
static void knowledge_alchemy_detail(const char *value, StringBuffer *buf)
void SockList_AddLen16Data(SockList *sl, const void *data, size_t len)
void SockList_Reset(SockList *sl)
const char * object_get_value(const object *op, const char *const key)
void apply_by_living_below(object *pl)
static int knowledge_add(knowledge_player *current, const char *item, const knowledge_type *kt)
void(* knowledge_summary)(const char *code, StringBuffer *buf)
static void knowledge_god_summary(const char *item, StringBuffer *buf)
size_t SockList_Avail(const SockList *sl)
static void knowledge_write_player_data(const knowledge_player *kp)
static const Face * knowledge_god_face(sstring code)
static const recipe * knowledge_alchemy_get_recipe(const char *value)
char * stringbuffer_finish(StringBuffer *sb)
knowledge_summary summary
sstring add_refcount(sstring str)
static int knowledge_message_validate(const char *item)
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
void command_take(object *op, const char *params)
static void free_knowledge_items(knowledge_player *kp)
void query_name(const object *op, char *buf, size_t size)
sstring stringbuffer_finish_shared(StringBuffer *sb)
#define MSG_TYPE_COMMAND_INFO
sstring add_string(const char *str)
static void knowledge_show(object *pl, const char *params)
void knowledge_give(player *pl, const char *marker, const object *book)
void command_help(object *op, const char *params)
struct linked_char * next
static void knowledge_monster_summary(const char *item, StringBuffer *buf)
static knowledge_player * knowledge_global
sstring get_message_body(const GeneralMessage *message)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
int knowledge_player_knows(const player *pl, const char *knowledge)
knowledge_is_valid_item validate
void SockList_Init(SockList *sl)
const GeneralMessage * get_message_from_identifier(const char *identifier)
void fatal(enum fatal_error err)
static knowledge_player * knowledge_get_or_create(const player *pl)
void knowledge_item_can_be_used_alchemy(object *op, const object *item)
static std::shared_ptr< inja::Environment > env
static const knowledge_type knowledges[]
#define MSG_TYPE_ADMIN_LOADSAVE
size_t strlcpy(char *dst, const char *src, size_t size)
void knowledge_read(player *pl, object *book)
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
void(* knowledge_detail)(const char *code, StringBuffer *buf)
void knowledge_first_player_save(player *pl)
void free_string(sstring str)
int(* knowledge_add_item)(knowledge_player *current, const char *item, const knowledge_type *type)
void SockList_Term(SockList *sl)
void command_knowledge(object *pl, const char *params)
static void knowledge_message_summary(const char *value, StringBuffer *buf)
archetype * find_archetype_by_object_name(const char *name)
sstring get_message_title(const GeneralMessage *message)
static const knowledge_type * knowledge_find(const char *type)
static void knowledge_monster_detail(const char *item, StringBuffer *buf)
const typedef char * sstring
void(* knowledge_attempt)(player *pl, const knowledge_item *item)
static const Face * knowledge_message_face(sstring code)
static void knowledge_do_display(object *pl, const knowledge_type *show_only, const char *search)
void knowledge_send_known(player *pl)
static void knowledge_god_detail(const char *item, StringBuffer *buf)
static const Face * knowledge_monster_face(sstring code)
static void knowledge_do_attempt(object *pl, const char *params)
#define MSG_TYPE_CLIENT_NOTICE
static void free_knowledge_player(knowledge_player *kp)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
StringBuffer *(* knowledge_can_use_alchemy)(sstring code, const char *item, StringBuffer *buf, int index)
const knowledge_type * handler
static int knowledge_monster_validate(const char *item)
archetype * try_find_archetype(const char *name)
const Face * try_find_face(const char *name, const Face *error)
static void knowledge_read_player_data(knowledge_player *kp)
static void knowledge_message_detail(const char *value, StringBuffer *buf)
static int knowledge_alchemy_validate(const char *item)
knowledge_can_use_alchemy use_alchemy
void knowledge_process_incremental(void)
int describe_god(const object *god, int what, StringBuffer *buf, size_t maxlen)
static void knowledge_alchemy_summary(const char *value, StringBuffer *buf)
static const Face * knowledge_alchemy_face(sstring code)
void examine(object *op, object *tmp)
void Send_With_Handling(socket_struct *ns, SockList *sl)
const Face * recipe_get_face(const recipe *rp)
const Face * get_message_face(const GeneralMessage *message)
const char * recipe_get_difficulty_string(int difficulty)
void SockList_AddPrintf(SockList *sl, const char *format,...)
static int knowledge_known(const knowledge_player *current, const char *item, const knowledge_type *kt)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)