Skip to content

Commit

Permalink
[Bug] remove classicEquipmentSlots (#679)
Browse files Browse the repository at this point in the history
The system is no longer functional, as so much code has been modified and no support has been given to it, it no longer makes sense to have it in the repository.
  • Loading branch information
murilo09 authored Dec 9, 2022
1 parent 7bfa4ca commit ec3a891
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 87 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ We use the [issue tracker on GitHub](https://github.com/opentibiabr/canary/issue

Before [creating a pull request](https://github.com/opentibiabr/canary/pulls) please keep in mind:

* Do not send Pull Request changing the map, as we can't review the changes it's better to use our [Discord](https://discord.gg/3NxYnyV) to talk about or send the map changes to the responsible for updating it.
* Do not send Pull Request changing the map, as we can't review the changes it's better to use our [Discord](https://discord.gg/X3mSnMH8jg) to talk about or send the map changes to the responsible for updating it.
* Focus on fixing only one thing, mixing too much things on the same Pull Request make it harder to review, harder to test and if we need to revert the change it will remove other things together.
* Follow the project indentation, if your editor support you can use the [editorconfig](https://editorconfig.org/) to automatic configure the indentation.
* There are people that doesn't play the game on the official server, so explain your changes to help understand what are you changing and why.
Expand Down
1 change: 0 additions & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ freePremium = false
kickIdlePlayerAfterMinutes = 15
maxMessageBuffer = 4
emoteSpells = false
classicEquipmentSlots = false
allowWalkthrough = true
coinPacketSize = 25
coinImagesURL = "http://127.0.0.1/images/store/"
Expand Down
1 change: 0 additions & 1 deletion src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ enum booleanConfig_t {
STAMINA_SYSTEM,
WARN_UNSAFE_SCRIPTS,
CONVERT_UNSAFE_SCRIPTS,
CLASSIC_EQUIPMENT_SLOTS,
CLASSIC_ATTACK_SPEED,
SCRIPTS_CONSOLE_LOGS,
REMOVE_WEAPON_AMMO,
Expand Down
1 change: 0 additions & 1 deletion src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ bool ConfigManager::load()
boolean[STAMINA_SYSTEM] = getGlobalBoolean(L, "staminaSystem", true);
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[CLASSIC_ATTACK_SPEED] = getGlobalBoolean(L, "classicAttackSpeed", false);
boolean[SCRIPTS_CONSOLE_LOGS] = getGlobalBoolean(L, "showScriptsLogInConsole", true);
boolean[STASH_MOVING] = getGlobalBoolean(L, "stashMoving", false);
Expand Down
157 changes: 76 additions & 81 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2993,11 +2993,7 @@ ReturnValue Player::queryAdd(int32_t index, const Thing& thing, uint32_t count,
} else if (slotPosition & SLOTP_TWO_HAND) {
ret = RETURNVALUE_PUTTHISOBJECTINBOTHHANDS;
} else if ((slotPosition & SLOTP_RIGHT) || (slotPosition & SLOTP_LEFT)) {
if (!g_configManager().getBoolean(CLASSIC_EQUIPMENT_SLOTS)) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else {
ret = RETURNVALUE_PUTTHISOBJECTINYOURHAND;
}
ret = RETURNVALUE_CANNOTBEDRESSED;
}

switch (index) {
Expand Down Expand Up @@ -3031,99 +3027,98 @@ ReturnValue Player::queryAdd(int32_t index, const Thing& thing, uint32_t count,

case CONST_SLOT_RIGHT: {
if (slotPosition & SLOTP_RIGHT) {
if (!g_configManager().getBoolean(CLASSIC_EQUIPMENT_SLOTS)) {
if (item->getWeaponType() != WEAPON_SHIELD && !item->isQuiver()) {
ret = RETURNVALUE_CANNOTBEDRESSED;
}
else {
const Item* leftItem = inventory[CONST_SLOT_LEFT];
if (leftItem) {
if ((leftItem->getSlotPosition() | slotPosition) & SLOTP_TWO_HAND) {
if (item->isQuiver() && leftItem->getWeaponType() == WEAPON_DISTANCE)
ret = RETURNVALUE_NOERROR;
else
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
}
else {
ret = RETURNVALUE_NOERROR;
}
}
else {
ret = RETURNVALUE_NOERROR;
}
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_LEFT] && inventory[CONST_SLOT_LEFT] != item) {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
if (item->getWeaponType() != WEAPON_SHIELD && !item->isQuiver()) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else {
const Item *leftItem = inventory[CONST_SLOT_LEFT];
if (leftItem) {
if ((leftItem->getSlotPosition() | slotPosition) & SLOTP_TWO_HAND) {
if (item->isQuiver() && leftItem->getWeaponType() == WEAPON_DISTANCE)
ret = RETURNVALUE_NOERROR;
else
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
} else {
ret = RETURNVALUE_NOERROR;
}
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (inventory[CONST_SLOT_LEFT]) {
const Item* leftItem = inventory[CONST_SLOT_LEFT];
WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();

if (leftItem->getSlotPosition() & SLOTP_TWO_HAND) {
ret = RETURNVALUE_DROPTWOHANDEDITEM;
} else if (item == leftItem && count == item->getItemCount()) {
ret = RETURNVALUE_NOERROR;
} else if (leftType == WEAPON_SHIELD && type == WEAPON_SHIELD) {
ret = RETURNVALUE_CANONLYUSEONESHIELD;
} else if (leftType == WEAPON_NONE || type == WEAPON_NONE ||
leftType == WEAPON_SHIELD || leftType == WEAPON_AMMO
|| type == WEAPON_SHIELD || type == WEAPON_AMMO) {
ret = RETURNVALUE_NOERROR;
} else {
ret = RETURNVALUE_CANONLYUSEONEWEAPON;
}
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_LEFT] && inventory[CONST_SLOT_LEFT] != item) {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (inventory[CONST_SLOT_LEFT]) {
const Item *leftItem = inventory[CONST_SLOT_LEFT];
WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();

if (leftItem->getSlotPosition() & SLOTP_TWO_HAND)
{
ret = RETURNVALUE_DROPTWOHANDEDITEM;
}
else if (item == leftItem && count == item->getItemCount())
{
ret = RETURNVALUE_NOERROR;
}
else if (leftType == WEAPON_SHIELD && type == WEAPON_SHIELD)
{
ret = RETURNVALUE_CANONLYUSEONESHIELD;
}
else if (leftType == WEAPON_NONE || type == WEAPON_NONE ||
leftType == WEAPON_SHIELD || leftType == WEAPON_AMMO || type == WEAPON_SHIELD || type == WEAPON_AMMO)
{
ret = RETURNVALUE_NOERROR;
}
else
{
ret = RETURNVALUE_CANONLYUSEONEWEAPON;
}
} else {
ret = RETURNVALUE_NOERROR;
}
break;
}

case CONST_SLOT_LEFT: {
if (slotPosition & SLOTP_LEFT) {
if (!g_configManager().getBoolean(CLASSIC_EQUIPMENT_SLOTS)) {
WeaponType_t type = item->getWeaponType();
if (type == WEAPON_NONE || type == WEAPON_SHIELD || type == WEAPON_AMMO) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (inventory[CONST_SLOT_RIGHT] && (slotPosition & SLOTP_TWO_HAND)) {
if (type == WEAPON_DISTANCE && inventory[CONST_SLOT_RIGHT]->isQuiver()) {
ret = RETURNVALUE_NOERROR;
}
else {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
}
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_RIGHT] && inventory[CONST_SLOT_RIGHT] != item) {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (inventory[CONST_SLOT_RIGHT]) {
const Item* rightItem = inventory[CONST_SLOT_RIGHT];
WeaponType_t type = item->getWeaponType(), rightType = rightItem->getWeaponType();

if (rightItem->getSlotPosition() & SLOTP_TWO_HAND) {
ret = RETURNVALUE_DROPTWOHANDEDITEM;
} else if (item == rightItem && count == item->getItemCount()) {
ret = RETURNVALUE_NOERROR;
} else if (rightType == WEAPON_SHIELD && type == WEAPON_SHIELD) {
ret = RETURNVALUE_CANONLYUSEONESHIELD;
} else if (rightType == WEAPON_NONE || type == WEAPON_NONE ||
rightType == WEAPON_SHIELD || rightType == WEAPON_AMMO
|| type == WEAPON_SHIELD || type == WEAPON_AMMO) {
WeaponType_t type = item->getWeaponType();
if (type == WEAPON_NONE || type == WEAPON_SHIELD || type == WEAPON_AMMO) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (inventory[CONST_SLOT_RIGHT] && (slotPosition & SLOTP_TWO_HAND)) {
if (type == WEAPON_DISTANCE && inventory[CONST_SLOT_RIGHT]->isQuiver()) {
ret = RETURNVALUE_NOERROR;
} else {
ret = RETURNVALUE_CANONLYUSEONEWEAPON;
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
}
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_RIGHT] && inventory[CONST_SLOT_RIGHT] != item) {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (inventory[CONST_SLOT_RIGHT]) {
const Item* rightItem = inventory[CONST_SLOT_RIGHT];
WeaponType_t type = item->getWeaponType(), rightType = rightItem->getWeaponType();

if (rightItem->getSlotPosition() & SLOTP_TWO_HAND) {
ret = RETURNVALUE_DROPTWOHANDEDITEM;
} else if (item == rightItem && count == item->getItemCount()) {
ret = RETURNVALUE_NOERROR;
} else if (rightType == WEAPON_SHIELD && type == WEAPON_SHIELD) {
ret = RETURNVALUE_CANONLYUSEONESHIELD;
} else if (rightType == WEAPON_NONE || type == WEAPON_NONE ||
rightType == WEAPON_SHIELD || rightType == WEAPON_AMMO || type == WEAPON_SHIELD || type == WEAPON_AMMO) {
ret = RETURNVALUE_NOERROR;
} else {
ret = RETURNVALUE_CANONLYUSEONEWEAPON;
}
} else {
ret = RETURNVALUE_NOERROR;
}
break;
}
Expand All @@ -3150,7 +3145,7 @@ ReturnValue Player::queryAdd(int32_t index, const Thing& thing, uint32_t count,
}

case CONST_SLOT_AMMO: {
if ((slotPosition & SLOTP_AMMO) || g_configManager().getBoolean(CLASSIC_EQUIPMENT_SLOTS)) {
if ((slotPosition & SLOTP_AMMO)) {
ret = RETURNVALUE_NOERROR;
}
break;
Expand Down
1 change: 0 additions & 1 deletion src/lua/functions/core/game/config_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void ConfigFunctions::init(lua_State* L) {
registerEnumIn(L, "configKeys", STAMINA_SYSTEM)
registerEnumIn(L, "configKeys", WARN_UNSAFE_SCRIPTS)
registerEnumIn(L, "configKeys", CONVERT_UNSAFE_SCRIPTS)
registerEnumIn(L, "configKeys", CLASSIC_EQUIPMENT_SLOTS)
registerEnumIn(L, "configKeys", ALLOW_BLOCK_SPAWN)
registerEnumIn(L, "configKeys", CLASSIC_ATTACK_SPEED)
registerEnumIn(L, "configKeys", REMOVE_WEAPON_AMMO)
Expand Down
2 changes: 1 addition & 1 deletion src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ int PlayerFunctions::luaPlayerAddTaskHuntingPoints(lua_State* L) {
if (Player* player = getUserdata<Player>(L, 1)) {
auto points = getNumber<uint64_t>(L, 2);
player->addTaskHuntingPoints(getNumber<uint64_t>(L, 2));
lua_pushnumber(L, points);
lua_pushnumber(L, static_cast<lua_Number>(points));
} else {
lua_pushnil(L);
}
Expand Down

0 comments on commit ec3a891

Please sign in to comment.