Skip to content

Instantly share code, notes, and snippets.

@iamgreaser
Last active December 17, 2015 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamgreaser/5545670 to your computer and use it in GitHub Desktop.
Save iamgreaser/5545670 to your computer and use it in GitHub Desktop.
64-player support for the pysnip server (go to pyspades/server.py and adjust the POWERTHIRST = False line to say True to activate the extra stuff that isn't supported in the vanilla client)
diff -r a808462ccd67 feature_server/commands.py
--- a/feature_server/commands.py Sun Dec 30 06:15:38 2012 -0500
+++ b/feature_server/commands.py Fri May 10 13:22:40 2013 +1200
@@ -190,6 +190,13 @@
connection.protocol.send_chat(value)
connection.protocol.irc_say(value)
+@admin
+def csay(connection, color, *arg):
+ value = ' '.join(arg)
+ color = int(color)
+ connection.protocol.send_chat(value, color = color)
+ connection.protocol.irc_say(value)
+
add_rights('kill', 'admin')
def kill(connection, value = None):
if value is None:
@@ -862,6 +869,7 @@
deaf,
global_chat,
say,
+ csay,
kill,
heal,
lock,
diff -r a808462ccd67 feature_server/run.py
--- a/feature_server/run.py Sun Dec 30 06:15:38 2012 -0500
+++ b/feature_server/run.py Fri May 10 13:22:40 2013 +1200
@@ -913,10 +913,10 @@
reactor.callLater(self.tip_frequency * 60, self.send_tip)
def send_chat(self, value, global_message = True, sender = None,
- team = None, irc = False):
+ team = None, irc = False, color = 0):
if irc:
self.irc_say('* %s' % value)
- ServerProtocol.send_chat(self, value, global_message, sender, team)
+ ServerProtocol.send_chat(self, value, global_message, sender, team, color = color)
# log high CPU usage
diff -r a808462ccd67 pyspades/server.py
--- a/pyspades/server.py Sun Dec 30 06:15:38 2012 -0500
+++ b/pyspades/server.py Fri May 10 13:22:40 2013 +1200
@@ -15,6 +15,15 @@
# You should have received a copy of the GNU General Public License
# along with pyspades. If not, see <http://www.gnu.org/licenses/>.
+POWERTHIRST = False # Set this to True if you want 64-player support and whatnot (requires Powerthirst Edition)
+
+SUPER_MAX_PLAYERS = 32
+MAX_NAME_LENGTH = 15
+
+if POWERTHIRST:
+ SUPER_MAX_PLAYERS = 64
+ MAX_NAME_LENGTH = 31
+
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from pyspades.protocol import BaseConnection, BaseProtocol
@@ -201,6 +210,7 @@
last_block = None
map_data = None
last_position_update = None
+ local = False
def __init__(self, *arg, **kw):
BaseConnection.__init__(self, *arg, **kw)
@@ -211,10 +221,12 @@
self.rapids = SlidingWindow(RAPID_WINDOW_ENTRIES)
def on_connect(self):
+ if self.local:
+ return
if self.peer.eventData != self.protocol.version:
self.disconnect(ERROR_WRONG_VERSION)
return
- max_players = min(32, self.protocol.max_players)
+ max_players = min(SUPER_MAX_PLAYERS, self.protocol.max_players)
if len(self.protocol.connections) > max_players:
self.disconnect(ERROR_FULL)
return
@@ -276,6 +288,10 @@
return
if returned is not None:
x, y, z = returned
+ if abs(x**2 + y**2 + z**2 - 1.0) > 0.005 and self.team != self.protocol.spectator_team and (self.user_types is None or 'admin' not in self.user_types):
+ self.on_hack_attempt(
+ 'Ghetto hack detected %s' % self.user_types)
+ return
world_object.set_orientation(x, y, z)
elif contained.id == loaders.PositionData.id:
current_time = reactor.seconds()
@@ -1088,7 +1104,7 @@
def send_data(self, data):
self.protocol.transport.write(data, self.address)
- def send_chat(self, value, global_message = None):
+ def send_chat(self, value, global_message = None, color = 0):
if self.deaf:
return
if global_message is None:
@@ -1097,7 +1113,9 @@
else:
chat_message.chat_type = CHAT_TEAM
# 34 is guaranteed to be out of range!
- chat_message.player_id = 35
+ # Yeah, Right (even a value of 67 works fine in an unmodded client) --GM
+ # the color= value is for the Powerthirst Edition only, it will be blue on vanilla --GM
+ chat_message.player_id = SUPER_MAX_PLAYERS+3+(color%8)
prefix = self.protocol.server_prefix + ' '
lines = textwrap.wrap(value, MAX_CHAT_SIZE - len(prefix) - 1)
for line in lines:
@@ -1444,7 +1462,7 @@
name = 'pyspades server'
game_mode = CTF_MODE
- max_players = 32
+ max_players = SUPER_MAX_PLAYERS
connections = None
player_ids = None
master = False
@@ -1582,7 +1600,7 @@
def update_network(self):
items = []
- for i in xrange(32):
+ for i in xrange(SUPER_MAX_PLAYERS):
position = orientation = None
try:
player = self.players[i]
@@ -1649,12 +1667,12 @@
def get_name(self, name):
name = name.replace('%', '').encode('ascii', 'ignore')
- new_name = name
+ new_name = name[:MAX_NAME_LENGTH]
names = [p.name.lower() for p in self.players.values()]
i = 0
while new_name.lower() in names:
i += 1
- new_name = name + str(i)
+ new_name = name[:MAX_NAME_LENGTH-len(str(i))] + str(i)
return new_name
def get_mode_mode(self):
@@ -1714,7 +1732,7 @@
entity.update()
def send_chat(self, value, global_message = None, sender = None,
- team = None):
+ team = None, color = 0):
for player in self.players.values():
if player is sender:
continue
@@ -1722,7 +1740,7 @@
continue
if team is not None and player.team is not team:
continue
- player.send_chat(value, global_message)
+ player.send_chat(value, global_message, color = color)
def set_fog_color(self, color):
self.fog_color = color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment