Skip to content

Commit

Permalink
Migrate objdat.cpp data to TSV
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Aug 5, 2024
1 parent e5e007c commit 84a762e
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 267 deletions.
1 change: 1 addition & 0 deletions CMake/Assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ set(devilutionx_assets
txtdata/missiles/missile_sprites.tsv
txtdata/monsters/monstdat.tsv
txtdata/monsters/unique_monstdat.tsv
txtdata/objects/objdat.tsv
txtdata/sound/effects.tsv
txtdata/spells/spelldat.tsv
ui_art/diablo.pal
Expand Down
1 change: 1 addition & 0 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,7 @@ int DiabloMain(int argc, char **argv)
LoadMissileData();
LoadMonsterData();
LoadItemData();
LoadObjectData();

DiabloInit();
#ifdef __UWP__
Expand Down
13 changes: 13 additions & 0 deletions Source/levels/gendung.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,4 +772,17 @@ void FloodTransparencyValues(uint8_t floorID)
}
}

tl::expected<dungeon_type, std::string> ParseDungeonType(std::string_view value)
{
if (value.empty()) return DTYPE_NONE;
if (value == "DTYPE_TOWN") return DTYPE_TOWN;
if (value == "DTYPE_CATHEDRAL") return DTYPE_CATHEDRAL;
if (value == "DTYPE_CATACOMBS") return DTYPE_CATACOMBS;
if (value == "DTYPE_CAVES") return DTYPE_CAVES;
if (value == "DTYPE_HELL") return DTYPE_HELL;
if (value == "DTYPE_NEST") return DTYPE_NEST;
if (value == "DTYPE_CRYPT") return DTYPE_CRYPT;
return tl::make_unexpected("Unknown enum value");
}

} // namespace devilution
6 changes: 6 additions & 0 deletions Source/levels/gendung.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <string_view>

#include <expected.hpp>

#include "engine/clx_sprite.hpp"
#include "engine/point.hpp"
Expand Down Expand Up @@ -71,6 +75,8 @@ enum dungeon_type : int8_t {
DTYPE_NONE = -1,
};

tl::expected<dungeon_type, std::string> ParseDungeonType(std::string_view value);

enum lvl_entry : uint8_t {
ENTRY_MAIN,
ENTRY_PREV,
Expand Down
318 changes: 129 additions & 189 deletions Source/objdat.cpp

Large diffs are not rendered by default.

80 changes: 10 additions & 70 deletions Source/objdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <cstdint>
#include <vector>

#include "levels/gendung.h"
#include "utils/enum_traits.h"
Expand Down Expand Up @@ -33,74 +34,8 @@ enum theme_id : int8_t {
THEME_NONE = -1,
};

enum object_graphic_id : int8_t {
OFILE_L1BRAZ,
OFILE_L1DOORS,
OFILE_LEVER,
OFILE_CHEST1,
OFILE_CHEST2,
OFILE_BANNER,
OFILE_SKULPILE,
OFILE_SKULFIRE,
OFILE_SKULSTIK,
OFILE_CRUXSK1,
OFILE_CRUXSK2,
OFILE_CRUXSK3,
OFILE_BOOK1,
OFILE_BOOK2,
OFILE_ROCKSTAN,
OFILE_ANGEL,
OFILE_CHEST3,
OFILE_BURNCROS,
OFILE_CANDLE2,
OFILE_NUDE2,
OFILE_SWITCH4,
OFILE_TNUDEM,
OFILE_TNUDEW,
OFILE_TSOUL,
OFILE_L2DOORS,
OFILE_WTORCH4,
OFILE_WTORCH3,
OFILE_SARC,
OFILE_FLAME1,
OFILE_PRSRPLT1,
OFILE_TRAPHOLE,
OFILE_MINIWATR,
OFILE_WTORCH2,
OFILE_WTORCH1,
OFILE_BCASE,
OFILE_BSHELF,
OFILE_WEAPSTND,
OFILE_BARREL,
OFILE_BARRELEX,
OFILE_LSHRINEG,
OFILE_RSHRINEG,
OFILE_BLOODFNT,
OFILE_DECAP,
OFILE_PEDISTL,
OFILE_L3DOORS,
OFILE_PFOUNTN,
OFILE_ARMSTAND,
OFILE_GOATSHRN,
OFILE_CAULDREN,
OFILE_MFOUNTN,
OFILE_TFOUNTN,
OFILE_ALTBOY,
OFILE_MCIRL,
OFILE_BKSLBRNT,
OFILE_MUSHPTCH,
OFILE_LZSTAND,
OFILE_POD,
OFILE_PODEX,
OFILE_L5DOORS,
OFILE_L5LEVER,
OFILE_L5CANDLE,
OFILE_L5SARC,
OFILE_URN,
OFILE_URNEX,
OFILE_L5BOOKS,
OFILE_NULL = -1,
};
// Index into ObjMasterLoadList.
using object_graphic_id = uint8_t;

enum _object_id : int8_t {
OBJ_L1LIGHT,
Expand Down Expand Up @@ -212,6 +147,8 @@ enum _object_id : int8_t {
OBJ_L5RDOOR,
OBJ_L5LEVER,
OBJ_L5SARC,

OBJ_LAST = OBJ_L5SARC,
OBJ_NULL = -1,
};

Expand Down Expand Up @@ -244,6 +181,7 @@ enum quest_id : int8_t {
};

enum class ObjectDataFlags : uint8_t {
None = 0,
Animated = 1U,
Solid = 1U << 1,
MissilesPassThrough = 1U << 2,
Expand Down Expand Up @@ -298,7 +236,9 @@ struct ObjectData {
};

extern const _object_id ObjTypeConv[];
extern const ObjectData AllObjects[109];
extern const char *const ObjMasterLoadList[];
extern std::vector<ObjectData> AllObjects;
extern std::vector<std::string> ObjMasterLoadList;

void LoadObjectData();

} // namespace devilution
14 changes: 9 additions & 5 deletions Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "minitext.h"
#include "missiles.h"
#include "monster.h"
#include "objdat.h"
#include "options.h"
#include "qol/stash.h"
#include "stores.h"
Expand Down Expand Up @@ -3681,7 +3682,7 @@ void LoadLevelObjects(uint16_t filesWidths[65])
}
}

