Browse Source

Clang-tidy: FunctionCase part 2

pull/2294/head
Anders Jenbo 5 years ago
parent
commit
ee2e7518c4
  1. 4
      Source/diablo.cpp
  2. 7
      Source/items.cpp
  3. 2144
      Source/loadsave.cpp
  4. 6
      Source/monster.cpp
  5. 3110
      Source/msg.cpp
  6. 1
      Source/msg.h
  7. 288
      Source/options.cpp
  8. 4
      Source/options.h
  9. 2
      Source/player.h
  10. 28
      Source/town.cpp
  11. 2
      test/writehero_test.cpp

4
Source/diablo.cpp

@ -106,11 +106,11 @@ uint16_t gnTickDelay = 50;
Keymapper keymapper {
// Workaround: remove once the INI library has been replaced.
[](const std::string &key, const std::string &value) {
setIniValue("Keymapping", key.c_str(), value.c_str());
SetIniValue("Keymapping", key.c_str(), value.c_str());
},
[](const std::string &key) -> std::string {
std::array<char, 64> result;
if (!getIniValue("Keymapping", key.c_str(), result.data(), result.size()))
if (!GetIniValue("Keymapping", key.c_str(), result.data(), result.size()))
return {};
return { result.data() };
}

7
Source/items.cpp

@ -3954,7 +3954,6 @@ void UseItem(int p, item_misc_id Mid, spell_id spl)
case IMISC_SCROLL:
if (spelldata[spl].sTargeted) {
player._pTSpell = spl;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
} else {
@ -3972,7 +3971,6 @@ void UseItem(int p, item_misc_id Mid, spell_id spl)
case IMISC_SCROLLT:
if (spelldata[spl].sTargeted) {
player._pTSpell = spl;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
} else {
@ -4032,31 +4030,26 @@ void UseItem(int p, item_misc_id Mid, spell_id spl)
break;
case IMISC_RUNEF:
player._pTSpell = SPL_RUNEFIRE;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
break;
case IMISC_RUNEL:
player._pTSpell = SPL_RUNELIGHT;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
break;
case IMISC_GR_RUNEL:
player._pTSpell = SPL_RUNENOVA;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
break;
case IMISC_GR_RUNEF:
player._pTSpell = SPL_RUNEIMMOLAT;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
break;
case IMISC_RUNES:
player._pTSpell = SPL_RUNESTONE;
player._pTSplType = RSPLTYPE_INVALID;
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
break;

2144
Source/loadsave.cpp

File diff suppressed because it is too large Load Diff

6
Source/monster.cpp

@ -2784,15 +2784,15 @@ bool M_DumbWalk(int i, Direction md)
return ok;
}
static Direction turn(Direction direction, bool turnLeft)
static Direction Turn(Direction direction, bool turnLeft)
{
return turnLeft ? left[direction] : right[direction];
}
bool M_RoundWalk(int i, Direction direction, int *dir)
{
Direction turn45deg = turn(direction, *dir != 0);
Direction turn90deg = turn(turn45deg, *dir != 0);
Direction turn45deg = Turn(direction, *dir != 0);
Direction turn90deg = Turn(turn45deg, *dir != 0);
if (DirOK(i, turn90deg)) {
// Turn 90 degrees

3110
Source/msg.cpp

File diff suppressed because it is too large Load Diff

1
Source/msg.h

@ -27,7 +27,6 @@ enum _cmd_id : uint8_t {
CMD_ADDMAG,
CMD_ADDDEX,
CMD_ADDVIT,
CMD_SBSPELL,
CMD_GETITEM,
CMD_AGETITEM,
CMD_PUTITEM,

288
Source/options.cpp

@ -38,18 +38,18 @@ namespace devilution {
namespace {
std::string getIniPath()
std::string GetIniPath()
{
auto path = paths::ConfigPath() + std::string("diablo.ini");
return path;
}
CSimpleIni &getIni()
CSimpleIni &GetIni()
{
static CSimpleIni ini;
static bool isIniLoaded = false;
if (!isIniLoaded) {
auto path = getIniPath();
auto path = GetIniPath();
auto stream = CreateFileStream(path.c_str(), std::fstream::in | std::fstream::binary);
ini.SetSpaces(false);
if (stream != nullptr)
@ -59,68 +59,68 @@ CSimpleIni &getIni()
return ini;
}
int getIniInt(const char *keyname, const char *valuename, int defaultValue)
int GetIniInt(const char *keyname, const char *valuename, int defaultValue)
{
long value = getIni().GetLongValue(keyname, valuename, defaultValue);
long value = GetIni().GetLongValue(keyname, valuename, defaultValue);
return value;
}
bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue)
bool GetIniBool(const char *sectionName, const char *keyName, bool defaultValue)
{
bool value = getIni().GetBoolValue(sectionName, keyName, defaultValue);
bool value = GetIni().GetBoolValue(sectionName, keyName, defaultValue);
return value;
}
float getIniFloat(const char *sectionName, const char *keyName, float defaultValue)
float GetIniFloat(const char *sectionName, const char *keyName, float defaultValue)
{
const double value = getIni().GetDoubleValue(sectionName, keyName, defaultValue);
const double value = GetIni().GetDoubleValue(sectionName, keyName, defaultValue);
return (float)value;
}
void setIniValue(const char *keyname, const char *valuename, int value)
void SetIniValue(const char *keyname, const char *valuename, int value)
{
getIni().SetLongValue(keyname, valuename, value);
GetIni().SetLongValue(keyname, valuename, value);
}
void setIniValue(const char *keyname, const char *valuename, std::uint8_t value)
void SetIniValue(const char *keyname, const char *valuename, std::uint8_t value)
{
getIni().SetLongValue(keyname, valuename, value);
GetIni().SetLongValue(keyname, valuename, value);
}
void setIniValue(const char *keyname, const char *valuename, std::uint32_t value)
void SetIniValue(const char *keyname, const char *valuename, std::uint32_t value)
{
getIni().SetLongValue(keyname, valuename, value);
GetIni().SetLongValue(keyname, valuename, value);
}
void setIniValue(const char *keyname, const char *valuename, bool value)
void SetIniValue(const char *keyname, const char *valuename, bool value)
{
getIni().SetLongValue(keyname, valuename, value ? 1 : 0);
GetIni().SetLongValue(keyname, valuename, value ? 1 : 0);
}
void setIniValue(const char *keyname, const char *valuename, float value)
void SetIniValue(const char *keyname, const char *valuename, float value)
{
getIni().SetDoubleValue(keyname, valuename, value);
GetIni().SetDoubleValue(keyname, valuename, value);
}
void SaveIni()
{
auto iniPath = getIniPath();
auto iniPath = GetIniPath();
auto stream = CreateFileStream(iniPath.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary);
getIni().Save(*stream, true);
GetIni().Save(*stream, true);
}
} // namespace
void setIniValue(const char *sectionName, const char *keyName, const char *value, int len)
void SetIniValue(const char *sectionName, const char *keyName, const char *value, int len)
{
auto &ini = getIni();
auto &ini = GetIni();
std::string stringValue(value, len != 0 ? len : strlen(value));
ini.SetValue(sectionName, keyName, stringValue.c_str());
}
bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, const char *defaultString)
bool GetIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, const char *defaultString)
{
const char *value = getIni().GetValue(sectionName, keyName);
const char *value = GetIni().GetValue(sectionName, keyName);
if (value == nullptr) {
strncpy(string, defaultString, stringSize);
return false;
@ -138,84 +138,84 @@ bool sbWasOptionsLoaded = false;
*/
void LoadOptions()
{
sgOptions.Diablo.bIntro = getIniBool("Diablo", "Intro", true);
sgOptions.Hellfire.bIntro = getIniBool("Hellfire", "Intro", true);
getIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem, sizeof(sgOptions.Hellfire.szItem), "");
sgOptions.Audio.nSoundVolume = getIniInt("Audio", "Sound Volume", VOLUME_MAX);
sgOptions.Audio.nMusicVolume = getIniInt("Audio", "Music Volume", VOLUME_MAX);
sgOptions.Audio.bWalkingSound = getIniBool("Audio", "Walking Sound", true);
sgOptions.Audio.bAutoEquipSound = getIniBool("Audio", "Auto Equip Sound", false);
sgOptions.Audio.nSampleRate = getIniInt("Audio", "Sample Rate", DEFAULT_AUDIO_SAMPLE_RATE);
sgOptions.Audio.nChannels = getIniInt("Audio", "Channels", DEFAULT_AUDIO_CHANNELS);
sgOptions.Audio.nBufferSize = getIniInt("Audio", "Buffer Size", DEFAULT_AUDIO_BUFFER_SIZE);
sgOptions.Audio.nResamplingQuality = getIniInt("Audio", "Resampling Quality", DEFAULT_AUDIO_RESAMPLING_QUALITY);
sgOptions.Graphics.nWidth = getIniInt("Graphics", "Width", DEFAULT_WIDTH);
sgOptions.Graphics.nHeight = getIniInt("Graphics", "Height", DEFAULT_HEIGHT);
sgOptions.Diablo.bIntro = GetIniBool("Diablo", "Intro", true);
sgOptions.Hellfire.bIntro = GetIniBool("Hellfire", "Intro", true);
GetIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem, sizeof(sgOptions.Hellfire.szItem), "");
sgOptions.Audio.nSoundVolume = GetIniInt("Audio", "Sound Volume", VOLUME_MAX);
sgOptions.Audio.nMusicVolume = GetIniInt("Audio", "Music Volume", VOLUME_MAX);
sgOptions.Audio.bWalkingSound = GetIniBool("Audio", "Walking Sound", true);
sgOptions.Audio.bAutoEquipSound = GetIniBool("Audio", "Auto Equip Sound", false);
sgOptions.Audio.nSampleRate = GetIniInt("Audio", "Sample Rate", DEFAULT_AUDIO_SAMPLE_RATE);
sgOptions.Audio.nChannels = GetIniInt("Audio", "Channels", DEFAULT_AUDIO_CHANNELS);
sgOptions.Audio.nBufferSize = GetIniInt("Audio", "Buffer Size", DEFAULT_AUDIO_BUFFER_SIZE);
sgOptions.Audio.nResamplingQuality = GetIniInt("Audio", "Resampling Quality", DEFAULT_AUDIO_RESAMPLING_QUALITY);
sgOptions.Graphics.nWidth = GetIniInt("Graphics", "Width", DEFAULT_WIDTH);
sgOptions.Graphics.nHeight = GetIniInt("Graphics", "Height", DEFAULT_HEIGHT);
#ifndef __vita__
sgOptions.Graphics.bFullscreen = getIniBool("Graphics", "Fullscreen", true);
sgOptions.Graphics.bFullscreen = GetIniBool("Graphics", "Fullscreen", true);
#else
sgOptions.Graphics.bFullscreen = true;
#endif
#if !defined(USE_SDL1)
sgOptions.Graphics.bUpscale = getIniBool("Graphics", "Upscale", true);
sgOptions.Graphics.bUpscale = GetIniBool("Graphics", "Upscale", true);
#else
sgOptions.Graphics.bUpscale = false;
#endif
sgOptions.Graphics.bFitToScreen = getIniBool("Graphics", "Fit to Screen", true);
getIniValue("Graphics", "Scaling Quality", sgOptions.Graphics.szScaleQuality, sizeof(sgOptions.Graphics.szScaleQuality), "2");
sgOptions.Graphics.bIntegerScaling = getIniBool("Graphics", "Integer Scaling", false);
sgOptions.Graphics.bVSync = getIniBool("Graphics", "Vertical Sync", true);
sgOptions.Graphics.bBlendedTransparancy = getIniBool("Graphics", "Blended Transparency", true);
sgOptions.Graphics.nGammaCorrection = getIniInt("Graphics", "Gamma Correction", 100);
sgOptions.Graphics.bColorCycling = getIniBool("Graphics", "Color Cycling", true);
sgOptions.Graphics.bFitToScreen = GetIniBool("Graphics", "Fit to Screen", true);
GetIniValue("Graphics", "Scaling Quality", sgOptions.Graphics.szScaleQuality, sizeof(sgOptions.Graphics.szScaleQuality), "2");
sgOptions.Graphics.bIntegerScaling = GetIniBool("Graphics", "Integer Scaling", false);
sgOptions.Graphics.bVSync = GetIniBool("Graphics", "Vertical Sync", true);
sgOptions.Graphics.bBlendedTransparancy = GetIniBool("Graphics", "Blended Transparency", true);
sgOptions.Graphics.nGammaCorrection = GetIniInt("Graphics", "Gamma Correction", 100);
sgOptions.Graphics.bColorCycling = GetIniBool("Graphics", "Color Cycling", true);
#ifndef USE_SDL1
sgOptions.Graphics.bHardwareCursor = getIniBool("Graphics", "Hardware Cursor", false);
sgOptions.Graphics.bHardwareCursor = GetIniBool("Graphics", "Hardware Cursor", false);
#else
sgOptions.Graphics.bHardwareCursor = false;
#endif
sgOptions.Graphics.bFPSLimit = getIniBool("Graphics", "FPS Limiter", true);
sgOptions.Graphics.bShowFPS = (getIniInt("Graphics", "Show FPS", 0) != 0);
sgOptions.Gameplay.nTickRate = getIniInt("Game", "Speed", 20);
sgOptions.Gameplay.bRunInTown = getIniBool("Game", "Run in Town", false);
sgOptions.Gameplay.bGrabInput = getIniBool("Game", "Grab Input", false);
sgOptions.Gameplay.bTheoQuest = getIniBool("Game", "Theo Quest", false);
sgOptions.Gameplay.bCowQuest = getIniBool("Game", "Cow Quest", false);
sgOptions.Gameplay.bFriendlyFire = getIniBool("Game", "Friendly Fire", true);
sgOptions.Gameplay.bTestBard = getIniBool("Game", "Test Bard", false);
sgOptions.Gameplay.bTestBarbarian = getIniBool("Game", "Test Barbarian", false);
sgOptions.Gameplay.bExperienceBar = getIniBool("Game", "Experience Bar", false);
sgOptions.Gameplay.bEnemyHealthBar = getIniBool("Game", "Enemy Health Bar", false);
sgOptions.Gameplay.bAutoGoldPickup = getIniBool("Game", "Auto Gold Pickup", false);
sgOptions.Gameplay.bAdriaRefillsMana = getIniBool("Game", "Adria Refills Mana", false);
sgOptions.Gameplay.bAutoEquipWeapons = getIniBool("Game", "Auto Equip Weapons", true);
sgOptions.Gameplay.bAutoEquipArmor = getIniBool("Game", "Auto Equip Armor", false);
sgOptions.Gameplay.bAutoEquipHelms = getIniBool("Game", "Auto Equip Helms", false);
sgOptions.Gameplay.bAutoEquipShields = getIniBool("Game", "Auto Equip Shields", false);
sgOptions.Gameplay.bAutoEquipJewelry = getIniBool("Game", "Auto Equip Jewelry", false);
sgOptions.Gameplay.bRandomizeQuests = getIniBool("Game", "Randomize Quests", true);
sgOptions.Gameplay.bShowMonsterType = getIniBool("Game", "Show Monster Type", false);
sgOptions.Gameplay.bDisableCripplingShrines = getIniBool("Game", "Disable Crippling Shrines", false);
getIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0");
sgOptions.Network.nPort = getIniInt("Network", "Port", 6112);
getIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost, sizeof(sgOptions.Network.szPreviousHost), "");
sgOptions.Graphics.bFPSLimit = GetIniBool("Graphics", "FPS Limiter", true);
sgOptions.Graphics.bShowFPS = (GetIniInt("Graphics", "Show FPS", 0) != 0);
sgOptions.Gameplay.nTickRate = GetIniInt("Game", "Speed", 20);
sgOptions.Gameplay.bRunInTown = GetIniBool("Game", "Run in Town", false);
sgOptions.Gameplay.bGrabInput = GetIniBool("Game", "Grab Input", false);
sgOptions.Gameplay.bTheoQuest = GetIniBool("Game", "Theo Quest", false);
sgOptions.Gameplay.bCowQuest = GetIniBool("Game", "Cow Quest", false);
sgOptions.Gameplay.bFriendlyFire = GetIniBool("Game", "Friendly Fire", true);
sgOptions.Gameplay.bTestBard = GetIniBool("Game", "Test Bard", false);
sgOptions.Gameplay.bTestBarbarian = GetIniBool("Game", "Test Barbarian", false);
sgOptions.Gameplay.bExperienceBar = GetIniBool("Game", "Experience Bar", false);
sgOptions.Gameplay.bEnemyHealthBar = GetIniBool("Game", "Enemy Health Bar", false);
sgOptions.Gameplay.bAutoGoldPickup = GetIniBool("Game", "Auto Gold Pickup", false);
sgOptions.Gameplay.bAdriaRefillsMana = GetIniBool("Game", "Adria Refills Mana", false);
sgOptions.Gameplay.bAutoEquipWeapons = GetIniBool("Game", "Auto Equip Weapons", true);
sgOptions.Gameplay.bAutoEquipArmor = GetIniBool("Game", "Auto Equip Armor", false);
sgOptions.Gameplay.bAutoEquipHelms = GetIniBool("Game", "Auto Equip Helms", false);
sgOptions.Gameplay.bAutoEquipShields = GetIniBool("Game", "Auto Equip Shields", false);
sgOptions.Gameplay.bAutoEquipJewelry = GetIniBool("Game", "Auto Equip Jewelry", false);
sgOptions.Gameplay.bRandomizeQuests = GetIniBool("Game", "Randomize Quests", true);
sgOptions.Gameplay.bShowMonsterType = GetIniBool("Game", "Show Monster Type", false);
sgOptions.Gameplay.bDisableCripplingShrines = GetIniBool("Game", "Disable Crippling Shrines", false);
GetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0");
sgOptions.Network.nPort = GetIniInt("Network", "Port", 6112);
GetIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost, sizeof(sgOptions.Network.szPreviousHost), "");
for (size_t i = 0; i < QUICK_MESSAGE_OPTIONS; i++)
getIniValue("NetMsg", QuickMessages[i].key, sgOptions.Chat.szHotKeyMsgs[i], MAX_SEND_STR_LEN, "");
GetIniValue("NetMsg", QuickMessages[i].key, sgOptions.Chat.szHotKeyMsgs[i], MAX_SEND_STR_LEN, "");
getIniValue("Controller", "Mapping", sgOptions.Controller.szMapping, sizeof(sgOptions.Controller.szMapping), "");
sgOptions.Controller.bSwapShoulderButtonMode = getIniBool("Controller", "Swap Shoulder Button Mode", false);
sgOptions.Controller.bDpadHotkeys = getIniBool("Controller", "Dpad Hotkeys", false);
sgOptions.Controller.fDeadzone = getIniFloat("Controller", "deadzone", 0.07);
GetIniValue("Controller", "Mapping", sgOptions.Controller.szMapping, sizeof(sgOptions.Controller.szMapping), "");
sgOptions.Controller.bSwapShoulderButtonMode = GetIniBool("Controller", "Swap Shoulder Button Mode", false);
sgOptions.Controller.bDpadHotkeys = GetIniBool("Controller", "Dpad Hotkeys", false);
sgOptions.Controller.fDeadzone = GetIniFloat("Controller", "deadzone", 0.07);
#ifdef __vita__
sgOptions.Controller.bRearTouch = getIniBool("Controller", "Enable Rear Touchpad", true);
sgOptions.Controller.bRearTouch = GetIniBool("Controller", "Enable Rear Touchpad", true);
#endif
getIniValue("Language", "Code", sgOptions.Language.szCode, sizeof(sgOptions.Language.szCode), "en");
GetIniValue("Language", "Code", sgOptions.Language.szCode, sizeof(sgOptions.Language.szCode), "en");
keymapper.load();
@ -227,77 +227,77 @@ void LoadOptions()
*/
void SaveOptions()
{
setIniValue("Diablo", "Intro", sgOptions.Diablo.bIntro);
setIniValue("Hellfire", "Intro", sgOptions.Hellfire.bIntro);
setIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem);
setIniValue("Audio", "Sound Volume", sgOptions.Audio.nSoundVolume);
setIniValue("Audio", "Music Volume", sgOptions.Audio.nMusicVolume);
setIniValue("Audio", "Walking Sound", sgOptions.Audio.bWalkingSound);
setIniValue("Audio", "Auto Equip Sound", sgOptions.Audio.bAutoEquipSound);
setIniValue("Audio", "Sample Rate", sgOptions.Audio.nSampleRate);
setIniValue("Audio", "Channels", sgOptions.Audio.nChannels);
setIniValue("Audio", "Buffer Size", sgOptions.Audio.nBufferSize);
setIniValue("Audio", "Resampling Quality", sgOptions.Audio.nResamplingQuality);
setIniValue("Graphics", "Width", sgOptions.Graphics.nWidth);
setIniValue("Graphics", "Height", sgOptions.Graphics.nHeight);
SetIniValue("Diablo", "Intro", sgOptions.Diablo.bIntro);
SetIniValue("Hellfire", "Intro", sgOptions.Hellfire.bIntro);
SetIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem);
SetIniValue("Audio", "Sound Volume", sgOptions.Audio.nSoundVolume);
SetIniValue("Audio", "Music Volume", sgOptions.Audio.nMusicVolume);
SetIniValue("Audio", "Walking Sound", sgOptions.Audio.bWalkingSound);
SetIniValue("Audio", "Auto Equip Sound", sgOptions.Audio.bAutoEquipSound);
SetIniValue("Audio", "Sample Rate", sgOptions.Audio.nSampleRate);
SetIniValue("Audio", "Channels", sgOptions.Audio.nChannels);
SetIniValue("Audio", "Buffer Size", sgOptions.Audio.nBufferSize);
SetIniValue("Audio", "Resampling Quality", sgOptions.Audio.nResamplingQuality);
SetIniValue("Graphics", "Width", sgOptions.Graphics.nWidth);
SetIniValue("Graphics", "Height", sgOptions.Graphics.nHeight);
#ifndef __vita__
setIniValue("Graphics", "Fullscreen", sgOptions.Graphics.bFullscreen);
SetIniValue("Graphics", "Fullscreen", sgOptions.Graphics.bFullscreen);
#endif
#if !defined(USE_SDL1)
setIniValue("Graphics", "Upscale", sgOptions.Graphics.bUpscale);
SetIniValue("Graphics", "Upscale", sgOptions.Graphics.bUpscale);
#endif
setIniValue("Graphics", "Fit to Screen", sgOptions.Graphics.bFitToScreen);
setIniValue("Graphics", "Scaling Quality", sgOptions.Graphics.szScaleQuality);
setIniValue("Graphics", "Integer Scaling", sgOptions.Graphics.bIntegerScaling);
setIniValue("Graphics", "Vertical Sync", sgOptions.Graphics.bVSync);
setIniValue("Graphics", "Blended Transparency", sgOptions.Graphics.bBlendedTransparancy);
setIniValue("Graphics", "Gamma Correction", sgOptions.Graphics.nGammaCorrection);
setIniValue("Graphics", "Color Cycling", sgOptions.Graphics.bColorCycling);
SetIniValue("Graphics", "Fit to Screen", sgOptions.Graphics.bFitToScreen);
SetIniValue("Graphics", "Scaling Quality", sgOptions.Graphics.szScaleQuality);
SetIniValue("Graphics", "Integer Scaling", sgOptions.Graphics.bIntegerScaling);
SetIniValue("Graphics", "Vertical Sync", sgOptions.Graphics.bVSync);
SetIniValue("Graphics", "Blended Transparency", sgOptions.Graphics.bBlendedTransparancy);
SetIniValue("Graphics", "Gamma Correction", sgOptions.Graphics.nGammaCorrection);
SetIniValue("Graphics", "Color Cycling", sgOptions.Graphics.bColorCycling);
#ifndef USE_SDL1
setIniValue("Graphics", "Hardware Cursor", sgOptions.Graphics.bHardwareCursor);
SetIniValue("Graphics", "Hardware Cursor", sgOptions.Graphics.bHardwareCursor);
#endif
setIniValue("Graphics", "FPS Limiter", sgOptions.Graphics.bFPSLimit);
setIniValue("Graphics", "Show FPS", sgOptions.Graphics.bShowFPS);
setIniValue("Game", "Speed", sgOptions.Gameplay.nTickRate);
setIniValue("Game", "Run in Town", sgOptions.Gameplay.bRunInTown);
setIniValue("Game", "Grab Input", sgOptions.Gameplay.bGrabInput);
setIniValue("Game", "Theo Quest", sgOptions.Gameplay.bTheoQuest);
setIniValue("Game", "Cow Quest", sgOptions.Gameplay.bCowQuest);
setIniValue("Game", "Friendly Fire", sgOptions.Gameplay.bFriendlyFire);
setIniValue("Game", "Test Bard", sgOptions.Gameplay.bTestBard);
setIniValue("Game", "Test Barbarian", sgOptions.Gameplay.bTestBarbarian);
setIniValue("Game", "Experience Bar", sgOptions.Gameplay.bExperienceBar);
setIniValue("Game", "Enemy Health Bar", sgOptions.Gameplay.bEnemyHealthBar);
setIniValue("Game", "Auto Gold Pickup", sgOptions.Gameplay.bAutoGoldPickup);
setIniValue("Game", "Adria Refills Mana", sgOptions.Gameplay.bAdriaRefillsMana);
setIniValue("Game", "Auto Equip Weapons", sgOptions.Gameplay.bAutoEquipWeapons);
setIniValue("Game", "Auto Equip Armor", sgOptions.Gameplay.bAutoEquipArmor);
setIniValue("Game", "Auto Equip Helms", sgOptions.Gameplay.bAutoEquipHelms);
setIniValue("Game", "Auto Equip Shields", sgOptions.Gameplay.bAutoEquipShields);
setIniValue("Game", "Auto Equip Jewelry", sgOptions.Gameplay.bAutoEquipJewelry);
setIniValue("Game", "Randomize Quests", sgOptions.Gameplay.bRandomizeQuests);
setIniValue("Game", "Show Monster Type", sgOptions.Gameplay.bShowMonsterType);
setIniValue("Game", "Disable Crippling Shrines", sgOptions.Gameplay.bDisableCripplingShrines);
setIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress);
setIniValue("Network", "Port", sgOptions.Network.nPort);
setIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost);
SetIniValue("Graphics", "FPS Limiter", sgOptions.Graphics.bFPSLimit);
SetIniValue("Graphics", "Show FPS", sgOptions.Graphics.bShowFPS);
SetIniValue("Game", "Speed", sgOptions.Gameplay.nTickRate);
SetIniValue("Game", "Run in Town", sgOptions.Gameplay.bRunInTown);
SetIniValue("Game", "Grab Input", sgOptions.Gameplay.bGrabInput);
SetIniValue("Game", "Theo Quest", sgOptions.Gameplay.bTheoQuest);
SetIniValue("Game", "Cow Quest", sgOptions.Gameplay.bCowQuest);
SetIniValue("Game", "Friendly Fire", sgOptions.Gameplay.bFriendlyFire);
SetIniValue("Game", "Test Bard", sgOptions.Gameplay.bTestBard);
SetIniValue("Game", "Test Barbarian", sgOptions.Gameplay.bTestBarbarian);
SetIniValue("Game", "Experience Bar", sgOptions.Gameplay.bExperienceBar);
SetIniValue("Game", "Enemy Health Bar", sgOptions.Gameplay.bEnemyHealthBar);
SetIniValue("Game", "Auto Gold Pickup", sgOptions.Gameplay.bAutoGoldPickup);
SetIniValue("Game", "Adria Refills Mana", sgOptions.Gameplay.bAdriaRefillsMana);
SetIniValue("Game", "Auto Equip Weapons", sgOptions.Gameplay.bAutoEquipWeapons);
SetIniValue("Game", "Auto Equip Armor", sgOptions.Gameplay.bAutoEquipArmor);
SetIniValue("Game", "Auto Equip Helms", sgOptions.Gameplay.bAutoEquipHelms);
SetIniValue("Game", "Auto Equip Shields", sgOptions.Gameplay.bAutoEquipShields);
SetIniValue("Game", "Auto Equip Jewelry", sgOptions.Gameplay.bAutoEquipJewelry);
SetIniValue("Game", "Randomize Quests", sgOptions.Gameplay.bRandomizeQuests);
SetIniValue("Game", "Show Monster Type", sgOptions.Gameplay.bShowMonsterType);
SetIniValue("Game", "Disable Crippling Shrines", sgOptions.Gameplay.bDisableCripplingShrines);
SetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress);
SetIniValue("Network", "Port", sgOptions.Network.nPort);
SetIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost);
for (size_t i = 0; i < QUICK_MESSAGE_OPTIONS; i++)
setIniValue("NetMsg", QuickMessages[i].key, sgOptions.Chat.szHotKeyMsgs[i]);
SetIniValue("NetMsg", QuickMessages[i].key, sgOptions.Chat.szHotKeyMsgs[i]);
setIniValue("Controller", "Mapping", sgOptions.Controller.szMapping);
setIniValue("Controller", "Swap Shoulder Button Mode", sgOptions.Controller.bSwapShoulderButtonMode);
setIniValue("Controller", "Dpad Hotkeys", sgOptions.Controller.bDpadHotkeys);
setIniValue("Controller", "deadzone", sgOptions.Controller.fDeadzone);
SetIniValue("Controller", "Mapping", sgOptions.Controller.szMapping);
SetIniValue("Controller", "Swap Shoulder Button Mode", sgOptions.Controller.bSwapShoulderButtonMode);
SetIniValue("Controller", "Dpad Hotkeys", sgOptions.Controller.bDpadHotkeys);
SetIniValue("Controller", "deadzone", sgOptions.Controller.fDeadzone);
#ifdef __vita__
setIniValue("Controller", "Enable Rear Touchpad", sgOptions.Controller.bRearTouch);
SetIniValue("Controller", "Enable Rear Touchpad", sgOptions.Controller.bRearTouch);
#endif
setIniValue("Language", "Code", sgOptions.Language.szCode);
SetIniValue("Language", "Code", sgOptions.Language.szCode);
keymapper.save();

