• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ TFS 1.5 8.6 strange bug when making "Look" in backpacks at NPC shop module

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,521
Solutions
27
Reaction score
870
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I found a little bug that crashes the server, if I "look" any backpack that is on selling NPC module. To explain it better i'll attach the following image:
1683473345537.png

So description doesn't even appear before the server is crashed. This only happens with backpacks on NPC modules, for the moment haven't found more situations where this can be triggered. Any ideas of how to fix?, or if this replicates on any TFS 1.5 downgrades 8.6? If someone is up to make the test/possibly fix I'll appreciate it a lot! Regards :)

Edit: it seems to happen with any container, parcels tested aswell and crash too
 
Bump, anyone has experienced something similar? Maybe we shall join some servers and try it on our own...
Post automatically merged:

Local debugging helped a lot. Problem was referring to the getName() method on null item. Crashes in server are done by nullpointer exception in that case. If you have quiver implementation from the topic: Feature - Quiver [TFS 1.X + 0.X] (https://otland.net/threads/quiver-tfs-1-x-0-x.264070/page-3#post-2740508) (I know it since we met there on that thread) nullpointr was thrown here:

Item.h
C++:
        const std::string& getName() const {
            if (hasAttribute(ITEM_ATTRIBUTE_NAME)) {
                return getStrAttr(ITEM_ATTRIBUTE_NAME);
            }
            return items[id].name;
        }

whole item was null so referring to "getName()" was crashing server. For me changing item.cpp implementation was work around good enough. Check code in Item::getDescription method regarding containers:
My working code is as follows ("item" was null, we've got whole data in "it").

C++:
else if (it.isContainer() || (item && item->getContainer())) {
        uint32_t volume = 0;
        if (!item || !item->hasAttribute(ITEM_ATTRIBUTE_UNIQUEID)) {
            if (it.isContainer()) {
                volume = it.name.find("quiver") != std::string::npos ? 5 : it.maxItems;
            } else {
                volume = item->getContainer()->capacity();
            }
        }

Hope it helps!
 
Last edited:
Back
Top