Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1c1,2
- < //Heavily remodified by Visolator/Kyuande.
- ---
- > // Heavily remodified by Visolator/Kyuande.
- > // (many) patches from TheBlackParrot
- 3c4,27
- < if($Server::AS::dir $= "")
- ---
- > $Pref::Server::AS::SaveDirectory = "saves/AutoSaver/";
- > $Pref::Server::AS::Announce = true;
- > $Pref::Server::AS::AnnounceSaveName = true;
- > $Pref::Server::AS::SavingInterval = 5;
- > $Pref::Server::AS::DetailedReport = true;
- > $Pref::Server::AS::SaveEvents = true;
- > // 0 = host, 1 = original owner, 2 = public
- > // http://forum.blockland.us/index.php?topic=255914.msg7446537#msg7446537
- > $Pref::Server::AS::LoadOwnership = 1;
- > $Pref::Server::AS::SaveOwnership = true;
- > $Pref::Server::AS::AllowOverwriting = true;
- > $Pref::Server::AS::AutoloadPreviousSave = true;
- > $Pref::Server::AS::SaveEvenIfSame = false;
- > // 1 = admin, 2 = super admin, 3 = host
- > $Pref::Server::AS::WhoCanSave = 2;
- > $Pref::Server::AS::LastAutoSave = "";
- > $Pref::Server::AS::LastBrickCount = 0;
- > $Pref::Server::AS::LastEventCount = 0;
- >
- > if(isFile("config/server/AutoSaver.prefs.cs")) {
- > exec("config/server/AutoSaver.prefs.cs");
- > }
- >
- > if($Pref::Server::AS::SaveDirectory $= "")
- 5c29
- < if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
- ---
- > if(isFile("Add-Ons/System_ReturnToBlockland/server.cs") || isFunction(RTB_registerPref))
- 7c31
- < if(!$RTB::Hooks::ServerControl)
- ---
- > if(!$RTB::Hooks::ServerControl && isFile("Add-Ons/System_ReturnToBlockland/hooks/serverControl.cs"))
- 10,19c34,46
- < RTB_registerPref("Announce", "Autosaver", "$Server::AS::announce", "bool", "Support_AutoSaver", 1, 0, 0);
- < RTB_registerPref("Folder location", "Autosaver", "$Server::AS::dir", "string 50 50", "Support_AutoSaver", "saves/AutoSaver/", 0, 0);
- < RTB_registerPref("Announce savename", "Autosaver", "$Server::AS::announceSaveName", "bool", "Support_AutoSaver", 1, 0);
- < RTB_registerPref("Interval", "Autosaver", "$Server::AS::interval", "int 0 16", "Support_AutoSaver", 5, 0, 0);
- < RTB_registerPref("Report stats", "Autosaver", "$Server::AS::report", "bool", "Support_AutoSaver", 1, 0, 0);
- < RTB_registerPref("Save events", "Autosaver", "$Server::AS::saveEvents", "bool", "Support_AutoSaver", 1, 0, 0);
- < RTB_registerPref("Save ownership", "Autosaver", "$Server::AS::saveOwnership", "bool", "Support_AutoSaver", 1, 0, 0);
- < RTB_registerPref("Overwrite temp save", "Autosaver", "$Server::AS::overwriteSave", "bool", "Support_AutoSaver", 0, 0, 0);
- < RTB_registerPref("Autoload save on start", "Autosaver", "$Server::AS::autoload", "bool", "Support_AutoSaver", 1, 0, 0);
- < RTB_registerPref("Autosave duplicates", "Autosaver", "$Server::AS::SaveRelatedBrickcount", "bool", "Support_AutoSaver", 0, 0, 0);
- ---
- > // Blockland Glass can hook into these as legacy prefs, you should be fine
- > RTB_registerPref("Announce", "Autosaver", "$Pref::Server::AS::Announce", "bool", "Support_AutoSaver", 1, 0, 0);
- > RTB_registerPref("Folder location", "Autosaver", "$Pref::Server::AS::SaveDirectory", "string 50 50", "Support_AutoSaver", "saves/AutoSaver/", 1, 0);
- > RTB_registerPref("Announce savename", "Autosaver", "$Pref::Server::AS::AnnounceSaveName", "bool", "Support_AutoSaver", 1, 0);
- > RTB_registerPref("Interval", "Autosaver", "$Pref::Server::AS::SavingInterval", "int 0 16", "Support_AutoSaver", 10, 0, 0);
- > RTB_registerPref("Report stats", "Autosaver", "$Pref::Server::AS::DetailedReport", "bool", "Support_AutoSaver", 1, 0, 0);
- > RTB_registerPref("Save events", "Autosaver", "$Pref::Server::AS::SaveEvents", "bool", "Support_AutoSaver", 1, 0, 0);
- > RTB_registerPref("Save ownership", "Autosaver", "$Pref::Server::AS::SaveOwnership", "bool", "Support_AutoSaver", 1, 0, 0);
- > RTB_registerPref("Load ownership", "Autosaver", "$Pref::Server::AS::LoadOwnership", "list Host 0 Owner 1 Public 2", "Support_AutoSaver", 1, 0, 0);
- > RTB_registerPref("Overwrite temp save", "Autosaver", "$Pref::Server::AS::AllowOverwriting", "bool", "Support_AutoSaver", 1, 0, 0);
- > RTB_registerPref("Autoload save on start", "Autosaver", "$Pref::Server::AS::AutoloadPreviousSave", "bool", "Support_AutoSaver", 1, 1, 0);
- > RTB_registerPref("Autosave duplicates", "Autosaver", "$Pref::Server::AS::SaveEvenIfSame", "bool", "Support_AutoSaver", 0, 0, 0);
- > RTB_registerPref("Allowed to save", "Autosaver", "$Pref::Server::AS::WhoCanSave", "list Admins 1 SuperAdmins 2 Host 3", "Support_AutoSaver", 2, 1, 0);
- 21,32c48,57
- < else
- < {
- < $Server::AS::dir = "saves/AutoSaver/";
- < $Server::AS::announce = true;
- < $Server::AS::announceSaveName = true;
- < $Server::AS::interval = 5;
- < $Server::AS::report = true;
- < $Server::AS::saveEvents = true;
- < $Server::AS::saveOwnership = true;
- < $Server::AS::overwriteSave = true;
- < $Server::AS::autoload = true;
- < $Server::AS::SaveRelatedBrickcount = false;
- ---
- > }
- >
- > // double-checking
- > if($Pref::Server::AS::SavingInterval $= "") {
- > $Pref::Server::AS::SavingInterval = 0;
- > }
- >
- > function GameConnection::isHost(%this) {
- > if(%this.bl_id == getNumKeyID() || %this.bl_id == 999999) {
- > return 1;
- 33a59,60
- >
- > return 0;
- 36,43c63,81
- < if(isFile("config/server/AutoSaver.cs"))
- < exec("config/server/AutoSaver.cs");
- <
- < function Server_AutoloadSave()
- < {
- < announce("\c5Autoloading last autosaved build.");
- < if($Server::AS::Pref["LastAutoSave"] !$= "")
- < loadAutoSaveBuild($Server::AS::Pref["LastAutoSave"]);
- ---
- > function GameConnection::canAutoSaveBricks(%this) {
- > switch($Pref::Server::AS::WhoCanSave) {
- > case 3:
- > if(%this.isHost()) {
- > return 1;
- > }
- >
- > case 2:
- > if(%this.isSuperAdmin) {
- > return 1;
- > }
- >
- > case 1:
- > if(%this.isAdmin) {
- > return 1;
- > }
- > }
- >
- > return 0;
- 48,49c86,89
- < $Server::AS::HasAutoLoaded = 1;
- < schedule(5000, 0, Server_AutoloadSave);
- ---
- > if($Pref::Server::AS::AutoloadPreviousSave) {
- > $Server::AS::HasAutoLoaded = 1;
- > schedule(5000, 0, LoadAutoSave, "last");
- > }
- 54c94,95
- < if(!%this.isSuperAdmin)
- ---
- > if(!%this.canAutoSaveBricks()) {
- > %this.play2D(errorSound);
- 55a97
- > }
- 58a101
- > %this.play2D(errorSound);
- 69,71c112,113
- < function serverCmdLoadAutoSave(%this, %msg0, %msg1, %msg2, %msg3, %msg4, %msg5, %msg6, %msg7, %msg8, %msg9)
- < {
- < if(!%this.isSuperAdmin)
- ---
- > function serverCmdLoadAutoSave(%this, %msg0, %msg1, %msg2, %msg3, %msg4, %msg5, %msg6, %msg7, %msg8, %msg9) {
- > if(!%this.canAutoSaveBricks())
- 74,75c116,123
- < for(%i = 0; %i < 9; %i++)
- < %msg = %msg SPC %msg[%i];
- ---
- > if(strstr(%msg0, " ") == -1) {
- > for(%i = 0; %i < 9; %i++)
- > %msg = %msg SPC %msg[%i];
- > } else {
- > // command was triggered via console
- > %msg = %msg0;
- > }
- >
- 82,84c130,135
- < if(%msg $= "last")
- < {
- < Server_AutoloadSave();
- ---
- > LoadAutoSave(%msg);
- > }
- >
- > function LoadAutoSave(%save)
- > {
- > if(%save $= "") {
- 88c139,147
- < loadAutoSaveBuild(%msg);
- ---
- > if(%save $= "last") {
- > if($Pref::Server::AS::LastAutoSave !$= "") {
- > announce("\c5Loading previous autosave...");
- > loadAutoSaveBuild($Pref::Server::AS::LastAutoSave);
- > }
- > return;
- > }
- >
- > loadAutoSaveBuild(%save);
- 108c167
- < function loadAutoSaveBuildPath(%path)
- ---
- > function loadAutoSaveBuild(%name)
- 110,114c169,171
- < if(!isFile(%path))
- < {
- < announce("loadAutoSaveBuildPath() - invalid save file (" @ %path @ ")");
- < return;
- < }
- ---
- > //if(%name $= "last") {
- > // %name = $Pref::Server::AS::LastAutoSave;
- > //}
- 116c173,174
- < if(fileExt(%path) !$= ".bls")
- ---
- > %path = $Pref::Server::AS::SaveDirectory @ %name @ ".bls";
- > if(!isFile(%path))
- 118c176
- < announce("loadAutoSaveBuildPath() - invalid save (" @ %path @ ")");
- ---
- > announce("loadAutoSaveBuild() - invalid save (" @ %path @ ")");
- 123d180
- <
- 129c186
- < serverDirectSaveFileLoad(%path, 3, "", 1);
- ---
- > serverDirectSaveFileLoad(%path, 3, "", $Pref::Server::AS::LoadOwnership);
- 134,139c191,192
- < function loadAutoSaveBuild(%name)
- < {
- < %path = $Server::AS::dir @ %name @ ".bls";
- < if(!isFile(%path))
- < {
- < announce("loadAutoSaveBuild() - invalid save (" @ %path @ ")");
- ---
- > function scheduleNextSave(%diff) {
- > if($Pref::Server::AS::SavingInterval <= 0) {
- 143,151c196,202
- < cancel($Server_AS_schedule);
- < //Put it as a temp file in case they have to reload it
- < WriteFromToFile(%path, "base/server/temp/temp.bls");
- <
- < %quotaObj = getCurrentQuotaObject();
- < clearCurrentQuotaObject();
- < serverDirectSaveFileLoad(%path, 3, "", 1);
- < if(isObject(%quotaObj))
- < setCurrentQuotaObject(%quotaObj);
- ---
- > %next_time = mFloor($Pref::Server::AS::SavingInterval * 60000 - %diff);
- > if(%next_time < 60000)
- > %next_time = 60000;
- >
- > if(!isEventPending($Server_AS_schedule)) {
- > $Server_AS_schedule = schedule(%next_time, 0, Server_AS1_begin);
- > }
- 162c213
- < if($Server::AS::saveOwnership)
- ---
- > if($Pref::Server::AS::SaveOwnership)
- 164c215
- < if($Server::AS::saveEvents)
- ---
- > if($Pref::Server::AS::SaveEvents)
- 171c222,224
- < $Server_AS_schedule = schedule($Server::AS::interval * 60 * 1000, 0, Server_AS1_begin);
- ---
- > if($Pref::Server::AS::SavingInterval > 0) {
- > $Server_AS_schedule = schedule($Pref::Server::AS::SavingInterval * 60 * 1000, 0, Server_AS1_begin);
- > }
- 177c230
- < if($Server::AS::announce)
- ---
- > if($Pref::Server::AS::Announce)
- 179,180c232,233
- < %eventMsg = ($Server::AS::saveEvents ? "\c6[\c4Events\c6]" : "");
- < %ownerMsg = ($Server::AS::saveOwnership ? "\c6[\c4Ownership\c6]" : "");
- ---
- > %eventMsg = ($Pref::Server::AS::SaveEvents ? "\c6[\c4Events\c6]" : "");
- > %ownerMsg = ($Pref::Server::AS::SaveOwnership ? "\c6[\c4Ownership\c6]" : "");
- 184c237
- < $time_beg = getSimTime();
- ---
- > $time_beg = $Sim::Time;
- 186c239
- < %dir = $Server::AS::dir;
- ---
- > %dir = $Pref::Server::AS::SaveDirectory;
- 195,198c248,253
- < %g = mainBrickGroup.getObject(%i);
- < %b = %g.getCount();
- < $Server::AS::state = "B: begin collecting groups (group "@ %g @")";
- < if(%b > 0)
- ---
- > // %g == %brickGroup
- > // %brickCount = %g.getCount()
- > %brickGroup = mainBrickGroup.getObject(%i);
- > %count = %brickGroup.getCount();
- > $Server::AS::state = "B: begin collecting groups (group "@ %brickGroup @")";
- > if(%count > 0)
- 200,201c255,256
- < %g.Server_AS_stop = %b;
- < $Server::AS_groups::group[$Server::AS_groups::group_count] = %g;
- ---
- > %brickGroup.Server_AS_stop = %count;
- > $Server::AS_groups::group[$Server::AS_groups::group_count] = %brickGroup;
- 208,209c263
- < if(isObject($Server::AS1::FO))
- < {
- ---
- > if(isObject($Server::AS1::FO)) {
- 211c265,266
- < $Server::AS1::FO.delete();
- ---
- > } else {
- > $Server::AS1::FO = new FileObject();
- 214d268
- < $Server::AS1::FO = new FileObject();
- 226,229d279
- < $Server::AS1::FO.delete();
- <
- < if($Server::AS::interval < 5)
- < $Server::AS::interval = 1;
- 231,232c281
- < if($Server::AS::interval > 16)
- < $Server::AS::interval = 16;
- ---
- > %diff = $Sim::Time - $time_beg;
- 234,236c283
- < %diff = (getSimTime() - $time_beg);
- <
- < if($Server::AS::announce)
- ---
- > if($Pref::Server::AS::Announce)
- 242,247c289
- < %next_time = 60 * 1000 - %diff;
- < %next_time = $Server::AS::interval * 60 * 1000 - %diff;
- < if(%next_time < 60000)
- < %next_time = $Server::AS::interval * 60 * 1000;
- <
- < $Server_AS_schedule = schedule(%next_time, 0, Server_AS1_begin);
- ---
- > scheduleNextSave(%diff*1000);
- 251c293
- < function Server_AS1_nextGroup(%f)
- ---
- > function Server_AS1_nextGroup()
- 252a295,296
- > %file = $Server::AS1::FO;
- >
- 257c301
- < return Server_AS1_end(%f);
- ---
- > return Server_AS1_end();
- 259c303
- < %g = $Server::AS_groups::group[$Server::AS_groups::cur_group];
- ---
- > %brickGroup = $Server::AS_groups::group[$Server::AS_groups::cur_group];
- 261c305
- < Server_AS1_nextBrick(%f, %g, 0);
- ---
- > Server_AS1_nextBrick(%brickGroup, 0);
- 264c308,311
- < function Server_AS1_nextBrick(%f, %g, %c)
- ---
- > // please quit using single letter variables, they don't speed things up, nor do they slow things down, it just confuses everyone
- > // - TBP
- >
- > function Server_AS1_nextBrick(%brickGroup, %current)
- 266,267c313,318
- < if(%c >= %g.getCount())
- < return Server_AS1_nextGroup(%f);
- ---
- > %file = $Server::AS1::FO;
- >
- > if(%current >= %brickGroup.getCount())
- > return Server_AS1_nextGroup();
- >
- > %brick = %brickGroup.getObject(%current);
- 269c320
- < if(%g.getObject(%c).isPlanted)
- ---
- > if(%brick.isPlanted)
- 271c322
- < %f.writeLine(%g.getObject(%c).getID());
- ---
- > %file.writeLine(%brick.getID());
- 274,281d324
- < else if(isObject(%g.getObject(%c)))
- < {
- < %del = 1;
- < for(%i=0;%i<clientgroup.getCount();%i++)
- < {
- < if(clientgroup.getObject(%i).player.tempBrick == %g.getObject(%c))
- < %del = 0;
- < }
- 283,287c326
- < if(%del) //This helps delete unwanted temp bricks that don't belong to anyone
- < %g.getObject(%c).delete();
- < }
- <
- < schedule(0, 0, Server_AS1_nextBrick, %f, %g, %c+1);
- ---
- > schedule(0, 0, Server_AS1_nextBrick, %brickGroup, %current+1);
- 290c329
- < function Server_AS1_end(%f)
- ---
- > function Server_AS1_end()
- 292,293c331
- < %f.close();
- < %f.delete();
- ---
- > $Server::AS1::FO.close();
- 304c342
- < %dir = $Server::AS::dir;
- ---
- > %dir = $Pref::Server::AS::SaveDirectory;
- 321,322c359,363
- < $Server::AS::TempA.path = %dir @ "SAVETEMP_1.bls";
- < $Server::AS::TempB.path = %dir @ "SAVETEMP_2.bls";
- ---
- > %fileA = $Server::AS::TempA;
- > %fileB = $Server::AS::TempB;
- >
- > %fileA.path = %dir @ "SAVETEMP_1.bls";
- > %fileB.path = %dir @ "SAVETEMP_2.bls";
- 324,327c365,368
- < $Server::AS::TempB.openForWrite($Server::AS::TempB.path);
- < $Server::AS::TempB.writeLine("This is a Blockland save file. You probably shouldn't modify it cause you'll mess it up.");
- < $Server::AS::TempB.writeLine("1");
- < $Server::AS::TempB.writeLine(%desc);
- ---
- > %fileB.openForWrite(%fileb.path);
- > %fileB.writeLine("This is a Blockland save file. You probably shouldn't modify it cause you'll mess it up.");
- > %fileB.writeLine("1");
- > %fileB.writeLine("Autosaved at" SPC getDateTime() SPC "on" SPC $Server::Name);
- 330c371
- < $Server::AS::TempB.writeLine(getColorIDTable(%i));
- ---
- > %fileB.writeLine(getColorIDTable(%i));
- 332c373
- < $Server::AS::TempB.writeLine("Linecount "@ $Server::AS_groups::brick_count);
- ---
- > %fileB.writeLine("Linecount "@ $Server::AS_groups::brick_count);
- 336,337c377,378
- < $Server::AS::TempA.openForRead($Server::AS::TempA.path);
- < Server_AS2_nextLine($Server::AS::TempA, $Server::AS::TempB);
- ---
- > %fileA.openForRead(%fileA.path);
- > Server_AS2_nextLine();
- 340c381
- < function Server_AS2_nextLine(%f_A, %f_B, %c)
- ---
- > function Server_AS2_nextLine(%fileA, %fileB, %c)
- 341a383,385
- > %fileA = $Server::AS::TempA;
- > %fileB = $Server::AS::TempB;
- >
- 343,344d386
- < %events = $Server::AS::saveEvents;
- < %ownership = $Server::AS::saveOwnership;
- 346c388
- < if(!%f_A.isEOF())
- ---
- > if(!%fileA.isEOF())
- 348c390
- < %brick = %f_A.readLine();
- ---
- > %brick = %fileA.readLine();
- 362c404
- < %f_B.writeLine(%brick.getDataBlock().uiName @ "\" " @ %brick.getPosition() SPC %brick.getAngleID() SPC %brick.isBasePlate() SPC %brick.getColorID()
- ---
- > %fileB.writeLine(%brick.getDataBlock().uiName @ "\" " @ %brick.getPosition() SPC %brick.getAngleID() SPC %brick.isBasePlate() SPC %brick.getColorID()
- 365,366c407,408
- < if(%ownership && !$Server::LAN)
- < %f_B.writeLine("+-OWNER " @ getBrickGroupFromObject(%brick).bl_id);
- ---
- > if($Pref::Server::AS::SaveOwnership && !$Server::LAN)
- > %fileB.writeLine("+-OWNER " @ getBrickGroupFromObject(%brick).bl_id);
- 368c410
- < if(%events)
- ---
- > if($Pref::Server::AS::SaveEvents)
- 371c413
- < %f_B.writeLine("+-NTOBJECTNAME " @ %brick.getName());
- ---
- > %fileB.writeLine("+-NTOBJECTNAME " @ %brick.getName());
- 373c415,416
- < for(%b = 0; %b < %brick.numEvents; %b++)
- ---
- > // %b = %eventNum
- > for(%eventNum = 0; %eventNum < %brick.numEvents; %eventNum++)
- 376,377c419,420
- < %targetClass = %brick.eventTargetIdx[%b] >= 0 ? getWord(getField($InputEvent_TargetListfxDTSBrick_[%brick.eventInputIdx[%b]], %brick.eventTargetIdx[%b]), 1) : "fxDtsBrick";
- < %paramList = $OutputEvent_parameterList[%targetClass, %brick.eventOutputIdx[%b]];
- ---
- > %targetClass = %brick.eventTargetIdx[%eventNum] >= 0 ? getWord(getField($InputEvent_TargetListfxDTSBrick_[%brick.eventInputIdx[%eventNum]], %brick.eventTargetIdx[%eventNum]), 1) : "fxDtsBrick";
- > %paramList = $OutputEvent_parameterList[%targetClass, %brick.eventOutputIdx[%eventNum]];
- 379c422,423
- < for(%c = 0; %c < 4; %c++)
- ---
- > // %c = %paramNum
- > for(%paramNum = 0; %paramNum < 4; %paramNum++)
- 381,384c425,429
- < if(firstWord(getField(%paramList, %c)) $= "dataBlock" && isObject(%brick.eventOutputParameter[%b, %c + 1]))
- < %params = %params TAB %brick.eventOutputParameter[%b, %c + 1];
- < else
- < %params = %params TAB %brick.eventOutputParameter[%b, %c + 1];
- ---
- > if(%params $= "") {
- > %params = %brick.eventOutputParameter[%eventNum, %paramNum + 1];
- > } else {
- > %params = %params TAB %brick.eventOutputParameter[%eventNum, %paramNum + 1];
- > }
- 386,387c431,432
- < %f_B.writeLine("+-EVENT" TAB %b TAB %brick.eventEnabled[%b] TAB %brick.eventInput[%b] TAB %brick.eventDelay[%b] TAB %brick.eventTarget[%b]
- < TAB %brick.eventNT[%b] TAB %brick.eventOutput[%b] @ %params);
- ---
- > %fileB.writeLine("+-EVENT" TAB %eventNum TAB %brick.eventEnabled[%eventNum] TAB %brick.eventInput[%eventNum] TAB %brick.eventDelay[%eventNum] TAB %brick.eventTarget[%eventNum]
- > TAB %brick.eventNT[%eventNum] TAB %brick.eventOutput[%eventNum] TAB %params);
- 392c437
- < %f_B.writeLine("+-EMITTER " @ %brick.emitter.emitter.uiName @ "\" " @ %brick.emitterDirection);
- ---
- > %fileB.writeLine("+-EMITTER " @ %brick.emitter.emitter.uiName @ "\" " @ %brick.emitterDirection);
- 395c440
- < %f_B.writeLine("+-LIGHT " @ %brick.getLightID().getDataBlock().uiName @ "\" "); // Not sure if something else comes after the name
- ---
- > %fileB.writeLine("+-LIGHT " @ %brick.getLightID().getDataBlock().uiName @ "\" "); // Not sure if something else comes after the name
- 398c443
- < %f_B.writeLine("+-ITEM " @ %brick.item.getDataBlock().uiName @ "\" " @ %brick.itemPosition SPC %brick.itemDirection SPC %brick.itemRespawnTime);
- ---
- > %fileB.writeLine("+-ITEM " @ %brick.item.getDataBlock().uiName @ "\" " @ %brick.itemPosition SPC %brick.itemDirection SPC %brick.itemRespawnTime);
- 401c446
- < %f_B.writeLine("+-AUDIOEMITTER " @ %brick.audioEmitter.getProfileID().uiName @ "\" "); // Not sure if something else comes after the name
- ---
- > %fileB.writeLine("+-AUDIOEMITTER " @ %brick.audioEmitter.getProfileID().uiName @ "\" "); // Not sure if something else comes after the name
- 404c449
- < %f_B.writeLine("+-VEHICLE " @ %brick.vehicleSpawnMarker.uiName @ "\" " @ %brick.reColorVehicle);
- ---
- > %fileB.writeLine("+-VEHICLE " @ %brick.vehicleSpawnMarker.uiName @ "\" " @ %brick.reColorVehicle);
- 407c452
- < return schedule(0, 0, Server_AS2_nextLine, %f_A, %f_B, %c);
- ---
- > return schedule(0, 0, Server_AS2_nextLine, %c);
- 414c459
- < Server_AS2_end(%f_A, %f_B);
- ---
- > Server_AS2_end();
- 418c463
- < function Server_AS2_end(%f_A, %f_B)
- ---
- > function Server_AS2_end()
- 420,422c465,470
- < %f_A.close();
- < %f_B.close();
- < %dir = $Server::AS::dir;
- ---
- > %fileA = $Server::AS::TempA;
- > %fileB = $Server::AS::TempB;
- >
- > %fileA.close();
- > %fileB.close();
- > %dir = $Pref::Server::AS::SaveDirectory;
- 427,439c475,487
- < %save_time = mFloatLength(getSubStr(getWord(getDateTime(), 1), 0, 2), 0);
- < %s = "AM";
- < %timeS = %save_time;
- < if(%timeS == 0)
- < %timeS = 1;
- < if(%save_time >= 12)
- < {
- < %timeS = %save_time - 12;
- < %s = "PM";
- < if(%timeS == 12)
- < {
- < %timeS = 12;
- < %s = "AM";
- ---
- > %timeString = strReplace(getWord(%date, 1), ":", ".");
- > if($Pref::Server::AS::Use12HourTime) {
- > %hour = mFloatLength(getSubStr(getWord(getDateTime(), 1), 0, 2), 0);
- > // i just dropped your original 24h --> 12h script, i was essentially rewriting it
- > // - TBP
- > if(%hour < 12) {
- > %suffix = "AM";
- > }
- > if(%hour >= 12) {
- > %suffix = "PM";
- > if(%hour > 12) {
- > %hour -= 12;
- > }
- 440a489
- > %timeString = %hour @ strReplace(getSubStr(getWord(%date, 1), 2, strLen(%date)), ":", ".") @ %suffix;
- 442d490
- < %timeS = %timeS @ strReplace(getSubStr(getWord(getDateTime(), 1), 2, 3), ":", ".") @ %s;
- 444,447c492,498
- < $Server::AS::RelatedBrickCount = 0;
- < if($Server::AS::Pref["LastBrickCount"] == $Server::AS_groups::brick_count && $Server::AS::Pref["LastEventCount"] == $Server::AS_groups::event_count)
- < $Server::AS::RelatedBrickCount = 1;
- < else
- ---
- > %countMismatch = 0;
- > if($Pref::Server::AS::LastBrickCount == $Server::AS_groups::brick_count)
- > %countMismatch = 1;
- > if($Pref::Server::AS::SaveEvents && $Pref::Server::AS::LastEventCount != $Server::AS_groups::event_count)
- > %countMismatch = 0;
- >
- > if(!%countMismatch)
- 449,450c500,501
- < $Server::AS::Pref["LastEventCount"] = $Server::AS_groups::event_count;
- < $Server::AS::Pref["LastBrickCount"] = $Server::AS_groups::brick_count;
- ---
- > $Pref::Server::AS::LastEventCount = $Server::AS_groups::event_count;
- > $Pref::Server::AS::LastBrickCount = $Server::AS_groups::brick_count;
- 453c504
- < if(!$Server::AS::RelatedBrickCount && !$Server::AS::SaveRelatedBrickcount)
- ---
- > if(!%countMismatch && !$Pref::Server::AS::SaveEvenIfSame)
- 455,457c506,508
- < %direc = %dir @ "Autosave " @ getWord(%date, 0) @ " at " @ %timeS @ ".bls";
- < if(isFile(%direc)) //Overwrite it, just delete it for sure
- < fileDelete(%direc);
- ---
- > %filename = %dir @ "Autosave " @ getWord(%date, 0) @ " at " @ %timeString @ ".bls";
- > if(isFile(%filename)) //Overwrite it, just delete it for sure
- > fileDelete(%filename);
- 459c510
- < fileCopy(%f_B.path, %direc);
- ---
- > fileCopy(%fileB.path, %filename);
- 461c512
- < else if($Server::AS::SaveRelatedBrickcount)
- ---
- > else if($Pref::Server::AS::SaveEvenIfSame)
- 463,465c514,516
- < %direc = %dir @ "Autosave " @ getWord(%date, 0) @ " at " @ %timeS @ ".bls";
- < if(isFile(%direc)) //Overwrite it, just delete it for sure
- < fileDelete(%direc);
- ---
- > %filename = %dir @ "Autosave " @ getWord(%date, 0) @ " at " @ %timeString @ ".bls";
- > if(isFile(%filename)) //Overwrite it, just delete it for sure
- > fileDelete(%filename);
- 467c518
- < fileCopy(%f_B.path, %direc);
- ---
- > fileCopy(%fileB.path, %filename);
- 470,471c521,523
- < if($Server::AS::overwriteSave)
- < fileCopy(%f_B.path, "base/server/temp/temp.bls");
- ---
- > // so far this is the only thing i'm happy you did, viso
- > if($Pref::Server::AS::AllowOverwriting)
- > fileCopy(%fileB.path, "base/server/temp/temp.bls");
- 473,474c525,526
- < fileDelete(%f_A.path);
- < fileDelete(%f_B.path);
- ---
- > fileDelete(%fileA.path);
- > fileDelete(%fileB.path);
- 476,477c528,529
- < %f_A.delete();
- < %f_B.delete();
- ---
- > %fileA.delete();
- > %fileB.delete();
- 481,493c533,544
- < if($Server::AS::interval < 5)
- < $Server::AS::interval = 1;
- <
- < if($Server::AS::interval > 16)
- < $Server::AS::interval = 16;
- <
- < %diff = (getSimTime() - $time_beg);
- < %time = %diff / 1000;
- < %msg = "in \c6"@ mFloatLength(%time, 2) @" \c5second" @ (%time == 1 ? "" : "s");
- < if(%time < 1)
- < %msg = "\c6instantly";
- <
- < %bGroups = $Server::AS_groups::cur_group;
- ---
- > %diff = $Sim::Time - $time_beg;
- > %msg = "in \c5"@ getTimeString(mFloatLength(%diff, 2));
- > // not really instantly
- > // if(%time < 1)
- > // %msg = "\c6instantly";
- >
- > %brickGroups = $Server::AS_groups::cur_group;
- >
- > if(!%countMismatch && !$Pref::Server::AS::SaveEvenIfSame)
- > $Pref::Server::AS::LastAutoSave = fileBase(%filename);
- > else if($Pref::Server::AS::SaveEvenIfSame)
- > $Pref::Server::AS::LastAutoSave = fileBase(%filename);
- 495,500c546
- < if(!$Server::AS::RelatedBrickCount && !$Server::AS::SaveRelatedBrickcount)
- < $Server::AS::Pref["LastAutoSave"] = fileBase(%direc);
- < else if($Server::AS::SaveRelatedBrickcount)
- < $Server::AS::Pref["LastAutoSave"] = fileBase(%direc);
- <
- < if($Server::AS::announce)
- ---
- > if($Pref::Server::AS::Announce)
- 502c548
- < if($Server::AS::RelatedBrickCount && !$Server::AS::SaveRelatedBrickcount)
- ---
- > if(%countMismatch && !$Pref::Server::AS::SaveEvenIfSame) {
- 503a550
- > }
- 506,507c553,554
- < if($Server::AS::announceSaveName)
- < %saveMsg = " Saved as \c6" @ $Server::AS::Pref["LastAutoSave"] @ "\c5.";
- ---
- > if($Pref::Server::AS::AnnounceSaveName)
- > %saveMsg = " Saved as \c6" @ $Pref::Server::AS::LastAutoSave @ "\c5.";
- 512c559
- < if($Server::AS::report)
- ---
- > if($Pref::Server::AS::DetailedReport)
- 514c561
- < " \c5and \c6" @ %bGroups @ " group" @ (%bGroups == 1 ? "" : "s") @ " \c5have been saved.");
- ---
- > " \c5and \c6" @ %brickGroups @ " group" @ (%brickGroups == 1 ? "" : "s") @ " \c5have been saved.");
- 518c565
- < if($Server::AS::RelatedBrickCount && !$Server::AS::SaveRelatedBrickcount)
- ---
- > if(%countMismatch && !$Pref::Server::AS::SaveEvenIfSame)
- 521c568
- < echo("[AutoSaver] - Autosaved " @ $Server::AS_groups::brick_count @ " bricks " @ %msg @ ". Saved as " @ $Server::AS::Pref["LastAutoSave"] @ ".");
- ---
- > echo("[AutoSaver] - Autosaved " @ $Server::AS_groups::brick_count @ " bricks " @ %msg @ ". Saved as " @ $Pref::Server::AS::LastAutoSave @ ".");
- 523c570
- < if($Server::AS::report)
- ---
- > if($Pref::Server::AS::DetailedReport)
- 525c572
- < if(!$Server::AS::RelatedBrickCount)
- ---
- > if(!%countMismatch)
- 527c574
- < " and " @ %bGroups @ " group" @ (%bGroups == 1 ? "" : "s") @ ".");
- ---
- > " and " @ %brickGroups @ " group" @ (%brickGroups == 1 ? "" : "s") @ ".");
- 530c577,578
- < export("$Server::AS::Pref*", "config/server/AutoSaver.cs");
- ---
- > // since you're so paranoid
- > export("$Pref::Server::AS*", "config/server/AutoSaver.prefs.cs");
- 532,535c580
- < %next_time = 60 * 1000 - %diff;
- < %next_time = $Server::AS::interval * 60 * 1000 - %diff;
- < if(%next_time < 60000)
- < %next_time = $Server::AS::interval * 60 * 1000;
- ---
- > scheduleNextSave(%diff*1000);
- 537c582
- < $Server_AS_schedule = schedule(%next_time, 0, Server_AS1_begin);
- ---
- > discoverFile(%filename);
- 540,541c585,593
- < cancel($Server_AS_schedule);
- < $Server_AS_schedule = schedule($Server::AS::interval * 60 * 1000, 0, Server_AS1_begin);
- \ No newline at end of file
- ---
- > scheduleNextSave(0);
- >
- > package AutoSaverPackage {
- > function onServerDestroyed() {
- > $Server::AS::HasAutoLoaded = 0;
- > return parent::onServerDestroyed();
- > }
- > };
- > activatePackage(AutoSaverPackage);
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement