Improved handling of non-existent worlds.
This commit is contained in:
parent
5bb3420514
commit
07ee86e50f
@ -43,6 +43,24 @@
|
||||
[quickItem removeAllObjects];
|
||||
[inventoryItem removeAllObjects];
|
||||
|
||||
// Reload data here because we have just invalidated all of the items used in the outline view.
|
||||
[outlineView reloadData];
|
||||
|
||||
|
||||
[self willChangeValueForKey:@"worldTime"];
|
||||
[level release];
|
||||
level = nil;
|
||||
[inventory release];
|
||||
inventory = nil;
|
||||
[self didChangeValueForKey:@"worldTime"];
|
||||
|
||||
|
||||
if (![IJMinecraftLevel worldExistsAtIndex:worldIndex])
|
||||
{
|
||||
NSBeginCriticalAlertSheet(@"No world exists in that slot.", @"Dismiss", nil, nil, self.window, nil, nil, nil, nil, @"Please create a new single player world in this slot using Minecraft and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
sessionLockValue = [IJMinecraftLevel writeToSessionLockAtIndex:worldIndex];
|
||||
if (![IJMinecraftLevel checkSessionLockAtIndex:worldIndex value:sessionLockValue])
|
||||
{
|
||||
@ -64,7 +82,6 @@
|
||||
|
||||
[self willChangeValueForKey:@"worldTime"];
|
||||
|
||||
[level release];
|
||||
level = [[IJMinecraftLevel nbtContainerWithData:fileData] retain];
|
||||
inventory = [[level inventory] retain];
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
+ (NSString *)pathForLevelDatAtIndex:(int)worldIndex;
|
||||
+ (NSString *)pathForSessionLockAtIndex:(int)worldIndex;
|
||||
|
||||
+ (BOOL)worldExistsAtIndex:(int)worldIndex;
|
||||
|
||||
+ (int64_t)writeToSessionLockAtIndex:(int)worldIndex;
|
||||
+ (BOOL)checkSessionLockAtIndex:(int)worldIndex value:(int64_t)checkValue;
|
||||
|
||||
|
||||
@ -96,7 +96,10 @@
|
||||
return [[[self class] pathForWorldAtIndex:worldIndex] stringByAppendingPathComponent:@"session.lock"];
|
||||
}
|
||||
|
||||
|
||||
+ (BOOL)worldExistsAtIndex:(int)worldIndex
|
||||
{
|
||||
return [[NSFileManager defaultManager] fileExistsAtPath:[[self class] pathForLevelDatAtIndex:worldIndex]];
|
||||
}
|
||||
|
||||
+ (NSData *)dataWithInt64:(int64_t)v
|
||||
{
|
||||
@ -138,7 +141,7 @@
|
||||
if (!data)
|
||||
{
|
||||
NSLog(@"Failed to read session lock at %@", path);
|
||||
return;
|
||||
return NO;
|
||||
}
|
||||
|
||||
int64_t milliseconds = [IJMinecraftLevel int64FromData:data];
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="13"/>
|
||||
<integer value="3"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@ -39,7 +39,7 @@
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="416152146">
|
||||
<int key="NSWindowStyleMask">27</int>
|
||||
<int key="NSWindowStyleMask">283</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{577, 347}, {249, 286}}</string>
|
||||
<int key="NSWTFlags">-1535637504</int>
|
||||
@ -175,7 +175,7 @@
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor" id="261073037">
|
||||
<object class="NSColor" key="NSTextColor" id="875174255">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">headerTextColor</string>
|
||||
@ -203,7 +203,7 @@
|
||||
<bool key="NSIsResizeable">YES</bool>
|
||||
<reference key="NSTableView" ref="69945491"/>
|
||||
</object>
|
||||
<object class="NSTableColumn" id="158143353">
|
||||
<object class="NSTableColumn" id="808120077">
|
||||
<string key="NSIdentifier">name</string>
|
||||
<double key="NSWidth">191</double>
|
||||
<double key="NSMinWidth">10</double>
|
||||
@ -219,9 +219,9 @@
|
||||
<string key="NSColorName">headerColor</string>
|
||||
<reference key="NSColor" ref="837009434"/>
|
||||
</object>
|
||||
<reference key="NSTextColor" ref="261073037"/>
|
||||
<reference key="NSTextColor" ref="875174255"/>
|
||||
</object>
|
||||
<object class="NSTextFieldCell" key="NSDataCell" id="529701029">
|
||||
<object class="NSTextFieldCell" key="NSDataCell" id="1045662122">
|
||||
<int key="NSCellFlags">337772096</int>
|
||||
<int key="NSCellFlags2">2048</int>
|
||||
<string key="NSContents">Text Cell</string>
|
||||
@ -474,7 +474,7 @@
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="457520173"/>
|
||||
<reference ref="158143353"/>
|
||||
<reference ref="808120077"/>
|
||||
</object>
|
||||
<reference key="parent" ref="1009868452"/>
|
||||
</object>
|
||||
@ -494,17 +494,17 @@
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">26</int>
|
||||
<reference key="object" ref="158143353"/>
|
||||
<reference key="object" ref="808120077"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="529701029"/>
|
||||
<reference ref="1045662122"/>
|
||||
</object>
|
||||
<reference key="parent" ref="69945491"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">27</int>
|
||||
<reference key="object" ref="529701029"/>
|
||||
<reference key="parent" ref="158143353"/>
|
||||
<reference key="object" ref="1045662122"/>
|
||||
<reference key="parent" ref="808120077"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user