Added updating synchronization

This commit is contained in:
Smallhacker 2019-01-13 21:03:16 -05:00
parent 32b19c2c47
commit 1e8fbe1b0d

View File

@ -8,6 +8,7 @@ import com.smallhacker.disbrowser.util.toUInt24
import kotlin.reflect.KMutableProperty1
private val RESET_VECTOR_LOCATION = address(0x00_FFFC)
private val UPDATE_MUTEX = Any()
private val VECTORS = listOf(
address(0x00_FFE4) to "COP",
@ -60,12 +61,14 @@ object Service {
}
fun updateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String) {
if (value.isEmpty()) {
if (address in game.gameData) {
doUpdateMetadata(game, address, field, null)
synchronized(UPDATE_MUTEX) {
if (value.isEmpty()) {
if (address in game.gameData) {
doUpdateMetadata(game, address, field, null)
}
} else {
doUpdateMetadata(game, address, field, value)
}
} else {
doUpdateMetadata(game, address, field, value)
}
}