Jump to content

chojuro

Members
  • Content Count

    28
  • Joined

  • Last visited

About chojuro

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. how to converte skill_db.txt to skill_db.conf?
  2. i actually updating my old hercules revision to the latest revision a little by little then i found some solution to the other error but this time it messed up with my mapflag plugins
  3. now i got this error no warning at compiler after iapplied this patch any idea how to fix that Index: src/char/Makefile.in =================================================================== --- src/char/Makefile.in (revision 38855) +++ src/char/Makefile.in (revision 38857) @@ -23,7 +23,7 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) ../plugins/HPMHooking.h SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. Index: src/common/HPM.c =================================================================== --- src/common/HPM.c (revision 38855) +++ src/common/HPM.c (revision 38857) @@ -38,6 +38,7 @@ #include "common/timer.h" #include "common/utils.h" #include "common/nullpo.h" +#include "plugins/HPMHooking.h" #include <stdio.h> #include <stdlib.h> @@ -51,6 +52,7 @@ struct malloc_interface *HPMiMalloc; struct HPM_interface HPM_s; struct HPM_interface *HPM; +struct HPMHooking_core_interface HPMHooking_core_s; /** * (char*) data name -> (unsigned int) HPMDataCheck[] index @@ -341,13 +343,13 @@ /* TODO: add ability for tracking using pID for the upcoming runtime load/unload support. */ bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID) { - if (!HPM->hooking) { + if (!HPM->hooking->enabled) { ShowError("HPM:AddHook Fail! '%s' tried to hook to '%s' but HPMHooking is disabled!\n",HPM->pid2name(pID),target); return false; } /* search if target is a known hook point within 'common' */ /* if not check if a sub-hooking list is available (from the server) and run it by */ - if (HPM->addhook_sub && HPM->addhook_sub(type,target,hook,pID)) + if (HPM->hooking->addhook_sub != NULL && HPM->hooking->addhook_sub(type,target,hook,pID)) return true; ShowError("HPM:AddHook: unknown Hooking Point '%s'!\n",target); @@ -358,12 +360,12 @@ void HPM_HookStop(const char *func, unsigned int pID) { /* track? */ - HPM->force_return = true; + HPM->hooking->force_return = true; } -bool HPM_HookStopped (void) +bool HPM_HookStopped(void) { - return HPM->force_return; + return HPM->hooking->force_return; } /** @@ -567,16 +569,20 @@ plugin->hpi->addToHPData = hplugins_addToHPData; plugin->hpi->getFromHPData = hplugins_getFromHPData; plugin->hpi->removeFromHPData = hplugins_removeFromHPData; - plugin->hpi->AddHook = HPM_AddHook; - plugin->hpi->HookStop = HPM_HookStop; - plugin->hpi->HookStopped = HPM_HookStopped; plugin->hpi->addArg = hpm_add_arg; plugin->hpi->addConf = hplugins_addconf; + if ((plugin->hpi->hooking = plugin_import(plugin->dll, "HPMHooking_s", struct HPMHooking_interface *)) != NULL) { + plugin->hpi->hooking->AddHook = HPM_AddHook; + plugin->hpi->hooking->HookStop = HPM_HookStop; + plugin->hpi->hooking->HookStopped = HPM_HookStopped; + } /* server specific */ if( HPM->load_sub ) HPM->load_sub(plugin); - ShowStatus("HPM: Loaded plugin '"CL_WHITE"%s"CL_RESET"' (%s).\n", plugin->info->name, plugin->info->version); + ShowStatus("HPM: Loaded plugin '"CL_WHITE"%s"CL_RESET"' (%s)%s.\n", + plugin->info->name, plugin->info->version, + plugin->hpi->hooking != NULL ? " built with HPMHooking support" : ""); return plugin; } @@ -660,12 +666,13 @@ bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); if ((func = plugin_import(plugin->dll, "Hooked",const char * (*)(bool *))) != NULL && (addhook_sub = plugin_import(plugin->dll, "HPM_Plugin_AddHook",bool (*)(enum HPluginHookType, const char *, void *, unsigned int))) != NULL) { - const char *failed = func(&HPM->force_return); + const char *failed = func(&HPM->hooking->force_return); if (failed) { ShowError("HPM: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"'!\n", failed, plugin_name); } else { - HPM->hooking = true; - HPM->addhook_sub = addhook_sub; + HPM->hooking->enabled = true; + HPM->hooking->addhook_sub = addhook_sub; + HPM->hooking->Hooked = func; // The purpose of this is type-checking 'func' at compile time. } } } @@ -1046,11 +1053,10 @@ void hpm_defaults(void) { HPM = &HPM_s; + HPM->hooking = &HPMHooking_core_s; memset(&HPM->filenames, 0, sizeof(HPM->filenames)); VECTOR_INIT(HPM->cmdline_load_plugins); - HPM->force_return = false; - HPM->hooking = false; /* */ HPM->init = hpm_init; HPM->final = hpm_final; @@ -1067,7 +1073,6 @@ HPM->pid2name = hplugins_id2name; HPM->parse_packets = hplugins_parse_packets; HPM->load_sub = NULL; - HPM->addhook_sub = NULL; HPM->parseConf = hplugins_parse_conf; HPM->getBattleConf = hplugins_get_battle_conf; HPM->DataCheck = HPM_DataCheck; @@ -1078,4 +1083,9 @@ HPM->data_store_create = hplugin_data_store_create; HPM->data_store_validate = hplugin_data_store_validate; HPM->data_store_validate_sub = NULL; + + HPM->hooking->enabled = false; + HPM->hooking->force_return = false; + HPM->hooking->addhook_sub = NULL; + HPM->hooking->Hooked = NULL; } Index: src/common/HPM.h =================================================================== --- src/common/HPM.h (revision 38855) +++ src/common/HPM.h (revision 38857) @@ -65,6 +65,8 @@ #endif // WIN32 +struct HPMHooking_core_interface; + struct hplugin { DLL dll; unsigned int idx; @@ -126,9 +128,6 @@ /* vars */ unsigned int version[2]; bool off; - bool hooking; - /* hooking */ - bool force_return; /* data */ VECTOR_DECL(struct hplugin *) plugins; VECTOR_DECL(struct hpm_symbol *) symbols; @@ -159,7 +158,6 @@ char *(*pid2name) (unsigned int pid); unsigned char (*parse_packets) (int fd, int packet_id, enum HPluginPacketHookingPoints point); void (*load_sub) (struct hplugin *plugin); - bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); /* for custom config parsing */ bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point); bool (*getBattleConf) (const char* w1, int *value); @@ -173,6 +171,9 @@ bool (*data_store_validate) (enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize); /* for server-specific HPData e.g. map_session_data */ bool (*data_store_validate_sub) (enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize); + + /* hooking */ + struct HPMHooking_core_interface *hooking; }; CMDLINEARG(loadplugin); Index: src/common/HPMi.h =================================================================== --- src/common/HPMi.h (revision 38855) +++ src/common/HPMi.h (revision 38857) @@ -25,6 +25,7 @@ #include "common/core.h" #include "common/showmsg.h" +struct HPMHooking_interface; struct Sql; // common/sql.h struct script_state; struct AtCommandInfo; @@ -32,7 +33,7 @@ struct map_session_data; struct hplugin_data_store; -#define HPM_VERSION "1.1" +#define HPM_VERSION "1.2" #define HPM_ADDCONF_LENGTH 40 struct hplugin_info { @@ -71,11 +72,6 @@ hpPHP_MAX, }; -enum HPluginHookType { - HOOK_TYPE_PRE, - HOOK_TYPE_POST, -}; - /** * Data types for plugin custom data. */ @@ -107,13 +103,6 @@ HPCT_MAX, }; -#define addHookPre(tname,hook) (HPMi->AddHook(HOOK_TYPE_PRE,(tname),(hook),HPMi->pid)) -#define addHookPost(tname,hook) (HPMi->AddHook(HOOK_TYPE_POST,(tname),(hook),HPMi->pid)) -/* need better names ;/ */ -/* will not run the original function after pre-hook processing is complete (other hooks will run) */ -#define hookStop() (HPMi->HookStop(__func__,HPMi->pid)) -#define hookStopped() (HPMi->HookStopped()) - #define addArg(name, param,func,help) (HPMi->addArg(HPMi->pid,(name),(param),(cmdline_arg_ ## func),(help))) /* HPData handy redirects */ /* session[] */ @@ -231,10 +220,6 @@ void (*removeFromHPData) (enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid); /* packet */ bool (*addPacket) (unsigned short cmd, unsigned short length, void (*receive)(int fd), unsigned int point, unsigned int pluginID); - /* Hooking */ - bool (*AddHook) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); - void (*HookStop) (const char *func, unsigned int pID); - bool (*HookStopped) (void); /* program --arg/-a */ bool (*addArg) (unsigned int pluginID, char *name, bool has_param, CmdlineExecFunc func, const char *help); /* battle-config recv param */ @@ -243,6 +228,9 @@ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); struct Sql *sql_handle; + + /* Hooking */ + struct HPMHooking_interface *hooking; }; #ifdef HERCULES_CORE #define HPM_SYMBOL(n, s) (HPM->share((s), (n)), true) Index: src/common/Makefile.in =================================================================== --- src/common/Makefile.in (revision 38855) +++ src/common/Makefile.in (revision 38857) @@ -50,7 +50,8 @@ COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h \ grfio.h hercules.h HPM.h HPMi.h memmgr.h mapindex.h md5calc.h \ mmo.h mutex.h nullpo.h random.h showmsg.h socket.h spinlock.h \ - sql.h strlib.h sysinfo.h thread.h timer.h utils.h winapi.h + sql.h strlib.h sysinfo.h thread.h timer.h utils.h winapi.h \ + ../plugins/HPMHooking.h COMMON_PH = COMMON_SQL_OBJ = obj_sql/sql.o Index: src/common/strlib.c =================================================================== --- src/common/strlib.c (revision 38855) +++ src/common/strlib.c (revision 38857) @@ -629,7 +629,6 @@ svstate.opt = opt; svstate.delim = delim; svstate.done = false; - svstate.start = 0; // parse count = 0; Index: src/login/Makefile.in =================================================================== --- src/login/Makefile.in (revision 38855) +++ src/login/Makefile.in (revision 38857) @@ -23,7 +23,7 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) ../plugins/HPMHooking.h SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. Index: src/map/Makefile.in =================================================================== --- src/map/Makefile.in (revision 38855) +++ src/map/Makefile.in (revision 38857) @@ -23,7 +23,7 @@ CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) ../plugins/HPMHooking.h SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. Index: src/plugins/HPMHooking.c =================================================================== --- src/plugins/HPMHooking.c (revision 38855) +++ src/plugins/HPMHooking.c (revision 38857) @@ -17,6 +17,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "HPMHooking.h" + #include "common/hercules.h" #include "common/db.h" #include "common/memmgr.h" Index: src/plugins/HPMHooking.h =================================================================== --- src/plugins/HPMHooking.h (nonexistent) +++ src/plugins/HPMHooking.h (revision 38857) @@ -0,0 +1,65 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef PLUGINS_HPMHOOKING_H +#define PLUGINS_HPMHOOKING_H + +#include "common/hercules.h" + +enum HPluginHookType { + HOOK_TYPE_PRE, + HOOK_TYPE_POST, +}; + +struct HPMHooking_interface { + bool (*AddHook) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); + void (*HookStop) (const char *func, unsigned int pID); + bool (*HookStopped) (void); +}; + +#ifdef HERCULES_CORE +struct HPMHooking_core_interface { + bool enabled; + bool force_return; + bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); + const char *(*Hooked)(bool *fr); +}; +#else // ! HERCULES_CORE +HPExport struct HPMHooking_interface HPMHooking_s; + +#include "HPMHooking/HPMHooking.Defs.inc" + +#define addHookPre(ifname, funcname, hook) ( \ + (void)((HPMHOOK_pre_ ## ifname ## _ ## funcname)0 == (hook)), \ + HPMi->hooking->AddHook(HOOK_TYPE_PRE, #ifname "->" #funcname, (hook), HPMi->pid) \ + ) + +#define addHookPost(ifname, funcname, hook) ( \ + (void)((HPMHOOK_post_ ## ifname ## _ ## funcname)0 == (hook)), \ + HPMi->hooking->AddHook(HOOK_TYPE_POST, #ifname "->" #funcname, (hook), HPMi->pid) \ + ) + +/* need better names ;/ */ +/* will not run the original function after pre-hook processing is complete (other hooks will run) */ +#define hookStop() (HPMi->hooking->HookStop(__func__,HPMi->pid)) +#define hookStopped() (HPMi->hooking->HookStopped()) + +#endif // ! HERCULES_CORE + +#endif // PLUGINS_HPMHOOKING_H Index: src/plugins/HPMHooking/HPMHooking.Defs.inc =================================================================== --- src/plugins/HPMHooking/HPMHooking.Defs.inc (nonexistent) +++ src/plugins/HPMHooking/HPMHooking.Defs.inc (revision 38857) @@ -0,0 +1,24 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2013-2016 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * NOTE: This file was auto-generated and should never be manually edited, + * as it will get overwritten. + */ Index: src/plugins/Makefile.in =================================================================== --- src/plugins/Makefile.in (revision 38855) +++ src/plugins/Makefile.in (revision 38857) @@ -47,7 +47,7 @@ COMMON_D = ../common # Includes private headers (plugins might need them) -COMMON_H = $(wildcard $(COMMON_D)/*.h) +COMMON_H = $(wildcard $(COMMON_D)/*.h) ../plugins/HPMHooking.h COMMON_INCLUDE = -I.. THIRDPARTY_INCLUDE = -I../../3rdparty Index: src/plugins/sample.c =================================================================== --- src/plugins/sample.c (revision 38855) +++ src/plugins/sample.c (revision 38857) @@ -29,6 +29,7 @@ #include "map/pc.h" #include "map/script.h" +#include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" /* should always be the last Hercules file included! (if you don't make it last, it'll intentionally break compile time) */ #include <stdio.h> @@ -199,13 +200,13 @@ /* in this sample we add a PreHook to pc->dropitem */ /* to identify whether the item being dropped is on amount higher than 1 */ /* if so, it stores the amount on a variable (my_pc_dropitem_storage) and changes the amount to 1 */ - addHookPre("pc->dropitem",my_pc_dropitem_pre); + addHookPre(pc, dropitem, my_pc_dropitem_pre); /* in this sample we add a PostHook to pc->dropitem */ /* if the original pc->dropitem was successful and the amount stored on my_pc_dropitem_storage is higher than 1, */ /* our posthook will display a message to the user about the cap */ /* - by checking whether it was successful (retVal value) it allows for the originals conditions to take place */ - addHookPost("pc->dropitem",my_pc_dropitem_post); + addHookPost(pc, dropitem, my_pc_dropitem_post); } } /* triggered when server starts loading, before any server-specific data is set */ Index: tools/HPMHookGen/HPMHookGen.pl =================================================================== --- tools/HPMHookGen/HPMHookGen.pl (revision 38855) +++ tools/HPMHookGen/HPMHookGen.pl (revision 38857) @@ -460,31 +460,13 @@ } my $year = (localtime)[5] + 1900; -foreach my $servertype (keys %keys) { - my $keysref = $keys{$servertype}; - # Some interfaces use different names - my %exportsymbols = map { - $_ => &{ sub ($) { - return 'battlegrounds' if $_ =~ /^bg$/; - return 'pc_groups' if $_ =~ /^pcg$/; - return $_; - }}($_); - } @$keysref; - my ($maxlen, $idx) = (0, 0); - my $fname; - - if ($servertype eq 'all') { - $fname = "../../src/common/HPMSymbols.inc.h"; - open(FH, ">", $fname) - or die "cannot open > $fname: $!"; - - print FH <<"EOF"; +my $fileheader = <<"EOF"; /** * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2015-$year Hercules Dev Team + * Copyright (C) 2013-$year Hercules Dev Team * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -504,7 +486,29 @@ * NOTE: This file was auto-generated and should never be manually edited, * as it will get overwritten. */ +EOF +foreach my $servertype (keys %keys) { + my $keysref = $keys{$servertype}; + # Some interfaces use different names + my %exportsymbols = map { + $_ => &{ sub ($) { + return 'battlegrounds' if $_ =~ /^bg$/; + return 'pc_groups' if $_ =~ /^pcg$/; + return $_; + }}($_); + } @$keysref; + + my ($maxlen, $idx) = (0, 0); + my $fname; + + if ($servertype eq 'all') { + $fname = "../../src/common/HPMSymbols.inc.h"; + open(FH, ">", $fname) + or die "cannot open > $fname: $!"; + + print FH <<"EOF"; +$fileheader #if !defined(HERCULES_CORE) EOF @@ -538,6 +542,36 @@ } EOF close FH; + + $fname = "../../src/plugins/HPMHooking/HPMHooking.Defs.inc"; + open(FH, ">", $fname) + or die "cannot open > $fname: $!"; + + print FH <<"EOF"; +$fileheader +EOF + + foreach my $key (@$keysref) { + print FH <<"EOF"; +#ifdef $fileguards{$key}->{guard} /* $key */ +EOF + + foreach my $if (@{ $ifs{$key} }) { + my ($predef, $postdef) = ($if->{predef}, $if->{postdef}); + $predef =~ s/preHookFunc/HPMHOOK_pre_${key}_$if->{name}/; + $postdef =~ s/postHookFunc/HPMHOOK_post_${key}_$if->{name}/; + + print FH <<"EOF"; +typedef $predef +typedef $postdef +EOF + } + print FH <<"EOF"; +#endif // $fileguards{$key}->{guard} +EOF + } + close FH; + next; } @@ -546,30 +580,7 @@ or die "cannot open > $fname: $!"; print FH <<"EOF"; -/** - * This file is part of Hercules. - * - * Copyright (C) 2013-$year Hercules Dev Team - * - * Hercules is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * NOTE: This file was auto-generated and should never be manually edited, - * as it will get overwritten. - */ - +$fileheader struct HookingPointData HookingPoints[] = { EOF @@ -597,31 +608,7 @@ or die "cannot open > $fname: $!"; print FH <<"EOF"; -/** - * This file is part of Hercules. - * http://herc.ws - http://github.com/HerculesWS/Hercules - * - * Copyright (C) 2013-$year Hercules Dev Team - * - * Hercules is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * NOTE: This file was auto-generated and should never be manually edited, - * as it will get overwritten. - */ - +$fileheader EOF foreach my $key (@$keysref) { @@ -636,31 +623,7 @@ or die "cannot open > $fname: $!"; print FH <<"EOF"; -/** - * This file is part of Hercules. - * http://herc.ws - http://github.com/HerculesWS/Hercules - * - * Copyright (C) 2013-$year Hercules Dev Team - * - * Hercules is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * NOTE: This file was auto-generated and should never be manually edited, - * as it will get overwritten. - */ - +$fileheader struct { EOF @@ -711,31 +674,7 @@ or die "cannot open > $fname: $!"; print FH <<"EOF"; -/** - * This file is part of Hercules. - * http://herc.ws - http://github.com/HerculesWS/Hercules - * - * Copyright (C) 2013-$year Hercules Dev Team - * - * Hercules is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * NOTE: This file was auto-generated and should never be manually edited, - * as it will get overwritten. - */ - +$fileheader EOF foreach my $key (@$keysref) {
  4. help me about my old plugins got error when update some revision of my old files thanks
  5. this line make me having error from this //To identify disguised characters. static inline bool disguised(struct block_list* bl) { struct map_session_data* sd = BL_CAST(BL_PC, bl); if (sd == NULL || sd->disguise == -1) return false; return true; } to this //To identify disguised characters. bool clif_isdisguised(struct block_list* bl) { struct map_session_data* sd = BL_CAST(BL_PC, bl); if (sd == NULL || sd->disguise == -1) return false; return true; }
  6. what diff bro maybe i can help
  7. hello @AnnieRuru can ask how to fix this im using quite old emulator
  8. //===== Hercules Plugin ====================================== //= change equipment skin //===== By: ================================================== //= AnnieRuru //===== Current Version: ===================================== //= 1.1 //===== Compatible With: ===================================== //= Hercules 2019-03-23 //===== Description: ========================================= //= change equipment skin //===== Topic ================================================ //= http://herc.ws/board/topic/16618-change-equipment-skin/ //===== Additional Comments: ================================= //= only weapon supported, LOOK_SHIELD are fuck up ... not supported //============================================================ #include "common/hercules.h" #include "map/pc.h" #include "map/clif.h" #include "map/battle.h" #include "map/script.h" #include "common/conf.h" #include "common/memmgr.h" //#include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" struct change_weapon_skin_data { int itemid; int skinid; }; VECTOR_DECL(struct change_weapon_skin_data) weapon_skin_data; HPExport struct hplugin_info pinfo = { "change_equipment_skin", SERVER_TYPE_MAP, "1.1", HPM_VERSION, }; void clif_sendlook_pre( struct block_list **bl, int *id, int *type, int *val, int *val2, enum send_target *target ) { struct map_session_data *sd = BL_CAST(BL_PC, *bl); if ( sd != NULL ) { if ( *type == LOOK_WEAPON ) { int i = pc->checkequip( sd, script->equip[EQI_SHADOW_WEAPON -1] ); if ( i >= 0 ) { struct item_data *item = sd->inventory_data[i]; if ( item == NULL ) return; for ( i = 0; i < VECTOR_LENGTH(weapon_skin_data); i++ ) { if ( item->nameid == VECTOR_INDEX(weapon_skin_data, i).itemid ) { *val = VECTOR_INDEX(weapon_skin_data, i).skinid; break; } } } } } } void pc_unequipitem_pos_pre( struct map_session_data **sd, int *n, int *pos ) { if ( *sd == NULL ) return; if ( *pos & EQP_SHADOW_WEAPON ) { (*sd)->weapontype1 = W_FIST; pc->calcweapontype(*sd); (*sd)->status.look.weapon = 0; clif->changelook( &(*sd)->bl, LOOK_WEAPON, (*sd)->status.look.weapon ); hookStop(); } return; } int read_change_equipment_skin(void) { const char *confpath = "conf/import/change_equipment_skin.conf"; struct config_t change_equipment_skin_conf; if ( !libconfig->load_file( &change_equipment_skin_conf, confpath ) ) { ShowError( "can't read %s, file not found !\n", confpath ); return -1; } struct config_setting_t *config_db = libconfig->setting_get_member( change_equipment_skin_conf.root, "change_equipment_skin" ); if ( config_db == NULL ) { ShowError( "can't read %s\n", confpath ); libconfig->destroy( &change_equipment_skin_conf ); return -1; } struct config_setting_t *config = NULL; int itemid_ = 0, skinid_ = 0, i = 0; const char *looktype_string = NULL; VECTOR_INIT(weapon_skin_data); while (( config = libconfig->setting_get_elem( config_db, i++ ) )) { if ( !libconfig->setting_lookup_string( config, "Type", &looktype_string ) ) { ShowError( "Missing 'Type' on entry no."CL_WHITE"%d"CL_RESET" in '"CL_WHITE"%s"CL_RESET"'.\n", i, confpath ); continue; } if ( !libconfig->setting_lookup_int( config, "ItemID", &itemid_ ) ) { ShowError( "Missing 'ItemID' on entry no."CL_WHITE"%d"CL_RESET" in '"CL_WHITE"%s"CL_RESET"'.\n", i, confpath ); continue; } if ( !libconfig->setting_lookup_int( config, "SkinID", &skinid_ ) ) { ShowError( "Missing 'SkinID' on entry no."CL_WHITE"%d"CL_RESET" in '"CL_WHITE"%s"CL_RESET"'.\n", i, confpath ); continue; } if ( !strcmp( looktype_string, "LOOK_WEAPON" ) ) { struct change_weapon_skin_data weapon_data_; weapon_data_.itemid = itemid_; weapon_data_.skinid = skinid_; VECTOR_ENSURE( weapon_skin_data, 1, 1 ); VECTOR_PUSH( weapon_skin_data, weapon_data_ ); } else ShowError( "Invalid 'Type' on entry no."CL_WHITE"%d"CL_RESET" in '"CL_WHITE"%s"CL_RESET"'.\n", i, confpath ); } // ShowDebug( "%d\n", VECTOR_LENGTH(weapon_skin_data) ); // for ( i = 0; i < VECTOR_LENGTH(weapon_skin_data); i++ ) { // ShowDebug( "%d", VECTOR_INDEX(weapon_skin_data, i).itemid ); // ShowDebug( "%d\n", VECTOR_INDEX(weapon_skin_data, i).skinid ); // } libconfig->destroy( &change_equipment_skin_conf ); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", VECTOR_LENGTH(weapon_skin_data), confpath); return VECTOR_LENGTH(weapon_skin_data); } void clean_change_equipment_skin(void) { VECTOR_CLEAR(weapon_skin_data); return; } ACMD(reloadequipmentskin) { int count = 0; char msg[CHAT_SIZE_MAX] = "Done reloading '@reloadequipmentskin' with %d entries."; clean_change_equipment_skin(); count = read_change_equipment_skin(); safesnprintf( msg, CHAT_SIZE_MAX, msg, count ); clif->message( sd->fd, msg ); return true; } HPExport void plugin_init (void) { addHookPre( clif, sendlook, clif_sendlook_pre ); addHookPre( pc, unequipitem_pos, pc_unequipitem_pos_pre ); addAtcommand( "reloadequipmentskin", reloadequipmentskin ); clean_change_equipment_skin(); read_change_equipment_skin(); } HPExport void plugin_final (void) { clean_change_equipment_skin(); } here is the code help me to implement this thanks
  9. yes it is very old hahaha but im updating it little by little
  10. 1charpergm_0.2a.c: In function ‘plugin_init’: 1charpergm_0.2a.c:53:65: error: macro "addHookPre" passed 3 arguments, but takes just 2 addHookPre( chr, make_new_char_sql, char_make_new_char_sql_pre ); ^ 1charpergm_0.2a.c:53:2: error: ‘addHookPre’ undeclared (first use in this function) addHookPre( chr, make_new_char_sql, char_make_new_char_sql_pre ); ^ 1charpergm_0.2a.c:53:2: note: each undeclared identifier is reported only once for each function it appears in 1charpergm_0.2a.c:54:65: error: macro "addHookPre" passed 3 arguments, but takes just 2 addHookPre( chr, parse_char_select, char_parse_char_select_pre ); ^ 1charpergm_0.2a.c: At top level: 1charpergm_0.2a.c:31:12: warning: ‘char_make_new_char_sql_pre’ defined but not used [-Wunused-function] static int char_make_new_char_sql_pre( struct char_session_data **sd, const char **name_, int *str, int *agi, int *vit, int *int_, int *dex, int *luk, int *slot, int *hair_color, int *hair_style, int *starting_job, uint8 *sex) { ^ 1charpergm_0.2a.c:40:13: warning: ‘char_parse_char_select_pre’ defined but not used [-Wunused-function] static void char_parse_char_select_pre( int *fd, struct char_session_data **sd, uint32 *ipl ) { ^ make[1]: *** [../../plugins/1charpergm_0.2a.so] Error 1 make[1]: Leaving directory `/root/hercules/src/plugins' make: *** [plugin.1charpergm_0.2a] Error 2 //===== Hercules Plugin ====================================== //= 1charpergm //===== By: ================================================== //= AnnieRuru //===== Current Version: ===================================== //= 0.2a //===== Compatible With: ===================================== //= Hercules 2019-02-16 //===== Description: ========================================= //= make each GM account can only have 1 character slot //===== Topic ================================================ //= http://herc.ws/board/topic/11215-one-char-per-gm-account/?do=findComment&comment=90332 //===== Additional Comments: ================================= //= simple trick, only allow them to create/login the character on slot 0 //============================================================ #include "common/hercules.h" #include "char/char.h" #include "common/nullpo.h" #include "common/socket.h" //#include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" HPExport struct hplugin_info pinfo = { "1charpergm", SERVER_TYPE_CHAR, "0.2a", HPM_VERSION, }; static int char_make_new_char_sql_pre( struct char_session_data **sd, const char **name_, int *str, int *agi, int *vit, int *int_, int *dex, int *luk, int *slot, int *hair_color, int *hair_style, int *starting_job, uint8 *sex) { nullpo_retr(-2, *sd); if ( *slot != 0 && (*sd)->group_id > 10 ) { // change 10 to minimum gm level hookStop(); return -2; } return 0; } static void char_parse_char_select_pre( int *fd, struct char_session_data **sd, uint32 *ipl ) { int slot = RFIFOB(*fd, 2); if ( slot != 0 && (*sd)->group_id > 10 ) { RFIFOSKIP(*fd, 3); chr->creation_failed(*fd, -4); hookStop(); } return; } int (*make_new_char_sql) (struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style); void (*parse_char_select) (int fd, struct char_session_data* sd, uint32 ipl); HPExport void plugin_init (void) { addHookPre( chr, make_new_char_sql, char_make_new_char_sql_pre ); addHookPre( chr, parse_char_select, char_parse_char_select_pre ); } this is the plugins i used any idea how to fixed this?
  11. if you click that error it will open the file contain testvar
  12. just disable testvar and it will works fine ignore warnings
  13. i got this error,debug and warning in console and nothing happen to the npc it doesnt disguise
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.