From 457e8853d1e7c1c741e78d70672c0ba68c845b5c Mon Sep 17 00:00:00 2001 From: Micrah <44911744+milestorme@users.noreply.github.com> Date: Sat, 21 Dec 2019 14:29:57 +1100 Subject: [PATCH] update module (#8) * update module * update readme --- .travis.yml | 102 ++++++++++++++++--------- CMakeLists.txt | 2 +- README.md | 3 + conf/conf.sh.dist | 9 +++ conf/reward_system.conf.dist | 7 ++ include.sh | 9 +++ sql/{ => characters}/reward_system.sql | 7 +- src/reward_system.cpp | 25 +++--- 8 files changed, 110 insertions(+), 54 deletions(-) create mode 100644 conf/conf.sh.dist rename sql/{ => characters}/reward_system.sql (73%) diff --git a/.travis.yml b/.travis.yml index 6cf74dd..848d188 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,76 @@ sudo: required -dist: trusty # (14.04) -# xenial (16.04) is not supported yet +dist: bionic # (18.04) language: cpp -compiler: - - clang + +cache: ccache + +addons: + apt: + update: true + +services: + - mysql git: - depth: 1 + depth: 10 -before_install: - - sudo apt-get -y install build-essential libtool make cmake cmake-data openssl - - sudo apt-get -y install libssl-dev libmysqlclient-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev libace-dev - - git config user.email "travis@build.bot" && git config user.name "Travis CI" - - git tag -a -m "Travis build" init - -install: - - cd .. - - git clone --depth=1 --branch=master https://github.com/azerothcore/azerothcore-wotlk.git azerothcore - - mv mod-reward-playtime azerothcore/modules - - cd azerothcore - - git submodule update --init --recursive +stages: + - prepare_cache + - run - - mysql -uroot -e 'create database test_mysql;' - - cd bin - - cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=0 -DSCRIPTS=1 -DSERVERS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=check_install - - cd .. +jobs: + include: + - stage: prepare_cache + env: TRAVIS_BUILD_ID="1" + before_install: + - cd .. + - git clone --depth=1 --branch=master https://github.com/azerothcore/azerothcore-wotlk.git azerothcore-wotlk + - mv "$TRAVIS_BUILD_DIR" azerothcore-wotlk/modules + - cd azerothcore-wotlk + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh OFF + script: + - source ./apps/ci/ci-compile.sh -script: - - $CXX --version - - mysql -uroot < data/sql/create/create_mysql.sql - - cat data/sql/base/db_auth/*.sql | mysql -uacore -pacore auth - - cat data/sql/base/db_characters/*.sql | mysql -uacore -pacore characters - - cat data/sql/base/db_world/*.sql | mysql -uacore -pacore world - - cat data/sql/updates/db_auth/*.sql | mysql -uacore -pacore auth - - cat data/sql/updates/db_characters/*.sql | mysql -uacore -pacore characters - - cat data/sql/updates/db_world/*.sql | mysql -uacore -pacore world - - mysql -uroot < data/sql/create/drop_mysql.sql - - cd bin - - make -j 8 -k && make install - - cd check_install/bin + - stage: run + env: TRAVIS_BUILD_ID="1" + before_install: + - cd .. + - git clone --depth=1 --branch=master https://github.com/azerothcore/azerothcore-wotlk.git azerothcore-wotlk + - mv "$TRAVIS_BUILD_DIR" azerothcore-wotlk/modules + - cd azerothcore-wotlk + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh ON + - source ./apps/ci/ci-import-db.sh + script: + - source ./apps/ci/ci-compile.sh + - source ./apps/ci/ci-worldserver-dry-run.sh + + - stage: prepare_cache + env: TRAVIS_BUILD_ID="2" + before_install: + - cd .. + - git clone --depth=1 --branch=master https://github.com/azerothcore/azerothcore-wotlk.git azerothcore-wotlk + - mv "$TRAVIS_BUILD_DIR" azerothcore-wotlk/modules + - cd azerothcore-wotlk + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh OFF + script: + - source ./apps/ci/ci-compile.sh + + - stage: run + env: TRAVIS_BUILD_ID="2" + before_install: + - cd .. + - git clone --depth=1 --branch=master https://github.com/azerothcore/azerothcore-wotlk.git azerothcore-wotlk + - mv "$TRAVIS_BUILD_DIR" azerothcore-wotlk/modules + - cd azerothcore-wotlk + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh ON + script: + - source ./apps/ci/ci-compile.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index be8fd93..932fdc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,6 @@ AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/reward_system.cpp") AC_ADD_SCRIPT_LOADER("RewardSystem" "${CMAKE_CURRENT_LIST_DIR}/src/loader.h") -CU_ADD_HOOK(AFTER_WORLDSERVER_CMAKE "${CMAKE_CURRENT_LIST_DIR}/src/cmake/after_ws_install.cmake") +AC_ADD_CONFIG_FILE("${CMAKE_CURRENT_LIST_DIR}/conf/reward_system.conf.dist") message("-- REWARD SYSTEM CONFIGURED --") diff --git a/README.md b/README.md index 50618fa..b1d03ed 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ +# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore # Reward System +-- Latest build status with azerothcore: [![Build Status](https://travis-ci.org/azerothcore/mod-reward-played-time.svg?branch=master)](https://travis-ci.org/azerothcore/mod-reward-played-time) + This is a module for [AzerothCore](http://www.azerothcore.org) that adds items for players that have stayed logged in the x amount of time. diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist new file mode 100644 index 0000000..89a53ac --- /dev/null +++ b/conf/conf.sh.dist @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# +# CUSTOM +# + + DB_CHARACTERS_CUSTOM_PATHS+=( + $MOD_REWARD_SYSTEM_ROOT"/sql/characters/" + ) \ No newline at end of file diff --git a/conf/reward_system.conf.dist b/conf/reward_system.conf.dist index a929549..890630e 100644 --- a/conf/reward_system.conf.dist +++ b/conf/reward_system.conf.dist @@ -1,5 +1,12 @@ [worldserver] +# +# RewardSystemAnnounce +# Description: Announce the reward system +# Default: 1 - (Enabled) +# +RewardSystem.Announce = 1 + # # RewardSystemEnable # Description: Enable the reward system diff --git a/include.sh b/include.sh index e69de29..0548f2a 100644 --- a/include.sh +++ b/include.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + + MOD_REWARD_SYSTEM_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )" + + source $MOD_REWARD_SYSTEM_ROOT"/conf/conf.sh.dist" + + if [ -f $MOD_REWARD_SYSTEM_ROOT"/conf/conf.sh" ]; then + source $MOD_REWARD_SYSTEM_ROOT"/conf/conf.sh" + fi diff --git a/sql/reward_system.sql b/sql/characters/reward_system.sql similarity index 73% rename from sql/reward_system.sql rename to sql/characters/reward_system.sql index ef112e3..21df419 100644 --- a/sql/reward_system.sql +++ b/sql/characters/reward_system.sql @@ -16,9 +16,6 @@ CREATE TABLE IF NOT EXISTS `reward_system` ( `roll` int(11) NOT NULL, `item` int(11) NOT NULL, `quantity` int(11) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + --- Data exporting was unselected. -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/src/reward_system.cpp b/src/reward_system.cpp index 6f22438..0056c9b 100644 --- a/src/reward_system.cpp +++ b/src/reward_system.cpp @@ -3,10 +3,10 @@ #include "Configuration/Config.h" #include "Player.h" #include "AccountMgr.h" -#include "Chat.h" #include "ScriptMgr.h" #include "Define.h" #include "GossipDef.h" +#include "Chat.h" bool RewardSystem_Enable; uint32 Max_roll; @@ -14,23 +14,21 @@ uint32 Max_roll; class reward_system : public PlayerScript { public: - reward_system() : PlayerScript("rewardsystem") {} + reward_system() : PlayerScript("reward_system") {} uint32 RewardTimer; int32 roll; - void OnLogin(Player* p) - { - if (RewardSystem_Enable) - { - ChatHandler(p->GetSession()).SendSysMessage("This server is running the |cff4CFF00Player Reward System |rmodule."); - RewardTimer = (sConfigMgr->GetIntDefault("RewardTime", 1)*HOUR*IN_MILLISECONDS); - } - } + void OnLogin(Player* player) override + { + if (sConfigMgr->GetBoolDefault("RewardSystem.Announce", true)) { + ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00Reward Time Played |rmodule."); + } + } - void OnBeforeUpdate(Player* player, uint32 p_time) + void OnBeforeUpdate(Player* player, uint32 p_time) override { - if (RewardSystem_Enable) + if (sConfigMgr->GetBoolDefault("RewardSystemEnable", true)) { if (RewardTimer > 0) { @@ -89,7 +87,6 @@ public: std::string cfg_def_file = cfg_file + ".dist"; sConfigMgr->LoadMore(cfg_def_file.c_str()); sConfigMgr->LoadMore(cfg_file.c_str()); - RewardSystem_Enable = sConfigMgr->GetBoolDefault("RewardSystemEnable", true); Max_roll = sConfigMgr->GetIntDefault("MaxRoll", 1000); } } @@ -99,4 +96,4 @@ void AddRewardSystemScripts() { new reward_system(); new reward_system_conf(); -} +} \ No newline at end of file