Change backedup to ChangedSinceBackup and invert logic for simplicity

This commit is contained in:
UnknownShadow200 2021-10-26 22:23:00 +11:00
parent 80de760878
commit abbfb2c01b
6 changed files with 8 additions and 9 deletions

View File

@ -91,7 +91,6 @@ namespace MCGalaxy.Commands.World {
static void JoinMuseum(Player p, string formattedMuseumName, string mapName, string path) {
Level lvl = IMapImporter.GetFor(path).Read(path, formattedMuseumName, false);
lvl.MapName = mapName;
lvl.backedup = true;
lvl.IsMuseum = true;
Level.LoadMetadata(lvl);

View File

@ -343,7 +343,7 @@ namespace MCGalaxy {
if (physics > 0 && ActivatesPhysics(block)) AddCheck(PosToInt(x, y, z));
Changed = true;
backedup = false;
ChangedSinceBackup = true;
return Block.VisuallyEquals(old, block) ? ChangeResult.VisuallySame : ChangeResult.Modified;
} catch (Exception e) {

View File

@ -61,6 +61,7 @@ namespace MCGalaxy {
internal AABB[] blockAABBs = new AABB[Block.ExtendedCount];
public ushort Width, Height, Length;
/// <summary> Whether this level should be treated as a readonly museum </summary>
public bool IsMuseum;
public int ReloadThreshold {
@ -77,6 +78,7 @@ namespace MCGalaxy {
public bool Changed;
/// <summary> Whether block changes made on this level should be saved to the BlockDB and .lvl files. </summary>
public bool SaveChanges = true;
public bool ChangedSinceBackup;
/// <summary> Whether players on this level sees server-wide chat. </summary>
public bool SeesServerWideChat { get { return Config.ServerWideChat && Server.Config.ServerWideChat; } }
@ -87,7 +89,6 @@ namespace MCGalaxy {
public List<UndoPos> UndoBuffer = new List<UndoPos>();
public VolatileArray<Zone> Zones = new VolatileArray<Zone>();
public bool backedup;
public BlockDB BlockDB;
public LevelAccessController VisitAccess, BuildAccess;

View File

@ -253,7 +253,7 @@ namespace MCGalaxy {
/// <param name="backup"> Specific name of the backup, or "" to automatically pick a name. </param>
/// <returns> The name of the backup, or null if no backup was saved. </returns>
public string Backup(bool force = false, string backup = "") {
if (!backedup || force) {
if (ChangedSinceBackup || force) {
string backupPath = LevelInfo.BackupBasePath(name);
if (!Directory.Exists(backupPath)) Directory.CreateDirectory(backupPath);
int next = LevelInfo.LatestBackup(name) + 1;
@ -283,7 +283,6 @@ namespace MCGalaxy {
try {
Level lvl = IMapImporter.GetFor(path).Read(path, name, true);
lvl.backedup = true;
LoadMetadata(lvl);
BotsFile.Load(lvl);

View File

@ -417,7 +417,7 @@ namespace MCGalaxy {
lvl.SaveChanges = false;
}
res.backedup = true;
res.ChangedSinceBackup = false;
Level.LoadMetadata(res);
BotsFile.Load(res);

View File

@ -173,7 +173,7 @@ namespace MCGalaxy.Modules.Relay.Discord
// 429 errors simply require retrying after sleeping for a bit
if (Handle429(ex)) continue;
// If unable to reach Discord, don't spam error logs
// If unable to reach Discord at all, don't spam error logs
if (ex.Status == WebExceptionStatus.NameResolutionFailure) {
Logger.Log(LogType.Warning, "Error sending request to Discord API - " + ex.Message);
return;