Remove setGM and gm name, now combined with setAdminAccess. TODO: disables

This commit is contained in:
John 2015-06-18 22:26:42 +03:00
parent cf74341d9e
commit e0765526be
10 changed files with 16 additions and 245 deletions

View file

@ -154,8 +154,7 @@ dclass DistributedPlayer : DistributedAvatar {
setDISLid(uint32 = 0) broadcast ownrecv ram db airecv required;
WishName(string = "") db ram;
WishNameState(string = "OPEN") db ram;
setAdminAccess(uint16 = 0) broadcast ownrecv required airecv db;
setAsGM(bool = 0) required ram broadcast ownrecv airecv;
setAdminAccess(uint16 = 0) required broadcast ownrecv db;
};
dclass MagicWordManager : DistributedObject {
@ -581,7 +580,6 @@ typedef int16 pair16[2];
dclass DistributedToon : DistributedPlayer {
setDNAString(blob) required broadcast ownrecv db;
setGM(uint16 = 0) required broadcast ownrecv db;
setMaxBankMoney(int16 maxMoney = 10000) required broadcast ownrecv db;
setBankMoney(int16 money = 0) required broadcast ownrecv db;
setMaxMoney(int16 maxMoney = 40) required broadcast ownrecv db;

View file

@ -23,7 +23,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
except:
self.DistributedPlayer_initialized = 1
DistributedAvatar.DistributedAvatar.__init__(self, cr)
PlayerBase.PlayerBase.__init__(self)
TelemetryLimited.__init__(self)
self.__teleportAvailable = 0
self.inventory = None
@ -357,4 +356,4 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
self.autoRun = value
def getAutoRun(self):
return self.autoRun
return self.autoRun

View file

@ -9,9 +9,9 @@ from otp.distributed import OtpDoGlobals
from otp.otpbase import OTPLocalizer
class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.PlayerBase):
def __init__(self, air):
DistributedAvatarAI.DistributedAvatarAI.__init__(self, air)
PlayerBase.PlayerBase.__init__(self)
self.friendsList = []
self.DISLid = 0
self.adminAccess = 0
@ -157,8 +157,8 @@ def maintenance(minutes):
countdown(minutes)
@magicWord(category=CATEGORY_SYSTEM_ADMINISTRATOR, types=[str, str, int])
def accessLevel(accessLevel, storage='PERSISTENT', showGM=1):
@magicWord(category=CATEGORY_SYSTEM_ADMINISTRATOR, types=[str, str])
def accessLevel(accessLevel, storage='PERSISTENT'):
"""
Modify the target's access level.
"""
@ -205,8 +205,6 @@ def accessLevel(accessLevel, storage='PERSISTENT', showGM=1):
if target.getAdminAccess() == accessLevel:
return "%s's access level is already %d!" % (target.getName(), accessLevel)
target.b_setAdminAccess(accessLevel)
if showGM:
target.b_setGM(accessLevel)
temporary = storage.upper() in ('SESSION', 'TEMP', 'TEMPORARY')
if not temporary:
target.air.dbInterface.updateObject(
@ -219,4 +217,4 @@ def accessLevel(accessLevel, storage='PERSISTENT', showGM=1):
return "%s's access level has been set to %d." % (target.getName(), accessLevel)
else:
target.d_setSystemMessage(0, '%s set your access level to %d temporarily!' % (invoker.getName(), accessLevel))
return "%s's access level has been set to %d temporarily." % (target.getName(), accessLevel)
return "%s's access level has been set to %d temporarily." % (target.getName(), accessLevel)

View file

@ -1,18 +1,7 @@
class PlayerBase:
def __init__(self):
self.gmState = False
def atLocation(self, locationId):
return True
def getLocation(self):
return []
def setAsGM(self, state):
self.gmState = state
def isGM(self):
return self.gmState
return []

View file

@ -82,7 +82,6 @@ class Party(Place.Place):
self.ignore(self.partyPlannerDoneEvent)
self.partyPlanner.close()
del self.partyPlanner
self.__removePartyHat()
self.fog = None
self.ignoreAll()
self.parentFSMState.removeChild(self.fsm)
@ -197,21 +196,10 @@ class Party(Place.Place):
if hasattr(base, 'distributedParty'):
if base.distributedParty.partyInfo.hostId in base.cr.doId2do:
host = base.cr.doId2do[base.distributedParty.partyInfo.hostId]
if hasattr(host, 'gmIcon') and host.gmIcon:
host.removeGMIcon()
host.setGMPartyIcon()
else:
if not (hasattr(host, 'gmIcon') and host.gmIcon):
np = NodePath(host.nametag.getIcon())
base.distributedParty.partyHat.reparentTo(np)
def __removePartyHat(self):
if hasattr(base, 'distributedParty'):
if base.distributedParty.partyInfo.hostId in base.cr.doId2do:
host = base.cr.doId2do[base.distributedParty.partyInfo.hostId]
if hasattr(host, 'gmIcon') and host.gmIcon:
host.removeGMIcon()
host.setGMIcon()
def enterTeleportOut(self, requestStatus):
Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone)

View file

@ -61,7 +61,6 @@ from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals
from toontown.battle import BattleParticles
if base.wantKarts:
from toontown.racing.KartDNA import *
@ -69,7 +68,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedToon')
partyNotify = DirectNotifyGlobal.directNotify.newCategory('DistributedToon_Party')
chatGarbler = ToonChatGarbler.ToonChatGarbler()
gmNameTag = None
def __init__(self, cr, bFake = False):
try:
@ -83,8 +81,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
DistributedSmoothNode.DistributedSmoothNode.__init__(self, cr)
self.bFake = bFake
self.kart = None
self._isGM = False
self._gmType = None
self.trophyScore = 0
self.trophyStar = None
self.trophyStarSpeed = 0
@ -172,10 +168,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.hostedParties = []
self.partiesInvitedTo = []
self.partyReplyInfoBases = []
self.gmState = 0
self.gmNameTagEnabled = 0
self.gmNameTagColor = 'whiteGM'
self.gmNameTagString = ''
self.buffs = []
self.redeemedCodes = []
self.ignored = []
@ -221,7 +213,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
if self.doId in self.cr.toons:
del self.cr.toons[self.doId]
DistributedPlayer.DistributedPlayer.disable(self)
return
def delete(self):
try:
@ -255,6 +246,11 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
def setDNAString(self, dnaString):
Toon.Toon.setDNAString(self, dnaString)
def setAdminAccess(self, access):
DistributedPlayer.DistributedPlayer.setAdminAccess(self, access)
self.removeGMIcon()
self.setGMIcon()
def setDNA(self, dna):
if base.cr.newsManager:
if base.cr.newsManager.isHolidayRunning(ToontownGlobals.SPOOKY_BLACK_CAT):
@ -292,15 +288,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
def setShoes(self, idx, textureIdx, colorIdx):
Toon.Toon.setShoes(self, idx, textureIdx, colorIdx)
def setGM(self, type):
wasGM = self._isGM
self._isGM = type != 0
self._gmType = None
if self._isGM:
self._gmType = type
if self._isGM != wasGM:
self._handleGMName()
def setExperience(self, experience):
self.experience = Experience.Experience(experience, self)
if self.inventory:
@ -409,49 +396,12 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
return
self.defaultZone = zoneId
def setAsGM(self, state):
self.notify.debug('Setting GM State: %s' % state)
DistributedPlayer.DistributedPlayer.setAsGM(self, state)
def d_updateGMNameTag(self):
self.refreshName()
def updateGMNameTag(self, tagString, color, state):
try:
unicode(tagString, 'utf-8')
except UnicodeDecodeError:
self.sendUpdate('logSuspiciousEvent', ['invalid GM name tag: %s from %s' % (tagString, self.doId)])
return
def refreshName(self):
return
self.notify.debug('Refreshing GM Nametag String: %s Color: %s State: %s' % (self.gmNameTagString, self.gmNameTagColor, self.gmNameTagEnabled))
if hasattr(self, 'nametag') and self.gmNameTagEnabled:
self.setDisplayName(self.gmNameTagString)
self.setName(self.gmNameTagString)
self.trophyStar1 = loader.loadModel('models/misc/smiley')
self.trophyStar1.reparentTo(self.nametag.getIcon())
self.trophyStar1.setScale(1)
self.trophyStar1.setZ(2.25)
self.trophyStar1.setColor(Vec4(0.75, 0.75, 0.75, 0.75))
self.trophyStar1.setTransparency(1)
self.trophyStarSpeed = 15
else:
taskMgr.add(self.__refreshNameCallBack, self.uniqueName('refreshNameCallBack'))
def __starSpin1(self, task):
now = globalClock.getFrameTime()
r = now * 90 % 360.0
self.trophyStar1.setH(r)
return Task.cont
def __refreshNameCallBack(self, task):
if hasattr(self, 'nametag') and self.nametag.getName() != '':
self.refreshName()
return Task.done
else:
return Task.cont
def isAvFriend(self, avId):
return base.cr.isFriend(avId)
@ -1384,7 +1334,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
pie = Sequence(pie, Func(self.pieFinishedFlying, sequence))
self.pieTracks[sequence] = pie
pie.start(startTime)
return
def pieFinishedFlying(self, sequence):
if sequence in self.pieTracks:
@ -1438,7 +1387,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.tossTrack.finish()
self.tossTrack = None
self.cleanupPieModel()
return
def setNumPies(self, numPies):
self.numPies = numPies
@ -1492,7 +1440,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.trophyStarSpeed = 8
if self.trophyScore >= ToontownGlobals.TrophyStarLevels[1]:
taskMgr.add(self.__starSpin, self.uniqueName('starSpin'))
return
def __starSpin(self, task):
now = globalClock.getFrameTime()
@ -2413,27 +2360,11 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
seq = Sequence(self.hpText.posInterval(1.0, Point3(0, 0, self.height + 1.5), blendType='easeOut'), Wait(0.85), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHpText))
seq.start()
def setName(self, name = 'unknownDistributedAvatar'):
DistributedPlayer.DistributedPlayer.setName(self, name)
self._handleGMName()
def _handleGMName(self):
name = self.name
self.setDisplayName(name)
if self._isGM:
self.setGMIcon(self._gmType)
self.gmToonLockStyle = False
else:
self.gmToonLockStyle = False
self.removeGMIcon()
def setGMIcon(self, gmType=None):
def setGMIcon(self):
if hasattr(self, 'gmIcon') and self.gmIcon:
return
if not gmType:
gmType = self._gmType
icons = loader.loadModel('phase_3/models/props/gm_icons.bam')
searchString = '**/access_level_' + str(gmType)
icons = loader.loadModel('phase_3/models/props/gm_icons')
searchString = '**/access_level_' + str(self.adminAccess)
self.gmIcon = icons.find(searchString)
np = NodePath(self.nametag.getIcon())
if np.isEmpty():
@ -2446,22 +2377,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.gmIconInterval = LerpHprInterval(self.gmIcon, 3.0, Point3(0, 0, 0), Point3(-360, 0, 0))
self.gmIconInterval.loop()
def setGMPartyIcon(self):
gmType = self._gmType
iconInfo = ('phase_3.5/models/gui/tt_m_gui_gm_toonResistance_fist', 'phase_3.5/models/gui/tt_m_gui_gm_toontroop_whistle', 'phase_3.5/models/gui/tt_m_gui_gm_toonResistance_fist', 'phase_3.5/models/gui/tt_m_gui_gm_toontroop_getConnected')
if gmType > len(iconInfo) - 1:
return
self.gmIcon = loader.loadModel(iconInfo[gmType])
self.gmIcon.reparentTo(NodePath(self.nametag.getIcon()))
self.gmIcon.setScale(3.25)
self.setTrophyScore(self.trophyScore)
self.gmIcon.setZ(1.0)
self.gmIcon.setY(0.0)
self.gmIcon.setColor(Vec4(1.0, 1.0, 1.0, 1.0))
self.gmIcon.setTransparency(1)
self.gmIconInterval = LerpHprInterval(self.gmIcon, 3.0, Point3(0, 0, 0), Point3(-360, 0, 0))
self.gmIconInterval.loop()
def removeGMIcon(self):
if hasattr(self, 'gmIconInterval') and self.gmIconInterval:
self.gmIconInterval.finish()

