mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Run flynt -a
This commit is contained in:
parent
cfdb4646d1
commit
9f8e97fbeb
|
@ -8,8 +8,8 @@ def create_enum_table(names, num):
|
|||
lines = []
|
||||
lines += ["enum", "{"]
|
||||
for name in names:
|
||||
lines += ["\t%s," % name]
|
||||
lines += ["\t%s" % num, "};"]
|
||||
lines += [f"\t{name},"]
|
||||
lines += [f"\t{num}", "};"]
|
||||
return lines
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ def create_flags_table(names):
|
|||
lines = []
|
||||
lines += ["enum", "{"]
|
||||
for i, name in enumerate(names):
|
||||
lines += ["\t%s = 1<<%d," % (name, i)]
|
||||
lines += [f"\t{name} = 1<<{int(i)},"]
|
||||
lines += ["};"]
|
||||
return lines
|
||||
|
||||
|
@ -25,10 +25,10 @@ def create_flags_table(names):
|
|||
def EmitEnum(names, num):
|
||||
print("enum")
|
||||
print("{")
|
||||
print("\t%s=0," % names[0])
|
||||
print(f"\t{names[0]}=0,")
|
||||
for name in names[1:]:
|
||||
print("\t%s," % name)
|
||||
print("\t%s" % num)
|
||||
print(f"\t{name},")
|
||||
print(f"\t{num}")
|
||||
print("};")
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ def EmitFlags(names):
|
|||
print("enum")
|
||||
print("{")
|
||||
for i, name in enumerate(names):
|
||||
print("\t%s = 1<<%d," % (name, i))
|
||||
print(f"\t{name} = 1<<{int(i)},")
|
||||
print("};")
|
||||
|
||||
|
||||
|
@ -48,12 +48,12 @@ def gen_network_header():
|
|||
print(network.RawHeader)
|
||||
|
||||
for e in network.Enums:
|
||||
for line in create_enum_table(["%s_%s"%(e.name, v) for v in e.values], 'NUM_%sS'%e.name): # pylint: disable=no-member
|
||||
for line in create_enum_table([f"{e.name}_{v}" for v in e.values], f'NUM_{e.name}S'): # pylint: disable=no-member
|
||||
print(line)
|
||||
print("")
|
||||
|
||||
for e in network.Flags:
|
||||
for line in create_flags_table(["%s_%s" % (e.name, v) for v in e.values]):
|
||||
for line in create_flags_table([f"{e.name}_{v}" for v in e.values]):
|
||||
print(line)
|
||||
print("")
|
||||
|
||||
|
@ -79,8 +79,8 @@ def gen_network_header():
|
|||
print(line)
|
||||
print("")
|
||||
|
||||
EmitEnum(["SOUND_%s"%i.name.value.upper() for i in content.container.sounds.items], "NUM_SOUNDS")
|
||||
EmitEnum(["WEAPON_%s"%i.name.value.upper() for i in content.container.weapons.id.items], "NUM_WEAPONS")
|
||||
EmitEnum([f"SOUND_{i.name.value.upper()}" for i in content.container.sounds.items], "NUM_SOUNDS")
|
||||
EmitEnum([f"WEAPON_{i.name.value.upper()}" for i in content.container.weapons.id.items], "NUM_WEAPONS")
|
||||
|
||||
print("""
|
||||
class CNetObjHandler
|
||||
|
@ -160,37 +160,37 @@ int CNetObjHandler::ClampInt(const char *pErrorMsg, int Value, int Min, int Max)
|
|||
lines = []
|
||||
lines += ["const char *CNetObjHandler::ms_apObjNames[] = {"]
|
||||
lines += ['\t"EX/UUID",']
|
||||
lines += ['\t"%s",' % o.name for o in network.Objects if o.ex is None]
|
||||
lines += [f'\t"{o.name}",' for o in network.Objects if o.ex is None]
|
||||
lines += ['\t""', "};", ""]
|
||||
|
||||
lines += ["const char *CNetObjHandler::ms_apExObjNames[] = {"]
|
||||
lines += ['\t"invalid",']
|
||||
lines += ['\t"%s",' % o.name for o in network.Objects if o.ex is not None]
|
||||
lines += [f'\t"{o.name}",' for o in network.Objects if o.ex is not None]
|
||||
lines += ['\t""', "};", ""]
|
||||
|
||||
lines += ["int CNetObjHandler::ms_aObjSizes[] = {"]
|
||||
lines += ['\t0,']
|
||||
lines += ['\tsizeof(%s),' % o.struct_name for o in network.Objects if o.ex is None]
|
||||
lines += [f'\tsizeof({o.struct_name}),' for o in network.Objects if o.ex is None]
|
||||
lines += ['\t0', "};", ""]
|
||||
|
||||
lines += ["int CNetObjHandler::ms_aUnpackedObjSizes[] = {"]
|
||||
lines += ['\t16,']
|
||||
lines += ['\tsizeof(%s),' % o.struct_name for o in network.Objects if o.ex is None]
|
||||
lines += [f'\tsizeof({o.struct_name}),' for o in network.Objects if o.ex is None]
|
||||
lines += ["};", ""]
|
||||
|
||||
lines += ["int CNetObjHandler::ms_aUnpackedExObjSizes[] = {"]
|
||||
lines += ['\t0,']
|
||||
lines += ['\tsizeof(%s),' % o.struct_name for o in network.Objects if o.ex is not None]
|
||||
lines += [f'\tsizeof({o.struct_name}),' for o in network.Objects if o.ex is not None]
|
||||
lines += ["};", ""]
|
||||
|
||||
lines += ['const char *CNetObjHandler::ms_apMsgNames[] = {']
|
||||
lines += ['\t"invalid",']
|
||||
lines += ['\t"%s",' % msg.name for msg in network.Messages if msg.ex is None]
|
||||
lines += [f'\t"{msg.name}",' for msg in network.Messages if msg.ex is None]
|
||||
lines += ['\t""', "};", ""]
|
||||
|
||||
lines += ['const char *CNetObjHandler::ms_apExMsgNames[] = {']
|
||||
lines += ['\t"invalid",']
|
||||
lines += ['\t"%s",' % msg.name for msg in network.Messages if msg.ex is not None]
|
||||
lines += [f'\t"{msg.name}",' for msg in network.Messages if msg.ex is not None]
|
||||
lines += ['\t""', "};", ""]
|
||||
|
||||
for line in lines:
|
||||
|
@ -332,7 +332,7 @@ bool CNetObjHandler::TeeHistorianRecordMsg(int Type)
|
|||
empty = True
|
||||
for msg in network.Messages:
|
||||
if not msg.teehistorian:
|
||||
lines += ['\tcase %s:' % msg.enum_name]
|
||||
lines += [f'\tcase {msg.enum_name}:']
|
||||
empty = False
|
||||
if not empty:
|
||||
lines += ['\t\treturn false;']
|
||||
|
@ -355,7 +355,7 @@ void RegisterGameUuids(CUuidManager *pManager)
|
|||
|
||||
for item in network.Objects + network.Messages:
|
||||
if item.ex is not None:
|
||||
lines += ['\tpManager->RegisterName(%s, "%s");' % (item.enum_name, item.ex)]
|
||||
lines += [f'\tpManager->RegisterName({item.enum_name}, "{item.ex}");']
|
||||
|
||||
lines += ["""
|
||||
RegisterMapItemTypeUuids(pManager);
|
||||
|
@ -384,9 +384,9 @@ def gen_common_content_header():
|
|||
print('extern CDataContainer *g_pData;')
|
||||
|
||||
# enums
|
||||
EmitEnum(["IMAGE_%s"%i.name.value.upper() for i in content.container.images.items], "NUM_IMAGES")
|
||||
EmitEnum(["ANIM_%s"%i.name.value.upper() for i in content.container.animations.items], "NUM_ANIMS")
|
||||
EmitEnum(["SPRITE_%s"%i.name.value.upper() for i in content.container.sprites.items], "NUM_SPRITES")
|
||||
EmitEnum([f"IMAGE_{i.name.value.upper()}" for i in content.container.images.items], "NUM_IMAGES")
|
||||
EmitEnum([f"ANIM_{i.name.value.upper()}" for i in content.container.animations.items], "NUM_ANIMS")
|
||||
EmitEnum([f"SPRITE_{i.name.value.upper()}" for i in content.container.sprites.items], "NUM_SPRITES")
|
||||
|
||||
def gen_common_content_source():
|
||||
EmitDefinition(content.container, "datacontainer")
|
||||
|
|
|
@ -25,11 +25,11 @@ def generate_map(a, b):
|
|||
return result
|
||||
|
||||
def output_map_header(name, m):
|
||||
print("extern const int gs_{}[{}];".format(name, len(m)))
|
||||
print("inline int {0}(int a) {{ if(a < 0 || a >= {1}) return -1; return gs_{0}[a]; }}".format(name, len(m)))
|
||||
print(f"extern const int gs_{name}[{len(m)}];")
|
||||
print(f"inline int {name}(int a) {{ if(a < 0 || a >= {len(m)}) return -1; return gs_{name}[a]; }}")
|
||||
|
||||
def output_map_source(name, m):
|
||||
print("const int gs_{}[{}] = {{".format(name, len(m)))
|
||||
print(f"const int gs_{name}[{len(m)}] = {{")
|
||||
print(*m, sep=',')
|
||||
print("};")
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ def GetID():
|
|||
GlobalIdCounter += 1
|
||||
return GlobalIdCounter
|
||||
def GetUID():
|
||||
return "x%d"%GetID()
|
||||
return f"x{int(GetID())}"
|
||||
|
||||
def FixCasing(Str):
|
||||
NewStr = ""
|
||||
|
@ -43,7 +43,7 @@ class BaseType:
|
|||
return self._id
|
||||
|
||||
def EmitDeclaration(self, name):
|
||||
return ["%s %s;"%(self.TypeName(), FormatName(self.TypeName(), name))]
|
||||
return [f"{self.TypeName()} {FormatName(self.TypeName(), name)};"]
|
||||
def EmitPreDefinition(self, target_name):
|
||||
self._target_name = target_name
|
||||
return []
|
||||
|
@ -101,15 +101,15 @@ class Array(BaseType):
|
|||
raise "bah"
|
||||
self.items += [instance]
|
||||
def EmitDeclaration(self, name):
|
||||
return ["int m_Num%s;"%(FixCasing(name)),
|
||||
"%s *%s;"%(self.TypeName(), FormatName("[]", name))]
|
||||
return [f"int m_Num{FixCasing(name)};",
|
||||
f"{self.TypeName()} *{FormatName('[]', name)};"]
|
||||
def EmitPreDefinition(self, target_name):
|
||||
BaseType.EmitPreDefinition(self, target_name)
|
||||
|
||||
lines = []
|
||||
i = 0
|
||||
for item in self.items:
|
||||
lines += item.EmitPreDefinition("%s[%d]"%(self.Identifyer(), i))
|
||||
lines += item.EmitPreDefinition(f"{self.Identifyer()}[{int(i)}]")
|
||||
i += 1
|
||||
|
||||
if self.items:
|
||||
|
@ -119,7 +119,7 @@ class Array(BaseType):
|
|||
lines += ["\t" + " ".join(itemlines).replace("\t", " ") + ","]
|
||||
lines += ["};"]
|
||||
else:
|
||||
lines += ["static %s *%s = 0;"%(self.TypeName(), self.Identifyer())]
|
||||
lines += [f"static {self.TypeName()} *{self.Identifyer()} = 0;"]
|
||||
|
||||
return lines
|
||||
def EmitDefinition(self, _name):
|
||||
|
@ -134,7 +134,7 @@ class Int(BaseType):
|
|||
def Set(self, value):
|
||||
self.value = value
|
||||
def EmitDefinition(self, _name):
|
||||
return ["%d"%self.value]
|
||||
return [f"{int(self.value)}"]
|
||||
#return ["%d /* %s */"%(self.value, self._target_name)]
|
||||
|
||||
class Float(BaseType):
|
||||
|
@ -144,7 +144,7 @@ class Float(BaseType):
|
|||
def Set(self, value):
|
||||
self.value = value
|
||||
def EmitDefinition(self, _name):
|
||||
return ["%ff"%self.value]
|
||||
return [f"{self.value:f}f"]
|
||||
#return ["%d /* %s */"%(self.value, self._target_name)]
|
||||
|
||||
class String(BaseType):
|
||||
|
@ -158,7 +158,7 @@ class String(BaseType):
|
|||
|
||||
class Pointer(BaseType):
|
||||
def __init__(self, typ, target):
|
||||
BaseType.__init__(self, "%s*"%typ().TypeName())
|
||||
BaseType.__init__(self, f"{typ().TypeName()}*")
|
||||
self.target = target
|
||||
def Set(self, target):
|
||||
self.target = target
|
||||
|
@ -180,7 +180,7 @@ def EmitTypeDeclaration(root):
|
|||
def EmitDefinition(root, name):
|
||||
for l in root.EmitPreDefinition(name):
|
||||
print(l)
|
||||
print("%s %s = " % (root.TypeName(), name))
|
||||
print(f"{root.TypeName()} {name} = ")
|
||||
for l in root.EmitDefinition(name):
|
||||
print(l)
|
||||
print(";")
|
||||
|
@ -207,9 +207,9 @@ class NetObject:
|
|||
self.base = ""
|
||||
if len(l) > 1:
|
||||
self.base = l[1]
|
||||
self.base_struct_name = "CNetObj_%s" % self.base
|
||||
self.struct_name = "CNetObj_%s" % self.name
|
||||
self.enum_name = "NETOBJTYPE_%s" % self.name.upper()
|
||||
self.base_struct_name = f"CNetObj_{self.base}"
|
||||
self.struct_name = f"CNetObj_{self.name}"
|
||||
self.enum_name = f"NETOBJTYPE_{self.name.upper()}"
|
||||
self.variables = variables
|
||||
self.ex = ex
|
||||
self.validate_size = validate_size
|
||||
|
@ -217,9 +217,9 @@ class NetObject:
|
|||
def emit_declaration(self):
|
||||
lines = []
|
||||
if self.base:
|
||||
lines += ["struct %s : public %s"%(self.struct_name,self.base_struct_name), "{"]
|
||||
lines += [f"struct {self.struct_name} : public {self.base_struct_name}", "{"]
|
||||
else:
|
||||
lines += ["struct %s"%self.struct_name, "{"]
|
||||
lines += [f"struct {self.struct_name}", "{"]
|
||||
for v in self.variables:
|
||||
lines += ["\t"+line for line in v.emit_declaration()]
|
||||
lines += ["};"]
|
||||
|
@ -227,9 +227,9 @@ class NetObject:
|
|||
|
||||
def emit_uncompressed_unpack_and_validate(self, base_item):
|
||||
lines = []
|
||||
lines += ["case %s:" % self.enum_name]
|
||||
lines += [f"case {self.enum_name}:"]
|
||||
lines += ["{"]
|
||||
lines += ["\t%s *pData = (%s *)m_aUnpackedData;" % (self.struct_name, self.struct_name)]
|
||||
lines += [f"\t{self.struct_name} *pData = ({self.struct_name} *)m_aUnpackedData;"]
|
||||
unpack_lines = []
|
||||
|
||||
variables = []
|
||||
|
@ -253,23 +253,23 @@ class NetObject:
|
|||
class NetEvent(NetObject):
|
||||
def __init__(self, name, variables, ex=None):
|
||||
NetObject.__init__(self, name, variables, ex=ex)
|
||||
self.base_struct_name = "CNetEvent_%s" % self.base
|
||||
self.struct_name = "CNetEvent_%s" % self.name
|
||||
self.enum_name = "NETEVENTTYPE_%s" % self.name.upper()
|
||||
self.base_struct_name = f"CNetEvent_{self.base}"
|
||||
self.struct_name = f"CNetEvent_{self.name}"
|
||||
self.enum_name = f"NETEVENTTYPE_{self.name.upper()}"
|
||||
|
||||
class NetMessage(NetObject):
|
||||
def __init__(self, name, variables, ex=None, teehistorian=True):
|
||||
NetObject.__init__(self, name, variables, ex=ex)
|
||||
self.base_struct_name = "CNetMsg_%s" % self.base
|
||||
self.struct_name = "CNetMsg_%s" % self.name
|
||||
self.enum_name = "NETMSGTYPE_%s" % self.name.upper()
|
||||
self.base_struct_name = f"CNetMsg_{self.base}"
|
||||
self.struct_name = f"CNetMsg_{self.name}"
|
||||
self.enum_name = f"NETMSGTYPE_{self.name.upper()}"
|
||||
self.teehistorian = teehistorian
|
||||
|
||||
def emit_unpack_msg(self):
|
||||
lines = []
|
||||
lines += ["case %s:" % self.enum_name]
|
||||
lines += [f"case {self.enum_name}:"]
|
||||
lines += ["{"]
|
||||
lines += ["\t%s *pData = (%s *)m_aUnpackedData;" % (self.struct_name, self.struct_name)]
|
||||
lines += [f"\t{self.struct_name} *pData = ({self.struct_name} *)m_aUnpackedData;"]
|
||||
|
||||
unpack_lines = []
|
||||
for v in self.variables:
|
||||
|
@ -332,47 +332,47 @@ class NetVariable:
|
|||
|
||||
class NetString(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["const char *%s;"%self.name]
|
||||
return [f"const char *{self.name};"]
|
||||
def emit_uncompressed_unpack_obj(self):
|
||||
return self.emit_unpack_msg()
|
||||
def emit_unpack_msg(self):
|
||||
return ["pData->%s = pUnpacker->GetString();" % self.name]
|
||||
return [f"pData->{self.name} = pUnpacker->GetString();"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddString(%s, -1);" % self.name]
|
||||
return [f"pPacker->AddString({self.name}, -1);"]
|
||||
|
||||
class NetStringHalfStrict(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["const char *%s;"%self.name]
|
||||
return [f"const char *{self.name};"]
|
||||
def emit_uncompressed_unpack_obj(self):
|
||||
return self.emit_unpack_msg()
|
||||
def emit_unpack_msg(self):
|
||||
return ["pData->%s = pUnpacker->GetString(CUnpacker::SANITIZE_CC);" % self.name]
|
||||
return [f"pData->{self.name} = pUnpacker->GetString(CUnpacker::SANITIZE_CC);"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddString(%s, -1);" % self.name]
|
||||
return [f"pPacker->AddString({self.name}, -1);"]
|
||||
|
||||
class NetStringStrict(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["const char *%s;"%self.name]
|
||||
return [f"const char *{self.name};"]
|
||||
def emit_uncompressed_unpack_obj(self):
|
||||
return self.emit_unpack_msg()
|
||||
def emit_unpack_msg(self):
|
||||
return ["pData->%s = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);" % self.name]
|
||||
return [f"pData->{self.name} = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddString(%s, -1);" % self.name]
|
||||
return [f"pPacker->AddString({self.name}, -1);"]
|
||||
|
||||
class NetIntAny(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["int %s;"%self.name]
|
||||
return [f"int {self.name};"]
|
||||
def emit_uncompressed_unpack_obj(self):
|
||||
if self.default is None:
|
||||
return ["pData->%s = pUnpacker->GetUncompressedInt();" % self.name]
|
||||
return ["pData->%s = pUnpacker->GetUncompressedIntOrDefault(%s);" % (self.name, self.default)]
|
||||
return [f"pData->{self.name} = pUnpacker->GetUncompressedInt();"]
|
||||
return [f"pData->{self.name} = pUnpacker->GetUncompressedIntOrDefault({self.default});"]
|
||||
def emit_unpack_msg(self):
|
||||
if self.default is None:
|
||||
return ["pData->%s = pUnpacker->GetInt();" % self.name]
|
||||
return ["pData->%s = pUnpacker->GetIntOrDefault(%s);" % (self.name, self.default)]
|
||||
return [f"pData->{self.name} = pUnpacker->GetInt();"]
|
||||
return [f"pData->{self.name} = pUnpacker->GetIntOrDefault({self.default});"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddInt(%s);" % self.name]
|
||||
return [f"pPacker->AddInt({self.name});"]
|
||||
|
||||
class NetIntRange(NetIntAny):
|
||||
def __init__(self, name, min_val, max_val, default=None):
|
||||
|
@ -380,7 +380,7 @@ class NetIntRange(NetIntAny):
|
|||
self.min = str(min_val)
|
||||
self.max = str(max_val)
|
||||
def emit_validate_obj(self):
|
||||
return ["pData->%s = ClampInt(\"%s\", pData->%s, %s, %s);"%(self.name, self.name, self.name, self.min, self.max)]
|
||||
return [f"pData->{self.name} = ClampInt(\"{self.name}\", pData->{self.name}, {self.min}, {self.max});"]
|
||||
def emit_unpack_msg_check(self):
|
||||
return ["if(pData->%s < %s || pData->%s > %s) { m_pMsgFailedOn = \"%s\"; break; }" % (self.name, self.min, self.name, self.max, self.name)]
|
||||
|
||||
|
@ -399,37 +399,37 @@ class NetArray(NetVariable):
|
|||
self.base_name = var.name
|
||||
self.var = var
|
||||
self.size = size
|
||||
self.name = self.base_name + "[%d]"%self.size
|
||||
self.name = self.base_name + f"[{int(self.size)}]"
|
||||
def emit_declaration(self):
|
||||
self.var.name = self.name
|
||||
return self.var.emit_declaration()
|
||||
def emit_uncompressed_unpack_obj(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_uncompressed_unpack_obj()
|
||||
return lines
|
||||
def emit_validate_obj(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_validate_obj()
|
||||
return lines
|
||||
def emit_unpack_msg(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_unpack_msg()
|
||||
return lines
|
||||
def emit_pack(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_pack()
|
||||
return lines
|
||||
def emit_unpack_msg_check(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_unpack_msg_check()
|
||||
return lines
|
||||
|
|
|
@ -29,7 +29,7 @@ GameInfoFlags2 = [
|
|||
"HUD_DDRACE",
|
||||
]
|
||||
ExPlayerFlags = ["AFK", "PAUSED", "SPEC"]
|
||||
ProjectileFlags = ["CLIENTID_BIT{}".format(i) for i in range(8)] + [
|
||||
ProjectileFlags = [f"CLIENTID_BIT{i}" for i in range(8)] + [
|
||||
"NO_OWNER", "IS_DDNET", "BOUNCE_HORIZONTAL", "BOUNCE_VERTICAL",
|
||||
"EXPLOSIVE", "FREEZE",
|
||||
]
|
||||
|
|
|
@ -6,10 +6,10 @@ from . import network
|
|||
def create_enum_table(names, num):
|
||||
lines = []
|
||||
lines += ["enum", "{"]
|
||||
lines += ["\t%s=0,"%names[0]]
|
||||
lines += [f"\t{names[0]}=0,"]
|
||||
for name in names[1:]:
|
||||
lines += ["\t%s,"%name]
|
||||
lines += ["\t%s" % num, "};"]
|
||||
lines += [f"\t{name},"]
|
||||
lines += [f"\t{num}", "};"]
|
||||
return lines
|
||||
|
||||
def create_flags_table(names):
|
||||
|
@ -17,7 +17,7 @@ def create_flags_table(names):
|
|||
lines += ["enum", "{"]
|
||||
i = 0
|
||||
for name in names:
|
||||
lines += ["\t%s = 1<<%d," % (name,i)]
|
||||
lines += [f"\t{name} = 1<<{int(i)},"]
|
||||
i += 1
|
||||
lines += ["};"]
|
||||
return lines
|
||||
|
@ -25,10 +25,10 @@ def create_flags_table(names):
|
|||
def EmitEnum(names, num):
|
||||
print("enum")
|
||||
print("{")
|
||||
print("\t%s=0," % names[0])
|
||||
print(f"\t{names[0]}=0,")
|
||||
for name in names[1:]:
|
||||
print("\t%s," % name)
|
||||
print("\t%s" % num)
|
||||
print(f"\t{name},")
|
||||
print(f"\t{num}")
|
||||
print("};")
|
||||
|
||||
def EmitFlags(names):
|
||||
|
@ -36,7 +36,7 @@ def EmitFlags(names):
|
|||
print("{")
|
||||
i = 0
|
||||
for name in names:
|
||||
print("\t%s = 1<<%d," % (name,i))
|
||||
print(f"\t{name} = 1<<{int(i)},")
|
||||
i += 1
|
||||
print("};")
|
||||
|
||||
|
@ -77,9 +77,9 @@ def main():
|
|||
print('extern CDataContainer *g_pData;')
|
||||
|
||||
# enums
|
||||
EmitEnum(["IMAGE_%s"%i.name.value.upper() for i in content.container.images.items], "NUM_IMAGES")
|
||||
EmitEnum(["ANIM_%s"%i.name.value.upper() for i in content.container.animations.items], "NUM_ANIMS")
|
||||
EmitEnum(["SPRITE_%s"%i.name.value.upper() for i in content.container.sprites.items], "NUM_SPRITES")
|
||||
EmitEnum([f"IMAGE_{i.name.value.upper()}" for i in content.container.images.items], "NUM_IMAGES")
|
||||
EmitEnum([f"ANIM_{i.name.value.upper()}" for i in content.container.animations.items], "NUM_ANIMS")
|
||||
EmitEnum([f"SPRITE_{i.name.value.upper()}" for i in content.container.sprites.items], "NUM_SPRITES")
|
||||
|
||||
if gen_client_content_source or gen_server_content_source:
|
||||
if gen_client_content_source:
|
||||
|
@ -102,12 +102,12 @@ def main():
|
|||
print(network.RawHeader)
|
||||
|
||||
for e in network.Enums:
|
||||
for l in create_enum_table(["%s_%s"%(e.name, v) for v in e.values], 'NUM_%sS'%e.name):
|
||||
for l in create_enum_table([f"{e.name}_{v}" for v in e.values], f'NUM_{e.name}S'):
|
||||
print(l)
|
||||
print("")
|
||||
|
||||
for e in network.Flags:
|
||||
for l in create_flags_table(["%s_%s" % (e.name, v) for v in e.values]):
|
||||
for l in create_flags_table([f"{e.name}_{v}" for v in e.values]):
|
||||
print(l)
|
||||
print("")
|
||||
|
||||
|
@ -138,8 +138,8 @@ def main():
|
|||
print(line)
|
||||
print("")
|
||||
|
||||
EmitEnum(["SOUND_%s"%i.name.value.upper() for i in content.container.sounds.items], "NUM_SOUNDS")
|
||||
EmitEnum(["WEAPON_%s"%i.name.value.upper() for i in content.container.weapons.id.items], "NUM_WEAPONS")
|
||||
EmitEnum([f"SOUND_{i.name.value.upper()}" for i in content.container.sounds.items], "NUM_SOUNDS")
|
||||
EmitEnum([f"WEAPON_{i.name.value.upper()}" for i in content.container.weapons.id.items], "NUM_WEAPONS")
|
||||
|
||||
print("""
|
||||
|
||||
|
@ -220,19 +220,19 @@ def main():
|
|||
|
||||
lines += ["const char *CNetObjHandler::ms_apObjNames[] = {"]
|
||||
lines += ['\t"invalid",']
|
||||
lines += ['\t"%s",' % o.name for o in network.Objects]
|
||||
lines += [f'\t"{o.name}",' for o in network.Objects]
|
||||
lines += ['\t""', "};", ""]
|
||||
|
||||
lines += ["int CNetObjHandler::ms_aObjSizes[] = {"]
|
||||
lines += ['\t0,']
|
||||
lines += ['\tsizeof(%s),' % o.struct_name for o in network.Objects]
|
||||
lines += [f'\tsizeof({o.struct_name}),' for o in network.Objects]
|
||||
lines += ['\t0', "};", ""]
|
||||
|
||||
|
||||
lines += ['const char *CNetObjHandler::ms_apMsgNames[] = {']
|
||||
lines += ['\t"invalid",']
|
||||
for msg in network.Messages:
|
||||
lines += ['\t"%s",' % msg.name]
|
||||
lines += [f'\t"{msg.name}",']
|
||||
lines += ['\t""']
|
||||
lines += ['};']
|
||||
lines += ['']
|
||||
|
|
|
@ -4,7 +4,7 @@ def GetID():
|
|||
GlobalIdCounter += 1
|
||||
return GlobalIdCounter
|
||||
def GetUID():
|
||||
return "x%d"%GetID()
|
||||
return f"x{int(GetID())}"
|
||||
|
||||
def FixCasing(Str):
|
||||
NewStr = ""
|
||||
|
@ -43,7 +43,7 @@ class BaseType:
|
|||
return self._id
|
||||
|
||||
def EmitDeclaration(self, name):
|
||||
return ["%s %s;"%(self.TypeName(), FormatName(self.TypeName(), name))]
|
||||
return [f"{self.TypeName()} {FormatName(self.TypeName(), name)};"]
|
||||
def EmitPreDefinition(self, target_name):
|
||||
self._target_name = target_name
|
||||
return []
|
||||
|
@ -101,15 +101,15 @@ class Array(BaseType):
|
|||
raise "bah"
|
||||
self.items += [instance]
|
||||
def EmitDeclaration(self, name):
|
||||
return ["int m_Num%s;"%(FixCasing(name)),
|
||||
"%s *%s;"%(self.TypeName(), FormatName("[]", name))]
|
||||
return [f"int m_Num{FixCasing(name)};",
|
||||
f"{self.TypeName()} *{FormatName('[]', name)};"]
|
||||
def EmitPreDefinition(self, target_name):
|
||||
BaseType.EmitPreDefinition(self, target_name)
|
||||
|
||||
lines = []
|
||||
i = 0
|
||||
for item in self.items:
|
||||
lines += item.EmitPreDefinition("%s[%d]"%(self.Identifyer(), i))
|
||||
lines += item.EmitPreDefinition(f"{self.Identifyer()}[{int(i)}]")
|
||||
i += 1
|
||||
|
||||
if self.items:
|
||||
|
@ -119,7 +119,7 @@ class Array(BaseType):
|
|||
lines += ["\t" + " ".join(itemlines).replace("\t", " ") + ","]
|
||||
lines += ["};"]
|
||||
else:
|
||||
lines += ["static %s *%s = nullptr;"%(self.TypeName(), self.Identifyer())]
|
||||
lines += [f"static {self.TypeName()} *{self.Identifyer()} = nullptr;"]
|
||||
|
||||
return lines
|
||||
def EmitDefinition(self, _name):
|
||||
|
@ -134,7 +134,7 @@ class Int(BaseType):
|
|||
def Set(self, value):
|
||||
self.value = value
|
||||
def EmitDefinition(self, _name):
|
||||
return ["%d"%self.value]
|
||||
return [f"{int(self.value)}"]
|
||||
#return ["%d /* %s */"%(self.value, self._target_name)]
|
||||
|
||||
class Float(BaseType):
|
||||
|
@ -144,7 +144,7 @@ class Float(BaseType):
|
|||
def Set(self, value):
|
||||
self.value = value
|
||||
def EmitDefinition(self, _name):
|
||||
return ["%ff"%self.value]
|
||||
return [f"{self.value:f}f"]
|
||||
#return ["%d /* %s */"%(self.value, self._target_name)]
|
||||
|
||||
class String(BaseType):
|
||||
|
@ -158,7 +158,7 @@ class String(BaseType):
|
|||
|
||||
class Pointer(BaseType):
|
||||
def __init__(self, typ, target):
|
||||
BaseType.__init__(self, "%s*"%typ().TypeName())
|
||||
BaseType.__init__(self, f"{typ().TypeName()}*")
|
||||
self.target = target
|
||||
def Set(self, target):
|
||||
self.target = target
|
||||
|
@ -186,7 +186,7 @@ def EmitTypeDeclaration(root):
|
|||
def EmitDefinition(root, name):
|
||||
for l in root.EmitPreDefinition(name):
|
||||
print(l)
|
||||
print("%s %s = " % (root.TypeName(), name))
|
||||
print(f"{root.TypeName()} {name} = ")
|
||||
for l in root.EmitDefinition(name):
|
||||
print(l)
|
||||
print(";")
|
||||
|
@ -213,23 +213,23 @@ class NetObject:
|
|||
self.base = ""
|
||||
if len(l) > 1:
|
||||
self.base = l[1]
|
||||
self.base_struct_name = "CNetObj_%s" % self.base
|
||||
self.struct_name = "CNetObj_%s" % self.name
|
||||
self.enum_name = "NETOBJTYPE_%s" % self.name.upper()
|
||||
self.base_struct_name = f"CNetObj_{self.base}"
|
||||
self.struct_name = f"CNetObj_{self.name}"
|
||||
self.enum_name = f"NETOBJTYPE_{self.name.upper()}"
|
||||
self.variables = variables
|
||||
def emit_declaration(self):
|
||||
if self.base:
|
||||
lines = ["struct %s : public %s"%(self.struct_name,self.base_struct_name), "{"]
|
||||
lines = [f"struct {self.struct_name} : public {self.base_struct_name}", "{"]
|
||||
else:
|
||||
lines = ["struct %s"%self.struct_name, "{"]
|
||||
lines = [f"struct {self.struct_name}", "{"]
|
||||
for v in self.variables:
|
||||
lines += ["\t"+line for line in v.emit_declaration()]
|
||||
lines += ["};"]
|
||||
return lines
|
||||
def emit_validate(self):
|
||||
lines = ["case %s:" % self.enum_name]
|
||||
lines = [f"case {self.enum_name}:"]
|
||||
lines += ["{"]
|
||||
lines += ["\t%s *pObj = (%s *)pData;"%(self.struct_name, self.struct_name)]
|
||||
lines += [f"\t{self.struct_name} *pObj = ({self.struct_name} *)pData;"]
|
||||
lines += ["\tif(sizeof(*pObj) != Size) return -1;"]
|
||||
for v in self.variables:
|
||||
lines += ["\t"+line for line in v.emit_validate()]
|
||||
|
@ -241,21 +241,21 @@ class NetObject:
|
|||
class NetEvent(NetObject):
|
||||
def __init__(self, name, variables):
|
||||
NetObject.__init__(self, name, variables)
|
||||
self.base_struct_name = "CNetEvent_%s" % self.base
|
||||
self.struct_name = "CNetEvent_%s" % self.name
|
||||
self.enum_name = "NETEVENTTYPE_%s" % self.name.upper()
|
||||
self.base_struct_name = f"CNetEvent_{self.base}"
|
||||
self.struct_name = f"CNetEvent_{self.name}"
|
||||
self.enum_name = f"NETEVENTTYPE_{self.name.upper()}"
|
||||
|
||||
class NetMessage(NetObject):
|
||||
def __init__(self, name, variables):
|
||||
NetObject.__init__(self, name, variables)
|
||||
self.base_struct_name = "CNetMsg_%s" % self.base
|
||||
self.struct_name = "CNetMsg_%s" % self.name
|
||||
self.enum_name = "NETMSGTYPE_%s" % self.name.upper()
|
||||
self.base_struct_name = f"CNetMsg_{self.base}"
|
||||
self.struct_name = f"CNetMsg_{self.name}"
|
||||
self.enum_name = f"NETMSGTYPE_{self.name.upper()}"
|
||||
def emit_unpack(self):
|
||||
lines = []
|
||||
lines += ["case %s:" % self.enum_name]
|
||||
lines += [f"case {self.enum_name}:"]
|
||||
lines += ["{"]
|
||||
lines += ["\t%s *pMsg = (%s *)m_aMsgData;" % (self.struct_name, self.struct_name)]
|
||||
lines += [f"\t{self.struct_name} *pMsg = ({self.struct_name} *)m_aMsgData;"]
|
||||
lines += ["\t(void)pMsg;"]
|
||||
for v in self.variables:
|
||||
lines += ["\t"+line for line in v.emit_unpack()]
|
||||
|
@ -299,29 +299,29 @@ class NetVariable:
|
|||
|
||||
class NetString(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["const char *%s;"%self.name]
|
||||
return [f"const char *{self.name};"]
|
||||
def emit_unpack(self):
|
||||
return ["pMsg->%s = pUnpacker->GetString();" % self.name]
|
||||
return [f"pMsg->{self.name} = pUnpacker->GetString();"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddString(%s, -1);" % self.name]
|
||||
return [f"pPacker->AddString({self.name}, -1);"]
|
||||
|
||||
class NetStringStrict(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["const char *%s;"%self.name]
|
||||
return [f"const char *{self.name};"]
|
||||
def emit_unpack(self):
|
||||
return ["pMsg->%s = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);" % self.name]
|
||||
return [f"pMsg->{self.name} = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddString(%s, -1);" % self.name]
|
||||
return [f"pPacker->AddString({self.name}, -1);"]
|
||||
|
||||
class NetIntAny(NetVariable):
|
||||
def emit_declaration(self):
|
||||
return ["int %s;"%self.name]
|
||||
return [f"int {self.name};"]
|
||||
def emit_unpack(self):
|
||||
if self.default is None:
|
||||
return ["pMsg->%s = pUnpacker->GetInt();" % self.name]
|
||||
return ["pMsg->%s = pUnpacker->GetIntOrDefault(%s);" % (self.name, self.default)]
|
||||
return [f"pMsg->{self.name} = pUnpacker->GetInt();"]
|
||||
return [f"pMsg->{self.name} = pUnpacker->GetIntOrDefault({self.default});"]
|
||||
def emit_pack(self):
|
||||
return ["pPacker->AddInt(%s);" % self.name]
|
||||
return [f"pPacker->AddInt({self.name});"]
|
||||
|
||||
class NetIntRange(NetIntAny):
|
||||
def __init__(self, name, min_val, max_val, default=None):
|
||||
|
@ -329,9 +329,9 @@ class NetIntRange(NetIntAny):
|
|||
self.min = str(min_val)
|
||||
self.max = str(max_val)
|
||||
def emit_validate(self):
|
||||
return ["if(!CheckInt(\"%s\", pObj->%s, %s, %s)) return -1;"%(self.name, self.name, self.min, self.max)]
|
||||
return [f"if(!CheckInt(\"{self.name}\", pObj->{self.name}, {self.min}, {self.max})) return -1;"]
|
||||
def emit_unpack_check(self):
|
||||
return ["if(!CheckInt(\"%s\", pMsg->%s, %s, %s)) break;"%(self.name, self.name, self.min, self.max)]
|
||||
return [f"if(!CheckInt(\"{self.name}\", pMsg->{self.name}, {self.min}, {self.max})) break;"]
|
||||
|
||||
class NetEnum(NetIntRange):
|
||||
def __init__(self, name, enum):
|
||||
|
@ -341,15 +341,15 @@ class NetFlag(NetIntAny):
|
|||
def __init__(self, name, flag):
|
||||
NetIntAny.__init__(self, name)
|
||||
if len(flag.values) > 0:
|
||||
self.mask = "%s_%s" % (flag.name, flag.values[0])
|
||||
self.mask = f"{flag.name}_{flag.values[0]}"
|
||||
for i in flag.values[1:]:
|
||||
self.mask += "|%s_%s" % (flag.name, i)
|
||||
self.mask += f"|{flag.name}_{i}"
|
||||
else:
|
||||
self.mask = "0"
|
||||
def emit_validate(self):
|
||||
return ["if(!CheckFlag(\"%s\", pObj->%s, %s)) return -1;"%(self.name, self.name, self.mask)]
|
||||
return [f"if(!CheckFlag(\"{self.name}\", pObj->{self.name}, {self.mask})) return -1;"]
|
||||
def emit_unpack_check(self):
|
||||
return ["if(!CheckFlag(\"%s\", pMsg->%s, %s)) break;"%(self.name, self.name, self.mask)]
|
||||
return [f"if(!CheckFlag(\"{self.name}\", pMsg->{self.name}, {self.mask})) break;"]
|
||||
|
||||
class NetBool(NetIntRange):
|
||||
def __init__(self, name, default=None):
|
||||
|
@ -366,31 +366,31 @@ class NetArray(NetVariable):
|
|||
self.base_name = var.name
|
||||
self.var = var
|
||||
self.size = size
|
||||
self.name = self.base_name + "[%d]"%self.size
|
||||
self.name = self.base_name + f"[{int(self.size)}]"
|
||||
def emit_declaration(self):
|
||||
self.var.name = self.name
|
||||
return self.var.emit_declaration()
|
||||
def emit_validate(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_validate()
|
||||
return lines
|
||||
def emit_unpack(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_unpack()
|
||||
return lines
|
||||
def emit_pack(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_pack()
|
||||
return lines
|
||||
def emit_unpack_check(self):
|
||||
lines = []
|
||||
for i in range(self.size):
|
||||
self.var.name = self.base_name + "[%d]"%i
|
||||
self.var.name = self.base_name + f"[{int(i)}]"
|
||||
lines += self.var.emit_unpack_check()
|
||||
return lines
|
||||
|
|
|
@ -4,7 +4,7 @@ f = open("src/engine/keys.h", "w")
|
|||
|
||||
keynames = []
|
||||
for i in range(0, 512):
|
||||
keynames += ["&%d"%i]
|
||||
keynames += [f"&{int(i)}"]
|
||||
|
||||
print("#ifndef ENGINE_KEYS_H", file=f)
|
||||
print("#define ENGINE_KEYS_H", file=f)
|
||||
|
@ -28,7 +28,7 @@ for line in open("scripts/SDL_scancode.h"):
|
|||
value = int(l[1].split(",")[0].strip())
|
||||
if key[0:2] == "/*":
|
||||
continue
|
||||
print("\t%s = %d,"%(key, value), file=f)
|
||||
print(f"\t{key} = {int(value)},", file=f)
|
||||
|
||||
keynames[value] = key.replace("KEY_", "").lower()
|
||||
|
||||
|
@ -37,74 +37,74 @@ for line in open("scripts/SDL_scancode.h"):
|
|||
|
||||
highestid += 1
|
||||
print("", file=f)
|
||||
print("\tKEY_MOUSE_1 = %d,"%(highestid), file=f); keynames[highestid] = "mouse1"; highestid += 1
|
||||
print("\tKEY_MOUSE_2 = %d,"%(highestid), file=f); keynames[highestid] = "mouse2"; highestid += 1
|
||||
print("\tKEY_MOUSE_3 = %d,"%(highestid), file=f); keynames[highestid] = "mouse3"; highestid += 1
|
||||
print("\tKEY_MOUSE_4 = %d,"%(highestid), file=f); keynames[highestid] = "mouse4"; highestid += 1
|
||||
print("\tKEY_MOUSE_5 = %d,"%(highestid), file=f); keynames[highestid] = "mouse5"; highestid += 1
|
||||
print("\tKEY_MOUSE_6 = %d,"%(highestid), file=f); keynames[highestid] = "mouse6"; highestid += 1
|
||||
print("\tKEY_MOUSE_7 = %d,"%(highestid), file=f); keynames[highestid] = "mouse7"; highestid += 1
|
||||
print("\tKEY_MOUSE_8 = %d,"%(highestid), file=f); keynames[highestid] = "mouse8"; highestid += 1
|
||||
print("\tKEY_MOUSE_9 = %d,"%(highestid), file=f); keynames[highestid] = "mouse9"; highestid += 1
|
||||
print("\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelup"; highestid += 1
|
||||
print("\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid), file=f); keynames[highestid] = "mousewheeldown"; highestid += 1
|
||||
print("\tKEY_MOUSE_WHEEL_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelleft"; highestid += 1
|
||||
print("\tKEY_MOUSE_WHEEL_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelright"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_1 = {int(highestid)},", file=f); keynames[highestid] = "mouse1"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_2 = {int(highestid)},", file=f); keynames[highestid] = "mouse2"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_3 = {int(highestid)},", file=f); keynames[highestid] = "mouse3"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_4 = {int(highestid)},", file=f); keynames[highestid] = "mouse4"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_5 = {int(highestid)},", file=f); keynames[highestid] = "mouse5"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_6 = {int(highestid)},", file=f); keynames[highestid] = "mouse6"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_7 = {int(highestid)},", file=f); keynames[highestid] = "mouse7"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_8 = {int(highestid)},", file=f); keynames[highestid] = "mouse8"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_9 = {int(highestid)},", file=f); keynames[highestid] = "mouse9"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_WHEEL_UP = {int(highestid)},", file=f); keynames[highestid] = "mousewheelup"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_WHEEL_DOWN = {int(highestid)},", file=f); keynames[highestid] = "mousewheeldown"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_WHEEL_LEFT = {int(highestid)},", file=f); keynames[highestid] = "mousewheelleft"; highestid += 1
|
||||
print(f"\tKEY_MOUSE_WHEEL_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "mousewheelright"; highestid += 1
|
||||
print("", file=f)
|
||||
print("\tKEY_JOYSTICK_BUTTON_0 = %d,"%(highestid), file=f); keynames[highestid] = "joystick0"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_1 = %d,"%(highestid), file=f); keynames[highestid] = "joystick1"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_2 = %d,"%(highestid), file=f); keynames[highestid] = "joystick2"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_3 = %d,"%(highestid), file=f); keynames[highestid] = "joystick3"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_4 = %d,"%(highestid), file=f); keynames[highestid] = "joystick4"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_5 = %d,"%(highestid), file=f); keynames[highestid] = "joystick5"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_6 = %d,"%(highestid), file=f); keynames[highestid] = "joystick6"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_7 = %d,"%(highestid), file=f); keynames[highestid] = "joystick7"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_8 = %d,"%(highestid), file=f); keynames[highestid] = "joystick8"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_9 = %d,"%(highestid), file=f); keynames[highestid] = "joystick9"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_10 = %d,"%(highestid), file=f); keynames[highestid] = "joystick10"; highestid += 1
|
||||
print("\tKEY_JOYSTICK_BUTTON_11 = %d,"%(highestid), file=f); keynames[highestid] = "joystick11"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_0 = {int(highestid)},", file=f); keynames[highestid] = "joystick0"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_1 = {int(highestid)},", file=f); keynames[highestid] = "joystick1"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_2 = {int(highestid)},", file=f); keynames[highestid] = "joystick2"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_3 = {int(highestid)},", file=f); keynames[highestid] = "joystick3"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_4 = {int(highestid)},", file=f); keynames[highestid] = "joystick4"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_5 = {int(highestid)},", file=f); keynames[highestid] = "joystick5"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_6 = {int(highestid)},", file=f); keynames[highestid] = "joystick6"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_7 = {int(highestid)},", file=f); keynames[highestid] = "joystick7"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_8 = {int(highestid)},", file=f); keynames[highestid] = "joystick8"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_9 = {int(highestid)},", file=f); keynames[highestid] = "joystick9"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_10 = {int(highestid)},", file=f); keynames[highestid] = "joystick10"; highestid += 1
|
||||
print(f"\tKEY_JOYSTICK_BUTTON_11 = {int(highestid)},", file=f); keynames[highestid] = "joystick11"; highestid += 1
|
||||
print("", file=f)
|
||||
print("\tKEY_JOY_HAT0_LEFTUP = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_leftup"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_UP = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_up"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_RIGHTUP = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_rightup"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_left"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_right"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_LEFTDOWN = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_leftdown"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_DOWN = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_down"; highestid += 1
|
||||
print("\tKEY_JOY_HAT0_RIGHTDOWN = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat0_rightdown"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_LEFTUP = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_leftup"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_UP = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_up"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_RIGHTUP = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_rightup"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_left"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_right"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_LEFTDOWN = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_leftdown"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_DOWN = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_down"; highestid += 1
|
||||
print("\tKEY_JOY_HAT1_RIGHTDOWN = %d,"%(highestid), file=f); keynames[highestid] = "joy_hat1_rightdown"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_LEFTUP = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_leftup"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_UP = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_up"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_RIGHTUP = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_rightup"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_LEFTDOWN = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_leftdown"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_DOWN = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_down"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT0_RIGHTDOWN = {int(highestid)},", file=f); keynames[highestid] = "joy_hat0_rightdown"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_LEFTUP = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_leftup"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_UP = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_up"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_RIGHTUP = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_rightup"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_LEFTDOWN = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_leftdown"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_DOWN = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_down"; highestid += 1
|
||||
print(f"\tKEY_JOY_HAT1_RIGHTDOWN = {int(highestid)},", file=f); keynames[highestid] = "joy_hat1_rightdown"; highestid += 1
|
||||
print("", file=f)
|
||||
print("\tKEY_JOY_AXIS_0_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis0_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_0_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis0_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_1_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis1_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_1_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis1_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_2_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis2_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_2_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis2_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_3_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis3_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_3_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis3_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_4_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis4_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_4_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis4_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_5_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis5_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_5_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis5_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_6_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis6_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_6_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis6_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_7_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis7_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_7_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis7_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_8_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis8_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_8_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis8_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_9_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis9_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_9_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis9_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_10_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis10_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_10_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis10_right"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_11_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis11_left"; highestid += 1
|
||||
print("\tKEY_JOY_AXIS_11_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "joy_axis11_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_0_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis0_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_0_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis0_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_1_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis1_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_1_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis1_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_2_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis2_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_2_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis2_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_3_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis3_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_3_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis3_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_4_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis4_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_4_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis4_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_5_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis5_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_5_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis5_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_6_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis6_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_6_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis6_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_7_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis7_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_7_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis7_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_8_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis8_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_8_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis8_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_9_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis9_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_9_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis9_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_10_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis10_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_10_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis10_right"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_11_LEFT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis11_left"; highestid += 1
|
||||
print(f"\tKEY_JOY_AXIS_11_RIGHT = {int(highestid)},", file=f); keynames[highestid] = "joy_axis11_right"; highestid += 1
|
||||
print("", file=f)
|
||||
print("\tKEY_LAST = 512,", file=f)
|
||||
print("", file=f)
|
||||
|
@ -133,7 +133,7 @@ print("", file=f)
|
|||
print("const char g_aaKeyStrings[512][20] = // NOLINT(misc-definitions-in-headers)", file=f)
|
||||
print("{", file=f)
|
||||
for n in keynames:
|
||||
print('\t"%s",'%n, file=f)
|
||||
print(f'\t"{n}",', file=f)
|
||||
|
||||
print("};", file=f)
|
||||
print("", file=f)
|
||||
|
|
|
@ -226,7 +226,7 @@ def get_list2(address):
|
|||
master_servers = []
|
||||
|
||||
for i in range(1, NUM_MASTERSERVERS+1):
|
||||
m = Master_Server_Info(("master%d.teeworlds.com"%i, MASTERSERVER_PORT))
|
||||
m = Master_Server_Info((f"master{int(i)}.teeworlds.com", MASTERSERVER_PORT))
|
||||
master_servers.append(m)
|
||||
m.start()
|
||||
time.sleep(0.001) # avoid issues
|
||||
|
|
Loading…
Reference in a new issue