xml parsing

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

xml parsing

Post by floppyfreak »

I want to use xml for a basic scripting language. Now I have written some code to read a configuration file with hierarchies of nodes using std::list<T> for multiple object definitions within my game. :idea: I have gone through all the nodes and so to say translated them to the datastructure I use in the game. Some hundred lines of code, works fine so far. :oops:
Now the work done I wonder, if this makes sense. I have an idea that this task has something to do with "serialisation" and "deserialisation" and stuff. Do I have to see at the end, I have invented the wheel a second time? My solution seems to be bulky and errorprone (although currently it seems to work). Is there a one click standard solution for this problem? :roll:
I safe your time and don't send example :lol:
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You're loading an XML file which tells you app which objects to load and where to place them?

IrrEdit does this for you with a nice visual editor and it creates .irr files which can then be loaded by Irrlicht to create the whole scene you've set up in IrrEdit... but i would have thought you knew about IrrEdit as you've been around a while so maybe i'm not understanding you right!
Image Image Image
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

JP wrote:You're loading an XML file which tells you app which objects to load and where to place them?
not quite. I use exactly that, place empty nodes in a scene created in blender, use userData to link them to functions that my program has to manage.
But the properties of those nodes (pickup weapons and stuff) I define in an own format that uses xml, for this file I have created an own parser. Was it for the birds?
Jgoldnight
Posts: 31
Joined: Thu Jun 07, 2007 6:23 pm
Location: New York
Contact:

Post by Jgoldnight »

IrrEdit is, indeed, a good choice and I think you can also import some custom scene nodes, so long as your game objects inherit from the ISceneNode class. Thus, you should be able to use IrrEdit to include your custom objects in a scene; however, I'm not sure if you can extend the parameter toolbox (in the environment) to include your class' members.

I think you should do a bit of research on IrrEdit (to see if it's applicable to your project) before you continue implementing your custom parser.

You also said that you felt that parts of your XML parser were buggy and error-prone. Post some of it if you want more advice.

Hope it helps!
Last edited by Jgoldnight on Tue Jun 17, 2008 2:38 pm, edited 1 time in total.
Computer scientist by day...
http://www.mrjoelkemp.com
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

erased
Last edited by floppyfreak on Fri Jun 06, 2008 7:34 am, edited 1 time in total.
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

If anybody more skilfull than me wants to do me the favour and give me a correction here my code. Currently I can't find an error in it, but the xml to be read will increase and I am not satisfied with the clumsyness of my work. At least I have the strong suspicion that this has to be said about it. The problem might be that I switched from little experience with C to c++ just a few weeks ago. here I didn't see a reason to define a class.


datastructure to hold data to be read in

Code: Select all

typedef struct tsplashlist{
    char*filename;
    char*abortkey;
    int countdown;
};

struct tpickupobject{
    char*name;
    char*modelfile;
    char*permanentsoundfile;
    float permanentsoundvolume;
    char*spawnsoundfile;
    float spawnsoundvolume;
    float pickupdistance;
    char* pickupsoundfile;
    float pickupsoundvolume;
    float addweight;
    float addenergy;
    float addshield;  
};

struct tspawnobject{
    char*name;
    int probabilityToSpawn;
};
struct tspawnstation{
    char*name;
    std::list<tspawnobject>spawnobjectlist;
};
struct tlevelcenter{
    char* name;
    vector3df bbox;
};
struct tshipobject
{
    char*name;
    char*onShotSoundFilename;
    bool onButtonPressShot;
};
struct tallGData{
    char*gamename;
    int countdown;
    std::list<tsplashlist>splashlist;
    std::list<tpickupobject>pickupobjectlist;
    struct tlevel{
        char*name;
        std::list<tspawnstation>spawnstationlist; //in .teg file: TE_Game_File.level.LevelObjectTypes.Spawnstation
        std::list<tlevelcenter>levelcenterlist; //in .teg file: TE_Game_File.level.LevelObjectTypes.LevelCenter
    }level;
    struct tship {
        struct transhipmovements
        {
            float mintime, rantime, minamplitude, ranamplitude;
        }ranshipmovements;
        std::list<tshipobject>shipobjectslist;
    }ship;
};
extern tallGData allGData;

code to read in xml stuff

Code: Select all


void insstr(char**name,const c8*string)
{
    char*mstr=new char[strlen(string)];
    strcpy(mstr,string);
    *name=mstr;
}

bool TEGRead()
{
//this method produces some lost memory. bog s nim. 
    initallGData();
    std::list<char*> ntree;
    std::list<char*>::iterator itn=ntree.begin();
    IXMLReaderUTF8*xmlr=irrDevice->getFileSystem()->createXMLReaderUTF8("masterv1.tex.xml");

    if (!xmlr) 
    {   
        cout<<"TE: TEGRead: No game file found. I leave idle"<<endl;
        return false;
    }
    cout<<"TE: Reading TEG file"<<endl;
    int level=0;
    while (xmlr->read())
    {
        if (xmlr->getNodeType()==EXN_ELEMENT)
        {
            if (!xmlr->getAttributeCount())
            {
//create a structure to hold current node hierarchy                
                char*el=new char[strlen(xmlr->getNodeName())];
                strcpy(el,xmlr->getNodeName());
                ntree.push_back(el);
                itn=ntree.begin();
//allocate structures and include them to the allGData structure. 
//we do whole hierarchy check here to provide option of 
//reusing nodenames freely
                if (!strcmp((*itn),"The_Experiment_Game_File"))
                {
                    itn++;
                    if (itn!=ntree.end()&&!strcmp((*itn),"PreGame"))
                    {
                        if (!strcmp(xmlr->getNodeName(),"Splash"))
                        {
                            if (int i=1)
                            {
                                tsplashlist *splashlistentry=new tsplashlist;
                                allGData.splashlist.push_back(*splashlistentry);
                            }
                        }
                    }
                    if (itn!=ntree.end()&&!strcmp((*itn),"Game"))
                    {
                        itn++;
                        if (itn!=ntree.end()&&!strcmp((*itn),"GameObjects"))
                        {
                            if (!strcmp(xmlr->getNodeName(),"PickupObject"))
                            {
                                tpickupobject *pickupentry=new tpickupobject;
                                pickupentry->name;
                                pickupentry->modelfile=0;
                                pickupentry->spawnsoundfile=0;
                                pickupentry->permanentsoundfile=0;
                                pickupentry->pickupsoundfile=0;
                                pickupentry->spawnsoundvolume=0;
                                pickupentry->permanentsoundvolume=0;
                                pickupentry->pickupsoundvolume=0;
                                pickupentry->addweight=0;
                                pickupentry->addenergy=0;
                                pickupentry->addshield=0;
                                allGData.pickupobjectlist.push_back(*pickupentry);
                            }
                        } //(itn!=ntree.end()&&!strcmp((*itn),"GameObjects"))
                    }//if (itn!=ntree.end()&&!strcmp((*itn),"Game"))
                    
                    if (itn!=ntree.end()&&!strcmp((*itn),"Level"))
                    {
                        itn++;
                        if (itn!=ntree.end()&&!strcmp((*itn),"LevelObjectTypes"))
                        {
                            if (!strcmp(xmlr->getNodeName(),"Spawnstation"))
                            {
                                tspawnstation*spawnentry=new tspawnstation;
                                spawnentry->name=0;
                                allGData.level.spawnstationlist.push_back(*spawnentry);
                            }
                            itn++;
                            if (itn!=ntree.end()&&!strcmp((*itn),"Spawnstation"))
                            {
                                if (!strcmp(xmlr->getNodeName(),"Spawnobject"))
                                {
                                    tspawnobject*spawnoentry=new tspawnobject;
                                    spawnoentry->name=0;
                                    spawnoentry->probabilityToSpawn=0;
                                    std::list<tspawnstation>::iterator itspst=allGData.level.spawnstationlist.end();
                                    itspst--;
                                    (itspst->spawnobjectlist).push_back(*spawnoentry);
                                }
                            }
                            if (!strcmp(xmlr->getNodeName(),"LevelCenter"))
                            {
                                tlevelcenter*levelcenterentry=new tlevelcenter;
                                levelcenterentry->name=0;
                                levelcenterentry->bbox= vector3df(0,0,0);
                                allGData.level.levelcenterlist.push_back(*levelcenterentry);
                            }
                        }//(itn!=ntree.end()&&!strcmp((*itn),"LevelObjectTypes"))
                    }//(itn!=ntree.end()&&!strcmp((*itn),"Level"))
                    if (itn!=ntree.end()&&!strcmp((*itn),"Ship"))
                    {
                        itn++;
                        if (itn!=ntree.end()&&!strcmp((*itn),"ShipObjects"))
                        {
                            itn++;
                            if (itn!=ntree.end()&&!strcmp((*itn),"Weapon"))
                            {
                                tshipobject *shoentry=new tshipobject;
                                shoentry->name=0;
                                shoentry->onShotSoundFilename=0;
                                shoentry->onButtonPressShot=true;
                                allGData.ship.shipobjectslist.push_back(*shoentry);
                            }
                        }

                    }//Ship
                } //(!strcmp((*itn),"The_Experiment_Game_File"))
            }//if (!xmlr->getAttributeCount())
//read all input values from gamefile here            
            else //  if (!xmlr->getAttributeCount())
            {
                itn=ntree.begin();
                itn++;
                if (itn!=ntree.end()&&!strcmp((*itn),"PreGame"))
                {
                    itn++;
                    if (itn!=ntree.end()&&!strcmp((*itn),"Splash"))
                    {
                        if (!strcmp(xmlr->getNodeName(),"string"))
                        {
                            std::list<tsplashlist>::iterator itspl=--allGData.splashlist.end();
                            if (!strcmp(xmlr->getAttributeName(0),"filename"))
                            {
                                insstr(&(itspl->filename),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                            }
                            if (!strcmp(xmlr->getAttributeName(0),"abortkey"))
                            {
                                insstr(&(itspl->abortkey),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                            }
                        }
                        if (!strcmp(xmlr->getNodeName(),"int"))
                        {
                            if (!strcmp(xmlr->getAttributeName(0),"countdown"))
                            {
                                std::list<tsplashlist>::iterator itspl=--allGData.splashlist.end();
                                itspl->countdown=xmlr->getAttributeValueAsInt("countdown");
                            }
                        }
                    }//Splash
                }//PreGame
                if (itn!=ntree.end()&&!strcmp((*itn),"Game"))
                {
                    itn++;
                    if (itn!=ntree.end()&&!strcmp((*itn),"Gameplay"))
                    {
                        if (!strcmp(xmlr->getNodeName(),"string"))
                        {
                            if (!strcmp(xmlr->getAttributeName(0),"gamename")) 
                            {
                                insstr(&(allGData.gamename),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                            }
                        }
                        if (!strcmp(xmlr->getNodeName(),"int"))
                            if (!strcmp(xmlr->getAttributeName(0),"countdown")) 
                                allGData.countdown=xmlr->getAttributeValueAsInt(0);
                        }
                    if (itn!=ntree.end()&&!strcmp((*itn),"GameObjects"))
                    {
                        itn++;
                        if (itn!=ntree.end()&&!strcmp((*itn),"PickupObject"))
                        {
                            if (!strcmp(xmlr->getNodeName(),"string"))
                            {
                                std::list<tpickupobject>::iterator itpic=--allGData.pickupobjectlist.end();
                                if (!strcmp(xmlr->getAttributeName(0),"name")) 
                                    insstr(&(itpic->name),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                if (!strcmp(xmlr->getAttributeName(0),"modelfile"))
                                    insstr(&(itpic->modelfile),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                if (!strcmp(xmlr->getAttributeName(0),"spawnsoundfile"))
                                    insstr(&(itpic->spawnsoundfile),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                if (!strcmp(xmlr->getAttributeName(0),"permanentsoundfile"))
                                    insstr(&(itpic->permanentsoundfile),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                if (!strcmp(xmlr->getAttributeName(0),"pickupsoundfile"))
                                    insstr(&(itpic->pickupsoundfile),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                            }
                            if (!strcmp(xmlr->getNodeName(),"float"))
                            {
                                std::list<tpickupobject>::iterator itpic=--allGData.pickupobjectlist.end();
                                if (!strcmp(xmlr->getAttributeName(0),"pickupdistance"))
                                    itpic->pickupdistance=xmlr->getAttributeValueAsFloat("pickupdistance");
                                if (!strcmp(xmlr->getAttributeName(0),"spawnsoundvolume"))
                                    itpic->spawnsoundvolume=xmlr->getAttributeValueAsFloat("spawnsoundvolume");
                                if (!strcmp(xmlr->getAttributeName(0),"permanentsoundvolume"))
                                    itpic->permanentsoundvolume=xmlr->getAttributeValueAsFloat("permanentsoundvolume");
                                if (!strcmp(xmlr->getAttributeName(0),"pickupsoundvolume"))
                                    itpic->pickupsoundvolume=xmlr->getAttributeValueAsFloat("pickupsoundvolume");
                                if (!strcmp(xmlr->getAttributeName(0),"addweight"))
                                    itpic->addweight=xmlr->getAttributeValueAsFloat("addweight");
                                if (!strcmp(xmlr->getAttributeName(0),"addenergy"))
                                    itpic->addenergy=xmlr->getAttributeValueAsFloat("addenergy");
                                if (!strcmp(xmlr->getAttributeName(0),"addshield"))
                                    itpic->addshield=xmlr->getAttributeValueAsFloat("addshield");
                            }
                        }//PickupObjects
                    }//GameObjects
                }//Game
                if (!strcmp((*itn),"Level"))
                {
                    //we must be sure this is game.level.name and not some other .name.//
                    if (itn==--ntree.end())
                    {
                        if (!strcmp(xmlr->getNodeName(),"string"))
                        {
                            
                            insstr(&(allGData.level.name),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                        }
                    }
                    itn++;
                    if (itn!=ntree.end()&&!strcmp((*itn),"LevelObjectTypes"))
                    {
                        itn++;
                        if (itn!=ntree.end()&&!strcmp((*itn),"Spawnstation"))
                        {
                            std::list<tspawnstation>::iterator itspawn=--allGData.level.spawnstationlist.end();
                            if (itn==--ntree.end()&&!strcmp(xmlr->getNodeName(),"string"))
                            {
                                insstr(&(itspawn->name),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                            }
                            itn++;
                            if (itn!=ntree.end()&&!strcmp((*itn),"Spawnobject"))
                            {
                                std::list<tspawnobject>::iterator itspawno=--itspawn->spawnobjectlist.end();
                                if (++itn==ntree.end()&&!strcmp(xmlr->getNodeName(),"string"))
                                {
                                    insstr(&(itspawno->name),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                }
                                if (!strcmp(xmlr->getNodeName(),"probabilityToSpawn"))
                                    itspawno->probabilityToSpawn=xmlr->getAttributeValueAsInt(0);
                            }
                        }//Spawnstation
                        if (itn!=ntree.end()&&!strcmp((*itn),"LevelCenter"))
                        {
                            std::list<tlevelcenter>::iterator itlevc=--allGData.level.levelcenterlist.end();
                            if (++itn==ntree.end())
                            {
                                if (!strcmp(xmlr->getNodeName(),"string"))
                                {
                                    insstr(&(itlevc->name),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                }
                            }
                            if (itn!=ntree.end()&&!strcmp((*itn),"bbox"))
                            {
                                if(!strcmp(xmlr->getNodeName(),"vector3df"))
                                {
                                    itlevc->bbox.X=xmlr->getAttributeValueAsFloat(xmlr->getAttributeName(0));
                                    itlevc->bbox.Y=xmlr->getAttributeValueAsFloat(xmlr->getAttributeName(1));
                                    itlevc->bbox.Z=xmlr->getAttributeValueAsFloat(xmlr->getAttributeName(2));
                                }
                            }
                        } //LevelCenter
                    }
                }//Level
                itn=++ntree.begin();
                if (!strcmp((*itn),"Ship"))
                {
                    itn++;
                    if (!strcmp((*itn),"RandomMovements"))
                    {
                        if (!strcmp(xmlr->getNodeName(),"float"))
                        {
                            if (!strcmp(xmlr->getAttributeName(0),"mintime"))
                                allGData.ship.ranshipmovements.mintime=xmlr->getAttributeValueAsFloat("mintime");
                            if (!strcmp(xmlr->getAttributeName(0),"rantime"))
                                allGData.ship.ranshipmovements.rantime=xmlr->getAttributeValueAsFloat("rantime");
                            if (!strcmp(xmlr->getAttributeName(0),"minamplitude"))
                                allGData.ship.ranshipmovements.minamplitude=xmlr->getAttributeValueAsFloat("minamplitude");
                            if (!strcmp(xmlr->getAttributeName(0),"ranamplitude"))
                                allGData.ship.ranshipmovements.ranamplitude=xmlr->getAttributeValueAsFloat("ranamplitude");
                            
                        }
                    }
                    if (!strcmp((*itn),"ShipObjects"))
                    {
                        itn++;
                        if (!strcmp((*itn),"Weapon"))
                        {
                            std::list<tshipobject>::iterator itweap=--allGData.ship.shipobjectslist.end();
                            if (!strcmp(xmlr->getNodeName(),"string"))
                            {
                                if (!strcmp(xmlr->getAttributeName(0),"name"))
                                    insstr(&(itweap->name),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                                if (!strcmp(xmlr->getAttributeName(0),"onShotSoundFilename"))
                                    insstr(&(itweap->onShotSoundFilename),xmlr->getAttributeValueSafe(xmlr->getAttributeName(0)));
                            }
                            if (!strcmp(xmlr->getNodeName(),"bool"))
                            {
                                if (!strcmp(xmlr->getAttributeName(0),"onButtonPressShot"))
                                {
                                    if (!strcmp(xmlr->getAttributeValueSafe("onButtonPressShot"),"true"))
                                        itweap->onButtonPressShot=true;
                                    if (!strcmp(xmlr->getAttributeValueSafe("onButtonPressShot"),"false"))
                                        itweap->onButtonPressShot=false;
                                }
                            }
                        }
                    }
                }//Ship
            }
//writeout nodehierarchy
            if (TES_TEGReadVerboseLevel>1)
            {
                itn=ntree.begin();
                while (itn!=ntree.end())
                {
                    cout<<*itn<<".";
                    itn++;
                }
                cout<<endl<<"working node: "<<xmlr->getNodeName()<<" attribute count: "<<xmlr->getAttributeCount()<<endl;
            }
        }//EXN_ELEMENT
        if (xmlr->getNodeType()==EXN_ELEMENT_END)
        {
            if (TES_TEGReadVerboseLevel>1)cout<<xmlr->getNodeName()<<" end"<<endl;
            if (!ntree.empty()) 
            {
                itn=--ntree.end();
                ntree.pop_back();
//                delete *itn;
            }
        }//EXN_ELEMENT_END
    }
    
//writeout allgamedata
    if (TES_TEGReadVerboseLevel)
    {
        cout<<endl<<endl<<"TEGRead: I have read the following data"<<endl;
        cout<<"gameplay.gamename "<<allGData.gamename<<endl;
        cout<<"gameplay.countdown "<<allGData.countdown<<endl;
        std::list<tsplashlist>::iterator itspl=allGData.splashlist.begin();
        int i=1;
        while (itspl!=allGData.splashlist.end())
        {
            cout<<"Splash nr "<<i<<" fn= "<<itspl->filename<<" abortkey= "<<itspl->abortkey<<" countdown= "<<itspl->countdown<<endl;
            itspl++;
            i++;
        }
        std::list<tpickupobject>::iterator itpick=allGData.pickupobjectlist.begin();
        i=1;
        while (itpick!=allGData.pickupobjectlist.end())
        {
            cout<<"GameObjects number "<<i<<" name = "<<itpick->name<<endl;
            if (itpick->spawnsoundfile) cout<<" spawnsoundfile "<<itpick->spawnsoundfile<<endl;
            if (itpick->permanentsoundfile) cout<<" permanentsoundfile "<<itpick->permanentsoundfile<<endl;
            if (itpick->pickupsoundfile) cout<<" pickupsoundfile "<<itpick->pickupsoundfile<<endl;
            if (itpick->spawnsoundvolume) cout<<" spawnsoundvolume "<<itpick->spawnsoundvolume<<endl;
            if (itpick->permanentsoundvolume) cout<<" permanentsoundvolume "<<itpick->permanentsoundvolume<<endl;
            if (itpick->pickupsoundvolume) cout<<" pickupsoundvolume "<<itpick->pickupsoundvolume<<endl;
            if (itpick->pickupdistance) cout<<" pickupdistance "<<itpick->pickupdistance<<endl;
            if (itpick->addweight) cout<<" addweight "<<itpick->addweight<<endl;
            if (itpick->addenergy) cout<<" addenergy "<<itpick->addenergy<<endl;
            if (itpick->addshield) cout<<" addshield "<<itpick->addshield<<endl;
            itpick++;
            i++;
        }
        std::list<tspawnstation>::iterator itspawnst=allGData.level.spawnstationlist.begin();
        cout<<"level filename = "<<allGData.level.name<<endl;
        while (itspawnst!=allGData.level.spawnstationlist.end())
        {
            cout<<"spawnstation= "<<itspawnst->name<<endl;
            std::list<tspawnobject>::iterator itspawno=itspawnst->spawnobjectlist.begin();
            while (itspawno!=itspawnst->spawnobjectlist.end())
            {
                if (itspawno->name) cout<<" SpawnstationObject= "<<itspawno->name<<endl;
                else cout<<"noname"<<endl;
                itspawno++;
            }
            itspawnst++;
        }//while (itspawnst!=allGData.level.spawnstationlist.end())
        std::list<tlevelcenter>::iterator itlevc=allGData.level.levelcenterlist.begin();
        while(itlevc!=allGData.level.levelcenterlist.end())
        {
            cout<<"levelcenter name= "<<itlevc->name<<endl;
            cout<<" bounding box= "<<itlevc->bbox.X<<" "<<itlevc->bbox.Y<<" "<<itlevc->bbox.Z<<" "<<endl;
            itlevc++;
        }
        
        cout<<endl<<"Shipproperties "<<endl;
        cout<<"random ship movements= "<<endl;
        cout<<" mintime= "<<allGData.ship.ranshipmovements.mintime<<" ";
        cout<<"rantime= "<<allGData.ship.ranshipmovements.rantime<<" ";
        cout<<"minamplitude= "<<allGData.ship.ranshipmovements.minamplitude<<" ";
        cout<<"ranamplitude= "<<allGData.ship.ranshipmovements.ranamplitude<<" "<<endl;
        cout<<"Weapons"<<endl;
        std::list<tshipobject>::iterator itweap=allGData.ship.shipobjectslist.begin();
        while (itweap!=allGData.ship.shipobjectslist.end())
        {
            cout<<" Weaponname= "<<itweap->name<<" onShotSoundFilename= "<<itweap->onShotSoundFilename;
            cout<<" onButtonPressShot= "<<itweap->onButtonPressShot<<endl;
            itweap++;
        }


        cout<<endl<<"TEGRead: TES_TEGReadVerboseLevel "<<TES_TEGReadVerboseLevel<<" end"<<endl;
    }// if (TES_TEGReadVerboseLevel)
    if (TES_TEGReadVerboseLevel) system("PAUSE");
	return true;
}


this is the xml read in:

Code: Select all

<The_Experiment_Game_File><!--comment-->
    <PreGame>
        <Splash>
            <string filename = "file1"/>
            <string abortkey = "anykey"/>
            <int countdown = "24"/>
        </Splash>
        <Splash>
            <string filename = "file2"/>
            <string abortkey = "anykey"/>
            <int countdown = "25"/>
        </Splash>
        <Splash>
            <string filename = "file3"/>
            <string abortkey = "lakey"/>
            <int countdown = "26"/>
        </Splash>
    </PreGame>
    <Game>
        <Gameplay>
            <int countdown = "300"/>
            <string gamename = "Dummycollector"/>
        </Gameplay>
        <GameObjects>
            <PickupObject>
                <string name = "dummy1"/>
                <string modelfilename = "dummy1mesh.irrmesh"/>
                <float pickupdistance = "2.5"/>
                <string spawnsoundfile = "spsound.wav"/>
                <float spawnsoundvolume = "1"/>
                <string permanentsoundfile = "permsound.wav"/>
                <float permanentsoundvolume = "1"/>
                <string pickupsoundfile = "pickupsound.wav"/>
                <float pickupsoundvolume = "1"/>
                <float addweight = "1000"/>
            </PickupObject>
            <PickupObject>
                <string name = "dummy2"/>
                <string modelfilename = "littlerusty1.irrmesh"/>
                <string spawnsoundfile = ""/>
                <float pickupdistance = "2"/>
            </PickupObject>
        </GameObjects>
    </Game>
    <Level>
        <string filename = "level/mylevel.irr"/>
        <LevelObjectTypes>
            <Spawnstation>
                <string name = "example"/>
                <Spawnobject>
                    <string name = "dummy1"/>
                    <int probabilityToSpawn = "10"/>
                </Spawnobject>
                <Spawnobject>
                    <string name = "dummy2"/>
                    <int probabilityToSpawn = "5"/>
                </Spawnobject>
            </Spawnstation>
            <Spawnstation>
                <string name = "spawnplace1"/>
                <Spawnobject>
                    <string name = "dummy21"/>
                    <int probabilityToSpawn = "10"/>
                </Spawnobject>
            </Spawnstation>
            <Spawnstation>
                <string name = "spawnplace2"/>
                <Spawnobject>
                    <string name = "dummy22"/>
                    <int probabilityToSpawn = "10"/>
                </Spawnobject>
            </Spawnstation>
            <LevelCenter>
                <string name = "delistation1"/>
                <bbox>
                    <vector3df
                        X = "1"
                        Y = "2"
                        Z = "3"/>
                </bbox>
            </LevelCenter>
        </LevelObjectTypes>
    </Level>
    <Ship>
        <RandomMovements>
            <float mintime = "1"/>
            <float rantime = "2"/>
            <float minamplitude = "3"/>
            <float ranamplitude = "4"/>
        </RandomMovements>
        <ShipObjects>
            <Weapon>
                <string name = "greenshot"/>
                <string onShotSoundFilename = "somefile"/>
                <bool onButtonPressShot = "true"/>
            </Weapon>
        </ShipObjects>
        <ResourceProperties>
            <Energy>
                <float countdown = "0"/>
                <float onStartupValue = "100"/>
                <float maxValue = "200"/>
            </Energy>
        </ResourceProperties>
    </Ship>
    <PostGame></PostGame>
</The_Experiment_Game_File>
And this the outpot with TES_TEGReadVerboseLevel=1

Code: Select all

Irrlicht Engine version 1.4.1
Microsoft Windows XP Personal Service Pack 2 (Build 2600)
TE: Reading TEG file


TEGRead: I have read the following data
gameplay.gamename Dummycollector
gameplay.countdown 300
Splash nr 1 fn= file1 abortkey= anykey countdown= 24
Splash nr 2 fn= file2 abortkey= anykey countdown= 25
Splash nr 3 fn= file3 abortkey= lakey countdown= 26
GameObjects number 1 name = dummy1
 spawnsoundfile spsound.wav
 permanentsoundfile permsound.wav
 pickupsoundfile pickupsound.wav
 spawnsoundvolume 1
 permanentsoundvolume 1
 pickupsoundvolume 1
 pickupdistance 2.5
 addweight 1000
GameObjects number 2 name = dummy2
 spawnsoundfile
 pickupdistance 2
level filename = level/mylevel.irr
spawnstation= example
 SpawnstationObject= dummy1
 SpawnstationObject= dummy2
spawnstation= spawnplace1
 SpawnstationObject= dummy21
spawnstation= spawnplace2
 SpawnstationObject= dummy22
levelcenter name= delistation1
 bounding box= 1 2 3

Shipproperties
random ship movements=
 mintime= 1 rantime= 2 minamplitude= 3 ranamplitude= 4
Weapons
 Weaponname= greenshot onShotSoundFilename= somefile onButtonPressShot= 1

TEGRead: TES_TEGReadVerboseLevel 1 end
Drücken Sie eine beliebige Taste . . .
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

it's a lot of code to check through for your problems... and we'd probably have to have multiple test versions of your format and spend a lot of time to get it working properly...

can you really not use IrrEdit instead? It would no doubt make your life a lot easier
Image Image Image
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

JP wrote:it's a lot of code to check through for your problems... and we'd probably have to have multiple test versions of your format and spend a lot of time to get it working properly...

can you really not use IrrEdit instead? It would no doubt make your life a lot easier
Your answer lets me wonder, if we talk about the same thing.
I can't see it would make a change what editor I use, because I set options in my .teg file that are not part of the irrlicht engine, it is tweaking code written by myself. For instance if I have a pickup weapon in my game I define in the .teg, what my program shal do with it. Add recources, add a weapon to the ship, give acces to closed doors, whatever. Does irredit provide service for such problems?
By the way, I don't want to have my code tested. I am not an exploiter :lol: . It was because of the friendly offer of Jgoldnight that i posted that rock of stupid code. The code is errorfree, as far as I can see.
Post Reply