Skip to content

Commit

Permalink
Merge pull request #127 from Goldensunboy/gsb
Browse files Browse the repository at this point in the history
Fix door appearance offset and frog switch timer saving
  • Loading branch information
shinespeciall authored Dec 6, 2018
2 parents f371c8f + c1dc587 commit 705ba73
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
beta-4:
- Fix frog switch timers not saving
- Fix Wario's appearance offset from destination door in DoorConfigDialog

beta-3:
- Disable most menu buttons before ROM is loaded
- Fix changing the destination door in DoorConfigDialog intermittently crashes
Expand Down
6 changes: 3 additions & 3 deletions Dialog/DoorConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ DoorConfigDialog::~DoorConfigDialog()
void DoorConfigDialog::UpdateCurrentDoorData()
{
CurrentRoom->GetDoor(DoorID)->SetDoorType(static_cast<LevelComponents::DoorType>(ui->ComboBox_DoorType->currentIndex() + 1));
CurrentRoom->GetDoor(DoorID)->SetDelta((unsigned char) ui->SpinBox_WarioX->value(), (unsigned char) ui->SpinBox_WarioY->value());
CurrentRoom->GetDoor(DoorID)->SetDelta((signed char) ui->SpinBox_WarioX->value(), (signed char) ui->SpinBox_WarioY->value());
CurrentRoom->GetDoor(DoorID)->SetDoorPlace(
(unsigned char) ui->SpinBox_DoorX->value(),
(unsigned char) (ui->SpinBox_DoorX->value() + ui->SpinBox_DoorWidth->value() - 1),
Expand Down Expand Up @@ -497,7 +497,7 @@ void DoorConfigDialog::on_SpinBox_WarioX_valueChanged(int arg1)
{
(void) arg1;
if(!IsInitialized) return;
tmpCurrentRoom->GetDoor(DoorID)->SetDelta((unsigned char) ui->SpinBox_WarioX->value(), (unsigned char) ui->SpinBox_WarioY->value());
tmpCurrentRoom->GetDoor(DoorID)->SetDelta((signed char) ui->SpinBox_WarioX->value(), (signed char) ui->SpinBox_WarioY->value());
}

/// <summary>
Expand All @@ -510,7 +510,7 @@ void DoorConfigDialog::on_SpinBox_WarioY_valueChanged(int arg1)
{
(void) arg1;
if(!IsInitialized) return;
tmpCurrentRoom->GetDoor(DoorID)->SetDelta((unsigned char) ui->SpinBox_WarioX->value(), (unsigned char) ui->SpinBox_WarioY->value());
tmpCurrentRoom->GetDoor(DoorID)->SetDelta((signed char) ui->SpinBox_WarioX->value(), (signed char) ui->SpinBox_WarioY->value());
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions LevelComponents/Door.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace LevelComponents
unsigned char y1;
unsigned char y2;
unsigned char LinkerDestination;
unsigned char HorizontalDelta;
unsigned char VerticalDelta;
signed char HorizontalDelta;
signed char VerticalDelta;
unsigned char EntitySetID;
unsigned short BGM_ID;
};
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace LevelComponents
void SetEntitySetID(unsigned char _EntitySetID) { DoorEntry.EntitySetID =_EntitySetID; }
void SetGlobalDoorID(int doorId) { DoorID = doorId; }
void SetLinkerDestination(int dest_RoomId) { DoorEntry.LinkerDestination = (unsigned char) dest_RoomId; }
void SetDelta(unsigned char _DeltaX, unsigned char _DeltaY)
void SetDelta(signed char _DeltaX, signed char _DeltaY)
{
DoorEntry.HorizontalDelta = (signed char) _DeltaX;
DoorEntry.VerticalDelta = (signed char) _DeltaY;
Expand Down
3 changes: 3 additions & 0 deletions LevelComponents/Level.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ namespace LevelComponents
void AddDoor(Door* newdoor);
~Level();
void GetSaveChunks(QVector<struct ROMUtils::SaveData> &chunks);
struct __LevelHeader *GetLevelHeader() { return &LevelHeader; }
enum __passage GetPassage() { return passage; }
enum __stage GetStage() { return stage; }
};
}

Expand Down
6 changes: 6 additions & 0 deletions ROMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ namespace ROMUtils
bool success = false;
QVector<struct SaveData> chunks;
LevelComponents::Level *currentLevel = singleton->GetCurrentLevel();
int levelHeaderOffset = WL4Constants::LevelHeaderIndexTable + currentLevel->GetPassage() * 24 + currentLevel->GetStage() * 4;
int levelHeaderIndex = ROMUtils::IntFromData(levelHeaderOffset);
int levelHeaderPointer = WL4Constants::LevelHeaderTable + levelHeaderIndex * 12;
currentLevel->GetSaveChunks(chunks);

// Finding space for the chunks can be done faster if the chunks are ordered by size
Expand Down Expand Up @@ -418,6 +421,9 @@ findspace: int chunkAddr = FindSpaceInROM(TempFile, TempLength, startAddr, chun
memcpy(destPtr + 12, chunk.data, chunkLen);
}

// Write the level header to the ROM
memcpy(TempFile + levelHeaderPointer, currentLevel->GetLevelHeader(), sizeof(struct LevelComponents::__LevelHeader));

{ // Prevent goto from crossing initialization of variables here
// Save the rom file from the CurrentFile copy
QFile file(filePath);
Expand Down
2 changes: 1 addition & 1 deletion WL4Constants.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef WL4CONSTANTS_H
#define WL4CONSTANTS_H

#define WL4EDITOR_VERSION "beta-3"
#define WL4EDITOR_VERSION "beta-4"

namespace WL4Constants
{
Expand Down
3 changes: 2 additions & 1 deletion WL4EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ void WL4EditorWindow::on_actionLevel_Config_triggered()
);

// If OK is pressed, then set the level attributes
if(dialog.exec() == QDialog::Accepted)
auto acc = dialog.exec();
if(acc == QDialog::Accepted)
{
CurrentLevel->SetLevelName(dialog.GetPaddedLevelName());
CurrentLevel->SetTimeCountdownCounter(LevelComponents::HardDifficulty, (unsigned int) dialog.GetHModeTimer());
Expand Down

0 comments on commit 705ba73

Please sign in to comment.