From e109b9d93f74cd4428656492f4ed68ee66e92954 Mon Sep 17 00:00:00 2001 From: 127-Z3R0 <81heti1bif@hft-stuttgart.de> Date: Wed, 1 Jul 2020 19:45:25 +0200 Subject: [PATCH] revert heartbeart for crashes --- GoldWars/GoldWars.xcodeproj/project.pbxproj | 8 ++++---- GoldWars/GoldWars/DataService.swift | 6 ------ GoldWars/GoldWars/GameCenterManager.swift | 16 +--------------- GoldWars/GoldWars/MultiplayerNetwork.swift | 6 ------ GoldWars/GoldWars/RoundTimer.swift | 6 ------ 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index d42f8be..fc0bcc6 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -611,14 +611,14 @@ CODE_SIGN_ENTITLEMENTS = GoldWars/GoldWars.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWars/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = de.hft.stuttgart.ip2.goldwars; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -634,14 +634,14 @@ CODE_SIGN_ENTITLEMENTS = GoldWars/GoldWars.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWars/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = de.hft.stuttgart.ip2.goldwars; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/GoldWars/GoldWars/DataService.swift b/GoldWars/GoldWars/DataService.swift index 4c5f63a..7739d81 100644 --- a/GoldWars/GoldWars/DataService.swift +++ b/GoldWars/GoldWars/DataService.swift @@ -5,12 +5,6 @@ // Created by Tim Herbst on 13.05.20. // Copyright © 2020 SP2. All rights reserved. // -import Foundation - -struct Heartbeat: Codable { - var date: Date -} - struct NotificationModel: Codable { let name: String diff --git a/GoldWars/GoldWars/GameCenterManager.swift b/GoldWars/GoldWars/GameCenterManager.swift index fbf0c8d..c52818d 100644 --- a/GoldWars/GoldWars/GameCenterManager.swift +++ b/GoldWars/GoldWars/GameCenterManager.swift @@ -215,25 +215,11 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG print("Recieved elo data: \(eloData.scoreToReport)") EloHelper.reportScore(score: eloData.scoreToReport) } - if let heartbeat = try? jsonDecoder.decode(Heartbeat.self, from: data) { - entityManager.getHUD()?.roundTimer.isHeartbeatLocked = false - let df = DateFormatter() - df.dateFormat = "yyyy-MM-dd HH:mm:ss" - let dateString = df.string(from: heartbeat.date) - print("Received last Heartbeat at \(dateString)") - } + MultiplayerNetwork.sharedInstance.isSending = false } - func match(_ match: GKMatch, player: GKPlayer, didChange state: GKPlayerConnectionState) { - if myMatch != match { return } - if state == GKPlayerConnectionState.disconnected { - self.opponentQuit = true; - gameScene?.gameQuit() - } - } - func initAndSendMap() -> Void { self.gameScene = GameScene(size: self.menusc!.size) let mapModel = MapFactory(scene: self.gameScene!, entityManager: entityManager).load() diff --git a/GoldWars/GoldWars/MultiplayerNetwork.swift b/GoldWars/GoldWars/MultiplayerNetwork.swift index 07cc2a8..596fd1f 100644 --- a/GoldWars/GoldWars/MultiplayerNetwork.swift +++ b/GoldWars/GoldWars/MultiplayerNetwork.swift @@ -71,10 +71,4 @@ class MultiplayerNetwork{ let encoded = (try? encoder.encode(NotificationModel(name: name)))! sendData(data: encoded) } - - func sendHeartbeatToPlayer() { - let encoder = JSONEncoder() - let encoded = (try? encoder.encode(Heartbeat(date: Date())))! - sendData(data: encoded) - } } diff --git a/GoldWars/GoldWars/RoundTimer.swift b/GoldWars/GoldWars/RoundTimer.swift index 666eb7a..27bf5a9 100644 --- a/GoldWars/GoldWars/RoundTimer.swift +++ b/GoldWars/GoldWars/RoundTimer.swift @@ -12,7 +12,6 @@ class RoundTimer: Timer { var timer: Timer? var timeLeft: Int = 0 - var isHeartbeatLocked = false var calculate = false var roundEnded = "Syncing" @@ -69,10 +68,5 @@ class RoundTimer: Timer { calculate = false } } - - if (!isHeartbeatLocked && (timeLeft % 7 == 0)){ - MultiplayerNetwork.sharedInstance.sendHeartbeatToPlayer() - isHeartbeatLocked = true; - } } }