Generate the 0.7 protocol

This commit is contained in:
Learath 2020-04-16 11:46:43 +03:00
parent f7e9df7abf
commit 807c92f1a4
14 changed files with 2053 additions and 61 deletions

View file

@ -335,7 +335,7 @@ if(UPNP)
find_package(Miniupnpc)
endif()
find_package(Pnglite)
find_package(PythonInterp)
find_package(Python3)
find_package(SDL2)
if(VIDEORECORDER)
find_package(FFMPEG)
@ -415,7 +415,7 @@ if(UPNP)
show_dependency_status("Miniupnpc" MINIUPNPC)
endif()
show_dependency_status("Pnglite" PNGLITE)
show_dependency_status("PythonInterp" PYTHONINTERP)
show_dependency_status("PythonInterp" Python3_Interpreter)
show_dependency_status("SDL2" SDL2)
if(VIDEORECORDER)
show_dependency_status("FFmpeg" FFMPEG)
@ -429,7 +429,7 @@ endif()
if(CLIENT AND NOT(CURL_FOUND))
message(SEND_ERROR "You must install Curl to compile DDNet")
endif()
if(NOT(PYTHONINTERP_FOUND))
if(NOT(Python3_Interpreter_FOUND))
message(SEND_ERROR "You must install Python to compile DDNet")
endif()
@ -591,7 +591,7 @@ file(COPY ${COPY_FILES} DESTINATION .)
function(generate_source output_file script_parameter)
add_custom_command(OUTPUT ${output_file}
COMMAND ${PYTHON_EXECUTABLE} datasrc/compile.py ${script_parameter}
COMMAND ${Python3_EXECUTABLE} datasrc/compile.py ${script_parameter}
> "${PROJECT_BINARY_DIR}/${output_file}"
DEPENDS
datasrc/compile.py
@ -602,6 +602,36 @@ function(generate_source output_file script_parameter)
)
endfunction()
function(generate_source7 output_file script_parameter)
add_custom_command(OUTPUT ${output_file}
COMMAND ${Python3_EXECUTABLE} datasrc/seven/compile.py ${script_parameter}
> "${PROJECT_BINARY_DIR}/${output_file}"
DEPENDS
datasrc/seven/compile.py
datasrc/seven/content.py
datasrc/seven/datatypes.py
datasrc/seven/network.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endfunction()
function(generate_maps output_file)
add_custom_command(OUTPUT ${output_file}
COMMAND ${Python3_EXECUTABLE} datasrc/crosscompile.py
> "${PROJECT_BINARY_DIR}/${output_file}"
DEPENDS
datasrc/compile.py
datasrc/content.py
datasrc/datatypes.py
datasrc/network.py
datasrc/seven/compile.py
datasrc/seven/content.py
datasrc/seven/datatypes.py
datasrc/seven/network.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endfunction()
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/game/generated/")
execute_process(COMMAND git rev-parse --git-dir
ERROR_QUIET
@ -616,7 +646,7 @@ if(NOT PROJECT_GIT_DIR_ERROR)
)
endif()
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src/game/generated/git_revision.cpp
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python3_EXECUTABLE}
scripts/git_revision.py
> ${PROJECT_BINARY_DIR}/src/game/generated/git_revision.cpp
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
@ -631,6 +661,10 @@ generate_source("src/game/generated/protocol.h" "network_header")
generate_source("src/game/generated/server_data.cpp" "server_content_source")
generate_source("src/game/generated/server_data.h" "server_content_header")
generate_source7("src/game/generated/protocol7.cpp" "network_source")
generate_source7("src/game/generated/protocol7.h" "network_header")
generate_maps("src/game/generated/protocolglue.h")
########################################################################
# SHARED
@ -787,6 +821,9 @@ set_src(GAME_SHARED GLOB src/game
# A bit hacky, but these are needed to register all the UUIDs, even for stuff
# that doesn't link game.
set(ENGINE_UUID_SHARED
src/game/generated/protocolglue.h
src/game/generated/protocol7.cpp
src/game/generated/protocol7.h
src/game/generated/protocol.cpp
src/game/generated/protocol.h
src/game/mapitems_ex.cpp
@ -802,6 +839,8 @@ list(REMOVE_ITEM GAME_SHARED ${ENGINE_UUID_SHARED})
set(GAME_GENERATED_SHARED
src/game/generated/git_revision.cpp
src/game/generated/protocol.h
src/game/generated/protocol7.h
src/game/generated/protocolglue.h
)
set(DEPS ${DEP_JSON} ${DEP_MD5} ${ZLIB_DEP})
@ -1586,7 +1625,7 @@ if(CLIENT AND (DMGTOOLS_FOUND OR HDIUTIL))
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TARGET_SERVER}> $<TARGET_FILE:${TARGET_SERVER_LAUNCHER}> ${DMG_TMPDIR}/${TARGET_SERVER}.app/Contents/MacOS/
# DMG
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/dmg.py create ${DMG_PARAMS} ${CPACK_PACKAGE_FILE_NAME}.dmg ${CPACK_PACKAGE_FILE_NAME} ${DMG_TMPDIR}
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/dmg.py create ${DMG_PARAMS} ${CPACK_PACKAGE_FILE_NAME}.dmg ${CPACK_PACKAGE_FILE_NAME} ${DMG_TMPDIR}
DEPENDS
${TARGET_CLIENT}

38
datasrc/crosscompile.py Normal file
View file

@ -0,0 +1,38 @@
def get_msgs():
from datatypes import NetMessage
import network
return ["NETMSG_INVALID"] + [m.enum_name for m in network.Messages]
def get_msgs_7():
from seven.datatypes import NetMessage
import seven.network as network
return ["NETMSG_INVALID"] + [m.enum_name for m in network.Messages]
def generate_map(a, b):
map = []
for i, m in enumerate(a):
try:
map += [b.index(m)]
except ValueError:
map += [-1]
return map
def output_map(name, map):
print("static const int gs_{}[{}] = {{".format(name, len(map)))
print(*map, sep=',')
print("};")
print("inline int {0}(int a) {{ return gs_{0}[a]; }}".format(name))
def main():
msgs = get_msgs()
msgs7 = get_msgs_7()
output_map("SixToSeven", generate_map(msgs, msgs7))
output_map("SevenToSix", generate_map(msgs7, msgs))
if __name__ == "__main__":
main()

342
datasrc/seven/compile.py Normal file
View file

@ -0,0 +1,342 @@
import sys
from datatypes import *
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
def create_flags_table(names):
lines = []
lines += ["enum", "{"]
i = 0
for name in names:
lines += ["\t%s = 1<<%d," % (name,i)]
i += 1
lines += ["};"]
return lines
def EmitEnum(names, num):
print("enum")
print("{")
print("\t%s=0," % names[0])
for name in names[1:]:
print("\t%s," % name)
print("\t%s" % num)
print("};")
def EmitFlags(names, num):
print("enum")
print("{")
i = 0
for name in names:
print("\t%s = 1<<%d," % (name,i))
i += 1
print("};")
gen_network_header = False
gen_network_source = False
gen_client_content_header = False
gen_client_content_source = False
gen_server_content_header = False
gen_server_content_source = False
if "network_header" in sys.argv: gen_network_header = True
if "network_source" in sys.argv: gen_network_source = True
if "client_content_header" in sys.argv: gen_client_content_header = True
if "client_content_source" in sys.argv: gen_client_content_source = True
if "server_content_header" in sys.argv: gen_server_content_header = True
if "server_content_source" in sys.argv: gen_server_content_source = True
if gen_client_content_header:
print("#ifndef CLIENT_CONTENT_HEADER")
print("#define CLIENT_CONTENT_HEADER")
if gen_server_content_header:
print("#ifndef SERVER_CONTENT_HEADER")
print("#define SERVER_CONTENT_HEADER")
if gen_client_content_header or gen_server_content_header:
# print some includes
print('#include <engine/graphics.h>')
print('#include <engine/sound.h>')
# emit the type declarations
contentlines = open("datasrc/content.py", "rb").readlines()
order = []
for line in contentlines:
line = line.strip()
if line[:6] == "class ".encode() and "(Struct)".encode() in line:
order += [line.split()[1].split("(".encode())[0].decode("ascii")]
for name in order:
EmitTypeDeclaration(content.__dict__[name])
# the container pointer
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")
if gen_client_content_source or gen_server_content_source:
if gen_client_content_source:
print('#include "client_data.h"')
if gen_server_content_source:
print('#include "server_data.h"')
EmitDefinition(content.container, "datacontainer")
print('CDataContainer *g_pData = &datacontainer;')
# NETWORK
if gen_network_header:
print("#ifndef GAME_GENERATED_PROTOCOL7_H")
print("#define GAME_GENERATED_PROTOCOL7_H")
print("namespace protocol7 {")
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): print(l)
print("")
for e in network.Flags:
for l in create_flags_table(["%s_%s" % (e.name, v) for v in e.values]): print(l)
print("")
for l in create_enum_table(["NETOBJ_INVALID"]+[o.enum_name for o in network.Objects], "NUM_NETOBJTYPES"): print(l)
print("")
for l in create_enum_table(["NETMSG_INVALID"]+[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("")
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")
print("""
class CNetObjHandler
{
const char *m_pMsgFailedOn;
char m_aMsgData[1024];
const char *m_pObjFailedOn;
int m_NumObjFailures;
bool CheckInt(const char *pErrorMsg, int Value, int Min, int Max);
bool CheckFlag(const char *pErrorMsg, int Value, int Mask);
static const char *ms_apObjNames[];
static int ms_aObjSizes[];
static const char *ms_apMsgNames[];
public:
CNetObjHandler();
int ValidateObj(int Type, const void *pData, int Size);
const char *GetObjName(int Type) const;
int GetObjSize(int Type) const;
const char *FailedObjOn() const;
int NumObjFailures() const;
const char *GetMsgName(int Type) const;
void *SecureUnpackMsg(int Type, CUnpacker *pUnpacker);
const char *FailedMsgOn() const;
};
""")
print("}")
print("#endif // GAME_GENERATED_PROTOCOL7_H")
if gen_network_source:
# create names
lines = []
lines += ['#include <engine/shared/protocol.h>']
lines += ['#include <engine/message.h>']
lines += ['#include "protocol7.h"']
lines += ['namespace protocol7 {']
lines += ['CNetObjHandler::CNetObjHandler()']
lines += ['{']
lines += ['\tm_pMsgFailedOn = "";']
lines += ['\tm_pObjFailedOn = "";']
lines += ['\tm_NumObjFailures = 0;']
lines += ['}']
lines += ['']
lines += ['const char *CNetObjHandler::FailedObjOn() const { return m_pObjFailedOn; }']
lines += ['int CNetObjHandler::NumObjFailures() const { return m_NumObjFailures; }']
lines += ['const char *CNetObjHandler::FailedMsgOn() const { return m_pMsgFailedOn; }']
lines += ['']
lines += ['']
lines += ['']
lines += ['']
lines += ['static const int max_int = 0x7fffffff;']
lines += ['']
lines += ['bool CNetObjHandler::CheckInt(const char *pErrorMsg, int Value, int Min, int Max)']
lines += ['{']
lines += ['\tif(Value < Min || Value > Max) { m_pObjFailedOn = pErrorMsg; m_NumObjFailures++; return false; }']
lines += ['\treturn true;']
lines += ['}']
lines += ['']
lines += ['bool CNetObjHandler::CheckFlag(const char *pErrorMsg, int Value, int Mask)']
lines += ['{']
lines += ['\tif((Value&Mask) != Value) { m_pObjFailedOn = pErrorMsg; m_NumObjFailures++; return false; }']
lines += ['\treturn true;']
lines += ['}']
lines += ['']
lines += ["const char *CNetObjHandler::ms_apObjNames[] = {"]
lines += ['\t"invalid",']
lines += ['\t"%s",' % 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 += ['\t0', "};", ""]
lines += ['const char *CNetObjHandler::ms_apMsgNames[] = {']
lines += ['\t"invalid",']
for msg in network.Messages:
lines += ['\t"%s",' % msg.name]
lines += ['\t""']
lines += ['};']
lines += ['']
lines += ['const char *CNetObjHandler::GetObjName(int Type) const']
lines += ['{']
lines += ['\tif(Type < 0 || Type >= NUM_NETOBJTYPES) return "(out of range)";']
lines += ['\treturn ms_apObjNames[Type];']
lines += ['};']
lines += ['']
lines += ['int CNetObjHandler::GetObjSize(int Type) const']
lines += ['{']
lines += ['\tif(Type < 0 || Type >= NUM_NETOBJTYPES) return 0;']
lines += ['\treturn ms_aObjSizes[Type];']
lines += ['};']
lines += ['']
lines += ['const char *CNetObjHandler::GetMsgName(int Type) const']
lines += ['{']
lines += ['\tif(Type < 0 || Type >= NUM_NETMSGTYPES) return "(out of range)";']
lines += ['\treturn ms_apMsgNames[Type];']
lines += ['};']
lines += ['']
for l in lines:
print(l)
if 0:
for item in network.Objects:
for line in item.emit_validate():
print(line)
print("")
# create validate tables
lines = []
lines += ['static int validate_invalid(void *data, int size) { return -1; }']
lines += ["typedef int(*VALIDATEFUNC)(void *data, int size);"]
lines += ["static VALIDATEFUNC validate_funcs[] = {"]
lines += ['\tvalidate_invalid,']
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 += ["};", ""]
lines = []
lines += ['int CNetObjHandler::ValidateObj(int Type, const void *pData, int Size)']
lines += ['{']
lines += ['\tswitch(Type)']
lines += ['\t{']
for item in network.Objects:
for line in item.emit_validate():
lines += ["\t" + line]
lines += ['\t']
lines += ['\t}']
lines += ['\treturn -1;']
lines += ['};']
lines += ['']
#int Validate(int Type, void *pData, int Size);
if 0:
for item in network.Messages:
for line in item.emit_unpack():
print(line)
print("")
lines += ['static void *secure_unpack_invalid(CUnpacker *pUnpacker) { return 0; }']
lines += ['typedef void *(*SECUREUNPACKFUNC)(CUnpacker *pUnpacker);']
lines += ['static SECUREUNPACKFUNC secure_unpack_funcs[] = {']
lines += ['\tsecure_unpack_invalid,']
for msg in network.Messages:
lines += ['\tsecure_unpack_%s,' % msg.name]
lines += ['\t0x0']
lines += ['};']
#
lines += ['void *CNetObjHandler::SecureUnpackMsg(int Type, CUnpacker *pUnpacker)']
lines += ['{']
lines += ['\tm_pMsgFailedOn = 0;']
lines += ['\tm_pObjFailedOn = 0;']
lines += ['\tswitch(Type)']
lines += ['\t{']
for item in network.Messages:
for line in item.emit_unpack():
lines += ["\t" + line]
lines += ['\t']
lines += ['\tdefault:']
lines += ['\t\tm_pMsgFailedOn = "(type out of range)";']
lines += ['\t\tbreak;']
lines += ['\t}']
lines += ['\t']
lines += ['\tif(pUnpacker->Error())']
lines += ['\t\tm_pMsgFailedOn = "(unpack error)";']
lines += ['\t']
lines += ['\tif(m_pMsgFailedOn || m_pObjFailedOn) {']
lines += ['\t\tif(!m_pMsgFailedOn)']
lines += ['\t\t\tm_pMsgFailedOn = "";']
lines += ['\t\tif(!m_pObjFailedOn)']
lines += ['\t\t\tm_pObjFailedOn = "";']
lines += ['\t\treturn 0;']
lines += ['\t}']
lines += ['\tm_pMsgFailedOn = "";']
lines += ['\tm_pObjFailedOn = "";']
lines += ['\treturn m_aMsgData;']
lines += ['};']
lines += ['}']
lines += ['']
for l in lines:
print(l)
if gen_client_content_header or gen_server_content_header:
print("#endif")

679
datasrc/seven/content.py Normal file
View file

@ -0,0 +1,679 @@
from datatypes import *
class Sound(Struct):
def __init__(self, filename=""):
Struct.__init__(self, "CDataSound")
self.id = SampleHandle()
self.filename = String(filename)
class SoundSet(Struct):
def __init__(self, name="", files=[]):
Struct.__init__(self, "CDataSoundset")
self.name = String(name)
self.sounds = Array(Sound())
self.last = Int(-1)
for name in files:
self.sounds.Add(Sound(name))
class Image(Struct):
def __init__(self, name="", filename="", linear_mapping=0):
Struct.__init__(self, "CDataImage")
self.name = String(name)
self.filename = String(filename)
self.flag = Int(linear_mapping)
self.id = TextureHandle()
class SpriteSet(Struct):
def __init__(self, name="", image=None, gridx=0, gridy=0):
Struct.__init__(self, "CDataSpriteset")
self.image = Pointer(Image, image) # TODO
self.gridx = Int(gridx)
self.gridy = Int(gridy)
class Sprite(Struct):
def __init__(self, name="", Set=None, x=0, y=0, w=0, h=0):
Struct.__init__(self, "CDataSprite")
self.name = String(name)
self.set = Pointer(SpriteSet, Set) # TODO
self.x = Int(x)
self.y = Int(y)
self.w = Int(w)
self.h = Int(h)
class Pickup(Struct):
def __init__(self, name="", respawntime=15, spawndelay=0):
Struct.__init__(self, "CDataPickupspec")
self.name = String(name)
self.respawntime = Int(respawntime)
self.spawndelay = Int(spawndelay)
class AnimKeyframe(Struct):
def __init__(self, time=0, x=0, y=0, angle=0):
Struct.__init__(self, "CAnimKeyframe")
self.time = Float(time)
self.x = Float(x)
self.y = Float(y)
self.angle = Float(angle)
class AnimSequence(Struct):
def __init__(self):
Struct.__init__(self, "CAnimSequence")
self.frames = Array(AnimKeyframe())
class Animation(Struct):
def __init__(self, name=""):
Struct.__init__(self, "CAnimation")
self.name = String(name)
self.body = AnimSequence()
self.back_foot = AnimSequence()
self.front_foot = AnimSequence()
self.attach = AnimSequence()
class WeaponSpec(Struct):
def __init__(self, container=None, name=""):
Struct.__init__(self, "CDataWeaponspec")
self.name = String(name)
self.sprite_body = Pointer(Sprite, Sprite())
self.sprite_cursor = Pointer(Sprite, Sprite())
self.sprite_proj = Pointer(Sprite, Sprite())
self.sprite_muzzles = Array(Pointer(Sprite, Sprite()))
self.visual_size = Int(96)
self.firedelay = Int(500)
self.maxammo = Int(10)
self.ammoregentime = Int(0)
self.damage = Int(1)
self.offsetx = Float(0)
self.offsety = Float(0)
self.muzzleoffsetx = Float(0)
self.muzzleoffsety = Float(0)
self.muzzleduration = Float(5)
# dig out sprites if we have a container
if container:
for sprite in container.sprites.items:
if sprite.name.value == "weapon_"+name+"_body": self.sprite_body.Set(sprite)
elif sprite.name.value == "weapon_"+name+"_cursor": self.sprite_cursor.Set(sprite)
elif sprite.name.value == "weapon_"+name+"_proj": self.sprite_proj.Set(sprite)
elif "weapon_"+name+"_muzzle" in sprite.name.value:
self.sprite_muzzles.Add(Pointer(Sprite, sprite))
class Weapon_Hammer(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecHammer")
self.base = Pointer(WeaponSpec, WeaponSpec())
class Weapon_Gun(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecGun")
self.base = Pointer(WeaponSpec, WeaponSpec())
self.curvature = Float(1.25)
self.speed = Float(2200)
self.lifetime = Float(2.0)
class Weapon_Shotgun(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecShotgun")
self.base = Pointer(WeaponSpec, WeaponSpec())
self.curvature = Float(1.25)
self.speed = Float(2200)
self.speeddiff = Float(0.8)
self.lifetime = Float(0.25)
class Weapon_Grenade(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecGrenade")
self.base = Pointer(WeaponSpec, WeaponSpec())
self.curvature = Float(7.0)
self.speed = Float(1000)
self.lifetime = Float(2.0)
class Weapon_Laser(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecLaser")
self.base = Pointer(WeaponSpec, WeaponSpec())
self.reach = Float(800.0)
self.bounce_delay = Int(150)
self.bounce_num = Int(1)
self.bounce_cost = Float(0)
class Weapon_Ninja(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecNinja")
self.base = Pointer(WeaponSpec, WeaponSpec())
self.duration = Int(15000)
self.movetime = Int(200)
self.velocity = Int(50)
class Weapons(Struct):
def __init__(self):
Struct.__init__(self, "CDataWeaponspecs")
self.hammer = Weapon_Hammer()
self.gun = Weapon_Gun()
self.shotgun = Weapon_Shotgun()
self.grenade = Weapon_Grenade()
self.laser = Weapon_Laser()
self.ninja = Weapon_Ninja()
self.id = Array(WeaponSpec())
class Explosion(Struct):
def __init__(self):
Struct.__init__(self, "CDataExplosion")
self.radius = Float(135)
self.max_force = Float(12)
class DataContainer(Struct):
def __init__(self):
Struct.__init__(self, "CDataContainer")
self.sounds = Array(SoundSet())
self.images = Array(Image())
self.pickups = Array(Pickup())
self.spritesets = Array(SpriteSet())
self.sprites = Array(Sprite())
self.animations = Array(Animation())
self.weapons = Weapons()
self.explosion = Explosion()
def FileList(format, num):
return [format%(x+1) for x in range(0,num)]
container = DataContainer()
container.sounds.Add(SoundSet("gun_fire", FileList("audio/wp_gun_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("shotgun_fire", FileList("audio/wp_shotty_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("grenade_fire", FileList("audio/wp_flump_launch-%02d.wv", 3)))
container.sounds.Add(SoundSet("hammer_fire", FileList("audio/wp_hammer_swing-%02d.wv", 3)))
container.sounds.Add(SoundSet("hammer_hit", FileList("audio/wp_hammer_hit-%02d.wv", 3)))
container.sounds.Add(SoundSet("ninja_fire", FileList("audio/wp_ninja_attack-%02d.wv", 3)))
container.sounds.Add(SoundSet("grenade_explode", FileList("audio/wp_flump_explo-%02d.wv", 3)))
container.sounds.Add(SoundSet("ninja_hit", FileList("audio/wp_ninja_hit-%02d.wv", 3)))
container.sounds.Add(SoundSet("laser_fire", FileList("audio/wp_laser_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("laser_bounce", FileList("audio/wp_laser_bnce-%02d.wv", 3)))
container.sounds.Add(SoundSet("weapon_switch", FileList("audio/wp_switch-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_pain_short", FileList("audio/vo_teefault_pain_short-%02d.wv", 12)))
container.sounds.Add(SoundSet("player_pain_long", FileList("audio/vo_teefault_pain_long-%02d.wv", 2)))
container.sounds.Add(SoundSet("body_land", FileList("audio/foley_land-%02d.wv", 4)))
container.sounds.Add(SoundSet("player_airjump", FileList("audio/foley_dbljump-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_jump", FileList("audio/foley_foot_left-%02d.wv", 4) + FileList("audio/foley_foot_right-%02d.wv", 4)))
container.sounds.Add(SoundSet("player_die", FileList("audio/foley_body_splat-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_spawn", FileList("audio/vo_teefault_spawn-%02d.wv", 7)))
container.sounds.Add(SoundSet("player_skid", FileList("audio/sfx_skid-%02d.wv", 4)))
container.sounds.Add(SoundSet("tee_cry", FileList("audio/vo_teefault_cry-%02d.wv", 2)))
container.sounds.Add(SoundSet("hook_loop", FileList("audio/hook_loop-%02d.wv", 2)))
container.sounds.Add(SoundSet("hook_attach_ground", FileList("audio/hook_attach-%02d.wv", 3)))
container.sounds.Add(SoundSet("hook_attach_player", FileList("audio/foley_body_impact-%02d.wv", 3)))
container.sounds.Add(SoundSet("hook_noattach", FileList("audio/hook_noattach-%02d.wv", 2)))
container.sounds.Add(SoundSet("pickup_health", FileList("audio/sfx_pickup_hrt-%02d.wv", 2)))
container.sounds.Add(SoundSet("pickup_armor", FileList("audio/sfx_pickup_arm-%02d.wv", 4)))
container.sounds.Add(SoundSet("pickup_grenade", ["audio/sfx_pickup_launcher.wv"]))
container.sounds.Add(SoundSet("pickup_shotgun", ["audio/sfx_pickup_sg.wv"]))
container.sounds.Add(SoundSet("pickup_ninja", ["audio/sfx_pickup_ninja.wv"]))
container.sounds.Add(SoundSet("weapon_spawn", FileList("audio/sfx_spawn_wpn-%02d.wv", 3)))
container.sounds.Add(SoundSet("weapon_noammo", FileList("audio/wp_noammo-%02d.wv", 5)))
container.sounds.Add(SoundSet("hit", FileList("audio/sfx_hit_weak-%02d.wv", 2)))
container.sounds.Add(SoundSet("chat_server", ["audio/sfx_msg-server.wv"]))
container.sounds.Add(SoundSet("chat_client", ["audio/sfx_msg-client.wv"]))
container.sounds.Add(SoundSet("chat_highlight", ["audio/sfx_msg-highlight.wv"]))
container.sounds.Add(SoundSet("ctf_drop", ["audio/sfx_ctf_drop.wv"]))
container.sounds.Add(SoundSet("ctf_return", ["audio/sfx_ctf_rtn.wv"]))
container.sounds.Add(SoundSet("ctf_grab_pl", ["audio/sfx_ctf_grab_pl.wv"]))
container.sounds.Add(SoundSet("ctf_grab_en", ["audio/sfx_ctf_grab_en.wv"]))
container.sounds.Add(SoundSet("ctf_capture", ["audio/sfx_ctf_cap_pl.wv"]))
container.sounds.Add(SoundSet("menu", ["audio/music_menu.wv"]))
image_null = Image("null", "")
image_particles = Image("particles", "particles.png")
image_game = Image("game", "game.png")
image_browseicons = Image("browseicons", "ui/icons/browse.png", 1)
image_browsericon = Image("browser", "ui/icons/browser.png", 1)
image_emoticons = Image("emoticons", "emoticons.png")
image_demobuttons = Image("demobuttons", "ui/demo_buttons.png", 1)
image_fileicons = Image("fileicons", "ui/file_icons.png", 1)
image_guibuttons = Image("guibuttons", "ui/gui_buttons.png", 1)
image_guiicons = Image("guiicons", "ui/gui_icons.png", 1)
image_menuicons = Image("menuicons", "ui/icons/menu.png", 1)
image_soundicons = Image("soundicons", "ui/sound_icons.png", 1)
image_toolicons = Image("toolicons", "ui/icons/tools.png", 1)
image_arrowicons = Image("arrowicons", "ui/icons/arrows.png", 1)
image_friendicons = Image("friendicons", "ui/icons/friend.png", 1)
image_levelicons = Image("levelicons", "ui/icons/level.png", 1)
image_sidebaricons = Image("sidebaricons", "ui/icons/sidebar.png", 1)
image_chatwhisper = Image("chatwhisper", "ui/icons/chat_whisper.png", 1)
image_timerclock = Image("timerclock", "ui/icons/timer_clock.png", 1)
container.images.Add(image_null)
container.images.Add(image_game)
container.images.Add(Image("deadtee", "deadtee.png"))
container.images.Add(image_particles)
container.images.Add(Image("cursor", "ui/gui_cursor.png"))
container.images.Add(Image("banner", "ui/gui_logo.png"))
container.images.Add(image_emoticons)
container.images.Add(image_browseicons)
container.images.Add(image_browsericon)
container.images.Add(Image("console_bg", "ui/console.png"))
container.images.Add(Image("console_bar", "ui/console_bar.png"))
container.images.Add(image_demobuttons)
container.images.Add(image_fileicons)
container.images.Add(image_guibuttons)
container.images.Add(image_guiicons)
container.images.Add(Image("no_skinpart", "ui/no_skinpart.png"))
container.images.Add(image_menuicons)
container.images.Add(image_soundicons)
container.images.Add(image_toolicons)
container.images.Add(image_arrowicons)
container.images.Add(image_friendicons)
container.images.Add(image_levelicons)
container.images.Add(image_sidebaricons)
container.images.Add(image_chatwhisper)
container.images.Add(Image("raceflag", "race_flag.png"))
container.images.Add(image_timerclock)
container.pickups.Add(Pickup("health"))
container.pickups.Add(Pickup("armor"))
container.pickups.Add(Pickup("grenade"))
container.pickups.Add(Pickup("shotgun"))
container.pickups.Add(Pickup("laser"))
container.pickups.Add(Pickup("ninja", 90, 90))
container.pickups.Add(Pickup("gun"))
container.pickups.Add(Pickup("hammer"))
set_particles = SpriteSet("particles", image_particles, 8, 8)
set_game = SpriteSet("game", image_game, 32, 16)
set_tee_body = SpriteSet("tee_body", image_null, 2, 2)
set_tee_markings = SpriteSet("tee_markings", image_null, 1, 1)
set_tee_decoration = SpriteSet("tee_decoration", image_null, 2, 1)
set_tee_hands = SpriteSet("tee_hands", image_null, 2, 1)
set_tee_feet = SpriteSet("tee_feet", image_null, 2, 1)
set_tee_eyes = SpriteSet("tee_eyes", image_null, 2, 4)
set_tee_hats = SpriteSet("tee_hats", image_null, 1, 4)
set_tee_bot = SpriteSet("tee_bot", image_null, 12, 5)
set_browseicons = SpriteSet("browseicons", image_browseicons, 4, 2)
set_browsericon = SpriteSet("browsericon", image_browsericon, 1, 2)
set_emoticons = SpriteSet("emoticons", image_emoticons, 4, 4)
set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1)
set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1)
set_guibuttons = SpriteSet("guibuttons", image_guibuttons, 12, 4)
set_guiicons = SpriteSet("guiicons", image_guiicons, 8, 2)
set_menuicons = SpriteSet("menuicons", image_menuicons, 4, 4)
set_toolicons = SpriteSet("toolicons", image_toolicons, 4, 2)
set_soundicons = SpriteSet("guiicons", image_soundicons, 1, 2)
set_arrowicons = SpriteSet("arrowicons", image_arrowicons, 4, 3)
set_friendicons = SpriteSet("friendicons", image_friendicons, 2, 2)
set_levelicons = SpriteSet("levelicons", image_levelicons, 4, 4)
set_sidebaricons = SpriteSet("sidebaricons", image_sidebaricons, 4, 2)
set_timerclock = SpriteSet("timerclock", image_timerclock, 1, 2)
container.spritesets.Add(set_particles)
container.spritesets.Add(set_game)
container.spritesets.Add(set_tee_body)
container.spritesets.Add(set_tee_markings)
container.spritesets.Add(set_tee_decoration)
container.spritesets.Add(set_tee_hands)
container.spritesets.Add(set_tee_feet)
container.spritesets.Add(set_tee_eyes)
container.spritesets.Add(set_tee_hats)
container.spritesets.Add(set_tee_bot)
container.spritesets.Add(set_browseicons)
container.spritesets.Add(set_emoticons)
container.spritesets.Add(set_demobuttons)
container.spritesets.Add(set_fileicons)
container.spritesets.Add(set_guibuttons)
container.spritesets.Add(set_guiicons)
container.spritesets.Add(set_menuicons)
container.spritesets.Add(set_soundicons)
container.spritesets.Add(set_toolicons)
container.spritesets.Add(set_arrowicons)
container.spritesets.Add(set_friendicons)
container.spritesets.Add(set_levelicons)
container.spritesets.Add(set_sidebaricons)
container.spritesets.Add(set_timerclock)
container.spritesets.Add(set_browsericon)
container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1))
container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1))
container.sprites.Add(Sprite("part_splat01", set_particles, 2,0,1,1))
container.sprites.Add(Sprite("part_splat02", set_particles, 3,0,1,1))
container.sprites.Add(Sprite("part_splat03", set_particles, 4,0,1,1))
container.sprites.Add(Sprite("part_smoke", set_particles, 0,1,1,1))
container.sprites.Add(Sprite("part_shell", set_particles, 0,2,2,2))
container.sprites.Add(Sprite("part_expl01", set_particles, 0,4,4,4))
container.sprites.Add(Sprite("part_airjump", set_particles, 2,2,2,2))
container.sprites.Add(Sprite("part_hit01", set_particles, 4,1,2,2))
container.sprites.Add(Sprite("health_full", set_game, 21,0,2,2))
container.sprites.Add(Sprite("health_empty", set_game, 23,0,2,2))
container.sprites.Add(Sprite("armor_full", set_game, 21,2,2,2))
container.sprites.Add(Sprite("armor_empty", set_game, 23,2,2,2))
container.sprites.Add(Sprite("star1", set_game, 15,0,2,2))
container.sprites.Add(Sprite("star2", set_game, 17,0,2,2))
container.sprites.Add(Sprite("star3", set_game, 19,0,2,2))
container.sprites.Add(Sprite("part1", set_game, 6,0,1,1))
container.sprites.Add(Sprite("part2", set_game, 6,1,1,1))
container.sprites.Add(Sprite("part3", set_game, 7,0,1,1))
container.sprites.Add(Sprite("part4", set_game, 7,1,1,1))
container.sprites.Add(Sprite("part5", set_game, 8,0,1,1))
container.sprites.Add(Sprite("part6", set_game, 8,1,1,1))
container.sprites.Add(Sprite("part7", set_game, 9,0,2,2))
container.sprites.Add(Sprite("part8", set_game, 11,0,2,2))
container.sprites.Add(Sprite("part9", set_game, 13,0,2,2))
container.sprites.Add(Sprite("weapon_gun_body", set_game, 2,4,4,2))
container.sprites.Add(Sprite("weapon_gun_cursor", set_game, 0,4,2,2))
container.sprites.Add(Sprite("weapon_gun_proj", set_game, 6,4,2,2))
container.sprites.Add(Sprite("weapon_gun_muzzle1", set_game, 8,4,3,2))
container.sprites.Add(Sprite("weapon_gun_muzzle2", set_game, 12,4,3,2))
container.sprites.Add(Sprite("weapon_gun_muzzle3", set_game, 16,4,3,2))
container.sprites.Add(Sprite("weapon_shotgun_body", set_game, 2,6,8,2))
container.sprites.Add(Sprite("weapon_shotgun_cursor", set_game, 0,6,2,2))
container.sprites.Add(Sprite("weapon_shotgun_proj", set_game, 10,6,2,2))
container.sprites.Add(Sprite("weapon_shotgun_muzzle1", set_game, 12,6,3,2))
container.sprites.Add(Sprite("weapon_shotgun_muzzle2", set_game, 16,6,3,2))
container.sprites.Add(Sprite("weapon_shotgun_muzzle3", set_game, 20,6,3,2))
container.sprites.Add(Sprite("weapon_grenade_body", set_game, 2,8,7,2))
container.sprites.Add(Sprite("weapon_grenade_cursor", set_game, 0,8,2,2))
container.sprites.Add(Sprite("weapon_grenade_proj", set_game, 10,8,2,2))
container.sprites.Add(Sprite("weapon_hammer_body", set_game, 2,1,4,3))
container.sprites.Add(Sprite("weapon_hammer_cursor", set_game, 0,0,2,2))
container.sprites.Add(Sprite("weapon_hammer_proj", set_game, 0,0,0,0))
container.sprites.Add(Sprite("weapon_ninja_body", set_game, 2,10,8,2))
container.sprites.Add(Sprite("weapon_ninja_cursor", set_game, 0,10,2,2))
container.sprites.Add(Sprite("weapon_ninja_proj", set_game, 0,0,0,0))
container.sprites.Add(Sprite("weapon_laser_body", set_game, 2,12,7,3))
container.sprites.Add(Sprite("weapon_laser_cursor", set_game, 0,12,2,2))
container.sprites.Add(Sprite("weapon_laser_proj", set_game, 10,12,2,2))
container.sprites.Add(Sprite("hook_chain", set_game, 2,0,1,1))
container.sprites.Add(Sprite("hook_head", set_game, 3,0,2,1))
container.sprites.Add(Sprite("weapon_ninja_muzzle1", set_game, 25,0,7,4))
container.sprites.Add(Sprite("weapon_ninja_muzzle2", set_game, 25,4,7,4))
container.sprites.Add(Sprite("weapon_ninja_muzzle3", set_game, 25,8,7,4))
container.sprites.Add(Sprite("pickup_health", set_game, 10,2,2,2))
container.sprites.Add(Sprite("pickup_armor", set_game, 12,2,2,2))
container.sprites.Add(Sprite("pickup_grenade", set_game, 2,8,7,2))
container.sprites.Add(Sprite("pickup_shotgun", set_game, 2,6,8,2))
container.sprites.Add(Sprite("pickup_laser", set_game, 2,12,7,3))
container.sprites.Add(Sprite("pickup_ninja", set_game, 2,10,8,2))
container.sprites.Add(Sprite("pickup_gun", set_game, 2,4,4,2))
container.sprites.Add(Sprite("pickup_hammer", set_game, 2,1,4,3))
container.sprites.Add(Sprite("flag_blue", set_game, 12,8,4,8))
container.sprites.Add(Sprite("flag_red", set_game, 16,8,4,8))
container.sprites.Add(Sprite("ninja_bar_full_left", set_game, 21,4,1,2))
container.sprites.Add(Sprite("ninja_bar_full", set_game, 22,4,1,2))
container.sprites.Add(Sprite("ninja_bar_empty", set_game, 23,4,1,2))
container.sprites.Add(Sprite("ninja_bar_empty_right", set_game, 24,4,1,2))
container.sprites.Add(Sprite("tee_body_outline", set_tee_body, 0,0,1,1))
container.sprites.Add(Sprite("tee_body", set_tee_body, 1,0,1,1))
container.sprites.Add(Sprite("tee_body_shadow", set_tee_body, 0,1,1,1))
container.sprites.Add(Sprite("tee_body_upper_outline", set_tee_body, 1,1,1,1))
container.sprites.Add(Sprite("tee_marking", set_tee_markings, 0,0,1,1))
container.sprites.Add(Sprite("tee_decoration", set_tee_decoration, 0,0,1,1))
container.sprites.Add(Sprite("tee_decoration_outline", set_tee_decoration, 1,0,1,1))
container.sprites.Add(Sprite("tee_hand", set_tee_hands, 0,0,1,1))
container.sprites.Add(Sprite("tee_hand_outline", set_tee_hands, 1,0,1,1))
container.sprites.Add(Sprite("tee_foot", set_tee_feet, 0,0,1,1))
container.sprites.Add(Sprite("tee_foot_outline", set_tee_feet, 1,0,1,1))
container.sprites.Add(Sprite("tee_eyes_normal", set_tee_eyes, 0,0,1,1))
container.sprites.Add(Sprite("tee_eyes_angry", set_tee_eyes, 1,0,1,1))
container.sprites.Add(Sprite("tee_eyes_pain", set_tee_eyes, 0,1,1,1))
container.sprites.Add(Sprite("tee_eyes_happy", set_tee_eyes, 1,1,1,1))
container.sprites.Add(Sprite("tee_eyes_surprise", set_tee_eyes, 0,2,1,1))
container.sprites.Add(Sprite("tee_hats_top1", set_tee_hats, 0,0,1,1))
container.sprites.Add(Sprite("tee_hats_top2", set_tee_hats, 0,1,1,1))
container.sprites.Add(Sprite("tee_hats_side1", set_tee_hats, 0,2,1,1))
container.sprites.Add(Sprite("tee_hats_side2", set_tee_hats, 0,3,1,1))
container.sprites.Add(Sprite("tee_bot_glow", set_tee_bot, 0,0,4,4))
container.sprites.Add(Sprite("tee_bot_foreground", set_tee_bot, 4,0,4,4))
container.sprites.Add(Sprite("tee_bot_background", set_tee_bot, 8,0,4,4))
container.sprites.Add(Sprite("oop", set_emoticons, 0, 0, 1, 1))
container.sprites.Add(Sprite("exclamation", set_emoticons, 1, 0, 1, 1))
container.sprites.Add(Sprite("hearts", set_emoticons, 2, 0, 1, 1))
container.sprites.Add(Sprite("drop", set_emoticons, 3, 0, 1, 1))
container.sprites.Add(Sprite("dotdot", set_emoticons, 0, 1, 1, 1))
container.sprites.Add(Sprite("music", set_emoticons, 1, 1, 1, 1))
container.sprites.Add(Sprite("sorry", set_emoticons, 2, 1, 1, 1))
container.sprites.Add(Sprite("ghost", set_emoticons, 3, 1, 1, 1))
container.sprites.Add(Sprite("sushi", set_emoticons, 0, 2, 1, 1))
container.sprites.Add(Sprite("splattee", set_emoticons, 1, 2, 1, 1))
container.sprites.Add(Sprite("deviltee", set_emoticons, 2, 2, 1, 1))
container.sprites.Add(Sprite("zomg", set_emoticons, 3, 2, 1, 1))
container.sprites.Add(Sprite("zzz", set_emoticons, 0, 3, 1, 1))
container.sprites.Add(Sprite("wtf", set_emoticons, 1, 3, 1, 1))
container.sprites.Add(Sprite("eyes", set_emoticons, 2, 3, 1, 1))
container.sprites.Add(Sprite("question", set_emoticons, 3, 3, 1, 1))
container.sprites.Add(Sprite("browse_lock_a", set_browseicons, 0,0,1,1))
container.sprites.Add(Sprite("browse_lock_b", set_browseicons, 0,1,1,1))
container.sprites.Add(Sprite("browse_unpure_a", set_browseicons, 1,0,1,1))
container.sprites.Add(Sprite("browse_unpure_b", set_browseicons, 1,1,1,1))
container.sprites.Add(Sprite("browse_star_a", set_browseicons, 2,0,1,1))
container.sprites.Add(Sprite("browse_star_b", set_browseicons, 2,1,1,1))
container.sprites.Add(Sprite("browse_heart_a", set_browseicons, 3,0,1,1))
container.sprites.Add(Sprite("browse_heart_b", set_browseicons, 3,1,1,1))
container.sprites.Add(Sprite("demobutton_play", set_demobuttons, 0,0,1,1))
container.sprites.Add(Sprite("demobutton_pause", set_demobuttons, 1,0,1,1))
container.sprites.Add(Sprite("demobutton_stop", set_demobuttons, 2,0,1,1))
container.sprites.Add(Sprite("demobutton_slower", set_demobuttons, 3,0,1,1))
container.sprites.Add(Sprite("demobutton_faster", set_demobuttons, 4,0,1,1))
container.sprites.Add(Sprite("file_demo1", set_fileicons, 0,0,1,1))
container.sprites.Add(Sprite("file_demo2", set_fileicons, 1,0,1,1))
container.sprites.Add(Sprite("file_folder", set_fileicons, 2,0,1,1))
container.sprites.Add(Sprite("file_map1", set_fileicons, 5,0,1,1))
container.sprites.Add(Sprite("file_map2", set_fileicons, 6,0,1,1))
container.sprites.Add(Sprite("guibutton_off", set_guibuttons, 0,0,4,4))
container.sprites.Add(Sprite("guibutton_on", set_guibuttons, 4,0,4,4))
container.sprites.Add(Sprite("guibutton_hover", set_guibuttons, 8,0,4,4))
container.sprites.Add(Sprite("guiicon_mute", set_guiicons, 0,0,4,2))
container.sprites.Add(Sprite("guiicon_friend", set_guiicons, 4,0,4,2))
container.sprites.Add(Sprite("menu_checkbox_active", set_menuicons, 0,0,1,1))
container.sprites.Add(Sprite("menu_checkbox_inactive", set_menuicons, 0,1,1,1))
container.sprites.Add(Sprite("menu_checkbox_hover", set_menuicons, 0,2,1,1))
container.sprites.Add(Sprite("menu_collapsed", set_menuicons, 1,0,1,1))
container.sprites.Add(Sprite("menu_expanded", set_menuicons, 1,1,1,1))
container.sprites.Add(Sprite("soundicon_on", set_soundicons, 0,0,1,1))
container.sprites.Add(Sprite("soundicon_mute", set_soundicons, 0,1,1,1))
container.sprites.Add(Sprite("tool_up_a", set_toolicons, 0,0,1,1))
container.sprites.Add(Sprite("tool_up_b", set_toolicons, 0,1,1,1))
container.sprites.Add(Sprite("tool_down_a", set_toolicons, 1,0,1,1))
container.sprites.Add(Sprite("tool_down_b", set_toolicons, 1,1,1,1))
container.sprites.Add(Sprite("tool_edit_a", set_toolicons, 2,0,1,1))
container.sprites.Add(Sprite("tool_edit_b", set_toolicons, 2,1,1,1))
container.sprites.Add(Sprite("tool_x_a", set_toolicons, 3,0,1,1))
container.sprites.Add(Sprite("tool_x_b", set_toolicons, 3,1,1,1))
container.sprites.Add(Sprite("arrow_left_a", set_arrowicons, 0,0,1,1))
container.sprites.Add(Sprite("arrow_left_b", set_arrowicons, 0,1,1,1))
container.sprites.Add(Sprite("arrow_left_c", set_arrowicons, 0,2,1,1))
container.sprites.Add(Sprite("arrow_up_a", set_arrowicons, 1,0,1,1))
container.sprites.Add(Sprite("arrow_up_b", set_arrowicons, 1,1,1,1))
container.sprites.Add(Sprite("arrow_up_c", set_arrowicons, 1,2,1,1))
container.sprites.Add(Sprite("arrow_right_a", set_arrowicons, 2,0,1,1))
container.sprites.Add(Sprite("arrow_right_b", set_arrowicons, 2,1,1,1))
container.sprites.Add(Sprite("arrow_right_c", set_arrowicons, 2,2,1,1))
container.sprites.Add(Sprite("arrow_down_a", set_arrowicons, 3,0,1,1))
container.sprites.Add(Sprite("arrow_down_b", set_arrowicons, 3,1,1,1))
container.sprites.Add(Sprite("arrow_down_c", set_arrowicons, 3,2,1,1))
container.sprites.Add(Sprite("friend_plus_a", set_friendicons, 0,0,1,1))
container.sprites.Add(Sprite("friend_plus_b", set_friendicons, 0,1,1,1))
container.sprites.Add(Sprite("friend_x_a", set_friendicons, 1,0,1,1))
container.sprites.Add(Sprite("friend_x_b", set_friendicons, 1,1,1,1))
container.sprites.Add(Sprite("level_a_on", set_levelicons, 0,0,1,1))
container.sprites.Add(Sprite("level_a_a", set_levelicons, 0,1,1,1))
container.sprites.Add(Sprite("level_a_b", set_levelicons, 0,2,1,1))
container.sprites.Add(Sprite("level_b_on", set_levelicons, 1,0,1,1))
container.sprites.Add(Sprite("level_b_a", set_levelicons, 1,1,1,1))
container.sprites.Add(Sprite("level_b_b", set_levelicons, 1,2,1,1))
container.sprites.Add(Sprite("level_c_on", set_levelicons, 2,0,1,1))
container.sprites.Add(Sprite("level_c_a", set_levelicons, 2,1,1,1))
container.sprites.Add(Sprite("level_c_b", set_levelicons, 2,2,1,1))
container.sprites.Add(Sprite("sidebar_refresh_a", set_sidebaricons, 0,0,1,1))
container.sprites.Add(Sprite("sidebar_refresh_b", set_sidebaricons, 0,1,1,1))
container.sprites.Add(Sprite("sidebar_friend_a", set_sidebaricons, 1,0,1,1))
container.sprites.Add(Sprite("sidebar_friend_b", set_sidebaricons, 1,1,1,1))
container.sprites.Add(Sprite("sidebar_filter_a", set_sidebaricons, 2,0,1,1))
container.sprites.Add(Sprite("sidebar_filter_b", set_sidebaricons, 2,1,1,1))
container.sprites.Add(Sprite("sidebar_info_a", set_sidebaricons, 3,0,1,1))
container.sprites.Add(Sprite("sidebar_info_b", set_sidebaricons, 3,1,1,1))
container.sprites.Add(Sprite("browser_a", set_browsericon, 0,0,1,1))
container.sprites.Add(Sprite("browser_b", set_browsericon, 0,1,1,1))
container.sprites.Add(Sprite("timerclock_a", set_timerclock, 0,0,1,1))
container.sprites.Add(Sprite("timerclock_b", set_timerclock, 0,1,1,1))
anim = Animation("base")
anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0))
anim.back_foot.frames.Add(AnimKeyframe(0, 0, 10, 0))
anim.front_foot.frames.Add(AnimKeyframe(0, 0, 10, 0))
container.animations.Add(anim)
anim = Animation("idle")
anim.back_foot.frames.Add(AnimKeyframe(0, -7, 0, 0))
anim.front_foot.frames.Add(AnimKeyframe(0, 7, 0, 0))
container.animations.Add(anim)
anim = Animation("inair")
anim.back_foot.frames.Add(AnimKeyframe(0, -3, 0, -0.1))
anim.front_foot.frames.Add(AnimKeyframe(0, 3, 0, -0.1))
container.animations.Add(anim)
anim = Animation("walk")
anim.body.frames.Add(AnimKeyframe(0.0, 0, 0, 0))
anim.body.frames.Add(AnimKeyframe(0.2, 0,-1, 0))
anim.body.frames.Add(AnimKeyframe(0.4, 0, 0, 0))
anim.body.frames.Add(AnimKeyframe(0.6, 0, 0, 0))
anim.body.frames.Add(AnimKeyframe(0.8, 0,-1, 0))
anim.body.frames.Add(AnimKeyframe(1.0, 0, 0, 0))
anim.back_foot.frames.Add(AnimKeyframe(0.0, 8, 0, 0))
anim.back_foot.frames.Add(AnimKeyframe(0.2, -8, 0, 0))
anim.back_foot.frames.Add(AnimKeyframe(0.4,-10,-4, 0.2))
anim.back_foot.frames.Add(AnimKeyframe(0.6, -8,-8, 0.3))
anim.back_foot.frames.Add(AnimKeyframe(0.8, 4,-4,-0.2))
anim.back_foot.frames.Add(AnimKeyframe(1.0, 8, 0, 0))
anim.front_foot.frames.Add(AnimKeyframe(0.0,-10,-4, 0.2))
anim.front_foot.frames.Add(AnimKeyframe(0.2, -8,-8, 0.3))
anim.front_foot.frames.Add(AnimKeyframe(0.4, 4,-4,-0.2))
anim.front_foot.frames.Add(AnimKeyframe(0.6, 8, 0, 0))
anim.front_foot.frames.Add(AnimKeyframe(0.8, 8, 0, 0))
anim.front_foot.frames.Add(AnimKeyframe(1.0,-10,-4, 0.2))
container.animations.Add(anim)
anim = Animation("hammer_swing")
anim.attach.frames.Add(AnimKeyframe(0.0, 0, 0, -0.10))
anim.attach.frames.Add(AnimKeyframe(0.3, 0, 0, 0.25))
anim.attach.frames.Add(AnimKeyframe(0.4, 0, 0, 0.30))
anim.attach.frames.Add(AnimKeyframe(0.5, 0, 0, 0.25))
anim.attach.frames.Add(AnimKeyframe(1.0, 0, 0, -0.10))
container.animations.Add(anim)
anim = Animation("ninja_swing")
anim.attach.frames.Add(AnimKeyframe(0.00, 0, 0, -0.25))
anim.attach.frames.Add(AnimKeyframe(0.10, 0, 0, -0.05))
anim.attach.frames.Add(AnimKeyframe(0.15, 0, 0, 0.35))
anim.attach.frames.Add(AnimKeyframe(0.42, 0, 0, 0.40))
anim.attach.frames.Add(AnimKeyframe(0.50, 0, 0, 0.35))
anim.attach.frames.Add(AnimKeyframe(1.00, 0, 0, -0.25))
container.animations.Add(anim)
weapon = WeaponSpec(container, "hammer")
weapon.firedelay.Set(125)
weapon.damage.Set(3)
weapon.visual_size.Set(96)
weapon.offsetx.Set(4)
weapon.offsety.Set(-20)
container.weapons.hammer.base.Set(weapon)
container.weapons.id.Add(weapon)
weapon = WeaponSpec(container, "gun")
weapon.firedelay.Set(125)
weapon.damage.Set(1)
weapon.ammoregentime.Set(500)
weapon.visual_size.Set(64)
weapon.offsetx.Set(32)
weapon.offsety.Set(-4)
weapon.muzzleoffsetx.Set(50)
weapon.muzzleoffsety.Set(6)
container.weapons.gun.base.Set(weapon)
container.weapons.id.Add(weapon)
weapon = WeaponSpec(container, "shotgun")
weapon.firedelay.Set(500)
weapon.damage.Set(1)
weapon.visual_size.Set(96)
weapon.offsetx.Set(24)
weapon.offsety.Set(-2)
weapon.muzzleoffsetx.Set(70)
weapon.muzzleoffsety.Set(6)
container.weapons.shotgun.base.Set(weapon)
container.weapons.id.Add(weapon)
weapon = WeaponSpec(container, "grenade")
weapon.firedelay.Set(500) # TODO: fix this
weapon.damage.Set(6)
weapon.visual_size.Set(96)
weapon.offsetx.Set(24)
weapon.offsety.Set(-2)
container.weapons.grenade.base.Set(weapon)
container.weapons.id.Add(weapon)
weapon = WeaponSpec(container, "laser")
weapon.firedelay.Set(800)
weapon.damage.Set(5)
weapon.visual_size.Set(92)
weapon.offsetx.Set(24)
weapon.offsety.Set(-2)
container.weapons.laser.base.Set(weapon)
container.weapons.id.Add(weapon)
weapon = WeaponSpec(container, "ninja")
weapon.firedelay.Set(800)
weapon.damage.Set(9)
weapon.visual_size.Set(96)
weapon.offsetx.Set(0)
weapon.offsety.Set(0)
weapon.muzzleoffsetx.Set(40)
weapon.muzzleoffsety.Set(-4)
container.weapons.ninja.base.Set(weapon)
container.weapons.id.Add(weapon)

398
datasrc/seven/datatypes.py Normal file
View file

@ -0,0 +1,398 @@
import sys
GlobalIdCounter = 0
def GetID():
global GlobalIdCounter
GlobalIdCounter += 1
return GlobalIdCounter
def GetUID():
return "x%d"%GetID()
def FixCasing(Str):
NewStr = ""
NextUpperCase = True
for c in Str:
if NextUpperCase:
NextUpperCase = False
NewStr += c.upper()
else:
if c == "_":
NextUpperCase = True
else:
NewStr += c.lower()
return NewStr
def FormatName(type, name):
if "*" in type:
return "m_p" + FixCasing(name)
if "[]" in type:
return "m_a" + FixCasing(name)
return "m_" + FixCasing(name)
class BaseType:
def __init__(self, type_name):
self._type_name = type_name
self._target_name = "INVALID"
self._id = GetID() # this is used to remember what order the members have in structures etc
def Identifyer(self): return "x"+str(self._id)
def TargetName(self): return self._target_name
def TypeName(self): return self._type_name
def ID(self): return self._id;
def EmitDeclaration(self, name):
return ["%s %s;"%(self.TypeName(), FormatName(self.TypeName(), name))]
def EmitPreDefinition(self, target_name):
self._target_name = target_name
return []
def EmitDefinition(self, name):
return []
class MemberType:
def __init__(self, name, var):
self.name = name
self.var = var
class Struct(BaseType):
def __init__(self, type_name):
BaseType.__init__(self, type_name)
def Members(self):
def sorter(a):
return a.var.ID()
m = []
for name in self.__dict__:
if name[0] == "_":
continue
m += [MemberType(name, self.__dict__[name])]
try:
m.sort(key = sorter)
except:
for v in m:
print(v.name, v.var)
sys.exit(-1)
return m
def EmitTypeDeclaration(self, name):
lines = []
lines += ["struct " + self.TypeName()]
lines += ["{"]
for member in self.Members():
lines += ["\t"+l for l in member.var.EmitDeclaration(member.name)]
lines += ["};"]
return lines
def EmitPreDefinition(self, target_name):
BaseType.EmitPreDefinition(self, target_name)
lines = []
for member in self.Members():
lines += member.var.EmitPreDefinition(target_name+"."+member.name)
return lines
def EmitDefinition(self, name):
lines = ["/* %s */ {" % self.TargetName()]
for member in self.Members():
lines += ["\t" + " ".join(member.var.EmitDefinition("")) + ","]
lines += ["}"]
return lines
class Array(BaseType):
def __init__(self, type):
BaseType.__init__(self, type.TypeName())
self.type = type
self.items = []
def Add(self, instance):
if instance.TypeName() != self.type.TypeName():
error("bah")
self.items += [instance]
def EmitDeclaration(self, name):
return ["int m_Num%s;"%(FixCasing(name)),
"%s *%s;"%(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))
i += 1
if len(self.items):
lines += ["static %s %s[] = {"%(self.TypeName(), self.Identifyer())]
for item in self.items:
itemlines = item.EmitDefinition("")
lines += ["\t" + " ".join(itemlines).replace("\t", " ") + ","]
lines += ["};"]
else:
lines += ["static %s *%s = 0;"%(self.TypeName(), self.Identifyer())]
return lines
def EmitDefinition(self, name):
return [str(len(self.items))+","+self.Identifyer()]
# Basic Types
class Int(BaseType):
def __init__(self, value):
BaseType.__init__(self, "int")
self.value = value
def Set(self, value):
self.value = value
def EmitDefinition(self, name):
return ["%d"%self.value]
#return ["%d /* %s */"%(self.value, self._target_name)]
class Float(BaseType):
def __init__(self, value):
BaseType.__init__(self, "float")
self.value = value
def Set(self, value):
self.value = value
def EmitDefinition(self, name):
return ["%ff"%self.value]
#return ["%d /* %s */"%(self.value, self._target_name)]
class String(BaseType):
def __init__(self, value):
BaseType.__init__(self, "const char*")
self.value = value
def Set(self, value):
self.value = value
def EmitDefinition(self, name):
return ['"'+self.value+'"']
class Pointer(BaseType):
def __init__(self, type, target):
BaseType.__init__(self, "%s*"%type().TypeName())
self.target = target
def Set(self, target):
self.target = target
def EmitDefinition(self, name):
return ["&"+self.target.TargetName()]
class TextureHandle(BaseType):
def __init__(self):
BaseType.__init__(self, "IGraphics::CTextureHandle")
def EmitDefinition(self, name):
return ["IGraphics::CTextureHandle()"]
class SampleHandle(BaseType):
def __init__(self):
BaseType.__init__(self, "ISound::CSampleHandle")
def EmitDefinition(self, name):
return ["ISound::CSampleHandle()"]
# helper functions
def EmitTypeDeclaration(root):
for l in root().EmitTypeDeclaration(""):
print(l)
def EmitDefinition(root, name):
for l in root.EmitPreDefinition(name):
print(l)
print("%s %s = " % (root.TypeName(), name))
for l in root.EmitDefinition(name):
print(l)
print(";")
# Network stuff after this
class Object:
pass
class Enum:
def __init__(self, name, values):
self.name = name
self.values = values
class Flags:
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]
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.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 = ["case %s:" % self.enum_name]
lines += ["{"]
lines += ["\t%s *pObj = (%s *)pData;"%(self.struct_name, self.struct_name)]
lines += ["\tif(sizeof(*pObj) != 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 = "CNetEvent_%s" % self.base
self.struct_name = "CNetEvent_%s" % self.name
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 = "CNetMsg_%s" % self.base
self.struct_name = "CNetMsg_%s" % self.name
self.enum_name = "NETMSGTYPE_%s" % self.name.upper()
def emit_unpack(self):
lines = []
lines += ["case %s:" % self.enum_name]
lines += ["{"]
lines += ["\t%s *pMsg = (%s *)m_aMsgData;" % (self.struct_name, self.struct_name)]
lines += ["\t(void)pMsg;"]
for v in self.variables:
lines += ["\t"+line for line in v.emit_unpack()]
for v in self.variables:
lines += ["\t"+line for line in v.emit_unpack_check()]
lines += ["} break;"]
return lines
def emit_declaration(self):
extra = []
extra += ["\tint MsgID() const { return %s; }" % self.enum_name]
extra += ["\t"]
extra += ["\tbool Pack(CMsgPacker *pPacker)"]
extra += ["\t{"]
#extra += ["\t\tmsg_pack_start(%s, flags);"%self.enum_name]
for v in self.variables:
extra += ["\t\t"+line for line in v.emit_pack()]
extra += ["\t\treturn pPacker->Error() != 0;"]
extra += ["\t}"]
lines = NetObject.emit_declaration(self)
lines = lines[:-1] + extra + lines[-1:]
return lines
class NetVariable:
def __init__(self, name, default=None):
self.name = name
self.default = None if default is None else str(default)
def emit_declaration(self):
return []
def emit_validate(self):
return []
def emit_pack(self):
return []
def emit_unpack(self):
return []
def emit_unpack_check(self):
return []
class NetString(NetVariable):
def emit_declaration(self):
return ["const char *%s;"%self.name]
def emit_unpack(self):
return ["pMsg->%s = pUnpacker->GetString();" % self.name]
def emit_pack(self):
return ["pPacker->AddString(%s, -1);" % self.name]
class NetStringStrict(NetVariable):
def emit_declaration(self):
return ["const char *%s;"%self.name]
def emit_unpack(self):
return ["pMsg->%s = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);" % self.name]
def emit_pack(self):
return ["pPacker->AddString(%s, -1);" % self.name]
class NetIntAny(NetVariable):
def emit_declaration(self):
return ["int %s;"%self.name]
def emit_unpack(self):
if self.default is None:
return ["pMsg->%s = pUnpacker->GetInt();" % self.name]
else:
return ["pMsg->%s = pUnpacker->GetIntOrDefault(%s);" % (self.name, self.default)]
def emit_pack(self):
return ["pPacker->AddInt(%s);" % self.name]
class NetIntRange(NetIntAny):
def __init__(self, name, min, max, default=None):
NetIntAny.__init__(self,name,default=default)
self.min = str(min)
self.max = str(max)
def emit_validate(self):
return ["if(!CheckInt(\"%s\", pObj->%s, %s, %s)) return -1;"%(self.name, self.name, self.min, self.max)]
def emit_unpack_check(self):
return ["if(!CheckInt(\"%s\", pMsg->%s, %s, %s)) break;"%(self.name, self.name, self.min, self.max)]
class NetEnum(NetIntRange):
def __init__(self, name, enum):
NetIntRange.__init__(self, name, 0, len(enum.values)-1)
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])
for i in flag.values[1:]:
self.mask += "|%s_%s" % (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)]
def emit_unpack_check(self):
return ["if(!CheckFlag(\"%s\", pMsg->%s, %s)) break;"%(self.name, self.name, self.mask)]
class NetBool(NetIntRange):
def __init__(self, name, default=None):
default = None if default is None else int(default)
NetIntRange.__init__(self,name,0,1,default=default)
class NetTick(NetIntRange):
def __init__(self, name):
NetIntRange.__init__(self,name,0,'max_int')
class NetArray(NetVariable):
def __init__(self, var, size):
self.base_name = var.name
self.var = var
self.size = size
self.name = self.base_name + "[%d]"%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
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
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
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
lines += self.var.emit_unpack_check()
return lines

478
datasrc/seven/network.py Normal file
View file

@ -0,0 +1,478 @@
from .datatypes import *
Pickups = Enum("PICKUP", ["HEALTH", "ARMOR", "GRENADE", "SHOTGUN", "LASER", "NINJA", "GUN", "HAMMER"])
Emotes = Enum("EMOTE", ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"])
Emoticons = Enum("EMOTICON", ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"])
Votes = Enum("VOTE", ["UNKNOWN", "START_OP", "START_KICK", "START_SPEC", "END_ABORT", "END_PASS", "END_FAIL"]) # todo 0.8: add RUN_OP, RUN_KICK, RUN_SPEC; rem UNKNOWN
ChatModes = Enum("CHAT", ["NONE", "ALL", "TEAM", "WHISPER"])
PlayerFlags = Flags("PLAYERFLAG", ["ADMIN", "CHATTING", "SCOREBOARD", "READY", "DEAD", "WATCHING", "BOT"])
GameFlags = Flags("GAMEFLAG", ["TEAMS", "FLAGS", "SURVIVAL", "RACE"])
GameStateFlags = Flags("GAMESTATEFLAG", ["WARMUP", "SUDDENDEATH", "ROUNDOVER", "GAMEOVER", "PAUSED", "STARTCOUNTDOWN"])
CoreEventFlags = Flags("COREEVENTFLAG", ["GROUND_JUMP", "AIR_JUMP", "HOOK_ATTACH_PLAYER", "HOOK_ATTACH_GROUND", "HOOK_HIT_NOHOOK"])
RaceFlags = Flags("RACEFLAG", ["HIDE_KILLMSG", "FINISHMSG_AS_CHAT", "KEEP_WANTED_WEAPON"])
GameMsgIDs = Enum("GAMEMSG", ["TEAM_SWAP", "SPEC_INVALIDID", "TEAM_SHUFFLE", "TEAM_BALANCE", "CTF_DROP", "CTF_RETURN",
"TEAM_ALL", "TEAM_BALANCE_VICTIM", "CTF_GRAB",
"CTF_CAPTURE",
"GAME_PAUSED"]) # todo 0.8: sort (1 para)
RawHeader = '''
#include <engine/message.h>
enum
{
INPUT_STATE_MASK=0x3f
};
enum
{
TEAM_SPECTATORS=-1,
TEAM_RED,
TEAM_BLUE,
NUM_TEAMS,
FLAG_MISSING=-3,
FLAG_ATSTAND,
FLAG_TAKEN,
SPEC_FREEVIEW=0,
SPEC_PLAYER,
SPEC_FLAGRED,
SPEC_FLAGBLUE,
NUM_SPECMODES,
SKINPART_BODY = 0,
SKINPART_MARKING,
SKINPART_DECORATION,
SKINPART_HANDS,
SKINPART_FEET,
SKINPART_EYES,
NUM_SKINPARTS,
};
'''
RawSource = '''
#include <engine/message.h>
#include "protocol.h"
'''
Enums = [
Pickups,
Emotes,
Emoticons,
Votes,
ChatModes,
GameMsgIDs,
]
Flags = [
PlayerFlags,
GameFlags,
GameStateFlags,
CoreEventFlags,
RaceFlags,
]
Objects = [
NetObject("PlayerInput", [
NetIntRange("m_Direction", -1, 1),
NetIntAny("m_TargetX"),
NetIntAny("m_TargetY"),
NetBool("m_Jump"),
NetIntAny("m_Fire"),
NetBool("m_Hook"),
NetFlag("m_PlayerFlags", PlayerFlags),
NetIntRange("m_WantedWeapon", 0, 'NUM_WEAPONS-1'),
NetIntAny("m_NextWeapon"),
NetIntAny("m_PrevWeapon"),
]),
NetObject("Projectile", [
NetIntAny("m_X"),
NetIntAny("m_Y"),
NetIntAny("m_VelX"),
NetIntAny("m_VelY"),
NetIntRange("m_Type", 0, 'NUM_WEAPONS-1'),
NetTick("m_StartTick"),
]),
NetObject("Laser", [
NetIntAny("m_X"),
NetIntAny("m_Y"),
NetIntAny("m_FromX"),
NetIntAny("m_FromY"),
NetTick("m_StartTick"),
]),
NetObject("Pickup", [
NetIntAny("m_X"),
NetIntAny("m_Y"),
NetEnum("m_Type", Pickups),
]),
NetObject("Flag", [
NetIntAny("m_X"),
NetIntAny("m_Y"),
NetIntRange("m_Team", 'TEAM_RED', 'TEAM_BLUE')
]),
NetObject("GameData", [
NetTick("m_GameStartTick"),
NetFlag("m_GameStateFlags", GameStateFlags),
NetTick("m_GameStateEndTick"),
]),
NetObject("GameDataTeam", [
NetIntAny("m_TeamscoreRed"),
NetIntAny("m_TeamscoreBlue"),
]),
NetObject("GameDataFlag", [
NetIntRange("m_FlagCarrierRed", 'FLAG_MISSING', 'MAX_CLIENTS-1'),
NetIntRange("m_FlagCarrierBlue", 'FLAG_MISSING', 'MAX_CLIENTS-1'),
NetTick("m_FlagDropTickRed"),
NetTick("m_FlagDropTickBlue"),
]),
NetObject("CharacterCore", [
NetTick("m_Tick"),
NetIntAny("m_X"),
NetIntAny("m_Y"),
NetIntAny("m_VelX"),
NetIntAny("m_VelY"),
NetIntAny("m_Angle"),
NetIntRange("m_Direction", -1, 1),
NetIntRange("m_Jumped", 0, 3),
NetIntRange("m_HookedPlayer", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_HookState", -1, 5),
NetTick("m_HookTick"),
NetIntAny("m_HookX"),
NetIntAny("m_HookY"),
NetIntAny("m_HookDx"),
NetIntAny("m_HookDy"),
]),
NetObject("Character:CharacterCore", [
NetIntRange("m_Health", 0, 10),
NetIntRange("m_Armor", 0, 10),
NetIntAny("m_AmmoCount"),
NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'),
NetEnum("m_Emote", Emotes),
NetTick("m_AttackTick"),
NetFlag("m_TriggeredEvents", CoreEventFlags),
]),
NetObject("PlayerInfo", [
NetFlag("m_PlayerFlags", PlayerFlags),
NetIntAny("m_Score"),
NetIntAny("m_Latency"),
]),
NetObject("SpectatorInfo", [
NetIntRange("m_SpecMode", 0, 'NUM_SPECMODES-1'),
NetIntRange("m_SpectatorID", -1, 'MAX_CLIENTS-1'),
NetIntAny("m_X"),
NetIntAny("m_Y"),
]),
## Demo
NetObject("De_ClientInfo", [
NetBool("m_Local"),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetArray(NetIntAny("m_aName"), 4),
NetArray(NetIntAny("m_aClan"), 3),
NetIntAny("m_Country"),
NetArray(NetArray(NetIntAny("m_aaSkinPartNames"), 6), 6),
NetArray(NetBool("m_aUseCustomColors"), 6),
NetArray(NetIntAny("m_aSkinPartColors"), 6),
]),
NetObject("De_GameInfo", [
NetFlag("m_GameFlags", GameFlags),
NetIntRange("m_ScoreLimit", 0, 'max_int'),
NetIntRange("m_TimeLimit", 0, 'max_int'),
NetIntRange("m_MatchNum", 0, 'max_int'),
NetIntRange("m_MatchCurrent", 0, 'max_int'),
]),
NetObject("De_TuneParams", [
# todo: should be done differently
NetArray(NetIntAny("m_aTuneParams"), 32),
]),
## Events
NetEvent("Common", [
NetIntAny("m_X"),
NetIntAny("m_Y"),
]),
NetEvent("Explosion:Common", []),
NetEvent("Spawn:Common", []),
NetEvent("HammerHit:Common", []),
NetEvent("Death:Common", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
]),
NetEvent("SoundWorld:Common", [
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'),
]),
NetEvent("Damage:Common", [ # Unused yet
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetIntAny("m_Angle"),
NetIntRange("m_HealthAmount", 0, 9),
NetIntRange("m_ArmorAmount", 0, 9),
NetBool("m_Self"),
]),
## Race
# todo 0.8: move up
NetObject("PlayerInfoRace", [
NetTick("m_RaceStartTick"),
]),
NetObject("GameDataRace", [
NetIntRange("m_BestTime", -1, 'max_int'),
NetIntRange("m_Precision", 0, 3),
NetFlag("m_RaceFlags", RaceFlags),
]),
]
Messages = [
### Server messages
NetMessage("Sv_Motd", [
NetString("m_pMessage"),
]),
NetMessage("Sv_Broadcast", [
NetString("m_pMessage"),
]),
NetMessage("Sv_Chat", [
NetIntRange("m_Mode", 0, 'NUM_CHATS-1'),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'),
NetIntRange("m_TargetID", -1, 'MAX_CLIENTS-1'),
NetStringStrict("m_pMessage"),
]),
NetMessage("Sv_Team", [
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetBool("m_Silent"),
NetTick("m_CooldownTick"),
]),
NetMessage("Sv_KillMsg", [
NetIntRange("m_Killer", -2, 'MAX_CLIENTS-1'),
NetIntRange("m_Victim", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Weapon", -3, 'NUM_WEAPONS-1'),
NetIntAny("m_ModeSpecial"),
]),
NetMessage("Sv_TuneParams", []),
NetMessage("Sv_ExtraProjectile", []),
NetMessage("Sv_ReadyToEnter", []),
NetMessage("Sv_WeaponPickup", [
NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'),
]),
NetMessage("Sv_Emoticon", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetEnum("m_Emoticon", Emoticons),
]),
NetMessage("Sv_VoteClearOptions", []),
NetMessage("Sv_VoteOptionListAdd", []),
NetMessage("Sv_VoteOptionAdd", [
NetStringStrict("m_pDescription"),
]),
NetMessage("Sv_VoteOptionRemove", [
NetStringStrict("m_pDescription"),
]),
NetMessage("Sv_VoteSet", [
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'),
NetEnum("m_Type", Votes),
NetIntRange("m_Timeout", 0, 60),
NetStringStrict("m_pDescription"),
NetStringStrict("m_pReason"),
]),
NetMessage("Sv_VoteStatus", [
NetIntRange("m_Yes", 0, 'MAX_CLIENTS'),
NetIntRange("m_No", 0, 'MAX_CLIENTS'),
NetIntRange("m_Pass", 0, 'MAX_CLIENTS'),
NetIntRange("m_Total", 0, 'MAX_CLIENTS'),
]),
NetMessage("Sv_ServerSettings", [
NetBool("m_KickVote"),
NetIntRange("m_KickMin", 0, 'MAX_CLIENTS'),
NetBool("m_SpecVote"),
NetBool("m_TeamLock"),
NetBool("m_TeamBalance"),
NetIntRange("m_PlayerSlots", 0, 'MAX_CLIENTS'),
]),
NetMessage("Sv_ClientInfo", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetBool("m_Local"),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetStringStrict("m_pName"),
NetStringStrict("m_pClan"),
NetIntAny("m_Country"),
NetArray(NetStringStrict("m_apSkinPartNames"), 6),
NetArray(NetBool("m_aUseCustomColors"), 6),
NetArray(NetIntAny("m_aSkinPartColors"), 6),
NetBool("m_Silent"),
]),
NetMessage("Sv_GameInfo", [
NetFlag("m_GameFlags", GameFlags),
NetIntRange("m_ScoreLimit", 0, 'max_int'),
NetIntRange("m_TimeLimit", 0, 'max_int'),
NetIntRange("m_MatchNum", 0, 'max_int'),
NetIntRange("m_MatchCurrent", 0, 'max_int'),
]),
NetMessage("Sv_ClientDrop", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetStringStrict("m_pReason"),
NetBool("m_Silent"),
]),
NetMessage("Sv_GameMsg", []),
## Demo messages
NetMessage("De_ClientEnter", [
NetStringStrict("m_pName"),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
]),
NetMessage("De_ClientLeave", [
NetStringStrict("m_pName"),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'),
NetStringStrict("m_pReason"),
]),
### Client messages
NetMessage("Cl_Say", [
NetIntRange("m_Mode", 0, 'NUM_CHATS-1'),
NetIntRange("m_Target", -1, 'MAX_CLIENTS-1'),
NetStringStrict("m_pMessage"),
]),
NetMessage("Cl_SetTeam", [
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
]),
NetMessage("Cl_SetSpectatorMode", [
NetIntRange("m_SpecMode", 0, 'NUM_SPECMODES-1'),
NetIntRange("m_SpectatorID", -1, 'MAX_CLIENTS-1'),
]),
NetMessage("Cl_StartInfo", [
NetStringStrict("m_pName"),
NetStringStrict("m_pClan"),
NetIntAny("m_Country"),
NetArray(NetStringStrict("m_apSkinPartNames"), 6),
NetArray(NetBool("m_aUseCustomColors"), 6),
NetArray(NetIntAny("m_aSkinPartColors"), 6),
]),
NetMessage("Cl_Kill", []),
NetMessage("Cl_ReadyChange", []),
NetMessage("Cl_Emoticon", [
NetEnum("m_Emoticon", Emoticons),
]),
NetMessage("Cl_Vote", [
NetIntRange("m_Vote", -1, 1),
]),
NetMessage("Cl_CallVote", [
NetStringStrict("m_Type"),
NetStringStrict("m_Value"),
NetStringStrict("m_Reason"),
NetBool("m_Force"),
]),
# todo 0.8: move up
NetMessage("Sv_SkinChange", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetArray(NetStringStrict("m_apSkinPartNames"), 6),
NetArray(NetBool("m_aUseCustomColors"), 6),
NetArray(NetIntAny("m_aSkinPartColors"), 6),
]),
NetMessage("Cl_SkinChange", [
NetArray(NetStringStrict("m_apSkinPartNames"), 6),
NetArray(NetBool("m_aUseCustomColors"), 6),
NetArray(NetIntAny("m_aSkinPartColors"), 6),
]),
## Race
NetMessage("Sv_RaceFinish", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Time", -1, 'max_int'),
NetIntAny("m_Diff"),
NetBool("m_RecordPersonal"),
NetBool("m_RecordServer", default=False),
]),
NetMessage("Sv_Checkpoint", [
NetIntAny("m_Diff"),
]),
NetMessage("Sv_CommandInfo", [
NetStringStrict("m_Name"),
NetStringStrict("m_ArgsFormat"),
NetStringStrict("m_HelpText")
]),
NetMessage("Sv_CommandInfoRemove", [
NetStringStrict("m_Name")
]),
NetMessage("Cl_Command", [
NetStringStrict("m_Name"),
NetStringStrict("m_Arguments")
]),
]

View file

@ -9,6 +9,7 @@
#include "kernel.h"
#include "message.h"
#include <game/generated/protocol.h>
#include <game/generated/protocol7.h>
#include <engine/shared/protocol.h>
struct CAntibotRoundData;

View file

@ -664,8 +664,8 @@ static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer, bool Sixup
MsgId += 4;
else if(MsgId >= NETMSG_PING && MsgId <= NETMSG_ERROR)
MsgId += 4;
else if(MsgId > 24)
MsgId -= 24;
else if(MsgId < 0)
MsgId *= -1;
else
{
dbg_msg("net", "DROP send sys %d", MsgId);
@ -680,8 +680,8 @@ static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer, bool Sixup
MsgId += 1;
else if(MsgId >= NETMSGTYPE_SV_TUNEPARAMS && MsgId <= NETMSGTYPE_SV_VOTESTATUS)
;
else if(MsgId > 24)
MsgId -= 24;
else if(MsgId < 0)
MsgId *= -1;
else
{
dbg_msg("net", "DROP send game %d", MsgId);
@ -862,6 +862,8 @@ void CServer::DoSnapshot()
}
// create delta
m_SnapshotDelta.SetStaticsize(protocol7::NETEVENTTYPE_SOUNDWORLD, m_aClients[i].m_Sixup);
m_SnapshotDelta.SetStaticsize(protocol7::NETEVENTTYPE_DAMAGE, m_aClients[i].m_Sixup);
DeltaSize = m_SnapshotDelta.CreateDelta(pDeltashot, pData, aDeltaData);
if(DeltaSize)
@ -1255,7 +1257,7 @@ static inline int MsgFromSixup(int Msg, bool System)
return -1;
}
}
else
/*else
{
if(Msg >= 24 && Msg <= 27)
Msg = NETMSGTYPE_CL_SAY + Msg - 24;
@ -1268,7 +1270,7 @@ static inline int MsgFromSixup(int Msg, bool System)
dbg_msg("net", "DROP recv msg %d", Msg);
return -1;
}
}
}*/
return Msg;
}

View file

@ -114,6 +114,19 @@ int CUnpacker::GetInt()
return i;
}
int CUnpacker::GetIntOrDefault(int Default)
{
if(m_Error)
{
return 0;
}
if(m_pCurrent == m_pEnd)
{
return Default;
}
return GetInt();
}
const char *CUnpacker::GetString(int SanitizeType)
{
if(m_Error)

View file

@ -43,6 +43,7 @@ public:
void Reset(const void *pData, int Size);
int GetInt();
int GetIntOrDefault(int Default);
const char *GetString(int SanitizeType = SANITIZE);
const unsigned char *GetRaw(int Size);
bool Error() const { return m_Error; }

View file

@ -13,6 +13,8 @@ static int ObjTypeToSixup(int Type)
Six = Type;
else if(Type >= NETOBJTYPE_CHARACTERCORE && Type <= NETOBJTYPE_PLAYERINFO)
Six = Type + 1;
else if(Type == NETOBJTYPE_SPECTATORINFO)
Six = Type;
else if(Type >= NETEVENTTYPE_COMMON && Type <= NETEVENTTYPE_DEATH)
Six = Type + 3;
else if(Type == NETEVENTTYPE_SOUNDWORLD)

View file

@ -18,6 +18,9 @@
#include <game/collision.h>
#include <game/gamecore.h>
#include <game/generated/protocol7.h>
#include <game/generated/protocolglue.h>
#include "gamemodes/DDRace.h"
#include "score.h"
#include "score/file_score.h"
@ -1110,8 +1113,7 @@ void CGameContext::OnClientEnter(int ClientID)
Server()->ExpireServerInfo();
// update client infos (others before local)
dbg_msg("debug", "sending info");
// update client infos (others before local)
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(i == ClientID || !m_apPlayers[i] || !Server()->ClientIngame(i))
@ -1120,7 +1122,7 @@ void CGameContext::OnClientEnter(int ClientID)
if(Server()->IsSixup(i))
{
// new info for others
CMsgPacker NewClientInfoMsg(18 + 24); // NETMSGTYPE_SV_CLIENTINFO
CMsgPacker NewClientInfoMsg(-protocol7::NETMSGTYPE_SV_CLIENTINFO); // NETMSGTYPE_SV_CLIENTINFO
NewClientInfoMsg.AddInt(ClientID);
NewClientInfoMsg.AddInt(0); // m_Local
NewClientInfoMsg.AddInt(m_apPlayers[ClientID]->GetTeam());
@ -1138,7 +1140,7 @@ void CGameContext::OnClientEnter(int ClientID)
if(Server()->IsSixup(ClientID))
{
// existing infos for new player
CMsgPacker ClientInfoMsg(18 + 24); // NETMSGTYPE_SV_CLIENTINFO
CMsgPacker ClientInfoMsg(-protocol7::NETMSGTYPE_SV_CLIENTINFO); // NETMSGTYPE_SV_CLIENTINFO
ClientInfoMsg.AddInt(i);
ClientInfoMsg.AddInt(0); // m_Local
ClientInfoMsg.AddInt(m_apPlayers[i]->GetTeam());
@ -1157,8 +1159,7 @@ void CGameContext::OnClientEnter(int ClientID)
// local info
if(Server()->IsSixup(ClientID))
{
dbg_msg("debug", "sending local client");
CMsgPacker SelfClientInfoMsg(18 + 24); // NETMSGTYPE_SV_CLIENTINFO
CMsgPacker SelfClientInfoMsg(-protocol7::NETMSGTYPE_SV_CLIENTINFO); // NETMSGTYPE_SV_CLIENTINFO
SelfClientInfoMsg.AddInt(ClientID);
SelfClientInfoMsg.AddInt(1); // m_Local
SelfClientInfoMsg.AddInt(m_apPlayers[ClientID]->GetTeam());
@ -1313,26 +1314,46 @@ void CGameContext::OnClientDDNetVersionKnown(int ClientID)
}
}
void *CGameContext::SecureUnpackMsg(int *MsgID, CUnpacker *pUnpacker, bool Sixup)
{
if(Sixup)
{
using namespace protocol7;
void *pRawMsg = m_NetObjHandler7.SecureUnpackMsg(*MsgID, pUnpacker);
if(!pRawMsg)
return 0;
static char aRawMsg[1024];
if(*MsgID == NETMSGTYPE_CL_SAY)
{
CNetMsg_Cl_Say *pMsg7 = (CNetMsg_Cl_Say *)pRawMsg;
::CNetMsg_Cl_Say *pMsg = aRawMsg;
pMsg->m_Team = pMsg7->m_Mode == CHAT_TEAM;
pMsg->m_pMessage = pMsg7->m_pMessage;
}
return pRawMsg;
}
else
return m_NetObjHandler.SecureUnpackMsg(*MsgID, pUnpacker);
}
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
{
void *pRawMsg = 0;
CPlayer *pPlayer = m_apPlayers[ClientID];
if(MsgID != NETMSGTYPE_CL_STARTINFO)
if(m_TeeHistorianActive)
{
pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker);
if(!pRawMsg)
return;
if(m_TeeHistorianActive)
if(m_NetObjHandler.TeeHistorianRecordMsg(MsgID))
{
if(m_NetObjHandler.TeeHistorianRecordMsg(MsgID))
{
m_TeeHistorian.RecordPlayerMessage(ClientID, pUnpacker->CompleteData(), pUnpacker->CompleteSize());
}
m_TeeHistorian.RecordPlayerMessage(ClientID, pUnpacker->CompleteData(), pUnpacker->CompleteSize());
}
}
void *pRawMsg = SecureUnpackMsg(&MsgID, pUnpacker, Server()->IsSixup(ClientID));
CPlayer *pPlayer = m_apPlayers[ClientID];
if(Server()->ClientIngame(ClientID))
{
if(MsgID == NETMSGTYPE_CL_SAY)
@ -1949,36 +1970,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
if(pPlayer->m_IsReady)
return;
CNetMsg_Cl_StartInfo Msg;
const char *apSkinPartNames[6];
int aUseCustomColors[6];
int aSkinPartColors[6];
Msg.m_pName = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
Msg.m_pClan = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
Msg.m_Country = pUnpacker->GetInt();
if(Server()->IsSixup(ClientID))
{
for(int p = 0; p < 6; p++) apSkinPartNames[p] = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
for(int p = 0; p < 6; p++) aUseCustomColors[p] = pUnpacker->GetInt();
for(int p = 0; p < 6; p++) aSkinPartColors[p] = pUnpacker->GetInt();
Msg.m_pSkin = "default";
Msg.m_UseCustomColor = 0;
Msg.m_ColorBody = 0;
Msg.m_ColorFeet = 0;
}
else
{
Msg.m_pSkin = pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
Msg.m_UseCustomColor = pUnpacker->GetInt();
Msg.m_ColorBody = pUnpacker->GetInt();
Msg.m_ColorFeet = pUnpacker->GetInt();
}
if(pUnpacker->Error())
return;
CNetMsg_Cl_StartInfo *pMsg = &Msg;
CNetMsg_Cl_StartInfo *pMsg = (CNetMsg_Cl_StartInfo *)pRawMsg;
if(!str_utf8_check(pMsg->m_pName)
|| !str_utf8_check(pMsg->m_pClan)

View file

@ -68,6 +68,7 @@ class CGameContext : public IGameServer
IAntibot *m_pAntibot;
CLayers m_Layers;
CCollision m_Collision;
protocol7::CNetObjHandler m_NetObjHandler7;
CNetObjHandler m_NetObjHandler;
CTuningParams m_Tuning;
CTuningParams m_aTuningList[NUM_TUNEZONES];
@ -225,6 +226,7 @@ public:
virtual void OnSnap(int ClientID);
virtual void OnPostSnap();
void *SecureUnpackMsg(int *MsgID, CUnpacker *pUnpacker, bool Sixup);
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID);
virtual void OnClientConnected(int ClientID);

View file

@ -96,6 +96,11 @@ public:
int m_UseCustomColor;
int m_ColorBody;
int m_ColorFeet;
// 0.7
char m_apSkinPartNames[6][24];
bool m_aUseCustomColors[6];
int m_aSkinPartColors[6];
} m_TeeInfos;
int m_DieTick;