Skip to content

Commit

Permalink
Update file format + add saving
Browse files Browse the repository at this point in the history
No more stupid double pointers

Co-Authored-By: STUPID Modder <[email protected]>
  • Loading branch information
Luminyx1 and stupidestmodder committed Jan 26, 2024
1 parent 69a2eff commit 2196a7a
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 125 deletions.
1 change: 1 addition & 0 deletions Terraformer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand Down
Binary file modified dist/CS_W1.a2ls
Binary file not shown.
14 changes: 13 additions & 1 deletion dist/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Size=1920,1050
Collapsed=0
DockId=0x8B93E3BD,0

[Window][Dear ImGui Demo]
ViewportPos=3065,1038
ViewportId=0xE927CF2F
Size=550,680
Collapsed=0

[Window][Terraformer | Editing map: New World]
Pos=0,30
Size=1920,1050
Collapsed=0
DockId=0x8B93E3BD,0

[Docking][Data]
DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=701,634 Size=1920,1050 CentralNode=1 Selected=0xC13A69E6
DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=505,569 Size=1920,1050 CentralNode=1 Selected=0xCF79E78A

40 changes: 13 additions & 27 deletions include/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include <vector>
#include <cstdint>

using u64 = std::uint64_t;
using u32 = std::uint32_t;
using u8 = std::uint8_t;
using u32 = std::uint32_t;
using s32 = std::int32_t;
using u64 = std::uint64_t;
using f32 = float;

inline void* AddOffset(const void* ptr, intptr_t offset) {
Expand All @@ -15,7 +16,7 @@ inline void* AddOffset(const void* ptr, intptr_t offset) {

template <typename T>
[[nodiscard]] T SwapEndian(const T value) {
const T newValue = value;
T newValue = value;
u8* data = (u8*)&newValue;
u8 temp;

Expand Down Expand Up @@ -64,7 +65,7 @@ class MapData {
} normal, passthrough;
struct {
u32 levelID;
u32 unlocksMapID;
s32 unlocksMapID;
} level;
};
};
Expand Down Expand Up @@ -95,32 +96,12 @@ class MapData {
Animation animation;
u32 unlockCriteriaOffs;

// extra
u8* unlockCriteriaData;
};

public:
explicit MapData(u8* data);
~MapData();

template <typename T>
void fixRef(T*& indexAsPtr) {
u64 index = reinterpret_cast<std::uintptr_t>(indexAsPtr);
if (index == 0xFFFFFFFF || index == 0) {
indexAsPtr = 0;
} else {
indexAsPtr = (T*)(((u8*)this) + index);
}
}

Header header;
WorldInfo worldInfo;
u32 nodeCount;
u32 nodes; // Node**
u32 pathCount;
u32 paths; // Path**

Node* nodesPtr;
Path* pathsPtr;
private:
MapData() = delete;
};

class Map {
Expand All @@ -129,6 +110,11 @@ class Map {
explicit Map(const std::string& filePath);
~Map();

void AddNode();
void AddPath();

void Save(const std::string& filePath);

MapData::Header header;
MapData::WorldInfo worldInfo;
std::vector<MapData::Node> nodes;
Expand Down
2 changes: 1 addition & 1 deletion include/terraformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Terraformer {
public:
Map* map = nullptr;
std::string message = "";
bool windowOpen = true;


void Update();
Expand All @@ -21,4 +20,5 @@ class Terraformer {
void NewFile();

void ShowMessage();
void Exit();
};
Loading

0 comments on commit 2196a7a

Please sign in to comment.