Skip to content

Commit

Permalink
otc features to config.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
MillhioreBT committed Apr 29, 2024
1 parent 943e542 commit fd5c373
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 291 deletions.
23 changes: 23 additions & 0 deletions src/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ ExperienceStages loadXMLStages()
return stages;
}

OTCFeatures loadLuaOTCFeatures(lua_State* L)
{
OTCFeatures features;

lua_getglobal(L, "OTCFeatures");
if (!lua_istable(L, -1)) {
return {};
}

lua_pushnil(L);
while (lua_next(L, -2) != 0) {
const auto feature = static_cast<uint8_t>(lua_tointeger(L, -1));
features.push_back(feature);
lua_pop(L, 1);
}
lua_pop(L, 1);
return features;
}

} // namespace

bool ConfigManager::load()
Expand Down Expand Up @@ -316,6 +335,8 @@ bool ConfigManager::load()
}
expStages.shrink_to_fit();

otcFeatures = loadLuaOTCFeatures(L);

loaded = true;
lua_close(L);

Expand Down Expand Up @@ -401,3 +422,5 @@ bool ConfigManager::setInteger(ConfigKeysInteger what, const int64_t value)
integers[what] = value;
return true;
}

OTCFeatures ConfigManager::getOTCFeatures() const { return otcFeatures; }
3 changes: 3 additions & 0 deletions src/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define FS_CONFIGMANAGER_H

using ExperienceStages = std::vector<std::tuple<uint32_t, uint32_t, float>>;
using OTCFeatures = std::vector<uint8_t>;

enum class ConfigKeysBoolean
{
Expand Down Expand Up @@ -154,6 +155,7 @@ class ConfigManager
std::string_view getString(ConfigKeysString what) const;
int64_t getInteger(ConfigKeysInteger what) const;
float getExperienceStage(const uint32_t level) const;
OTCFeatures getOTCFeatures() const;

bool setBoolean(ConfigKeysBoolean what, const bool value);
bool setString(ConfigKeysString what, std::string_view value);
Expand All @@ -169,6 +171,7 @@ class ConfigManager
ConfigValues<int64_t, ConfigKeysInteger> integers;

ExperienceStages expStages = {};
OTCFeatures otcFeatures = {};

bool loaded = false;
};
Expand Down
142 changes: 0 additions & 142 deletions src/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,148 +487,6 @@ enum ReloadTypes_t : uint8_t
RELOAD_TYPE_WEAPONS,
};

