2010-04-18 14:18:53 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# Generate the table of offsets for different action pointers
|
|
|
|
# in the different Heretic versions.
|
|
|
|
#
|
|
|
|
|
|
|
|
require "common.rb"
|
|
|
|
|
|
|
|
def action_func_names
|
|
|
|
names = {}
|
|
|
|
|
|
|
|
for config in CONFIGS
|
|
|
|
config::ACTION_POINTERS.each_value do |name|
|
|
|
|
names[name] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
names.keys
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_func_offset(config, name)
|
|
|
|
config::ACTION_POINTERS.each_pair do |offset, funcname|
|
|
|
|
if name == funcname
|
|
|
|
return offset
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
0
|
|
|
|
end
|
|
|
|
|
|
|
|
def func_offsets(name)
|
|
|
|
CONFIGS.map do |config|
|
|
|
|
get_func_offset(config, name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def format_func_offsets(offsets)
|
|
|
|
formatted = offsets.map do |offset|
|
2010-04-18 14:20:41 +00:00
|
|
|
sprintf("%6i", offset)
|
2010-04-18 14:18:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
"{ " + formatted.join(", ") + " }"
|
|
|
|
end
|
|
|
|
|
2010-04-18 18:31:40 +00:00
|
|
|
puts "static hhe_action_pointer_t action_pointers[] ="
|
|
|
|
puts "{"
|
2010-04-18 14:18:53 +00:00
|
|
|
|
|
|
|
for name in action_func_names.sort
|
|
|
|
offsets = func_offsets(name)
|
|
|
|
print " { "
|
|
|
|
print format_func_offsets(offsets) + ", "
|
2010-04-18 14:52:14 +00:00
|
|
|
print name
|
2010-04-18 14:18:53 +00:00
|
|
|
print " },\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "};"
|
|
|
|
puts
|
|
|
|
|