From 658fb2a49848bcb3199c3b0fdfe9239e736636e9 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Tue, 16 Apr 2024 19:26:47 -0300 Subject: [PATCH 01/18] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20new=20branch=20?= =?UTF-8?q?to=20work=20with=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README.md | 57 ++++ Servers/Dockerfile | 10 + docker-compose.yml | 46 +++ sql/main.sql | 86 ----- sql/update-2017-09-01_1.sql | 1 - sql/update-2017-09-02_1.sql | 10 - sql/update-2017-09-04_1.sql | 3 - sql/update-2017-09-12_1.sql | 17 - sql/update-2017-09-14_1.sql | 14 - sql/update-2017-09-19_1.sql | 8 - sql/update-2017-09-19_2.sql | 2 - sql/update-2017-09-19_3.sql | 18 - sql/update-2017-09-25_1.sql | 15 - sql/update-2017-09-26_1.sql | 1 - sql/update-2017-09-28_1.sql | 1 - sql/update-2017-09-29_1.sql | 1 - sql/update-2017-10-31_1.sql | 13 - sql/update-2021-09-08_1.sql | 1 - sql/update-2021-09-14_1.sql | 1 - sql/update-2021-09-28_1.sql | 19 -- sql/update-2021-10-07_1.sql | 2 - sql/update-2021-10-07_2.sql | 1 - sql/update-2021-10-13_1.sql | 23 -- sql/update-2023-05-10_1.sql | 1 - sql/update-2023-05-11_1.sql | 1 - sql/update-2023-05-21_1.sql | 8 - sql/update-2023-05-22_1.sql | 3 - sql/update-2023-05-22_2.sql | 4 - sql/update-2023-05-23_1.sql | 2 - sql/update-2023-05-25_1.sql | 1 - sql/update-2023-05-25_2.sql | 1 - sql/update-2023-05-29_1.sql | 4 - sql/update-2023-05-31_1.sql | 2 - sql/update-2023-05-31_2.sql | 1 - sql/update-2023-06-01_1.sql | 1 - sql/update-2023-06-02_1.sql | 1 - sql/update-2023-06-03_1.sql | 67 ---- sql/update-2023-06-03_2.sql | 18 - sql/update-2023-06-26_1.sql | 18 - sql/update-2023-06-27_1.sql | 17 - sql/update-2023-06-30_1.sql | 34 -- sql/update-2023-07-03_1.sql | 6 - sql/update-2023-07-03_2.sql | 1 - sql/update-2023-07-12_1.sql | 3 - sql/update-2023-07-15_1.sql | 17 - sql/update-2024-03-11_1.sql | 1 - sql/update_2015-08-17_1.sql | 1 - sql/update_2015-08-17_2.sql | 2 - sql/update_2015-08-17_3.sql | 1 - sql/update_2015-08-20_1.sql | 10 - sql/update_2015-08-20_2.sql | 2 - sql/update_2015-08-27_1.sql | 1 - sql/update_2015-09-03_1.sql | 1 - sql/update_2015-09-16_1.sql | 3 - sql/update_2015-12-12_1.sql | 3 - sql/update_2016-04-01_1.sql | 1 - sql/update_2016-04-02_1.sql | 2 - sql/update_2016-04-03_1.sql | 19 -- sql/update_2016-04-11_1.sql | 8 - sql/update_2016-04-23_1.sql | 1 - sql/update_2017-09-03_1.sql | 10 - sql_start/Merge_All_SQLs.sql | 469 ++++++++++++++++++++++++++ src/BarracksServer/BarracksServer.cs | 8 +- src/Shared/Configuration/Files/Web.cs | 2 +- src/WebServer/WebServer.cs | 11 +- src/ZoneServer/ZoneServer.cs | 8 +- start | 56 +++ stop | 7 + system/conf/database.conf | 4 +- system/conf/web.conf | 2 +- 71 files changed, 666 insertions(+), 530 deletions(-) create mode 100644 Servers/Dockerfile create mode 100644 docker-compose.yml delete mode 100644 sql/main.sql delete mode 100644 sql/update-2017-09-01_1.sql delete mode 100644 sql/update-2017-09-02_1.sql delete mode 100644 sql/update-2017-09-04_1.sql delete mode 100644 sql/update-2017-09-12_1.sql delete mode 100644 sql/update-2017-09-14_1.sql delete mode 100644 sql/update-2017-09-19_1.sql delete mode 100644 sql/update-2017-09-19_2.sql delete mode 100644 sql/update-2017-09-19_3.sql delete mode 100644 sql/update-2017-09-25_1.sql delete mode 100644 sql/update-2017-09-26_1.sql delete mode 100644 sql/update-2017-09-28_1.sql delete mode 100644 sql/update-2017-09-29_1.sql delete mode 100644 sql/update-2017-10-31_1.sql delete mode 100644 sql/update-2021-09-08_1.sql delete mode 100644 sql/update-2021-09-14_1.sql delete mode 100644 sql/update-2021-09-28_1.sql delete mode 100644 sql/update-2021-10-07_1.sql delete mode 100644 sql/update-2021-10-07_2.sql delete mode 100644 sql/update-2021-10-13_1.sql delete mode 100644 sql/update-2023-05-10_1.sql delete mode 100644 sql/update-2023-05-11_1.sql delete mode 100644 sql/update-2023-05-21_1.sql delete mode 100644 sql/update-2023-05-22_1.sql delete mode 100644 sql/update-2023-05-22_2.sql delete mode 100644 sql/update-2023-05-23_1.sql delete mode 100644 sql/update-2023-05-25_1.sql delete mode 100644 sql/update-2023-05-25_2.sql delete mode 100644 sql/update-2023-05-29_1.sql delete mode 100644 sql/update-2023-05-31_1.sql delete mode 100644 sql/update-2023-05-31_2.sql delete mode 100644 sql/update-2023-06-01_1.sql delete mode 100644 sql/update-2023-06-02_1.sql delete mode 100644 sql/update-2023-06-03_1.sql delete mode 100644 sql/update-2023-06-03_2.sql delete mode 100644 sql/update-2023-06-26_1.sql delete mode 100644 sql/update-2023-06-27_1.sql delete mode 100644 sql/update-2023-06-30_1.sql delete mode 100644 sql/update-2023-07-03_1.sql delete mode 100644 sql/update-2023-07-03_2.sql delete mode 100644 sql/update-2023-07-12_1.sql delete mode 100644 sql/update-2023-07-15_1.sql delete mode 100644 sql/update-2024-03-11_1.sql delete mode 100644 sql/update_2015-08-17_1.sql delete mode 100644 sql/update_2015-08-17_2.sql delete mode 100644 sql/update_2015-08-17_3.sql delete mode 100644 sql/update_2015-08-20_1.sql delete mode 100644 sql/update_2015-08-20_2.sql delete mode 100644 sql/update_2015-08-27_1.sql delete mode 100644 sql/update_2015-09-03_1.sql delete mode 100644 sql/update_2015-09-16_1.sql delete mode 100644 sql/update_2015-12-12_1.sql delete mode 100644 sql/update_2016-04-01_1.sql delete mode 100644 sql/update_2016-04-02_1.sql delete mode 100644 sql/update_2016-04-03_1.sql delete mode 100644 sql/update_2016-04-11_1.sql delete mode 100644 sql/update_2016-04-23_1.sql delete mode 100644 sql/update_2017-09-03_1.sql create mode 100644 sql_start/Merge_All_SQLs.sql create mode 100755 start create mode 100755 stop diff --git a/.gitignore b/.gitignore index 08e27d1a8..f1ff7f5df 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ /log/ /logs/ /cache/ - +/.mysql/ /user/** !/user/conf/database-example.conf diff --git a/README.md b/README.md index da5d3e4a1..e85e65fb9 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,63 @@ with any services provided by game developers or publishers, and we don't endorse such actions. We're here to learn and create, not to steal or destroy. +Docker +----------------------------------------------------------------------------- + +This repository aims to make Melia easier to setup and run in any environment. +To achieve this, we're making a few changes do add the capability of building +and running Melia on Linux, as well as building and running the server in a +few Docker containers. + +For this to work, you will need [Docker](https://docs.docker.com/) installed +on your system. Recent versions of Docker comes with [Docker Compose](https://docs.docker.com/compose/) +pre-installed, so you don't have to worry about it. + +After cloning or downloading this repository, navigate to the project folder +(where you'll find `docker-compose.yml` ) and run: + +``` +docker compose build +``` + +This will download the necessary Docker Images for our project to run and +build a new image with `/server/Dockerfile`, where our server dependencies +are listed. + +Now, you can run: +``` +docker compose run --rm melia-server dotnet build +``` + +This will create our server binaries, making it ready to start with our next +command: +``` +docker compose up -d +``` + +Wait for a few seconds for everything to initialize. Then, you can go to your +browser and access [http://127.0.0.1/toslive/patch/serverlist.xml] to check +if server is up and running. + +You can restart server if anything goes wrong using: +``` +docker compose restart +``` + +If you change anything on source code, you need to run +`docker compose run --rm melia-server dotnet build` again and restart your +server with `docker compose restart` + + +Database +----------------------------------------------------------------------------- + +With the Docker containers, we've added a PHPMyAdmin container, which can be +accessed via [http://127.0.0.1:8080]. Default user is `root` and password +is `123456` (You can change password on `docker-compose.yml`, but remember +to change on source files as well). + + Client ----------------------------------------------------------------------------- diff --git a/Servers/Dockerfile b/Servers/Dockerfile new file mode 100644 index 000000000..164783240 --- /dev/null +++ b/Servers/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:22.04 +ARG DEBIAN_FRONTEND=noninteractive + +WORKDIR / + +RUN apt update -y && apt upgrade -y && apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0 git php libapache2-mod-php php-cgi php-mysql + +WORKDIR /melia + +CMD ["./start", "Debug", "BarracksServer"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..c172d8357 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +name: "melia" +services: + melia-database: + container_name: melia-database + image: mysql:8.3 + networks: + - melia-network + ports: + - 3306:3306 + environment: + - MYSQL_ROOT_PASSWORD=123456 # Change to secure password + volumes: + - ./sql_start:/docker-entrypoint-initdb.d + - ./.mysql/:/var/lib/mysql + restart: unless-stopped + melia-server: + container_name: melia-server + command: "./start Debug" + build: "./Servers" + networks: + - melia-network + volumes: + - ./:/melia + depends_on: + - melia-database + ports: + - "2000:2000" + - "6001:6001" + - "7001:7001" + - "7002:7002" + - "80:80" + phpmyadmin: + container_name: melia-dbadmin + networks: + - melia-network + image: phpmyadmin + ports: + - 8080:80 + environment: + - PMA_HOST=melia-database + - PMA_USER=root + - PMA_PASSWORD=123456 # Change to secure password (Same as before) + - UPLOAD_LIMIT=300M + profiles: [] +networks: + melia-network: diff --git a/sql/main.sql b/sql/main.sql deleted file mode 100644 index 253f7b803..000000000 --- a/sql/main.sql +++ /dev/null @@ -1,86 +0,0 @@ -CREATE DATABASE IF NOT EXISTS `melia` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -USE `melia`; - -CREATE TABLE IF NOT EXISTS `accounts` ( - `accountId` bigint(20) NOT NULL AUTO_INCREMENT, - `name` varchar(32) NOT NULL, - `password` varchar(32) NOT NULL, - `teamName` varchar(64) DEFAULT NULL, - `authority` int(11) NOT NULL DEFAULT '0', - `settings` varchar(512) NOT NULL DEFAULT '', - PRIMARY KEY (`accountId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `characters` ( - `characterId` bigint(20) NOT NULL AUTO_INCREMENT, - `accountId` bigint(20) NOT NULL, - `name` varchar(64) NOT NULL, - `teamName` varchar(32) DEFAULT NULL, - `job` smallint(6) NOT NULL, - `gender` tinyint(4) NOT NULL, - `hair` tinyint(4) NOT NULL, - `level` int(11) NOT NULL DEFAULT '1', - `bx` float NOT NULL, - `by` float NOT NULL, - `bz` float NOT NULL, - `zone` int(11) NOT NULL, - `x` float NOT NULL, - `y` float NOT NULL, - `z` float NOT NULL, - `exp` int(11) NOT NULL DEFAULT '0', - `maxExp` int(11) NOT NULL DEFAULT '1000', - `hp` int(11) NOT NULL DEFAULT '100', - `maxHp` int(11) NOT NULL DEFAULT '100', - `sp` int(11) NOT NULL DEFAULT '50', - `maxSp` int(11) NOT NULL DEFAULT '50', - `stamina` int(11) NOT NULL DEFAULT '25000', - `maxStamina` int(11) NOT NULL DEFAULT '25000', - `str` float NOT NULL DEFAULT '1', - `con` float NOT NULL DEFAULT '1', - `int` float NOT NULL DEFAULT '1', - `spr` float NOT NULL DEFAULT '1', - `dex` float NOT NULL DEFAULT '1', - `statByLevel` float NOT NULL DEFAULT '0', - `statByBonus` float NOT NULL DEFAULT '0', - `usedStat` float NOT NULL DEFAULT '0', - PRIMARY KEY (`characterId`), - KEY `accountId` (`accountId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `items` ( - `itemUniqueId` bigint(20) NOT NULL AUTO_INCREMENT, - `characterId` bigint(11) NOT NULL, - `itemId` int(11) NOT NULL, - `amount` int(11) NOT NULL, - `sort` int(11) NOT NULL, - `equipSlot` tinyint(4) NOT NULL DEFAULT '127', - PRIMARY KEY (`itemUniqueId`), - KEY `characterId` (`characterId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `updates` ( - `path` varchar(255) NOT NULL, - PRIMARY KEY (`path`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -INSERT INTO `updates` (`path`) VALUES -('main.sql'), -('update_2015-08-17_1.sql'), -('update_2015-08-17_2.sql'), -('update_2015-08-17_3.sql'), -('update_2015-08-20_1.sql'), -('update_2015-08-20_2.sql'), -('update_2015-08-27_1.sql'), -('update_2015-09-03_1.sql'), -('update_2015-09-16_1.sql'), -('update_2015-12-12_1.sql'), -('update_2016-04-01_1.sql'), -('update_2016-04-02_1.sql'), -('update_2016-04-03_1.sql'); - - -ALTER TABLE `characters` - ADD CONSTRAINT `characters_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `items` - ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-01_1.sql b/sql/update-2017-09-01_1.sql deleted file mode 100644 index 57e4b01dd..000000000 --- a/sql/update-2017-09-01_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD COLUMN `barrackLayer` INT NOT NULL DEFAULT 1; \ No newline at end of file diff --git a/sql/update-2017-09-02_1.sql b/sql/update-2017-09-02_1.sql deleted file mode 100644 index ed4ac498f..000000000 --- a/sql/update-2017-09-02_1.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE IF NOT EXISTS `chatmacros` ( - `chatMacroId` bigint(20) NOT NULL AUTO_INCREMENT, - `accountId` bigint(20) NOT NULL, - `index` tinyint(4) NOT NULL, - `message` varchar(128) NOT NULL, - `pose` tinyint(4) NOT NULL DEFAULT 0, - PRIMARY KEY (`chatMacroId`), - CONSTRAINT `FK_ChatMacro_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, - CONSTRAINT `UQ_ChatMacro_index` UNIQUE (`accountId`, `index`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; diff --git a/sql/update-2017-09-04_1.sql b/sql/update-2017-09-04_1.sql deleted file mode 100644 index 8f79562f3..000000000 --- a/sql/update-2017-09-04_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `accounts` ADD `medals` INT NOT NULL DEFAULT 0; -ALTER TABLE `accounts` ADD `giftMedals` INT NOT NULL DEFAULT 0; -ALTER TABLE `accounts` ADD `premiumMedals` INT NOT NULL DEFAULT 0; diff --git a/sql/update-2017-09-12_1.sql b/sql/update-2017-09-12_1.sql deleted file mode 100644 index e57a097e4..000000000 --- a/sql/update-2017-09-12_1.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE `session_objects_properties` ( - `sessionObjectPropertyId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `sessionObjectId` int(11) NOT NULL, - `propertyId` int(11) NOT NULL, - `value` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `session_objects_properties` - ADD PRIMARY KEY (`sessionObjectPropertyId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `session_objects_properties` - MODIFY `sessionObjectPropertyId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `session_objects_properties` - ADD CONSTRAINT `session_object_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-14_1.sql b/sql/update-2017-09-14_1.sql deleted file mode 100644 index 07276ff20..000000000 --- a/sql/update-2017-09-14_1.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE `jobs` ( - `characterId` bigint(20) NOT NULL, - `jobId` int(11) NOT NULL, - `circle` int(11) NOT NULL DEFAULT '1', - `skillPoints` int(11) NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `jobs` - ADD PRIMARY KEY (`characterId`,`jobId`); - - -ALTER TABLE `jobs` - ADD CONSTRAINT `jobs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-19_1.sql b/sql/update-2017-09-19_1.sql deleted file mode 100644 index c922d7849..000000000 --- a/sql/update-2017-09-19_1.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE `characters` CHANGE `str` `str` INT NOT NULL DEFAULT '1', - CHANGE `con` `con` INT NOT NULL DEFAULT '1', - CHANGE `int` `int` INT NOT NULL DEFAULT '1', - CHANGE `spr` `spr` INT NOT NULL DEFAULT '1', - CHANGE `dex` `dex` INT NOT NULL DEFAULT '1', - CHANGE `statByLevel` `statByLevel` INT NOT NULL DEFAULT '0', - CHANGE `statByBonus` `statByBonus` INT NOT NULL DEFAULT '0', - CHANGE `usedStat` `usedStat` INT NOT NULL DEFAULT '0'; diff --git a/sql/update-2017-09-19_2.sql b/sql/update-2017-09-19_2.sql deleted file mode 100644 index 49b1c849c..000000000 --- a/sql/update-2017-09-19_2.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `characters` CHANGE `barrackLayer` `barrackLayer` INT(11) NOT NULL DEFAULT '1' AFTER `level`; -ALTER TABLE `characters` ADD `abilityPoints` INT NOT NULL DEFAULT '0' AFTER `usedStat`; diff --git a/sql/update-2017-09-19_3.sql b/sql/update-2017-09-19_3.sql deleted file mode 100644 index 8af9845e6..000000000 --- a/sql/update-2017-09-19_3.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE `skills` ( - `skillId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `id` int(11) NOT NULL, - `level` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `skills` - ADD PRIMARY KEY (`skillId`), - ADD KEY `characterId` (`characterId`); - - -ALTER TABLE `skills` - MODIFY `skillId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `skills` - ADD CONSTRAINT `skills_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-25_1.sql b/sql/update-2017-09-25_1.sql deleted file mode 100644 index 04365f4e9..000000000 --- a/sql/update-2017-09-25_1.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE `abilities` ( - `abilityId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `id` int(11) NOT NULL, - `level` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `abilities` - ADD PRIMARY KEY (`abilityId`), - ADD KEY `characterId` (`characterId`); - - -ALTER TABLE `abilities` - MODIFY `abilityId` bigint(20) NOT NULL AUTO_INCREMENT; diff --git a/sql/update-2017-09-26_1.sql b/sql/update-2017-09-26_1.sql deleted file mode 100644 index 70809b73a..000000000 --- a/sql/update-2017-09-26_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-28_1.sql b/sql/update-2017-09-28_1.sql deleted file mode 100644 index e5c876f95..000000000 --- a/sql/update-2017-09-28_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `maxExp`; diff --git a/sql/update-2017-09-29_1.sql b/sql/update-2017-09-29_1.sql deleted file mode 100644 index 33f8a360e..000000000 --- a/sql/update-2017-09-29_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `jobs` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `skillPoints`; diff --git a/sql/update-2017-10-31_1.sql b/sql/update-2017-10-31_1.sql deleted file mode 100644 index f1d51e9c9..000000000 --- a/sql/update-2017-10-31_1.sql +++ /dev/null @@ -1,13 +0,0 @@ -ALTER TABLE `characters` ADD `hpRate` FLOAT NOT NULL DEFAULT '1' AFTER `hp`, - ADD `spRate` FLOAT NOT NULL DEFAULT '1' AFTER `sp`, - ADD `strByJob` INT NOT NULL DEFAULT '0' AFTER `str`, - ADD `conByJob` INT NOT NULL DEFAULT '0' AFTER `con`, - ADD `intByJob` INT NOT NULL DEFAULT '0' AFTER `int`, - ADD `sprByJob` INT NOT NULL DEFAULT '0' AFTER `spr`, - ADD `dexByJob` INT NOT NULL DEFAULT '0' AFTER `dex`, - ADD `staminaByJob` INT NOT NULL DEFAULT '0' AFTER `stamina`, - CHANGE `str` `str` INT NOT NULL DEFAULT '0', - CHANGE `con` `con` INT NOT NULL DEFAULT '0', - CHANGE `int` `int` INT NOT NULL DEFAULT '0', - CHANGE `spr` `spr` INT NOT NULL DEFAULT '0', - CHANGE `dex` `dex` INT NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/sql/update-2021-09-08_1.sql b/sql/update-2021-09-08_1.sql deleted file mode 100644 index e11d579aa..000000000 --- a/sql/update-2021-09-08_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` CHANGE `hair` `hair` INT NOT NULL; diff --git a/sql/update-2021-09-14_1.sql b/sql/update-2021-09-14_1.sql deleted file mode 100644 index b90c58e80..000000000 --- a/sql/update-2021-09-14_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `slot` INT NOT NULL AFTER `level`; diff --git a/sql/update-2021-09-28_1.sql b/sql/update-2021-09-28_1.sql deleted file mode 100644 index 2efa63286..000000000 --- a/sql/update-2021-09-28_1.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE `character_properties` ( - `propertyId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `id` int(11) NOT NULL, - `type` varchar(1) NOT NULL, - `value` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `character_properties` - ADD PRIMARY KEY (`propertyId`), - ADD KEY `characterId` (`characterId`); - - -ALTER TABLE `character_properties` - MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `character_properties` - ADD CONSTRAINT `character_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2021-10-07_1.sql b/sql/update-2021-10-07_1.sql deleted file mode 100644 index f887cc759..000000000 --- a/sql/update-2021-10-07_1.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `accounts` ADD `additionalSlotCount` INT NOT NULL DEFAULT '0' AFTER `premiumMedals`; -ALTER TABLE `accounts` ADD `teamExp` INT NOT NULL DEFAULT '0' AFTER `additionalSlotCount`; diff --git a/sql/update-2021-10-07_2.sql b/sql/update-2021-10-07_2.sql deleted file mode 100644 index 51e2cfbe6..000000000 --- a/sql/update-2021-10-07_2.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `silver` BIGINT NOT NULL DEFAULT '0' AFTER `abilityPoints`; diff --git a/sql/update-2021-10-13_1.sql b/sql/update-2021-10-13_1.sql deleted file mode 100644 index e1025cf06..000000000 --- a/sql/update-2021-10-13_1.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE `inventory` ( - `characterId` bigint(20) NOT NULL, - `itemId` bigint(20) NOT NULL, - `sort` int(11) NOT NULL, - `equipSlot` tinyint(4) NOT NULL DEFAULT '127' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TRIGGER `cascadeDeleteItem` AFTER DELETE ON `inventory` FOR EACH ROW - DELETE FROM `items` WHERE `itemUniqueId` = OLD.`itemId`; - -ALTER TABLE `inventory` - ADD PRIMARY KEY (`characterId`,`itemId`), - ADD KEY `itemId` (`itemId`); - -ALTER TABLE `inventory` - ADD CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; - -INSERT INTO `inventory` (SELECT `characterId`, `itemUniqueId` AS `itemId`, `sort`, `equipSlot` FROM `items`); -ALTER TABLE `items` DROP FOREIGN KEY `items_ibfk_1`; -ALTER TABLE `items` DROP `characterId`; -ALTER TABLE `items` DROP `sort`; -ALTER TABLE `items` DROP `equipSlot`; diff --git a/sql/update-2023-05-10_1.sql b/sql/update-2023-05-10_1.sql deleted file mode 100644 index 525a117c1..000000000 --- a/sql/update-2023-05-10_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` CHANGE `settings` `settings` VARCHAR(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; diff --git a/sql/update-2023-05-11_1.sql b/sql/update-2023-05-11_1.sql deleted file mode 100644 index dbab81bfb..000000000 --- a/sql/update-2023-05-11_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `jobs` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-05-21_1.sql b/sql/update-2023-05-21_1.sql deleted file mode 100644 index 040bb7024..000000000 --- a/sql/update-2023-05-21_1.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELETE FROM `character_properties` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); -DELETE FROM `skills` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); - -ALTER TABLE `character_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `chatmacros` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `revealedmaps` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `session_objects_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `skills` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-05-22_1.sql b/sql/update-2023-05-22_1.sql deleted file mode 100644 index ec6c30e35..000000000 --- a/sql/update-2023-05-22_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `character_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `id`; -UPDATE `character_properties` SET `name` = CAST(`id` AS CHAR(64)); -ALTER TABLE `character_properties` DROP `id`; diff --git a/sql/update-2023-05-22_2.sql b/sql/update-2023-05-22_2.sql deleted file mode 100644 index c35a351df..000000000 --- a/sql/update-2023-05-22_2.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `session_objects_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `propertyId`; -ALTER TABLE `session_objects_properties` ADD `type` VARCHAR(1) NOT NULL AFTER `name`; -UPDATE `session_objects_properties` SET `name` = CAST(`propertyId` AS CHAR(64)); -ALTER TABLE `session_objects_properties` DROP `propertyId`; diff --git a/sql/update-2023-05-23_1.sql b/sql/update-2023-05-23_1.sql deleted file mode 100644 index 1388ed259..000000000 --- a/sql/update-2023-05-23_1.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `characters` ADD `bd` FLOAT NOT NULL AFTER `bz`; -UPDATE `characters` SET `bd` = FLOOR(RAND() * 180); diff --git a/sql/update-2023-05-25_1.sql b/sql/update-2023-05-25_1.sql deleted file mode 100644 index 32be3999d..000000000 --- a/sql/update-2023-05-25_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` ADD `barracksThema` INT NOT NULL DEFAULT '11' AFTER `teamExp`; diff --git a/sql/update-2023-05-25_2.sql b/sql/update-2023-05-25_2.sql deleted file mode 100644 index 1b9e6155a..000000000 --- a/sql/update-2023-05-25_2.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` ADD `themas` VARCHAR(128) NOT NULL DEFAULT '11' AFTER `barracksThema`; diff --git a/sql/update-2023-05-29_1.sql b/sql/update-2023-05-29_1.sql deleted file mode 100644 index feeede46b..000000000 --- a/sql/update-2023-05-29_1.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `characters` CHANGE `exp` `exp` BIGINT NOT NULL DEFAULT '0', - CHANGE `maxExp` `maxExp` BIGINT NOT NULL DEFAULT '1000', - CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; -ALTER TABLE `jobs` CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; diff --git a/sql/update-2023-05-31_1.sql b/sql/update-2023-05-31_1.sql deleted file mode 100644 index 2d3e796aa..000000000 --- a/sql/update-2023-05-31_1.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE `vars` SET `name` = "Melia.PropertiesInitialized" WHERE `name` = "PropertiesInitialized"; -UPDATE `vars` SET `name` = "Melia.QuickSlotList" WHERE `name` = "_QuickSlotList"; diff --git a/sql/update-2023-05-31_2.sql b/sql/update-2023-05-31_2.sql deleted file mode 100644 index 9e76dc539..000000000 --- a/sql/update-2023-05-31_2.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM `vars` WHERE `name` = "Melia.QuickSlotList"; diff --git a/sql/update-2023-06-01_1.sql b/sql/update-2023-06-01_1.sql deleted file mode 100644 index b69fc551c..000000000 --- a/sql/update-2023-06-01_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` ADD `selectedSlot` TINYINT NOT NULL DEFAULT '0' AFTER `themas`; diff --git a/sql/update-2023-06-02_1.sql b/sql/update-2023-06-02_1.sql deleted file mode 100644 index 01df8c89a..000000000 --- a/sql/update-2023-06-02_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `equipVisibility` INT NOT NULL DEFAULT 0xFFFF AFTER `silver`; diff --git a/sql/update-2023-06-03_1.sql b/sql/update-2023-06-03_1.sql deleted file mode 100644 index 682fbaae0..000000000 --- a/sql/update-2023-06-03_1.sql +++ /dev/null @@ -1,67 +0,0 @@ -START TRANSACTION; - - --- Add new character vars table -CREATE TABLE `vars_characters` ( - `varId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `name` varchar(128) NOT NULL, - `type` char(2) NOT NULL, - `value` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; - -ALTER TABLE `vars_characters` - ADD PRIMARY KEY (`varId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `vars_characters` - MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `vars_characters` - ADD CONSTRAINT `vars_characters_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; - --- Remove variables of characters that don't exist anymore -DELETE FROM `vars` WHERE `owner` LIKE "character:%" AND SUBSTRING(`owner`, 11) NOT IN (SELECT `characterId` FROM `characters`); - --- Move remaining variables to new table -INSERT INTO `vars_characters` (`characterId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 11) AS `characterId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "character:%"; - --- Remove old vars -DELETE FROM `vars` WHERE `owner` LIKE "character:%"; - - --- Add new account vars table -CREATE TABLE `vars_accounts` ( - `varId` bigint(20) NOT NULL, - `accountId` bigint(20) NOT NULL, - `name` varchar(128) NOT NULL, - `type` char(2) NOT NULL, - `value` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; - -ALTER TABLE `vars_accounts` - ADD PRIMARY KEY (`varId`), - ADD KEY `accountId` (`accountId`); - -ALTER TABLE `vars_accounts` - MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `vars_accounts` - ADD CONSTRAINT `vars_accounts_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `characters` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; - --- Remove variables of characters that don't exist anymore -DELETE FROM `vars` WHERE `owner` LIKE "account:%" AND SUBSTRING(`owner`, 9) NOT IN (SELECT `accountId` FROM `characters`); - --- Move remaining variables to new table -INSERT INTO `vars_accounts` (`accountId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 9) AS `accountId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "account:%"; - --- Remove old vars -DELETE FROM `vars` WHERE `owner` LIKE "account:%"; - - --- Turn vars table in global vars -RENAME TABLE `vars` TO `vars_global`; -ALTER TABLE `vars_global` DROP `owner`; - - -COMMIT; diff --git a/sql/update-2023-06-03_2.sql b/sql/update-2023-06-03_2.sql deleted file mode 100644 index 892e64b19..000000000 --- a/sql/update-2023-06-03_2.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE `buffs` ( - `buffId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `classId` int(11) NOT NULL, - `numArg1` int(11) NOT NULL, - `numArg2` int(11) NOT NULL, - `remainingDuration` time NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `buffs` - ADD PRIMARY KEY (`buffId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `buffs` - MODIFY `buffId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `buffs` - ADD CONSTRAINT `buffs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-06-26_1.sql b/sql/update-2023-06-26_1.sql deleted file mode 100644 index 8eee1f5d1..000000000 --- a/sql/update-2023-06-26_1.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE `cooldowns` ( - `cooldownId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `classId` int(11) NOT NULL, - `remaining` time NOT NULL, - `duration` time NOT NULL, - `startTime` datetime NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `cooldowns` - ADD PRIMARY KEY (`cooldownId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `cooldowns` - MODIFY `cooldownId` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; - -ALTER TABLE `cooldowns` - ADD CONSTRAINT `cooldowns_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-06-27_1.sql b/sql/update-2023-06-27_1.sql deleted file mode 100644 index 9e5de6a0f..000000000 --- a/sql/update-2023-06-27_1.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE `vars_buffs` ( - `varId` bigint(20) NOT NULL, - `buffId` bigint(20) NOT NULL, - `name` varchar(128) NOT NULL, - `type` char(2) NOT NULL, - `value` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; - -ALTER TABLE `vars_buffs` - ADD PRIMARY KEY (`varId`), - ADD KEY `characterId` (`buffId`); - -ALTER TABLE `vars_buffs` - MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `vars_buffs` - ADD CONSTRAINT `vars_buffs_ibfk_1` FOREIGN KEY (`buffId`) REFERENCES `buffs` (`buffId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-06-30_1.sql b/sql/update-2023-06-30_1.sql deleted file mode 100644 index e4dcb671b..000000000 --- a/sql/update-2023-06-30_1.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE `quests` ( - `questId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `classId` int(11) NOT NULL, - `status` int(11) NOT NULL, - `startTime` datetime NOT NULL, - `completeTime` datetime NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TABLE `quests_progress` ( - `questId` bigint(20) NOT NULL, - `characterId` bigint(20) NOT NULL, - `ident` varchar(64) CHARACTER SET utf8mb4 NOT NULL, - `count` int(11) NOT NULL, - `done` tinyint(1) NOT NULL, - `unlocked` tinyint(1) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; - -ALTER TABLE `quests` - ADD PRIMARY KEY (`questId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `quests_progress` - ADD PRIMARY KEY (`questId`,`ident`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `quests` - MODIFY `questId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `quests` - ADD CONSTRAINT `quests_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `quests_progress` - ADD CONSTRAINT `quests_progress_ibfk_1` FOREIGN KEY (`questId`) REFERENCES `quests` (`questId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-07-03_1.sql b/sql/update-2023-07-03_1.sql deleted file mode 100644 index af7019c1d..000000000 --- a/sql/update-2023-07-03_1.sql +++ /dev/null @@ -1,6 +0,0 @@ -START TRANSACTION; - -DELETE FROM `abilities` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); -ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; - -COMMIT; diff --git a/sql/update-2023-07-03_2.sql b/sql/update-2023-07-03_2.sql deleted file mode 100644 index 5c3ff38fe..000000000 --- a/sql/update-2023-07-03_2.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `abilities` ADD `active` BOOLEAN NOT NULL DEFAULT TRUE AFTER `level`; diff --git a/sql/update-2023-07-12_1.sql b/sql/update-2023-07-12_1.sql deleted file mode 100644 index 07eb2f3f4..000000000 --- a/sql/update-2023-07-12_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `accounts` -ADD `loginState` TINYINT NOT NULL DEFAULT '0' AFTER `selectedSlot`, -ADD `loginCharacter` BIGINT NOT NULL DEFAULT '0' AFTER `loginState`; diff --git a/sql/update-2023-07-15_1.sql b/sql/update-2023-07-15_1.sql deleted file mode 100644 index 1e6c67c81..000000000 --- a/sql/update-2023-07-15_1.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE `account_properties` ( - `propertyId` bigint(20) NOT NULL, - `accountId` bigint(20) NOT NULL, - `name` varchar(64) NOT NULL, - `type` varchar(1) NOT NULL, - `value` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `account_properties` - ADD PRIMARY KEY (`propertyId`), - ADD KEY `accountId` (`accountId`); - -ALTER TABLE `account_properties` - MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `account_properties` - ADD CONSTRAINT `account_properties_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2024-03-11_1.sql b/sql/update-2024-03-11_1.sql deleted file mode 100644 index 7bb0a3dbe..000000000 --- a/sql/update-2024-03-11_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `skinColor` INT UNSIGNED NOT NULL DEFAULT 0xFF808080 AFTER `hair`; diff --git a/sql/update_2015-08-17_1.sql b/sql/update_2015-08-17_1.sql deleted file mode 100644 index 8c97ef633..000000000 --- a/sql/update_2015-08-17_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `teamName` VARCHAR(32) NOT NULL AFTER `name`; diff --git a/sql/update_2015-08-17_2.sql b/sql/update_2015-08-17_2.sql deleted file mode 100644 index 02610422e..000000000 --- a/sql/update_2015-08-17_2.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `characters` ADD `zone` INT NOT NULL AFTER `level`; -ALTER TABLE `characters` ADD `exp` INT NOT NULL DEFAULT '0' , ADD `maxExp` INT NOT NULL DEFAULT '1000' , ADD `hp` INT NOT NULL DEFAULT '100' , ADD `maxHp` INT NOT NULL DEFAULT '100' , ADD `sp` INT NOT NULL DEFAULT '50' , ADD `maxSp` INT NOT NULL DEFAULT '50' , ADD `stamina` INT NOT NULL DEFAULT '50000' ; diff --git a/sql/update_2015-08-17_3.sql b/sql/update_2015-08-17_3.sql deleted file mode 100644 index d3bd91eeb..000000000 --- a/sql/update_2015-08-17_3.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `bx` FLOAT NOT NULL AFTER `level`, ADD `by` FLOAT NOT NULL AFTER `bx`, ADD `bz` FLOAT NOT NULL AFTER `by`; diff --git a/sql/update_2015-08-20_1.sql b/sql/update_2015-08-20_1.sql deleted file mode 100644 index 31a1371ab..000000000 --- a/sql/update_2015-08-20_1.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE IF NOT EXISTS `items` ( - `characterId` bigint(11) NOT NULL, - `itemId` int(11) NOT NULL, - `amount` int(11) NOT NULL, - `sort` int(11) NOT NULL, - KEY `characterId` (`characterId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `items` - ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update_2015-08-20_2.sql b/sql/update_2015-08-20_2.sql deleted file mode 100644 index aa7e1523e..000000000 --- a/sql/update_2015-08-20_2.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `items` ADD `equipSlot` TINYINT NOT NULL DEFAULT '127' ; -ALTER TABLE `items` ADD `itemUniqueId` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; diff --git a/sql/update_2015-08-27_1.sql b/sql/update_2015-08-27_1.sql deleted file mode 100644 index 9118dab3a..000000000 --- a/sql/update_2015-08-27_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `characters` ADD `str` FLOAT NOT NULL DEFAULT '1' , ADD `con` FLOAT NOT NULL DEFAULT '1' , ADD `int` FLOAT NOT NULL DEFAULT '1' , ADD `spr` FLOAT NOT NULL DEFAULT '1' , ADD `dex` FLOAT NOT NULL DEFAULT '1' ; diff --git a/sql/update_2015-09-03_1.sql b/sql/update_2015-09-03_1.sql deleted file mode 100644 index d45e33203..000000000 --- a/sql/update_2015-09-03_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` ADD `settings` VARCHAR(512) NOT NULL DEFAULT '' ; diff --git a/sql/update_2015-09-16_1.sql b/sql/update_2015-09-16_1.sql deleted file mode 100644 index 08f24b647..000000000 --- a/sql/update_2015-09-16_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `characters` ADD `statByLevel` FLOAT NOT NULL DEFAULT '0' ; -ALTER TABLE `characters` ADD `usedStat` FLOAT NOT NULL DEFAULT '0' ; -ALTER TABLE `characters` ADD `statByBonus` FLOAT NOT NULL DEFAULT '0' AFTER `statByLevel`; diff --git a/sql/update_2015-12-12_1.sql b/sql/update_2015-12-12_1.sql deleted file mode 100644 index 0475d9f1e..000000000 --- a/sql/update_2015-12-12_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -UPDATE `characters` SET `stamina` = 25000 WHERE `stamina` = 50000; -ALTER TABLE `characters` ADD `maxStamina` INT NOT NULL DEFAULT '25000' AFTER `stamina`; -ALTER TABLE `characters` CHANGE `stamina` `stamina` INT(11) NOT NULL DEFAULT '25000'; diff --git a/sql/update_2016-04-01_1.sql b/sql/update_2016-04-01_1.sql deleted file mode 100644 index a2ce49001..000000000 --- a/sql/update_2016-04-01_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` ADD `authority` INT NOT NULL DEFAULT '0' AFTER `teamName`; diff --git a/sql/update_2016-04-02_1.sql b/sql/update_2016-04-02_1.sql deleted file mode 100644 index ac2979120..000000000 --- a/sql/update_2016-04-02_1.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `accounts` MODIFY COLUMN `teamName` varchar(64) NULL; -ALTER TABLE `characters` MODIFY COLUMN `teamName` varchar(32) NULL; diff --git a/sql/update_2016-04-03_1.sql b/sql/update_2016-04-03_1.sql deleted file mode 100644 index 23ec5585b..000000000 --- a/sql/update_2016-04-03_1.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE IF NOT EXISTS `updates` ( - `path` varchar(255) NOT NULL, - PRIMARY KEY (`path`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -INSERT INTO `updates` (`path`) VALUES -('main.sql'), -('update_2015-08-17_1.sql'), -('update_2015-08-17_2.sql'), -('update_2015-08-17_3.sql'), -('update_2015-08-20_1.sql'), -('update_2015-08-20_2.sql'), -('update_2015-08-27_1.sql'), -('update_2015-09-03_1.sql'), -('update_2015-09-16_1.sql'), -('update_2015-12-12_1.sql'), -('update_2016-04-01_1.sql'), -('update_2016-04-02_1.sql'), -('update_2016-04-03_1.sql'); diff --git a/sql/update_2016-04-11_1.sql b/sql/update_2016-04-11_1.sql deleted file mode 100644 index b19d7e0d2..000000000 --- a/sql/update_2016-04-11_1.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE IF NOT EXISTS `vars` ( - `varId` bigint(20) NOT NULL AUTO_INCREMENT, - `owner` varchar(128) NOT NULL, - `name` varchar(128) NOT NULL, - `type` char(2) NOT NULL, - `value` mediumtext NOT NULL, - PRIMARY KEY (`varId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/sql/update_2016-04-23_1.sql b/sql/update_2016-04-23_1.sql deleted file mode 100644 index a1f055157..000000000 --- a/sql/update_2016-04-23_1.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; diff --git a/sql/update_2017-09-03_1.sql b/sql/update_2017-09-03_1.sql deleted file mode 100644 index 4426de652..000000000 --- a/sql/update_2017-09-03_1.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE IF NOT EXISTS `revealedmaps` ( - `revealedMapId` bigint(20) NOT NULL AUTO_INCREMENT, - `accountId` bigint(20) NOT NULL, - `map` int(11) NOT NULL, - `explored` varbinary(128) NOT NULL, - `percentage` FLOAT(10,2) NOT NULL DEFAULT 0, - PRIMARY KEY (`revealedMapId`), - CONSTRAINT `FK_revealedMaps_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, - CONSTRAINT `UQ_revealedMaps_map` UNIQUE (`accountId`, `map`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; diff --git a/sql_start/Merge_All_SQLs.sql b/sql_start/Merge_All_SQLs.sql new file mode 100644 index 000000000..5a9f1cb87 --- /dev/null +++ b/sql_start/Merge_All_SQLs.sql @@ -0,0 +1,469 @@ +CREATE DATABASE IF NOT EXISTS `melia` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `melia`; + +CREATE TABLE IF NOT EXISTS `accounts` ( + `accountId` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(32) NOT NULL, + `password` varchar(32) NOT NULL, + `teamName` varchar(64) DEFAULT NULL, + `authority` int(11) NOT NULL DEFAULT '0', + `settings` varchar(512) NOT NULL DEFAULT '', + PRIMARY KEY (`accountId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `characters` ( + `characterId` bigint(20) NOT NULL AUTO_INCREMENT, + `accountId` bigint(20) NOT NULL, + `name` varchar(64) NOT NULL, + `teamName` varchar(32) DEFAULT NULL, + `job` smallint(6) NOT NULL, + `gender` tinyint(4) NOT NULL, + `hair` tinyint(4) NOT NULL, + `level` int(11) NOT NULL DEFAULT '1', + `bx` float NOT NULL, + `by` float NOT NULL, + `bz` float NOT NULL, + `zone` int(11) NOT NULL, + `x` float NOT NULL, + `y` float NOT NULL, + `z` float NOT NULL, + `exp` int(11) NOT NULL DEFAULT '0', + `maxExp` int(11) NOT NULL DEFAULT '1000', + `hp` int(11) NOT NULL DEFAULT '100', + `maxHp` int(11) NOT NULL DEFAULT '100', + `sp` int(11) NOT NULL DEFAULT '50', + `maxSp` int(11) NOT NULL DEFAULT '50', + `stamina` int(11) NOT NULL DEFAULT '25000', + `maxStamina` int(11) NOT NULL DEFAULT '25000', + `str` float NOT NULL DEFAULT '1', + `con` float NOT NULL DEFAULT '1', + `int` float NOT NULL DEFAULT '1', + `spr` float NOT NULL DEFAULT '1', + `dex` float NOT NULL DEFAULT '1', + `statByLevel` float NOT NULL DEFAULT '0', + `statByBonus` float NOT NULL DEFAULT '0', + `usedStat` float NOT NULL DEFAULT '0', + PRIMARY KEY (`characterId`), + KEY `accountId` (`accountId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `items` ( + `itemUniqueId` bigint(20) NOT NULL AUTO_INCREMENT, + `characterId` bigint(11) NOT NULL, + `itemId` int(11) NOT NULL, + `amount` int(11) NOT NULL, + `sort` int(11) NOT NULL, + `equipSlot` tinyint(4) NOT NULL DEFAULT '127', + PRIMARY KEY (`itemUniqueId`), + KEY `characterId` (`characterId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `updates` ( + `path` varchar(255) NOT NULL, + PRIMARY KEY (`path`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `characters` + ADD CONSTRAINT `characters_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +CREATE TABLE IF NOT EXISTS `items` ( + `characterId` bigint(11) NOT NULL, + `itemId` int(11) NOT NULL, + `amount` int(11) NOT NULL, + `sort` int(11) NOT NULL, + KEY `characterId` (`characterId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `items` + ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +UPDATE `characters` SET `stamina` = 25000 WHERE `stamina` = 50000; +ALTER TABLE `characters` CHANGE `stamina` `stamina` INT(11) NOT NULL DEFAULT '25000'; +ALTER TABLE `accounts` MODIFY COLUMN `teamName` varchar(64) NULL; +ALTER TABLE `characters` MODIFY COLUMN `teamName` varchar(32) NULL; +CREATE TABLE IF NOT EXISTS `updates` ( + `path` varchar(255) NOT NULL, + PRIMARY KEY (`path`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `vars` ( + `varId` bigint(20) NOT NULL AUTO_INCREMENT, + `owner` varchar(128) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL, + PRIMARY KEY (`varId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +ALTER TABLE `accounts` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `characters` ADD COLUMN `barrackLayer` INT NOT NULL DEFAULT 1;CREATE TABLE IF NOT EXISTS `chatmacros` ( + `chatMacroId` bigint(20) NOT NULL AUTO_INCREMENT, + `accountId` bigint(20) NOT NULL, + `index` tinyint(4) NOT NULL, + `message` varchar(128) NOT NULL, + `pose` tinyint(4) NOT NULL DEFAULT 0, + PRIMARY KEY (`chatMacroId`), + CONSTRAINT `FK_ChatMacro_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, + CONSTRAINT `UQ_ChatMacro_index` UNIQUE (`accountId`, `index`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; +CREATE TABLE IF NOT EXISTS `revealedmaps` ( + `revealedMapId` bigint(20) NOT NULL AUTO_INCREMENT, + `accountId` bigint(20) NOT NULL, + `map` int(11) NOT NULL, + `explored` varbinary(128) NOT NULL, + `percentage` FLOAT(10,2) NOT NULL DEFAULT 0, + PRIMARY KEY (`revealedMapId`), + CONSTRAINT `FK_revealedMaps_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, + CONSTRAINT `UQ_revealedMaps_map` UNIQUE (`accountId`, `map`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; +ALTER TABLE `accounts` ADD `medals` INT NOT NULL DEFAULT 0; +ALTER TABLE `accounts` ADD `giftMedals` INT NOT NULL DEFAULT 0; +ALTER TABLE `accounts` ADD `premiumMedals` INT NOT NULL DEFAULT 0; +CREATE TABLE `session_objects_properties` ( + `sessionObjectPropertyId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `sessionObjectId` int(11) NOT NULL, + `propertyId` int(11) NOT NULL, + `value` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `session_objects_properties` + ADD PRIMARY KEY (`sessionObjectPropertyId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `session_objects_properties` + MODIFY `sessionObjectPropertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `session_objects_properties` + ADD CONSTRAINT `session_object_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +CREATE TABLE `jobs` ( + `characterId` bigint(20) NOT NULL, + `jobId` int(11) NOT NULL, + `circle` int(11) NOT NULL DEFAULT '1', + `skillPoints` int(11) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `jobs` + ADD PRIMARY KEY (`characterId`,`jobId`); + + +ALTER TABLE `jobs` + ADD CONSTRAINT `jobs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `characters` CHANGE `str` `str` INT NOT NULL DEFAULT '1', + CHANGE `con` `con` INT NOT NULL DEFAULT '1', + CHANGE `int` `int` INT NOT NULL DEFAULT '1', + CHANGE `spr` `spr` INT NOT NULL DEFAULT '1', + CHANGE `dex` `dex` INT NOT NULL DEFAULT '1', + CHANGE `statByLevel` `statByLevel` INT NOT NULL DEFAULT '0', + CHANGE `statByBonus` `statByBonus` INT NOT NULL DEFAULT '0', + CHANGE `usedStat` `usedStat` INT NOT NULL DEFAULT '0'; +ALTER TABLE `characters` CHANGE `barrackLayer` `barrackLayer` INT(11) NOT NULL DEFAULT '1' AFTER `level`; +ALTER TABLE `characters` ADD `abilityPoints` INT NOT NULL DEFAULT '0' AFTER `usedStat`; +CREATE TABLE `skills` ( + `skillId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `id` int(11) NOT NULL, + `level` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `skills` + ADD PRIMARY KEY (`skillId`), + ADD KEY `characterId` (`characterId`); + + +ALTER TABLE `skills` + MODIFY `skillId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `skills` + ADD CONSTRAINT `skills_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +CREATE TABLE `abilities` ( + `abilityId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `id` int(11) NOT NULL, + `level` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `abilities` + ADD PRIMARY KEY (`abilityId`), + ADD KEY `characterId` (`characterId`); + + +ALTER TABLE `abilities` + MODIFY `abilityId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `characters` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `maxExp`; +ALTER TABLE `jobs` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `skillPoints`; +ALTER TABLE `characters` ADD `hpRate` FLOAT NOT NULL DEFAULT '1' AFTER `hp`, + ADD `spRate` FLOAT NOT NULL DEFAULT '1' AFTER `sp`, + ADD `strByJob` INT NOT NULL DEFAULT '0' AFTER `str`, + ADD `conByJob` INT NOT NULL DEFAULT '0' AFTER `con`, + ADD `intByJob` INT NOT NULL DEFAULT '0' AFTER `int`, + ADD `sprByJob` INT NOT NULL DEFAULT '0' AFTER `spr`, + ADD `dexByJob` INT NOT NULL DEFAULT '0' AFTER `dex`, + ADD `staminaByJob` INT NOT NULL DEFAULT '0' AFTER `stamina`, + CHANGE `str` `str` INT NOT NULL DEFAULT '0', + CHANGE `con` `con` INT NOT NULL DEFAULT '0', + CHANGE `int` `int` INT NOT NULL DEFAULT '0', + CHANGE `spr` `spr` INT NOT NULL DEFAULT '0', + CHANGE `dex` `dex` INT NOT NULL DEFAULT '0';ALTER TABLE `characters` CHANGE `hair` `hair` INT NOT NULL; +ALTER TABLE `characters` ADD `slot` INT NOT NULL AFTER `level`; +CREATE TABLE `character_properties` ( + `propertyId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `id` int(11) NOT NULL, + `type` varchar(1) NOT NULL, + `value` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `character_properties` + ADD PRIMARY KEY (`propertyId`), + ADD KEY `characterId` (`characterId`); + + +ALTER TABLE `character_properties` + MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `character_properties` + ADD CONSTRAINT `character_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `accounts` ADD `additionalSlotCount` INT NOT NULL DEFAULT '0' AFTER `premiumMedals`; +ALTER TABLE `accounts` ADD `teamExp` INT NOT NULL DEFAULT '0' AFTER `additionalSlotCount`; +ALTER TABLE `characters` ADD `silver` BIGINT NOT NULL DEFAULT '0' AFTER `abilityPoints`; +CREATE TABLE `inventory` ( + `characterId` bigint(20) NOT NULL, + `itemId` bigint(20) NOT NULL, + `sort` int(11) NOT NULL, + `equipSlot` tinyint(4) NOT NULL DEFAULT '127' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TRIGGER `cascadeDeleteItem` AFTER DELETE ON `inventory` FOR EACH ROW + DELETE FROM `items` WHERE `itemUniqueId` = OLD.`itemId`; + +ALTER TABLE `inventory` + ADD PRIMARY KEY (`characterId`,`itemId`), + ADD KEY `itemId` (`itemId`); + +ALTER TABLE `inventory` + ADD CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; + +INSERT INTO `inventory` (SELECT `characterId`, `itemUniqueId` AS `itemId`, `sort`, `equipSlot` FROM `items`); +ALTER TABLE `items` DROP FOREIGN KEY `items_ibfk_1`; +ALTER TABLE `items` DROP `characterId`; +ALTER TABLE `items` DROP `sort`; +ALTER TABLE `items` DROP `equipSlot`; +ALTER TABLE `accounts` CHANGE `settings` `settings` VARCHAR(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; +ALTER TABLE `jobs` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +DELETE FROM `character_properties` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); +DELETE FROM `skills` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); + +ALTER TABLE `character_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `chatmacros` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `revealedmaps` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `session_objects_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `skills` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `character_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `id`; +UPDATE `character_properties` SET `name` = CAST(`id` AS CHAR(64)); +ALTER TABLE `character_properties` DROP `id`; +ALTER TABLE `session_objects_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `propertyId`; +ALTER TABLE `session_objects_properties` ADD `type` VARCHAR(1) NOT NULL AFTER `name`; +UPDATE `session_objects_properties` SET `name` = CAST(`propertyId` AS CHAR(64)); +ALTER TABLE `session_objects_properties` DROP `propertyId`; +ALTER TABLE `characters` ADD `bd` FLOAT NOT NULL AFTER `bz`; +UPDATE `characters` SET `bd` = FLOOR(RAND() * 180); +ALTER TABLE `accounts` ADD `barracksThema` INT NOT NULL DEFAULT '11' AFTER `teamExp`; +ALTER TABLE `accounts` ADD `themas` VARCHAR(128) NOT NULL DEFAULT '11' AFTER `barracksThema`; +ALTER TABLE `characters` CHANGE `exp` `exp` BIGINT NOT NULL DEFAULT '0', + CHANGE `maxExp` `maxExp` BIGINT NOT NULL DEFAULT '1000', + CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; +ALTER TABLE `jobs` CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; +UPDATE `vars` SET `name` = "Melia.PropertiesInitialized" WHERE `name` = "PropertiesInitialized"; +UPDATE `vars` SET `name` = "Melia.QuickSlotList" WHERE `name` = "_QuickSlotList"; +DELETE FROM `vars` WHERE `name` = "Melia.QuickSlotList"; +ALTER TABLE `accounts` ADD `selectedSlot` TINYINT NOT NULL DEFAULT '0' AFTER `themas`; +ALTER TABLE `characters` ADD `equipVisibility` INT NOT NULL DEFAULT 0xFFFF AFTER `silver`; +START TRANSACTION; + + +-- Add new character vars table +CREATE TABLE `vars_characters` ( + `varId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `vars_characters` + ADD PRIMARY KEY (`varId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `vars_characters` + MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `vars_characters` + ADD CONSTRAINT `vars_characters_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- Remove variables of characters that don't exist anymore +DELETE FROM `vars` WHERE `owner` LIKE "character:%" AND SUBSTRING(`owner`, 11) NOT IN (SELECT `characterId` FROM `characters`); + +-- Move remaining variables to new table +INSERT INTO `vars_characters` (`characterId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 11) AS `characterId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "character:%"; + +-- Remove old vars +DELETE FROM `vars` WHERE `owner` LIKE "character:%"; + + +-- Add new account vars table +CREATE TABLE `vars_accounts` ( + `varId` bigint(20) NOT NULL, + `accountId` bigint(20) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `vars_accounts` + ADD PRIMARY KEY (`varId`), + ADD KEY `accountId` (`accountId`); + +ALTER TABLE `vars_accounts` + MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `vars_accounts` + ADD CONSTRAINT `vars_accounts_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `characters` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- Remove variables of characters that don't exist anymore +DELETE FROM `vars` WHERE `owner` LIKE "account:%" AND SUBSTRING(`owner`, 9) NOT IN (SELECT `accountId` FROM `characters`); + +-- Move remaining variables to new table +INSERT INTO `vars_accounts` (`accountId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 9) AS `accountId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "account:%"; + +-- Remove old vars +DELETE FROM `vars` WHERE `owner` LIKE "account:%"; + + +-- Turn vars table in global vars +RENAME TABLE `vars` TO `vars_global`; +ALTER TABLE `vars_global` DROP `owner`; + + +COMMIT; +CREATE TABLE `buffs` ( + `buffId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `classId` int(11) NOT NULL, + `numArg1` int(11) NOT NULL, + `numArg2` int(11) NOT NULL, + `remainingDuration` time NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `buffs` + ADD PRIMARY KEY (`buffId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `buffs` + MODIFY `buffId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `buffs` + ADD CONSTRAINT `buffs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +CREATE TABLE `cooldowns` ( + `cooldownId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `classId` int(11) NOT NULL, + `remaining` time NOT NULL, + `duration` time NOT NULL, + `startTime` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `cooldowns` + ADD PRIMARY KEY (`cooldownId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `cooldowns` + MODIFY `cooldownId` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; + +ALTER TABLE `cooldowns` + ADD CONSTRAINT `cooldowns_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +CREATE TABLE `vars_buffs` ( + `varId` bigint(20) NOT NULL, + `buffId` bigint(20) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `vars_buffs` + ADD PRIMARY KEY (`varId`), + ADD KEY `characterId` (`buffId`); + +ALTER TABLE `vars_buffs` + MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `vars_buffs` + ADD CONSTRAINT `vars_buffs_ibfk_1` FOREIGN KEY (`buffId`) REFERENCES `buffs` (`buffId`) ON DELETE CASCADE ON UPDATE CASCADE; +CREATE TABLE `quests` ( + `questId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `classId` int(11) NOT NULL, + `status` int(11) NOT NULL, + `startTime` datetime NOT NULL, + `completeTime` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `quests_progress` ( + `questId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `ident` varchar(64) CHARACTER SET utf8mb4 NOT NULL, + `count` int(11) NOT NULL, + `done` tinyint(1) NOT NULL, + `unlocked` tinyint(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `quests` + ADD PRIMARY KEY (`questId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `quests_progress` + ADD PRIMARY KEY (`questId`,`ident`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `quests` + MODIFY `questId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `quests` + ADD CONSTRAINT `quests_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `quests_progress` + ADD CONSTRAINT `quests_progress_ibfk_1` FOREIGN KEY (`questId`) REFERENCES `quests` (`questId`) ON DELETE CASCADE ON UPDATE CASCADE; +START TRANSACTION; + +DELETE FROM `abilities` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); +ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +COMMIT; +ALTER TABLE `abilities` ADD `active` BOOLEAN NOT NULL DEFAULT TRUE AFTER `level`; +ALTER TABLE `accounts` +ADD `loginState` TINYINT NOT NULL DEFAULT '0' AFTER `selectedSlot`, +ADD `loginCharacter` BIGINT NOT NULL DEFAULT '0' AFTER `loginState`; +CREATE TABLE `account_properties` ( + `propertyId` bigint(20) NOT NULL, + `accountId` bigint(20) NOT NULL, + `name` varchar(64) NOT NULL, + `type` varchar(1) NOT NULL, + `value` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `account_properties` + ADD PRIMARY KEY (`propertyId`), + ADD KEY `accountId` (`accountId`); + +ALTER TABLE `account_properties` + MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `account_properties` + ADD CONSTRAINT `account_properties_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `characters` ADD `skinColor` INT UNSIGNED NOT NULL DEFAULT 0xFF808080 AFTER `hair`; diff --git a/src/BarracksServer/BarracksServer.cs b/src/BarracksServer/BarracksServer.cs index 6a0b21ad7..b445eb6af 100644 --- a/src/BarracksServer/BarracksServer.cs +++ b/src/BarracksServer/BarracksServer.cs @@ -67,7 +67,7 @@ public override void Run(string[] args) var title = string.Format("Barracks ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.Magenta, ConsoleHeader.Logo, ConsoleHeader.Credits); - ConsoleUtil.LoadingTitle(); + // ConsoleUtil.LoadingTitle(); Log.Init("BarracksServer" + serverId); @@ -86,8 +86,10 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartAcceptor(); - ConsoleUtil.RunningTitle(); - new BarracksConsoleCommands().Wait(); + // Event Loop to keep server running on Docker + while(true) { + System.Threading.Thread.Sleep(5000); + } } /// diff --git a/src/Shared/Configuration/Files/Web.cs b/src/Shared/Configuration/Files/Web.cs index 28a199962..ffbfed29f 100644 --- a/src/Shared/Configuration/Files/Web.cs +++ b/src/Shared/Configuration/Files/Web.cs @@ -19,7 +19,7 @@ public void Load(string filePath) { this.Include(filePath); - this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe")); + this.PhpCgiFilePath = this.GetString("php_cgi_bin", "/usr/bin/php-cgi"); this.PhpDownloadUrl = this.GetString("php_download", "https://windows.php.net/downloads/releases/php-8.2.7-nts-Win32-vs16-x86.zip"); } } diff --git a/src/WebServer/WebServer.cs b/src/WebServer/WebServer.cs index b3bd017c0..a69f54c16 100644 --- a/src/WebServer/WebServer.cs +++ b/src/WebServer/WebServer.cs @@ -43,7 +43,7 @@ public override void Run(string[] args) var title = string.Format("Web ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.DarkRed, ConsoleHeader.Logo, ConsoleHeader.Credits); - ConsoleUtil.LoadingTitle(); + // ConsoleUtil.LoadingTitle(); this.NavigateToRoot(); this.LoadConf(this.Conf); @@ -54,9 +54,10 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartWebServer(); - ConsoleUtil.RunningTitle(); - - new ConsoleCommands().Wait(); + // Event Loop to keep server running on Docker + while(true) { + System.Threading.Thread.Sleep(5000); + } } /// @@ -66,7 +67,7 @@ private void CheckDependencies() { var phpFilePath = this.Conf.Web.PhpCgiFilePath; var phpFolderPath = Path.GetDirectoryName(phpFilePath); - + Log.Info(phpFilePath); // If the binary exists we got all we need if (File.Exists(phpFilePath)) return; diff --git a/src/ZoneServer/ZoneServer.cs b/src/ZoneServer/ZoneServer.cs index 01d0297c4..a52367f53 100644 --- a/src/ZoneServer/ZoneServer.cs +++ b/src/ZoneServer/ZoneServer.cs @@ -88,7 +88,7 @@ public override void Run(string[] args) var title = string.Format("Zone ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.DarkGreen, ConsoleHeader.Logo, ConsoleHeader.Credits); - ConsoleUtil.LoadingTitle(); + // ConsoleUtil.LoadingTitle(); // Set up zone server specific logging or we might run into // issues with multiple servers trying to write files at the @@ -111,8 +111,10 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartAcceptor(); - ConsoleUtil.RunningTitle(); - new ConsoleCommands().Wait(); + // Event Loop to keep server running on Docker + while(true) { + System.Threading.Thread.Sleep(5000); + } } /// diff --git a/start b/start new file mode 100755 index 000000000..128d41941 --- /dev/null +++ b/start @@ -0,0 +1,56 @@ +#!/bin/sh +killall -9 BarracksServer +killall -9 ZoneServer +killall -9 WebServer +echo "Starting Melia Project..." +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +ENVIRONMENT=$1 +FILENAME=$2 +GROUP_ID=$3 +SERVER_ID=$4 +SUBFOLDER="net8.0" + +do_error () { + echo "" + echo $1 + echo "" + exit 1 +} + +run_all() { + cd "$SCRIPTPATH/bin/$ENVIRONMENT/$SUBFOLDER" + for FILEN in BarracksServer ZoneServer WebServer + do + sh -c "./$FILEN $GROUP_ID $SERVER_ID" & + sleep 10 + done + tail -f /dev/null +} + +run_process() { + cd "$SCRIPTPATH/bin/$ENVIRONMENT/$SUBFOLDER" + sh -c "./$FILENAME $GROUP_ID $SERVER_ID" +} + +if [ -z "$ENVIRONMENT" ] +then + ENVIRONMENT="Debug" +fi + +if [ -z "$GROUP_ID" ] +then + GROUP_ID="1001" +fi + +if [ -z "$SERVER_ID" ] +then + SERVER_ID="1" +fi + +if [ -z "$FILENAME" ] +then + run_all +else + run_process +fi + diff --git a/stop b/stop new file mode 100755 index 000000000..bf721bd30 --- /dev/null +++ b/stop @@ -0,0 +1,7 @@ +#!/bin/sh +clear +echo "Stoping Melia Project..." + +killall -9 BarracksServer +killall -9 ZoneServer +killall -9 WebServer diff --git a/system/conf/database.conf b/system/conf/database.conf index 314324f8e..773a2450a 100644 --- a/system/conf/database.conf +++ b/system/conf/database.conf @@ -2,9 +2,9 @@ // Configuration file //---------------------------------------------------------------------------- -host : 127.0.0.1 +host : melia-database user : root -pass : +pass : 123456 database : melia include "/user/conf/database.conf" diff --git a/system/conf/web.conf b/system/conf/web.conf index d7cf866d3..e06fbc756 100644 --- a/system/conf/web.conf +++ b/system/conf/web.conf @@ -5,6 +5,6 @@ // Path to the PHP CGI executable // If the file doesn't exist, and the configured path is in user/tools/, // PHP is downloaded automatically on Windows. -php_cgi_exe: user/tools/php/php-cgi.exe +php_cgi_exe: /usr/bin/php-cgi include "/user/conf/web.conf" From d9d3a750d7e9a7707f93f44b3b7703a4a92170bc Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Tue, 16 Apr 2024 21:24:51 -0300 Subject: [PATCH 02/18] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Missing=20SQL=20fol?= =?UTF-8?q?der=20when=20starting=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/dummy | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sql/dummy diff --git a/sql/dummy b/sql/dummy new file mode 100644 index 000000000..e69de29bb From 2a8635373ca9ce913ae0c046c31e4540872a3b35 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Tue, 16 Apr 2024 23:59:42 -0300 Subject: [PATCH 03/18] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Changing=20SQL=20qu?= =?UTF-8?q?eries=20due=20to=20capital=20letters=20conflict?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ZoneServer/Database/ZoneDb.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ZoneServer/Database/ZoneDb.cs b/src/ZoneServer/Database/ZoneDb.cs index 4fb0cd59a..8440a571c 100644 --- a/src/ZoneServer/Database/ZoneDb.cs +++ b/src/ZoneServer/Database/ZoneDb.cs @@ -825,7 +825,7 @@ protected void LoadVars(MySqlConnection conn, Variables vars, string tableName, private void LoadChatMacros(Account account) { using (var conn = this.GetConnection()) - using (var mc = new MySqlCommand("SELECT * FROM `chatMacros` WHERE `accountId` = @accountId ORDER BY `index` DESC", conn)) + using (var mc = new MySqlCommand("SELECT * FROM `chatmacros` WHERE `accountId` = @accountId ORDER BY `index` DESC", conn)) { mc.Parameters.AddWithValue("@accountId", account.Id); @@ -853,7 +853,7 @@ private void SaveChatMacros(Account account) using (var conn = this.GetConnection()) using (var trans = conn.BeginTransaction()) { - using (var mc = new MySqlCommand("DELETE FROM `chatMacros` WHERE `accountId` = @accountId", conn, trans)) + using (var mc = new MySqlCommand("DELETE FROM `chatmacros` WHERE `accountId` = @accountId", conn, trans)) { mc.Parameters.AddWithValue("@accountId", account.Id); mc.ExecuteNonQuery(); @@ -861,7 +861,7 @@ private void SaveChatMacros(Account account) foreach (var macro in account.GetChatMacros().OrderBy(x => x.Index)) { - using (var cmd = new InsertCommand("INSERT INTO `chatMacros` {0}", conn, trans)) + using (var cmd = new InsertCommand("INSERT INTO `chatmacros` {0}", conn, trans)) { cmd.Set("accountId", account.Id); cmd.Set("index", macro.Index); @@ -883,7 +883,7 @@ private void SaveChatMacros(Account account) private void LoadRevealedMaps(Account account) { using (var conn = this.GetConnection()) - using (var mc = new MySqlCommand("SELECT * FROM `revealedMaps` WHERE `accountId` = @accountId", conn)) + using (var mc = new MySqlCommand("SELECT * FROM `revealedmaps` WHERE `accountId` = @accountId", conn)) { mc.Parameters.AddWithValue("@accountId", account.Id); @@ -911,7 +911,7 @@ private void SaveRevealedMaps(Account account) using (var conn = this.GetConnection()) using (var trans = conn.BeginTransaction()) { - using (var mc = new MySqlCommand("DELETE FROM `revealedMaps` WHERE `accountId` = @accountId", conn, trans)) + using (var mc = new MySqlCommand("DELETE FROM `revealedmaps` WHERE `accountId` = @accountId", conn, trans)) { mc.Parameters.AddWithValue("@accountId", account.Id); mc.ExecuteNonQuery(); @@ -919,7 +919,7 @@ private void SaveRevealedMaps(Account account) foreach (var revealedMap in account.GetRevealedMaps()) { - using (var cmd = new InsertCommand("INSERT INTO `revealedMaps` {0}", conn, trans)) + using (var cmd = new InsertCommand("INSERT INTO `revealedmaps` {0}", conn, trans)) { cmd.Set("accountId", account.Id); cmd.Set("map", revealedMap.MapId); From f7dd52cdf455a7f0c8676107af7787aa247d9796 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Wed, 17 Apr 2024 14:38:09 -0300 Subject: [PATCH 04/18] feat: :art: Add .env file for configuring docker-compose --- .env.example | 11 +++++++++++ .gitignore | 1 + docker-compose.yml | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..39f40a884 --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +# ENVIRONMENT determines the folder where we'll look for binaries. +# If you're using Release, change the build command to: docker compose run --rm melia-server dotnet publish +# Release performance tends to have better performance, Debug will have more info for development. + +ENVIRONMENT="Debug" # Options: Release | Debug + +# Database password +MYSQL_ROOT_PASSWORD="123456" # Use a strong password, change in ./user/conf/database.conf too + +# Automatically restart server. If using on-failure, sets amount of retries +SERVER_RESTART="unless-stopped" # Options: no | unless-stopped | always | on-failure:5 \ No newline at end of file diff --git a/.gitignore b/.gitignore index f1ff7f5df..9144edb94 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /cache/ /.mysql/ /user/** +/.env !/user/conf/database-example.conf !/user/db/items-example.txt diff --git a/docker-compose.yml b/docker-compose.yml index c172d8357..ed9f93f0e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,14 +8,16 @@ services: ports: - 3306:3306 environment: - - MYSQL_ROOT_PASSWORD=123456 # Change to secure password + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} volumes: - ./sql_start:/docker-entrypoint-initdb.d - ./.mysql/:/var/lib/mysql - restart: unless-stopped + restart: ${SERVER_RESTART} + env_file: + - ./.env melia-server: container_name: melia-server - command: "./start Debug" + command: "./start Release" build: "./Servers" networks: - melia-network @@ -29,6 +31,9 @@ services: - "7001:7001" - "7002:7002" - "80:80" + restart: ${SERVER_RESTART} + env_file: + - ./.env phpmyadmin: container_name: melia-dbadmin networks: @@ -36,11 +41,14 @@ services: image: phpmyadmin ports: - 8080:80 + restart: ${SERVER_RESTART} environment: - PMA_HOST=melia-database - PMA_USER=root - - PMA_PASSWORD=123456 # Change to secure password (Same as before) + - PMA_PASSWORD=${MYSQL_ROOT_PASSWORD} - UPLOAD_LIMIT=300M profiles: [] + env_file: + - ./.env networks: melia-network: From cfa2971a4fb3f8dc22fb25f71ffbcc6b60c7d3f0 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Wed, 17 Apr 2024 14:39:02 -0300 Subject: [PATCH 05/18] docs: :memo: Improve documentation on docker and client setup --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e85e65fb9..d4471e050 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ with any services provided by game developers or publishers, and we don't endorse such actions. We're here to learn and create, not to steal or destroy. -Docker +Installation with Docker ----------------------------------------------------------------------------- -This repository aims to make Melia easier to setup and run in any environment. +This branch aims to make Melia easier to setup and run in any environment. To achieve this, we're making a few changes do add the capability of building and running Melia on Linux, as well as building and running the server in a few Docker containers. @@ -24,7 +24,8 @@ For this to work, you will need [Docker](https://docs.docker.com/) installed on your system. Recent versions of Docker comes with [Docker Compose](https://docs.docker.com/compose/) pre-installed, so you don't have to worry about it. -After cloning or downloading this repository, navigate to the project folder +After cloning or downloading this repository, rename file `.env.example` to +`.env` and change configuration as needed. Then, navigate to the project folder (where you'll find `docker-compose.yml` ) and run: ``` @@ -32,7 +33,7 @@ docker compose build ``` This will download the necessary Docker Images for our project to run and -build a new image with `/server/Dockerfile`, where our server dependencies +build a new image with `./Servers/Dockerfile`, where our server dependencies are listed. Now, you can run: @@ -60,13 +61,16 @@ If you change anything on source code, you need to run server with `docker compose restart` -Database +Database with Docker ----------------------------------------------------------------------------- With the Docker containers, we've added a PHPMyAdmin container, which can be accessed via [http://127.0.0.1:8080]. Default user is `root` and password -is `123456` (You can change password on `docker-compose.yml`, but remember -to change on source files as well). +is `123456` (You can change password on `.env`, but remember to change on +`user/conf/database.conf` as well). + +By default, database will be loaded with data from `sql_start/Merge_All_SQLs.sql`. + Client @@ -76,6 +80,35 @@ Melia does not have a client of its own at this time. Instead, it's designed to be network compatible with the latest client of the international version of ToS, which is freely available on Steam. +After downloading, open your client folder (Steam > Right-Click on Game > +Manage > Browse Local Files). Then, open `release/client.xml` with a text +editor. + +Change the line which starts with ` +``` + +Note: If your server is not on the same machine you're playing, change +`127.0.0.1` to your Server's LAN / WAN IP. + +Now you can open your game and play. + +If you're using Docker, you can't use server's console to create your +account, so, when logging in for the first time, use `new__` as a prefix +to your username. + +Example: +``` +Username: new__myaccount +Password: mypassword +``` + +This will create an account with username `myaccount` and password +`mypassword`. You can check the database to make sure everything is okay, +but you'll already be connected and playing. Next time, just login with +your username without the `new__` prefix. + State of Development ----------------------------------------------------------------------------- From 1f2e05965f39be011063150d725a07c71a73e41c Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Wed, 17 Apr 2024 15:04:53 -0300 Subject: [PATCH 06/18] fix: :bug: Use ENVIRONMENT variable from .env file to run correct server binaries --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index ed9f93f0e..066b3c2a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: - ./.env melia-server: container_name: melia-server - command: "./start Release" + command: "./start ${ENVIRONMENT}" build: "./Servers" networks: - melia-network From 681cdd0942915edc63882bcaf1dfff42ffd3a4d4 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Fri, 19 Apr 2024 13:25:40 -0300 Subject: [PATCH 07/18] fix: :zap: Re-enable console commands on Windows systems Allow usage of command inputs on baremetal Windows OS while keeping disable for incompatible systems (UNIX + Docker and MacOS) --- src/BarracksServer/BarracksServer.cs | 59 +++++++++++++++++----------- src/WebServer/WebServer.cs | 29 ++++++++++---- src/ZoneServer/ZoneServer.cs | 23 +++++++++-- 3 files changed, 76 insertions(+), 35 deletions(-) diff --git a/src/BarracksServer/BarracksServer.cs b/src/BarracksServer/BarracksServer.cs index b445eb6af..11ca333f2 100644 --- a/src/BarracksServer/BarracksServer.cs +++ b/src/BarracksServer/BarracksServer.cs @@ -67,7 +67,10 @@ public override void Run(string[] args) var title = string.Format("Barracks ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.Magenta, ConsoleHeader.Logo, ConsoleHeader.Credits); - // ConsoleUtil.LoadingTitle(); + + // Skip the following command on incompatible systems + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + ConsoleUtil.LoadingTitle(); Log.Init("BarracksServer" + serverId); @@ -86,9 +89,19 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartAcceptor(); - // Event Loop to keep server running on Docker - while(true) { - System.Threading.Thread.Sleep(5000); + // If running on Windows system, enable console inputs + // otherwise, start an event loop to keep server running until stopped + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + ConsoleUtil.RunningTitle(); + new BarracksConsoleCommands().Wait(); + } + else + { + while (true) + { + System.Threading.Thread.Sleep(5000); + } } } @@ -180,21 +193,21 @@ private void Communicator_OnMessageReceived(string sender, ICommMessage message) switch (message) { case ServerUpdateMessage serverUpdateMessage: - { - if (serverUpdateMessage.ServerType == ServerType.Zone) - _zoneServerNames[sender] = serverUpdateMessage.ServerId; + { + if (serverUpdateMessage.ServerType == ServerType.Zone) + _zoneServerNames[sender] = serverUpdateMessage.ServerId; - this.ServerList.Update(serverUpdateMessage); - this.Communicator.Broadcast("ServerUpdates", serverUpdateMessage); + this.ServerList.Update(serverUpdateMessage); + this.Communicator.Broadcast("ServerUpdates", serverUpdateMessage); - Send.BC_NORMAL.ZoneTraffic(); - break; - } + Send.BC_NORMAL.ZoneTraffic(); + break; + } case RequestMessage requestMessage: - { - this.Communicator_OnRequestReceived(sender, requestMessage); - break; - } + { + this.Communicator_OnRequestReceived(sender, requestMessage); + break; + } } } @@ -208,15 +221,15 @@ private void Communicator_OnRequestReceived(string sender, RequestMessage reques switch (requestMessage.Message) { case ReqPlayerCountMessage reqPlayerCountMessage: - { - var playerCount = this.ServerList.GetAll(ServerType.Zone).Sum(server => server.CurrentPlayers); + { + var playerCount = this.ServerList.GetAll(ServerType.Zone).Sum(server => server.CurrentPlayers); - var message = new ResPlayerCountMessage(playerCount); - var responseMessage = new ResponseMessage(requestMessage.Id, message); + var message = new ResPlayerCountMessage(playerCount); + var responseMessage = new ResponseMessage(requestMessage.Id, message); - this.Communicator.Send(sender, responseMessage); - break; - } + this.Communicator.Send(sender, responseMessage); + break; + } } } diff --git a/src/WebServer/WebServer.cs b/src/WebServer/WebServer.cs index a69f54c16..e1ae63228 100644 --- a/src/WebServer/WebServer.cs +++ b/src/WebServer/WebServer.cs @@ -43,7 +43,10 @@ public override void Run(string[] args) var title = string.Format("Web ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.DarkRed, ConsoleHeader.Logo, ConsoleHeader.Credits); - // ConsoleUtil.LoadingTitle(); + + // Skip the following command on incompatible systems + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + ConsoleUtil.LoadingTitle(); this.NavigateToRoot(); this.LoadConf(this.Conf); @@ -54,9 +57,19 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartWebServer(); - // Event Loop to keep server running on Docker - while(true) { - System.Threading.Thread.Sleep(5000); + // If running on Windows system, enable console inputs + // otherwise, start an event loop to keep server running until stopped + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + ConsoleUtil.RunningTitle(); + new ConsoleCommands().Wait(); + } + else + { + while (true) + { + System.Threading.Thread.Sleep(5000); + } } } @@ -231,10 +244,10 @@ private void Communicator_OnMessageReceived(string sender, ICommMessage message) switch (message) { case ServerUpdateMessage serverUpdateMessage: - { - this.ServerList.Update(serverUpdateMessage); - break; - } + { + this.ServerList.Update(serverUpdateMessage); + break; + } } } diff --git a/src/ZoneServer/ZoneServer.cs b/src/ZoneServer/ZoneServer.cs index a52367f53..7edb3f77a 100644 --- a/src/ZoneServer/ZoneServer.cs +++ b/src/ZoneServer/ZoneServer.cs @@ -88,7 +88,11 @@ public override void Run(string[] args) var title = string.Format("Zone ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.DarkGreen, ConsoleHeader.Logo, ConsoleHeader.Credits); - // ConsoleUtil.LoadingTitle(); + + // Skip the following command on incompatible systems + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + ConsoleUtil.LoadingTitle(); + // Set up zone server specific logging or we might run into // issues with multiple servers trying to write files at the @@ -111,9 +115,20 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartAcceptor(); - // Event Loop to keep server running on Docker - while(true) { - System.Threading.Thread.Sleep(5000); + + // If running on Windows system, enable console inputs + // otherwise, start an event loop to keep server running until stopped + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + ConsoleUtil.RunningTitle(); + new ConsoleCommands().Wait(); + } + else + { + while (true) + { + System.Threading.Thread.Sleep(5000); + } } } From 840cfb7bde0fc580450d0f4fd82b157a02934813 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Fri, 19 Apr 2024 13:30:14 -0300 Subject: [PATCH 08/18] revert: :card_file_box: Revert removal of SQL files from master branch --- sql/main.sql | 86 +++++++++++++++++++++++++++++++++++++ sql/update-2017-09-01_1.sql | 1 + sql/update-2017-09-02_1.sql | 10 +++++ sql/update-2017-09-04_1.sql | 3 ++ sql/update-2017-09-12_1.sql | 17 ++++++++ sql/update-2017-09-14_1.sql | 14 ++++++ sql/update-2017-09-19_1.sql | 8 ++++ sql/update-2017-09-19_2.sql | 2 + sql/update-2017-09-19_3.sql | 18 ++++++++ sql/update-2017-09-25_1.sql | 15 +++++++ sql/update-2017-09-26_1.sql | 1 + sql/update-2017-09-28_1.sql | 1 + sql/update-2017-09-29_1.sql | 1 + sql/update-2017-10-31_1.sql | 13 ++++++ sql/update-2021-09-08_1.sql | 1 + sql/update-2021-09-14_1.sql | 1 + sql/update-2021-09-28_1.sql | 19 ++++++++ sql/update-2021-10-07_1.sql | 2 + sql/update-2021-10-07_2.sql | 1 + sql/update-2021-10-13_1.sql | 23 ++++++++++ sql/update-2023-05-10_1.sql | 1 + sql/update-2023-05-11_1.sql | 1 + sql/update-2023-05-21_1.sql | 8 ++++ sql/update-2023-05-22_1.sql | 3 ++ sql/update-2023-05-22_2.sql | 4 ++ sql/update-2023-05-23_1.sql | 2 + sql/update-2023-05-25_1.sql | 1 + sql/update-2023-05-25_2.sql | 1 + sql/update-2023-05-29_1.sql | 4 ++ sql/update-2023-05-31_1.sql | 2 + sql/update-2023-05-31_2.sql | 1 + sql/update-2023-06-01_1.sql | 1 + sql/update-2023-06-02_1.sql | 1 + sql/update-2023-06-03_1.sql | 67 +++++++++++++++++++++++++++++ sql/update-2023-06-03_2.sql | 18 ++++++++ sql/update-2023-06-26_1.sql | 18 ++++++++ sql/update-2023-06-27_1.sql | 17 ++++++++ sql/update-2023-06-30_1.sql | 34 +++++++++++++++ sql/update-2023-07-03_1.sql | 6 +++ sql/update-2023-07-03_2.sql | 1 + sql/update-2023-07-12_1.sql | 3 ++ sql/update-2023-07-15_1.sql | 17 ++++++++ sql/update-2024-03-11_1.sql | 1 + sql/update_2015-08-17_1.sql | 1 + sql/update_2015-08-17_2.sql | 2 + sql/update_2015-08-17_3.sql | 1 + sql/update_2015-08-20_1.sql | 10 +++++ sql/update_2015-08-20_2.sql | 2 + sql/update_2015-08-27_1.sql | 1 + sql/update_2015-09-03_1.sql | 1 + sql/update_2015-09-16_1.sql | 3 ++ sql/update_2015-12-12_1.sql | 3 ++ sql/update_2016-04-01_1.sql | 1 + sql/update_2016-04-02_1.sql | 2 + sql/update_2016-04-03_1.sql | 19 ++++++++ sql/update_2016-04-11_1.sql | 8 ++++ sql/update_2016-04-23_1.sql | 1 + sql/update_2017-09-03_1.sql | 10 +++++ 58 files changed, 514 insertions(+) create mode 100644 sql/main.sql create mode 100644 sql/update-2017-09-01_1.sql create mode 100644 sql/update-2017-09-02_1.sql create mode 100644 sql/update-2017-09-04_1.sql create mode 100644 sql/update-2017-09-12_1.sql create mode 100644 sql/update-2017-09-14_1.sql create mode 100644 sql/update-2017-09-19_1.sql create mode 100644 sql/update-2017-09-19_2.sql create mode 100644 sql/update-2017-09-19_3.sql create mode 100644 sql/update-2017-09-25_1.sql create mode 100644 sql/update-2017-09-26_1.sql create mode 100644 sql/update-2017-09-28_1.sql create mode 100644 sql/update-2017-09-29_1.sql create mode 100644 sql/update-2017-10-31_1.sql create mode 100644 sql/update-2021-09-08_1.sql create mode 100644 sql/update-2021-09-14_1.sql create mode 100644 sql/update-2021-09-28_1.sql create mode 100644 sql/update-2021-10-07_1.sql create mode 100644 sql/update-2021-10-07_2.sql create mode 100644 sql/update-2021-10-13_1.sql create mode 100644 sql/update-2023-05-10_1.sql create mode 100644 sql/update-2023-05-11_1.sql create mode 100644 sql/update-2023-05-21_1.sql create mode 100644 sql/update-2023-05-22_1.sql create mode 100644 sql/update-2023-05-22_2.sql create mode 100644 sql/update-2023-05-23_1.sql create mode 100644 sql/update-2023-05-25_1.sql create mode 100644 sql/update-2023-05-25_2.sql create mode 100644 sql/update-2023-05-29_1.sql create mode 100644 sql/update-2023-05-31_1.sql create mode 100644 sql/update-2023-05-31_2.sql create mode 100644 sql/update-2023-06-01_1.sql create mode 100644 sql/update-2023-06-02_1.sql create mode 100644 sql/update-2023-06-03_1.sql create mode 100644 sql/update-2023-06-03_2.sql create mode 100644 sql/update-2023-06-26_1.sql create mode 100644 sql/update-2023-06-27_1.sql create mode 100644 sql/update-2023-06-30_1.sql create mode 100644 sql/update-2023-07-03_1.sql create mode 100644 sql/update-2023-07-03_2.sql create mode 100644 sql/update-2023-07-12_1.sql create mode 100644 sql/update-2023-07-15_1.sql create mode 100644 sql/update-2024-03-11_1.sql create mode 100644 sql/update_2015-08-17_1.sql create mode 100644 sql/update_2015-08-17_2.sql create mode 100644 sql/update_2015-08-17_3.sql create mode 100644 sql/update_2015-08-20_1.sql create mode 100644 sql/update_2015-08-20_2.sql create mode 100644 sql/update_2015-08-27_1.sql create mode 100644 sql/update_2015-09-03_1.sql create mode 100644 sql/update_2015-09-16_1.sql create mode 100644 sql/update_2015-12-12_1.sql create mode 100644 sql/update_2016-04-01_1.sql create mode 100644 sql/update_2016-04-02_1.sql create mode 100644 sql/update_2016-04-03_1.sql create mode 100644 sql/update_2016-04-11_1.sql create mode 100644 sql/update_2016-04-23_1.sql create mode 100644 sql/update_2017-09-03_1.sql diff --git a/sql/main.sql b/sql/main.sql new file mode 100644 index 000000000..253f7b803 --- /dev/null +++ b/sql/main.sql @@ -0,0 +1,86 @@ +CREATE DATABASE IF NOT EXISTS `melia` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `melia`; + +CREATE TABLE IF NOT EXISTS `accounts` ( + `accountId` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(32) NOT NULL, + `password` varchar(32) NOT NULL, + `teamName` varchar(64) DEFAULT NULL, + `authority` int(11) NOT NULL DEFAULT '0', + `settings` varchar(512) NOT NULL DEFAULT '', + PRIMARY KEY (`accountId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `characters` ( + `characterId` bigint(20) NOT NULL AUTO_INCREMENT, + `accountId` bigint(20) NOT NULL, + `name` varchar(64) NOT NULL, + `teamName` varchar(32) DEFAULT NULL, + `job` smallint(6) NOT NULL, + `gender` tinyint(4) NOT NULL, + `hair` tinyint(4) NOT NULL, + `level` int(11) NOT NULL DEFAULT '1', + `bx` float NOT NULL, + `by` float NOT NULL, + `bz` float NOT NULL, + `zone` int(11) NOT NULL, + `x` float NOT NULL, + `y` float NOT NULL, + `z` float NOT NULL, + `exp` int(11) NOT NULL DEFAULT '0', + `maxExp` int(11) NOT NULL DEFAULT '1000', + `hp` int(11) NOT NULL DEFAULT '100', + `maxHp` int(11) NOT NULL DEFAULT '100', + `sp` int(11) NOT NULL DEFAULT '50', + `maxSp` int(11) NOT NULL DEFAULT '50', + `stamina` int(11) NOT NULL DEFAULT '25000', + `maxStamina` int(11) NOT NULL DEFAULT '25000', + `str` float NOT NULL DEFAULT '1', + `con` float NOT NULL DEFAULT '1', + `int` float NOT NULL DEFAULT '1', + `spr` float NOT NULL DEFAULT '1', + `dex` float NOT NULL DEFAULT '1', + `statByLevel` float NOT NULL DEFAULT '0', + `statByBonus` float NOT NULL DEFAULT '0', + `usedStat` float NOT NULL DEFAULT '0', + PRIMARY KEY (`characterId`), + KEY `accountId` (`accountId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `items` ( + `itemUniqueId` bigint(20) NOT NULL AUTO_INCREMENT, + `characterId` bigint(11) NOT NULL, + `itemId` int(11) NOT NULL, + `amount` int(11) NOT NULL, + `sort` int(11) NOT NULL, + `equipSlot` tinyint(4) NOT NULL DEFAULT '127', + PRIMARY KEY (`itemUniqueId`), + KEY `characterId` (`characterId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `updates` ( + `path` varchar(255) NOT NULL, + PRIMARY KEY (`path`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `updates` (`path`) VALUES +('main.sql'), +('update_2015-08-17_1.sql'), +('update_2015-08-17_2.sql'), +('update_2015-08-17_3.sql'), +('update_2015-08-20_1.sql'), +('update_2015-08-20_2.sql'), +('update_2015-08-27_1.sql'), +('update_2015-09-03_1.sql'), +('update_2015-09-16_1.sql'), +('update_2015-12-12_1.sql'), +('update_2016-04-01_1.sql'), +('update_2016-04-02_1.sql'), +('update_2016-04-03_1.sql'); + + +ALTER TABLE `characters` + ADD CONSTRAINT `characters_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `items` + ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-01_1.sql b/sql/update-2017-09-01_1.sql new file mode 100644 index 000000000..57e4b01dd --- /dev/null +++ b/sql/update-2017-09-01_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD COLUMN `barrackLayer` INT NOT NULL DEFAULT 1; \ No newline at end of file diff --git a/sql/update-2017-09-02_1.sql b/sql/update-2017-09-02_1.sql new file mode 100644 index 000000000..ed4ac498f --- /dev/null +++ b/sql/update-2017-09-02_1.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS `chatmacros` ( + `chatMacroId` bigint(20) NOT NULL AUTO_INCREMENT, + `accountId` bigint(20) NOT NULL, + `index` tinyint(4) NOT NULL, + `message` varchar(128) NOT NULL, + `pose` tinyint(4) NOT NULL DEFAULT 0, + PRIMARY KEY (`chatMacroId`), + CONSTRAINT `FK_ChatMacro_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, + CONSTRAINT `UQ_ChatMacro_index` UNIQUE (`accountId`, `index`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; diff --git a/sql/update-2017-09-04_1.sql b/sql/update-2017-09-04_1.sql new file mode 100644 index 000000000..8f79562f3 --- /dev/null +++ b/sql/update-2017-09-04_1.sql @@ -0,0 +1,3 @@ +ALTER TABLE `accounts` ADD `medals` INT NOT NULL DEFAULT 0; +ALTER TABLE `accounts` ADD `giftMedals` INT NOT NULL DEFAULT 0; +ALTER TABLE `accounts` ADD `premiumMedals` INT NOT NULL DEFAULT 0; diff --git a/sql/update-2017-09-12_1.sql b/sql/update-2017-09-12_1.sql new file mode 100644 index 000000000..e57a097e4 --- /dev/null +++ b/sql/update-2017-09-12_1.sql @@ -0,0 +1,17 @@ +CREATE TABLE `session_objects_properties` ( + `sessionObjectPropertyId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `sessionObjectId` int(11) NOT NULL, + `propertyId` int(11) NOT NULL, + `value` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `session_objects_properties` + ADD PRIMARY KEY (`sessionObjectPropertyId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `session_objects_properties` + MODIFY `sessionObjectPropertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `session_objects_properties` + ADD CONSTRAINT `session_object_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-14_1.sql b/sql/update-2017-09-14_1.sql new file mode 100644 index 000000000..07276ff20 --- /dev/null +++ b/sql/update-2017-09-14_1.sql @@ -0,0 +1,14 @@ +CREATE TABLE `jobs` ( + `characterId` bigint(20) NOT NULL, + `jobId` int(11) NOT NULL, + `circle` int(11) NOT NULL DEFAULT '1', + `skillPoints` int(11) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `jobs` + ADD PRIMARY KEY (`characterId`,`jobId`); + + +ALTER TABLE `jobs` + ADD CONSTRAINT `jobs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-19_1.sql b/sql/update-2017-09-19_1.sql new file mode 100644 index 000000000..c922d7849 --- /dev/null +++ b/sql/update-2017-09-19_1.sql @@ -0,0 +1,8 @@ +ALTER TABLE `characters` CHANGE `str` `str` INT NOT NULL DEFAULT '1', + CHANGE `con` `con` INT NOT NULL DEFAULT '1', + CHANGE `int` `int` INT NOT NULL DEFAULT '1', + CHANGE `spr` `spr` INT NOT NULL DEFAULT '1', + CHANGE `dex` `dex` INT NOT NULL DEFAULT '1', + CHANGE `statByLevel` `statByLevel` INT NOT NULL DEFAULT '0', + CHANGE `statByBonus` `statByBonus` INT NOT NULL DEFAULT '0', + CHANGE `usedStat` `usedStat` INT NOT NULL DEFAULT '0'; diff --git a/sql/update-2017-09-19_2.sql b/sql/update-2017-09-19_2.sql new file mode 100644 index 000000000..49b1c849c --- /dev/null +++ b/sql/update-2017-09-19_2.sql @@ -0,0 +1,2 @@ +ALTER TABLE `characters` CHANGE `barrackLayer` `barrackLayer` INT(11) NOT NULL DEFAULT '1' AFTER `level`; +ALTER TABLE `characters` ADD `abilityPoints` INT NOT NULL DEFAULT '0' AFTER `usedStat`; diff --git a/sql/update-2017-09-19_3.sql b/sql/update-2017-09-19_3.sql new file mode 100644 index 000000000..8af9845e6 --- /dev/null +++ b/sql/update-2017-09-19_3.sql @@ -0,0 +1,18 @@ +CREATE TABLE `skills` ( + `skillId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `id` int(11) NOT NULL, + `level` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `skills` + ADD PRIMARY KEY (`skillId`), + ADD KEY `characterId` (`characterId`); + + +ALTER TABLE `skills` + MODIFY `skillId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `skills` + ADD CONSTRAINT `skills_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-25_1.sql b/sql/update-2017-09-25_1.sql new file mode 100644 index 000000000..04365f4e9 --- /dev/null +++ b/sql/update-2017-09-25_1.sql @@ -0,0 +1,15 @@ +CREATE TABLE `abilities` ( + `abilityId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `id` int(11) NOT NULL, + `level` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `abilities` + ADD PRIMARY KEY (`abilityId`), + ADD KEY `characterId` (`characterId`); + + +ALTER TABLE `abilities` + MODIFY `abilityId` bigint(20) NOT NULL AUTO_INCREMENT; diff --git a/sql/update-2017-09-26_1.sql b/sql/update-2017-09-26_1.sql new file mode 100644 index 000000000..70809b73a --- /dev/null +++ b/sql/update-2017-09-26_1.sql @@ -0,0 +1 @@ +ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2017-09-28_1.sql b/sql/update-2017-09-28_1.sql new file mode 100644 index 000000000..e5c876f95 --- /dev/null +++ b/sql/update-2017-09-28_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `maxExp`; diff --git a/sql/update-2017-09-29_1.sql b/sql/update-2017-09-29_1.sql new file mode 100644 index 000000000..33f8a360e --- /dev/null +++ b/sql/update-2017-09-29_1.sql @@ -0,0 +1 @@ +ALTER TABLE `jobs` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `skillPoints`; diff --git a/sql/update-2017-10-31_1.sql b/sql/update-2017-10-31_1.sql new file mode 100644 index 000000000..f1d51e9c9 --- /dev/null +++ b/sql/update-2017-10-31_1.sql @@ -0,0 +1,13 @@ +ALTER TABLE `characters` ADD `hpRate` FLOAT NOT NULL DEFAULT '1' AFTER `hp`, + ADD `spRate` FLOAT NOT NULL DEFAULT '1' AFTER `sp`, + ADD `strByJob` INT NOT NULL DEFAULT '0' AFTER `str`, + ADD `conByJob` INT NOT NULL DEFAULT '0' AFTER `con`, + ADD `intByJob` INT NOT NULL DEFAULT '0' AFTER `int`, + ADD `sprByJob` INT NOT NULL DEFAULT '0' AFTER `spr`, + ADD `dexByJob` INT NOT NULL DEFAULT '0' AFTER `dex`, + ADD `staminaByJob` INT NOT NULL DEFAULT '0' AFTER `stamina`, + CHANGE `str` `str` INT NOT NULL DEFAULT '0', + CHANGE `con` `con` INT NOT NULL DEFAULT '0', + CHANGE `int` `int` INT NOT NULL DEFAULT '0', + CHANGE `spr` `spr` INT NOT NULL DEFAULT '0', + CHANGE `dex` `dex` INT NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/sql/update-2021-09-08_1.sql b/sql/update-2021-09-08_1.sql new file mode 100644 index 000000000..e11d579aa --- /dev/null +++ b/sql/update-2021-09-08_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` CHANGE `hair` `hair` INT NOT NULL; diff --git a/sql/update-2021-09-14_1.sql b/sql/update-2021-09-14_1.sql new file mode 100644 index 000000000..b90c58e80 --- /dev/null +++ b/sql/update-2021-09-14_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `slot` INT NOT NULL AFTER `level`; diff --git a/sql/update-2021-09-28_1.sql b/sql/update-2021-09-28_1.sql new file mode 100644 index 000000000..2efa63286 --- /dev/null +++ b/sql/update-2021-09-28_1.sql @@ -0,0 +1,19 @@ +CREATE TABLE `character_properties` ( + `propertyId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `id` int(11) NOT NULL, + `type` varchar(1) NOT NULL, + `value` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `character_properties` + ADD PRIMARY KEY (`propertyId`), + ADD KEY `characterId` (`characterId`); + + +ALTER TABLE `character_properties` + MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `character_properties` + ADD CONSTRAINT `character_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2021-10-07_1.sql b/sql/update-2021-10-07_1.sql new file mode 100644 index 000000000..f887cc759 --- /dev/null +++ b/sql/update-2021-10-07_1.sql @@ -0,0 +1,2 @@ +ALTER TABLE `accounts` ADD `additionalSlotCount` INT NOT NULL DEFAULT '0' AFTER `premiumMedals`; +ALTER TABLE `accounts` ADD `teamExp` INT NOT NULL DEFAULT '0' AFTER `additionalSlotCount`; diff --git a/sql/update-2021-10-07_2.sql b/sql/update-2021-10-07_2.sql new file mode 100644 index 000000000..51e2cfbe6 --- /dev/null +++ b/sql/update-2021-10-07_2.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `silver` BIGINT NOT NULL DEFAULT '0' AFTER `abilityPoints`; diff --git a/sql/update-2021-10-13_1.sql b/sql/update-2021-10-13_1.sql new file mode 100644 index 000000000..e1025cf06 --- /dev/null +++ b/sql/update-2021-10-13_1.sql @@ -0,0 +1,23 @@ +CREATE TABLE `inventory` ( + `characterId` bigint(20) NOT NULL, + `itemId` bigint(20) NOT NULL, + `sort` int(11) NOT NULL, + `equipSlot` tinyint(4) NOT NULL DEFAULT '127' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TRIGGER `cascadeDeleteItem` AFTER DELETE ON `inventory` FOR EACH ROW + DELETE FROM `items` WHERE `itemUniqueId` = OLD.`itemId`; + +ALTER TABLE `inventory` + ADD PRIMARY KEY (`characterId`,`itemId`), + ADD KEY `itemId` (`itemId`); + +ALTER TABLE `inventory` + ADD CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; + +INSERT INTO `inventory` (SELECT `characterId`, `itemUniqueId` AS `itemId`, `sort`, `equipSlot` FROM `items`); +ALTER TABLE `items` DROP FOREIGN KEY `items_ibfk_1`; +ALTER TABLE `items` DROP `characterId`; +ALTER TABLE `items` DROP `sort`; +ALTER TABLE `items` DROP `equipSlot`; diff --git a/sql/update-2023-05-10_1.sql b/sql/update-2023-05-10_1.sql new file mode 100644 index 000000000..525a117c1 --- /dev/null +++ b/sql/update-2023-05-10_1.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` CHANGE `settings` `settings` VARCHAR(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; diff --git a/sql/update-2023-05-11_1.sql b/sql/update-2023-05-11_1.sql new file mode 100644 index 000000000..dbab81bfb --- /dev/null +++ b/sql/update-2023-05-11_1.sql @@ -0,0 +1 @@ +ALTER TABLE `jobs` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-05-21_1.sql b/sql/update-2023-05-21_1.sql new file mode 100644 index 000000000..040bb7024 --- /dev/null +++ b/sql/update-2023-05-21_1.sql @@ -0,0 +1,8 @@ +DELETE FROM `character_properties` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); +DELETE FROM `skills` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); + +ALTER TABLE `character_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `chatmacros` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `revealedmaps` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `session_objects_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `skills` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-05-22_1.sql b/sql/update-2023-05-22_1.sql new file mode 100644 index 000000000..ec6c30e35 --- /dev/null +++ b/sql/update-2023-05-22_1.sql @@ -0,0 +1,3 @@ +ALTER TABLE `character_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `id`; +UPDATE `character_properties` SET `name` = CAST(`id` AS CHAR(64)); +ALTER TABLE `character_properties` DROP `id`; diff --git a/sql/update-2023-05-22_2.sql b/sql/update-2023-05-22_2.sql new file mode 100644 index 000000000..c35a351df --- /dev/null +++ b/sql/update-2023-05-22_2.sql @@ -0,0 +1,4 @@ +ALTER TABLE `session_objects_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `propertyId`; +ALTER TABLE `session_objects_properties` ADD `type` VARCHAR(1) NOT NULL AFTER `name`; +UPDATE `session_objects_properties` SET `name` = CAST(`propertyId` AS CHAR(64)); +ALTER TABLE `session_objects_properties` DROP `propertyId`; diff --git a/sql/update-2023-05-23_1.sql b/sql/update-2023-05-23_1.sql new file mode 100644 index 000000000..1388ed259 --- /dev/null +++ b/sql/update-2023-05-23_1.sql @@ -0,0 +1,2 @@ +ALTER TABLE `characters` ADD `bd` FLOAT NOT NULL AFTER `bz`; +UPDATE `characters` SET `bd` = FLOOR(RAND() * 180); diff --git a/sql/update-2023-05-25_1.sql b/sql/update-2023-05-25_1.sql new file mode 100644 index 000000000..32be3999d --- /dev/null +++ b/sql/update-2023-05-25_1.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` ADD `barracksThema` INT NOT NULL DEFAULT '11' AFTER `teamExp`; diff --git a/sql/update-2023-05-25_2.sql b/sql/update-2023-05-25_2.sql new file mode 100644 index 000000000..1b9e6155a --- /dev/null +++ b/sql/update-2023-05-25_2.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` ADD `themas` VARCHAR(128) NOT NULL DEFAULT '11' AFTER `barracksThema`; diff --git a/sql/update-2023-05-29_1.sql b/sql/update-2023-05-29_1.sql new file mode 100644 index 000000000..feeede46b --- /dev/null +++ b/sql/update-2023-05-29_1.sql @@ -0,0 +1,4 @@ +ALTER TABLE `characters` CHANGE `exp` `exp` BIGINT NOT NULL DEFAULT '0', + CHANGE `maxExp` `maxExp` BIGINT NOT NULL DEFAULT '1000', + CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; +ALTER TABLE `jobs` CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; diff --git a/sql/update-2023-05-31_1.sql b/sql/update-2023-05-31_1.sql new file mode 100644 index 000000000..2d3e796aa --- /dev/null +++ b/sql/update-2023-05-31_1.sql @@ -0,0 +1,2 @@ +UPDATE `vars` SET `name` = "Melia.PropertiesInitialized" WHERE `name` = "PropertiesInitialized"; +UPDATE `vars` SET `name` = "Melia.QuickSlotList" WHERE `name` = "_QuickSlotList"; diff --git a/sql/update-2023-05-31_2.sql b/sql/update-2023-05-31_2.sql new file mode 100644 index 000000000..9e76dc539 --- /dev/null +++ b/sql/update-2023-05-31_2.sql @@ -0,0 +1 @@ +DELETE FROM `vars` WHERE `name` = "Melia.QuickSlotList"; diff --git a/sql/update-2023-06-01_1.sql b/sql/update-2023-06-01_1.sql new file mode 100644 index 000000000..b69fc551c --- /dev/null +++ b/sql/update-2023-06-01_1.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` ADD `selectedSlot` TINYINT NOT NULL DEFAULT '0' AFTER `themas`; diff --git a/sql/update-2023-06-02_1.sql b/sql/update-2023-06-02_1.sql new file mode 100644 index 000000000..01df8c89a --- /dev/null +++ b/sql/update-2023-06-02_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `equipVisibility` INT NOT NULL DEFAULT 0xFFFF AFTER `silver`; diff --git a/sql/update-2023-06-03_1.sql b/sql/update-2023-06-03_1.sql new file mode 100644 index 000000000..682fbaae0 --- /dev/null +++ b/sql/update-2023-06-03_1.sql @@ -0,0 +1,67 @@ +START TRANSACTION; + + +-- Add new character vars table +CREATE TABLE `vars_characters` ( + `varId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `vars_characters` + ADD PRIMARY KEY (`varId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `vars_characters` + MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `vars_characters` + ADD CONSTRAINT `vars_characters_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- Remove variables of characters that don't exist anymore +DELETE FROM `vars` WHERE `owner` LIKE "character:%" AND SUBSTRING(`owner`, 11) NOT IN (SELECT `characterId` FROM `characters`); + +-- Move remaining variables to new table +INSERT INTO `vars_characters` (`characterId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 11) AS `characterId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "character:%"; + +-- Remove old vars +DELETE FROM `vars` WHERE `owner` LIKE "character:%"; + + +-- Add new account vars table +CREATE TABLE `vars_accounts` ( + `varId` bigint(20) NOT NULL, + `accountId` bigint(20) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `vars_accounts` + ADD PRIMARY KEY (`varId`), + ADD KEY `accountId` (`accountId`); + +ALTER TABLE `vars_accounts` + MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `vars_accounts` + ADD CONSTRAINT `vars_accounts_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `characters` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- Remove variables of characters that don't exist anymore +DELETE FROM `vars` WHERE `owner` LIKE "account:%" AND SUBSTRING(`owner`, 9) NOT IN (SELECT `accountId` FROM `characters`); + +-- Move remaining variables to new table +INSERT INTO `vars_accounts` (`accountId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 9) AS `accountId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "account:%"; + +-- Remove old vars +DELETE FROM `vars` WHERE `owner` LIKE "account:%"; + + +-- Turn vars table in global vars +RENAME TABLE `vars` TO `vars_global`; +ALTER TABLE `vars_global` DROP `owner`; + + +COMMIT; diff --git a/sql/update-2023-06-03_2.sql b/sql/update-2023-06-03_2.sql new file mode 100644 index 000000000..892e64b19 --- /dev/null +++ b/sql/update-2023-06-03_2.sql @@ -0,0 +1,18 @@ +CREATE TABLE `buffs` ( + `buffId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `classId` int(11) NOT NULL, + `numArg1` int(11) NOT NULL, + `numArg2` int(11) NOT NULL, + `remainingDuration` time NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `buffs` + ADD PRIMARY KEY (`buffId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `buffs` + MODIFY `buffId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `buffs` + ADD CONSTRAINT `buffs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-06-26_1.sql b/sql/update-2023-06-26_1.sql new file mode 100644 index 000000000..8eee1f5d1 --- /dev/null +++ b/sql/update-2023-06-26_1.sql @@ -0,0 +1,18 @@ +CREATE TABLE `cooldowns` ( + `cooldownId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `classId` int(11) NOT NULL, + `remaining` time NOT NULL, + `duration` time NOT NULL, + `startTime` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `cooldowns` + ADD PRIMARY KEY (`cooldownId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `cooldowns` + MODIFY `cooldownId` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; + +ALTER TABLE `cooldowns` + ADD CONSTRAINT `cooldowns_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-06-27_1.sql b/sql/update-2023-06-27_1.sql new file mode 100644 index 000000000..9e5de6a0f --- /dev/null +++ b/sql/update-2023-06-27_1.sql @@ -0,0 +1,17 @@ +CREATE TABLE `vars_buffs` ( + `varId` bigint(20) NOT NULL, + `buffId` bigint(20) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `vars_buffs` + ADD PRIMARY KEY (`varId`), + ADD KEY `characterId` (`buffId`); + +ALTER TABLE `vars_buffs` + MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `vars_buffs` + ADD CONSTRAINT `vars_buffs_ibfk_1` FOREIGN KEY (`buffId`) REFERENCES `buffs` (`buffId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-06-30_1.sql b/sql/update-2023-06-30_1.sql new file mode 100644 index 000000000..e4dcb671b --- /dev/null +++ b/sql/update-2023-06-30_1.sql @@ -0,0 +1,34 @@ +CREATE TABLE `quests` ( + `questId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `classId` int(11) NOT NULL, + `status` int(11) NOT NULL, + `startTime` datetime NOT NULL, + `completeTime` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `quests_progress` ( + `questId` bigint(20) NOT NULL, + `characterId` bigint(20) NOT NULL, + `ident` varchar(64) CHARACTER SET utf8mb4 NOT NULL, + `count` int(11) NOT NULL, + `done` tinyint(1) NOT NULL, + `unlocked` tinyint(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +ALTER TABLE `quests` + ADD PRIMARY KEY (`questId`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `quests_progress` + ADD PRIMARY KEY (`questId`,`ident`), + ADD KEY `characterId` (`characterId`); + +ALTER TABLE `quests` + MODIFY `questId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `quests` + ADD CONSTRAINT `quests_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `quests_progress` + ADD CONSTRAINT `quests_progress_ibfk_1` FOREIGN KEY (`questId`) REFERENCES `quests` (`questId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2023-07-03_1.sql b/sql/update-2023-07-03_1.sql new file mode 100644 index 000000000..af7019c1d --- /dev/null +++ b/sql/update-2023-07-03_1.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +DELETE FROM `abilities` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); +ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +COMMIT; diff --git a/sql/update-2023-07-03_2.sql b/sql/update-2023-07-03_2.sql new file mode 100644 index 000000000..5c3ff38fe --- /dev/null +++ b/sql/update-2023-07-03_2.sql @@ -0,0 +1 @@ +ALTER TABLE `abilities` ADD `active` BOOLEAN NOT NULL DEFAULT TRUE AFTER `level`; diff --git a/sql/update-2023-07-12_1.sql b/sql/update-2023-07-12_1.sql new file mode 100644 index 000000000..07eb2f3f4 --- /dev/null +++ b/sql/update-2023-07-12_1.sql @@ -0,0 +1,3 @@ +ALTER TABLE `accounts` +ADD `loginState` TINYINT NOT NULL DEFAULT '0' AFTER `selectedSlot`, +ADD `loginCharacter` BIGINT NOT NULL DEFAULT '0' AFTER `loginState`; diff --git a/sql/update-2023-07-15_1.sql b/sql/update-2023-07-15_1.sql new file mode 100644 index 000000000..1e6c67c81 --- /dev/null +++ b/sql/update-2023-07-15_1.sql @@ -0,0 +1,17 @@ +CREATE TABLE `account_properties` ( + `propertyId` bigint(20) NOT NULL, + `accountId` bigint(20) NOT NULL, + `name` varchar(64) NOT NULL, + `type` varchar(1) NOT NULL, + `value` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `account_properties` + ADD PRIMARY KEY (`propertyId`), + ADD KEY `accountId` (`accountId`); + +ALTER TABLE `account_properties` + MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `account_properties` + ADD CONSTRAINT `account_properties_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2024-03-11_1.sql b/sql/update-2024-03-11_1.sql new file mode 100644 index 000000000..7bb0a3dbe --- /dev/null +++ b/sql/update-2024-03-11_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `skinColor` INT UNSIGNED NOT NULL DEFAULT 0xFF808080 AFTER `hair`; diff --git a/sql/update_2015-08-17_1.sql b/sql/update_2015-08-17_1.sql new file mode 100644 index 000000000..8c97ef633 --- /dev/null +++ b/sql/update_2015-08-17_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `teamName` VARCHAR(32) NOT NULL AFTER `name`; diff --git a/sql/update_2015-08-17_2.sql b/sql/update_2015-08-17_2.sql new file mode 100644 index 000000000..02610422e --- /dev/null +++ b/sql/update_2015-08-17_2.sql @@ -0,0 +1,2 @@ +ALTER TABLE `characters` ADD `zone` INT NOT NULL AFTER `level`; +ALTER TABLE `characters` ADD `exp` INT NOT NULL DEFAULT '0' , ADD `maxExp` INT NOT NULL DEFAULT '1000' , ADD `hp` INT NOT NULL DEFAULT '100' , ADD `maxHp` INT NOT NULL DEFAULT '100' , ADD `sp` INT NOT NULL DEFAULT '50' , ADD `maxSp` INT NOT NULL DEFAULT '50' , ADD `stamina` INT NOT NULL DEFAULT '50000' ; diff --git a/sql/update_2015-08-17_3.sql b/sql/update_2015-08-17_3.sql new file mode 100644 index 000000000..d3bd91eeb --- /dev/null +++ b/sql/update_2015-08-17_3.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `bx` FLOAT NOT NULL AFTER `level`, ADD `by` FLOAT NOT NULL AFTER `bx`, ADD `bz` FLOAT NOT NULL AFTER `by`; diff --git a/sql/update_2015-08-20_1.sql b/sql/update_2015-08-20_1.sql new file mode 100644 index 000000000..31a1371ab --- /dev/null +++ b/sql/update_2015-08-20_1.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS `items` ( + `characterId` bigint(11) NOT NULL, + `itemId` int(11) NOT NULL, + `amount` int(11) NOT NULL, + `sort` int(11) NOT NULL, + KEY `characterId` (`characterId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `items` + ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update_2015-08-20_2.sql b/sql/update_2015-08-20_2.sql new file mode 100644 index 000000000..aa7e1523e --- /dev/null +++ b/sql/update_2015-08-20_2.sql @@ -0,0 +1,2 @@ +ALTER TABLE `items` ADD `equipSlot` TINYINT NOT NULL DEFAULT '127' ; +ALTER TABLE `items` ADD `itemUniqueId` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; diff --git a/sql/update_2015-08-27_1.sql b/sql/update_2015-08-27_1.sql new file mode 100644 index 000000000..9118dab3a --- /dev/null +++ b/sql/update_2015-08-27_1.sql @@ -0,0 +1 @@ +ALTER TABLE `characters` ADD `str` FLOAT NOT NULL DEFAULT '1' , ADD `con` FLOAT NOT NULL DEFAULT '1' , ADD `int` FLOAT NOT NULL DEFAULT '1' , ADD `spr` FLOAT NOT NULL DEFAULT '1' , ADD `dex` FLOAT NOT NULL DEFAULT '1' ; diff --git a/sql/update_2015-09-03_1.sql b/sql/update_2015-09-03_1.sql new file mode 100644 index 000000000..d45e33203 --- /dev/null +++ b/sql/update_2015-09-03_1.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` ADD `settings` VARCHAR(512) NOT NULL DEFAULT '' ; diff --git a/sql/update_2015-09-16_1.sql b/sql/update_2015-09-16_1.sql new file mode 100644 index 000000000..08f24b647 --- /dev/null +++ b/sql/update_2015-09-16_1.sql @@ -0,0 +1,3 @@ +ALTER TABLE `characters` ADD `statByLevel` FLOAT NOT NULL DEFAULT '0' ; +ALTER TABLE `characters` ADD `usedStat` FLOAT NOT NULL DEFAULT '0' ; +ALTER TABLE `characters` ADD `statByBonus` FLOAT NOT NULL DEFAULT '0' AFTER `statByLevel`; diff --git a/sql/update_2015-12-12_1.sql b/sql/update_2015-12-12_1.sql new file mode 100644 index 000000000..0475d9f1e --- /dev/null +++ b/sql/update_2015-12-12_1.sql @@ -0,0 +1,3 @@ +UPDATE `characters` SET `stamina` = 25000 WHERE `stamina` = 50000; +ALTER TABLE `characters` ADD `maxStamina` INT NOT NULL DEFAULT '25000' AFTER `stamina`; +ALTER TABLE `characters` CHANGE `stamina` `stamina` INT(11) NOT NULL DEFAULT '25000'; diff --git a/sql/update_2016-04-01_1.sql b/sql/update_2016-04-01_1.sql new file mode 100644 index 000000000..a2ce49001 --- /dev/null +++ b/sql/update_2016-04-01_1.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` ADD `authority` INT NOT NULL DEFAULT '0' AFTER `teamName`; diff --git a/sql/update_2016-04-02_1.sql b/sql/update_2016-04-02_1.sql new file mode 100644 index 000000000..ac2979120 --- /dev/null +++ b/sql/update_2016-04-02_1.sql @@ -0,0 +1,2 @@ +ALTER TABLE `accounts` MODIFY COLUMN `teamName` varchar(64) NULL; +ALTER TABLE `characters` MODIFY COLUMN `teamName` varchar(32) NULL; diff --git a/sql/update_2016-04-03_1.sql b/sql/update_2016-04-03_1.sql new file mode 100644 index 000000000..23ec5585b --- /dev/null +++ b/sql/update_2016-04-03_1.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS `updates` ( + `path` varchar(255) NOT NULL, + PRIMARY KEY (`path`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `updates` (`path`) VALUES +('main.sql'), +('update_2015-08-17_1.sql'), +('update_2015-08-17_2.sql'), +('update_2015-08-17_3.sql'), +('update_2015-08-20_1.sql'), +('update_2015-08-20_2.sql'), +('update_2015-08-27_1.sql'), +('update_2015-09-03_1.sql'), +('update_2015-09-16_1.sql'), +('update_2015-12-12_1.sql'), +('update_2016-04-01_1.sql'), +('update_2016-04-02_1.sql'), +('update_2016-04-03_1.sql'); diff --git a/sql/update_2016-04-11_1.sql b/sql/update_2016-04-11_1.sql new file mode 100644 index 000000000..b19d7e0d2 --- /dev/null +++ b/sql/update_2016-04-11_1.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS `vars` ( + `varId` bigint(20) NOT NULL AUTO_INCREMENT, + `owner` varchar(128) NOT NULL, + `name` varchar(128) NOT NULL, + `type` char(2) NOT NULL, + `value` mediumtext NOT NULL, + PRIMARY KEY (`varId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/sql/update_2016-04-23_1.sql b/sql/update_2016-04-23_1.sql new file mode 100644 index 000000000..a1f055157 --- /dev/null +++ b/sql/update_2016-04-23_1.sql @@ -0,0 +1 @@ +ALTER TABLE `accounts` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; diff --git a/sql/update_2017-09-03_1.sql b/sql/update_2017-09-03_1.sql new file mode 100644 index 000000000..4426de652 --- /dev/null +++ b/sql/update_2017-09-03_1.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS `revealedmaps` ( + `revealedMapId` bigint(20) NOT NULL AUTO_INCREMENT, + `accountId` bigint(20) NOT NULL, + `map` int(11) NOT NULL, + `explored` varbinary(128) NOT NULL, + `percentage` FLOAT(10,2) NOT NULL DEFAULT 0, + PRIMARY KEY (`revealedMapId`), + CONSTRAINT `FK_revealedMaps_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, + CONSTRAINT `UQ_revealedMaps_map` UNIQUE (`accountId`, `map`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; From 06a6f2595fc183fa6dfbc92061ccde07698fe5df Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Fri, 19 Apr 2024 13:32:14 -0300 Subject: [PATCH 09/18] refactor: :recycle: Necessary changes in Merged SQL files to keep SQL entire folder --- sql_start/Merge_All_SQLs.sql | 984 ++++++++++++++++++++++++++--------- 1 file changed, 744 insertions(+), 240 deletions(-) diff --git a/sql_start/Merge_All_SQLs.sql b/sql_start/Merge_All_SQLs.sql index 5a9f1cb87..5a0bd5907 100644 --- a/sql_start/Merge_All_SQLs.sql +++ b/sql_start/Merge_All_SQLs.sql @@ -1,4 +1,5 @@ CREATE DATABASE IF NOT EXISTS `melia` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; + USE `melia`; CREATE TABLE IF NOT EXISTS `accounts` ( @@ -9,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `accounts` ( `authority` int(11) NOT NULL DEFAULT '0', `settings` varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (`accountId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; CREATE TABLE IF NOT EXISTS `characters` ( `characterId` bigint(20) NOT NULL AUTO_INCREMENT, @@ -45,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `characters` ( `usedStat` float NOT NULL DEFAULT '0', PRIMARY KEY (`characterId`), KEY `accountId` (`accountId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; CREATE TABLE IF NOT EXISTS `items` ( `itemUniqueId` bigint(20) NOT NULL AUTO_INCREMENT, @@ -56,16 +57,79 @@ CREATE TABLE IF NOT EXISTS `items` ( `equipSlot` tinyint(4) NOT NULL DEFAULT '127', PRIMARY KEY (`itemUniqueId`), KEY `characterId` (`characterId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; CREATE TABLE IF NOT EXISTS `updates` ( `path` varchar(255) NOT NULL, PRIMARY KEY (`path`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `characters` - ADD CONSTRAINT `characters_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +INSERT INTO + `updates` (`path`) +VALUES + ('main.sql'), + ('update-2017-09-01_1.sql'), + ('update-2017-09-02_1.sql'), + ('update-2017-09-04_1.sql'), + ('update-2017-09-12_1.sql'), + ('update-2017-09-14_1.sql'), + ('update-2017-09-19_1.sql'), + ('update-2017-09-19_2.sql'), + ('update-2017-09-19_3.sql'), + ('update-2017-09-25_1.sql'), + ('update-2017-09-26_1.sql'), + ('update-2017-09-28_1.sql'), + ('update-2017-09-29_1.sql'), + ('update-2017-10-31_1.sql'), + ('update-2021-09-08_1.sql'), + ('update-2021-09-14_1.sql'), + ('update-2021-09-28_1.sql'), + ('update-2021-10-07_1.sql'), + ('update-2021-10-07_2.sql'), + ('update-2021-10-13_1.sql'), + ('update-2023-05-10_1.sql'), + ('update-2023-05-11_1.sql'), + ('update-2023-05-21_1.sql'), + ('update-2023-05-22_1.sql'), + ('update-2023-05-22_2.sql'), + ('update-2023-05-23_1.sql'), + ('update-2023-05-25_1.sql'), + ('update-2023-05-25_2.sql'), + ('update-2023-05-29_1.sql'), + ('update-2023-05-31_1.sql'), + ('update-2023-05-31_2.sql'), + ('update-2023-06-01_1.sql'), + ('update-2023-06-02_1.sql'), + ('update-2023-06-03_1.sql'), + ('update-2023-06-03_2.sql'), + ('update-2023-06-26_1.sql'), + ('update-2023-06-27_1.sql'), + ('update-2023-06-30_1.sql'), + ('update-2023-07-03_1.sql'), + ('update-2023-07-03_2.sql'), + ('update-2023-07-12_1.sql'), + ('update-2023-07-15_1.sql'), + ('update-2024-03-11_1.sql'), + ('update_2015-08-17_1.sql'), + ('update_2015-08-17_2.sql'), + ('update_2015-08-17_3.sql'), + ('update_2015-08-20_1.sql'), + ('update_2015-08-20_2.sql'), + ('update_2015-08-27_1.sql'), + ('update_2015-09-03_1.sql'), + ('update_2015-09-16_1.sql'), + ('update_2015-12-12_1.sql'), + ('update_2016-04-01_1.sql'), + ('update_2016-04-02_1.sql'), + ('update_2016-04-03_1.sql'), + ('update_2016-04-11_1.sql'), + ('update_2016-04-23_1.sql'), + ('update_2017-09-03_1.sql'); + +ALTER TABLE + `characters` +ADD + CONSTRAINT `characters_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE IF NOT EXISTS `items` ( `characterId` bigint(11) NOT NULL, @@ -73,19 +137,37 @@ CREATE TABLE IF NOT EXISTS `items` ( `amount` int(11) NOT NULL, `sort` int(11) NOT NULL, KEY `characterId` (`characterId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `items` - ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -UPDATE `characters` SET `stamina` = 25000 WHERE `stamina` = 50000; -ALTER TABLE `characters` CHANGE `stamina` `stamina` INT(11) NOT NULL DEFAULT '25000'; -ALTER TABLE `accounts` MODIFY COLUMN `teamName` varchar(64) NULL; -ALTER TABLE `characters` MODIFY COLUMN `teamName` varchar(32) NULL; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `items` +ADD + CONSTRAINT `items_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +UPDATE + `characters` +SET + `stamina` = 25000 +WHERE + `stamina` = 50000; + +ALTER TABLE + `characters` CHANGE `stamina` `stamina` INT(11) NOT NULL DEFAULT '25000'; + +ALTER TABLE + `accounts` +MODIFY + COLUMN `teamName` varchar(64) NULL; + +ALTER TABLE + `characters` +MODIFY + COLUMN `teamName` varchar(32) NULL; + CREATE TABLE IF NOT EXISTS `updates` ( `path` varchar(255) NOT NULL, PRIMARY KEY (`path`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +) ENGINE = InnoDB DEFAULT CHARSET = utf8; CREATE TABLE IF NOT EXISTS `vars` ( `varId` bigint(20) NOT NULL AUTO_INCREMENT, @@ -94,9 +176,17 @@ CREATE TABLE IF NOT EXISTS `vars` ( `type` char(2) NOT NULL, `value` mediumtext NOT NULL, PRIMARY KEY (`varId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -ALTER TABLE `accounts` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; -ALTER TABLE `characters` ADD COLUMN `barrackLayer` INT NOT NULL DEFAULT 1;CREATE TABLE IF NOT EXISTS `chatmacros` ( +) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; + +ALTER TABLE + `accounts` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; + +ALTER TABLE + `characters` +ADD + COLUMN `barrackLayer` INT NOT NULL DEFAULT 1; + +CREATE TABLE IF NOT EXISTS `chatmacros` ( `chatMacroId` bigint(20) NOT NULL AUTO_INCREMENT, `accountId` bigint(20) NOT NULL, `index` tinyint(4) NOT NULL, @@ -105,188 +195,466 @@ ALTER TABLE `characters` ADD COLUMN `barrackLayer` INT NOT NULL DEFAULT 1;CREATE PRIMARY KEY (`chatMacroId`), CONSTRAINT `FK_ChatMacro_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, CONSTRAINT `UQ_ChatMacro_index` UNIQUE (`accountId`, `index`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; + CREATE TABLE IF NOT EXISTS `revealedmaps` ( `revealedMapId` bigint(20) NOT NULL AUTO_INCREMENT, `accountId` bigint(20) NOT NULL, `map` int(11) NOT NULL, `explored` varbinary(128) NOT NULL, - `percentage` FLOAT(10,2) NOT NULL DEFAULT 0, + `percentage` FLOAT(10, 2) NOT NULL DEFAULT 0, PRIMARY KEY (`revealedMapId`), CONSTRAINT `FK_revealedMaps_accountId` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE, CONSTRAINT `UQ_revealedMaps_map` UNIQUE (`accountId`, `map`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; -ALTER TABLE `accounts` ADD `medals` INT NOT NULL DEFAULT 0; -ALTER TABLE `accounts` ADD `giftMedals` INT NOT NULL DEFAULT 0; -ALTER TABLE `accounts` ADD `premiumMedals` INT NOT NULL DEFAULT 0; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; + +ALTER TABLE + `accounts` +ADD + `medals` INT NOT NULL DEFAULT 0; + +ALTER TABLE + `accounts` +ADD + `giftMedals` INT NOT NULL DEFAULT 0; + +ALTER TABLE + `accounts` +ADD + `premiumMedals` INT NOT NULL DEFAULT 0; + CREATE TABLE `session_objects_properties` ( `sessionObjectPropertyId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, `sessionObjectId` int(11) NOT NULL, `propertyId` int(11) NOT NULL, `value` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; -ALTER TABLE `session_objects_properties` - ADD PRIMARY KEY (`sessionObjectPropertyId`), - ADD KEY `characterId` (`characterId`); +ALTER TABLE + `session_objects_properties` +ADD + PRIMARY KEY (`sessionObjectPropertyId`), +ADD + KEY `characterId` (`characterId`); -ALTER TABLE `session_objects_properties` - MODIFY `sessionObjectPropertyId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE + `session_objects_properties` +MODIFY + `sessionObjectPropertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE + `session_objects_properties` +ADD + CONSTRAINT `session_object_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `session_objects_properties` - ADD CONSTRAINT `session_object_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE `jobs` ( `characterId` bigint(20) NOT NULL, `jobId` int(11) NOT NULL, `circle` int(11) NOT NULL DEFAULT '1', `skillPoints` int(11) NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `jobs` - ADD PRIMARY KEY (`characterId`,`jobId`); +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `jobs` +ADD + PRIMARY KEY (`characterId`, `jobId`); + +ALTER TABLE + `jobs` +ADD + CONSTRAINT `jobs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `characters` CHANGE `str` `str` INT NOT NULL DEFAULT '1', + CHANGE `con` `con` INT NOT NULL DEFAULT '1', + CHANGE `int` `int` INT NOT NULL DEFAULT '1', + CHANGE `spr` `spr` INT NOT NULL DEFAULT '1', + CHANGE `dex` `dex` INT NOT NULL DEFAULT '1', + CHANGE `statByLevel` `statByLevel` INT NOT NULL DEFAULT '0', + CHANGE `statByBonus` `statByBonus` INT NOT NULL DEFAULT '0', + CHANGE `usedStat` `usedStat` INT NOT NULL DEFAULT '0'; + +ALTER TABLE + `characters` CHANGE `barrackLayer` `barrackLayer` INT(11) NOT NULL DEFAULT '1' +AFTER + `level`; + +ALTER TABLE + `characters` +ADD + `abilityPoints` INT NOT NULL DEFAULT '0' +AFTER + `usedStat`; - -ALTER TABLE `jobs` - ADD CONSTRAINT `jobs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `characters` CHANGE `str` `str` INT NOT NULL DEFAULT '1', - CHANGE `con` `con` INT NOT NULL DEFAULT '1', - CHANGE `int` `int` INT NOT NULL DEFAULT '1', - CHANGE `spr` `spr` INT NOT NULL DEFAULT '1', - CHANGE `dex` `dex` INT NOT NULL DEFAULT '1', - CHANGE `statByLevel` `statByLevel` INT NOT NULL DEFAULT '0', - CHANGE `statByBonus` `statByBonus` INT NOT NULL DEFAULT '0', - CHANGE `usedStat` `usedStat` INT NOT NULL DEFAULT '0'; -ALTER TABLE `characters` CHANGE `barrackLayer` `barrackLayer` INT(11) NOT NULL DEFAULT '1' AFTER `level`; -ALTER TABLE `characters` ADD `abilityPoints` INT NOT NULL DEFAULT '0' AFTER `usedStat`; CREATE TABLE `skills` ( `skillId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, `id` int(11) NOT NULL, `level` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +) ENGINE = InnoDB DEFAULT CHARSET = utf8; -ALTER TABLE `skills` - ADD PRIMARY KEY (`skillId`), - ADD KEY `characterId` (`characterId`); +ALTER TABLE + `skills` +ADD + PRIMARY KEY (`skillId`), +ADD + KEY `characterId` (`characterId`); +ALTER TABLE + `skills` +MODIFY + `skillId` bigint(20) NOT NULL AUTO_INCREMENT; -ALTER TABLE `skills` - MODIFY `skillId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE + `skills` +ADD + CONSTRAINT `skills_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `skills` - ADD CONSTRAINT `skills_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE `abilities` ( `abilityId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, `id` int(11) NOT NULL, `level` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `abilities` - ADD PRIMARY KEY (`abilityId`), - ADD KEY `characterId` (`characterId`); - - -ALTER TABLE `abilities` - MODIFY `abilityId` bigint(20) NOT NULL AUTO_INCREMENT; -ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `characters` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `maxExp`; -ALTER TABLE `jobs` ADD `totalExp` INT NOT NULL DEFAULT '0' AFTER `skillPoints`; -ALTER TABLE `characters` ADD `hpRate` FLOAT NOT NULL DEFAULT '1' AFTER `hp`, - ADD `spRate` FLOAT NOT NULL DEFAULT '1' AFTER `sp`, - ADD `strByJob` INT NOT NULL DEFAULT '0' AFTER `str`, - ADD `conByJob` INT NOT NULL DEFAULT '0' AFTER `con`, - ADD `intByJob` INT NOT NULL DEFAULT '0' AFTER `int`, - ADD `sprByJob` INT NOT NULL DEFAULT '0' AFTER `spr`, - ADD `dexByJob` INT NOT NULL DEFAULT '0' AFTER `dex`, - ADD `staminaByJob` INT NOT NULL DEFAULT '0' AFTER `stamina`, - CHANGE `str` `str` INT NOT NULL DEFAULT '0', - CHANGE `con` `con` INT NOT NULL DEFAULT '0', - CHANGE `int` `int` INT NOT NULL DEFAULT '0', - CHANGE `spr` `spr` INT NOT NULL DEFAULT '0', - CHANGE `dex` `dex` INT NOT NULL DEFAULT '0';ALTER TABLE `characters` CHANGE `hair` `hair` INT NOT NULL; -ALTER TABLE `characters` ADD `slot` INT NOT NULL AFTER `level`; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `abilities` +ADD + PRIMARY KEY (`abilityId`), +ADD + KEY `characterId` (`characterId`); + +ALTER TABLE + `abilities` +MODIFY + `abilityId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE + `abilities` +ADD + FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `characters` +ADD + `totalExp` INT NOT NULL DEFAULT '0' +AFTER + `maxExp`; + +ALTER TABLE + `jobs` +ADD + `totalExp` INT NOT NULL DEFAULT '0' +AFTER + `skillPoints`; + +ALTER TABLE + `characters` +ADD + `hpRate` FLOAT NOT NULL DEFAULT '1' +AFTER + `hp`, +ADD + `spRate` FLOAT NOT NULL DEFAULT '1' +AFTER + `sp`, +ADD + `strByJob` INT NOT NULL DEFAULT '0' +AFTER + `str`, +ADD + `conByJob` INT NOT NULL DEFAULT '0' +AFTER + `con`, +ADD + `intByJob` INT NOT NULL DEFAULT '0' +AFTER + `int`, +ADD + `sprByJob` INT NOT NULL DEFAULT '0' +AFTER + `spr`, +ADD + `dexByJob` INT NOT NULL DEFAULT '0' +AFTER + `dex`, +ADD + `staminaByJob` INT NOT NULL DEFAULT '0' +AFTER + `stamina`, + CHANGE `str` `str` INT NOT NULL DEFAULT '0', + CHANGE `con` `con` INT NOT NULL DEFAULT '0', + CHANGE `int` `int` INT NOT NULL DEFAULT '0', + CHANGE `spr` `spr` INT NOT NULL DEFAULT '0', + CHANGE `dex` `dex` INT NOT NULL DEFAULT '0'; + +ALTER TABLE + `characters` CHANGE `hair` `hair` INT NOT NULL; + +ALTER TABLE + `characters` +ADD + `slot` INT NOT NULL +AFTER + `level`; + CREATE TABLE `character_properties` ( `propertyId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, `id` int(11) NOT NULL, `type` varchar(1) NOT NULL, `value` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -ALTER TABLE `character_properties` - ADD PRIMARY KEY (`propertyId`), - ADD KEY `characterId` (`characterId`); +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `character_properties` +ADD + PRIMARY KEY (`propertyId`), +ADD + KEY `characterId` (`characterId`); + +ALTER TABLE + `character_properties` +MODIFY + `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE + `character_properties` +ADD + CONSTRAINT `character_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `accounts` +ADD + `additionalSlotCount` INT NOT NULL DEFAULT '0' +AFTER + `premiumMedals`; + +ALTER TABLE + `accounts` +ADD + `teamExp` INT NOT NULL DEFAULT '0' +AFTER + `additionalSlotCount`; + +ALTER TABLE + `characters` +ADD + `silver` BIGINT NOT NULL DEFAULT '0' +AFTER + `abilityPoints`; - -ALTER TABLE `character_properties` - MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `character_properties` - ADD CONSTRAINT `character_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `accounts` ADD `additionalSlotCount` INT NOT NULL DEFAULT '0' AFTER `premiumMedals`; -ALTER TABLE `accounts` ADD `teamExp` INT NOT NULL DEFAULT '0' AFTER `additionalSlotCount`; -ALTER TABLE `characters` ADD `silver` BIGINT NOT NULL DEFAULT '0' AFTER `abilityPoints`; CREATE TABLE `inventory` ( `characterId` bigint(20) NOT NULL, `itemId` bigint(20) NOT NULL, `sort` int(11) NOT NULL, `equipSlot` tinyint(4) NOT NULL DEFAULT '127' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TRIGGER `cascadeDeleteItem` AFTER DELETE ON `inventory` FOR EACH ROW - DELETE FROM `items` WHERE `itemUniqueId` = OLD.`itemId`; - -ALTER TABLE `inventory` - ADD PRIMARY KEY (`characterId`,`itemId`), - ADD KEY `itemId` (`itemId`); - -ALTER TABLE `inventory` - ADD CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; - -INSERT INTO `inventory` (SELECT `characterId`, `itemUniqueId` AS `itemId`, `sort`, `equipSlot` FROM `items`); -ALTER TABLE `items` DROP FOREIGN KEY `items_ibfk_1`; -ALTER TABLE `items` DROP `characterId`; -ALTER TABLE `items` DROP `sort`; -ALTER TABLE `items` DROP `equipSlot`; -ALTER TABLE `accounts` CHANGE `settings` `settings` VARCHAR(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; -ALTER TABLE `jobs` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -DELETE FROM `character_properties` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); -DELETE FROM `skills` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); - -ALTER TABLE `character_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `chatmacros` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `revealedmaps` ADD FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `session_objects_properties` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `skills` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `character_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `id`; -UPDATE `character_properties` SET `name` = CAST(`id` AS CHAR(64)); -ALTER TABLE `character_properties` DROP `id`; -ALTER TABLE `session_objects_properties` ADD `name` VARCHAR(64) NOT NULL AFTER `propertyId`; -ALTER TABLE `session_objects_properties` ADD `type` VARCHAR(1) NOT NULL AFTER `name`; -UPDATE `session_objects_properties` SET `name` = CAST(`propertyId` AS CHAR(64)); -ALTER TABLE `session_objects_properties` DROP `propertyId`; -ALTER TABLE `characters` ADD `bd` FLOAT NOT NULL AFTER `bz`; -UPDATE `characters` SET `bd` = FLOOR(RAND() * 180); -ALTER TABLE `accounts` ADD `barracksThema` INT NOT NULL DEFAULT '11' AFTER `teamExp`; -ALTER TABLE `accounts` ADD `themas` VARCHAR(128) NOT NULL DEFAULT '11' AFTER `barracksThema`; -ALTER TABLE `characters` CHANGE `exp` `exp` BIGINT NOT NULL DEFAULT '0', - CHANGE `maxExp` `maxExp` BIGINT NOT NULL DEFAULT '1000', - CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; -ALTER TABLE `jobs` CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; -UPDATE `vars` SET `name` = "Melia.PropertiesInitialized" WHERE `name` = "PropertiesInitialized"; -UPDATE `vars` SET `name` = "Melia.QuickSlotList" WHERE `name` = "_QuickSlotList"; -DELETE FROM `vars` WHERE `name` = "Melia.QuickSlotList"; -ALTER TABLE `accounts` ADD `selectedSlot` TINYINT NOT NULL DEFAULT '0' AFTER `themas`; -ALTER TABLE `characters` ADD `equipVisibility` INT NOT NULL DEFAULT 0xFFFF AFTER `silver`; -START TRANSACTION; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +CREATE TRIGGER `cascadeDeleteItem` +AFTER + DELETE ON `inventory` FOR EACH ROW +DELETE FROM + `items` +WHERE + `itemUniqueId` = OLD.`itemId`; + +ALTER TABLE + `inventory` +ADD + PRIMARY KEY (`characterId`, `itemId`), +ADD + KEY `itemId` (`itemId`); + +ALTER TABLE + `inventory` +ADD + CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, +ADD + CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; + +INSERT INTO + `inventory` ( + SELECT + `characterId`, + `itemUniqueId` AS `itemId`, + `sort`, + `equipSlot` + FROM + `items` + ); + +ALTER TABLE + `items` DROP FOREIGN KEY `items_ibfk_1`; + +ALTER TABLE + `items` DROP `characterId`; + +ALTER TABLE + `items` DROP `sort`; + +ALTER TABLE + `items` DROP `equipSlot`; + +ALTER TABLE + `accounts` CHANGE `settings` `settings` VARCHAR(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; + +ALTER TABLE + `jobs` +ADD + FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +DELETE FROM + `character_properties` +WHERE + `characterId` NOT IN ( + SELECT + `characterId` + FROM + `characters` + ); + +DELETE FROM + `skills` +WHERE + `characterId` NOT IN ( + SELECT + `characterId` + FROM + `characters` + ); + +ALTER TABLE + `character_properties` +ADD + FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `chatmacros` +ADD + FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `revealedmaps` +ADD + FOREIGN KEY (`accountId`) REFERENCES `accounts`(`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `session_objects_properties` +ADD + FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `skills` +ADD + FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `character_properties` +ADD + `name` VARCHAR(64) NOT NULL +AFTER + `id`; + +UPDATE + `character_properties` +SET + `name` = CAST(`id` AS CHAR(64)); + +ALTER TABLE + `character_properties` DROP `id`; + +ALTER TABLE + `session_objects_properties` +ADD + `name` VARCHAR(64) NOT NULL +AFTER + `propertyId`; + +ALTER TABLE + `session_objects_properties` +ADD + `type` VARCHAR(1) NOT NULL +AFTER + `name`; + +UPDATE + `session_objects_properties` +SET + `name` = CAST(`propertyId` AS CHAR(64)); + +ALTER TABLE + `session_objects_properties` DROP `propertyId`; + +ALTER TABLE + `characters` +ADD + `bd` FLOAT NOT NULL +AFTER + `bz`; + +UPDATE + `characters` +SET + `bd` = FLOOR(RAND() * 180); + +ALTER TABLE + `accounts` +ADD + `barracksThema` INT NOT NULL DEFAULT '11' +AFTER + `teamExp`; + +ALTER TABLE + `accounts` +ADD + `themas` VARCHAR(128) NOT NULL DEFAULT '11' +AFTER + `barracksThema`; + +ALTER TABLE + `characters` CHANGE `exp` `exp` BIGINT NOT NULL DEFAULT '0', + CHANGE `maxExp` `maxExp` BIGINT NOT NULL DEFAULT '1000', + CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; + +ALTER TABLE + `jobs` CHANGE `totalExp` `totalExp` BIGINT NOT NULL DEFAULT '0'; + +UPDATE + `vars` +SET + `name` = "Melia.PropertiesInitialized" +WHERE + `name` = "PropertiesInitialized"; + +UPDATE + `vars` +SET + `name` = "Melia.QuickSlotList" +WHERE + `name` = "_QuickSlotList"; + +DELETE FROM + `vars` +WHERE + `name` = "Melia.QuickSlotList"; + +ALTER TABLE + `accounts` +ADD + `selectedSlot` TINYINT NOT NULL DEFAULT '0' +AFTER + `themas`; + +ALTER TABLE + `characters` +ADD + `equipVisibility` INT NOT NULL DEFAULT 0xFFFF +AFTER + `silver`; +START TRANSACTION; -- Add new character vars table CREATE TABLE `vars_characters` ( @@ -295,27 +663,55 @@ CREATE TABLE `vars_characters` ( `name` varchar(128) NOT NULL, `type` char(2) NOT NULL, `value` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 ROW_FORMAT = COMPACT; -ALTER TABLE `vars_characters` - ADD PRIMARY KEY (`varId`), - ADD KEY `characterId` (`characterId`); +ALTER TABLE + `vars_characters` +ADD + PRIMARY KEY (`varId`), +ADD + KEY `characterId` (`characterId`); -ALTER TABLE `vars_characters` - MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE + `vars_characters` +MODIFY + `varId` bigint(20) NOT NULL AUTO_INCREMENT; -ALTER TABLE `vars_characters` - ADD CONSTRAINT `vars_characters_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE + `vars_characters` +ADD + CONSTRAINT `vars_characters_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -- Remove variables of characters that don't exist anymore -DELETE FROM `vars` WHERE `owner` LIKE "character:%" AND SUBSTRING(`owner`, 11) NOT IN (SELECT `characterId` FROM `characters`); +DELETE FROM + `vars` +WHERE + `owner` LIKE "character:%" + AND SUBSTRING(`owner`, 11) NOT IN ( + SELECT + `characterId` + FROM + `characters` + ); -- Move remaining variables to new table -INSERT INTO `vars_characters` (`characterId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 11) AS `characterId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "character:%"; +INSERT INTO + `vars_characters` (`characterId`, `name`, `type`, `value`) +SELECT + SUBSTRING(`owner`, 11) AS `characterId`, + `name`, + `type`, + `value` +FROM + `vars` +WHERE + `owner` LIKE "character:%"; -- Remove old vars -DELETE FROM `vars` WHERE `owner` LIKE "character:%"; - +DELETE FROM + `vars` +WHERE + `owner` LIKE "character:%"; -- Add new account vars table CREATE TABLE `vars_accounts` ( @@ -324,34 +720,64 @@ CREATE TABLE `vars_accounts` ( `name` varchar(128) NOT NULL, `type` char(2) NOT NULL, `value` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 ROW_FORMAT = COMPACT; -ALTER TABLE `vars_accounts` - ADD PRIMARY KEY (`varId`), - ADD KEY `accountId` (`accountId`); +ALTER TABLE + `vars_accounts` +ADD + PRIMARY KEY (`varId`), +ADD + KEY `accountId` (`accountId`); -ALTER TABLE `vars_accounts` - MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE + `vars_accounts` +MODIFY + `varId` bigint(20) NOT NULL AUTO_INCREMENT; -ALTER TABLE `vars_accounts` - ADD CONSTRAINT `vars_accounts_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `characters` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE + `vars_accounts` +ADD + CONSTRAINT `vars_accounts_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `characters` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; -- Remove variables of characters that don't exist anymore -DELETE FROM `vars` WHERE `owner` LIKE "account:%" AND SUBSTRING(`owner`, 9) NOT IN (SELECT `accountId` FROM `characters`); +DELETE FROM + `vars` +WHERE + `owner` LIKE "account:%" + AND SUBSTRING(`owner`, 9) NOT IN ( + SELECT + `accountId` + FROM + `characters` + ); -- Move remaining variables to new table -INSERT INTO `vars_accounts` (`accountId`, `name`, `type`, `value`) SELECT SUBSTRING(`owner`, 9) AS `accountId`, `name`, `type`, `value` FROM `vars` WHERE `owner` LIKE "account:%"; +INSERT INTO + `vars_accounts` (`accountId`, `name`, `type`, `value`) +SELECT + SUBSTRING(`owner`, 9) AS `accountId`, + `name`, + `type`, + `value` +FROM + `vars` +WHERE + `owner` LIKE "account:%"; -- Remove old vars -DELETE FROM `vars` WHERE `owner` LIKE "account:%"; - +DELETE FROM + `vars` +WHERE + `owner` LIKE "account:%"; -- Turn vars table in global vars RENAME TABLE `vars` TO `vars_global`; -ALTER TABLE `vars_global` DROP `owner`; +ALTER TABLE + `vars_global` DROP `owner`; COMMIT; + CREATE TABLE `buffs` ( `buffId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, @@ -359,17 +785,25 @@ CREATE TABLE `buffs` ( `numArg1` int(11) NOT NULL, `numArg2` int(11) NOT NULL, `remainingDuration` time NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `buffs` +ADD + PRIMARY KEY (`buffId`), +ADD + KEY `characterId` (`characterId`); -ALTER TABLE `buffs` - ADD PRIMARY KEY (`buffId`), - ADD KEY `characterId` (`characterId`); +ALTER TABLE + `buffs` +MODIFY + `buffId` bigint(20) NOT NULL AUTO_INCREMENT; -ALTER TABLE `buffs` - MODIFY `buffId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE + `buffs` +ADD + CONSTRAINT `buffs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `buffs` - ADD CONSTRAINT `buffs_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE `cooldowns` ( `cooldownId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, @@ -377,34 +811,51 @@ CREATE TABLE `cooldowns` ( `remaining` time NOT NULL, `duration` time NOT NULL, `startTime` datetime NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `cooldowns` - ADD PRIMARY KEY (`cooldownId`), - ADD KEY `characterId` (`characterId`); +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `cooldowns` +ADD + PRIMARY KEY (`cooldownId`), +ADD + KEY `characterId` (`characterId`); + +ALTER TABLE + `cooldowns` +MODIFY + `cooldownId` bigint(20) NOT NULL AUTO_INCREMENT, + AUTO_INCREMENT = 13; + +ALTER TABLE + `cooldowns` +ADD + CONSTRAINT `cooldowns_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `cooldowns` - MODIFY `cooldownId` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; - -ALTER TABLE `cooldowns` - ADD CONSTRAINT `cooldowns_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE `vars_buffs` ( `varId` bigint(20) NOT NULL, `buffId` bigint(20) NOT NULL, `name` varchar(128) NOT NULL, `type` char(2) NOT NULL, `value` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 ROW_FORMAT = COMPACT; + +ALTER TABLE + `vars_buffs` +ADD + PRIMARY KEY (`varId`), +ADD + KEY `characterId` (`buffId`); -ALTER TABLE `vars_buffs` - ADD PRIMARY KEY (`varId`), - ADD KEY `characterId` (`buffId`); +ALTER TABLE + `vars_buffs` +MODIFY + `varId` bigint(20) NOT NULL AUTO_INCREMENT; -ALTER TABLE `vars_buffs` - MODIFY `varId` bigint(20) NOT NULL AUTO_INCREMENT; +ALTER TABLE + `vars_buffs` +ADD + CONSTRAINT `vars_buffs_ibfk_1` FOREIGN KEY (`buffId`) REFERENCES `buffs` (`buffId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `vars_buffs` - ADD CONSTRAINT `vars_buffs_ibfk_1` FOREIGN KEY (`buffId`) REFERENCES `buffs` (`buffId`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE `quests` ( `questId` bigint(20) NOT NULL, `characterId` bigint(20) NOT NULL, @@ -412,7 +863,7 @@ CREATE TABLE `quests` ( `status` int(11) NOT NULL, `startTime` datetime NOT NULL, `completeTime` datetime NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; CREATE TABLE `quests_progress` ( `questId` bigint(20) NOT NULL, @@ -421,49 +872,102 @@ CREATE TABLE `quests_progress` ( `count` int(11) NOT NULL, `done` tinyint(1) NOT NULL, `unlocked` tinyint(1) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; - -ALTER TABLE `quests` - ADD PRIMARY KEY (`questId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `quests_progress` - ADD PRIMARY KEY (`questId`,`ident`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `quests` - MODIFY `questId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `quests` - ADD CONSTRAINT `quests_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +) ENGINE = InnoDB DEFAULT CHARSET = utf8 ROW_FORMAT = COMPACT; + +ALTER TABLE + `quests` +ADD + PRIMARY KEY (`questId`), +ADD + KEY `characterId` (`characterId`); + +ALTER TABLE + `quests_progress` +ADD + PRIMARY KEY (`questId`, `ident`), +ADD + KEY `characterId` (`characterId`); + +ALTER TABLE + `quests` +MODIFY + `questId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE + `quests` +ADD + CONSTRAINT `quests_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `quests_progress` +ADD + CONSTRAINT `quests_progress_ibfk_1` FOREIGN KEY (`questId`) REFERENCES `quests` (`questId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `quests_progress` - ADD CONSTRAINT `quests_progress_ibfk_1` FOREIGN KEY (`questId`) REFERENCES `quests` (`questId`) ON DELETE CASCADE ON UPDATE CASCADE; START TRANSACTION; -DELETE FROM `abilities` WHERE `characterId` NOT IN (SELECT `characterId` FROM `characters`); -ALTER TABLE `abilities` ADD FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +DELETE FROM + `abilities` +WHERE + `characterId` NOT IN ( + SELECT + `characterId` + FROM + `characters` + ); + +ALTER TABLE + `abilities` +ADD + FOREIGN KEY (`characterId`) REFERENCES `characters`(`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; COMMIT; -ALTER TABLE `abilities` ADD `active` BOOLEAN NOT NULL DEFAULT TRUE AFTER `level`; -ALTER TABLE `accounts` -ADD `loginState` TINYINT NOT NULL DEFAULT '0' AFTER `selectedSlot`, -ADD `loginCharacter` BIGINT NOT NULL DEFAULT '0' AFTER `loginState`; + +ALTER TABLE + `abilities` +ADD + `active` BOOLEAN NOT NULL DEFAULT TRUE +AFTER + `level`; + +ALTER TABLE + `accounts` +ADD + `loginState` TINYINT NOT NULL DEFAULT '0' +AFTER + `selectedSlot`, +ADD + `loginCharacter` BIGINT NOT NULL DEFAULT '0' +AFTER + `loginState`; + CREATE TABLE `account_properties` ( `propertyId` bigint(20) NOT NULL, `accountId` bigint(20) NOT NULL, `name` varchar(64) NOT NULL, `type` varchar(1) NOT NULL, `value` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `account_properties` - ADD PRIMARY KEY (`propertyId`), - ADD KEY `accountId` (`accountId`); - -ALTER TABLE `account_properties` - MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `account_properties` - ADD CONSTRAINT `account_properties_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `characters` ADD `skinColor` INT UNSIGNED NOT NULL DEFAULT 0xFF808080 AFTER `hair`; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + +ALTER TABLE + `account_properties` +ADD + PRIMARY KEY (`propertyId`), +ADD + KEY `accountId` (`accountId`); + +ALTER TABLE + `account_properties` +MODIFY + `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; + +ALTER TABLE + `account_properties` +ADD + CONSTRAINT `account_properties_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE + `characters` +ADD + `skinColor` INT UNSIGNED NOT NULL DEFAULT 0xFF808080 +AFTER + `hair`; \ No newline at end of file From 2bb0a584348f0d7c50aa68b47dd9eeaa4c932c07 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Tue, 23 Apr 2024 18:15:51 -0300 Subject: [PATCH 10/18] fix: :zap: Make sure database started before starting servers --- docker-compose.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 066b3c2a5..5f61015cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,11 @@ services: restart: ${SERVER_RESTART} env_file: - ./.env + healthcheck: + test: "/usr/bin/mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --execute \"SHOW DATABASES;\"" + interval: 5s + timeout: 10s + retries: 40 melia-server: container_name: melia-server command: "./start ${ENVIRONMENT}" @@ -24,7 +29,8 @@ services: volumes: - ./:/melia depends_on: - - melia-database + melia-database: + condition: service_healthy ports: - "2000:2000" - "6001:6001" @@ -50,5 +56,8 @@ services: profiles: [] env_file: - ./.env + depends_on: + melia-database: + condition: service_healthy networks: melia-network: From cc5879c9e4175de6a56972e15d94789fc46c72f3 Mon Sep 17 00:00:00 2001 From: Gustavo Barbosa Date: Tue, 23 Apr 2024 18:30:45 -0300 Subject: [PATCH 11/18] docs: :memo: Improve documentation ordering for branch specifics --- README.md | 66 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d4471e050..c7f5cb37f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,30 @@ with any services provided by game developers or publishers, and we don't endorse such actions. We're here to learn and create, not to steal or destroy. + +State of Development +----------------------------------------------------------------------------- + +Melia has been in semi-active development for several years, and is +being worked on more or less depending on the time and motivation of +the available developers. The server is functional and provides many +of the typical features you would expect from an online RPG, but +there's still a way to go before we'd call it truly playable. + +Specifically, some of the major features that are working are as follows: +- Characters (creation, deletion, etc.) +- Inventory (managing items, equipping, etc.) +- Chat +- Stats +- Skills + - Distrbution of skill points + - Basic and experimental combat, incl. monster AI + - Basic and experimental support for select skills +- NPC dialogues and shops +- Monster spawns +- Quests + + Installation with Docker ----------------------------------------------------------------------------- @@ -72,7 +96,6 @@ is `123456` (You can change password on `.env`, but remember to change on By default, database will be loaded with data from `sql_start/Merge_All_SQLs.sql`. - Client ----------------------------------------------------------------------------- @@ -109,29 +132,21 @@ This will create an account with username `myaccount` and password but you'll already be connected and playing. Next time, just login with your username without the `new__` prefix. -State of Development + +Installation from scratch ----------------------------------------------------------------------------- -Melia has been in semi-active development for several years, and is -being worked on more or less depending on the time and motivation of -the available developers. The server is functional and provides many -of the typical features you would expect from an online RPG, but -there's still a way to go before we'd call it truly playable. +* Compile Melia +* Run `sql/main.sql` to setup the database +* Copy `system/conf/database.conf` to `user/conf/`, + adjust the necessary values and remove the rest. -Specifically, some of the major features that are working are as follows: -- Characters (creation, deletion, etc.) -- Inventory (managing items, equipping, etc.) -- Chat -- Stats -- Skills - - Distrbution of skill points - - Basic and experimental combat, incl. monster AI - - Basic and experimental support for select skills -- NPC dialogues and shops -- Monster spawns -- Quests +Afterwards, you should be able to start Melia via the provided scripts or +directly from the bin directories. If not, or if you need a more detailed +guide, head over to our forum, the chat, or the wiki. -Requirements + +Requirements to build from scratch ----------------------------------------------------------------------------- Melia is being developed in C# (.NET 8+) and uses a MySQL database for @@ -147,17 +162,6 @@ macOS, you will need to install the SDK as well. For more detailed instructions, please wait patiently while we give our documentation a much-needed overhaul. It's only a matter of time. -Installation ------------------------------------------------------------------------------ - -* Compile Melia -* Run `sql/main.sql` to setup the database -* Copy `system/conf/database.conf` to `user/conf/`, - adjust the necessary values and remove the rest. - -Afterwards, you should be able to start Melia via the provided scripts or -directly from the bin directories. If not, or if you need a more detailed -guide, head over to our forum, the chat, or the wiki. Contribution ----------------------------------------------------------------------------- From e45283e40030895d6ae7c4c59f9f50f8501b0ae7 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Fri, 9 Aug 2024 19:28:10 +0900 Subject: [PATCH 12/18] more commands --- .../Commands/ChatCommands.Handlers.cs | 258 +++++++++++++++++- system/conf/commands.conf | 13 + 2 files changed, 265 insertions(+), 6 deletions(-) diff --git a/src/ZoneServer/Commands/ChatCommands.Handlers.cs b/src/ZoneServer/Commands/ChatCommands.Handlers.cs index 65d25d527..83ee4b027 100644 --- a/src/ZoneServer/Commands/ChatCommands.Handlers.cs +++ b/src/ZoneServer/Commands/ChatCommands.Handlers.cs @@ -62,7 +62,20 @@ public ChatCommands() this.Add("item", " [amount]", "Spawns item.", this.HandleItem); this.Add("silver", "", "Spawns silver.", this.HandleSilver); this.Add("spawn", " [amount=1] ['ai'=BasicMonster] ['tendency'=peaceful] ['hp'=amount]", "Spawns monster.", this.HandleSpawn); - this.Add("madhatter", "", "Spawns all headgears.", this.HandleGetAllHats); + + this.Add("madhatter", "", "Spawns all hair accessories.", this.HandleGetAllHairAccessories); + this.Add("getallwings", "", "Spawns all wings.", this.HandleGetAllWings); + this.Add("getalltoys", "", "Spawns all toys.", this.HandleGetAllToys); + this.Add("getallarmbands", "", "Spawns all armbands.", this.HandleGetAllArmbands); + this.Add("getallcostumes", "", "Spawns all costumes.", this.HandleGetAllCostumes); + this.Add("getalllens", "", "Spawns all lens.", this.HandleGetAllLens); + this.Add("getalleffectcostumes", "", "Spawns all effect costumes.", this.HandleGetAllEffectCostumes); + this.Add("getallspecialcostumes", "", "Spawns all special costumes.", this.HandleGetAllSpecialCostumes); + this.Add("getallspecialcostumeskins", "", "Spawns all special costume skins.", this.HandleGetAllSpecialCostumeSkins); + this.Add("getallhairs", "", "Spawns all hairs.", this.HandleGetAllHairs); + this.Add("getallhelmets", "", "Spawns all helmets.", this.HandleGetAllHelmets); + this.Add("getalldolls", "", "Spawns all dolls.", this.HandleGetAllDolls); + this.Add("levelup", "", "Increases character's level.", this.HandleLevelUp); this.Add("joblevelup", "", "Increases character's job level.", this.HandleJobLevelUp); this.Add("speed", "", "Modifies character's speed.", this.HandleSpeed); @@ -682,10 +695,243 @@ private CommandResult HandleSpawn(Character sender, Character target, string mes /// /// /// - private CommandResult HandleGetAllHats(Character sender, Character target, string message, string command, Arguments args) + private CommandResult HandleGetAllHairAccessories(Character sender, Character target, string message, string command, Arguments args) + { + int startId=628001; + int endId=629511; + int[] additionalItems = new int[] { }; + string itemTypeName = "hair accessories"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available wings to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllWings(Character sender, Character target, string message, string command, Arguments args) + { + int startId=637000; + int endId=637999; + int[] additionalItems = new int[] { 635572 }; // Add the Little Ghost Balloon which is off ID range + string itemTypeName = "wings"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available toys to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllToys(Character sender, Character target, string message, string command, Arguments args) + { + int startId=630001; + int endId=635121; + int[] additionalItems = new int[] { }; + string itemTypeName = "toys"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available armbands to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllArmbands(Character sender, Character target, string message, string command, Arguments args) + { + int startId=11101; + int endId=11147; + int[] additionalItems = new int[] { }; + string itemTypeName = "armbands"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available costumes to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllCostumes(Character sender, Character target, string message, string command, Arguments args) + { + int startId=620101; + int endId=635510; + int[] additionalItems = new int[] { 635570, 635571 }; // Reissue Cafe T-shirt Male and Female + string itemTypeName = "costumes"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available lens to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllLens(Character sender, Character target, string message, string command, Arguments args) + { + int startId=18001; + int endId=18016; + int[] additionalItems = new int[] { }; + string itemTypeName = "lens"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available effect costumes to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllEffectCostumes(Character sender, Character target, string message, string command, Arguments args) + { + int startId=639101; + int endId=639126; + int[] additionalItems = new int[] { 640000 }; // White Snowflake Crystal + string itemTypeName = "effect costumes"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available special costumes to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllSpecialCostumes(Character sender, Character target, string message, string command, Arguments args) + { + int startId=638000; + int endId=638012; + int[] additionalItems = new int[] { }; + string itemTypeName = "special costumes"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available special costume skins to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllSpecialCostumeSkins(Character sender, Character target, string message, string command, Arguments args) + { + int startId=750000; + int endId=750008; + int[] additionalItems = new int[] { }; + string itemTypeName = "special costume skins"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available hairs to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllHairs(Character sender, Character target, string message, string command, Arguments args) + { + int startId=12111; + int endId=19003; + int[] additionalItems = new int[] { 635054, 635055 }; // [EVENT] Cockatrice Head (Male, Female) + string itemTypeName = "hairs"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available helmets to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllHelmets(Character sender, Character target, string message, string command, Arguments args) + { + int startId=10001; + int endId=19030; + int[] additionalItems = new int[] { }; + string itemTypeName = "helmets"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all available dolls to target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllDolls(Character sender, Character target, string message, string command, Arguments args) + { + int startId=900001; + int endId=900004; + int[] additionalItems = new int[] { }; + string itemTypeName = "dolls"; + return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); + } + + /// + /// Adds all requested and availabled items to target's inventory. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleGetAllSelectedItems(Character sender, Character target, string message, string command, Arguments args, int startId, int endId, int[] additionalItems, string itemTypeName) { var addedCount = 0; - for (var itemId = 628001; itemId <= 629503; ++itemId) + for (var itemId = startId; itemId <= endId; ++itemId) + { + if (!ZoneServer.Instance.Data.ItemDb.Contains(itemId)) + continue; + + if (!sender.Inventory.HasItem(itemId)) + { + sender.Inventory.Add(new Item(itemId), InventoryAddType.PickUp); + addedCount++; + } + } + + // for each additional item + foreach (var itemId in additionalItems) { if (!ZoneServer.Instance.Data.ItemDb.Contains(itemId)) continue; @@ -699,12 +945,12 @@ private CommandResult HandleGetAllHats(Character sender, Character target, strin if (sender == target) { - sender.ServerMessage(Localization.Get("Added {0} hats to your inventory."), addedCount); + sender.ServerMessage(Localization.Get("Added {0} {1} to your inventory."), addedCount, itemTypeName); } else { - target.ServerMessage(Localization.Get("{1} added {0} hats to your inventory."), addedCount, sender.TeamName); - sender.ServerMessage(Localization.Get("Added {0} hats to target's inventory."), addedCount); + target.ServerMessage(Localization.Get("{1} added {0} {2} to your inventory."), addedCount, sender.TeamName, itemTypeName); + sender.ServerMessage(Localization.Get("Added {0} {1} to target's inventory."), addedCount, itemTypeName); } return CommandResult.Okay; diff --git a/system/conf/commands.conf b/system/conf/commands.conf index a120bf632..dcbb94bd6 100644 --- a/system/conf/commands.conf +++ b/system/conf/commands.conf @@ -86,6 +86,19 @@ spawn : 50,50 // Adds all hats to inventory madhatter : 50,50 +// Adds all {item type} to inventory +getallwings : 50,50 +getalltoys : 50,50 +getallarmbands : 50,50 +getallcostumes : 50,50 +getalllens : 50,50 +getalleffectcostumes : 50,50 +getallspecialcostumes : 50,50 +getallspecialcostumeskins : 50,50 +getallhairs : 50,50 +getallhelmets : 50,50 +getalldolls : 50,50 + // Levels character up levelup : 50,50 From bf27246b7f8092cfdab57c83cc010cd2f0c82489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=83=A3=E3=83=BC=E3=83=AB=E3=82=BA?= <8145020+y4my4my4m@users.noreply.github.com> Date: Sat, 10 Aug 2024 20:25:57 +0900 Subject: [PATCH 13/18] Update ChatCommands.Handlers.cs --- .../Commands/ChatCommands.Handlers.cs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/ZoneServer/Commands/ChatCommands.Handlers.cs b/src/ZoneServer/Commands/ChatCommands.Handlers.cs index 83ee4b027..41c08e629 100644 --- a/src/ZoneServer/Commands/ChatCommands.Handlers.cs +++ b/src/ZoneServer/Commands/ChatCommands.Handlers.cs @@ -902,6 +902,47 @@ private CommandResult HandleGetAllDolls(Character sender, Character target, stri return HandleGetAllSelectedItems(sender, target, message, command, args, startId, endId, additionalItems, itemTypeName); } + + /// + /// Remove all available gendered items from target's inventory. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleRemoveAllFromGender(Character sender, Character target, string message, string command, Arguments args) + { + string itemTypeName = "item"; + var addedCount = 0; + + string strCompare = sender.Gender == Gender.Male ? "(Female)" : "(Male)"; + + foreach (var item in sender.Inventory.GetItems()) + { + + Log.Warning(item.Value.Data.Name); + var itemIsToBeDeleted = item.Value.Data.Name.Contains(strCompare, StringComparison.InvariantCultureIgnoreCase); + if(itemIsToBeDeleted) + { + sender.Inventory.Remove(item.Value, 1, InventoryItemRemoveMsg.Destroyed); + addedCount++; + } + }; + if (sender == target) + { + sender.ServerMessage(Localization.Get("Removed {0} {1} from your inventory."), addedCount, itemTypeName); + } + else + { + target.ServerMessage(Localization.Get("{1} removed {0} {2} from your inventory."), addedCount, sender.TeamName, itemTypeName); + sender.ServerMessage(Localization.Get("Removed {0} {1} to target's inventory."), addedCount, itemTypeName); + } + + return CommandResult.Okay; + } + /// /// Adds all requested and availabled items to target's inventory. /// From 54b0d11804729a64c74a90e4a66b1d0b6f08aa1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=83=A3=E3=83=BC=E3=83=AB=E3=82=BA?= <8145020+y4my4my4m@users.noreply.github.com> Date: Sat, 10 Aug 2024 20:26:13 +0900 Subject: [PATCH 14/18] Update ChatCommands.Handlers.cs --- src/ZoneServer/Commands/ChatCommands.Handlers.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ZoneServer/Commands/ChatCommands.Handlers.cs b/src/ZoneServer/Commands/ChatCommands.Handlers.cs index 41c08e629..ff1284b13 100644 --- a/src/ZoneServer/Commands/ChatCommands.Handlers.cs +++ b/src/ZoneServer/Commands/ChatCommands.Handlers.cs @@ -75,6 +75,7 @@ public ChatCommands() this.Add("getallhairs", "", "Spawns all hairs.", this.HandleGetAllHairs); this.Add("getallhelmets", "", "Spawns all helmets.", this.HandleGetAllHelmets); this.Add("getalldolls", "", "Spawns all dolls.", this.HandleGetAllDolls); + this.Add("removeallfromgender", "", "Remove All from gender.", this.HandleRemoveAllFromGender); this.Add("levelup", "", "Increases character's level.", this.HandleLevelUp); this.Add("joblevelup", "", "Increases character's job level.", this.HandleJobLevelUp); From 90b9773cefd6bbafab58b840ea7c46f2d8c3c97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=83=A3=E3=83=BC=E3=83=AB=E3=82=BA?= <8145020+y4my4my4m@users.noreply.github.com> Date: Sat, 10 Aug 2024 20:26:59 +0900 Subject: [PATCH 15/18] Update commands.conf --- system/conf/commands.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/conf/commands.conf b/system/conf/commands.conf index dcbb94bd6..a35517b98 100644 --- a/system/conf/commands.conf +++ b/system/conf/commands.conf @@ -99,6 +99,9 @@ getallhairs : 50,50 getallhelmets : 50,50 getalldolls : 50,50 +// Remove all items in inventory that are for the other gender +removeallfromgender : 50,50 + // Levels character up levelup : 50,50 From bddca9199babf931936d310531f6623cdf889630 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Tue, 13 Aug 2024 18:42:30 +0900 Subject: [PATCH 16/18] update --- .gitignore | 1 + README.md | 46 ++++++++++----------- Servers/Dockerfile | 2 +- Servers/entrypoint.sh | 16 -------- docker-compose.yml | 3 +- sql/update-2024-08-11_1.sql | 21 +++++----- sql/update-2024-08-11_2.sql | 22 +++++++--- src/BarracksServer/BarracksServer.cs | 59 ++++++++++----------------- src/Shared/Configuration/Files/Web.cs | 13 ++++-- src/WebServer/WebServer.cs | 32 ++++----------- start | 6 +-- stop | 1 - system/conf/database.conf | 6 +-- 13 files changed, 98 insertions(+), 130 deletions(-) delete mode 100644 Servers/entrypoint.sh diff --git a/.gitignore b/.gitignore index 36e98ee86..df9864c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /.env !/user/conf/database-example.conf +!/user/conf/database-example-for-docker.conf !/user/db/items-example.txt !/user/scripts/scripts_custom-example.txt !/user/scripts/scripts_content-example.txt diff --git a/README.md b/README.md index c7f5cb37f..b6e52f09d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ with any services provided by game developers or publishers, and we don't endorse such actions. We're here to learn and create, not to steal or destroy. - State of Development ----------------------------------------------------------------------------- @@ -23,6 +22,7 @@ of the typical features you would expect from an online RPG, but there's still a way to go before we'd call it truly playable. Specifically, some of the major features that are working are as follows: + - Characters (creation, deletion, etc.) - Inventory (managing items, equipping, etc.) - Chat @@ -35,7 +35,6 @@ Specifically, some of the major features that are working are as follows: - Monster spawns - Quests - Installation with Docker ----------------------------------------------------------------------------- @@ -50,9 +49,9 @@ pre-installed, so you don't have to worry about it. After cloning or downloading this repository, rename file `.env.example` to `.env` and change configuration as needed. Then, navigate to the project folder -(where you'll find `docker-compose.yml` ) and run: +(where you'll find `docker-compose.yml` ) and run: -``` +```bash docker compose build ``` @@ -61,13 +60,15 @@ build a new image with `./Servers/Dockerfile`, where our server dependencies are listed. Now, you can run: -``` + +```bash docker compose run --rm melia-server dotnet build ``` This will create our server binaries, making it ready to start with our next command: -``` + +```bash docker compose up -d ``` @@ -76,15 +77,15 @@ browser and access [http://127.0.0.1/toslive/patch/serverlist.xml] to check if server is up and running. You can restart server if anything goes wrong using: -``` + +```bash docker compose restart ``` -If you change anything on source code, you need to run +If you change anything on source code, you need to run `docker compose run --rm melia-server dotnet build` again and restart your server with `docker compose restart` - Database with Docker ----------------------------------------------------------------------------- @@ -93,9 +94,6 @@ accessed via [http://127.0.0.1:8080]. Default user is `root` and password is `123456` (You can change password on `.env`, but remember to change on `user/conf/database.conf` as well). -By default, database will be loaded with data from `sql_start/Merge_All_SQLs.sql`. - - Client ----------------------------------------------------------------------------- @@ -108,7 +106,8 @@ Manage > Browse Local Files). Then, open `release/client.xml` with a text editor. Change the line which starts with ` ``` @@ -122,7 +121,8 @@ account, so, when logging in for the first time, use `new__` as a prefix to your username. Example: -``` + +```bash Username: new__myaccount Password: mypassword ``` @@ -132,20 +132,18 @@ This will create an account with username `myaccount` and password but you'll already be connected and playing. Next time, just login with your username without the `new__` prefix. - Installation from scratch ----------------------------------------------------------------------------- -* Compile Melia -* Run `sql/main.sql` to setup the database -* Copy `system/conf/database.conf` to `user/conf/`, +- Compile Melia +- Run `sql/main.sql` to setup the database +- Copy `system/conf/database.conf` to `user/conf/`, adjust the necessary values and remove the rest. Afterwards, you should be able to start Melia via the provided scripts or directly from the bin directories. If not, or if you need a more detailed guide, head over to our forum, the chat, or the wiki. - Requirements to build from scratch ----------------------------------------------------------------------------- @@ -162,7 +160,6 @@ macOS, you will need to install the SDK as well. For more detailed instructions, please wait patiently while we give our documentation a much-needed overhaul. It's only a matter of time. - Contribution ----------------------------------------------------------------------------- @@ -171,8 +168,7 @@ Check the file CONTRIBUTING.md for instructions on how you may contribute. Links ----------------------------------------------------------------------------- -* GitHub: https://github.com/NoCode-NoLife/melia -* Wiki: https://github.com/NoCode-NoLife/melia/wiki -* Forum: https://nocodenolife.org/forum/65-melia/ -* Chat: https://discord.gg/5sszEgw - +- GitHub: https://github.com/NoCode-NoLife/melia +- Wiki: https://github.com/NoCode-NoLife/melia/wiki +- Forum: https://nocodenolife.org/forum/65-melia/ +- Chat: https://discord.gg/5sszEgw diff --git a/Servers/Dockerfile b/Servers/Dockerfile index 164783240..67fdb3b52 100644 --- a/Servers/Dockerfile +++ b/Servers/Dockerfile @@ -3,7 +3,7 @@ ARG DEBIAN_FRONTEND=noninteractive WORKDIR / -RUN apt update -y && apt upgrade -y && apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0 git php libapache2-mod-php php-cgi php-mysql +RUN apt update -y && apt upgrade -y && apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0 git php libapache2-mod-php php-cgi php-mysql vim WORKDIR /melia diff --git a/Servers/entrypoint.sh b/Servers/entrypoint.sh deleted file mode 100644 index 6589190a1..000000000 --- a/Servers/entrypoint.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Wait for MySQL to be ready -until mysql --host=127.0.0.1 --user=root --password=${MYSQL_ROOT_PASSWORD} -e "SELECT 1"; do - echo "Waiting for MySQL..." - sleep 3 -done - -# Run all SQL files -for file in /docker-entrypoint-initdb.d/*.sql; do - echo "Executing $file..." - mysql --host=127.0.0.1 --user=root --password=${MYSQL_ROOT_PASSWORD} < "$file" -done - -# Run the default entrypoint -exec "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 7fb1d7ad4..911b399b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,6 @@ services: volumes: - ./sql:/docker-entrypoint-initdb.d - ./.mysql/:/var/lib/mysql - - ./Servers/entrypoint.sh:/docker-entrypoint.sh restart: ${SERVER_RESTART} env_file: - ./.env @@ -21,9 +20,11 @@ services: interval: 5s timeout: 10s retries: 40 + melia-server: container_name: melia-server command: "./start ${ENVIRONMENT}" + # command: "tail -f /dev/null" build: "./Servers" networks: - melia-network diff --git a/sql/update-2024-08-11_1.sql b/sql/update-2024-08-11_1.sql index 7ce4ba50d..e83a8e58d 100644 --- a/sql/update-2024-08-11_1.sql +++ b/sql/update-2024-08-11_1.sql @@ -1,18 +1,17 @@ -CREATE TABLE `character_etc_properties` ( - `propertyId` bigint(20) NOT NULL, +CREATE TABLE IF NOT EXISTS `character_etc_properties` ( + `propertyId` bigint(20) NOT NULL AUTO_INCREMENT, `characterId` bigint(20) NOT NULL, `name` varchar(64) NOT NULL, `type` varchar(1) NOT NULL, - `value` varchar(255) NOT NULL + `value` varchar(255) NOT NULL, + PRIMARY KEY (`propertyId`), + KEY `characterId` (`characterId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; -ALTER TABLE `character_etc_properties` - ADD PRIMARY KEY (`propertyId`), - ADD KEY `characterId` (`characterId`); - -ALTER TABLE `character_etc_properties` - MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; +-- Drop the foreign key if it exists +-- ALTER TABLE `character_etc_properties` +-- DROP FOREIGN KEY `character_etc_properties_ibfk_1`; +-- Add the foreign key constraint again ALTER TABLE `character_etc_properties` - ADD CONSTRAINT `character_etc_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `character_etc_properties_ibfk_2` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; +ADD CONSTRAINT `character_etc_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/update-2024-08-11_2.sql b/sql/update-2024-08-11_2.sql index 69fee9512..948950c7f 100644 --- a/sql/update-2024-08-11_2.sql +++ b/sql/update-2024-08-11_2.sql @@ -1,13 +1,23 @@ -CREATE TABLE `storage_team` ( +CREATE TABLE IF NOT EXISTS `storage_team` ( `accountId` bigint(20) NOT NULL, `itemId` bigint(20) NOT NULL, - `position` int(11) NOT NULL + `position` int(11) NOT NULL, + PRIMARY KEY (`accountId`, `itemId`), + KEY `itemId` (`itemId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +-- Drop the first foreign key if it exists +-- ALTER TABLE `storage_team` +-- DROP FOREIGN KEY `storage_team_ibfk_1`; + +-- Drop the second foreign key if it exists +-- ALTER TABLE `storage_team` +-- DROP FOREIGN KEY `storage_team_ibfk_2`; + +-- Add the first foreign key constraint ALTER TABLE `storage_team` - ADD PRIMARY KEY (`accountId`,`itemId`), - ADD KEY `itemId` (`itemId`); +ADD CONSTRAINT `storage_team_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; +-- Add the second foreign key constraint ALTER TABLE `storage_team` - ADD CONSTRAINT `storage_team_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `storage_team_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; +ADD CONSTRAINT `storage_team_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/BarracksServer/BarracksServer.cs b/src/BarracksServer/BarracksServer.cs index 11ca333f2..6a0b21ad7 100644 --- a/src/BarracksServer/BarracksServer.cs +++ b/src/BarracksServer/BarracksServer.cs @@ -67,10 +67,7 @@ public override void Run(string[] args) var title = string.Format("Barracks ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.Magenta, ConsoleHeader.Logo, ConsoleHeader.Credits); - - // Skip the following command on incompatible systems - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - ConsoleUtil.LoadingTitle(); + ConsoleUtil.LoadingTitle(); Log.Init("BarracksServer" + serverId); @@ -89,20 +86,8 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartAcceptor(); - // If running on Windows system, enable console inputs - // otherwise, start an event loop to keep server running until stopped - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - { - ConsoleUtil.RunningTitle(); - new BarracksConsoleCommands().Wait(); - } - else - { - while (true) - { - System.Threading.Thread.Sleep(5000); - } - } + ConsoleUtil.RunningTitle(); + new BarracksConsoleCommands().Wait(); } /// @@ -193,21 +178,21 @@ private void Communicator_OnMessageReceived(string sender, ICommMessage message) switch (message) { case ServerUpdateMessage serverUpdateMessage: - { - if (serverUpdateMessage.ServerType == ServerType.Zone) - _zoneServerNames[sender] = serverUpdateMessage.ServerId; + { + if (serverUpdateMessage.ServerType == ServerType.Zone) + _zoneServerNames[sender] = serverUpdateMessage.ServerId; - this.ServerList.Update(serverUpdateMessage); - this.Communicator.Broadcast("ServerUpdates", serverUpdateMessage); + this.ServerList.Update(serverUpdateMessage); + this.Communicator.Broadcast("ServerUpdates", serverUpdateMessage); - Send.BC_NORMAL.ZoneTraffic(); - break; - } + Send.BC_NORMAL.ZoneTraffic(); + break; + } case RequestMessage requestMessage: - { - this.Communicator_OnRequestReceived(sender, requestMessage); - break; - } + { + this.Communicator_OnRequestReceived(sender, requestMessage); + break; + } } } @@ -221,15 +206,15 @@ private void Communicator_OnRequestReceived(string sender, RequestMessage reques switch (requestMessage.Message) { case ReqPlayerCountMessage reqPlayerCountMessage: - { - var playerCount = this.ServerList.GetAll(ServerType.Zone).Sum(server => server.CurrentPlayers); + { + var playerCount = this.ServerList.GetAll(ServerType.Zone).Sum(server => server.CurrentPlayers); - var message = new ResPlayerCountMessage(playerCount); - var responseMessage = new ResponseMessage(requestMessage.Id, message); + var message = new ResPlayerCountMessage(playerCount); + var responseMessage = new ResponseMessage(requestMessage.Id, message); - this.Communicator.Send(sender, responseMessage); - break; - } + this.Communicator.Send(sender, responseMessage); + break; + } } } diff --git a/src/Shared/Configuration/Files/Web.cs b/src/Shared/Configuration/Files/Web.cs index ffbfed29f..de3c206c2 100644 --- a/src/Shared/Configuration/Files/Web.cs +++ b/src/Shared/Configuration/Files/Web.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using Yggdrasil.Configuration; namespace Melia.Shared.Configuration.Files @@ -18,8 +19,14 @@ public class WebConfFile : ConfFile public void Load(string filePath) { this.Include(filePath); - - this.PhpCgiFilePath = this.GetString("php_cgi_bin", "/usr/bin/php-cgi"); + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe")); + } + else + { + this.PhpCgiFilePath = this.GetString("php_cgi_bin", "/usr/bin/php-cgi"); + } this.PhpDownloadUrl = this.GetString("php_download", "https://windows.php.net/downloads/releases/php-8.2.7-nts-Win32-vs16-x86.zip"); } } diff --git a/src/WebServer/WebServer.cs b/src/WebServer/WebServer.cs index e1ae63228..b3bd017c0 100644 --- a/src/WebServer/WebServer.cs +++ b/src/WebServer/WebServer.cs @@ -43,10 +43,7 @@ public override void Run(string[] args) var title = string.Format("Web ({0}, {1})", groupId, serverId); ConsoleUtil.WriteHeader(ConsoleHeader.ProjectName, title, ConsoleColor.DarkRed, ConsoleHeader.Logo, ConsoleHeader.Credits); - - // Skip the following command on incompatible systems - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - ConsoleUtil.LoadingTitle(); + ConsoleUtil.LoadingTitle(); this.NavigateToRoot(); this.LoadConf(this.Conf); @@ -57,20 +54,9 @@ public override void Run(string[] args) this.StartCommunicator(); this.StartWebServer(); - // If running on Windows system, enable console inputs - // otherwise, start an event loop to keep server running until stopped - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - { - ConsoleUtil.RunningTitle(); - new ConsoleCommands().Wait(); - } - else - { - while (true) - { - System.Threading.Thread.Sleep(5000); - } - } + ConsoleUtil.RunningTitle(); + + new ConsoleCommands().Wait(); } /// @@ -80,7 +66,7 @@ private void CheckDependencies() { var phpFilePath = this.Conf.Web.PhpCgiFilePath; var phpFolderPath = Path.GetDirectoryName(phpFilePath); - Log.Info(phpFilePath); + // If the binary exists we got all we need if (File.Exists(phpFilePath)) return; @@ -244,10 +230,10 @@ private void Communicator_OnMessageReceived(string sender, ICommMessage message) switch (message) { case ServerUpdateMessage serverUpdateMessage: - { - this.ServerList.Update(serverUpdateMessage); - break; - } + { + this.ServerList.Update(serverUpdateMessage); + break; + } } } diff --git a/start b/start index 128d41941..0ebc9e0f8 100755 --- a/start +++ b/start @@ -1,7 +1,7 @@ #!/bin/sh -killall -9 BarracksServer -killall -9 ZoneServer -killall -9 WebServer +# killall -9 BarracksServer +# killall -9 ZoneServer +# killall -9 WebServer echo "Starting Melia Project..." SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" ENVIRONMENT=$1 diff --git a/stop b/stop index bf721bd30..8ef4cc2e7 100755 --- a/stop +++ b/stop @@ -1,5 +1,4 @@ #!/bin/sh -clear echo "Stoping Melia Project..." killall -9 BarracksServer diff --git a/system/conf/database.conf b/system/conf/database.conf index 773a2450a..a385611e9 100644 --- a/system/conf/database.conf +++ b/system/conf/database.conf @@ -2,9 +2,9 @@ // Configuration file //---------------------------------------------------------------------------- -host : melia-database +host : 127.0.0.1 user : root -pass : 123456 +pass : database : melia -include "/user/conf/database.conf" +include "/user/conf/database.conf" \ No newline at end of file From 875c1326f061fcaa1365b994a2b11375b9845616 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Tue, 13 Aug 2024 18:46:36 +0900 Subject: [PATCH 17/18] temp fix --- .gitignore | 1 + user/conf/database-example-for-docker.conf | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 user/conf/database-example-for-docker.conf diff --git a/.gitignore b/.gitignore index df9864c6b..c05e26234 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /user/** /.env +!/user/conf/ !/user/conf/database-example.conf !/user/conf/database-example-for-docker.conf !/user/db/items-example.txt diff --git a/user/conf/database-example-for-docker.conf b/user/conf/database-example-for-docker.conf new file mode 100644 index 000000000..0fc5648f6 --- /dev/null +++ b/user/conf/database-example-for-docker.conf @@ -0,0 +1,8 @@ +// Melia +// Configuration file +//---------------------------------------------------------------------------- + +host : melia-database +user : root +pass : 123456 +database : melia From e93bcfe518ad35e8c44fe3f04748cbe8b9a09f54 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Tue, 13 Aug 2024 18:47:01 +0900 Subject: [PATCH 18/18] git ignore all again --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index c05e26234..df9864c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ /user/** /.env -!/user/conf/ !/user/conf/database-example.conf !/user/conf/database-example-for-docker.conf !/user/db/items-example.txt