Exemple #1
0
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))
Exemple #2
0
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.")
Exemple #3
0
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.")
Exemple #4
0
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.")
Exemple #5
0
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
Exemple #6
0
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))))
Exemple #7
0
	def failreg(self, args):
		self.responses_needed -= 1
		serverNotice('Master server registration failed: %s' % args)
		triggerServerEvent('master_registration_failed', ())
Exemple #8
0
	def succreg(self, args):
		self.responses_needed -= 1
		serverNotice('Master server registration successful')
		triggerServerEvent('master_registration_succeeded', ())
Exemple #9
0
def deletefile(caller,filename):
	"""Deletes the specified file from the server."""
	filename=safepath(config["storage"],filename)
	os.remove(filename)
	serverNotice("Deleted %s" % (filename,))
Exemple #10
0
def deletefile(caller,filename):
	filename=safepath(config["storage"],filename)
	os.remove(filename)
	serverNotice("Deleted %s" % (filename,))
Exemple #11
0
def noclients():
	serverNotice("Server is now empty.")
	systemCS.executestring("mastermode %s" % (config["defaultmastermode"]))