Remove a bunch of unused scripts

scripts/compiler.py: Looks like an older version of datasrc/datatypes.py
scripts/copyright.py: Checks copyright headers in files
scripts/count_source.sh: Counts source files, from SVN(!) times
scripts/dat2c: Writes a C constant with the contents of a file
scripts/font_converter.py: Conversion tool for an old font format
scripts/font_installer.sh: Calls the conversion tool on all fonts
scripts/linecount.sh: Counts source code lines (using `wc` and `find`)
scripts/make_docs.sh: Generates source code docs that haven't existed for a long time
scripts/mass_server.py: Starts a lot of `fake_server`
scripts/netobj.py: Looks like an older version of datasrc/datatypes.py
scripts/nicks.txt: Auxiliary file for scripts/mass_server.py
scripts/png.py: Conversion of image file formats
scripts/process_blame.py: SVN-era source count
This commit is contained in:
heinrich5991 2018-07-06 15:14:13 +02:00
parent 7c3e4e7f09
commit f46f811280
13 changed files with 0 additions and 1521 deletions

View file

@ -1,658 +0,0 @@
#!/usr/bin/python
import sys
import struct
import os
option_ptrsize = struct.calcsize("P")
option_intsize = struct.calcsize("l")
option_floatsize = struct.calcsize("f")
option_inttype = "long"
option_floattype = "float"
class node:
def __init__(self):
self.values = []
self.children = []
self.parent = 0
def name(self):
if len(self.values):
return self.values[0]
return ""
def debug_print(self, level):
print (" "*level) + " ".join(self.values),
if len(self.children):
print "{"
for c in self.children:
c.debug_print(level+1)
print (" "*level)+"}"
else:
print ""
def debug_root(self):
for c in self.children:
c.debug_print(0)
# TODO: should return list of items in the tree,
def gather(self, str):
def recurse(parts, path, node):
if not len(parts):
r = {}
path = path + "." + node.values[0]
r = [node]
#print "found", path
return r
l = []
for c in node.children:
if parts[0] == "*" or c.values[0] == parts[0]:
if len(node.values):
if len(path):
l += recurse(parts[1:], path+"."+node.values[0], c)
else:
l += recurse(parts[1:], node.values[0], c)
else:
l += recurse(parts[1:], path, c)
return l
parts = str.split(".")
return recurse(parts, "", self)
def find_node(self, str):
parts = str.split(".")
node = self
for part in parts:
if len(part) == 0:
continue
if part == "parent":
node = node.parent
else:
found = 0
for c in node.children:
if part == c.values[0]:
node = c
found = 1
break
if node == self:
return
return node
def get_single(self, str):
parts = str.split("@")
index = -1
if len(parts) == 2:
index = int(parts[1])
node = self
if len(parts[0]):
node = self.find_node(parts[0])
if not node:
print "failed to get", str
return Null
if index == -1:
return node.get_path()[1:]
return node.values[index]
def get_path(self):
if self.parent == 0:
return ""
return self.parent.get_path() + "." + self.values[0]
def get_single_name(self, str):
return self.get_path()[1:] + "." + str
class parser:
lines = []
def parse_node(self, this_node):
while len(self.lines):
line = self.lines.pop(0) # grab line
fields = line.strip().split() # TODO: improve this to handle strings with spaces
if not len(fields):
continue
if fields[-1] == '{':
new_node = node()
new_node.parent = this_node
new_node.values = fields[:-1]
this_node.children += [new_node]
self.parse_node(new_node)
elif fields[-1] == '}':
break
else:
new_node = node()
new_node.parent = this_node
new_node.values = fields
this_node.children += [new_node]
def parse_file(self, filename):
self.lines = file(filename).readlines()
n = node()
self.parse_node(n)
return n
def parse_file(filename):
return parser().parse_file(filename)
class pointer:
def __init__(self, index, target):
self.index = index
self.target = target
class data_constructor:
def __init__(self):
self.data = ""
self.trans = 0
self.pointers = []
self.targets = {}
self.enums = {}
def get_type(self, s):
return self.trans.types[s]
def allocate(self, size):
index = len(self.data)
self.data += "\0"*size
return index
def add_pointer(self, index, target):
self.pointers += [pointer(index, target)]
def add_enum(self, name, value):
self.enums[name] = value
def get_enum_value(self, name):
if not name in self.enums:
print "ERROR: couldn't find enum '%s'" % (name)
return self.enums[name]
def add_target(self, target, index):
# TODO: warn about duplicates
#print "add_target(target='%s' index=%d)" % (target, index)
self.targets[target] = index
def write(self, index, size, data):
try:
self.data = self.data[:index] + data + self.data[index+size:]
except:
print "write error:"
print "\tself.data =", self.data
print "\tdata =", data
def patch_pointers(self):
for p in self.pointers:
if p.target in self.targets:
i = self.targets[p.target]
#print "ptr @ %d -> %s -> %d" % (p.index, p.target, i)
data = struct.pack("P", i)
self.write(p.index, len(data), data)
else:
print "ERROR: couldn't find target '%s' for pointer at %d" % (p.target, p.index)
class type:
def __init__(self):
self.name = ""
def size(self):
pass
class structure:
def __init__(self):
self.name = ""
self.members = []
def size(self):
s = 0
for m in self.members:
s += m.size()
return s
def emit_header_code(self, out):
print >>out, "struct", self.name
print >>out, "{"
for m in self.members:
for l in m.get_code():
print >>out, "\t" + l
print >>out, "};"
print >>out, ""
def emit_source_code(self, out):
print >>out, "static void patch_ptr_%s(%s *self, char *base)" % (self.name, self.name)
print >>out, "{"
for m in self.members:
for l in m.get_patch_code("self", "base"):
print >>out, "\t" + l
print >>out, "}"
print >>out, ""
def emit_data(self, cons, index, src_data):
#print self.name+":"
member_index = index
for m in self.members:
#print "\t" + m.name
m.emit_data(cons, member_index, src_data)
member_index += m.size()
class variable:
def __init__(self):
self.expr = ""
self.type = ""
self.subtype = ""
def get_code(self):
return []
def get_patch_code(self, ptrname, basename):
return []
def emit_data(self, cons, index, src_data):
pass
class variable_int(variable):
def get_code(self):
return ["%s %s;" % (option_inttype, self.name)]
def size(self):
return option_intsize
def emit_data(self, cons, index, src_data):
try:
value = int(self.expr)
except:
value = int(src_data.get_single(self.expr))
#print "int", self.name, "=", value, "@", index
data = struct.pack("l", value)
cons.write(index, len(data), data)
class variable_float(variable):
def get_code(self):
return ["%s %s;" % (option_floattype, self.name)]
def size(self):
return option_floatsize
def emit_data(self, cons, index, src_data):
try:
value = float(self.expr)
except:
value = float(src_data.get_single(self.expr))
#print "int", self.name, "=", value, "@", index
data = struct.pack("f", value)
cons.write(index, len(data), data)
class variable_string(variable):
def get_code(self):
return ["char *%s;" % (self.name)]
def get_patch_code(self, ptrname, basename):
return ["patch_ptr((char **)&(%s->%s), %s);" % (ptrname, self.name, basename)]
def size(self):
return option_ptrsize
def emit_data(self, cons, index, src_data):
string = src_data.get_single(self.expr)
string = string.strip()[1:-1] # skip " and "
string_index = cons.allocate(len(string)+1)
cons.write(string_index, len(string), string)
data = struct.pack("P", string_index) # TODO: solve this
cons.write(index, len(data), data)
class variable_ptr(variable):
def get_code(self):
return ["%s *%s;" % (self.subtype, self.name)]
def get_patch_code(self, ptrname, basename):
return ["patch_ptr((char**)&(%s->%s), %s);" % (ptrname, self.name, basename)]
def size(self):
return option_ptrsize
def emit_data(self, cons, index, src_data):
target = src_data.get_single(self.expr)
cons.add_pointer(index, target)
class variable_enum(variable):
def get_code(self):
return ["long *%s;" % (self.name)]
def size(self):
return option_intsize
def emit_data(self, cons, index, src_data):
target = src_data.get_single(self.expr)
data = struct.pack("l", cons.get_enum_value(target))
cons.write(index, len(data), data)
class variable_instance(variable):
def get_code(self):
return ["%s %s;" % (self.subtype, self.name)]
def get_patch_code(self, ptrname, basename):
return ["patch_ptr_%s(&(%s->%s), %s);" % (self.subtype, ptrname, self.name, basename)]
def size(self):
return self.translator.types[self.subtype].size()
def emit_data(self, cons, index, src_data):
target = src_data.find_node(self.expr)
translator.types[self.subtype].emit_data(cons, index, target)
#target =
#cons.add_pointer(index, target)
class variable_array(variable):
def get_code(self):
return ["long num_%s;" % self.name,
"%s *%s;" % (self.subtype, self.name)]
def get_patch_code(self, ptrname, baseptr):
code = []
code += ["patch_ptr((char**)&(%s->%s), %s);" % (ptrname, self.name, baseptr)]
code += ["for(int i = 0; i < %s->num_%s; i++)" % (ptrname, self.name)]
code += ["\tpatch_ptr_%s(%s->%s+i, %s);" % (self.subtype, ptrname, self.name, baseptr)]
return code
def emit_data(self, cons, index, src_data):
array_data = src_data.gather(self.expr)
array_type = cons.get_type(self.subtype)
size = array_type.size()*len(array_data)
#print "packing array", self.name
#print "\ttype =", array_type.name
#print "\tsize =", array_type.size()
array_index = cons.allocate(size)
data = struct.pack("lP", len(array_data), array_index) # TODO: solve this
cons.write(index, len(data), data)
member_index = array_index
for node in array_data:
cons.add_target(node.get_path()[1:], member_index)
array_type.emit_data(cons, member_index, node)
member_index += array_type.size()
#print "array", member_index
def size(self):
return option_ptrsize+option_intsize
class const_arrayint:
def __init__(self):
self.name = ""
self.values = []
def emit_header_code(self, out):
print >>out, "enum"
print >>out, "{"
for i in xrange(0, len(self.values)):
print >>out, "\t%s_%s = %d," % (self.name.upper(), self.values[i].upper(), i)
print >>out, "\tNUM_%sS = %d" % (self.name.upper(), len(self.values))
print >>out, "};"
print >>out, ""
class translator:
def __init__(self):
self.types = {}
self.structs = []
self.constants = []
self.data = 0
self.srcdata = 0
self.types["int"] = variable_int()
self.types["float"] = variable_float()
self.types["string"] = variable_string()
self.types["ptr"] = variable_ptr()
self.types["array"] = variable_array()
def parse_variable(self, node):
if len(node.values) != 4:
print node.values
raise "error parsing variable"
type = node.values[0]
subtype = ""
if type == "int":
v = variable_int()
elif type == "enum":
v = variable_enum()
elif type == "float":
v = variable_float()
elif type == "string":
v = variable_string()
else:
# complex type
parts = type.split(":")
if len(parts) != 2:
raise "can't emit code for variable %s of type %s" % (self.name, self.type)
elif parts[0] == "ptr":
subtype = parts[1]
v = variable_ptr()
elif parts[0] == "instance":
subtype = parts[1]
v = variable_instance()
elif parts[0] == "array":
subtype = parts[1]
v = variable_array()
else:
raise "can't emit code for variable %s of type %s" % (self.name, self.type)
v.translator = self
v.type = node.values[0]
v.subtype = subtype
v.name = node.values[1]
assignment = node.values[2]
v.expr = node.values[3]
if assignment != "=":
raise "error parsing variable. expected ="
return v
def parse_struct(self, node):
if len(node.values) != 2:
raise "error parsing struct"
s = structure()
s.name = node.values[1]
for statement in node.children:
s.members += [self.parse_variable(statement)]
return s
def parse_constant(self, node):
if len(node.values) != 5:
print node.values
raise "error parsing constant"
type = node.values[1]
name = node.values[2]
assignment = node.values[3]
expression = node.values[4]
if assignment != "=":
print node.values
raise "error parsing constant"
ints = const_arrayint()
ints.name = name
items = self.srcdata.gather(expression)
for c in items:
ints.values += [c.name()]
self.constants += [ints]
def parse(self, script, srcdata):
self.srcdata = srcdata
for statement in script.children:
if statement.values[0] == "struct":
s = self.parse_struct(statement)
self.structs += [s]
self.types[s.name] = s
elif statement.values[0] == "const":
self.parse_constant(statement)
else:
raise "unknown statement:" + statement
def emit_header_code(self, out):
for c in self.constants:
c.emit_header_code(out)
for s in self.structs:
s.emit_header_code(out)
print >>out, ""
print >>out, "struct data_container *load_data_from_file(const char *filename);"
print >>out, "struct data_container *load_data_from_memory(unsigned char *filename);"
print >>out, ""
def emit_source_code(self, out, header_filename):
print >>out, '''
#include "%s"
#include <stdio.h>
#include <stdlib.h>
static void patch_ptr(char **ptr, char *base)
{
*ptr = base+(size_t)(*ptr);
}
''' % header_filename
for s in self.structs:
s.emit_source_code(out)
print >>out, '''
data_container *load_data_from_memory(unsigned char *mem)
{
if(mem[0] != sizeof(void*))
return 0;
if(mem[1] != sizeof(long))
return 0;
if(mem[2] != sizeof(float))
return 0;
/* patch all pointers */
data_container *con = (data_container*)(mem + 4);
patch_ptr_data_container(con, (char *)con);
return con;
}
data_container *load_data_from_file(const char *filename)
{
unsigned char *data = 0;
int size;
/* open file */
FILE *f = fopen(filename, "rb");
/* get size */
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);
/* allocate, read data and close file */
data = (unsigned char *)malloc(size);
fread(data, 1, size, f);
fclose(f);
return load_data_from_memory(data);
}
'''
def emit_data(self):
for s in self.structs:
if s.name == "data_container":
#print "found data_container"
cons = data_constructor()
cons.trans = self
i = cons.allocate(s.size())
s.emit_data(cons, i, self.srcdata)
cons.patch_pointers()
header = struct.pack("bbbb", option_ptrsize, option_intsize, option_floatsize, 0)
return header + cons.data
def create_translator(script, srcdata):
t = translator()
t.parse(script, srcdata)
return t
def validate(script, validator):
def validate_values(values, check):
if not len(check) or check[0] == "*":
print "too many values"
return
p = check[0].split(":")
type = p[0]
name = p[1]
# TODO: check type and stuff
# recurse
if len(values) > 1:
if not len(check):
print "unexpected value"
validate_values(values[1:], check[1:])
else:
if len(check) > 1 and check[1] != "*":
print "to few values"
if len(script.values):
validate_values(script.values, validator.values)
for child in script.children:
tag = child.values[0]
n = validator.find_node("tag:"+tag)
if not n:
found = 0
for vc in validator.children:
if "ident:" in vc.values[0]:
validate(child, vc)
print vc.values[0]
found = 1
break
if not found:
print "error:", tag, "not found"
else:
print "tag:"+tag
validate(child, n)
input_filename = sys.argv[1]
script_filename = sys.argv[2]
output_filename = 0
coutput_filename = 0
header_filename = 0
source_filename = 0
sheader_filename = 0
if sys.argv[3] == '-h':
header_filename = sys.argv[4]
elif sys.argv[3] == '-s':
source_filename = sys.argv[4]
sheader_filename = sys.argv[5]
elif sys.argv[3] == '-d':
output_filename = sys.argv[4]
elif sys.argv[3] == '-c':
coutput_filename = sys.argv[4]
srcdata = parse_file(input_filename)
script = parse_file(script_filename)
translator = create_translator(script, srcdata)
if header_filename:
translator.emit_header_code(file(header_filename, "w"))
if source_filename:
translator.emit_source_code(file(source_filename, "w"), os.path.basename(sheader_filename))
if output_filename:
rawdata = translator.emit_data()
file(output_filename, "wb").write(rawdata)
if coutput_filename:
i = 0
rawdata = translator.emit_data()
f = file(coutput_filename, "w")
print >>f,"unsigned char internal_data[] = {"
print >>f,str(ord(rawdata[0])),
for d in rawdata[1:]:
s = ","+str(ord(d))
print >>f,s,
i += len(s)+1
if i >= 70:
print >>f,""
i = 0
print >>f,""
print >>f,"};"
print >>f,""
f.close()

View file

@ -1,65 +0,0 @@
import os, re, sys
match = re.search('(.*)/', sys.argv[0])
if match != None:
os.chdir(match.group(1))
os.chdir('../')
notice = [b"/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */\n", b"/* If you are missing that file, acquire a complete release at teeworlds.com. */\n"]
exclude = ["src%sengine%sexternal" % (os.sep, os.sep), "src%sosxlaunch" % os.sep]
updated_files = 0
def fix_copyright_notice(filename):
global updated_files
f = open(filename, "rb")
lines = f.readlines()
f.close()
i = 0
length_lines = len(lines)
if length_lines > 0:
while i <= length_lines and (lines[i].decode("utf-8").lstrip()[:2] == "//" or lines[i].decode("utf-8").lstrip()[:2] == "/*" and lines[i].decode("utf-8").rstrip()[-2:] == "*/") and ("Magnus" in lines[i].decode("utf-8") or "magnus" in lines[i].decode("utf-8") or "Auvinen" in lines[i].decode("utf-8") or "auvinen" in lines[i].decode("utf-8") or "license" in lines[i].decode("utf-8") or "teeworlds" in lines[i].decode("utf-8")):
i += 1
length_notice = len(notice)
if i > 0:
j = 0
while lines[j] == notice[j]:
j += 1
if j == length_notice:
return
k = j
j = 0
while j < length_notice -1 - k:
lines = [notice[j]] + lines
j += 1
while j < length_notice:
lines[j] = notice[j]
j += 1
if length_lines == 0 or i == 0:
j = length_notice - 1
while j >= 0:
lines = [notice[j]] + lines
j -= 1
open(filename, "wb").writelines(lines)
updated_files += 1
skip = False
for root, dirs, files in os.walk("src"):
for excluding in exclude:
if root[:len(excluding)] == excluding:
skip = True
break
if skip == True:
skip = False
continue
for name in files:
filename = os.path.join(root, name)
if filename[-2:] != ".c" and filename[-4:] != ".cpp" and filename[-2:] != ".h":
continue
fix_copyright_notice(filename)
output = "file"
if updated_files != 1:
output += "s"
print("*** updated %d %s ***" % (updated_files, output))

View file

@ -1 +0,0 @@
svn blame `svn -R ls | grep ^src | grep -v external | grep -v /$ | grep -v \.txt` | python scripts/process_blame.py

View file

@ -1,17 +0,0 @@
import sys
data = file(sys.argv[1], "rb").read()
i = 0
print "unsigned char", sys.argv[2], "[] = {"
print str(ord(data[0])),
for d in data[1:]:
s = ","+str(ord(d))
print s,
i += len(s)+1
if i >= 70:
print ""
i = 0
print ""
print "};"

View file

@ -1,148 +0,0 @@
from __future__ import with_statement
import struct
import sys
import re
def convert(input, output):
with open(input, "r") as in_file:
with open(output, "w") as out_file:
def build_dic(parts):
dic = {}
for part in parts:
key, value = part.split('=')
try:
dic[key] = int(value)
except:
dic[key] = value
return dic
def get_entry(line):
while line[-1] == "\r" or line[-1] == "\n":
line = line[0:-1]
parts = []
quote = 0
part = ""
for c in line:
if c == "\"":
quote = 1-quote
elif c == " " and not quote:
if part:
parts.append(part)
part = ""
else:
part += c
if part:
parts.append(part)
type = parts[0]
dic = build_dic(parts[1:])
return type, dic
def write_int16(val):
out_file.write(struct.pack('<h', val))
def write_info(dic):
write_int16(dic["size"])
def write_common(dic):
write_int16(dic["scaleW"])
write_int16(dic["scaleH"])
write_int16(dic["lineHeight"])
write_int16(dic["base"])
def write_page(dic):
pass
def write_chars(dic):
pass
def write_char(dic):
write_int16(dic["x"])
write_int16(dic["y"])
write_int16(dic["width"])
write_int16(dic["height"])
write_int16(dic["xoffset"])
write_int16(dic["yoffset"])
write_int16(dic["xadvance"])
def write_default_char():
write_int16(0)
write_int16(0)
write_int16(0)
write_int16(0)
write_int16(0)
write_int16(0)
write_int16(0)
def write_kernings(dic):
pass
def write_kerning(dic):
write_int16(dic["amount"])
def write_default_kerning():
write_int16(0)
chars = []
kernings = []
for i in range(256):
chars.append(None)
for i in range(256*256):
kernings.append(None)
def save_char(dic):
if dic["id"] < 256:
chars[dic["id"]] = dic
def save_kerning(dic):
kernings[dic["first"] + dic["second"]*256] = dic
write_table = {
"info": write_info,
"common": write_common,
"page": write_page,
"chars": write_chars,
"char": save_char,
"kernings": write_kernings,
"kerning": save_kerning
}
for line in in_file:
type, dic = get_entry(line)
write_table[type](dic)
for i in range(256):
if chars[i]:
write_char(chars[i])
else:
write_default_char()
for i in range(256*256):
if kernings[i]:
write_kerning(kernings[i])
else:
write_default_kerning()
if len(sys.argv) >= 2:
print "converting..."
filenames = sys.argv[1:]
for filename in filenames:
input = filename
output = re.sub("fnt$", "tfnt", input)
print "input: %s, output: %s" % (input, output)
convert(input, output)
print "done!"
else:
print "font converter! converts .fnt files to teeworlds .tfnt"
print "usage: font_converter <input>"

View file

@ -1,3 +0,0 @@
echo Generating .fnts...
../../font_generator/a.out
python ../scripts/font_converter.py default*.fnt

View file

@ -1,2 +0,0 @@
#!/bin/sh
wc `find . -iname *.cpp` `find . -iname *.h` `find . -iname *.c`

View file

@ -1 +0,0 @@
perl docs/tool/NaturalDocs -i src/game -i src/engine -xi src/engine/external -p docs/conf -o html docs/output

View file

@ -1,50 +0,0 @@
#from random import choice
import random
import os
masterservers = ["localhost 8300"]
maps = [
["dm1", "dm2", "dm6"],
["dm1", "dm2", "dm6"],
["ctf1", "ctf2", "ctf3"],
]
servernames = [
"%s playhouse",
"%s own server",
]
nicks = []
for l in file("scripts/nicks.txt"):
nicks += l.replace(":port80c.se.quakenet.org 353 matricks_ = #pcw :", "").strip().split()
inick = 0
def get_nick():
global inick, nicks
inick = (inick+1)%len(nicks)
return nicks[inick].replace("`", "\`")
for s in xrange(0, 350):
cmd = "./fake_server_d_d "
cmd += '-n "%s" ' % (random.choice(servernames) % get_nick())
for m in masterservers:
cmd += '-m %s '%m
max = random.randint(2, 16)
cmd += "-x %d " % max
t = random.randint(0, 2)
cmd += '-a "%s" ' % random.choice(maps[t])
cmd += '-g %d ' % random.randint(0, 100)
cmd += '-t %d ' % t # dm, tdm, ctf
cmd += "-f %d " % random.randint(0, 1) # password protected
for p in xrange(0, random.randint(0, max)):
cmd += '-p "%s" %d ' % (get_nick(), random.randint(0, 20))
print cmd
os.popen2(cmd)

View file

@ -1,430 +0,0 @@
import sys, os
line_count = 0
class variable:
name = "unknown"
def __init__(self, args, name):
global line_count
self.name = name
self.line = line_count
def emit_declaration(self):
return ["\tint %s;" % self.name]
def linedef(self):
return "#line %d" % self.line
def emit_secure(self, parent):
return []
def emit_unpack(self):
return ["msg.%s = msg_unpack_int();" % self.name]
def emit_unpack_check(self):
return []
def emit_pack(self):
return ["\t\tmsg_pack_int(%s);" % self.name]
class var_any(variable):
def __init__(self, args, name):
variable.__init__(self, args, name)
class var_range(variable):
def __init__(self, args, name):
variable.__init__(self, args, name)
self.min = args[0]
self.max = args[1]
def emit_unpack_check(self):
return ["if(msg.%s < %s || msg.%s > %s) { msg_failed_on = \"%s\"; return 0; }" % (self.name, self.min, self.name, self.max, self.name)]
def emit_secure(self, parent):
return [self.linedef(), "obj->%s = netobj_clamp_int(\"%s.%s\", obj->%s, %s, %s);" % (self.name, parent.name, self.name, self.name, self.min, self.max)]
class var_string(variable):
def __init__(self, args, name):
variable.__init__(self, args, name)
class var_string(variable):
def __init__(self, args, name):
variable.__init__(self, args, name)
def emit_declaration(self):
return ["\tconst char *%s;" % self.name]
def emit_unpack(self):
return ["msg.%s = msg_unpack_string();" % self.name]
def emit_pack(self):
return ["\t\tmsg_pack_string(%s, -1);" % self.name]
class object:
def __init__(self, line):
fields = line.split()
self.name = fields[1]
self.extends = None
if len(fields) == 4 and fields[2] == "extends":
self.extends = fields[3]
self.enum_name = "NETOBJTYPE_%s" % self.name.upper()
self.struct_name = "NETOBJ_%s" % self.name.upper()
self.members = []
def parse(self, lines):
global line_count
for index in xrange(0, len(lines)):
line_count += 1
line = lines[index]
if not len(line):
continue
if line == "end":
return lines[index+1:]
else:
# check for argument
fields = line.split(")", 1)
if len(fields) == 2:
names = [line.strip() for line in fields[1].split(",")]
l = fields[0].split("(", 1)
type = l[0]
args = [line.strip() for line in l[1].split(",")]
else:
l = fields[0].split(None, 1)
type = l[0]
args = []
names = [line.strip() for line in l[1].split(",")]
for name in names:
create_string = 'var_%s(%s, "%s")' % (type, args, name)
new_member = eval(create_string)
self.members += [new_member]
raise BaseException("Parse error")
def emit_declaration(self):
lines = []
if self.extends:
lines += ["struct %s : public NETOBJ_%s\n {" % (self.struct_name, self.extends.upper())]
else:
lines += ["struct %s\n {" % self.struct_name]
for m in self.members:
lines += m.emit_declaration()
lines += ["};"]
return lines
def emit_secure(self):
lines = []
for m in self.members:
lines += m.emit_secure(self)
return lines
class message:
def __init__(self, line):
fields = line.split()
self.name = fields[1]
self.enum_name = "NETMSGTYPE_%s" % self.name.upper()
self.struct_name = "NETMSG_%s" % self.name.upper()
self.members = []
def parse(self, lines):
global line_count
for index in xrange(0, len(lines)):
line_count += 1
line = lines[index]
if not len(line):
continue
if line == "end":
return lines[index+1:]
else:
# check for argument
fields = line.split(")", 1)
if len(fields) == 2:
names = [line.strip() for line in fields[1].split(",")]
l = fields[0].split("(", 1)
type = l[0]
args = [line.strip() for line in l[1].split(",")]
else:
l = fields[0].split(None, 1)
type = l[0]
args = []
names = [line.strip() for line in l[1].split(",")]
for name in names:
create_string = 'var_%s(%s, "%s")' % (type, args, name)
new_member = eval(create_string)
self.members += [new_member]
raise BaseException("Parse error")
def emit_declaration(self):
lines = []
lines += ["struct %s\n {" % self.struct_name]
for m in self.members:
lines += m.emit_declaration()
lines += ["\tvoid pack(int flags)"]
lines += ["\t{"]
lines += ["\t\tmsg_pack_start(%s, flags);" % self.enum_name]
for m in self.members:
lines += m.emit_pack()
lines += ["\t\tmsg_pack_end();"]
lines += ["\t}"]
lines += ["};"]
return lines
def emit_unpack(self):
lines = []
for m in self.members:
lines += m.emit_unpack()
for m in self.members:
lines += m.emit_unpack_check()
return lines
def emit_pack(self):
lines = []
for m in self.members:
lines += m.emit_pack()
return lines
class event(object):
def __init__(self, line):
object.__init__(self, line)
self.enum_name = "NETEVENTTYPE_%s" % self.name.upper()
self.struct_name = "NETEVENT_%s" % self.name.upper()
class raw_reader:
def __init__(self):
self.raw_lines = []
def parse(self, lines):
global line_count
for index in xrange(0, len(lines)):
line_count += 1
line = lines[index]
if not len(line):
continue
if line == "end":
return lines[index+1:]
else:
self.raw_lines += [line]
raise BaseException("Parse error")
class proto:
def __init__(self):
self.objects = []
self.messages = []
self.source_raw = []
self.header_raw = []
def load(filename):
# read the file
global line_count
line_count = 0
lines = [line.split("//", 2)[0].strip() for line in file(filename).readlines()]
p = proto()
while len(lines):
line_count += 1
line = lines[0]
if not len(line):
del lines[0]
continue
fields = line.split(None, 1)
del lines[0]
if fields[0] == "object":
new_obj = object(line)
lines = new_obj.parse(lines)
p.objects += [new_obj]
elif fields[0] == "message":
new_msg = message(line)
lines = new_msg.parse(lines)
p.messages += [new_msg]
elif fields[0] == "event":
new_obj = event(line)
lines = new_obj.parse(lines)
p.objects += [new_obj]
elif fields[0] == "raw_source":
raw = raw_reader()
lines = raw.parse(lines)
p.source_raw += raw.raw_lines
elif fields[0] == "raw_header":
raw = raw_reader()
lines = raw.parse(lines)
p.header_raw += raw.raw_lines
else:
print "error, strange line:", line
return p
def emit_header_file(f, p):
for l in p.header_raw:
print >>f, l
if 1: # emit the enum table for objects
print >>f, "enum {"
print >>f, "\tNETOBJTYPE_INVALID=0,"
for obj in p.objects:
print >>f, "\t%s," % obj.enum_name
print >>f, "\tNUM_NETOBJTYPES"
print >>f, "};"
print >>f, ""
if 1: # emit the enum table for messages
print >>f, "enum {"
print >>f, "\tNETMSGTYPE_INVALID=0,"
for msg in p.messages:
print >>f, "\t%s," % msg.enum_name
print >>f, "\tNUM_NETMSGTYPES"
print >>f, "};"
print >>f, ""
print >>f, "int netobj_secure(int type, void *data, int size);"
print >>f, "const char *netobj_get_name(int type);"
print >>f, "int netobj_num_corrections();"
print >>f, "const char *netobj_corrected_on();"
print >>f, ""
print >>f, "void *netmsg_secure_unpack(int type);"
print >>f, "const char *netmsg_get_name(int type);"
print >>f, "const char *netmsg_failed_on();"
print >>f, ""
for obj in p.objects:
for l in obj.emit_declaration():
print >>f, l
print >>f, ""
for msg in p.messages:
for l in msg.emit_declaration():
print >>f, l
print >>f, ""
def emit_source_file(f, p, protofilename):
print >>f, "#line 1 \"%s\"" % os.path.abspath(protofilename).replace("\\", "\\\\")
for l in p.source_raw:
print >>f, l
print >>f, "const char *msg_failed_on = \"\";"
print >>f, "const char *obj_corrected_on = \"\";"
print >>f, "static int num_corrections = 0;"
print >>f, "int netobj_num_corrections() { return num_corrections; }"
print >>f, "const char *netobj_corrected_on() { return obj_corrected_on; }"
print >>f, "const char *netmsg_failed_on() { return msg_failed_on; }"
print >>f, ""
print >>f, "static int netobj_clamp_int(const char *error_msg, int v, int min, int max)"
print >>f, "{"
print >>f, "\tif(v<min) { obj_corrected_on = error_msg; num_corrections++; return min; }"
print >>f, "\tif(v>max) { obj_corrected_on = error_msg; num_corrections++; return max; }"
print >>f, "\treturn v;"
print >>f, "}"
print >>f, ""
if 1: # names
print >>f, "static const char *object_names[] = {"
print >>f, "\t" + '"invalid",'
for obj in p.objects:
print >>f, '\t"%s",' % obj.name
print >>f, '\t""'
print >>f, "};"
print >>f, ""
if 1: # secure functions
print >>f, "static int secure_object_invalid(void *data, int size) { return 0; }"
for obj in p.objects:
print >>f, "static int secure_%s(void *data, int size)" % obj.name
print >>f, "{"
print >>f, "\t%s *obj = (%s *)data;" % (obj.struct_name, obj.struct_name)
print >>f, "\t(void)obj;" # to get rid of "unused variable" warning
print >>f, "\tif(size != sizeof(%s)) return -1;" % obj.struct_name
if obj.extends:
print >>f, "\tif(secure_%s(data, sizeof(NETOBJ_%s)) != 0) return -1;" % (obj.extends, obj.extends.upper())
for l in obj.emit_secure():
print >>f, "\t" + l
print >>f, "\treturn 0;";
print >>f, "}"
print >>f, ""
if 1: # secure function table
print >>f, "typedef int(*SECUREFUNC)(void *data, int size);"
print >>f, "static SECUREFUNC secure_funcs[] = {"
print >>f, "\t" + 'secure_object_invalid,'
for obj in p.objects:
print >>f, "\tsecure_%s," % obj.name
print >>f, "\t" + '0x0'
print >>f, "};"
print >>f, ""
if 1:
print >>f, "int netobj_secure(int type, void *data, int size)"
print >>f, "{"
print >>f, "\tif(type < 0 || type >= NUM_NETOBJTYPES) return -1;"
print >>f, "\treturn secure_funcs[type](data, size);"
print >>f, "};"
print >>f, ""
if 1:
print >>f, "const char *netobj_get_name(int type)"
print >>f, "{"
print >>f, "\tif(type < 0 || type >= NUM_NETOBJTYPES) return \"(invalid)\";"
print >>f, "\treturn object_names[type];"
print >>f, "};"
print >>f, ""
if 1: # names
print >>f, "static const char *message_names[] = {"
print >>f, "\t" + '"invalid",'
for msg in p.messages:
print >>f, '\t"%s",' % msg.name
print >>f, '\t""'
print >>f, "};"
print >>f, ""
if 1: # secure functions
print >>f, "static void *secure_unpack_invalid() { return 0; }"
for msg in p.messages:
print >>f, "static void *secure_unpack_%s()" % msg.name
print >>f, "{"
print >>f, "\tstatic %s msg;" % msg.struct_name
for l in msg.emit_unpack():
print >>f, "\t" + l
print >>f, "\treturn &msg;";
print >>f, "}"
print >>f, ""
if 1: # secure function table
print >>f, "typedef void *(*SECUREUNPACKFUNC)();"
print >>f, "static SECUREUNPACKFUNC secure_unpack_funcs[] = {"
print >>f, "\t" + 'secure_unpack_invalid,'
for msg in p.messages:
print >>f, "\tsecure_unpack_%s," % msg.name
print >>f, "\t" + '0x0'
print >>f, "};"
print >>f, ""
if 1:
print >>f, "void *netmsg_secure_unpack(int type)"
print >>f, "{"
print >>f, "\tvoid *msg;"
print >>f, "\tmsg_failed_on = \"\";"
print >>f, "\tif(type < 0 || type >= NUM_NETMSGTYPES) return 0;"
print >>f, "\tmsg = secure_unpack_funcs[type]();"
print >>f, "\tif(msg_unpack_error()) return 0;"
print >>f, "\treturn msg;"
print >>f, "};"
print >>f, ""
if 1:
print >>f, "const char *netmsg_get_name(int type)"
print >>f, "{"
print >>f, "\tif(type < 0 || type >= NUM_NETMSGTYPES) return \"(invalid)\";"
print >>f, "\treturn message_names[type];"
print >>f, "};"
print >>f, ""
if sys.argv[1] == "header":
p = load(sys.argv[2])
emit_header_file(file(sys.argv[3], "w"), p)
elif sys.argv[1] == "source":
p = load(sys.argv[2])
emit_source_file(file(sys.argv[3], "w"), p, sys.argv[2])
else:
print "invalid command"
sys.exit(-1)

View file

@ -1,32 +0,0 @@
:port80c.se.quakenet.org 353 matricks_ = #pcw :SPQR|Snapshot em0k1d n1sse iTouch|HedaN Hyeen Mattzki i9`Nilzon matricks_ WCG|Johan format` |ceMan PREGE lololollalalal kishe|Pookie polisen Rambo-ohsite firre15 ais-nax Obbmaster diskoturk SR|KinG gone-andytheman [FG]AkO cfg-gunnar proshit|Benis raaEW bengan-- Loser^ zNEKS Fokka Ping28|kwnztahh Palo^ partyZAH NillePillopio discover J-N ios Cajanen Bsite`oZe haxxcoto Hell[v]SOVA rabies Lampard2k7 DeFuN Linkan bjorniss Soet-DgR-_-[A] BridgeMill|Mod1
:port80c.se.quakenet.org 353 matricks_ = #pcw :Mutt Hofvits [G][L][H][f] dahlgren Zervantes ben_dover fanfanfanfan ibersklan-ruyrl Grismusen Ploxzish Ejwin^mp Poontuus sintr0z hbfs___dSq Bombastic sasdd ErNoI TaizK UnLess Astan SwS-Garcia WyH|spliffstar lololololol Simixiz SD|barkeN MOOE keekz Centern Xzide^^ N43-HYPER LeaW`3D hotnils Lectra`MAEKTIG fnytt frtyschoooooooo insanity|DavidO dr-tom MIM wayu n9ef dinmammaamamam eppel Fess1g wardh hzapRingMeisteR kidneb xplayn Lajgarn flaxe HEJJADANNE
:port80c.se.quakenet.org 353 matricks_ = #pcw :Big^F Bsite`layd hejehjhk hsd1rrruffe AroooooN lexx_ lucchi AriGold DeDDu maflip eMO-aboOoOo Ramos6 ruub bjuse Chawn r3t _ogg kAerhu AIE|malle KimIO-SWE LooOOLiiiZ333eN kullersten Poke_- DryNox KoSmurfen ExakTT Gs|T1AO vtine|MAAAUNS heroX Twind [wc3]-Chiwi[CL] chilirec|raimat SeeWaR erdussel TROPP- exay franky540 ActionBarbie mHz\ZTK`sleep RRP^Jaffa cookiemonstAH WarL|thiDe Oskar^ qK-iMaz Nacka VILLIG-Booyah Beltdjur SoX-cOUPE kund|playz BCS|Winter
:port80c.se.quakenet.org 353 matricks_ = #pcw :Pajsarn svamp tfs\a TruqN babben hr-gil mapD|endoZz gnomie bostrom kA-WANGA kNNas Abxtract|pilshe vogga koolaid-krille DeVixx jwn rdl-- Kee FjuNe koolaid-iskn Pr0`Z10d3y snowsky vibes Nikjou vtine|zlivero OmGaAA mAJ|Britt hekla [0]apa kEy [F]Kaela bananskalFTW|da jeb` vampyren H0JT4R0LJ4 SheVa^ mAxXI Lectro FtN bajajajajajajja mZ`WIGGE dAMI^ moll3 GitfaN boisan [cs]-sNT Ex`Novag[jb] PPB|everest[wa] xiver- KulaN N43-xhady pluffenFOSHO wilho
:port80c.se.quakenet.org 353 matricks_ = #pcw :Nilsson^Arvika nRe`SmitH Ice`Lie[jb] sukki elgenkek drt0FF TaZ- Caesarion Limonaatipoika robf[S] DNAtive broder lolipop jollsy Genander Ballo_Ong Musikant|musicu ToY|Machine nerf|dupl0x gopy` fn\EXESSION FreZZ joharn _Folz [D]KvasteN daeeawewasdfadf CamelRyttArn Xabian HinzeL qRoN _dARUUF CUC|MiniMe^Away hewnk ASTRA|ove xideR Krigarn^ nIw|PlixxaN nMe|| Plumpen S0DA|BorrE teddis daboomb Bongo` Unknownperson TTA`BAdh SefuTzu`AWAY QRLGRIM neraz
:port80c.se.quakenet.org 353 matricks_ = #pcw :Xipho|Fudge Guggztah etojk Lindgrene [V]ZAIKON BmF^Off Wf`jeager\aw Havsmanet-ehn krisa hojhoj alfonz RoBBY faB|mHk Cheeser Admin1337 DoFFrR Caution- mZ`NoKaas HR|bramhultz`` mxyzptlk luder^myfish i`pikoL ZhenjkEe^^-777 Mansvalp sajje1996 v4de Redical`quexOFF n^sdadasJo eXITD`aw teknikvm-jaoel FLIPP-Shapen ALEJKO cliz^ acequeen Ferato Shudde sinsKal`ply frittlol Deadlier Farbrorspurk FizaH` \Azash sWingY fb\ekN xtreck addeadam KneKk azkiN rinxzor
:port80c.se.quakenet.org 353 matricks_ = #pcw :ArneH asdn brunte GeN|HollywoodHu bL\ZuND UNNEBERZ Synthetic|Xorci portoni saxparty|imso Inti |RnE oFFily Sp|DiamaNt Rhombus Nebrek kelamies Thingg BFB|incedeNt TAZzen whinan J0nte p12|wiggie okaJ mZ`Raztad FABF R3|sNELL blaupunkt2 Norrland-WaHoO maccan Ben---- aimD aLTOR EVIG|Falken nilsso bamstAr aGona`scalper reign[m4]n inzejN|ZoneX imag1ne a^meda|EYIE conejito puhaaa clime dsp123 mario_o bRRRA litextra|wezy TG|SaTaN Mando Weiche- wezzan
:port80c.se.quakenet.org 353 matricks_ = #pcw :Labe mp`serve soulK [V]Gudiikzt4r XampeD fs\dcube TrolleRovarN Emptyy SG-daskep0t Byssan Bernts1 SG|YAhoo KOKKA rL`SnowZen^ hIGHTECH__ aPPeLk4k4n otto^_ backs`wouL DeaGJIa mONGOLOJD|kree xekafutuwu uris vagrant ^a^cklet neaK-spiN nozter Arve S0oker GotticH pr0n^ traff`mElissA BC|Kebab2000 CipRi andor-- barbara- traff`lizze harserver3on3 RalleTruss EAES EKEMAN Cowafuckingdogk superlime LokY Hockey-Syvve Gigi qk-WyverN Larsito spendex eiviN und`feelme
:port80c.se.quakenet.org 353 matricks_ = #pcw :aderblasu yHYSS Cmore WaskE lodiz NachiMux Bodde kiiM Claddy TTAgital soker2on2plz mixzxz TmY- KrabbateN HAKKAKDGK VarsKo^aW Fuzak GZ`Kirra^^ mhaji Full|Hytra saxy0z0z0z Akapulka|urban CaZzpeR DarkLink FALLE- AmoZ mADSEN inetpro asd1 [100fps]elgit0 loltih GOLIATH`JONKAN sn1tch_4qs ischi87 Wazee LLLgHOST Derotti flw mandis daskdkad BlixteN_OFF Mjada-Hickdead Eazy-game|pAjk DulleN Sp3karn aimstar^mWd voffsi asdas Keo-muAz Liviu^^ vLaNskyldig
:port80c.se.quakenet.org 353 matricks_ = #pcw :sdfgdfg [4]bappo polackn [42]xeelol basseeee LuppaN eSport|RoxoR Heat2 Helgon`KEXITAN vaxxus|kY kaarel_ i-Link`Slobbo DazOFF Lectra`VolveR [51N19E]Mdr NFTS_aptand pd\cilleh wirram Ag- kn1^ROSA Nixt0n @Josi berrtill mikl ut|brbr LoLiz3N Ishootudie HaGa1 Tetrispro|Veloc Stilig firin Local`Bhz goodR N-Bot GangstA^Niise CLOCKK MaGeN churru` tB-SidW playm8|DjwaNdz PenisPasta sbd-phuntanN Sh4cky vED kimpann mylvis ville_12345678 MeLL^-Q sio\chaez
:port80c.se.quakenet.org 353 matricks_ = #pcw :PLAYER|ZOMG KappeZ^ pennpenn FatzoooO Snark^ Laakko FreddaN zure fiSKen vaccA[cx] Beart FD|Phoenix latrviabaatvik saffu tveka`StiKo HubbaBubbaBoyz q5^n3imad RETARDED pLym|Muffe GYG|RagnarssoN rF|neddemIRC HydrOO ollee sliff Eaten_Alive bollih\away fisarn Fanboyz\qcube Oish Da5|Poppo brottare mHz\xAantic [blueprint|Sn] SneZ WarQ|TriZ^ webcore|R3D95 rubeiiin`1st elius j0mppe- Zwoltex hebbe lallala vAH_ cp^traxzzlol Kung-Fonz Sprattelvatten inzejn[M]
:port80c.se.quakenet.org 353 matricks_ = #pcw :IR|psN backs`Fester Linus CreEckDeztrox _hillztaah IrLo bissen jonjonjon giant^da princip-xtinct smaakskcake [P]use ZerOSh00TS WarQ|Mathilda [P]nikkz sEasiun N43-PuNKy PuttEE Sp|SaLo^| zErios Klerburgare Silikon|Laxen e`zejN hejkanin Zien volvers promizer yewlar HeJ_hEj`aw jeakk rilleh x1ofdewm Swift^ Infinit3 RattiSorsa Ludvika|keken `m1r0n robbagg PillaD-Goss3N Apa`MAx |1g|LegoBilen Ainish [EN]Xanti aviad- puFFFin hejbabuirabakal Hodja WildHead
:port80c.se.quakenet.org 353 matricks_ = #pcw :Lo2P VadeHs|FortFarN Bollhuvve ebayer BEckzOFF Gonzo9014 DarkmindTheGrea trwon nena_ skillbill TpN-Rille^OFF Apl- zune[N] matsinyyyy spyyr stkiih MOSSEN Mathiaz dot222222222 MUFFINN DIMMamxxx xtinct BANZAI|Unders siCKO^^ ALEXMAN GM95 PinkDeagle Chlebo WiNk0 NITR0 Mykos Immortal-King Brodda inzejN|TiGeR Jaaanpoo GZ`SneLF |Ahoehoe R4mzi sadasda FoSho zOOM^ HEHEO2 princip-HermiN^ SUPERFASTTEC yohanseN n23|folieN-_- muffins crakkiz tmd-vdF Ello^
:port80c.se.quakenet.org 353 matricks_ = #pcw :WOTS|christian |F|6|F|Volle Sp4rv3N Nibbler|LAN BVG|Anonim HENNING Local`sNl ifektO whipee\ vaxxus|gtv cL\\ninjaaraben r4jz_- vaxxus|nIc vaxxus|aVd Beastie^ Meier bjarne-_-12 Kalhygge|aBc inspet nuLLifY zlF BLAN|sUPERJAK biggy flon-sebbe fjurtis-otrolig Kalhygge|naXo Playgr0und Bamsar^Bwhl Kalhygge|meXA Kindow sylta pZi paraL^Deja BlasTmaN-tB deeh` [5b]CW|maxii AceDude_- LG^Panik GoA-Het^y|OFF sTr1nG^AFK zxn^off denbette^BNC ZoniX^Off LG^bruzken
:port80c.se.quakenet.org 353 matricks_ = #pcw :Zip^BNC ANONZOFF c`FoOjegerOff Ordspil^afk zanoJ-off bakhoj^off VeLuX^BNC p-zkarp Error404 Nivius^^ DP^OFF|SILENTY VICKY SkytteNOFF nAz JC|RedeTeZ^BNC hooligan`away Splutt|BNC svennjeavlnOFF aNTWAn CB|knubbiz-`AWA bliztr NB|freq[N] kOllEH deML|StoLeN\OFF DOED|EnRIz erN^BNC^AW jompa Cha0tix^OFF Pinstrup-off wolves-munkaway skoogan airhead^OFF Jeffie D5|Lindahl^OFF onaqui skinK aNders|BNC KadaveR^ valtsu_ sledz[aw] Cryptztahh`off FleexOFF stycket
:port80c.se.quakenet.org 353 matricks_ = #pcw :xGx_kmn^off WC anto_o GAndroo^aw schmaCk|icko lyngordon wUULF tX|Dzenan dERG0 chansurf HW|eriksson SG|Hornet xTz`ReXor^off_ syn4psE catsie skize Hezxy tomater HildaOFF nEXIN-tirre [NeutroN] ^sne WoA|dfish xTz`xNitroX^off exero koiz drastic`aVoid Checky_OFF Graxor LinusOFF_ nesc|Meibi` crezz eLiaZ unrea CharlieE eco`nejked tompA^ exp3rt Moejoe FloraCs|Aora Kalhygge|z1 iksO fake[n]ick FloraCsAora inzejN|Jonse ZoRoXo FD|tVEKA XMG\Gngs brrave^Borta
:port80c.se.quakenet.org 353 matricks_ = #pcw :aLpi-AtroOFF mustafakrister PEWPEW MiRRE`OFFLiNE Mixxarna-WejK^ gP|Deex cAD-BNC1 tomh BnCinzejn henka snacjsar EnE|vilsN TixoNBnc shifty|ossi WSOP|fredada MortenSoccer kiimpan [E]Polle^ doke muuuie Androoz SIXO wtai|tryckveard [sc]-falle Tele\weRRe`OFF Martin_- annette-away iGwtRealT3cH gUsk smekarn Onttu xVera`kreeeeee Somppiaeae LasseMan [SS]BoZo inzejn[A] HR|WINESY ^^juh0^^ BYS`vojnik nejmzah Sh1ft-_- Thunder-str R22du sankan DDark MtM PlayN-ziNk^Aw
:port80c.se.quakenet.org 353 matricks_ = #pcw :pd|firren GROSSER LIMEDNULKE HellkaN Mattan tzeron`g0ne Mr-Zorky HoD-Espen BAdhBNC ahlt ramoneur roxon_ dOFF`bth WcG|memphis Jules_ Hye Toot Justicia hajpad-Ante Fia`T8im e5g-Re\FILM hjort iNet\fjollabero Jeespoks SH|Thonk ztar`oFF Widow[away] mj\away CheatoN^BNC LAPPHOREoff dO`esn paal`aw Prayon emFFF zeLo FluBBa dalleBNC aTer waah|off kdo^ C_OFFE Dynis|AWAY miniwolbc BpN^away ReF^Zzz kyAx-OFF therazorsedge vT-viggolito CaLm[mC] Fredde^ acuBNC
:port80c.se.quakenet.org 353 matricks_ = #pcw :Xipho|HollyWood _ArvedssoN^BNC Rayan Mastodonten kempa Blizo`bnc SnIpa Suspected`Bnc1 Neftus dO`RadeoN Madicken daniel123 D-Line|m00jsi osbnc2 AWskian quality`BNC2 inzite`chad CHiLLiPiLl^bnc swaftan QlintoN iTouch|LundiN vandalizm Qslig[FM] makke Tele\wHomp^bnc steamacc4sale Playbackvxo asiQ^BNC Cash-Flow deniiX ITFYTD olssonn nehyd [421]Bihaz- CrilleeOFF elicious`wE111A sndOFF`Ass_slac kusn Myscobnc shade`nu [1Ramlosa] j1m1bnc TPI-piggerN
:port80c.se.quakenet.org 353 matricks_ = #pcw :gedis`AFK mX|Ximer3`BNC Rofel Std samhOFF tG`JeBuu roxz peace`zwa _jacce dRELL tetta bubbenBNC`[GA] __viktor ture frell newbcake k00HOOHO-- makkan Bihaz_- joacim _simon sajje1995 emf|zupppiyoyoy elixyr forfam|bOFF elitasson _sockan Gulle der-Andy RexorN NER|M0wz`aw n0pL_OFF AdamBNC kRIIL falCoOFF ajz antein splexan DNX Team-Unic_bnc2 Team-Unic_bnc1 Team-dH^Jacki3 |F|6|F|Penelo SCUMMY-OFF goL|GustiS^away koppar MartinsBNC xANIZ\bnc chilLboY
:port80c.se.quakenet.org 353 matricks_ = #pcw :Erik2son powerbnc2 Nizer Qeamer tobiasmatss swsBNC `Tobb Pyret Gv\MortiOFF aTschi xamber123 _borre boeka`kankeOFF reaction-bnc1 wiggan Zenhto TUX|ximmy hariiss HS|JagaleX^Offl ohm-bnc4 Iam hawkztr wibbaan Stamina\Proteus rME st4rl\heawen cursed-^^ _LarssoN_ Empis KnaspeR freez Deja-OFF QseBNC ninjaFREDDE ReTrez^Bnc^Away Divid0 mosklubba XnoW MozzyOFF mZ`Freddy Kladden^bnc alkh`aw Prood nIIICKOOOOO CR^SquierBNC H9jE^ b`hoffenOFF grikko sevonOFF
:port80c.se.quakenet.org 353 matricks_ = #pcw :Vexey avdunkad Rizley razzz BJARTMAR PlayHardGoFat Bubstah Gaffel [imbaOFF]sajkez mooaern emric Znap Hyso[csP] Kvasten^-off @Fabi Ind`laaKen amsrOFF Stamina\Achtung aceit\MorianA- c^KNDOO DAJMEN`AW runpuff Drunke fisken10 Let_It_Whip Poxi boeka`zeppOFF bodil avlid^bnc markisen`bnc qurry oBiee PZ|FiC-Aw Jonirl_gone luttman _micro Cr33d^Away Anderss^OFF rasmus11 axl0n17 pAjk Vibban\OFF zAt-off `tyrantBNC HB`off|djnatnat mP`off|Redfir3 TS|kolben_afk
:port80c.se.quakenet.org 353 matricks_ = #pcw :Manual\AFK mP`off|Redbot RetardacE ewh`FL1NK\away TaeferN`aw Divan^KaLa^BNC Divan^myRan^BNC DUMBASS`BNC sudden21 Cyber`Mnisaway [BFF]-REeLexX AEEEEEEEEEEEEEE ZMLB-Odis deaf-cs|Lille Ninjan` bojer^off freaKKKy_BNC Replay` GuFFe D3nim smn-_- jerry[bnc] D`timex a5\eqiNawaY inviz maRkN_ Brodda^SKOLAN zG|CBB^Off TisPik_off AFK^[TC]pvp chiva0FF hughi-off amokz^BNC SteelpliX^BNC Bioonic nIELSENoFF OFF|fZoe OliverL2`AWAY babb Chuck_N SNOEN^OFF [CYBER]niijaz
:port80c.se.quakenet.org 353 matricks_ = #pcw :LilleGris^BnC zG|Flod__ \lEGO`OFF LinusOFF SaX`Gubbi`OFF kolmio m|Smith Mitt3 iluen haMp gDesigns Reb_6ff blank|tox^off Unf[BNC]JLS SYNTEK|bArk FJERLEND PerSpelmann toXq` ieS|make`away pwang12 wajk\aw InV^Raccoon-OFF ComsyS ElakSomFan^^ @m3z @pimpo @MYM|Muesli`off ADAMeh^zzzz DLM^b1ue^Off Hootarn croz kylan_off ing\\tsabNC Offson n1mez`off spanier^off dieNasty`brb [D]Bamb DKB|Night[oFF] Basket-off xS|HeliuM Hardcorehilda attixoff thorr_ minib
:port80c.se.quakenet.org 353 matricks_ = #pcw :rwn ironic|Haunted khalannz PCW-Poker spitz Hiippari- iMrClean C5|Jakobervaek Casa`berssaBNC gamer`away myNKOFF Tjalfeen^off_ ^cooling noisi-a-way JennaDD mySKi-[a]ngeh mav0FF sanoj\ dicti KLADDIS`AWAY OFF|ShAmOnE dollface WoC^RuFi selo|elloAFK LnC-Kezse kn1^Mole__ haVec- BorgareN^ steddan Verga PawP SAAAID onemind`xent dyfu`viciouz Ice`OFF_ kEbAbMaNnEn gamax|luN_ guragoa`off xorTon Kirka bruikki SkarvaNOFF empton nessaia|noHn-OF iNet\xerp
:port80c.se.quakenet.org 353 matricks_ = #pcw :]5[kbz tjaeder sulaN^OFFLAJN Relayish mr-o oxido drulen CR1M3Z^off_ ziNx` Local`MickeMann deaf-cs|Brajen cL\\ninjaBNC tomh^soet eriik^ Carn4tioN`away Rapt0r KAAAALLLEE`BNC raY^^ aNnaa` ^apan LpY|p0sh[kol] dempAWAY zuxen\OFF aztro ToggeN [A1]No_52 [A1]etuxia Jusa Playm|DjToppi- Bodoom BCS^OFF|mkiss skau ThumbSucker^BNC tOFF-FuSe fnpOFF|aes ^SlappFisa^ Bhz`OFF Unf[BNC]Lion b00z\away Raised|ProBlem [A]fittb extinct`zake blike|AplE`oFF eNtiC MeLLKeR
:port80c.se.quakenet.org 353 matricks_ = #pcw :SNELHEST Nexo rkO`aw zG|Numse_ Maff n9way|mIkLo bEnz SpiderA _cgx GZ`cAD RICK1DAH fun|Skippsen INFAME|eRIKa\aw SS|xtinqt _mys|da HolySmoke Rq hoorai\naolein qutip mYth|schnaLz_M rengo`off aRa|Voilala^Off skilleAWAY BCS^OFF|dexer @FSHost-com aeom`away tvekaOFF`haMME Smog^ PartyPoker Sp|SpeTLighT^OF [Fixx]Olle sIMMe`offline panik_herman avu\partz0r rekyL^_- BCS^OFF|AMPARI Fluen^BNC Wkd^off eXm-SunnY^ ^hej Kniks DiXeR`off rfwdm_ TPI_piggerN_ Mataza|off
:port80c.se.quakenet.org 353 matricks_ = #pcw :epzBNC Ampro @hardstep goL|craJpAW WwG-Muste E|Evil^off MADREFLEX`rhZ adde` Crazy^SpexXI Jerker alq-andreA H1Xer aGILITY`POLYMOX Joker^BNC Mohkis [LEGE]HeJLeN^ Caprice Intgen`BAERB{J} VILLIG-7thAWAY Neehajd`BNC Batti LewfeN^Off Ravnn sky\bangz0ff`` SkenaN^bnc GladPanda fausti pittins^BNC SaX|f|Gubbi^ rM|pIx^^ Rms- RANGERBOY`aw FixxeR^ Edvnz uga BoSS|Benal`BNC sjonasm8k PND\s humpyskump SKOVDE|Snasi @HighTech @spam-scan @S @Q @[-hoorai-] STEN11
:port80c.se.quakenet.org 353 matricks_ = #pcw :Voteski xP|Puhbaer^off Yoshi_ CWE`Flippen CeveRR [ShaKa]CoOoL`AW h3h3 LnC-iNZANEoff_ Wu-djaoff Zerooo Pieper_ chica`SanziLOFF BB4FRAGS|XTM`A limespOFF`malle oPS|JBbnc staphe G`Quix NItron\bnc c55-feros hejx HighG`wdE_OFF eco`zN Myt willybob`bnc Rh-G^TippeR^ JUHP-BNC|Jumert mthz Moldskred MxG\\MailBoX MeejtAWAY [c]eKipz dkz`xfx zaped`off ptrNo_OFF Jeamu c`Crelle-R^off rew`away Ak-87^ TOOOMMY\off L2D_-_Rappi Ghost^BNC _AraCi SKytteN^ ^StoKer^
:port80c.se.quakenet.org 353 matricks_ = #pcw :zNei mYth|LucK3r n-N|TarriC poohi hamasbnc Coutz1 Char|ieBoY AZ^LEVING-BNC plike^HuliaN___ uR`saniOFF Gtrip|Hebo`OFF Redical`Score IceBlu EvilEye_bnc maaxi`off [AWAY]Darkling Noobet|StajOFF bjarne-_- zG|Eriksen^Off venom^off mHuen utini_off eveni\OFF Xqe MefistoFX`oFF bas-off|f4me TRiCK`iDfye MAAUNS CamiK^ GrQnaerten blike|amns`oFF sandersan Lt`HipPus Mossepo siOFF \zimze`BNC R33t Gs\BaZe^OFF zaney drateR^OFF Free1337 off|Hunter ifrit apfelmus
:port80c.se.quakenet.org 353 matricks_ = #pcw :eu-off|Blade jfl-oFF`miD Uniline charlie` painkiller`kool OFF|ShOcK telk0^BNC gh|jack^off EX-adrin^bnc w\Hairboi osfa|puddy^off CruisE-OFF- [A1]EnGud kungeeN^^ CMAX|[m]addilo Sk-off|MichYs9N NTL-Sentinal Tjalfuglen^off KapteWN`BNC cichlide^AWAY ChomP`away paltieBNC^[cz] WGV|PwnZ^Off pidde-_- TELETUBBIE Ecka fazer|NoxtrnOFF Lolad-net^ diRectAWAY evil|parasite xultRoNaw genics^BNC steri`off RaliAWAY oxid`zsiltsoff xazury`bnc IRLHELTEN r0ntti
:port80c.se.quakenet.org 353 matricks_ = #pcw :searon_ Saturn` Nimra jOHNSONN KegleN^AFK JC|PlaNke d4NNY`0fflajn MuGGe^Bnc _4P|StyLish^bnc s8`swinnnk Jackkis F`off`NickyH F5_rakkeeee Thuriaz inzym Moriz edom z1ax^0FFL1NE eXm-nex0r|bNc unstuck|L- aimstyle`vzn\a Gaylorden WrD ShadowOfAMaN gh|8Ball^off Retard-- SAGG-Lipton backyard\KoWORK awaylen BCS^OFF|Pipe TPI`Ferro fredde` xeet_ BlaZe180 Macan_ biblas^BNC Cyeclone Vali[away] BK|awayman armoryh oKend _cB-Us3-Bnc_ Kefir [nerd]Kurr3

