icewolfz / jiMUD

MUD client for ShadowMUD.com using electron
http://www.shadowmud.com
7 stars 0 forks source link

Backup: Expand backup to include all map data for all characters #294

Open icewolfz opened 2 weeks ago

icewolfz commented 2 weeks ago

This will require a redesign and rethinking of how to handle backups as the file size alone could be up to 2 or 3 megs and take up to 5 minutes to upload, could redesign to a background async process maybe, another issue is the server may not work well with large file sizes so that is something else to consider, a possible solution is changing compression methods but limited to what the web client supports, as its hard to support a lot there granted a lot of map data is duplicate so another option is custom data storage, reformat all the map data into a shared system, store all the room data in 1 place, and then each charcter just store id #s and when important reformat back to full formats that would reduce the data size by a ton i think

icewolfz commented 1 week ago

playing around 2 waus:

//this method compresses better as it loads the raw room/exitdata as js objects then converted to strings, but more complex to recreate as you have to remake the database including all tables, keys and everything then put in the data
//this created data from around 15 megs of maps of a target file of around 5.6 megs
                s = parseTemplate(data.characters[c].Map);
                if (existsSync(s)) { 
                    _db = new sqlite3(this.mapFile);
                    data.characters[c].mapData = {}
                    data.characters[c].mapData.rooms = _db.prepare('Select * FROM Rooms').all();
                    data.characters[c].mapData.exits = _db.prepare('Select * FROM Exits').all();
                    _db.close();
                }

or

//this way is just a raw data dump of the binary file, this is larger and not compressed as well as it is a binary file but requires less work to require as you just dump the file back as is to disk and it should work in just 1 line of code
//this created using the same data from above a target of around 9.6 megs so nearly twice the size
data.characters[c].mapData = fs.readFileSync(s, 'utf-8');