for (int i = OFILE_L1BRAZ; i <= OFILE_L5BOOKS; i++) {
for (size_t i = 0, n = ObjMasterLoadList.size(); i < n; ++i) {
if (filesWidths[i] == 0) {
continue;
}
Expand All @@ -3699,13 +3700,16 @@ void InitObjectGFX()
uint16_t filesWidths[65] = {};

if (IsAnyOf(currlevel, 4, 8, 12)) {
filesWidths[OFILE_BKSLBRNT] = AllObjects[OBJ_STORYBOOK].animWidth;
filesWidths[OFILE_CANDLE2] = AllObjects[OBJ_STORYCANDLE].animWidth;
for (const auto id : { OBJ_STORYBOOK, OBJ_STORYCANDLE }) {
const ObjectData &obj = AllObjects[id];
filesWidths[obj.ofindex] = obj.animWidth;
}
}

for (const ObjectData objectData : AllObjects) {
for (size_t id = 0, n = AllObjects.size(); id < n; ++id) {
const ObjectData &objectData = AllObjects[id];
if (objectData.minlvl != 0 && currlevel >= objectData.minlvl && currlevel <= objectData.maxlvl) {
if (IsAnyOf(objectData.ofindex, OFILE_TRAPHOLE, OFILE_TRAPHOLE) && leveltype == DTYPE_HELL) {
if (IsAnyOf(static_cast<_object_id>(id), OBJ_TRAPL, OBJ_TRAPR) && leveltype == DTYPE_HELL) {
continue;
}

Expand Down
110 changes: 110 additions & 0 deletions assets/txtdata/objects/objdat.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
id file minLevel maxLevel levelType theme quest flags animDelay animLen animWidth selFlag
OBJ_L1LIGHT l1braz 0 0 DTYPE_CATHEDRAL Animated,Solid,MissilesPassThrough 1 26 64 0
OBJ_L1LDOOR l1doors 0 0 DTYPE_CATHEDRAL Light,Trap 1 0 64 3
OBJ_L1RDOOR l1doors 0 0 DTYPE_CATHEDRAL Light,Trap 2 0 64 3
OBJ_SKFIRE skulfire 0 0 THEME_SKELROOM Animated,Solid,MissilesPassThrough 2 11 96 0
OBJ_LEVER lever 0 0 Solid,MissilesPassThrough,Light,Trap 1 1 96 1
OBJ_CHEST1 chest1 1 24 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_CHEST2 chest2 1 24 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_CHEST3 chest3 1 24 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_CANDLE1 l1braz 0 0 0 0 0 0
OBJ_CANDLE2 candle2 0 0 THEME_SHRINE Q_PWATER Animated,Solid,MissilesPassThrough,Light 2 4 96 0
OBJ_CANDLEO l1braz 0 0 0 0 0 0
OBJ_BANNERL banner 0 0 THEME_SKELROOM Solid,MissilesPassThrough,Light 2 0 96 0
OBJ_BANNERM banner 0 0 THEME_SKELROOM Solid,MissilesPassThrough,Light 1 0 96 0
OBJ_BANNERR banner 0 0 THEME_SKELROOM Solid,MissilesPassThrough,Light 3 0 96 0
OBJ_SKPILE skulpile 0 0 Solid,MissilesPassThrough,Light 1 1 96 0
OBJ_SKSTICK1 l1braz 0 0 0 0 0 0
OBJ_SKSTICK2 l1braz 0 0 0 0 0 0
OBJ_SKSTICK3 l1braz 0 0 0 0 0 0
OBJ_SKSTICK4 l1braz 0 0 0 0 0 0
OBJ_SKSTICK5 l1braz 0 0 0 0 0 0
OBJ_CRUX1 cruxsk1 0 0 Solid,Light,Breakable 1 15 96 3
OBJ_CRUX2 cruxsk2 0 0 Solid,Light,Breakable 1 15 96 3
OBJ_CRUX3 cruxsk3 0 0 Solid,Light,Breakable 1 15 96 3
OBJ_STAND rockstan 5 5 Solid,MissilesPassThrough,Light 1 0 96 0
OBJ_ANGEL angel 0 0 Solid,Light 1 0 96 0
OBJ_BOOK2L book2 0 0 Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_BCROSS burncros 0 0 Animated,Solid 0 10 160 0
OBJ_NUDEW2R nude2 0 0 Animated,Solid,Light 3 6 128 0
OBJ_SWITCHSKL switch4 16 16 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_TNUDEM1 tnudem 13 15 Q_BUTCHER Solid,Light 1 0 128 0
OBJ_TNUDEM2 tnudem 13 15 THEME_TORTURE Q_BUTCHER Solid,Light 2 0 128 0
OBJ_TNUDEM3 tnudem 13 15 THEME_TORTURE Q_BUTCHER Solid,Light 3 0 128 0
OBJ_TNUDEM4 tnudem 13 15 THEME_TORTURE Q_BUTCHER Solid,Light 4 0 128 0
OBJ_TNUDEW1 tnudew 13 15 THEME_TORTURE Q_BUTCHER Solid,Light 1 0 128 0
OBJ_TNUDEW2 tnudew 13 15 THEME_TORTURE Q_BUTCHER Solid,Light 2 0 128 0
OBJ_TNUDEW3 tnudew 13 15 THEME_TORTURE Q_BUTCHER Solid,Light 3 0 128 0
OBJ_TORTURE1 tsoul 13 15 Q_BUTCHER MissilesPassThrough,Light 1 0 128 0
OBJ_TORTURE2 tsoul 13 15 Q_BUTCHER MissilesPassThrough,Light 2 0 128 0
OBJ_TORTURE3 tsoul 13 15 Q_BUTCHER MissilesPassThrough,Light 3 0 128 0
OBJ_TORTURE4 tsoul 13 15 Q_BUTCHER MissilesPassThrough,Light 4 0 128 0
OBJ_TORTURE5 tsoul 13 15 Q_BUTCHER MissilesPassThrough,Light 5 0 128 0
OBJ_BOOK2R book2 6 6 Solid,MissilesPassThrough,Light 4 0 96 3
OBJ_L2LDOOR l2doors 0 0 DTYPE_CATACOMBS Light,Trap 1 0 64 3
OBJ_L2RDOOR l2doors 0 0 DTYPE_CATACOMBS Light,Trap 2 0 64 3
OBJ_TORCHL wtorch4 5 8 Animated,MissilesPassThrough 1 9 96 0
OBJ_TORCHR wtorch3 5 8 Animated,MissilesPassThrough 1 9 96 0
OBJ_TORCHL2 wtorch1 5 8 Animated,MissilesPassThrough 1 9 96 0
OBJ_TORCHR2 wtorch2 5 8 Animated,MissilesPassThrough 1 9 96 0
OBJ_SARC sarc 1 4 Solid,MissilesPassThrough,Light,Trap 1 5 128 3
OBJ_FLAMEHOLE flame1 0 0 MissilesPassThrough,Light 1 20 96 0
OBJ_FLAMELVR lever 0 0 Solid,MissilesPassThrough,Light,Trap 1 2 96 1
OBJ_WATER miniwatr 0 0 Animated,Solid,Light 1 10 64 0
OBJ_BOOKLVR book1 0 0 Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_TRAPL traphole 1 24 MissilesPassThrough,Light 1 0 64 0
OBJ_TRAPR traphole 1 24 MissilesPassThrough,Light 2 0 64 0
OBJ_BOOKSHELF bcase 0 0 Solid,Light 1 0 96 0
OBJ_WEAPRACK weapstnd 0 0 Solid,Light 1 0 96 0
OBJ_BARREL barrel 1 15 Solid,MissilesPassThrough,Light,Breakable 1 9 96 3
OBJ_BARRELEX barrelex 1 15 Solid,MissilesPassThrough,Light,Breakable 1 10 96 3
OBJ_SHRINEL lshrineg 0 0 THEME_SHRINE Light 1 11 128 3
OBJ_SHRINER rshrineg 0 0 THEME_SHRINE Light 1 11 128 3
OBJ_SKELBOOK book2 0 0 THEME_SKELROOM Solid,MissilesPassThrough,Light 4 0 96 3
OBJ_BOOKCASEL bcase 0 0 THEME_LIBRARY Solid,Light 3 0 96 3
OBJ_BOOKCASER bcase 0 0 THEME_LIBRARY Solid,Light 4 0 96 3
OBJ_BOOKSTAND book2 0 0 THEME_LIBRARY Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_BOOKCANDLE candle2 0 0 THEME_LIBRARY Animated,Solid,MissilesPassThrough,Light 2 4 96 0
OBJ_BLOODFTN bloodfnt 0 0 THEME_BLOODFOUNTAIN Animated,Solid,MissilesPassThrough,Light 2 10 96 3
OBJ_DECAP decap 13 15 THEME_DECAPITATED Solid,MissilesPassThrough,Light 1 0 96 1
OBJ_TCHEST1 chest1 1 24 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_TCHEST2 chest2 1 24 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_TCHEST3 chest3 1 24 Solid,MissilesPassThrough,Light,Trap 1 0 96 1
OBJ_BLINDBOOK book1 0 0 Q_BLIND Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_BLOODBOOK book1 0 0 Q_BLOOD Solid,MissilesPassThrough,Light 4 0 96 3
OBJ_PEDESTAL pedistl 0 0 Q_BLOOD Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_L3LDOOR l3doors 0 0 DTYPE_CAVES Light,Trap 1 0 64 3
OBJ_L3RDOOR l3doors 0 0 DTYPE_CAVES Light,Trap 2 0 64 3
OBJ_PURIFYINGFTN pfountn 0 0 THEME_PURIFYINGFOUNTAIN Animated,Solid,MissilesPassThrough,Light 2 10 128 3
OBJ_ARMORSTAND armstand 0 0 THEME_ARMORSTAND Solid,Light 1 0 96 3
OBJ_ARMORSTANDN armstand 0 0 THEME_ARMORSTAND Solid,Light 2 0 96 0
OBJ_GOATSHRINE goatshrn 0 0 THEME_GOATSHRINE Animated,Solid,MissilesPassThrough,Light 2 10 96 3
OBJ_CAULDRON cauldren 13 15 Solid,Light 1 0 96 3
OBJ_MURKYFTN mfountn 0 0 THEME_MURKYFOUNTAIN Animated,Solid,MissilesPassThrough,Light 2 10 128 3
OBJ_TEARFTN tfountn 0 0 THEME_TEARFOUNTAIN Animated,Solid,MissilesPassThrough,Light 2 4 128 3
OBJ_ALTBOY altboy 0 0 Q_BETRAYER Solid,MissilesPassThrough,Light 1 0 128 0
OBJ_MCIRCLE1 mcirl 0 0 Q_BETRAYER MissilesPassThrough,Light 1 0 96 0
OBJ_MCIRCLE2 mcirl 0 0 Q_BETRAYER MissilesPassThrough,Light 1 0 96 0
OBJ_STORYBOOK bkslbrnt 0 0 Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_STORYCANDLE candle2 0 0 Q_BETRAYER Animated,Solid,MissilesPassThrough,Light 2 4 96 0
OBJ_STEELTOME book1 0 0 Q_WARLORD Solid,MissilesPassThrough,Light 4 0 96 3
OBJ_WARARMOR armstand 0 0 Q_WARLORD Solid,Light 1 0 96 3
OBJ_WARWEAP weapstnd 0 0 Q_WARLORD Solid,Light 1 0 96 3
OBJ_TBCROSS burncros 0 0 THEME_BRNCROSS Animated,Solid 0 10 160 0
OBJ_WEAPONRACK weapstnd 0 0 THEME_WEAPONRACK Solid,Light 1 0 96 3
OBJ_WEAPONRACKN weapstnd 0 0 THEME_WEAPONRACK Solid,Light 2 0 96 0
OBJ_MUSHPATCH mushptch 0 0 Q_MUSHROOM Solid,MissilesPassThrough,Light,Trap 1 0 96 3
OBJ_LAZSTAND lzstand 0 0 Q_BETRAYER Solid,Light 1 0 128 3
OBJ_SLAINHERO decap 9 9 Solid,MissilesPassThrough,Light 2 0 96 1
OBJ_SIGNCHEST chest3 0 0 Solid,MissilesPassThrough,Light 1 0 96 1
OBJ_BOOKSHELFR bcase 0 0 Solid,Light 2 0 96 0
OBJ_POD l6pod1 17 20 Solid,MissilesPassThrough,Light,Breakable 1 9 96 3
OBJ_PODEX l6pod2 17 20 Solid,MissilesPassThrough,Light,Breakable 1 10 96 3
OBJ_URN urn 21 24 Solid,MissilesPassThrough,Light,Breakable 1 9 96 3
OBJ_URNEX urnexpld 21 24 Solid,MissilesPassThrough,Light,Breakable 1 10 96 3
OBJ_L5BOOKS l5books 21 24 Solid,MissilesPassThrough,Light 1 0 96 3
OBJ_L5CANDLE l5light 21 23 Animated,Solid,MissilesPassThrough,Light 2 4 96 0
OBJ_L5LDOOR l5door 0 0 DTYPE_CRYPT Light,Trap 1 0 64 3
OBJ_L5RDOOR l5door 0 0 DTYPE_CRYPT Light,Trap 2 0 64 3
OBJ_L5LEVER l5lever 24 24 Solid,MissilesPassThrough,Light,Trap 1 1 96 1
OBJ_L5SARC l5sarco 21 24 Solid,MissilesPassThrough,Light,Trap 1 5 128 3
1 change: 1 addition & 0 deletions test/timedemo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void RunTimedemo(std::string timedemoFolderName)
LoadMissileData();
LoadMonsterData();
LoadItemData();
LoadObjectData();
pfile_ui_set_hero_infos(Dummy_GetHeroInfo);
gbLoadGame = true;

Expand Down
6 changes: 3 additions & 3 deletions uwp-project/devilutionx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<ClCompile>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalIncludeDirectories>..\Source;..\build\SDL\include;..\build\_deps\sdl_audiolib-src\include;..\build\_deps\sdl_audiolib-build;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\Source;..\build\SDL\include;..\build\_deps\sdl_audiolib-src\include;..\build\_deps\sdl_audiolib-build;..\3rdParty\tl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<PreprocessorDefinitions>_DEBUG;__UWP__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand All @@ -102,7 +102,7 @@
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<PreprocessorDefinitions>NDEBUG;__UWP__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<AdditionalIncludeDirectories>..\Source;..\build\SDL\include;..\build\_deps\sdl_audiolib-src\include;..\build\_deps\sdl_audiolib-build;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\Source;..\build\SDL\include;..\build\_deps\sdl_audiolib-src\include;..\build\_deps\sdl_audiolib-build;..\3rdParty\tl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
Expand Down Expand Up @@ -142,4 +142,4 @@
<Import Project="$(VSINSTALLDIR)\Common7\IDE\Extensions\Microsoft\VsGraphics\MeshContentTask.targets" />
<Import Project="$(VSINSTALLDIR)\Common7\IDE\Extensions\Microsoft\VsGraphics\ShaderGraphContentTask.targets" />
</ImportGroup>
</Project>
</Project>

0 comments on commit 84a762e

Please sign in to comment.