View file

@ -109,8 +109,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.unlimitedGags = 0
self.numPies = 0
self.pieType = 0
self._isGM = False
self._gmType = None
self.hpOwnedByBattle = 0
if simbase.wantPets:
self.petTrickPhrases = []
@ -155,7 +153,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.partiesInvitedTo = []
self.partyReplyInfoBases = []
self.teleportOverride = 0
self._gmDisabled = False
self.buffs = []
self.redeemedCodes = []
self.ignored = []
@ -3894,56 +3891,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
def setAwardNotify(self, awardNotify):
self.awardNotify = awardNotify
def b_setGM(self, gmType):
if (gmType < CATEGORY_USER.defaultAccess) and (gmType != 0):
gmType = self.getGMType()
self.sendUpdate('setGM', [gmType])
self.setGM(gmType)
def setGM(self, gmType):
if (gmType < CATEGORY_USER.defaultAccess) and (gmType != 0):
gmType = self.getGMType()
self._isGM = gmType != 0
self._gmType = None
if self._isGM:
self._gmType = gmType
def isGM(self):
return (self._isGM and (not self._gmDisabled))
def getGMType(self):
gmType = self._gmType
if (gmType < CATEGORY_USER.defaultAccess) and (gmType != 0):
gmType = self.getAdminAccess()
return gmType
def _nameIsPrefixed(self, prefix):
if len(self.name) > len(prefix):
if self.name[:len(prefix)] == prefix:
return True
return False
def _updateGMName(self, formerType = None):
if formerType is None:
formerType = self._gmType
name = self.name
if formerType is not None:
gmPrefix = TTLocalizer.GM_NAMES[formerType] + ' '
if self._nameIsPrefixed(gmPrefix):
name = self.name[len(gmPrefix):]
if self._isGM:
gmPrefix = TTLocalizer.GM_NAMES[self._gmType] + ' '
newName = gmPrefix + name
else:
newName = name
if self.name != newName:
self.b_setName(newName)
return
def setName(self, name):
DistributedPlayerAI.DistributedPlayerAI.setName(self, name)
self._updateGMName()
def teleportResponseToAI(self, toAvId, available, shardId, hoodId, zoneId, fromAvId):
senderId = self.air.getAvatarIdFromSender()
if toAvId != self.doId:
@ -4461,49 +4408,6 @@ def shoes(shoesIndex, shoesTex=0):
invoker.b_setShoes(shoesIndex, shoesTex, 0)
return "Set %s's shoes to %d, %d!" % (invoker.getName(), shoesIndex, shoesTex)
@magicWord(category=CATEGORY_COMMUNITY_MANAGER, types=[int])
def gmIcon(accessLevel=None):
"""
Toggles the target's GM icon. If an access level is provided, however, the
target's GM icon will be overridden.
"""
invoker = spellbook.getInvoker()
target = spellbook.getTarget()
invokerAccess = spellbook.getInvokerAccess()
if invokerAccess != CATEGORY_SYSTEM_ADMINISTRATOR.defaultAccess:
if accessLevel is not None:
return "You must be of a higher access level to override your GM icon."
target = spellbook.getInvoker()
target.sendUpdate('setGM', [0])
if target.isGM() and (accessLevel is None):
target._gmDisabled = True
if target == invoker:
return 'Your GM icon has been disabled for this session!'
return "%s's GM icon has been disabled for this session!" % target.getName()
else:
target._gmDisabled = False
if accessLevel is None:
accessLevel = target.getAdminAccess()
if accessLevel != target.getGMType():
if invokerAccess != CATEGORY_SYSTEM_ADMINISTRATOR.defaultAccess:
accessLevel = target.getGMType()
if accessLevel not in (0,
CATEGORY_COMMUNITY_MANAGER.defaultAccess,
CATEGORY_MODERATOR.defaultAccess,
CATEGORY_CREATIVE.defaultAccess,
CATEGORY_PROGRAMMER.defaultAccess,
CATEGORY_ADMINISTRATOR.defaultAccess,
CATEGORY_SYSTEM_ADMINISTRATOR.defaultAccess):
return 'Invalid access level!'
target.b_setGM(accessLevel)
if accessLevel == target.getAdminAccess():
if target == invoker:
return 'Your GM icon is now enabled!'
return "%s's GM icon is now enabled!" % target.getName()
if target == invoker:
return 'Your GM icon has been set to: ' + str(accessLevel)
return "%s's GM icon has been set to: %d" % (target.getName(), accessLevel)
@magicWord(category=CATEGORY_COMMUNITY_MANAGER)
def ghost():
"""

View file

@ -10,9 +10,6 @@ class DistributedToonUD(DistributedObjectUD):
def setDNAString(self, todo0):
pass
def setGM(self, todo0):
pass
def setMaxBankMoney(self, todo0):
pass

View file

@ -412,19 +412,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.gardenPage = GardenPage.GardenPage()
self.gardenPage.load()
self.book.addPage(self.gardenPage, pageName=TTLocalizer.GardenPageTitle)
return
def setAsGM(self, state):
self.notify.debug('Setting GM State: %s in LocalToon' % state)
DistributedToon.DistributedToon.setAsGM(self, state)
if self.gmState:
if base.config.GetString('gm-nametag-string', '') != '':
self.gmNameTagString = base.config.GetString('gm-nametag-string')
if base.config.GetString('gm-nametag-color', '') != '':
self.gmNameTagColor = base.config.GetString('gm-nametag-color')
if base.config.GetInt('gm-nametag-enabled', 0):
self.gmNameTagEnabled = 1
self.d_updateGMNameTag()
def displayTalkWhisper(self, avId, chat):
sender = base.cr.identifyAvatar(avId)

View file

@ -60,10 +60,6 @@ NametagFontNames = (
NametagLabel = ' Nametag'
BasicNameTag = 'Basic'
ScreenshotPath = 'user/screenshots/'
GM_NAMES = ('TOON COUNCIL',
'TOON TROOPER',
'RESISTANCE RANGER',
'GC')
Flippy = 'Flippy'
lTheBrrrgh = 'The Brrrgh'
lDaisyGardens = 'Daisy Gardens'