 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
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);
78 for (
size_t i = 0; i < count; i++) {
79 if (strcmp(
split[i],
"*") == 0) {
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);
static void ring_bell(void)
Ring the city bells for each player.
player * next
Pointer to next player, NULL if this is last.
player * first_player
First player.
std::string fallback
Message if the god's name is not in Region::bells.
size_t bufferreader_current_line(BufferReader *br)
Return the index of the last line returned by bufferreader_next_line().
@ llevError
Error, serious thing.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
object * ob
The object representing the player.
struct mapstruct * map
Pointer to the map in which this object is present.
Represents the ingame time.
void get_tod(timeofday_t *tod)
Computes the ingame time of the day.
char * name
Shortend name of the region as maps refer to it.
std::unordered_map< std::string, std::string > bells
Map between a god's name and the message to display.
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
event_registration events_register_global_handler(int eventcode, f_plug_event hook)
Register a global event handler.
std::vector< char * > disabled_plugins
List of disabled plugins, 'All' means all.
struct player * contr
Pointer to the player which control this object.
const char * determine_god(object *op)
Determines if op worships a god.
void assets_add_collector_hook(const char *name, collectorHook hook)
void events_unregister_global_handler(int eventcode, event_registration id)
Remove a global event handler.
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.
void cfcitybell_init(Settings *, ServerSettings *serverSettings)
Citybells module initialisation.
#define EVENT_CLOCK
Global time event.
#define NDI_UNIQUE
Print immediately, don't buffer.
std::vector< region * > all_regions
unsigned long event_registration
Registration identifier type.
ServerSettings serverSettings
static std::unordered_map< std::string, Region * > regions
All defined regions.
static event_registration global_handler
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
Crossfire Architecture the general intention is to enhance the enjoyability and playability of CF In this code
static std::vector< std::string > split(const std::string &field, const std::string &by)
static int clock_listener(int *type,...)
Global event handling, only uses EVENT_CLOCK.
static void load_bells(BufferReader *reader, const char *filename)
Load a .bells file.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.