Ejemplo n.º 1
0
	def read(self, raw, offset):
		self.data = dict()

		#char name0[21];
		#char name1[13];
		#int32_t slp_id;
		#int8_t unknown;
		#int8_t unknown;
		#int8_t layer;
		#int16_t player_color;
		#bool replay;
		#int16_t coordinates[4];
		#uint16_t delta_count;
		#int16_t sound_id;
		#bool attack_sound_used;
		#uint16_t frame_count;
		#uint16_t angle_count;
		#float new_speed;
		#float frame_rate;
		#float replay_delay;
		#int8_t sequence_type;
		#int16_t id;
		#int16_t mirroring_mode;
		graphic_header_struct = Struct(endianness + "21s 13s i 3b h ? 4h H h ? 2H 3f b 2h")

		pc = graphic_header_struct.unpack_from(raw, offset)
		offset += graphic_header_struct.size

		self.data["name0"]             = zstr(pc[0])
		self.data["name1"]             = zstr(pc[1])
		self.data["slp_id"]            = pc[2]
		#self.data[""] = pc[3]
		#self.data[""] = pc[4]
		self.data["layer"]             = pc[5]
		self.data["player_color"]      = pc[6]
		self.data["replay"]            = pc[7]
		self.data["coordinates"]       = pc[8:12]
		self.data["delta_count"]       = pc[12]
		self.data["sound_id"]          = pc[13]
		self.data["attack_sound_used"] = pc[14]
		self.data["frame_count"]       = pc[15]
		self.data["angle_count"]       = pc[16]
		self.data["new_speed"]         = pc[17]
		self.data["frame_rate"]        = pc[18]
		self.data["replay_rate"]       = pc[19]
		self.data["sequence_type"]     = pc[20]
		self.data["id"]                = pc[21]
		self.data["mirroring_mode"]    = pc[22]

		return offset
Ejemplo n.º 2
0
	def read(self, raw, offset):
		self.data = dict()

		#int16_t enabled;
		#char name0[13];
		#char name1[13];
		#int32_t ressource_id;
		#int32_t unknown;
		#int32_t unknown;
		#uint8_t color[3];
		#int8_t unknown;
		#int32_t unknown;
		#int32_t unknown;
		terrain_border_struct0 = Struct(endianness + "h 13s 13s 3i 3B b 2i")

		pc = terrain_border_struct0.unpack_from(raw, offset)
		offset += terrain_border_struct0.size

		self.data["enabled"]      = pc[0]
		self.data["name0"]        = zstr(pc[1])
		self.data["name1"]        = zstr(pc[2])
		self.data["ressource_id"] = pc[3]
		#self.data[""] = pc[4]
		#self.data[""] = pc[5]
		self.data["color"]        = pc[6:(6+3)]
		#self.data[""] = pc[9]
		#self.data[""] = pc[10]
		#self.data[""] = pc[11]

		self.data["frame_data"] = list()
		for i in range(230):
			t = FrameData()
			offset = t.read(raw, offset)
			self.data["frame_data"] += [t.data]

		#int16_t frame_count;
		#int16_t unknown;
		#int16_t unknown;
		#int16_t unknown;
		terrain_border_struct1 = Struct(endianness + "4h")

		pc = terrain_border_struct1.unpack_from(raw, offset)
		offset += terrain_border_struct1.size

		self.data["frame_count"] = pc[0]
		#self.data[""] = pc[1]
		#self.data[""] = pc[2]
		#self.data[""] = pc[3]

		return offset
Ejemplo n.º 3
0
	def read(self, raw, offset):
		self.data = dict()

		#int16_t[6] required_techs;
		research0_struct = Struct(endianness + "6h")

		pc = research0_struct.unpack_from(raw, offset)
		offset += research0_struct.size

		self.data["required_techs"] = pc[0]

		self.data["research_ressource_cost"] = list()
		for i in range(3):
			t = ResearchRessourceCost()
			offset = t.read(raw, offset)
			self.data["research_ressource_cost"] += [t.data]


		#int16_t required_tech_count;
		#int16_t civilisation_id;
		#int16_t full_tech_mode;
		#int16_t research_location_id;
		#uint16_t language_dll_name;
		#uint16_t language_dll_description;
		#int16_t research_time;
		#int16_t tech_id;
		#int16_t tech_type;
		#int16_t icon_id;
		#int8_t button_id;
		#int32_t pointers[3];
		#uint16_t name_length;
		research1_struct = Struct(endianness + "4h 2H 4h b 3i H")

		pc = research1_struct.unpack_from(raw, offset)
		offset += research1_struct.size

		self.data["required_tech_count"] = pc[0]
		self.data["civilisation_id"] = pc[1]
		self.data["full_tech_mode"] = pc[2]
		self.data["research_location_id"] = pc[3]
		self.data["language_dll_name"] = pc[4]
		self.data["language_dll_description"] = pc[5]
		self.data["research_time"] = pc[6]
		self.data["tech_id"] = pc[7]
		self.data["tech_type"] = pc[8]
		self.data["icon_id"] = pc[9]
		self.data["button_id"] = pc[10]
		self.data["pointers"] = pc[11:(11+3)]
		self.data["name_length"] = pc[14]

		research_name_struct = Struct(endianness + "%ds" % self.data["name_length"])

		pc = research_name_struct.unpack_from(raw, offset)
		offset += research_name_struct.size

		#char name[name_length];
		self.data["name"] = zstr(pc[0])

		return offset
Ejemplo n.º 4
0
	def read(self, raw, offset):
		self.data = dict()

		#char filename[13];
		#int32_t resource_id;
		#int16_t probability;
		#int16_t civilisation;
		#int16_t unknown;
		sound_item_struct = Struct(endianness + "13s i 3h")

		pc = sound_item_struct.unpack_from(raw, offset)
		offset += sound_item_struct.size

		self.data["filename"]      = zstr(pc[0])
		self.data["resource_id"]   = pc[1]
		self.data["probablilty"]   = pc[2]
		self.data["civilisation"]  = pc[3]
		#self.data[""] = pc[4]

		return offset
Ejemplo n.º 5
0
	def read(self, raw, offset):
		self.data = dict()

		#char name[31];
		#uint16_t effect_count;
		tech_struct = Struct(endianness + "31s H")

		pc = tech_struct.unpack_from(raw, offset)
		offset += tech_struct.size

		self.data["name"]         = zstr(pc[0])
		self.data["effect_count"] = pc[1]

		self.data["effect"] = list()
		for i in range(self.data["effect_count"]):
			t = Effect()
			offset = t.read(raw, offset)
			self.data["effect"] += [t.data]

		return offset
Ejemplo n.º 6
0
	def read(self, raw, offset):
		self.data = dict()


		#int16_t unknown;
		#int16_t unknown;
		#char name0[13];
		#char name1[13];
		#int32_t slp_id;
		#int32_t unknown;
		#int32_t sound_id;
		#int32_t blend_priority;
		#int32_t blend_mode;
		#uint8_t color[3];
		#uint8_t unknown[5];
		#float unknown;
		#int8_t unknown[18];
		#int16_t frame_count;
		#int16_t angle_count;
		#int16_t terrain_id;
		#int16_t elevation_graphic[54];
		#int16_t terrain_replacement_id;
		#int16_t terrain_dimensions0;
		#int16_t terrain_dimensions1;
		#int8_t terrain_border_id[84];
		#int16_t terrain_unit_id[30];
		#int16_t terrain_unit_density[30];
		#int8_t terrain_unit_priority[30];
		#int16_t terrain_units_used_count;
		terrain_struct = Struct(endianness + "2h 13s 13s 5i 3B 5b f 18b 3h 54h 3h 84b 30h 30h 30b h")

		pc = terrain_struct.unpack_from(raw, offset)
		offset += terrain_struct.size

		#self.data[""] = pc[0]
		#self.data[""] = pc[1]
		self.data["name0"]                    = zstr(pc[2])
		self.data["name1"]                    = zstr(pc[3])
		self.data["slp_id"]                   = pc[4]
		#self.data[""] = pc[5]
		self.data["sound_id"]                 = pc[6]
		self.data["blend_priority"]           = pc[7]
		self.data["blend_mode"]               = pc[8]
		self.data["color"]                    = pc[9:(9+3)]
		#self.data[""] = pc[12:(12+5)]
		#self.data[""] = pc[17]
		#self.data[""] = pc[18:(18+18)]

		self.data["frame_count"]              = pc[36]
		self.data["angle_count"]              = pc[37]
		self.data["terrain_id"]               = pc[38]
		self.data["elevation_graphic"]        = pc[39:(39+54)]
		self.data["terrain_replacement_id"]   = pc[93]
		self.data["terrain_dimensions0"]      = pc[94]
		self.data["terrain_dimensions1"]      = pc[95]
		self.data["terrain_border_id"]        = pc[96:(96+84)]
		self.data["terrain_unit_id"]          = pc[180:(180+30)]
		self.data["terrain_unit_density"]     = pc[210:(210+30)]
		self.data["terrain_unit_priority"]    = pc[240:(240+30)]
		self.data["terrain_units_used_count"] = pc[270]

		return offset
