33 #include <unordered_map> 39 std::unordered_map<std::string, std::string>
bells;
44 static std::unordered_map<std::string, Region *>
regions;
57 if (line[0] ==
'\0' || line[0] ==
'#') {
60 char *space = strchr(line,
' ');
68 if (strcmp(line,
"region") == 0) {
74 LOG(
llevError,
"Missing 'region' in bell file %s\n", filename);
77 size_t count =
split_string(line, split,
sizeof(split),
',');
78 for (
size_t i = 0; i < count; i++) {
79 if (strcmp(split[i],
"*") == 0) {
82 current->
bells[split[i]] = space;
102 auto god = found->second->bells.find(god_name);
103 std::string msg = god == found->second->bells.end() ? found->second->fallback : god->second;
104 auto r = msg.find(
"%god");
105 if (r != std::string::npos) {
106 msg.replace(r, 4, god_name);
129 va_start(args, type);
130 code = va_arg(args,
int);
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
const char * determine_god(object *op)
Determines if op worships a god.
static event_registration global_handler
std::string fallback
Message if the god's name is not in Region::bells.
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
static std::vector< std::string > split(const std::string &field, const std::string &by)
void assets_add_collector_hook(const char *name, collectorHook hook)
player * first_player
First player.
std::vector< region * > all_regions
size_t bufferreader_current_line(BufferReader *br)
Return the index of the last line returned by bufferreader_next_line().
Represents the ingame time.
Global type definitions and header inclusions.
static std::unordered_map< std::string, Region * > regions
All defined regions.
struct player * contr
Pointer to the player which control this object.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
player * next
Pointer to next player, NULL if this is last.
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings...
unsigned long event_registration
Registration identifier type.
void cfcitybell_init(Settings *, ServerSettings *serverSettings)
Citybells module initialisation.
std::vector< std::string > disabled_plugins
List of disabled plugins, 'All' means all.
#define EVENT_CLOCK
Global time event.
char * name
Shortend name of the region as maps refer to it.
ServerSettings serverSettings
object * ob
The object representing the player.
std::unordered_map< std::string, std::string > bells
Map between a god's name and the message to display.
struct mapstruct * map
Pointer to the map in which this object is present.
void get_tod(timeofday_t *tod)
Computes the ingame time of the day.
Object structure, the core of Crossfire.
static void ring_bell(void)
Ring the city bells for each player.
static void load_bells(BufferReader *reader, const char *filename)
Load a .bells file.
void events_unregister_global_handler(int eventcode, event_registration id)
Remove a global event handler.
static int clock_listener(int *type,...)
Global event handling, only uses EVENT_CLOCK.
#define NDI_UNIQUE
Print immediately, don't buffer.
C function wrappers to interact with assets.
event_registration events_register_global_handler(int eventcode, f_plug_event hook)
Register a global event handler.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.