diff --git a/trunk/.settings/org.eclipse.jdt.core.prefs b/trunk/.settings/org.eclipse.jdt.core.prefs
index de0a433b36..7b961756cb 100644
--- a/trunk/.settings/org.eclipse.jdt.core.prefs
+++ b/trunk/.settings/org.eclipse.jdt.core.prefs
@@ -15,17 +15,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
@@ -34,7 +25,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
@@ -121,7 +111,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/trunk/build.xml b/trunk/build.xml
index 1e0f85ec08..c5cedd0f52 100644
--- a/trunk/build.xml
+++ b/trunk/build.xml
@@ -28,7 +28,7 @@
-
+
@@ -110,6 +110,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/dist/db_installer/images/help.png b/trunk/dist/db_installer/images/help.png
new file mode 100644
index 0000000000..5c870176d4
Binary files /dev/null and b/trunk/dist/db_installer/images/help.png differ
diff --git a/trunk/dist/db_installer/images/l2j.png b/trunk/dist/db_installer/images/l2j.png
new file mode 100644
index 0000000000..28d252208b
Binary files /dev/null and b/trunk/dist/db_installer/images/l2j.png differ
diff --git a/trunk/dist/tools/sql/game/account_gsdata.sql b/trunk/dist/db_installer/sql/game/account_gsdata.sql
similarity index 83%
rename from trunk/dist/tools/sql/game/account_gsdata.sql
rename to trunk/dist/db_installer/sql/game/account_gsdata.sql
index a5b1895e7a..f1feb947f5 100644
--- a/trunk/dist/tools/sql/game/account_gsdata.sql
+++ b/trunk/dist/db_installer/sql/game/account_gsdata.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `account_gsdata`;
CREATE TABLE IF NOT EXISTS `account_gsdata` (
`account_name` VARCHAR(45) NOT NULL DEFAULT '',
`var` VARCHAR(255) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/account_premium.sql b/trunk/dist/db_installer/sql/game/account_premium.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/account_premium.sql
rename to trunk/dist/db_installer/sql/game/account_premium.sql
diff --git a/trunk/dist/tools/sql/game/airships.sql b/trunk/dist/db_installer/sql/game/airships.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/airships.sql
rename to trunk/dist/db_installer/sql/game/airships.sql
index 44d7d54284..f52d650a54 100644
--- a/trunk/dist/tools/sql/game/airships.sql
+++ b/trunk/dist/db_installer/sql/game/airships.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `airships`;
CREATE TABLE IF NOT EXISTS `airships` (
`owner_id` INT, -- object id of the player or clan, owner of this airship
`fuel` decimal(5,0) NOT NULL DEFAULT 600,
diff --git a/trunk/dist/tools/sql/game/announcements.sql b/trunk/dist/db_installer/sql/game/announcements.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/announcements.sql
rename to trunk/dist/db_installer/sql/game/announcements.sql
index f87fd4772a..abbd92b886 100644
--- a/trunk/dist/tools/sql/game/announcements.sql
+++ b/trunk/dist/db_installer/sql/game/announcements.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `announcements`;
CREATE TABLE IF NOT EXISTS `announcements` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL,
diff --git a/trunk/dist/tools/sql/classic/auction.sql b/trunk/dist/db_installer/sql/game/auction.sql
similarity index 93%
rename from trunk/dist/tools/sql/classic/auction.sql
rename to trunk/dist/db_installer/sql/game/auction.sql
index 0b6c2751d2..cb1a05ab68 100644
--- a/trunk/dist/tools/sql/classic/auction.sql
+++ b/trunk/dist/db_installer/sql/game/auction.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `auction`;
CREATE TABLE IF NOT EXISTS `auction` (
`id` int(11) NOT NULL DEFAULT '0',
`sellerId` int(11) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/auction_bid.sql b/trunk/dist/db_installer/sql/game/auction_bid.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/auction_bid.sql
rename to trunk/dist/db_installer/sql/game/auction_bid.sql
index 828a1a9ba4..c084d3e3af 100644
--- a/trunk/dist/tools/sql/game/auction_bid.sql
+++ b/trunk/dist/db_installer/sql/game/auction_bid.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `auction_bid`;
CREATE TABLE IF NOT EXISTS `auction_bid` (
`id` INT NOT NULL DEFAULT 0,
`auctionId` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/auction_watch.sql b/trunk/dist/db_installer/sql/game/auction_watch.sql
similarity index 82%
rename from trunk/dist/tools/sql/game/auction_watch.sql
rename to trunk/dist/db_installer/sql/game/auction_watch.sql
index 57619ccaf3..fce297db3c 100644
--- a/trunk/dist/tools/sql/game/auction_watch.sql
+++ b/trunk/dist/db_installer/sql/game/auction_watch.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `auction_watch`;
CREATE TABLE IF NOT EXISTS `auction_watch` (
`charObjId` INT NOT NULL DEFAULT 0,
`auctionId` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/bbs_favorite.sql b/trunk/dist/db_installer/sql/game/bbs_favorite.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/bbs_favorite.sql
rename to trunk/dist/db_installer/sql/game/bbs_favorite.sql
index ac3e587a2d..8e6fe0d258 100644
--- a/trunk/dist/tools/sql/game/bbs_favorite.sql
+++ b/trunk/dist/db_installer/sql/game/bbs_favorite.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `bbs_favorites`;
CREATE TABLE IF NOT EXISTS `bbs_favorites` (
`favId` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`playerId` INT UNSIGNED NOT NULL,
diff --git a/trunk/dist/tools/sql/game/bot_reported_char_data.sql b/trunk/dist/db_installer/sql/game/bot_reported_char_data.sql
similarity index 83%
rename from trunk/dist/tools/sql/game/bot_reported_char_data.sql
rename to trunk/dist/db_installer/sql/game/bot_reported_char_data.sql
index f6db4d65cc..8632e578ec 100644
--- a/trunk/dist/tools/sql/game/bot_reported_char_data.sql
+++ b/trunk/dist/db_installer/sql/game/bot_reported_char_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `bot_reported_char_data`;
CREATE TABLE IF NOT EXISTS `bot_reported_char_data` (
`botId` INT UNSIGNED NOT NULL DEFAULT 0,
`reporterId` INT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/buylists.sql b/trunk/dist/db_installer/sql/game/buylists.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/buylists.sql
rename to trunk/dist/db_installer/sql/game/buylists.sql
index af679454ca..b95ce7278a 100644
--- a/trunk/dist/tools/sql/game/buylists.sql
+++ b/trunk/dist/db_installer/sql/game/buylists.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `buylists`;
CREATE TABLE IF NOT EXISTS `buylists` (
`buylist_id` INT UNSIGNED,
`item_id` INT UNSIGNED,
diff --git a/trunk/dist/tools/sql/game/castle.sql b/trunk/dist/db_installer/sql/game/castle.sql
similarity index 94%
rename from trunk/dist/tools/sql/game/castle.sql
rename to trunk/dist/db_installer/sql/game/castle.sql
index 755d660e00..2389565b6c 100644
--- a/trunk/dist/tools/sql/game/castle.sql
+++ b/trunk/dist/db_installer/sql/game/castle.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle`;
CREATE TABLE IF NOT EXISTS `castle` (
`id` INT NOT NULL DEFAULT 0,
`name` varchar(25) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/castle_doorupgrade.sql b/trunk/dist/db_installer/sql/game/castle_doorupgrade.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/castle_doorupgrade.sql
rename to trunk/dist/db_installer/sql/game/castle_doorupgrade.sql
index 0c3dd7feeb..282ac7a260 100644
--- a/trunk/dist/tools/sql/game/castle_doorupgrade.sql
+++ b/trunk/dist/db_installer/sql/game/castle_doorupgrade.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle_doorupgrade`;
CREATE TABLE IF NOT EXISTS `castle_doorupgrade` (
`doorId` int(8) unsigned NOT NULL DEFAULT '0',
`ratio` tinyint(3) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/castle_functions.sql b/trunk/dist/db_installer/sql/game/castle_functions.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/castle_functions.sql
rename to trunk/dist/db_installer/sql/game/castle_functions.sql
index 9d2e56eb18..99f38f78bc 100644
--- a/trunk/dist/tools/sql/game/castle_functions.sql
+++ b/trunk/dist/db_installer/sql/game/castle_functions.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle_functions`;
CREATE TABLE IF NOT EXISTS `castle_functions` (
`castle_id` int(2) NOT NULL DEFAULT '0',
`type` int(1) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/castle_manor_procure.sql b/trunk/dist/db_installer/sql/game/castle_manor_procure.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/castle_manor_procure.sql
rename to trunk/dist/db_installer/sql/game/castle_manor_procure.sql
index f158bf03a5..506aac1c9f 100644
--- a/trunk/dist/tools/sql/game/castle_manor_procure.sql
+++ b/trunk/dist/db_installer/sql/game/castle_manor_procure.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle_manor_procure`;
CREATE TABLE IF NOT EXISTS `castle_manor_procure` (
`castle_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`crop_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/castle_manor_production.sql b/trunk/dist/db_installer/sql/game/castle_manor_production.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/castle_manor_production.sql
rename to trunk/dist/db_installer/sql/game/castle_manor_production.sql
index 7ccdbf827c..0235dee668 100644
--- a/trunk/dist/tools/sql/game/castle_manor_production.sql
+++ b/trunk/dist/db_installer/sql/game/castle_manor_production.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle_manor_production`;
CREATE TABLE IF NOT EXISTS `castle_manor_production` (
`castle_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`seed_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/castle_siege_guards.sql b/trunk/dist/db_installer/sql/game/castle_siege_guards.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/castle_siege_guards.sql
rename to trunk/dist/db_installer/sql/game/castle_siege_guards.sql
diff --git a/trunk/dist/tools/sql/game/castle_trapupgrade.sql b/trunk/dist/db_installer/sql/game/castle_trapupgrade.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/castle_trapupgrade.sql
rename to trunk/dist/db_installer/sql/game/castle_trapupgrade.sql
index 9ae87a50c9..9724333a61 100644
--- a/trunk/dist/tools/sql/game/castle_trapupgrade.sql
+++ b/trunk/dist/db_installer/sql/game/castle_trapupgrade.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle_trapupgrade`;
CREATE TABLE IF NOT EXISTS `castle_trapupgrade` (
`castleId` tinyint(3) unsigned NOT NULL DEFAULT '0',
`towerIndex` tinyint(3) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/character_contacts.sql b/trunk/dist/db_installer/sql/game/character_contacts.sql
similarity index 81%
rename from trunk/dist/tools/sql/game/character_contacts.sql
rename to trunk/dist/db_installer/sql/game/character_contacts.sql
index a03a989924..d29d284c07 100644
--- a/trunk/dist/tools/sql/game/character_contacts.sql
+++ b/trunk/dist/db_installer/sql/game/character_contacts.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_contacts`;
CREATE TABLE IF NOT EXISTS `character_contacts` (
charId INT UNSIGNED NOT NULL DEFAULT 0,
contactId INT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_friends.sql b/trunk/dist/db_installer/sql/game/character_friends.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/character_friends.sql
rename to trunk/dist/db_installer/sql/game/character_friends.sql
index d79f6bc720..40e33838e7 100644
--- a/trunk/dist/tools/sql/game/character_friends.sql
+++ b/trunk/dist/db_installer/sql/game/character_friends.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_friends`;
CREATE TABLE IF NOT EXISTS `character_friends` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`friendId` INT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_hennas.sql b/trunk/dist/db_installer/sql/game/character_hennas.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/character_hennas.sql
rename to trunk/dist/db_installer/sql/game/character_hennas.sql
index 71babee3e7..0a2ccc9297 100644
--- a/trunk/dist/tools/sql/game/character_hennas.sql
+++ b/trunk/dist/db_installer/sql/game/character_hennas.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_hennas`;
CREATE TABLE IF NOT EXISTS `character_hennas` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`symbol_id` INT,
diff --git a/trunk/dist/tools/sql/game/character_instance_time.sql b/trunk/dist/db_installer/sql/game/character_instance_time.sql
similarity index 83%
rename from trunk/dist/tools/sql/game/character_instance_time.sql
rename to trunk/dist/db_installer/sql/game/character_instance_time.sql
index 85a10e27d2..fffd5672bc 100644
--- a/trunk/dist/tools/sql/game/character_instance_time.sql
+++ b/trunk/dist/db_installer/sql/game/character_instance_time.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_instance_time`;
CREATE TABLE IF NOT EXISTS `character_instance_time` (
`charId` INT UNSIGNED NOT NULL DEFAULT '0',
`instanceId` int(3) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/character_item_reuse_save.sql b/trunk/dist/db_installer/sql/game/character_item_reuse_save.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/character_item_reuse_save.sql
rename to trunk/dist/db_installer/sql/game/character_item_reuse_save.sql
index eae3364bb9..2a2afb4dd0 100644
--- a/trunk/dist/tools/sql/game/character_item_reuse_save.sql
+++ b/trunk/dist/db_installer/sql/game/character_item_reuse_save.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_item_reuse_save`;
CREATE TABLE IF NOT EXISTS `character_item_reuse_save` (
`charId` INT NOT NULL DEFAULT 0,
`itemId` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_macroses.sql b/trunk/dist/db_installer/sql/game/character_macroses.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/character_macroses.sql
rename to trunk/dist/db_installer/sql/game/character_macroses.sql
index 0dd982ecfa..ad9c508e72 100644
--- a/trunk/dist/tools/sql/game/character_macroses.sql
+++ b/trunk/dist/db_installer/sql/game/character_macroses.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_macroses`;
CREATE TABLE IF NOT EXISTS `character_macroses` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`id` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_mentees.sql b/trunk/dist/db_installer/sql/game/character_mentees.sql
similarity index 76%
rename from trunk/dist/tools/sql/game/character_mentees.sql
rename to trunk/dist/db_installer/sql/game/character_mentees.sql
index ad94c0984a..8bb93f27a3 100644
--- a/trunk/dist/tools/sql/game/character_mentees.sql
+++ b/trunk/dist/db_installer/sql/game/character_mentees.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_mentees`;
CREATE TABLE IF NOT EXISTS `character_mentees` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`mentorId` int(10) unsigned NOT NULL DEFAULT '0'
diff --git a/trunk/dist/tools/sql/game/character_offline_trade.sql b/trunk/dist/db_installer/sql/game/character_offline_trade.sql
similarity index 83%
rename from trunk/dist/tools/sql/game/character_offline_trade.sql
rename to trunk/dist/db_installer/sql/game/character_offline_trade.sql
index 35ac445a98..4f40b27c23 100644
--- a/trunk/dist/tools/sql/game/character_offline_trade.sql
+++ b/trunk/dist/db_installer/sql/game/character_offline_trade.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_offline_trade`;
CREATE TABLE IF NOT EXISTS `character_offline_trade` (
`charId` int(10) unsigned NOT NULL,
`time` bigint(13) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/character_offline_trade_items.sql b/trunk/dist/db_installer/sql/game/character_offline_trade_items.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/character_offline_trade_items.sql
rename to trunk/dist/db_installer/sql/game/character_offline_trade_items.sql
index c25e3ebb99..4ffc434d56 100644
--- a/trunk/dist/tools/sql/game/character_offline_trade_items.sql
+++ b/trunk/dist/db_installer/sql/game/character_offline_trade_items.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_offline_trade_items`;
CREATE TABLE IF NOT EXISTS `character_offline_trade_items` (
`charId` int(10) unsigned NOT NULL,
`item` int(10) unsigned NOT NULL DEFAULT '0', -- itemId(for buy) & ObjectId(for sell)
diff --git a/trunk/dist/tools/sql/game/character_pet_skills_save.sql b/trunk/dist/db_installer/sql/game/character_pet_skills_save.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/character_pet_skills_save.sql
rename to trunk/dist/db_installer/sql/game/character_pet_skills_save.sql
index fe0e74836f..e88b3a61c3 100644
--- a/trunk/dist/tools/sql/game/character_pet_skills_save.sql
+++ b/trunk/dist/db_installer/sql/game/character_pet_skills_save.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_pet_skills_save`;
CREATE TABLE IF NOT EXISTS `character_pet_skills_save` (
`petObjItemId` INT NOT NULL DEFAULT 0,
`skill_id` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_premium_items.sql b/trunk/dist/db_installer/sql/game/character_premium_items.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/character_premium_items.sql
rename to trunk/dist/db_installer/sql/game/character_premium_items.sql
index 10871c4355..de92ffc0c5 100644
--- a/trunk/dist/tools/sql/game/character_premium_items.sql
+++ b/trunk/dist/db_installer/sql/game/character_premium_items.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_premium_items`;
CREATE TABLE IF NOT EXISTS `character_premium_items` (
`charId` int(11) NOT NULL,
`itemNum` int(11) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/character_quest_global_data.sql b/trunk/dist/db_installer/sql/game/character_quest_global_data.sql
similarity index 80%
rename from trunk/dist/tools/sql/game/character_quest_global_data.sql
rename to trunk/dist/db_installer/sql/game/character_quest_global_data.sql
index e5f42c5970..54db700b4d 100644
--- a/trunk/dist/tools/sql/game/character_quest_global_data.sql
+++ b/trunk/dist/db_installer/sql/game/character_quest_global_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_quest_global_data`;
CREATE TABLE IF NOT EXISTS `character_quest_global_data` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`var` VARCHAR(20) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/character_quests.sql b/trunk/dist/db_installer/sql/game/character_quests.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/character_quests.sql
rename to trunk/dist/db_installer/sql/game/character_quests.sql
index a6425cb284..19dc8ebae2 100644
--- a/trunk/dist/tools/sql/game/character_quests.sql
+++ b/trunk/dist/db_installer/sql/game/character_quests.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_quests`;
CREATE TABLE IF NOT EXISTS `character_quests` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`name` VARCHAR(60) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/character_recipebook.sql b/trunk/dist/db_installer/sql/game/character_recipebook.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/character_recipebook.sql
rename to trunk/dist/db_installer/sql/game/character_recipebook.sql
index f1cbac43d5..391441d601 100644
--- a/trunk/dist/tools/sql/game/character_recipebook.sql
+++ b/trunk/dist/db_installer/sql/game/character_recipebook.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_recipebook`;
CREATE TABLE IF NOT EXISTS `character_recipebook` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`id` decimal(11) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_recipeshoplist.sql b/trunk/dist/db_installer/sql/game/character_recipeshoplist.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/character_recipeshoplist.sql
rename to trunk/dist/db_installer/sql/game/character_recipeshoplist.sql
index ca911240a1..f578195e5f 100644
--- a/trunk/dist/tools/sql/game/character_recipeshoplist.sql
+++ b/trunk/dist/db_installer/sql/game/character_recipeshoplist.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_recipeshoplist`;
CREATE TABLE IF NOT EXISTS `character_recipeshoplist` (
`charId` int(10) unsigned NOT NULL DEFAULT 0,
`recipeId` int(11) UNSIGNED NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_reco_bonus.sql b/trunk/dist/db_installer/sql/game/character_reco_bonus.sql
similarity index 86%
rename from trunk/dist/tools/sql/game/character_reco_bonus.sql
rename to trunk/dist/db_installer/sql/game/character_reco_bonus.sql
index 6ab766918e..58e5b8b1c0 100644
--- a/trunk/dist/tools/sql/game/character_reco_bonus.sql
+++ b/trunk/dist/db_installer/sql/game/character_reco_bonus.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_reco_bonus`;
CREATE TABLE IF NOT EXISTS `character_reco_bonus` (
`charId` int(10) unsigned NOT NULL,
`rec_have` tinyint(3) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/character_shortcuts.sql b/trunk/dist/db_installer/sql/game/character_shortcuts.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/character_shortcuts.sql
rename to trunk/dist/db_installer/sql/game/character_shortcuts.sql
index e42b2e4bd6..4200257284 100644
--- a/trunk/dist/tools/sql/game/character_shortcuts.sql
+++ b/trunk/dist/db_installer/sql/game/character_shortcuts.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_shortcuts`;
CREATE TABLE IF NOT EXISTS `character_shortcuts` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`slot` decimal(3) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_skills.sql b/trunk/dist/db_installer/sql/game/character_skills.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/character_skills.sql
rename to trunk/dist/db_installer/sql/game/character_skills.sql
index c7532d9971..c7a74baa51 100644
--- a/trunk/dist/tools/sql/game/character_skills.sql
+++ b/trunk/dist/db_installer/sql/game/character_skills.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_skills`;
CREATE TABLE IF NOT EXISTS `character_skills` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`skill_id` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_skills_save.sql b/trunk/dist/db_installer/sql/game/character_skills_save.sql
similarity index 92%
rename from trunk/dist/tools/sql/game/character_skills_save.sql
rename to trunk/dist/db_installer/sql/game/character_skills_save.sql
index 7b1692ecf7..8fa3eb3879 100644
--- a/trunk/dist/tools/sql/game/character_skills_save.sql
+++ b/trunk/dist/db_installer/sql/game/character_skills_save.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_skills_save`;
CREATE TABLE IF NOT EXISTS `character_skills_save` (
`charId` INT NOT NULL DEFAULT 0,
`skill_id` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_subclasses.sql b/trunk/dist/db_installer/sql/game/character_subclasses.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/character_subclasses.sql
rename to trunk/dist/db_installer/sql/game/character_subclasses.sql
index ea34bfbd73..4d01414226 100644
--- a/trunk/dist/tools/sql/game/character_subclasses.sql
+++ b/trunk/dist/db_installer/sql/game/character_subclasses.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_subclasses`;
CREATE TABLE IF NOT EXISTS `character_subclasses` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`class_id` int(2) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_summon_skills_save.sql b/trunk/dist/db_installer/sql/game/character_summon_skills_save.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/character_summon_skills_save.sql
rename to trunk/dist/db_installer/sql/game/character_summon_skills_save.sql
index 715957428c..a08932a5da 100644
--- a/trunk/dist/tools/sql/game/character_summon_skills_save.sql
+++ b/trunk/dist/db_installer/sql/game/character_summon_skills_save.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_summon_skills_save`;
CREATE TABLE IF NOT EXISTS `character_summon_skills_save` (
`ownerId` INT NOT NULL DEFAULT 0,
`ownerClassIndex` INT(1) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/character_summons.sql b/trunk/dist/db_installer/sql/game/character_summons.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/character_summons.sql
rename to trunk/dist/db_installer/sql/game/character_summons.sql
index 1f0b693009..2d6ef32e0d 100644
--- a/trunk/dist/tools/sql/game/character_summons.sql
+++ b/trunk/dist/db_installer/sql/game/character_summons.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_summons`;
CREATE TABLE IF NOT EXISTS `character_summons` (
`ownerId` int(10) unsigned NOT NULL,
`summonId` int(10) unsigned NOT NULL,
diff --git a/trunk/dist/tools/sql/game/character_tpbookmark.sql b/trunk/dist/db_installer/sql/game/character_tpbookmark.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/character_tpbookmark.sql
rename to trunk/dist/db_installer/sql/game/character_tpbookmark.sql
index 51dd922dcd..fe691ea5ef 100644
--- a/trunk/dist/tools/sql/game/character_tpbookmark.sql
+++ b/trunk/dist/db_installer/sql/game/character_tpbookmark.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_tpbookmark`;
CREATE TABLE IF NOT EXISTS `character_tpbookmark` (
`charId` int(20) NOT NULL,
`Id` int(20) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/character_ui_actions.sql b/trunk/dist/db_installer/sql/game/character_ui_actions.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/character_ui_actions.sql
rename to trunk/dist/db_installer/sql/game/character_ui_actions.sql
index d1e2205f29..454499ba97 100644
--- a/trunk/dist/tools/sql/game/character_ui_actions.sql
+++ b/trunk/dist/db_installer/sql/game/character_ui_actions.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_ui_actions`;
CREATE TABLE IF NOT EXISTS `character_ui_actions` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`cat` tinyint(4) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/character_ui_categories.sql b/trunk/dist/db_installer/sql/game/character_ui_categories.sql
similarity index 83%
rename from trunk/dist/tools/sql/game/character_ui_categories.sql
rename to trunk/dist/db_installer/sql/game/character_ui_categories.sql
index 86a2368a21..87e28d9b03 100644
--- a/trunk/dist/tools/sql/game/character_ui_categories.sql
+++ b/trunk/dist/db_installer/sql/game/character_ui_categories.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_ui_categories`;
CREATE TABLE IF NOT EXISTS `character_ui_categories` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`catId` tinyint(4) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/character_variables.sql b/trunk/dist/db_installer/sql/game/character_variables.sql
similarity index 78%
rename from trunk/dist/tools/sql/game/character_variables.sql
rename to trunk/dist/db_installer/sql/game/character_variables.sql
index a112b3d34f..40603ac06b 100644
--- a/trunk/dist/tools/sql/game/character_variables.sql
+++ b/trunk/dist/db_installer/sql/game/character_variables.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `character_variables`;
CREATE TABLE IF NOT EXISTS `character_variables` (
`charId` int(10) UNSIGNED NOT NULL,
`var` varchar(255) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/characters.sql b/trunk/dist/db_installer/sql/game/characters.sql
similarity index 96%
rename from trunk/dist/tools/sql/game/characters.sql
rename to trunk/dist/db_installer/sql/game/characters.sql
index ba889fdfc3..b0e5629fdd 100644
--- a/trunk/dist/tools/sql/game/characters.sql
+++ b/trunk/dist/db_installer/sql/game/characters.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `characters`;
CREATE TABLE IF NOT EXISTS `characters` (
`account_name` VARCHAR(45) DEFAULT NULL,
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/clan_data.sql b/trunk/dist/db_installer/sql/game/clan_data.sql
similarity index 94%
rename from trunk/dist/tools/sql/game/clan_data.sql
rename to trunk/dist/db_installer/sql/game/clan_data.sql
index 46d79ee1ae..fabffaa056 100644
--- a/trunk/dist/tools/sql/game/clan_data.sql
+++ b/trunk/dist/db_installer/sql/game/clan_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clan_data`;
CREATE TABLE IF NOT EXISTS `clan_data` (
`clan_id` INT NOT NULL DEFAULT 0,
`clan_name` varchar(45) ,
diff --git a/trunk/dist/tools/sql/game/clan_notices.sql b/trunk/dist/db_installer/sql/game/clan_notices.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/clan_notices.sql
rename to trunk/dist/db_installer/sql/game/clan_notices.sql
index 83cd47fdd3..0b5cfecf6c 100644
--- a/trunk/dist/tools/sql/game/clan_notices.sql
+++ b/trunk/dist/db_installer/sql/game/clan_notices.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clan_notices`;
CREATE TABLE IF NOT EXISTS `clan_notices` (
`clan_id` INT NOT NULL DEFAULT 0,
`enabled` enum('true','false') DEFAULT 'false' NOT NULL,
diff --git a/trunk/dist/tools/sql/game/clan_privs.sql b/trunk/dist/db_installer/sql/game/clan_privs.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/clan_privs.sql
rename to trunk/dist/db_installer/sql/game/clan_privs.sql
index 8904833cd4..0c21cb33e8 100644
--- a/trunk/dist/tools/sql/game/clan_privs.sql
+++ b/trunk/dist/db_installer/sql/game/clan_privs.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clan_privs`;
CREATE TABLE IF NOT EXISTS `clan_privs` (
`clan_id` INT NOT NULL DEFAULT 0,
`rank` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/clan_skills.sql b/trunk/dist/db_installer/sql/game/clan_skills.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/clan_skills.sql
rename to trunk/dist/db_installer/sql/game/clan_skills.sql
index 6652823b59..c17980216e 100644
--- a/trunk/dist/tools/sql/game/clan_skills.sql
+++ b/trunk/dist/db_installer/sql/game/clan_skills.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clan_skills`;
CREATE TABLE IF NOT EXISTS `clan_skills` (
`clan_id` int(11) NOT NULL DEFAULT 0,
`skill_id` int(11) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/clan_subpledges.sql b/trunk/dist/db_installer/sql/game/clan_subpledges.sql
similarity index 86%
rename from trunk/dist/tools/sql/game/clan_subpledges.sql
rename to trunk/dist/db_installer/sql/game/clan_subpledges.sql
index 8af49cc45f..90b017e627 100644
--- a/trunk/dist/tools/sql/game/clan_subpledges.sql
+++ b/trunk/dist/db_installer/sql/game/clan_subpledges.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clan_subpledges`;
CREATE TABLE IF NOT EXISTS `clan_subpledges` (
`clan_id` INT NOT NULL DEFAULT '0',
`sub_pledge_id` INT NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/clan_wars.sql b/trunk/dist/db_installer/sql/game/clan_wars.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/clan_wars.sql
rename to trunk/dist/db_installer/sql/game/clan_wars.sql
index 62cc814101..d3acd91109 100644
--- a/trunk/dist/tools/sql/game/clan_wars.sql
+++ b/trunk/dist/db_installer/sql/game/clan_wars.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clan_wars`;
CREATE TABLE IF NOT EXISTS `clan_wars` (
`clan1` varchar(35) NOT NULL DEFAULT '',
`clan2` varchar(35) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/clanentry.sql b/trunk/dist/db_installer/sql/game/clanentry.sql
similarity index 86%
rename from trunk/dist/tools/sql/game/clanentry.sql
rename to trunk/dist/db_installer/sql/game/clanentry.sql
index 803b25fa5c..ec86a23b79 100644
--- a/trunk/dist/tools/sql/game/clanentry.sql
+++ b/trunk/dist/db_installer/sql/game/clanentry.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `pledge_applicant`;
CREATE TABLE IF NOT EXISTS `pledge_applicant` (
`charId` int(10) NOT NULL,
`clanId` int(10) NOT NULL,
@@ -6,6 +7,7 @@ CREATE TABLE IF NOT EXISTS `pledge_applicant` (
PRIMARY KEY (`charId`,`clanId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+DROP TABLE IF EXISTS `pledge_recruit`;
CREATE TABLE IF NOT EXISTS `pledge_recruit` (
`clan_id` int(10) NOT NULL,
`karma` tinyint(1) NOT NULL,
@@ -14,6 +16,7 @@ CREATE TABLE IF NOT EXISTS `pledge_recruit` (
PRIMARY KEY (`clan_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+DROP TABLE IF EXISTS `pledge_waiting_list`;
CREATE TABLE IF NOT EXISTS `pledge_waiting_list` (
`char_id` int(10) NOT NULL,
`karma` tinyint(1) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/clanhall.sql b/trunk/dist/db_installer/sql/game/clanhall.sql
similarity index 98%
rename from trunk/dist/tools/sql/game/clanhall.sql
rename to trunk/dist/db_installer/sql/game/clanhall.sql
index a3b640d8ec..1d9624195a 100644
--- a/trunk/dist/tools/sql/game/clanhall.sql
+++ b/trunk/dist/db_installer/sql/game/clanhall.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clanhall`;
CREATE TABLE IF NOT EXISTS `clanhall` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(40) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/clanhall_functions.sql b/trunk/dist/db_installer/sql/game/clanhall_functions.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/clanhall_functions.sql
rename to trunk/dist/db_installer/sql/game/clanhall_functions.sql
index ea33f9734a..e6ef2558b8 100644
--- a/trunk/dist/tools/sql/game/clanhall_functions.sql
+++ b/trunk/dist/db_installer/sql/game/clanhall_functions.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clanhall_functions`;
CREATE TABLE IF NOT EXISTS `clanhall_functions` (
`hall_id` int(2) NOT NULL DEFAULT '0',
`type` int(1) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/clanhall_siege_attackers.sql b/trunk/dist/db_installer/sql/game/clanhall_siege_attackers.sql
similarity index 77%
rename from trunk/dist/tools/sql/game/clanhall_siege_attackers.sql
rename to trunk/dist/db_installer/sql/game/clanhall_siege_attackers.sql
index 1c601f0ded..e10faf0217 100644
--- a/trunk/dist/tools/sql/game/clanhall_siege_attackers.sql
+++ b/trunk/dist/db_installer/sql/game/clanhall_siege_attackers.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clanhall_siege_attackers`;
CREATE TABLE IF NOT EXISTS `clanhall_siege_attackers` (
`clanhall_id` int(3) NOT NULL DEFAULT '0',
`attacker_id` int(10) NOT NULL DEFAULT '0'
diff --git a/trunk/dist/tools/sql/game/clanhall_siege_guards.sql b/trunk/dist/db_installer/sql/game/clanhall_siege_guards.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/clanhall_siege_guards.sql
rename to trunk/dist/db_installer/sql/game/clanhall_siege_guards.sql
diff --git a/trunk/dist/tools/sql/game/auction.sql b/trunk/dist/db_installer/sql/game/classic/auction.sql
similarity index 93%
rename from trunk/dist/tools/sql/game/auction.sql
rename to trunk/dist/db_installer/sql/game/classic/auction.sql
index 0b6c2751d2..cb1a05ab68 100644
--- a/trunk/dist/tools/sql/game/auction.sql
+++ b/trunk/dist/db_installer/sql/game/classic/auction.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `auction`;
CREATE TABLE IF NOT EXISTS `auction` (
`id` int(11) NOT NULL DEFAULT '0',
`sellerId` int(11) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/classic/castle.sql b/trunk/dist/db_installer/sql/game/classic/castle.sql
similarity index 95%
rename from trunk/dist/tools/sql/classic/castle.sql
rename to trunk/dist/db_installer/sql/game/classic/castle.sql
index a39c403b4f..d0a51537a9 100644
--- a/trunk/dist/tools/sql/classic/castle.sql
+++ b/trunk/dist/db_installer/sql/game/classic/castle.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `castle`;
CREATE TABLE IF NOT EXISTS `castle` (
`id` INT NOT NULL DEFAULT 0,
`name` varchar(25) NOT NULL,
diff --git a/trunk/dist/tools/sql/classic/clanhall.sql b/trunk/dist/db_installer/sql/game/classic/clanhall.sql
similarity index 98%
rename from trunk/dist/tools/sql/classic/clanhall.sql
rename to trunk/dist/db_installer/sql/game/classic/clanhall.sql
index 7b9dd11119..065779a109 100644
--- a/trunk/dist/tools/sql/classic/clanhall.sql
+++ b/trunk/dist/db_installer/sql/game/classic/clanhall.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `clanhall`;
CREATE TABLE IF NOT EXISTS `clanhall` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(40) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/classic/grandboss_data.sql b/trunk/dist/db_installer/sql/game/classic/grandboss_data.sql
similarity index 94%
rename from trunk/dist/tools/sql/classic/grandboss_data.sql
rename to trunk/dist/db_installer/sql/game/classic/grandboss_data.sql
index 12e8a243bf..615ef1c57c 100644
--- a/trunk/dist/tools/sql/classic/grandboss_data.sql
+++ b/trunk/dist/db_installer/sql/game/classic/grandboss_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `grandboss_data`;
CREATE TABLE IF NOT EXISTS `grandboss_data` (
`boss_id` smallint(5) unsigned NOT NULL,
`loc_x` mediumint(6) NOT NULL,
diff --git a/trunk/dist/tools/sql/classic/pets_skills.sql b/trunk/dist/db_installer/sql/game/classic/pets_skills.sql
similarity index 100%
rename from trunk/dist/tools/sql/classic/pets_skills.sql
rename to trunk/dist/db_installer/sql/game/classic/pets_skills.sql
diff --git a/trunk/dist/tools/sql/classic/raidboss_spawnlist.sql b/trunk/dist/db_installer/sql/game/classic/raidboss_spawnlist.sql
similarity index 100%
rename from trunk/dist/tools/sql/classic/raidboss_spawnlist.sql
rename to trunk/dist/db_installer/sql/game/classic/raidboss_spawnlist.sql
diff --git a/trunk/dist/tools/sql/classic/random_spawn.sql b/trunk/dist/db_installer/sql/game/classic/random_spawn.sql
similarity index 100%
rename from trunk/dist/tools/sql/classic/random_spawn.sql
rename to trunk/dist/db_installer/sql/game/classic/random_spawn.sql
diff --git a/trunk/dist/tools/sql/classic/random_spawn_loc.sql b/trunk/dist/db_installer/sql/game/classic/random_spawn_loc.sql
similarity index 100%
rename from trunk/dist/tools/sql/classic/random_spawn_loc.sql
rename to trunk/dist/db_installer/sql/game/classic/random_spawn_loc.sql
diff --git a/trunk/dist/tools/sql/classic/spawnlist.sql b/trunk/dist/db_installer/sql/game/classic/spawnlist.sql
similarity index 100%
rename from trunk/dist/tools/sql/classic/spawnlist.sql
rename to trunk/dist/db_installer/sql/game/classic/spawnlist.sql
diff --git a/trunk/dist/tools/sql/game/commission_items.sql b/trunk/dist/db_installer/sql/game/commission_items.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/commission_items.sql
rename to trunk/dist/db_installer/sql/game/commission_items.sql
index 191d8e3377..fbee838447 100644
--- a/trunk/dist/tools/sql/game/commission_items.sql
+++ b/trunk/dist/db_installer/sql/game/commission_items.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `commission_items`;
CREATE TABLE IF NOT EXISTS `commission_items` (
`commission_id` BIGINT NOT NULL AUTO_INCREMENT,
`item_object_id` INT NOT NULL,
diff --git a/trunk/dist/tools/sql/game/crests.sql b/trunk/dist/db_installer/sql/game/crests.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/crests.sql
rename to trunk/dist/db_installer/sql/game/crests.sql
index 57970ad700..621f887b9b 100644
--- a/trunk/dist/tools/sql/game/crests.sql
+++ b/trunk/dist/db_installer/sql/game/crests.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `crests`;
CREATE TABLE IF NOT EXISTS `crests` (
`crest_id` INT,
`data` VARBINARY(2176) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/cursed_weapons.sql b/trunk/dist/db_installer/sql/game/cursed_weapons.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/cursed_weapons.sql
rename to trunk/dist/db_installer/sql/game/cursed_weapons.sql
index 440c20ceb0..177d415ab6 100644
--- a/trunk/dist/tools/sql/game/cursed_weapons.sql
+++ b/trunk/dist/db_installer/sql/game/cursed_weapons.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `cursed_weapons`;
CREATE TABLE IF NOT EXISTS `cursed_weapons` (
`itemId` INT,
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/custom_npc_buffer.sql b/trunk/dist/db_installer/sql/game/custom_npc_buffer.sql
similarity index 94%
rename from trunk/dist/tools/sql/game/custom_npc_buffer.sql
rename to trunk/dist/db_installer/sql/game/custom_npc_buffer.sql
index ae988339ee..5f9a6729da 100644
--- a/trunk/dist/tools/sql/game/custom_npc_buffer.sql
+++ b/trunk/dist/db_installer/sql/game/custom_npc_buffer.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `custom_npc_buffer`;
CREATE TABLE IF NOT EXISTS `custom_npc_buffer` (
`npc_id` mediumint(7) NOT NULL,
`skill_id` int(6) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/custom_spawnlist.sql b/trunk/dist/db_installer/sql/game/custom_spawnlist.sql
similarity index 92%
rename from trunk/dist/tools/sql/game/custom_spawnlist.sql
rename to trunk/dist/db_installer/sql/game/custom_spawnlist.sql
index 56c764614c..9a782d8873 100644
--- a/trunk/dist/tools/sql/game/custom_spawnlist.sql
+++ b/trunk/dist/db_installer/sql/game/custom_spawnlist.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `custom_spawnlist`;
CREATE TABLE IF NOT EXISTS `custom_spawnlist` (
`location` varchar(40) NOT NULL DEFAULT '',
`count` tinyint(1) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/custom_teleport.sql b/trunk/dist/db_installer/sql/game/custom_teleport.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/custom_teleport.sql
rename to trunk/dist/db_installer/sql/game/custom_teleport.sql
index 1ed18ba227..d073e804aa 100644
--- a/trunk/dist/tools/sql/game/custom_teleport.sql
+++ b/trunk/dist/db_installer/sql/game/custom_teleport.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `custom_teleport`;
CREATE TABLE IF NOT EXISTS `custom_teleport` (
`Description` varchar(75) DEFAULT NULL,
`id` mediumint(7) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/fishing_championship.sql b/trunk/dist/db_installer/sql/game/fishing_championship.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/fishing_championship.sql
rename to trunk/dist/db_installer/sql/game/fishing_championship.sql
diff --git a/trunk/dist/tools/sql/game/fort.sql b/trunk/dist/db_installer/sql/game/fort.sql
similarity index 94%
rename from trunk/dist/tools/sql/game/fort.sql
rename to trunk/dist/db_installer/sql/game/fort.sql
index 584733bd5f..6d7c25b71e 100644
--- a/trunk/dist/tools/sql/game/fort.sql
+++ b/trunk/dist/db_installer/sql/game/fort.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `fort`;
CREATE TABLE IF NOT EXISTS `fort` (
`id` int(11) NOT NULL DEFAULT 0,
`name` varchar(25) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/fort_doorupgrade.sql b/trunk/dist/db_installer/sql/game/fort_doorupgrade.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/fort_doorupgrade.sql
rename to trunk/dist/db_installer/sql/game/fort_doorupgrade.sql
index e4c87934f3..2b55ee02d6 100644
--- a/trunk/dist/tools/sql/game/fort_doorupgrade.sql
+++ b/trunk/dist/db_installer/sql/game/fort_doorupgrade.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `fort_doorupgrade`;
CREATE TABLE IF NOT EXISTS `fort_doorupgrade` (
`doorId` int(11) NOT NULL DEFAULT '0',
`fortId` int(11) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/fort_functions.sql b/trunk/dist/db_installer/sql/game/fort_functions.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/fort_functions.sql
rename to trunk/dist/db_installer/sql/game/fort_functions.sql
index a21ab5953e..09dc7431cb 100644
--- a/trunk/dist/tools/sql/game/fort_functions.sql
+++ b/trunk/dist/db_installer/sql/game/fort_functions.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `fort_functions`;
CREATE TABLE IF NOT EXISTS `fort_functions` (
`fort_id` int(2) NOT NULL DEFAULT '0',
`type` int(1) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/fort_siege_guards.sql b/trunk/dist/db_installer/sql/game/fort_siege_guards.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/fort_siege_guards.sql
rename to trunk/dist/db_installer/sql/game/fort_siege_guards.sql
diff --git a/trunk/dist/tools/sql/game/fort_spawnlist.sql b/trunk/dist/db_installer/sql/game/fort_spawnlist.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/fort_spawnlist.sql
rename to trunk/dist/db_installer/sql/game/fort_spawnlist.sql
diff --git a/trunk/dist/tools/sql/game/fortsiege_clans.sql b/trunk/dist/db_installer/sql/game/fortsiege_clans.sql
similarity index 81%
rename from trunk/dist/tools/sql/game/fortsiege_clans.sql
rename to trunk/dist/db_installer/sql/game/fortsiege_clans.sql
index 2fd0083c9d..49f5479f28 100644
--- a/trunk/dist/tools/sql/game/fortsiege_clans.sql
+++ b/trunk/dist/db_installer/sql/game/fortsiege_clans.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `fortsiege_clans`;
CREATE TABLE IF NOT EXISTS `fortsiege_clans` (
`fort_id` int(1) NOT NULL DEFAULT '0',
`clan_id` int(11) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/forums.sql b/trunk/dist/db_installer/sql/game/forums.sql
similarity index 92%
rename from trunk/dist/tools/sql/game/forums.sql
rename to trunk/dist/db_installer/sql/game/forums.sql
index 99025ffad2..c3597f089d 100644
--- a/trunk/dist/tools/sql/game/forums.sql
+++ b/trunk/dist/db_installer/sql/game/forums.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `forums`;
CREATE TABLE IF NOT EXISTS `forums` (
`forum_id` int(8) NOT NULL DEFAULT '0',
`forum_name` varchar(255) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/four_sepulchers_spawnlist.sql b/trunk/dist/db_installer/sql/game/four_sepulchers_spawnlist.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/four_sepulchers_spawnlist.sql
rename to trunk/dist/db_installer/sql/game/four_sepulchers_spawnlist.sql
diff --git a/trunk/dist/tools/sql/game/games.sql b/trunk/dist/db_installer/sql/game/games.sql
similarity index 91%
rename from trunk/dist/tools/sql/game/games.sql
rename to trunk/dist/db_installer/sql/game/games.sql
index 413e7a6774..3c99af696f 100644
--- a/trunk/dist/tools/sql/game/games.sql
+++ b/trunk/dist/db_installer/sql/game/games.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `games`;
CREATE TABLE IF NOT EXISTS `games` (
`id` INT NOT NULL DEFAULT 0,
`idnr` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/global_tasks.sql b/trunk/dist/db_installer/sql/game/global_tasks.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/global_tasks.sql
rename to trunk/dist/db_installer/sql/game/global_tasks.sql
index 6208a5908d..ede80d7004 100644
--- a/trunk/dist/tools/sql/game/global_tasks.sql
+++ b/trunk/dist/db_installer/sql/game/global_tasks.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `global_tasks`;
CREATE TABLE IF NOT EXISTS `global_tasks` (
`id` int(11) NOT NULL auto_increment,
`task` varchar(50) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/global_variables.sql b/trunk/dist/db_installer/sql/game/global_variables.sql
similarity index 79%
rename from trunk/dist/tools/sql/game/global_variables.sql
rename to trunk/dist/db_installer/sql/game/global_variables.sql
index d348724f7c..ff529c8ffe 100644
--- a/trunk/dist/tools/sql/game/global_variables.sql
+++ b/trunk/dist/db_installer/sql/game/global_variables.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `global_variables`;
CREATE TABLE IF NOT EXISTS `global_variables` (
`var` VARCHAR(20) NOT NULL DEFAULT '',
`value` VARCHAR(255) ,
diff --git a/trunk/dist/tools/sql/game/grandboss_data.sql b/trunk/dist/db_installer/sql/game/grandboss_data.sql
similarity index 96%
rename from trunk/dist/tools/sql/game/grandboss_data.sql
rename to trunk/dist/db_installer/sql/game/grandboss_data.sql
index 3ce29d7693..8c7c31adab 100644
--- a/trunk/dist/tools/sql/game/grandboss_data.sql
+++ b/trunk/dist/db_installer/sql/game/grandboss_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `grandboss_data`;
CREATE TABLE IF NOT EXISTS `grandboss_data` (
`boss_id` smallint(5) unsigned NOT NULL,
`loc_x` mediumint(6) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/grandboss_list.sql b/trunk/dist/db_installer/sql/game/grandboss_list.sql
similarity index 81%
rename from trunk/dist/tools/sql/game/grandboss_list.sql
rename to trunk/dist/db_installer/sql/game/grandboss_list.sql
index 1d7c16d247..e3860ccc3a 100644
--- a/trunk/dist/tools/sql/game/grandboss_list.sql
+++ b/trunk/dist/db_installer/sql/game/grandboss_list.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `grandboss_list`;
CREATE TABLE IF NOT EXISTS `grandboss_list` (
`player_id` decimal(11,0) NOT NULL,
`zone` decimal(11,0) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/herb_droplist_groups.sql b/trunk/dist/db_installer/sql/game/herb_droplist_groups.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/herb_droplist_groups.sql
rename to trunk/dist/db_installer/sql/game/herb_droplist_groups.sql
diff --git a/trunk/dist/tools/sql/game/heroes.sql b/trunk/dist/db_installer/sql/game/heroes.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/heroes.sql
rename to trunk/dist/db_installer/sql/game/heroes.sql
index 09054d0b09..8b60cfb980 100644
--- a/trunk/dist/tools/sql/game/heroes.sql
+++ b/trunk/dist/db_installer/sql/game/heroes.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `heroes`;
CREATE TABLE IF NOT EXISTS `heroes` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`class_id` decimal(3,0) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/heroes_diary.sql b/trunk/dist/db_installer/sql/game/heroes_diary.sql
similarity index 87%
rename from trunk/dist/tools/sql/game/heroes_diary.sql
rename to trunk/dist/db_installer/sql/game/heroes_diary.sql
index f6fbd86c7f..3d932332df 100644
--- a/trunk/dist/tools/sql/game/heroes_diary.sql
+++ b/trunk/dist/db_installer/sql/game/heroes_diary.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `heroes_diary`;
CREATE TABLE IF NOT EXISTS `heroes_diary` (
`charId` int(10) unsigned NOT NULL,
`time` bigint(13) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/item_attributes.sql b/trunk/dist/db_installer/sql/game/item_attributes.sql
similarity index 81%
rename from trunk/dist/tools/sql/game/item_attributes.sql
rename to trunk/dist/db_installer/sql/game/item_attributes.sql
index 66d8e12c38..9f07c65a60 100644
--- a/trunk/dist/tools/sql/game/item_attributes.sql
+++ b/trunk/dist/db_installer/sql/game/item_attributes.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `item_attributes`;
CREATE TABLE IF NOT EXISTS `item_attributes` (
`itemId` int(11) NOT NULL DEFAULT 0,
`augAttributes` int(11) NOT NULL DEFAULT -1,
diff --git a/trunk/dist/tools/sql/game/item_auction.sql b/trunk/dist/db_installer/sql/game/item_auction.sql
similarity index 88%
rename from trunk/dist/tools/sql/game/item_auction.sql
rename to trunk/dist/db_installer/sql/game/item_auction.sql
index 6b9b7e0d0c..813d1705fd 100644
--- a/trunk/dist/tools/sql/game/item_auction.sql
+++ b/trunk/dist/db_installer/sql/game/item_auction.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `item_auction`;
CREATE TABLE IF NOT EXISTS `item_auction` (
`auctionId` int(11) NOT NULL,
`instanceId` int(11) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/item_auction_bid.sql b/trunk/dist/db_installer/sql/game/item_auction_bid.sql
similarity index 82%
rename from trunk/dist/tools/sql/game/item_auction_bid.sql
rename to trunk/dist/db_installer/sql/game/item_auction_bid.sql
index 6e90338353..5832690f2e 100644
--- a/trunk/dist/tools/sql/game/item_auction_bid.sql
+++ b/trunk/dist/db_installer/sql/game/item_auction_bid.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `item_auction_bid`;
CREATE TABLE IF NOT EXISTS `item_auction_bid` (
`auctionId` int(11) NOT NULL,
`playerObjId` int(11) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/item_elementals.sql b/trunk/dist/db_installer/sql/game/item_elementals.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/item_elementals.sql
rename to trunk/dist/db_installer/sql/game/item_elementals.sql
index ff156d9f1f..5e6085fdd7 100644
--- a/trunk/dist/tools/sql/game/item_elementals.sql
+++ b/trunk/dist/db_installer/sql/game/item_elementals.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `item_elementals`;
CREATE TABLE IF NOT EXISTS `item_elementals` (
`itemId` int(11) NOT NULL DEFAULT 0,
`elemType` tinyint(1) NOT NULL DEFAULT -1,
diff --git a/trunk/dist/tools/sql/game/item_variables.sql b/trunk/dist/db_installer/sql/game/item_variables.sql
similarity index 80%
rename from trunk/dist/tools/sql/game/item_variables.sql
rename to trunk/dist/db_installer/sql/game/item_variables.sql
index 79b8068815..e4aa2b3270 100644
--- a/trunk/dist/tools/sql/game/item_variables.sql
+++ b/trunk/dist/db_installer/sql/game/item_variables.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `item_variables`;
CREATE TABLE IF NOT EXISTS `item_variables` (
`id` int(10) UNSIGNED NOT NULL,
`var` varchar(255) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/items.sql b/trunk/dist/db_installer/sql/game/items.sql
similarity index 94%
rename from trunk/dist/tools/sql/game/items.sql
rename to trunk/dist/db_installer/sql/game/items.sql
index 45ad0ecf48..aba2fb15ed 100644
--- a/trunk/dist/tools/sql/game/items.sql
+++ b/trunk/dist/db_installer/sql/game/items.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `items`;
CREATE TABLE IF NOT EXISTS `items` (
`owner_id` INT, -- object id of the player or clan,owner of this item
`object_id` INT NOT NULL DEFAULT 0, -- object id of the item
diff --git a/trunk/dist/tools/sql/game/itemsonground.sql b/trunk/dist/db_installer/sql/game/itemsonground.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/itemsonground.sql
rename to trunk/dist/db_installer/sql/game/itemsonground.sql
index b780f3906b..1e385e6ad7 100644
--- a/trunk/dist/tools/sql/game/itemsonground.sql
+++ b/trunk/dist/db_installer/sql/game/itemsonground.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `itemsonground`;
CREATE TABLE IF NOT EXISTS `itemsonground` (
`object_id` int(11) NOT NULL DEFAULT '0',
`item_id` int(11) DEFAULT NULL,
diff --git a/trunk/dist/tools/sql/game/locations.sql b/trunk/dist/db_installer/sql/game/locations.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/locations.sql
rename to trunk/dist/db_installer/sql/game/locations.sql
diff --git a/trunk/dist/tools/sql/game/merchant_lease.sql b/trunk/dist/db_installer/sql/game/merchant_lease.sql
similarity index 86%
rename from trunk/dist/tools/sql/game/merchant_lease.sql
rename to trunk/dist/db_installer/sql/game/merchant_lease.sql
index caa27dea46..e86517f8f3 100644
--- a/trunk/dist/tools/sql/game/merchant_lease.sql
+++ b/trunk/dist/db_installer/sql/game/merchant_lease.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `merchant_lease`;
CREATE TABLE IF NOT EXISTS `merchant_lease` (
`merchant_id` int(11) NOT NULL DEFAULT 0,
`player_id` int(11) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/messages.sql b/trunk/dist/db_installer/sql/game/messages.sql
similarity index 94%
rename from trunk/dist/tools/sql/game/messages.sql
rename to trunk/dist/db_installer/sql/game/messages.sql
index 59294466ec..b80a0585e1 100644
--- a/trunk/dist/tools/sql/game/messages.sql
+++ b/trunk/dist/db_installer/sql/game/messages.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `messages`;
CREATE TABLE IF NOT EXISTS `messages` (
`messageId` INT NOT NULL DEFAULT 0,
`senderId` INT NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/mods_wedding.sql b/trunk/dist/db_installer/sql/game/mods_wedding.sql
similarity index 89%
rename from trunk/dist/tools/sql/game/mods_wedding.sql
rename to trunk/dist/db_installer/sql/game/mods_wedding.sql
index a73878bdc0..a20736aaf0 100644
--- a/trunk/dist/tools/sql/game/mods_wedding.sql
+++ b/trunk/dist/db_installer/sql/game/mods_wedding.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `mods_wedding`;
CREATE TABLE IF NOT EXISTS `mods_wedding` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`player1Id` int(11) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/npc_buffer.sql b/trunk/dist/db_installer/sql/game/npc_buffer.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/npc_buffer.sql
rename to trunk/dist/db_installer/sql/game/npc_buffer.sql
diff --git a/trunk/dist/tools/sql/game/olympiad_data.sql b/trunk/dist/db_installer/sql/game/olympiad_data.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/olympiad_data.sql
rename to trunk/dist/db_installer/sql/game/olympiad_data.sql
index 35ac5fad9a..730b26c786 100644
--- a/trunk/dist/tools/sql/game/olympiad_data.sql
+++ b/trunk/dist/db_installer/sql/game/olympiad_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `olympiad_data`;
CREATE TABLE IF NOT EXISTS `olympiad_data` (
`id` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`current_cycle` MEDIUMINT UNSIGNED NOT NULL DEFAULT 1,
diff --git a/trunk/dist/tools/sql/game/olympiad_fights.sql b/trunk/dist/db_installer/sql/game/olympiad_fights.sql
similarity index 91%
rename from trunk/dist/tools/sql/game/olympiad_fights.sql
rename to trunk/dist/db_installer/sql/game/olympiad_fights.sql
index fba150333e..b835c29e6b 100644
--- a/trunk/dist/tools/sql/game/olympiad_fights.sql
+++ b/trunk/dist/db_installer/sql/game/olympiad_fights.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `olympiad_fights`;
CREATE TABLE IF NOT EXISTS `olympiad_fights` (
`charOneId` int(10) unsigned NOT NULL,
`charTwoId` int(10) unsigned NOT NULL,
diff --git a/trunk/dist/tools/sql/game/olympiad_nobles.sql b/trunk/dist/db_installer/sql/game/olympiad_nobles.sql
similarity index 93%
rename from trunk/dist/tools/sql/game/olympiad_nobles.sql
rename to trunk/dist/db_installer/sql/game/olympiad_nobles.sql
index d7ac04ecba..1adbe23982 100644
--- a/trunk/dist/tools/sql/game/olympiad_nobles.sql
+++ b/trunk/dist/db_installer/sql/game/olympiad_nobles.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `olympiad_nobles`;
CREATE TABLE IF NOT EXISTS `olympiad_nobles` (
`charId` int(10) unsigned NOT NULL DEFAULT 0,
`class_id` tinyint(3) unsigned NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/olympiad_nobles_eom.sql b/trunk/dist/db_installer/sql/game/olympiad_nobles_eom.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/olympiad_nobles_eom.sql
rename to trunk/dist/db_installer/sql/game/olympiad_nobles_eom.sql
index 881f0dd9f1..9ca5120c36 100644
--- a/trunk/dist/tools/sql/game/olympiad_nobles_eom.sql
+++ b/trunk/dist/db_installer/sql/game/olympiad_nobles_eom.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `olympiad_nobles_eom`;
CREATE TABLE IF NOT EXISTS `olympiad_nobles_eom` (
`charId` int(10) unsigned NOT NULL DEFAULT 0,
`class_id` tinyint(3) unsigned NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/petition_feedback.sql b/trunk/dist/db_installer/sql/game/petition_feedback.sql
similarity index 84%
rename from trunk/dist/tools/sql/game/petition_feedback.sql
rename to trunk/dist/db_installer/sql/game/petition_feedback.sql
index ed9025ead4..664d2a1b88 100644
--- a/trunk/dist/tools/sql/game/petition_feedback.sql
+++ b/trunk/dist/db_installer/sql/game/petition_feedback.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `petition_feedback`;
CREATE TABLE IF NOT EXISTS `petition_feedback` (
`charName` VARCHAR(35) NOT NULL,
`gmName` VARCHAR(35) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/pets.sql b/trunk/dist/db_installer/sql/game/pets.sql
similarity index 92%
rename from trunk/dist/tools/sql/game/pets.sql
rename to trunk/dist/db_installer/sql/game/pets.sql
index 77b30ca930..6f18180f81 100644
--- a/trunk/dist/tools/sql/game/pets.sql
+++ b/trunk/dist/db_installer/sql/game/pets.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `pets`;
CREATE TABLE IF NOT EXISTS `pets` (
`item_obj_id` int(10) unsigned NOT NULL,
`name` varchar(16),
diff --git a/trunk/dist/tools/sql/game/pets_skills.sql b/trunk/dist/db_installer/sql/game/pets_skills.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/pets_skills.sql
rename to trunk/dist/db_installer/sql/game/pets_skills.sql
diff --git a/trunk/dist/tools/sql/game/posts.sql b/trunk/dist/db_installer/sql/game/posts.sql
similarity index 91%
rename from trunk/dist/tools/sql/game/posts.sql
rename to trunk/dist/db_installer/sql/game/posts.sql
index be34a9b0f1..076536d120 100644
--- a/trunk/dist/tools/sql/game/posts.sql
+++ b/trunk/dist/db_installer/sql/game/posts.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `posts`;
CREATE TABLE IF NOT EXISTS `posts` (
`post_id` int(8) NOT NULL DEFAULT '0',
`post_owner_name` varchar(255) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/punishments.sql b/trunk/dist/db_installer/sql/game/punishments.sql
similarity index 90%
rename from trunk/dist/tools/sql/game/punishments.sql
rename to trunk/dist/db_installer/sql/game/punishments.sql
index 0656a628b9..e7019913b3 100644
--- a/trunk/dist/tools/sql/game/punishments.sql
+++ b/trunk/dist/db_installer/sql/game/punishments.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `punishments`;
CREATE TABLE IF NOT EXISTS `punishments` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`key` varchar(255) NOT NULL,
diff --git a/trunk/dist/tools/sql/game/quest_global_data.sql b/trunk/dist/db_installer/sql/game/quest_global_data.sql
similarity index 91%
rename from trunk/dist/tools/sql/game/quest_global_data.sql
rename to trunk/dist/db_installer/sql/game/quest_global_data.sql
index 0281297cc5..02235a5d1c 100644
--- a/trunk/dist/tools/sql/game/quest_global_data.sql
+++ b/trunk/dist/db_installer/sql/game/quest_global_data.sql
@@ -3,6 +3,7 @@
-- against it, primarily for aesthetic purposes, cleaningness of code, expectability, and
-- to keep char-related data purely as char-related data, global purely as global.
+DROP TABLE IF EXISTS `quest_global_data`;
CREATE TABLE IF NOT EXISTS `quest_global_data` (
`quest_name` VARCHAR(40) NOT NULL DEFAULT '',
`var` VARCHAR(20) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/game/raidboss_spawnlist.sql b/trunk/dist/db_installer/sql/game/raidboss_spawnlist.sql
similarity index 98%
rename from trunk/dist/tools/sql/game/raidboss_spawnlist.sql
rename to trunk/dist/db_installer/sql/game/raidboss_spawnlist.sql
index 802478459d..26d1f3d50c 100644
--- a/trunk/dist/tools/sql/game/raidboss_spawnlist.sql
+++ b/trunk/dist/db_installer/sql/game/raidboss_spawnlist.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `raidboss_spawnlist`;
CREATE TABLE IF NOT EXISTS `raidboss_spawnlist` (
`boss_id` smallint(5) unsigned NOT NULL,
`amount` tinyint(1) unsigned NOT NULL DEFAULT '1',
diff --git a/trunk/dist/tools/sql/game/rainbowsprings_attacker_list.sql b/trunk/dist/db_installer/sql/game/rainbowsprings_attacker_list.sql
similarity index 77%
rename from trunk/dist/tools/sql/game/rainbowsprings_attacker_list.sql
rename to trunk/dist/db_installer/sql/game/rainbowsprings_attacker_list.sql
index 872c3b96df..9c19d6ac3e 100644
--- a/trunk/dist/tools/sql/game/rainbowsprings_attacker_list.sql
+++ b/trunk/dist/db_installer/sql/game/rainbowsprings_attacker_list.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `rainbowsprings_attacker_list`;
CREATE TABLE IF NOT EXISTS `rainbowsprings_attacker_list` (
`clanId` int(10) DEFAULT NULL,
`war_decrees_count` double(20,0) DEFAULT NULL,
diff --git a/trunk/dist/tools/sql/game/random_spawn.sql b/trunk/dist/db_installer/sql/game/random_spawn.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/random_spawn.sql
rename to trunk/dist/db_installer/sql/game/random_spawn.sql
diff --git a/trunk/dist/tools/sql/game/random_spawn_loc.sql b/trunk/dist/db_installer/sql/game/random_spawn_loc.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/random_spawn_loc.sql
rename to trunk/dist/db_installer/sql/game/random_spawn_loc.sql
diff --git a/trunk/dist/tools/sql/game/siegable_clanhall.sql b/trunk/dist/db_installer/sql/game/siegable_clanhall.sql
similarity index 95%
rename from trunk/dist/tools/sql/game/siegable_clanhall.sql
rename to trunk/dist/db_installer/sql/game/siegable_clanhall.sql
index bceef77d79..3c4806019b 100644
--- a/trunk/dist/tools/sql/game/siegable_clanhall.sql
+++ b/trunk/dist/db_installer/sql/game/siegable_clanhall.sql
@@ -6,6 +6,7 @@
-- mm = Minutes of the day when siege must start
-- Example for a siege each 7 days which starts at 12 o clock: 7;0;0;12;00
+DROP TABLE IF EXISTS `siegable_clanhall`;
CREATE TABLE IF NOT EXISTS `siegable_clanhall` (
`clanHallId` int(10) NOT NULL DEFAULT '0',
`name` varchar(45) DEFAULT NULL,
diff --git a/trunk/dist/tools/sql/game/siegable_hall_flagwar_attackers.sql b/trunk/dist/db_installer/sql/game/siegable_hall_flagwar_attackers.sql
similarity index 85%
rename from trunk/dist/tools/sql/game/siegable_hall_flagwar_attackers.sql
rename to trunk/dist/db_installer/sql/game/siegable_hall_flagwar_attackers.sql
index e32f053b90..ce20145c42 100644
--- a/trunk/dist/tools/sql/game/siegable_hall_flagwar_attackers.sql
+++ b/trunk/dist/db_installer/sql/game/siegable_hall_flagwar_attackers.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `siegable_hall_flagwar_attackers`;
CREATE TABLE IF NOT EXISTS `siegable_hall_flagwar_attackers` (
`hall_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`flag` int(10) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/siegable_hall_flagwar_attackers_members.sql b/trunk/dist/db_installer/sql/game/siegable_hall_flagwar_attackers_members.sql
similarity index 83%
rename from trunk/dist/tools/sql/game/siegable_hall_flagwar_attackers_members.sql
rename to trunk/dist/db_installer/sql/game/siegable_hall_flagwar_attackers_members.sql
index 1439bfc65b..4d363b1754 100644
--- a/trunk/dist/tools/sql/game/siegable_hall_flagwar_attackers_members.sql
+++ b/trunk/dist/db_installer/sql/game/siegable_hall_flagwar_attackers_members.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `siegable_hall_flagwar_attackers_members`;
CREATE TABLE IF NOT EXISTS `siegable_hall_flagwar_attackers_members` (
`hall_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`clan_id` int(10) unsigned NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/game/siege_clans.sql b/trunk/dist/db_installer/sql/game/siege_clans.sql
similarity index 86%
rename from trunk/dist/tools/sql/game/siege_clans.sql
rename to trunk/dist/db_installer/sql/game/siege_clans.sql
index 10430ad219..810005dae7 100644
--- a/trunk/dist/tools/sql/game/siege_clans.sql
+++ b/trunk/dist/db_installer/sql/game/siege_clans.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `siege_clans`;
CREATE TABLE IF NOT EXISTS `siege_clans` (
`castle_id` int(1) NOT NULL DEFAULT 0,
`clan_id` int(11) NOT NULL DEFAULT 0,
diff --git a/trunk/dist/tools/sql/game/spawnlist.sql b/trunk/dist/db_installer/sql/game/spawnlist.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/spawnlist.sql
rename to trunk/dist/db_installer/sql/game/spawnlist.sql
diff --git a/trunk/dist/tools/sql/game/teleport.sql b/trunk/dist/db_installer/sql/game/teleport.sql
similarity index 100%
rename from trunk/dist/tools/sql/game/teleport.sql
rename to trunk/dist/db_installer/sql/game/teleport.sql
diff --git a/trunk/dist/tools/sql/game/topic.sql b/trunk/dist/db_installer/sql/game/topic.sql
similarity index 92%
rename from trunk/dist/tools/sql/game/topic.sql
rename to trunk/dist/db_installer/sql/game/topic.sql
index c0cd2af820..ebe5be412c 100644
--- a/trunk/dist/tools/sql/game/topic.sql
+++ b/trunk/dist/db_installer/sql/game/topic.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `topic`;
CREATE TABLE IF NOT EXISTS `topic` (
`topic_id` int(8) NOT NULL DEFAULT '0',
`topic_forum_id` int(8) NOT NULL DEFAULT '0',
diff --git a/trunk/dist/tools/sql/login/account_data.sql b/trunk/dist/db_installer/sql/login/account_data.sql
similarity index 84%
rename from trunk/dist/tools/sql/login/account_data.sql
rename to trunk/dist/db_installer/sql/login/account_data.sql
index d090180a2c..4fcb334775 100644
--- a/trunk/dist/tools/sql/login/account_data.sql
+++ b/trunk/dist/db_installer/sql/login/account_data.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `account_data`;
CREATE TABLE IF NOT EXISTS `account_data` (
`account_name` VARCHAR(45) NOT NULL DEFAULT '',
`var` VARCHAR(20) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/sql/login/accounts.sql b/trunk/dist/db_installer/sql/login/accounts.sql
similarity index 92%
rename from trunk/dist/tools/sql/login/accounts.sql
rename to trunk/dist/db_installer/sql/login/accounts.sql
index a7ee2a763d..6a65467e95 100644
--- a/trunk/dist/tools/sql/login/accounts.sql
+++ b/trunk/dist/db_installer/sql/login/accounts.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `accounts`;
CREATE TABLE IF NOT EXISTS `accounts` (
`login` VARCHAR(45) NOT NULL default '',
`password` VARCHAR(45),
diff --git a/trunk/dist/tools/sql/login/accounts_ipauth.sql b/trunk/dist/db_installer/sql/login/accounts_ipauth.sql
similarity index 81%
rename from trunk/dist/tools/sql/login/accounts_ipauth.sql
rename to trunk/dist/db_installer/sql/login/accounts_ipauth.sql
index a6c92e29e9..38b7ded763 100644
--- a/trunk/dist/tools/sql/login/accounts_ipauth.sql
+++ b/trunk/dist/db_installer/sql/login/accounts_ipauth.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `accounts_ipauth`;
CREATE TABLE IF NOT EXISTS `accounts_ipauth` (
`login` varchar(45) NOT NULL,
`ip` char(15) NOT NULL,
diff --git a/trunk/dist/tools/sql/login/gameservers.sql b/trunk/dist/db_installer/sql/login/gameservers.sql
similarity index 87%
rename from trunk/dist/tools/sql/login/gameservers.sql
rename to trunk/dist/db_installer/sql/login/gameservers.sql
index 3632f20ba2..f35d6dffd1 100644
--- a/trunk/dist/tools/sql/login/gameservers.sql
+++ b/trunk/dist/db_installer/sql/login/gameservers.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `gameservers`;
CREATE TABLE IF NOT EXISTS `gameservers` (
`server_id` int(11) NOT NULL DEFAULT '0',
`hexid` varchar(50) NOT NULL DEFAULT '',
diff --git a/trunk/dist/tools/database_installer.bat b/trunk/dist/tools/database_installer.bat
deleted file mode 100644
index a115d30ef5..0000000000
--- a/trunk/dist/tools/database_installer.bat
+++ /dev/null
@@ -1,93 +0,0 @@
-@Echo off
-TITLE Mobius Project - Database Installer
-cls
-echo This script will help you install the server database.
-echo To continue, press the space bar to exit Ctrl + C
-pause > nul
-echo ======================================================================
-echo Checks environment ...
-mysql --help >nul 2>nul
-if errorlevel 1 goto nomysql
-echo - MySQL... ok
-echo ======================================================================
-echo Database installer is ready.
-echo Please perform the initial configuration
-echo ======================================================================
-set DO_INSTALL=Y
-set /P DO_INSTALL=Install the login server [Y/n]
-if "%DO_INSTALL%"=="N" goto installgame
-if "%DO_INSTALL%"=="n" goto installgame
-set INSTALL_MODE=login
-:prepare
-set DB_HOST=localhost
-set DB_USER=root
-set DB_PASSWORD=
-set DB_NAME=lineage2
-:step2
-
-set /P DB_HOST=The database server [%DB_HOST%]:
-
-set /P DB_USER=User DB [%DB_USER%]:
-
-set /P DB_PASSWORD=The %DB_USER% user password:
-
-set /P DB_NAME=DB name [%DB_NAME%]:
-SET MYSQL_PARAM=-u %DB_USER% -h %DB_HOST%
-if NOT "%DB_PASSWORD%"=="" SET MYSQL_PARAM=%MYSQL_PARAM% --password=%DB_PASSWORD%
-echo exit | mysql %MYSQL_PARAM% >nul 2>nul
-if errorlevel 1 goto dberror
-echo exit | mysql %MYSQL_PARAM% %DB_NAME% >nul 2>nul
-if errorlevel 1 goto dbnotexists
-goto install
-:dbnotexists
-echo The database %DB_NAME% does not exist!
-set ANSWER=Y
-set /P ANSWER=Create it [Y/n]?
-if "%ANSWER%"=="y" goto createdb
-if "%ANSWER%"=="Y" goto createdb
-goto step2
-:createdb
-echo create database %DB_NAME% charset=utf8; | mysql %MYSQL_PARAM%
-if errorlevel 1 goto dberror
-goto install
-:dberror
-echo ! Can not connect to the database. Check the connection settings!
-goto step2
-
-:install
-cls
-echo ======================================================================
-echo Check the input parameters
-echo - The server will be installed in %INSTALL_DIR%
-echo - The database server %DB_HOST%
-echo - Database Name %DB_NAME%
-set ANSWER=Y
-set /P ANSWER=All settings are correct [Y/n]?
-if "%ANSWER%"=="n" goto step1
-if "%ANSWER%"=="N" goto step1
-echo - Installing the database, wait...
-for %%i in (sql\%INSTALL_MODE%\*.sql) do mysql %MYSQL_PARAM% %DB_NAME% < %%i
-if "%INSTALL_MODE%"=="login" goto installgame
-goto end
-:installgame
-cls
-set DO_INSTALL=Y
-set /P DO_INSTALL=Install game server [Y/n]
-if "%DO_INSTALL%"=="N" goto end
-if "%DO_INSTALL%"=="n" goto end
-set INSTALL_MODE=game
-goto prepare
-:nomysql
-cls
-echo ! Utility mysql available
-echo Make sure that mysql.exe in the environment variable
-echo or the current directory with the script installation
-goto end
-:end
-cls
-echo ======================================================================
-echo ======================================================================
-echo Installation is complete...
-echo ======================================================================
-echo ======================================================================
-pause > nul
\ No newline at end of file
diff --git a/trunk/dist/tools/database_installer.sh b/trunk/dist/tools/database_installer.sh
deleted file mode 100644
index 11c7ff7258..0000000000
--- a/trunk/dist/tools/database_installer.sh
+++ /dev/null
@@ -1,270 +0,0 @@
-#!/bin/bash
-trap finish 2
-
-configure() {
-echo "#############################################"
-echo "# You entered script configuration area #"
-echo "# No change will be performed in your DB #"
-echo "# I will just ask you some questions about #"
-echo "# your hosts and DB. #"
-echo "#############################################"
-MYSQLDUMPPATH=`which -a mysqldump 2>/dev/null`
-MYSQLPATH=`which -a mysql 2>/dev/null`
-if [ $? -ne 0 ]; then
-echo "We were unable to find MySQL binaries on your path"
-while :
- do
- echo -ne "\nPlease enter MySQL binaries directory (no trailing slash): "
- read MYSQLBINPATH
- if [ -e "$MYSQLBINPATH" ] && [ -d "$MYSQLBINPATH" ] && \
- [ -e "$MYSQLBINPATH/mysqldump" ] && [ -e "$MYSQLBINPATH/mysql" ]; then
- MYSQLDUMPPATH="$MYSQLBINPATH/mysqldump"
- MYSQLPATH="$MYSQLBINPATH/mysql"
- break
- else
- echo "The data you entered is invalid. Please verify and try again."
- exit 1
- fi
- done
-fi
-#LS
-echo -ne "\nPlease enter MySQL Login Server hostname (default localhost): "
-read LSDBHOST
-if [ -z "$LSDBHOST" ]; then
- LSDBHOST="localhost"
-fi
-echo -ne "\nPlease enter MySQL Login Server database name (default lineage2): "
-read LSDB
-if [ -z "$LSDB" ]; then
- LSDB="lineage2"
-fi
-echo -ne "\nPlease enter MySQL Login Server user (default root): "
-read LSUSER
-if [ -z "$LSUSER" ]; then
- LSUSER="root"
-fi
-echo -ne "\nPlease enter MySQL Login Server $LSUSER's password (won't be displayed) :"
-stty -echo
-read LSPASS
-stty echo
-echo ""
-if [ -z "$LSPASS" ]; then
- echo "Hum.. I'll let it be but don't be stupid and avoid empty passwords"
-elif [ "$LSUSER" == "$LSPASS" ]; then
- echo "You're not too brilliant choosing passwords huh?"
-fi
-#GS
-echo -ne "\nPlease enter MySQL Game Server hostname (default $LSDBHOST): "
-read GSDBHOST
-if [ -z "$GSDBHOST" ]; then
- GSDBHOST="localhost"
-fi
-echo -ne "\nPlease enter MySQL Game Server database name (default l2jgs): "
-read GSDB
-if [ -z "$GSDB" ]; then
- GSDB="lineage2"
-fi
-echo -ne "\nPlease enter MySQL Game Server user (default $LSUSER): "
-read GSUSER
-if [ -z "$GSUSER" ]; then
- GSUSER="root"
-fi
-echo -ne "\nPlease enter MySQL Game Server $GSUSER's password (won't be displayed): "
-stty -echo
-read GSPASS
-stty echo
-echo ""
-if [ -z "$GSPASS" ]; then
- echo "Hum.. I'll let it be but don't be stupid and avoid empty passwords"
-elif [ "$GSUSER" == "$GSPASS" ]; then
- echo "You're not too brilliant choosing passwords huh?"
-fi
-save_config $1
-}
-
-save_config() {
-if [ -n "$1" ]; then
-CONF="$1"
-else
-CONF="database_installer.rc"
-fi
-echo ""
-echo "With these data I can generate a configuration file which can be read"
-echo "on future updates. WARNING: this file will contain clear text passwords!"
-echo -ne "Shall I generate config file $CONF? (Y/n):"
-read SAVE
-if [ "$SAVE" == "y" -o "$SAVE" == "Y" -o "$SAVE" == "" ];then
-cat <$CONF
-#Configuration settings for L2J-Datapack database installer script
-MYSQLDUMPPATH=$MYSQLDUMPPATH
-MYSQLPATH=$MYSQLPATH
-LSDBHOST=$LSDBHOST
-LSDB=$LSDB
-LSUSER=$LSUSER
-LSPASS=$LSPASS
-GSDBHOST=$GSDBHOST
-GSDB=$GSDB
-GSUSER=$GSUSER
-GSPASS=$GSPASS
-EOF
-chmod 600 $CONF
-echo "Configuration saved as $CONF"
-echo "Permissions changed to 600 (rw- --- ---)"
-elif [ "$SAVE" != "n" -a "$SAVE" != "N" ]; then
- save_config
-fi
-}
-
-load_config() {
-if [ -n "$1" ]; then
-CONF="$1"
-else
-CONF="database_installer.rc"
-fi
-if [ -e "$CONF" ] && [ -f "$CONF" ]; then
-. $CONF
-else
-echo "Settings file not found: $CONF"
-echo "You can specify an alternate settings filename:"
-echo $0 config_filename
-echo ""
-echo "If file doesn't exist it can be created"
-echo "If nothing is specified script will try to work with ./database_installer.rc"
-echo ""
-configure $CONF
-fi
-}
-
-asklogin(){
-clear
-echo "#############################################"
-echo "# WARNING: This section of the script CAN #"
-echo "# destroy your characters and accounts #"
-echo "# information. Read questions carefully #"
-echo "# before you reply. #"
-echo "#############################################"
-echo ""
-echo "Choose full (f) if you don't have and 'accounts' table or would"
-echo "prefer to erase the existing accounts information."
-echo "Choose skip (s) to skip loginserver DB installation and go to"
-echo "gameserver DB installation/upgrade."
-echo -ne "LOGINSERVER DB install type: (f) full, (s) skip or (q) quit? "
-read LOGINPROMPT
-case "$LOGINPROMPT" in
- "f"|"F") logininstall; loginupgrade;;
- "s"|"S") gsbackup;;
- "q"|"Q") finish;;
- *) asklogin;;
-esac
-}
-
-logininstall(){
-echo "Deleting loginserver tables for new content."
-$MYL < ls_cleanup.sql
-}
-
-loginupgrade(){
-clear
-echo "Installling new loginserver content."
-for login in $(ls ./sql/login/*.sql);do
- echo "Installing loginserver table : $login"
- $MYL < $login
-done
-gsbackup
-}
-
-gsbackup(){
-while :
- do
- echo ""
- echo -ne "Do you want to make a backup copy of your GSDB? (y/n): "
- read LSB
- if [ "$LSB" == "Y" -o "$LSB" == "y" ]; then
- echo "Making a backup of the original gameserver database."
- $MYSQLDUMPPATH --add-drop-table -h $GSDBHOST -u $GSUSER --password=$GSPASS $GSDB > gs_backup.sql
- if [ $? -ne 0 ];then
- clear
- echo ""
- echo "There was a problem accesing your GS database, either it wasnt created or authentication data is incorrect."
- exit 1
- fi
- break
- elif [ "$LSB" == "n" -o "$LSB" == "N" ]; then
- break
- fi
- done
- asktype
-}
-
-lsbackup(){
-while :
- do
- clear
- echo ""
- echo -ne "Do you want to make a backup copy of your LSDB? (y/n): "
- read LSB
- if [ "$LSB" == "Y" -o "$LSB" == "y" ]; then
- echo "Making a backup of the original loginserver database."
- $MYSQLDUMPPATH --add-drop-table -h $LSDBHOST -u $LSUSER --password=$LSPASS $LSDB > ls_backup.sql
- if [ $? -ne 0 ];then
- clear
- echo ""
- echo "There was a problem accesing your LS database, either it wasnt created or authentication data is incorrect."
- exit 1
- fi
- break
- elif [ "$LSB" == "n" -o "$LSB" == "N" ]; then
- break
- fi
- done
-}
-
-asktype(){
-echo ""
-echo ""
-echo "WARNING: A full install (f) will destroy all existing character data."
-echo -ne "GAMESERVER DB install type: (f) full install, (u) upgrade or (q) quit? "
-read INSTALLTYPE
-case "$INSTALLTYPE" in
- "f"|"F") fullinstall; upgradeinstall I;;
- "u"|"U") upgradeinstall U;;
- "q"|"Q") finish;;
- *) asktype;;
-esac
-}
-
-fullinstall(){
-clear
-echo "Deleting all gameserver tables for new content."
-$MYG < gs_cleanup.sql
-}
-
-upgradeinstall(){
-clear
-if [ "$1" == "I" ]; then
-echo "Installling new gameserver content."
-else
-echo "Upgrading gameserver content"
-fi
-
-for gs in $(ls ./sql/game/*.sql);do
- echo "Installing GameServer table : $gs"
- $MYG < $gs
-done
-
-finish
-}
-
-finish(){
-clear
-echo "Script execution finished."
-echo ""
-exit 0
-}
-
-clear
-load_config $1
-MYL="$MYSQLPATH -h $LSDBHOST -u $LSUSER --password=$LSPASS -D $LSDB"
-MYG="$MYSQLPATH -h $GSDBHOST -u $GSUSER --password=$GSPASS -D $GSDB"
-lsbackup
-asklogin
\ No newline at end of file
diff --git a/trunk/dist/tools/mysql.exe b/trunk/dist/tools/mysql.exe
deleted file mode 100644
index 717eeea34c..0000000000
Binary files a/trunk/dist/tools/mysql.exe and /dev/null differ
diff --git a/trunk/dist/tools/mysqldump.exe b/trunk/dist/tools/mysqldump.exe
deleted file mode 100644
index d00dc128f9..0000000000
Binary files a/trunk/dist/tools/mysqldump.exe and /dev/null differ
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/AbstractDBLauncher.java b/trunk/java/com/l2jserver/tools/dbinstaller/AbstractDBLauncher.java
new file mode 100644
index 0000000000..bb08ec5c1d
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/AbstractDBLauncher.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller;
+
+/**
+ * Abstract Database Launcher.
+ * @author Zoey76
+ */
+public abstract class AbstractDBLauncher
+{
+ protected static String getArg(String arg, String[] args)
+ {
+ try
+ {
+ int i = 0;
+ do
+ {
+ // Nothing is missing here.
+ }
+ while (!arg.equalsIgnoreCase(args[i++]));
+ return args[i];
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/DBOutputInterface.java b/trunk/java/com/l2jserver/tools/dbinstaller/DBOutputInterface.java
new file mode 100644
index 0000000000..ee7ec6fae2
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/DBOutputInterface.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller;
+
+import java.sql.Connection;
+
+/**
+ * @author mrTJO
+ */
+public interface DBOutputInterface
+{
+ public void setProgressIndeterminate(boolean value);
+
+ public void setProgressMaximum(int maxValue);
+
+ public void setProgressValue(int value);
+
+ public void setFrameVisible(boolean value);
+
+ public void appendToProgressArea(String text);
+
+ public Connection getConnection();
+
+ public int requestConfirm(String title, String message, int type);
+
+ public void showMessage(String title, String message, int type);
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/LauncherGS.java b/trunk/java/com/l2jserver/tools/dbinstaller/LauncherGS.java
new file mode 100644
index 0000000000..ee03507f87
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/LauncherGS.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller;
+
+import java.awt.HeadlessException;
+
+import javax.swing.UIManager;
+
+import com.l2jserver.tools.dbinstaller.console.DBInstallerConsole;
+import com.l2jserver.tools.dbinstaller.gui.DBConfigGUI;
+
+/**
+ * Contains main class for Database Installer If system doesn't support the graphical UI, start the installer in console mode.
+ * @author mrTJO
+ */
+public class LauncherGS extends AbstractDBLauncher
+{
+ public static void main(String[] args)
+ {
+ String defDatabase = "lineage2";
+ String dir = "sql/game/";
+
+ if ((args != null) && (args.length > 0))
+ {
+ new DBInstallerConsole(defDatabase, dir, getArg("-h", args), getArg("-p", args), getArg("-u", args), getArg("-pw", args), getArg("-d", args), getArg("-m", args));
+ return;
+ }
+
+ try
+ {
+ // Set OS Look And Feel
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ }
+ catch (Exception e)
+ {
+ }
+
+ try
+ {
+ new DBConfigGUI(defDatabase, dir);
+ }
+ catch (HeadlessException e)
+ {
+ new DBInstallerConsole(defDatabase, dir);
+ }
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/LauncherLS.java b/trunk/java/com/l2jserver/tools/dbinstaller/LauncherLS.java
new file mode 100644
index 0000000000..264d2de91c
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/LauncherLS.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller;
+
+import java.awt.HeadlessException;
+
+import javax.swing.UIManager;
+
+import com.l2jserver.tools.dbinstaller.console.DBInstallerConsole;
+import com.l2jserver.tools.dbinstaller.gui.DBConfigGUI;
+
+/**
+ * Contains main class for Database Installer If system doesn't support the graphical UI, start the installer in console mode.
+ * @author mrTJO
+ */
+public class LauncherLS extends AbstractDBLauncher
+{
+ public static void main(String[] args)
+ {
+ String defDatabase = "lineage2";
+ String dir = "sql/login/";
+
+ if ((args != null) && (args.length > 0))
+ {
+ new DBInstallerConsole(defDatabase, dir, getArg("-h", args), getArg("-p", args), getArg("-u", args), getArg("-pw", args), getArg("-d", args), getArg("-m", args));
+ return;
+ }
+
+ try
+ {
+ // Set OS Look And Feel
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ }
+ catch (Exception e)
+ {
+ }
+
+ try
+ {
+ new DBConfigGUI(defDatabase, dir);
+ }
+ catch (HeadlessException e)
+ {
+ new DBInstallerConsole(defDatabase, dir);
+ }
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/RunTasks.java b/trunk/java/com/l2jserver/tools/dbinstaller/RunTasks.java
new file mode 100644
index 0000000000..a4e54eb1f6
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/RunTasks.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller;
+
+import java.io.File;
+import java.sql.SQLException;
+
+import javax.swing.JOptionPane;
+
+import com.l2jserver.tools.dbinstaller.util.mysql.DBDumper;
+import com.l2jserver.tools.dbinstaller.util.mysql.ScriptExecutor;
+
+/**
+ * @author mrTJO
+ */
+public class RunTasks extends Thread
+{
+ DBOutputInterface _frame;
+ boolean _classicInstall;
+ String _db;
+ String _sqlDir;
+
+ public RunTasks(DBOutputInterface frame, String db, String sqlDir, boolean classicInstall)
+ {
+ _frame = frame;
+ _db = db;
+ _classicInstall = classicInstall;
+ _sqlDir = sqlDir;
+ }
+
+ @Override
+ public void run()
+ {
+ new DBDumper(_frame, _db);
+ ScriptExecutor exec = new ScriptExecutor(_frame);
+
+ _frame.appendToProgressArea("Installing Database Content...");
+ exec.execSqlBatch(new File(_sqlDir));
+
+ if (_classicInstall)
+ {
+ File cusDir = new File(_sqlDir, "classic");
+ if (cusDir.exists())
+ {
+ _frame.appendToProgressArea("Installing Classic Tables...");
+ exec.execSqlBatch(cusDir);
+ }
+ }
+
+ _frame.appendToProgressArea("Database Installation Complete!");
+
+ try
+ {
+ _frame.getConnection().close();
+ }
+ catch (SQLException e)
+ {
+ JOptionPane.showMessageDialog(null, "Cannot close MySQL Connection: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ _frame.setFrameVisible(false);
+ _frame.showMessage("Done!", "Database Installation Complete!", JOptionPane.INFORMATION_MESSAGE);
+ System.exit(0);
+
+ }
+
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/console/DBInstallerConsole.java b/trunk/java/com/l2jserver/tools/dbinstaller/console/DBInstallerConsole.java
new file mode 100644
index 0000000000..7c0b8a6774
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/console/DBInstallerConsole.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.console;
+
+import java.sql.Connection;
+import java.util.Scanner;
+import java.util.prefs.Preferences;
+
+import com.l2jserver.tools.dbinstaller.DBOutputInterface;
+import com.l2jserver.tools.dbinstaller.RunTasks;
+import com.l2jserver.tools.dbinstaller.util.CloseShieldedInputStream;
+import com.l2jserver.tools.dbinstaller.util.mysql.MySqlConnect;
+
+/**
+ * @author mrTJO
+ */
+public class DBInstallerConsole implements DBOutputInterface
+{
+ Connection _con;
+
+ public DBInstallerConsole(String db, String dir)
+ {
+ System.out.println("Welcome to L2J DataBase installer");
+ Preferences prop = Preferences.userRoot();
+ RunTasks rt = null;
+ try (Scanner scn = new Scanner(new CloseShieldedInputStream(System.in)))
+ {
+ while (_con == null)
+ {
+ System.out.printf("%s (%s): ", "Host", prop.get("dbHost_" + db, "localhost"));
+ String dbHost = scn.nextLine();
+ System.out.printf("%s (%s): ", "Port", prop.get("dbPort_" + db, "3306"));
+ String dbPort = scn.nextLine();
+ System.out.printf("%s (%s): ", "Username", prop.get("dbUser_" + db, "root"));
+ String dbUser = scn.nextLine();
+ System.out.printf("%s (%s): ", "Password", "");
+ String dbPass = scn.nextLine();
+ System.out.printf("%s (%s): ", "Database", prop.get("dbDbse_" + db, db));
+ String dbDbse = scn.nextLine();
+
+ dbHost = dbHost.isEmpty() ? prop.get("dbHost_" + db, "localhost") : dbHost;
+ dbPort = dbPort.isEmpty() ? prop.get("dbPort_" + db, "3306") : dbPort;
+ dbUser = dbUser.isEmpty() ? prop.get("dbUser_" + db, "root") : dbUser;
+ dbDbse = dbDbse.isEmpty() ? prop.get("dbDbse_" + db, db) : dbDbse;
+
+ MySqlConnect connector = new MySqlConnect(dbHost, dbPort, dbUser, dbPass, dbDbse, true);
+
+ _con = connector.getConnection();
+ }
+
+ System.out.print("(C)lean install, (U)pdate or (E)xit? ");
+ String resp = scn.next();
+ if (resp.equalsIgnoreCase("c"))
+ {
+ System.out.print("Do you really want to destroy your db (Y/N)?");
+ if (scn.next().equalsIgnoreCase("y"))
+ {
+ rt = new RunTasks(this, db, dir, true);
+ }
+ }
+ else if (resp.equalsIgnoreCase("u"))
+ {
+ rt = new RunTasks(this, db, dir, false);
+ }
+ }
+
+ if (rt != null)
+ {
+ rt.run();
+ }
+ else
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * Database Console Installer constructor.
+ * @param defDatabase the default database name
+ * @param dir the SQL script's directory
+ * @param host the host name
+ * @param port the port
+ * @param user the user name
+ * @param pass the password
+ * @param database the database name
+ * @param mode the mode, c: Clean, u:update
+ */
+ public DBInstallerConsole(String defDatabase, String dir, String host, String port, String user, String pass, String database, String mode)
+ {
+ if ((database == null) || database.isEmpty())
+ {
+ database = defDatabase;
+ }
+
+ final MySqlConnect connector = new MySqlConnect(host, port, user, pass, database, true);
+
+ _con = connector.getConnection();
+
+ if ((mode != null) && ("c".equalsIgnoreCase(mode) || "u".equalsIgnoreCase(mode)))
+ {
+ final RunTasks rt = new RunTasks(this, database, dir, "c".equalsIgnoreCase(mode));
+ rt.run();
+ }
+ }
+
+ @Override
+ public void appendToProgressArea(String text)
+ {
+ System.out.println(text);
+ }
+
+ @Override
+ public Connection getConnection()
+ {
+ return _con;
+ }
+
+ @Override
+ public void setProgressIndeterminate(boolean value)
+ {
+ }
+
+ @Override
+ public void setProgressMaximum(int maxValue)
+ {
+ }
+
+ @Override
+ public void setProgressValue(int value)
+ {
+ }
+
+ @Override
+ public void setFrameVisible(boolean value)
+ {
+ }
+
+ @Override
+ public int requestConfirm(String title, String message, int type)
+ {
+ System.out.print(message);
+ String res = "";
+ try (Scanner scn = new Scanner(new CloseShieldedInputStream(System.in)))
+ {
+ res = scn.next();
+ }
+ return res.equalsIgnoreCase("y") ? 0 : 1;
+ }
+
+ @Override
+ public void showMessage(String title, String message, int type)
+ {
+ System.out.println(message);
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/gui/DBConfigGUI.java b/trunk/java/com/l2jserver/tools/dbinstaller/gui/DBConfigGUI.java
new file mode 100644
index 0000000000..2fb907cf71
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/gui/DBConfigGUI.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.gui;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.event.ActionListener;
+import java.util.prefs.Preferences;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPasswordField;
+import javax.swing.JTextField;
+import javax.swing.SpringLayout;
+import javax.swing.SwingConstants;
+
+import com.l2jserver.tools.dbinstaller.RunTasks;
+import com.l2jserver.tools.dbinstaller.images.ImagesTable;
+import com.l2jserver.tools.dbinstaller.util.mysql.MySqlConnect;
+import com.l2jserver.tools.dbinstaller.util.swing.SpringUtilities;
+
+/**
+ * @author mrTJO
+ */
+public class DBConfigGUI extends JFrame
+{
+ JTextField _dbHost;
+ JTextField _dbPort;
+ JTextField _dbUser;
+ JPasswordField _dbPass;
+ JTextField _dbDbse;
+
+ String _db;
+ String _dir;
+
+ Preferences _prop;
+
+ public DBConfigGUI(String db, String dir)
+ {
+ super("Database Installer");
+ setLayout(new SpringLayout());
+ setDefaultLookAndFeelDecorated(true);
+ setIconImage(ImagesTable.getImage("l2j.png").getImage());
+
+ _db = db;
+ _dir = dir;
+
+ int width = 260;
+ int height = 220;
+ Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
+
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
+ setResizable(false);
+
+ _prop = Preferences.userRoot();
+
+ // Host
+ JLabel labelDbHost = new JLabel("Host: ", SwingConstants.LEFT);
+ add(labelDbHost);
+ _dbHost = new JTextField(15);
+ _dbHost.setText(_prop.get("dbHost_" + db, "localhost"));
+ labelDbHost.setLabelFor(_dbHost);
+ add(_dbHost);
+
+ // Port
+ JLabel labelDbPort = new JLabel("Port: ", SwingConstants.LEFT);
+ add(labelDbPort);
+ _dbPort = new JTextField(15);
+ _dbPort.setText(_prop.get("dbPort_" + db, "3306"));
+ labelDbPort.setLabelFor(_dbPort);
+ add(_dbPort);
+
+ // Username
+ JLabel labelDbUser = new JLabel("Username: ", SwingConstants.LEFT);
+ add(labelDbUser);
+ _dbUser = new JTextField(15);
+ _dbUser.setText(_prop.get("dbUser_" + db, "root"));
+ labelDbUser.setLabelFor(_dbUser);
+ add(_dbUser);
+
+ // Password
+ JLabel labelDbPass = new JLabel("Password: ", SwingConstants.LEFT);
+ add(labelDbPass);
+ _dbPass = new JPasswordField(15);
+ _dbPass.setText(_prop.get("dbPass_" + db, ""));
+ labelDbPass.setLabelFor(_dbPass);
+ add(_dbPass);
+
+ // Database
+ JLabel labelDbDbse = new JLabel("Database: ", SwingConstants.LEFT);
+ add(labelDbDbse);
+ _dbDbse = new JTextField(15);
+ _dbDbse.setText(_prop.get("dbDbse_" + db, db));
+ labelDbDbse.setLabelFor(_dbDbse);
+ add(_dbDbse);
+
+ ActionListener cancelListener = e -> System.exit(0);
+
+ // Cancel
+ JButton btnCancel = new JButton("Cancel");
+ btnCancel.addActionListener(cancelListener);
+ add(btnCancel);
+
+ ActionListener connectListener = e ->
+ {
+ MySqlConnect connector = new MySqlConnect(_dbHost.getText(), _dbPort.getText(), _dbUser.getText(), new String(_dbPass.getPassword()), _dbDbse.getText(), false);
+
+ if (connector.getConnection() != null)
+ {
+ _prop.put("dbHost_" + _db, _dbHost.getText());
+ _prop.put("dbPort_" + _db, _dbPort.getText());
+ _prop.put("dbUser_" + _db, _dbUser.getText());
+ _prop.put("dbDbse_" + _db, _dbDbse.getText());
+
+ boolean classicInstall = false;
+ DBInstallerGUI dbi = new DBInstallerGUI(connector.getConnection());
+ setVisible(false);
+
+ if (!_dir.equals("sql/login/"))
+ {
+ Object[] options =
+ {
+ "Classic Install",
+ "Ertheia Install",
+ "Exit"
+ };
+ int n = JOptionPane.showOptionDialog(null, "Select Installation Type", "Installation Type", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
+
+ if ((n == 2) || (n == -1))
+ {
+ System.exit(0);
+ }
+
+ if (n == 0)
+ {
+ classicInstall = true;
+ }
+ }
+ dbi.setVisible(true);
+
+ RunTasks task = new RunTasks(dbi, _db, _dir, classicInstall);
+ task.setPriority(Thread.MAX_PRIORITY);
+ task.start();
+ }
+ };
+
+ // Connect
+ JButton btnConnect = new JButton("Connect");
+ btnConnect.addActionListener(connectListener);
+ add(btnConnect);
+
+ SpringUtilities.makeCompactGrid(getContentPane(), 6, 2, 5, 5, 5, 5);
+
+ setVisible(true);
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/gui/DBInstallerGUI.java b/trunk/java/com/l2jserver/tools/dbinstaller/gui/DBInstallerGUI.java
new file mode 100644
index 0000000000..a900d029e1
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/gui/DBInstallerGUI.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.sql.Connection;
+
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import com.l2jserver.tools.dbinstaller.DBOutputInterface;
+import com.l2jserver.tools.dbinstaller.images.ImagesTable;
+
+/**
+ * @author mrTJO
+ */
+public class DBInstallerGUI extends JFrame implements DBOutputInterface
+{
+ private final JProgressBar _progBar;
+ private final JTextArea _progArea;
+ private final Connection _con;
+
+ public DBInstallerGUI(Connection con)
+ {
+ super("Database Installer");
+ setLayout(new BorderLayout());
+ setDefaultLookAndFeelDecorated(true);
+ setIconImage(ImagesTable.getImage("l2j.png").getImage());
+
+ _con = con;
+
+ int width = 480;
+ int height = 360;
+ Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
+
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
+ setResizable(false);
+
+ _progBar = new JProgressBar();
+ _progBar.setIndeterminate(true);
+ add(_progBar, BorderLayout.PAGE_START);
+
+ _progArea = new JTextArea();
+ JScrollPane scrollPane = new JScrollPane(_progArea);
+
+ _progArea.setEditable(false);
+ appendToProgressArea("Connected");
+
+ add(scrollPane, BorderLayout.CENTER);
+ }
+
+ @Override
+ public void setProgressIndeterminate(boolean value)
+ {
+ _progBar.setIndeterminate(value);
+ }
+
+ @Override
+ public void setProgressMaximum(int maxValue)
+ {
+ _progBar.setMaximum(maxValue);
+ }
+
+ @Override
+ public void setProgressValue(int value)
+ {
+ _progBar.setValue(value);
+ }
+
+ @Override
+ public void appendToProgressArea(String text)
+ {
+ _progArea.append(text + System.getProperty("line.separator"));
+ _progArea.setCaretPosition(_progArea.getDocument().getLength());
+ }
+
+ @Override
+ public Connection getConnection()
+ {
+ return _con;
+ }
+
+ @Override
+ public void setFrameVisible(boolean value)
+ {
+ setVisible(value);
+ }
+
+ @Override
+ public int requestConfirm(String title, String message, int type)
+ {
+ return JOptionPane.showConfirmDialog(null, message, title, type);
+ }
+
+ @Override
+ public void showMessage(String title, String message, int type)
+ {
+ JOptionPane.showMessageDialog(null, message, title, type);
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/images/ImagesTable.java b/trunk/java/com/l2jserver/tools/dbinstaller/images/ImagesTable.java
new file mode 100644
index 0000000000..daa236f35f
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/images/ImagesTable.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.images;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.ImageIcon;
+
+/**
+ * Usage of this class causes images to be loaded and kept in memory, and therefore should only be used by helper applications.
+ * Some icons from famfamfam (http://www.famfamfam.com/) credit *MUST* be given.
+ * @author KenM
+ */
+public class ImagesTable
+{
+ private static final Map IMAGES = new HashMap<>();
+
+ public static final String IMAGES_DIRECTORY = "images/";
+
+ public static ImageIcon getImage(String name)
+ {
+ if (!IMAGES.containsKey(name))
+ {
+ IMAGES.put(name, new ImageIcon(IMAGES_DIRECTORY + name));
+ }
+ return IMAGES.get(name);
+ }
+}
\ No newline at end of file
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/util/CloseShieldedInputStream.java b/trunk/java/com/l2jserver/tools/dbinstaller/util/CloseShieldedInputStream.java
new file mode 100644
index 0000000000..16e5564e8f
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/util/CloseShieldedInputStream.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Prevent the underlying input stream to close.
+ * @author Joe Cheng, Zoey76
+ */
+public class CloseShieldedInputStream extends InputStream
+{
+ private InputStream _in = null;
+
+ /**
+ * Instantiates a new close shielded input stream.
+ * @param in the in
+ */
+ public CloseShieldedInputStream(InputStream in)
+ {
+ _in = in;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void close()
+ {
+ _in = null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int read() throws IOException
+ {
+ if (_in == null)
+ {
+ throw new IOException("Stream is null!");
+ }
+ return _in.read();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int read(byte b[]) throws IOException
+ {
+ if (_in == null)
+ {
+ throw new IOException("Stream is null!");
+ }
+ return _in.read(b);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int read(byte b[], int off, int len) throws IOException
+ {
+ if (_in == null)
+ {
+ throw new IOException("Stream is null!");
+ }
+ return _in.read(b, off, len);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public long skip(long n) throws IOException
+ {
+ if (_in == null)
+ {
+ throw new IOException("Stream is null!");
+ }
+ return _in.skip(n);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void mark(int readlimit)
+ {
+ if (_in != null)
+ {
+ _in.mark(readlimit);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean markSupported()
+ {
+ if (_in == null)
+ {
+ return false;
+ }
+ return _in.markSupported();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void reset() throws IOException
+ {
+ if (_in == null)
+ {
+ throw new IOException("Stream is null!");
+ }
+ _in.reset();
+ }
+
+ /**
+ * Gets the underlying stream.
+ * @return the underlying stream
+ */
+ public InputStream getUnderlyingStream()
+ {
+ return _in;
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/util/FileWriterStdout.java b/trunk/java/com/l2jserver/tools/dbinstaller/util/FileWriterStdout.java
new file mode 100644
index 0000000000..147834bcc2
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/util/FileWriterStdout.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.util;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * @author mrTJO
+ */
+public class FileWriterStdout extends BufferedWriter
+{
+ public FileWriterStdout(FileWriter fileWriter)
+ {
+ super(fileWriter);
+ }
+
+ public void println() throws IOException
+ {
+ append(System.getProperty("line.separator"));
+ }
+
+ public void println(String line) throws IOException
+ {
+ append(line + System.getProperty("line.separator"));
+ }
+
+ public void print(String text) throws IOException
+ {
+ append(text);
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/DBDumper.java b/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/DBDumper.java
new file mode 100644
index 0000000000..e4aa99d650
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/DBDumper.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.util.mysql;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Formatter;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.l2jserver.tools.dbinstaller.DBOutputInterface;
+import com.l2jserver.tools.dbinstaller.util.FileWriterStdout;
+
+/**
+ * @author mrTJO
+ */
+public class DBDumper
+{
+ DBOutputInterface _frame;
+ String _db;
+
+ public DBDumper(DBOutputInterface frame, String db)
+ {
+ _frame = frame;
+ _db = db;
+ createDump();
+ }
+
+ public void createDump()
+ {
+ try (Formatter form = new Formatter())
+ {
+ Connection con = _frame.getConnection();
+ try (Statement s = con.createStatement();
+ ResultSet rset = s.executeQuery("SHOW TABLES"))
+ {
+ File dump = new File("dumps", form.format("%1$s_dump_%2$tY%2$tm%2$td-%2$tH%2$tM%2$tS.sql", _db, new GregorianCalendar().getTime()).toString());
+ new File("dumps").mkdir();
+ dump.createNewFile();
+
+ _frame.appendToProgressArea("Writing dump " + dump.getName());
+ if (rset.last())
+ {
+ int rows = rset.getRow();
+ rset.beforeFirst();
+ if (rows > 0)
+ {
+ _frame.setProgressIndeterminate(false);
+ _frame.setProgressMaximum(rows);
+ }
+ }
+
+ try (FileWriter fileWriter = new FileWriter(dump);
+ FileWriterStdout fws = new FileWriterStdout(fileWriter))
+ {
+ while (rset.next())
+ {
+ _frame.setProgressValue(rset.getRow());
+ _frame.appendToProgressArea("Dumping Table " + rset.getString(1));
+ fws.println("CREATE TABLE `" + rset.getString(1) + "`");
+ fws.println("(");
+ try (Statement desc = con.createStatement();
+ ResultSet dset = desc.executeQuery("DESC " + rset.getString(1)))
+ {
+ Map> keys = new HashMap<>();
+ boolean isFirst = true;
+ while (dset.next())
+ {
+ if (!isFirst)
+ {
+ fws.println(",");
+ }
+ fws.print("\t`" + dset.getString(1) + "`");
+ fws.print(" " + dset.getString(2));
+ if (dset.getString(3).equals("NO"))
+ {
+ fws.print(" NOT NULL");
+ }
+ if (!dset.getString(4).isEmpty())
+ {
+ if (!keys.containsKey(dset.getString(4)))
+ {
+ keys.put(dset.getString(4), new ArrayList());
+ }
+ keys.get(dset.getString(4)).add(dset.getString(1));
+ }
+ if (dset.getString(5) != null)
+ {
+ fws.print(" DEFAULT '" + dset.getString(5) + "'");
+ }
+ if (!dset.getString(6).isEmpty())
+ {
+ fws.print(" " + dset.getString(6));
+ }
+ isFirst = false;
+ }
+ if (keys.containsKey("PRI"))
+ {
+ fws.println(",");
+ fws.print("\tPRIMARY KEY (");
+ isFirst = true;
+ for (String key : keys.get("PRI"))
+ {
+ if (!isFirst)
+ {
+ fws.print(", ");
+ }
+ fws.print("`" + key + "`");
+ isFirst = false;
+ }
+ fws.print(")");
+ }
+ if (keys.containsKey("MUL"))
+ {
+ fws.println(",");
+ isFirst = true;
+ for (String key : keys.get("MUL"))
+ {
+ if (!isFirst)
+ {
+ fws.println(", ");
+ }
+ fws.print("\tKEY `key_" + key + "` (`" + key + "`)");
+ isFirst = false;
+ }
+ }
+ fws.println();
+ fws.println(");");
+ fws.flush();
+ }
+
+ try (Statement desc = con.createStatement();
+ ResultSet dset = desc.executeQuery("SELECT * FROM " + rset.getString(1)))
+ {
+ boolean isFirst = true;
+ int cnt = 0;
+ while (dset.next())
+ {
+ if ((cnt % 100) == 0)
+ {
+ fws.println("INSERT INTO `" + rset.getString(1) + "` VALUES ");
+ }
+ else
+ {
+ fws.println(",");
+ }
+
+ fws.print("\t(");
+ boolean isInFirst = true;
+ for (int i = 1; i <= dset.getMetaData().getColumnCount(); i++)
+ {
+ if (!isInFirst)
+ {
+ fws.print(", ");
+ }
+
+ if (dset.getString(i) == null)
+ {
+ fws.print("NULL");
+ }
+ else
+ {
+ fws.print("'" + dset.getString(i).replace("\'", "\\\'") + "'");
+ }
+ isInFirst = false;
+ }
+ fws.print(")");
+ isFirst = false;
+
+ if ((cnt % 100) == 99)
+ {
+ fws.println(";");
+ }
+ cnt++;
+ }
+ if (!isFirst && ((cnt % 100) != 0))
+ {
+ fws.println(";");
+ }
+ fws.println();
+ fws.flush();
+ }
+ }
+ fws.flush();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ _frame.appendToProgressArea("Dump Complete!");
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/MySqlConnect.java b/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/MySqlConnect.java
new file mode 100644
index 0000000000..cfd12bd926
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/MySqlConnect.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.util.mysql;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Formatter;
+
+import javax.swing.JOptionPane;
+
+/**
+ * @author mrTJO
+ */
+public class MySqlConnect
+{
+ Connection con = null;
+
+ public MySqlConnect(String host, String port, String user, String password, String db, boolean console)
+ {
+ try (Formatter form = new Formatter())
+ {
+ Class.forName("com.mysql.jdbc.Driver").newInstance();
+ final String formattedText = form.format("jdbc:mysql://%1$s:%2$s", host, port).toString();
+ con = DriverManager.getConnection(formattedText, user, password);
+
+ try (Statement s = con.createStatement())
+ {
+ s.execute("CREATE DATABASE IF NOT EXISTS `" + db + "`");
+ s.execute("USE `" + db + "`");
+ }
+ }
+ catch (SQLException e)
+ {
+ if (console)
+ {
+ e.printStackTrace();
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(null, "MySQL Error: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ catch (InstantiationException e)
+ {
+ if (console)
+ {
+ e.printStackTrace();
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(null, "Instantiation Exception: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ if (console)
+ {
+ e.printStackTrace();
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(null, "Illegal Access: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ if (console)
+ {
+ e.printStackTrace();
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(null, "Cannot find MySQL Connector: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public Connection getConnection()
+ {
+ return con;
+ }
+
+ public Statement getStatement()
+ {
+ try
+ {
+ return con.createStatement();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ System.out.println("Statement Null");
+ return null;
+ }
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/ScriptExecutor.java b/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/ScriptExecutor.java
new file mode 100644
index 0000000000..3156ab9cc0
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/util/mysql/ScriptExecutor.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2004-2015 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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.
+ *
+ * L2J Server 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 .
+ */
+package com.l2jserver.tools.dbinstaller.util.mysql;
+
+import java.awt.HeadlessException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.Scanner;
+
+import javax.swing.JOptionPane;
+
+import com.l2jserver.tools.dbinstaller.DBOutputInterface;
+import com.l2jserver.util.file.filter.SQLFilter;
+
+/**
+ * @author mrTJO
+ */
+public class ScriptExecutor
+{
+ DBOutputInterface _frame;
+
+ public ScriptExecutor(DBOutputInterface frame)
+ {
+ _frame = frame;
+ }
+
+ public void execSqlBatch(File dir)
+ {
+ execSqlBatch(dir, false);
+ }
+
+ public void execSqlBatch(File dir, boolean skipErrors)
+ {
+ final File[] files = dir.listFiles(new SQLFilter());
+ if (files != null)
+ {
+ Arrays.sort(files);
+ _frame.setProgressIndeterminate(false);
+ _frame.setProgressMaximum(files.length - 1);
+ for (int i = 0; i < files.length; i++)
+ {
+ _frame.setProgressValue(i);
+ execSqlFile(files[i], skipErrors);
+ }
+ }
+ }
+
+ public void execSqlFile(File file)
+ {
+ execSqlFile(file, false);
+ }
+
+ public void execSqlFile(File file, boolean skipErrors)
+ {
+ _frame.appendToProgressArea("Installing " + file.getName());
+ String line = "";
+ Connection con = _frame.getConnection();
+ try (Statement stmt = con.createStatement();
+ Scanner scn = new Scanner(file))
+ {
+ StringBuilder sb = new StringBuilder();
+ while (scn.hasNextLine())
+ {
+ line = scn.nextLine();
+ if (line.startsWith("--"))
+ {
+ continue;
+ }
+ else if (line.contains("--"))
+ {
+ line = line.split("--")[0];
+ }
+
+ line = line.trim();
+ if (!line.isEmpty())
+ {
+ sb.append(line + System.getProperty("line.separator"));
+ }
+
+ if (line.endsWith(";"))
+ {
+ stmt.execute(sb.toString());
+ sb = new StringBuilder();
+ }
+ }
+ }
+ catch (FileNotFoundException e)
+ {
+ JOptionPane.showMessageDialog(null, "File Not Found!: " + e.getMessage(), "Installer Error", JOptionPane.ERROR_MESSAGE);
+ }
+ catch (SQLException e)
+ {
+ if (!skipErrors)
+ {
+ try
+ {
+ Object[] options =
+ {
+ "Continue",
+ "Abort"
+ };
+
+ int n = JOptionPane.showOptionDialog(null, "MySQL Error: " + e.getMessage(), "Script Error", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
+ if (n == 1)
+ {
+ System.exit(0);
+ }
+ }
+ catch (HeadlessException h)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git a/trunk/java/com/l2jserver/tools/dbinstaller/util/swing/SpringUtilities.java b/trunk/java/com/l2jserver/tools/dbinstaller/util/swing/SpringUtilities.java
new file mode 100644
index 0000000000..9644555e55
--- /dev/null
+++ b/trunk/java/com/l2jserver/tools/dbinstaller/util/swing/SpringUtilities.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle or the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.l2jserver.tools.dbinstaller.util.swing;
+
+import java.awt.Component;
+import java.awt.Container;
+
+import javax.swing.Spring;
+import javax.swing.SpringLayout;
+
+/**
+ * A 1.4 file that provides utility methods for creating form- or grid-style layouts with SpringLayout.
+ * These utilities are used by several programs, such as SpringBox and SpringCompactGrid.
+ */
+public class SpringUtilities
+{
+ /**
+ * A debugging utility that prints to stdout the component's minimum, preferred, and maximum sizes.
+ * @param c
+ */
+ public static void printSizes(Component c)
+ {
+ System.out.println("minimumSize = " + c.getMinimumSize());
+ System.out.println("preferredSize = " + c.getPreferredSize());
+ System.out.println("maximumSize = " + c.getMaximumSize());
+ }
+
+ /**
+ * Aligns the first rows
* cols
components of parent
in a grid. Each component is as big as the maximum preferred width and height of the components. The parent is made just big enough to fit them all.
+ * @param parent
+ * @param rows number of rows
+ * @param cols number of columns
+ * @param initialX x location to start the grid at
+ * @param initialY y location to start the grid at
+ * @param xPad x padding between cells
+ * @param yPad y padding between cells
+ */
+ public static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
+ {
+ SpringLayout layout;
+ try
+ {
+ layout = (SpringLayout) parent.getLayout();
+ }
+ catch (ClassCastException exc)
+ {
+ System.err.println("The first argument to makeGrid must use SpringLayout.");
+ return;
+ }
+
+ Spring xPadSpring = Spring.constant(xPad);
+ Spring yPadSpring = Spring.constant(yPad);
+ Spring initialXSpring = Spring.constant(initialX);
+ Spring initialYSpring = Spring.constant(initialY);
+ int max = rows * cols;
+
+ // Calculate Springs that are the max of the width/height so that all
+ // cells have the same size.
+ Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
+ Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
+ for (int i = 1; i < max; i++)
+ {
+ SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
+
+ maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
+ maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
+ }
+
+ // Apply the new width/height Spring. This forces all the
+ // components to have the same size.
+ for (int i = 0; i < max; i++)
+ {
+ SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
+
+ cons.setWidth(maxWidthSpring);
+ cons.setHeight(maxHeightSpring);
+ }
+
+ // Then adjust the x/y constraints of all the cells so that they
+ // are aligned in a grid.
+ SpringLayout.Constraints lastCons = null;
+ SpringLayout.Constraints lastRowCons = null;
+ for (int i = 0; i < max; i++)
+ {
+ SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
+ if ((i % cols) == 0)
+ { // start of new row
+ lastRowCons = lastCons;
+ cons.setX(initialXSpring);
+ }
+ else
+ {
+ // x position depends on previous component
+ if (lastCons != null)
+ {
+ cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring));
+ }
+ }
+
+ if ((i / cols) == 0)
+ {
+ // first row
+ cons.setY(initialYSpring);
+ }
+ else
+ {
+ // y position depends on previous row
+ if (lastRowCons != null)
+ {
+ cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring));
+ }
+ }
+ lastCons = cons;
+ }
+
+ // Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ if (lastCons != null)
+ {
+ pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
+ pCons.setConstraint(SpringLayout.EAST, Spring.sum(Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)));
+ }
+ }
+
+ /* Used by makeCompactGrid. */
+ private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols)
+ {
+ SpringLayout layout = (SpringLayout) parent.getLayout();
+ Component c = parent.getComponent((row * cols) + col);
+ return layout.getConstraints(c);
+ }
+
+ /**
+ * Aligns the first rows
* cols
components of parent
in a grid. Each component in a column is as wide as the maximum preferred width of the components in that column; height is similarly determined for each row. The parent is made just big enough to fit
+ * them all.
+ * @param parent
+ * @param rows number of rows
+ * @param cols number of columns
+ * @param initialX x location to start the grid at
+ * @param initialY y location to start the grid at
+ * @param xPad x padding between cells
+ * @param yPad y padding between cells
+ */
+ public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
+ {
+ SpringLayout layout;
+ try
+ {
+ layout = (SpringLayout) parent.getLayout();
+ }
+ catch (ClassCastException exc)
+ {
+ System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
+ return;
+ }
+
+ // Align all cells in each column and make them the same width.
+ Spring x = Spring.constant(initialX);
+ for (int c = 0; c < cols; c++)
+ {
+ Spring width = Spring.constant(0);
+ for (int r = 0; r < rows; r++)
+ {
+ width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
+ }
+ for (int r = 0; r < rows; r++)
+ {
+ SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
+ constraints.setX(x);
+ constraints.setWidth(width);
+ }
+ x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
+ }
+
+ // Align all cells in each row and make them the same height.
+ Spring y = Spring.constant(initialY);
+ for (int r = 0; r < rows; r++)
+ {
+ Spring height = Spring.constant(0);
+ for (int c = 0; c < cols; c++)
+ {
+ height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
+ }
+ for (int c = 0; c < cols; c++)
+ {
+ SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
+ constraints.setY(y);
+ constraints.setHeight(height);
+ }
+ y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
+ }
+
+ // Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ pCons.setConstraint(SpringLayout.SOUTH, y);
+ pCons.setConstraint(SpringLayout.EAST, x);
+ }
+}