Compare commits

18 Commits

Author SHA1 Message Date
ad3e4b14fc ESP Tree view. 2022-09-10 22:12:31 +10:00
222df3c54c Implemented interface scaling. 2022-09-10 18:20:39 +10:00
60faf540ae Copied Imgui example to new project Navmesher and setup build system. 2022-09-10 10:24:55 +10:00
bd8e5b7ca0 Added glfw and imgui as submodules. 2022-09-09 21:08:16 +10:00
ff466c154d Naming inconsistencies. 2022-09-09 19:40:22 +10:00
fa7025f774 Split out sized buffer type and added tests. Modified reader to better utilise sized buffer. Debugged and working at least as well as previous. 2022-09-09 14:59:56 +10:00
392e226013 Still haven't properly tested MetaTree. But have all of the current features working together. 2022-09-08 19:41:27 +10:00
abc9cf6a61 Tree builder not crashing, need to check functional correctness. 2022-09-08 12:54:37 +10:00
2d5c85f0e8 A little more formatting. 2022-09-08 12:30:59 +10:00
ff95aeafbf A lot of formatting and an untested implementation of espr_create_tree. 2022-09-08 12:23:16 +10:00
4d7bdcf3cc Fixed a bug in espr_stats where the esp_stats structure was not being properly initialised.
Also, significantly sped up the header printing functions.
2022-09-07 20:56:43 +10:00
de1a27e337 Added a few more comments. Changed rt_hash to return an enum record_type rather than an enum record_type_hash. Modified rfs and rfs_refr to suit. 2022-09-07 10:09:25 +10:00
86d2c1a002 Formatting fixes. 2022-09-07 09:39:13 +10:00
380c623776 Added ESPTree header, which will handle the meta tree structure created on top of the esp/esm file buffer. Added editorconfig for column guidelines. 2022-09-07 09:32:28 +10:00
373d799f97 Fixed misuse of _ in variables. Re-added NONE to record_type enum, as it is required for rth2rt. 2022-09-06 19:12:28 +10:00
5471bcf102 Reformatting. 2022-09-06 18:45:31 +10:00
7063f4b763 Moved RT_HASH enum into LUT.c as it shouldn't be directly accessible. 2022-09-06 18:09:13 +10:00
027c9fa999 Cleaned up repository and add licensing notices to files. Project licensed under Mozilla Public License. 2022-09-06 17:37:04 +10:00
37 changed files with 3232 additions and 2623 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
root = true
# All files
[*]
indent_style = space
guidelines = 80
# Xml files
[*.xml]
indent_size = 2

2
.gitignore vendored
View File

@@ -3,7 +3,7 @@
## ##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
NavmeshList/Skyrim.esm *.esm
# User-specific files # User-specific files
*.rsuser *.rsuser

6
.gitmodules vendored
View File

@@ -1,3 +1,9 @@
[submodule "zlib-win-build"] [submodule "zlib-win-build"]
path = zlib-win-build path = zlib-win-build
url = https://github.com/kiyolee/zlib-win-build.git url = https://github.com/kiyolee/zlib-win-build.git
[submodule "imgui"]
path = imgui
url = https://github.com/ocornut/imgui.git
[submodule "glfw"]
path = glfw
url = https://github.com/glfw/glfw.git

232
LICENSE
View File

@@ -1,232 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

File diff suppressed because it is too large Load Diff

View File

@@ -72,6 +72,7 @@
<ProjectGuid>{4ce7e7fd-7fff-4c42-ab16-c9c2b01e5d56}</ProjectGuid> <ProjectGuid>{4ce7e7fd-7fff-4c42-ab16-c9c2b01e5d56}</ProjectGuid>
<RootNamespace>NavmeshList</RootNamespace> <RootNamespace>NavmeshList</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>NavmeshList</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
@@ -408,7 +409,8 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../ESPReader</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\SizedBuffer;..\ESPReader</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@@ -420,13 +422,13 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>EnableAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../ESPReader</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\SizedBuffer;..\ESPReader</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View File

@@ -1,3 +1,8 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
#include "ESPReader.h" #include "ESPReader.h"
#include <stdio.h> #include <stdio.h>
@@ -6,38 +11,103 @@
#include <assert.h> #include <assert.h>
int main(void) { int main(void) {
errno_t ret = 0;
// Read in the esp file
SizedBuf esp_buf = { 0 };
{
FILE *fp; FILE *fp;
errno_t ret = fopen_s(&fp, "Skyrim.esm", "rb"); ret = fopen_s(&fp, "Skyrim.esm", "rb");
if (ret || !fp) if (ret || !fp)
return ret; goto exit1;
fseek(fp, 0L, SEEK_END); fseek(fp, 0L, SEEK_END);
size_t size = ftell(fp); esp_buf.size = ftell(fp);
rewind(fp); rewind(fp);
char *buffer = malloc(size); esp_buf.data = malloc(esp_buf.size);
if (!buffer) if (!esp_buf.data) {
return errno; ret = errno;
goto exit1;
}
size_t read = fread(buffer, sizeof(char), size, fp); size_t read = fread(esp_buf.data, sizeof(char), esp_buf.size, fp);
assert(read == size); fclose(fp);
assert(read == esp_buf.size);
}
size_t dc_size = espr_decompressed_size(buffer, size); // Calculate esp stats
ESPStats stats = espr_stats(esp_buf);
char *decompressed = malloc(dc_size); // Decompress the esp file
if (!decompressed) SizedBuf decom_buf = { 0 };
return errno; {
decom_buf.size = stats.decompressed_size;
decom_buf.data = malloc(decom_buf.size);
if (!decom_buf.data) {
ret = errno;
goto exit2;
}
espr_decompress(buffer, size, decompressed, dc_size); espr_decompress(esp_buf, decom_buf);
}
free(buffer); // Construct the meta tree
SizedBuf tree_buf = { 0 };
MetaTree tree = { 0 };
{
tree_buf.size = espr_tree_size(stats);
tree_buf.data = malloc(tree_buf.size);
if (!tree_buf.data) {
ret = errno;
goto exit3;
}
tree = espr_create_tree(decom_buf, tree_buf);
}
size_t formid_count = espr_formid_count(decompressed, dc_size); // Serialize and write out the uncompressed esp
SizedBuf serialized_buf = { 0 };
{
serialized_buf.size = tree.size;
serialized_buf.data = malloc(serialized_buf.size);
if (!serialized_buf.data) {
ret = errno;
goto exit4;
}
printf("FormID Count: %zu\n", formid_count); espr_serialize(tree, serialized_buf);
free(decompressed); printf("Serialized.\n");
FILE *fp;
ret = fopen_s(&fp, "Test.esm", "wb");
if (ret || !fp)
goto exit5;
size_t written = fwrite(serialized_buf.data, sizeof(char),
serialized_buf.size, fp);
fclose(fp);
assert(written == serialized_buf.size);
printf("Written.\n");
}
exit5:
free(serialized_buf.data);
exit4:
free(tree_buf.data);
exit3:
free(decom_buf.data);
exit2:
free(esp_buf.data);
exit1:
// lazy file pointer cleanup
_fcloseall();
printf("Finished.\n");
(void)getc(stdin);
return 0; return 0;
} }

View File

@@ -7,10 +7,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ESPReader", "espReader\espR
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NavmeshList", "NavmeshList\NavmeshList.vcxproj", "{4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NavmeshList", "NavmeshList\NavmeshList.vcxproj", "{4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mph_gen", "mph_gen\mph_gen.vcxproj", "{385E9D8D-F3F4-4FD4-B182-D06F877CB090}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libz-static", "zlib-win-build\build-VS2022\libz-static\libz-static.vcxproj", "{B56D17BC-072B-42F3-844A-870A07AFBAAA}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libz-static", "zlib-win-build\build-VS2022\libz-static\libz-static.vcxproj", "{B56D17BC-072B-42F3-844A-870A07AFBAAA}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F2B93142-BC5A-4D28-8AAA-24D52FA59514}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SizedBuffer", "SizedBuffer\SizedBuffer.vcxproj", "{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl3", "imgui\examples\example_glfw_opengl3\example_glfw_opengl3.vcxproj", "{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Navmesher", "Navmesher\Navmesher.vcxproj", "{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Itanium = Debug|Itanium Debug|Itanium = Debug|Itanium
@@ -60,24 +69,6 @@ Global
{4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}.ReleaseWithoutAsm|x64.Build.0 = Release|x64 {4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}.ReleaseWithoutAsm|x64.Build.0 = Release|x64
{4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32 {4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32
{4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32 {4CE7E7FD-7FFF-4C42-AB16-C9C2B01E5D56}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Debug|Itanium.ActiveCfg = Debug|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Debug|Itanium.Build.0 = Debug|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Debug|x64.ActiveCfg = Debug|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Debug|x64.Build.0 = Debug|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Debug|x86.ActiveCfg = Debug|Win32
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Debug|x86.Build.0 = Debug|Win32
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Release|Itanium.ActiveCfg = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Release|Itanium.Build.0 = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Release|x64.ActiveCfg = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Release|x64.Build.0 = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Release|x86.ActiveCfg = Release|Win32
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.Release|x86.Build.0 = Release|Win32
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.ReleaseWithoutAsm|Itanium.Build.0 = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.ReleaseWithoutAsm|x64.Build.0 = Release|x64
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32
{385E9D8D-F3F4-4FD4-B182-D06F877CB090}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32
{B56D17BC-072B-42F3-844A-870A07AFBAAA}.Debug|Itanium.ActiveCfg = Debug|x64 {B56D17BC-072B-42F3-844A-870A07AFBAAA}.Debug|Itanium.ActiveCfg = Debug|x64
{B56D17BC-072B-42F3-844A-870A07AFBAAA}.Debug|Itanium.Build.0 = Debug|x64 {B56D17BC-072B-42F3-844A-870A07AFBAAA}.Debug|Itanium.Build.0 = Debug|x64
{B56D17BC-072B-42F3-844A-870A07AFBAAA}.Debug|x64.ActiveCfg = Debug|x64 {B56D17BC-072B-42F3-844A-870A07AFBAAA}.Debug|x64.ActiveCfg = Debug|x64
@@ -96,6 +87,60 @@ Global
{B56D17BC-072B-42F3-844A-870A07AFBAAA}.ReleaseWithoutAsm|x64.Build.0 = Release|x64 {B56D17BC-072B-42F3-844A-870A07AFBAAA}.ReleaseWithoutAsm|x64.Build.0 = Release|x64
{B56D17BC-072B-42F3-844A-870A07AFBAAA}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32 {B56D17BC-072B-42F3-844A-870A07AFBAAA}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32
{B56D17BC-072B-42F3-844A-870A07AFBAAA}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32 {B56D17BC-072B-42F3-844A-870A07AFBAAA}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Debug|Itanium.ActiveCfg = Debug|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Debug|Itanium.Build.0 = Debug|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Debug|x64.ActiveCfg = Debug|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Debug|x64.Build.0 = Debug|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Debug|x86.ActiveCfg = Debug|Win32
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Debug|x86.Build.0 = Debug|Win32
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Release|Itanium.ActiveCfg = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Release|Itanium.Build.0 = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Release|x64.ActiveCfg = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Release|x64.Build.0 = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Release|x86.ActiveCfg = Release|Win32
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.Release|x86.Build.0 = Release|Win32
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.ReleaseWithoutAsm|Itanium.Build.0 = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.ReleaseWithoutAsm|x64.Build.0 = Release|x64
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32
{CB1C8F66-5B90-4DE7-890B-F6430DAAF25F}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Itanium.ActiveCfg = Debug|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Itanium.Build.0 = Debug|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.ActiveCfg = Debug|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.Build.0 = Debug|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x86.ActiveCfg = Debug|Win32
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x86.Build.0 = Debug|Win32
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Itanium.ActiveCfg = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Itanium.Build.0 = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.ActiveCfg = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.Build.0 = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x86.ActiveCfg = Release|Win32
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x86.Build.0 = Release|Win32
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.ReleaseWithoutAsm|Itanium.Build.0 = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.ReleaseWithoutAsm|x64.Build.0 = Release|x64
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Debug|Itanium.ActiveCfg = Debug|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Debug|Itanium.Build.0 = Debug|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Debug|x64.ActiveCfg = Debug|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Debug|x64.Build.0 = Debug|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Debug|x86.ActiveCfg = Debug|Win32
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Debug|x86.Build.0 = Debug|Win32
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Release|Itanium.ActiveCfg = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Release|Itanium.Build.0 = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Release|x64.ActiveCfg = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Release|x64.Build.0 = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Release|x86.ActiveCfg = Release|Win32
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.Release|x86.Build.0 = Release|Win32
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.ReleaseWithoutAsm|Itanium.Build.0 = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.ReleaseWithoutAsm|x64.Build.0 = Release|x64
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.ReleaseWithoutAsm|x86.ActiveCfg = Release|Win32
{036D6C81-1E1C-4ADE-A48A-F1DDAF9286A1}.ReleaseWithoutAsm|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

173
Navmesher/Navmesher.vcxproj Normal file
View File

@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{036d6c81-1e1c-4ade-a48a-f1ddaf9286a1}</ProjectGuid>
<RootNamespace>Navmesher</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\SizedBuffer;..\ESPReader;..\imgui\backends;..\glfw\include;..\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\glfw\build\src\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
<EntryPointSymbol>
</EntryPointSymbol>
<AdditionalDependencies>opengl32.lib;glfw3.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\imgui\backends;..\glfw\include;..\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\glfw\build\src\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>opengl32.lib;glfw3.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\imgui\backends\imgui_impl_glfw.cpp" />
<ClCompile Include="..\imgui\backends\imgui_impl_opengl3.cpp" />
<ClCompile Include="..\imgui\imgui.cpp" />
<ClCompile Include="..\imgui\imgui_demo.cpp" />
<ClCompile Include="..\imgui\imgui_draw.cpp" />
<ClCompile Include="..\imgui\imgui_tables.cpp" />
<ClCompile Include="..\imgui\imgui_widgets.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\imgui\backends\imgui_impl_glfw.h" />
<ClInclude Include="..\imgui\backends\imgui_impl_opengl3.h" />
<ClInclude Include="..\imgui\backends\imgui_impl_opengl3_loader.h" />
<ClInclude Include="..\imgui\imconfig.h" />
<ClInclude Include="..\imgui\imgui.h" />
<ClInclude Include="..\imgui\imgui_internal.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\imgui\misc\debuggers\imgui.natvis" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\espReader\espReader.vcxproj">
<Project>{c403cba2-86ae-4442-87cf-26b283a549c2}</Project>
</ProjectReference>
<ProjectReference Include="..\SizedBuffer\SizedBuffer.vcxproj">
<Project>{cb1c8f66-5b90-4de7-890b-f6430daaf25f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="imgui">
<UniqueIdentifier>{e93560d6-5678-4cf7-a5e0-7d56705806fe}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\imgui\imgui.cpp">
<Filter>imgui</Filter>
</ClCompile>
<ClCompile Include="..\imgui\imgui_demo.cpp">
<Filter>imgui</Filter>
</ClCompile>
<ClCompile Include="..\imgui\imgui_draw.cpp">
<Filter>imgui</Filter>
</ClCompile>
<ClCompile Include="..\imgui\imgui_tables.cpp">
<Filter>imgui</Filter>
</ClCompile>
<ClCompile Include="..\imgui\imgui_widgets.cpp">
<Filter>imgui</Filter>
</ClCompile>
<ClCompile Include="..\imgui\backends\imgui_impl_glfw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\imgui\backends\imgui_impl_opengl3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\imgui\imconfig.h">
<Filter>imgui</Filter>
</ClInclude>
<ClInclude Include="..\imgui\imgui.h">
<Filter>imgui</Filter>
</ClInclude>
<ClInclude Include="..\imgui\imgui_internal.h">
<Filter>imgui</Filter>
</ClInclude>
<ClInclude Include="..\imgui\backends\imgui_impl_glfw.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\imgui\backends\imgui_impl_opengl3.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\imgui\backends\imgui_impl_opengl3_loader.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\imgui\misc\debuggers\imgui.natvis">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
</Project>

291
Navmesher/main.cpp Normal file
View File

@@ -0,0 +1,291 @@
// Based on Dear ImGui GLFW + OpenGL 3 standalone example
#include "ESPReader.h"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <stdio.h>
#include <cstdlib>
#undef NDEBUG
#include <assert.h>
#define NDEBUG
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
const float BASE_FONT_SIZE = 13;
const ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings;
MetaTree ReadESP(const char *filename);
GLFWwindow *Setup(void);
void NewFrame(void);
void Fullscreen(void);
void Render(GLFWwindow *window, const ImVec4 clear_color);
void Cleanup(GLFWwindow *window);
void ChangeScale(bool *scale_update, const float scale);
void ScalingWidget(bool *scale_update, float *scale);
void ESPTreeWalk(MetaNode *m);
static void glfw_error_callback(int error, const char *description)
{
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
}
int main(int, char **)
{
GLFWwindow *window = Setup();
if (!window)
return 1;
MetaTree m = ReadESP("Skyrim.esm");
m.root->user = (void *)true;
// Our state
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
bool scale_update = false;
float scale = 1.0f;
// Main loop
while (!glfwWindowShouldClose(window))
{
// Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
glfwPollEvents();
// Interface scaling
ChangeScale(&scale_update, scale);
// Start the Dear ImGui frame
NewFrame();
// Setup for fullscreen
Fullscreen();
// Begin window
ImGui::Begin("ESP Browser", NULL, window_flags);
ScalingWidget(&scale_update, &scale);
ESPTreeWalk(m.root);
// End window
ImGui::End();
Render(window, clear_color);
}
free(m.esp.data);
free(m.tree.data);
Cleanup(window);
return 0;
}
MetaTree ReadESP(const char *filename)
{
errno_t ret = 0;
SizedBuf esp_buf = { 0 };
ESPStats stats = { 0 };
SizedBuf tree_buf = { 0 };
MetaTree tree = { 0 };
// Read in the esp file
{
FILE *fp;
ret = fopen_s(&fp, "Skyrim.esm", "rb");
assert(fp && !ret);
fseek(fp, 0L, SEEK_END);
esp_buf.size = ftell(fp);
rewind(fp);
esp_buf.data = (char *)malloc(esp_buf.size);
assert(esp_buf.data);
size_t read = fread(esp_buf.data, sizeof(char), esp_buf.size, fp);
fclose(fp);
assert(read == esp_buf.size);
}
// Calculate esp stats
stats = espr_stats(esp_buf);
// Construct the meta tree
{
tree_buf.size = espr_tree_size(stats);
tree_buf.data = (char *)malloc(tree_buf.size);
assert(tree_buf.data);
tree = espr_create_tree(esp_buf, tree_buf);
}
// lazy file pointer cleanup
_fcloseall();
return tree;
}
GLFWwindow *Setup(void)
{
// Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return NULL;
// GL 3.0 + GLSL 130
const char *glsl_version = "#version 130";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// Create window with graphics context
GLFWwindow *window = glfwCreateWindow(1920, 1080, "Dear ImGui GLFW+OpenGL3 example", NULL, NULL);
if (window == NULL)
return NULL;
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // Enable vsync
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO &io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle &style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
return window;
}
void NewFrame(void)
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void Fullscreen(void)
{
const ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(viewport->WorkSize);
}
void Render(GLFWwindow * window, const ImVec4 clear_color)
{
ImGuiIO &io = ImGui::GetIO();
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow *backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
glfwSwapBuffers(window);
}
void Cleanup(GLFWwindow *window)
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
}
void ChangeScale(bool *scale_update, const float scale)
{
static ImGuiStyle reference_style(ImGui::GetStyle());
ImGuiIO &io = ImGui::GetIO();
ImGuiStyle &style = ImGui::GetStyle();
if (*scale_update) {
ImFontConfig font_config;
// Truncate to 2 decimal places
font_config.SizePixels = ((float)(int)(BASE_FONT_SIZE * scale * 100)) / 100;
io.Fonts->Clear();
io.Fonts->AddFontDefault(&font_config);
ImGui_ImplOpenGL3_UpdateFontsTexture();
style = reference_style;
style.ScaleAllSizes(scale);
*scale_update = false;
}
}
void ScalingWidget(bool *scale_update, float *scale)
{
ImGuiIO &io = ImGui::GetIO();
ImGuiStyle &style = ImGui::GetStyle();
const float MIN_SCALE = 0.3f;
const float MAX_SCALE = 3.0f;
ImGui::PushItemWidth(ImGui::GetFontSize() * 20);
if (ImGui::DragFloat("scale", scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) {
*scale_update = true;
}
ImGui::PopItemWidth();
}
void ESPTreeWalk(MetaNode *m)
{
char buf[1024] = { 0 };
SizedBuf sb = { buf, 1024 };
espr_meta_string(m, sb);
if (m->n.type == NT_RECORD) {
ImGui::BulletText(buf);
} else {
if (ImGui::TreeNode(buf)) {
MetaNode *c = m->first_child;
while (c) {
ESPTreeWalk(c);
c = c->next;
}
ImGui::TreePop();
}
}
}

81
SizedBuffer/SizedBuffer.h Normal file
View File

@@ -0,0 +1,81 @@
#pragma once
// Guards for C++ usage
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <stdbool.h>
/* A sized buffer abstraction.
*
* Functions that return int's will return 0 on success and nonzero otherwise.
*/
typedef struct sized_buf SizedBuf;
struct sized_buf
{
char *data;
size_t size;
};
// Returns 0 if the given buffer has at least size bytes available
inline int sb_check(const SizedBuf sb, const size_t size)
{
return !(sb.size >= size);
}
// Moves the buffer size bytes forward, makes no checks
inline void sb_update(SizedBuf *const sb, const size_t size)
{
sb->data += size;
sb->size -= size;
}
// Copies size bytes of data from the source to the buffer
inline int sb_copyin(SizedBuf *const sb, const char *const source, const size_t size)
{
int ret = sb_check(*sb, size);
if (!ret) {
memcpy(sb->data, source, size);
sb_update(sb, size);
}
return ret;
}
// "Recasts" size bytes of memory and returns a pointer to said memory in out
inline int sb_recast(SizedBuf *const sb, const size_t size, const void **const out)
{
int ret = sb_check(*sb, size);
if (!ret) {
*out = sb->data;
sb_update(sb, size);
}
return ret;
}
// "Recasts" size bytes of memory without actually consuming the buffer
inline int sb_peek(const SizedBuf sb, const size_t size, const void **const out)
{
*out = sb.data;
return sb_check(sb, size);
}
// Returns a pointer just after the end of the sized buffer
inline char *sb_end(const SizedBuf sb)
{
return sb.data + sb.size;
}
inline bool sb_empty(const SizedBuf sb)
{
return sb.size == 0;
}
// End C++ guard
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{cb1c8f66-5b90-4de7-890b-f6430daaf25f}</ProjectGuid>
<RootNamespace>SizedBuffer</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="SizedBuffer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="SizedBufferTest.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SizedBuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SizedBufferTest.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,146 @@
#include "SizedBuffer.h"
#undef NDBEUG
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
void test_sb_check(void) {
SizedBuf t = { .size = 0 };
assert(sb_check(t, 0) == 0);
assert(sb_check(t, 1) != 0);
assert(sb_check(t, SIZE_MAX) != 0);
t.size = 100;
assert(sb_check(t, 99) == 0);
assert(sb_check(t, 100) == 0);
assert(sb_check(t, 101) != 0);
assert(sb_check(t, SIZE_MAX) != 0);
t.size = SIZE_MAX;
assert(sb_check(t, 0) == 0);
assert(sb_check(t, 1) == 0);
assert(sb_check(t, SIZE_MAX) == 0);
}
void test_sb_update(void) {
SizedBuf t;
t = (SizedBuf){ .data = 0, .size = 0 };
sb_update(&t, 0);
assert(t.data == 0 && t.size == 0);
t.size = 100;
sb_update(&t, 25);
assert(t.data == (void *)25 && t.size == 75);
sb_update(&t, 75);
assert(t.data == (void *)100 && t.size == 0);
}
void test_sb_copyin(void) {
#define TEST_SIZE 128
char buf[TEST_SIZE] = { 0 };
SizedBuf sb = { .data = buf, .size = TEST_SIZE };
char test_buf[TEST_SIZE] = { 0 };
memset(test_buf, 0xff, TEST_SIZE);
int ret = 0;
assert(sb_copyin(&sb, NULL, SIZE_MAX) != 0);
assert(sb_copyin(&sb, NULL, TEST_SIZE + 1) != 0);
assert(sb_copyin(&sb, test_buf, TEST_SIZE) == 0);
assert(memcmp(buf, test_buf, TEST_SIZE) == 0);
assert(sb.size == 0);
assert(sb.data == buf + TEST_SIZE);
#undef TEST_SIZE
}
void test_sb_recast(void) {
#define TEST_SIZE 33
char *const start = NULL;
SizedBuf t = { .data = start, .size = TEST_SIZE };
void *out = NULL;
assert(sb_recast(&t, SIZE_MAX, &out) != 0);
assert(sb_recast(&t, TEST_SIZE + 1, &out) != 0);
assert(sb_recast(&t, 13, &out) == 0);
assert(t.data == start + 13);
assert(t.size == TEST_SIZE - 13);
assert(out == NULL);
assert(sb_recast(&t, 8, &out) == 0);
assert(t.data == (void *)(13 + 8));
assert(t.size == TEST_SIZE - 13 - 8);
assert(out == (void *)13);
#undef TEST_SIZE
}
void test_sb_end(void) {
SizedBuf sb = { .data = NULL, .size = SIZE_MAX };
assert(sb_end(sb) == (void *)SIZE_MAX);
sb = (SizedBuf){ .data = (void *)0xdeadbeefull, .size = 0x1337 };
assert(sb_end(sb) == (void *)(0xdeadbeefull + 0x1337ull));
}
void test_sb_empty(void) {
SizedBuf sb = { .data = NULL, .size = SIZE_MAX };
assert(!sb_empty(sb));
sb.size = 1;
assert(!sb_empty(sb));
sb.size = 0;
assert(sb_empty(sb));
}
void test_sb_peek(void) {
#define TEST_SIZE 128
SizedBuf sb = { .data = NULL, .size = TEST_SIZE };
void *test = (void *)0xdeadbeefull;
assert(sb_peek(sb, SIZE_MAX, &test) != 0);
assert(sb_peek(sb, TEST_SIZE + 1, &test) != 0);
assert(sb_peek(sb, TEST_SIZE, &test) == 0);
assert(sb.data == test);
assert(sb.size == TEST_SIZE);
test = (void *)'FOUR';
assert(sb_peek(sb, 0, &test) == 0);
assert(sb.data == test);
assert(sb.size == TEST_SIZE);
#undef TEST_SIZE
}
typedef struct {
void (*test)(void);
const char *const name;
} Test;
#define TEST(x) { x, #x }
Test tests[] = {
TEST(test_sb_check),
TEST(test_sb_update),
TEST(test_sb_copyin),
TEST(test_sb_recast),
TEST(test_sb_end),
TEST(test_sb_empty),
TEST(test_sb_peek),
};
#undef TEST
int main() {
#ifdef DISABLE_STDOUT
fclose(stdout);
#endif
// run all tests
size_t num_tests = sizeof(tests) / sizeof(tests[0]);
for (size_t i = 0; i < num_tests; i++) {
tests[i].test();
fprintf(stderr, "Test passed: %s\n", tests[i].name);
}
fprintf(stderr, "All tests passed.\n");
return 0;
}

View File

@@ -1,635 +0,0 @@
#include "ESPReader.h"
#define LE(x) (((x >> 24) & 0x000000ffu) | ((x >> 8) & 0x0000ff00u) | \
((x << 8) & 0x00ff0000u) | ((x << 24) & 0xff000000u))
const enum record_type group_order[GO_SIZE] = {
GMST, KYWD, LCRT, AACT, TXST, GLOB,
CLAS, FACT, HDPT, HAIR, EYES, RACE,
SOUN, ASPC, MGEF, SCPT, LTEX, ENCH,
SPEL, SCRL, ACTI, TACT, ARMO, BOOK,
CONT, DOOR, INGR, LIGH, MISC, APPA,
STAT, SCOL, MSTT, PWAT, GRAS, TREE,
CLDC, FLOR, FURN, WEAP, AMMO, NPC_,
LVLN, KEYM, ALCH, IDLM, COBJ, PROJ,
HAZD, SLGM, LVLI, WTHR, CLMT, SPGD,
RFCT, REGN, NAVI, CELL, WRLD, DIAL,
QUST, IDLE, PACK, CSTY, LSCR, LVSP,
ANIO, WATR, EFSH, EXPL, DEBR, IMGS,
IMAD, FLST, PERK, BPTD, ADDN, AVIF,
CAMS, CPTH, VTYP, MATT, IPCT, IPDS,
ARMA, ECZN, LCTN, MESG, RGDL, DOBJ,
LGTM, MUSC, FSTP, FSTS, SMBN, SMQN,
SMEN, DLBR, MUST, DLVW, WOOP, SHOU,
EQUP, RELA, SCEN, ASTP, OTFT, ARTO,
MATO, MOVT, HAZD, SNDR, DUAL, SNCT,
SOPM, COLL, CLFM, REVB
};
// record type to record type value
const uint32_t rt[RT_SIZE] = {
[AACT] = LE('AACT'), [ACHR] = LE('ACHR'), [ACTI] = LE('ACTI'),
[ADDN] = LE('ADDN'), [ALCH] = LE('ALCH'), [AMMO] = LE('AMMO'),
[ANIO] = LE('ANIO'), [APPA] = LE('APPA'), [ARMA] = LE('ARMA'),
[ARMO] = LE('ARMO'), [ARTO] = LE('ARTO'), [ASPC] = LE('ASPC'),
[ASTP] = LE('ASTP'), [AVIF] = LE('AVIF'), [BOOK] = LE('BOOK'),
[BPTD] = LE('BPTD'), [CAMS] = LE('CAMS'), [CELL] = LE('CELL'),
[CLAS] = LE('CLAS'), [CLDC] = LE('CLDC'), [CLFM] = LE('CLFM'),
[CLMT] = LE('CLMT'), [COBJ] = LE('COBJ'), [COLL] = LE('COLL'),
[CONT] = LE('CONT'), [CPTH] = LE('CPTH'), [CSTY] = LE('CSTY'),
[DEBR] = LE('DEBR'), [DIAL] = LE('DIAL'), [DLBR] = LE('DLBR'),
[DLVW] = LE('DLVW'), [DOBJ] = LE('DOBJ'), [DOOR] = LE('DOOR'),
[DUAL] = LE('DUAL'), [ECZN] = LE('ECZN'), [EFSH] = LE('EFSH'),
[ENCH] = LE('ENCH'), [EQUP] = LE('EQUP'), [EXPL] = LE('EXPL'),
[EYES] = LE('EYES'), [FACT] = LE('FACT'), [FLOR] = LE('FLOR'),
[FLST] = LE('FLST'), [FSTP] = LE('FSTP'), [FSTS] = LE('FSTS'),
[FURN] = LE('FURN'), [GLOB] = LE('GLOB'), [GMST] = LE('GMST'),
[GRAS] = LE('GRAS'), [GRUP] = LE('GRUP'), [HAIR] = LE('HAIR'),
[HAZD] = LE('HAZD'), [HDPT] = LE('HDPT'), [IDLE] = LE('IDLE'),
[IDLM] = LE('IDLM'), [IMAD] = LE('IMAD'), [IMGS] = LE('IMGS'),
[INFO] = LE('INFO'), [INGR] = LE('INGR'), [IPCT] = LE('IPCT'),
[IPDS] = LE('IPDS'), [KEYM] = LE('KEYM'), [KYWD] = LE('KYWD'),
[LAND] = LE('LAND'), [LCRT] = LE('LCRT'), [LCTN] = LE('LCTN'),
[LGTM] = LE('LGTM'), [LIGH] = LE('LIGH'), [LSCR] = LE('LSCR'),
[LTEX] = LE('LTEX'), [LVLI] = LE('LVLI'), [LVLN] = LE('LVLN'),
[LVSP] = LE('LVSP'), [MATO] = LE('MATO'), [MATT] = LE('MATT'),
[MESG] = LE('MESG'), [MGEF] = LE('MGEF'), [MISC] = LE('MISC'),
[MOVT] = LE('MOVT'), [MSTT] = LE('MSTT'), [MUSC] = LE('MUSC'),
[MUST] = LE('MUST'), [NAVI] = LE('NAVI'), [NAVM] = LE('NAVM'),
[NOTE] = LE('NOTE'), [NPC_] = LE('NPC_'), [OTFT] = LE('OTFT'),
[PACK] = LE('PACK'), [PERK] = LE('PERK'), [PGRE] = LE('PGRE'),
[PHZD] = LE('PHZD'), [PROJ] = LE('PROJ'), [PWAT] = LE('PWAT'),
[QUST] = LE('QUST'), [RACE] = LE('RACE'), [REFR] = LE('REFR'),
[REGN] = LE('REGN'), [RELA] = LE('RELA'), [REVB] = LE('REVB'),
[RFCT] = LE('RFCT'), [RGDL] = LE('RGDL'), [SCEN] = LE('SCEN'),
[SCOL] = LE('SCOL'), [SCPT] = LE('SCPT'), [SCRL] = LE('SCRL'),
[SHOU] = LE('SHOU'), [SLGM] = LE('SLGM'), [SMBN] = LE('SMBN'),
[SMEN] = LE('SMEN'), [SMQN] = LE('SMQN'), [SNCT] = LE('SNCT'),
[SNDR] = LE('SNDR'), [SOPM] = LE('SOPM'), [SOUN] = LE('SOUN'),
[SPEL] = LE('SPEL'), [SPGD] = LE('SPGD'), [STAT] = LE('STAT'),
[TACT] = LE('TACT'), [TES4] = LE('TES4'), [TREE] = LE('TREE'),
[TXST] = LE('TXST'), [VTYP] = LE('VTYP'), [WATR] = LE('WATR'),
[WEAP] = LE('WEAP'), [WOOP] = LE('WOOP'), [WRLD] = LE('WRLD'),
[WTHR] = LE('WTHR'),
};
const uint16_t rt2rth[RT_SIZE] = {
[AACT] = RT_AACT,[ACHR] = RT_ACHR,[ACTI] = RT_ACTI,
[ADDN] = RT_ADDN,[ALCH] = RT_ALCH,[AMMO] = RT_AMMO,
[ANIO] = RT_ANIO,[APPA] = RT_APPA,[ARMA] = RT_ARMA,
[ARMO] = RT_ARMO,[ARTO] = RT_ARTO,[ASPC] = RT_ASPC,
[ASTP] = RT_ASTP,[AVIF] = RT_AVIF,[BOOK] = RT_BOOK,
[BPTD] = RT_BPTD,[CAMS] = RT_CAMS,[CELL] = RT_CELL,
[CLAS] = RT_CLAS,[CLDC] = RT_CLDC,[CLFM] = RT_CLFM,
[CLMT] = RT_CLMT,[COBJ] = RT_COBJ,[COLL] = RT_COLL,
[CONT] = RT_CONT,[CPTH] = RT_CPTH,[CSTY] = RT_CSTY,
[DEBR] = RT_DEBR,[DIAL] = RT_DIAL,[DLBR] = RT_DLBR,
[DLVW] = RT_DLVW,[DOBJ] = RT_DOBJ,[DOOR] = RT_DOOR,
[DUAL] = RT_DUAL,[ECZN] = RT_ECZN,[EFSH] = RT_EFSH,
[ENCH] = RT_ENCH,[EQUP] = RT_EQUP,[EXPL] = RT_EXPL,
[EYES] = RT_EYES,[FACT] = RT_FACT,[FLOR] = RT_FLOR,
[FLST] = RT_FLST,[FSTP] = RT_FSTP,[FSTS] = RT_FSTS,
[FURN] = RT_FURN,[GLOB] = RT_GLOB,[GMST] = RT_GMST,
[GRAS] = RT_GRAS,[GRUP] = RT_GRUP,[HAIR] = RT_HAIR,
[HAZD] = RT_HAZD,[HDPT] = RT_HDPT,[IDLE] = RT_IDLE,
[IDLM] = RT_IDLM,[IMAD] = RT_IMAD,[IMGS] = RT_IMGS,
[INFO] = RT_INFO,[INGR] = RT_INGR,[IPCT] = RT_IPCT,
[IPDS] = RT_IPDS,[KEYM] = RT_KEYM,[KYWD] = RT_KYWD,
[LAND] = RT_LAND,[LCRT] = RT_LCRT,[LCTN] = RT_LCTN,
[LGTM] = RT_LGTM,[LIGH] = RT_LIGH,[LSCR] = RT_LSCR,
[LTEX] = RT_LTEX,[LVLI] = RT_LVLI,[LVLN] = RT_LVLN,
[LVSP] = RT_LVSP,[MATO] = RT_MATO,[MATT] = RT_MATT,
[MESG] = RT_MESG,[MGEF] = RT_MGEF,[MISC] = RT_MISC,
[MOVT] = RT_MOVT,[MSTT] = RT_MSTT,[MUSC] = RT_MUSC,
[MUST] = RT_MUST,[NAVI] = RT_NAVI,[NAVM] = RT_NAVM,
[NOTE] = RT_NOTE,[NPC_] = RT_NPC_,[OTFT] = RT_OTFT,
[PACK] = RT_PACK,[PERK] = RT_PERK,[PGRE] = RT_PGRE,
[PHZD] = RT_PHZD,[PROJ] = RT_PROJ,[PWAT] = RT_PWAT,
[QUST] = RT_QUST,[RACE] = RT_RACE,[REFR] = RT_REFR,
[REGN] = RT_REGN,[RELA] = RT_RELA,[REVB] = RT_REVB,
[RFCT] = RT_RFCT,[RGDL] = RT_RGDL,[SCEN] = RT_SCEN,
[SCOL] = RT_SCOL,[SCPT] = RT_SCPT,[SCRL] = RT_SCRL,
[SHOU] = RT_SHOU,[SLGM] = RT_SLGM,[SMBN] = RT_SMBN,
[SMEN] = RT_SMEN,[SMQN] = RT_SMQN,[SNCT] = RT_SNCT,
[SNDR] = RT_SNDR,[SOPM] = RT_SOPM,[SOUN] = RT_SOUN,
[SPEL] = RT_SPEL,[SPGD] = RT_SPGD,[STAT] = RT_STAT,
[TACT] = RT_TACT,[TES4] = RT_TES4,[TREE] = RT_TREE,
[TXST] = RT_TXST,[VTYP] = RT_VTYP,[WATR] = RT_WATR,
[WEAP] = RT_WEAP,[WOOP] = RT_WOOP,[WRLD] = RT_WRLD,
[WTHR] = RT_WTHR,
};
const uint8_t rth2rt[RT_HASH_SIZE] = {
[RT_AACT] = AACT,[RT_ACHR] = ACHR,[RT_ACTI] = ACTI,
[RT_ADDN] = ADDN,[RT_ALCH] = ALCH,[RT_AMMO] = AMMO,
[RT_ANIO] = ANIO,[RT_APPA] = APPA,[RT_ARMA] = ARMA,
[RT_ARMO] = ARMO,[RT_ARTO] = ARTO,[RT_ASPC] = ASPC,
[RT_ASTP] = ASTP,[RT_AVIF] = AVIF,[RT_BOOK] = BOOK,
[RT_BPTD] = BPTD,[RT_CAMS] = CAMS,[RT_CELL] = CELL,
[RT_CLAS] = CLAS,[RT_CLDC] = CLDC,[RT_CLFM] = CLFM,
[RT_CLMT] = CLMT,[RT_COBJ] = COBJ,[RT_COLL] = COLL,
[RT_CONT] = CONT,[RT_CPTH] = CPTH,[RT_CSTY] = CSTY,
[RT_DEBR] = DEBR,[RT_DIAL] = DIAL,[RT_DLBR] = DLBR,
[RT_DLVW] = DLVW,[RT_DOBJ] = DOBJ,[RT_DOOR] = DOOR,
[RT_DUAL] = DUAL,[RT_ECZN] = ECZN,[RT_EFSH] = EFSH,
[RT_ENCH] = ENCH,[RT_EQUP] = EQUP,[RT_EXPL] = EXPL,
[RT_EYES] = EYES,[RT_FACT] = FACT,[RT_FLOR] = FLOR,
[RT_FLST] = FLST,[RT_FSTP] = FSTP,[RT_FSTS] = FSTS,
[RT_FURN] = FURN,[RT_GLOB] = GLOB,[RT_GMST] = GMST,
[RT_GRAS] = GRAS,[RT_GRUP] = GRUP,[RT_HAIR] = HAIR,
[RT_HAZD] = HAZD,[RT_HDPT] = HDPT,[RT_IDLE] = IDLE,
[RT_IDLM] = IDLM,[RT_IMAD] = IMAD,[RT_IMGS] = IMGS,
[RT_INFO] = INFO,[RT_INGR] = INGR,[RT_IPCT] = IPCT,
[RT_IPDS] = IPDS,[RT_KEYM] = KEYM,[RT_KYWD] = KYWD,
[RT_LAND] = LAND,[RT_LCRT] = LCRT,[RT_LCTN] = LCTN,
[RT_LGTM] = LGTM,[RT_LIGH] = LIGH,[RT_LSCR] = LSCR,
[RT_LTEX] = LTEX,[RT_LVLI] = LVLI,[RT_LVLN] = LVLN,
[RT_LVSP] = LVSP,[RT_MATO] = MATO,[RT_MATT] = MATT,
[RT_MESG] = MESG,[RT_MGEF] = MGEF,[RT_MISC] = MISC,
[RT_MOVT] = MOVT,[RT_MSTT] = MSTT,[RT_MUSC] = MUSC,
[RT_MUST] = MUST,[RT_NAVI] = NAVI,[RT_NAVM] = NAVM,
[RT_NOTE] = NOTE,[RT_NPC_] = NPC_,[RT_OTFT] = OTFT,
[RT_PACK] = PACK,[RT_PERK] = PERK,[RT_PGRE] = PGRE,
[RT_PHZD] = PHZD,[RT_PROJ] = PROJ,[RT_PWAT] = PWAT,
[RT_QUST] = QUST,[RT_RACE] = RACE,[RT_REFR] = REFR,
[RT_REGN] = REGN,[RT_RELA] = RELA,[RT_REVB] = REVB,
[RT_RFCT] = RFCT,[RT_RGDL] = RGDL,[RT_SCEN] = SCEN,
[RT_SCOL] = SCOL,[RT_SCPT] = SCPT,[RT_SCRL] = SCRL,
[RT_SHOU] = SHOU,[RT_SLGM] = SLGM,[RT_SMBN] = SMBN,
[RT_SMEN] = SMEN,[RT_SMQN] = SMQN,[RT_SNCT] = SNCT,
[RT_SNDR] = SNDR,[RT_SOPM] = SOPM,[RT_SOUN] = SOUN,
[RT_SPEL] = SPEL,[RT_SPGD] = SPGD,[RT_STAT] = STAT,
[RT_TACT] = TACT,[RT_TES4] = TES4,[RT_TREE] = TREE,
[RT_TXST] = TXST,[RT_VTYP] = VTYP,[RT_WATR] = WATR,
[RT_WEAP] = WEAP,[RT_WOOP] = WOOP,[RT_WRLD] = WRLD,
[RT_WTHR] = WTHR,
};
const char *const group_type_strings[GTS_SIZE] = {
"Top Type",
"World Children",
"Interior Cell Block",
"Interior Cell Sub-Block",
"Exterior Cell",
"Exterior Cell Sub-Block",
"Cell Children",
"Topic Children",
"Cell Persistent Children",
"Cell Temporary Children",
};
// Non-REFR flags
rfs_inner _achr = {
[9] = "Starts Dead",
[10] = "Persistent",
[11] = "Initially Disabled",
[25] = "No AI Acquire",
[29] = "Don't Havok Settle",
[30] = "ACHR Unknown 30",
};
rfs_inner _acti = {
[6] = "Has Tree LOD",
[8] = "Must Update Anims",
[9] = "Hidden From Local Map",
[15] = "Has Distant LOD",
[16] = "Random Anim Start",
[17] = "Dangerous",
[20] = "Ignore Object Interaction",
[23] = "Is Marker",
[25] = "Obstacle",
[26] = "NavMesh Generation - Filter",
[27] = "NavMesh Generation - Bounding Box",
[29] = "Child Can Use",
[30] = "NavMesh Generation - Ground",
};
rfs_inner _tact = {
[9] = "Hidden From Local Map",
[16] = "Random Anim Start",
[17] = "Radio Station",
};
rfs_inner _alch = {
[29] = "Medicine",
};
rfs_inner _ammo = {
[2] = "Non-Playable",
};
rfs_inner _anio = {
[9] = "ANIO Unknown 9",
};
rfs_inner _armo = {
[2] = "Non-Playable",
[6] = "Shield",
[10] = "ARMO Unknown 10",
[15] = "ARMO Unknown 15",
};
#define REFERENCE_RECORD { \
[7] = "Turn Off Fire", \
[10] = "Persistent", \
[11] = "Initially Disabled", \
[28] = "Reflected by Auto Water", \
[30] = "No Respawn", \
}
rfs_inner _parw = REFERENCE_RECORD;
rfs_inner _pbar = REFERENCE_RECORD;
rfs_inner _pbea = REFERENCE_RECORD;
rfs_inner _pcon = REFERENCE_RECORD;
rfs_inner _pfla = REFERENCE_RECORD;
rfs_inner _pgre = REFERENCE_RECORD;
rfs_inner _phzd = REFERENCE_RECORD;
rfs_inner _pmis = REFERENCE_RECORD;
#undef REFERENCE_RECORD
rfs_inner _cell = {
[10] = "Persistent",
[17] = "Off Limits",
[18] = "Compressed",
[19] = "Can't Wait",
};
rfs_inner _cont = {
[15] = "Has Distant LOD",
[16] = "Random Anim Start",
[25] = "Obstacle",
[26] = "NavMesh Generation - Filter",
[27] = "NavMesh Generation - Bounding Box",
[30] = "NavMesh Generation - Ground",
};
rfs_inner _csty = {
[19] = "Allow Dual Wielding",
};
rfs_inner _door = {
[15] = "Has Distant LOD",
[16] = "Random Anim Start",
[23] = "Is Marker",
};
rfs_inner _eyes = {
[2] = "Non-Playable",
};
rfs_inner _furn = {
[7] = "Is Perch",
[16] = "Has Distant LOD",
[23] = "Is Marker",
[28] = "Must Exit To Talk",
[29] = "Child Can Use",
};
rfs_inner _glob = {
[6] = "Constant",
};
rfs_inner _hdpt = {
[2] = "Non-Playable",
};
rfs_inner _mstt = {
[8] = "Must Update Anims",
[9] = "Hidden From Local Map",
[15] = "Has Distant LOD",
[16] = "Random Anim Start",
[19] = "Has Currents",
[25] = "Obstacle",
[26] = "NavMesh Generation - Filter",
[27] = "NavMesh Generation - Bounding Box",
[30] = "NavMesh Generation - Ground",
};
rfs_inner _idlm = {
[29] = "Child Can Use",
};
rfs_inner _slgm = {
[17] = "Can Hold NPC Soul",
};
rfs_inner _navm = {
[18] = "Compressed",
[26] = "AutoGen",
[31] = "NavmeshGenCell",
};
rfs_inner _perk = {
[2] = "Non-Playable",
};
rfs_inner _shou = {
[7] = "Treat Spells As Powers",
};
rfs_inner _rela = {
[6] = "Secret",
};
rfs_inner _clfm = {
[2] = "Non-Playable",
};
rfs_inner _info = {
[13] = "Actor Changed",
};
rfs_inner _keym = {
[2] = "Non-Playable",
};
rfs_inner _land = {
[18] = "Compressed",
};
rfs_inner _ligh = {
[16] = "Random Anim Start",
[17] = "Portal-strict",
[25] = "Obstacle",
};
rfs_inner _lscr = {
[10] = "Displays In Main Menu",
};
rfs_inner _misc = {
[2] = "Non-Playable",
};
rfs_inner _npc_ = {
[10] = "NPC_ Unknown 10",
[18] = "Compressed",
[19] = "NPC_ Unknown 19",
[29] = "Bleedout Override",
};
rfs_inner _race = {
[19] = "Critter (?)",
};
// these are generic refr flags for any reference type not handled by the refr
// specific flag lut
rfs_inner _refr = {
[10] = "Persistent",
[11] = "Initially Disabled",
[16] = "Is Full LOD",
[26] = "Filter (Collision Geometry)",
[27] = "Bounding Box (Collision Geometry)",
[30] = "Ground",
[31] = "Multibound",
};
rfs_inner _regn = {
[6] = "Border Region",
};
rfs_inner _stat = {
[2] = "Never Fades",
[5] = "Deleted",
[6] = "Has Tree LOD",
[7] = "Add-On LOD Object",
[9] = "Hidden From Local Map",
[11] = "STAT Unknown 11",
[15] = "Has Distant LOD",
[16] = "STAT Unknown 16",
[17] = "Uses HD LOD Texture",
[19] = "Has Currents",
[23] = "Is Marker",
[25] = "Obstacle",
[26] = "NavMesh Generation - Filter",
[27] = "NavMesh Generation - Bounding Box",
[28] = "Show In World Map",
[30] = "NavMesh Generation - Ground",
};
rfs_inner _tes4 = {
[0] = "ESM",
[1] = "Altered",
[2] = "Checked",
[3] = "Active",
[4] = "Optimized File",
[5] = "Temp ID Owner",
[7] = "Localized",
[8] = "Precalc Data Only",
[9] = "ESL",
};
rfs_inner _tree = {
[15] = "Has Distant LOD",
};
rfs_inner _weap = {
[2] = "Non-Playable",
};
rfs_inner _wrld = {
[19] = "Can't Wait",
};
rfs_inner *const rfs[RT_HASH_SIZE] = {
[RT_AACT] = NULL, [RT_ACHR] = _achr, [RT_ACTI] = _acti,
[RT_ADDN] = NULL, [RT_ALCH] = _alch, [RT_AMMO] = _ammo,
[RT_ANIO] = _anio, [RT_APPA] = NULL, [RT_ARMA] = NULL,
[RT_ARMO] = _armo, [RT_ARTO] = NULL, [RT_ASPC] = NULL,
[RT_ASTP] = NULL, [RT_AVIF] = NULL, [RT_BOOK] = NULL,
[RT_BPTD] = NULL, [RT_CAMS] = NULL, [RT_CELL] = _cell,
[RT_CLAS] = NULL, [RT_CLDC] = NULL, [RT_CLFM] = _clfm,
[RT_CLMT] = NULL, [RT_COBJ] = NULL, [RT_COLL] = NULL,
[RT_CONT] = _cont, [RT_CPTH] = NULL, [RT_CSTY] = _csty,
[RT_DEBR] = NULL, [RT_DIAL] = NULL, [RT_DLBR] = NULL,
[RT_DLVW] = NULL, [RT_DOBJ] = NULL, [RT_DOOR] = _door,
[RT_DUAL] = NULL, [RT_ECZN] = NULL, [RT_EFSH] = NULL,
[RT_ENCH] = NULL, [RT_EQUP] = NULL, [RT_EXPL] = NULL,
[RT_EYES] = _eyes, [RT_FACT] = NULL, [RT_FLOR] = NULL,
[RT_FLST] = NULL, [RT_FSTP] = NULL, [RT_FSTS] = NULL,
[RT_FURN] = _furn, [RT_GLOB] = _glob, [RT_GMST] = NULL,
[RT_GRAS] = NULL, [RT_GRUP] = NULL, [RT_HAIR] = NULL,
[RT_HAZD] = NULL, [RT_HDPT] = _hdpt, [RT_IDLE] = NULL,
[RT_IDLM] = _idlm, [RT_IMAD] = NULL, [RT_IMGS] = NULL,
[RT_INFO] = _info, [RT_INGR] = NULL, [RT_IPCT] = NULL,
[RT_IPDS] = NULL, [RT_KEYM] = _keym, [RT_KYWD] = NULL,
[RT_LAND] = _land, [RT_LCRT] = NULL, [RT_LCTN] = NULL,
[RT_LGTM] = NULL, [RT_LIGH] = _ligh, [RT_LSCR] = _lscr,
[RT_LTEX] = NULL, [RT_LVLI] = NULL, [RT_LVLN] = NULL,
[RT_LVSP] = NULL, [RT_MATO] = NULL, [RT_MATT] = NULL,
[RT_MESG] = NULL, [RT_MGEF] = NULL, [RT_MISC] = _misc,
[RT_MOVT] = NULL, [RT_MSTT] = _mstt, [RT_MUSC] = NULL,
[RT_MUST] = NULL, [RT_NAVI] = NULL, [RT_NAVM] = _navm,
[RT_NOTE] = NULL, [RT_NPC_] = _npc_, [RT_OTFT] = NULL,
[RT_PACK] = NULL, [RT_PERK] = _perk, [RT_PGRE] = _pgre,
[RT_PHZD] = _phzd, [RT_PROJ] = NULL, [RT_PWAT] = NULL,
[RT_QUST] = NULL, [RT_RACE] = _race, [RT_REFR] = _refr,
[RT_REGN] = _regn, [RT_RELA] = _rela, [RT_REVB] = NULL,
[RT_RFCT] = NULL, [RT_RGDL] = NULL, [RT_SCEN] = NULL,
[RT_SCOL] = NULL, [RT_SCPT] = NULL, [RT_SCRL] = NULL,
[RT_SHOU] = _shou, [RT_SLGM] = _slgm, [RT_SMBN] = NULL,
[RT_SMEN] = NULL, [RT_SMQN] = NULL, [RT_SNCT] = NULL,
[RT_SNDR] = NULL, [RT_SOPM] = NULL, [RT_SOUN] = NULL,
[RT_SPEL] = NULL, [RT_SPGD] = NULL, [RT_STAT] = _stat,
[RT_TACT] = _tact, [RT_TES4] = _tes4, [RT_TREE] = _tree,
[RT_TXST] = NULL, [RT_VTYP] = NULL, [RT_WATR] = NULL,
[RT_WEAP] = _weap, [RT_WOOP] = NULL, [RT_WRLD] = _wrld,
[RT_WTHR] = NULL,
};
// REFR flags depend on what its NAME field references
#define REFR_GROUP1 { \
[9] = "Hidden From Local Map", \
[10] = "Persistent", \
[11] = "Initially Disabled", \
[13] = "Sky Marker", \
[15] = "Visible When Distant", \
[16] = "Is Full LOD", \
[26] = "Filter (Collision Geometry)", \
[27] = "Bounding Box (Collision Geometry)", \
[28] = "Reflected By Auto Water", \
[29] = "Don't Havok Settle", \
[30] = "No Respawn", \
[31] = "Multibound", \
}
rfs_inner _refr_acti = REFR_GROUP1;
rfs_inner _refr_stat = REFR_GROUP1;
rfs_inner _refr_tree = REFR_GROUP1;
rfs_inner _refr_flor = REFR_GROUP1;
#undef REFR_GROUP1
rfs_inner _refr_cont = {
[10] = "Persistent",
[11] = "Initially Disabled",
[16] = "Is Full LOD",
[25] = "No AI Acquire",
[26] = "Filter (Collision Geometry)",
[27] = "Bounding Box (Collision Geometry)",
[28] = "Reflected By Auto Water",
[29] = "Don't Havok Settle",
[30] = "Ground",
[31] = "Multibound",
};
rfs_inner _refr_door = {
[6] = "Hidden From Local Map",
[8] = "Inaccessible",
[10] = "Persistent",
[11] = "Initially Disabled",
[16] = "Is Full LOD",
[26] = "Filter (Collision Geometry)",
[27] = "Bounding Box (Collision Geometry)",
[28] = "Reflected By Auto Water",
[29] = "Don't Havok Settle",
[30] = "No Respawn",
[31] = "Multibound",
};
rfs_inner _refr_ligh = {
[8] = "Doesn't Light Water",
[9] = "Casts Shadows",
[10] = "Persistent",
[11] = "Initially Disabled",
[16] = "Never Fades",
[17] = "Doesn't Light Landscape",
[25] = "No AI Acquire",
[28] = "Reflected By Auto Water",
[29] = "Don't Havok Settle",
[30] = "No Respawn",
[31] = "Multibound",
};
rfs_inner _refr_mstt = {
[9] = "Motion Blur",
[10] = "Persistent",
[11] = "Initially Disabled",
[16] = "Is Full LOD",
[26] = "Filter (Collision Geometry)",
[27] = "Bounding Box (Collision Geometry)",
[28] = "Reflected By Auto Water",
[29] = "Don't Havok Settle",
[30] = "No Respawn",
[31] = "Multibound",
};
rfs_inner _refr_addn = {
[10] = "Persistent",
[11] = "Initially Disabled",
[16] = "Is Full LOD",
[28] = "Reflected By Auto Water",
[29] = "Don't Havok Settle",
[30] = "No Respawn",
[31] = "Multibound",
};
#define REFR_GROUP2 { \
[10] = "Persistent", \
[11] = "Initially Disabled", \
[16] = "Is Full LOD", \
[25] = "No AI Acquire", \
[28] = "Reflected By Auto Water", \
[29] = "Don't Havok Settle", \
[30] = "No Respawn", \
[31] = "Multibound", \
}
rfs_inner _refr_alch = REFR_GROUP2;
rfs_inner _refr_scrl = REFR_GROUP2;
rfs_inner _refr_ammo = REFR_GROUP2;
rfs_inner _refr_armo = REFR_GROUP2;
rfs_inner _refr_ingr = REFR_GROUP2;
rfs_inner _refr_keym = REFR_GROUP2;
rfs_inner _refr_misc = REFR_GROUP2;
rfs_inner _refr_slgm = REFR_GROUP2;
rfs_inner _refr_weap = REFR_GROUP2;
rfs_inner *const rfs_refr[] = {
[RT_AACT] = NULL ,[RT_ACHR] = NULL ,[RT_ACTI] = _refr_acti,
[RT_ADDN] = _refr_addn,[RT_ALCH] = _refr_alch,[RT_AMMO] = _refr_ammo,
[RT_ANIO] = NULL ,[RT_APPA] = NULL ,[RT_ARMA] = NULL ,
[RT_ARMO] = _refr_armo,[RT_ARTO] = NULL ,[RT_ASPC] = NULL ,
[RT_ASTP] = NULL ,[RT_AVIF] = NULL ,[RT_BOOK] = NULL ,
[RT_BPTD] = NULL ,[RT_CAMS] = NULL ,[RT_CELL] = NULL ,
[RT_CLAS] = NULL ,[RT_CLDC] = NULL ,[RT_CLFM] = NULL ,
[RT_CLMT] = NULL ,[RT_COBJ] = NULL ,[RT_COLL] = NULL ,
[RT_CONT] = _refr_cont,[RT_CPTH] = NULL ,[RT_CSTY] = NULL ,
[RT_DEBR] = NULL ,[RT_DIAL] = NULL ,[RT_DLBR] = NULL ,
[RT_DLVW] = NULL ,[RT_DOBJ] = NULL ,[RT_DOOR] = _refr_door,
[RT_DUAL] = NULL ,[RT_ECZN] = NULL ,[RT_EFSH] = NULL ,
[RT_ENCH] = NULL ,[RT_EQUP] = NULL ,[RT_EXPL] = NULL ,
[RT_EYES] = NULL ,[RT_FACT] = NULL ,[RT_FLOR] = _refr_flor,
[RT_FLST] = NULL ,[RT_FSTP] = NULL ,[RT_FSTS] = NULL ,
[RT_FURN] = NULL ,[RT_GLOB] = NULL ,[RT_GMST] = NULL ,
[RT_GRAS] = NULL ,[RT_GRUP] = NULL ,[RT_HAIR] = NULL ,
[RT_HAZD] = NULL ,[RT_HDPT] = NULL ,[RT_IDLE] = NULL ,
[RT_IDLM] = NULL ,[RT_IMAD] = NULL ,[RT_IMGS] = NULL ,
[RT_INFO] = NULL ,[RT_INGR] = _refr_ingr,[RT_IPCT] = NULL ,
[RT_IPDS] = NULL ,[RT_KEYM] = _refr_keym,[RT_KYWD] = NULL ,
[RT_LAND] = NULL ,[RT_LCRT] = NULL ,[RT_LCTN] = NULL ,
[RT_LGTM] = NULL ,[RT_LIGH] = _refr_ligh,[RT_LSCR] = NULL ,
[RT_LTEX] = NULL ,[RT_LVLI] = NULL ,[RT_LVLN] = NULL ,
[RT_LVSP] = NULL ,[RT_MATO] = NULL ,[RT_MATT] = NULL ,
[RT_MESG] = NULL ,[RT_MGEF] = NULL ,[RT_MISC] = _refr_misc,
[RT_MOVT] = NULL ,[RT_MSTT] = _refr_mstt,[RT_MUSC] = NULL ,
[RT_MUST] = NULL ,[RT_NAVI] = NULL ,[RT_NAVM] = NULL ,
[RT_NOTE] = NULL ,[RT_NPC_] = NULL ,[RT_OTFT] = NULL ,
[RT_PACK] = NULL ,[RT_PERK] = NULL ,[RT_PGRE] = NULL ,
[RT_PHZD] = NULL ,[RT_PROJ] = NULL ,[RT_PWAT] = NULL ,
[RT_QUST] = NULL ,[RT_RACE] = NULL ,[RT_REFR] = NULL ,
[RT_REGN] = NULL ,[RT_RELA] = NULL ,[RT_REVB] = NULL ,
[RT_RFCT] = NULL ,[RT_RGDL] = NULL ,[RT_SCEN] = NULL ,
[RT_SCOL] = NULL ,[RT_SCPT] = NULL ,[RT_SCRL] = _refr_scrl,
[RT_SHOU] = NULL ,[RT_SLGM] = _refr_slgm,[RT_SMBN] = NULL ,
[RT_SMEN] = NULL ,[RT_SMQN] = NULL ,[RT_SNCT] = NULL ,
[RT_SNDR] = NULL ,[RT_SOPM] = NULL ,[RT_SOUN] = NULL ,
[RT_SPEL] = NULL ,[RT_SPGD] = NULL ,[RT_STAT] = _refr_stat,
[RT_TACT] = NULL ,[RT_TES4] = NULL ,[RT_TREE] = _refr_tree,
[RT_TXST] = NULL ,[RT_VTYP] = NULL ,[RT_WATR] = NULL ,
[RT_WEAP] = _refr_weap,[RT_WOOP] = NULL ,[RT_WRLD] = NULL ,
[RT_WTHR] = NULL ,
};

View File

@@ -1,3 +1,8 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
#pragma once #pragma once
/* For reading structured data out of Creation Engine esp/esm files. /* For reading structured data out of Creation Engine esp/esm files.
@@ -19,33 +24,49 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <string.h>
#undef NDEBUG
#include <assert.h>
#define NDEBUG
#include "msh.h" #include "msh.h"
#include "SizedBuffer.h"
// Guards for C++ usage // Guards for C++ usage
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// Flag fields are 32 bits, so there are 32 flags
#define RFS_INNER_SIZE 32 #define RFS_INNER_SIZE 32
// There are 127 record types + a NONE type used for sanity checks
#define RT_SIZE 128 #define RT_SIZE 128
/* RT hash seed was externally calculated s.t. the fourcc codes perfectly hash into /* RT hash seed was externally calculated s.t. the fourcc codes perfectly hash
* indices between 0 and 511. That is, there are no hashing collisions. This allows * into indices between 0 and 511. That is, there are no hashing collisions.
* for hard coded lookup tables for the fourcc codes in a relatively small space. * This allows for hard coded lookup tables for the fourcc codes in a relatively
* small space.
* *
* A minimal perfect hash is also possible with an intermediate seed table, though * A minimal perfect hash is also possible with an intermediate seed table,
* I'm not sure which is faster, if it's worth trying to speed this up, etc. * though I'm not sure which is faster, if it's worth trying to speed this up,
* etc.
*/ */
#define RT_HASH_SIZE 512 #define RT_HASH_SIZE 512
#define RT_HASH_BITS 9 #define RT_HASH_BITS 9
#define RT_HASH_SEED 131261257 #define RT_HASH_SEED 131261257
// Used for identifying records that are compressed
#define COMPRESSED_FLAG (((uint32_t)1) << 18) #define COMPRESSED_FLAG (((uint32_t)1) << 18)
// Top level group order, there are 118 top level groups
#define GO_SIZE 118 #define GO_SIZE 118
// There are 10 Group Types
#define GTS_SIZE 10 #define GTS_SIZE 10
#define LIT(L) (const struct str_lit) STR_LIT(L)
#define STR_LIT(L) { .lit = L , .size = sizeof( L ) - 1 }
// //
// === FORWARD DEFS === // === FORWARD DEFS ===
@@ -56,36 +77,59 @@ extern "C" {
typedef struct group Group; typedef struct group Group;
typedef struct record Record; typedef struct record Record;
typedef struct field Field; typedef struct field Field;
typedef struct meta_node MetaNode;
typedef struct meta_tree MetaTree;
typedef struct esp_stats ESPStats;
// //
// === SIMPLE TYPES === // === SIMPLE TYPES ===
// //
// Basic types // 3 byte ID, upper byte is determined at run time and is used to
// reference across esp/esm files
typedef uint32_t formid; typedef uint32_t formid;
// char[4] with uint32_t access // char[4] with uint32_t access, used to access fourcc values
union type4 { union type4 {
char bytes[4]; char bytes[4];
uint32_t uint; uint32_t uint;
}; };
// indexed by flag bit struct str_lit {
typedef const char *const rfs_inner[RFS_INNER_SIZE]; const char *const lit;
const int size;
const char _pad[4];
};
// Inner type for Record Flag String LUT. Indexed by flag bit.
typedef const struct str_lit rfs_inner[RFS_INNER_SIZE];
struct esp_stats {
size_t decompressed_size;
uint32_t group_count;
uint32_t record_count;
};
struct str_buf {
char *buf;
int size;
char _pad[4];
};
// //
// === ENUMS === // === ENUMS ===
// //
// Tag for generic node tagged union // Tag for generic node tagged union
enum node_type { // NT_ prefix enum node_type {
NT_GROUP, NT_GROUP,
NT_RECORD, NT_RECORD,
}; };
// Record type enum // Record type enum
enum record_type { enum record_type {
_NONE, NONE,
AACT, ACHR, ACTI, ADDN, ALCH, AMMO, AACT, ACHR, ACTI, ADDN, ALCH, AMMO,
ANIO, APPA, ARMA, ARMO, ARTO, ASPC, ANIO, APPA, ARMA, ARMO, ARTO, ASPC,
ASTP, AVIF, BOOK, BPTD, CAMS, CELL, ASTP, AVIF, BOOK, BPTD, CAMS, CELL,
@@ -110,44 +154,8 @@ extern "C" {
WTHR, WTHR,
}; };
// Enums of perfect hash values for // Group type enum
enum record_type_hash { enum group_type {
RT_AACT = 496, RT_ACHR = 249, RT_ACTI = 293, RT_ADDN = 316,
RT_ALCH = 312, RT_AMMO = 157, RT_ANIO = 297, RT_APPA = 230,
RT_ARMA = 222, RT_ARMO = 218, RT_ARTO = 328, RT_ASPC = 252,
RT_ASTP = 384, RT_AVIF = 309, RT_BOOK = 318, RT_BPTD = 454,
RT_CAMS = 319, RT_CELL = 18, RT_CLAS = 16, RT_CLDC = 68,
RT_CLFM = 389, RT_CLMT = 497, RT_COBJ = 422, RT_COLL = 140,
RT_CONT = 169, RT_CPTH = 30, RT_CSTY = 193, RT_DEBR = 460,
RT_DIAL = 304, RT_DLBR = 340, RT_DLVW = 434, RT_DOBJ = 437,
RT_DOOR = 347, RT_DUAL = 246, RT_ECZN = 229, RT_EFSH = 509,
RT_ENCH = 194, RT_EQUP = 57, RT_EXPL = 153, RT_EYES = 181,
RT_FACT = 62, RT_FLOR = 137, RT_FLST = 199, RT_FSTP = 462,
RT_FSTS = 388, RT_FURN = 105, RT_GLOB = 376, RT_GMST = 125,
RT_GRAS = 49, RT_GRUP = 511, RT_HAIR = 481, RT_HAZD = 21,
RT_HDPT = 100, RT_IDLE = 204, RT_IDLM = 348, RT_IMAD = 390,
RT_IMGS = 187, RT_INFO = 82, RT_INGR = 463, RT_IPCT = 292,
RT_IPDS = 89, RT_KEYM = 54, RT_KYWD = 123, RT_LAND = 261,
RT_LCRT = 138, RT_LCTN = 172, RT_LGTM = 177, RT_LIGH = 13,
RT_LSCR = 288, RT_LTEX = 447, RT_LVLI = 235, RT_LVLN = 453,
RT_LVSP = 343, RT_MATO = 2, RT_MATT = 220, RT_MESG = 66,
RT_MGEF = 32, RT_MISC = 145, RT_MOVT = 378, RT_MSTT = 132,
RT_MUSC = 87, RT_MUST = 9, RT_NAVI = 50, RT_NAVM = 122,
RT_NOTE = 366, RT_NPC_ = 440, RT_OTFT = 365, RT_PACK = 441,
RT_PERK = 243, RT_PGRE = 210, RT_PHZD = 26, RT_PROJ = 120,
RT_PWAT = 397, RT_QUST = 71, RT_RACE = 108, RT_REFR = 449,
RT_REGN = 320, RT_RELA = 182, RT_REVB = 266, RT_RFCT = 311,
RT_RGDL = 19, RT_SCEN = 119, RT_SCOL = 276, RT_SCPT = 363,
RT_SCRL = 104, RT_SHOU = 115, RT_SLGM = 70, RT_SMBN = 413,
RT_SMEN = 240, RT_SMQN = 63, RT_SNCT = 117, RT_SNDR = 280,
RT_SOPM = 306, RT_SOUN = 165, RT_SPEL = 190, RT_SPGD = 443,
RT_STAT = 202, RT_TACT = 282, RT_TES4 = 474, RT_TREE = 27,
RT_TXST = 359, RT_VTYP = 335, RT_WATR = 84, RT_WEAP = 10,
RT_WOOP = 352, RT_WRLD = 38, RT_WTHR = 83,
};
// GRUP type values
enum group_type { // GT_ prefix
GT_TOP = 0, GT_TOP = 0,
GT_WORLD_CHILDREN = 1, GT_WORLD_CHILDREN = 1,
GT_INTERIOR_CELL_BLOCK = 2, GT_INTERIOR_CELL_BLOCK = 2,
@@ -164,31 +172,96 @@ extern "C" {
// === COMPOSITE TYPES === // === COMPOSITE TYPES ===
// //
// Generic node // Generic node in the esp/esm tree
typedef struct node Node; typedef struct node Node;
struct node { struct node {
union { union {
Group *group; Group *group;
Record *record; Record *record;
} header; } header;
char *const data; char *data;
enum node_type type; enum node_type type;
uint32_t _pad; uint32_t _pad;
}; };
// calculated timestamp // Used for passing around parsed timestamps
struct timestamp { struct timestamp {
uint16_t year; uint16_t year;
uint8_t month; uint8_t month;
uint8_t day; uint8_t day;
}; };
/* Given to espr_walk.
*
* pre is called before the children of the current node have been
* walked post is called after the children of the current node have
* been walked
*
* carry_out and carry_in is a pointer to a void * on the stack that can
* be used for passing data between pre and post for a node.
*
* data is a pointer that the user can supply when calling espr_walk
* that will be passed to pre and post when they are called.
*/
struct walker_callbacks { struct walker_callbacks {
void (*pre)(Node n, void *data, void **carry_out); void (*pre)(
void (*post)(Node n, void *data, void **carry_in); Node n,
void *data,
void **carry_out,
void *from_parent,
void **to_children
);
void (*post)(Node n, void *data, void *carry_in);
void *data; void *data;
}; };
struct meta_callbacks {
void (*pre)(MetaNode *m, void *data);
void *data;
};
/* Meta Nodes are used for constructing a more flexible tree structure
* on top of the natural structure of ESP/ESM files.
*
* Meta Nodes do not create a pure tree structure, rather they have
* pointers to their parent and first child, and children have pointers
* backwards and forward through a linked list of all of the children of
* the parent node.
*
* There is no root node as such, rather there is a root linked list for
* which all of the Meta Nodes have no parents.
*
* While the ESP/ESM buffer can be modified in-place, any modification
* that changes the size of the stored data cannot be directly written
* to the buffer without first shifting all of the data after the point
* of modification.
*
* Modifications that change data size are:
* - Adding or deleting a group or record
* - Adding or deleting a field in a record
* - Changing a variable length field with data of different length
*
* With a Meta Node you can instead allocate new, arbitrarily sized
* memory for the node data. The Meta Node tree can then be walked to
* reconstruct a contiguous view of discontiguous memory.
*/
struct meta_node {
Node n;
void *user;
MetaNode *first_child;
MetaNode *last_child;
MetaNode *prev;
MetaNode *next;
};
struct meta_tree {
// hack, not usable when modifying tree
SizedBuf tree;
SizedBuf esp;
MetaNode *root;
size_t size;
};
// //
// === BINARY DATA OVERLAYS === // === BINARY DATA OVERLAYS ===
// //
@@ -200,7 +273,7 @@ extern "C" {
Type4 grup; // always RT_GRUP Type4 grup; // always RT_GRUP
uint32_t size; // uncludes the 24 byte group header uint32_t size; // uncludes the 24 byte group header
union { union {
Type4 type; // this may be mangled and should not be relied on Type4 type; // this may be mangled, do not rely on
formid formid; formid formid;
int32_t number; int32_t number;
int16_t coord[2]; int16_t coord[2];
@@ -245,57 +318,87 @@ extern "C" {
// type -> flag mappings // type -> flag mappings
// NULL table pointers indicate no flags // NULL table pointers indicate no flags
// NULL string pointers indicate invalid flag // NULL string pointers indicate invalid flag
extern rfs_inner *const rfs[RT_HASH_SIZE]; extern rfs_inner *const rfs[RT_SIZE];
extern rfs_inner *const rfs_refr[RT_SIZE];
extern rfs_inner *const rfs_refr[RT_HASH_SIZE];
// Expected (probably) order of top level groups in an esp/esm // Expected (probably) order of top level groups in an esp/esm
extern const enum record_type group_order[GO_SIZE]; extern const enum record_type group_order[GO_SIZE];
// Printable strings for group types // Printable strings for group types
extern const char *const group_type_strings[GTS_SIZE]; extern const struct str_lit group_type_strings[GTS_SIZE];
// //
// === FUNCTIONS === // === FUNCTIONS ===
// //
// hashes type value into RT_ hash value // hashes type value into a record type enum value
inline uint32_t rt_hash(uint32_t type) { inline uint32_t rt_hash(uint32_t type) {
return uint32_t_msh(type, RT_HASH_BITS, RT_HASH_SEED); return rth2rt[uint32_t_msh(type, RT_HASH_BITS, RT_HASH_SEED)];
} }
/* `espr_walk` walks through the tree structure of the esp/esm binary data /* `espr_walk` walks through the tree structure of the esp/esm binary
* starting at `data` of `size` bytes. * data starting at `data` of `size` bytes.
* *
* `cb` is a callback that takes a `Node` to process. `pt` is a pointer to * `cb` is a callback that takes a `Node` to process. `pt` is a pointer
* arbitrary data that is passed on to `cb` whenever it is called. * to arbitrary data that is passed on to `cb` whenever it is called.
* *
* Data is walked sequentially. Nodes passed to `cb` will be strictly increasing * Data is walked sequentially. Nodes passed to `cb` will be strictly
* in terms of memory location within the buffer. * increasing in terms of memory location within the buffer.
*/ */
void espr_walk(char *data, size_t size, struct walker_callbacks cb); void espr_walk(
SizedBuf esp,
struct walker_callbacks cb,
void *from_parent
);
/* `espr_print` prints the header of every group and record in the given /* `espr_print` prints the header of every group and record in the given
* esp/esm binary data. * esp/esm binary data.
*/ */
void espr_print(char *data, size_t size); void espr_print(SizedBuf esp);
/* Calculates the size of the esp data if all of the compressed records are /* Calculates the number of groups and records in the esp/esm file and
* the size of the esp/esm if all of the compressed records were
* decompressed. * decompressed.
*/ */
size_t espr_decompressed_size(char *data, size_t size); ESPStats espr_stats(SizedBuf esp);
/* Counts the number of formids present in the esp/esm data. This should be // Calculates the number of formid's in an esm/esp from the stats
* equal to the number of records. inline uint32_t espr_formid_count(ESPStats stats) {
*/ return stats.record_count;
size_t espr_formid_count(char *data, size_t size); }
/* Copies the data from `data` to `buf` decompressing compressed fields as // Calculates the number of nodes in the esp/esm from the stats
* it does so. buf_size should be the value returned from `espr_decompressed_size`, inline uint32_t espr_node_count(ESPStats stats) {
* and `buf` should be at least of that size. return stats.record_count + stats.group_count;
}
// Calculates the size of a MetaNode tree constructed over the esp/esm
// for which the stats were generated.
inline size_t espr_tree_size(ESPStats stats) {
return sizeof(MetaNode) * ((size_t)espr_node_count(stats) + 1);
}
/* Copies the data from `data` to `buf` decompressing compressed fields
* as it does so. buf_size should be the value returned from
* `espr_decompressed_size`, and `buf` should be at least of that size.
*/ */
void espr_decompress(char *data, size_t size, char *buf, size_t buf_size); void espr_decompress(SizedBuf esp, SizedBuf decom);
/* Constructs a MetaNode tree in `tree` over the esp/esm data in `in`.
*
* MetaNode trees allows for easier programatic traversal of the esp/esm
* data, and also allow for modifications that add, remove, or change
* the size of groups/records/fields.
*/
MetaTree espr_create_tree(SizedBuf in, SizedBuf tree);
void espr_meta_walk(MetaTree tree, struct meta_callbacks cb);
void espr_meta_node_walk(MetaNode *m, struct meta_callbacks cb);
void espr_serialize(MetaTree tree, SizedBuf out);
void espr_meta_string(MetaNode *m, SizedBuf str_buf);
// End C++ guard // End C++ guard
#ifdef __cplusplus #ifdef __cplusplus

680
espReader/LUT.c Normal file
View File

@@ -0,0 +1,680 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
#include "ESPReader.h"
#define LE(x) (((x >> 24) & 0x000000ffu) | ((x >> 8) & 0x0000ff00u) | \
((x << 8) & 0x00ff0000u) | ((x << 24) & 0xff000000u))
#define CP(x) ((rfs_inner *const)x)
const enum record_type group_order[GO_SIZE] = {
GMST, KYWD, LCRT, AACT, TXST, GLOB,
CLAS, FACT, HDPT, HAIR, EYES, RACE,
SOUN, ASPC, MGEF, SCPT, LTEX, ENCH,
SPEL, SCRL, ACTI, TACT, ARMO, BOOK,
CONT, DOOR, INGR, LIGH, MISC, APPA,
STAT, SCOL, MSTT, PWAT, GRAS, TREE,
CLDC, FLOR, FURN, WEAP, AMMO, NPC_,
LVLN, KEYM, ALCH, IDLM, COBJ, PROJ,
HAZD, SLGM, LVLI, WTHR, CLMT, SPGD,
RFCT, REGN, NAVI, CELL, WRLD, DIAL,
QUST, IDLE, PACK, CSTY, LSCR, LVSP,
ANIO, WATR, EFSH, EXPL, DEBR, IMGS,
IMAD, FLST, PERK, BPTD, ADDN, AVIF,
CAMS, CPTH, VTYP, MATT, IPCT, IPDS,
ARMA, ECZN, LCTN, MESG, RGDL, DOBJ,
LGTM, MUSC, FSTP, FSTS, SMBN, SMQN,
SMEN, DLBR, MUST, DLVW, WOOP, SHOU,
EQUP, RELA, SCEN, ASTP, OTFT, ARTO,
MATO, MOVT, HAZD, SNDR, DUAL, SNCT,
SOPM, COLL, CLFM, REVB
};
// record type to record type value
const uint32_t rt[RT_SIZE] = {
[AACT] = LE('AACT'),[ACHR] = LE('ACHR'),[ACTI] = LE('ACTI'),
[ADDN] = LE('ADDN'),[ALCH] = LE('ALCH'),[AMMO] = LE('AMMO'),
[ANIO] = LE('ANIO'),[APPA] = LE('APPA'),[ARMA] = LE('ARMA'),
[ARMO] = LE('ARMO'),[ARTO] = LE('ARTO'),[ASPC] = LE('ASPC'),
[ASTP] = LE('ASTP'),[AVIF] = LE('AVIF'),[BOOK] = LE('BOOK'),
[BPTD] = LE('BPTD'),[CAMS] = LE('CAMS'),[CELL] = LE('CELL'),
[CLAS] = LE('CLAS'),[CLDC] = LE('CLDC'),[CLFM] = LE('CLFM'),
[CLMT] = LE('CLMT'),[COBJ] = LE('COBJ'),[COLL] = LE('COLL'),
[CONT] = LE('CONT'),[CPTH] = LE('CPTH'),[CSTY] = LE('CSTY'),
[DEBR] = LE('DEBR'),[DIAL] = LE('DIAL'),[DLBR] = LE('DLBR'),
[DLVW] = LE('DLVW'),[DOBJ] = LE('DOBJ'),[DOOR] = LE('DOOR'),
[DUAL] = LE('DUAL'),[ECZN] = LE('ECZN'),[EFSH] = LE('EFSH'),
[ENCH] = LE('ENCH'),[EQUP] = LE('EQUP'),[EXPL] = LE('EXPL'),
[EYES] = LE('EYES'),[FACT] = LE('FACT'),[FLOR] = LE('FLOR'),
[FLST] = LE('FLST'),[FSTP] = LE('FSTP'),[FSTS] = LE('FSTS'),
[FURN] = LE('FURN'),[GLOB] = LE('GLOB'),[GMST] = LE('GMST'),
[GRAS] = LE('GRAS'),[GRUP] = LE('GRUP'),[HAIR] = LE('HAIR'),
[HAZD] = LE('HAZD'),[HDPT] = LE('HDPT'),[IDLE] = LE('IDLE'),
[IDLM] = LE('IDLM'),[IMAD] = LE('IMAD'),[IMGS] = LE('IMGS'),
[INFO] = LE('INFO'),[INGR] = LE('INGR'),[IPCT] = LE('IPCT'),
[IPDS] = LE('IPDS'),[KEYM] = LE('KEYM'),[KYWD] = LE('KYWD'),
[LAND] = LE('LAND'),[LCRT] = LE('LCRT'),[LCTN] = LE('LCTN'),
[LGTM] = LE('LGTM'),[LIGH] = LE('LIGH'),[LSCR] = LE('LSCR'),
[LTEX] = LE('LTEX'),[LVLI] = LE('LVLI'),[LVLN] = LE('LVLN'),
[LVSP] = LE('LVSP'),[MATO] = LE('MATO'),[MATT] = LE('MATT'),
[MESG] = LE('MESG'),[MGEF] = LE('MGEF'),[MISC] = LE('MISC'),
[MOVT] = LE('MOVT'),[MSTT] = LE('MSTT'),[MUSC] = LE('MUSC'),
[MUST] = LE('MUST'),[NAVI] = LE('NAVI'),[NAVM] = LE('NAVM'),
[NOTE] = LE('NOTE'),[NPC_] = LE('NPC_'),[OTFT] = LE('OTFT'),
[PACK] = LE('PACK'),[PERK] = LE('PERK'),[PGRE] = LE('PGRE'),
[PHZD] = LE('PHZD'),[PROJ] = LE('PROJ'),[PWAT] = LE('PWAT'),
[QUST] = LE('QUST'),[RACE] = LE('RACE'),[REFR] = LE('REFR'),
[REGN] = LE('REGN'),[RELA] = LE('RELA'),[REVB] = LE('REVB'),
[RFCT] = LE('RFCT'),[RGDL] = LE('RGDL'),[SCEN] = LE('SCEN'),
[SCOL] = LE('SCOL'),[SCPT] = LE('SCPT'),[SCRL] = LE('SCRL'),
[SHOU] = LE('SHOU'),[SLGM] = LE('SLGM'),[SMBN] = LE('SMBN'),
[SMEN] = LE('SMEN'),[SMQN] = LE('SMQN'),[SNCT] = LE('SNCT'),
[SNDR] = LE('SNDR'),[SOPM] = LE('SOPM'),[SOUN] = LE('SOUN'),
[SPEL] = LE('SPEL'),[SPGD] = LE('SPGD'),[STAT] = LE('STAT'),
[TACT] = LE('TACT'),[TES4] = LE('TES4'),[TREE] = LE('TREE'),
[TXST] = LE('TXST'),[VTYP] = LE('VTYP'),[WATR] = LE('WATR'),
[WEAP] = LE('WEAP'),[WOOP] = LE('WOOP'),[WRLD] = LE('WRLD'),
[WTHR] = LE('WTHR'),
};
// Enums of perfect hash values
enum record_type_hash {
RT_AACT = 496, RT_ACHR = 249, RT_ACTI = 293, RT_ADDN = 316,
RT_ALCH = 312, RT_AMMO = 157, RT_ANIO = 297, RT_APPA = 230,
RT_ARMA = 222, RT_ARMO = 218, RT_ARTO = 328, RT_ASPC = 252,
RT_ASTP = 384, RT_AVIF = 309, RT_BOOK = 318, RT_BPTD = 454,
RT_CAMS = 319, RT_CELL = 18, RT_CLAS = 16, RT_CLDC = 68,
RT_CLFM = 389, RT_CLMT = 497, RT_COBJ = 422, RT_COLL = 140,
RT_CONT = 169, RT_CPTH = 30, RT_CSTY = 193, RT_DEBR = 460,
RT_DIAL = 304, RT_DLBR = 340, RT_DLVW = 434, RT_DOBJ = 437,
RT_DOOR = 347, RT_DUAL = 246, RT_ECZN = 229, RT_EFSH = 509,
RT_ENCH = 194, RT_EQUP = 57, RT_EXPL = 153, RT_EYES = 181,
RT_FACT = 62, RT_FLOR = 137, RT_FLST = 199, RT_FSTP = 462,
RT_FSTS = 388, RT_FURN = 105, RT_GLOB = 376, RT_GMST = 125,
RT_GRAS = 49, RT_GRUP = 511, RT_HAIR = 481, RT_HAZD = 21,
RT_HDPT = 100, RT_IDLE = 204, RT_IDLM = 348, RT_IMAD = 390,
RT_IMGS = 187, RT_INFO = 82, RT_INGR = 463, RT_IPCT = 292,
RT_IPDS = 89, RT_KEYM = 54, RT_KYWD = 123, RT_LAND = 261,
RT_LCRT = 138, RT_LCTN = 172, RT_LGTM = 177, RT_LIGH = 13,
RT_LSCR = 288, RT_LTEX = 447, RT_LVLI = 235, RT_LVLN = 453,
RT_LVSP = 343, RT_MATO = 2, RT_MATT = 220, RT_MESG = 66,
RT_MGEF = 32, RT_MISC = 145, RT_MOVT = 378, RT_MSTT = 132,
RT_MUSC = 87, RT_MUST = 9, RT_NAVI = 50, RT_NAVM = 122,
RT_NOTE = 366, RT_NPC_ = 440, RT_OTFT = 365, RT_PACK = 441,
RT_PERK = 243, RT_PGRE = 210, RT_PHZD = 26, RT_PROJ = 120,
RT_PWAT = 397, RT_QUST = 71, RT_RACE = 108, RT_REFR = 449,
RT_REGN = 320, RT_RELA = 182, RT_REVB = 266, RT_RFCT = 311,
RT_RGDL = 19, RT_SCEN = 119, RT_SCOL = 276, RT_SCPT = 363,
RT_SCRL = 104, RT_SHOU = 115, RT_SLGM = 70, RT_SMBN = 413,
RT_SMEN = 240, RT_SMQN = 63, RT_SNCT = 117, RT_SNDR = 280,
RT_SOPM = 306, RT_SOUN = 165, RT_SPEL = 190, RT_SPGD = 443,
RT_STAT = 202, RT_TACT = 282, RT_TES4 = 474, RT_TREE = 27,
RT_TXST = 359, RT_VTYP = 335, RT_WATR = 84, RT_WEAP = 10,
RT_WOOP = 352, RT_WRLD = 38, RT_WTHR = 83,
};
const uint16_t rt2rth[RT_SIZE] = {
[AACT] = RT_AACT,[ACHR] = RT_ACHR,[ACTI] = RT_ACTI,
[ADDN] = RT_ADDN,[ALCH] = RT_ALCH,[AMMO] = RT_AMMO,
[ANIO] = RT_ANIO,[APPA] = RT_APPA,[ARMA] = RT_ARMA,
[ARMO] = RT_ARMO,[ARTO] = RT_ARTO,[ASPC] = RT_ASPC,
[ASTP] = RT_ASTP,[AVIF] = RT_AVIF,[BOOK] = RT_BOOK,
[BPTD] = RT_BPTD,[CAMS] = RT_CAMS,[CELL] = RT_CELL,
[CLAS] = RT_CLAS,[CLDC] = RT_CLDC,[CLFM] = RT_CLFM,
[CLMT] = RT_CLMT,[COBJ] = RT_COBJ,[COLL] = RT_COLL,
[CONT] = RT_CONT,[CPTH] = RT_CPTH,[CSTY] = RT_CSTY,
[DEBR] = RT_DEBR,[DIAL] = RT_DIAL,[DLBR] = RT_DLBR,
[DLVW] = RT_DLVW,[DOBJ] = RT_DOBJ,[DOOR] = RT_DOOR,
[DUAL] = RT_DUAL,[ECZN] = RT_ECZN,[EFSH] = RT_EFSH,
[ENCH] = RT_ENCH,[EQUP] = RT_EQUP,[EXPL] = RT_EXPL,
[EYES] = RT_EYES,[FACT] = RT_FACT,[FLOR] = RT_FLOR,
[FLST] = RT_FLST,[FSTP] = RT_FSTP,[FSTS] = RT_FSTS,
[FURN] = RT_FURN,[GLOB] = RT_GLOB,[GMST] = RT_GMST,
[GRAS] = RT_GRAS,[GRUP] = RT_GRUP,[HAIR] = RT_HAIR,
[HAZD] = RT_HAZD,[HDPT] = RT_HDPT,[IDLE] = RT_IDLE,
[IDLM] = RT_IDLM,[IMAD] = RT_IMAD,[IMGS] = RT_IMGS,
[INFO] = RT_INFO,[INGR] = RT_INGR,[IPCT] = RT_IPCT,
[IPDS] = RT_IPDS,[KEYM] = RT_KEYM,[KYWD] = RT_KYWD,
[LAND] = RT_LAND,[LCRT] = RT_LCRT,[LCTN] = RT_LCTN,
[LGTM] = RT_LGTM,[LIGH] = RT_LIGH,[LSCR] = RT_LSCR,
[LTEX] = RT_LTEX,[LVLI] = RT_LVLI,[LVLN] = RT_LVLN,
[LVSP] = RT_LVSP,[MATO] = RT_MATO,[MATT] = RT_MATT,
[MESG] = RT_MESG,[MGEF] = RT_MGEF,[MISC] = RT_MISC,
[MOVT] = RT_MOVT,[MSTT] = RT_MSTT,[MUSC] = RT_MUSC,
[MUST] = RT_MUST,[NAVI] = RT_NAVI,[NAVM] = RT_NAVM,
[NOTE] = RT_NOTE,[NPC_] = RT_NPC_,[OTFT] = RT_OTFT,
[PACK] = RT_PACK,[PERK] = RT_PERK,[PGRE] = RT_PGRE,
[PHZD] = RT_PHZD,[PROJ] = RT_PROJ,[PWAT] = RT_PWAT,
[QUST] = RT_QUST,[RACE] = RT_RACE,[REFR] = RT_REFR,
[REGN] = RT_REGN,[RELA] = RT_RELA,[REVB] = RT_REVB,
[RFCT] = RT_RFCT,[RGDL] = RT_RGDL,[SCEN] = RT_SCEN,
[SCOL] = RT_SCOL,[SCPT] = RT_SCPT,[SCRL] = RT_SCRL,
[SHOU] = RT_SHOU,[SLGM] = RT_SLGM,[SMBN] = RT_SMBN,
[SMEN] = RT_SMEN,[SMQN] = RT_SMQN,[SNCT] = RT_SNCT,
[SNDR] = RT_SNDR,[SOPM] = RT_SOPM,[SOUN] = RT_SOUN,
[SPEL] = RT_SPEL,[SPGD] = RT_SPGD,[STAT] = RT_STAT,
[TACT] = RT_TACT,[TES4] = RT_TES4,[TREE] = RT_TREE,
[TXST] = RT_TXST,[VTYP] = RT_VTYP,[WATR] = RT_WATR,
[WEAP] = RT_WEAP,[WOOP] = RT_WOOP,[WRLD] = RT_WRLD,
[WTHR] = RT_WTHR,
};
const uint8_t rth2rt[RT_HASH_SIZE] = {
[RT_AACT] = AACT,[RT_ACHR] = ACHR,[RT_ACTI] = ACTI,
[RT_ADDN] = ADDN,[RT_ALCH] = ALCH,[RT_AMMO] = AMMO,
[RT_ANIO] = ANIO,[RT_APPA] = APPA,[RT_ARMA] = ARMA,
[RT_ARMO] = ARMO,[RT_ARTO] = ARTO,[RT_ASPC] = ASPC,
[RT_ASTP] = ASTP,[RT_AVIF] = AVIF,[RT_BOOK] = BOOK,
[RT_BPTD] = BPTD,[RT_CAMS] = CAMS,[RT_CELL] = CELL,
[RT_CLAS] = CLAS,[RT_CLDC] = CLDC,[RT_CLFM] = CLFM,
[RT_CLMT] = CLMT,[RT_COBJ] = COBJ,[RT_COLL] = COLL,
[RT_CONT] = CONT,[RT_CPTH] = CPTH,[RT_CSTY] = CSTY,
[RT_DEBR] = DEBR,[RT_DIAL] = DIAL,[RT_DLBR] = DLBR,
[RT_DLVW] = DLVW,[RT_DOBJ] = DOBJ,[RT_DOOR] = DOOR,
[RT_DUAL] = DUAL,[RT_ECZN] = ECZN,[RT_EFSH] = EFSH,
[RT_ENCH] = ENCH,[RT_EQUP] = EQUP,[RT_EXPL] = EXPL,
[RT_EYES] = EYES,[RT_FACT] = FACT,[RT_FLOR] = FLOR,
[RT_FLST] = FLST,[RT_FSTP] = FSTP,[RT_FSTS] = FSTS,
[RT_FURN] = FURN,[RT_GLOB] = GLOB,[RT_GMST] = GMST,
[RT_GRAS] = GRAS,[RT_GRUP] = GRUP,[RT_HAIR] = HAIR,
[RT_HAZD] = HAZD,[RT_HDPT] = HDPT,[RT_IDLE] = IDLE,
[RT_IDLM] = IDLM,[RT_IMAD] = IMAD,[RT_IMGS] = IMGS,
[RT_INFO] = INFO,[RT_INGR] = INGR,[RT_IPCT] = IPCT,
[RT_IPDS] = IPDS,[RT_KEYM] = KEYM,[RT_KYWD] = KYWD,
[RT_LAND] = LAND,[RT_LCRT] = LCRT,[RT_LCTN] = LCTN,
[RT_LGTM] = LGTM,[RT_LIGH] = LIGH,[RT_LSCR] = LSCR,
[RT_LTEX] = LTEX,[RT_LVLI] = LVLI,[RT_LVLN] = LVLN,
[RT_LVSP] = LVSP,[RT_MATO] = MATO,[RT_MATT] = MATT,
[RT_MESG] = MESG,[RT_MGEF] = MGEF,[RT_MISC] = MISC,
[RT_MOVT] = MOVT,[RT_MSTT] = MSTT,[RT_MUSC] = MUSC,
[RT_MUST] = MUST,[RT_NAVI] = NAVI,[RT_NAVM] = NAVM,
[RT_NOTE] = NOTE,[RT_NPC_] = NPC_,[RT_OTFT] = OTFT,
[RT_PACK] = PACK,[RT_PERK] = PERK,[RT_PGRE] = PGRE,
[RT_PHZD] = PHZD,[RT_PROJ] = PROJ,[RT_PWAT] = PWAT,
[RT_QUST] = QUST,[RT_RACE] = RACE,[RT_REFR] = REFR,
[RT_REGN] = REGN,[RT_RELA] = RELA,[RT_REVB] = REVB,
[RT_RFCT] = RFCT,[RT_RGDL] = RGDL,[RT_SCEN] = SCEN,
[RT_SCOL] = SCOL,[RT_SCPT] = SCPT,[RT_SCRL] = SCRL,
[RT_SHOU] = SHOU,[RT_SLGM] = SLGM,[RT_SMBN] = SMBN,
[RT_SMEN] = SMEN,[RT_SMQN] = SMQN,[RT_SNCT] = SNCT,
[RT_SNDR] = SNDR,[RT_SOPM] = SOPM,[RT_SOUN] = SOUN,
[RT_SPEL] = SPEL,[RT_SPGD] = SPGD,[RT_STAT] = STAT,
[RT_TACT] = TACT,[RT_TES4] = TES4,[RT_TREE] = TREE,
[RT_TXST] = TXST,[RT_VTYP] = VTYP,[RT_WATR] = WATR,
[RT_WEAP] = WEAP,[RT_WOOP] = WOOP,[RT_WRLD] = WRLD,
[RT_WTHR] = WTHR,
};
const struct str_lit group_type_strings[GTS_SIZE] = {
STR_LIT("Top Type"),
STR_LIT("World Children"),
STR_LIT("Interior Cell Block"),
STR_LIT("Interior Cell Sub-Block"),
STR_LIT("Exterior Cell"),
STR_LIT("Exterior Cell Sub-Block"),
STR_LIT("Cell Children"),
STR_LIT("Topic Children"),
STR_LIT("Cell Persistent Children"),
STR_LIT("Cell Temporary Children"),
};
// Non-REFR flags
rfs_inner achr = {
[9] = STR_LIT("Starts Dead"),
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[25] = STR_LIT("No AI Acquire"),
[29] = STR_LIT("Don't Havok Settle"),
[30] = STR_LIT("ACHR Unknown 30"),
};
rfs_inner acti = {
[6] = STR_LIT("Has Tree LOD"),
[8] = STR_LIT("Must Update Anims"),
[9] = STR_LIT("Hidden From Local Map"),
[15] = STR_LIT("Has Distant LOD"),
[16] = STR_LIT("Random Anim Start"),
[17] = STR_LIT("Dangerous"),
[20] = STR_LIT("Ignore Object Interaction"),
[23] = STR_LIT("Is Marker"),
[25] = STR_LIT("Obstacle"),
[26] = STR_LIT("NavMesh Generation - Filter"),
[27] = STR_LIT("NavMesh Generation - Bounding Box"),
[29] = STR_LIT("Child Can Use"),
[30] = STR_LIT("NavMesh Generation - Ground"),
};
rfs_inner tact = {
[9] = STR_LIT("Hidden From Local Map"),
[16] = STR_LIT("Random Anim Start"),
[17] = STR_LIT("Radio Station"),
};
rfs_inner alch = {
[29] = STR_LIT("Medicine"),
};
rfs_inner ammo = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner anio = {
[9] = STR_LIT("ANIO Unknown 9"),
};
rfs_inner armo = {
[2] = STR_LIT("Non-Playable"),
[6] = STR_LIT("Shield"),
[10] = STR_LIT("ARMO Unknown 10"),
[15] = STR_LIT("ARMO Unknown 15"),
};
#define REFERENCE_RECORD { \
[7] = STR_LIT("Turn Off Fire"), \
[10] = STR_LIT("Persistent"), \
[11] = STR_LIT("Initially Disabled"), \
[28] = STR_LIT("Reflected by Auto Water"), \
[30] = STR_LIT("No Respawn"), \
}
rfs_inner parw = REFERENCE_RECORD;
rfs_inner pbar = REFERENCE_RECORD;
rfs_inner pbea = REFERENCE_RECORD;
rfs_inner pcon = REFERENCE_RECORD;
rfs_inner pfla = REFERENCE_RECORD;
rfs_inner pgre = REFERENCE_RECORD;
rfs_inner phzd = REFERENCE_RECORD;
rfs_inner pmis = REFERENCE_RECORD;
#undef REFERENCE_RECORD
rfs_inner cell = {
[10] = STR_LIT("Persistent"),
[17] = STR_LIT("Off Limits"),
[18] = STR_LIT("Compressed"),
[19] = STR_LIT("Can't Wait"),
};
rfs_inner cont = {
[15] = STR_LIT("Has Distant LOD"),
[16] = STR_LIT("Random Anim Start"),
[25] = STR_LIT("Obstacle"),
[26] = STR_LIT("NavMesh Generation - Filter"),
[27] = STR_LIT("NavMesh Generation - Bounding Box"),
[30] = STR_LIT("NavMesh Generation - Ground"),
};
rfs_inner csty = {
[19] = STR_LIT("Allow Dual Wielding"),
};
rfs_inner door = {
[15] = STR_LIT("Has Distant LOD"),
[16] = STR_LIT("Random Anim Start"),
[23] = STR_LIT("Is Marker"),
};
rfs_inner eyes = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner furn = {
[7] = STR_LIT("Is Perch"),
[16] = STR_LIT("Has Distant LOD"),
[23] = STR_LIT("Is Marker"),
[28] = STR_LIT("Must Exit To Talk"),
[29] = STR_LIT("Child Can Use"),
};
rfs_inner glob = {
[6] = STR_LIT("Constant"),
};
rfs_inner hdpt = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner mstt = {
[8] = STR_LIT("Must Update Anims"),
[9] = STR_LIT("Hidden From Local Map"),
[15] = STR_LIT("Has Distant LOD"),
[16] = STR_LIT("Random Anim Start"),
[19] = STR_LIT("Has Currents"),
[25] = STR_LIT("Obstacle"),
[26] = STR_LIT("NavMesh Generation - Filter"),
[27] = STR_LIT("NavMesh Generation - Bounding Box"),
[30] = STR_LIT("NavMesh Generation - Ground"),
};
rfs_inner idlm = {
[29] = STR_LIT("Child Can Use"),
};
rfs_inner slgm = {
[17] = STR_LIT("Can Hold NPC Soul"),
};
rfs_inner navm = {
[18] = STR_LIT("Compressed"),
[26] = STR_LIT("AutoGen"),
[31] = STR_LIT("NavmeshGenCell"),
};
rfs_inner perk = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner shou = {
[7] = STR_LIT("Treat Spells As Powers"),
};
rfs_inner rela = {
[6] = STR_LIT("Secret"),
};
rfs_inner clfm = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner info = {
[13] = STR_LIT("Actor Changed"),
};
rfs_inner keym = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner land = {
[18] = STR_LIT("Compressed"),
};
rfs_inner ligh = {
[16] = STR_LIT("Random Anim Start"),
[17] = STR_LIT("Portal-strict"),
[25] = STR_LIT("Obstacle"),
};
rfs_inner lscr = {
[10] = STR_LIT("Displays In Main Menu"),
};
rfs_inner misc = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner npc_ = {
[10] = STR_LIT("NPC_ Unknown 10"),
[18] = STR_LIT("Compressed"),
[19] = STR_LIT("NPC_ Unknown 19"),
[29] = STR_LIT("Bleedout Override"),
};
rfs_inner race = {
[19] = STR_LIT("Critter (?)"),
};
// these are generic refr flags for any reference type not handled by the refr
// specific flag lut
rfs_inner refr = {
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[16] = STR_LIT("Is Full LOD"),
[26] = STR_LIT("Filter (Collision Geometry)"),
[27] = STR_LIT("Bounding Box (Collision Geometry)"),
[30] = STR_LIT("Ground"),
[31] = STR_LIT("Multibound"),
};
rfs_inner regn = {
[6] = STR_LIT("Border Region"),
};
rfs_inner stat = {
[2] = STR_LIT("Never Fades"),
[5] = STR_LIT("Deleted"),
[6] = STR_LIT("Has Tree LOD"),
[7] = STR_LIT("Add-On LOD Object"),
[9] = STR_LIT("Hidden From Local Map"),
[11] = STR_LIT("STAT Unknown 11"),
[15] = STR_LIT("Has Distant LOD"),
[16] = STR_LIT("STAT Unknown 16"),
[17] = STR_LIT("Uses HD LOD Texture"),
[19] = STR_LIT("Has Currents"),
[23] = STR_LIT("Is Marker"),
[25] = STR_LIT("Obstacle"),
[26] = STR_LIT("NavMesh Generation - Filter"),
[27] = STR_LIT("NavMesh Generation - Bounding Box"),
[28] = STR_LIT("Show In World Map"),
[30] = STR_LIT("NavMesh Generation - Ground"),
};
rfs_inner tes4 = {
[0] = STR_LIT("ESM"),
[1] = STR_LIT("Altered"),
[2] = STR_LIT("Checked"),
[3] = STR_LIT("Active"),
[4] = STR_LIT("Optimized File"),
[5] = STR_LIT("Temp ID Owner"),
[7] = STR_LIT("Localized"),
[8] = STR_LIT("Precalc Data Only"),
[9] = STR_LIT("ESL"),
};
rfs_inner tree = {
[15] = STR_LIT("Has Distant LOD"),
};
rfs_inner weap = {
[2] = STR_LIT("Non-Playable"),
};
rfs_inner wrld = {
[19] = STR_LIT("Can't Wait"),
};
rfs_inner *const rfs[RT_SIZE] = {
[AACT] = CP(NULL),[ACHR] = CP(achr),[ACTI] = CP(acti),
[ADDN] = CP(NULL),[ALCH] = CP(alch),[AMMO] = CP(ammo),
[ANIO] = CP(anio),[APPA] = CP(NULL),[ARMA] = CP(NULL),
[ARMO] = CP(armo),[ARTO] = CP(NULL),[ASPC] = CP(NULL),
[ASTP] = CP(NULL),[AVIF] = CP(NULL),[BOOK] = CP(NULL),
[BPTD] = CP(NULL),[CAMS] = CP(NULL),[CELL] = CP(cell),
[CLAS] = CP(NULL),[CLDC] = CP(NULL),[CLFM] = CP(clfm),
[CLMT] = CP(NULL),[COBJ] = CP(NULL),[COLL] = CP(NULL),
[CONT] = CP(cont),[CPTH] = CP(NULL),[CSTY] = CP(csty),
[DEBR] = CP(NULL),[DIAL] = CP(NULL),[DLBR] = CP(NULL),
[DLVW] = CP(NULL),[DOBJ] = CP(NULL),[DOOR] = CP(door),
[DUAL] = CP(NULL),[ECZN] = CP(NULL),[EFSH] = CP(NULL),
[ENCH] = CP(NULL),[EQUP] = CP(NULL),[EXPL] = CP(NULL),
[EYES] = CP(eyes),[FACT] = CP(NULL),[FLOR] = CP(NULL),
[FLST] = CP(NULL),[FSTP] = CP(NULL),[FSTS] = CP(NULL),
[FURN] = CP(furn),[GLOB] = CP(glob),[GMST] = CP(NULL),
[GRAS] = CP(NULL),[GRUP] = CP(NULL),[HAIR] = CP(NULL),
[HAZD] = CP(NULL),[HDPT] = CP(hdpt),[IDLE] = CP(NULL),
[IDLM] = CP(idlm),[IMAD] = CP(NULL),[IMGS] = CP(NULL),
[INFO] = CP(info),[INGR] = CP(NULL),[IPCT] = CP(NULL),
[IPDS] = CP(NULL),[KEYM] = CP(keym),[KYWD] = CP(NULL),
[LAND] = CP(land),[LCRT] = CP(NULL),[LCTN] = CP(NULL),
[LGTM] = CP(NULL),[LIGH] = CP(ligh),[LSCR] = CP(lscr),
[LTEX] = CP(NULL),[LVLI] = CP(NULL),[LVLN] = CP(NULL),
[LVSP] = CP(NULL),[MATO] = CP(NULL),[MATT] = CP(NULL),
[MESG] = CP(NULL),[MGEF] = CP(NULL),[MISC] = CP(misc),
[MOVT] = CP(NULL),[MSTT] = CP(mstt),[MUSC] = CP(NULL),
[MUST] = CP(NULL),[NAVI] = CP(NULL),[NAVM] = CP(navm),
[NOTE] = CP(NULL),[NPC_] = CP(npc_),[OTFT] = CP(NULL),
[PACK] = CP(NULL),[PERK] = CP(perk),[PGRE] = CP(pgre),
[PHZD] = CP(phzd),[PROJ] = CP(NULL),[PWAT] = CP(NULL),
[QUST] = CP(NULL),[RACE] = CP(race),[REFR] = CP(refr),
[REGN] = CP(regn),[RELA] = CP(rela),[REVB] = CP(NULL),
[RFCT] = CP(NULL),[RGDL] = CP(NULL),[SCEN] = CP(NULL),
[SCOL] = CP(NULL),[SCPT] = CP(NULL),[SCRL] = CP(NULL),
[SHOU] = CP(shou),[SLGM] = CP(slgm),[SMBN] = CP(NULL),
[SMEN] = CP(NULL),[SMQN] = CP(NULL),[SNCT] = CP(NULL),
[SNDR] = CP(NULL),[SOPM] = CP(NULL),[SOUN] = CP(NULL),
[SPEL] = CP(NULL),[SPGD] = CP(NULL),[STAT] = CP(stat),
[TACT] = CP(tact),[TES4] = CP(tes4),[TREE] = CP(tree),
[TXST] = CP(NULL),[VTYP] = CP(NULL),[WATR] = CP(NULL),
[WEAP] = CP(weap),[WOOP] = CP(NULL),[WRLD] = CP(wrld),
[WTHR] = CP(NULL),
};
// REFR flags depend on what its NAME field references
#define REFR_GROUP1 { \
[9] = STR_LIT("Hidden From Local Map"), \
[10] = STR_LIT("Persistent"), \
[11] = STR_LIT("Initially Disabled"), \
[13] = STR_LIT("Sky Marker"), \
[15] = STR_LIT("Visible When Distant"), \
[16] = STR_LIT("Is Full LOD"), \
[26] = STR_LIT("Filter (Collision Geometry)"), \
[27] = STR_LIT("Bounding Box (Collision Geometry)"), \
[28] = STR_LIT("Reflected By Auto Water"), \
[29] = STR_LIT("Don't Havok Settle"), \
[30] = STR_LIT("No Respawn"), \
[31] = STR_LIT("Multibound"), \
}
rfs_inner r_acti = REFR_GROUP1;
rfs_inner r_stat = REFR_GROUP1;
rfs_inner r_tree = REFR_GROUP1;
rfs_inner r_flor = REFR_GROUP1;
#undef REFR_GROUP1
rfs_inner r_cont = {
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[16] = STR_LIT("Is Full LOD"),
[25] = STR_LIT("No AI Acquire"),
[26] = STR_LIT("Filter (Collision Geometry)"),
[27] = STR_LIT("Bounding Box (Collision Geometry)"),
[28] = STR_LIT("Reflected By Auto Water"),
[29] = STR_LIT("Don't Havok Settle"),
[30] = STR_LIT("Ground"),
[31] = STR_LIT("Multibound"),
};
rfs_inner r_door = {
[6] = STR_LIT("Hidden From Local Map"),
[8] = STR_LIT("Inaccessible"),
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[16] = STR_LIT("Is Full LOD"),
[26] = STR_LIT("Filter (Collision Geometry)"),
[27] = STR_LIT("Bounding Box (Collision Geometry)"),
[28] = STR_LIT("Reflected By Auto Water"),
[29] = STR_LIT("Don't Havok Settle"),
[30] = STR_LIT("No Respawn"),
[31] = STR_LIT("Multibound"),
};
rfs_inner r_ligh = {
[8] = STR_LIT("Doesn't Light Water"),
[9] = STR_LIT("Casts Shadows"),
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[16] = STR_LIT("Never Fades"),
[17] = STR_LIT("Doesn't Light Landscape"),
[25] = STR_LIT("No AI Acquire"),
[28] = STR_LIT("Reflected By Auto Water"),
[29] = STR_LIT("Don't Havok Settle"),
[30] = STR_LIT("No Respawn"),
[31] = STR_LIT("Multibound"),
};
rfs_inner r_mstt = {
[9] = STR_LIT("Motion Blur"),
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[16] = STR_LIT("Is Full LOD"),
[26] = STR_LIT("Filter (Collision Geometry)"),
[27] = STR_LIT("Bounding Box (Collision Geometry)"),
[28] = STR_LIT("Reflected By Auto Water"),
[29] = STR_LIT("Don't Havok Settle"),
[30] = STR_LIT("No Respawn"),
[31] = STR_LIT("Multibound"),
};
rfs_inner r_addn = {
[10] = STR_LIT("Persistent"),
[11] = STR_LIT("Initially Disabled"),
[16] = STR_LIT("Is Full LOD"),
[28] = STR_LIT("Reflected By Auto Water"),
[29] = STR_LIT("Don't Havok Settle"),
[30] = STR_LIT("No Respawn"),
[31] = STR_LIT("Multibound"),
};
#define REFR_GROUP2 { \
[10] = STR_LIT("Persistent"), \
[11] = STR_LIT("Initially Disabled"), \
[16] = STR_LIT("Is Full LOD"), \
[25] = STR_LIT("No AI Acquire"), \
[28] = STR_LIT("Reflected By Auto Water"), \
[29] = STR_LIT("Don't Havok Settle"), \
[30] = STR_LIT("No Respawn"), \
[31] = STR_LIT("Multibound"), \
}
rfs_inner r_alch = REFR_GROUP2;
rfs_inner r_scrl = REFR_GROUP2;
rfs_inner r_ammo = REFR_GROUP2;
rfs_inner r_armo = REFR_GROUP2;
rfs_inner r_ingr = REFR_GROUP2;
rfs_inner r_keym = REFR_GROUP2;
rfs_inner r_misc = REFR_GROUP2;
rfs_inner r_slgm = REFR_GROUP2;
rfs_inner r_weap = REFR_GROUP2;
#undef REFR_GROUP2
rfs_inner *const rfs_r[RT_SIZE] = {
[AACT] = CP(NULL ),[ACHR] = CP(NULL ),[ACTI] = CP(r_acti),
[ADDN] = CP(r_addn),[ALCH] = CP(r_alch),[AMMO] = CP(r_ammo),
[ANIO] = CP(NULL ),[APPA] = CP(NULL ),[ARMA] = CP(NULL ),
[ARMO] = CP(r_armo),[ARTO] = CP(NULL ),[ASPC] = CP(NULL ),
[ASTP] = CP(NULL ),[AVIF] = CP(NULL ),[BOOK] = CP(NULL ),
[BPTD] = CP(NULL ),[CAMS] = CP(NULL ),[CELL] = CP(NULL ),
[CLAS] = CP(NULL ),[CLDC] = CP(NULL ),[CLFM] = CP(NULL ),
[CLMT] = CP(NULL ),[COBJ] = CP(NULL ),[COLL] = CP(NULL ),
[CONT] = CP(r_cont),[CPTH] = CP(NULL ),[CSTY] = CP(NULL ),
[DEBR] = CP(NULL ),[DIAL] = CP(NULL ),[DLBR] = CP(NULL ),
[DLVW] = CP(NULL ),[DOBJ] = CP(NULL ),[DOOR] = CP(r_door),
[DUAL] = CP(NULL ),[ECZN] = CP(NULL ),[EFSH] = CP(NULL ),
[ENCH] = CP(NULL ),[EQUP] = CP(NULL ),[EXPL] = CP(NULL ),
[EYES] = CP(NULL ),[FACT] = CP(NULL ),[FLOR] = CP(r_flor),
[FLST] = CP(NULL ),[FSTP] = CP(NULL ),[FSTS] = CP(NULL ),
[FURN] = CP(NULL ),[GLOB] = CP(NULL ),[GMST] = CP(NULL ),
[GRAS] = CP(NULL ),[GRUP] = CP(NULL ),[HAIR] = CP(NULL ),
[HAZD] = CP(NULL ),[HDPT] = CP(NULL ),[IDLE] = CP(NULL ),
[IDLM] = CP(NULL ),[IMAD] = CP(NULL ),[IMGS] = CP(NULL ),
[INFO] = CP(NULL ),[INGR] = CP(r_ingr),[IPCT] = CP(NULL ),
[IPDS] = CP(NULL ),[KEYM] = CP(r_keym),[KYWD] = CP(NULL ),
[LAND] = CP(NULL ),[LCRT] = CP(NULL ),[LCTN] = CP(NULL ),
[LGTM] = CP(NULL ),[LIGH] = CP(r_ligh),[LSCR] = CP(NULL ),
[LTEX] = CP(NULL ),[LVLI] = CP(NULL ),[LVLN] = CP(NULL ),
[LVSP] = CP(NULL ),[MATO] = CP(NULL ),[MATT] = CP(NULL ),
[MESG] = CP(NULL ),[MGEF] = CP(NULL ),[MISC] = CP(r_misc),
[MOVT] = CP(NULL ),[MSTT] = CP(r_mstt),[MUSC] = CP(NULL ),
[MUST] = CP(NULL ),[NAVI] = CP(NULL ),[NAVM] = CP(NULL ),
[NOTE] = CP(NULL ),[NPC_] = CP(NULL ),[OTFT] = CP(NULL ),
[PACK] = CP(NULL ),[PERK] = CP(NULL ),[PGRE] = CP(NULL ),
[PHZD] = CP(NULL ),[PROJ] = CP(NULL ),[PWAT] = CP(NULL ),
[QUST] = CP(NULL ),[RACE] = CP(NULL ),[REFR] = CP(NULL ),
[REGN] = CP(NULL ),[RELA] = CP(NULL ),[REVB] = CP(NULL ),
[RFCT] = CP(NULL ),[RGDL] = CP(NULL ),[SCEN] = CP(NULL ),
[SCOL] = CP(NULL ),[SCPT] = CP(NULL ),[SCRL] = CP(r_scrl),
[SHOU] = CP(NULL ),[SLGM] = CP(r_slgm),[SMBN] = CP(NULL ),
[SMEN] = CP(NULL ),[SMQN] = CP(NULL ),[SNCT] = CP(NULL ),
[SNDR] = CP(NULL ),[SOPM] = CP(NULL ),[SOUN] = CP(NULL ),
[SPEL] = CP(NULL ),[SPGD] = CP(NULL ),[STAT] = CP(r_stat),
[TACT] = CP(NULL ),[TES4] = CP(NULL ),[TREE] = CP(r_tree),
[TXST] = CP(NULL ),[VTYP] = CP(NULL ),[WATR] = CP(NULL ),
[WEAP] = CP(r_weap),[WOOP] = CP(NULL ),[WRLD] = CP(NULL ),
[WTHR] = CP(NULL ),
};

View File

@@ -1,9 +1,19 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <intrin.h> #include <intrin.h>
#include <ammintrin.h>
#include <crtdbg.h>
#include <io.h>
#include "zlib.h" #include "zlib.h"
@@ -13,6 +23,8 @@
// === CONSTANTS === // === CONSTANTS ===
// //
#define STDOUT_FILENO 1
// timestamp field access // timestamp field access
const uint16_t day_mask = 0x1F; const uint16_t day_mask = 0x1F;
const uint16_t month_mask = 0xF; const uint16_t month_mask = 0xF;
@@ -27,64 +39,219 @@ const int year_offset = 9;
void asserts(void); void asserts(void);
// Tree walkers // Tree walkers
char *walk_concat(char *data, size_t size, struct walker_callbacks cb); void walk_concat(SizedBuf *tree, struct walker_callbacks cb, void *from_parent);
char *walk_group(char *data, struct walker_callbacks cb); void walk_group(SizedBuf *tree, struct walker_callbacks cb, void *from_parent);
char *walk_record(char *data, struct walker_callbacks cb); void walk_record(SizedBuf *tree, struct walker_callbacks cb, void *from_parent);
// Header printers // Header printers
void print_group_header(Group *header); void print_group_header(Group *header);
void print_record_header(Record *header); void print_record_header(Record *header);
// Printer helpers // Printer helpers
void print_group_label(Group *header); void litcopy(struct str_buf *sb, struct str_lit lit);
void print_record_flags(Record *header); void num_str(struct str_buf *sb, unsigned long num, int radix);
void print_timestamp(uint16_t ts); void type_str(struct str_buf *sb, Type4 type);
void print_type(Type4 type); void timestamp_str(struct str_buf *sb, uint16_t timestamp);
void print_type4(Type4 val); void group_label_str(struct str_buf *sb, Group *header);
void record_flags_str(struct str_buf *sb, Record *header);
void sb_write(int fp, struct str_buf sb_pre, struct str_buf sb_post);
// Utilities // Utilities
Timestamp convert_ts(uint16_t ts); Timestamp convert_ts(uint16_t ts);
void print_callback(Node n, void *data, void **carry_out);
void dc_size_cb(Node n, void *data, void **carry_out); // Callbacks
void formid_count_cb(Node n, void *data, void **carry_out); void print_cb(
void decompress_pre(Node n, void *data, void **carry_out); Node n,
void decompress_post(Node n, void *data, void **carry_in); void *data,
void **carry_out,
void *from_parent,
void **to_children
);
void stats_cb(
Node n,
void *data,
void **carry_out,
void *from_parent,
void **to_children
);
void decompress_pre(
Node n,
void *decom_ptr,
void **carry_out,
void *from_parent,
void **to_children
);
void decompress_post(
Node n,
void *data,
void *carry_in
);
void create_tree_cb(
Node n,
void *data,
void **carry_out,
void *from_parent,
void **to_children
);
void serialize_cb(MetaNode *m, void *data);
// //
// === FUNCTIONS === // === FUNCTIONS ===
// //
void asserts(void) { void asserts(void)
{
// binary overlay size checks // binary overlay size checks
assert(sizeof(Record) == 24); // Record struct incorrect size assert(sizeof(Record) == 24); // Record struct incorrect size
assert(sizeof(Group) == 24); // Group struct incorrect size assert(sizeof(Group) == 24); // Group struct incorrect size
assert(sizeof((Group) { 0 }.label) == 4); // Label union in group struct incorrect size assert(sizeof((Group) { 0 }.label) == 4); // Label union incorrect size
assert(sizeof(Field) == 6); // Field struct incorrect size assert(sizeof(Field) == 6); // Field struct incorrect size
assert(sizeof(uLongf) == sizeof(uint32_t)); // zlib compatability
assert(sizeof(MetaNode) == 64); // 1 cache line
// zlib compatability
assert(sizeof(uLongf) == sizeof(uint32_t));
assert(sizeof(Bytef) == sizeof(char));
} }
void espr_walk(char *data, size_t size, struct walker_callbacks cb) { void espr_walk(
SizedBuf esp,
struct walker_callbacks cb,
void *from_parent
) {
// check assertions that cannot be checked at compile time // check assertions that cannot be checked at compile time
asserts(); asserts();
char *data_start = data;
// check that we are at the start of the file // check that we are at the start of the file
const Type4 type = *(const Type4 *)data; {
assert(type.uint == rt[TES4]); Type4 *type = NULL;
int err = sb_peek(esp, sizeof(Type4), &type);
data = walk_concat(data, size, cb); assert(err == 0);
assert(data == data_start + size); assert(type->uint == rt[TES4]);
} }
void espr_print(char *data, size_t size) { walk_concat(&esp, cb, from_parent);
struct walker_callbacks cb = { .pre = print_callback }; assert(sb_empty(esp));
espr_walk(data, size, cb);
} }
void print_callback(Node n, void *data, void **carry_out) { /* Unknown data will be some concatenation of groups and records.
*
* `walk_concat` will call the appropriate walking function
* for each segment of unknown data in this concatenation.
*/
void walk_concat(SizedBuf *tree, struct walker_callbacks cb, void *from_parent)
{
while (!sb_empty(*tree)) {
const Type4 *type = NULL;
int err = sb_peek(*tree, sizeof(Type4), &type);
assert(err == 0);
// check valid type
assert(rt[rt_hash(type->uint)] == type->uint);
// only need to distinguish between groups and records
if (type->uint == rt[GRUP])
walk_group(tree, cb, from_parent);
else
walk_record(tree, cb, from_parent);
}
}
/* Walk a group record. Group records are containers for any other type of
* record, including other group records.
*
* This function will also call `cb` with the node constructed from this group
* record.
*/
void walk_group(SizedBuf *tree, struct walker_callbacks cb, void *from_parent)
{
Group *header = NULL;
{
int err = sb_peek(*tree, sizeof(Group), &header);
assert(err == 0);
}
SizedBuf group = { .size = header->size };
{
int err = sb_recast(tree, group.size, &group.data);
assert(err == 0);
err = sb_recast(&group, sizeof(Group), &header);
assert(err == 0);
}
Node n = {
.header.group = header,
.data = group.data,
.type = NT_GROUP
};
void *carry = NULL;
void *to_children = NULL;
// Pre-walk callback
if (cb.pre)
cb.pre(n, cb.data, &carry, from_parent, &to_children);
// Walk through the concatenation of data inside the group.
walk_concat(&group, cb, to_children);
assert(sb_empty(group));
// Post-walk callback
if (cb.post)
cb.post(n, cb.data, carry);
}
void walk_record(SizedBuf *tree, struct walker_callbacks cb, void *from_parent)
{
Record *header = NULL;
char *data = NULL;
{
int err = sb_recast(tree, sizeof(Record), &header);
assert(err == 0);
err = sb_recast(tree, header->size, &data);
assert(err == 0);
}
assert(header->type.uint != rt[GRUP]);
Node n = {
.header.record = header,
.data = data,
.type = NT_RECORD
};
void *carry = NULL;
void *to_children = NULL;
/* Pre and post walk callbacks make less sense for record walking as
* records are leaf-ish, will still call both here for now as field
* walking may be added in the future.
*/
// Pre-walk callback
if (cb.pre)
cb.pre(n, cb.data, &carry, from_parent, &to_children);
// Post-walk callback
if (cb.post)
cb.post(n, cb.data, carry);
}
void espr_print(SizedBuf esp)
{
struct walker_callbacks cb = { .pre = print_cb };
espr_walk(esp, cb, NULL);
}
void print_cb(
Node n, void *data,
void **carry_out,
void *from_parent,
void **to_children
) {
(void)data; (void)data;
(void)carry_out; (void)carry_out;
(void)from_parent;
(void)to_children;
switch (n.type) { switch (n.type) {
case NT_GROUP: case NT_GROUP:
print_group_header(n.header.group); print_group_header(n.header.group);
@@ -97,82 +264,98 @@ void print_callback(Node n, void *data, void **carry_out) {
} }
} }
size_t espr_decompressed_size(char *data, size_t size) { ESPStats espr_stats(SizedBuf esp)
size_t dc_size = 0; {
struct walker_callbacks cb = { .pre = dc_size_cb, .data = &dc_size }; ESPStats stats = { 0 };
espr_walk(data, size, cb); struct walker_callbacks cb = { .pre = stats_cb, .data = &stats };
return dc_size; espr_walk(esp, cb, NULL);
return stats;
} }
// Adds the size of every node up, reading decompressed size from compressed records. /* Tallies up the group and record count. Calculates uncompressed size; groups
void dc_size_cb(Node n, void *data, void **carry_out) { * only need their header size tallied as their data size will be handled by
* further walking of the tree.
*/
void stats_cb(
Node n,
void *data,
void **carry_out,
void *from_parent,
void **to_children
) {
(void)carry_out; (void)carry_out;
size_t *dc_size = data; (void)from_parent;
(void)to_children;
struct esp_stats *stats = data;
switch (n.type) { switch (n.type) {
case NT_GROUP: case NT_GROUP:
// Only add header size for groups, internals will be walked stats->group_count++;
*dc_size += sizeof(Group); stats->decompressed_size += sizeof(Group);
break; break;
case NT_RECORD: case NT_RECORD:
// Add the whole record and header, records are leaf-ish stats->record_count++;
*dc_size += sizeof(Record); stats->decompressed_size += sizeof(Record);
if (n.header.record->flags & COMPRESSED_FLAG) { if (n.header.record->flags & COMPRESSED_FLAG) {
// Read decompressed size // uncompressed size is stored in the first 4 bytes of
*dc_size += *((uint32_t *)n.data); // data
} else stats->decompressed_size += *((uint32_t *)n.data);
*dc_size += n.header.record->size; } else {
stats->decompressed_size += n.header.record->size;
}
break; break;
default: default:
assert(false); // invalid node type assert(false); // invalid node type
} }
} }
size_t espr_formid_count(char *data, size_t size) { void espr_decompress(SizedBuf esp, SizedBuf decom)
size_t count = 0; {
struct walker_callbacks cb = { .pre = formid_count_cb, .data = &count }; struct walker_callbacks cb = {
espr_walk(data, size, cb); .pre = decompress_pre,
return count; .post = decompress_post,
} .data = &decom
/* FormID <-> Record relationship should be bijective. I do not believe
* groups have formids, and every record should have a unique formid,
* otherwise there would be clashes in the id space.
*/
void formid_count_cb(Node n, void *data, void **carry_out) {
(void)carry_out;
size_t *count = data;
if (n.type == NT_RECORD) {
(*count)++;
}
}
struct decom {
char *buf;
size_t remaining;
}; };
espr_walk(esp, cb, NULL);
void espr_decompress(char *data, size_t size, char *buf, size_t buf_size) {
struct decom s = { .buf = buf, .remaining = buf_size };
struct walker_callbacks cb = { .pre = decompress_pre, .post = decompress_post, .data = &s };
espr_walk(data, size, cb);
} }
void decompress_pre(Node n, void *decom_ptr, void **carry_out) { /* Handles the copying of groups and records, and the decompression of
struct decom *d = decom_ptr; * compressed record data.
*
* For groups it copies only the header as group data will be handled by further
* walking. The destination prior to copying will also be saved to carry_out for
* groups so that decompress_post can correctly update the size of the copied
* group.
*
* For uncompressed records it simply copies the entirety of the record to the
* destination. For compressed records in copies the header first and then
* directly decompresses the compressed record into the destination.
*/
void decompress_pre(
Node n,
void *out_buf,
void **carry_out,
void *from_parent,
void **to_children
) {
(void)from_parent;
(void)to_children;
SizedBuf *d = out_buf;
switch (n.type) { switch (n.type) {
case NT_RECORD: case NT_RECORD:
// compressed record // compressed record
if (n.header.record->flags & COMPRESSED_FLAG) { if (n.header.record->flags & COMPRESSED_FLAG) {
Record *copied_header = NULL;
{
// Acces for copied header
int err = sb_peek(*d, sizeof(Record), &copied_header);
assert(err == 0);
// copy header // copy header
memcpy(d->buf, n.header.record, sizeof(Record)); err = sb_copyin(d, (char *)n.header.record, sizeof(Record));
assert(err == 0);
// copied header reference }
Record *header = (Record *)d->buf;
// update decom struct
d->remaining -= sizeof(Record);
d->buf += sizeof(Record);
// decompress directly into buffer // decompress directly into buffer
// first 4 bytes are the decompressed size // first 4 bytes are the decompressed size
@@ -180,40 +363,40 @@ void decompress_pre(Node n, void *decom_ptr, void **carry_out) {
uint32_t to_copy = dc_size; uint32_t to_copy = dc_size;
uint32_t cur_size = n.header.record->size - sizeof(uint32_t); uint32_t cur_size = n.header.record->size - sizeof(uint32_t);
char *data_start = n.data + sizeof(uint32_t); char *data_start = n.data + sizeof(uint32_t);
int ret = uncompress((Bytef *)d->buf, (uLongf *)&to_copy, (Bytef *)data_start, (uLong)cur_size);
// check that we have enough space in the buffer
sb_check(*d, dc_size);
int ret = uncompress(
(Bytef *)d->data,
(uLongf *)&to_copy,
(Bytef *)data_start,
(uLong)cur_size
);
assert(ret == Z_OK); assert(ret == Z_OK);
assert(to_copy == dc_size); assert(to_copy == dc_size);
// update decom struct // update the buffer
d->remaining -= dc_size; sb_update(d, dc_size);
d->buf += dc_size;
// update header data size // update header data size
header->size = dc_size; copied_header->size = dc_size;
// unset compressed flag // unset compressed flag
header->flags &= ~COMPRESSED_FLAG; copied_header->flags &= ~COMPRESSED_FLAG;
} } else {
else {
// copy record // copy record
size_t record_size = sizeof(Record) + n.header.record->size; size_t record_size = sizeof(Record)
memcpy(d->buf, n.header.record, record_size); + n.header.record->size;
sb_copyin(d, (char *)n.header.record, record_size);
// update decom
d->remaining -= record_size;
d->buf += record_size;
} }
break; break;
case NT_GROUP: case NT_GROUP:
// copy header, contents will be copied while walking
memcpy(d->buf, n.header.group, sizeof(Group));
// save copied header location for post-walk group size recalc // save copied header location for post-walk group size recalc
*carry_out = (void *)d->buf; *carry_out = (void *)d->data;
// update decom // copy header, contents will be copied while walking
d->buf += sizeof(Group); sb_copyin(d, (char *)n.header.group, sizeof(Group));
d->remaining -= sizeof(Group);
break; break;
default: default:
@@ -221,151 +404,170 @@ void decompress_pre(Node n, void *decom_ptr, void **carry_out) {
} }
} }
void decompress_post(Node n, void *decom_ptr, void **carry_in) { /* Handles recalculating group size after decompression. The location of the
struct decom *d = decom_ptr; * the group's copied header will be passed in in carry_in and can be used both
* to access the copied group header and calculate the new size of the group
* based on the difference between the current destination pointer and the
* group header pointer.
*/
void decompress_post(Node n, void *out, void *carry_in)
{
SizedBuf *d = out;
// only need to handle group resize // only need to handle group resize
if (n.type == NT_GROUP) { if (n.type == NT_GROUP) {
Group *g = (Group *)(*carry_in); Group *g = (Group *)carry_in;
uint32_t new_size = (uint32_t)((char *)d->buf - (char *)g); uint32_t new_size = (uint32_t)((char *)d->data - (char *)g);
g->size = new_size; g->size = new_size;
} }
} }
/* Unknown data will be some concatenation of groups and records. void print_group_header(Group *header)
* {
* `walk_concat` will call the appropriate walking function
* for each segment of unknown data in this concatenation.
*/
char *walk_concat(char *data, size_t size, struct walker_callbacks cb) {
const char *end = data + size;
while (data != end) {
assert(data < end);
const Type4 *type = (Type4 *)data;
// check valid type
assert(rt[rth2rt[rt_hash(type->uint)]] == type->uint);
// only need to distinguish between groups and records
if (type->uint == rt[GRUP])
data = walk_group(data, cb);
else
data = walk_record(data, cb);
}
return data;
}
/* Walk a group record. Group records are containers for any other type of record,
* including other group records.
*
* This function will also call `cb` with the node constructed from this group record.
*/
char *walk_group(char *data, struct walker_callbacks cb) {
Group *const header = (Group *const)data;
// The size in the group header includes the size of the header
char *data_start = data + sizeof(Group);
char *data_end = data + header->size;
size_t data_size = data_end - data_start;
Node n = { .header.group = header, .data = data_start, .type = NT_GROUP };
void *carry;
// Pre-walk callback
if (cb.pre)
cb.pre(n, cb.data, &carry);
// Walk through the concatenation of data inside the group.
data = walk_concat(data_start, data_size, cb);
assert(data == data_end);
// Post-walk callback
if (cb.post)
cb.post(n, cb.data, &carry);
return data;
}
char *walk_record(char *data, struct walker_callbacks cb) {
Record *header = (Record *)data;
assert(header->type.uint != rt[GRUP]);
char *data_start = data + sizeof(Record);
Node n = { .header.record = header, .data = data_start, .type = NT_RECORD };
void *carry;
/* Pre and post walk callbacks make less sense for record walking as records
* are leaf-ish, will still call both here for now as field walking may be
* added in the future.
*/
// Pre-walk callback
if (cb.pre)
cb.pre(n, cb.data, &carry);
// Update data ptr based on record size.
data += sizeof(Record) + header->size;
// Post-walk callback
if (cb.post)
cb.post(n, cb.data, &carry);
return data;
}
void print_group_header(Group *header) {
printf("--- HEADER: GROUP ---\n");
print_type(header->grup);
printf("Size: %u\n", header->size);
print_group_label(header);
assert(header->type < GTS_SIZE); assert(header->type < GTS_SIZE);
printf("Group type: %s\n", group_type_strings[header->type]);
print_timestamp(header->timestamp); // Guess at enough with significant margin
printf("Version Control Info: %04x\n", header->vcinfo); char buf[1024] = { 0 };
printf("Unknown: %08x\n", header->unknown); const struct str_buf sb_pre = { .buf = buf, .size = sizeof(buf) };
struct str_buf sb = sb_pre;
// literals
struct str_lit
l1 = STR_LIT("--- HEADER: GROUP ---"),
l2 = STR_LIT("\nType: "),
l3 = STR_LIT("\nSize: "),
l4 = STR_LIT("\nLabel: "),
l5 = STR_LIT("\nGroup type: "),
l6 = STR_LIT("\nTimestamp: "),
l7 = STR_LIT("\nVersion Control Info: "),
l8 = STR_LIT("\nUnknown: "),
l9 = STR_LIT("\n");
struct str_lit gt = group_type_strings[header->type];
// construct output
litcopy(&sb, l1);
litcopy(&sb, l2); type_str(&sb, header->grup);
litcopy(&sb, l3); num_str(&sb, header->size, 10);
litcopy(&sb, l4); group_label_str(&sb, header);
litcopy(&sb, l5); litcopy(&sb, gt);
litcopy(&sb, l6); timestamp_str(&sb, header->timestamp);
litcopy(&sb, l7); num_str(&sb, header->vcinfo, 16);
litcopy(&sb, l8); num_str(&sb, header->unknown, 16);
litcopy(&sb, l9);
sb_write(STDOUT_FILENO, sb_pre, sb);
} }
void print_record_header(Record *header) { void litcopy(struct str_buf *sb, struct str_lit lit)
printf("--- HEADER: RECORD ---\n"); {
print_type(header->type); assert(sb->size >= lit.size);
print_record_flags(header); memcpy(sb->buf, lit.lit, lit.size);
printf("FormID: %x\n", header->formid); sb->size -= lit.size;
print_timestamp(header->timestamp); sb->buf += lit.size;
printf("Version Control Info: %04x\n", header->vcinfo);
printf("Version: %u\n", header->version);
printf("Unknown: %08x\n", header->unknown);
} }
void print_group_label(Group *header) { void num_str(struct str_buf *sb, unsigned long num, int radix)
printf("Label: "); {
_CrtSetDebugFillThreshold(0);
errno_t ret = _ultoa_s(num, sb->buf, sb->size, radix);
assert(ret == 0);
_CrtSetDebugFillThreshold(SIZE_MAX);
int len = (int)strlen(sb->buf);
sb->size -= len;
sb->buf += len;
}
void type_str(struct str_buf *sb, Type4 type)
{
assert(sb->size >= 4);
for (size_t i = 0; i != 4; i++)
sb->buf[i] = type.bytes[i];
sb->buf += 4;
sb->size -= 4;
}
void group_label_str(struct str_buf *sb, Group *header)
{
switch (header->type) { switch (header->type) {
case GT_TOP: case GT_TOP:
print_type4(header->label.type); type_str(sb, header->label.type);
break; break;
case GT_INTERIOR_CELL_BLOCK: case GT_INTERIOR_CELL_BLOCK:
case GT_INTERIOR_CELL_SUBBLOCK: case GT_INTERIOR_CELL_SUBBLOCK:
printf("%d", header->label.number); num_str(sb, header->label.number, 10);
break;
case GT_EXTERIOR_CELL_BLOCK: case GT_EXTERIOR_CELL_BLOCK:
case GT_EXTERIOR_CELL_SUBBLOCK: case GT_EXTERIOR_CELL_SUBBLOCK:
printf("X: %d, Y: %d", header->label.coord[1], header->label.coord[0]); uint16_t x = header->label.coord[1], y = header->label.coord[0];
litcopy(sb, LIT("X: ")); num_str(sb, x, 10);
litcopy(sb, LIT("Y: ")); num_str(sb, y, 10);
break;
case GT_WORLD_CHILDREN: case GT_WORLD_CHILDREN:
case GT_CELL_CHILDREN: case GT_CELL_CHILDREN:
case GT_TOPIC_CHILDREN: case GT_TOPIC_CHILDREN:
case GT_CELL_PERSISTENT_CHILDREN: case GT_CELL_PERSISTENT_CHILDREN:
case GT_CELL_TEMPORARY_CHILDREN: case GT_CELL_TEMPORARY_CHILDREN:
printf("FormID[%x]", header->label.formid); litcopy(sb, LIT("FormID["));
num_str(sb, header->label.formid, 16);
litcopy(sb, LIT("]"));
break; break;
default: default:
assert(false); // invalid group type assert(false); // invalid group type
} }
printf("\n");
} }
void print_record_flags(Record *header) { void timestamp_str(struct str_buf *sb, uint16_t timestamp)
printf("Flags:\n"); {
Timestamp ts = convert_ts(timestamp);
litcopy(sb, LIT("20x"));
num_str(sb, ts.year, 10);
litcopy(sb, LIT("-"));
num_str(sb, ts.month, 10);
litcopy(sb, LIT("-"));
num_str(sb, ts.day, 10);
}
void sb_write(int fp, struct str_buf sb_pre, struct str_buf sb_post)
{
int size = sb_pre.size - sb_post.size;
assert(size >= 0);
int ret = _write(fp, sb_pre.buf, size);
assert(ret == size);
}
void print_record_header(Record *header)
{
char buf[1024] = { 0 };
const struct str_buf sb_pre = { .buf = buf, .size = sizeof(buf) };
struct str_buf sb = sb_pre;
const struct str_lit
l1 = LIT("--- HEADER: RECORD ---"),
l2 = LIT("\nType: "),
l3 = LIT("\nFlags: "),
l4 = LIT("\nFormID: "),
l5 = LIT("\nTimestamp: "),
l6 = LIT("\nVersion Control Info: "),
l7 = LIT("\nVersion: "),
l8 = LIT("\nUnknown: "),
l9 = LIT("\n");
litcopy(&sb, l1);
litcopy(&sb, l2); type_str(&sb, header->type);
litcopy(&sb, l3); record_flags_str(&sb, header);
litcopy(&sb, l4); num_str(&sb, header->formid, 16);
litcopy(&sb, l5); timestamp_str(&sb, header->timestamp);
litcopy(&sb, l6); num_str(&sb, header->vcinfo, 16);
litcopy(&sb, l7); num_str(&sb, header->version, 10);
litcopy(&sb, l8); num_str(&sb, header->unknown, 16);
litcopy(&sb, l9);
sb_write(STDOUT_FILENO, sb_pre, sb);
}
void record_flags_str(struct str_buf *sb, Record *header)
{
uint32_t flags = header->flags; uint32_t flags = header->flags;
const uint32_t type = header->type.uint; const uint32_t type = header->type.uint;
@@ -378,19 +580,27 @@ void print_record_flags(Record *header) {
rfs_inner *const flag_lut = rfs[rt_hash(type)]; rfs_inner *const flag_lut = rfs[rt_hash(type)];
if (flag_lut) { if (flag_lut) {
while (flags != 0) { while (flags != 0) {
// get next flag, from lowest bit to highest
// will always be >= 0 as flags is not 0 // will always be >= 0 as flags is not 0
int highest = 31 - __lzcnt(flags); int lowest = _tzcnt_u32(flags);
assert(highest >= 0); assert(lowest < 32);
const char *const str = (*flag_lut)[highest];
if (str) { // get flag string
printf(" - %s\n", str); const struct str_lit lit = (*flag_lut)[lowest];
flags -= ((uint32_t)1) << highest;
} else // not a valid flag
if (!lit.lit)
break; break;
// copy flag string
litcopy(sb, LIT("\n - ")); litcopy(sb, lit);
// remove flag from to be processed
flags ^= ((uint32_t)1) << lowest;
} }
} }
} }
// slow path
if (flags != 0) { if (flags != 0) {
printf("\n\nOriginal flags: %08x\n", header->flags); printf("\n\nOriginal flags: %08x\n", header->flags);
printf("Unhandled flags: %08x\n", flags); printf("Unhandled flags: %08x\n", flags);
@@ -398,25 +608,14 @@ void print_record_flags(Record *header) {
} }
} }
// This is the Skyrim SE timestamp format /* Converts the bit-packed/encoded timestamp used in esp/esm files into day,
void print_timestamp(uint16_t _ts) { * month and year. See UESP for further explanation.
Timestamp ts = convert_ts(_ts); *
printf("Timestamp: 20x%u-%02u-%02u\n", ts.year, ts.month, ts.day); * This currently handles the timestamp format used in Skyrim.esm, but newer
} * files apparently use a different format. This will need to be handled later.
*/
void print_type(Type4 type) { Timestamp convert_ts(uint16_t ts)
printf("Type: "); {
print_type4(type);
printf("\n");
}
void print_type4(Type4 val) {
// invariant: printed i characters from val.bytes
for (size_t i = 0; i != 4; i++)
printf("%c", val.bytes[i]);
}
Timestamp convert_ts(uint16_t ts) {
/* /*
const uint8_t day = (uint8_t)(ts & day_mask); const uint8_t day = (uint8_t)(ts & day_mask);
const uint8_t month = (uint8_t)((ts >> month_offset) & month_mask); const uint8_t month = (uint8_t)((ts >> month_offset) & month_mask);
@@ -431,3 +630,140 @@ Timestamp convert_ts(uint16_t ts) {
return (Timestamp) { year, month, day }; return (Timestamp) { year, month, day };
} }
MetaTree espr_create_tree(SizedBuf in, SizedBuf tree)
{
MetaTree mtree = { .esp = in, .tree = tree };
// create root node
MetaNode *root = NULL;
{
int err = sb_recast(&tree, sizeof(MetaNode), &root);
assert(err == 0);
}
*root = (MetaNode){ 0 };
// walk
struct walker_callbacks cb = { .pre = create_tree_cb, .data = &tree };
espr_walk(in, cb, root);
mtree.root = root;
mtree.size = in.size;
return mtree;
}
void create_tree_cb(
const Node n,
void *data,
void **carry_out,
void *from_parent,
void **to_children
) {
(void)carry_out;
// add new metanode to tree
SizedBuf *tree = data;
MetaNode *m = NULL;
{
int err = sb_recast(tree, sizeof(MetaNode), &m);
assert(err == 0);
}
// parent passes their MetaNode to children
MetaNode *p = from_parent;
// construct new node
*m = (MetaNode){ 0 }; // zero/null unused
m->n = n;
m->prev = p->last_child;
// the linked list of children may not already exist
if (p->last_child)
p->last_child->next = m;
else
p->first_child = m;
p->last_child = m;
// send self to children
*to_children = m;
}
void espr_meta_walk(MetaTree tree, struct meta_callbacks cb) {
espr_meta_node_walk(tree.root, cb);
}
void espr_meta_node_walk(MetaNode *m, struct meta_callbacks cb) {
cb.pre(m, cb.data);
MetaNode *child = m->first_child;
while (child) {
espr_meta_node_walk(child, cb);
child = child->next;
}
}
void espr_serialize(MetaTree tree, SizedBuf out) {
struct meta_callbacks cb = { .pre = serialize_cb, .data = &out };
espr_meta_walk(tree, cb);
}
void serialize_cb(MetaNode *m, void *data) {
SizedBuf *out = data;
// exit on empty node
if (!m->n.data)
return;
switch (m->n.type) {
case NT_GROUP:
// only serialize the header of groups
{
int err = sb_copyin(out, (char *)m->n.header.group, sizeof(Group));
assert(err == 0);
}
break;
case NT_RECORD:
size_t data_size = m->n.header.record->size;
char *header = (char *)m->n.header.record;
// serialize header and data separately as they may be
// discontiguous
{
int err = sb_copyin(out, header, sizeof(Record));
assert(err == 0);
err = sb_copyin(out, m->n.data, data_size);
assert(err == 0);
}
break;
default:
assert(false);
}
}
void espr_meta_string(MetaNode *m, SizedBuf str_buf)
{
// root node
if (!m->n.data) {
snprintf(str_buf.data, str_buf.size, "Root");
return;
}
char buf[1024] = { 0 };
struct str_buf sb = { .buf = buf, .size = 1024 };
switch (m->n.type) {
case NT_GROUP:
{
group_label_str(&sb, m->n.header.group);
const char *lbl = group_type_strings[m->n.header.group->type].lit;
snprintf(str_buf.data, str_buf.size, "GRUP; %s; %s", lbl, buf);
break;
}
case NT_RECORD:
{
type_str(&sb, m->n.header.record->type);
snprintf(str_buf.data, str_buf.size, "%s; FormID[%08x]", buf, m->n.header.record->formid);
break;
}
default:
assert(false);
}
}

View File

@@ -111,7 +111,7 @@
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C> <LanguageStandard_C>stdc11</LanguageStandard_C>
<AdditionalIncludeDirectories>..\zlib</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\zlib-win-build;..\SizedBuffer</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
</ClCompile> </ClCompile>
<Link> <Link>
@@ -129,7 +129,7 @@
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard_C>stdc11</LanguageStandard_C> <LanguageStandard_C>stdc11</LanguageStandard_C>
<AdditionalIncludeDirectories>..\zlib-win-build</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\zlib-win-build;..\SizedBuffer</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem> <SubSystem>
@@ -144,10 +144,13 @@
<ClInclude Include="msh.h" /> <ClInclude Include="msh.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Derived.c" /> <ClCompile Include="LUT.c" />
<ClCompile Include="Reader.c" /> <ClCompile Include="Reader.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SizedBuffer\SizedBuffer.vcxproj">
<Project>{cb1c8f66-5b90-4de7-890b-f6430daaf25f}</Project>
</ProjectReference>
<ProjectReference Include="..\zlib-win-build\build-VS2022\libz-static\libz-static.vcxproj"> <ProjectReference Include="..\zlib-win-build\build-VS2022\libz-static\libz-static.vcxproj">
<Project>{b56d17bc-072b-42f3-844a-870a07afbaaa}</Project> <Project>{b56d17bc-072b-42f3-844a-870a07afbaaa}</Project>
</ProjectReference> </ProjectReference>

View File

@@ -26,7 +26,7 @@
<ClCompile Include="Reader.c"> <ClCompile Include="Reader.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Derived.c"> <ClCompile Include="LUT.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>

View File

@@ -1,3 +1,8 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>

View File

@@ -1,33 +0,0 @@
with open("record_types.txt", "r") as f:
data = f.read()
ACCEPTED = {
"ACHR", "ACTI", "TACT", "ALCH", "AMMO", "ANIO",
"ARMO", "PARW", "PBAR", "PBEA", "PCON", "PFLA",
"PGRE", "PHZD", "PMIS", "CELL", "CONT", "CSTY",
"DOOR", "EYES", "FURN", "GLOB", "HDPT", "MSTT",
"IDLM", "SLGM", "NAVM", "PERK", "SHOU", "RELA",
"CLFM", "INFO", "KEYM", "LAND", "LIGH", "LSCR",
"MISC", "NPC_", "RACE", "REFR", "REGN", "STAT",
"TES4", "TREE", "WEAP", "WRLD",
}
NONE = "none"
GROUPING = 3
PREFIX = "RT_"
line = []
out = ""
for i, l in enumerate(data.split("\n")):
word = l.strip()
if word in ACCEPTED:
line += [f"[{PREFIX}{word}] = _{word.lower()}"]
else:
line += [f"[{PREFIX}{word}] = _{NONE}"]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
if line:
out += ", ".join(line) + ",\n"
print(out)

View File

@@ -1,20 +0,0 @@
with open("group_order.txt", "r") as f:
data = f.read()
types = data.split(", ")
PREFIX = "RT_"
GROUPING = 6
out = ""
line = []
for i, t in enumerate(types):
line += [f"{PREFIX}{t}"]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
# leftover
if line:
out += ", ".join(line) + ",\n"
print(out)

View File

@@ -1,28 +0,0 @@
with open("record_types.txt", "r") as f:
data = f.read()
ACCEPTED = {
"ACTI", "STAT", "TREE", "FLOR", "CONT", "DOOR",
"LIGH", "MSTT", "ADDN", "ALCH", "SCRL", "AMMO",
"ARMO", "INGR", "KEYM", "MISC", "SLGM", "WEAP",
}
NONE = "none"
GROUPING = 3
PREFIX = "RT_"
line = []
out = ""
for i, l in enumerate(data.split("\n")):
word = l.strip()
if word in ACCEPTED:
line += [f"[{PREFIX}{word}] = _refr_{word.lower()}"]
else:
line += [f"[{PREFIX}{word}] = _{NONE} "]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
if line:
out += ", ".join(line) + ",\n"
print(out)

View File

@@ -1,22 +0,0 @@
with open("record_types.txt", "r") as f:
data = f.read()
GROUPING = 3
PREFIX = "RT_"
line = []
out = ""
for i, l in enumerate(data.split("\n")):
word = l.strip()
#bytes_ = [ord(c) for c in word]
#le_hex = "".join([hex(c)[2:] for c in reversed(bytes_)])
#line += [f"0x{le_hex}u"]
line += [f"[{word}] = {PREFIX}{word}"]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
if line:
out += ", ".join(line) + ",\n"
print(out)

View File

@@ -1,22 +0,0 @@
with open("record_types.txt", "r") as f:
data = f.read()
GROUPING = 3
PREFIX = "RT_"
line = []
out = ""
for i, l in enumerate(data.split("\n")):
word = l.strip()
#bytes_ = [ord(c) for c in word]
#le_hex = "".join([hex(c)[2:] for c in reversed(bytes_)])
#line += [f"0x{le_hex}u"]
line += [f"[{PREFIX}{word}] = {word}"]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
if line:
out += ", ".join(line) + ",\n"
print(out)

View File

@@ -1,19 +0,0 @@
with open("record_types.txt", "r") as f:
data = f.read()
GROUPING = 6
PREFIX = "RT_"
line = []
out = ""
for i, l in enumerate(data.split("\n")):
word = l.strip()
line += [f"{PREFIX}{word}"]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
if line:
out += ", ".join(line) + ",\n"
print(out)

View File

@@ -1,22 +0,0 @@
with open("record_types.txt", "r") as f:
data = f.read()
GROUPING = 3
PREFIX = "RT_"
line = []
out = ""
for i, l in enumerate(data.split("\n")):
word = l.strip()
#bytes_ = [ord(c) for c in word]
#le_hex = "".join([hex(c)[2:] for c in reversed(bytes_)])
#line += [f"0x{le_hex}u"]
line += [f"[{PREFIX}{word}] = LE('{word}')"]
if (i + 1) % GROUPING == 0:
out += ", ".join(line) + ",\n"
line = []
if line:
out += ", ".join(line) + ",\n"
print(out)

1
glfw Submodule

Submodule glfw added at 6b57e08bb0

View File

@@ -1 +0,0 @@
GMST, KYWD, LCRT, AACT, TXST, GLOB, CLAS, FACT, HDPT, HAIR, EYES, RACE, SOUN, ASPC, MGEF, SCPT, LTEX, ENCH, SPEL, SCRL, ACTI, TACT, ARMO, BOOK, CONT, DOOR, INGR, LIGH, MISC, APPA, STAT, SCOL, MSTT, PWAT, GRAS, TREE, CLDC, FLOR, FURN, WEAP, AMMO, NPC_, LVLN, KEYM, ALCH, IDLM, COBJ, PROJ, HAZD, SLGM, LVLI, WTHR, CLMT, SPGD, RFCT, REGN, NAVI, CELL, WRLD, DIAL, QUST, IDLE, PACK, CSTY, LSCR, LVSP, ANIO, WATR, EFSH, EXPL, DEBR, IMGS, IMAD, FLST, PERK, BPTD, ADDN, AVIF, CAMS, CPTH, VTYP, MATT, IPCT, IPDS, ARMA, ECZN, LCTN, MESG, RGDL, DOBJ, LGTM, MUSC, FSTP, FSTS, SMBN, SMQN, SMEN, DLBR, MUST, DLVW, WOOP, SHOU, EQUP, RELA, SCEN, ASTP, OTFT, ARTO, MATO, MOVT, HAZD, SNDR, DUAL, SNCT, SOPM, COLL, CLFM, REVB

1
imgui Submodule

Submodule imgui added at aceab9a877

View File

@@ -1,3 +1,9 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0.If a copy of the MPL was not distributed with this
* file, You can obtain one at http ://mozilla.org/MPL/2.0/.
*/
// CURRENTLY BROKEN, needs to be remade for new ESPReader structure // CURRENTLY BROKEN, needs to be remade for new ESPReader structure
#include "msh.h" #include "msh.h"
@@ -18,7 +24,7 @@
bool buf[NUM]; bool buf[NUM];
int main() { int main(void) {
uint32_t seed = 1; uint32_t seed = 1;
bool clash; bool clash;
size_t max = 0; size_t max = 0;
@@ -40,7 +46,8 @@ int main() {
} }
clash = true; clash = true;
break; break;
} else { }
else {
buf[index] = true; buf[index] = true;
} }
} }
@@ -67,7 +74,8 @@ int main() {
printf(" "); printf(" ");
printf("RT_%s = %3u,", name, index); printf("RT_%s = %3u,", name, index);
} }
} else { }
else {
printf("Seed not found. Max: %llu\n", max); printf("Seed not found. Max: %llu\n", max);
} }

View File

@@ -114,7 +114,7 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>EnableAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>

View File

@@ -1,5 +0,0 @@
as per xedit
unknown flags: left/right/compute cover? preferred pathing?
is the grid a literal grid overlayed with triangles assigned to each grid square?

View File

@@ -1,121 +0,0 @@
Action
Actor Reference
Activator
Addon Node
Potion
Ammo
Animation Object
Apparatus (probably unused)
Armor Addon (Model)
Armor
Art Object
Acoustic Space
Association Type
Actor Values/Perk Tree Graphics
Book
Body Part Data
Camera Shot
Cell
Class
Color
Climate
Constructible Object (recipes)
Collision Layer
Container
Camera Path
Combat Style
Debris
Dialog Topic
Dialog Branch
Dialog View
Default Object Manager
Door
Dual Cast Data (possibly unused)
Encounter Zone
Effect Shader
Enchantment
Equip Slot (flag-type values)
Explosion
Eyes
Faction
Flora
Form List (non-leveled list)
Footstep
Footstep Set
Furniture
Global Variable
Game Setting
Grass
Form Group
Hazard
Head Part
Idle Animation
Idle Marker
Image Space Modifier
Image Space
Dialog Topic Info
Ingredient
Impact Data
Impact Data Set
Key
Keyword
Landscape
Location Reference Type
Location
Lighting Template
Light
Load Screen
Land Texture
Leveled Item
Leveled Actor
Leveled Spell
Material Object
Material Type
Message
Magic Effect
Misc. Object
Movement Type
Movable Static
Music Type
Music Track
Navigation (master data)
NavMesh
Note
Actor (NPC, Creature)
Outfit
AI Package
Perk
Placed grenade
Placed hazard
Projectile
Quest
Race / Creature type
Object Reference
Region (Audio/Weather)
Relationship
Reverb Parameters
Visual Effect
Scene
Scroll
Shout
Soul Gem
Story Manager Branch Node
Story Manager Event Node
Story Manager Quest Node
Sound Category
Sound Reference
Sound Output Model
Sound
Spell
Shader Particle Geometry
Static
Talking Activator
Plugin info / Header
Tree
Texture Set
Voice Type
Water Type
Weapon
Word Of Power
Worldspace
Weather

View File

@@ -1,127 +0,0 @@
AACT
ACHR
ACTI
ADDN
ALCH
AMMO
ANIO
APPA
ARMA
ARMO
ARTO
ASPC
ASTP
AVIF
BOOK
BPTD
CAMS
CELL
CLAS
CLDC
CLFM
CLMT
COBJ
COLL
CONT
CPTH
CSTY
DEBR
DIAL
DLBR
DLVW
DOBJ
DOOR
DUAL
ECZN
EFSH
ENCH
EQUP
EXPL
EYES
FACT
FLOR
FLST
FSTP
FSTS
FURN
GLOB
GMST
GRAS
GRUP
HAIR
HAZD
HDPT
IDLE
IDLM
IMAD
IMGS
INFO
INGR
IPCT
IPDS
KEYM
KYWD
LAND
LCRT
LCTN
LGTM
LIGH
LSCR
LTEX
LVLI
LVLN
LVSP
MATO
MATT
MESG
MGEF
MISC
MOVT
MSTT
MUSC
MUST
NAVI
NAVM
NOTE
NPC_
OTFT
PACK
PERK
PGRE
PHZD
PROJ
PWAT
QUST
RACE
REFR
REGN
RELA
REVB
RFCT
RGDL
SCEN
SCOL
SCPT
SCRL
SHOU
SLGM
SMBN
SMEN
SMQN
SNCT
SNDR
SOPM
SOUN
SPEL
SPGD
STAT
TACT
TES4
TREE
TXST
VTYP
WATR
WEAP
WOOP
WRLD
WTHR