From 91e76d2397fdc3eabe7f28eff7809531381f7a50 Mon Sep 17 00:00:00 2001 From: Jakob Gillich Date: Sat, 22 May 2021 07:11:02 +0200 Subject: [PATCH] Add base certifications config option --- src/main/resources/application.conf | 11 ++++++++++- .../psforever/actors/session/AvatarActor.scala | 2 +- .../psforever/objects/avatar/Certification.scala | 2 +- .../net/psforever/packet/GamePacketOpcode.scala | 2 +- src/main/scala/net/psforever/util/Config.scala | 15 ++++++++------- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 8504f693a..ab4bfe6ca 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -101,6 +101,15 @@ game { # Starting command rank cr = 0 } + + # Certifications to add to every character. Note that they do not become free, their cost is deducted from the + # player's certification points. The default base certifications are 0 cost. + # Values are `Certification` member names. + base-certifications = [ + standard_assault, + standard_armor, + agile_armor + ] } anti-cheat { @@ -141,7 +150,7 @@ network { development { # List of GM commands available to everyone - # Values are ChatMessageType members, for example: [CMT_ADDBATTLEEXPERIENCE, CMT_CAPTUREBASE] + # Values are `ChatMessageType` members, for example: [CMT_ADDBATTLEEXPERIENCE, CMT_CAPTUREBASE] unprivileged-gm-commands = [] net-sim { diff --git a/src/main/scala/net/psforever/actors/session/AvatarActor.scala b/src/main/scala/net/psforever/actors/session/AvatarActor.scala index e5435fd80..122657c58 100644 --- a/src/main/scala/net/psforever/actors/session/AvatarActor.scala +++ b/src/main/scala/net/psforever/actors/session/AvatarActor.scala @@ -355,7 +355,7 @@ class AvatarActor( loadouts = loadouts, // make sure we always have the base certifications certifications = - certs.map(cert => Certification.withValue(cert.id)).toSet ++ Certification.values.filter(_.cost == 0), + certs.map(cert => Certification.withValue(cert.id)).toSet ++ Config.app.game.baseCertifications, implants = implants.map(implant => Some(Implant(implant.toImplantDefinition))).padTo(3, None) ) diff --git a/src/main/scala/net/psforever/objects/avatar/Certification.scala b/src/main/scala/net/psforever/objects/avatar/Certification.scala index 5dde46d33..1fe4cd856 100644 --- a/src/main/scala/net/psforever/objects/avatar/Certification.scala +++ b/src/main/scala/net/psforever/objects/avatar/Certification.scala @@ -92,7 +92,7 @@ case object Certification extends IntEnum[Certification] { case object BFRAntiInfantry extends Certification(value = 25, name = "TODO4", cost = 1, requires = Set(BattleFrameRobotics)) // TODO name - case object StandardExoSuit extends Certification(value = 26, name = "TODO5", cost = 0) + case object StandardExoSuit extends Certification(value = 26, name = "standard_armor", cost = 0) case object AgileExoSuit extends Certification(value = 27, name = "agile_armor", cost = 0) diff --git a/src/main/scala/net/psforever/packet/GamePacketOpcode.scala b/src/main/scala/net/psforever/packet/GamePacketOpcode.scala index 1cc5d89c0..b57cd0337 100644 --- a/src/main/scala/net/psforever/packet/GamePacketOpcode.scala +++ b/src/main/scala/net/psforever/packet/GamePacketOpcode.scala @@ -295,7 +295,7 @@ object GamePacketOpcode extends Enumeration { = Value private def noDecoder(opcode: GamePacketOpcode.Type) = - (bits: BitVector) => Attempt.failure(Err(s"Could not find a marshaller for game packet $opcode (${bits.toHex}")) + (bits: BitVector) => Attempt.failure(Err(s"Could not find a marshaller for game packet $opcode (${bits.toHex})")) /// Mapping of packet IDs to decoders. Notice that we are using the @switch annotation which ensures that the Scala /// compiler will be able to optimize this as a lookup table (switch statement). Microbenchmarks show a nearly 400x diff --git a/src/main/scala/net/psforever/util/Config.scala b/src/main/scala/net/psforever/util/Config.scala index d3057fcb7..38d881912 100644 --- a/src/main/scala/net/psforever/util/Config.scala +++ b/src/main/scala/net/psforever/util/Config.scala @@ -1,11 +1,10 @@ package net.psforever.util import java.nio.file.Paths - import com.typesafe.config.{Config => TypesafeConfig} import enumeratum.{Enum, EnumEntry} import enumeratum.values.{IntEnum, IntEnumEntry} -import net.psforever.objects.avatar.{BattleRank, CommandRank} +import net.psforever.objects.avatar.{BattleRank, Certification, CommandRank} import net.psforever.packet.game.ServerType import net.psforever.types.ChatMessageType import pureconfig.ConfigConvert.viaNonEmptyStringOpt @@ -34,6 +33,7 @@ object Config { case e: ServerType if e.name == v => e.asInstanceOf[A] case e: BattleRank if e.value.toString == v => e.asInstanceOf[A] case e: CommandRank if e.value.toString == v => e.asInstanceOf[A] + case e: Certification if e.name == v => e.asInstanceOf[A] }, _.value.toString ) @@ -119,10 +119,10 @@ case class NetworkConfig( ) case class MiddlewareConfig( - packetBundlingDelay: FiniteDuration, - inReorderTimeout: FiniteDuration, - inSubslotMissingDelay: FiniteDuration, - inSubslotMissingAttempts: Int + packetBundlingDelay: FiniteDuration, + inReorderTimeout: FiniteDuration, + inSubslotMissingDelay: FiniteDuration, + inSubslotMissingAttempts: Int ) case class SessionConfig( @@ -138,7 +138,8 @@ case class GameConfig( cepRate: Double, newAvatar: NewAvatar, hart: HartConfig, - sharedMaxCooldown: Boolean + sharedMaxCooldown: Boolean, + baseCertifications: Seq[Certification] ) case class NewAvatar(