Skip to content

Fix gcc 142 warnings #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bin/
*.exe
*.bak
~Autorecover*.*
landstalker_gfx
landstalker_editor
VC2019/Debug
VC2019/Release
VC2019/.vs
Expand Down
6 changes: 4 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"/usr/local/lib/wx/include/gtk3-unicode-static-3.2",
"/usr/local/include/wx-3.2"
],
"defines": ["__WXGTK__"],
"compilerPath": "/usr/bin/gcc",
"defines": [
"__WXGTK__"
],
"compilerPath": null,
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"program": "${workspaceFolder}/landstalker_editor",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
Expand Down
14 changes: 9 additions & 5 deletions VC2019/landstalker_edit.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@
<ClCompile Include="..\src\user_interface\script\src\DataViewScriptActionRenderer.cpp">
<Filter>src\UI\Script</Filter>
</ClCompile>
<ClCompile Include="..\src\landstalker\script\src\ScriptFunction.cpp" />
<ClCompile Include="..\src\user_interface\script\src\ProgressFlagsDataViewModel.cpp">
<Filter>src\UI\Script</Filter>
</ClCompile>
Expand All @@ -580,6 +579,9 @@
<ClCompile Include="..\src\landstalker\script\src\ProgressFlags.cpp">
<Filter>src\Data\Script</Filter>
</ClCompile>
<ClCompile Include="..\src\landstalker\script\src\ScriptFunction.cpp">
<Filter>src\Data\Script</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\landstalker\2d_maps\include\Blockmap2D.h">
Expand Down Expand Up @@ -738,9 +740,6 @@
<ClInclude Include="..\src\user_interface\blockset\include\BlocksetEditorFrame.h">
<Filter>include\UI\Blockset</Filter>
</ClInclude>
<ClInclude Include="..\src\user_interface\main\include\EditorFrame.h">
<Filter>include\UI\Main</Filter>
</ClInclude>
<ClInclude Include="..\src\user_interface\main\include\Icons.h">
<Filter>include\UI\Main</Filter>
</ClInclude>
Expand Down Expand Up @@ -948,7 +947,6 @@
<ClInclude Include="..\src\user_interface\script\include\DataViewScriptActionRenderer.h">
<Filter>include\UI\Script</Filter>
</ClInclude>
<ClInclude Include="..\src\landstalker\script\include\ScriptFunction.h" />
<ClInclude Include="..\src\user_interface\script\include\ProgressFlagsDataViewModel.h">
<Filter>include\UI\Script</Filter>
</ClInclude>
Expand All @@ -970,6 +968,12 @@
<ClInclude Include="..\src\landstalker\script\include\ProgressFlags.h">
<Filter>include\Data\Script</Filter>
</ClInclude>
<ClInclude Include="..\src\user_interface\main\include\EditorFrame.h">
<Filter>include\UI\Behaviours</Filter>
</ClInclude>
<ClInclude Include="..\src\landstalker\script\include\ScriptFunction.h">
<Filter>include\UI\Script</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\src\user_interface\wxresource\resource\win_resources.rc">
Expand Down
2 changes: 1 addition & 1 deletion src/landstalker/3d_maps/include/Doors.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct Door

std::pair<uint8_t, uint8_t> GetBytes() const;

std::vector<std::pair<int, int>> GetMapRegionPoly(std::shared_ptr<const Tilemap3D> tilemap = nullptr, int tile_width = 8, int tile_height = 8) const;
std::pair<bool, std::vector<std::pair<int, int>>> GetMapRegionPoly(std::shared_ptr<const Tilemap3D> tilemap = nullptr, int tile_width = 8, int tile_height = 8) const;
static std::vector<std::pair<int, int>> OffsetRegionPoly(const std::vector<std::pair<int, int>>& points, const std::pair<int, int>& offset);
std::pair<int, int> GetTileOffset(std::shared_ptr<const Tilemap3D> tilemap = nullptr, const Tilemap3D::Layer& layer = Tilemap3D::Layer::BG) const;
std::pair<int, int> GetTileOffset(const Tilemap3D& tilemap, const Tilemap3D::Layer& layer = Tilemap3D::Layer::BG) const;
Expand Down
5 changes: 3 additions & 2 deletions src/landstalker/3d_maps/include/TileSwaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct TileSwap
};

