Skip to content

Commit

Permalink
Merge pull request #10 from enderslash1010/being-a-little-silly
Browse files Browse the repository at this point in the history
Being a little silly
  • Loading branch information
enderslash1010 authored Oct 27, 2024
2 parents 72be742 + 76e11ea commit 44fbfec
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 140 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: CMake on multiple platforms

on:
push:
branches: [ "main" ]
branches: [ "*" ]
pull_request:
branches: [ "*" ]
jobs:
Expand Down Expand Up @@ -77,4 +77,4 @@ jobs:
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
src/main.cpp
gui/mainwindow.cpp
gui/mainwindow.ui
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
Expand Down
File renamed without changes.
92 changes: 46 additions & 46 deletions include/ArrayID.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@

enum ITEMWeaponArray
{
ITEMWeaponID1,
ITEMWeaponStatic1, // 2
ITEMWeaponID2,
ITEMWeaponStatic2, // 0
ITEMWeaponStatic3, // 0
ITEMWeaponInventorySlot,
ITEMWeaponStatic4, // 1
ITEMWeaponStatic5, // 0
ITEMWeaponGem1ID,
ITEMWeaponGem2ID,
ITEMWeaponGem3ID,
ITEMWeaponGem4ID,
ITEMWeaponGem1Index,
ITEMWeaponGem2Index,
ITEMWeaponGem3Index,
ITEMWeaponGem4Index,
ITEMWeaponNumGemSlots,
ITEMWeaponStatic6, // 6
ITEMWeaponStatic7 // 0
ITEMWeapon_ID1,
ITEMWeapon_Static1, // 2
ITEMWeapon_ID2,
ITEMWeapon_Static2, // 0
ITEMWeapon_Static3, // 0
ITEMWeapon_InventorySlot,
ITEMWeapon_Static4, // 1
ITEMWeapon_Static5, // 0
ITEMWeapon_Gem1ID,
ITEMWeapon_Gem2ID,
ITEMWeapon_Gem3ID,
ITEMWeapon_Gem4ID,
ITEMWeapon_Gem1Index,
ITEMWeapon_Gem2Index,
ITEMWeapon_Gem3Index,
ITEMWeapon_Gem4Index,
ITEMWeapon_NumGemSlots,
ITEMWeapon_Static6, // 6
ITEMWeapon_Static7 // 0
};

enum ITEMGemArray
{
ITEMGemStatic1, // 0xEA33
ITEMGemID1,
ITEMGemUnk1,
ITEMGemStatic2, // 0
ITEMGemInventorySlot,
ITEMGemStatic3, // 1
ITEMGemStatic4, // 0/3
ITEMGemUnk2,
ITEMGemValue,
ITEMGemRank,
ITEMGemUnk3,
ITEMGemID2,
ITEMGemStatic5, // 2
ITEMGemStatic6 // 0
ITEMGem_Static1, // 0xEA33
ITEMGem_ID1,
ITEMGem_Unk1,
ITEMGem_Static2, // 0
ITEMGem_InventorySlot,
ITEMGem_Static3, // 1
ITEMGem_Static4, // 0/3
ITEMGem_Unk2,
ITEMGem_Value,
ITEMGem_Rank,
ITEMGem_Unk3,
ITEMGem_ID2,
ITEMGem_Static5, // 2
ITEMGem_Static6 // 0
};

enum MINEArray
{
MINECooldown,
MINENumHarvests,
MINEMineID,
MINEMapID,
MINE_Cooldown,
MINE_NumHarvests,
MINE_MineID,
MINE_MapID,
};

enum TBOXElementID
enum TBOXArray
{
TBOXZeroObject,
TBOXPositionX,
TBOXPositionY,
TBOXPositionZ,
TBOXAngle,
TBOXRank,
TBOXDropTable,
TBOXMapID
TBOX_ZeroObject,
TBOX_PositionX,
TBOX_PositionY,
TBOX_PositionZ,
TBOX_Angle,
TBOX_Rank,
TBOX_DropTable,
TBOX_MapID
};
5 changes: 1 addition & 4 deletions include/ArrayObject.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include "SaveDefines.h"
#include <vector>
#include <stdint.h>
#include "DataObject.h"

typedef struct
Expand All @@ -14,10 +12,9 @@ typedef struct
class ArrayObject : public DataObject
{
std::vector<std::vector<DataObject>> dataObjs = std::vector<std::vector<DataObject>>();
unsigned int numRows, numColumns;
std::vector<int> staticValues;
public:
ArrayObject(unsigned int elementSizeBytes, unsigned int arraySize, const std::vector<Element> elements);
virtual const DataObject* at(unsigned int row, unsigned int column) const;
const DataObject* at(unsigned int row, unsigned int column) const;
virtual const int getStaticValue(unsigned int column) const;
};
6 changes: 3 additions & 3 deletions include/DataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "SaveDefines.h"
#include <vector>
#include <stdint.h>
#include <iostream>
#include "Types.h"

class DataObject
Expand All @@ -17,6 +16,7 @@ class DataObject

unsigned int numRows, numColumns;

DataObject(unsigned int startByte, unsigned int lengthInBytes, Type type, unsigned int numRows, unsigned int numColumns);
public:
DataObject(unsigned int startByte, unsigned int startBit, unsigned int lengthInBits, Type type);
DataObject(unsigned int startByte, unsigned int lengthInBytes, Type type);
Expand All @@ -43,8 +43,8 @@ class DataObject

virtual const int getStaticValue(unsigned int column) const { return 0; }

