Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: features OTCR natively in canary #3061

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4c54d85
1/6 feature: Creature : AttachedEffect, Shader
kokekanon Nov 4, 2024
745b7b8
2/7 feature: Map Shader
kokekanon Nov 4, 2024
ee26730
3/7 feature: TypingIcon
kokekanon Nov 5, 2024
23e166a
review: mehah
kokekanon Nov 5, 2024
eae4112
4/7 feature: Item Shader
kokekanon Nov 5, 2024
74ea55f
5/7 send disableFeature / enableFeature
kokekanon Nov 5, 2024
b09547e
review: dudantas
kokekanon Nov 5, 2024
9484492
fix sonarcloud bot
kokekanon Nov 5, 2024
f490ce4
fix sonarcloud bot 2
kokekanon Nov 5, 2024
1437b7e
fix: wrong review
dudantas Nov 5, 2024
67777a9
Code format - (Clang-format)
github-actions[bot] Nov 5, 2024
6766389
fix: itemShader old protocol otcr
kokekanon Nov 5, 2024
7c45b97
clean variable
kokekanon Nov 6, 2024
bd1854c
fix return get shader
kokekanon Nov 6, 2024
0ff915e
missing content player:getAttachedEffects
kokekanon Nov 6, 2024
f538950
simple test Talkations. delete when finished
kokekanon Nov 6, 2024
0217e80
Lua code format - (Stylua)
github-actions[bot] Nov 6, 2024
4b5fbad
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 6, 2024
9fe26c5
format
kokekanon Nov 6, 2024
7956f08
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 6, 2024
8d6961d
improve: variable name
kokekanon Nov 6, 2024
558b212
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Nov 6, 2024
3744f16
game_outfit functional version, not cleaned or optimized
kokekanon Nov 6, 2024
789354a
this requires review canary team .no break v8 and cipsoft
kokekanon Nov 7, 2024
6a23e40
Lua code format - (Stylua)
github-actions[bot] Nov 7, 2024
36da43e
fix: review sonarcloud ?
kokekanon Nov 7, 2024
8e939e5
Code format - (Clang-format)
github-actions[bot] Nov 7, 2024
c551152
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 7, 2024
5b5dc84
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Nov 7, 2024
9e763f7
simple test
kokekanon Nov 7, 2024
300f92c
Lua code format - (Stylua)
github-actions[bot] Nov 7, 2024
3bb868b
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 8, 2024
ef754d0
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Nov 8, 2024
6b27bb9
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 10, 2024
6097de3
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 10, 2024
ec0bd43
murge
kokekanon Nov 10, 2024
e30fd35
fix: compilation windows
kokekanon Nov 10, 2024
29919ed
Code format - (Clang-format)
github-actions[bot] Nov 10, 2024
6ed239c
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 13, 2024
2c46d0a
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 16, 2024
687d0b2
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 18, 2024
dce1886
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 25, 2024
f44bf10
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 29, 2024
8350458
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Dec 12, 2024
4d85029
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Dec 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,17 @@ metricsPrometheusAddress = "0.0.0.0:9464"
--- OStream
metricsEnableOstream = false
metricsOstreamInterval = 1000

-- OTC Features
-- NOTE: Features added in this list will be forced to be used on the client
-- These features can be found in "modules/gamelib/const.lua"
OTCRFeatures = {
enableFeature = {
101, -- g_game.enableFeature(GameItemShader)
102, -- g_game.enableFeature(GameCreatureAttachedEffect)
103, -- g_game.enableFeature(GameCreatureShader)
118 -- g_game.enableFeature(GameWingsAurasEffectsShader)
},
disableFeature = {
}
}
15 changes: 15 additions & 0 deletions data/XML/attachedeffects.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<attachedeffects>
<!-- aura -->
<aura id="8" name="8 aura" />
<!-- shader -->
<shader id="1" name="Outfit - Rainbow" />
<shader id="2" name="Outfit - Ghost" />
<shader id="3" name="Outfit - Jelly" />
<shader id="4" name="Outfit - Fragmented" />
<shader id="5" name="Outfit - Outline" />
<!-- effect -->
<effect id="7" name="7 effect" />
<!-- wing -->
<wing id="2" name="2 wings" />
<wing id="11" name="11 wings" />
</attachedeffects>
199 changes: 199 additions & 0 deletions data/scripts/talkactions/gm/delete_test_otcr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
local talkAction = TalkAction("!testOTCR")

local options = {
Creature = {
{
name = "set attach Effect 7",
action = function(player)
player:attachEffectById(7)
end,
},
{
name = "get all attach Effect",
action = function(player)
local effects = player:getAttachedEffects()
if #effects > 0 then
local effectsString = "your AE are: " .. table.concat(effects, ", ")
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, effectsString)
else
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "you do not have any AE.")
end
end,
},
{
name = "detach Effect 7",
action = function(player)
player:detachEffectById(7)
end,
},
{
name = "set Shader player",
action = function(player)
player:setShader("Outfit - Rainbow")
end,
},
{
name = "no shader player",
action = function(player)
player:setShader("")
end,
},
{
name = "get Shader player",
action = function(player)
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, player:getShader())
end,
},
},
Map = {
{
name = "set Shader Map",
action = function(player)
player:setMapShader("Map - Party")
end,
},
{
name = "no shader Map",
action = function(player)
player:setMapShader("")
end,
},
{
name = "get Shader Map",
action = function(player)
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, player:getMapShader())
end,
},
},
Items = { {
name = "Shader",
action = function(player)
local item = player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
item:setShader("Map - Party")
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "item have shader : " .. item:getShader())
end,
} },
game_outfit = {
{
name = "pdump auras",
action = function(player)
local effects = Game.getAllAttachedeffects("aura")
if #effects > 0 then
local ids = {}
for _, effect in ipairs(effects) do
table.insert(ids, effect.id)
end
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "aura registered on the server: ".. table.concat(ids, ", "))
else
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "the server did not charge aura check .xml")

end
end,
},
{
name = "pdump wing",
action = function(player)
local effects = Game.getAllAttachedeffects("wing")
if #effects > 0 then
local ids = {}
for _, effect in ipairs(effects) do
table.insert(ids, effect.id)
end
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "wing registered on the server: "..table.concat(ids, ", "))
else
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "the server did not charge wing check .xml")
end
end,
},
{
name = "pdump effect",
action = function(player)

local effects = Game.getAllAttachedeffects("effect")
if #effects > 0 then
local ids = {}
for _, effect in ipairs(effects) do
table.insert(ids, effect.id)
end
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "effect registered on the server: "..table.concat(ids, ", "))
else
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "the server did not charge effect check .xml")
end

end,
},
{
name = "pdump shader",
action = function(player)

local effects = Game.getAllAttachedeffects("shader")
if #effects > 0 then
local ids = {}
for _, effect in ipairs(effects) do
table.insert(ids, effect.name)
end
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "shader registered on the server: "..table.concat(ids, ", "))
else
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "the server did not charge shader check .xml")
end

end,
},
},
}

function talkAction.onSay(player, words, param, type)
local modalWindow = ModalWindow({
title = "Fast Test",
message = "Choose one of the following options:",
})

for category, subOptions in pairs(options) do
modalWindow:addChoice(category, function(player, button, choice)
local subModalWindow = ModalWindow({
title = "Select a Sub-Option",
message = "Choose one of the following sub-options for " .. category .. ":",
})

for _, subOption in ipairs(subOptions) do
subModalWindow:addChoice(subOption.name, function(plyr, btn, ch)
if button.name == "OK" then
subOption.action(plyr)
end
end)
end

subModalWindow:addButton("OK")
subModalWindow:addButton("Cancel", function(plyr)
subModalWindow:clear()
end)
subModalWindow:sendToPlayer(player)
end)
end

modalWindow:addButton("OK")
modalWindow:addButton("Cancel", function(player)
modalWindow:clear()
end)
modalWindow:sendToPlayer(player)
return false
end

talkAction:groupType("gamemaster")
talkAction:separator(" ")
talkAction:register()


local playerLoginTestOTCR = CreatureEvent("simpletest")

function playerLoginTestOTCR.onLogin(player)
if not player then
return false
end
if player:getClient().os >= 10 and player:getClient().os < 20 then
player:say("say !testOTCR", TALKTYPE_SAY)
end
return true
end

playerLoginTestOTCR:register()
42 changes: 42 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ bool ConfigManager::load() {
loadStringConfig(L, WORLD_TYPE, "worldType", "pvp");
loadStringConfig(L, LOGLEVEL, "logLevel", "info");

loadLuaOTCFeatures(L);

loaded = true;
lua_close(L);
return true;
Expand Down Expand Up @@ -464,3 +466,43 @@ float ConfigManager::getFloat(const ConfigKey_t &key, const std::source_location
g_logger().warn("[{}] accessing invalid or wrong type index: {}[{}]. Called line: {}:{}, in {}", __FUNCTION__, magic_enum::enum_name(key), fmt::underlying(key), location.line(), location.column(), location.function_name());
return 0.0f;
}

void ConfigManager::loadLuaOTCFeatures(lua_State* L) {
lua_getglobal(L, "OTCRFeatures");
if (!lua_istable(L, -1)) {
return;
}

lua_pushstring(L, "enableFeature");
lua_gettable(L, -2);
if (lua_istable(L, -1)) {
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
const auto feature = static_cast<uint8_t>(lua_tointeger(L, -1));
enabledFeaturesOTC.push_back(feature);
lua_pop(L, 1);
}
}
lua_pop(L, 1);

lua_pushstring(L, "disableFeature");
lua_gettable(L, -2);
if (lua_istable(L, -1)) {
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
const auto feature = static_cast<uint8_t>(lua_tointeger(L, -1));
disabledFeaturesOTC.push_back(feature);
lua_pop(L, 1);
}
}
lua_pop(L, 1);

lua_pop(L, 1);
}
OTCFeatures ConfigManager::getEnabledFeaturesOTC() const {
return enabledFeaturesOTC;
}

OTCFeatures ConfigManager::getDisabledFeaturesOTC() const {
return disabledFeaturesOTC;
}
6 changes: 6 additions & 0 deletions src/config/configmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "config_enums.hpp"

using ConfigValue = std::variant<std::string, int32_t, bool, float>;
using OTCFeatures = std::vector<uint8_t>;

class ConfigManager {
public:
Expand Down Expand Up @@ -40,6 +41,8 @@ class ConfigManager {
[[nodiscard]] int32_t getNumber(const ConfigKey_t &key, const std::source_location &location = std::source_location::current()) const;
[[nodiscard]] bool getBoolean(const ConfigKey_t &key, const std::source_location &location = std::source_location::current()) const;
[[nodiscard]] float getFloat(const ConfigKey_t &key, const std::source_location &location = std::source_location::current()) const;
OTCFeatures getEnabledFeaturesOTC() const;
OTCFeatures getDisabledFeaturesOTC() const;

private:
phmap::flat_hash_map<ConfigKey_t, ConfigValue> configs;
Expand All @@ -50,6 +53,9 @@ class ConfigManager {

std::string configFileLua = { "config.lua" };
bool loaded = false;
OTCFeatures enabledFeaturesOTC = {};
OTCFeatures disabledFeaturesOTC = {};
void loadLuaOTCFeatures(lua_State* L);
};

constexpr auto g_configManager = ConfigManager::getInstance;
1 change: 1 addition & 0 deletions src/creatures/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
target_sources(${PROJECT_NAME}_lib PRIVATE
appearance/mounts/mounts.cpp
appearance/outfit/outfit.cpp
appearance/attachedeffects/attachedeffects.cpp
combat/combat.cpp
combat/condition.cpp
combat/spells.cpp
Expand Down
Loading