TileSwap(const std::vector<uint8_t>& in);
TileSwap() : map({ 0,0,0,0,1,1 }), heightmap({ 0,0,0,0,1,1 }), mode(Mode::FLOOR), active(false) {}
TileSwap(CopyOp p_map, CopyOp p_heightmap, Mode p_mode) : map(p_map), heightmap(p_heightmap), mode(p_mode), active(false) {}
TileSwap() : trigger(0), map({ 0,0,0,0,1,1 }), heightmap({ 0,0,0,0,1,1 }), mode(Mode::FLOOR), active(false) {}
TileSwap(uint8_t p_trigger, CopyOp p_map, CopyOp p_heightmap, Mode p_mode) : trigger(p_trigger), map(p_map), heightmap(p_heightmap), mode(p_mode), active(false) {}
std::vector<uint8_t> GetBytes(uint16_t room, uint8_t idx) const;

std::vector<std::pair<int, int>> GetMapRegionPoly(Region region = Region::UNDEFINED, int tile_width = 8, int tile_height = 8) const;
Expand All @@ -49,6 +49,7 @@ struct TileSwap
bool operator==(const TileSwap& rhs) const;
bool operator!=(const TileSwap& rhs) const;

uint8_t trigger;
CopyOp map;
CopyOp heightmap;
Mode mode;
Expand Down
7 changes: 4 additions & 3 deletions src/landstalker/3d_maps/src/Doors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ std::pair<uint8_t, uint8_t> Door::GetBytes() const
static_cast<uint8_t>(((x + 12) & 0x3F) | ((sz & 0x03) << 6)) };
}

std::vector<std::pair<int, int>> Door::GetMapRegionPoly(std::shared_ptr<const Tilemap3D> tilemap, int tile_width, int tile_height) const
std::pair<bool, std::vector<std::pair<int, int>>> Door::GetMapRegionPoly(std::shared_ptr<const Tilemap3D> tilemap, int tile_width, int tile_height) const
{
Tilemap3D::FloorType type = Tilemap3D::FloorType::NORMAL;
TileSwap ts;
Expand All @@ -123,16 +123,17 @@ std::vector<std::pair<int, int>> Door::GetMapRegionPoly(std::shared_ptr<const Ti
ts.map.dst_y = 0;
ts.map.width = SIZES.at(size).first;
ts.map.height = SIZES.at(size).second;
bool valid = true;
if (tilemap)
{
type = static_cast<Tilemap3D::FloorType>(tilemap->GetCellType({ x, y }));
}
if (type != Tilemap3D::FloorType::DOOR_NE && type != Tilemap3D::FloorType::DOOR_NW)
{
return {};
valid = false;
}
ts.mode = (type == Tilemap3D::FloorType::DOOR_NE) ? TileSwap::Mode::WALL_NE : TileSwap::Mode::WALL_NW;
return ts.GetMapRegionPoly(TileSwap::Region::UNDEFINED, tile_width, tile_height);
return {valid, ts.GetMapRegionPoly(TileSwap::Region::UNDEFINED, tile_width, tile_height)};
}

std::vector<std::pair<int, int>> Door::OffsetRegionPoly(const std::vector<std::pair<int, int>>& points, const std::pair<int, int>& offset)
Expand Down
8 changes: 7 additions & 1 deletion src/landstalker/3d_maps/src/RoomToTmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ bool RoomToTmx::ExportToTmx(const std::string& fname, int roomnum, std::shared_p
lantern_room_property->AddAttribute("value", roomData->HasLanternFlag(roomnum) ? "true" : "false");
properties->AddChild(lantern_room_property);

auto lantern_flags_property = new wxXmlNode(wxXML_ELEMENT_NODE, "property");
lantern_flags_property->AddAttribute("name", "FlagLantern");
lantern_flags_property->AddAttribute("type", "int");
lantern_flags_property->AddAttribute("value", std::to_string(roomData->GetLanternFlag(roomnum)));
properties->AddChild(lantern_flags_property);
tmx.GetRoot()->AddChild(properties);

// Misc Properties
auto shop_room_property = new wxXmlNode(wxXML_ELEMENT_NODE, "property");
shop_room_property->AddAttribute("name", "FlagIsShopChurchInn");
Expand All @@ -121,7 +128,6 @@ bool RoomToTmx::ExportToTmx(const std::string& fname, int roomnum, std::shared_p
lifestock_sale_flags_property->AddAttribute("type", "int");
lifestock_sale_flags_property->AddAttribute("value", std::to_string(roomData->GetLifestockSaleFlag(roomnum)));
properties->AddChild(lifestock_sale_flags_property);

tmx.GetRoot()->AddChild(properties);


Expand Down
13 changes: 5 additions & 8 deletions src/landstalker/3d_maps/src/TileSwaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ TileSwaps::TileSwaps(const std::vector<uint8_t>& bytes)
{
break;
}
uint8_t idx = bytes[i + 14] >> 3;
TileSwap swap(std::vector<uint8_t>(bytes.cbegin() + i, bytes.cbegin() + i + 16));
if (m_swaps.count(room) == 0)
{
m_swaps.insert({ idx, {} });
m_swaps.insert({ room, {} });
}
if (idx >= m_swaps[room].size())
{
m_swaps[room].resize(idx + 1);
}
m_swaps[room][idx] = swap;
m_swaps[room].push_back(swap);
}
}

Expand Down Expand Up @@ -106,6 +101,7 @@ TileSwap::TileSwap(const std::vector<uint8_t>& in)
heightmap.dst_y = std::clamp<uint8_t>(in[9] - 12, 0, 0x3F);
heightmap.width = in[10] + 1;
heightmap.height = in[11] + 1;
trigger = in[14] >> 3;
mode = static_cast<Mode>(in[15]);
}

