Skip to content

Commit

Permalink
Merge pull request #126 from Goldensunboy/gsb
Browse files Browse the repository at this point in the history
Bugfixes for beta-3
  • Loading branch information
shinespeciall authored Dec 5, 2018
2 parents 205ce9a + 71cf701 commit f371c8f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
beta-3:
- Disable most menu buttons before ROM is loaded
- Fix changing the destination door in DoorConfigDialog intermittently crashes
- Fix rendering of certain entities in Room.cpp crashes editor

beta-2:
- Added changelog
- Reorder difficulty timers by normal, hard, s.hard in level config dialog
Expand Down
2 changes: 1 addition & 1 deletion Dialog/DoorConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void DoorConfigDialog::on_ComboBox_DoorDestinationPicker_currentIndexChanged(int
QGraphicsScene *oldScene = ui->GraphicsView_DestinationDoor->scene();
if(oldScene)
{
delete oldScene; // UI automaticcally update
delete oldScene; // UI automatically update
}
}
}
Expand Down
33 changes: 15 additions & 18 deletions LevelComponents/Room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,36 +104,35 @@ namespace LevelComponents
/// <remarks>
/// the new instance should only be used to render Room graphic temporarily, it is unsafe to add it to a Level.
/// </remarks>
Room::Room(Room *room)
Room::Room(Room *room) :
CameraControlType(room->GetCameraControlType()),
RoomID(room->GetRoomID()),
LevelID(room->GetLevelID()),
Width(room->GetWidth()),
Height(room->GetHeight()),
RoomHeader(room->GetRoomHeader()),
CurrentEntitySetID(room->GetCurrentEntitySetID()),
IsCopy(true)
{
IsCopy = true;
RoomID = room->GetRoomID();
LevelID = room->GetLevelID();
// Zero out the arrays
memset(RenderedLayers, 0, sizeof(RenderedLayers));
memset(drawLayers, 0, sizeof(drawLayers));
memset(EntityLayerZValue, 0, sizeof(EntityLayerZValue));
memset(EntityListDirty, 0, sizeof(EntityListDirty));

// Copy the room header information
RoomHeader = room->GetRoomHeader();

// Set up tileset, TODO: if we support Tileset changes in the editor, this need to be changed
int tilesetPtr = WL4Constants::TilesetDataTable + RoomHeader.TilesetID * 36;
tileset = new Tileset(tilesetPtr, RoomHeader.TilesetID);

// Set up the layer data
Width = room->GetWidth();
Height = room->GetHeight();
for(int i = 0; i < 4; ++i)
{
layers[i] = new Layer(*(room->GetLayer(i)));
layers[i] = new Layer(*room->GetLayer(i));
}

SetLayerPriorityAndAlphaAttributes((int) room->GetRoomHeader().LayerEffects);
SetLayerPriorityAndAlphaAttributes(room->GetRoomHeader().LayerEffects);

// Set up camera control data
// TODO are there more types than 1, 2 and 3?
CameraControlType = room->GetCameraControlType();
if(CameraControlType == LevelComponents::HasControlAttrs)
{
CameraControlRecords = room->GetCameraControlRecords(true);
Expand All @@ -146,7 +145,6 @@ namespace LevelComponents
}

// Deep Copy Entityset and Entities
CurrentEntitySetID = room->GetCurrentEntitySetID();
ResetEntitySet(CurrentEntitySetID);
}

Expand Down Expand Up @@ -212,10 +210,9 @@ namespace LevelComponents
FreeDrawLayers();
if(currentEntitySet) delete currentEntitySet;
FreecurrentEntityListSource();
for(unsigned int i = 0; i < CameraControlRecords.size(); ++i)
foreach(struct __CameraControlRecord *C, CameraControlRecords)
{
struct __CameraControlRecord *currentCameralimitator = CameraControlRecords[i];
delete currentCameralimitator;
delete C;
}
CameraControlRecords.clear();
if(IsCopy && doors.size())
Expand Down Expand Up @@ -371,7 +368,7 @@ namespace LevelComponents
unsigned char EntityID = EntityList[currentDifficulty].at(i).EntityID;
// TODO this continue statement may not be addressing the underlying problem,
// if it is at all possible for out-of-range entity IDs to reach this point
if((unsigned int) EntityID > currentEntityListSource.size()) continue;
if((unsigned int) EntityID > currentEntityListSource.size() - 1) continue;
Entity *currententity = currentEntityListSource[EntityID];
// Use an alternative method to render the Entity in a not-so-bad place
if(Layer0ColorBlending && !Layer0ColorBlendCoefficient_EVB)
Expand Down
11 changes: 7 additions & 4 deletions LevelComponents/Room.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,16 @@ namespace LevelComponents
unsigned char GetBGScrollParameter() { return RoomHeader.Layer3Scrolling; }
std::vector<struct __CameraControlRecord*> GetCameraControlRecords(bool create_new_instances = false)
{
if(create_new_instances) return CameraControlRecords;
if(!create_new_instances)
{
return CameraControlRecords;
}
std::vector<struct __CameraControlRecord*> newCameraControlRecords;
for(unsigned int i = 0; i < CameraControlRecords.size(); ++i)
{
struct __CameraControlRecord *currentCameralimitator = new __CameraControlRecord;
memcpy(currentCameralimitator, CameraControlRecords[i], sizeof(struct __CameraControlRecord));
newCameraControlRecords.push_back(currentCameralimitator);
struct __CameraControlRecord *newCameraLimitator = new __CameraControlRecord();
memcpy(newCameraLimitator, CameraControlRecords[i], sizeof(struct __CameraControlRecord));
newCameraControlRecords.push_back(newCameraLimitator);
}
return newCameraControlRecords;
}
Expand Down
4 changes: 2 additions & 2 deletions ROMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ findspace: int chunkAddr = FindSpaceInROM(TempFile, TempLength, startAddr, chun
}
}
indexToChunkPtr[chunks[i].index] = chunkAddr;
startAddr = chunkAddr + chunkSize; // do not re-search old areas of the ROM
startAddr = chunkAddr + chunks[i].size + 12; // do not re-search old areas of the ROM
}

