Permalink
Browse files

more stuff :)

  • Loading branch information...
1 parent a7cb368 commit ac18c6a3bd9b1e497cd97c52fd77f256961b48e6 @matricks matricks committed Apr 27, 2008
Showing with 874 additions and 0 deletions.
  1. +213 −0 datasrc/compile.py
  2. +350 −0 datasrc/content.py
  3. +86 −0 datasrc/datatypes.py
  4. +212 −0 datasrc/network.py
  5. +1 −0 scripts/count_source.sh
  6. +12 −0 scripts/process_blame.py
View
213 datasrc/compile.py
@@ -0,0 +1,213 @@
+import os, imp, sys
+import datatypes
+import content
+import network
+
+
+def create_enum_table(names, num):
+ lines = []
+ lines += ["enum", "{"]
+ lines += ["\t%s=0,"%names[0]]
+ for name in names[1:]:
+ lines += ["\t%s,"%name]
+ lines += ["\t%s" % num, "};"]
+ return lines
+
+gen_content_header = False
+gen_content_source = True
+
+
+# collect sprites
+sprites = []
+for set in content.Sprites:
+ sprites += set.sprites
+
+
+if gen_content_header:
+
+ print """
+struct SOUND
+{
+ int id;
+ const char *filename;
+};
+
+struct SOUNDSET
+{
+ int num_sounds;
+ SOUND *sound;
+};
+
+struct IMAGE
+{
+ int id;
+ const char *filename;
+};
+
+struct SPRITESET
+{
+ IMAGE *image;
+ int gridx;
+ int gridy;
+};
+
+struct SPRITE
+{
+ SPRITESET *set;
+ int x, y, w, h;
+};
+
+"""
+
+ def generate_struct(this, name, parent_name):
+ print "struct %s" % name
+
+ print "{"
+ if parent_name:
+ print "\t%s base;" % parent_name
+ for var in this.fields[this.baselen:]:
+ for l in var.emit_declaration(): print "\t"+l
+ print "};"
+
+ generate_struct(content.WeaponBase, "WEAPONSPEC", None)
+ for weapon in content.Weapons:
+ generate_struct(weapon, "WEAPONSPEC_%s"%weapon.name.upper(), "WEAPONSPEC")
+
+ # generate enums
+ for l in create_enum_table(["SOUND_"+o.name.upper() for o in content.Sounds], "NUM_SOUNDS"): print l
+ for l in create_enum_table(["IMAGE_"+o.name.upper() for o in content.Images], "NUM_IMAGES"): print l
+ for l in create_enum_table(["SPRITE_"+o.name.upper() for o in sprites], "NUM_SPRITES"): print l
+
+ for l in create_enum_table(["WEAPONTYPE_"+o.name.upper() for o in content.Weapons], "NUM_WEAPONTYPES"): print l
+
+if gen_content_source:
+ # generate data
+ for s in content.Sounds:
+ print "static SOUND sounds_%s[%d] = {" % (s.name, len(s.files))
+ for filename in s.files:
+ print '\t{%d, "%s"},' % (-1, filename)
+ print "};"
+
+ print "static SOUNDSET soundsets[%d] = {" % len(content.Sounds)
+ for s in content.Sounds:
+ print "\t{%d, sounds_%s}," % (len(s.files), s.name)
+ #for filename in s.files:
+ # print "\t{%d, '%s'}," % (-1, filename)
+ print "};"
+
+ print "static IMAGE images[%d] = {" % len(content.Images)
+ for i in content.Images:
+ print '\t{%d, "%s"},' % (-1, i.filename)
+ print "};"
+
+ print "static SPRITESET spritesets[%d] = {" % len(content.Sprites)
+ for set in content.Sprites:
+ if set.image:
+ print '\t{&images[IMAGE_%s], %d, %d},' % (set.image.upper(), set.grid[0], set.grid[1])
+ else:
+ print '\t{0, %d, %d},' % (set.grid[0], set.grid[1])
+ print "};"
+
+ print "static SPRITE sprites[%d] = {" % len(sprites)
+ spritesetid = 0
+ for set in content.Sprites:
+ for sprite in set.sprites:
+ print '\t{&spritesets[%d], %d, %d, %d, %d},' % (spritesetid, sprite.pos[0], sprite.pos[1], sprite.pos[2], sprite.pos[3])
+ spritesetid += 1
+ print "};"
+
+ for weapon in content.Weapons:
+ print "static WEAPONSPEC_%s weapon_%s = {" % (weapon.name.upper(), weapon.name)
+ for var in weapon.fields:
+ for l in var.emit_definition(): print "\t"+l,
+ print ","
+ print "};"
+
+ print "struct WEAPONS"
+ print "{"
+ print "\tWEAPONSPEC *id[%d];" % len(content.Weapons)
+ for w in content.Weapons:
+ print "\tWEAPONSPEC_%s &weapon_%s;" % (w.name.upper(), w.name)
+ print ""
+ print "};"
+
+ print "static WEAPONS weapons = {{%s}," % (",".join(["&weapon_%s.base"%w.name for w in content.Weapons]))
+ for w in content.Weapons:
+ print "\tweapon_%s," % w.name
+ print "};"
+
+
+
+ print """
+struct DATACONTAINER
+{
+ int num_sounds;
+ SOUNDSET *sounds;
+
+ int num_images;
+ IMAGE *images;
+
+ int num_sprites;
+ SPRITE *sprites;
+
+ WEAPONS &weapons;
+};"""
+
+ print "DATACONTAINER data = {"
+ print "\t%d, soundsets," % len(content.Sounds)
+ print "\t%d, images," % len(content.Images)
+ print "\t%d, sprites," % len(content.Sprites)
+ print "\tweapons,"
+ print "};"
+
+
+# NETWORK
+if 0:
+
+
+ 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): print l
+ print ""
+
+ for l in create_enum_table([o.enum_name for o in network.Objects], "NUM_NETOBJTYPES"): print l
+ print ""
+ for l in create_enum_table([o.enum_name for o in network.Messages], "NUM_NETMSGTYPES"): print l
+ print ""
+
+ for item in network.Objects + network.Messages:
+ for line in item.emit_declaration():
+ print line
+ print ""
+
+
+if 0:
+ # create names
+ lines = []
+ lines += ["static const char *netobj_names[] = {"]
+ lines += ['\t"%s",' % o.name for o in network.Objects]
+ lines += ['\t""', "};", ""]
+
+ for l in lines:
+ print l
+
+ for item in network.Objects:
+ for line in item.emit_validate():
+ print line
+ print ""
+
+ # create validate tables
+ lines = []
+ lines += ["typedef int(*VALIDATEFUNC)(void *data, int size);"]
+ lines += ["static VALIDATEFUNC validate_funcs[] = {"]
+ lines += ['\tvalidate_%s,' % o.name for o in network.Objects]
+ lines += ["\t0x0", "};", ""]
+
+ lines += ["int netobj_validate(int type, void *data, int size)"]
+ lines += ["{"]
+ lines += ["\tif(type < 0 || type >= NUM_NETOBJTYPES) return -1;"]
+ lines += ["\treturn validate_funcs[type](data, size);"]
+ lines += ["};", ""]
+
+ for l in lines:
+ print l
+
View
350 datasrc/content.py
@@ -0,0 +1,350 @@
+import copy
+
+class SoundSet:
+ def __init__(self, name, files):
+ self.name = name
+ self.files = files
+
+class Image:
+ def __init__(self, name, filename):
+ self.name = name
+ self.filename = filename
+
+class Pickup:
+ def __init__(self, name, respawntime=15, spawndelay=0):
+ self.name = name
+ self.respawntime = respawntime
+ self.spawndelay = spawndelay
+
+class Variable:
+ def __init__(self, name, value):
+ self.name = name
+ self.value = value
+
+class Int(Variable):
+ def emit_declaration(self):
+ return ["int %s;"%self.name]
+ def emit_definition(self):
+ return ["%d"%self.value]
+
+class Float(Variable):
+ def emit_declaration(self):
+ return ["float %s;"%self.name]
+ def emit_definition(self):
+ return ["%ff"%self.value]
+
+class String(Variable):
+ def emit_declaration(self):
+ return ["const char *%s;"%self.name]
+ def emit_definition(self):
+ return ['"%s"'%self.value]
+
+class SpriteRef(Variable):
+ def emit_declaration(self):
+ return ["SPRITE *%s;"%self.name]
+ def emit_definition(self):
+ return ['&sprites[SPRITE_%s]'%self.value.upper()]
+
+class SpriteSet:
+ def __init__(self, image, grid, sprites):
+ self.image = image
+ self.grid = grid
+ self.sprites = sprites
+
+class Sprite:
+ def __init__(self, name, pos):
+ self.name = name
+ self.pos = pos
+
+# TODO: rename this
+class FieldStorage:
+ def __init__(self, name, base, fields):
+ self.name = name
+ self.fields = []
+ if base:
+ self.fields = copy.deepcopy(base.fields)
+ self.base = base
+ self.baselen = len(self.fields)
+
+ self.autoupdate()
+
+ self.update_all(fields)
+
+ def update_all(self, fields):
+ for v in fields:
+ if not self.update(v):
+ self.fields += [v]
+
+ def update(self, value):
+ for i in xrange(0, len(self.fields)):
+ if self.fields[i].name == value.name:
+ self.fields[i] = value
+ return True
+ return False
+
+ def autoupdate(self):
+ pass
+
+def FileList(format, num):
+ return [format%x for x in xrange(1,num)]
+
+
+Sounds = [
+ SoundSet("gun_fire", FileList("data/audio/wp_gun_fire-%02d.wv", 3)),
+ SoundSet("shotgun_fire", FileList("data/audio/wp_shotty_fire-%02d.wv", 3)),
+ SoundSet("grenade_fire", FileList("data/audio/wp_flump_launch-%02d.wv", 3)),
+ SoundSet("hammer_fire", FileList("data/audio/wp_hammer_swing-%02d.wv", 3)),
+ SoundSet("hammer_hit", FileList("data/audio/wp_hammer_hit-%02d.wv", 3)),
+ SoundSet("ninja_fire", FileList("data/audio/wp_ninja_attack-%02d.wv", 3)),
+ SoundSet("grenade_explode", FileList("data/audio/wp_flump_explo-%02d.wv", 3)),
+ SoundSet("ninja_hit", FileList("data/audio/wp_ninja_hit-%02d.wv", 3)),
+ SoundSet("rifle_fire", FileList("data/audio/wp_rifle_fire-%02d.wv", 3)),
+ SoundSet("rifle_bounce", FileList("data/audio/wp_rifle_bnce-%02d.wv", 3)),
+ SoundSet("weapon_switch", FileList("data/audio/wp_switch-%02d.wv", 3)),
+
+ SoundSet("player_pain_short", FileList("data/audio/vo_teefault_pain_short-%02d.wv", 12)),
+ SoundSet("player_pain_long", FileList("data/audio/vo_teefault_pain_long-%02d.wv", 2)),
+
+ SoundSet("body_land", FileList("data/audio/foley_land-%02d.wv", 4)),
+ SoundSet("player_airjump", FileList("data/audio/foley_dbljump-%02d.wv", 3)),
+ SoundSet("player_jump", FileList("data/audio/foley_foot_left-%02d.wv", 4) + FileList("data/audio/foley_foot_right-%02d.wv", 4)),
+ SoundSet("player_die", FileList("data/audio/foley_body_splat-%02d.wv", 3)),
+ SoundSet("player_spawn", FileList("data/audio/vo_teefault_spawn-%02d.wv", 7)),
+ SoundSet("player_skid", FileList("data/audio/sfx_skid-%02d.wv", 4)),
+ SoundSet("tee_cry", FileList("data/audio/vo_teefault_cry-%02d.wv", 2)),
+
+ SoundSet("hook_loop", FileList("data/audio/hook_loop-%02d.wv", 2)),
+
+ SoundSet("hook_attach_ground", FileList("data/audio/hook_attach-%02d.wv", 3)),
+ SoundSet("hook_attach_player", FileList("data/audio/foley_body_impact-%02d.wv", 3)),
+ SoundSet("pickup_health", FileList("data/audio/sfx_pickup_hrt-%02d.wv", 2)),
+ SoundSet("pickup_armor", FileList("data/audio/sfx_pickup_arm-%02d.wv", 4)),
+
+ SoundSet("pickup_grenade", FileList("data/audio/sfx_pickup_arm-%02d.wv", 1)),
+ SoundSet("pickup_shotgun", FileList("data/audio/sfx_pickup_arm-%02d.wv", 1)),
+ SoundSet("pickup_ninja", FileList("data/audio/sfx_pickup_arm-%02d.wv", 1)),
+ SoundSet("weapon_spawn", FileList("data/audio/sfx_spawn_wpn-%02d.wv", 3)),
+ SoundSet("weapon_noammo", FileList("data/audio/wp_noammo-%02d.wv", 5)),
+
+ SoundSet("hit", FileList("data/audio/sfx_hit_weak-%02d.wv", 2)),
+
+ SoundSet("chat_server", ["data/audio/sfx_msg-server.wv"]),
+ SoundSet("chat_client", ["data/audio/sfx_msg-client.wv"]),
+ SoundSet("ctf_drop", ["data/audio/sfx_ctf_drop.wv"]),
+ SoundSet("ctf_return", ["data/audio/sfx_ctf_rtn.wv"]),
+ SoundSet("ctf_grab_pl", ["data/audio/sfx_ctf_grab_pl.wv"]),
+ SoundSet("ctf_grab_en", ["data/audio/sfx_ctf_grab_en.wv"]),
+ SoundSet("ctf_capture", ["data/audio/sfx_ctf_cap_pl.wv"]),
+]
+
+Images = [
+ Image("null", ""),
+ Image("game", "data/game.png"),
+ Image("particles", "data/particles.png"),
+ Image("cursor", "data/gui_cursor.png"),
+ Image("banner", "data/gui_logo.png"),
+ Image("emoticons", "data/emoticons.png"),
+ Image("browseicons", "data/browse_icons.png"),
+ Image("console_bg", "data/console.png"),
+ Image("console_bar", "data/console_bar.png"),
+]
+
+Pickups = [
+ Pickup("health"),
+ Pickup("armor"),
+ Pickup("weapon"),
+ Pickup("ninja", 90, 90),
+]
+
+Sprites = [
+ SpriteSet("particles", (8,8), [
+ Sprite("part_slice", (0,0,1,1)),
+ Sprite("part_ball", (1,0,1,1)),
+ Sprite("part_splat01", (2,0,1,1)),
+ Sprite("part_splat02", (3,0,1,1)),
+ Sprite("part_splat03", (4,0,1,1)),
+
+ Sprite("part_smoke", (0,1,1,1)),
+ Sprite("part_shell", (0,2,2,2)),
+ Sprite("part_expl01", (0,4,4,4)),
+ Sprite("part_airjump", (2,2,2,2)),
+ ]),
+
+ SpriteSet("game", (8,8), [
+ Sprite("health_full", (21,0,2,2)),
+ Sprite("health_empty", (23,0,2,2)),
+ Sprite("armor_full", (21,2,2,2)),
+ Sprite("armor_empty", (23,2,2,2)),
+
+ Sprite("star1", (15,0,2,2)),
+ Sprite("star2", (17,0,2,2)),
+ Sprite("star3", (19,0,2,2)),
+
+ Sprite("part1", (6,0,1,1)),
+ Sprite("part2", (6,1,1,1)),
+ Sprite("part3", (7,0,1,1)),
+ Sprite("part4", (7,1,1,1)),
+ Sprite("part5", (8,0,1,1)),
+ Sprite("part6", (8,1,1,1)),
+ Sprite("part7", (9,0,2,2)),
+ Sprite("part8", (11,0,2,2)),
+ Sprite("part9", (13,0,2,2)),
+
+ Sprite("weapon_gun_body", (2,4,4,2)),
+ Sprite("weapon_gun_cursor", (0,4,2,2)),
+ Sprite("weapon_gun_proj", (6,4,2,2)),
+ Sprite("weapon_gun_muzzle1", (8,4,3,2)),
+ Sprite("weapon_gun_muzzle2", (12,4,3,2)),
+ Sprite("weapon_gun_muzzle3", (16,4,3,2)),
+
+ Sprite("weapon_shotgun_body", (2,6,8,2)),
+ Sprite("weapon_shotgun_cursor", (0,6,2,2)),
+ Sprite("weapon_shotgun_proj", (10,6,2,2)),
+ Sprite("weapon_shotgun_muzzle1", (12,6,3,2)),
+ Sprite("weapon_shotgun_muzzle2", (16,6,3,2)),
+ Sprite("weapon_shotgun_muzzle3", (20,6,3,2)),
+
+ Sprite("weapon_grenade_body", (2,8,7,2)),
+ Sprite("weapon_grenade_cursor", (0,8,2,2)),
+ Sprite("weapon_grenade_proj", (10,8,2,2)),
+
+ Sprite("weapon_hammer_body", (2,1,4,3)),
+ Sprite("weapon_hammer_cursor", (0,0,2,2)),
+ Sprite("weapon_hammer_proj", (0,0,0,0)),
+
+ Sprite("weapon_ninja_body", (2,10,7,2)),
+ Sprite("weapon_ninja_cursor", (0,10,2,2)),
+ Sprite("weapon_ninja_proj", (0,0,0,0)),
+
+ Sprite("weapon_rifle_body", (2,12,7,3)),
+ Sprite("weapon_rifle_cursor", (0,12,2,2)),
+ Sprite("weapon_rifle_proj", (10,12,2,2)),
+
+ Sprite("hook_chain", (2,0,1,1)),
+ Sprite("hook_head", (3,0,2,1)),
+
+ Sprite("hadoken1", (25,0,7,4)),
+ Sprite("hadoken2", (25,4,7,4)),
+ Sprite("hadoken3", (25,8,7,4)),
+
+ Sprite("pickup_health", (10,2,2,2)),
+ Sprite("pickup_armor", (12,2,2,2)),
+ Sprite("pickup_weapon", (3,0,6,2)),
+ Sprite("pickup_ninja", (3,10,7,2)),
+
+ Sprite("flag_blue", (12,8,4,8)),
+ Sprite("flag_red", (16,8,4,8)),
+ ]),
+
+ SpriteSet(None, (8,4), [
+ Sprite("tee_body", (0,0,3,3)),
+ Sprite("tee_body_outline", (3,0,3,3)),
+ Sprite("tee_foot", (6,1,2,1)),
+ Sprite("tee_foot_outline", (6,2,2,1)),
+ Sprite("tee_hand", (6,0,1,1)),
+ Sprite("tee_hand_outline", (7,0,1,1)),
+
+ Sprite("tee_eye_normal", (2,3,1,1)),
+ Sprite("tee_eye_angry", (3,3,1,1)),
+ Sprite("tee_eye_pain", (4,3,1,1)),
+ Sprite("tee_eye_happy", (5,3,1,1)),
+ Sprite("tee_eye_dead", (6,3,1,1)),
+ Sprite("tee_eye_surprise", (7,3,1,1)),
+ ]),
+
+ SpriteSet("browseicons", (4,1), [
+ Sprite("browse_lock", (0,0,1,1)),
+ Sprite("browse_progress1", (1,0,1,1)),
+ Sprite("browse_progress2", (2,0,1,1)),
+ Sprite("browse_progress3", (3,0,1,1)),
+ ]),
+]
+
+class Weapon(FieldStorage):
+ def autoupdate(self):
+ self.update(String("name", self.name))
+ self.update(SpriteRef("sprite_body", "weapon_%s_body"%self.name))
+ self.update(SpriteRef("sprite_cursor", "weapon_%s_cursor"%self.name))
+ self.update(SpriteRef("sprite_proj", "weapon_%s_proj"%self.name))
+
+WeaponBase = Weapon("weapon", None, [
+ String("name", "base"),
+ SpriteRef("sprite_body", None),
+ SpriteRef("sprite_cursor", None),
+ SpriteRef("sprite_proj", None),
+ Int("damage", 1),
+ Int("firedelay", 500),
+ Int("visual_size", 96),
+])
+
+Weapons = [
+ Weapon("hammer", WeaponBase, [
+ Int("firedelay", 100),
+ Int("damage", 3),
+ ]),
+
+ Weapon("gun", WeaponBase, [
+ Int("firedelay", 100),
+ Int("damage", 1),
+
+ Float("curvature", 1.25),
+ Float("speed", 2200.0),
+ Float("lifetime", 2.0),
+ ]),
+
+ Weapon("shotgun", WeaponBase, [
+ Int("firedelay", 500),
+ Int("damage", 1),
+
+ Float("curvature", 1.25),
+ Float("speed", 2200.0),
+ Float("speeddiff", 0.8),
+ Float("lifetime", 0.25),
+ ]),
+
+ Weapon("grenade", WeaponBase, [
+ Int("firedelay", 100),
+ Int("damage", 6),
+
+ Float("curvature", 7.0),
+ Float("speed", 1000.0),
+ Float("lifetime", 2.0),
+ ]),
+
+ Weapon("rifle", WeaponBase, [
+ Int("firedelay", 800),
+ Int("visual_size", 92),
+ Int("damage", 5),
+
+ Float("reach", 800.0),
+ Float("bounce_delay", 150),
+ Float("bounce_num", 1),
+ Float("bounce_cost", 0),
+ ]),
+
+ Weapon("ninja", WeaponBase, [
+ Int("firedelay", 800),
+ Int("damage", 9),
+ ]),
+]
+
+ticks_per_second = 50.0
+Physics = FieldStorage("physics", None, [
+ Float("ground_control_speed", 10.0),
+ Float("ground_control_accel", 100.0 / ticks_per_second),
+ Float("ground_friction", 0.5),
+ Float("ground_jump_impulse", 12.6),
+ Float("air_jump_impulse", 11.5),
+ Float("air_control_speed", 250.0 / ticks_per_second),
+ Float("air_control_accel", 1.5),
+ Float("air_friction", 0.95),
+ Float("hook_length", 380.0),
+ Float("hook_fire_speed", 80.0),
+ Float("hook_drag_accel", 3.0),
+ Float("hook_drag_speed", 15.0),
+ Float("gravity", 0.5),
+
+ Float("velramp_start", 550),
+ Float("velramp_range", 2000),
+ Float("velramp_curvature", 1.4),
+])
View
86 datasrc/datatypes.py
@@ -0,0 +1,86 @@
+
+class Object:
+ pass
+
+class Enum():
+ def __init__(self, name, values):
+ self.name = name
+ self.values = values
+
+class NetObject:
+ def __init__(self, name, variables):
+ l = name.split(":")
+ self.name = l[0].lower()
+ self.base = ""
+ if len(l) > 1:
+ self.base = l[1]
+ self.base_struct_name = "NETOBJ_%s" % self.base.upper()
+ self.struct_name = "NETOBJ_%s" % self.name.upper()
+ self.enum_name = "NETOBJTYPE_%s" % 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), "{"]
+ else:
+ lines = ["struct %s"%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 = ["static int validate_%s(void *data, int size)" % self.name]
+ lines += ["{"]
+ lines += ["\t%s *obj = (%s *)data;"%(self.struct_name, self.struct_name)]
+ lines += ["\tif(sizeof(*obj) != size) return -1;"]
+ for v in self.variables:
+ lines += ["\t"+line for line in v.emit_validate()]
+ lines += ["\treturn 0;"]
+ lines += ["}"]
+ return lines
+
+
+class NetEvent(NetObject):
+ def __init__(self, name, variables):
+ NetObject.__init__(self, name, variables)
+ self.base_struct_name = "NETEVENT_%s" % self.base.upper()
+ self.struct_name = "NETEVENT_%s" % self.name.upper()
+ self.enum_name = "NETEVENTTYPE_%s" % self.name.upper()
+
+class NetMessage(NetObject):
+ def __init__(self, name, variables):
+ NetObject.__init__(self, name, variables)
+ self.base_struct_name = "NETMSG_%s" % self.base.upper()
+ self.struct_name = "NETMSG_%s" % self.name.upper()
+ self.enum_name = "NETMSGTYPE_%s" % self.name.upper()
+
+class NetVariable:
+ def __init__(self, name):
+ self.name = name
+ def emit_declaration(self):
+ return []
+ def emit_validate(self):
+ return []
+
+class NetString(NetVariable):
+ def emit_declaration(self):
+ return ["const char *%s;"%self.name]
+
+class NetIntAny(NetVariable):
+ def emit_declaration(self):
+ return ["int %s;"%self.name]
+
+class NetIntRange(NetIntAny):
+ def __init__(self, name, min, max):
+ NetIntAny.__init__(self,name)
+ self.min = str(min)
+ self.max = str(max)
+ def emit_validate(self):
+ return ["netobj_clamp_int(obj->%s, %s %s)"%(self.name, self.min, self.max)]
+
+class NetBool(NetIntRange):
+ def __init__(self, name):
+ NetIntRange.__init__(self,name,0,1)
+
+class NetTick(NetIntRange):
+ def __init__(self, name):
+ NetIntRange.__init__(self,name,0,'max_int')
View
212 datasrc/network.py
@@ -0,0 +1,212 @@
+from datatypes import *
+
+Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
+PlayerStates = ["UNKNOWN", "PLAYING", "IN_MENU", "CHATTING"]
+GameTypes = ["DM", "TDM", "CTF"]
+
+Enums = [Enum("GAMETYPE", GameTypes), Enum("PLAYERSTATE", PlayerStates), Enum("EMOTE", Emotes)]
+
+Objects = [
+
+ NetObject("PlayerInput", [
+ NetIntAny("direction"),
+ NetIntAny("target_x"),
+ NetIntAny("target_y"),
+
+ NetIntAny("jump"),
+ NetIntAny("fire"),
+ NetIntAny("hook"),
+
+ NetIntRange("player_state", 0, len(PlayerStates)),
+
+ NetIntAny("wanted_weapon"),
+ NetIntAny("next_weapon"),
+ NetIntAny("prev_weapon"),
+ ]),
+
+ NetObject("Projectile", [
+ NetIntAny("x"),
+ NetIntAny("y"),
+ NetIntAny("vx"),
+ NetIntAny("vy"),
+
+ NetIntRange("type", 0, 'NUM_WEAPONS-1'),
+ NetTick("start_tick"),
+ ]),
+
+ NetObject("Laser", [
+ NetIntAny("x"),
+ NetIntAny("y"),
+ NetIntAny("from_x"),
+ NetIntAny("from_y"),
+
+ NetTick("start_tick"),
+ ]),
+
+ NetObject("Pickup", [
+ NetIntAny("x"),
+ NetIntAny("y"),
+
+ NetIntRange("type", 0, 'max_int'),
+ NetIntRange("subtype", 0, 'max_int'),
+ ]),
+
+ NetObject("Flag", [
+ NetIntAny("x"),
+ NetIntAny("y"),
+
+ NetIntRange("team", 0, 1),
+ NetIntRange("carried_by", -2, 'MAX_CLIENTS-1')
+ ]),
+
+ NetObject("Game", [
+ NetIntRange("team", 0, 1),
+ NetTick("round_start_tick"),
+
+ NetIntRange("game_over", 0, 1),
+ NetIntRange("sudden_death", 0, 1),
+ NetIntRange("paused", 0, 1),
+
+ NetIntRange("score_limit", 0, 'max_int'),
+ NetIntRange("time_limit", 0, 'max_int'),
+ NetIntRange("gametype", 0, len(GameTypes)),
+
+ NetIntRange("warmup", 0, 'max_int'),
+
+ NetIntAny("teamscore_red"),
+ NetIntAny("teamscore_blue"),
+ ]),
+
+ NetObject("PlayerCore", [
+ NetIntAny("x"),
+ NetIntAny("y"),
+ NetIntAny("vx"),
+ NetIntAny("vy"),
+
+ NetIntAny("angle"),
+
+ NetIntRange("jumped", 0, 3),
+ NetIntRange("hooked_player", 0, 'MAX_CLIENTS-1'),
+ NetIntRange("hook_state", -1, 5),
+ NetTick("hook_tick"),
+
+ NetIntAny("hook_x"),
+ NetIntAny("hook_y"),
+ NetIntAny("hook_dx"),
+ NetIntAny("hook_dy"),
+ ]),
+
+ NetObject("PlayerCharacter:PlayerCore", [
+ NetIntRange("local", 0, 1),
+ NetIntRange("cid", 0, 'MAX_CLIENTS-1'),
+ NetIntRange("team", -1, 1),
+
+ NetIntAny("score"),
+ NetIntAny("latency"),
+ NetIntAny("latency_flux"),
+ ]),
+
+ ## Events
+
+ NetEvent("CommonEvent", [
+ NetIntAny("x"),
+ NetIntAny("y"),
+ ]),
+
+
+ NetEvent("Explosion:CommonEvent", []),
+ NetEvent("Spawn:CommonEvent", []),
+ NetEvent("Death:CommonEvent", []),
+ NetEvent("AirJump:CommonEvent", []),
+
+ NetEvent("SoundGlobal:CommonEvent", [
+ NetIntRange("soundid", 0, 'NUM_SOUNDS-1'),
+ ]),
+
+ NetEvent("SoundWorld:CommonEvent", [
+ NetIntRange("soundid", 0, 'NUM_SOUNDS-1'),
+ ]),
+
+ NetEvent("DamageInd:CommonEvent", [
+ NetIntAny("angle"),
+ ]),
+]
+
+Messages = [
+
+ ### Server messages
+ NetMessage("sv_motd", [
+ NetString("message"),
+ ]),
+
+ NetMessage("sv_broadcast", [
+ NetString("message"),
+ ]),
+
+ NetMessage("sv_chat", [
+ NetIntRange("team", -1, 1),
+ NetIntRange("cid", -1, 'MAX_CLIENTS-1'),
+ NetString("message"),
+ ]),
+
+ NetMessage("sv_setinfo", [
+ NetIntRange("cid", 0, 'MAX_CLIENTS-1'),
+ NetString("name"),
+ NetString("skin"),
+ NetBool("use_custom_color"),
+ NetIntAny("color_body"),
+ NetIntAny("color_feet"),
+ ]),
+
+ NetMessage("sv_killmsg", [
+ NetIntRange("killer", 0, 'MAX_CLIENTS-1'),
+ NetIntRange("victim", 0, 'MAX_CLIENTS-1'),
+ NetIntRange("weapon", 0, 'NUM_WEAPONS-1'),
+ NetIntAny("mode_special"),
+ ]),
+
+ NetMessage("sv_soundglobal", [
+ NetIntRange("soundid", 0, 'NUM_SOUNDS-1'),
+ ]),
+
+ NetMessage("sv_tuneparams", []),
+ NetMessage("sv_extraprojectile", []),
+ NetMessage("sv_readytoenter", []),
+
+ NetMessage("sv_weaponpickup", [
+ NetIntRange("weapon", 0, 'NUM_WEAPONS-1'),
+ ]),
+
+ NetMessage("sv_emoticon", [
+ NetIntRange("cid", 0, 'MAX_CLIENTS-1'),
+ NetIntRange("emoticon", 0, 'NUM_EMOTICONS-1'),
+ ]),
+
+
+ ### Client messages
+ NetMessage("cl_say", [
+ NetBool("team"),
+ NetString("message"),
+ ]),
+
+ NetMessage("cl_setteam", [
+ NetIntRange("team", -1, 1),
+ ]),
+
+ NetMessage("cl_startinfo", [
+ NetString("name"),
+ NetString("skin"),
+ NetBool("use_custom_color"),
+ NetIntAny("color_body"),
+ NetIntAny("color_feet"),
+ ]),
+
+ NetMessage("cl_changeinfo:cl_startinfo", []),
+
+ NetMessage("cl_kill", []),
+
+ NetMessage("cl_emoticon", [
+ NetIntRange("emoticon", 0, 'NUM_EMOTICONS-1'),
+ ]),
+
+]
View
1 scripts/count_source.sh
@@ -0,0 +1 @@
+svn blame `svn -R ls | grep ^src | grep -v external | grep -v /$` | python scripts/process_blame.py
View
12 scripts/process_blame.py
@@ -0,0 +1,12 @@
+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")

0 comments on commit ac18c6a

Please sign in to comment.