creature flags, lots of unknown ones

develop
Petr Mrázek 2009-10-24 02:32:57 +00:00
parent 1d704c646b
commit 6fb365b558
3 changed files with 169 additions and 36 deletions

@ -129,16 +129,6 @@ struct t_tree_desc
uint16_t z;
};
struct t_creature
{
uint16_t x;
uint16_t y;
uint16_t z;
uint32_t type;
uint32_t flags1;
uint32_t flags2;
};
/*
case 10:
ret += "leather";
@ -215,6 +205,113 @@ enum BiomeOffset
eBiomeCount
};
union t_creaturflags1
{
uint32_t whole;
struct {
//0000 0001 - 0000 0080
unsigned int unk1 : 1;
unsigned int dead : 1;
unsigned int unk3 : 1;
unsigned int mood_survivor : 1;
unsigned int hostile : 1;
unsigned int unk6 : 1;
unsigned int unk7_friendly : 1;
unsigned int unk8_friendly : 1;
//0000 0100 - 0000 8000
unsigned int unk9_not_on_unit_screen1 : 1;
unsigned int unk10 : 1;
unsigned int unk11_not_on_unit_screen2 : 1;
unsigned int unk12_friendly : 1;
unsigned int zombie : 1;
unsigned int skeletal : 1;
unsigned int unk15_not_part_of_fortress : 1; // resets to 0?
unsigned int unconscious : 1;
// 0001 0000 - 0080 0000
unsigned int unk17_not_visible : 1; // hidden? caged?
unsigned int invader1 : 1;
unsigned int unk19_not_listed_among_dwarves : 1;
unsigned int invader2 : 1;
unsigned int unk21 : 1;
unsigned int unk22 : 1;
unsigned int unk23 : 1;
unsigned int unk24 : 1;
// 0100 0000 - 8000 0000
unsigned int unk25 : 1;
unsigned int unk26_invisible_hidden : 1;
unsigned int tame : 1;
unsigned int unk28 : 1;
unsigned int royal_guard : 1;
unsigned int fortress_guard : 1;
unsigned int unk31 : 1;
unsigned int unk32 : 1;
} bits;
};
union t_creaturflags2
{
uint32_t whole;
struct {
//0000 0001 - 0000 0080
unsigned int unk1 : 1;
unsigned int unk2 : 1;
unsigned int unk3 : 1;
unsigned int unk4 : 1;
unsigned int unk5 : 1;
unsigned int unk6 : 1;
unsigned int unk7 : 1; // commonly set on dwarves
unsigned int dead : 1; // another dead bit
//0000 0100 - 0000 8000
unsigned int unk9 : 1;
unsigned int unk10 : 1;
unsigned int unk11 : 1;
unsigned int unk12 : 1;
unsigned int unk13 : 1;
unsigned int unk14 : 1;
unsigned int unk15 : 1;
unsigned int ground : 1;
// 0001 0000 - 0080 0000
unsigned int flying : 1;
unsigned int slaughter : 1;
unsigned int underworld : 1;
unsigned int unk20 : 1;
unsigned int unk21 : 1;
unsigned int unk22 : 1;
unsigned int unk23 : 1;
unsigned int unk24 : 1;
// 0100 0000 - 8000 0000
unsigned int unk25 : 1;
unsigned int unk26 : 1;
unsigned int unk27 : 1;
unsigned int unk28 : 1;
unsigned int unk29 : 1;
unsigned int unk30 : 1;
unsigned int unk31 : 1;
unsigned int unk32 : 1;
} bits;
};
struct t_creature
{
uint16_t x;
uint16_t y;
uint16_t z;
uint32_t type;
t_creaturflags1 flags1;
t_creaturflags2 flags2;
};
// TODO: research this further? consult DF hacker wizards?
union t_designation
{

@ -140,32 +140,11 @@ void Mwrite (uint32_t offset, uint32_t size, uint8_t *source)
inline
const string MreadCString (const uint32_t &offset)
{
string temp;
char temp_c[256];
DWORD read;
ReadProcessMemory(g_ProcessHandle, (int *) offset, temp_c, 255, &read);
temp_c[read+1] = 0;
temp = temp_c;
return temp;
// I'll let the original code go down in infamy, and burn. Burn. BURN. YES, BURN! DIE YOU HORRIBLE, HORRIBLE, CODE!
// Problems:
// * Does not check counter < 255, so potential buffer overrun.
// * Reads a single byte at a time, which is extremely inefficient (iirc, user -> kernel mode switch).
// * It adds an unnecessary null termination.
#if 0
string temp;
char temp_c[256];
int counter = 0;
char r;
do
{
r = MreadByte(offset+counter);
temp_c[counter] = r;
counter++;
} while (r);
temp_c[counter] = 0;
DWORD read;
ReadProcessMemory(g_ProcessHandle, (int *) offset, temp_c, 255, &read);
temp_c[read+1] = 0;
temp = temp_c;
return temp;
#endif
}

@ -46,10 +46,67 @@ int main (void)
t_creature temp;
DF.ReadCreature(i, temp);
cout << "creature type " << creaturestypes[temp.type].id << ", position:" << temp.x << " " << temp.y << " "<< temp.z << endl;
/*
* FLAGS 1
*/
cout << "flags1: ";
print_bits(temp.flags1, cout);
print_bits(temp.flags1.whole, cout);
cout << endl;
if(temp.flags1.bits.dead)
{
cout << "dead ";
}
if(temp.flags1.bits.unconscious)
{
cout << "unconscious ";
}
if(temp.flags1.bits.skeletal)
{
cout << "skeletal ";
}
if(temp.flags1.bits.zombie)
{
cout << "zombie ";
}
if(temp.flags1.bits.tame)
{
cout << "tame ";
}
if(temp.flags1.bits.royal_guard)
{
cout << "royal_guard ";
}
if(temp.flags1.bits.fortress_guard)
{
cout << "fortress_guard ";
}
/*
* FLAGS 2
*/
cout << endl << "flags2: ";
print_bits(temp.flags2, cout);
print_bits(temp.flags2.whole, cout);
cout << endl;
if(temp.flags2.bits.dead)
{
cout << "dead! ";
}
if(temp.flags2.bits.flying)
{
cout << "flying ";
}
if(temp.flags2.bits.ground)
{
cout << "grounded ";
}
if(temp.flags2.bits.slaughter)
{
cout << "slaughter ";
}
if(temp.flags2.bits.underworld)
{
cout << "from the underworld ";
}
cout << endl << endl;
}
DF.FinishReadCreatures();