4
Source/options.h

@ -158,8 +158,8 @@ struct Options {
LanguageOptions Language;
};
bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, const char *defaultString = "");
void setIniValue(const char *sectionName, const char *keyName, const char *value, int len = 0);
bool GetIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, const char *defaultString = "");
void SetIniValue(const char *sectionName, const char *keyName, const char *value, int len = 0);
extern Options sgOptions;
extern bool sbWasOptionsLoaded;

2
Source/player.h

@ -191,11 +191,9 @@ struct PlayerStruct {
spell_type _pSplType;
int8_t _pSplFrom; // TODO Create enum
spell_id _pTSpell;
spell_type _pTSplType;
spell_id _pRSpell;
spell_type _pRSplType;
spell_id _pSBkSpell;
spell_type _pSBkSplType;
int8_t _pSplLvl[64];
uint64_t _pMemSpells; // Bitmask of learned spells
uint64_t _pAblSpells; // Bitmask of abilities

28
Source/town.cpp

@ -23,7 +23,7 @@ namespace {
* @param xi upper left destination
* @param yy upper left destination
*/
void T_FillSector(const char *path, int xi, int yy)
void FillSector(const char *path, int xi, int yy)
{
auto dunData = LoadFileInMem<uint16_t>(path);
@ -66,7 +66,7 @@ void T_FillSector(const char *path, int xi, int yy)
* @param yy upper left destination
* @param t tile id
*/
void T_FillTile(int xx, int yy, int t)
void FillTile(int xx, int yy, int t)
{
MegaTile mega = pMegaTiles[t - 1];
@ -151,7 +151,7 @@ void TownCloseGrave()
/**
* @brief Initialize all of the levels data
*/
void T_Pass3()
void DrlgTPass3()
{
for (int yy = 0; yy < MAXDUNY; yy += 2) {
for (int xx = 0; xx < MAXDUNX; xx += 2) {
@ -162,22 +162,22 @@ void T_Pass3()
}
}
T_FillSector("Levels\\TownData\\Sector1s.DUN", 46, 46);
T_FillSector("Levels\\TownData\\Sector2s.DUN", 46, 0);
T_FillSector("Levels\\TownData\\Sector3s.DUN", 0, 46);
T_FillSector("Levels\\TownData\\Sector4s.DUN", 0, 0);
FillSector("Levels\\TownData\\Sector1s.DUN", 46, 46);
FillSector("Levels\\TownData\\Sector2s.DUN", 46, 0);
FillSector("Levels\\TownData\\Sector3s.DUN", 0, 46);
FillSector("Levels\\TownData\\Sector4s.DUN", 0, 0);
if (gbIsSpawn || !gbIsMultiplayer) {
if (gbIsSpawn || ((plr[myplr].pTownWarps & 1) == 0 && (!gbIsHellfire || plr[myplr]._pLevel < 10))) {
T_FillTile(48, 20, 320);
FillTile(48, 20, 320);
}
if (gbIsSpawn || ((plr[myplr].pTownWarps & 2) == 0 && (!gbIsHellfire || plr[myplr]._pLevel < 15))) {
T_FillTile(16, 68, 332);
T_FillTile(16, 70, 331);
FillTile(16, 68, 332);
FillTile(16, 70, 331);
}
if (gbIsSpawn || ((plr[myplr].pTownWarps & 4) == 0 && (!gbIsHellfire || plr[myplr]._pLevel < 20))) {
for (int x = 36; x < 46; x++) {
T_FillTile(x, 78, GenerateRnd(4) + 1);
FillTile(x, 78, GenerateRnd(4) + 1);
}
}
}
@ -195,9 +195,9 @@ void T_Pass3()
}
if (quests[Q_PWATER]._qactive != QUEST_DONE && quests[Q_PWATER]._qactive != QUEST_NOTAVAIL) {
T_FillTile(60, 70, 342);
FillTile(60, 70, 342);
} else {
T_FillTile(60, 70, 71);
FillTile(60, 70, 71);
}
}
@ -317,7 +317,7 @@ void CreateTown(lvl_entry entry)
}
}
T_Pass3();
DrlgTPass3();
memset(dFlags, 0, sizeof(dFlags));
memset(dLight, 0, sizeof(dLight));
memset(dFlags, 0, sizeof(dFlags));

2
test/writehero_test.cpp

@ -300,11 +300,9 @@ static void AssertPlayer(PlayerStruct &player)
ASSERT_EQ(player._pSplType, 4);
ASSERT_EQ(player._pSplFrom, 0);
ASSERT_EQ(player._pTSpell, 0);
ASSERT_EQ(player._pTSplType, 0);
ASSERT_EQ(player._pRSpell, -1);
ASSERT_EQ(player._pRSplType, 4);
ASSERT_EQ(player._pSBkSpell, -1);
ASSERT_EQ(player._pSBkSplType, 0);
ASSERT_EQ(player._pAblSpells, 134217728);
ASSERT_EQ(player._pScrlSpells, 0);
ASSERT_EQ(player._pSpellFlags, 0);

Loading…
Cancel
Save