From 6ac39df62add3f89a2f93ad0394e572e10571535 Mon Sep 17 00:00:00 2001 From: Loudrob Date: Mon, 13 Jul 2015 13:04:39 -0400 Subject: [PATCH] District Reset Prevention. --- otp/otpbase/OTPLocalizerEnglish.py | 3 +- .../distributed/ToontownInternalRepository.py | 29 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/otp/otpbase/OTPLocalizerEnglish.py b/otp/otpbase/OTPLocalizerEnglish.py index 401fcdb1..490d7151 100755 --- a/otp/otpbase/OTPLocalizerEnglish.py +++ b/otp/otpbase/OTPLocalizerEnglish.py @@ -132,7 +132,8 @@ CRBootedReasons = {100: 'You have been disconnected because someone else just lo 102: 'You are not authorized to use administrator privileges.', 103: 'You were banned by a moderator.\n\nBehave next time!', 105: 'Toontown Stride is now temporarily closed for maintenance. Everyone who was playing has been disconnected from the game.\n\nFor more information, please visit the Toontown Stride website.', - 153: 'The district you were playing on has been reset. Everyone who was playing on that district has been disconnected. However, you should be able to connect again and go right back into the game.'} + 153: 'The district you were playing on has been reset. Everyone who was playing on that district has been disconnected. However, you should be able to connect again and go right back into the game.', + 166: 'You were disconnected to prevent a district reset.'} CRBootedReasonUnknownCode = 'An unexpected problem has occurred (error code %s). Your connection has been lost, but you should be able to connect again and go right back into the game.' CRTryConnectAgain = '\n\nTry to connect again?' CRToontownUnavailable = 'The server appears to be temporarily unavailable, still trying...' diff --git a/toontown/distributed/ToontownInternalRepository.py b/toontown/distributed/ToontownInternalRepository.py index 0dba7ba3..3bf1b399 100755 --- a/toontown/distributed/ToontownInternalRepository.py +++ b/toontown/distributed/ToontownInternalRepository.py @@ -1,6 +1,9 @@ from direct.distributed.AstronInternalRepository import AstronInternalRepository from otp.distributed.OtpDoGlobals import * from toontown.distributed.ToontownNetMessengerAI import ToontownNetMessengerAI +from direct.distributed.PyDatagram import PyDatagram +import traceback +import sys class ToontownInternalRepository(AstronInternalRepository): GameGlobalsId = OTP_DO_ID_TOONTOWN @@ -32,13 +35,35 @@ class ToontownInternalRepository(AstronInternalRepository): AstronInternalRepository.handleDatagram(self, di) def getAvatarIdFromSender(self): - return self.getMsgSender() & 0xFFFFFFFF + return int(self.getMsgSender() & 0xFFFFFFFF) def getAccountIdFromSender(self): - return (self.getMsgSender()>>32) & 0xFFFFFFFF + return int((self.getMsgSender()>>32) & 0xFFFFFFFF) def _isValidPlayerLocation(self, parentId, zoneId): if zoneId < 1000 and zoneId != 1: return False return True + + def readerPollOnce(self): + try: + return AstronInternalRepository.readerPollOnce(self) + + except SystemExit, KeyboardInterrupt: + raise + + except Exception as e: + if self.getAvatarIdFromSender() > 100000000: + dg = PyDatagram() + dg.addServerHeader(self.getMsgSender(), self.ourChannel, CLIENTAGENT_EJECT) + dg.addUint16(166) + dg.addString('You were disconnected to prevent a district reset.') + self.send(dg) + + self.writeServerEvent('INTERNAL-EXCEPTION', self.getAvatarIdFromSender(), self.getAccountIdFromSender(), repr(e), traceback.format_exc()) + self.notify.warning('INTERNAL-EXCEPTION: %s (%s)' % (repr(e), self.getAvatarIdFromSender())) + print traceback.format_exc() + sys.exc_clear() + + return 1