import pygame import os import random import sys import select import socket import pickle import lib.constants as constants from lib.gameregistry import GameRegistry from lib.map import Map from lib.character import Character from lib.block import Block from lib.player import Player from lib.player_img import PlayerImg from time import sleep import pprint import blocks pp=pprint.PrettyPrinter(indent=2) def recv_str(sock,print_str=True): str="" ch="" while True: ch=sock.recv(1).decode("utf-8") if ch=="\n": break str+=ch if print_str: pass # print("Got string: "+str) return str def send_str(sock,str): # print("Sending string: "+str) sock.send((str+"\n").encode("utf-8")) def recv_hash(sock): hash={} len=int(recv_str(sock,False)) for _ in range(len): key=recv_str(sock,False) val=recv_str(sock,False) hash[key]=val # print("Got hash: "+pp.pformat(hash)) return hash def recvall(sock): BUFF_SIZE=4096 data=b'' while True: part=sock.recv(BUFF_SIZE) data+=part if len(part)