Regenerate input timing with correct order
also remove the boolean placeholder if there is no bool field
This commit is contained in:
parent
6089fe9c7b
commit
3ab4fc61d1
|
@ -7,7 +7,7 @@ require_relative '../packer'
|
|||
#
|
||||
# Server -> Client
|
||||
class InputTiming
|
||||
attr_accessor :time_left, :intended_tick
|
||||
attr_accessor :intended_tick, :time_left
|
||||
|
||||
def initialize(hash_or_raw)
|
||||
if hash_or_raw.instance_of?(Hash)
|
||||
|
@ -19,27 +19,27 @@ class InputTiming
|
|||
|
||||
def init_raw(data)
|
||||
u = Unpacker.new(data)
|
||||
@time_left = u.get_int
|
||||
@intended_tick = u.get_int
|
||||
@time_left = u.get_int
|
||||
end
|
||||
|
||||
def init_hash(attr)
|
||||
@time_left = attr[:time_left] || 0
|
||||
@intended_tick = attr[:intended_tick] || 0
|
||||
@time_left = attr[:time_left] || 0
|
||||
end
|
||||
|
||||
def to_h
|
||||
{
|
||||
time_left: @time_left,
|
||||
intended_tick: @intended_tick
|
||||
intended_tick: @intended_tick,
|
||||
time_left: @time_left
|
||||
}
|
||||
end
|
||||
|
||||
# basically to_network
|
||||
# int array the Server sends to the Client
|
||||
def to_a
|
||||
Packer.pack_int(@time_left) +
|
||||
Packer.pack_int(@intended_tick)
|
||||
Packer.pack_int(@intended_tick) +
|
||||
Packer.pack_int(@time_left)
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -81,7 +81,7 @@ function _edit_line_in_file() {
|
|||
fi
|
||||
{
|
||||
head -n "$from_ln" "$filename"
|
||||
echo -e "$replace_str"
|
||||
echo -ne "$replace_str"
|
||||
tail -n +"$to_ln" "$filename"
|
||||
} > "$filename".tmp
|
||||
mv "$filename".tmp "$filename"
|
||||
|
@ -343,7 +343,7 @@ function action_generate() {
|
|||
accessors+=", :$field_name"
|
||||
done < <(echo "${fields[@]}" | tr ' ' '\n')
|
||||
IFS=$'\n'
|
||||
replace_line "$tmpfile" attr_accessor " attr_accessor${accessors:1}"
|
||||
replace_line "$tmpfile" attr_accessor " attr_accessor${accessors:1}\n"
|
||||
|
||||
local unpacks=''
|
||||
while IFS=':' read -r field_name field_type
|
||||
|
@ -356,7 +356,7 @@ function action_generate() {
|
|||
fi
|
||||
done < <(echo "${fields[@]}" | tr ' ' '\n')
|
||||
IFS=$'\n'
|
||||
replace_line "$tmpfile" Unpacker.new " u = Unpacker.new(data)$unpacks"
|
||||
replace_line "$tmpfile" Unpacker.new " u = Unpacker.new(data)$unpacks\n"
|
||||
|
||||
local hashs=''
|
||||
while IFS=':' read -r field_name field_type
|
||||
|
@ -378,7 +378,7 @@ function action_generate() {
|
|||
fi
|
||||
done < <(echo "${fields[@]}" | tr ' ' '\n')
|
||||
IFS=$'\n'
|
||||
replace_line "$tmpfile" "@foo = attr[:foo] || 0" "${hashs:2}"
|
||||
replace_line "$tmpfile" "@foo = attr[:foo] || 0" "${hashs:2}\n"
|
||||
|
||||
hashs=' {'
|
||||
while IFS=':' read -r field_name field_type
|
||||
|
@ -388,7 +388,7 @@ function action_generate() {
|
|||
IFS=$'\n'
|
||||
hashs="${hashs::-1}"
|
||||
hashs+="\n }"
|
||||
replace_line "$tmpfile" "{ foo: @foo," "${hashs:2}"
|
||||
replace_line "$tmpfile" "{ foo: @foo," "${hashs:2}\n"
|
||||
|
||||
local packs=''
|
||||
while IFS=':' read -r field_name field_type
|
||||
|
@ -405,7 +405,7 @@ function action_generate() {
|
|||
fi
|
||||
done < <(echo "${fields[@]}" | tr ' ' '\n')
|
||||
IFS=$'\n'
|
||||
replace_line "$tmpfile" Packer.pack_int "${packs:2:-4}"
|
||||
replace_line "$tmpfile" Packer.pack_int "${packs:2:-4}\n"
|
||||
|
||||
local bools=''
|
||||
while IFS=':' read -r field_name field_type
|
||||
|
@ -419,7 +419,12 @@ function action_generate() {
|
|||
done < <(echo "${fields[@]}" | tr ' ' '\n')
|
||||
IFS=$'\n'
|
||||
|
||||
replace_lines_from "$tmpfile" 'def foo?' "${bools::-2}" 3
|
||||
if [ "$bools" == "" ]
|
||||
then
|
||||
replace_lines_from "$tmpfile" 'def foo?' '' 3
|
||||
else
|
||||
replace_lines_from "$tmpfile" 'def foo?' "${bools::-2}\n" 3
|
||||
fi
|
||||
|
||||
local destfile
|
||||
destfile="lib/models/$(basename "$tmpfile")"
|
||||
|
|
Loading…
Reference in a new issue