Import/Export single area of map?

All and any discussion and development of the Mudlet Mapper.
Post Reply
Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Import/Export single area of map?

Post by Nyyrazzilyss » Mon Jun 29, 2015 2:33 pm

Any easy way to import/export individual map areas?

I can save the entire map, but just individual areas? I'd assume if not i'd probably just need to write something to copy the data into a table, and write the table to disk. I would guess the biggest difficulty would be with getting border rooms to sync up between areas since the room ids would likely change on import.

User avatar
SlySven
Posts: 919
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Import/Export single area of map?

Post by SlySven » Fri Jul 03, 2015 4:26 pm

There does appear to be some sort of map import/export code framework in the TMap class: (void)TMap::exportMapToDatabase() and (void)TMap::importMapFromDatabase(), which when invoked compile and invoke Lua functions exportMapToDatabse("dataBasename") and importMapFromDatabase("dataBasename") respectively - however they are dead code and are not used - so the typo on the lua export command is not currently an issue. I have not been able to track down those corresponding lua functions so I am not sure what they would actually do if they existed.

When you add a room you only have to use a room Id that does not currently exist - so if you are creating it piecemeal from a coherent source (say by selected bits from a database) then you should know whether the room is already loaded. All that createRoomID() does is give you the lowest room Id that has not been used in the rooms already there, which is not going to be much use in your case. If you are going to allow a user to change the map then you need to start your "predefined" map above the range that you instruct the user that they are OK to use - perhaps writing a getNewRoomID() function AND TELLING THE USER TO USE IT that uses createRoomID() and "fudges" the results to avoid the ranges that you need...

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Import/Export single area of map?

Post by Nyyrazzilyss » Fri Jul 03, 2015 7:55 pm

When you add a room you only have to use a room Id that does not currently exist
I hadn't realized that, and rechecking the cmud import script it should have been obvious: Room numbers can quite easily be created out of order. If I just renumber the source database to have a minimum value of (5000?), a call to createRoomID should never return a value inside the range i'm using.

As to range: What is the maximum value for a room id?

User avatar
SlySven
Posts: 919
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Import/Export single area of map?

Post by SlySven » Sat Jul 04, 2015 1:15 am

At least 32767...!

it is specified as an int ("{signed} integer") in the TRoom class header, and that limit (2^15-1) is all that I believe can be promised for that object type.

It is likely that in practice you will find that you will probably have 2147483647 (2^31-1) possible rooms, though some might have more - unfortunately the variable types chosen when Mudlet was first put together neglected to consider that data files might be moved between systems that had potentially different sizes for some common object types so there is potentially the scope for problems which we could avoid if we "fixed" them in the future - by explicitly using something like a {Qt defined} qint32 where the room id number is specified so that it will always be a (signed) 32 bit number whatever version of Qt/Compiler/phase of the moon applies when the code is built/used (I think we have some code that uses a negative room id or a zero for error handling so we have already halved the range available for normal usage by needing to use a signed variable whereas an unsigned one would give twice as many leaving the zero value for a sentinel value!)

For instance I did a lot of development work in the past on an aged Pentium Laptap which had a single 32-processor and a pair of 32-bit OSes on-board, now I have changed to a quad-core AMD unit which dual boots (well al-right, only once in a blue moon do I boot 'doze 7! :) ) 64-bit OSes and whilst we currently only provide 32-bit Windows pre-compiled binaries as Qt do not themselves provide a ready to run F.O.S.S. 64-bit Qt IDE/Library on that platform, *nix users can be using either 32 or 64 bits which could in theory change what their compiler uses for the "generic" types... :shock:

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Import/Export single area of map?

Post by Nyyrazzilyss » Sat Jul 04, 2015 1:51 am

At least 32767...!

That might be a difficulty. While at this time i've only moved a half dozen or so zones into the mapper, the mud I play/that i'm writing this for (TorilMud) has a map of rooms twice that size - Even an unsigned int for roomid wouldn't be able to handle the entire map :( Hopefully it is 32bit, though being explicitly defined to be that (signed long) would be much better :)

Total number of zones in world: 352
Total number of rooms in world: 66237

I'll look at splitting the map into multiple files, but that might also be difficult.

User avatar
SlySven
Posts: 919
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Import/Export single area of map?

Post by SlySven » Sat Jul 04, 2015 12:06 pm

I'm sure that in practice you won't have a problem with several hundred thousands of rooms - and I'll raise a bug against this and other insufficiently defined variables to see if we can avoid even the potential for problems going forward...

EDIT: Bug 1471406 filed.

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Import/Export single area of map?

Post by Nyyrazzilyss » Mon Jul 06, 2015 5:23 pm

I created/gave a room the number 85000, and it worked/was able save the map/reload it and the room still showed with that number. I'm using 3.0-delta on windows 7, so while I can't speak to other versions / operating systems, it's definitely larger then 2 bytes with my setup.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests