Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
deeaych
Newbie


Joined: 30 Dec 2012
Posts: 2

PostPosted: Sun Dec 30, 2012 5:02 pm   

Converting Room/Exit database to map
 
This may be too ambitious of a project for what CMud is capable of, but I thought I'd run it by the experts before I spend too much time banging my head against this just to realize it's not possible.

My favorite MUD has recently open-sourced all their code, which includes SQL dumps of all their database tables. The three tables I'm interested in are "zone", "room", and "roomexit".
- Zone has one record for each zone in the game, with the important fields being a unique zone number as the primary key, and the zone name.
- Room contains one row for every room in the game, with the unique VNUM as the primary key, a room name, long description, X/Y/Z coordinates, and a foreign key to the zone number to which it belongs.
- Roomexit contains a row for every exit from every room in the game. Each row contains the VNUM of the room from which it exits, the direction of the exit, the door name if applicable, and the VNUM of the destination room.

I have all of the tables imported in to mySQL right now. Would the easiest thing be just to programmatically convert the data directly to a map database file (.mdb I think, correct?) that CMud can read? Or would I need to use CMud scripting commands (using CMud Pro 3.34) and SQL queries to create and link the rooms one by one (if that's a possibility)?

Sorry if this sounds crazy, it just seems a shame to go through and map the entire mud manually when I have all that data already at my fingertips.

Thanks!
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Dec 30, 2012 5:41 pm   
 
The problem with converting the data is that there's a lot more that goes into a CMUD mapper database than that. If you really want to try this, I'd suggest creating a new map, making a zone and a few rooms, then open up the database in an SQLite viewer and look at the results. It's been a while since I messed with the mapper database directly, but off the top of my head, a few tips for you:
- The three tables you'll want to look at are ObjectTbl (rooms), ExitTbl and ZoneTbl.
- All the fields you listed should have one-to-one mappings in the mapper database.
- I'm not sure how your X/Y/Z coordinate fields work, but in the mapper database, the X/Y/Z fields correspond to (I think?) pixel locations on the map canvas. I don't remember how it works exactly, but they don't change in increments of 1.
- Your exit table might work the same way, but in the mapper database, you need two rows for two-way exits. For example, an exit east from room 1 to room 2, and an exit west from room 2 to room 1.
- Directions aren't stored in the exit table by name, they're stored by an id number. IIRC there's a directions table that you can look at for the numbers.

I'm sure I (and others) will come up with more later, and feel free to post questions as you go. Good luck!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Dec 30, 2012 5:48 pm   
 
Cmud is easily capable of this, but the major stumbling block is the map database itself. The interconnectivity of the data is so complex few, if any, users have even attempted to "reinvent the wheel" to handle all that the mapper already doe internally.

FYI, it's typically a bad idea to modify the database (in the way you'll have to to make all the changes) while cmud is using it. Your changes won't appear until you restart the session.
_________________
EDIT: I didn't like my old signature
Reply with quote
deeaych
Newbie


Joined: 30 Dec 2012
Posts: 2

PostPosted: Sun Dec 30, 2012 6:44 pm   
 
Hey guys, thanks for the responses.

Daern wrote:
The problem with converting the data is that there's a lot more that goes into a CMUD mapper database than that. If you really want to try this, I'd suggest creating a new map, making a zone and a few rooms, then open up the database in an SQLite viewer and look at the results. It's been a while since I messed with the mapper database directly, but off the top of my head, a few tips for you:
- The three tables you'll want to look at are ObjectTbl (rooms), ExitTbl and ZoneTbl.
- All the fields you listed should have one-to-one mappings in the mapper database.
- I'm not sure how your X/Y/Z coordinate fields work, but in the mapper database, the X/Y/Z fields correspond to (I think?) pixel locations on the map canvas. I don't remember how it works exactly, but they don't change in increments of 1.
- Your exit table might work the same way, but in the mapper database, you need two rows for two-way exits. For example, an exit east from room 1 to room 2, and an exit west from room 2 to room 1.
- Directions aren't stored in the exit table by name, they're stored by an id number. IIRC there's a directions table that you can look at for the numbers.


It sounds like the tables I have from my MUD are set up very closely to how the CMud tables are designed. There is a row for every exit from every room, so there would be two for a two-way exit like you said, and the directions in my tables are also integers corresponding to the direction, so I'll have to translate those. Maybe they're the same as CMud, even. The X/Y/Z coordinates may not be important at all - I'm not sure it was even necessary to include them in my original post. I'll experiment with it and see if they're useful.

MattLofton wrote:
Cmud is easily capable of this, but the major stumbling block is the map database itself. The interconnectivity of the data is so complex few, if any, users have even attempted to "reinvent the wheel" to handle all that the mapper already doe internally.

FYI, it's typically a bad idea to modify the database (in the way you'll have to to make all the changes) while cmud is using it. Your changes won't appear until you restart the session.


In your opinion, what would be the best way to go about this project? Do you think it would be easier to try to copy my data directly in to a CMUD mapper database, or to write a script using Zscript commands to iterate through the tables with SQL queries and dynamically create/link each room in order?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Dec 30, 2012 8:00 pm   
 
deeaych wrote:
The X/Y/Z coordinates may not be important at all

The X/Y/Z coordinates are definitely important in the mapper database, that's how the mapper determines where to draw the rooms in relation to each other.

deeaych wrote:
In your opinion, what would be the best way to go about this project? Do you think it would be easier to try to copy my data directly in to a CMUD mapper database, or to write a script using Zscript commands to iterate through the tables with SQL queries and dynamically create/link each room in order?

I thought about doing it with zScript commands, but as far as I can tell there's no way to make an arbitrary room. #makeroom only makes a room in relation to your current position in the map. If you have CMUDPro though, you have access to the advanced COM mapper interface, and you can create rooms with that. I'd say that's the only way that's really feasible to do it with pure zScript, and that likely would be much easier than trying to build a database from scratch with SQL.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net