forked from hipstercat/giantsd
Added things
This commit is contained in:
parent
b303320d69
commit
8aa376511e
@ -151,8 +151,15 @@ class Netserver(asyncio.DatagramProtocol):
|
|||||||
logger.debug("%s:%s > %s (CFRAME CONNECT)", addr[0], addr[1], data.getvalue().hex())
|
logger.debug("%s:%s > %s (CFRAME CONNECT)", addr[0], addr[1], data.getvalue().hex())
|
||||||
# CONNECT CFRAME
|
# CONNECT CFRAME
|
||||||
if session and session.Full:
|
if session and session.Full:
|
||||||
logger.error("Session %s:%s was already fully connected. Ignoring.", session.ip, session.port)
|
if False:
|
||||||
return
|
logger.error("Session %s:%s was already fully connected. Ignoring.", session.ip, session.port)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
logger.error("Session %s:%s was already fully connected. Kicking the old one.", session.ip, session.port)
|
||||||
|
player = self.get_player(session)
|
||||||
|
if player:
|
||||||
|
self.server.remove_player(self.get_player(session))
|
||||||
|
self.addrs.remove(session)
|
||||||
elif session and not session.Full and session.SessID == cframe.SessID:
|
elif session and not session.Full and session.SessID == cframe.SessID:
|
||||||
# send CONNECTED
|
# send CONNECTED
|
||||||
logger.debug("Already partially established connection. Sending a CFRAME CONNECTED again.")
|
logger.debug("Already partially established connection. Sending a CFRAME CONNECTED again.")
|
||||||
@ -501,14 +508,10 @@ class Netserver(asyncio.DatagramProtocol):
|
|||||||
objid = "75"
|
objid = "75"
|
||||||
plix = "01"
|
plix = "01"
|
||||||
model = "4b"
|
model = "4b"
|
||||||
async def spawn(objid, plix, model):
|
#async def spawn(objid, plix, model):
|
||||||
await player.session.send_gamedata(bytes.fromhex("05"+plix+objid+"0000"+model+"00000000"), acknow=False)
|
# await player.session.send_gamedata(bytes.fromhex("05"+plix+objid+"0000"+model+"00000000"), acknow=False)
|
||||||
await player.session.send_gamedata(bytes.fromhex("0a32000000"+plix+objid+"000001"+model+"0000000000000000000000000000000000000000000000000000000000000000000000000000000a12000000"+plix+objid+"0000"+model+"020000000000000000"), acknow=False)
|
# await player.session.send_gamedata(bytes.fromhex("0a32000000"+plix+objid+"000001"+model+"0000000000000000000000000000000000000000000000000000000000000000000000000000000a12000000"+plix+objid+"0000"+model+"020000000000000000"), acknow=False)
|
||||||
await spawn(objid, plix, model)
|
#await spawn(objid, plix, model)
|
||||||
|
|
||||||
|
|
||||||
#for i in range(76, 200):
|
|
||||||
# await spawn(struct.pack("<B", i).hex(), plix, model)
|
|
||||||
|
|
||||||
# makes one player change team
|
# makes one player change team
|
||||||
#await player.session.send_gamedata(bytes.fromhex("0f1c49e2450e0000000000"), acknow=False)
|
#await player.session.send_gamedata(bytes.fromhex("0f1c49e2450e0000000000"), acknow=False)
|
||||||
|
@ -19,6 +19,7 @@ class Session:
|
|||||||
self.LastMsgID = 0
|
self.LastMsgID = 0
|
||||||
self.connect_retry_timer_num = 0
|
self.connect_retry_timer_num = 0
|
||||||
self.connect_retry_timer = False
|
self.connect_retry_timer = False
|
||||||
|
|
||||||
self.lock = asyncio.Lock()
|
self.lock = asyncio.Lock()
|
||||||
|
|
||||||
def send(self, packet):
|
def send(self, packet):
|
||||||
|
@ -6,9 +6,10 @@ import struct
|
|||||||
class Commands:
|
class Commands:
|
||||||
def __init__(self, server):
|
def __init__(self, server):
|
||||||
self.server = server
|
self.server = server
|
||||||
|
self._nextid = 118
|
||||||
|
|
||||||
async def on_player_chat(self, player, type, team, message):
|
async def on_player_chat(self, player, type, team, message):
|
||||||
await self.server.broadcast_message("%s (%s,%s): %s" % (player.name, type, team, message), color=ChatColor.Yellow)
|
await self.server.broadcast_message_except(player, "%s: %s" % (player.name, message), color=ChatColor.Yellow)
|
||||||
print(message)
|
print(message)
|
||||||
command = message.split(" ")
|
command = message.split(" ")
|
||||||
|
|
||||||
@ -58,6 +59,10 @@ class Commands:
|
|||||||
await player.send_message("Death by id: %s" % diemethod)
|
await player.send_message("Death by id: %s" % diemethod)
|
||||||
await player.session.send_gamedata(bytes.fromhex("0b1a0000000002070000a5b0d4c35d9714c450abef354a68fb410914000000020700000402000000")+struct.pack("<L",diemethod)+bytes.fromhex("0000"))
|
await player.session.send_gamedata(bytes.fromhex("0b1a0000000002070000a5b0d4c35d9714c450abef354a68fb410914000000020700000402000000")+struct.pack("<L",diemethod)+bytes.fromhex("0000"))
|
||||||
|
|
||||||
|
if command[0] == "spawn" and len(command) > 1:
|
||||||
|
await self.server.broadcast_message("Spawning "+command[1]+"")
|
||||||
|
await self.server.spawn(self._nextid, "00", command[1])
|
||||||
|
|
||||||
|
|
||||||
def setup(server):
|
def setup(server):
|
||||||
plugin = Commands(server)
|
plugin = Commands(server)
|
||||||
|
11
server.py
11
server.py
@ -10,6 +10,7 @@ from utils.logger import setup_logger
|
|||||||
import traceback
|
import traceback
|
||||||
import asyncio
|
import asyncio
|
||||||
from aioconsole import ainput
|
from aioconsole import ainput
|
||||||
|
import struct
|
||||||
|
|
||||||
logger = setup_logger(__name__)
|
logger = setup_logger(__name__)
|
||||||
|
|
||||||
@ -137,6 +138,16 @@ class Server:
|
|||||||
continue
|
continue
|
||||||
await player.session.send_gamedata(payload, **kwargs)
|
await player.session.send_gamedata(payload, **kwargs)
|
||||||
|
|
||||||
|
async def broadcast_message_except(self, player, text, color=ChatColor.Yellow, type=ChatType.All):
|
||||||
|
for pplayer in self.players:
|
||||||
|
if pplayer.name == "[Server]" or pplayer == player:
|
||||||
|
continue
|
||||||
|
await pplayer.send_message(text, color=color, type=type)
|
||||||
|
|
||||||
|
async def spawn(self, objid, plix, model):
|
||||||
|
await self.broadcast_gamedata(bytes.fromhex("05" + plix + struct.pack("<B", objid).hex() + "0000" + model + "00000000"), acknow=False)
|
||||||
|
await self.broadcast_gamedata(bytes.fromhex("0a32000000" + plix + struct.pack("<B", objid).hex() + "000001" + model + "000000ff00000000000000000000000000000000000000000000000000000000000000000000000a12000000" + plix + struct.pack("<B", objid).hex() + "0000" + model + "020000000000000000"), acknow=False)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
server = Server(name="giantsd", maxplayers=20, register=False, teams=Teams.MvM) #, map=Map("Three Way Island - Canyons.gck"))
|
server = Server(name="giantsd", maxplayers=20, register=False, teams=Teams.MvM) #, map=Map("Three Way Island - Canyons.gck"))
|
||||||
|
Loading…
Reference in New Issue
Block a user