aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalevalapokalypsi/Server')
-rw-r--r--src/scalevalapokalypsi/Server/Client.scala10
-rw-r--r--src/scalevalapokalypsi/Server/Server.scala7
2 files changed, 8 insertions, 9 deletions
diff --git a/src/scalevalapokalypsi/Server/Client.scala b/src/scalevalapokalypsi/Server/Client.scala
index d689356..5727fc6 100644
--- a/src/scalevalapokalypsi/Server/Client.scala
+++ b/src/scalevalapokalypsi/Server/Client.scala
@@ -3,6 +3,7 @@ package scalevalapokalypsi.Server
import java.net.Socket
import scala.math.{min,max}
import scalevalapokalypsi.constants.*
+import scalevalapokalypsi.utils.*
import ServerProtocolState.*
import scalevalapokalypsi.Model.Action
import scalevalapokalypsi.Model.Entities.Player
@@ -113,8 +114,7 @@ class Client(val socket: Socket):
val rest = this.incompleteMessage.drop(nextCRLF + 2)
this.incompleteMessage = rest ++ Array.fill(nextCRLF + 1)(0.toByte)
this.incompleteMessageIndex = 0
- // TODO: the conversion may probably be exploited to crash the server
- Some(String(message))
+ byteArrayToString(message)
else
None
@@ -178,7 +178,7 @@ class Client(val socket: Socket):
this.singStartTime = None
- case None =>
+ case None if isPrintable(line) =>
val action = Action(line)
val takesATurn = this.character.exists(p => action.execute(p))
@@ -186,6 +186,10 @@ class Client(val socket: Socket):
this.addDataToSend(s"$ACTION_BLOCKING_INDICATOR")
this.turnUsed = true
+ case None =>
+
+ () // There were some illegal chars but whatever
+
end executeLine
end Client
diff --git a/src/scalevalapokalypsi/Server/Server.scala b/src/scalevalapokalypsi/Server/Server.scala
index 8debdba..89db302 100644
--- a/src/scalevalapokalypsi/Server/Server.scala
+++ b/src/scalevalapokalypsi/Server/Server.scala
@@ -124,12 +124,7 @@ class Server(
target.foreach(t =>
if c.player.exists(_.isSinging) && !c.clientHasSong then
val verse = t.getVerseAgainst
- println(s"got verse against: “$verse”")
- this.writeToClient(
- s"${SING_INDICATOR}$verse\r\n",
- // TODO: store the verse and check how close client input is when determining sing quality
- c
- )
+ this.writeToClient(s"${SING_INDICATOR}$verse\r\n", c)
c.startSong(verse)
)
)