-
Notifications
You must be signed in to change notification settings - Fork 93
Add bz_eReloadEvent API event #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4286,10 +4286,29 @@ BZF_API const char* bz_getServerOwner() | |
| return getPublicOwner().c_str(); | ||
| } | ||
|
|
||
| BZF_API void bz_reloadAll() | ||
| { | ||
| bz_ReloadData_V1 event; | ||
| event.target = "all"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since each method individually calls load events, is this redundant?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically no, since this will send "all" and each call below will send a different string, but if "all" is exploded on the other side then ...
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I was thinking that if we want to listen to an explicit |
||
|
|
||
| bz_reloadLocalBans(); | ||
| bz_reloadMasterBans(); | ||
| bz_reloadGroups(); | ||
| bz_reloadUsers(); | ||
| bz_reloadHelp(); | ||
| bz_reloadBadwords(); | ||
| } | ||
|
|
||
| BZF_API void bz_reloadLocalBans() | ||
| { | ||
| // reload the banlist | ||
| logDebugMessage(3,"Reloading bans\n"); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.target = "bans"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as noted below, what's the proper interaction with the event manager? Should the call be before the |
||
|
|
||
| clOptions->acl.load(); | ||
|
|
||
| rescanForBans(); | ||
|
|
@@ -4302,6 +4321,11 @@ BZF_API void bz_reloadMasterBans() | |
|
|
||
| // reload the banlist | ||
| logDebugMessage(3,"Reloading master bans\n"); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.target = "masterbans"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method can short-circuit (line 4320 above), meaning the event manager will not dispatch this message. Is that right? |
||
|
|
||
| clOptions->acl.purgeMasters(); | ||
|
|
||
| masterBanHandler.start(); | ||
|
|
@@ -4310,13 +4334,24 @@ BZF_API void bz_reloadMasterBans() | |
| BZF_API void bz_reloadGroups() | ||
| { | ||
| logDebugMessage(3,"Reloading groups\n"); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.target = "groups"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
|
||
| groupAccess.clear(); | ||
| initGroups(); | ||
| } | ||
|
|
||
| BZF_API void bz_reloadUsers() | ||
| { | ||
| logDebugMessage(3,"Reloading users\n"); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.target = "users"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
|
||
|
|
||
| userDatabase.clear(); | ||
|
|
||
| if (userDatabaseFile.size()) | ||
|
|
@@ -4328,12 +4363,23 @@ BZF_API void bz_reloadHelp() | |
| { | ||
| // reload the text chunks | ||
| logDebugMessage(3,"Reloading helpfiles\n"); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.target = "helpfiles"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
|
||
|
|
||
| clOptions->textChunker.reload(); | ||
| } | ||
|
|
||
| BZF_API void bz_reloadBadwords() | ||
| { | ||
| logDebugMessage(3,"Reloading bad words\n"); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.target = "badwords"; | ||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
|
||
| clOptions->filter.clear(); | ||
| loadBadwordsList(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2762,13 +2762,20 @@ bool ReloadCommand::operator() (const char *message, | |
|
|
||
| logDebugMessage(3,"Command is %s\n", cmd.c_str()); | ||
|
|
||
| bz_ReloadData_V1 event; | ||
| event.playerID = t; | ||
| event.target = cmd.c_str(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this need validation prior to being shoved down the event manager?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call, this would allow for |
||
|
|
||
| worldEventManager.callEvents(bz_eReloadEvent, &event); | ||
|
|
||
| /* handle subcommands */ | ||
|
|
||
| bool reload_bans = false; | ||
| bool reload_groups = false; | ||
| bool reload_users = false; | ||
| bool reload_helpfiles = false; | ||
| bool reload_badwords = false; | ||
|
|
||
| if ((cmd == "") || (cmd == "all")) | ||
| { | ||
| logDebugMessage(3,"Reload all\n"); | ||
|
|
@@ -2805,8 +2812,14 @@ bool ReloadCommand::operator() (const char *message, | |
| } | ||
| else | ||
| { | ||
| // Allow a plug-in to take over | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming the unconditional event manager call is correct, then shouldn't this be moved immediately after it? I apologize for not being clear on how the event manager interacts; is the point to "do what we do" and allow plugins to extend, or do we allow plugins to override? |
||
| if (event.handled) { | ||
| return true; | ||
| } | ||
|
|
||
| sendMessage(ServerPlayer, t, "Invalid option for the reload command"); | ||
| sendMessage(ServerPlayer, t, "Usage: /reload [all|bans|badwords|helpfiles|groups|users]"); | ||
|
|
||
| return true; // Bail out | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.