def onMapVote(cn, mapname, mapmode): p = player(cn) if sbserver.mapName() == '': setMap(mapname, mapmode) elif isAtLeastMaster(cn) and sbserver.masterMode() > 0: setMap(mapname, mapmode) elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote): p.message(error('You cannot vote for a new game mode')) else: try: vote = player(cn).gamevars['mapvote'] allow_vote = vote[0] != mapname and vote[1] != mapmode except KeyError: allow_vote = True if allow_vote: sbserver.message( info( request_temp.substitute( colordict, user=p.name(), modename=sbserver.modeName(mapmode), mapname=mapname))) p.gamevars['mapvote'] = (mapname, mapmode) else: sbserver.playerMessage( cn, error('You have already requested this map.')) countVotes()
def onMapSet(cn, mapname, mapmode): p = player(cn) if sbserver.mapName() == '': setMap(mapname, mapmode) elif mapreload[0]: setMap(mapname, mapmode) mapreload[0] = False elif isAtLeastMaster(cn) and sbserver.masterMode() > 0: sbserver.setMap(mapname, mapmode) elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote): p.message(error('You cannot request a new game mode'))
def savemap(caller,name=None): """This allows players to savemaps to the server. This not only allows for easier transfer of files later on, but also allows for partial asynchronous work on a map by saving the map back to the server.""" if name is None: name=sbserver.mapName() ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"wb") mapdata=sbserver.getMapDataFile() mapdata.seek(0) ogz.write(mapdata.read()) ogz.close() triggerServerEvent("savemap",[caller,name,ogzfilename])
def savemap(caller,name=None): """Saves the map to the server. Note that the map must be sent prior to saving.""" if name is None: name=sbserver.mapName() ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"wb") mapdata=sbserver.getMapDataFile() mapdata.seek(0) ogz.write(mapdata.read()) ogz.close() triggerServerEvent("savemap",[caller,name,ogzfilename])
def presetRotate(): try: map = getSuccessor(sbserver.gameMode(), sbserver.mapName()) except KeyError: logging.warning('No map list specified for current mode. Defaulting to user-specified rotation.') clientReloadRotate() except ValueError: logging.info('Maps list for current mode is empty. Defaulting to user-specified rotation.') clientReloadRotate() else: sbserver.setMap(map, sbserver.gameMode()) if sbserver.numClients() == 0: rotate_on_join[0] = True sbserver.setPaused(True)
def loadmap(caller,name=None): """This is the opposite of #savemap. This is automatically executed when you change to a map that the server has in storage.""" if name is None: name=sbserver.mapName() ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"rb") mapdata=sbserver.getMapDataFile() mapdata.seek(0) mapdata.truncate(0) mapdata.write(ogz.read()) mapdata.flush() ogz.close() triggerServerEvent("loadmap",[caller,name,ogzfilename])
def onNextMapCmd(cn, args): '''@description Display next map @usage @public''' if args != '': sbserver.playerMessage(cn, error('Usage: #nextmap')) else: try: sbserver.playerMessage( cn, info( nextmap_response.substitute(colordict, mapname=getSuccessor( sbserver.gameMode(), sbserver.mapName())))) except (KeyError, ValueError): sbserver.playerMessage(cn, error('Could not determine next map'))
def presetRotate(): try: map = getSuccessor(sbserver.gameMode(), sbserver.mapName()) except KeyError: logging.warning( 'No map list specified for current mode. Defaulting to user-specified rotation.' ) clientReloadRotate() except ValueError: logging.info( 'Maps list for current mode is empty. Defaulting to user-specified rotation.' ) clientReloadRotate() else: sbserver.setMap(map, sbserver.gameMode()) if sbserver.numClients() == 0: rotate_on_join[0] = True sbserver.setPaused(True)
def onMapVote(cn, mapname, mapmode): p = player(cn) if sbserver.mapName() == '': setMap(mapname, mapmode) elif isAtLeastMaster(cn) and sbserver.masterMode() > 0: setMap(mapname, mapmode) elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote): p.message(error('You cannot vote for a new game mode')) else: try: vote = player(cn).gamevars['mapvote'] allow_vote = vote[0] != mapname and vote[1] != mapmode except KeyError: allow_vote = True if allow_vote: sbserver.message(info(request_temp.substitute(colordict, user=p.name(), modename=sbserver.modeName(mapmode), mapname=mapname))) p.gamevars['mapvote'] = (mapname, mapmode) else: sbserver.playerMessage(cn, error('You have already requested this map.')) countVotes()
def currentMap(): '''Name of current map''' return sbserver.mapName()
def onNextMapCmd(cn, args): '''@description Display next map @usage @public''' if args != '': sbserver.playerMessage(cn, error('Usage: #nextmap')) else: try: sbserver.playerMessage(cn, info(nextmap_response.substitute(colordict, mapname=getSuccessor(sbserver.gameMode(), sbserver.mapName())))) except (KeyError, ValueError): sbserver.playerMessage(cn, error('Could not determine next map'))