summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-02 17:14:01 -0300
committershennetsind <ind@henn.et>2013-05-02 17:14:01 -0300
commita2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d (patch)
tree710a44f94cceff2f0198211d21ddfbe99b66f02c /src/plugins
parent219a4f5267b33349649f952266532a132a48c2a3 (diff)
downloadhercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.tar.gz
hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.tar.bz2
hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.tar.xz
hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.zip
Introducing Hercules Plugin Mananger
http://hercules.ws/board/topic/549-introducing-hercules-plugin-manager/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CMakeLists.txt36
-rw-r--r--src/plugins/Makefile.in28
-rw-r--r--src/plugins/sample.c74
3 files changed, 138 insertions, 0 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
new file mode 100644
index 000000000..4e4851bc5
--- /dev/null
+++ b/src/plugins/CMakeLists.txt
@@ -0,0 +1,36 @@
+#
+# setup
+#
+get_property( CAN_BUILD_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS )
+if( NOT CAN_BUILD_SHARED_LIBS )
+ return()
+endif()
+
+#
+# sample
+#
+option( BUILD_PLUGIN_sample "build sample plugin" OFF )
+if( BUILD_PLUGIN_sample )
+message( STATUS "Creating target sample" )
+set( SAMPLE_SOURCES
+ "${CMAKE_CURRENT_SOURCE_DIR}/sample.c"
+ )
+set( LIBRARIES ${GLOBAL_LIBRARIES} )
+set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} )
+set( DEFINITIONS ${GLOBAL_DEFINITIONS} )
+set( SOURCE_FILES ${SAMPLE_SOURCES} )
+source_group( sample FILES ${SAMPLE_SOURCES} )
+include_directories( ${INCLUDE_DIRS} )
+add_library( sample SHARED ${SOURCE_FILES} )
+target_link_libraries( sample ${LIBRARIES} )
+set_target_properties( sample PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
+set_target_properties( sample PROPERTIES PREFIX "" )
+if( INSTALL_COMPONENT_RUNTIME )
+ cpack_add_component( Runtime_sample DESCRIPTION "sample plugin" DISPLAY_NAME "sample" GROUP Runtime )
+ install( TARGETS sample
+ DESTINATION "plugins"
+ COMPONENT Runtime_sample )
+endif( INSTALL_COMPONENT_RUNTIME )
+set( TARGET_LIST ${TARGET_LIST} sample CACHE INTERNAL "" )
+message( STATUS "Creating target sample - done" )
+endif( BUILD_PLUGIN_sample ) \ No newline at end of file
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
new file mode 100644
index 000000000..71b743dca
--- /dev/null
+++ b/src/plugins/Makefile.in
@@ -0,0 +1,28 @@
+
+COMMON_H = ../common/HPMi.h ../common/cbasetypes.h
+
+PLUGINS = sample
+
+@SET_MAKE@
+
+#####################################################################
+.PHONY : all $(PLUGINS) sample clean help
+
+all: $(PLUGINS)
+
+sample: sample@DLLEXT@
+
+clean:
+ @echo " CLEAN plugins"
+ @rm -rf *.o
+
+help:
+ @echo "possible targets are $(PLUGINS:%='%') 'all' 'clean' 'help'"
+ @echo "'sample' - sample plugin"
+ @echo "'help' - outputs this message"
+
+#####################################################################
+
+%@DLLEXT@: %.c $(COMMON_H)
+ @echo " CC $<"
+ @@CC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o ../../plugins/$@ $< \ No newline at end of file
diff --git a/src/plugins/sample.c b/src/plugins/sample.c
new file mode 100644
index 000000000..8e6b8fc86
--- /dev/null
+++ b/src/plugins/sample.c
@@ -0,0 +1,74 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Sample Hercules Plugin
+
+#include <stdio.h>
+#include <string.h>
+#include "../common/HPMi.h"
+#include "../map/script.h"
+#include "../map/pc.h"
+
+HPExport struct hplugin_info pinfo = {
+ "Sample", // Plugin name
+ SERVER_TYPE_MAP,// Which server types this plugin works with?
+ "0.1", // Plugin version
+ HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
+};
+ACMD(sample) {//@sample command - 5 params: const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info
+ printf("I'm being run! message -> '%s' by %s\n",message,sd->status.name);
+ return true;
+}
+BUILDIN(sample) {//script command 'sample(num);' - 1 param: struct script_state* st
+ int arg = script_getnum(st,2);
+ ShowInfo("I'm being run! arg -> '%d'\n",arg);
+ return true;
+}
+CPCMD(sample) {//console command 'sample' - 1 param: char *line
+ ShowInfo("I'm being run! arg -> '%s'\n",line?line:"NONE");
+}
+struct script_interface *script;/* used by script commands */
+/* run when server starts */
+HPExport void plugin_init (void) {
+ char *server_type;
+ char *server_name;
+
+ //get the symbols from the server
+ server_type = GET_SYMBOL("SERVER_TYPE");
+ server_name = GET_SYMBOL("SERVER_NAME");
+
+ script = GET_SYMBOL("script");
+
+ if( !(script = GET_SYMBOL("script")) ) {
+ ShowError("Failed to load script interface var!\n");
+ }
+
+ ShowInfo ("Server type is ");
+
+ switch (*server_type) {
+ case SERVER_TYPE_LOGIN: printf ("Login Server\n"); break;
+ case SERVER_TYPE_CHAR: printf ("Char Server\n"); break;
+ case SERVER_TYPE_MAP: printf ("Map Server\n"); break;
+ }
+
+ ShowInfo ("I'm being run from the '%s' filename\n", server_name);
+
+ if( HPMi->addCommand != NULL ) {//link our '@sample' command
+ HPMi->addCommand("sample",ACMD_A(sample));
+ }
+
+ if( HPMi->addScript != NULL ) {//link our 'sample' script command
+ HPMi->addScript("sample","i",BUILDIN_A(sample));
+ }
+
+ if( HPMi->addCPCommand != NULL ) {//link our 'sample' console command
+ HPMi->addCPCommand("this:is:a:sample",CPCMD_A(sample));
+ }
+}
+/* run when server is ready (online) */
+HPExport void server_online (void) {
+
+}
+/* run when server is shutting down */
+HPExport void plugin_final (void) {
+ ShowInfo ("%s says ~Bye world\n",pinfo.name);
+} \ No newline at end of file