def playerLeaveWorld(self, player): zones = copy(self.liveZoneInstances) zones.extend(self.waitingZoneInstances) if CoreSettings.PGSERVER: self.daemonPerspective.callRemote("playerLeftWorld", player.publicName, player.transfering) if CoreSettings.MAXPARTY == 1 and not player.transfering: self.clearDeathMarker(player) for zinst in zones: if player == zinst.owningPlayer: #XXX remove all this owningPlayer crap, it was a good idea at the time self.closeZone(zinst) #hm self.activePlayers.remove(player) player.zone = None if player.extract: CharacterServerAvatar.extractLoggingPlayer( player, not player.enteringWorld) if self.singlePlayer: self.shutdown()
def DaemonConnected(perspective): from mud.world.cserveravatar import CharacterServerAvatar csa = CharacterServerAvatar() world = World.byName("TheWorld") world.daemonPerspective = perspective DAEMON.perspective = perspective d = perspective.callRemote("setWorldPID",os.getpid(),WORLDPORT,str(world.genesisTime),csa) d.addCallback(GotCSMind) zpid = [] zport = [] zpassword = [] for zname in STATICZONES: for z in world.liveZoneInstances: if zname == z.zone.name: if z.pid == None: print_stack() print "AssertionError: z.pid is None!" return zpid.append(z.pid) zpassword.append(z.password) zport.append(z.port) #this also marks this cluster server as live perspective.callRemote("setZonePID",zpid,zport,zpassword) from mud.worldserver.charutil import SetClusterNum SetClusterNum(CLUSTER) THESERVER.allowConnections = True THEWORLD.allowConnections = True
def playerLeaveWorld(self, player): zones = copy(self.liveZoneInstances) zones.extend(self.waitingZoneInstances) if CoreSettings.PGSERVER: self.daemonPerspective.callRemote("playerLeftWorld",player.publicName,player.transfering) if CoreSettings.MAXPARTY == 1 and not player.transfering: self.clearDeathMarker(player) for zinst in zones: if player == zinst.owningPlayer: #XXX remove all this owningPlayer crap, it was a good idea at the time self.closeZone(zinst) #hm self.activePlayers.remove(player) player.zone = None if player.extract: CharacterServerAvatar.extractLoggingPlayer(player,not player.enteringWorld) if self.singlePlayer: self.shutdown()
def tick(self): if not self.running: return reactor.callLater(.5, self.tick) #2x sec if False: #CoreSettings.PGSERVER: if len(self.liveZoneInstances) == len( self.staticZoneNames) and self.allowConnections: if not len(self.activePlayers) and self.priority: self.priority = 0 win32process.SetPriorityClass( win32process.GetCurrentProcess(), win32process.IDLE_PRIORITY_CLASS) if len(self.activePlayers) and not self.priority: self.priority = 1 win32process.SetPriorityClass( win32process.GetCurrentProcess(), win32process.NORMAL_PRIORITY_CLASS) #if not self.priority: # win32api.Sleep(2000) elif not self.priority: self.priority = 1 win32process.SetPriorityClass( win32process.GetCurrentProcess(), win32process.NORMAL_PRIORITY_CLASS) if False: #RPG_BUILD_DEMO: t = sysTime() - self.pauseTime if 13 * 60 >= t >= 12 * 60: self.paused = True elif t > 13 * 60: self.paused = False self.pauseTime = sysTime() else: self.paused = False self.time.tick() #store in db if self.time.hour != self.hour: self.minute = self.time.minute self.hour = self.time.hour self.day = self.time.day CharacterServerAvatar.tick() #if self.lasttime == -1: # self.lasttime = sysTime()-2 #delta = sysTime()-self.lasttime #if delta > .5: #self.lasttime = sysTime() if CoreSettings.PGSERVER: if self.isShuttingDown: self.cpuSpawn = 0 self.cpuDespawn = 0 else: self.cpuSpawn = 4 self.cpuDespawn = 8 else: self.cpuSpawn = 1000000 self.cpuDespawn = 1000000 # Select the zone which will be allowed to spawn mobs. spawnZone = None if len(self.liveZoneInstances) > 0: if self.spawnZoneIndex > len(self.liveZoneInstances) - 1: self.spawnZoneIndex = 0 spawnZone = self.liveZoneInstances[self.spawnZoneIndex] self.spawnZoneIndex += 1 # Tick all live zone instances. for z in self.liveZoneInstances: z.tick(spawnZone) #weed out dynamic zones that haven't any players for x amount of time #we need to weed out failed zones (stuck in waiting, etc) if not self.singlePlayer: timedOut = [] for z in self.liveZoneInstances: if not z.dynamic: continue if not len(z.players) and not len(z.playerQueue): if z.timeOut == -1: z.timeOut = sysTime() elif (sysTime() - z.timeOut) / 60 > 20: # 20 minutes timedOut.append(z) else: z.timeOut = -1 for z in timedOut: self.closeZone(z) # Backup single player data every minute. else: self.singlePlayerBackupTimer -= 1 if self.singlePlayerBackupTimer < 0: # Reset timer to one minute. self.singlePlayerBackupTimer = 120 for player in self.activePlayers: # If there's no party, player hasn't logged in yet and # there's no need to back up. if player.party: player.backupPlayer() # Force a write to database. conn = Persistent._connection.getConnection() cursor = conn.cursor() cursor.execute("END;") cursor.execute("BEGIN;") cursor.close()
def tick(self): if not self.running: return reactor.callLater(.5,self.tick) #2x sec if False:#CoreSettings.PGSERVER: if len(self.liveZoneInstances)==len(self.staticZoneNames) and self.allowConnections: if not len(self.activePlayers) and self.priority: self.priority = 0 win32process.SetPriorityClass(win32process.GetCurrentProcess(),win32process.IDLE_PRIORITY_CLASS) if len(self.activePlayers) and not self.priority: self.priority = 1 win32process.SetPriorityClass(win32process.GetCurrentProcess(),win32process.NORMAL_PRIORITY_CLASS) #if not self.priority: # win32api.Sleep(2000) elif not self.priority: self.priority = 1 win32process.SetPriorityClass(win32process.GetCurrentProcess(),win32process.NORMAL_PRIORITY_CLASS) if False:#RPG_BUILD_DEMO: t = sysTime() - self.pauseTime if 13*60 >= t >= 12*60: self.paused = True elif t>13*60: self.paused = False self.pauseTime = sysTime() else: self.paused=False self.time.tick() #store in db if self.time.hour != self.hour: self.minute = self.time.minute self.hour = self.time.hour self.day = self.time.day CharacterServerAvatar.tick() #if self.lasttime == -1: # self.lasttime = sysTime()-2 #delta = sysTime()-self.lasttime #if delta > .5: #self.lasttime = sysTime() if CoreSettings.PGSERVER: if self.isShuttingDown: self.cpuSpawn = 0 self.cpuDespawn = 0 else: self.cpuSpawn = 4 self.cpuDespawn = 8 else: self.cpuSpawn = 1000000 self.cpuDespawn = 1000000 # Select the zone which will be allowed to spawn mobs. spawnZone = None if len(self.liveZoneInstances) > 0: if self.spawnZoneIndex > len(self.liveZoneInstances) - 1: self.spawnZoneIndex = 0 spawnZone = self.liveZoneInstances[self.spawnZoneIndex] self.spawnZoneIndex += 1 # Tick all live zone instances. for z in self.liveZoneInstances: z.tick(spawnZone) #weed out dynamic zones that haven't any players for x amount of time #we need to weed out failed zones (stuck in waiting, etc) if not self.singlePlayer: timedOut = [] for z in self.liveZoneInstances: if not z.dynamic: continue if not len(z.players) and not len(z.playerQueue): if z.timeOut == -1: z.timeOut = sysTime() elif (sysTime() - z.timeOut)/60 > 20: # 20 minutes timedOut.append(z) else: z.timeOut = -1 for z in timedOut: self.closeZone(z) # Backup single player data every minute. else: self.singlePlayerBackupTimer -= 1 if self.singlePlayerBackupTimer < 0: # Reset timer to one minute. self.singlePlayerBackupTimer = 120 for player in self.activePlayers: # If there's no party, player hasn't logged in yet and # there's no need to back up. if player.party: player.backupPlayer() # Force a write to database. conn = Persistent._connection.getConnection() cursor = conn.cursor() cursor.execute("END;") cursor.execute("BEGIN;") cursor.close()