• 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+ Console getting spammed with "1"

Zombiegod

Active Member
Joined
Oct 22, 2009
Messages
198
Solutions
1
Reaction score
25
legit no clue, so i just got everything moved over from 1.2 to the latest source, was testing things out, fixing things, updating code ect.
I got to the point that it was time to do login testing.

everything went mostly fine, had a few things i forgot. but good none the less.

The issue start when i go near my trainers, my console gets spammed with "1" till the point it crashed me once.

Its not just them, being near any creature will make "1" randomly appear in console, but not as bad as the trainers.

I tried changing and adding things i saw the monsters that were not spamming my console had. Nothing.

Any ideas what is causing this spam?


XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
  <monster name="Training Dummy" nameDescription="a training dummy" race="undead" experience="1" speed="0" manacost="0">
    <health now="1000000000" max="1000000000"/>
    <look typeex="5787" corpse="5972"/>
    <targetchange interval="40000" chance="0" />  <!-- excessively long intervals was a fix in the last server due to setting the think interval in the source from 1000 too 1 --> <!-- also this bit of code was added in a attempt to find out the problem -->
    <flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="0" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="100" />
        <flag runonhealth="0" />
        <flag rewardchest="1" />   <!-- does not need to be here, was testing things, removed at once point did not stop the spam -->
    </flags>
    <attacks>
      <attack name="melee" interval="20000" attack="1" skill="60"/>
    </attacks>
    <defenses armor="0" defense="0">
      <defense name="all outfits" interval="40000" chance="100">  <!-- spell to make them change outfits, removed at one point no change in the "1" spam -->
      </defense>
      <defense name="healing" interval="10000" chance="100" min="1000000000" max="1000000000"/> <!-- upped the interval on this, was at 1, but did not change anything -->
    </defenses>
    <immunities>
      <immunity invisible="1"/>
    </immunities>
    <loot>
    <item id="5903" chance="100000" uniquedrop="1" /><!-- ferumbras' hat -->
    <item name="longsword" chance="4000" />
    </loot>
  </monster>

any help would be much appreciated!
 
Have you done a folder search for print(1) ?
huh what do you mean?

EDIT: oh no one sec
Post automatically merged:

just search everything, even my source no "print(1)" anywhere, look up "print(" got a lot of results but nothing to do with 1.
 
Last edited:
after a bit of testing, i found that this monster is not sending 1 at all to the console


XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Berserker Chicken" namedescription="a admin murder chicken" race="blood" experience="0" speed="30000" manacost="220">
    <health now="1000000000" max="1000000000" />
    <look type="111" corpse="6042" />
    <targetchange interval="5000" chance="8" />
    <flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="0" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="100" />
        <flag runonhealth="0" />
        <flag canwalkonenergy="1" />
        <flag canwalkonfire="1" />
        <flag canwalkonpoison="1" />
        </flags>
    <attacks>
        <attack name="melee" interval="1" min="-1000000000" max="-1000000000" />
    </attacks>
    <defenses armor="1000000000" defense="1000000000">
    </defenses>
    <elements>
        <element holyPercent="1000000000" />
        <element deathPercent="1000000000" />
        <element firePercent="1000000000" />
        <element energyPercent="1000000000" />
        <element icePercent="1000000000" />
        <element earthPercent="1000000000" />
        <element physicalPercent="1000000000" />
    </elements>
    <immunities>
        <immunity death="1" />
        <immunity earth="1" />
        <immunity paralyze="1" />
        <immunity drunk="1" />
        <immunity drown="1" />
        <immunity invisible="1" />
        <immunity lifedrain="1" />
        <immunity drown="1" />
    </immunities>
    <voices interval="5000" chance="10">
        <voice sentence="Stay out! Admin only!" />
        <voice sentence="Players killed by me will be in trouble!" />
        <voice sentence="Death to all that enter" />
    </voices>
    <loot>
        <item name="gold coin" countmax="100" chance="50000" />
    </loot>
