Ejemplo n.º 1
0
 def makepacket(ent):
     assert ent.entID is not None
     return str(
         GameProtocol.SpawnEnt(asUnixPath(ent.typeInfo.typePath),
                               ent.scriptname, ent.entID,
                               ent.location.x, ent.location.y,
                               ent.location.z, ent.q4.x, ent.q4.y,
                               ent.q4.z, ent.q4.w))
Ejemplo n.º 2
0
 def onReceive(self, event):
     msg = GameProtocol.read(event.packet.data)
     if msg.name == 'SpawnEnt':
         #print msg
         self.world.netSpawnEnt(msg)
     elif msg.name == 'MoveEnt':
         #print event.packet
         self.world.netMoveEnt(msg)
     elif msg.name == 'MoveActor':
         self.world.netMoveActor(msg)
Ejemplo n.º 3
0
 def onReceive(self, event):
     msg = GameProtocol.read( event.packet.data )
     if msg.name == 'SpawnEnt':
         #print msg
         self.world.netSpawnEnt( msg )
     elif msg.name == 'MoveEnt':
         #print event.packet
         self.world.netMoveEnt( msg )
     elif msg.name == 'MoveActor':
         self.world.netMoveActor(msg)
Ejemplo n.º 4
0
 def makemovepacket(ent):
     #ent.velocity actually has to make a foreign function
     #call to C to get the velocity, so we only want to call it once
     ev = ent.velocity
     return str(GameProtocol.MoveEnt(ent.entID,
                                 ent.location.x,
                                 ent.location.y,
                                 ent.location.z,
                                 ent.q4.x,
                                 ent.q4.y,
                                 ent.q4.z,
                                 ent.q4.w,
                                 ev.x, ev.y, ev.z
                                 ))
Ejemplo n.º 5
0
def simpletest():
    global name
    print "Name?"
    name = sys.stdin.readline(32)
    ch = ChatClient('127.0.0.1', 1234)
    ch.runUpdateThread()
    try:
        done = False
        while not done:
            input = sys.stdin.readline()
            if input.strip() == 'quit':
                ch.disconnect()
                done = True
            else:
                ch.send(GameProtocol.ChatMessage(input))
    except KeyboardInterrupt:
        print "Quitting..."
        ch.disconnect()
        done = True
    ch.stopUpdateThread()
Ejemplo n.º 6
0
 def onReceive(self, event):
     print "Received Message", GameProtocol.read(event.packet.data)
Ejemplo n.º 7
0
 def onReceive(self, connection, event):
     #relay
     print "Received message on connection:", connection
     msg = GameProtocol.read(event.packet.data)
     print msg
Ejemplo n.º 8
0
 def makeUpdatePacket(self):
     return str(
         GameProtocol.MoveEnt(self.entID, self.location.x, self.location.y,
                              self.location.z, self.q4.x, self.q4.y,
                              self.q4.z, self.q4.w, 0, 0, 0))
Ejemplo n.º 9
0
 def onReceive(self, event):
     msg = GameProtocol.read(event.packet.data)
     if 'message' in msg.keys():
         self.sendToAll(GameProtocol.ChatMessage(msg['message']))
     print event.peer.address, msg
Ejemplo n.º 10
0
prompt = True
automatch = True

# Build the socket and create the game protocol object
port = sys.argv[2]
host = sys.argv[1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = (str(host), int(port))
try:
    s.connect(server_address)
except:
    print('could not connected to server')
    not_done = False
lock = threading.Lock()

p = GameProtocol(s, server_address)

# dict for executing commands.
pro = {
    'games': p.GAMES,
    'place': p.PLACE,
    'exit': p.EXIT,
    'play': p.PLAY,
    'who': p.WHO,
    'login': p.LOGIN,
    'observe': p.OBSERVE,
    'unobserve': p.UNOBSERVE,
    'comment': p.COMMENT,
    'automatch': p.automatch,
    'prompt': changePrompt
}
Ejemplo n.º 11
0
 def onReceive(self, event):
     print "Received Message", GameProtocol.read(event.packet.data)
Ejemplo n.º 12
0
 def onConnect(self, event):
     print "Connected to:", event.peer.address
     self.send(GameProtocol.SetName(name))
Ejemplo n.º 13
0
 def makeUpdatePacket(self):
     return str(
         GameProtocol.MoveActor(self.entID, self.location.x,
                                self.location.y, self.location.z, self.yaw,
                                self.pitch))
Ejemplo n.º 14
0
 def onReceive(self, event):
     msg = GameProtocol.read( event.packet.data )
     if 'message' in msg.keys():
         self.sendToAll( GameProtocol.ChatMessage(msg['message']) )
     print event.peer.address, msg
Ejemplo n.º 15
0
 def onReceive(self, connection, event):
     #relay
     print "Received message on connection:", connection
     msg = GameProtocol.read( event.packet.data )
     print msg