mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 14:23:44 -07:00
Convert c-style casts to static_cast.
This commit is contained in:
parent
53c6102b8f
commit
7f2969be63
6 changed files with 29 additions and 27 deletions
|
@ -61,8 +61,8 @@ std::vector<AltTrapType> getEnabledAddTraps() {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void RollRandomTrap(uint32_t seed) {
|
static void RollRandomTrap(uint32_t seed) {
|
||||||
uint32_t finalSeed =
|
uint32_t finalSeed = seed + (IS_RANDO ? Rando::Context::GetInstance()->GetSeed()
|
||||||
seed + (IS_RANDO ? Rando::Context::GetInstance()->GetSeed() : (uint32_t)gSaveContext.ship.stats.fileCreatedAt);
|
: static_cast<uint32_t>(gSaveContext.ship.stats.fileCreatedAt));
|
||||||
Random_Init(finalSeed);
|
Random_Init(finalSeed);
|
||||||
|
|
||||||
roll = RandomElement(getEnabledAddTraps());
|
roll = RandomElement(getEnabledAddTraps());
|
||||||
|
@ -126,12 +126,12 @@ static void OnPlayerUpdate() {
|
||||||
Play_TriggerRespawn(gPlayState);
|
Play_TriggerRespawn(gPlayState);
|
||||||
break;
|
break;
|
||||||
case ADD_AMMO_TRAP:
|
case ADD_AMMO_TRAP:
|
||||||
AMMO(ITEM_STICK) = (int8_t)floor(AMMO(ITEM_STICK) * 0.5f);
|
AMMO(ITEM_STICK) = static_cast<int8_t>(floor(AMMO(ITEM_STICK) * 0.5f));
|
||||||
AMMO(ITEM_NUT) = (int8_t)floor(AMMO(ITEM_NUT) * 0.5f);
|
AMMO(ITEM_NUT) = static_cast<int8_t>(floor(AMMO(ITEM_NUT) * 0.5f));
|
||||||
AMMO(ITEM_SLINGSHOT) = (int8_t)floor(AMMO(ITEM_SLINGSHOT) * 0.5f);
|
AMMO(ITEM_SLINGSHOT) = static_cast<int8_t>(floor(AMMO(ITEM_SLINGSHOT) * 0.5f));
|
||||||
AMMO(ITEM_BOW) = (int8_t)floor(AMMO(ITEM_BOW) * 0.5f);
|
AMMO(ITEM_BOW) = static_cast<int8_t>(floor(AMMO(ITEM_BOW) * 0.5f));
|
||||||
AMMO(ITEM_BOMB) = (int8_t)floor(AMMO(ITEM_BOMB) * 0.5f);
|
AMMO(ITEM_BOMB) = static_cast<int8_t>(floor(AMMO(ITEM_BOMB) * 0.5f));
|
||||||
AMMO(ITEM_BOMBCHU) = (int8_t)floor(AMMO(ITEM_BOMBCHU) * 0.5f);
|
AMMO(ITEM_BOMBCHU) = static_cast<int8_t>(floor(AMMO(ITEM_BOMBCHU) * 0.5f));
|
||||||
Audio_PlaySoundGeneral(NA_SE_VO_FR_SMILE_0, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
Audio_PlaySoundGeneral(NA_SE_VO_FR_SMILE_0, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||||
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -111,7 +111,7 @@ const char* BossRush_GetSettingChoiceName(u8 optionIndex, u8 choiceIndex, u8 lan
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 BossRush_GetSettingOptionsAmount(u8 optionIndex) {
|
u8 BossRush_GetSettingOptionsAmount(u8 optionIndex) {
|
||||||
return (u8)BossRushOptions[optionIndex].choices.size();
|
return static_cast<u8>(BossRushOptions[optionIndex].choices.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BossRush_SpawnBlueWarps(PlayState* play) {
|
void BossRush_SpawnBlueWarps(PlayState* play) {
|
||||||
|
@ -311,7 +311,8 @@ void BossRush_HandleCompleteBoss(PlayState* play) {
|
||||||
play->sceneNum == SCENE_GANON_BOSS) {
|
play->sceneNum == SCENE_GANON_BOSS) {
|
||||||
gSaveContext.ship.stats.playTimer += 2;
|
gSaveContext.ship.stats.playTimer += 2;
|
||||||
gSaveContext.ship.stats.gameComplete = 1;
|
gSaveContext.ship.stats.gameComplete = 1;
|
||||||
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_BOSSRUSH_FINISH] = (uint32_t)GAMEPLAYSTAT_TOTAL_TIME;
|
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_BOSSRUSH_FINISH] =
|
||||||
|
static_cast<uint32_t>(GAMEPLAYSTAT_TOTAL_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ void Mouse_HandleFirstPerson(Player* player) {
|
||||||
: 1;
|
: 1;
|
||||||
s8 invertYAxisMulti = CVarGetInteger(CVAR_SETTING("Controls.InvertAimingYAxis"), 1) ? 1 : -1;
|
s8 invertYAxisMulti = CVarGetInteger(CVAR_SETTING("Controls.InvertAimingYAxis"), 1) ? 1 : -1;
|
||||||
if (MOUSE_ENABLED) {
|
if (MOUSE_ENABLED) {
|
||||||
player->actor.focus.rot.y -= (int16_t)(mouseCoordRel.x * 6.0f * xAxisMulti * invertXAxisMulti);
|
player->actor.focus.rot.y -= static_cast<int16_t>(mouseCoordRel.x * 6.0f * xAxisMulti * invertXAxisMulti);
|
||||||
player->actor.focus.rot.x += (int16_t)(mouseCoordRel.y * 6.0f * yAxisMulti * invertYAxisMulti);
|
player->actor.focus.rot.x += static_cast<int16_t>(mouseCoordRel.y * 6.0f * yAxisMulti * invertYAxisMulti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void Mouse_RecenterCursor() {
|
||||||
u32 width = GetWindow()->GetWidth();
|
u32 width = GetWindow()->GetWidth();
|
||||||
u32 height = GetWindow()->GetHeight();
|
u32 height = GetWindow()->GetHeight();
|
||||||
if (MOUSE_ENABLED) {
|
if (MOUSE_ENABLED) {
|
||||||
GetWindow()->SetMousePos({ (s32)(width / 2), (s32)(height / 2) });
|
GetWindow()->SetMousePos({ static_cast<s32>(width / 2), static_cast<s32>(height / 2) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ void Mouse_HandleShield(f32* sp50, f32* sp54) {
|
||||||
if (MOUSE_ENABLED) {
|
if (MOUSE_ENABLED) {
|
||||||
s32 width = GetWindow()->GetWidth();
|
s32 width = GetWindow()->GetWidth();
|
||||||
s32 height = GetWindow()->GetHeight();
|
s32 height = GetWindow()->GetHeight();
|
||||||
f32 xBound = 7200 / ((f32)width / 2);
|
f32 xBound = 7200 / (width / 2.0f);
|
||||||
f32 yBound = 6000 / ((f32)height / 2);
|
f32 yBound = 6000 / (height / 2.0f);
|
||||||
*sp50 +=
|
*sp50 +=
|
||||||
(mouseCoord.x - (width / 2)) * xBound * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? 1 : -1);
|
(mouseCoord.x - (width / 2)) * xBound * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? 1 : -1);
|
||||||
*sp54 += (mouseCoord.y - (height / 2)) * yBound;
|
*sp54 += (mouseCoord.y - (height / 2)) * yBound;
|
||||||
|
|
|
@ -112,7 +112,7 @@ void GameInteractor::RawAction::FreezePlayer() {
|
||||||
void GameInteractor::RawAction::BurnPlayer() {
|
void GameInteractor::RawAction::BurnPlayer() {
|
||||||
Player* player = GET_PLAYER(gPlayState);
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
for (int i = 0; i < 18; i++) {
|
for (int i = 0; i < 18; i++) {
|
||||||
player->bodyFlameTimers[i] = (uint8_t)Rand_S16Offset(0, 200);
|
player->bodyFlameTimers[i] = static_cast<uint8_t>(Rand_S16Offset(0, 200));
|
||||||
}
|
}
|
||||||
player->bodyIsBurning = true;
|
player->bodyIsBurning = true;
|
||||||
func_80837C0C(gPlayState, player, 0, 0, 0, 0, 0);
|
func_80837C0C(gPlayState, player, 0, 0, 0, 0, 0);
|
||||||
|
@ -617,7 +617,7 @@ GameInteractionEffectQueryResult GameInteractor::RawAction::SpawnEnemyWithOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate point in random angle with a radius.
|
// Generate point in random angle with a radius.
|
||||||
float angle = (float)(RandomDouble() * 2 * M_PI);
|
float angle = static_cast<float>(RandomDouble() * 2 * M_PI);
|
||||||
float radius = 150;
|
float radius = 150;
|
||||||
float posXOffset = radius * cos(angle);
|
float posXOffset = radius * cos(angle);
|
||||||
float posZOffset = radius * sin(angle);
|
float posZOffset = radius * sin(angle);
|
||||||
|
|
|
@ -21,17 +21,17 @@ template <typename T> T RandomElement(std::vector<T>& vector, bool erase) {
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
template <typename Container> auto& RandomElement(Container& container) {
|
template <typename Container> auto& RandomElement(Container& container) {
|
||||||
return container[Random(0, (uint32_t)std::size(container))];
|
return container[Random(0, static_cast<uint32_t>(std::size(container)))];
|
||||||
}
|
}
|
||||||
template <typename Container> const auto& RandomElement(const Container& container) {
|
template <typename Container> const auto& RandomElement(const Container& container) {
|
||||||
return container[Random(0, (uint32_t)std::size(container))];
|
return container[Random(0, static_cast<uint32_t>(std::size(container)))];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> const T RandomElementFromSet(const std::set<T>& set) {
|
template <typename T> const T RandomElementFromSet(const std::set<T>& set) {
|
||||||
if (set.size() == 1) {
|
if (set.size() == 1) {
|
||||||
return *set.begin();
|
return *set.begin();
|
||||||
}
|
}
|
||||||
uint32_t rand = Random(0, (uint32_t)set.size());
|
uint32_t rand = Random(0, static_cast<uint32_t>(set.size()));
|
||||||
auto it = set.begin();
|
auto it = set.begin();
|
||||||
for (uint32_t i = 0; i < rand; i++) {
|
for (uint32_t i = 0; i < rand; i++) {
|
||||||
it++;
|
it++;
|
||||||
|
@ -44,11 +44,11 @@ template <typename T> const T RandomElementFromSet(const std::set<T>& set) {
|
||||||
// RANDOTODO There's probably a more efficient way to do what this does.
|
// RANDOTODO There's probably a more efficient way to do what this does.
|
||||||
template <typename T> void Shuffle(std::vector<T>& vector) {
|
template <typename T> void Shuffle(std::vector<T>& vector) {
|
||||||
for (size_t i = 0; i + 1 < vector.size(); i++) {
|
for (size_t i = 0; i + 1 < vector.size(); i++) {
|
||||||
std::swap(vector[i], vector[Random((uint32_t)i, (uint32_t)vector.size())]);
|
std::swap(vector[i], vector[Random(static_cast<uint32_t>(i), static_cast<uint32_t>(vector.size()))]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <typename T, size_t size> void Shuffle(std::array<T, size>& arr) {
|
template <typename T, size_t size> void Shuffle(std::array<T, size>& arr) {
|
||||||
for (size_t i = 0; i + 1 < arr.size(); i++) {
|
for (size_t i = 0; i + 1 < arr.size(); i++) {
|
||||||
std::swap(arr[i], arr[Random((uint32_t)i, (uint32_t)arr.size())]);
|
std::swap(arr[i], arr[Random(static_cast<uint32_t>(i), static_cast<uint32_t>(arr.size()))]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() {
|
||||||
(getItemEntry.getItemCategory == ITEM_CATEGORY_JUNK ||
|
(getItemEntry.getItemCategory == ITEM_CATEGORY_JUNK ||
|
||||||
getItemEntry.getItemCategory == ITEM_CATEGORY_SKULLTULA_TOKEN ||
|
getItemEntry.getItemCategory == ITEM_CATEGORY_SKULLTULA_TOKEN ||
|
||||||
getItemEntry.getItemCategory == ITEM_CATEGORY_LESSER))))) {
|
getItemEntry.getItemCategory == ITEM_CATEGORY_LESSER))))) {
|
||||||
Item_DropCollectible(gPlayState, &spawnPos, (int16_t)(ITEM00_SOH_GIVE_ITEM_ENTRY | 0x8000));
|
Item_DropCollectible(gPlayState, &spawnPos, static_cast<int16_t>(ITEM00_SOH_GIVE_ITEM_ENTRY | 0x8000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2157,7 +2157,7 @@ void RandomizerOnGameFrameUpdateHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_MAGIC_METER)) {
|
if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_MAGIC_METER)) {
|
||||||
gSaveContext.magic = (int8_t)gSaveContext.magicCapacity;
|
gSaveContext.magic = static_cast<int8_t>(gSaveContext.magicCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_BOMBCHUS)) {
|
if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_BOMBCHUS)) {
|
||||||
|
@ -2203,7 +2203,8 @@ void RandomizerOnActorUpdateHandler(void* refActor) {
|
||||||
if (actor->id == ACTOR_OBJ_COMB) {
|
if (actor->id == ACTOR_OBJ_COMB) {
|
||||||
ObjComb* combActor = reinterpret_cast<ObjComb*>(actor);
|
ObjComb* combActor = reinterpret_cast<ObjComb*>(actor);
|
||||||
combActor->actor.shape.rot.x =
|
combActor->actor.shape.rot.x =
|
||||||
(int16_t)Math_SinS(combActor->unk_1B2) * CLAMP_MIN(combActor->unk_1B0, 0) + combActor->actor.home.rot.x;
|
static_cast<int16_t>(Math_SinS(combActor->unk_1B2)) * CLAMP_MIN(combActor->unk_1B0, 0) +
|
||||||
|
combActor->actor.home.rot.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2298,8 +2299,8 @@ void RandomizerOnSceneSpawnActorsHandler() {
|
||||||
switch (gPlayState->sceneNum) {
|
switch (gPlayState->sceneNum) {
|
||||||
case SCENE_TEMPLE_OF_TIME:
|
case SCENE_TEMPLE_OF_TIME:
|
||||||
if (gPlayState->roomCtx.curRoom.num == 1) {
|
if (gPlayState->roomCtx.curRoom.num == 1) {
|
||||||
Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_XC, -104, -40, 2382, 0, (int16_t)0x8000, 0,
|
Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_XC, -104, -40, 2382, 0,
|
||||||
SHEIK_TYPE_RANDO, false);
|
static_cast<int16_t>(0x8000), 0, SHEIK_TYPE_RANDO, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCENE_INSIDE_GANONS_CASTLE:
|
case SCENE_INSIDE_GANONS_CASTLE:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue