Cocoa Port: In the cheat system code, remove Obj-C dot syntax for object properties to avoid ambiguity with features from other languages.

This commit is contained in:
rogerman 2023-06-21 14:53:49 -07:00
parent b468aee01a
commit aeefd86f57
2 changed files with 171 additions and 149 deletions

View File

@ -1,6 +1,6 @@
/* /*
Copyright (C) 2011 Roger Manuel Copyright (C) 2011 Roger Manuel
Copyright (C) 2011-2015 DeSmuME team Copyright (C) 2011-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -23,6 +23,28 @@ class CHEATS;
class CHEATS_LIST; class CHEATS_LIST;
class CHEATSEARCH; class CHEATSEARCH;
enum CheatType
{
CheatType_Internal = 0,
CheatType_ActionReplay = 1,
CheatType_CodeBreaker = 2
};
enum CheatFreezeType
{
CheatFreezeType_Normal = 0,
CheatFreezeType_CanDecrease = 1,
CheatFreezeType_CanIncrease = 2
};
enum CheatSystemError
{
CheatSystemError_NoError = 0,
CheatSystemError_FileOpenFailed = 1,
CheatSystemError_FileFormatInvalid = 2,
CheatSystemError_CheatNotFound = 3,
CheatSystemError_ExportError = 4
};
/******************************************************************************************** /********************************************************************************************
CocoaDSCheatItem - OBJECTIVE-C CLASS CocoaDSCheatItem - OBJECTIVE-C CLASS

View File

@ -73,14 +73,14 @@ static NSImage *iconCodeBreaker = nil;
data = internalData; data = internalData;
self.enabled = NO; [self setEnabled:NO];
self.cheatType = CHEAT_TYPE_INTERNAL; [self setCheatType:CHEAT_TYPE_INTERNAL];
self.freezeType = 0; [self setFreezeType:CheatFreezeType_Normal];
self.description = @""; [self setDescription:@""];
self.code = @""; [self setCode:@""];
self.memAddress = 0x00000000; [self setMemAddress:0x00000000];
self.bytes = 1; [self setBytes:1];
self.value = 0; [self setValue:0];
} }
else else
{ {
@ -136,7 +136,7 @@ static NSImage *iconCodeBreaker = nil;
pthread_mutex_lock(&mutexData); pthread_mutex_lock(&mutexData);
CHEATS_LIST *thisData = data; CHEATS_LIST *thisData = data;
CHEATS_LIST *workingData = workingCopy.data; CHEATS_LIST *workingData = [workingCopy data];
*workingData = *thisData; *workingData = *thisData;
pthread_mutex_unlock(&mutexData); pthread_mutex_unlock(&mutexData);
@ -178,7 +178,7 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.enabled = theState; [workingCopy setEnabled:theState];
} }
} }
@ -200,7 +200,7 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.description = desc; [workingCopy setDescription:desc];
} }
} }
@ -221,18 +221,18 @@ static NSImage *iconCodeBreaker = nil;
switch (theType) switch (theType)
{ {
case CHEAT_TYPE_INTERNAL: case CHEAT_TYPE_INTERNAL:
self.cheatTypeIcon = iconInternalCheat; [self setCheatTypeIcon:iconInternalCheat];
self.isSupportedCheatType = YES; [self setIsSupportedCheatType:YES];
break; break;
case CHEAT_TYPE_ACTION_REPLAY: case CHEAT_TYPE_ACTION_REPLAY:
self.cheatTypeIcon = iconActionReplay; [self setCheatTypeIcon:iconActionReplay];
self.isSupportedCheatType = YES; [self setIsSupportedCheatType:YES];
break; break;
case CHEAT_TYPE_CODE_BREAKER: case CHEAT_TYPE_CODE_BREAKER:
self.cheatTypeIcon = iconCodeBreaker; [self setCheatTypeIcon:iconCodeBreaker];
self.isSupportedCheatType = NO; [self setIsSupportedCheatType:NO];
break; break;
default: default:
@ -241,7 +241,7 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.cheatType = theType; [workingCopy setCheatType:theType];
} }
} }
@ -254,7 +254,7 @@ static NSImage *iconCodeBreaker = nil;
{ {
NSImage *theIcon = nil; NSImage *theIcon = nil;
switch (self.cheatType) switch ([self cheatType])
{ {
case CHEAT_TYPE_INTERNAL: case CHEAT_TYPE_INTERNAL:
theIcon = iconInternalCheat; theIcon = iconInternalCheat;
@ -279,7 +279,7 @@ static NSImage *iconCodeBreaker = nil;
{ {
BOOL isSupported = YES; BOOL isSupported = YES;
switch (self.cheatType) switch ([self cheatType])
{ {
case CHEAT_TYPE_INTERNAL: case CHEAT_TYPE_INTERNAL:
case CHEAT_TYPE_ACTION_REPLAY: case CHEAT_TYPE_ACTION_REPLAY:
@ -313,7 +313,7 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.freezeType = theType; [workingCopy setFreezeType:theType];
} }
} }
@ -328,7 +328,7 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.bytes = byteSize; [workingCopy setBytes:byteSize];
} }
} }
@ -347,7 +347,7 @@ static NSImage *iconCodeBreaker = nil;
NSString *codeLine = @""; NSString *codeLine = @"";
NSString *cheatCodes = @""; NSString *cheatCodes = @"";
NSUInteger numberCodes = self.codeCount; NSUInteger numberCodes = [self codeCount];
if (numberCodes > MAX_XX_CODE) if (numberCodes > MAX_XX_CODE)
{ {
return nil; return nil;
@ -378,18 +378,18 @@ static NSImage *iconCodeBreaker = nil;
free(codeCString); free(codeCString);
codeCString = NULL; codeCString = NULL;
self.codeCount = self.codeCount; [self setCodeCount:[self codeCount]];
self.bytes = self.bytes; [self setBytes:[self bytes]];
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.code = theCode; [workingCopy setCode:theCode];
} }
} }
- (UInt32) memAddress - (UInt32) memAddress
{ {
if (self.cheatType != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type if ([self cheatType] != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type
{ {
return 0; return 0;
} }
@ -399,7 +399,7 @@ static NSImage *iconCodeBreaker = nil;
- (void) setMemAddress:(UInt32)theAddress - (void) setMemAddress:(UInt32)theAddress
{ {
if (self.cheatType != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type if ([self cheatType] != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type
{ {
return; return;
} }
@ -410,45 +410,45 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.memAddress = theAddress; [workingCopy setMemAddress:theAddress];
} }
} }
- (NSString *) memAddressString - (NSString *) memAddressString
{ {
return [NSString stringWithFormat:@"0x%08X", (unsigned int)self.memAddress]; return [NSString stringWithFormat:@"0x%08X", (unsigned int)[self memAddress]];
} }
- (void) setMemAddressString:(NSString *)addressString - (void) setMemAddressString:(NSString *)addressString
{ {
if (self.cheatType != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type if ([self cheatType] != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type
{ {
return; return;
} }
u32 address = 0x00000000; u32 address = 0x00000000;
[[NSScanner scannerWithString:addressString] scanHexInt:&address]; [[NSScanner scannerWithString:addressString] scanHexInt:&address];
self.memAddress = address; [self setMemAddress:address];
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.memAddressString = addressString; [workingCopy setMemAddressString:addressString];
} }
} }
- (NSString *) memAddressSixDigitString - (NSString *) memAddressSixDigitString
{ {
return [NSString stringWithFormat:@"%06X", (unsigned int)(self.memAddress & 0x00FFFFFF)]; return [NSString stringWithFormat:@"%06X", (unsigned int)([self memAddress] & 0x00FFFFFF)];
} }
- (void) setMemAddressSixDigitString:(NSString *)addressString - (void) setMemAddressSixDigitString:(NSString *)addressString
{ {
self.memAddressString = addressString; [self setMemAddressString:addressString];
} }
- (SInt64) value - (SInt64) value
{ {
if (self.cheatType != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type if ([self cheatType] != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type
{ {
return 0; return 0;
} }
@ -458,7 +458,7 @@ static NSImage *iconCodeBreaker = nil;
- (void) setValue:(SInt64)theValue - (void) setValue:(SInt64)theValue
{ {
if (self.cheatType != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type if ([self cheatType] != CHEAT_TYPE_INTERNAL) // Needs to be the Internal Cheat type
{ {
return; return;
} }
@ -467,26 +467,26 @@ static NSImage *iconCodeBreaker = nil;
if (workingCopy != nil) if (workingCopy != nil)
{ {
workingCopy.value = theValue; [workingCopy setValue:theValue];
} }
} }
- (void) update - (void) update
{ {
self.enabled = self.enabled; [self setEnabled:[self enabled]];
self.description = self.description; [self setDescription:[self description]];
self.cheatType = self.cheatType; [self setCheatType:[self cheatType]];
self.freezeType = self.freezeType; [self setFreezeType:[self freezeType]];
if (self.cheatType == CHEAT_TYPE_INTERNAL) if ([self cheatType] == CHEAT_TYPE_INTERNAL)
{ {
self.bytes = self.bytes; [self setBytes:[self bytes]];
self.memAddress = self.memAddress; [self setMemAddress:[self memAddress]];
self.value = self.value; [self setValue:[self value]];
} }
else else
{ {
self.code = self.code; [self setCode:[self code]];
} }
} }
@ -499,9 +499,9 @@ static NSImage *iconCodeBreaker = nil;
[workingCopy release]; [workingCopy release];
} }
newWorkingCopy = [[CocoaDSCheatItem alloc] initWithCheatData:self.data]; newWorkingCopy = [[CocoaDSCheatItem alloc] initWithCheatData:[self data]];
[newWorkingCopy retainData]; [newWorkingCopy retainData];
newWorkingCopy.parent = self; [newWorkingCopy setParent:self];
workingCopy = newWorkingCopy; workingCopy = newWorkingCopy;
return newWorkingCopy; return newWorkingCopy;
@ -520,8 +520,8 @@ static NSImage *iconCodeBreaker = nil;
return; return;
} }
CHEATS_LIST *thisData = self.data; CHEATS_LIST *thisData = [self data];
CHEATS_LIST *workingData = workingCopy.data; CHEATS_LIST *workingData = [workingCopy data];
pthread_mutex_lock(&mutexData); pthread_mutex_lock(&mutexData);
*thisData = *workingData; *thisData = *workingData;
@ -537,8 +537,8 @@ static NSImage *iconCodeBreaker = nil;
return; return;
} }
CHEATS_LIST *thisData = self.data; CHEATS_LIST *thisData = [self data];
CHEATS_LIST *parentData = parent.data; CHEATS_LIST *parentData = [parent data];
pthread_mutex_lock(&mutexData); pthread_mutex_lock(&mutexData);
*parentData = *thisData; *parentData = *thisData;
@ -557,45 +557,45 @@ static NSImage *iconCodeBreaker = nil;
NSNumber *enabledNumber = (NSNumber *)[dataDict valueForKey:@"enabled"]; NSNumber *enabledNumber = (NSNumber *)[dataDict valueForKey:@"enabled"];
if (enabledNumber != nil) if (enabledNumber != nil)
{ {
self.enabled = [enabledNumber boolValue]; [self setEnabled:[enabledNumber boolValue]];
} }
NSString *descriptionString = (NSString *)[dataDict valueForKey:@"description"]; NSString *descriptionString = (NSString *)[dataDict valueForKey:@"description"];
if (descriptionString != nil) if (descriptionString != nil)
{ {
self.description = descriptionString; [self setDescription:descriptionString];
} }
NSNumber *freezeTypeNumber = (NSNumber *)[dataDict valueForKey:@"freezeType"]; NSNumber *freezeTypeNumber = (NSNumber *)[dataDict valueForKey:@"freezeType"];
if (freezeTypeNumber != nil) if (freezeTypeNumber != nil)
{ {
self.freezeType = [freezeTypeNumber integerValue]; [self setFreezeType:[freezeTypeNumber integerValue]];
} }
NSNumber *cheatTypeNumber = (NSNumber *)[dataDict valueForKey:@"cheatType"]; NSNumber *cheatTypeNumber = (NSNumber *)[dataDict valueForKey:@"cheatType"];
if (cheatTypeNumber != nil) if (cheatTypeNumber != nil)
{ {
self.cheatType = [cheatTypeNumber integerValue]; [self setCheatType:[cheatTypeNumber integerValue]];
} }
if (self.cheatType == CHEAT_TYPE_INTERNAL) if ([self cheatType] == CHEAT_TYPE_INTERNAL)
{ {
NSNumber *bytesNumber = (NSNumber *)[dataDict valueForKey:@"bytes"]; NSNumber *bytesNumber = (NSNumber *)[dataDict valueForKey:@"bytes"];
if (bytesNumber != nil) if (bytesNumber != nil)
{ {
self.bytes = [bytesNumber unsignedIntegerValue]; [self setBytes:[bytesNumber unsignedIntegerValue]];
} }
NSNumber *memAddressNumber = (NSNumber *)[dataDict valueForKey:@"memAddress"]; NSNumber *memAddressNumber = (NSNumber *)[dataDict valueForKey:@"memAddress"];
if (memAddressNumber != nil) if (memAddressNumber != nil)
{ {
self.memAddress = (u32)[memAddressNumber unsignedIntegerValue]; [self setMemAddress:(u32)[memAddressNumber unsignedIntegerValue]];
} }
NSNumber *valueNumber = (NSNumber *)[dataDict valueForKey:@"value"]; NSNumber *valueNumber = (NSNumber *)[dataDict valueForKey:@"value"];
if (valueNumber != nil) if (valueNumber != nil)
{ {
self.value = [valueNumber integerValue]; [self setValue:[valueNumber integerValue]];
} }
} }
else else
@ -603,7 +603,7 @@ static NSImage *iconCodeBreaker = nil;
NSString *codeString = (NSString *)[dataDict valueForKey:@"code"]; NSString *codeString = (NSString *)[dataDict valueForKey:@"code"];
if (codeString != nil) if (codeString != nil)
{ {
self.code = codeString; [self setCode:codeString];
} }
} }
} }
@ -611,17 +611,17 @@ static NSImage *iconCodeBreaker = nil;
- (NSDictionary *) dataDictionary - (NSDictionary *) dataDictionary
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:self.enabled], @"enabled", [NSNumber numberWithBool:[self enabled]], @"enabled",
[NSNumber numberWithInteger:self.cheatType], @"cheatType", [NSNumber numberWithInteger:[self cheatType]], @"cheatType",
self.description, @"description", [self description], @"description",
[NSNumber numberWithInteger:self.freezeType], @"freezeType", [NSNumber numberWithInteger:[self freezeType]], @"freezeType",
[NSNumber numberWithUnsignedInteger:self.codeCount], @"codeCount", [NSNumber numberWithUnsignedInteger:[self codeCount]], @"codeCount",
[NSNumber numberWithUnsignedInteger:self.bytes], @"bytes", [NSNumber numberWithUnsignedInteger:[self bytes]], @"bytes",
[NSNumber numberWithUnsignedInt:self.memAddress], @"memAddress", [NSNumber numberWithUnsignedInt:[self memAddress]], @"memAddress",
self.memAddressString, @"memAddressString", [self memAddressString], @"memAddressString",
[NSNumber numberWithInteger:self.value], @"value", [NSNumber numberWithInteger:[self value]], @"value",
self.code, @"code", [self code], @"code",
[NSNumber numberWithBool:self.isSupportedCheatType], @"isSupportedCheatType", [NSNumber numberWithBool:[self isSupportedCheatType]], @"isSupportedCheatType",
nil]; nil];
} }
@ -735,10 +735,10 @@ static NSImage *iconCodeBreaker = nil;
- (void)dealloc - (void)dealloc
{ {
self.dbTitle = nil; [self setDbTitle:nil];
self.dbDate = nil; [self setDbDate:nil];
[list release]; [list release];
delete (CHEATS *)self.listData; delete (CHEATS *)[self listData];
cheats = NULL; cheats = NULL;
if (isUsingDummyRWlock) if (isUsingDummyRWlock)
@ -793,33 +793,33 @@ static NSImage *iconCodeBreaker = nil;
// Get the current pointer to the raw cheat list data. We will need it later // Get the current pointer to the raw cheat list data. We will need it later
// to check if the list got reallocated. // to check if the list got reallocated.
CHEATS_LIST *cheatListData = self.listData->getListPtr(); CHEATS_LIST *cheatListData = [self listData]->getListPtr();
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
const bool cheatItemEnabled = (cheatItem.enabled) ? true : false; const bool cheatItemEnabled = ([cheatItem enabled]) ? true : false;
switch (cheatItem.cheatType) switch ([cheatItem cheatType])
{ {
case CHEAT_TYPE_INTERNAL: case CHEAT_TYPE_INTERNAL:
result = self.listData->add(cheatItem.bytes - 1, cheatItem.memAddress, (u32)cheatItem.value, [cheatItem descriptionCString], cheatItemEnabled); result = [self listData]->add([cheatItem bytes] - 1, [cheatItem memAddress], (u32)[cheatItem value], [cheatItem descriptionCString], cheatItemEnabled);
break; break;
case CHEAT_TYPE_ACTION_REPLAY: case CHEAT_TYPE_ACTION_REPLAY:
{ {
char *cheatCodes = (char *)[cheatItem.code cStringUsingEncoding:NSUTF8StringEncoding]; char *cheatCodes = (char *)[[cheatItem code] cStringUsingEncoding:NSUTF8StringEncoding];
if (cheatCodes != nil) if (cheatCodes != nil)
{ {
result = self.listData->add_AR(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled); result = [self listData]->add_AR(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled);
} }
break; break;
} }
case CHEAT_TYPE_CODE_BREAKER: case CHEAT_TYPE_CODE_BREAKER:
{ {
char *cheatCodes = (char *)[cheatItem.code cStringUsingEncoding:NSUTF8StringEncoding]; char *cheatCodes = (char *)[[cheatItem code] cStringUsingEncoding:NSUTF8StringEncoding];
if (cheatCodes != nil) if (cheatCodes != nil)
{ {
result = self.listData->add_CB(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled); result = [self listData]->add_CB(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled);
} }
break; break;
} }
@ -828,28 +828,28 @@ static NSImage *iconCodeBreaker = nil;
break; break;
} }
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
if (![self.list containsObject:cheatItem]) if (![[self list] containsObject:cheatItem])
{ {
[self.list addObject:cheatItem]; [[self list] addObject:cheatItem];
} }
// Adding a new item may cause the raw list data to get reallocated, which // Adding a new item may cause the raw list data to get reallocated, which
// will break the data pointers. So check for reallocation, and if it occurs, // will break the data pointers. So check for reallocation, and if it occurs,
// reset the data pointers for each item. // reset the data pointers for each item.
if (cheatListData != self.listData->getListPtr()) if (cheatListData != [self listData]->getListPtr())
{ {
NSUInteger listCount = self.listData->getListSize(); NSUInteger listCount = [self listData]->getListSize();
for (NSUInteger i = 0; i < listCount; i++) for (NSUInteger i = 0; i < listCount; i++)
{ {
CocoaDSCheatItem *itemInList = (CocoaDSCheatItem *)[self.list objectAtIndex:i]; CocoaDSCheatItem *itemInList = (CocoaDSCheatItem *)[[self list] objectAtIndex:i];
itemInList.data = self.listData->getItemPtrAtIndex(i); [itemInList setData:[self listData]->getItemPtrAtIndex(i)];
} }
} }
else else
{ {
cheatItem.data = self.listData->getItemPtrAtIndex(self.listData->getListSize() - 1); [cheatItem setData:[self listData]->getItemPtrAtIndex([self listData]->getListSize() - 1)];
} }
return result; return result;
@ -862,26 +862,26 @@ static NSImage *iconCodeBreaker = nil;
return; return;
} }
NSUInteger selectionIndex = [self.list indexOfObject:cheatItem]; NSUInteger selectionIndex = [[self list] indexOfObject:cheatItem];
if (selectionIndex == NSNotFound) if (selectionIndex == NSNotFound)
{ {
return; return;
} }
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
self.listData->remove(selectionIndex); [self listData]->remove(selectionIndex);
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
// Removing an item from the raw cheat list data shifts all higher elements // Removing an item from the raw cheat list data shifts all higher elements
// by one, so we need to do the same. // by one, so we need to do the same.
NSUInteger listCount = self.listData->getListSize(); NSUInteger listCount = [self listData]->getListSize();
for (NSUInteger i = selectionIndex; i < listCount; i++) for (NSUInteger i = selectionIndex; i < listCount; i++)
{ {
[(CocoaDSCheatItem *)[self.list objectAtIndex:(i + 1)] setData:self.listData->getItemPtrAtIndex(i)]; [(CocoaDSCheatItem *)[[self list] objectAtIndex:(i + 1)] setData:[self listData]->getItemPtrAtIndex(i)];
} }
cheatItem.data = nil; [cheatItem setData:nil];
[self.list removeObject:cheatItem]; [[self list] removeObject:cheatItem];
} }
- (BOOL) update:(CocoaDSCheatItem *)cheatItem - (BOOL) update:(CocoaDSCheatItem *)cheatItem
@ -893,37 +893,37 @@ static NSImage *iconCodeBreaker = nil;
return result; return result;
} }
NSUInteger selectionIndex = [self.list indexOfObject:cheatItem]; NSUInteger selectionIndex = [[self list] indexOfObject:cheatItem];
if (selectionIndex == NSNotFound) if (selectionIndex == NSNotFound)
{ {
return result; return result;
} }
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
const bool cheatItemEnabled = (cheatItem.enabled) ? true : false; const bool cheatItemEnabled = ([cheatItem enabled]) ? true : false;
switch (cheatItem.cheatType) switch ([cheatItem cheatType])
{ {
case CHEAT_TYPE_INTERNAL: case CHEAT_TYPE_INTERNAL:
result = self.listData->update(cheatItem.bytes - 1, cheatItem.memAddress, (u32)cheatItem.value, [cheatItem descriptionCString], cheatItemEnabled, selectionIndex); result = [self listData]->update([cheatItem bytes] - 1, [cheatItem memAddress], (u32)[cheatItem value], [cheatItem descriptionCString], cheatItemEnabled, selectionIndex);
break; break;
case CHEAT_TYPE_ACTION_REPLAY: case CHEAT_TYPE_ACTION_REPLAY:
{ {
char *cheatCodes = (char *)[cheatItem.code cStringUsingEncoding:NSUTF8StringEncoding]; char *cheatCodes = (char *)[[cheatItem code] cStringUsingEncoding:NSUTF8StringEncoding];
if (cheatCodes != nil) if (cheatCodes != nil)
{ {
result = self.listData->update_AR(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled, selectionIndex); result = [self listData]->update_AR(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled, selectionIndex);
} }
break; break;
} }
case CHEAT_TYPE_CODE_BREAKER: case CHEAT_TYPE_CODE_BREAKER:
{ {
char *cheatCodes = (char *)[cheatItem.code cStringUsingEncoding:NSUTF8StringEncoding]; char *cheatCodes = (char *)[[cheatItem code] cStringUsingEncoding:NSUTF8StringEncoding];
if (cheatCodes != nil) if (cheatCodes != nil)
{ {
result = self.listData->update_CB(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled, selectionIndex); result = [self listData]->update_CB(cheatCodes, [cheatItem descriptionCString], cheatItemEnabled, selectionIndex);
} }
break; break;
} }
@ -932,7 +932,7 @@ static NSImage *iconCodeBreaker = nil;
break; break;
} }
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
[cheatItem update]; [cheatItem update];
@ -941,18 +941,18 @@ static NSImage *iconCodeBreaker = nil;
- (BOOL) save - (BOOL) save
{ {
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
BOOL result = self.listData->save(); BOOL result = [self listData]->save();
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
return result; return result;
} }
- (NSUInteger) activeCount - (NSUInteger) activeCount
{ {
pthread_rwlock_rdlock(self.rwlockCoreExecute); pthread_rwlock_rdlock([self rwlockCoreExecute]);
NSUInteger activeCheatsCount = self.listData->getActiveCount(); NSUInteger activeCheatsCount = [self listData]->getActiveCount();
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
return activeCheatsCount; return activeCheatsCount;
} }
@ -978,14 +978,14 @@ static NSImage *iconCodeBreaker = nil;
} }
else else
{ {
self.dbTitle = [NSString stringWithCString:(const char *)exporter->gametitle encoding:NSUTF8StringEncoding]; [self setDbTitle:[NSString stringWithCString:(const char *)exporter->gametitle encoding:NSUTF8StringEncoding]];
self.dbDate = [NSString stringWithCString:(const char *)exporter->date encoding:NSUTF8StringEncoding]; [self setDbDate:[NSString stringWithCString:(const char *)exporter->date encoding:NSUTF8StringEncoding]];
newDBList = [CocoaDSCheatManager cheatListWithItemStructArray:exporter->getCheats() count:exporter->getCheatsNum()]; newDBList = [CocoaDSCheatManager cheatListWithItemStructArray:exporter->getCheats() count:exporter->getCheatsNum()];
if (newDBList != nil) if (newDBList != nil)
{ {
for (CocoaDSCheatItem *cheatItem in newDBList) for (CocoaDSCheatItem *cheatItem in newDBList)
{ {
cheatItem.willAdd = NO; [cheatItem setWillAdd:NO];
[cheatItem retainData]; [cheatItem retainData];
} }
} }
@ -1004,19 +1004,19 @@ static NSImage *iconCodeBreaker = nil;
return; return;
} }
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
[CocoaDSCheatManager applyInternalCheatWithItem:cheatItem]; [CocoaDSCheatManager applyInternalCheatWithItem:cheatItem];
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
} }
+ (void) setMasterCheatList:(CocoaDSCheatManager *)cheatListManager + (void) setMasterCheatList:(CocoaDSCheatManager *)cheatListManager
{ {
cheats = cheatListManager.listData; cheats = [cheatListManager listData];
} }
+ (void) applyInternalCheatWithItem:(CocoaDSCheatItem *)cheatItem + (void) applyInternalCheatWithItem:(CocoaDSCheatItem *)cheatItem
{ {
[CocoaDSCheatManager applyInternalCheatWithAddress:cheatItem.memAddress value:(u32)cheatItem.value bytes:cheatItem.bytes]; [CocoaDSCheatManager applyInternalCheatWithAddress:[cheatItem memAddress] value:(u32)[cheatItem value] bytes:[cheatItem bytes]];
} }
+ (void) applyInternalCheatWithAddress:(UInt32)address value:(UInt32)value bytes:(NSUInteger)bytes + (void) applyInternalCheatWithAddress:(UInt32)address value:(UInt32)value bytes:(NSUInteger)bytes
@ -1167,12 +1167,12 @@ static NSImage *iconCodeBreaker = nil;
- (void)dealloc - (void)dealloc
{ {
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
self.listData->close(); [self listData]->close();
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
[addressList release]; [addressList release];
delete (CHEATSEARCH *)self.listData; delete (CHEATSEARCH *)[self listData];
if (isUsingDummyRWlock) if (isUsingDummyRWlock)
{ {
@ -1224,17 +1224,17 @@ static NSImage *iconCodeBreaker = nil;
{ {
byteSize--; byteSize--;
pthread_rwlock_rdlock(self.rwlockCoreExecute); pthread_rwlock_rdlock([self rwlockCoreExecute]);
listExists = (NSUInteger)self.listData->start((u8)CHEATSEARCH_SEARCHSTYLE_EXACT_VALUE, (u8)byteSize, (u8)signType); listExists = (NSUInteger)[self listData]->start((u8)CHEATSEARCH_SEARCHSTYLE_EXACT_VALUE, (u8)byteSize, (u8)signType);
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
} }
if (listExists) if (listExists)
{ {
pthread_rwlock_rdlock(self.rwlockCoreExecute); pthread_rwlock_rdlock([self rwlockCoreExecute]);
itemCount = (NSUInteger)self.listData->search((u32)value); itemCount = (NSUInteger)[self listData]->search((u32)value);
NSMutableArray *newAddressList = [[CocoaDSCheatSearch addressListWithListObject:self.listData maxItems:100] retain]; NSMutableArray *newAddressList = [[CocoaDSCheatSearch addressListWithListObject:[self listData] maxItems:100] retain];
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
[addressList release]; [addressList release];
addressList = newAddressList; addressList = newAddressList;
@ -1249,7 +1249,7 @@ static NSImage *iconCodeBreaker = nil;
- (void) runExactValueSearchOnThread:(id)object - (void) runExactValueSearchOnThread:(id)object
{ {
CocoaDSCheatSearchParams *searchParams = (CocoaDSCheatSearchParams *)object; CocoaDSCheatSearchParams *searchParams = (CocoaDSCheatSearchParams *)object;
[self runExactValueSearch:searchParams.value byteSize:searchParams.byteSize signType:searchParams.signType]; [self runExactValueSearch:[searchParams value] byteSize:[searchParams byteSize] signType:[searchParams signType]];
} }
- (NSUInteger) runComparativeSearch:(NSInteger)typeID byteSize:(UInt8)byteSize signType:(NSInteger)signType - (NSUInteger) runComparativeSearch:(NSInteger)typeID byteSize:(UInt8)byteSize signType:(NSInteger)signType
@ -1261,18 +1261,18 @@ static NSImage *iconCodeBreaker = nil;
{ {
byteSize--; byteSize--;
pthread_rwlock_rdlock(self.rwlockCoreExecute); pthread_rwlock_rdlock([self rwlockCoreExecute]);
listExists = (NSUInteger)self.listData->start((u8)CHEATSEARCH_SEARCHSTYLE_COMPARATIVE, (u8)byteSize, (u8)signType); listExists = (NSUInteger)[self listData]->start((u8)CHEATSEARCH_SEARCHSTYLE_COMPARATIVE, (u8)byteSize, (u8)signType);
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
addressList = nil; addressList = nil;
} }
else else
{ {
pthread_rwlock_rdlock(self.rwlockCoreExecute); pthread_rwlock_rdlock([self rwlockCoreExecute]);
itemCount = (NSUInteger)self.listData->search((u8)typeID); itemCount = (NSUInteger)[self listData]->search((u8)typeID);
NSMutableArray *newAddressList = [[CocoaDSCheatSearch addressListWithListObject:self.listData maxItems:100] retain]; NSMutableArray *newAddressList = [[CocoaDSCheatSearch addressListWithListObject:[self listData] maxItems:100] retain];
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
[addressList release]; [addressList release];
addressList = newAddressList; addressList = newAddressList;
@ -1291,14 +1291,14 @@ static NSImage *iconCodeBreaker = nil;
- (void) runComparativeSearchOnThread:(id)object - (void) runComparativeSearchOnThread:(id)object
{ {
CocoaDSCheatSearchParams *searchParams = (CocoaDSCheatSearchParams *)object; CocoaDSCheatSearchParams *searchParams = (CocoaDSCheatSearchParams *)object;
[self runComparativeSearch:searchParams.comparativeSearchType byteSize:searchParams.byteSize signType:searchParams.signType]; [self runComparativeSearch:[searchParams comparativeSearchType] byteSize:[searchParams byteSize] signType:[searchParams signType]];
} }
- (void) reset - (void) reset
{ {
pthread_rwlock_wrlock(self.rwlockCoreExecute); pthread_rwlock_wrlock([self rwlockCoreExecute]);
self.listData->close(); [self listData]->close();
pthread_rwlock_unlock(self.rwlockCoreExecute); pthread_rwlock_unlock([self rwlockCoreExecute]);
searchCount = 0; searchCount = 0;
[addressList release]; [addressList release];