summaryrefslogtreecommitdiff
path: root/src/map/HPMmap.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-01-13 23:52:27 -0200
committershennetsind <ind@henn.et>2014-01-13 23:52:27 -0200
commite1a0059919dbc4f5c7e803a496b8d150c0a070f5 (patch)
tree1f6b3b05202e9401ca8eadf3777cc8710a8eab05 /src/map/HPMmap.c
parent8d1b8108fcad1a628531801914950b5f92767b0a (diff)
downloadhercules-e1a0059919dbc4f5c7e803a496b8d150c0a070f5.tar.gz
hercules-e1a0059919dbc4f5c7e803a496b8d150c0a070f5.tar.bz2
hercules-e1a0059919dbc4f5c7e803a496b8d150c0a070f5.tar.xz
hercules-e1a0059919dbc4f5c7e803a496b8d150c0a070f5.zip
Fixed HPM support for group permissions
pcg->add_permission dropped, use 'AddGroupPermission("name",unsigned int var for mask id)' Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/HPMmap.c')
-rw-r--r--src/map/HPMmap.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 8d7c74ef2..9c09a7ad1 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -65,8 +65,9 @@ void HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
}
void HPM_map_plugin_load_sub(struct hplugin *plugin) {
- plugin->hpi->addCommand = HPM->import_symbol("addCommand",plugin->idx);
- plugin->hpi->addScript = HPM->import_symbol("addScript",plugin->idx);
+ plugin->hpi->addCommand = HPM->import_symbol("addCommand",plugin->idx);
+ plugin->hpi->addScript = HPM->import_symbol("addScript",plugin->idx);
+ plugin->hpi->addPCGPermission = HPM->import_symbol("addGroupPermission",plugin->idx);
}
bool HPM_map_add_atcommand(char *name, AtCommandFunc func) {
@@ -98,6 +99,30 @@ void HPM_map_atcommands(void) {
}
void HPM_map_do_final(void) {
+ unsigned char i;
+
if( atcommand_list )
aFree(atcommand_list);
+ /**
+ * why is pcg->HPM being cleared here? because PCG's do_final is not final,
+ * is used on reload, and would thus cause plugin-provided permissions to go away
+ **/
+ for( i = 0; i < pcg->HPMpermissions_count; i++ ) {
+ aFree(pcg->HPMpermissions[i].name);
+ }
+ if( pcg->HPMpermissions )
+ aFree(pcg->HPMpermissions);
+}
+
+/**
+ * Adds a new group permission to the HPM-provided list
+ **/
+void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned int *mask) {
+ unsigned char index = pcg->HPMpermissions_count;
+
+ RECREATE(pcg->HPMpermissions, struct pc_groups_new_permission, ++pcg->HPMpermissions_count);
+
+ pcg->HPMpermissions[index].pID = pluginID;
+ pcg->HPMpermissions[index].name = aStrdup(name);
+ pcg->HPMpermissions[index].mask = mask;
}