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

Item cloning and server crash with 'classicEquipmentSlots = true' #457

Closed
2 of 5 tasks
gerotib opened this issue Jul 26, 2022 · 3 comments · Fixed by #464
Closed
2 of 5 tasks

Item cloning and server crash with 'classicEquipmentSlots = true' #457

gerotib opened this issue Jul 26, 2022 · 3 comments · Fixed by #464
Labels
Priority: Critical Represents a risk to live servers Status: Pending Test This PR or Issue requires more testing Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@gerotib
Copy link
Contributor

gerotib commented Jul 26, 2022

Priority

Critical

Area

  • Datapack
  • Source
  • Map
  • Other

What happened?

With classicEquipmentSlots = true in config.lua it is possible to clone stackable items after changing id in clientoptions.json file. If theres any stackable and quippable item by default it will be possible without clientoptions edit.
Additionally if you take your backpack off and try to do this again, it will just crash the server.

Thread 2 (Thread 0x7ffff5bba700 (LWP 1208985)):
#0  0x00005555557fd206 in Game::onPressHotkeyEquip(unsigned int, unsigned short) ()
No symbol table info available.
#1  0x000055555568e013 in Dispatcher::threadMain() ()
No symbol table info available.
#2  0x00007ffff70a2de4 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.

Steps to reproduce:

  1. Set anything to hotkey with 'Equip/unequip' option
  2. Copy id of stackable item you want to clone.
  3. Exit client.
  4. Open clientoptions.json in client files and change id from hotkey to one you want to clone
   "useEquipSmartMode": false,
   "useObject": 3043, <-- here
   "useType": "Equip"
  1. Save file.
  2. Open client and put one item you want to clone in hand and second in arrow slot.
  3. Spam the hotkey and youll get +1 item each time.

Video: (click hd option)
https://gfycat.com/splendidsamehoneycreeper

What OS are you seeing the problem on?

Windows

Code of Conduct

  • I agree to follow this project's Code of Conduct
@gerotib gerotib added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Jul 26, 2022
@gerotib gerotib changed the title Stackable item cloning with 'classicEquipmentSlots = true' Item cloning and server crash with 'classicEquipmentSlots = true' Jul 26, 2022
@github-actions github-actions bot added map Priority: Critical Represents a risk to live servers Status: Pending Test This PR or Issue requires more testing labels Jul 26, 2022
@un000000
Copy link
Contributor

Hey.
Im posting a solution (that worked for me) to problem issued in this thread. Be warned that im not very knowledgeable in cpp, and this is my first post on github :)

  1. To avoid crashes change this line in game.cpp:

Container* mainBP = player->getInventoryItem(CONST_SLOT_BACKPACK)->getContainer();

to

Item* playerItem = player->getInventoryItem(CONST_SLOT_BACKPACK);
if(playerItem == NULL){break;}
Container* mainBP = playerItem->getContainer();
if(mainBP == NULL){break;}

  1. To avoid item dupe change this line in game.cpp:

internalAddItem(player, newSlotitem, slotP, FLAG_NOLIMIT);

to

if(count>0){
internalAddItem(player, newSlotitem, slotP, FLAG_NOLIMIT);
}

@dudantas
Copy link
Contributor

dudantas commented Jul 27, 2022

Hey. Im posting a solution (that worked for me) to problem issued in this thread. Be warned that im not very knowledgeable in cpp, and this is my first post on github :)

  1. To avoid crashes change this line in game.cpp:

Container* mainBP = player->getInventoryItem(CONST_SLOT_BACKPACK)->getContainer();

to

Item* playerItem = player->getInventoryItem(CONST_SLOT_BACKPACK); if(playerItem == NULL){break;} Container* mainBP = playerItem->getContainer(); if(mainBP == NULL){break;}

  1. To avoid item dupe change this line in game.cpp:

internalAddItem(player, newSlotitem, slotP, FLAG_NOLIMIT);

to

if(count>0){ internalAddItem(player, newSlotitem, slotP, FLAG_NOLIMIT); }

Thanks for the feedback, I'll open a pull request and ask them to test it, if it confirms that it solves, we'll merge it.

Regards!

@dudantas
Copy link
Contributor

@gerotib can test #459?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Critical Represents a risk to live servers Status: Pending Test This PR or Issue requires more testing Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants