• 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.3] stages.xml dont accept (dotted numbers)

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Hi, I noticed that in tfs 1.3 there is a bug, stages.xml does not support dotted exp stages.
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<stages>
    <config enabled="1" />
        <stage minlevel="1" maxlevel="10" multiplier="10"/>
        <stage minlevel="101" maxlevel="200" multiplier="5"/>
        <stage minlevel="201" maxlevel="300" multiplier="2.5"/>
        <stage minlevel="301" maxlevel="400" multiplier="1.5"/>
        <stage minlevel="401" maxlevel="500" multiplier="1"/>
        <stage minlevel="501" multiplier="0.5"/>
</stages>

for exemple, if player is in stage (201 to 300) and i print
Code:
Game.getExperienceStage(self:getLevel())
it print 0, because have a dot in multiplier (2.5)
if i put multiplier value 2 or 3 it print correct....
in previous tfs (0.3.6, 0.4) I could put a point, would that be a source bug 1.3??
 
Last edited:
No. You'll very rarely have to worry about performance in Lua.
is hard to add here in source code? to accept dot
C++:
bool Game::loadExperienceStages()
{
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file("data/XML/stages.xml");
    if (!result) {
        printXMLError("Error - Game::loadExperienceStages", "data/XML/stages.xml", result);
        return false;
    }

    for (auto stageNode : doc.child("stages").children()) {
        if (strcasecmp(stageNode.name(), "config") == 0) {
            stagesEnabled = stageNode.attribute("enabled").as_bool();
        } else {
            uint32_t minLevel, maxLevel, multiplier;

            pugi::xml_attribute minLevelAttribute = stageNode.attribute("minlevel");
            if (minLevelAttribute) {
                minLevel = pugi::cast<uint32_t>(minLevelAttribute.value());
            } else {
                minLevel = 1;
            }

            pugi::xml_attribute maxLevelAttribute = stageNode.attribute("maxlevel");
            if (maxLevelAttribute) {
                maxLevel = pugi::cast<uint32_t>(maxLevelAttribute.value());
            } else {
                maxLevel = 0;
                lastStageLevel = minLevel;
                useLastStageLevel = true;
            }

            pugi::xml_attribute multiplierAttribute = stageNode.attribute("multiplier");
            if (multiplierAttribute) {
                multiplier = pugi::cast<uint32_t>(multiplierAttribute.value());
            } else {
                multiplier = 1;
            }

            if (useLastStageLevel) {
                stages[lastStageLevel] = multiplier;
            } else {
                for (uint32_t i = minLevel; i <= maxLevel; ++i) {
                    stages[i] = multiplier;
                }
            }
        }
    }
    return true;
}
 
is hard to add here in source code? to accept dot
C++:
bool Game::loadExperienceStages()
{
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file("data/XML/stages.xml");
    if (!result) {
        printXMLError("Error - Game::loadExperienceStages", "data/XML/stages.xml", result);
        return false;
    }

    for (auto stageNode : doc.child("stages").children()) {
        if (strcasecmp(stageNode.name(), "config") == 0) {
            stagesEnabled = stageNode.attribute("enabled").as_bool();
        } else {
            uint32_t minLevel, maxLevel, multiplier;

            pugi::xml_attribute minLevelAttribute = stageNode.attribute("minlevel");
            if (minLevelAttribute) {
                minLevel = pugi::cast<uint32_t>(minLevelAttribute.value());
            } else {
                minLevel = 1;
            }

            pugi::xml_attribute maxLevelAttribute = stageNode.attribute("maxlevel");
            if (maxLevelAttribute) {
                maxLevel = pugi::cast<uint32_t>(maxLevelAttribute.value());
            } else {
                maxLevel = 0;
                lastStageLevel = minLevel;
                useLastStageLevel = true;
            }

            pugi::xml_attribute multiplierAttribute = stageNode.attribute("multiplier");
            if (multiplierAttribute) {
                multiplier = pugi::cast<uint32_t>(multiplierAttribute.value());
            } else {
                multiplier = 1;
            }

            if (useLastStageLevel) {
                stages[lastStageLevel] = multiplier;
            } else {
                for (uint32_t i = minLevel; i <= maxLevel; ++i) {
                    stages[i] = multiplier;
                }
            }
        }
    }
    return true;
}
It's not worth the effort.
 
Back
Top