about summary refs log tree commit diff
path: root/datasrc
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-07-08 09:07:21 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-07-08 09:07:21 +0000
commita13b94f9e0bca8ea892311d9d9e0c0bc48616ea7 (patch)
treec74b01682d62d8a5e13948a828307f263de36ac6 /datasrc
parent9d632dd826c8a312095de0f56df66b2580d336cb (diff)
downloadzcatch-a13b94f9e0bca8ea892311d9d9e0c0bc48616ea7.tar.gz
zcatch-a13b94f9e0bca8ea892311d9d9e0c0bc48616ea7.zip
minor update
Diffstat (limited to 'datasrc')
-rw-r--r--datasrc/compile.py16
-rw-r--r--datasrc/network.py12
2 files changed, 25 insertions, 3 deletions
diff --git a/datasrc/compile.py b/datasrc/compile.py
index af0671de..30734a21 100644
--- a/datasrc/compile.py
+++ b/datasrc/compile.py
@@ -66,6 +66,8 @@ if gen_client_content_source or gen_server_content_source:
 # NETWORK
 if gen_network_header:
 	
+	print "#ifndef FILE_G_PROTOCOL_H"
+	print "#define FILE_G_PROTOCOL_H"
 	print network.RawHeader
 	
 	for e in network.Enums:
@@ -87,11 +89,13 @@ if gen_network_header:
 
 	print "int netobj_validate(int type, void *data, int size);"
 	print "const char *netobj_get_name(int type);"
+	print "int netobj_get_size(int type);"
 	print "void *netmsg_secure_unpack(int type);"
 	print "const char *netmsg_get_name(int type);"
 	print "const char *netmsg_failed_on();"
 	print "int netobj_num_corrections();"
 	print "const char *netobj_corrected_on();"
+	print "#endif // FILE_G_PROTOCOL_H"
 	
 
 if gen_network_source:
@@ -117,9 +121,14 @@ if gen_network_source:
 	lines += ['}']
 
 	lines += ["static const char *netobj_names[] = {"]
+	lines += ['\t"invalid",']
 	lines += ['\t"%s",' % o.name for o in network.Objects]
 	lines += ['\t""', "};", ""]
 
+	lines += ["static int netobj_sizes[] = {"]
+	lines += ['\t0,']
+	lines += ['\tsizeof(%s),' % o.struct_name for o in network.Objects]
+	lines += ['\t0', "};", ""]
 	for l in lines:
 		print l
 
@@ -150,6 +159,13 @@ if gen_network_source:
 	lines += ['};']
 	lines += ['']
 
+	lines += ['int netobj_get_size(int type)']
+	lines += ['{']
+	lines += ['\tif(type < 0 || type >= NUM_NETOBJTYPES) return 0;']
+	lines += ['\treturn netobj_sizes[type];']
+	lines += ['};']
+	lines += ['']
+	
 	for item in network.Messages:
 		for line in item.emit_unpack():
 			print line
diff --git a/datasrc/network.py b/datasrc/network.py
index 46add62b..4c49f149 100644
--- a/datasrc/network.py
+++ b/datasrc/network.py
@@ -99,7 +99,7 @@ Objects = [
 		NetIntAny("teamscore_blue"),
 	]),
 
-	NetObject("Player_Core", [
+	NetObject("Character_Core", [
 		NetIntAny("x"),
 		NetIntAny("y"),
 		NetIntAny("vx"),
@@ -118,7 +118,7 @@ Objects = [
 		NetIntAny("hook_dy"),
 	]),
 
-	NetObject("Player_Character:Player_Core", [
+	NetObject("Character:Character_Core", [
 		NetIntRange("player_state", 0, 'NUM_PLAYERSTATES-1'),
 		NetIntRange("wanted_direction", -1, 1),
 		NetIntRange("health", 0, 10),
@@ -238,7 +238,13 @@ Messages = [
 		NetIntAny("color_feet"),
 	]),	
 
-	NetMessage("cl_changeinfo:cl_startinfo", []),
+	NetMessage("cl_changeinfo", [
+		NetString("name"),
+		NetString("skin"),
+		NetBool("use_custom_color"),
+		NetIntAny("color_body"),
+		NetIntAny("color_feet"),
+	]),
 	
 	NetMessage("cl_kill", []),