</monster>
and this one sends out a 1 every now and then but not as fast as the trainer.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Cat" nameDescription="a cat" race="blood" experience="0" speed="124" manacost="0">
    <health now="20" max="20"/>
    <look type="276" corpse="7637"/>
    <targetchange interval="2000" chance="0"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="1"/>
        <flag convinceable="1"/>
        <flag pushable="1"/>
        <flag canpushitems="0"/>
        <flag canpushcreatures="0"/>
        <flag targetdistance="1"/>
        <flag staticattack="90"/>
        <flag runonhealth="0"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2000" skill="15" attack="7"/>
    </attacks>
    <defenses armor="1" defense="2"/>
</monster>
 
check your prints. it doesn't have to be print(1) it can be print(variable) where the variable holds the value 1
in sources you should search for cout or clog and same thing there it can be either 1 or a variable with value 1
 
It's probably some debug statement in monster or creature class, that someone left in your sources.

What sources do you use? Can you post it? Or search for std::cout << in your monsters.cpp or creature.cpp
 
check your prints. it doesn't have to be print(1) it can be print(variable) where the variable holds the value 1
in sources you should search for cout or clog and same thing there it can be either 1 or a variable with value 1
It's probably some debug statement in monster or creature class, that someone left in your sources.

What sources do you use? Can you post it? Or search for std::cout << in your monsters.cpp or creature.cpp

Double checked all prints, they are set to something like a error this or error that, including source ones in the file you ask me to check. And i am using the latest (as of 2 days ago) source from the github

I did find this while searching, its in my lib and it does print something but i have no idea what. its called dump.lua and its in debugging. So maybe?


Lua:
-- recursive dump function
function dumpLevel(input, level)
    local indent = ''

    for i = 1, level do
        indent = indent .. '    '
    end

    if type(input) == 'table' then
        local str = '{ \n'
        local lines = {}

        for k, v in pairs(input) do
            if type(k) ~= 'number' then
                k = '"' .. k .. '"'
            end

            if type(v) == 'string' then
                v = '"' .. v .. '"'
            end

            table.insert(lines, indent .. '    [' .. k .. '] = ' .. dumpLevel(v, level + 1))
        end
        return str .. table.concat(lines, ',\n') .. '\n' .. indent .. '}'
    end

    return tostring(input)
end

-- Return a string representation of input for debugging purposes
function dump(input)
    return dumpLevel(input, 0)
end

-- Call the dump function and print it to console
function pdump(input)
    local dump_str = dump(input)
    print(dump_str)
    return dump_str
end

-- Call the dump function with a title and print it beautifully to the console
function tdump(title, input)
    local title_fill = ''
    for i = 1, title:len() do
        title_fill = title_fill .. '='
    end

    local header_str = '\n====' .. title_fill .. '====\n'
    header_str = header_str .. '=== ' .. title .. ' ===\n'
    header_str = header_str .. '====' .. title_fill .. '====\n'

    local dump_str = dump(input)
    local footer_str = '\n====' .. title_fill .. '====\n'

    print(header_str .. dump_str .. footer_str)

    return dump_str
end

EDIT: IDM sharing my source, i have only made 2 custom edits that were not copy paste code, and their not much to talk about.
 
Last edited:
The two different creature files have a different XML encoding, could that be the issue?

Feel sorry for you mate, that would drive me insane, hope you find a quick fix. Surely a source issue. But out of curiosity, in what scenario would the functions pdump and tdump be called?
 
The two different creature files have a different XML encoding, could that be the issue?

Feel sorry for you mate, that would drive me insane, hope you find a quick fix. Surely a source issue. But out of curiosity, in what scenario would the functions pdump and tdump be called?
nah, i tried changing the encoding.
 
Failed to reproduce, but found a few syntax errors in the XML file.

Tested using:
XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Training Dummy" nameDescription="a training dummy" race="undead" experience="1" speed="0" manacost="0">

    <health now="1000000" max="1000000"/>

    <look typeex="5787" corpse="5972"/>

    <targetchange interval="1000" chance="0" />

    <flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="0" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="100" />
        <flag runonhealth="0" />
    </flags>

    <attacks>
        <attack name="melee" interval="500" attack="1" skill="60"/>
    </attacks>

    <defenses armor="0" defense="0">
        <defense name="healing" interval="1000" chance="100" min="10000" max="20000"/>
    </defenses>

    <immunities>
        <immunity invisible="1"/>
    </immunities>

    <loot>
        <item id="5903" chance="100000" uniquedrop="1" /><!-- ferumbras' hat -->
        <item name="longsword" chance="4000" />
    </loot>

</monster>



1584999972166.png

Could you provide the Lua spell code behind <defense name="all outfits" interval="40000" chance="100">? I suspect its either your custom Lua code, or something with onThink. (We have recently been messing around with events, but I cant find anything obvious in the repo).
 
Failed to reproduce, but found a few syntax errors in the XML file.

Tested using:
XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Training Dummy" nameDescription="a training dummy" race="undead" experience="1" speed="0" manacost="0">

    <health now="1000000" max="1000000"/>

    <look typeex="5787" corpse="5972"/>

    <targetchange interval="1000" chance="0" />

    <flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="0" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="100" />
        <flag runonhealth="0" />
    </flags>

    <attacks>
        <attack name="melee" interval="500" attack="1" skill="60"/>
    </attacks>

    <defenses armor="0" defense="0">
        <defense name="healing" interval="1000" chance="100" min="10000" max="20000"/>
    </defenses>

    <immunities>
        <immunity invisible="1"/>
    </immunities>

    <loot>
        <item id="5903" chance="100000" uniquedrop="1" /><!-- ferumbras' hat -->
        <item name="longsword" chance="4000" />
    </loot>

</monster>



View attachment 43383

Could you provide the Lua spell code behind <defense name="all outfits" interval="40000" chance="100">? I suspect its either your custom Lua code, or something with onThink. (We have recently been messing around with events, but I cant find anything obvious in the repo).
its something i found of otland.
and the other related scripting i have to trainers is this
 
Put this inside of global.lua before every other line (before dofile as well)
Lua:
debug.sethook(function()
    local info = debug.getinfo(2)
    if info and info.name == 'print' then
        local i = 0
        while true do
            i = i + 1
            local _, val = debug.getlocal(2, i)
            if not val then
                break
            end
            if tostring(val) == '1' then
                local scriptInfo = debug.getinfo(3)
                print('------- PRINT FOUND -------')
                print('Script: '.. scriptInfo.short_src)
                print('Line: '.. scriptInfo.currentline)
                print('---------------------------')
            end
        end
    end
end, 'c')

The top of your global.lua should look something like this:
Lua:
debug.sethook(function()
    local info = debug.getinfo(2)
    if info and info.name == 'print' then
        local i = 0
        while true do
            i = i + 1
            local _, val = debug.getlocal(2, i)
            if not val then
                break
            end
            if tostring(val) == '1' then
                local scriptInfo = debug.getinfo(3)
                print('------- PRINT FOUND -------')
                print('Script: '.. scriptInfo.short_src)
                print('Line: '.. scriptInfo.currentline)
                print('---------------------------')
            end
        end
    end
end, 'c')

math.randomseed(os.time())
dofile('data/lib/lib.lua')

Wait for your console to output the 1s again, any prints called from a script should be caught by this and will output to console where it's from.
Example:
uYXSbjnR

o6uq66ue
 
Last edited:
Put this inside of global.lua before every other line (before dofile as well)
Lua:
debug.sethook(function()
    local info = debug.getinfo(2)
    if info and info.name == 'print' then
        local i = 0
        while true do
            i = i + 1
            local _, val = debug.getlocal(2, i)
            if not val then
                break
            end
            if tostring(val) == '1' then
                local scriptInfo = debug.getinfo(3)
                print('------- PRINT FOUND -------')
                print('Script: '.. scriptInfo.short_src)
                print('Line: '.. scriptInfo.currentline)
                print('---------------------------')
            end
        end
    end
end, 'c')

The top of your global.lua should look something like this:
Lua:
debug.sethook(function()
    local info = debug.getinfo(2)
    if info and info.name == 'print' then
        local i = 0
        while true do
            i = i + 1
            local _, val = debug.getlocal(2, i)
            if not val then
                break
            end
            if tostring(val) == '1' then
                local scriptInfo = debug.getinfo(3)
                print('------- PRINT FOUND -------')
                print('Script: '.. scriptInfo.short_src)
                print('Line: '.. scriptInfo.currentline)
                print('---------------------------')
            end
        end
    end
end, 'c')

math.randomseed(os.time())
dofile('data/lib/lib.lua')

Wait for your console to output the 1s again, any prints called from a script should be caught by this and will output to console where it's from.
Example:
uYXSbjnR

o6uq66ue
1585043575353.png
nothing

already said i looked through all my files for print.
 
Good news!, i happened to randomly stumble upon what was causing "1" to be spammed, bad news, i have 0 clue why it was being spammed when players entered the monsters view.

So this bit of code
C++:
std::cout << bonusRebirth << std::endl;

From this system Feature - Reborn System | Reset level, increase power, set exclusive items, spells, houses, web and more! (https://otland.net/threads/reborn-system-reset-level-increase-power-set-exclusive-items-spells-houses-web-and-more.245808/)

was causing the spam.

The reason i said bad news, is to my knowledge it should not of caused the spam where it was placed, at least not till health was changed. this is what i mean.


C++:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    const Position& targetPos = target->getPosition();
    if (damage.primary.value > 0) {
        if (target->getHealth() <= 0) {
            return false;
        }

        Player* attackerPlayer;
        if (attacker) {
            attackerPlayer = attacker->getPlayer();
        }
        else {
            attackerPlayer = nullptr;
        }

        Player* targetPlayer = target->getPlayer();
        if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
            return false;
        }

        double bonusRebirth = 0.0;
        if (attackerPlayer != nullptr) {
            bonusRebirth = attackerPlayer->rebirth * g_config.getNumber(ConfigManager::REBORN_DMGBONUS);
            bonusRebirth /= 10;
            bonusRebirth /= 100;
            bonusRebirth += 1;
        }
        else
            bonusRebirth = 1.0;

        std::cout << bonusRebirth << std::endl;

        damage.primary.value = std::abs(damage.primary.value) * bonusRebirth;
        damage.secondary.value = std::abs(damage.secondary.value * bonusRebirth);

        if (damage.origin != ORIGIN_NONE) {

i undid the removal for this copy and paste so you could see where i found it. Best of my knowledge this should not be spamming, unless the server is considering healing at full health a combat health change.
 
Perhaps the creature performs something on wake, that calls combatChangeHealth. Not sure why a cat would do that and other creatures wouldn't.
 
Perhaps the creature performs something on wake, that calls combatChangeHealth. Not sure why a cat would do that and other creatures wouldn't.
i have 0 clue, as to why i mentioned where i found it, and showed where it was. To my knowledge nothing should of triggered it without being attacked. As it was on my TFS 1.2, at the time i just was like w/e we are in dev and it only happened when you attacked or were attacked.

EDIT: just to clarify the reason i did not mention it before hand was because the numbers that were spammed changed, and the they started spamming were drastically different.
 
combatChangeHealth?

My guess is that the healing spell the monks spam all the time could be the culprit here. (Even if the monks have full health).
(as well as when damage is taken/recieved).
 
combatChangeHealth?

My guess is that the healing spell the monks spam all the time could be the culprit here. (Even if the monks have full health).
(as well as when damage is taken/recieved).
Yea, however it strange, as other mobs that did not do heals such as the cat i posted earlier were also triggering it, not as rapidly, but they were.

Also it was not triggering in 1.2 unless you attacked something.
 
Back
Top