├── .dockerignore ├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── README.zh-TW.md ├── bin └── unlight ├── client ├── Dockerfile ├── bin │ ├── compile-client │ └── prepare-assets ├── lib │ └── as3crypto.swc └── scripts │ ├── patch.sh │ └── prepare.sh ├── compile.env.example ├── db ├── conf.d │ └── .gitkeep └── data │ └── .gitkeep ├── dist └── .gitkeep ├── docker-compose.external.yml ├── docker-compose.yml ├── docs └── images │ └── create-droplet.png ├── fonts └── .gitkeep ├── patches ├── Unlight-config.xml.patch ├── compile │ ├── 001_create_const_data.rb.patch │ ├── 002_ProfoundNoticePanel.as.patch │ └── 003_register_tweener.patch ├── constants.rb.patch ├── create_const_data.rb.patch ├── create_font_swf.rb.patch ├── crypt.rb.patch ├── import_csv_data.rb.patch └── server.patch ├── server.env.example ├── server ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── bin │ ├── server │ ├── update │ └── wait-db ├── scripts │ ├── patch.sh │ └── prepare.sh └── src │ ├── db_config.rb │ ├── extension.rb │ ├── unlight.rb │ └── xmlsocket.rb └── templates └── docker-compose.custom.yml.erb /.dockerignore: -------------------------------------------------------------------------------- 1 | assets/ 2 | dist/ 3 | db/ 4 | .git/ 5 | server/Dockerfile 6 | client/Dockerfile 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | fonts/* 2 | *.env 3 | 4 | # User Defined Content 5 | dist/**/* 6 | customize/**/* 7 | docker-compose.custom.yml 8 | 9 | # Database 10 | db/**/* 11 | 12 | !.gitkeep 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src"] 2 | path = src 3 | url = https://github.com/unlightcpa/Unlight.git 4 | [submodule "assets"] 5 | path = assets 6 | url = https://github.com/unlightcpa/Unlight-Images.git 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Zheng Xian Qiu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Project Setting 2 | ROOT_DIR=$(shell pwd) 3 | -include server.env 4 | 5 | .PHONY: server client 6 | 7 | builder: 8 | @echo 'Prepare build environment...' 9 | @docker build -t openunlight/legacy-builder -f client/Dockerfile . 10 | 11 | Unlight.swf: 12 | @docker run --rm -v ${ROOT_DIR}/assets:/assets \ 13 | -v ${ROOT_DIR}/dist:/app/dist \ 14 | -v ${ROOT_DIR}/fonts:/app/fonts \ 15 | --env-file compile.env \ 16 | openunlight/legacy-builder compile-client 17 | 18 | client: builder Unlight.swf 19 | 20 | server: 21 | @echo 'Prepare docker image for server...' 22 | @docker build -t openunlight/legacy-server -f server/Dockerfile . 23 | 24 | update: 25 | @echo 'Starting import new game data...' 26 | @bin/unlight up -d db memcached 27 | @bin/unlight run auth_server update 28 | @bin/unlight rm -f auth_server 29 | 30 | setup: server update 31 | 32 | start: 33 | @bin/unlight up -d --scale db=${ENABLE_DB} \ 34 | --scale memcached=${ENABLE_MEMCACHED} 35 | 36 | restart: 37 | @bin/unlight restart 38 | 39 | stop: 40 | @bin/unlight stop 41 | 42 | mysql: 43 | @bin/unlight exec db mysql -u ${MYSQL_USER} -D ${MYSQL_DATABASE} -p 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Legacy Unlight Docker 2 | === 3 | 4 | [![](https://images.microbadger.com/badges/image/openunlight/legacy-server.svg)](https://microbadger.com/images/openunlight/legacy-server "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/openunlight/legacy-server.svg)](https://microbadger.com/images/openunlight/legacy-server "Get your own version badge on microbadger.com") [![Docker Repository on Quay](https://quay.io/repository/open-unlight/legacy-server/status "Docker Repository on Quay")](https://quay.io/repository/open-unlight/legacy-server) 5 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopen-unlight%2Flegacy-unlight-docker.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopen-unlight%2Flegacy-unlight-docker?ref=badge_shield) 6 | 7 | The CPA is released Unlight's [source code](https://github.com/unlightcpa/Unlight) but there is no any document and stable version for setup. 8 | This repository provides a pre-package docker image for compile client (SWF) and server (Ruby) and lets anyone can serve their Unlight server. 9 | 10 | ## Requirement 11 | 12 | * Docker 19.03+ 13 | * Docker Compose 1.24+ 14 | * git 2+ 15 | * make 16 | * Ruby 2.6+ 17 | 18 | ## Install 19 | 20 | For compile client or serve a game server, you need to download this repository to your local machine or server. 21 | 22 | ```bash 23 | git clone https://github.com/open-unlight/legacy-unlight-docker.git 24 | cd legacy-unlight-docker 25 | # Download offical source code and assets 26 | git submodule init 27 | git submodule update --recursive 28 | ``` 29 | 30 | ### DigitalOcean 31 | 32 | We provide a marketplace image for one-click setup server. 33 | 34 | [![Create Droplet](https://github.com/open-unlight/legacy-unlight-docker/blob/master/docs/images/create-droplet.png?raw=true)](https://marketplace.digitalocean.com/apps/open-unlight?action=deploy&refcode=3e237256289e) 35 | 36 | 37 | ## Usage 38 | 39 | ### Client 40 | 41 | The fonts are included in `Unlight.swf`, you have to download the font file and put it into `fonts/` directory. 42 | 43 | |Language|Required Fonts| 44 | |--------|--------------| 45 | |Traditional Chinese| cwming.ttf (cwTeXMing 明體), wt004.ttf (王漢宗特明體), nbr.ttf| 46 | 47 | > `nbr.ttf` is `Bradley Gratis` but with customize. 48 | 49 | Next, you need to configure `compile.env` to define the preferences you want. 50 | 51 | ```bash 52 | # Copy example file and modify 53 | cp compile.env.example compile.env 54 | ``` 55 | 56 | Then you can compile `Unlight.swf` via Docker. 57 | 58 | ```bash 59 | make client 60 | ``` 61 | 62 | > More customize options will add soon 63 | 64 | ### Server 65 | 66 | To setup server, you need build server docker image in first run. 67 | 68 | Before start, we need to setup server config. 69 | 70 | ```bash 71 | cp server.env.example server.env 72 | ``` 73 | 74 | > If you host the database and Memcached in another server, please update the config. 75 | 76 | ```bash 77 | make setup 78 | ``` 79 | 80 | This command will build a docker image and initialize load database. 81 | 82 | After the server is ready, we can start all servers 83 | 84 | ```bash 85 | make start 86 | ``` 87 | 88 | After servers are ready, we have to set up static files. 89 | 90 | ```bash 91 | bin/prepare-assets --t_chinese -P dist/ 92 | ``` 93 | 94 | > The `dist/` directory is your web server root folder includes Unlight's `public/` directory. This will change SWF to your locale. 95 | 96 | #### Pre-build Image 97 | 98 | We also provide pre-build image and allow you setup server without build it by yourself. 99 | 100 | ```yaml 101 | x-image: &image 102 | image: openunlight/legacy-server:latest # Change this line 103 | env_file: 104 | - server.env 105 | restart: unless-stopped 106 | depends_on: 107 | - memcached 108 | - db 109 | ``` 110 | 111 | #### Customize Docker 112 | 113 | The Docker Compose's scale feature will break our services, please add your external server to `docker-compose.custom.yml` 114 | 115 | ```yml 116 | version: '3.4' 117 | x-image: &image 118 | image: unlight-server 119 | env_file: 120 | - server.env 121 | restart: unless-stopped 122 | lobby2_server: 123 | <<: *image 124 | command: server lobby 12002 125 | ports: 126 | - '12003:12002' 127 | ``` 128 | 129 | And run `make start` to start the new server. 130 | 131 | ##### Customize MySQL 132 | 133 | If you plan to use Docker to run your database server and want to change something, add your `.cnf` to `db/conf.d` and restart the database. 134 | 135 | ```cnf 136 | ; my.cnf 137 | [mysqld] 138 | character-set-server=utf8mb4 139 | collation-server=utf8mb4_unicode_ci 140 | init_connect='SET NAMES utf8mb4' 141 | 142 | [client] 143 | default-character-set=utf8mb4 144 | 145 | [mysql] 146 | default-character-set=utf8mb4 147 | ``` 148 | 149 | And run `bin/unlight restart db` to restart your database server. 150 | 151 | ##### Unlight Command 152 | 153 | This project use shared docker-compose.yml, please use `bin/unlight` to replace with `docker-compose` otherwise you will lose config. 154 | 155 | 156 | ## License 157 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopen-unlight%2Flegacy-unlight-docker.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopen-unlight%2Flegacy-unlight-docker?ref=badge_large) 158 | -------------------------------------------------------------------------------- /README.zh-TW.md: -------------------------------------------------------------------------------- 1 | Legacy Unlight Docker 2 | === 3 | 4 | CPA 釋出了 Unlight's [原始碼](https://github.com/unlightcpa/Unlight) 但是並沒有提供任何文件或是穩定版本。 5 | 為了讓任何人都可以運行他們自己的 Unlight 遊戲,因此這個專案提供了預先封裝的 Docker Image 用來建置客戶端(SWF)和伺服器(Ruby) 6 | 7 | ## 系統需求 8 | 9 | * Docker 19.03+ 10 | * Docker Compose 1.24+ 11 | * git 2+ 12 | * make 13 | * Ruby 2.6+ 14 | 15 | ## 安裝 16 | 17 | 不論是編譯客戶端或者伺服器,你都會需要將這個專案的原始碼下載回來。 18 | 19 | ``` 20 | git clone https://github.com/open-unlight/legacy-unlight-docker.git 21 | cd legacy-unlight-docker 22 | # 將官方原本的原始碼及素材下載 23 | git submodule init 24 | git submodule update --recursive 25 | ``` 26 | 27 | ## 使用方式 28 | 29 | ### 客戶端 30 | 31 | 因為字體檔案會被在編譯的時候加入 `Unlight.swf` 所以需要把對應的字體放到 `fonts/` 資料夾裡面。 32 | 33 | |語言|必要字體| 34 | |--------|--------------| 35 | |繁體中文| cwming.ttf (cwTeXMing 明體), wt004.ttf (王漢宗特明體), nbr.ttf| 36 | 37 | > `nbr.ttf` 是叫做 `Bradley Gratis` 的字體,但是 Unlight 是有客製化過的。 38 | 39 | 然後要設定編譯環境,透過設定 `compile.env` 來定義需要的編譯設定。 40 | 41 | ```bash 42 | # 可以先複製範例檔然後調整 43 | cp compile.env.example compile.env 44 | ``` 45 | 46 | 接下來透過 Docker 就可以將 `Unlight.swf` 編譯出來。 47 | 48 | ```bash 49 | make client 50 | ``` 51 | 52 | > 目前還暫時無法做太多客製化,會陸續加入客製化選項。 53 | 54 | 55 | ### 伺服端 56 | 57 | 首先,你需要伺服器的 Docker Image 來啟動伺服器,但是在這之前我們需要先設定伺服器。 58 | 59 | 60 | ```bash 61 | cp server.env.example server.env 62 | ``` 63 | 64 | > 如果你打算把 MySQL 和 Memcached 放在其他伺服器,記得修改設定成你的伺服器位置。 65 | 66 | ```bash 67 | make setup 68 | ``` 69 | 70 | 這個指令會將遊戲的初始資料匯入進去,完成之後我們就可以將全部的伺服器打開。 71 | 72 | ```bash 73 | make start 74 | ``` 75 | 76 | 在伺服器啟動之後,我們需要確保遊戲的素材已經切換到目前的語言,所以需要執行以下指令。 77 | 78 | ```bash 79 | bin/prepare-assets --t_chinese -P dist/ 80 | ``` 81 | 82 | > 指令示範的 `dist/` 資料夾是有放著你從 Unlight-Images 抓出來的 `public/` 目錄的資料夾,這樣我們才能將語言切換。 83 | 84 | ##### 自訂 Docker 85 | 86 | 因為 Docker Compose 預設的 Scale 機制無法分配 Port 會造成無法開啟,請把你的額外伺服器放到 `docker-compose.custom.yml` 裡面。 87 | 88 | ```yml 89 | version: '3.4' 90 | x-image: &image 91 | image: unlight-server 92 | env_file: 93 | - server.env 94 | restart: unless-stopped 95 | lobby2_server: 96 | <<: *image 97 | command: server lobby 12002 98 | ports: 99 | - '12003:12002' 100 | ``` 101 | 102 | 修改後請記得執行 `make start` 更新伺服器。 103 | 104 | ##### 自訂 MySQL 105 | 106 | 如果你打算用 Docker 來當資料庫伺服器,你會需要修改設定來調整你的資料庫,請把你的 `.cnf` 設定檔案放到 `db/conf.d` 裡面,並且重新啟動伺服器。 107 | 108 | ```cnf 109 | ; my.cnf 110 | [mysqld] 111 | character-set-server=utf8mb4 112 | collation-server=utf8mb4_unicode_ci 113 | init_connect='SET NAMES utf8mb4' 114 | 115 | [client] 116 | default-character-set=utf8mb4 117 | 118 | [mysql] 119 | default-character-set=utf8mb4 120 | ``` 121 | 122 | 完成後執行 `bin/unlight restart db` 將資料庫重開。 123 | 124 | ##### Unlight 指令 125 | 126 | 因為使用了共用的 `docker-compose.yml` 設定,所以請用 `bin/unlight` 來取代 `docker-compose` 指令,以免發生遺失設定的狀況。 127 | -------------------------------------------------------------------------------- /bin/unlight: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export PROJECT_ROOT=$(dirname $(dirname $0)) 6 | 7 | source $PROJECT_ROOT/server.env 8 | 9 | if [ ! -f $PROJECT_ROOT/docker-compose.custom.yml ]; then 10 | echo "version: '3.4'" > $PROJECT_ROOT/docker-compose.custom.yml 11 | fi 12 | 13 | exec docker-compose \ 14 | -p unlight \ 15 | -f $PROJECT_ROOT/docker-compose.yml \ 16 | -f $PROJECT_ROOT/docker-compose.external.yml \ 17 | -f $PROJECT_ROOT/docker-compose.custom.yml \ 18 | "$@" 19 | -------------------------------------------------------------------------------- /client/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG APP_ROOT=/app 2 | 3 | FROM ubuntu:bionic 4 | 5 | # Install Dependencies 6 | ENV DEBIAN_FRONTEND noninteractive 7 | RUN apt-get update \ 8 | && apt-get install -y --no-install-recommends \ 9 | git \ 10 | default-jdk \ 11 | ruby \ 12 | ruby-dev \ 13 | memcached \ 14 | mysql-client \ 15 | libmysqlclient-dev \ 16 | libssl-dev \ 17 | ant \ 18 | unzip \ 19 | curl \ 20 | build-essential \ 21 | sqlite3 \ 22 | libsqlite3-dev \ 23 | && apt-get purge -y --auto-remove \ 24 | && apt-get clean \ 25 | && rm -rf /var/lib/apt/lists/* \ 26 | /tmp/* 27 | 28 | RUN gem install bundler -v 1.17.3 29 | 30 | ARG APP_ROOT 31 | ENV APP_ROOT=${APP_ROOT} 32 | ENV SERVER_ROOT=${APP_ROOT}/server 33 | ENV CLIENT_ROOT=${APP_ROOT}/client 34 | ENV DIST_DIR=${APP_ROOT}/dist 35 | 36 | # Setup Application 37 | RUN mkdir -p $SERVER_ROOT \ 38 | $CLIENT_ROOT \ 39 | $DIST_DIR 40 | WORKDIR $CLIENT_ROOT 41 | 42 | # Setup Server 43 | COPY server/Gemfile* $SERVER_ROOT/ 44 | RUN cd $SERVER_ROOT && bundle install 45 | 46 | # Setup Flex 47 | ENV FLEXSDK_VERSION 3.6a 48 | RUN curl -fL -o /tmp/flexsdk.zip http://download.macromedia.com/pub/flex/sdk/flex_sdk_${FLEXSDK_VERSION}.zip \ 49 | && unzip /tmp/flexsdk.zip -d /usr/lib/flex3 \ 50 | && rm -rf /tmp/* 51 | 52 | # Add Source Files 53 | ADD src/app $APP_ROOT 54 | ADD server/ $SERVER_ROOT 55 | ADD client/ $CLIENT_ROOT 56 | ADD patches/ /app/patches 57 | 58 | ENV PATH $CLIENT_ROOT/bin:$PATH 59 | 60 | # Prepare necessary directory 61 | RUN mkdir -p $SERVER_ROOT/bin/pids \ 62 | && mkdir -p $SERVER_ROOT/data/backup \ 63 | && mkdir -p $CLIENT_ROOT/script/data 64 | 65 | # Apply patch 66 | RUN sh $CLIENT_ROOT/scripts/prepare.sh \ 67 | && sh $CLIENT_ROOT/scripts/patch.sh 68 | -------------------------------------------------------------------------------- /client/bin/compile-client: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | echo 'Prepare static assets...' 5 | cp -r /assets/* $CLIENT_ROOT 6 | 7 | echo 'Add fonts...' 8 | cp -r $APP_ROOT/fonts/* $CLIENT_ROOT/data 9 | 10 | # Start services 11 | /etc/init.d/memcached start 12 | 13 | cd $SERVER_ROOT 14 | # Import Game Data (mysql command must be executed correctly) 15 | ruby -E UTF-8 script/import_csv_data.rb $LANGUAGE 16 | # Create constdata_keys_jp.rb 17 | ruby script/update_const_keys.rb 18 | # Font SWf is required database backup 19 | ruby -E UTF-8 script/backup_db.rb 20 | ruby -E UTF-8 script/create_font_swf.rb -c 21 | # TODO: _tcn keys is not exists 22 | cp script/constdata_keys_jp.rb script/constdata_keys_$LANGUAGE.rb 23 | 24 | cd $CLIENT_ROOT 25 | # Initialize 26 | ruby script/update_version_file.rb 27 | # Choose to use Traditional Chinese version swf 28 | ruby script/switch_resorce.rb -c 29 | # Generate constdata (Required server configure correctly) 30 | ruby script/create_const_data.rb 31 | ruby script/dae_converter.rb 32 | # Generate Unlight.swf 33 | /usr/lib/flex3/bin/mxmlc ./src/Unlight.mxml 34 | 35 | # Copy files to dist 36 | cd $DIST_DIR 37 | cp $CLIENT_ROOT/src/Unlight.swf . 38 | cp $SERVER_ROOT/script/normal_index.html ./index.html 39 | -------------------------------------------------------------------------------- /client/bin/prepare-assets: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # frozen_string_literal: true 4 | # -*- coding: utf-8 -*- 5 | 6 | require 'find' 7 | require 'pathname' 8 | require 'optparse' 9 | require 'fileutils' 10 | require 'logger' 11 | 12 | LOG = Logger.new(STDOUT) 13 | opt = OptionParser.new 14 | 15 | mode_reg = /_jp.swf/ 16 | root = Dir.pwd 17 | opt.on('-e', '--english', '英語用') do |v| 18 | mode_reg = /_en.swf/ if v 19 | end 20 | 21 | opt.on('-c', '--t_chinese', '繁體中文') do |v| 22 | mode_reg = /_ch.swf/ if v 23 | end 24 | 25 | opt.on('-sc', '--s_chinese', '簡體中文') do |v| 26 | mode_reg = /_sc.swf/ if v 27 | end 28 | 29 | opt.on('-kr', '--korean', '韓国語') do |v| 30 | mode_reg = /_en.swf/ if v 31 | end 32 | 33 | opt.on('-fr', '--french', 'フランス語語') do |v| 34 | mode_reg = /_fr.swf/ if v 35 | end 36 | 37 | opt.on('-P', '--path WEBROOT', 'The assets root path') do |v| 38 | root = v if v 39 | end 40 | 41 | opt.parse!(ARGV) 42 | 43 | Find.find("#{root}/public/image/") do |src| 44 | next if File.directory?(src) 45 | 46 | dest = src.gsub(mode_reg, '.swf') 47 | LOG.info("Copy from #{src} to #{dest}") 48 | FileUtils.copy_entry(src, dest) if src =~ mode_reg 49 | end 50 | -------------------------------------------------------------------------------- /client/lib/as3crypto.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-unlight/legacy-unlight-docker/0ac93015da404cda8202c0daaab3d0a39bd25fe4/client/lib/as3crypto.swc -------------------------------------------------------------------------------- /client/scripts/patch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | cd $APP_ROOT 4 | # Prepare server for dump data 5 | patch -p0 < $APP_ROOT/patches/server.patch 6 | 7 | patch -p0 < $APP_ROOT/patches/import_csv_data.rb.patch 8 | patch -p0 < $APP_ROOT/patches/create_const_data.rb.patch 9 | patch -p0 < $APP_ROOT/patches/create_font_swf.rb.patch 10 | patch -p0 < $APP_ROOT/patches/constants.rb.patch 11 | 12 | # Compile client with SQLite 13 | patch -p0 < $APP_ROOT/patches/Unlight-config.xml.patch 14 | find $APP_ROOT/patches/compile -type f | xargs cat | patch -p0 15 | -------------------------------------------------------------------------------- /client/scripts/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Prepare server for dump data 4 | cp $SERVER_ROOT/src/server_ip.rb_orig $SERVER_ROOT/src/server_ip.rb 5 | cp $SERVER_ROOT/src/net/crypt.rb_orig $SERVER_ROOT/src/net/crypt.rb 6 | cp $SERVER_ROOT/src/constants/locale_constants.rb_sb $SERVER_ROOT/src/constants/locale_constants.rb 7 | cp $SERVER_ROOT/src/constants/locale_constants.rb_sb $SERVER_ROOT/src/constants/locale_constants.rb_tcn 8 | 9 | # Initialize 10 | cp $CLIENT_ROOT/src/Unlight-config_sandbox.xml $CLIENT_ROOT/src/Unlight-config.xml 11 | -------------------------------------------------------------------------------- /compile.env.example: -------------------------------------------------------------------------------- 1 | # Available: tcn 2 | LANGUAGE=tcn 3 | -------------------------------------------------------------------------------- /db/conf.d/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-unlight/legacy-unlight-docker/0ac93015da404cda8202c0daaab3d0a39bd25fe4/db/conf.d/.gitkeep -------------------------------------------------------------------------------- /db/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-unlight/legacy-unlight-docker/0ac93015da404cda8202c0daaab3d0a39bd25fe4/db/data/.gitkeep -------------------------------------------------------------------------------- /dist/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-unlight/legacy-unlight-docker/0ac93015da404cda8202c0daaab3d0a39bd25fe4/dist/.gitkeep -------------------------------------------------------------------------------- /docker-compose.external.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | services: 3 | db: 4 | image: mysql:5.7 5 | command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 6 | env_file: 7 | - server.env 8 | volumes: 9 | - './db/data:/var/lib/mysql' 10 | - './db/conf.d:/etc/mysql/mysql.conf.d' 11 | memcached: 12 | image: memcached:1.5.16-alpine 13 | 14 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | x-image: &image 3 | image: unlight-server 4 | env_file: 5 | - server.env 6 | restart: unless-stopped 7 | depends_on: 8 | - memcached 9 | - db 10 | services: 11 | xmlsocket: 12 | <<: *image 13 | command: server xmlsocket 14 | ports: 15 | - '11999:11999' # XMLSocket for Flash Policy 16 | auth_server: 17 | <<: *image 18 | command: server authentication 12001 19 | ports: 20 | - '12001:12001' 21 | lobby_server: 22 | <<: *image 23 | command: server lobby 12002 24 | ports: 25 | - '12002:12002' 26 | quest_server: 27 | <<: *image 28 | command: server quest 12005 29 | ports: 30 | - '12005:12005' 31 | game_server: 32 | <<: *image 33 | command: server game 12008 34 | ports: 35 | - '12008:12008' 36 | match_server: 37 | <<: *image 38 | command: server matching 12018 39 | ports: 40 | - '12018:12018' 41 | chat_server: 42 | <<: *image 43 | command: server chat 12012 44 | ports: 45 | - '12012:12012' 46 | global_chat_server: 47 | <<: *image 48 | command: server global_chat 12020 49 | ports: 50 | - '12020:12020' 51 | data_server: 52 | <<: *image 53 | command: server data_lobby 12032 54 | ports: 55 | - '12032:12032' 56 | raid_server: 57 | <<: *image 58 | command: server raid 12050 59 | ports: 60 | - '12050:12050' 61 | raid_rank_server: 62 | <<: *image 63 | command: server raid_rank 12070 64 | ports: 65 | - '12070:12070' 66 | watch_server: 67 | <<: *image 68 | command: server watch 12080 69 | ports: 70 | - '12080:12080' 71 | raid_chat_server: 72 | <<: *image 73 | command: server raid_chat 12090 74 | ports: 75 | - '12090:12090' 76 | raid_data_server: 77 | <<: *image 78 | command: server raid_data 12100 79 | ports: 80 | - '12100:12100' 81 | -------------------------------------------------------------------------------- /docs/images/create-droplet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-unlight/legacy-unlight-docker/0ac93015da404cda8202c0daaab3d0a39bd25fe4/docs/images/create-droplet.png -------------------------------------------------------------------------------- /fonts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-unlight/legacy-unlight-docker/0ac93015da404cda8202c0daaab3d0a39bd25fe4/fonts/.gitkeep -------------------------------------------------------------------------------- /patches/Unlight-config.xml.patch: -------------------------------------------------------------------------------- 1 | --- client/src/Unlight-config.xml 2 | +++ client/src/Unlight-config.xml 3 | @@ -2,9 +2,9 @@ 4 | 5 | 10.0.12 6 | 7 | - 8 | - ../lib/as3crypto.swc 9 | - 10 | + 11 | + ../lib/as3crypto.swc 12 | + 13 | 14 | . 15 | ../lib 16 | @@ -56,7 +56,7 @@ 17 | 18 | 19 | CONFIG::LOCALE_JP 20 | - true 21 | + false 22 | 23 | 24 | CONFIG::LOCALE_EN 25 | @@ -68,7 +68,7 @@ 26 | 27 | 28 | CONFIG::LOCALE_TCN 29 | - false 30 | + true 31 | 32 | 33 | CONFIG::LOCALE_SCN 34 | -------------------------------------------------------------------------------- /patches/compile/001_create_const_data.rb.patch: -------------------------------------------------------------------------------- 1 | --- client/script/create_const_data.rb 2 | +++ client/script/create_const_data.rb 3 | @@ -30,18 +30,21 @@ module Unlight 4 | end 5 | $encrypt_on = true 6 | end 7 | - DB = Sequel.mysql2(nil,MYSQL_CONFIG) 8 | - 9 | - MYSQL_CONFIG = { 10 | - :host =>"db", 11 | - :user => "unlight", 12 | - :password =>"unlight", 13 | - :database =>"unlight_db", 14 | - :encoding => 'utf8', 15 | - :max_connections => 5, 16 | - :loggers => Logger.new(File.dirname(__FILE__).gsub("src","")+"/data/#{$SERVER_NAME}_mysqldb.log", 32, 10*1024*1024) 17 | - } 18 | - DB = Sequel.mysql2(nil,MYSQL_CONFIG) 19 | + DB_SERVER_LOG = Logger.new(File.dirname(__FILE__).gsub("src/constants","")+"/data/#{$SERVER_NAME}_mysqldb.log", 48, 10*1024*1024) 20 | + DB_SERVER_LOG.level = Logger::DEBUG 21 | + DB = Sequel.connect("sqlite://#{SQLITE3[:DB_File]}", :loggers => [DB_SERVER_LOG]) 22 | + # DB = Sequel.mysql2(nil,MYSQL_CONFIG) 23 | + 24 | + # MYSQL_CONFIG = { 25 | + # :host =>"db", 26 | + # :user => "unlight", 27 | + # :password =>"unlight", 28 | + # :database =>"unlight_db", 29 | + # :encoding => 'utf8', 30 | + # :max_connections => 5, 31 | + # :loggers => Logger.new(File.dirname(__FILE__).gsub("src","")+"/data/#{$SERVER_NAME}_mysqldb.log", 32, 10*1024*1024) 32 | + # } 33 | + # DB = Sequel.mysql2(nil,MYSQL_CONFIG) 34 | 35 | opt.on('-s',"--sandbox","sandboxを作る") do |v| 36 | if v 37 | -------------------------------------------------------------------------------- /patches/compile/002_ProfoundNoticePanel.as.patch: -------------------------------------------------------------------------------- 1 | --- client/src/view/scene/raid/ProfoundNoticePanel.as 2 | +++ client/src/view/scene/raid/ProfoundNoticePanel.as 3 | @@ -260,7 +260,7 @@ package view.scene.raid 4 | hide(); 5 | var num:int = ProfoundNotice.getNoticeNum(); 6 | if (num>0) 7 | - {LobbyCtrl.instance.profoundNoticeClear(num);} 8 | + {RaidDataCtrl.instance.profoundNoticeClear(num);} 9 | } 10 | return ret; 11 | } 12 | -------------------------------------------------------------------------------- /patches/compile/003_register_tweener.patch: -------------------------------------------------------------------------------- 1 | --- client/src/view/MainView.as 2 | +++ client/src/view/MainView.as 3 | @@ -15,6 +15,9 @@ package view 4 | 5 | import view.RaidHelpView; 6 | 7 | + import caurina.transitions.properties.TextShortcuts; 8 | + import caurina.transitions.properties.DisplayShortcuts; 9 | + 10 | 11 | /** 12 | * メインのビュークラス 13 | @@ -49,6 +52,9 @@ package view 14 | _container.addChildAt(_bg,0); 15 | _stage.addChildAt(_container,0); 16 | log.writeLog(log.LV_INFO, this, "Main Finish"); 17 | + 18 | + TextShortcuts.init(); 19 | + DisplayShortcuts.init(); 20 | } 21 | 22 | // スレッドのスタート 23 | -------------------------------------------------------------------------------- /patches/constants.rb.patch: -------------------------------------------------------------------------------- 1 | --- server/src/constants/constants.rb 2 | +++ server/src/constants/constants.rb 3 | @@ -382,7 +382,7 @@ module Unlight 4 | case STORE_TYPE 5 | when :sqlite3 6 | # ログレベル 7 | - DB_SERVER_LOG = Logger.new(File.dirname(__FILE__).gsub("src/constants","")+"data/#{$SERVER_NAME}_mysqldb.log", 48, 10*1024*1024) 8 | + DB_SERVER_LOG = Logger.new(STDOUT) 9 | DB_SERVER_LOG.level = Logger::DEBUG 10 | # DB = Sequel.connect("sqlite://#{SQLITE3[:DB_File]}", :loggers => [Logger.new(SQLITE3[:LOG_File],3,)]) 11 | DB = Sequel.connect("sqlite://#{SQLITE3[:DB_File]}", :loggers => [DB_SERVER_LOG]) 12 | @@ -400,7 +400,7 @@ module Unlight 13 | end 14 | 15 | # ログの出力先 16 | - SERVER_LOG = Logger.new(File.dirname(__FILE__).gsub("src/constants","")+"bin/pids/#{$SERVER_NAME}.log", 128, 10*1024*1024) 17 | + SERVER_LOG = Logger.new(STDOUT) 18 | # ログレベル 19 | # SERVER_LOG.level = Logger::DEBUG 20 | SERVER_LOG.level = Logger::INFO 21 | -------------------------------------------------------------------------------- /patches/create_const_data.rb.patch: -------------------------------------------------------------------------------- 1 | --- client/script/create_const_data.rb 2 | +++ client/script/create_const_data.rb 3 | @@ -142,7 +142,7 @@ 4 | a << "],\n" 5 | tsv << a 6 | end 7 | - tsv.chop!.chop! 8 | + tsv.chop!&.chop! 9 | end 10 | 11 | def get_data_csv_str(dataset) 12 | @@ -154,7 +154,7 @@ 13 | a << "],\n" 14 | tsv << a 15 | end 16 | - tsv.chop!.chop! 17 | + tsv.chop!&.chop! 18 | end 19 | -------------------------------------------------------------------------------- /patches/create_font_swf.rb.patch: -------------------------------------------------------------------------------- 1 | --- server/script/create_font_swf.rb 2 | +++ server/script/create_font_swf.rb 3 | @@ -162,6 +162,6 @@ __END__ 4 | private static const Font:Class; 5 | [Embed(source='../data/__FONT_R__', fontName='mincho'__font_UTF_NO__)] 6 | private static const Font2:Class; 7 | -[Embed(source='../data/nbr.otf', fontName='bradley')] 8 | +[Embed(source='../data/nbr.ttf', fontName='bradley')] 9 | private static const Font3:Class; 10 | 11 | -------------------------------------------------------------------------------- /patches/crypt.rb.patch: -------------------------------------------------------------------------------- 1 | --- server/src/net/crypt.rb 2 | +++ server/src/net/crypt.rb 3 | @@ -31,7 +31,7 @@ module Unlight 4 | des_a[i]=a[i]^s[(i)%slen] 5 | i+=1 6 | end 7 | - des_a 8 | + des_a.pack("C*") 9 | end 10 | 11 | def encrypt2(data) 12 | -------------------------------------------------------------------------------- /patches/import_csv_data.rb.patch: -------------------------------------------------------------------------------- 1 | --- server/script/import_csv_data.rb 2 | +++ server/script/import_csv_data.rb 3 | @@ -35,11 +35,11 @@ if $VER_NUMBERING && $VER_RESTART 4 | end 5 | 6 | $arg = ARGV.shift 7 | -puts "serverに存在するcsvdataでインポートしますか (sb)"+over_text 8 | -$arg = gets.chomp 9 | +# puts "serverに存在するcsvdataでインポートしますか (sb)"+over_text 10 | +# $arg = gets.chomp 11 | @m_set = [] 12 | LANGUAGE_SET = /_tcn$|_en$|_scn$|_kr$|_fr$|_ina$|_thai$/ 13 | -MESSAGES={ "sb" => "SandBox"} 14 | +MESSAGES={ "sb" => "SandBox", "tcn" => "繁體中文"} 15 | DATABASES={ 16 | "192.168.1.14:5001"=>"SandBox", 17 | } 18 | @@ -147,8 +147,8 @@ unless MESSAGES.key?($arg) 19 | exit 20 | end 21 | db_name = Unlight::MYSQL_CONFIG[:host] == "192.168.1.14" ? DATABASES["#{Unlight::MYSQL_CONFIG[:host]}:#{Unlight::MYSQL_CONFIG[:port]}"] : "" 22 | -puts "#{MESSAGES[$arg]}版CSVを#{db_name}DBに適用します OK? (y/n)" 23 | -exit if gets.chomp != 'y' 24 | +# puts "#{MESSAGES[$arg]}版CSVを#{db_name}DBに適用します OK? (y/n)" 25 | +# exit if gets.chomp != 'y' 26 | 27 | print_file_list() if $VER_NUMBERING || $VER_RESTART 28 | 29 | -------------------------------------------------------------------------------- /patches/server.patch: -------------------------------------------------------------------------------- 1 | --- server/src/authentication.rb 2 | +++ server/src/authentication.rb 3 | @@ -21,7 +21,7 @@ module Unlight 4 | $SERVER_NAME = "AUTH_SV#{$SV_PORT}" 5 | 6 | begin 7 | - SV_IP = `wget -q -O - ipcheck.ieserver.net -T=3` 8 | + SV_IP = ENV['SV_IP'] || '0.0.0.0' 9 | rescue =>e 10 | SERVER_LOG.fatal("GameServer:IP 未設定") 11 | end 12 | --- server/src/chat.rb 13 | +++ server/src/chat.rb 14 | @@ -20,7 +20,7 @@ module Unlight 15 | opt.parse! ARGV 16 | $SERVER_NAME = "CHAT_SV#{SV_PORT}" 17 | begin 18 | - SV_IP = `wget -q -O - ipcheck.ieserver.net -T=3` 19 | + SV_IP = ENV['SV_IP'] || '0.0.0.0' 20 | rescue =>e 21 | SERVER_LOG.fatal("GameServer:IP 未設定") 22 | end 23 | --- server/src/global_chat.rb 24 | +++ server/src/global_chat.rb 25 | @@ -20,7 +20,7 @@ module Unlight 26 | opt.parse! ARGV 27 | $SERVER_NAME = "GLOBAL_CHAT_SV#{SV_PORT}" 28 | begin 29 | - SV_IP = `wget -q -O - ipcheck.ieserver.net -T=3` 30 | + SV_IP = ENV['SV_IP'] || '0.0.0.0' 31 | rescue =>e 32 | SERVER_LOG.fatal("GlobalChatServer:IP 未設定") 33 | end 34 | --- server/src/raid_chat.rb 35 | +++ server/src/raid_chat.rb 36 | @@ -20,7 +20,7 @@ module Unlight 37 | opt.parse! ARGV 38 | $SERVER_NAME = "RAIDCHAT_SV#{SV_PORT}" 39 | begin 40 | - SV_IP = `wget -q -O - ipcheck.ieserver.net -T=3` 41 | + SV_IP = ENV['SV_IP'] || '0.0.0.0' 42 | rescue =>e 43 | SERVER_LOG.fatal("RaidChatServer:IP 未設定") 44 | end 45 | --- server/src/raid_data.rb 46 | +++ server/src/raid_data.rb 47 | @@ -20,7 +20,7 @@ module Unlight 48 | opt.parse! ARGV 49 | $SERVER_NAME = "RAIDDATA_SV#{SV_PORT}" 50 | begin 51 | - SV_IP = `wget -q -O - ipcheck.ieserver.net -T=3` 52 | + SV_IP = ENV['SV_IP'] || '0.0.0.0' 53 | rescue =>e 54 | SERVER_LOG.fatal("RaidDataServer:IP 未設定") 55 | end 56 | --- server/src/raid_rank.rb 57 | +++ server/src/raid_rank.rb 58 | @@ -20,7 +20,7 @@ module Unlight 59 | opt.parse! ARGV 60 | $SERVER_NAME = "RAIDRANK_SV#{SV_PORT}" 61 | begin 62 | - SV_IP = `wget -q -O - ipcheck.ieserver.net -T=3` 63 | + SV_IP = ENV['SV_IP'] || '0.0.0.0' 64 | rescue =>e 65 | SERVER_LOG.fatal("RaidRankServer:IP 未設定") 66 | end 67 | -------------------------------------------------------------------------------- /server.env.example: -------------------------------------------------------------------------------- 1 | # Database Configure 2 | DB_ADAPTER=mysql 3 | DB_HOST=db 4 | MYSQL_USER=unlight 5 | MYSQL_PASSWORD=unlight 6 | MYSQL_DATABASE=unlight_db 7 | MYSQL_ROOT_PASSWORD=unlight 8 | # DB_POOL_SIZE=5 9 | MEMCACHED_HOST=memcached:11211 10 | 11 | # Docker Options 12 | ENABLE_DB=1 13 | ENABLE_MEMCACHED=1 14 | -------------------------------------------------------------------------------- /server/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG APP_ROOT=/app 2 | ARG RUBY_VERSION=2.6.5 3 | 4 | # Pre-compile Gems 5 | FROM ruby:${RUBY_VERSION}-alpine AS gem 6 | 7 | RUN apk --update \ 8 | add --no-cache \ 9 | build-base \ 10 | ca-certificates \ 11 | zlib-dev \ 12 | libressl-dev \ 13 | mariadb-dev \ 14 | mariadb-client \ 15 | sqlite \ 16 | sqlite-dev 17 | 18 | # Setup Application 19 | ARG APP_ROOT 20 | ENV APP_ROOT=${APP_ROOT} 21 | ENV SERVER_ROOT=$APP_ROOT/server 22 | 23 | RUN mkdir -p $SERVER_ROOT 24 | WORKDIR $SERVER_ROOT 25 | 26 | COPY server/Gemfile* $SERVER_ROOT/ 27 | RUN cd $SERVER_ROOT \ 28 | && gem install bundler:1.17.3 \ 29 | && gem uninstall bundler:1.17.2 \ 30 | && bundle config --global deployment 'true' \ 31 | && bundle config --global frozen 'true' \ 32 | && bundle config --global without 'development test' \ 33 | && bundle install --no-cache \ 34 | && find /usr/local/bundle -type f -name '*.c' -delete \ 35 | && find /usr/local/bundle -type f -name '*.o' -delete \ 36 | && rm -rf /usr/local/bundle/cache/*.gem 37 | 38 | # Server 39 | FROM ruby:${RUBY_VERSION}-alpine 40 | 41 | RUN apk --update \ 42 | add --no-cache \ 43 | gcc \ 44 | libc-dev \ 45 | ca-certificates \ 46 | zlib-dev \ 47 | libressl-dev \ 48 | mariadb-connector-c \ 49 | mariadb-client \ 50 | sqlite 51 | 52 | ARG APP_ROOT 53 | ENV APP_ROOT=${APP_ROOT} 54 | ENV SERVER_ROOT=$APP_ROOT/server 55 | 56 | # Setup Application 57 | RUN mkdir -p $SERVER_ROOT \ 58 | && mkdir -p $SERVER_ROOT/bin/pids \ 59 | && mkdir -p $SERVER_ROOT/data/backup 60 | WORKDIR $SERVER_ROOT 61 | 62 | COPY --from=gem /usr/local/bundle /usr/local/bundle 63 | 64 | # Add Source Files 65 | ADD src/app/server/ $SERVER_ROOT 66 | ADD server/ $SERVER_ROOT 67 | ADD patches/ $APP_ROOT/patches 68 | 69 | ENV PATH $SERVER_ROOT/bin:$PATH 70 | 71 | # Patch for Dockerize 72 | RUN sh $SERVER_ROOT/scripts/prepare.sh \ 73 | && sh $SERVER_ROOT/scripts/patch.sh 74 | -------------------------------------------------------------------------------- /server/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | gem 'dalli', '~>2.0.2' 5 | gem 'eventmachine' 6 | gem 'mysql2','~>0.5.2' 7 | gem 'oauth','~>0.4.7' 8 | gem 'sequel','~>4.0' 9 | gem 'RubyInline','~>3.12.4' 10 | gem 'sqlite3','~>1.3.11' 11 | gem 'daemons' 12 | gem 'gmp' 13 | 14 | group :development do 15 | gem 'RocketAMF','~>0.2.1' 16 | gem 'rspec','~>2.11.0' 17 | end 18 | -------------------------------------------------------------------------------- /server/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | RocketAMF (0.2.1) 5 | RubyInline (3.12.5) 6 | ZenTest (~> 4.3) 7 | ZenTest (4.12.0) 8 | daemons (1.3.1) 9 | dalli (2.0.5) 10 | diff-lcs (1.1.3) 11 | eventmachine (1.2.7) 12 | gmp (0.7.43) 13 | mysql2 (0.5.3) 14 | oauth (0.4.7) 15 | rspec (2.11.0) 16 | rspec-core (~> 2.11.0) 17 | rspec-expectations (~> 2.11.0) 18 | rspec-mocks (~> 2.11.0) 19 | rspec-core (2.11.1) 20 | rspec-expectations (2.11.3) 21 | diff-lcs (~> 1.1.3) 22 | rspec-mocks (2.11.3) 23 | sequel (4.49.0) 24 | sqlite3 (1.3.13) 25 | 26 | PLATFORMS 27 | ruby 28 | 29 | DEPENDENCIES 30 | RocketAMF (~> 0.2.1) 31 | RubyInline (~> 3.12.4) 32 | daemons 33 | dalli (~> 2.0.2) 34 | eventmachine 35 | gmp 36 | mysql2 (~> 0.5.2) 37 | oauth (~> 0.4.7) 38 | rspec (~> 2.11.0) 39 | sequel (~> 4.0) 40 | sqlite3 (~> 1.3.11) 41 | 42 | BUNDLED WITH 43 | 1.17.2 44 | -------------------------------------------------------------------------------- /server/bin/server: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | wait-db 5 | 6 | cd /app/server 7 | # Create constdata_keys_jp.rb 8 | bundle exec ruby script/update_const_keys.rb 9 | # TODO: constdata_keys.rb not exists 10 | cp script/constdata_keys_jp.rb script/constdata_keys.rb 11 | 12 | # Start server 13 | bundle exec ruby -roptparse src/$1.rb -p $2 14 | -------------------------------------------------------------------------------- /server/bin/update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | wait-db 5 | 6 | cd /app/server 7 | bundle exec ruby -E UTF-8 script/import_csv_data.rb tcn 8 | 9 | # TODO: Check for other setup tasks 10 | -------------------------------------------------------------------------------- /server/bin/wait-db: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | maxcounter=30 4 | 5 | counter=1 6 | echo "Check database connection..." 7 | while ! mysql --protocol TCP -h"$DB_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "show databases;" > /dev/null 2>&1; do 8 | sleep 1 9 | echo "Retry ${counter} to connect database ..." 10 | counter=`expr $counter + 1` 11 | if [ $counter -gt $maxcounter ]; then 12 | >&2 echo "Unable to connect database" 13 | exit 1 14 | fi; 15 | done 16 | -------------------------------------------------------------------------------- /server/scripts/patch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | cd $APP_ROOT 4 | # TODO: Allow specify language 5 | patch -p0 < $APP_ROOT/patches/import_csv_data.rb.patch 6 | 7 | # Dockerize 8 | patch -p0 < $APP_ROOT/patches/constants.rb.patch 9 | patch -p0 < $APP_ROOT/patches/crypt.rb.patch 10 | patch -p0 < $APP_ROOT/patches/server.patch 11 | -------------------------------------------------------------------------------- /server/scripts/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Initialize 4 | cp $APP_ROOT/server/src/server_ip.rb_orig $APP_ROOT/server/src/server_ip.rb 5 | cp $APP_ROOT/server/src/constants/locale_constants.rb_sb $APP_ROOT/server/src/constants/locale_constants.rb 6 | cp $APP_ROOT/server/src/net/crypt.rb_orig $APP_ROOT/server/src/net/crypt.rb 7 | 8 | # TODO: Allow specify language 9 | cp $APP_ROOT/server/src/constants/locale_constants.rb_sb $APP_ROOT/server/src/constants/locale_constants.rb_tcn 10 | -------------------------------------------------------------------------------- /server/src/db_config.rb: -------------------------------------------------------------------------------- 1 | ## Unlight 2 | # Copyright(c)2019 CPA 3 | # This software is released under the MIT License. 4 | # http://opensource.org/licenses/mit-license.php 5 | 6 | require 'rubygems' 7 | require 'sequel' 8 | require 'logger' 9 | require 'db_config' 10 | 11 | module Unlight 12 | # ============== DB関連定数 ================== 13 | #保存形式 :csv または:sqlite3,:mysql 14 | unless $SERVER_NAME 15 | $SERVER_NAME = "NOT_SV" 16 | end 17 | STORE_TYPE = (ENV['DB_ADAPTER'] || :sqlite3).to_sym 18 | # memcached server 19 | MEMCACHE_CONFIG = (ENV['MEMCACHED_HOST'] || 'localhost:11211') 20 | MEMCACHE_OPTIONS = { 21 | timeout: 1, 22 | namespace: 'unlight' 23 | } 24 | 25 | #mysql設定のデフォルト 26 | MYSQL_CONFIG = { 27 | host: ENV['DB_HOST'] || 'db', 28 | user: ENV['MYSQL_USER'] || 'unlight', 29 | password: ENV['MYSQL_PASSWORD'] || 'unlight', 30 | database: ENV['MYSQL_DATABASE'] || 'unlight_db', 31 | encoding: 'utf8', 32 | port: (ENV['DB_PORT'] || 3306).to_i, 33 | max_connections: (ENV['DB_POOL_SIZE'] || 5).to_i, 34 | loggers: Logger.new(STDOUT) 35 | } 36 | end 37 | 38 | -------------------------------------------------------------------------------- /server/src/extension.rb: -------------------------------------------------------------------------------- 1 | # Author: Aotokitsuruya 2 | # Home Page: https://blog.frost.tw 3 | # 4 | # This is a patch to fix `blank?` method not exists 5 | 6 | class String 7 | def blank? 8 | self.length == 0 9 | end 10 | end 11 | 12 | class Array 13 | def blank? 14 | self.length == 0 15 | end 16 | end 17 | 18 | class Fixnum 19 | def blank? 20 | self == 0 21 | end 22 | end 23 | 24 | class NilClass 25 | def blank? 26 | true 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /server/src/unlight.rb: -------------------------------------------------------------------------------- 1 | # Unlight 2 | # Copyright(c)2019 CPA 3 | # This software is released under the MIT License. 4 | # http://opensource.org/licenses/mit-license.php 5 | 6 | $:.unshift File.dirname(__FILE__) 7 | d = File.dirname(__FILE__).gsub!("src","") 8 | ENV['INLINEDIR']="#{d}lib/ruby_inline" 9 | 10 | require 'rubygems' 11 | require 'sequel' 12 | require 'logger' 13 | require 'dalli' 14 | Sequel::Model.require_valid_table = false 15 | 16 | require 'db_config' 17 | if File.exist?(File.dirname(__FILE__)+"/server_ip.rb") 18 | require 'server_ip' 19 | end 20 | 21 | # 定数 22 | require 'constants/common_constants' 23 | require 'constants/reward_constants' 24 | require 'constants/cpu_data_constants' 25 | require 'constants/constants' 26 | require 'constants/locale_constants' 27 | 28 | # ルール 29 | require 'rule/context' 30 | require 'rule/event/event' 31 | 32 | require 'rule/event/entrant_event' 33 | require 'rule/event/multi_duel_event' 34 | require 'rule/event/chara_card_event' 35 | require 'rule/event/deck_event' 36 | require 'rule/event/action_card_event' 37 | require 'rule/event/avatar_event' 38 | require 'rule/event/reward_event' 39 | require 'rule/event/ai_event' 40 | 41 | require 'rule/deck' 42 | require 'rule/event_deck' 43 | require 'rule/reward' 44 | require 'rule/entrant' 45 | require 'rule/multi_duel' 46 | 47 | # Model 48 | require 'model/action_card.rb' 49 | require 'model/card_inventory.rb' 50 | require 'model/channel.rb' 51 | require 'model/chara_card.rb' 52 | require 'model/chara_card_requirement.rb' 53 | require 'model/chara_card_slot_inventory.rb' 54 | require 'model/chara_card_deck.rb' 55 | require 'model/chara_card_story.rb' 56 | require 'model/chara_record.rb' 57 | require 'model/cpu_card_data.rb' 58 | require 'model/cpu_room_data.rb' 59 | require 'model/dialogue.rb' 60 | require 'model/dialogue_weight.rb' 61 | require 'model/equip_card.rb' 62 | require 'model/event_card.rb' 63 | require 'model/feat.rb' 64 | require 'model/passive_skill.rb' 65 | require 'model/passive_skill_inventory.rb' 66 | require 'model/feat_inventory.rb' 67 | require 'model/friend_link.rb' 68 | require 'model/invite_log.rb' 69 | require 'model/comeback_log.rb' 70 | require 'model/item_inventory.rb' 71 | require 'model/lot_log.rb' 72 | require 'model/match.rb' 73 | require 'model/match_log.rb' 74 | require 'model/monster_treasure_inventory.rb' 75 | require 'model/part_inventory.rb' 76 | require 'model/payment_log.rb' 77 | require 'model/player.rb' 78 | require 'model/quest.rb' 79 | require 'model/achievement.rb' 80 | require 'model/achievement_inventory.rb' 81 | require 'model/quest_clear_log.rb' 82 | require 'model/quest_land.rb' 83 | require 'model/quest_log.rb' 84 | require 'model/quest_map.rb' 85 | require 'model/rare_card_lot.rb' 86 | require 'model/real_money_item.rb' 87 | require 'model/shop.rb' 88 | require 'model/treasure_data.rb' 89 | require 'model/weapon_card.rb' 90 | require 'model/avatar_item.rb' 91 | require 'model/avatar_part.rb' 92 | require 'model/avatar_quest_inventory.rb' 93 | require 'model/charactor.rb' 94 | require 'model/avatar.rb' 95 | require 'model/total_ranking.rb' 96 | require 'model/weekly_duel_ranking.rb' 97 | require 'model/total_duel_ranking.rb' 98 | require 'model/weekly_quest_ranking.rb' 99 | require 'model/total_quest_ranking.rb' 100 | require 'model/total_chara_vote_ranking.rb' 101 | require 'model/total_event_ranking.rb' 102 | require 'model/estimation_ranking.rb' 103 | require 'model/avatar_notice.rb' 104 | require 'model/avatar_apology.rb' 105 | require 'model/reward_data.rb' 106 | require 'model/event_serial.rb' 107 | require 'model/clear_code.rb' 108 | require 'model/infection_collabo_serial.rb' 109 | require 'model/watch_duel.rb' 110 | require 'model/watch_real_duel.rb' 111 | require 'model/profound_data.rb' 112 | require 'model/profound.rb' 113 | require 'model/profound_inventory.rb' 114 | require 'model/profound_log.rb' 115 | require 'model/profound_comment.rb' 116 | require 'model/profound_treasure_data.rb' 117 | require 'model/scenario.rb' 118 | require 'model/scenario_inventory.rb' 119 | require 'model/scenario_flag_inventory.rb' 120 | require 'model/event_quest_flag.rb' 121 | require 'model/event_quest_flag_inventory.rb' 122 | require 'model/combine_case.rb' 123 | require 'model/reissue_request.rb' 124 | require 'rule/ai' 125 | 126 | require 'extension' 127 | 128 | # メモリリークチェック用関数 129 | module Unlight 130 | require "objspace" 131 | 132 | def self::puts_obj_count(c) 133 | count = ObjectSpace.each_object(c) { |x| x } 134 | SERVER_LOG.info( "LEAK_CHECK:#{c.name} num is #{count}") 135 | end 136 | 137 | def self::debug_memory_leak 138 | GC::Profiler.enable 139 | GC.start() 140 | GC::Profiler.report 141 | p Time.now 142 | puts "OBJ COUNT #{ObjectSpace.count_objects}" 143 | # puts "OBJ COUNT_SIZE #{ObjectSpace.count_objects_size}" 144 | # puts "OBJ MEM_SIZE #{ObjectSpace.memsize_of_all}" 145 | # puts "OBJ TDATA_COUNT #{ObjectSpace.count_tdata_objects}" 146 | SERVER_LOG.info( "LEAK_CHECK:ModelObj") 147 | puts_obj_count(ActionCard) 148 | puts_obj_count(CardInventory) 149 | puts_obj_count(Channel) 150 | puts_obj_count(CharaCard) 151 | puts_obj_count(CharaCardSlotInventory) 152 | puts_obj_count(CharaCardDeck) 153 | puts_obj_count(EventCard) 154 | puts_obj_count(Feat) 155 | puts_obj_count(PassiveSkill) 156 | puts_obj_count(PassiveSkillInventory) 157 | puts_obj_count(FeatInventory) 158 | puts_obj_count(Player) 159 | puts_obj_count(Avatar) 160 | puts_obj_count(ProfoundData) 161 | puts_obj_count(Profound) 162 | puts_obj_count(ProfoundInventory) 163 | puts_obj_count(ProfoundLog) 164 | puts_obj_count(ProfoundComment) 165 | puts_obj_count(ProfoundTreasureData) 166 | SERVER_LOG.info( "LEAK_CHECK:EventObj") 167 | puts_obj_count(Deck) 168 | puts_obj_count(EventDeck) 169 | puts_obj_count(Reward) 170 | puts_obj_count(Entrant) 171 | puts_obj_count(MultiDuel) 172 | puts_obj_count(Array) 173 | # puts_obj_count(QuestServer) 174 | # puts_obj_count(ItemInventory) 175 | # puts_obj_count(LotLog) 176 | # puts_obj_count(Match) 177 | # puts_obj_count(MatchLog) 178 | # puts_obj_count(MonsterTreasureInventory) 179 | # puts_obj_count(PaymentLog) 180 | end 181 | 182 | 183 | end 184 | 185 | -------------------------------------------------------------------------------- /server/src/xmlsocket.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'socket' 4 | require 'logger' 5 | 6 | SERVER_LOG = Logger.new('/dev/stdout') 7 | RESPONSE = File.read('/app/server/script/Perl_xinetd/flashpolicy.xml') 8 | 9 | server = TCPServer.new 11999 10 | 11 | SERVER_LOG.info('XMLSocket server is starting...') 12 | 13 | loop do 14 | client = server.accept 15 | Thread.new do 16 | SERVER_LOG.info("Client #{client.addr&.last} is connected") 17 | client.write(RESPONSE) 18 | client.close 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /templates/docker-compose.custom.yml.erb: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | x-image: &image 3 | image: unlight-server 4 | env_file: 5 | - server.env 6 | restart: unless-stopped 7 | services: 8 | <% services.each do |service| %> 9 | <%= "#{service.name}_server" %>: 10 | <<: *image 11 | command: <%= service.command %> 12 | ports: 13 | - '<%= service.port %>' 14 | <% end %> 15 | --------------------------------------------------------------------------------