Possible XML loading bug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
easy
Posts: 14
Joined: Thu Dec 09, 2010 11:14 am
Location: Hungary

Possible XML loading bug

Post by easy »

Hello,

Here's my previous post about the error I get when loading a hand-crafted font.

I've dig into the font-loading of Irrlicht, and everything looked all right.

The solution was to add the correct tabs and double newline-characters:

Code: Select all

<?xml version="1.0"?>

<font type="bitmap">

	<Texture index="0" filename="base.png" hasAlpha="true" />

	<c c=" " r="5, 0, 46, 51" />
	<c c="!" r="56, 0, 97, 51" />
	<c c=""" r="107, 0, 148, 51" />
	<c c="#" r="158, 0, 199, 51" />
	<c c="$" r="209, 0, 250, 51" />
	<c c="%" r="260, 0, 301, 51" />
	<c c="&" r="311, 0, 352, 51" />
	<c c="'" r="362, 0, 403, 51" />
	<c c="(" r="413, 0, 454, 51" />
	<c c=")" r="464, 0, 505, 51" />
	<c c="*" r="5, 51, 46, 102" />
	<c c="+" r="56, 51, 97, 102" />
	<c c="," r="107, 51, 148, 102" />
	<c c="-" r="158, 51, 199, 102" />
	<c c="." r="209, 51, 250, 102" />
	<c c="/" r="260, 51, 301, 102" />
	<c c="0" r="311, 51, 352, 102" />
	<c c="1" r="362, 51, 403, 102" />
	<c c="2" r="413, 51, 454, 102" />
	<c c="3" r="464, 51, 505, 102" />
	<c c="4" r="5, 102, 46, 153" />
	<c c="5" r="56, 102, 97, 153" />
	<c c="6" r="107, 102, 148, 153" />
	<c c="7" r="158, 102, 199, 153" />
	<c c="8" r="209, 102, 250, 153" />
	<c c="9" r="260, 102, 301, 153" />
	<c c=":" r="311, 102, 352, 153" />
	<c c=";" r="362, 102, 403, 153" />
	<c c="<" r="413, 102, 454, 153" />
	<c c="=" r="464, 102, 505, 153" />
	<c c=">" r="5, 153, 46, 204" />
	<c c="?" r="56, 153, 97, 204" />
	<c c="@" r="107, 153, 148, 204" />
	<c c="A" r="158, 153, 199, 204" />
	<c c="B" r="209, 153, 250, 204" />
	<c c="C" r="260, 153, 301, 204" />
	<c c="D" r="311, 153, 352, 204" />
	<c c="E" r="362, 153, 403, 204" />
	<c c="F" r="413, 153, 454, 204" />
	<c c="G" r="464, 153, 505, 204" />
	<c c="H" r="5, 204, 46, 255" />
	<c c="I" r="56, 204, 97, 255" />
	<c c="J" r="107, 204, 148, 255" />
	<c c="K" r="158, 204, 199, 255" />
	<c c="L" r="209, 204, 250, 255" />
	<c c="M" r="260, 204, 301, 255" />
	<c c="N" r="311, 204, 352, 255" />
	<c c="O" r="362, 204, 403, 255" />
	<c c="P" r="413, 204, 454, 255" />
	<c c="Q" r="464, 204, 505, 255" />
	<c c="R" r="5, 255, 46, 306" />
	<c c="S" r="56, 255, 97, 306" />
	<c c="T" r="107, 255, 148, 306" />
	<c c="U" r="158, 255, 199, 306" />
	<c c="V" r="209, 255, 250, 306" />
	<c c="W" r="260, 255, 301, 306" />
	<c c="X" r="311, 255, 352, 306" />
	<c c="Y" r="362, 255, 403, 306" />
	<c c="Z" r="413, 255, 454, 306" />
	<c c="[" r="464, 255, 505, 306" />
	<c c="\" r="5, 306, 46, 357" />
	<c c="]" r="56, 306, 97, 357" />
	<c c="^" r="107, 306, 148, 357" />
	<c c="_" r="158, 306, 199, 357" />
	<c c="`" r="209, 306, 250, 357" />
	<c c="a" r="260, 306, 301, 357" />
	<c c="b" r="311, 306, 352, 357" />
	<c c="c" r="362, 306, 403, 357" />
	<c c="d" r="413, 306, 454, 357" />
	<c c="e" r="464, 306, 505, 357" />
	<c c="f" r="5, 357, 46, 408" />
	<c c="g" r="56, 357, 97, 408" />
	<c c="h" r="107, 357, 148, 408" />
	<c c="i" r="158, 357, 199, 408" />
	<c c="j" r="209, 357, 250, 408" />
	<c c="k" r="260, 357, 301, 408" />
	<c c="l" r="311, 357, 352, 408" />
	<c c="m" r="362, 357, 403, 408" />
	<c c="n" r="413, 357, 454, 408" />
	<c c="o" r="464, 357, 505, 408" />
	<c c="p" r="5, 408, 46, 459" />
	<c c="q" r="56, 408, 97, 459" />
	<c c="r" r="107, 408, 148, 459" />
	<c c="s" r="158, 408, 199, 459" />
	<c c="t" r="209, 408, 250, 459" />
	<c c="u" r="260, 408, 301, 459" />
	<c c="v" r="311, 408, 352, 459" />
	<c c="w" r="362, 408, 403, 459" />
	<c c="x" r="413, 408, 454, 459" />
	<c c="y" r="464, 408, 505, 459" />
	<c c="z" r="5, 459, 46, 510" />
	<c c="{" r="56, 459, 97, 510" />
	<c c="|" r="107, 459, 148, 510" />
	<c c="}" r="158, 459, 199, 510" />
	<c c="~" r="209, 459, 250, 510" />

</font>
And the app that created the .xml above:

Code: Select all

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    char fname[80] = "noname.xml";
    char imgname[80] = "noname.png";
    cout << "Output file name: ";
    cin >> fname;
    cout << "Image file name: ";
    cin >> imgname;

    int startcn, endcn, mapx, mapy, letterx, lettery, cutx, cuty;
    cout << "Start char num: ";
    cin >> startcn;
    cout << "End char num: ";
    cin >> endcn;
    cout << "Map size x: ";
    cin >> mapx;
    cout << "Map size y: ";
    cin >> mapy;
    cout << "Letter size x: ";
    cin >> letterx;
    cout << "Letter size y: ";
    cin >> lettery;
    cout << "Cut x: ";
    cin >> cutx;
    cout << "Cut y: ";
    cin >> cuty;

    ofstream fout;
    fout.open(fname);
    fout << "<?xml version=\"1.0\"?>\n\n";
    fout << "<font type=\"bitmap\">\n\n";
    fout << "\t<Texture index=\"0\" filename=\"" << imgname << "\" hasAlpha=\"true\" />\n\n";

    char curc = startcn;
    bool quit = false;

    for (int j = 0; j < int(mapy / lettery); ++j)
    {
        for (int i = 0; i < int(mapx / letterx); ++i)
        {
            int sx, sy, ex, ey;
            sx = (i * letterx) + cutx;
            sy = (j * lettery) + cuty;
            ex = ((i + 1) * letterx) - cutx;
            ey = ((j + 1) * lettery) - cuty;

            //<c c=" " r="0, 0, 5, 14"/>
            fout << "\t<c c=\"";

            switch (curc)
            {
                case 34: fout << """; break;
                case 38: fout << "&"; break;
                case 60: fout << "<"; break;
                case 62: fout << ">"; break;
                default: fout << curc;
            }

            fout << "\" r=\"" << sx << ", " << sy << ", " << ex << ", " << ey << "\" />\n";

            if (endcn > startcn && curc >= endcn) { quit = true; break; }

            ++curc;
        }

        if (quit) break;
    }

    fout << "\n</font>";
    fout.close();

    return 0;
}
Can anyone else confirm that removing tabs and newline characters can crash the .xml loading? I think loading an .xml should be more tolerating.

Cheers,
easy
Post Reply