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,6 +61,7 @@ object Service {
}
fun updateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String) {
synchronized(UPDATE_MUTEX) {
if (value.isEmpty()) {
if (address in game.gameData) {
doUpdateMetadata(game, address, field, null)
@ -68,6 +70,7 @@ object Service {
doUpdateMetadata(game, address, field, value)
}
}
}
private fun doUpdateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String?) {
val line = game.gameData.getOrCreate(address)