Hey folks,
I have posted before that I am developing a procedurally generated wilderness for Luminari - We currently have 1024x1024 locations and a function that returns an elevation (which can be mapped to SECTOR_TYPE) if given an x,y coordinate. There is some other magic in there (heh) but that is basically the worldgen.
The players see the wilderness as rooms with a bigger, more detailed world-style map, you can share rooms with mobs, objects, etc. and basically interact as you would normally. To move to described areas you just take an exit in a special pre-built wilderness room. It looks no different to the player than any other room.
(BTW; this is all on the development port, if you want to see, let me know and I will show you. It's a bit unstable, details follow!)
I am using a special area for the wilderness, with 10000 rooms. Not all of these are built, of course, but they are reserved for expansion.
- Vnum 1000000 is special, exits leading to this room force the use of the coordinate system
- Vnums 1000001-1003999 are only for pre-built rooms
- Vnums 1004000-1005999 are the DYNAMIC WILDERNESS ROOM POOL - THESE ROOMS ARE BUILT
- The remaining vnums are for expansion
So my issue is with char_to_room(ch, room), unsurprisingly.
I have modified do_simple_move to allocate rooms, etc from the pool as needed. This, however, is not everything, although most standard cases (walking, riding, following, fleeing) work perfectly. Other movement types, magical movement, immortal movement (goto), etc. as well as coming back from idle, relogging in, etc. have strange (to the player) results, since the rooms from the dynamic pool are reused once they become empty.
I am sure you can imagine the weirdness...
You are at (233, 74), standing alone in the grasslands and you log out and 15 seconds later you log back in. Suddenly, you are at [34, 65] in the middle of a pack of aggressive wolves! (The wolf mobs, as they moved, allocated the vnum that you were last in!)
You are fleeing a PK situation, and lose link. Frantically, you try to reconnect, but in the meantime your character voids and hangs with puff while your internet comes back online. Finally logging in, you are transported to the SAME room as your pursuers, who had since given up and were mining some iron ore in the hills! Needless to say, it did not end well for you.
So - It is pretty obvious what is happening. You are being sent to the room you were last in, not to the coordinates you were last in. Fine, fine, just check the player coordinates in char_to_room and see if the room has the same coords, and make sure you update the coords before you do char_to_room(). That seems like an easy solution, but I am wondering if I am missing something here. Is there a better way?
And my question: What is a good way to manage coordinates in this system?
Thanks, you are some bright folks, I am looking forward to your responses.
Here is the worldmap, if anyone is interested:
(Click for a BIG verison, 1 pixel = 1 room.)