Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 73bda711 rédigé par Pol Lamothe's avatar Pol Lamothe
Parcourir les fichiers

Ajout de délai pour améliorer la synchronisation

parent a00343d6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!19Branch pol
......@@ -360,7 +360,6 @@ func SendPos(x, y int) {
for SendingConfirmation {
}
Conn.Write(data)
Conn.Write(data)
for WaitingForResponse {
}
if configuration.Global.DebugMultiplayer {
......
......@@ -6,6 +6,7 @@ import (
"gitlab.univ-nantes.fr/jezequel-l/quadtree/configuration"
"net"
"strings"
"time"
)
func ConnectAsServer() {
......@@ -68,6 +69,9 @@ func handleClient(conn net.Conn) {
}
for i := 1; i < len(dataArray); i++ {
dataArray[i] = "{" + dataArray[i]
if configuration.Global.DebugMultiplayer {
fmt.Println("desynchronised")
}
}
for i := 0; i < len(dataArray); i++ {
err = json.Unmarshal([]byte(dataArray[i]), &jsonData)
......@@ -80,6 +84,7 @@ func handleClient(conn net.Conn) {
case "SendKeyPressed":
KeyPressed = jsonData["Data"].(string)
DatatReceived()
time.Sleep(250 * time.Millisecond)
case "SendBlock":
treatBlocReceived(jsonData)
case "DataReceived":
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter