Skip to content

Instantly share code, notes, and snippets.

@apathyboy
Created February 4, 2014 02:04
Show Gist options
  • Select an option

  • Save apathyboy/8796240 to your computer and use it in GitHub Desktop.

Select an option

Save apathyboy/8796240 to your computer and use it in GitHub Desktop.
Reading shared_armor_bone_s01_bicep_l.iff
FORM - STOT - children: 3
FORM - DERV - children: 1
XXXX - chunk size: 55
0000: 6f 62 6a 65 63 74 2f 74 61 6e 67 69 62 6c 65 2f object/tangible/
0010: 77 65 61 72 61 62 6c 65 73 2f 62 61 73 65 2f 73 wearables/base/s
0020: 68 61 72 65 64 5f 62 61 73 65 5f 62 69 63 65 70 hared_base_bicep
0030: 5f 6c 2e 69 66 66 00 _l.iff.
FORM - 0007 - children: 8
PCNT - chunk size: 4
0000: 07 00 00 00 ....
XXXX - chunk size: 40
0000: 70 61 6c 65 74 74 65 43 6f 6c 6f 72 43 75 73 74 paletteColorCust
0010: 6f 6d 69 7a 61 74 69 6f 6e 56 61 72 69 61 62 6c omizationVariabl
0020: 65 73 00 01 00 00 00 00 es......
XXXX - chunk size: 37
0000: 72 61 6e 67 65 64 49 6e 74 43 75 73 74 6f 6d 69 rangedIntCustomi
0010: 7a 61 74 69 6f 6e 56 61 72 69 61 62 6c 65 73 00 zationVariables.
0020: 01 00 00 00 00 .....
XXXX - chunk size: 39
0000: 63 6f 6e 73 74 53 74 72 69 6e 67 43 75 73 74 6f constStringCusto
0010: 6d 69 7a 61 74 69 6f 6e 56 61 72 69 61 62 6c 65 mizationVariable
0020: 73 00 01 00 00 00 00 s......
XXXX - chunk size: 24
0000: 73 6f 63 6b 65 74 44 65 73 74 69 6e 61 74 69 6f socketDestinatio
0010: 6e 73 00 01 00 00 00 00 ns......
XXXX - chunk size: 28
0000: 73 74 72 75 63 74 75 72 65 46 6f 6f 74 70 72 69 structureFootpri
0010: 6e 74 46 69 6c 65 4e 61 6d 65 00 00 ntFileName..
XXXX - chunk size: 30
0000: 75 73 65 53 74 72 75 63 74 75 72 65 46 6f 6f 74 useStructureFoot
0010: 70 72 69 6e 74 4f 75 74 6c 69 6e 65 00 00 printOutline..
XXXX - chunk size: 12
0000: 74 61 72 67 65 74 61 62 6c 65 00 00 targetable..
FORM - SHOT - children: 2
FORM - DERV - children: 1
XXXX - chunk size: 55
0000: 6f 62 6a 65 63 74 2f 74 61 6e 67 69 62 6c 65 2f object/tangible/
0010: 77 65 61 72 61 62 6c 65 73 2f 62 61 73 65 2f 73 wearables/base/s
0020: 68 61 72 65 64 5f 62 61 73 65 5f 62 69 63 65 70 hared_base_bicep
0030: 5f 6c 2e 69 66 66 00 _l.iff.
FORM - 0007 - children: 27
PCNT - chunk size: 4
0000: 1a 00 00 00 ....
XXXX - chunk size: 52
0000: 6f 62 6a 65 63 74 4e 61 6d 65 00 01 01 77 65 61 objectName...wea
0010: 72 61 62 6c 65 73 5f 6e 61 6d 65 00 01 61 72 6d rables_name..arm
0020: 6f 72 5f 62 6f 6e 65 5f 73 30 31 5f 62 69 63 65 or_bone_s01_bice
0030: 70 5f 6c 00 p_l.
XXXX - chunk size: 63
0000: 64 65 74 61 69 6c 65 64 44 65 73 63 72 69 70 74 detailedDescript
0010: 69 6f 6e 00 01 01 77 65 61 72 61 62 6c 65 73 5f ion...wearables_
0020: 64 65 74 61 69 6c 00 01 61 72 6d 6f 72 5f 62 6f detail..armor_bo
0030: 6e 65 5f 73 30 31 5f 62 69 63 65 70 5f 6c 00 ne_s01_bicep_l.
XXXX - chunk size: 54
0000: 6c 6f 6f 6b 41 74 54 65 78 74 00 01 01 77 65 61 lookAtText...wea
0010: 72 61 62 6c 65 73 5f 6c 6f 6f 6b 61 74 00 01 61 rables_lookat..a
0020: 72 6d 6f 72 5f 62 6f 6e 65 5f 73 30 31 5f 62 69 rmor_bone_s01_bi
0030: 63 65 70 5f 6c 00 cep_l.
XXXX - chunk size: 15
0000: 73 6e 61 70 54 6f 54 65 72 72 61 69 6e 00 00 snapToTerrain..
XXXX - chunk size: 16
0000: 63 6f 6e 74 61 69 6e 65 72 54 79 70 65 00 00 20 containerType..
0010:
XXXX - chunk size: 23
0000: 63 6f 6e 74 61 69 6e 65 72 56 6f 6c 75 6d 65 4c containerVolumeL
0010: 69 6d 69 74 00 00 20 imit..
XXXX - chunk size: 13
0000: 74 69 6e 74 50 61 6c 65 74 74 65 00 00 tintPalette..
XXXX - chunk size: 24
0000: 73 6c 6f 74 44 65 73 63 72 69 70 74 6f 72 46 69 slotDescriptorFi
0010: 6c 65 6e 61 6d 65 00 00 lename..
XXXX - chunk size: 31
0000: 61 72 72 61 6e 67 65 6d 65 6e 74 44 65 73 63 72 arrangementDescr
0010: 69 70 74 6f 72 46 69 6c 65 6e 61 6d 65 00 00 iptorFilename..
XXXX - chunk size: 60
0000: 61 70 70 65 61 72 61 6e 63 65 46 69 6c 65 6e 61 appearanceFilena
0010: 6d 65 00 01 61 70 70 65 61 72 61 6e 63 65 2f 61 me..appearance/a
0020: 72 6d 6f 72 5f 62 6f 6e 65 5f 73 30 31 5f 62 69 rmor_bone_s01_bi
0030: 63 65 70 5f 6c 5f 66 2e 73 61 74 00 cep_l_f.sat.
XXXX - chunk size: 22
0000: 70 6f 72 74 61 6c 4c 61 79 6f 75 74 46 69 6c 65 portalLayoutFile
0010: 6e 61 6d 65 00 00 name..
XXXX - chunk size: 16
0000: 63 6c 69 65 6e 74 44 61 74 61 46 69 6c 65 00 00 clientDataFile..
0010:
XXXX - chunk size: 25
0000: 63 6f 6c 6c 69 73 69 6f 6e 4d 61 74 65 72 69 61 collisionMateria
0010: 6c 46 6c 61 67 73 00 00 20 lFlags..
XXXX - chunk size: 29
0000: 63 6f 6c 6c 69 73 69 6f 6e 4d 61 74 65 72 69 61 collisionMateria
0010: 6c 50 61 73 73 46 6c 61 67 73 00 00 20 lPassFlags..
XXXX - chunk size: 30
0000: 63 6f 6c 6c 69 73 69 6f 6e 4d 61 74 65 72 69 61 collisionMateria
0010: 6c 42 6c 6f 63 6b 46 6c 61 67 73 00 00 20 lBlockFlags..
XXXX - chunk size: 23
0000: 63 6f 6c 6c 69 73 69 6f 6e 41 63 74 69 6f 6e 46 collisionActionF
0010: 6c 61 67 73 00 00 20 lags..
XXXX - chunk size: 27
0000: 63 6f 6c 6c 69 73 69 6f 6e 41 63 74 69 6f 6e 50 collisionActionP
0010: 61 73 73 46 6c 61 67 73 00 00 20 assFlags..
XXXX - chunk size: 28
0000: 63 6f 6c 6c 69 73 69 6f 6e 41 63 74 69 6f 6e 42 collisionActionB
0010: 6c 6f 63 6b 46 6c 61 67 73 00 00 20 lockFlags..
XXXX - chunk size: 8
0000: 73 63 61 6c 65 00 00 20 scale..
XXXX - chunk size: 21
0000: 67 61 6d 65 4f 62 6a 65 63 74 54 79 70 65 00 01 gameObjectType..
0010: 20 05 01 00 00 ....
XXXX - chunk size: 14
0000: 73 65 6e 64 54 6f 43 6c 69 65 6e 74 00 00 sendToClient..
XXXX - chunk size: 33
0000: 73 63 61 6c 65 54 68 72 65 73 68 6f 6c 64 42 65 scaleThresholdBe
0010: 66 6f 72 65 45 78 74 65 6e 74 54 65 73 74 00 00 foreExtentTest..
0020: 20
XXXX - chunk size: 19
0000: 63 6c 65 61 72 46 6c 6f 72 61 52 61 64 69 75 73 clearFloraRadius
0010: 00 00 20 ..
XXXX - chunk size: 14
0000: 73 75 72 66 61 63 65 54 79 70 65 00 00 20 surfaceType..
XXXX - chunk size: 16
0000: 6e 6f 42 75 69 6c 64 52 61 64 69 75 73 00 00 20 noBuildRadius..
0010:
XXXX - chunk size: 20
0000: 6f 6e 6c 79 56 69 73 69 62 6c 65 49 6e 54 6f 6f onlyVisibleInToo
0010: 6c 73 00 00 ls..
Duration: 4ms
// This file is part of SWGANH which is released under the MIT license.
// See file LICENSE or go to http://swganh.com/LICENSE
#include <chrono>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <string>
#include "iff.hpp"
swganh::ByteBuffer read_iff(std::string iff_filename);
void print_iff_nodes(swganh::tre::iff_node* head, int depth = 0);
int main(int argc, char *argv[])
{
if (argc != 2)
{
std::cout << "Usage: " << argv[0] << " <path to terrain file>" << std::endl;
exit(0);
}
auto start_time = std::chrono::high_resolution_clock::now();
std::cout << "Reading " << argv[1] << std::endl;
swganh::ByteBuffer data = read_iff(argv[1]);
auto iff_head = swganh::tre::parse_iff(data);
if (iff_head)
{
print_iff_nodes(iff_head.get());
}
auto stop_time = std::chrono::high_resolution_clock::now();
std::cout << "Duration: " <<
std::chrono::duration_cast<std::chrono::milliseconds>
(stop_time - start_time).count() << "ms" << std::endl;
return 0;
}
swganh::ByteBuffer read_iff(std::string iff_filename)
{
std::ifstream in(iff_filename, std::ios::in | std::ios::binary);
if (!in.is_open())
{
std::cout << "Invalid filename given: " << iff_filename << std::endl;
throw std::runtime_error("Invalid file");
}
std::vector<char> tmp { std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>() };
in.close();
return swganh::ByteBuffer(reinterpret_cast<unsigned char*>(tmp.data()), tmp.size());
}
void print_iff_nodes(swganh::tre::iff_node* head, int depth)
{
for (int i = 0; i < depth; ++i)
{
std::cout << std::string(" ");
}
std::cout << head->str_name();
if (head->form_type)
{
std::cout << std::string(" - ") << head->str_form_type();
std::cout << std::string(" - children: ") << head->children.size();
}
else
{
std::cout << " - chunk size: " << head->data.size() << std::endl;
std::cout << head->data;
}
std::cout << std::endl;
for (const auto& child : head->children)
{
print_iff_nodes(child.get(), depth + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment