mirror of
https://github.com/Smallhacker/disbrowser.git
synced 2024-06-08 05:29:34 +00:00
Added updating synchronization
This commit is contained in:
parent
32b19c2c47
commit
1e8fbe1b0d
|
@ -8,6 +8,7 @@ import com.smallhacker.disbrowser.util.toUInt24
|
||||||
import kotlin.reflect.KMutableProperty1
|
import kotlin.reflect.KMutableProperty1
|
||||||
|
|
||||||
private val RESET_VECTOR_LOCATION = address(0x00_FFFC)
|
private val RESET_VECTOR_LOCATION = address(0x00_FFFC)
|
||||||
|
private val UPDATE_MUTEX = Any()
|
||||||
|
|
||||||
private val VECTORS = listOf(
|
private val VECTORS = listOf(
|
||||||
address(0x00_FFE4) to "COP",
|
address(0x00_FFE4) to "COP",
|
||||||
|
@ -60,6 +61,7 @@ object Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String) {
|
fun updateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String) {
|
||||||
|
synchronized(UPDATE_MUTEX) {
|
||||||
if (value.isEmpty()) {
|
if (value.isEmpty()) {
|
||||||
if (address in game.gameData) {
|
if (address in game.gameData) {
|
||||||
doUpdateMetadata(game, address, field, null)
|
doUpdateMetadata(game, address, field, null)
|
||||||
|
@ -68,6 +70,7 @@ object Service {
|
||||||
doUpdateMetadata(game, address, field, value)
|
doUpdateMetadata(game, address, field, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun doUpdateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String?) {
|
private fun doUpdateMetadata(game: Game, address: SnesAddress, field: KMutableProperty1<MetadataLine, String?>, value: String?) {
|
||||||
val line = game.gameData.getOrCreate(address)
|
val line = game.gameData.getOrCreate(address)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user