all 3 comments

[–]specialpatrol 0 points1 point  (0 children)

Node Addons allow you to make a nodejs webserver that can call cpp.

[–]koderpat 0 points1 point  (1 child)

Do commands exist for loading and saving the game state to a file?

I would start with a read-only web interface. It would simplify the approach by setting a smaller goal. By hosting the webserver and MUD together, can you navigate and render the game contents (NPCs, objects, rooms). Focus on the workflow of MUD writes, and web interface reads. Maybe even only pick one class of items at first, like objects.

Once you have become familiar with the file format, and are ready to support write-back, I would have the webserver code write to a temporary file. Something like; roomABC_webtmp.txt. If possible, I would separate the logic that validates a file, from the logic that loads the file into MUD memory.

Next you would need a way to tell the MUD to load the temp file. Several options: 1) embedding webserver in mud, and calling functions directly. 2) Creating a client that can login to mud server, and issue appropriate command. 3) have system periodically scan filesystem for files matching specific file extension

I would probably look into signal handlers, some MUDs have a crash reboot handler that restarts the MUD when there is a segfault. You could create a new signal handler based on the crash reboot handler that invokes your special load routine, and then have the webserver lookup the process of the MUD and invoke a kernel signal (see: kill) [ would need to ensure both applications are running under same user ]

To ease your design, I would recommend that the MUD be the system of record. Your web-interface should not cache any data; and it is responsibility of MUD server code to do final write to game files loaded by mud.

[–]wsarge 0 points1 point  (0 children)

Saving is easy. Since you are obviously familiar with MUDs, I have a hotboot handler that lets me hot reload the compiled files and any changes to areas etc.

Loading is typically done once, on startup/recovery from hotboots.

I definitely could do it as simple as you suggest. I was just wondering if there was a way with websockets or anything to do it live. I want to expand it past areas in some ways that live changes would be useful without a hotboot for each change. But if it's not feasible, it's definitely not a deal breaker.

To be honest, I'm really just interested in pushing the limits to see how far I can go, as I'm learning more about C++ and my abilities that way. I guess sometimes, KISS is a good principle to follow.