enum class GameFeature : uint8_t
{
ProtocolChecksum = 1,
AccountNames = 2,
ChallengeOnLogin = 3,
PenalityOnDeath = 4,
NameOnNpcTrade = 5,
DoubleFreeCapacity = 6,
DoubleExperience = 7,
TotalCapacity = 8,
SkillsBase = 9,
PlayerRegenerationTime = 10,
ChannelPlayerList = 11,
PlayerMounts = 12,
EnvironmentEffect = 13,
CreatureEmblems = 14,
ItemAnimationPhase = 15,
MagicEffectU16 = 16,
PlayerMarket = 17,
SpritesU32 = 18,
TileAddThingWithStackpos = 19,
OfflineTrainingTime = 20,
PurseSlot = 21,
FormatCreatureName = 22,
SpellList = 23,
ClientPing = 24,
ExtendedClientPing = 25,
DoubleHealth = 28,
DoubleSkills = 29,
ChangeMapAwareRange = 30,
MapMovePosition = 31,
AttackSeq = 32,
BlueNpcNameColor = 33,
DiagonalAnimatedText = 34,
LoginPending = 35,
NewSpeedLaw = 36,
ForceFirstAutoWalkStep = 37,
MinimapRemove = 38,
DoubleShopSellAmount = 39,
ContainerPagination = 40,
ThingMarks = 41,
LooktypeU16 = 42,
PlayerStamina = 43,
PlayerAddons = 44,
MessageStatements = 45,
MessageLevel = 46,
NewFluids = 47,
PlayerStateU16 = 48,
NewOutfitProtocol = 49,
PVPMode = 50,
WritableDate = 51,
AdditionalVipInfo = 52,
BaseSkillU16 = 53,
CreatureIcons = 54,
HideNpcNames = 55,
SpritesAlphaChannel = 56,
PremiumExpiration = 57,
BrowseField = 58,
EnhancedAnimations = 59,
OGLInformation = 60,
MessageSizeCheck = 61,
PreviewState = 62,
LoginPacketEncryption = 63,
ClientVersion = 64,
ContentRevision = 65,
ExperienceBonus = 66,
Authenticator = 67,
UnjustifiedPoints = 68,
SessionKey = 69,
DeathType = 70,
IdleAnimations = 71,
KeepUnawareTiles = 72,
IngameStore = 73,
IngameStoreHighlights = 74,
IngameStoreServiceType = 75,
AdditionalSkills = 76,
DistanceEffectU16 = 77,
Prey = 78,
DoubleMagicLevel = 79,

ExtendedOpcode = 80,
MinimapLimitedToSingleFloor = 81,
SendWorldName = 82,

DoubleLevel = 83,
DoubleSoul = 84,
DoublePlayerGoodsMoney = 85,
CreatureWalkthrough = 86,
DoubleTradeMoney = 87,
SequencedPackets = 88,
Tibia12Protocol = 89,

// 90-99 otclientv8 features
NewWalking = 90,
SlowerManualWalking = 91,

ItemTooltip = 93,

Bot = 95,
BiggerMapCache = 96,
ForceLight = 97,
NoDebug = 98,
BotProtection = 99,

// Custom features for customer
CreatureDirectionPassable = 100,
FasterAnimations = 101,
CenteredOutfits = 102,
SendIdentifiers = 103,
WingsAndAura = 104,
PlayerStateU32 = 105,
OutfitShaders = 106,
ForceAllowItemHotkeys = 107,
CountU16 = 108,
DrawAuraOnTop = 109,

// advanced features
PacketSizeU32 = 110,
PacketCompression = 111,

// OTCv8-dev features
OldInformationBar = 112,
HealthInfoBackground = 113,
WingOffset = 114,
AuraFrontAndBack = 115,

MapDrawGroundFirst = 116,
MapIgnoreCorpseCorrection = 117,
DontCacheFiles = 118,
BigAurasCenter = 119,
NewUpdateWalk = 120,
NewCreatureStacking = 121,
CreaturesMana = 122,
QuickLootFlags = 123,
DontMergeAnimatedText = 124,
MissionId = 125,
ItemCustomAttributes = 126,
AnimatedTextCustomFont = 127,

LastFeature = 130
};

inline constexpr int32_t CHANNEL_GUILD = 0x00;
inline constexpr int32_t CHANNEL_PARTY = 0x01;
inline constexpr int32_t CHANNEL_PRIVATE = 0xFFFF;
Expand Down
141 changes: 0 additions & 141 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,147 +1236,6 @@ void LuaScriptInterface::registerFunctions()
registerEnumClass(ExperienceRateType::BONUS);
registerEnumClass(ExperienceRateType::STAMINA);

// GameFeature
registerTable("GameFeature");

