diff --git a/.gitignore b/.gitignore index ea69607..9c8929f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,10 @@ Cargo.lock # keys /keys/ + +# Vim temp files +.*.swp +.*.swo + +# Autogenerated files +/gen/ diff --git a/gen_ids.sh b/gen_ids.sh new file mode 100755 index 0000000..cd26ea5 --- /dev/null +++ b/gen_ids.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +#echo "#[macro_use]"; +#echo "extern crate num_derive;"; + +#echo ""; + +echo "// Autogenerated file, do not edit!" + +echo ""; + +echo "#[repr(u16)]"; +echo "#[derive(FromPrimitive, ToPrimitive)]"; +echo "#[derive(Debug, PartialEq, Eq, Clone, Hash)]"; + +echo "pub enum PacketId {"; + +for f in protobuf/*; do + CMD_ID=`cat $f | grep CMD_ID | cut -d'=' -f2 | tr -d ' ;\015'`; + + if [ "x${CMD_ID}" != "x" ]; then + NAME=`echo $f | cut -d'/' -f2 | cut -d'.' -f1`; + echo " ${NAME} = ${CMD_ID}," + fi +done + +echo "}";