summaryrefslogtreecommitdiff
path: root/tools/HPMHookGen/HPMHookGen.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/HPMHookGen/HPMHookGen.pl')
-rwxr-xr-xtools/HPMHookGen/HPMHookGen.pl177
1 files changed, 58 insertions, 119 deletions
diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl
index 0e33fd002..4dedb48c2 100755
--- a/tools/HPMHookGen/HPMHookGen.pl
+++ b/tools/HPMHookGen/HPMHookGen.pl
@@ -460,31 +460,13 @@ foreach my $file (@files) { # Loop through the xml files
}
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 @@ foreach my $servertype (keys %keys) {
* 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
}
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 @@ EOF
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 @@ EOF
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 @@ EOF
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 @@ EOF
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) {