Improved server shutdown order
Improved GE threading, introduced locks fixing server lags and GE offers not executing Moved player login hooks to the major update worker (from management server thread) Fixed random events in rare circumstances causing noted item loss
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import core.game.ge.OfferState
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -7,6 +10,7 @@ import org.junit.jupiter.api.fail
|
||||
import rs09.game.ge.GEDB
|
||||
import rs09.game.ge.GrandExchange
|
||||
import rs09.game.ge.GrandExchangeOffer
|
||||
import rs09.game.ge.PriceIndex
|
||||
import rs09.game.system.SystemLogger
|
||||
import java.io.File
|
||||
import kotlin.random.Random
|
||||
@@ -100,4 +104,15 @@ import kotlin.random.Random
|
||||
|
||||
Assertions.assertEquals(defaultPrice, GrandExchange.getRecommendedPrice(4151))
|
||||
}
|
||||
|
||||
@Test fun concurrentlySubmittedOffersShouldNotThrowExceptions(){
|
||||
runBlocking {
|
||||
val a = GlobalScope.launch { for(i in 0 until 5) {PriceIndex.allowItem(i); GrandExchange.addBotOffer(i, 1)} }
|
||||
val b = GlobalScope.launch { for(i in 0 until 5) {PriceIndex.allowItem(i); GrandExchange.addBotOffer(i, 1)} }
|
||||
a.join()
|
||||
b.join()
|
||||
Assertions.assertEquals(false, a.isCancelled)
|
||||
Assertions.assertEquals(false, b.isCancelled)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package content
|
||||
|
||||
import TestUtils
|
||||
import core.game.node.item.Item
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.content.ame.RandomEventNPC
|
||||
import rs09.game.world.GameWorld
|
||||
|
||||
class RandomEventManager {
|
||||
@@ -33,4 +36,41 @@ class RandomEventManager {
|
||||
TestUtils.advanceTicks(rs09.game.content.ame.RandomEventManager.MAX_DELAY_TICKS + 5)
|
||||
Assertions.assertNotNull(p.getAttribute("re-npc", null))
|
||||
}
|
||||
|
||||
@Test fun teleportAndNotePunishmentShouldNotAffectAlreadyNotedItems() {
|
||||
val p = TestUtils.getMockPlayer("Shitforbrains")
|
||||
p.setAttribute("tutorial:complete", true)
|
||||
rs09.game.content.ame.RandomEventManager().login(p)
|
||||
|
||||
p.inventory.add(Item(Items.RAW_SHARK_384, 1000))
|
||||
rs09.game.content.ame.RandomEventManager.getInstance(p)?.fireEvent()
|
||||
p.getAttribute<RandomEventNPC>("re-npc")!!.noteAndTeleport()
|
||||
|
||||
Assertions.assertEquals(1000, p.inventory.getAmount(Items.RAW_SHARK_384))
|
||||
}
|
||||
|
||||
@Test fun teleportAndNotePunishmentShouldNoteNotableUnnotedItems() {
|
||||
val p = TestUtils.getMockPlayer("shitforbrains2")
|
||||
p.setAttribute("tutorial:complete", true)
|
||||
rs09.game.content.ame.RandomEventManager().login(p)
|
||||
|
||||
p.inventory.add(Item(4151, 5))
|
||||
rs09.game.content.ame.RandomEventManager.getInstance(p)?.fireEvent()
|
||||
p.getAttribute<RandomEventNPC>("re-npc")!!.noteAndTeleport()
|
||||
|
||||
Assertions.assertEquals(5, p.inventory.getAmount(4152))
|
||||
Assertions.assertEquals(0, p.inventory.getAmount(4151))
|
||||
}
|
||||
|
||||
@Test fun teleportAndNotePunishmentShouldNotAffectUnnotableItems() {
|
||||
val p = TestUtils.getMockPlayer("shitforbrains3")
|
||||
p.setAttribute("tutorial:complete", true)
|
||||
rs09.game.content.ame.RandomEventManager().login(p)
|
||||
|
||||
p.inventory.add(Item(Items.AIR_RUNE_556, 30))
|
||||
rs09.game.content.ame.RandomEventManager.getInstance(p)?.fireEvent()
|
||||
p.getAttribute<RandomEventNPC>("re-npc")!!.noteAndTeleport()
|
||||
|
||||
Assertions.assertEquals(30, p.inventory.getAmount(Items.AIR_RUNE_556))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user