unsigned const int getNumRows() const { return this->numRows; }
unsigned const int getNumColumns() const { return this->numColumns; }
unsigned const int getNumRows() const { return this->numRows; }
unsigned const int getNumColumns() const { return this->numColumns; }

void print();
};
9 changes: 4 additions & 5 deletions include/SaveFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
#include <string>
#include <vector>
#include "SaveFieldID.h"
#include <iostream>
#include <fstream>
#include "DataObject.h"
#include "ArrayObject.h"
#include "ArrayID.h"
#include "Types.h"
#include "SaveDefines.h"
#include <stdexcept>

#define NUM_SECTIONS 12

Expand Down Expand Up @@ -115,7 +113,7 @@ class SaveFile
{DataObject(0x1C518, 2, UINT_T), 0}, // ITEMWeaponGem3Index
{DataObject(0x1C51A, 2, UINT_T), 0}, // ITEMWeaponGem4Index
{DataObject(0x1C51C, 1, UINT_T), 0}, // ITEMWeaponNumGemSlots
{DataObject(0x1C51D, 1, UINT_T), 0}, // ITEMWeaponStatic6 (6)
{DataObject(0x1C51D, 1, UINT_T), 6}, // ITEMWeaponStatic6 (6)
{DataObject(0x1C51E, 2, UINT_T), 0} // ITEMWeaponStatic7 (0)
}),
new ArrayObject(16, 300, std::vector<Element> { // ITEMGemArray
Expand All @@ -131,7 +129,7 @@ class SaveFile
{DataObject(0x206E2, 1, 3, UINT_T), 0}, // ITEMGemRank
{DataObject(0x206E3, 6, 7, UINT_T), 0}, // ITEMGemUnk3
{DataObject(0x206E4, 7, 12, UINT_T), 0},// ITEMGemID2
{DataObject(0x206E5, 3, 4, UINT_T), 0}, // ITEMGemStatic5 (2)
{DataObject(0x206E5, 3, 4, UINT_T), 2}, // ITEMGemStatic5 (2)
{DataObject(0x206E6, 2, UINT_T), 0}// ITEMGemStatic6 (0)
}),

Expand Down Expand Up @@ -206,6 +204,7 @@ class SaveFile
void setArrayRawBytes(SaveFieldID aID, unsigned int index, unsigned int elementName, std::vector<uint8_t> value);

void saveToFile();
void saveToFile(std::string file);

Type getType(SaveFieldID sfID);

Expand Down
11 changes: 0 additions & 11 deletions main.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions mainwindow.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions mainwindow.ui

This file was deleted.

14 changes: 6 additions & 8 deletions src/ArrayObject.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#include "ArrayObject.h"
#include <stdexcept>

ArrayObject::ArrayObject(unsigned int elementSizeBytes, unsigned int arraySize, const std::vector<Element> elements) :
DataObject(elements.at(0).dataObject.getStartByte(), (elementSizeBytes * arraySize), ARRAY_T)
DataObject(elements.at(0).dataObject.getStartByte(), (elementSizeBytes * arraySize), ARRAY_T, arraySize, elements.size())
{
if (elements.size() == 0 || elementSizeBytes == 0) throw std::invalid_argument("Cannot instantiate ArrayObject: Empty element");

this->numRows = arraySize;
this->numColumns = elements.size();

// Ensure elements has same number of bytes as elementSizeBytes
int numBits = 0;
for (int i = 0; i < elements.size(); i++)
{
{
numBits += elements.at(i).dataObject.getLengthInBits();
this->staticValues.push_back(elements.at(i).staticValue);
}
Expand All @@ -22,16 +20,16 @@ ArrayObject::ArrayObject(unsigned int elementSizeBytes, unsigned int arraySize,
unsigned int currByte = elements.at(0).dataObject.getStartByte();
int currBit = 7;

for (int row = 0; row < this->numRows; row++)
for (int row = 0; row < arraySize; row++)
{
// Initialize element for row n
std::vector<DataObject> element;

// Populate element with same DataObjects in dataObj, with their own startByte
for (int column = 0; column < this->numColumns; column++)
for (int column = 0; column < elements.size(); column++)
{
unsigned int sizeInBits = elements.at(column).dataObject.getLengthInBits();
Type type = elements.at(column).dataObject.getType();
Type type = elements.at(column).dataObject.getType();

element.push_back(DataObject(currByte, currBit, sizeInBits, type));

Expand Down
11 changes: 11 additions & 0 deletions src/DataObject.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "DataObject.h"
#include <ios>
#include <iostream>
#include <stdexcept>

DataObject::DataObject(unsigned int startByte, unsigned int lengthInBytes, Type type)
{
Expand Down Expand Up @@ -35,6 +38,14 @@ DataObject::DataObject(unsigned int startByte, unsigned int startBit, unsigned i
if (this->endByte + 1 > SAVEFILE_LENGTH_BYTES) throw std::invalid_argument("DataObject exceeds save file length");
}

DataObject::DataObject(unsigned int startByte, unsigned int lengthInBytes, Type type, unsigned int numRows, unsigned int numColumns)
{
DataObject(startByte, lengthInBytes, type);

this->numRows = numRows;
this->numColumns = numColumns;
}

std::vector<uint8_t> DataObject::getRawBytes(uint8_t (&saveFile)[SAVEFILE_LENGTH_BYTES]) const
{
std::vector<uint8_t> result;
Expand Down
Loading

0 comments on commit 44fbfec

Please sign in to comment.