registerEnumClass(GameFeature::ProtocolChecksum);
registerEnumClass(GameFeature::AccountNames);
registerEnumClass(GameFeature::ChallengeOnLogin);
registerEnumClass(GameFeature::PenalityOnDeath);
registerEnumClass(GameFeature::NameOnNpcTrade);
registerEnumClass(GameFeature::DoubleFreeCapacity);
registerEnumClass(GameFeature::DoubleExperience);
registerEnumClass(GameFeature::TotalCapacity);
registerEnumClass(GameFeature::SkillsBase);
registerEnumClass(GameFeature::PlayerRegenerationTime);
registerEnumClass(GameFeature::ChannelPlayerList);
registerEnumClass(GameFeature::PlayerMounts);
registerEnumClass(GameFeature::EnvironmentEffect);
registerEnumClass(GameFeature::CreatureEmblems);
registerEnumClass(GameFeature::ItemAnimationPhase);
registerEnumClass(GameFeature::MagicEffectU16);
registerEnumClass(GameFeature::PlayerMarket);
registerEnumClass(GameFeature::SpritesU32);
registerEnumClass(GameFeature::TileAddThingWithStackpos);
registerEnumClass(GameFeature::OfflineTrainingTime);
registerEnumClass(GameFeature::PurseSlot);
registerEnumClass(GameFeature::FormatCreatureName);
registerEnumClass(GameFeature::SpellList);
registerEnumClass(GameFeature::ClientPing);
registerEnumClass(GameFeature::ExtendedClientPing);
registerEnumClass(GameFeature::DoubleHealth);
registerEnumClass(GameFeature::DoubleSkills);
registerEnumClass(GameFeature::ChangeMapAwareRange);
registerEnumClass(GameFeature::MapMovePosition);
registerEnumClass(GameFeature::AttackSeq);
registerEnumClass(GameFeature::BlueNpcNameColor);
registerEnumClass(GameFeature::DiagonalAnimatedText);
registerEnumClass(GameFeature::LoginPending);
registerEnumClass(GameFeature::NewSpeedLaw);
registerEnumClass(GameFeature::ForceFirstAutoWalkStep);
registerEnumClass(GameFeature::MinimapRemove);
registerEnumClass(GameFeature::DoubleShopSellAmount);
registerEnumClass(GameFeature::ContainerPagination);
registerEnumClass(GameFeature::ThingMarks);
registerEnumClass(GameFeature::LooktypeU16);
registerEnumClass(GameFeature::PlayerStamina);
registerEnumClass(GameFeature::PlayerAddons);
registerEnumClass(GameFeature::MessageStatements);
registerEnumClass(GameFeature::MessageLevel);
registerEnumClass(GameFeature::NewFluids);
registerEnumClass(GameFeature::PlayerStateU16);
registerEnumClass(GameFeature::NewOutfitProtocol);
registerEnumClass(GameFeature::PVPMode);
registerEnumClass(GameFeature::WritableDate);
registerEnumClass(GameFeature::AdditionalVipInfo);
registerEnumClass(GameFeature::BaseSkillU16);
registerEnumClass(GameFeature::CreatureIcons);
registerEnumClass(GameFeature::HideNpcNames);
registerEnumClass(GameFeature::SpritesAlphaChannel);
registerEnumClass(GameFeature::PremiumExpiration);
registerEnumClass(GameFeature::BrowseField);
registerEnumClass(GameFeature::EnhancedAnimations);
registerEnumClass(GameFeature::OGLInformation);
registerEnumClass(GameFeature::MessageSizeCheck);
registerEnumClass(GameFeature::PreviewState);
registerEnumClass(GameFeature::LoginPacketEncryption);
registerEnumClass(GameFeature::ClientVersion);
registerEnumClass(GameFeature::ContentRevision);
registerEnumClass(GameFeature::ExperienceBonus);
registerEnumClass(GameFeature::Authenticator);
registerEnumClass(GameFeature::UnjustifiedPoints);
registerEnumClass(GameFeature::SessionKey);
registerEnumClass(GameFeature::DeathType);
registerEnumClass(GameFeature::IdleAnimations);
registerEnumClass(GameFeature::KeepUnawareTiles);
registerEnumClass(GameFeature::IngameStore);
registerEnumClass(GameFeature::IngameStoreHighlights);
registerEnumClass(GameFeature::IngameStoreServiceType);
registerEnumClass(GameFeature::AdditionalSkills);
registerEnumClass(GameFeature::DistanceEffectU16);
registerEnumClass(GameFeature::Prey);
registerEnumClass(GameFeature::DoubleMagicLevel);

registerEnumClass(GameFeature::ExtendedOpcode);
registerEnumClass(GameFeature::MinimapLimitedToSingleFloor);
registerEnumClass(GameFeature::SendWorldName);

