def downloadfile(caller,address,filename=None): if filename is None: filename=posixpath.split(address)[-1] source=urllib2.urlopen(address) destfilename,destination=openfile(filename,"wb") destination.write(source.read()) destination.close() serverNotice("Downloaded %s to %s" % (address,destfilename))
def loadimage1(caller,imagename,s=16,maxh=20): s=int(s) (xsize, ysize, heights)=loadheightmap(imagename,int(maxh)) serverNotice("Loading image %s for blocky heightmaps. %sx%sx%s" % (imagename,xsize,ysize,s)) mapsize=base.newmap(caller,math.ceil(max(math.log(xsize*s,2),math.log(ysize*s,2)))) middleheight=2**(mapsize-1)/s for y in xrange(ysize): for x in xrange(xsize): cubes.makecolumn(caller,x,y,middleheight,heights[x][y],s) serverNotice("Done filling packet queue with heightmap.")
def loadimage1(caller,imagename,s=16,maxh=20): '''Loads an image and starts the process of converting a heightmap into cube packets for map generation(blocky).''' s=int(s) (xsize, ysize, heights)=loadheightmap(imagename,int(maxh)) serverNotice("Loading image %s for blocky heightmaps. %sx%sx%s" % (imagename,xsize,ysize,s)) mapsize=base.newmap(caller,math.ceil(max(math.log(xsize*s,2),math.log(ysize*s,2)))) middleheight=2**(mapsize-1)/s for y in xrange(ysize): for x in xrange(xsize): cubes.makecolumn(caller,x,y,middleheight,heights[x][y],s) serverNotice("Done filling packet queue with heightmap.")
def loadimage2(caller,imagename,s=16,maxh=20): s=int(s) (xsize, ysize, heights)=loadheightmap(imagename,int(maxh)*8) serverNotice("Loading image %s for smooth heightmaps. %sx%sx%s" % (imagename,xsize,ysize,s)) mapsize=base.newmap(caller,math.ceil(max(math.log(xsize*s,2),math.log(ysize*s,2)))) middleheight=2**(mapsize-1)/s for y in xrange(ysize-1): for x in xrange(xsize-1): neighbourheights=(heights[y][x],heights[y][x+1],heights[y+1][x],heights[y+1][x+1]) cubeheight=(max(neighbourheights)-1)/8+1 cubes.makecolumn(caller,x,y,middleheight,cubeheight,s) cubes.corners(x,y,middleheight+cubeheight-1,(cubeheight*8-h for h in neighbourheights),s) serverNotice("Done filling packet queue with heightmap.")
def checkConnectBanned(cn): checklist=( sbserver.playerName(cn), ipLongToString(sbserver.playerIpLong(cn)) ) matches=bandatabase.search(checklist) if len(matches)>0: timeperiod="indefinatelly" reason=matches[0][2] if reason== "": reason="none" serverNotice("%s is banned %s, reason: %s" % (sbserver.playerName(cn),matches[0][1],reason)) return True return False
def noticeEditPacket(cn,packettype,*data): if config["editpacketnotices"]=="yes": serverNotice("Edit Packet from %s: %s %s" % (formatCaller(("ingame",cn)),packettypes[packettype][0],' '.join(map(str,data))))
def failreg(self, args): self.responses_needed -= 1 serverNotice('Master server registration failed: %s' % args) triggerServerEvent('master_registration_failed', ())
def succreg(self, args): self.responses_needed -= 1 serverNotice('Master server registration successful') triggerServerEvent('master_registration_succeeded', ())
def deletefile(caller,filename): """Deletes the specified file from the server.""" filename=safepath(config["storage"],filename) os.remove(filename) serverNotice("Deleted %s" % (filename,))
def deletefile(caller,filename): filename=safepath(config["storage"],filename) os.remove(filename) serverNotice("Deleted %s" % (filename,))
def noclients(): serverNotice("Server is now empty.") systemCS.executestring("mastermode %s" % (config["defaultmastermode"]))