View file

@ -1,102 +0,0 @@
import struct, zlib, sys
class image:
w = 0
h = 0
data = []
def read_tga(f):
image = f.read()
img_type = struct.unpack("<B", image[2:3])[0]
img_bpp = struct.unpack("<B", image[16:17])[0]
img_width = struct.unpack("<H", image[12:14])[0]
img_height = struct.unpack("<H", image[14:16])[0]
if img_type != 2 or img_bpp != 32:
print "image must be a RGBA"
start = 18+struct.unpack("B", image[0])[0]
end = start + img_width*img_height*4
image_data = image[start:end] # fetch raw data
return image_data
def write_tga(f, w, h, bpp, data):
f.write(struct.pack("<BBBHHBHHHHBB", 0, 0, 2, 0, 0, 0, 0, 0, w, h, bpp, 0) + data)
def load_png(f):
def read(fmt): return struct.unpack("!"+fmt, f.read(struct.calcsize("!"+fmt)))
def skip(count): f.read(count)
# read signature
if read("cccccccc") != ('\x89', 'P', 'N', 'G', '\r', '\n', '\x1a', '\n'):
return 0
# read chunks
width = -1
height = -1
imagedata = ""
while 1:
size, id = read("I4s")
if id == "IHDR": # read header
width, height, bpp, colortype, compression, filter, interlace = read("IIBBBBB")
if bpp != 8 or compression != 0 or filter != 0 or interlace != 0 or (colortype != 2 and colortype != 6):
print "can't handle png of this type"
print width, height, bpp, colortype, compression, filter, interlace
return 0
skip(4)
elif id == "IDAT":
imagedata += f.read(size)
skip(4) # read data
elif id == "IEND":
break # we are done! \o/
else:
skip(size+4) # skip unknown chunks
# decompress image data
rawdata = map(ord, zlib.decompress(imagedata))
# apply per scanline filters
pitch = width*4+1
bpp = 4
imgdata = []
prevline = [0 for x in xrange(0, (width+1)*bpp)]
for y in xrange(0,height):
filter = rawdata[pitch*y]
pixeldata = rawdata[pitch*y+1:pitch*y+pitch]
thisline = [0 for x in xrange(0,bpp)]
def paeth(a, b, c):
p = a + b - c
pa = abs(p - a)
pb = abs(p - b)
pc = abs(p - c)
if pa <= pb and pa <= pc:
return a
if pb <= pc:
return b
return c
if filter == 0: f = lambda a,b,c: 0
elif filter == 1: f = lambda a,b,c: a
elif filter == 2: f = lambda a,b,c: b
elif filter == 3: f = lambda a,b,c: (a+b)/2
elif filter == 4: f = paeth
for x in xrange(0, width*bpp):
thisline += [(pixeldata[x] + f(thisline[x], prevline[x+bpp], prevline[x])) % 256]
prevline = thisline
imgdata += thisline[4:]
raw = ""
for x in imgdata:
raw += struct.pack("B", x)
#print len(raw), width*height*4
write_tga(file("test2.tga", "w"), width, height, 32, raw)
return 0
load_png(file("butterfly2.png", "rb"))

View file

@ -1,12 +0,0 @@
import sys
user_map = {"kma":"matricks", "teetow":"matricks", "jlha":"matricks", "jdv":"void", "jaf":"serp"}
users = {}
for line in sys.stdin:
fields = line.split()
name = user_map.get(fields[1], fields[1])
users[name] = users.get(name, 0) + 1
total = reduce(lambda x,y: x+y, users.values())
for u in users:
print "%6s %6d %s" % ("%03.2f"%(users[u]*100.0/total), users[u], u)
print "%03.2f %6d %s" % (100, total, "Total")