Ejemplo n.º 7
0
	def read(self, raw, offset):
		self.data = dict()

		#unit type==:
		#object = 10
		#flag = 20
		#dead_fish = 30
		#bird = 40
		#projectile = 60
		#creatable = 70
		#building = 80
		#tree = 90

		#int8_t type;
		#uint16_t name_length;
		#int16_t id0;
		#uint16_t language_dll_name;
		#uint16_t language_dll_creation;
		#int16_t unit_class;
		#int16_t graphic_standing0;
		#int16_t graphic_standing1;
		#int16_t graphic_dying0;
		#int16_t graphic_dying1;
		#int8_t death_mode;
		#int16_t hit_points;
		#float line_of_sight;
		#int8_t garnison_capacity;
		#float radius_size0;
		#float radius_size1;
		#float hp_bar_height0;
		#int16_t sound_train0;
		#int16_t sound_train1;
		#int16_t dead_unit_id;
		#int8_t placement_mode;
		#int8_t air_mode;
		#int16_t icon_id;
		#int8_t hidden_in_editor;
		#int16_t unknown;
		#int16_t enabled;
		#int16_t placement_by_pass_terrain0;
		#int16_t placement_by_pass_terrain1;
		#int16_t placement_terrain0;
		#int16_t placement_terrain1;
		#float editor_radius0;
		#float editor_radius1;
		#int8_t building_mode;
		#int8_t visible_in_fog;
		#int16_t terrain_restriction;
		#int8_t fly_mode;
		#int16_t ressource_capacity;
		#float ressource_decay;
		#int8_t blast_type;
		#int8_t unknown;
		#int8_t interaction_mode;
		#int8_t minimap_mode;
		#int16_t command_attribute;
		#int16_t unknown;
		#int16_t unknown;
		#uint16_t language_dll_help;
		#int16_t[4] hot_keys;
		#int8_t unknown;
		#int8_t unknown;
		#bool unselectable;
		#int8_t unknown;
		#int8_t unknown;
		#int8_t unknown;
		#int8_t selection_mask;
		#int8_t selection_shape_type;
		#int8_t selection_shape;
		#int8_t attribute;
		#int8_t civilisation;
		#int16_t unknown;
		#int8_t selection_effect;
		#uint8_t editor_selection_color;
		#float selection_radius0;
		#float selection_radius1;
		#float hp_bar_height1;
		unit0_struct = Struct(endianness + "b H h 2H 5h b h f b 3f 3h 2b h b 6h 2f 2b h b h f 4b 3h H 4h 2b ? 8b h b B 3f")

		pc = unit0_struct.unpack_from(raw, offset)
		offset_info(offset, pc, "unit header0", unit0_struct)
		offset += unit0_struct.size


		self.data["type"]                       = pc[0]
		self.data["name_length"]                = pc[1]

		if self.data["name_length"] > 100:
			raise Exception("name is longer than 100, very unlikely: %d" % self.data["name_length"])

		self.data["id0"]                        = pc[2]
		self.data["language_dll_name"]          = pc[3]
		self.data["language_dll_creation"]      = pc[4]
		self.data["unit_class"]                 = pc[5]
		self.data["graphic_standing0"]          = pc[6]
		check_file(pc[6])
		self.data["graphic_standing1"]          = pc[7]
		check_file(pc[7])
		self.data["graphic_dying0"]             = pc[8]
		self.data["graphic_dying1"]             = pc[9]
		self.data["death_mode"]                 = pc[10]
		self.data["hit_points"]                 = pc[11]
		self.data["line_of_sight"]              = pc[12]
		self.data["garnison_capacity"]          = pc[13]
		self.data["radius_size0"]               = pc[14]
		self.data["radius_size1"]               = pc[15]
		self.data["hp_bar_height0"]             = pc[16]
		self.data["sound_train0"]               = pc[17]
		check_file(pc[17])
		self.data["sound_train1"]               = pc[18]
		check_file(pc[18])
		self.data["dead_unit_id"]               = pc[19]
		self.data["placement_mode"]             = pc[20]
		self.data["air_mode"]                   = pc[21]
		self.data["icon_id"]                    = pc[22]
		self.data["hidden_in_editor"]           = pc[23]
		#self.data[""] = pc[24]
		self.data["enabled"]                    = pc[25]
		self.data["placement_by_pass_terrain0"] = pc[26]
		self.data["placement_by_pass_terrain1"] = pc[27]
		self.data["placement_terrain0"]         = pc[28]
		self.data["placement_terrain1"]         = pc[29]
		self.data["editor_radius0"]             = pc[30]
		self.data["editor_radius1"]             = pc[31]
		self.data["building_mode"]              = pc[32]
		self.data["visible_in_fog"]             = pc[33]
		self.data["terrain_restriction"]        = pc[34]
		self.data["fly_mode"]                   = pc[35]
		self.data["ressource_capacity"]         = pc[36]
		self.data["ressource_decay"]            = pc[37]
		self.data["blast_type"]                 = pc[38]
		#self.data[""] = pc[39]
		self.data["interaction_mode"]           = pc[40]
		self.data["minimap_mode"]               = pc[41]
		self.data["command_attribute"]          = pc[42]
		#self.data[""] = pc[43]
		#self.data[""] = pc[44]
		self.data["language_dll_help"]          = pc[45]
		self.data["hot_keys"]                   = pc[46:(46+4)]
		#self.data[""] = pc[50]
		#self.data[""] = pc[51]
		self.data["unselectable"]               = pc[52]
		#self.data[""] = pc[53]
		#self.data[""] = pc[54]
		#self.data[""] = pc[55]
		self.data["selection_mask"]             = pc[56]
		self.data["selection_shape_type"]       = pc[57]
		self.data["selection_shape"]            = pc[58]
		self.data["attribute"]                  = pc[59]
		self.data["civilisation"]               = pc[60]
		#self.data[""] = pc[61]
		self.data["selection_effect"]           = pc[61]
		self.data["editor_selection_color"]     = pc[62]
		self.data["selection_radius0"]          = pc[63]
		self.data["selection_radius1"]          = pc[64]
		self.data["hp_bar_height1"]             = pc[65]


		self.data["ressource_storage"] = list()
		for i in range(3):
			t = RessourceStorage()
			offset = t.read(raw, offset)
			self.data["ressource_storage"] += [t.data]

		#int8_t damage_graphic_count
		unit1_struct = Struct(endianness + "b")

		pc = unit1_struct.unpack_from(raw, offset)
		offset += unit1_struct.size

		self.data["damage_graphic_count"], = pc

		self.data["damage_graphic"] = list()
		for i in range(self.data["damage_graphic_count"]):
			t = DamageGraphic()
			offset = t.read(raw, offset)
			self.data["damage_graphic"] += [t.data]


		#int16_t selection_sound;
		#int16_t dying_sound;
		#int16_t attack_sound;
		#char name[name_length];
		#int16_t id1;
		#int16_t id2;
		unit2_struct = Struct(endianness + "3h %ds 2h" % self.data["name_length"])

		pc = unit2_struct.unpack_from(raw, offset)
		offset_info(offset, pc, "unit header 2", unit2_struct)
		offset += unit2_struct.size


		self.data["sound_selection"] = pc[0]
		check_file(pc[0])
		self.data["sound_dying"]     = pc[1]
		check_file(pc[1])
		self.data["sound_attack"]    = pc[2]
		check_file(pc[2])
		self.data["name"]            = zstr(pc[3])
		self.data["id1"]             = pc[4]
		self.data["id2"]             = pc[5]


		dbg("unit type = %d\nname = %s" % (self.data["type"], self.data["name"]), 2)

		#every thing else only exists for non-trees (!= 90)
		#and things with id >= 20
		if self.data["type"] != 90 and self.data["type"] >= 20:
			#float speed;
			tmp_struct = Struct(endianness + "f")
			pc = tmp_struct.unpack_from(raw, offset)
			offset_info(offset, pc, ">=20 SPEED", tmp_struct)
			offset += tmp_struct.size

			self.data["speed"], = pc

			if math.isnan(self.data["speed"]):
				raise Exception("Speed is NaN!")

			dbg("speed:" + str(pc), 2)


			if self.data["type"] >= 30:
				#int16_t walking_graphics0;
				#int16_t walking_graphics1;
				#float rotation_speed;
				#int8_t unknown;
				#int16_t tracking_unit;
				#bool tracking_unit_used;
				#float tracking_unit_density;
				#float unknown;
				#int8_t unknown[17];
				tmp_struct = Struct(endianness + "2h f b h ? 2f 17b")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=30", tmp_struct)
				offset += tmp_struct.size

				self.data["walking_graphics0"]     = pc[0]
				check_file(pc[0])
				self.data["walking_graphics1"]     = pc[1]
				check_file(pc[1])
				self.data["rotation_speed"]        = pc[2]
				#self.data[""] = pc[2]
				self.data["tracking_unit"]         = pc[3]
				self.data["tracking_unit_used"]    = pc[4]
				self.data["tracking_unit_density"] = pc[5]
				#self.data[""] = pc[6]
				#self.data[""] = pc[7:(7+17)]


			if self.data["type"] >= 40:
				#int16_t sheep_conversion;
				#float search_radius;
				#float work_rate;
				#int16_t drop_site0;
				#int16_t drop_site1;
				#int8_t villager_mode;
				#int16_t move_sound;
				#int16_t stop_sound;
				#int8_t animal_mode;
				tmp_struct = Struct(endianness + "h 2f 2h b 2h b")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=40", tmp_struct)
				offset += tmp_struct.size


				self.data["sheep_conversion"] = pc[0]
				self.data["search_radius"]    = pc[1]
				self.data["work_rate"]        = pc[2]
				self.data["drop_site0"]       = pc[3]
				self.data["drop_site1"]       = pc[4]
				self.data["villager_mode"]    = pc[5]
				self.data["move_sound"]       = pc[6]
				check_file(pc[6])
				self.data["stop_sound"]       = pc[7]
				check_file(pc[7])
				self.data["animal_mode"]      = pc[8]


			if self.data["type"] >= 60:
				#int8_t unknown;
				#int8_t unknown;
				tmp_struct = Struct(endianness + "2b")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=60 header0", tmp_struct)
				offset += tmp_struct.size

				#self.data[""] = pc[0]
				#self.data[""] = pc[1]

				#uint16_t attack_count;
				tmp_struct = Struct(endianness + "H")
				pc = tmp_struct.unpack_from(raw, offset)
				offset += tmp_struct.size

				self.data["attack_count"] = pc[0]

				self.data["attack"] = list()
				for i in range(self.data["attack_count"]):
					t = HitType()
					offset_tmp = t.read(raw, offset)
					self.data["attack"] += [t.data]
					offset = offset_tmp

				#uint16_t armor_count;
				tmp_struct = Struct(endianness + "H")
				pc = tmp_struct.unpack_from(raw, offset)
				offset += tmp_struct.size

				self.data["armor_count"] = pc[0]

				self.data["armor"] = list()
				for i in range(self.data["armor_count"]):
					t = HitType()
					offset_tmp = t.read(raw, offset)
					self.data["armor"] += [t.data]
					offset = offset_tmp

				#int16_t unknown;
				#float max_range;
				#float blast_radius;
				#float reload_time0;
				#int16_t projectile_unit_id;
				#int16_t accuracy_percent;
				#int8_t tower_mode;
				#int16_t delay;
				#float graphics_displacement[3];
				#int8_t unknown;
				#float min_range;
				#float garnison_recovery_rate;
				#int16_t attack_graphic;
				#int16_t melee_armor_displayed;
				#int16_t attack_displayed;
				#int16_t range_displayed;
				#float reload_time1;
				tmp_struct = Struct(endianness + "h 3f 2h b h 3f b 2f 4h xx f")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=60 data", tmp_struct)
				offset += tmp_struct.size - 2


				#self.data[""] = pc[0]
				self.data["max_range"]              = pc[1]
				self.data["blast_radius"]           = pc[2]
				self.data["reload_time0"]           = pc[3]
				self.data["projectile_unit_id"]     = pc[4]
				self.data["accuracy_percent"]       = pc[5]
				self.data["tower_mode"]             = pc[6]
				self.data["delay"]                  = pc[7]
				self.data["graphics_displacement"]  = pc[8:(8+3)]

				#self.data[""] = pc[11]
				self.data["min_range"]              = pc[12]
				self.data["garnison_recovery_rate"] = pc[13]
				self.data["attack_graphic"]         = pc[14]
				self.data["melee_armor_displayed"]  = pc[15]
				self.data["attack_displayed"]       = pc[16]
				self.data["range_displayed"]        = pc[17]
				self.data["reload_time1"]           = pc[18]


			if self.data["type"] == 60:

				#int8_t stretch_mode;
				#int8_t compensation_mode;
				#int8_t drop_animation_mode;
				#int8_t penetration_mode;
				#int8_t unknown;
				#float projectile_arc;
				tmp_struct = Struct(endianness + "5b x x f")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, "==60", tmp_struct)
				offset += tmp_struct.size

				self.data["stretch_mode"]        = pc[0]
				self.data["compensation_mode"]   = pc[1]
				self.data["drop_animation_mode"] = pc[2]
				self.data["penetration_mode"]    = pc[3]
				#self.data[""] = pc[4]
				self.data["projectile_arc"]      = pc[5]


			if self.data["type"] >= 70:
				self.data["ressource_cost"] = list()
				for i in range(3):
					t = RessourceCost()
					offset = t.read(raw, offset)
					self.data["ressource_cost"] += [t.data]

				#int16_t train_time;
				#int16_t train_location_id;
				#int8_t button_id;
				#int32_t unknown;
				#int32_t unknown;
				#int8_t missile_graphic_delay;
				#int8_t hero_mode;
				#int16_t garnison_graphic0;
				#int16_t garnison_graphic1;
				#float attack_missile_duplication0;
				#int8_t attack_missile_duplication1;
				#float attack_missile_duplication_spawning[3];
				#int32_t attack_missile_duplication_unit;
				#int32_t attack_missile_duplication_graphic;
				#int8_t unknown;
				#int16_t pierce_armor_displayed;
				tmp_struct = Struct(endianness + "2h b 2i 2b 2h xx f b 3f 2i b h")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=70", tmp_struct)
				offset += tmp_struct.size


				self.data["train_time"]                          = pc[0]
				self.data["train_location_id"]                   = pc[1]
				self.data["button_id"]                           = pc[2]
				#self.data[""] = pc[3]
				#self.data[""] = pc[4]
				self.data["missile_graphic_delay"]               = pc[5]
				self.data["hero_mode"]                           = pc[6]
				self.data["garnison_graphic0"]                   = pc[7]
				self.data["garnison_graphic1"]                   = pc[8]
				self.data["attack_missile_duplication0"]         = pc[9]
				self.data["attack_missile_duplication1"]         = pc[10]
				self.data["attack_missile_duplication_spawning"] = pc[11:(11+3)]
				self.data["attack_missile_duplication_unit"]     = pc[14]
				self.data["attack_missile_duplication_graphic"]  = pc[15]
				#self.data[""] = pc[16]
				self.data["pierce_armor_displayed"]              = pc[17]

				#raise Exception()


			if self.data["type"] >= 80:
				#int16_t construction_graphic_id;
				#int16_t snow_graphic_id;
				#int16_t adjacent_mode;
				#int8_t unknown;
				#int8_t unknown;
				#int16_t stack_unit_id;
				#int16_t terrain_id;
				#int16_t unknown;
				#int16_t research_id;
				#int8_t unknown;
				tmp_struct = Struct(endianness + "3h 2b 4h b")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=80 header 0", tmp_struct)
				offset += tmp_struct.size

				self.data["construction_graphic_id"] = pc[0]
				check_file(pc[0])
				self.data["snow_graphic_id"]         = pc[1]
				check_file(pc[1])
				self.data["adjacent_mode"]           = pc[2]
				#self.data[""] = pc[3]
				#self.data[""] = pc[4]
				self.data["stack_unit_id"]           = pc[5]
				self.data["terrain_id"]              = pc[6]
				#self.data[""] = pc[7]
				#self.data["research_id"]             = pc[8]
				#self.data[""] = pc[9]

				self.data["building_annex"] = list()
				for i in range(4):
					t = BuildingAnnex()
					offset_tmp = t.read(raw, offset)
					offset = offset_tmp

					self.data["building_annex"] += [t.data]

				#int16_t head_unit;
				#int16_t transform_unit;
				#int16_t unknown;
				#int16_t construction_sound_id;
				#int8_t garnison_type;
				#float garnison_heal_rate;
				#int32_t unknown;
				#int16_t unknown;
				#int8_t unknown[6];
				tmp_struct = Struct(endianness + "4h b f i h 6b")
				pc = tmp_struct.unpack_from(raw, offset)
				offset_info(offset, pc, ">=80 header 1", tmp_struct)
				offset += tmp_struct.size

				self.data["head_unit"] = pc[0]
				self.data["transform_unit"] = pc[1]
				#self.data[""] = pc[2]
				self.data["construction_sound_id"] = pc[3]
				check_file(pc[3])
				self.data["garnison_type"] = pc[4]
				self.data["garnison_heal_rate"] = pc[5]
				#self.data[""] = pc[6]
				#self.data[""] = pc[7]
				#self.data[""] = pc[8:(8+6)]

		return offset
Ejemplo n.º 8
0
    def read(self, raw, offset):
        self.data = dict()

        # int8_t one;
        # char name[20];
        # uint16_t ressources_count;
        # int16_t tech_tree_id;
        # int16_t team_bonus_id;
        civ_header0_struct = Struct(endianness + "b 20s H 2h")

        pc = civ_header0_struct.unpack_from(raw, offset)
        offset += civ_header0_struct.size

        self.data["one"] = pc[0]
        self.data["name"] = zstr(pc[1])
        self.data["ressource_count"] = pc[2]
        self.data["tech_tree_id"] = pc[3]
        self.data["team_bonus_id"] = pc[4]

        # float[ressources_count] ressources;
        civ_ressources_struct = Struct(endianness + "%df" % self.data["ressource_count"])

        pc = civ_ressources_struct.unpack_from(raw, offset)
        offset += civ_ressources_struct.size

        self.data["ressources"] = pc

        # int8_t graphic_set;
        # uint16_t unit_count;
        civ_header1_struct = Struct(endianness + "b H")

        pc = civ_header1_struct.unpack_from(raw, offset)
        offset += civ_header1_struct.size

        self.data["graphic_set"] = pc[0]
        self.data["unit_count"] = pc[1]

        # int32_t unit_offsets[unit_count];
        civ_header2_struct = Struct(endianness + "%di" % self.data["unit_count"])
        pc = civ_header2_struct.unpack_from(raw, offset)
        offset += civ_header2_struct.size

        self.data["unit_offsets"] = pc

        self.data["unit"] = list()
        dbg("unit count = %d" % self.data["unit_count"], 2)
        for i in range(self.data["unit_count"]):
            dbg("%%%%%%%%%%%%%%%%%%%%%%%%%%%% UNIT entry %d" % i, 2)

            uo = self.data["unit_offsets"][i]
            dbg("unit offset = %d" % uo, 3)
            if uo == 0:
                dbg("skipping UNIT entry %d" % i, 2)
                continue

            from gamedata import unit

            t = unit.Unit()
            offset = t.read(raw, offset)
            self.data["unit"] += [t.data]

        return offset
Ejemplo n.º 9
0
    def read(self, raw, offset):

        # char versionstr[8];
        header_struct = Struct(endianness + "8s")
        header = header_struct.unpack_from(raw, offset)
        offset += header_struct.size

        self.data["version"] = zstr(header[0])

        dbg("dat version: %s" % (self.data["version"]), 1)

        from gamedata import terrain

        t = terrain.TerrainHeaderData()
        offset = t.read(raw, offset)
        self.data["terrain"] = t.data

        from gamedata import playercolor

        t = playercolor.PlayerColorData()
        offset = t.read(raw, offset)
        self.data["color"] = t.data

        from gamedata import sound

        t = sound.SoundData()
        offset = t.read(raw, offset)
        self.data["sound"] = t.data

        from gamedata import graphic

        t = graphic.GraphicData()
        offset = t.read(raw, offset)
        self.data["graphic"] = t.data

        from gamedata import terrain

        t = terrain.TerrainData(self.data["terrain"]["terrain_count"])
        offset = t.read(raw, offset)
        self.data["terrain"].update(t.data)

        tmp_struct = Struct(endianness + "438c")
        offset += tmp_struct.size

        from gamedata import terrain

        t = terrain.TerrainBorderData()
        offset = t.read(raw, offset)
        self.data["terrain"].update(t.data)

        from gamedata import tech

        t = tech.TechData()
        offset = t.read(raw, offset)
        self.data["tech"] = t.data

        from gamedata import unit

        t = unit.UnitHeaderData()
        offset = t.read(raw, offset)
        self.data["unit"] = t.data

        from gamedata import civ

        t = civ.CivData()
        offset = t.read(raw, offset)
        self.data["civ"] = t.data

        from gamedata import research

        t = research.ResearchData()
        offset = t.read(raw, offset)
        self.data["research"] = t.data

        tmp_struct = Struct(endianness + "7i")
        offset += tmp_struct.size

        from gamedata import tech

        t = tech.TechtreeData()
        offset = t.read(raw, offset)
        self.data["tech"] = t.data

        # self.data = dict()
        # import pprint
        # pprint.pprint(t.data)

        return offset