Convert untagged unions to tagged. Fix some edge cases in check-structures-sanity union checking.

develop
Ben Lubar 2020-02-29 15:08:39 -06:00
parent 3240b6d897
commit 18523a1821
No known key found for this signature in database
GPG Key ID: 92939677AB59EDA4
3 changed files with 13 additions and 4 deletions

@ -1,9 +1,9 @@
df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() const df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() const
{ {
int32_t value = category * 32; int32_t value = int32_t(flag_type) * 32;
for (int32_t i = 0; i < 32; i++) for (int32_t i = 0; i < 32; i++)
{ {
if (flags.whole & (1 << i)) if (flag_data.whole & (1 << i))
{ {
value += i; value += i;
break; break;

@ -1 +1 @@
Subproject commit 17b1c45fff78d0c49aa8b4dc4824dc36ae7eae08 Subproject commit caf5b7dfd090c73a0cb08b5507b588ea8f12bab9

@ -6,6 +6,8 @@
#include "LuaTools.h" #include "LuaTools.h"
#include "LuaWrapper.h" #include "LuaWrapper.h"
#include "df/large_integer.h"
#if defined(WIN32) && defined(DFHACK64) #if defined(WIN32) && defined(DFHACK64)
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0501
#define WINVER 0x0501 #define WINVER 0x0501
@ -92,7 +94,7 @@ static const struct_field_info *find_union_tag(const struct_field_info *fields,
name.erase(name.length() - 4, 4); name.erase(name.length() - 4, 4);
name += "type"; name += "type";
if (tag_field->name == name) if (tag_field->mode != struct_field_info::END && tag_field->name == name)
{ {
// fast path; we already have the correct field // fast path; we already have the correct field
} }
@ -700,6 +702,13 @@ void Checker::check_dispatch(ToCheck & item)
return; return;
} }
// special case for large_integer weirdness
if (item.identity == df::identity_traits<df::large_integer>::get())
{
item.identity = df::identity_traits<int64_t>::get();
}
switch (item.identity->type()) switch (item.identity->type())
{ {
case IDTYPE_GLOBAL: case IDTYPE_GLOBAL: