Loading MTA Race map with XML Loader
#1

Hello!

I'm trying to load an MTA Race map with XML loader. Small maps are loaded without any problem, but one of the advanced DM maps with 5000-7000 objects is taking way too long to load.

Anyone got any clue on how to reduce this lag/time created?

Any answer is appreciated.

This is the part of code that loads the maps:

pawn Код:
for(new i = 1;i <= xml_get_int(file, "count(map/object)");i++)
    {
        new model, Float:pos[6];

        format(string, STRING_LENG, "map/object[%d]/@model", i);
        model = xml_get_int(file, string);

        format(string, STRING_LENG, "map/object[%d]/@posX", i);
        pos[0] = xml_get_float(file, string);

        format(string, STRING_LENG, "map/object[%d]/@posY", i);
        pos[1] = xml_get_float(file, string);

        format(string, STRING_LENG, "map/object[%d]/@posZ", i);
        pos[2] = xml_get_float(file, string);

        format(string, STRING_LENG, "map/object[%d]/@rotX", i);
        pos[3] = xml_get_float(file, string);

        format(string, STRING_LENG, "map/object[%d]/@rotY", i);
        pos[4] = xml_get_float(file, string);

        format(string, STRING_LENG, "map/object[%d]/@rotZ", i);
        pos[5] = xml_get_float(file, string);

        CreateObject(model, pos[0], pos[1], pos[2], pos[3], pos[4], pos[5],GLOBAL_OBJECTS_DISTANCE);
    }
Reply
#2

Write your own parser. :P (or try other ones, there are a few includes). Depending on your XML reader it might just be the plugin itself being that slow. Some of them read & process the complete file with all sections, though there are just the half of the information needed.
I've done a MTA parser (which works with getchar) that loads about 20k objects quite quickly (compared to the mass of data).

Btw how long does loading take for you? Does the reader open/close the XML file with every xml_get_int? Closing/Opening takes its time too, especially for older harddrives.
Reply
#3

It is homehosted and the plugins/includes are up to date. Loading takes a long time, I've added prints and I see that it takes way TOO long under the LoadObjects stock (that might exceed 3 minutes), but even after loading, the map will be half loaded.

Код:
Does the reader open/close the XML file with every xml_get_int?
Didn't quite get that part.
Reply
#4

3 minutes? Wow... Mine (and others too) reads that many objects in under 10 seconds, even on my slow HDD.

XML files are very good for configuration etc but I don't like them for storing data just because of this.

Well it's an internal thing of the plugin. If the plugin opens, reads and closes the file with every action you make (like reading an int) it will surely use a lot of time just for that.
Which XML plugin do you use?
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=150755

XML Loader by Zeex, even if it is old enough..
Reply
#6

Well I don't exactly know what's the cause for the long time needed to read the files here. It could just be the size of the file or how it gets read.

But you should try other methods to see if they're faster. If yes, you at least know if it's the plugin or not.

If you search for mta .map loader you will find some includes, just for testing.

I think this should work for testing: https://sampforum.blast.hk/showthread.php?tid=519790
Reply
#7

I tried it out, but the gamemode will crash (unknown gamemode) because of DLL's or the server plugins. CVector is causing the error, as it has missing DLL, after installing, the server wont start due to the DLL/plugin problem.
Reply
#8

Use y_xml, I created a tutorial for it before.. Search..
I tested it to read & write an item 1000 times, And it took like ~5 secs AFAIR.
Reply
#9

I prefer staying away ****** releases now that he left and we don't have support anymore, including I'm a total newbie into Y_XML and will never be able to get any future assistance after reference thread is deleted.
Reply
#10

Well you dont need further assistance once you get it working imo. It's just an XML Loader, and with a tutorial it should work fine.

For the DLL's, it should show you which is missing, just get that one and put it into server directory.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)