• 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+ Crash getOutfitByLookType

CastorFlynn

Member
Joined
Aug 29, 2021
Messages
100
Reaction score
15
TFS 1.3+
After the server save the server crashed after 2 minutes and did not return. The website was also offline until the tfs screen on Ubuntu was closed. In the last log record there were 25 players online, the same number of console errors.

Console error log:
Code:
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'
[Error - mysql_real_query] Query: INSERT INTO `players_online` VALUES (0)
Message: Duplicate entry '0' for key 'PRIMARY'

Thread 2 "tfs" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6c8e700 (LWP 2030252)]
Outfits::getOutfitByLookType (this=this@entry=0x5555558cbdc0 <Outfits::getInstance()::instance>, sex=3, lookType=1437) at outfit.cpp:58
58            if (outfit.lookType == lookType) {

Thread 2 "tfs" received signal SIGSEGV, Segmentation fault.
Outfits::getOutfitByLookType (this=this@entry=0x5555558cbdc0 <Outfits::getInstance()::instance>, sex=3, lookType=lookType@entry=136) at outfit.cpp:58
58            if (outfit.lookType == lookType) {
/home/Server/gdb_config:6: Error in sourced command file:
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(Game::saveServer()) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb)

outfit.cpp:
C++:
#include "otpch.h"

#include "outfit.h"

#include "pugicast.h"
#include "tools.h"

bool Outfits::loadFromXml()
{
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file("data/XML/outfits.xml");
    if (!result) {
        printXMLError("Error - Outfits::loadFromXml", "data/XML/outfits.xml", result);
        return false;
    }

    for (auto outfitNode : doc.child("outfits").children()) {
        pugi::xml_attribute attr;
        if ((attr = outfitNode.attribute("enabled")) && !attr.as_bool()) {
            continue;
        }

        if ((attr = outfitNode.attribute("ignoreAddons"))) {
        }

        if (!(attr = outfitNode.attribute("type"))) {
            std::cout << "[Warning - Outfits::loadFromXml] Missing outfit type." << std::endl;
            continue;
        }

        uint16_t type = pugi::cast<uint16_t>(attr.value());
        if (type > PLAYERSEX_LAST) {
            std::cout << "[Warning - Outfits::loadFromXml] Invalid outfit type " << type << "." << std::endl;
            continue;
        }

        pugi::xml_attribute lookTypeAttribute = outfitNode.attribute("looktype");
        if (!lookTypeAttribute) {
            std::cout << "[Warning - Outfits::loadFromXml] Missing looktype on outfit." << std::endl;
            continue;
        }

        outfits[type].emplace_back(
            outfitNode.attribute("name").as_string(),
            pugi::cast<uint16_t>(lookTypeAttribute.value()),
            outfitNode.attribute("premium").as_bool(),
            outfitNode.attribute("unlocked").as_bool(true),
            outfitNode.attribute("ignoreAddons").as_bool()

        );
    }
    return true;
}

const Outfit* Outfits::getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const
{
    for (const Outfit& outfit : outfits[sex]) {
        if (outfit.lookType == lookType) {
            return &outfit;
        }
    }
    return nullptr;
}

const Outfit* Outfits::getOutfitByLookType(uint16_t lookType) const
{
    for (uint8_t sex = PLAYERSEX_FEMALE; sex <= PLAYERSEX_LAST; sex++) {
        for (const Outfit& outfit : outfits[sex]) {
            if (outfit.lookType == lookType) {
                return &outfit;
            }
        }
    }
    return nullptr;
}
 
Back
Top