Add all create responses

Signed-off-by: Graham <gpe@openrs2.org>
Graham 2 years ago
parent f31b2519f9
commit fa41b48f1a
  1. 53
      protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt
  2. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CannotCreateAtThisTimeCodec.kt
  3. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CountryInvalidCodec.kt
  4. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateClientOutOfDateCodec.kt
  5. 8
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateDownstream.kt
  6. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateIpLimitCodec.kt
  7. 8
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateOkCodec.kt
  8. 30
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateResponse.kt
  9. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateServerFullCodec.kt
  10. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/CreateServerOfflineCodec.kt
  11. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/DateOfBirthFutureCodec.kt
  12. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/DateOfBirthInvalidCodec.kt
  13. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/DateOfBirthLastYearCodec.kt
  14. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/DateOfBirthThisYearCodec.kt
  15. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/EmailInvalid1Codec.kt
  16. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/EmailInvalid2Codec.kt
  17. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/EmailInvalidCodec.kt
  18. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/NameInvalidCodec.kt
  19. 45
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/NameSuggestionsCodec.kt
  20. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/NameUnavailableCodec.kt
  21. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordGuessable1Codec.kt
  22. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordGuessableCodec.kt
  23. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordInvalidCharsCodec.kt
  24. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordInvalidLengthCodec.kt
  25. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordSimilarToName1Codec.kt
  26. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordSimilarToName2Codec.kt
  27. 10
      protocol/src/main/kotlin/org/openrs2/protocol/create/downstream/PasswordSimilarToNameCodec.kt

@ -6,6 +6,31 @@ import com.google.inject.TypeLiteral
import com.google.inject.multibindings.Multibinder import com.google.inject.multibindings.Multibinder
import org.openrs2.buffer.BufferModule import org.openrs2.buffer.BufferModule
import org.openrs2.crypto.CryptoModule import org.openrs2.crypto.CryptoModule
import org.openrs2.protocol.create.downstream.CannotCreateAtThisTimeCodec
import org.openrs2.protocol.create.downstream.CountryInvalidCodec
import org.openrs2.protocol.create.downstream.CreateClientOutOfDateCodec
import org.openrs2.protocol.create.downstream.CreateDownstream
import org.openrs2.protocol.create.downstream.CreateIpLimitCodec
import org.openrs2.protocol.create.downstream.CreateOkCodec
import org.openrs2.protocol.create.downstream.CreateServerFullCodec
import org.openrs2.protocol.create.downstream.CreateServerOfflineCodec
import org.openrs2.protocol.create.downstream.DateOfBirthFutureCodec
import org.openrs2.protocol.create.downstream.DateOfBirthInvalidCodec
import org.openrs2.protocol.create.downstream.DateOfBirthLastYearCodec
import org.openrs2.protocol.create.downstream.DateOfBirthThisYearCodec
import org.openrs2.protocol.create.downstream.EmailInvalid1Codec
import org.openrs2.protocol.create.downstream.EmailInvalid2Codec
import org.openrs2.protocol.create.downstream.EmailInvalidCodec
import org.openrs2.protocol.create.downstream.NameInvalidCodec
import org.openrs2.protocol.create.downstream.NameSuggestionsCodec
import org.openrs2.protocol.create.downstream.NameUnavailableCodec
import org.openrs2.protocol.create.downstream.PasswordGuessable1Codec
import org.openrs2.protocol.create.downstream.PasswordGuessableCodec
import org.openrs2.protocol.create.downstream.PasswordInvalidCharsCodec
import org.openrs2.protocol.create.downstream.PasswordInvalidLengthCodec
import org.openrs2.protocol.create.downstream.PasswordSimilarToName1Codec
import org.openrs2.protocol.create.downstream.PasswordSimilarToName2Codec
import org.openrs2.protocol.create.downstream.PasswordSimilarToNameCodec
import org.openrs2.protocol.js5.downstream.Js5ClientOutOfDateCodec import org.openrs2.protocol.js5.downstream.Js5ClientOutOfDateCodec
import org.openrs2.protocol.js5.downstream.Js5IpLimitCodec import org.openrs2.protocol.js5.downstream.Js5IpLimitCodec
import org.openrs2.protocol.js5.downstream.Js5OkCodec import org.openrs2.protocol.js5.downstream.Js5OkCodec
@ -60,6 +85,34 @@ public object ProtocolModule : AbstractModule() {
install(BufferModule) install(BufferModule)
install(CryptoModule) install(CryptoModule)
bindProtocol(
CreateDownstream::class.java,
CreateOkCodec::class.java,
CreateServerOfflineCodec::class.java,
CreateServerFullCodec::class.java,
CreateIpLimitCodec::class.java,
DateOfBirthInvalidCodec::class.java,
DateOfBirthFutureCodec::class.java,
DateOfBirthThisYearCodec::class.java,
DateOfBirthLastYearCodec::class.java,
CountryInvalidCodec::class.java,
NameUnavailableCodec::class.java,
NameSuggestionsCodec::class.java,
NameInvalidCodec::class.java,
PasswordInvalidLengthCodec::class.java,
PasswordInvalidCharsCodec::class.java,
PasswordGuessableCodec::class.java,
PasswordGuessable1Codec::class.java,
PasswordSimilarToNameCodec::class.java,
PasswordSimilarToName1Codec::class.java,
PasswordSimilarToName2Codec::class.java,
CreateClientOutOfDateCodec::class.java,
CannotCreateAtThisTimeCodec::class.java,
EmailInvalidCodec::class.java,
EmailInvalid1Codec::class.java,
EmailInvalid2Codec::class.java
)
bindProtocol( bindProtocol(
Js5RemoteDownstream::class.java, Js5RemoteDownstream::class.java,
Js5OkCodec::class.java, Js5OkCodec::class.java,

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class CannotCreateAtThisTimeCodec : EmptyPacketCodec<CreateResponse.CannotCreateAtThisTime>(
packet = CreateResponse.CannotCreateAtThisTime,
opcode = 38
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class CountryInvalidCodec : EmptyPacketCodec<CreateResponse.CountryInvalid>(
packet = CreateResponse.CountryInvalid,
opcode = 14
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class CreateClientOutOfDateCodec : EmptyPacketCodec<CreateResponse.ClientOutOfDate>(
packet = CreateResponse.ClientOutOfDate,
opcode = 37
)

@ -0,0 +1,8 @@
package org.openrs2.protocol.create.downstream
import javax.inject.Qualifier
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION)
public annotation class CreateDownstream

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class CreateIpLimitCodec : EmptyPacketCodec<CreateResponse.IpLimit>(
packet = CreateResponse.IpLimit,
opcode = 9
)

@ -0,0 +1,8 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
public class CreateOkCodec : EmptyPacketCodec<CreateResponse.Ok>(
packet = CreateResponse.Ok,
opcode = 2
)

@ -0,0 +1,30 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.Packet
public sealed class CreateResponse : Packet {
public object Ok : CreateResponse()
public object CreateServerOffline : CreateResponse()
public object ServerFull : CreateResponse()
public object IpLimit : CreateResponse()
public object DateOfBirthInvalid : CreateResponse()
public object DateOfBirthFuture : CreateResponse()
public object DateOfBirthThisYear : CreateResponse()
public object DateOfBirthLastYear : CreateResponse()
public object CountryInvalid : CreateResponse()
public object NameUnavailable : CreateResponse()
public data class NameSuggestions(val names: List<String>) : CreateResponse()
public object NameInvalid : CreateResponse()
public object PasswordInvalidLength : CreateResponse()
public object PasswordInvalidChars : CreateResponse()
public object PasswordGuessable : CreateResponse()
public object PasswordGuessable1 : CreateResponse()
public object PasswordSimilarToName : CreateResponse()
public object PasswordSimilarToName1 : CreateResponse()
public object PasswordSimilarToName2 : CreateResponse()
public object ClientOutOfDate : CreateResponse()
public object CannotCreateAtThisTime : CreateResponse()
public object EmailInvalid : CreateResponse()
public object EmailInvalid1 : CreateResponse()
public object EmailInvalid2 : CreateResponse()
}

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class CreateServerFullCodec : EmptyPacketCodec<CreateResponse.ServerFull>(
packet = CreateResponse.ServerFull,
opcode = 7
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class CreateServerOfflineCodec : EmptyPacketCodec<CreateResponse.CreateServerOffline>(
packet = CreateResponse.CreateServerOffline,
opcode = 3
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class DateOfBirthFutureCodec : EmptyPacketCodec<CreateResponse.DateOfBirthFuture>(
packet = CreateResponse.DateOfBirthFuture,
opcode = 11
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class DateOfBirthInvalidCodec : EmptyPacketCodec<CreateResponse.DateOfBirthInvalid>(
packet = CreateResponse.DateOfBirthInvalid,
opcode = 10
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class DateOfBirthLastYearCodec : EmptyPacketCodec<CreateResponse.DateOfBirthLastYear>(
packet = CreateResponse.DateOfBirthLastYear,
opcode = 13
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class DateOfBirthThisYearCodec : EmptyPacketCodec<CreateResponse.DateOfBirthThisYear>(
packet = CreateResponse.DateOfBirthThisYear,
opcode = 12
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class EmailInvalid1Codec : EmptyPacketCodec<CreateResponse.EmailInvalid1>(
packet = CreateResponse.EmailInvalid1,
opcode = 42
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class EmailInvalid2Codec : EmptyPacketCodec<CreateResponse.EmailInvalid2>(
packet = CreateResponse.EmailInvalid2,
opcode = 43
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class EmailInvalidCodec : EmptyPacketCodec<CreateResponse.EmailInvalid>(
packet = CreateResponse.EmailInvalid,
opcode = 41
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class NameInvalidCodec : EmptyPacketCodec<CreateResponse.NameInvalid>(
packet = CreateResponse.NameInvalid,
opcode = 22
)

@ -0,0 +1,45 @@
package org.openrs2.protocol.create.downstream
import io.netty.buffer.ByteBuf
import org.openrs2.crypto.StreamCipher
import org.openrs2.protocol.PacketCodec
import org.openrs2.util.Base37
public class NameSuggestionsCodec : PacketCodec<CreateResponse.NameSuggestions>(
type = CreateResponse.NameSuggestions::class.java,
opcode = 21
) {
override fun decode(input: ByteBuf, cipher: StreamCipher): CreateResponse.NameSuggestions {
val names = mutableListOf<String>()
while (input.readableBytes() >= 8) {
names += Base37.decodeLowerCase(input.readLong())
}
return CreateResponse.NameSuggestions(names)
}
override fun encode(input: CreateResponse.NameSuggestions, output: ByteBuf, cipher: StreamCipher) {
for (name in input.names) {
output.writeLong(Base37.encode(name))
}
}
override fun isLengthReadable(input: ByteBuf): Boolean {
return input.isReadable
}
override fun readLength(input: ByteBuf): Int {
return input.readUnsignedByte().toInt() * 8
}
override fun writeLengthPlaceholder(output: ByteBuf) {
output.writeZero(1)
}
override fun setLength(output: ByteBuf, index: Int, written: Int) {
require(written % 8 != 0) {
"Name suggestions payload length must be a multiple of 8"
}
output.setByte(index, written / 8)
}
}

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class NameUnavailableCodec : EmptyPacketCodec<CreateResponse.NameUnavailable>(
packet = CreateResponse.NameUnavailable,
opcode = 20
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordGuessable1Codec : EmptyPacketCodec<CreateResponse.PasswordGuessable1>(
packet = CreateResponse.PasswordGuessable1,
opcode = 33
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordGuessableCodec : EmptyPacketCodec<CreateResponse.PasswordGuessable>(
packet = CreateResponse.PasswordGuessable,
opcode = 32
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordInvalidCharsCodec : EmptyPacketCodec<CreateResponse.PasswordInvalidChars>(
packet = CreateResponse.PasswordInvalidChars,
opcode = 31
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordInvalidLengthCodec : EmptyPacketCodec<CreateResponse.PasswordInvalidLength>(
packet = CreateResponse.PasswordInvalidLength,
opcode = 30
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordSimilarToName1Codec : EmptyPacketCodec<CreateResponse.PasswordSimilarToName1>(
packet = CreateResponse.PasswordSimilarToName1,
opcode = 35
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordSimilarToName2Codec : EmptyPacketCodec<CreateResponse.PasswordSimilarToName2>(
packet = CreateResponse.PasswordSimilarToName2,
opcode = 36
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.create.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class PasswordSimilarToNameCodec : EmptyPacketCodec<CreateResponse.PasswordSimilarToName>(
packet = CreateResponse.PasswordSimilarToName,
opcode = 34
)
Loading…
Cancel
Save