修复重新进入 FOV 时其他客户端字符的偏移量,(PyGame 和套接字)

fix the offset on other client's char when re-entering FOV, (PyGame and sockets)

我希望在这里发布问题没有什么坏处。这真的让我发疯...

https://hastebin.com/ekigenewel.rb <- 客户

https://hastebin.com/esuhanigop.py <- 服务器

https://hastebin.com/orutodejif.yaml <- .owo 地图文件

我确实知道 bug 追踪需要时间并且愿意提供帮助,因此我不期待任何事情,只是我怀疑我自己能否做到,我已经浪费了大约 4 个小时 我的想法是用 pygame 和套接字制作多人游戏。我有一个问题,当客户端 A 上的 char A 退出客户端 B FOV,然后第二个跟随它时发生。问题是客户端 B char A 被常量 delta [3.3].

偏移

提前致谢

您的网络代码无法处理客户端断开连接。一个简单的检测方法是当 socket .recv() returns 为空数据列表时。目前它进入了一个快速的无限循环。

您的 esuhanigop.py threaded_client() 函数的一个小补丁足以解决问题:

def threaded_client(connection,addr):
    while True:
        data = connection.recv(2048)
        if ( len( data ) == 0 ):                     # Client has disconnected
            break                                    # Stop communications
        set_dat(addr,str(data,encoding='UTF-8'))
        dat = get_dat()
        if dat:
            connection.sendall(str.encode(dat,encoding='UTF-8'))
    connection.close()

有了这个补丁,我可以多次连接和断开与服务器的连接,而不会看到任何 python 错误。