#!/usr/bin/env python """ heroes renaissance copyright 2008 - Johannes 'josch' Schauer This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import gzip import struct import pyglet def extract(filename): h3m_data = gzip.open(filename) map_data = {} #read general info (map_data["version"], ) = struct.unpack(" 0: map_data[color]["heroes"] = {} for i in range(map_data[color]["heroes_count"]): (map_data[color]["heroes"]["portrait"], ) = struct.unpack(" 0: map_data["commands"] = struct.unpack("<8B", h3m_data.read(8)) #Free Heroes h3m_data.read(20) #free heroes h3m_data.read(4) #junk (map_data["heroes_count"], ) = struct.unpack(" 0: map_data["free_heroes"] = [] for i in range(map_data["heroes_count"]): (hero_id, ) = struct.unpack(" 0: map_data["rumors"] = [] for i in range(map_data["rumor_count"]): (name_length, ) = struct.unpack("> x) & 1]) h3m_data.read(6) #actions h3m_data.read(2) #landscape h3m_data.read(2) #land_edit_groups (obj_class, ) = struct.unpack(" 0: for i in range(knapsack_count): (knapsackID, ) = struct.unpack(" 0: for i in range(eventQuantity): (length, ) = struct.unpack(" 0: for i in range(secSkills): (skill_id, skill_lvl) = struct.unpack(" 0: for i in range(artefacts): (artID, ) = struct.unpack(" 0: for i in range(spells): (spellID, ) = struct.unpack(" 0: for i in range(monsters): (guard_id, guard_count) = struct.unpack(" 0: for i in range(secSkills): (skill_id, skill_lvl) = struct.unpack(" 0: for i in range(artefacts): (artID, ) = struct.unpack(" 0: for i in range(spells): (spellID, ) = struct.unpack(" 0: for i in range(monsters): (guard_id, guard_count) = struct.unpack("