// Apply source pointer modifications
Expand Down Expand Up @@ -398,7 +398,7 @@ findspace: int chunkAddr = FindSpaceInROM(TempFile, TempLength, startAddr, chun
singleton,
"RATS chunk too large",
QString("Unable to save changes because ") + QString::number(chunk.size) +
" contiguous free bytes are necessary for a save chunk with type " +
" contiguous free bytes are necessary for some save chunk of type " +
QString::number(chunk.ChunkType) + ", but the editor currently"
" only supports up to size " + QString::number(0xFFFF) + ".",
QMessageBox::Ok,
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-2"
#define WL4EDITOR_VERSION "beta-3"

namespace WL4Constants
{
Expand Down
13 changes: 10 additions & 3 deletions WL4EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ void WL4EditorWindow::OpenROM()
ui->loadLevelButton->setEnabled(true);
ui->actionLevel_Config->setEnabled(true);
ui->actionRoom_Config->setEnabled(true);
ui->actionSave_ROM->setEnabled(true);
ui->actionSave_As->setEnabled(true);
ui->menuAdd->setEnabled(true);
ui->actionRedo->setEnabled(true);
ui->actionUndo->setEnabled(true);

// Load Dock widget
addDockWidget(Qt::RightDockWidgetArea, EditModeWidget);
Expand Down Expand Up @@ -661,18 +666,20 @@ void WL4EditorWindow::on_actionRoom_Config_triggered()
/// </summary>
void WL4EditorWindow::on_actionNew_Door_triggered()
{
if(!firstROMLoaded) return;
// Create a new door struct with blank fields
LevelComponents::__DoorEntry newDoorEntry;
memset(&newDoorEntry, 0, sizeof(LevelComponents::__DoorEntry));

// Initialize the fields
newDoorEntry.DoorTypeByte = (unsigned char) 2;
newDoorEntry.EntitySetID = (unsigned char) 1;
newDoorEntry.RoomID = (unsigned char) selectedRoom;
newDoorEntry.DoorTypeByte = LevelComponents::DoorType::Instant;
LevelComponents::Door *newDoor = new LevelComponents::Door(newDoorEntry, (unsigned char) selectedRoom, CurrentLevel->GetDoors().size());
newDoor->SetEntitySetID((unsigned char) CurrentLevel->GetRooms()[selectedRoom]->GetCurrentEntitySetID());
newDoor->SetBGM(0);
newDoor->SetDelta(0, 0);
newDoor->SetDestinationDoor(CurrentLevel->GetDoors()[0]);

// Add the new door to the Level object and re-render the screen
CurrentLevel->AddDoor(newDoor);
RenderScreenElementsLayersUpdate((unsigned int) -1, -1);
SetUnsavedChanges(true);
Expand Down
15 changes: 15 additions & 0 deletions WL4EditorWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
<string>Edit</string>
</property>
<widget class="QMenu" name="menuAdd">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Add</string>
</property>
Expand Down Expand Up @@ -165,6 +168,9 @@
</property>
</action>
<action name="actionSave_ROM">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save ROM</string>
</property>
Expand All @@ -181,6 +187,9 @@
</property>
</action>
<action name="actionUndo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Undo</string>
</property>
Expand All @@ -189,6 +198,9 @@
</property>
</action>
<action name="actionRedo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Redo</string>
</property>
Expand All @@ -215,6 +227,9 @@
</property>
</action>
<action name="actionSave_As">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save As...</string>
</property>
Expand Down

0 comments on commit f371c8f

Please sign in to comment.