Skip to content

Instantly share code, notes, and snippets.

@ranisalt
Created May 11, 2015 05:36
Show Gist options
  • Select an option

  • Save ranisalt/bde8bab916461593d5c8 to your computer and use it in GitHub Desktop.

Select an option

Save ranisalt/bde8bab916461593d5c8 to your computer and use it in GitHub Desktop.
Offline training optional
From 39f11e36d0fc2cf43a06108808d6bba35462dc8f Mon Sep 17 00:00:00 2001
From: Ranieri Althoff <ranisalt@gmail.com>
Date: Mon, 11 May 2015 01:36:26 -0300
Subject: [PATCH] Make offline training optional via config.lua
---
config.lua | 1 +
src/actions.cpp | 6 +++++-
src/configmanager.cpp | 1 +
src/configmanager.h | 1 +
4 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/config.lua b/config.lua
index 927cc2b..b7b0da6 100644
--- a/config.lua
+++ b/config.lua
@@ -70,6 +70,7 @@ kickIdlePlayerAfterMinutes = 15
maxMessageBuffer = 4
emoteSpells = false
classicEquipmentSlots = false
+offlineTrainingSystem = true
-- Rates
-- NOTE: rateExp is not used if you have enabled stages in data/XML/stages.xml
diff --git a/src/actions.cpp b/src/actions.cpp
index aa28e50..32983ff 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -303,7 +303,11 @@ ReturnValue Actions::internalUseItem(Player* player, const Position& pos, uint8_
if (bed->trySleep(player)) {
player->setBedItem(bed);
- g_game.sendOfflineTrainingDialog(player);
+ if (g_config.getBoolean(ConfigManager::OFFLINE_TRAINING_SYSTEM)) {
+ g_game.sendOfflineTrainingDialog(player);
+ } else {
+ bed->sleep(player);
+ }
}
return RETURNVALUE_NOERROR;
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index 897c002..e4de361 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -88,6 +88,7 @@ bool ConfigManager::load()
boolean[WARN_UNSAFE_SCRIPTS] = getGlobalBoolean(L, "warnUnsafeScripts", true);
boolean[CONVERT_UNSAFE_SCRIPTS] = getGlobalBoolean(L, "convertUnsafeScripts", true);
boolean[CLASSIC_EQUIPMENT_SLOTS] = getGlobalBoolean(L, "classicEquipmentSlots", false);
+ boolean[OFFLINE_TRAINING_SYSTEM] = getGlobalBoolean(L, "offlineTrainingSystem", true);
string[DEFAULT_PRIORITY] = getGlobalString(L, "defaultPriority", "high");
string[SERVER_NAME] = getGlobalString(L, "serverName", "");
diff --git a/src/configmanager.h b/src/configmanager.h
index 9dfa46d..d3b47a3 100644
--- a/src/configmanager.h
+++ b/src/configmanager.h
@@ -44,6 +44,7 @@ class ConfigManager
WARN_UNSAFE_SCRIPTS,
CONVERT_UNSAFE_SCRIPTS,
CLASSIC_EQUIPMENT_SLOTS,
+ OFFLINE_TRAINING_SYSTEM,
LAST_BOOLEAN_CONFIG /* this must be the last one */
};
--
2.4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment