Skip to content

Commit

Permalink
switch database json to c source
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman committed Nov 4, 2024
1 parent 7666227 commit 96acd8f
Show file tree
Hide file tree
Showing 470 changed files with 50,352 additions and 11 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/headers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ jobs:
- name: Run unit tests
run: python -m unittest discover -v -s ./scripts/headers -p '*test.py'

- name: Run generate_headers.py script
run: python scripts/headers/bw1_decomp_gen/generate_headers.py

- name: Run analyze_headers.py script
run: python scripts/headers/analyze_headers.py

- name: Upload generated headers as artifact
uses: actions/upload-artifact@v3
with:
name: bw1_decomp_gen_headers
path: generated_headers_output/
- name: Run generate_headers.py script
run: python scripts/headers/bw1_decomp_gen/generate_headers.py

- run: git diff

- name: Upload re-generated database as artifact
- name: Upload generated database as artifact
uses: actions/upload-artifact@v3
with:
name: bw1_decomp_gen_database
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bw1-decomp

[![Headers (Auto-generated)](https://img.shields.io/badge/Headers-(Autogenerated)-669ad3)](https://nightly.link/openblack/bw1-decomp/workflows/headers/main/bw1_decomp_gen_headers.zip)
[![Database (Auto-generated)](https://img.shields.io/badge/Database-(Autogenerated)-669ad3)](https://nightly.link/openblack/bw1-decomp/workflows/headers/main/bw1_decomp_gen_database.zip)

* [Reverse Engineering Wiki](https://github.com/openblack/bw1-decomp/wiki)
* [Black & White Patches](https://github.com/openblack/bw1-patches/tree/master/patches)
142 changes: 142 additions & 0 deletions black/Abode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#ifndef BW1_DECOMP_ABODE_INCLUDED_H
#define BW1_DECOMP_ABODE_INCLUDED_H

#include <assert.h> /* For static_assert */
#include <stdbool.h> /* For bool */
#include <stdint.h> /* For uint32_t, uint8_t, uintptr_t */

#include <chlasm/Enum.h> /* For RESOURCE_TYPE_LAST, enum TRIBE_TYPE */
#include <lionhead/lhlib/VER5.0/LHListHead.h> /* For DECLARE_LH_LIST_HEAD */

#include "GameThingWithPos.h" /* For struct GameThingWithPos */
#include "MapCoords.h" /* For struct MapCoords */
#include "MultiMapFixed.h" /* For struct MultiMapFixed, struct MultiMapFixedVftable */
#include "Object.h" /* For struct Object */
#include "Villager.h" /* For struct Villager */

// Forward Declares

struct Abode;
struct GAbodeInfo;
struct GPlayer;
struct GTribeInfo;
struct GameThingVftable;
struct GameThingWithPosVftable;
struct LH3DMesh;
struct LH3DSmoke;
struct LHPoint;
struct ObjectVftable;
struct Town;

enum ABODE_EPP
{
ABODE_EPP_LANTERN = 0x0,
ABODE_EPP_SCRIPT_HIGHLIGHT = 0x1,
_ABODE_EPP_COUNT = 0x2
};
static_assert(sizeof(enum ABODE_EPP) == 0x4, "Data type is of wrong size");

static const char* ABODE_EPP_strs[_ABODE_EPP_COUNT] = {
"ABODE_EPP_LANTERN",
"ABODE_EPP_SCRIPT_HIGHLIGHT",
};

struct AbodeVftable
{
struct MultiMapFixedVftable super; /* 0x0 */
uintptr_t MoveAbodeToPlannedAbodes; /* 0x90c */
void (__fastcall* DeleteDependancys)(struct Abode* this); /* 0x910 */
void (__fastcall* MakeFunctional)(struct Abode* this);
void (__fastcall* StopBeingFunctional)(struct Abode* this, const void* edx, struct GPlayer* param_1);
uintptr_t RestartBeingFunctional;
bool (__fastcall* CausesTownEmergencyIfDamaged)(struct Abode* this); /* 0x920 */
bool (__fastcall* CanBeHiddenIn)(struct Abode* this);
struct GTribeInfo* (__fastcall* GetTribe)(struct Abode* this);
};
static_assert(sizeof(struct AbodeVftable) == 0x92c, "Data type is of wrong size");

union AbodeBase
{
struct MultiMapFixed super;
struct Object super_object;
struct GameThingWithPos super_gamethingwithpos;
struct AbodeVftable* abode_vftable;
struct ObjectVftable* object_vftable;
struct MultiMapFixedVftable* multiMapFixed_vftable;
struct GameThingVftable* gameThing_vftable;
struct GameThingWithPosVftable* gameThingWithPos_vftable;
};
static_assert(sizeof(union AbodeBase) == 0x7c, "Data type is of wrong size");

struct Abode
{
union AbodeBase base; /* 0x0 */
uint32_t field_0x7c;
struct MapCoords drinking_water; /* 0x80 */
struct LH3DSmoke* smoke;
struct LH3DMesh* destruction_mesh; /* 0x90 */
uint32_t field_0x94;
struct Town* town;
struct Abode* next;
struct LHListHead__Villager villagers; /* 0xa0 */
struct Villager* male_female_villagers[0x2];
uint32_t field_0xb0;
uint8_t adult_count;
uint8_t field_0xb5;
uint8_t field_0xb6;
uint8_t field_0xb7;
uint8_t index;
uint8_t field_0xb9;
uint32_t resources[RESOURCE_TYPE_LAST];
};
static_assert(sizeof(struct Abode) == 0xc4, "Data type is of wrong size");

static struct AbodeVftable* __vt__5Abode = (struct AbodeVftable*)0x008a9a64;

// Static methods

// win1.41 00402e20 mac 103bf260 Abode::Create(MapCoords const &, GAbodeInfo const *, Town *, float, float, unsigned long, unsigned long, float, int, int)
struct Abode* __cdecl Create__5AbodeFRC9MapCoordsPC10GAbodeInfoP4TownffUlUlfii(const struct MapCoords* coords, const struct GAbodeInfo* info, struct Town* town, float y_angle, float scale, uint32_t param_6, uint32_t param_7, float food, int wood, int param_10);

// Constructors

// win1.41 00401350 mac 1033b330 Abode::Abode(MapCoords const &, GAbodeInfo const *, Town *, float, float, float, int)
struct Abode* __fastcall __ct__5AbodeFRC9MapCoordsPC10GAbodeInfoP4Townfffi(struct Abode* this, const void* edx, const struct MapCoords* coords, const struct GAbodeInfo* info, struct Town* town, float y_angle, float scale, float food, int wood);

// Non-virtual methods

// win1.41 00402bc0 mac inlined Abode::SetZero(void)
void __fastcall SetZero__5AbodeFv(struct Abode* this);
// win1.41 00403130 mac 1033b920 Abode::Init(int, unsigned long, unsigned long)
void __fastcall Init__5AbodeFiUlUl(struct Abode* this, const void* edx, int param_1, uint32_t food_amount, uint32_t wood_amount);
// win1.41 00403590 mac 103602f0 Abode::GetNewEp(ABODE_EPP, MapCoords*)
bool __fastcall GetNewEp__5AbodeF8ABODE_EPP7LHPoint(struct Abode* this, const void* edx, enum ABODE_EPP index, struct LHPoint* point);
// win1.41 00403e00 mac 10494a10 Abode::CreateAbodeSurroundingObjects(void)
void __fastcall CreateAbodeSurroundingObjects__5AbodeFv(struct Abode* this);
// win1.41 00404060 mac 100d2ca0 Abode::AddVillagerToAbode(Villager *)
void __fastcall AddVillagerToAbode__5AbodeFP8Villager(struct Abode* this, const void* edx, struct Villager* villager);
// win1.41 00404220 mac 1033b0e0 Abode::RemoveDeletedVillagerFromAbode(Villager *)
void __fastcall RemoveDeletedVillagerFromAbode__5AbodeFP8Villager(struct Abode* this, const void* edx, struct Villager* villager);
// win1.41 00404660 mac 1032c3e0 Abode::GetRoomLeftForAdults(void)
int __fastcall GetRoomLeftForAdults__5AbodeFv(struct Abode* this);
// win1.41 00404b40 mac 10329410 Abode::CalculateScoreForAddingVillagerToAbode(Villager *)
float __fastcall CalculateScoreForAddingVillagerToAbode__5AbodeFP8Villager(struct Abode* this, const void* edx, struct Villager* villager);
// win1.41 00405f40 mac 10177200 Abode::GetTribeType(void) const
enum TRIBE_TYPE __fastcall GetTribeType__5AbodeCFv(struct Abode* this);
// win1.41 00407020 mac inlined Abode::FindNearestDrinkingWater(float)
void __fastcall FindNearestDrinkingWater__5AbodeFf(struct Abode* this, const void* edx, float max_dist);
// win1.41 004072e0 mac 1000cd50 Abode::GetPosOutside(float, float, float)
struct MapCoords* __fastcall GetPosOutside__5AbodeFfff(struct Abode* this, const void* edx, struct MapCoords* coords, float param_2, float param_3, float param_4);

// Override methods

// win1.41 00403ee0 mac 1036edb0 Abode::InsertMapObject(void)
void __fastcall InsertMapObject__5AbodeFv(struct Abode* this);
// win1.41 00403200 mac 10576c70 Abode::CallVirtualFunctionsForCreation(const MapCoords&)
void __fastcall CallVirtualFunctionsForCreation__5AbodeFRC9MapCoords(struct Abode* this, const void* edx, const struct MapCoords* coords);
// win1.41 004047e0 mac 103c1e30 Abode::MakeFunctional(void)
void __fastcall MakeFunctional__5AbodeFv(struct Abode* this);

DECLARE_LH_LIST_HEAD(Abode);

#endif /* BW1_DECOMP_ABODE_INCLUDED_H */
76 changes: 76 additions & 0 deletions black/AbodeInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#ifndef BW1_DECOMP_ABODE_INFO_INCLUDED_H
#define BW1_DECOMP_ABODE_INFO_INCLUDED_H

#include <assert.h> /* For static_assert */
#include <stdbool.h> /* For bool */
#include <stdint.h> /* For uint32_t */

#include <chlasm/Enum.h> /* For enum ABODE_NUMBER, enum ABODE_TYPE, enum DYK_CATEGORY, enum TRIBE_TYPE */

#include "MultiMapFixedInfo.h" /* For struct GMultiMapFixedInfo */
#include "Name.h" /* For struct Name */

// Forward Declares

struct LHFile;
struct MapCoords;
struct Town;

struct GAbodeInfo
{
struct GMultiMapFixedInfo super; /* 0x0 */
enum ABODE_TYPE abodeType; /* 0x120 */
enum ABODE_NUMBER abodeNumber;
struct Name description;
uint32_t field_0x148;
uint32_t field_0x14c;
uint32_t field_0x150;
uint32_t field_0x154;
enum TRIBE_TYPE tribe_type;
uint32_t meshId;
uint32_t canBePhysicallyDamaged; /* 0x160 */
float startLife;
uint32_t startStrength;
float startDefence;
uint32_t startInfluence; /* 0x170 */
int maxVillagersInAbode;
int maxChildrenInAbode;
uint32_t startVillagersInAbode;
uint32_t startChildrenInAbode; /* 0x180 */
uint32_t startFood;
uint32_t startFoodRAnd;
uint32_t startWood;
uint32_t startWoodRAnd; /* 0x190 */
uint32_t howLongRuinLastsFor;
uint32_t potForResourceFood;
uint32_t potForResourceWood;
float percentTooCrowded; /* 0x1a0 */
int producesMobileObject;
float maxNumMobileObjectsToProduce;
float timeEachMobileObjectTakesToProduce;
float emptyAbodeLifeReducer; /* 0x1b0 */
int populationWhenNeeded;
float thresholdForStopBeingFunctional;
int toolTipsForBuild;
int didYouKnow; /* 0x1c0 */
enum DYK_CATEGORY dykCategory;
};
static_assert(sizeof(struct GAbodeInfo) == 0x1c8, "Data type is of wrong size");

static struct GObjectInfoVftable* __vt__10GAbodeInfo = (struct GObjectInfoVftable*)0x008a99f8;

// Static methods

// win1.41 00405a70 mac 101ca0c0 GAbodeInfo::GetInfoFromText(char *)
int __cdecl GetInfoFromText__10GAbodeInfoFPc(const char* text);
// win1.41 00405b30 mac 1006f680 GAbodeInfo::Find(TRIBE_TYPE, ABODE_NUMBER)
struct GAbodeInfo* __cdecl Find__10GAbodeInfoF10TRIBE_TYPE12ABODE_NUMBER(enum TRIBE_TYPE tribe_type, enum ABODE_NUMBER abode_number);

// Non-virtual methods

// win1.41 00404b10 mac 1015a260 GAbodeInfo::IsOkToCreateAtPos(MapCoords const &, float, float, Town *) const
bool __fastcall IsOkToCreateAtPos__10GAbodeInfoCFRC9MapCoordsffP4Town(const struct GAbodeInfo* this, const void* edx, const struct MapCoords* coords, float param_2, float param_3, struct Town* town);
// win1.41 0042e520 mac inlined GAbodeInfo::LoadBinary(LHFile *)
void __fastcall LoadBinary__10GAbodeInfoFP6LHFile(struct GAbodeInfo* this, const void* edx, struct LHFile* file);

#endif /* BW1_DECOMP_ABODE_INFO_INCLUDED_H */
18 changes: 18 additions & 0 deletions black/Alignment.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BW1_DECOMP_ALIGNMENT_INCLUDED_H
#define BW1_DECOMP_ALIGNMENT_INCLUDED_H

#include <assert.h> /* For static_assert */

#include "Base.h" /* For struct Base */

struct GAlignment
{
struct Base super; /* 0x0 */
float value;
float field_0xc;
};
static_assert(sizeof(struct GAlignment) == 0x10, "Data type is of wrong size");

static struct BaseVftable* __vt__10GAlignment = (struct BaseVftable*)0x008cc7f0;

#endif /* BW1_DECOMP_ALIGNMENT_INCLUDED_H */
47 changes: 47 additions & 0 deletions black/Animal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef BW1_DECOMP_ANIMAL_INCLUDED_H
#define BW1_DECOMP_ANIMAL_INCLUDED_H

#include <assert.h> /* For static_assert */
#include <stdint.h> /* For uint32_t, uint8_t */

#include <chlasm/GStates.h> /* For ANIMAL_STATE_LAST_STATE */

#include "Living.h" /* For struct Living */
#include "LivingAction.h" /* For struct Living__StateTableEntry */

struct Animal__StateTable
{
struct Living__StateTableEntry entries[ANIMAL_STATE_LAST_STATE]; /* 0x0 */
};
static_assert(sizeof(struct Animal__StateTable) == 0x1dd0, "Data type is of wrong size");

struct Animal
{
struct Living super; /* 0x0 */
uint8_t field_0xe0[0x2c];
uint8_t death_reason; /* 0x10c */
float field_0x110;
float field_0x114;
float field_0x118;
float field_0x11c;
uint32_t field_0x120;
float field_0x124;
float field_0x128;
float field_0x12c;
float field_0x130;
float field_0x134;
float field_0x138;
float field_0x13c;
float field_0x140;
float field_0x144;
};
static_assert(sizeof(struct Animal) == 0x148, "Data type is of wrong size");

static struct LivingVftable* __vt__6Animal = (struct LivingVftable*)0x008ab7cc;

// Non-virtual methods

// win1.41 0041abb0 mac 10087bd0 Animal::KeepFlockMemberWithinFlockArea(void)
uint32_t __fastcall KeepFlockMemberWithinFlockArea__6AnimalFv(struct Animal* this);

#endif /* BW1_DECOMP_ANIMAL_INCLUDED_H */
22 changes: 22 additions & 0 deletions black/AnimatedStatic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef BW1_DECOMP_ANIMATED_STATIC_INCLUDED_H
#define BW1_DECOMP_ANIMATED_STATIC_INCLUDED_H

#include <assert.h> /* For static_assert */
#include <stdint.h> /* For uint8_t */

#include <lionhead/lhlib/VER5.0/LHLinkedList.h> /* For DECLARE_LH_LINKED_LIST */

#include "Feature.h" /* For struct Feature */

struct AnimatedStatic
{
struct Feature super; /* 0x0 */
uint8_t field_0x7c[0x1c];
};
static_assert(sizeof(struct AnimatedStatic) == 0x98, "Data type is of wrong size");

static struct MultiMapFixedVftable* __vt__14AnimatedStatic = (struct MultiMapFixedVftable*)0x008c1a10;

DECLARE_LH_LINKED_LIST(AnimatedStatic);

#endif /* BW1_DECOMP_ANIMATED_STATIC_INCLUDED_H */
22 changes: 22 additions & 0 deletions black/Arena.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef BW1_DECOMP_ARENA_INCLUDED_H
#define BW1_DECOMP_ARENA_INCLUDED_H

#include <assert.h> /* For static_assert */
#include <stdint.h> /* For uint8_t */

#include <lionhead/lhlib/VER5.0/LHListHead.h> /* For DECLARE_LH_LIST_HEAD */

#include "GameThingWithPos.h" /* For struct GameThingWithPos */

struct GArena
{
struct GameThingWithPos super; /* 0x0 */
uint8_t field_0x28[0x24];
};
static_assert(sizeof(struct GArena) == 0x4c, "Data type is of wrong size");

static struct GameThingVftable* __vt__6GArena = (struct GameThingVftable*)0x008c2c98;

DECLARE_LH_LIST_HEAD(GArena);

#endif /* BW1_DECOMP_ARENA_INCLUDED_H */
22 changes: 22 additions & 0 deletions black/Artifact.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef BW1_DECOMP_ARTIFACT_INCLUDED_H
#define BW1_DECOMP_ARTIFACT_INCLUDED_H

#include <assert.h> /* For static_assert */
#include <stdint.h> /* For uint8_t */

#include <lionhead/lhlib/VER5.0/LHLinkedList.h> /* For DECLARE_LH_LINKED_LIST */

#include "GameThing.h" /* For struct GameThing */

struct TownArtifact
{
struct GameThing super; /* 0x0 */
uint8_t field_0x14[0x2c];
};
static_assert(sizeof(struct TownArtifact) == 0x40, "Data type is of wrong size");

static struct GameThingVftable* __vt__12TownArtifact = (struct GameThingVftable*)0x008c47d0;

DECLARE_LH_LINKED_LIST(TownArtifact);

#endif /* BW1_DECOMP_ARTIFACT_INCLUDED_H */
Loading

0 comments on commit 96acd8f

Please sign in to comment.