Fix for bug where awardEquipment:EQ_TRUMBLE while a trumble infection is in progress would innoculate the player against future trumble infections. Also added code to un-innoculate existing saved games.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1264 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2007-12-04 21:43:18 +00:00
parent ea5d5fc9e9
commit c1dd9c5b1a
4 changed files with 36 additions and 13 deletions

View File

@ -974,7 +974,7 @@
083325DC09DDBCDE00F5B8E4 /* OOColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOColor.m; sourceTree = "<group>"; };
083DB4D30A70E51E00B419B2 /* OOBrain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBrain.h; sourceTree = "<group>"; };
083DB4D40A70E51E00B419B2 /* OOBrain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBrain.m; sourceTree = "<group>"; };
0865432206B8447D000CA0AB /* Oolite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Oolite.app; sourceTree = BUILT_PRODUCTS_DIR; };
0865432206B8447D000CA0AB /* OoliteDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OoliteDev.app; sourceTree = BUILT_PRODUCTS_DIR; };
0878FD2F086EF845004CB752 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1A020E0A0D020AFB00C3F51E /* changedScriptHandlers.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = changedScriptHandlers.plist; sourceTree = "<group>"; };
@ -1605,7 +1605,7 @@
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
0865432206B8447D000CA0AB /* Oolite.app */,
0865432206B8447D000CA0AB /* OoliteDev.app */,
1A71E6F30BCE340C00CD5C13 /* libpng.a */,
);
name = Products;
@ -2756,7 +2756,7 @@
name = Oolite;
productInstallPath = "$(HOME)/Applications";
productName = Oolite;
productReference = 0865432206B8447D000CA0AB /* Oolite.app */;
productReference = 0865432206B8447D000CA0AB /* OoliteDev.app */;
productType = "com.apple.product-type.application";
};
1A71E6F20BCE340C00CD5C13 /* libpng-custom */ = {

View File

@ -500,6 +500,20 @@ static PlayerEntity *sSharedPlayer = nil;
if ([dict objectForKey:@"extra_equipment"])
{
[extra_equipment addEntriesFromDictionary:(NSDictionary *)[dict objectForKey:@"extra_equipment"]];
/* Bug workaround: extra_equipment should never contain EQ_TRUMBLE,
which is basically a magic flag passed to awardEquipment: to infect
the player. However, prior to Oolite 1.70.1, if the player had a
trumble infection and awardEquipment:EQ_TRUMBLE was called, an
EQ_TRUMBLE would be added to the equipment list. Subsequent calls
to awardEquipment:EQ_TRUMBLE would exit early because there was an
EQ_TRUMBLE in the equipment list. as a result, it would no longer
be possible to infect the player after the current infection ended.
The bug is fixed in 1.70.1. The following line is to fix old saved
games which had been "corrupted" by the bug.
-- Ahruman 2007-12-04
*/
[extra_equipment removeObjectForKey:@"EQ_TRUMBLE"];
}
// bools (mostly deprecated by use of the extra_equipment dictionary, keep for compatibility)
@ -5712,9 +5726,18 @@ static int last_outfitting_index;
[extra_equipment removeObjectForKey:damaged_eq_key];
// deal with trumbles..
if ([eq_key isEqual:@"EQ_TRUMBLE"] && (trumbleCount < 1))
if ([eq_key isEqual:@"EQ_TRUMBLE"])
{
/* Bug fix: must return here if eq_key == @"EQ_TRUMBLE", even if
trumbleCount >= 1. Otherwise, the player becomes immune to
trumbles. See comment in -setCommanderDataFromDictionary: for more
details.
-- Ahruman 2008-12-04
*/
if (trumbleCount < 1)
{
[self addTrumble:trumble[ranrot_rand() % PLAYER_MAX_TRUMBLES]]; // first one!
}
return;
}

View File

@ -1276,8 +1276,8 @@ static int scriptRandomSeed = -1; // ensure proper random function
return;
}
roleString = (NSString *)[tokens objectAtIndex:0];
numberString = (NSString *)[tokens objectAtIndex:1];
roleString = [tokens objectAtIndex:0];
numberString = [tokens objectAtIndex:1];
int number = [numberString intValue];
if (number < 0)