RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Updating Statics and Maps while the client is running

Praxiiz

Sorceror
I'm trying to determine if updating maps and statics with the client running is worth the effort that would go into it. I would like feedback on the network and bandwidth implications that this type of system would incur (and any side effects like synchronization issues between the client and helper application that I would build).

The ultimate goal is to have a malleable map where players could alter the terrain under certain circumstances. (For example, after a certain amount of time mining in one spot, the terrain would lower slightly.)
 

HellRazor

Knight
I don't think the changes will sync in real time. The client loads in the map a block at a time and at a minimum they would probably need to leave the screen and come back to see the change. Not sure about other implecations (client crashing etc.) although I think the OSI God Client allows real-time editing of the map from the client, so it seems like it might be doable.
 

Praxiiz

Sorceror
HellRazor said:
at a minimum they would probably need to leave the screen and come back to see the change.
That's exactly what happens, it only updates after the client has moved out of its update range. I have a prototype application that allows me to edit the maps while the client is running, but you're right, you have to move a screen or two away and come back to see the changes. I have been slowly searching through the client assembly looking for a way to trick it into updating immediately, but its a slow process. Any thoughts on how much bandwidth map updates would consume?
 

HellRazor

Knight
It shouldn't consume any more than the client normally uses since it loads the map as you enter the area (and that is all client-side).

Out of curiosity, how are you changing the map client-side? The map would need to be edited both clientside and serverside otherwise there will be issues.

I think there may be some ways to trick the client into refreshing the view via packets. Not sure. I have seen conversations about this in the forum but can't remember what the outcome was (there are some other situations where this can happen with objects aside from a map update).
 

Praxiiz

Sorceror
I haven't started modifying the core to accommodate map edits yet on the server side, I thought I'd hash out the client issues first. To edit the map client side, I opened up the client in a hex editor (after finding the locations in ida pro) and I edited the parameters passed to CreateFile, CreateFileMapping, and MapViewOfFile. The access and sharing modes are hard coded in the client, so its just a matter of passing in the correct modes. Normally the client is set to read-only. Changing it to read | write in the subroutine will make the client open every memory mapped file in read/write mode.

Then the only thing lacking was that the client passes null as a parameter for the shared name (which is the name that other processes need to share the memory space when they call OpenFileMapping). Changing that to something predictable wasn't very difficult. The subroutine was already using the file and path. I wrote a simple function in C and compiled it to bytecode that iterated through the string until it had a pointer to the filename without the path. I found some empty space between subroutines and injected the bytecode. Then it was just a matter of changing a couple instructions to get the client to jump to my code, push the new pointer onto the stack and jump back just before calling CreateFileMapping. The result was that the client would then open its mul files in shared mode with predictable names.

Then in my prototype application, I could call OpenFileMapping with the shared access rights and pass it a name like map0.mul. Then I'd have access to the same memory mapped file the client was using, and any changes I made would be paged back out to disk, and the next time the client accessed that section of memory from the file mapping, it would see the altered memory.

I'm sure there's better way to make it work with more clients without patching the client.exe (maybe dll injection / searching through the client process), but this made sense to me at the time and I thought it would be a good experiment to see if something like this would actually work.
 

Praxiiz

Sorceror
If there's a way to trick the client into updating immediately, then the major roadblocks on the client would be solved and I can write a helper application that could receive updates from the server and mirror the map changes that were made server side onto the client in real time.
 

HellRazor

Knight
Would be a great capability to have. Womder if amy of that God Client code for msp editing is in the client.exe still, only unused.
 

Praxiiz

Sorceror
I know that the packet handler in the 5.x clients still has subroutines for handling the 0x3f and 0x40 packets for updating terrain and statics, I ran across them today. The 7.x client that I've been doing my prototypes on isn't as easy for me to get around in so I haven't found the packet handler in it, but when I do find it, we will know if the newer client still has the old packets for the statics and terrain updates.
 

Praxiiz

Sorceror
The 7.x clients do seem to have the packet handlers for the 0x3f and 0x40 packets. Now its just a matter of looking at the assembly to see what they actually do.
 

Vlek

Sorceror
Are you still working on this? I would be very interested in what comes of this, too. Do you have anything in mind you're trying to accomplish with this? I had the same idea, but I didn't know the issues client side that would arise or if it was even possible.
 

wlrdwawoolard

Sorceror
this would have to be server side and client side but anyways not trying to be negative but u would have to do alot of work in making new tiles and tiles and tiles maybe ur own tiledata.mul im saying this cant be done but inorder for this to work u have to make everything custom to run in a smooth path and might cause alot alot alot of lag... and dont forget about scripts. like refilling the holes so players can move. but anyways i think its a good idea but alot of thought must be more to come.
 

Vlek

Sorceror
Well, right. Like, say, in the middle of a forest, a player inserts an acorn into the ground, and sprouts a tree that is written into the map file. I am using this as a thought experiment considering how the actual system would be abused by players. At any rate, the modification is possible, but it would take a lot of work. What we're trying to find out is exactly how much work it would take to make it functional.
 

Vlek

Sorceror
So at best we're looking at everyone having to download a "special" map (just one with all of the trees removed).
 

Talow

Sorceror
I've actually been watching what prax has been doing rather closely in different forms....

With the system he is trying to design it would expand a one time open client to the point where it would allow the map files to be edited in game and on the fly.

meaning you would not have to script the trees, remove all the trees from the .mul files, but instead you would be able to edit the lumberjack skill to update the info on the map tile, and at that point be able to remove the tree, you would also at the same time be able to add an item to the spot. This item would be able to stop players from dropping houses where they should not go and also respawn the tree on the map when timer dies.

Edit:

And then with the system he's trying to design (be it through razor or whatever) the map on the client would then be able to be over written by the server. This would then let any server be able to have a dynamic map.
 

Talow

Sorceror
Yes that's correct, he is working to make it so that the server will, in realtime be able to send packets to the client and thu allow the client to update the map.mul on the fly.
 

wlrdwawoolard

Sorceror
ohhh got yea never really did anything like this and new to me but ill be helping as much as i can so bring another project :D
 
Top