Skip to content

Commit

Permalink
Reformat code to match .clang-format soecs
Browse files Browse the repository at this point in the history
  • Loading branch information
azihassan committed Oct 6, 2024
1 parent 75f0dfb commit 4a287e7
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 105 deletions.
4 changes: 2 additions & 2 deletions Source/DiabloUI/mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void MainmenuEsc()
void MainmenuLoad(const char *name)
{
#ifndef __DREAMCAST__
//single player save files are too big for the VMU
//todo reactivate when SD card saving is implemented
// single player save files are too big for the VMU
// todo reactivate when SD card saving is implemented
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Single Player"), MAINMENU_SINGLE_PLAYER));
#endif
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Multi Player"), MAINMENU_MULTIPLAYER));
Expand Down
30 changes: 15 additions & 15 deletions Source/controls/devices/joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ StaticVector<ControllerButtonEvent, 4> Joystick::ToControllerButtonEvents(const
case SDL_JOYAXISMOTION:
case SDL_JOYBALLMOTION:
#ifdef __DREAMCAST__
if(event.jaxis.axis == 3) {
Log("BUTTON_LEFTSHOULDER detected");
Log("event.jbutton.button = {}", event.jbutton.button);
Log("event.jbutton.state == SDL_RELEASED = {}", event.jbutton.state == SDL_RELEASED);
return { ControllerButtonEvent { ControllerButton_BUTTON_LEFTSHOULDER, event.jaxis.value < 255 } };
}
if(event.jaxis.axis == 2) {
Log("BUTTON_RIGHTSHOULDER detected");
Log("event.jbutton.button = {}", event.jbutton.button);
Log("event.jbutton.state == SDL_RELEASED = {}", event.jbutton.state == SDL_RELEASED);
return { ControllerButtonEvent { ControllerButton_BUTTON_RIGHTSHOULDER, event.jaxis.value < 255 } };
}
if (event.jaxis.axis == 3) {
Log("BUTTON_LEFTSHOULDER detected");
Log("event.jbutton.button = {}", event.jbutton.button);
Log("event.jbutton.state == SDL_RELEASED = {}", event.jbutton.state == SDL_RELEASED);
return { ControllerButtonEvent { ControllerButton_BUTTON_LEFTSHOULDER, event.jaxis.value < 255 } };
}
if (event.jaxis.axis == 2) {
Log("BUTTON_RIGHTSHOULDER detected");
Log("event.jbutton.button = {}", event.jbutton.button);
Log("event.jbutton.state == SDL_RELEASED = {}", event.jbutton.state == SDL_RELEASED);
return { ControllerButtonEvent { ControllerButton_BUTTON_RIGHTSHOULDER, event.jaxis.value < 255 } };
}
#endif
// ProcessAxisMotion() requires a ControllerButtonEvent parameter
// so provide one here using ControllerButton_NONE
Expand Down Expand Up @@ -322,19 +322,19 @@ bool Joystick::ProcessAxisMotion(const SDL_Event &event)
Log("event.jbutton.state == SDL_RELEASED = {}", event.jbutton.state == SDL_RELEASED);

switch (event.jaxis.axis) {
case 0: //horizontal
case 0: // horizontal
leftStickXUnscaled = event.jaxis.value;
leftStickNeedsScaling = true;
return true;
case 1: //vertical
case 1: // vertical
leftStickYUnscaled = event.jaxis.value;
leftStickNeedsScaling = true;
return true;
default:
return false;
}
}
#else //!ifdef __DREAMCAST__
#else //! ifdef __DREAMCAST__
bool Joystick::ProcessAxisMotion(const SDL_Event &event)
{
if (event.type != SDL_JOYAXISMOTION)
Expand Down
5 changes: 2 additions & 3 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,11 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState)
#endif
default:
if (IsCustomEvent(event.type)) {
if (gbIsMultiplayer)
{
if (gbIsMultiplayer) {
Log("IsCustomEvent({}) = true", event.type);
Log("pfile_write_hero");
pfile_write_hero();
}
}
nthread_ignore_mutex(true);
PaletteFadeOut(8);
sound_stop();
Expand Down
6 changes: 3 additions & 3 deletions Source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ bool CheckExtraFontsVersion(AssetRef &&ref)
bool AreExtraFontsOutOfDate(const std::string &path)
{
#ifdef __DREAMCAST__
//handle ISO 9660 trailing period
const std::string versionPath = path + "fonts" DIRECTORY_SEPARATOR_STR "VERSION.";
// handle ISO 9660 trailing period
const std::string versionPath = path + "fonts" DIRECTORY_SEPARATOR_STR "VERSION.";
#else
const std::string versionPath = path + "fonts" DIRECTORY_SEPARATOR_STR "VERSION";
const std::string versionPath = path + "fonts" DIRECTORY_SEPARATOR_STR "VERSION";
#endif

if (versionPath.size() + 1 > AssetRef::PathBufSize)
Expand Down
16 changes: 8 additions & 8 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class SaveHelper {

~SaveHelper()
{
//const auto encodedLen = m_cur_;
// const auto encodedLen = m_cur_;
const auto encodedLen = codec_get_encoded_len(m_cur_);
const char *const password = pfile_get_password();
Log("codec_encode(m_buffer_.get(), {}, {})", m_cur_, encodedLen);
Expand Down Expand Up @@ -2235,7 +2235,7 @@ size_t HotkeysSize(size_t nHotkeys = NumHotkeys)

void LoadHotkeys()
{
//hotkeys => htks to get around VMU filename size limits
// hotkeys => htks to get around VMU filename size limits
LoadHelper file(OpenSaveArchive(gSaveNumber), "htks");
if (!file.IsValid())
return;
Expand Down Expand Up @@ -2278,7 +2278,7 @@ void LoadHotkeys()

void SaveHotkeys(SaveWriter &saveWriter, const Player &player)
{
//hotkeys => htks to get around VMU filename size limits
// hotkeys => htks to get around VMU filename size limits
SaveHelper file(saveWriter, "htks", HotkeysSize());

// Write the number of spell hotkeys
Expand All @@ -2299,7 +2299,7 @@ void SaveHotkeys(SaveWriter &saveWriter, const Player &player)

void LoadHeroItems(Player &player)
{
//heroitems => hitms to get around VMU filename size limits
// heroitems => hitms to get around VMU filename size limits
LoadHelper file(OpenSaveArchive(gSaveNumber), "hitms");
if (!file.IsValid())
return;
Expand Down Expand Up @@ -2585,12 +2585,12 @@ void LoadGame(bool firstflag)
gbIsHellfireSaveGame = gbIsHellfire;
}

//todo restore saving of inventory body
// todo restore saving of inventory body
void SaveHeroItems(SaveWriter &saveWriter, Player &player)
{
size_t itemCount = static_cast<size_t>(NUM_INVLOC) + InventoryGridCells + MaxBeltItems; //7 + 40 + 8 = 55
//heroitems => hitms to get around VMU filename size limits
SaveHelper file(saveWriter, "hitms", itemCount * (gbIsHellfire ? HellfireItemSaveSize : DiabloItemSaveSize) + sizeof(uint8_t)); //55 * 368 + 1 = 20241 bytes
size_t itemCount = static_cast<size_t>(NUM_INVLOC) + InventoryGridCells + MaxBeltItems; // 7 + 40 + 8 = 55
// heroitems => hitms to get around VMU filename size limits
SaveHelper file(saveWriter, "hitms", itemCount * (gbIsHellfire ? HellfireItemSaveSize : DiabloItemSaveSize) + sizeof(uint8_t)); // 55 * 368 + 1 = 20241 bytes

file.WriteLE<uint8_t>(gbIsHellfire ? 1 : 0);

Expand Down
7 changes: 4 additions & 3 deletions Source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
#include "diablo.h"

#ifdef __DREAMCAST__
//fchmod fails to link on the dreamcast, this stub is provided as a workaround
extern "C" int fchmod(int fd, mode_t mode) {
return 0;
// fchmod fails to link on the dreamcast, this stub is provided as a workaround
extern "C" int fchmod(int fd, mode_t mode)
{
return 0;
}
#endif

Expand Down
Loading

0 comments on commit 4a287e7

Please sign in to comment.