summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/HPMHookGen/HPMDataCheckGen.pl18
-rwxr-xr-xtools/HPMHookGen/HPMHookGen.pl144
-rw-r--r--tools/HPMHookGen/doxygen.conf118
-rw-r--r--tools/Script-Checker.applescript2
-rwxr-xr-xtools/itemdbconverter.pl2
-rwxr-xr-xtools/mobdbconvall.sh6
-rwxr-xr-xtools/mobdbconverter.py282
-rwxr-xr-xtools/questdbconverter.pl2
8 files changed, 527 insertions, 47 deletions
diff --git a/tools/HPMHookGen/HPMDataCheckGen.pl b/tools/HPMHookGen/HPMDataCheckGen.pl
index 06b58127a..e658f8be8 100644
--- a/tools/HPMHookGen/HPMDataCheckGen.pl
+++ b/tools/HPMHookGen/HPMDataCheckGen.pl
@@ -26,10 +26,18 @@ foreach my $file (@files) {
next if $data->{compounddef}->{$filekey}->{compoundname}->[0] =~ /::/; # its a duplicate with a :: name e.g. struct script_state {<...>} ay;
my @filepath = split(/[\/\\]/, $data->{compounddef}->{$filekey}->{location}->[0]->{file});
my $foldername = uc($filepath[-2]);
+ next if $filepath[-1] eq "HPM.h"; # Skip the HPM core, plugins don't need it
my $filename = uc($filepath[-1]); $filename =~ s/-/_/g; $filename =~ s/\.[^.]*$//;
my $plugintypes = 'SERVER_TYPE_UNKNOWN';
- $plugintypes = 'SERVER_TYPE_ALL' if $foldername eq 'COMMON';
- $plugintypes = "SERVER_TYPE_${foldername}" if $foldername =~ /^(LOGIN|CHAR|MAP)/;
+ if ($foldername eq 'COMMON') {
+ if ($filename eq 'MAPINDEX') {
+ $plugintypes = 'SERVER_TYPE_CHAR|SERVER_TYPE_MAP';
+ } else {
+ $plugintypes = 'SERVER_TYPE_ALL';
+ }
+ } elsif ($foldername =~ /^(LOGIN|CHAR|MAP)/) {
+ $plugintypes = "SERVER_TYPE_${foldername}";
+ }
my $symboldata = {
name => $data->{compounddef}->{$filekey}->{compoundname}->[0],
type => $plugintypes,
@@ -50,6 +58,12 @@ print FH <<"EOF";
#ifndef HPM_DATA_CHECK_H
#define HPM_DATA_CHECK_H
+#if !defined(HPMHOOKGEN)
+#include "common/HPMSymbols.inc.h"
+#endif // ! HPMHOOKGEN
+#ifdef HPM_SYMBOL
+#undef HPM_SYMBOL
+#endif // HPM_SYMBOL
HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
EOF
diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl
index 4fa548e44..d1b96efb3 100755
--- a/tools/HPMHookGen/HPMHookGen.pl
+++ b/tools/HPMHookGen/HPMHookGen.pl
@@ -21,6 +21,7 @@ sub trim($) {
sub parse($$) {
my ($p, $d) = @_;
+
$p =~ s/^.*?\)\((.*)\).*$/$1/; # Clean up extra parentheses )(around the arglist)
# Retrieve return type
@@ -221,13 +222,20 @@ sub parse($$) {
$rtinit = ' = HCS_STATUS_FAIL';
} elsif ($x =~ /^enum\s+bg_queue_types$/) { # Known enum bg_queue_types
$rtinit = ' = BGQT_INVALID';
- } elsif ($x =~ /^struct\s+.*$/ or $x eq 'DBData') { # Structs
+ } elsif ($x =~ /^(?:enum\s+)?DBOptions$/) { # Known enum DBOptions
+ $rtinit = ' = DB_OPT_BASE';
+ } elsif ($x eq 'DBComparator' or $x eq 'DBHasher' or $x eq 'DBReleaser') { # DB function pointers
+ $rtinit = ' = NULL';
+ } elsif ($x =~ /^struct\s+.*$/ or $x eq 'DBData' or $x eq 'DBKey') { # Structs and unions
$rtinit = '';
$rtmemset = 1;
+ } elsif ($x =~ /^float|double$/) { # Floating point variables
+ $rtinit = ' = 0.';
} elsif ($x =~ /^(?:(?:un)?signed\s+)?(?:char|int|long|short)$/
or $x =~ /^(?:long|short)\s+(?:int|long)$/
or $x =~ /^u?int(?:8|16|32|64)$/
or $x eq 'defType'
+ or $x eq 'size_t'
) { # Numeric variables
$rtinit = ' = 0';
} else { # Anything else
@@ -256,7 +264,9 @@ my %keys = (
login => [ ],
char => [ ],
map => [ ],
+ all => [ ],
);
+my %fileguards = ( );
foreach my $file (@files) { # Loop through the xml files
my $xml = new XML::Simple;
@@ -264,34 +274,64 @@ foreach my $file (@files) { # Loop through the xml files
my $filekey = (keys %{ $data->{compounddef} })[0];
my $loc = $data->{compounddef}->{$filekey}->{location}->[0];
- next unless $loc->{file} =~ /src\/(map|char|login)\//;
+ next unless $loc->{file} =~ /src\/(map|char|login|common)\//;
+ next if $loc->{file} =~ /\/HPM.*\.h/; # Don't allow hooking into the HPM itself
my $servertype = $1;
-
my $key = $data->{compounddef}->{$filekey}->{compoundname}->[0];
my $original = $key;
+ my @servertypes = ();
+ my $servermask = 'SERVER_TYPE_NONE';
+ if ($servertype ne "common") {
+ push @servertypes, $1;
+ $servermask = 'SERVER_TYPE_' . uc($1);
+ } elsif ($key eq "mapindex_interface") {
+ push @servertypes, ("map", "char"); # Currently not used by the login server
+ $servermask = 'SERVER_TYPE_MAP|SERVER_TYPE_CHAR';
+ } else {
+ push @servertypes, ("map", "char", "login");
+ $servermask = 'SERVER_TYPE_ALL';
+ }
+ my @filepath = split(/[\/\\]/, $loc->{file});
+ my $foldername = uc($filepath[-2]);
+ my $filename = uc($filepath[-1]); $filename =~ s/-/_/g; $filename =~ s/\.[^.]*$//;
+ my $guardname = "${foldername}_${filename}_H";
# Some known interfaces with different names
if ($key =~ /battleground/) {
$key = "bg";
} elsif ($key =~ /guild_storage/) {
$key = "gstorage";
- } elsif ($key =~ /inter_homunculus/) { # to avoid replace to homun
- $key = "inter_homunculus";
- } elsif ($key =~ /homunculus/) {
+ } elsif ($key eq "homunculus_interface") {
$key = "homun";
- } elsif ($key =~ /irc_bot/) {
+ } elsif ($key eq "irc_bot_interface") {
$key = "ircbot";
- } elsif ($key =~ /log_interface/) {
+ } elsif ($key eq "log_interface") {
$key = "logs";
- } elsif ($key =~ /pc_groups_interface/) {
+ } elsif ($key eq "pc_groups_interface") {
$key = "pcg";
- } elsif ($key =~ /char_interface/) {
+ } elsif ($key eq "pcre_interface") {
+ $key = "libpcre";
+ } elsif ($key eq "char_interface") {
$key = "chr";
+ } elsif ($key eq "db_interface") {
+ $key = "DB";
+ } elsif ($key eq "malloc_interface") {
+ $key = "iMalloc";
+ } elsif ($key eq "socket_interface") {
+ $key = "sockt";
+ } elsif ($key eq "sql_interface") {
+ $key = "SQL";
+ } elsif ($key eq "stringbuf_interface") {
+ $key = "StrBuf";
+ } elsif ($key eq "console_input_interface") {
+ # TODO
+ next;
} else {
$key =~ s/_interface//;
}
- foreach my $v ($data->{compounddef}->{$filekey}->{sectiondef}->[0]) { # Loop through the sections
+ my $sectiondef = $data->{compounddef}->{$filekey}->{sectiondef};
+ foreach my $v (@$sectiondef) { # Loop through the sections
my $memberdef = $v->{memberdef};
foreach my $f (sort { # Sort the members in declaration order according to what the xml says
my $astart = $a->{location}->[0]->{bodystart} || $a->{location}->[0]->{line};
@@ -380,7 +420,14 @@ foreach my $file (@files) { # Loop through the xml files
push(@{ $ifs{$key} }, $if);
}
}
- push(@{ $keys{$servertype} }, $key) if $key2original{$key};
+ foreach $servertype (@servertypes) {
+ push(@{ $keys{$servertype} }, $key) if $key2original{$key};
+ }
+ push(@{ $keys{all} }, $key) if $key2original{$key};
+ $fileguards{$key} = {
+ guard => $guardname,
+ type => $servermask,
+ };
}
foreach my $servertype (keys %keys) {
@@ -388,14 +435,61 @@ foreach my $servertype (keys %keys) {
# Some interfaces use different names
my %exportsymbols = map {
$_ => &{ sub ($) {
- return 'battlegrounds' if $servertype eq 'map' and $_ =~ /^bg$/;
- return 'pc_groups' if $servertype eq 'map' and $_ =~ /^pcg$/;
+ 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";
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+//
+// NOTE: This file was auto-generated and should never be manually edited,
+// as it will get overwritten.
+
+#if !defined(HERCULES_CORE)
+EOF
+
+ foreach my $key (@$keysref) {
+ print FH <<"EOF";
+#ifdef $fileguards{$key}->{guard} /* $key */
+struct $key2original{$key} *$key;
+#endif // $fileguards{$key}->{guard}
+EOF
+ }
+
+ print FH <<"EOF";
+#endif // ! HERCULES_CORE
+
+HPExport const char *HPM_shared_symbols(int server_type)
+{
+EOF
+
+ foreach my $key (@$keysref) {
+ print FH <<"EOF";
+#ifdef $fileguards{$key}->{guard} /* $key */
+if ((server_type&($fileguards{$key}->{type})) && !HPM_SYMBOL("$exportsymbols{$key}", $key)) return "$exportsymbols{$key}";
+#endif // $fileguards{$key}->{guard}
+EOF
+ }
+
+ print FH <<"EOF";
+ return NULL;
+}
+EOF
+ close FH;
+ next;
+ }
+
$fname = "../../src/plugins/HPMHooking/HPMHooking_${servertype}.HookingPoints.inc";
open(FH, ">", $fname)
or die "cannot open > $fname: $!";
@@ -419,7 +513,7 @@ EOF
EOF
$idx += 2;
- $maxlen = length($key."->".$if->{name}) if( length($key."->".$if->{name}) > $maxlen )
+ $maxlen = length($key."->".$if->{name}) if( length($key."->".$if->{name}) > $maxlen );
}
}
print FH <<"EOF";
@@ -449,26 +543,6 @@ EOF
}
close FH;
- $fname = "../../src/plugins/HPMHooking/HPMHooking_${servertype}.GetSymbol.inc";
- open(FH, ">", $fname)
- or die "cannot open > $fname: $!";
-
- print FH <<"EOF";
-// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
-// See the LICENSE file
-//
-// NOTE: This file was auto-generated and should never be manually edited,
-// as it will get overwritten.
-
-EOF
- foreach my $key (@$keysref) {
-
- print FH <<"EOF";
-if( !($key = GET_SYMBOL("$exportsymbols{$key}") ) ) return false;
-EOF
- }
- close FH;
-
$fname = "../../src/plugins/HPMHooking/HPMHooking_${servertype}.HPMHooksCore.inc";
open(FH, ">", $fname)
or die "cannot open > $fname: $!";
diff --git a/tools/HPMHookGen/doxygen.conf b/tools/HPMHookGen/doxygen.conf
index b6dc7444b..380a3d8de 100644
--- a/tools/HPMHookGen/doxygen.conf
+++ b/tools/HPMHookGen/doxygen.conf
@@ -1,10 +1,16 @@
-# Doxyfile 1.8.4
+# Doxyfile 1.8.10
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "Hercules HPMHookGen"
PROJECT_NUMBER =
+PROJECT_BRIEF =
+PROJECT_LOGO =
OUTPUT_DIRECTORY = doxyoutput
CREATE_SUBDIRS = NO
+ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = NO
REPEAT_BRIEF = NO
@@ -22,20 +28,31 @@ INHERIT_DOCS = NO
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
+TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING = h=C
+MARKDOWN_SUPPORT = YES
+AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
+GROUP_NESTED_COMPOUNDS = NO
SUBGROUPING = NO
+INLINE_GROUPED_CLASSES = NO
+INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = NO
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = NO
+LOOKUP_CACHE_SIZE = 0
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
+EXTRACT_PACKAGE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
@@ -47,7 +64,9 @@ HIDE_IN_BODY_DOCS = YES
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
+HIDE_COMPOUND_REFERENCE= NO
SHOW_INCLUDE_FILES = NO
+SHOW_GROUPED_MEMB_INC = NO
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
@@ -55,6 +74,7 @@ SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
+STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
@@ -66,6 +86,10 @@ SHOW_FILES = NO
SHOW_NAMESPACES = NO
FILE_VERSION_FILTER =
LAYOUT_FILE =
+CITE_BIB_FILES =
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
@@ -73,9 +97,16 @@ WARN_IF_DOC_ERROR = NO
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
-INPUT = ../../src/map ../../src/common ../../src/char ../../src/login
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = ../../src/map \
+ ../../src/common \
+ ../../src/char \
+ ../../src/login
INPUT_ENCODING = UTF-8
-FILE_PATTERNS = *.c *.h
+FILE_PATTERNS = *.c \
+ *.h
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
@@ -88,28 +119,43 @@ IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
+FILTER_SOURCE_PATTERNS =
+USE_MDFILE_AS_MAINPAGE =
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = NO
+SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
GENERATE_HTML = NO
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
+HTML_EXTRA_STYLESHEET =
+HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = YES
HTML_DYNAMIC_SECTIONS = NO
+HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
@@ -139,8 +185,21 @@ TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
+USE_MATHJAX = NO
+MATHJAX_FORMAT = HTML-CSS
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+MATHJAX_EXTENSIONS =
+MATHJAX_CODEFILE =
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
+EXTERNAL_SEARCH = NO
+SEARCHENGINE_URL =
+SEARCHDATA_FILE = searchdata.xml
+EXTERNAL_SEARCH_ID =
+EXTRA_SEARCH_MAPPINGS =
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
@@ -149,45 +208,84 @@ COMPACT_LATEX = NO
PAPER_TYPE = a4
EXTRA_PACKAGES =
LATEX_HEADER =
+LATEX_FOOTER =
+LATEX_EXTRA_STYLESHEET =
+LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
LATEX_SOURCE_CODE = NO
+LATEX_BIB_STYLE = plain
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
+RTF_SOURCE_CODE = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
+MAN_SUBDIR =
MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
GENERATE_XML = YES
XML_OUTPUT = xml
XML_PROGRAMLISTING = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+GENERATE_DOCBOOK = NO
+DOCBOOK_OUTPUT = docbook
+DOCBOOK_PROGRAMLISTING = NO
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
-INCLUDE_PATH =
+INCLUDE_PATH = ../../src
INCLUDE_FILE_PATTERNS =
-PREDEFINED =
+PREDEFINED = __attribute__(x)= \
+ HPMHOOKGEN
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = NO
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = NO
+EXTERNAL_PAGES = YES
PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
MSCGEN_PATH =
+DIA_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
DOT_NUM_THREADS = 0
@@ -198,6 +296,7 @@ CLASS_GRAPH = NO
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = NO
UML_LOOK = NO
+UML_LIMIT_NUM_FIELDS = 10
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
@@ -206,8 +305,13 @@ CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DIRECTORY_GRAPH = NO
DOT_IMAGE_FORMAT = png
+INTERACTIVE_SVG = NO
DOT_PATH =
DOTFILE_DIRS =
+MSCFILE_DIRS =
+DIAFILE_DIRS =
+PLANTUML_JAR_PATH =
+PLANTUML_INCLUDE_PATH =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
diff --git a/tools/Script-Checker.applescript b/tools/Script-Checker.applescript
index db1983f4b..eb4e7629a 100644
--- a/tools/Script-Checker.applescript
+++ b/tools/Script-Checker.applescript
@@ -1,7 +1,7 @@
(*
Copyright (c) Hercules Dev Team, licensed under GNU GPL.
See the LICENSE file
- Base Author: Haru @ http://hercules.ws
+ Base Author: Haru @ http://herc.ws
*)
(*
diff --git a/tools/itemdbconverter.pl b/tools/itemdbconverter.pl
index 13805c09e..9486308a6 100755
--- a/tools/itemdbconverter.pl
+++ b/tools/itemdbconverter.pl
@@ -2,7 +2,7 @@
#
# Copyright (c) Hercules Dev Team, licensed under GNU GPL.
# See the LICENSE file
-# Base Author: Haru @ http://hercules.ws
+# Base Author: Haru @ http://herc.ws
#
# This script converts an item_db(2).txt to the new item_db(2).conf format.
# usage example: perl tools/itemdbconverter.pl < db/item_db2.txt > db/item_db2.conf
diff --git a/tools/mobdbconvall.sh b/tools/mobdbconvall.sh
new file mode 100755
index 000000000..15dcd898a
--- /dev/null
+++ b/tools/mobdbconvall.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+./mobdbconverter.py re .. ../db/re/mob_db.txt > ../db/re/mob_db.conf
+./mobdbconverter.py re .. ../db/mob_db2.txt > ../db/mob_db2.conf
+./mobdbconverter.py pre-re .. ../db/pre-re/mob_db.txt > ../db/pre-re/mob_db.conf
+#./mobdbconverter.py pre-re .. ../db/mob_db2.txt > ../db/mob_db2.conf
diff --git a/tools/mobdbconverter.py b/tools/mobdbconverter.py
new file mode 100755
index 000000000..e1c642981
--- /dev/null
+++ b/tools/mobdbconverter.py
@@ -0,0 +1,282 @@
+#! /usr/bin/env python
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2015 Andrei Karas (4144)
+
+# This Script converts mob_db.txt to mob_db.conf format
+
+import os
+import re
+import sys
+
+comaSplit = re.compile(",")
+
+def printHeader():
+ print("""mob_db: (
+// Mobs Database
+//
+/******************************************************************************
+ ************* Entry structure ************************************************
+ ******************************************************************************
+{
+ // =================== Mandatory fields ===============================
+ Id: ID (int)
+ SpriteName: "SPRITE_NAME" (string)
+ Name: "Mob name" (string)
+ // =================== Optional fields ================================
+ Lv: level (int, defaults to 1)
+ Hp: health (int, defaults to 1)
+ Sp: mana (int, defaults to 0)
+ Exp: basic experience (int, defaults to 0)
+ JExp: job experience (int, defaults to 0)
+ AttackRange: attack range (int, defaults to 1)
+ Attack: [attack1, attack2] (int, defaults to 0)
+ Def: defence (int, defaults to 0)
+ Mdef: magic defence (int, defaults to 0)
+ Stats: {
+ Str: strength (int, defaults to 0)
+ Agi: agility (int, defaults to 0)
+ Vit: vitality (int, defaults to 0)
+ Int: intelligence (int, defaults to 0)
+ Dex: dexterity (int, defaults to 0)
+ Luk: luck (int, defaults to 0)
+ }
+ ViewRange: view range (int, defaults to 1)
+ ChaseRange: chase range (int, defaults to 1)
+ Size: size (int, defaults to 1)
+ Race: race (int, defaults to 0)
+ Element: (type, level)
+ Mode: {
+ CanMove: true/false (bool)
+ Looter: true/false (bool)
+ Aggressive: true/false (bool)
+ Assist: true/false (bool)
+ CastSensorIdle:true/false (bool)
+ Boss: true/false (bool)
+ Plant: true/false (bool)
+ CanAttack: true/false (bool)
+ Detector: true/false (bool)
+ CastSensorChase: true/false (bool)
+ ChangeChase: true/false (bool)
+ Angry: true/false (bool)
+ ChangeTargetMelee: true/false (bool)
+ ChangeTargetChase: true/false (bool)
+ TargetWeak: true/false (bool)
+ }
+ MoveSpeed: move speed (int, defaults to 0)
+ AttackDelay: attack delay (int, defaults to 4000)
+ AttackMotion: attack motion (int, defaults to 2000)
+ DamageMotion: damage motion (int, defaults to 0)
+ MvpExp: mvp experience (int, defaults to 0)
+ MvpDrops: {
+ AegisName: chance (string: int)
+ ...
+ }
+ Drops: {
+ AegisName: chance (string: int)
+ ...
+ }
+
+},
+******************************************************************************/
+
+""")
+
+def printFooter():
+ print(")")
+
+def printField(name, value):
+ print("\t{0}: {1}".format(name, value))
+
+def printField2(name, value):
+ print("\t\t{0}: {1}".format(name, value))
+
+def printFieldCond2(cond, name):
+ if cond != 0:
+ print("\t\t{0}: true".format(name))
+
+def printFieldArr(name, value, value2):
+ print("\t{0}: [{1}, {2}]".format(name, value, value2))
+
+def printFieldStr(name, value):
+ print("\t{0}: \"{1}\"".format(name, value))
+
+def startGroup(name):
+ print("\t{0}: {{".format(name))
+
+def endGroup():
+ print("\t}")
+
+def printHelp():
+ print("MobDB converter from txt to conf format")
+ print("Usage:")
+ print(" mobdbconverter.py re serverpath dbfilepath")
+ print(" mobdbconverter.py pre-re serverpath dbfilepath")
+ print("Usage for read from stdin:")
+ print(" mobdbconverter.py re dbfilepath")
+
+def isHaveData(fields, start, cnt):
+ for f in range(0, cnt):
+ value = fields[start + f * 2]
+ chance = fields[start + f * 2]
+ if value == "" or value == "0" or chance == "" or chance == "0":
+ continue
+ return True
+ return False
+
+def convertFile(inFile, itemDb):
+ if inFile != "" and not os.path.exists(inFile):
+ return
+
+ if inFile == "":
+ r = sys.stdin
+ else:
+ r = open(inFile, "r")
+
+ printHeader()
+ for line in r:
+ if line.strip() == "":
+ continue
+ if len(line) < 5 or line[:2] == "//":
+ print(line)
+ continue
+ fields = comaSplit.split(line)
+ if len(fields) != 57:
+ print(line)
+ continue
+ for f in range(0, len(fields)):
+ fields[f] = fields[f].strip()
+ print("{")
+ printField("Id", fields[0])
+ printFieldStr("SpriteName", fields[1])
+ printFieldStr("Name", fields[2])
+ printField("Lv", fields[4])
+ printField("Hp", fields[5])
+ printField("Sp", fields[6])
+ printField("Exp", fields[7])
+ printField("JExp", fields[8])
+ printField("AttackRange", fields[9])
+ printFieldArr("Attack", fields[10], fields[11])
+ printField("Def", fields[12])
+ printField("Mdef", fields[13])
+ startGroup("Stats")
+ printField2("Str", fields[14])
+ printField2("Agi", fields[15])
+ printField2("Vit", fields[16])
+ printField2("Int", fields[17])
+ printField2("Dex", fields[18])
+ printField2("Luk", fields[19])
+ endGroup()
+ printField("ViewRange", fields[20])
+ printField("ChaseRange", fields[21])
+ printField("Size", fields[22])
+ printField("Race", fields[23])
+ print("\tElement: ({0}, {1})".format(int(fields[24]) % 10, int(fields[24]) / 20));
+ mode = int(fields[25], 0)
+ if mode != 0:
+ startGroup("Mode")
+ printFieldCond2(mode & 0x0001, "CanMove")
+ printFieldCond2(mode & 0x0002, "Looter")
+ printFieldCond2(mode & 0x0004, "Aggressive")
+ printFieldCond2(mode & 0x0008, "Assist")
+ printFieldCond2(mode & 0x0010, "CastSensorIdle")
+ printFieldCond2(mode & 0x0020, "Boss")
+ printFieldCond2(mode & 0x0040, "Plant")
+ printFieldCond2(mode & 0x0080, "CanAttack")
+ printFieldCond2(mode & 0x0100, "Detector")
+ printFieldCond2(mode & 0x0200, "CastSensorChase")
+ printFieldCond2(mode & 0x0400, "ChangeChase")
+ printFieldCond2(mode & 0x0800, "Angry")
+ printFieldCond2(mode & 0x1000, "ChangeTargetMelee")
+ printFieldCond2(mode & 0x2000, "ChangeTargetChase")
+ printFieldCond2(mode & 0x4000, "TargetWeak")
+ printFieldCond2(mode & 0x8000, "LiveWithoutMaster")
+ endGroup()
+ printField("MoveSpeed", fields[26])
+ printField("AttackDelay", fields[27])
+ printField("AttackMotion", fields[28])
+ printField("DamageMotion", fields[29])
+ printField("MvpExp", fields[30])
+ if isHaveData(fields, 31, 3):
+ startGroup("MvpDrops")
+ for f in range(0, 3):
+ value = fields[31 + f * 2]
+ chance = fields[32 + f * 2]
+ if value == "" or value == "0" or chance == "" or chance == "0":
+ continue
+ value = int(value)
+ if value not in itemDb:
+ print("// Error: mvp drop with id {0} not found in item_db.conf".format(value))
+ else:
+ printField2(itemDb[value], chance)
+ endGroup()
+ if isHaveData(fields, 37, 10):
+ startGroup("Drops")
+ for f in range(0, 10):
+ value = fields[37 + f * 2]
+ chance = fields[38 + f * 2]
+ if value == "" or value == "0" or chance == "" or chance == "0":
+ continue
+ value = int(value)
+ if value not in itemDb:
+ print("// Error: drop with id {0} not found in item_db.conf".format(value))
+ else:
+ printField2(itemDb[value], chance)
+ endGroup()
+ print("},")
+ printFooter()
+ if inFile != "":
+ r.close()
+
+def readItemDB(inFile, itemDb):
+ itemId = 0
+ itemName = ""
+ started = False
+ with open(inFile, "r") as r:
+ for line in r:
+ line = line.strip()
+ if started == True:
+ if line == "},":
+ started = False
+ elif line[:10] == "AegisName:":
+ itemName = line[12:-1]
+ elif line[:3] == "Id:":
+ try:
+ itemId = int(line[4:])
+ except:
+ started = False
+ if itemId != 0 and itemName != "":
+# was need for remove wrong characters
+# itemName = itemName.replace(".", "")
+# if itemName[0] >= "0" and itemName[0] <= "9":
+# itemName = "Num" + itemName
+ itemDb[itemId] = itemName
+ started = False
+ else:
+ if line == "{":
+ started = True
+ itemId = 0
+ itemName = ""
+ return itemDb
+
+if len(sys.argv) != 4 and len(sys.argv) != 3:
+ printHelp();
+ exit(1)
+startPath = sys.argv[2]
+if len(sys.argv) == 4:
+ sourceFile = sys.argv[3]
+else:
+ sourceFile = "";
+
+itemDb = dict()
+if sys.argv[1] == "re":
+ itemDb = readItemDB(startPath + "/db/re/item_db.conf", itemDb)
+ itemDb = readItemDB(startPath + "/db/item_db2.conf", itemDb)
+elif sys.argv[1] == "pre-re":
+ itemDb = readItemDB(startPath + "/db/pre-re/item_db.conf", itemDb)
+ itemDb = readItemDB(startPath + "/db/item_db2.conf", itemDb)
+else:
+ printHelp();
+ exit(1)
+
+convertFile(sourceFile, itemDb)
diff --git a/tools/questdbconverter.pl b/tools/questdbconverter.pl
index 00431fb79..49e7b76bf 100755
--- a/tools/questdbconverter.pl
+++ b/tools/questdbconverter.pl
@@ -2,7 +2,7 @@
#
# Copyright (c) Hercules Dev Team, licensed under GNU GPL.
# See the LICENSE file
-# Base Author: Dastgir @ http://hercules.ws
+# Base Author: Dastgir @ http://herc.ws
#
# This Script converts quest_db.txt to quest_db.conf format.
# usage example: perl tools/questdbconverter.pl < db/quest_db.txt > db/quest_db.conf