Better Handling for TM Multilap maps, now there is a Setting to save either single Lap Time or Full Race Time (default). #159
There is a small bug left that Multilap times are not saved in Dedimania due differences of Checkpoint Numbers between Nadeo and Dedimania.
This commit is contained in:
		| @@ -52,7 +52,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, | |||||||
| 	/* | 	/* | ||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const VERSION                     = '0.226'; | 	const VERSION                     = '0.227'; | ||||||
| 	const API_VERSION                 = '2013-04-16'; | 	const API_VERSION                 = '2013-04-16'; | ||||||
| 	const MIN_DEDIVERSION             = '2017-05-03_21_00'; | 	const MIN_DEDIVERSION             = '2017-05-03_21_00'; | ||||||
| 	const SCRIPT_TIMEOUT              = 40; | 	const SCRIPT_TIMEOUT              = 40; | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const ID             = 8; | 	const ID             = 8; | ||||||
| 	const VERSION        = 0.5; | 	const VERSION        = 0.6; | ||||||
| 	const AUTHOR         = 'MCTeam'; | 	const AUTHOR         = 'MCTeam'; | ||||||
| 	const NAME           = 'Dedimania Plugin'; | 	const NAME           = 'Dedimania Plugin'; | ||||||
| 	const MLID_DEDIMANIA = 'Dedimania.ManialinkId'; | 	const MLID_DEDIMANIA = 'Dedimania.ManialinkId'; | ||||||
| @@ -110,7 +110,6 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleCheckpointCallback'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleCheckpointCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONLAPFINISH, $this, 'handleFinishCallback'); |  | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERLOOP, $this, 'handleAfterLoop'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERLOOP, $this, 'handleAfterLoop'); | ||||||
|  |  | ||||||
| @@ -270,15 +269,16 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * @param OnWayPointEventStructure $callback | 	 * @param OnWayPointEventStructure $callback | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handleCheckpointCallback(OnWayPointEventStructure $structure) { | 	public function handleCheckpointCallback(OnWayPointEventStructure $structure) { | ||||||
| 		if (!$structure->getLapTime()) { | 		if (!$structure->getRaceTime()) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		//TODO in Dedimania There is a small Bug somewhere with the amount of Checkpoints | ||||||
| 		$login = $structure->getLogin(); | 		$login = $structure->getLogin(); | ||||||
| 		if (!isset($this->checkpoints[$login])) { | 		if (!isset($this->checkpoints[$login])) { | ||||||
| 			$this->checkpoints[$login] = array(); | 			$this->checkpoints[$login] = array(); | ||||||
| 		} | 		} | ||||||
| 		$this->checkpoints[$login][$structure->getCheckPointInLap()] = $structure->getLapTime(); | 		$this->checkpoints[$login][$structure->getCheckPointInRace()] = $structure->getRaceTime(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -305,14 +305,14 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$player = $structure->getPlayer(); | 		$player = $structure->getPlayer(); | ||||||
|  |  | ||||||
| 		$oldRecord = $this->getDedimaniaRecord($player->login); | 		$oldRecord = $this->getDedimaniaRecord($player->login); | ||||||
| 		if ($oldRecord->nullRecord || $oldRecord && $oldRecord->best > $structure->getLapTime()) { | 		if ($oldRecord->nullRecord || $oldRecord && $oldRecord->best > $structure->getRaceTime()) { | ||||||
| 			// Save time | 			// Save time | ||||||
| 			$newRecord = new RecordData(null); | 			$newRecord = new RecordData(null); | ||||||
|  |  | ||||||
| 			$checkPoints = $this->getCheckpoints($player->login); | 			$checkPoints = $this->getCheckpoints($player->login); | ||||||
| 			$checkPoints = $checkPoints . "," . $structure->getLapTime(); | 			$checkPoints = $checkPoints . "," . $structure->getRaceTime(); | ||||||
|  |  | ||||||
| 			$newRecord->constructNewRecord($player->login, $player->nickname, $structure->getLapTime(), $checkPoints, true); | 			$newRecord->constructNewRecord($player->login, $player->nickname, $structure->getRaceTime(), $checkPoints, true); | ||||||
|  |  | ||||||
| 			if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) { | 			if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) { | ||||||
| 				// Get newly saved record | 				// Get newly saved record | ||||||
| @@ -346,7 +346,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
|  |  | ||||||
| 				$message = '$390$<$fff' . $notifyName . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Dedimania Record: $<$fff' . Formatter::formatTime($newRecord->best) . '$>'; | 				$message = '$390$<$fff' . $notifyName . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Dedimania Record: $<$fff' . Formatter::formatTime($newRecord->best) . '$>'; | ||||||
| 				if (!$oldRecord->nullRecord) { | 				if (!$oldRecord->nullRecord) { | ||||||
| 					$message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $structure->getLapTime())) . '$>)'; | 					$message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $structure->getRaceTime())) . '$>)'; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				if ($newRecord->rank <= $notifyOnlyBestRecords) { | 				if ($newRecord->rank <= $notifyOnlyBestRecords) { | ||||||
|   | |||||||
| @@ -266,8 +266,7 @@ class DedimaniaWebHandler implements TimerListener { | |||||||
|  |  | ||||||
| 		$this->addRequest(self::DEDIMANIA_WARNINGSANDTTR2, array()); | 		$this->addRequest(self::DEDIMANIA_WARNINGSANDTTR2, array()); | ||||||
|  |  | ||||||
| 		$content = xmlrpc_encode_request(self::XMLRPC_MULTICALL, array($this->requests), array('encoding'  => 'UTF-8', 'escaping' => 'markup', | 		$content = xmlrpc_encode_request(self::XMLRPC_MULTICALL, array($this->requests), array('encoding' => 'UTF-8', 'escaping' => 'markup', 'verbosity' => 'no_white_space')); | ||||||
| 		                                                                                       'verbosity' => 'no_white_space')); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 		$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, self::DEDIMANIA_URL); | 		$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, self::DEDIMANIA_URL); | ||||||
| @@ -383,8 +382,7 @@ class DedimaniaWebHandler implements TimerListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function encodeRequest($method, $params) { | 	private function encodeRequest($method, $params) { | ||||||
| 		$paramArray = array(array('methodName' => $method, 'params' => $params), array('methodName' => self::DEDIMANIA_WARNINGSANDTTR2, 'params' => array())); | 		$paramArray = array(array('methodName' => $method, 'params' => $params), array('methodName' => self::DEDIMANIA_WARNINGSANDTTR2, 'params' => array())); | ||||||
| 		return xmlrpc_encode_request(self::XMLRPC_MULTICALL, array($paramArray), array('encoding'  => 'UTF-8', 'escaping' => 'markup', | 		return xmlrpc_encode_request(self::XMLRPC_MULTICALL, array($paramArray), array('encoding' => 'UTF-8', 'escaping' => 'markup', 'verbosity' => 'no_white_space')); | ||||||
| 		                                                                               'verbosity' => 'no_white_space')); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -487,6 +485,7 @@ class DedimaniaWebHandler implements TimerListener { | |||||||
| 					case 'Rounds': | 					case 'Rounds': | ||||||
| 					case 'Cup': | 					case 'Cup': | ||||||
| 					case 'Team': | 					case 'Team': | ||||||
|  | 					case 'Chase': | ||||||
| 						return 'Rounds'; | 						return 'Rounds'; | ||||||
| 					case 'TimeAttack': | 					case 'TimeAttack': | ||||||
| 					case 'Laps': | 					case 'Laps': | ||||||
|   | |||||||
| @@ -5,14 +5,12 @@ namespace MCTeam; | |||||||
| use FML\Controls\Frame; | use FML\Controls\Frame; | ||||||
| use FML\Controls\Label; | use FML\Controls\Label; | ||||||
| use FML\Controls\Quad; | use FML\Controls\Quad; | ||||||
| use FML\Controls\Quads\Quad_Bgs1InRace; |  | ||||||
| use FML\Controls\Quads\Quad_BgsPlayerCard; | use FML\Controls\Quads\Quad_BgsPlayerCard; | ||||||
| use FML\Controls\Quads\Quad_Icons64x64_1; | use FML\Controls\Quads\Quad_Icons64x64_1; | ||||||
| use FML\ManiaLink; | use FML\ManiaLink; | ||||||
| use FML\Script\Features\Paging; | use FML\Script\Features\Paging; | ||||||
| use ManiaControl\Admin\AuthenticationManager; | use ManiaControl\Admin\AuthenticationManager; | ||||||
| use ManiaControl\Callbacks\CallbackListener; | use ManiaControl\Callbacks\CallbackListener; | ||||||
| use ManiaControl\Callbacks\CallbackManager; |  | ||||||
| use ManiaControl\Callbacks\Callbacks; | use ManiaControl\Callbacks\Callbacks; | ||||||
| use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure; | use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure; | ||||||
| use ManiaControl\Callbacks\TimerListener; | use ManiaControl\Callbacks\TimerListener; | ||||||
| @@ -43,11 +41,12 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const ID                           = 7; | 	const ID                           = 7; | ||||||
| 	const VERSION                      = 0.4; | 	const VERSION                      = 0.5; | ||||||
| 	const NAME                         = 'Local Records Plugin'; | 	const NAME                         = 'Local Records Plugin'; | ||||||
| 	const AUTHOR                       = 'MCTeam'; | 	const AUTHOR                       = 'MCTeam'; | ||||||
| 	const MLID_RECORDS                 = 'ml_local_records'; | 	const MLID_RECORDS                 = 'ml_local_records'; | ||||||
| 	const TABLE_RECORDS                = 'mc_localrecords'; | 	const TABLE_RECORDS                = 'mc_localrecords'; | ||||||
|  | 	const SETTING_MULTILAP_SAVE_SINGLE = 'Save every Lap as Record in Multilap'; | ||||||
| 	const SETTING_WIDGET_TITLE         = 'Widget Title'; | 	const SETTING_WIDGET_TITLE         = 'Widget Title'; | ||||||
| 	const SETTING_WIDGET_POSX          = 'Widget Position: X'; | 	const SETTING_WIDGET_POSX          = 'Widget Position: X'; | ||||||
| 	const SETTING_WIDGET_POSY          = 'Widget Position: Y'; | 	const SETTING_WIDGET_POSY          = 'Widget Position: Y'; | ||||||
| @@ -72,6 +71,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 	private $recordWidget    = null; | 	private $recordWidget    = null; | ||||||
| 	private $updateManialink = false; | 	private $updateManialink = false; | ||||||
| 	private $checkpoints     = array(); | 	private $checkpoints     = array(); | ||||||
|  | 	private $scriptName      = 'TimeAttack'; | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * @see \ManiaControl\Plugins\Plugin::prepare() | 	 * @see \ManiaControl\Plugins\Plugin::prepare() | ||||||
| @@ -137,9 +137,11 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, 10); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, 10); | ||||||
| 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ADJUST_OUTER_BORDER, false); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ADJUST_OUTER_BORDER, false); | ||||||
| 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RECORDS_BEFORE_AFTER, 2); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RECORDS_BEFORE_AFTER, 2); | ||||||
|  | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MULTILAP_SAVE_SINGLE, false); | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000); | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000); | ||||||
|  | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Minute', 60000); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleMapBegin'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleMapBegin'); | ||||||
| @@ -149,7 +151,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleCheckpointCallback'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleCheckpointCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONLAPFINISH, $this, 'handleFinishCallback'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONLAPFINISH, $this, 'handleFinishLapCallback'); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCommandManager()->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.'); | ||||||
| 		$this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteRecord', true, 'Removes a record from the database.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteRecord', true, 'Removes a record from the database.'); | ||||||
| @@ -197,6 +199,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Handle ManiaControl After Init | 	 * Handle ManiaControl After Init | ||||||
|  | 	 * | ||||||
| 	 * @internal | 	 * @internal | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handleAfterInit() { | 	public function handleAfterInit() { | ||||||
| @@ -205,6 +208,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Handle 1 Second Callback | 	 * Handle 1 Second Callback | ||||||
|  | 	 * | ||||||
| 	 * @internal | 	 * @internal | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handle1Second() { | 	public function handle1Second() { | ||||||
| @@ -218,6 +222,15 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** Fetch the Current Scriptname every Minute | ||||||
|  | 	 * | ||||||
|  | 	 * @internal | ||||||
|  | 	 */ | ||||||
|  | 	public function handle1Minute() { | ||||||
|  | 		$scriptNameResponse = $this->maniaControl->getClient()->getScriptName(); | ||||||
|  | 		$this->scriptName   = str_replace('.Script.txt', '', $scriptNameResponse['CurrentValue']); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Build the local records widget ManiaLink and send it to the players | 	 * Build the local records widget ManiaLink and send it to the players | ||||||
| 	 * | 	 * | ||||||
| @@ -415,7 +428,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 	 * Handle Checkpoint Callback | 	 * Handle Checkpoint Callback | ||||||
| 	 * | 	 * | ||||||
| 	 * @internal | 	 * @internal | ||||||
| 	 * @param OnWayPointEventStructure $callback | 	 * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handleCheckpointCallback(OnWayPointEventStructure $structure) { | 	public function handleCheckpointCallback(OnWayPointEventStructure $structure) { | ||||||
| 		$playerLogin = $structure->getLogin(); | 		$playerLogin = $structure->getLogin(); | ||||||
| @@ -425,6 +438,25 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 		$this->checkpoints[$playerLogin][$structure->getCheckPointInLap()] = $structure->getLapTime(); | 		$this->checkpoints[$playerLogin][$structure->getCheckPointInLap()] = $structure->getLapTime(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Handle End of Lap Callback | ||||||
|  | 	 * | ||||||
|  | 	 * @internal | ||||||
|  | 	 * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure | ||||||
|  | 	 */ | ||||||
|  | 	public function handleFinishLapCallback(OnWayPointEventStructure $structure) { | ||||||
|  |  | ||||||
|  | 		$multiLapSaveSingle = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MULTILAP_SAVE_SINGLE); | ||||||
|  |  | ||||||
|  | 		if ($this->scriptName != "TimeAttack" && !$multiLapSaveSingle) { | ||||||
|  | 			//Do Nothing on Finishing a Single Lap | ||||||
|  | 		} else { | ||||||
|  | 			//Save on every pass through of a Lap | ||||||
|  | 			$this->saveRecord($structure, $structure->getLapTime()); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Handle Finish Callback | 	 * Handle Finish Callback | ||||||
| 	 * | 	 * | ||||||
| @@ -432,7 +464,12 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 	 * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure | 	 * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handleFinishCallback(OnWayPointEventStructure $structure) { | 	public function handleFinishCallback(OnWayPointEventStructure $structure) { | ||||||
| 		if ($structure->getLapTime() <= 0) { | 		$this->saveRecord($structure, $structure->getRaceTime());; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	private function saveRecord(OnWayPointEventStructure $structure, $time) { | ||||||
|  | 		if ($time <= 0) { | ||||||
| 			// Invalid time | 			// Invalid time | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -454,11 +491,11 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 		// Check old record of the player | 		// Check old record of the player | ||||||
| 		$oldRecord = $this->getLocalRecord($map, $player); | 		$oldRecord = $this->getLocalRecord($map, $player); | ||||||
| 		if ($oldRecord) { | 		if ($oldRecord) { | ||||||
| 			if ($oldRecord->time < $structure->getLapTime()) { | 			if ($oldRecord->time < $time) { | ||||||
| 				// Not improved | 				// Not improved | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| 			if ($oldRecord->time == $structure->getLapTime()) { | 			if ($oldRecord->time == $time) { | ||||||
| 				// Same time | 				// Same time | ||||||
| 				$message = '$3c0'; | 				$message = '$3c0'; | ||||||
| 				if ($notifyOnlyDriver) { | 				if ($notifyOnlyDriver) { | ||||||
| @@ -489,7 +526,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 				) VALUES ( | 				) VALUES ( | ||||||
| 				{$map->index}, | 				{$map->index}, | ||||||
| 				{$player->index}, | 				{$player->index}, | ||||||
| 				{$structure->getLapTime()}, | 				{$time}, | ||||||
| 				'{$checkpointsString}' | 				'{$checkpointsString}' | ||||||
| 				) ON DUPLICATE KEY UPDATE | 				) ON DUPLICATE KEY UPDATE | ||||||
| 				`time` = VALUES(`time`), | 				`time` = VALUES(`time`), | ||||||
| @@ -506,7 +543,6 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 		$improvedRank = (!$oldRecord || $newRecord->rank < $oldRecord->rank); | 		$improvedRank = (!$oldRecord || $newRecord->rank < $oldRecord->rank); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 		$message = '$3c0'; | 		$message = '$3c0'; | ||||||
| 		if ($notifyOnlyDriver) { | 		if ($notifyOnlyDriver) { | ||||||
| 			$message .= 'You'; | 			$message .= 'You'; | ||||||
| @@ -534,6 +570,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene | |||||||
| 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord); | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Get current checkpoint string for local record | 	 * Get current checkpoint string for local record | ||||||
| 	 * | 	 * | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user