summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check-doc28
-rwxr-xr-xtools/item_db.pl116
-rw-r--r--tools/mapreg-converter.php38
-rwxr-xr-xtools/mob_db.pl150
-rwxr-xr-xtools/stackdump62
5 files changed, 394 insertions, 0 deletions
diff --git a/tools/check-doc b/tools/check-doc
new file mode 100755
index 000000000..4a5dccc88
--- /dev/null
+++ b/tools/check-doc
@@ -0,0 +1,28 @@
+#!/bin/sh
+# checking-doc script by trojal
+# modified by lighta
+
+case $1 in
+ 'script')
+ #find which script commands are missing from doc/script_commands.txt
+ echo "Missing script documentation for function :"
+ awk '/BUILDIN_DEF\(.*\),/ {b=match($0,"BUILDIN_DEF(.*),");c=match($0,",");print substr($0,b+12,c-b-12);}' ../src/map/script.c | xargs -I{} sh -c '! grep -Lq {} ../doc/script_commands.txt && echo {}'
+ awk '/BUILDIN_DEF2\(.*\),/ {b=match($0,"BUILDIN_DEF2(.*),");c=match($0,",");d=match($0 ,"\",\"");print substr($0,c+2,d-c-2);}' ../src/map/script.c | xargs -I{} sh -c '! grep -Lq {} ../doc/script_commands.txt && echo {}'
+ ;;
+
+ 'atc')
+ #find which atcommands are missing from doc/atcommands.txt
+ echo "Missing atcommand documentation for function :"
+ awk '/ACMD_DEF\(.*\),/ {b=match($0,"ACMD_DEF(.*),");c=match($0,",");print substr($0,b+9,c-b-10);}' ../src/map/atcommand.c | xargs -I{} sh -c '! grep -Lq {} ../doc/atcommands.txt && echo {}'
+ awk '/ACMD_DEF2\(.*\),/ {b=match($0,"ACMD_DEF2(.*),");c=match($0,",");print substr($0,b+10,c-b-10);}' ../src/map/atcommand.c | xargs -I{} sh -c '! grep -Lq {} ../doc/atcommands.txt && echo {}'
+ ;;
+ 'both')
+ $0 script
+ $0 atc
+ ;;
+
+ *)
+ echo "Usage: check-doc { script | atc | both }"
+ ;;
+esac
+
diff --git a/tools/item_db.pl b/tools/item_db.pl
new file mode 100755
index 000000000..a2b443de9
--- /dev/null
+++ b/tools/item_db.pl
@@ -0,0 +1,116 @@
+#!/usr/bin/perl
+$db = "item_db";
+$nb_columns = 22;
+@str_col = (1,2,7,19,20,21);
+$line_format = "([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),([^\,]*),(\{.*\}),(\{.*\}),(\{.*\})";
+#$line_format = ;
+$create_table = "#
+# Table structure for table `item_db`
+#
+
+DROP TABLE IF EXISTS `item_db`;
+CREATE TABLE `item_db` (
+ `id` smallint(5) unsigned NOT NULL default '0',
+ `name_english` varchar(50) NOT NULL default '',
+ `name_japanese` varchar(50) NOT NULL default '',
+ `type` tinyint(2) unsigned NOT NULL default '0',
+ `price_buy` mediumint(10) unsigned default NULL,
+ `price_sell` mediumint(10) unsigned default NULL,
+ `weight` smallint(5) unsigned NOT NULL default '0',
+ `attack` smallint(3) unsigned default NULL,
+ `defence` tinyint(3) unsigned default NULL,
+ `range` tinyint(2) unsigned default NULL,
+ `slots` tinyint(2) unsigned default NULL,
+ `equip_jobs` int(12) unsigned default NULL,
+ `equip_upper` tinyint(8) unsigned default NULL,
+ `equip_genders` tinyint(2) unsigned default NULL,
+ `equip_locations` smallint(4) unsigned default NULL,
+ `weapon_level` tinyint(2) unsigned default NULL,
+ `equip_level` tinyint(3) unsigned default NULL,
+ `refineable` tinyint(1) unsigned default NULL,
+ `view` smallint(3) unsigned default NULL,
+ `script` text,
+ `equip_script` text,
+ `unequip_script` text,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM;
+";
+printf("%s\n",$create_table);
+while ($ligne=<STDIN>)
+{
+ if ($ligne =~ /[^\r\n]+/)
+ {
+ $ligne = $&;
+ if ($ligne =~ /^\/\//)
+ {
+ printf("# ");
+ $ligne = substr($ligne, 2);
+ }
+ if ($ligne =~ $line_format) {
+ @champ = ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22);
+ } else {
+ @champ = ();
+ }
+ if ($#champ != $nb_columns - 1)
+ {
+ # Can't parse, it's a real comment
+ printf ("%s\n", $ligne);
+ } else {
+ printf("REPLACE INTO `%s` VALUES (", $db);
+ for ($i=0; $i<$#champ; $i++)
+ {
+ printField($champ[$i],",",$i);
+ }
+ printField($champ[$#champ],");\n",$#champ);
+ }
+ }
+}
+print("\n");
+
+
+sub printField {
+ my ($str, $suffix, $idCol) = @_;
+ # Remove first { and last }
+ if ($str =~ /{.*}/)
+ {
+ $str = substr($&,1,-1);
+ }
+ # If nothing, put NULL
+ if ($str eq "") {
+ printf("NULL%s", $suffix);
+ } else {
+ my $flag = 0;
+ # Search if it's a string column ?
+ foreach $col (@str_col)
+ {
+ if ($col == $idCol)
+ {
+ $flag = 1;
+ break;
+ }
+ }
+ if ($flag == 1)
+ {
+ # String column, so escape and add ''
+ printf("'%s'%s", escape($str), $suffix);
+ } else {
+ # Not a string column
+ printf("%s%s", $str,$suffix);
+ }
+ }
+}
+
+sub escape {
+ my ($str) = @_;
+ my @str_splitted = split("'", $str);
+ my $result = "";
+ for (my $i=0; $i<=$#str_splitted; $i++)
+ {
+ if ($i == 0) {
+ $result = @str_splitted[0];
+ } else {
+ $result = $result."\\'".@str_splitted[$i];
+ }
+ }
+ return $result
+}
diff --git a/tools/mapreg-converter.php b/tools/mapreg-converter.php
new file mode 100644
index 000000000..3d548554a
--- /dev/null
+++ b/tools/mapreg-converter.php
@@ -0,0 +1,38 @@
+<?php
+ // mapreg.txt -> sql import file converter
+ // author : theultramage / Yommy
+ // version: 16. august 2008
+?>
+<?php
+ fwrite(STDERR, "mapreg txt->sql converter".PHP_EOL);
+ fwrite(STDERR, "-------------------------".PHP_EOL);
+ if( @$_SERVER["argc"] < 2 )
+ {
+ fwrite(STDERR, "Usage: {$_SERVER["argv"][0]} [file]".PHP_EOL);
+ exit();
+ }
+
+ $input = @$_SERVER["argv"][1];
+ $data = file($input);
+ if( $data === FALSE )
+ die("Invalid input file '".$input."'!");
+
+ if( function_exists("mysql_escape_string") === FALSE )
+ die("Please enable the php_mysql extension first!");
+
+ fwrite(STDERR, "Converting {$input}...".PHP_EOL);
+ define("EOL", PHP_EOL);
+
+ foreach( $data as $line )
+ {
+ if( preg_match('/(.*),(\d+)\t(.*)/m', $line, $regs) )
+ fwrite(STDOUT, "INSERT INTO `mapreg` (`varname`,`index`,`value`) VALUES ('".mysql_escape_string($regs[1])."',".mysql_escape_string($regs[2]).",'".mysql_escape_string(rtrim($regs[3]))."');".EOL);
+ else
+ if( preg_match('/(.*)\t(.*)/m', $line, $regs) )
+ fprintf(STDOUT, "INSERT INTO `mapreg` (`varname`,`index`,`value`) VALUES ('".mysql_escape_string($regs[1])."',0,'".mysql_escape_string(rtrim($regs[2]))."');".EOL);
+ else
+ fprintf(STDERR, "Invalid data: ".$line.PHP_EOL);
+ }
+
+ fprintf(STDERR, "done.".PHP_EOL);
+?> \ No newline at end of file
diff --git a/tools/mob_db.pl b/tools/mob_db.pl
new file mode 100755
index 000000000..3872153fa
--- /dev/null
+++ b/tools/mob_db.pl
@@ -0,0 +1,150 @@
+#!/usr/bin/perl
+$db = "mob_db";
+$nb_columns = 57;
+@str_col = (1,2,3);
+$create_table = "#
+# Table structure for table `mob_db`
+#
+
+DROP TABLE IF EXISTS `mob_db`;
+CREATE TABLE `mob_db` (
+ `ID` mediumint(9) unsigned NOT NULL default '0',
+ `Sprite` text NOT NULL,
+ `kName` text NOT NULL,
+ `iName` text NOT NULL,
+ `LV` tinyint(6) unsigned NOT NULL default '0',
+ `HP` int(9) unsigned NOT NULL default '0',
+ `SP` mediumint(9) unsigned NOT NULL default '0',
+ `EXP` mediumint(9) unsigned NOT NULL default '0',
+ `JEXP` mediumint(9) unsigned NOT NULL default '0',
+ `Range1` tinyint(4) unsigned NOT NULL default '0',
+ `ATK1` smallint(6) unsigned NOT NULL default '0',
+ `ATK2` smallint(6) unsigned NOT NULL default '0',
+ `DEF` smallint(6) unsigned NOT NULL default '0',
+ `MDEF` smallint(6) unsigned NOT NULL default '0',
+ `STR` smallint(6) unsigned NOT NULL default '0',
+ `AGI` smallint(6) unsigned NOT NULL default '0',
+ `VIT` smallint(6) unsigned NOT NULL default '0',
+ `INT` smallint(6) unsigned NOT NULL default '0',
+ `DEX` smallint(6) unsigned NOT NULL default '0',
+ `LUK` smallint(6) unsigned NOT NULL default '0',
+ `Range2` tinyint(4) unsigned NOT NULL default '0',
+ `Range3` tinyint(4) unsigned NOT NULL default '0',
+ `Scale` tinyint(4) unsigned NOT NULL default '0',
+ `Race` tinyint(4) unsigned NOT NULL default '0',
+ `Element` tinyint(4) unsigned NOT NULL default '0',
+ `Mode` smallint(6) unsigned NOT NULL default '0',
+ `Speed` smallint(6) unsigned NOT NULL default '0',
+ `aDelay` smallint(6) unsigned NOT NULL default '0',
+ `aMotion` smallint(6) unsigned NOT NULL default '0',
+ `dMotion` smallint(6) unsigned NOT NULL default '0',
+ `MEXP` mediumint(9) unsigned NOT NULL default '0',
+ `MVP1id` smallint(9) unsigned NOT NULL default '0',
+ `MVP1per` smallint(9) unsigned NOT NULL default '0',
+ `MVP2id` smallint(9) unsigned NOT NULL default '0',
+ `MVP2per` smallint(9) unsigned NOT NULL default '0',
+ `MVP3id` smallint(9) unsigned NOT NULL default '0',
+ `MVP3per` smallint(9) unsigned NOT NULL default '0',
+ `Drop1id` smallint(9) unsigned NOT NULL default '0',
+ `Drop1per` smallint(9) unsigned NOT NULL default '0',
+ `Drop2id` smallint(9) unsigned NOT NULL default '0',
+ `Drop2per` smallint(9) unsigned NOT NULL default '0',
+ `Drop3id` smallint(9) unsigned NOT NULL default '0',
+ `Drop3per` smallint(9) unsigned NOT NULL default '0',
+ `Drop4id` smallint(9) unsigned NOT NULL default '0',
+ `Drop4per` smallint(9) unsigned NOT NULL default '0',
+ `Drop5id` smallint(9) unsigned NOT NULL default '0',
+ `Drop5per` smallint(9) unsigned NOT NULL default '0',
+ `Drop6id` smallint(9) unsigned NOT NULL default '0',
+ `Drop6per` smallint(9) unsigned NOT NULL default '0',
+ `Drop7id` smallint(9) unsigned NOT NULL default '0',
+ `Drop7per` smallint(9) unsigned NOT NULL default '0',
+ `Drop8id` smallint(9) unsigned NOT NULL default '0',
+ `Drop8per` smallint(9) unsigned NOT NULL default '0',
+ `Drop9id` smallint(9) unsigned NOT NULL default '0',
+ `Drop9per` smallint(9) unsigned NOT NULL default '0',
+ `DropCardid` smallint(9) unsigned NOT NULL default '0',
+ `DropCardper` smallint(9) unsigned NOT NULL default '0',
+ PRIMARY KEY (`ID`)
+) ENGINE=MyISAM;
+";
+printf("%s\n",$create_table);
+while ($ligne=<STDIN>)
+{
+ if ($ligne =~ /[^\r\n]+/)
+ {
+ $ligne = $&;
+ if ($ligne =~ /^\/\//)
+ {
+ printf("# ");
+ $ligne = substr($ligne, 2);
+ }
+ @champ = split (",",$ligne);
+ if ($#champ != $nb_columns - 1)
+ {
+ # Can't parse, it's a real comment
+ printf ("%s\n", $ligne);
+ } else {
+ printf("REPLACE INTO `%s` VALUES (", $db);
+ for ($i=0; $i<$#champ; $i++)
+ {
+ printField($champ[$i],",",$i);
+ }
+ printField($champ[$#champ],");\n",$#champ);
+ }
+ }
+}
+print("\n");
+
+
+sub printField {
+ my ($str, $suffix, $idCol) = @_;
+ # Remove first { and last }
+ if ($str =~ /{.*}/)
+ {
+ $str = substr($&,1,-1);
+ }
+ # Remove comment at end of line
+ if ($str =~ /[^\/]*\/\//)
+ {
+ $str = substr($&,0,-2);
+ }
+ # If nothing, put NULL
+ if ($str eq "") {
+ printf("NULL%s", $suffix);
+ } else {
+ my $flag = 0;
+ # Search if it's a string column ?
+ foreach $col (@str_col)
+ {
+ if ($col == $idCol)
+ {
+ $flag = 1;
+ break;
+ }
+ }
+ if ($flag == 1)
+ {
+ # String column, so escape and add ''
+ printf("'%s'%s", escape($str), $suffix);
+ } else {
+ # Not a string column
+ printf("%s%s", $str,$suffix);
+ }
+ }
+}
+
+sub escape {
+ my ($str) = @_;
+ my @str_splitted = split("'", $str);
+ my $result = "";
+ for (my $i=0; $i<=$#str_splitted; $i++)
+ {
+ if ($i == 0) {
+ $result = @str_splitted[0];
+ } else {
+ $result = $result."\\'".@str_splitted[$i];
+ }
+ }
+ return $result
+}
diff --git a/tools/stackdump b/tools/stackdump
new file mode 100755
index 000000000..25b1fa46a
--- /dev/null
+++ b/tools/stackdump
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+case "$1" in
+ map|char|login)
+ # Check for SQL postfix
+ if [ "$2" = "sql" ]; then
+ SERVER="$1-server_sql"
+ else
+ SERVER="$1-server"
+ fi
+ ;;
+
+ *|""|help)
+ echo "Usage 1: ${0##*/} [server-type] [txt/sql]"
+ echo Server type can be map, login, or char. Examples:
+ echo "$ ./${0##*/} map"
+ echo "$ ./${0##*/} login sql"
+ echo
+ echo "Usage 2: ${0##*/} [server-type] [txt/sql] [number]"
+ echo Server type can be map, login, or char. Examples:
+ echo "$ ./${0##*/} map txt 0001"
+ echo "$ ./${0##*/} login sql 0002"
+ echo
+ echo Note: Dump files inside /log will also be scanned.
+ exit
+ ;;
+esac
+
+# Check if server file needs .exe (Windows/Cygwin)
+if [ -e $SERVER.exe ]; then
+ SERVER="$SERVER.exe"
+elif [ ! -e $SERVER ]; then
+ echo Error: $SERVER not found!
+ exit
+fi
+
+# Assemble stackdump filename
+if [ $# -gt 2 ]; then
+ STACK="$SERVER$3.stackdump"
+else
+ STACK="$SERVER.stackdump"
+fi
+
+# Check if file exists.
+# Try looking under '/log' if it isn't
+
+if [ ! -e $STACK ]; then
+ if [ -e log/$STACK ]; then
+ STACK=log/$STACK
+ else
+ echo Error: $STACK not found!
+ exit
+ fi
+fi
+
+# Finally dump the backtrace
+# If number is given, Sig-plugin format. otherwise, standard stackdump format
+if [ $# -gt 2 ]; then
+ awk '$2 ~ /[0-9a-eA-E]\]$/{print $2}' $STACK | tr -d \[\] | addr2line -f -e $SERVER
+else
+ awk '/^[0-9]/{print $2}' $STACK | addr2line -f -e $SERVER
+fi