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");
317 while ((*
name) !=
'\0' && (isdigit(*
name) || (*
name) ==
' '))
327 if (strcmp(rec->
title,
"NONE"))
330 if (
arch->clone.title != NULL) {
352 object *cauldron = NULL, *
inv;
353 object *ingredients[50];
355 uint32_t
count, counts[50];
368 LOG(
llevError,
"knowledge: recipe %s has more than 50 ingredients!",
item->item);
374 for (cauldron =
pl->
ob->
below; cauldron; cauldron = cauldron->
below) {
379 if (cauldron == NULL) {
384 cauldron_tag = cauldron->
count;
388 ingredients[
index] = NULL;
395 if (
inv->title == NULL)
401 for (ing = rp->
ingred; ing != NULL; ing = ing->
next) {
403 if (ingredients[
index] != NULL) {
410 while (isdigit(*ingname)) {
416 while (*ingname ==
' ')
432 for (ing = rp->
ingred; ing != NULL; ing = ing->
next) {
433 if (ingredients[
index] == NULL) {
451 while (cauldron->
inv != NULL) {
454 if (cauldron->
inv ==
inv) {
493 while (cauldron->
inv) {
515 LOG(
llevError,
"knowledge: couldn't find recipe for %s", code);
531 for (i = 0; i <
current->item_count; i++) {
532 if (strcmp(kt->
type,
current->items[i]->handler->type) == 0 && strcmp(
item,
current->items[i]->item) == 0) {
623 char *pos, *first = dup;
627 pos = strchr(first,
':');
631 first = pos ? pos + 1 : NULL;
686 what = atoi(pos + 1);
738 what = atoi(pos + 1);
740 for (i = 0; i <
current->item_count; i++) {
745 if (strncmp(
check->item, dup, strlen(dup)) == 0) {
748 pos = strchr(
check->item,
':');
749 known = atoi(pos + 1);
777 letter = strlen(
buf);
779 for (; letter < strlen(
buf); letter++) {
780 if (
buf[letter] ==
':') {
787 if (altar_arch == NULL)
851 {
"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 },
852 {
"monster",
knowledge_monster_summary,
knowledge_monster_detail,
knowledge_monster_validate,
knowledge_monster_add,
"monsters", NULL, NULL,
"knowledge_monsters.111",
knowledge_monster_face },
853 {
"god",
knowledge_god_summary,
knowledge_god_detail,
knowledge_god_validate,
knowledge_god_add,
"gods", NULL, NULL,
"knowledge_gods.111",
knowledge_god_face },
854 {
"message",
knowledge_message_summary,
knowledge_message_detail,
knowledge_message_validate,
knowledge_add,
"messages", NULL, NULL,
"knowledge_messages.111",
knowledge_message_face },
855 { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
896 fprintf(
file,
"%s:%s\n",
item->handler->type,
item->item);
918 file = fopen(
final,
"r");
924 while (fgets(read,
sizeof(read),
file) != NULL) {
925 if (strlen(read) > 0)
926 read[strlen(read) - 1] =
'\0';
928 dot = strchr(read,
':');
930 LOG(
llevError,
"knowledge: invalid line in file %s\n",
final);
938 LOG(
llevError,
"knowledge: invalid type %s in file %s\n", read,
final);
941 if (!
type->validate(dot + 1)) {
942 LOG(
llevDebug,
"knowledge: ignoring now invalid %s in file %s\n", read,
final);
994 char *dot, *copy, *code;
1000 dot = strchr(marker,
':');
1004 copy = strdup(marker);
1008 dot = strchr(copy,
':');
1014 LOG(
llevError,
"knowledge: invalid marker type %s in %s\n", copy, book == NULL ?
"(null)" : book->
name);
1019 none = (
current->items == NULL);
1022 while (code && code[0] !=
'\0') {
1023 dot = strchr(code,
'/');
1028 if (
type->validate(code)) {
1072 assert(search == NULL || search[0] !=
'\0');
1080 item->handler->summary(
item->item, summary);
1083 if (show_only != NULL &&
item->handler != show_only) {
1086 if (search != NULL && search[0] !=
'\0') {
1087 if (strstr(
final, search) == NULL) {
1090 item->handler->detail(
item->item, detail);
1092 if (strstr(fd, search) == NULL)
1102 else if (show_only != NULL)
1118 else if (show_only != NULL)
1143 if (show_only == NULL) {
1198 if (
item->handler->attempt_alchemy == NULL) {
1201 item->handler->attempt_alchemy(
pl->contr,
item);
1213 LOG(
llevError,
"command_knowledge: called for %s not a player!\n",
pl->name);
1222 if (strncmp(
params,
"list", 4) == 0) {
1227 if (strncmp(
params,
"search ", 7) == 0) {
1232 if (strncmp(
params,
"show ", 5) == 0) {
1237 if (strncmp(
params,
"attempt ", 8) == 0) {
1306 pos = strchr(copy,
':');
1344 if (
item->title != NULL) {
1345 snprintf(item_name,
sizeof(item_name),
"%s %s",
item->name,
item->title);
1486 if (
item->handler->item_face != NULL)
1487 face =
item->handler->item_face(
item->item);
1492 size = 4 + (2 + strlen(
item->handler->type)) + (2 + strlen(
title)) + 4;
1529 if (
op->contr == NULL)
#define object_was_destroyed(op, old_tag)
static int knowledge_alchemy_validate(const char *item)
struct knowledge_player * next
void SockList_AddInt(SockList *sl, uint32_t data)
void knowledge_send_info(socket_struct *ns)
sstring add_refcount(sstring str)
recipelist * get_formulalist(int i)
int(* knowledge_is_valid_item)(const char *code)
sstring add_string(const char *str)
StringBuffer * stringbuffer_new(void)
void knowledge_process_incremental(void)
static void knowledge_message_summary(const char *value, StringBuffer *buf)
int use_alchemy(object *op)
#define MONSTER_EXCLUDE_FROM_READABLE_KEY
static void knowledge_monster_summary(const char *item, StringBuffer *buf)
static void knowledge_read_player_data(knowledge_player *kp)
#define QUERY_FLAG(xyz, p)
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
void free_knowledge(void)
StringBuffer *(* knowledge_can_use_alchemy)(sstring code, const char *item, StringBuffer *buf, int index)
void command_knowledge(object *pl, const char *params)
void SockList_AddString(SockList *sl, const char *data)
static const Face * knowledge_monster_face(sstring code)
knowledge_attempt attempt_alchemy
static int knowledge_known(const knowledge_player *current, const char *item, const knowledge_type *kt)
knowledge
DIALOGCHECK MINARGS 1 MAXARGS 1
const typedef Face *(* knowledge_face)(sstring code)
struct knowledge_item knowledge_item
#define MSG_TYPE_COMMAND_EXAMINE
static int knowledge_god_validate(const char *item)
struct knowledge_player knowledge_player
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
void SockList_AddLen16Data(SockList *sl, const void *data, size_t len)
void SockList_Reset(SockList *sl)
static void knowledge_god_detail(const char *item, StringBuffer *buf)
void apply_by_living_below(object *pl)
sstring get_message_body(const GeneralMessage *message)
static void knowledge_god_summary(const char *item, StringBuffer *buf)
size_t SockList_Avail(const SockList *sl)
const char * object_get_value(const object *op, const char *const key)
void free_string(sstring str)
static void knowledge_do_attempt(object *pl, const char *params)
knowledge_summary summary
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
static void knowledge_monster_detail(const char *item, StringBuffer *buf)
void command_take(object *op, const char *params)
static int knowledge_god_add(struct knowledge_player *current, const char *item, const struct knowledge_type *type)
void query_name(const object *op, char *buf, size_t size)
sstring stringbuffer_finish_shared(StringBuffer *sb)
int of_close(OutputFile *of)
#define MSG_TYPE_COMMAND_INFO
void fatal(enum fatal_error err)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
static void knowledge_write_player_data(const knowledge_player *kp)
EXTERN player * first_player
void knowledge_add_probe_monster(object *op, object *mon)
void command_help(object *op, const char *params)
int knowledge_player_knows(const player *pl, const char *knowledge)
char * stringbuffer_finish(StringBuffer *sb)
struct linked_char * next
const typedef char * sstring
static const knowledge_type * knowledge_find(const char *type)
const Face * recipe_get_face(const recipe *rp)
static const recipe * knowledge_alchemy_get_recipe(const char *value)
knowledge_is_valid_item validate
void SockList_Init(SockList *sl)
const GeneralMessage * get_message_from_identifier(const char *identifier)
static void knowledge_alchemy_detail(const char *value, StringBuffer *buf)
struct knowledge_item ** items
struct knowledge_type knowledge_type
static void knowledge_display(object *pl, const char *params)
static int knowledge_monster_validate(const char *item)
size_t strlcpy(char *dst, const char *src, size_t size)
static std::shared_ptr< inja::Environment > env
#define MSG_TYPE_ADMIN_LOADSAVE
void knowledge_first_player_save(player *pl)
const Face * get_message_face(const GeneralMessage *message)
void SockList_Term(SockList *sl)
static knowledge_player * knowledge_get_or_create(const player *pl)
archetype * find_archetype_by_object_name(const char *name)
static const knowledge_type knowledges[]
void(* knowledge_detail)(const char *code, StringBuffer *buf)
static knowledge_player * knowledge_global
void LOG(LogLevel logLevel, const char *format,...)
FILE * of_open(OutputFile *of, const char *fname)
static void knowledge_alchemy_attempt(player *pl, const knowledge_item *item)
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,...)
struct recipestruct * next
void(* knowledge_summary)(const char *code, StringBuffer *buf)
#define MSG_TYPE_CLIENT_NOTICE
static void free_knowledge_items(knowledge_player *kp)
struct recipestruct * items
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
const knowledge_type * handler
archetype * try_find_archetype(const char *name)
const Face * try_find_face(const char *name, const Face *error)
int(* knowledge_add_item)(struct knowledge_player *current, const char *item, const struct knowledge_type *type)
void(* knowledge_attempt)(player *pl, const struct knowledge_item *item)
static int knowledge_message_validate(const char *item)
knowledge_can_use_alchemy use_alchemy
static void knowledge_alchemy_summary(const char *value, StringBuffer *buf)
int describe_god(const object *god, int what, StringBuffer *buf, size_t maxlen)
static void knowledge_do_display(object *pl, const knowledge_type *show_only, const char *search)
void knowledge_item_can_be_used_alchemy(object *op, const object *item)
void knowledge_read(player *pl, object *book)
static void knowledge_message_detail(const char *value, StringBuffer *buf)
static const Face * knowledge_message_face(sstring code)
static const Face * knowledge_alchemy_face(sstring code)
void examine(object *op, object *tmp)
void Send_With_Handling(socket_struct *ns, SockList *sl)
static int knowledge_monster_add(struct knowledge_player *current, const char *item, const struct knowledge_type *type)
void knowledge_send_known(player *pl)
static void knowledge_show(object *pl, const char *params)
static void free_knowledge_player(knowledge_player *kp)
static const Face * knowledge_god_face(sstring code)
void knowledge_give(player *pl, const char *marker, const object *book)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
static int knowledge_add(knowledge_player *current, const char *item, const knowledge_type *kt)
void SockList_AddPrintf(SockList *sl, const char *format,...)
sstring get_message_title(const GeneralMessage *message)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)