Author Topic: Dedicated Server Brick Saving  (Read 1280 times)

SaveBricks is entirely clientside from what I understand, so that means it doesn't load for dedicated servers. Has anyone come up with a solution that I've missed?

Look at the brick save format, then write a method to export one of those files serverside?

Look at the brick save format, then write a method to export one of those files serverside?
That involves work. I was posting in hopes that I didn't have to do that, honestly... But, if nobody else already has, I have little other choice.

I'll do it if you want, it sounds fun.

Leave it to Randy to take on the tasks no-one else does  :cookieMonster:

I did it for an old dedicated server I used to run, It'd do backups every hour and saved ownership of bricks which was quite useful.

Yeah, but the trick is you're not posting the code for us lazy bums to leech off of :P

I wouldn't want to rob Randy of his fun.

This would be greatly appreciated on my end too.




You know Ephi, if you actually told people what you already made, you'd save allot of people work :P

He did, he told us just now. Doesn't mean he's going to release it though. :(

Eh, he just lets people redo work he already did.

Oh well. It was worth a shot. Time to write up some ugly ContainerSearch script!

Here it is, tell me if you find any bugs.
Code: [Select]
function dediSave(%name, %desc){
%path = "base/saves/" @ MissionInfo.saveName @ "/" @ %name @ ".bls";
%file = new FileObject();
%file.openForWrite(%path);
%file.writeLine("This is a Blockland save file.  You probably shouldn't modify it cause you'll screw it up.");
%file.writeLine("1"); // What does this mean?
%file.writeLine(%desc);
for(%i=0;%i<64;%i++){
%file.writeLine(getColorIDTable(%i));
}
%bricks = 0;
for(%i=0;%i<mainBrickGroup.getCount();%i++)
%bricks += mainBrickGroup.getObject(%i).getCount();
%file.writeLine("Linecount " @ %bricks);
for(%i=0;%i<mainBrickGroup.getCount();%i++){
%group = mainBrickGroup.getObject(%i);
for(%a=0;%a<%group.getCount();%a++){
%brick = %group.getObject(%a);
%print = (%brick.getDataBlock().subCategory $= "Prints") ? getPrintTexture(%brick.getPrintID()) : "NOPRINT"; // Possibly better way to check?
%file.writeLine(%brick.getDataBlock().uiName @ "\" " @ %brick.getPosition() SPC %brick.getAngleID() SPC %brick.isBasePlate() SPC %brick.getColorID() SPC %print SPC %brick.getColorFXID() SPC %brick.getShapeFXID());
if(isObject(%brick.audioEmitter)){
%file.writeLine("+-AUDIOEMITTER " @ %brick.audioEmitter.getProfileID().uiName @ "\" "); // Not sure if something else comes after the name
}
if(isObject(%brick.vehicleSpawnMarker)){
%file.writeLine("+-VEHICLE " @ %brick.vehicleSpawnMarker.uiName @ "\" " @ %brick.reColorVehicle);
}
if(isObject(%brick.emitter)){
%file.writeLine("+-EMITTER " @ %brick.emitter.emitter.uiName @ "\" " @ %brick.emitterDirection);
}
if(%brick.getLightID() >= 0){
%file.writeLine("+-LIGHT " @ %brick.getLightID().getDataBlock().uiName @ "\"");
}
if(isObject(%brick.item)){
%file.writeLine("+-ITEM " @ %brick.item.getDataBlock().uiName @ "\" " @ %brick.itemPosition SPC %brick.itemDirection SPC %brick.itemRespawnTime);
}
}
}
%file.close();
%file.delete();
}

Thanks, Randy. Let's see how well she works out.

Edit: Perfectly. Combine this with serverDirectSaveFileLoad and everyone wins! Thanks again, Randy.
« Last Edit: July 31, 2008, 03:05:59 PM by Dilt »

Thanks, but I'd much prefer that it saves ownership (hint hint ephi, Randy had his fun) that version would be so much more usefull for my tile town server I'm running.