registerEnumClass(GameFeature::DoubleLevel);
registerEnumClass(GameFeature::DoubleSoul);
registerEnumClass(GameFeature::DoublePlayerGoodsMoney);
registerEnumClass(GameFeature::CreatureWalkthrough);
registerEnumClass(GameFeature::DoubleTradeMoney);
registerEnumClass(GameFeature::SequencedPackets);
registerEnumClass(GameFeature::Tibia12Protocol);

// 90 - 99 otclientv8 features registerEnumClass(GameFeature::NewWalking);
registerEnumClass(GameFeature::SlowerManualWalking);

registerEnumClass(GameFeature::ItemTooltip);

registerEnumClass(GameFeature::Bot);
registerEnumClass(GameFeature::BiggerMapCache);
registerEnumClass(GameFeature::ForceLight);
registerEnumClass(GameFeature::NoDebug);
registerEnumClass(GameFeature::BotProtection);

// Custom features for customer
registerEnumClass(GameFeature::CreatureDirectionPassable);
registerEnumClass(GameFeature::FasterAnimations);
registerEnumClass(GameFeature::CenteredOutfits);
registerEnumClass(GameFeature::SendIdentifiers);
registerEnumClass(GameFeature::WingsAndAura);
registerEnumClass(GameFeature::PlayerStateU32);
registerEnumClass(GameFeature::OutfitShaders);
registerEnumClass(GameFeature::ForceAllowItemHotkeys);
registerEnumClass(GameFeature::CountU16);
registerEnumClass(GameFeature::DrawAuraOnTop);

// advanced features
registerEnumClass(GameFeature::PacketSizeU32);
registerEnumClass(GameFeature::PacketCompression);

// OTCv8 - dev features
registerEnumClass(GameFeature::OldInformationBar);
registerEnumClass(GameFeature::HealthInfoBackground);
registerEnumClass(GameFeature::WingOffset);
registerEnumClass(GameFeature::AuraFrontAndBack);

registerEnumClass(GameFeature::MapDrawGroundFirst);
registerEnumClass(GameFeature::MapIgnoreCorpseCorrection);
registerEnumClass(GameFeature::DontCacheFiles);
registerEnumClass(GameFeature::BigAurasCenter);
registerEnumClass(GameFeature::NewUpdateWalk);
registerEnumClass(GameFeature::NewCreatureStacking);
registerEnumClass(GameFeature::CreaturesMana);
registerEnumClass(GameFeature::QuickLootFlags);
registerEnumClass(GameFeature::DontMergeAnimatedText);
registerEnumClass(GameFeature::MissionId);
registerEnumClass(GameFeature::ItemCustomAttributes);
registerEnumClass(GameFeature::AnimatedTextCustomFont);

registerEnumClass(GameFeature::LastFeature);

// Combat Formula
registerEnum(COMBAT_FORMULA_UNDEFINED);
registerEnum(COMBAT_FORMULA_LEVELMAGIC);
Expand Down
12 changes: 4 additions & 8 deletions src/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
}

if (isOTCv8) {
//sendOTCv8Features();
sendOTCv8Features();
NetworkMessage opcodeMessage;
opcodeMessage.addByte(0x32);
opcodeMessage.addByte(0x00);
Expand Down Expand Up @@ -2704,17 +2704,13 @@ void ProtocolGame::parseExtendedOpcode(NetworkMessage& msg)

void ProtocolGame::sendOTCv8Features()
{
std::vector<GameFeature> features = {GameFeature::ExtendedOpcode, GameFeature::PlayerMounts,
GameFeature::SpritesU32, GameFeature::SpritesAlphaChannel,
GameFeature::IdleAnimations, GameFeature::EnhancedAnimations,
GameFeature::AdditionalSkills, GameFeature::DoubleSkills,
GameFeature::SkillsBase, GameFeature::BaseSkillU16};
const auto& features = g_config.getOTCFeatures();

auto msg = getOutputBuffer(1024);
msg->addByte(0x43);
msg->add<uint16_t>(features.size());
for (const GameFeature& feature : features) {
msg->addByte(static_cast<uint8_t>(feature));
for (uint8_t feature : features) {
msg->addByte(feature);
msg->addByte(0x01);
}

Expand Down

0 comments on commit fd5c373

Please sign in to comment.