26 int text = 0, nrofmsg = 0;
28 LOG(
llevDebug,
"Reading messages from %s...\n", filename.c_str());
33 if (*buf ==
'#' || (*buf ==
'\0' && !text))
37 cp = buf + strlen(buf);
38 while (cp > buf && (cp[-1] ==
' ' || cp[-1] ==
'\t'))
45 if (text && strncmp(buf,
"ENDMSG", 6) == 0) {
47 LOG(
llevDebug,
"Warning: this string exceeded max book buf size:\n");
51 if (tmp->identifier[0] !=
'\n' && tmp->title == NULL) {
68 }
else if (strcmp(buf,
"TEXT") == 0) {
70 }
else if (strncmp(buf,
"CHANCE ", 7) == 0) {
71 tmp->chance = atoi(buf + 7);
72 }
else if (strncmp(buf,
"TITLE ", 6) == 0) {
74 }
else if (strncmp(buf,
"QUEST ", 6) == 0) {
76 }
else if (strncmp(buf,
"FACE ", 5) == 0) {
82 }
else if (strncmp(buf,
"MSG", 3) == 0) {
94 if (!tmp->identifier) {
109 LOG(
llevDebug,
"done messages %s, found %d messages.\n", filename.c_str(), nrofmsg);
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
New face structure - this enforces the notion that data is face by face only - you can not change the...
#define HUGE_BUF
Used for messages - some can be quite long.
AssetsTracker * m_tracker
sstring add_string(const char *str)
Share a string.
size_t bufferreader_current_line(BufferReader *br)
Return the index of the last line returned by bufferreader_next_line().
Global type definitions and header inclusions.
#define BOOK_BUF
Maximum message buf size for books.
Base class to be informed of where an asset is defined.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Compatibility implementations of useful nonstandard types and functions.
virtual void assetDefined(const archetype *asset, const std::string &filename)
Function called when an asset is defined in a file.
int buf_overflow(const char *buf1, const char *buf2, size_t bufsize)
We don't want to exceed the buffer size of buf1 by adding on buf2!
Only for debugging purposes.
const Face * find_face(const char *name)
MessageLoader(Messages *messages, AssetsTracker *tracker)
One general message, from the lib/messages file.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
virtual void load(BufferReader *reader, const std::string &filename) override
Load assets from the specified reader.
T * define(const Key &name, T *asset)
Define an asset, erasing an existing one.