Expand Down Expand Up @@ -349,7 +345,8 @@ bool TileSwap::IsHeightmapPointInSwap(int x, int y) const

bool TileSwap::operator==(const TileSwap& rhs) const
{
return (this->map.src_x == rhs.map.src_x &&
return (this->trigger == rhs.trigger &&
this->map.src_x == rhs.map.src_x &&
this->map.src_y == rhs.map.src_y &&
this->map.dst_x == rhs.map.dst_x &&
this->map.dst_y == rhs.map.dst_y &&
Expand Down
4 changes: 2 additions & 2 deletions src/landstalker/3d_maps/src/Tilemap3DCmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,9 @@ IsoPoint2D Tilemap3D::ToIsometric(const Point2D& p, Layer layer) const
return IsoPoint2D{ x, y };
}

IsoPoint2D Tilemap3D::PixelToIsometric(const PixelPoint2D& pix, Layer layer) const
IsoPoint2D Tilemap3D::PixelToIsometric(const PixelPoint2D& /*pix*/, Layer /*layer*/) const
{
if (IsPixelPointValid(pix, layer) == false) return { -1, -1 };
// TODO
return IsoPoint2D{ -1, -1 };
}

Expand Down
7 changes: 4 additions & 3 deletions src/landstalker/behaviours/src/BehaviourYamlConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ std::vector<Behaviours::Command> BehaviourYamlConverter::FromYaml(const std::str
{
if (c.IsScalar())
{
const auto& cmddef = Behaviours::GetCommandByName(c.as<std::string>());
const Behaviours::CommandDefinition cmddef = Behaviours::GetCommandByName(c.as<std::string>());
if (!cmddef.params.empty())
{
std::string err("#" + std::to_string(cmd_index) + ": Expected parameters for command \"" + cmddef.aliases.front() + "\"");
Expand All @@ -102,7 +102,7 @@ std::vector<Behaviours::Command> BehaviourYamlConverter::FromYaml(const std::str
}
else if (c.IsMap() && c.size() >= 1)
{
const auto& cmddef = Behaviours::GetCommandByName(c.begin()->first.as<std::string>());
const Behaviours::CommandDefinition cmddef = Behaviours::GetCommandByName(c.begin()->first.as<std::string>());
Behaviours::Command cmd;
cmd.command = cmddef.id;
std::vector<bool> params_set(cmddef.params.size());
Expand All @@ -111,7 +111,8 @@ std::vector<Behaviours::Command> BehaviourYamlConverter::FromYaml(const std::str
{
cmd.params.push_back({ p.first, -1, Behaviours::ParamType::NONE });
}
for (const auto& p : c.begin()->second)
auto params = c.begin()->second;
for (const auto& p : params)
{
const auto& pname = p.first.as<std::string>();
auto pdef = std::find_if(cmddef.params.cbegin(), cmddef.params.cend(), [&pname](const auto& v)
Expand Down
2 changes: 1 addition & 1 deletion src/landstalker/behaviours/src/Behaviours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const std::unordered_map<Behaviours::CommandType, Behaviours::CommandDefinition>
{ CommandType::JUMP , { CommandType::JUMP , {"Jump"}, {} }},
{ CommandType::ENABLE_FRAME_UPDATE , { CommandType::ENABLE_FRAME_UPDATE , {"EnableFrameUpdate"}, {} }},
{ CommandType::DISABLE_FRAME_UPDATE , { CommandType::DISABLE_FRAME_UPDATE , {"DisableFrameUpdate"}, {} }},
{ CommandType::MOVE_RANDOM_TIMED , { CommandType::MOVE_RANDOM_TIMED , {"MoveRandomTimed"}, {{"Ticks", ParamType::UINT8}} }},
{ CommandType::MOVE_RANDOM_TIMED , { CommandType::MOVE_RANDOM_TIMED , {"MoveRandomTimed"}, {{"Ticks", ParamType::UINT8}, {"BaseTicks", ParamType::UINT8}} }},
{ CommandType::LOAD_SPECIAL_AI , { CommandType::LOAD_SPECIAL_AI , {"LoadSpecialAI"}, {} }},
{ CommandType::FOLLOW_PLAYER_NO_JUMP , { CommandType::FOLLOW_PLAYER_NO_JUMP , {"FollowPlayerNoJump"}, {{"Unknown", ParamType::UINT8}} }},
{ CommandType::UNKNOWN_B2D , { CommandType::UNKNOWN_B2D , {"UnknownB2D"}, {} }},
Expand Down
4 changes: 2 additions & 2 deletions src/landstalker/main/include/DataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DataManager
std::string GetName() const;
void SetName(const std::string& val);
std::filesystem::path GetFilename() const;
void SetFilename(const std::filesystem::path& val) const;
void SetFilename(const std::filesystem::path& val);
uint32_t GetStartAddress() const;
uint32_t GetDataLength();
uint32_t GetEndAddress();
Expand Down Expand Up @@ -245,7 +245,7 @@ inline std::filesystem::path DataManager::Entry<T>::GetFilename() const
}

template<class T>
inline void DataManager::Entry<T>::SetFilename(const std::filesystem::path& val) const
inline void DataManager::Entry<T>::SetFilename(const std::filesystem::path& val)
{
m_filename = val;
}
Expand Down
8 changes: 4 additions & 4 deletions src/landstalker/main/include/RoomData.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ class RoomData : public DataManager
TileSwaps m_gfxswaps;
TileSwaps m_gfxswaps_orig;

std::vector<TileSwapFlag> m_gfxswap_flags;
std::vector<TileSwapFlag> m_gfxswap_flags_orig;
std::vector<TileSwapFlag> m_gfxswap_locked_door_flags;
std::vector<TileSwapFlag> m_gfxswap_locked_door_flags_orig;
std::map<uint16_t, std::vector<TileSwapFlag>> m_gfxswap_flags;
std::map<uint16_t, std::vector<TileSwapFlag>> m_gfxswap_flags_orig;
std::map<uint16_t, std::vector<TileSwapFlag>> m_gfxswap_locked_door_flags;
std::map<uint16_t, std::vector<TileSwapFlag>> m_gfxswap_locked_door_flags_orig;
std::vector<TreeWarpFlag> m_gfxswap_big_tree_flags;
std::vector<TreeWarpFlag> m_gfxswap_big_tree_flags_orig;
std::set<uint16_t> m_shop_list;
Expand Down
4 changes: 2 additions & 2 deletions src/landstalker/main/src/AsmFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,12 @@ bool AsmFile::ProcessInst<AsmFile::Inst::DC>(const AsmFile::AsmLine& line)
for (std::size_t i = 0; i < static_cast<std::size_t>(width); ++i)
{
uint8_t byte = (result >> ((static_cast<std::size_t>(width) - i - 1) * 8)) & 0xFF;
m_data.push_back(byte);
m_data.emplace_back(byte);
}
}
else
{
m_data.push_back(word);
m_data.emplace_back(word);
}
}
return true;
Expand Down
Loading
Loading