diff --git a/src/common/GameModeSettings.cpp b/src/common/GameModeSettings.cpp index f94c3384..43afa92a 100644 --- a/src/common/GameModeSettings.cpp +++ b/src/common/GameModeSettings.cpp @@ -1,23 +1,23 @@ #include "GameModeSettings.h" ClassicGameModeSettings::ClassicGameModeSettings() - : style(0) //Respawn on death + : style(DeathStyle::Respawn) //Respawn on death , scoring(0) //All kills will score {} FragGameModeSettings::FragGameModeSettings() - : style(0) //Respawn on death + : style(DeathStyle::Respawn) //Respawn on death , scoring(0) //All kills will score {} TimeGameModeSettings::TimeGameModeSettings() - : style(0) //Respawn on death + : style(DeathStyle::Respawn) //Respawn on death , scoring(0) //All kills will score , percentextratime(10) //10% chance of a heart spawning {} JailGameModeSettings::JailGameModeSettings() - : style(1) //defaults to color jail play + : style(JailStyle::Owned) //defaults to color jail play , tagfree(true) //players on same team can free player by touching , timetofree(1240) //20 seconds of jail , percentkey(30) //30% chance of a key spawning @@ -74,7 +74,7 @@ TagGameModeSettings::TagGameModeSettings() StarGameModeSettings::StarGameModeSettings() : time(30) //default to 30 seconds - , shine(0) //default to hot potato (ztar) + , shine(StarStyle::Ztar) //default to hot potato (ztar) , percentextratime(10) //10 percent chance of an extra time poweurp spawning {} diff --git a/src/common/GameModeSettings.h b/src/common/GameModeSettings.h index 8cc60ab3..42e3b9d1 100644 --- a/src/common/GameModeSettings.h +++ b/src/common/GameModeSettings.h @@ -1,25 +1,26 @@ #ifndef GAMEMODESETTINGS_H #define GAMEMODESETTINGS_H +#include "GameplayStyles.h" #include "GlobalConstants.h" #include "MatchTypes.h" struct ClassicGameModeSettings { - short style; //on kill, either respawn the player or shield them and let them keep playing + DeathStyle style; //on kill, either respawn the player or shield them and let them keep playing short scoring; //When to credit a score, all kills or push kills only (sumo mode) ClassicGameModeSettings(); }; struct FragGameModeSettings { - short style; //on kill, either respawn the player or shield them and let them keep playing + DeathStyle style; //on kill, either respawn the player or shield them and let them keep playing short scoring; //When to credit a score, all kills or push kills only (sumo mode) FragGameModeSettings(); }; struct TimeGameModeSettings { - short style; //on kill, either respawn the player or shield them and let them keep playing + DeathStyle style; //on kill, either respawn the player or shield them and let them keep playing short scoring; //When to credit a score, all kills or push kills only (sumo mode) short percentextratime; //percent chance a stopwatch with extra game time will spawn @@ -27,7 +28,7 @@ struct TimeGameModeSettings { }; struct JailGameModeSettings { - short style; //Style of play: classic, owned, free for all + JailStyle style; //Style of play: classic, owned, free for all bool tagfree; //Free jailed player by tagging on same team short timetofree; //Time it takes for a jailed player to be freed short percentkey; //percent chance a jail key will spawn @@ -84,7 +85,7 @@ struct TagGameModeSettings { struct StarGameModeSettings { short time; //Time to get rid or keep star - short shine; //If we are playing shine mode vs. ztar vs. stars mode + StarStyle shine; //If we are playing shine mode vs. ztar vs. stars mode short percentextratime; //percent chance a stopwatch with extra game time will spawn StarGameModeSettings(); diff --git a/src/common/GameplayStyles.h b/src/common/GameplayStyles.h index c8f7d9cd..a0c0b950 100644 --- a/src/common/GameplayStyles.h +++ b/src/common/GameplayStyles.h @@ -18,3 +18,24 @@ enum class TournamentControlStyle : unsigned char { RandomLoser, RoundRobin, }; + + +enum class DeathStyle : unsigned char { + Respawn, + Shield, +}; + + +enum class JailStyle : unsigned char { + Classic, + Owned, + FreeForAll, +}; + + +enum class StarStyle : unsigned char { + Ztar, + Shine, + Multi, + Random, +}; diff --git a/src/common/ui/MI_SelectField.cpp b/src/common/ui/MI_SelectField.cpp index 3aad47f7..3c50e65d 100644 --- a/src/common/ui/MI_SelectField.cpp +++ b/src/common/ui/MI_SelectField.cpp @@ -381,3 +381,6 @@ template class MI_SelectField; #include "GameplayStyles.h" template class MI_SelectField; template class MI_SelectField; +template class MI_SelectField; +template class MI_SelectField; +template class MI_SelectField; diff --git a/src/smw/gamemodes/Classic.cpp b/src/smw/gamemodes/Classic.cpp index 759d213f..f67f6a7b 100644 --- a/src/smw/gamemodes/Classic.cpp +++ b/src/smw/gamemodes/Classic.cpp @@ -68,7 +68,7 @@ PlayerKillType CGM_Classic::playerkilledplayer(CPlayer &inflictor, CPlayer &othe } } - if (game_values.gamemode->gamemode == game_mode_classic && game_values.gamemodesettings.classic.style == 1) { + if (game_values.gamemode->gamemode == game_mode_classic && game_values.gamemodesettings.classic.style == DeathStyle::Shield) { ifSoundOnPlay(rm->sfx_powerdown); other.Shield().reset(); return PlayerKillType::NonKill; @@ -116,7 +116,7 @@ PlayerKillType CGM_Classic::playerkilledself(CPlayer &player, KillStyle style) } } - if (game_values.gamemode->gamemode == game_mode_classic && game_values.gamemodesettings.classic.style == 1) { + if (game_values.gamemode->gamemode == game_mode_classic && game_values.gamemodesettings.classic.style == DeathStyle::Shield) { ifSoundOnPlay(rm->sfx_powerdown); player.Shield().reset(); return PlayerKillType::NonKill; diff --git a/src/smw/gamemodes/Frag.cpp b/src/smw/gamemodes/Frag.cpp index 87fc2a31..8d9547f0 100644 --- a/src/smw/gamemodes/Frag.cpp +++ b/src/smw/gamemodes/Frag.cpp @@ -34,7 +34,7 @@ PlayerKillType CGM_Frag::playerkilledplayer(CPlayer &inflictor, CPlayer &other, PlayerKillType iRet = CheckWinner(&inflictor); - if (game_values.gamemode->gamemode == game_mode_frag && game_values.gamemodesettings.frag.style == 1) { + if (game_values.gamemode->gamemode == game_mode_frag && game_values.gamemodesettings.frag.style == DeathStyle::Shield) { ifSoundOnPlay(rm->sfx_powerdown); other.Shield().reset(); return PlayerKillType::NonKill; @@ -50,7 +50,7 @@ PlayerKillType CGM_Frag::playerkilledself(CPlayer &player, KillStyle style) if (!gameover) { player.Score().AdjustScore(-1); - if (game_values.gamemode->gamemode == game_mode_frag && game_values.gamemodesettings.frag.style == 1) { + if (game_values.gamemode->gamemode == game_mode_frag && game_values.gamemodesettings.frag.style == DeathStyle::Shield) { ifSoundOnPlay(rm->sfx_powerdown); player.Shield().reset(); return PlayerKillType::NonKill; diff --git a/src/smw/gamemodes/Jail.cpp b/src/smw/gamemodes/Jail.cpp index 161bc2f4..34ea7750 100644 --- a/src/smw/gamemodes/Jail.cpp +++ b/src/smw/gamemodes/Jail.cpp @@ -40,7 +40,7 @@ PlayerKillType CGM_Jail::playerkilledplayer(CPlayer &inflictor, CPlayer &other, other.Jail().lockInBy(inflictor); //Apply rules for "Classic" jail - if (game_values.gamemodesettings.jail.style == 0) { + if (game_values.gamemodesettings.jail.style == JailStyle::Classic) { short jailedteams[4]; short i; @@ -91,7 +91,7 @@ PlayerKillType CGM_Jail::playerkilledplayer(CPlayer &inflictor, CPlayer &other, } } //Apply rules for "Owned" jail - else if (game_values.gamemodesettings.jail.style == 1) { + else if (game_values.gamemodesettings.jail.style == JailStyle::Owned) { short jailedteams[4] = {-1, -1, -1, -1}; //Figure out which teams have been jailed diff --git a/src/smw/gamemodes/Star.cpp b/src/smw/gamemodes/Star.cpp index 2ac52184..e12e1fa9 100644 --- a/src/smw/gamemodes/Star.cpp +++ b/src/smw/gamemodes/Star.cpp @@ -27,7 +27,7 @@ CGM_Star::CGM_Star() : CGM_TimeLimit() goal = 5; gamemode = game_mode_star; SetupModeStrings("Star", "Lives", 1); - iCurrentModeType = 0; + iCurrentModeType = StarStyle::Ztar; }; void CGM_Star::init() @@ -38,12 +38,9 @@ void CGM_Star::init() gameClock.Init(game_values.gamemodesettings.star.time < 1 ? 30 : game_values.gamemodesettings.star.time, true); - if (game_values.gamemodesettings.star.shine < 0 || game_values.gamemodesettings.star.shine > 3) - game_values.gamemodesettings.star.shine = 0; - iCurrentModeType = game_values.gamemodesettings.star.shine; - if (iCurrentModeType == 3) - iCurrentModeType = RANDOM_INT(3); + if (iCurrentModeType == StarStyle::Random) + iCurrentModeType = static_cast(RANDOM_INT(3)); fReverseScoring = goal == -1; @@ -77,7 +74,7 @@ void CGM_Star::SetupMode() } //If multi star, add more stars - if (iCurrentModeType == 2) { + if (iCurrentModeType == StarStyle::Multi) { CPlayer * players[4]; short iNumPlayers = GetScoreRankedPlayerList(players, fReverseScoring); @@ -89,9 +86,9 @@ void CGM_Star::SetupMode() objectcontainer[1].add(starItem[iStar]); } } else { //otherwise, add just a single star - starPlayer[0] = GetHighestScorePlayer(!fReverseScoring && iCurrentModeType == 0); + starPlayer[0] = GetHighestScorePlayer(!fReverseScoring && iCurrentModeType == StarStyle::Ztar); - starItem[0] = new CO_Star(&rm->spr_star, iCurrentModeType == 0 ? 0 : 1, 0); + starItem[0] = new CO_Star(&rm->spr_star, iCurrentModeType == StarStyle::Ztar ? 0 : 1, 0); objectcontainer[1].add(starItem[0]); } } @@ -104,7 +101,7 @@ void CGM_Star::think() } //Make sure there is a star player(s) - if (iCurrentModeType == 2) { + if (iCurrentModeType == StarStyle::Multi) { for (short iStar1 = 0; iStar1 < list_players_cnt - 1; iStar1++) { //If we're missing a star player, then reassign them all if (!starPlayer[iStar1]) { @@ -122,7 +119,7 @@ void CGM_Star::think() } } else { if (!starPlayer[0]) { - starPlayer[0] = GetHighestScorePlayer(!fReverseScoring && !game_values.gamemodesettings.star.shine); + starPlayer[0] = GetHighestScorePlayer(!fReverseScoring && game_values.gamemodesettings.star.shine == StarStyle::Ztar); starItem[0]->placeStar(); } } @@ -138,7 +135,7 @@ void CGM_Star::think() gameClock.SetTime(game_values.gamemodesettings.star.time < 1 ? 30 : game_values.gamemodesettings.star.time); ifSoundOnPlay(rm->sfx_thunder); - if (iCurrentModeType == 0) { + if (iCurrentModeType == StarStyle::Ztar) { if (score[starPlayer[0]->getTeamID()]->score > 1 || fReverseScoring) starPlayer[0]->KillPlayerMapHazard(true, KillStyle::Environment, false); @@ -155,7 +152,7 @@ void CGM_Star::think() starPlayer[0] = GetHighestScorePlayer(!fReverseScoring); starItem[0]->placeStar(); - } else if (iCurrentModeType == 1) { + } else if (iCurrentModeType == StarStyle::Shine) { for (short iPlayer = 0; iPlayer < list_players_cnt; iPlayer++) { if (starPlayer[0]->getTeamID() == list_players[iPlayer]->getTeamID()) continue; @@ -182,7 +179,7 @@ void CGM_Star::think() starPlayer[0] = GetHighestScorePlayer(false); starItem[0]->placeStar(); - } else if (iCurrentModeType == 2) { + } else if (iCurrentModeType == StarStyle::Multi) { for (short iPlayer = 0; iPlayer < list_players_cnt; iPlayer++) { bool fFound = false; for (short iStar = 0; iStar < list_players_cnt - 1; iStar++) { @@ -208,14 +205,14 @@ void CGM_Star::think() fDisplayTimer = !RemoveTeam(list_players[iPlayer]->getTeamID()); //Don't setup the mode if this is a random game because it will be setup below - if (game_values.gamemodesettings.star.shine != 3) { + if (game_values.gamemodesettings.star.shine != StarStyle::Random) { SetupMode(); fNeedRebalance = false; } } } - if (game_values.gamemodesettings.star.shine != 3 && fNeedRebalance) { + if (game_values.gamemodesettings.star.shine != StarStyle::Random && fNeedRebalance) { CPlayer * players[4]; short iNumPlayers = GetScoreRankedPlayerList(players, fReverseScoring); @@ -253,9 +250,8 @@ void CGM_Star::think() } //If random game, then choose a new game type - if (game_values.gamemodesettings.star.shine == 3 && fDisplayTimer) { -#pragma warning ("neagix: This should be 4, possibly?") - iCurrentModeType = RANDOM_INT(3); + if (game_values.gamemodesettings.star.shine == StarStyle::Random && fDisplayTimer) { + iCurrentModeType = static_cast(RANDOM_INT(3)); SetupMode(); } } @@ -311,11 +307,11 @@ CPlayer * CGM_Star::swapplayer(short id, CPlayer * player) starPlayer[id] = player; - if (iCurrentModeType == 2) + if (iCurrentModeType == StarStyle::Multi) starItem[id]->setPlayerColor(starPlayer[id]->getColorID()); if (starItem[id]->getType() == 1) - eyecandy[2].add(new EC_GravText(&rm->game_font_large, player->centerX(), player->bottomY(), iCurrentModeType == 2 ? "Star Get!" : "Shine Get!", -VELJUMP*1.5)); + eyecandy[2].add(new EC_GravText(&rm->game_font_large, player->centerX(), player->bottomY(), iCurrentModeType == StarStyle::Multi ? "Star Get!" : "Shine Get!", -VELJUMP*1.5)); else eyecandy[2].add(new EC_GravText(&rm->game_font_large, player->centerX(), player->bottomY(), "Ztarred!", -VELJUMP*1.5)); diff --git a/src/smw/gamemodes/Star.h b/src/smw/gamemodes/Star.h index 4b437082..9fde5b60 100644 --- a/src/smw/gamemodes/Star.h +++ b/src/smw/gamemodes/Star.h @@ -1,6 +1,7 @@ #pragma once #include "TimeLimit.h" +#include "GameplayStyles.h" class CO_Star; @@ -27,7 +28,7 @@ class CGM_Star : public CGM_TimeLimit return starPlayer[id]; } - short getcurrentmodetype() { + StarStyle getcurrentmodetype() const { return iCurrentModeType; } @@ -42,6 +43,6 @@ class CGM_Star : public CGM_TimeLimit CO_Star * starItem[3]; CPlayer * starPlayer[3]; - short iCurrentModeType; + StarStyle iCurrentModeType; bool fDisplayTimer; }; diff --git a/src/smw/gamemodes/TimeLimit.cpp b/src/smw/gamemodes/TimeLimit.cpp index 77a42d2a..e41851d9 100644 --- a/src/smw/gamemodes/TimeLimit.cpp +++ b/src/smw/gamemodes/TimeLimit.cpp @@ -65,7 +65,7 @@ PlayerKillType CGM_TimeLimit::playerkilledplayer(CPlayer &inflictor, CPlayer &ot inflictor.Score().AdjustScore(1); } - if (game_values.gamemode->gamemode == game_mode_timelimit && game_values.gamemodesettings.time.style == 1) { + if (game_values.gamemode->gamemode == game_mode_timelimit && game_values.gamemodesettings.time.style == DeathStyle::Shield) { ifSoundOnPlay(rm->sfx_powerdown); other.Shield().reset(); return PlayerKillType::NonKill; diff --git a/src/smw/menu/ModeOptionsMenu.cpp b/src/smw/menu/ModeOptionsMenu.cpp index 0cc241e0..154abdfd 100644 --- a/src/smw/menu/ModeOptionsMenu.cpp +++ b/src/smw/menu/ModeOptionsMenu.cpp @@ -21,9 +21,9 @@ UI_ModeOptionsMenu::UI_ModeOptionsMenu() // Classic Mode Settings //*********************** - miClassicModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 200, "On Kill", 400, 180); - miClassicModeStyleField->add("Respawn", 0); - miClassicModeStyleField->add("Shield", 1); + miClassicModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 200, "On Kill", 400, 180); + miClassicModeStyleField->add("Respawn", DeathStyle::Respawn); + miClassicModeStyleField->add("Shield", DeathStyle::Shield); miClassicModeStyleField->setOutputPtr(&game_values.gamemodemenusettings.classic.style); miClassicModeStyleField->setCurrentValue(game_values.gamemodemenusettings.classic.style); @@ -56,9 +56,9 @@ UI_ModeOptionsMenu::UI_ModeOptionsMenu() // Frag Mode Settings //*********************** - miFragModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 200, "On Kill", 400, 180); - miFragModeStyleField->add("Respawn", 0); - miFragModeStyleField->add("Shield", 1); + miFragModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 200, "On Kill", 400, 180); + miFragModeStyleField->add("Respawn", DeathStyle::Respawn); + miFragModeStyleField->add("Shield", DeathStyle::Shield); miFragModeStyleField->setOutputPtr(&game_values.gamemodemenusettings.frag.style); miFragModeStyleField->setCurrentValue(game_values.gamemodemenusettings.frag.style); @@ -91,9 +91,9 @@ UI_ModeOptionsMenu::UI_ModeOptionsMenu() // Time Limit Mode Settings //*********************** - miTimeLimitModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 180, "On Kill", 400, 150); - miTimeLimitModeStyleField->add("Respawn", 0); - miTimeLimitModeStyleField->add("Shield", 1); + miTimeLimitModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 180, "On Kill", 400, 150); + miTimeLimitModeStyleField->add("Respawn", DeathStyle::Respawn); + miTimeLimitModeStyleField->add("Shield", DeathStyle::Shield); miTimeLimitModeStyleField->setOutputPtr(&game_values.gamemodemenusettings.time.style); miTimeLimitModeStyleField->setCurrentValue(game_values.gamemodemenusettings.time.style); @@ -153,10 +153,10 @@ UI_ModeOptionsMenu::UI_ModeOptionsMenu() // Jail Mode Settings //*********************** - miJailModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 160, "Style", 400, 150); - miJailModeStyleField->add("Classic", 0); - miJailModeStyleField->add("Owned", 1, false); - miJailModeStyleField->add("Free For All", 2, false); + miJailModeStyleField = new MI_SelectField(&rm->spr_selectfield, 120, 160, "Style", 400, 150); + miJailModeStyleField->add("Classic", JailStyle::Classic); + miJailModeStyleField->add("Owned", JailStyle::Owned); + miJailModeStyleField->add("Free For All", JailStyle::FreeForAll); miJailModeStyleField->setOutputPtr(&game_values.gamemodemenusettings.jail.style); miJailModeStyleField->setCurrentValue(game_values.gamemodemenusettings.jail.style); @@ -608,11 +608,11 @@ UI_ModeOptionsMenu::UI_ModeOptionsMenu() miStarModeTimeField->setOutputPtr(&game_values.gamemodemenusettings.star.time); miStarModeTimeField->setCurrentValue(game_values.gamemodemenusettings.star.time); - miStarModeShineField = new MI_SelectField(&rm->spr_selectfield, 120, 220, "Star Type", 400, 150); - miStarModeShineField->add("Ztar", 0); - miStarModeShineField->add("Shine", 1); - miStarModeShineField->add("Multi Star", 2); - miStarModeShineField->add("Random", 3); + miStarModeShineField = new MI_SelectField(&rm->spr_selectfield, 120, 220, "Star Type", 400, 150); + miStarModeShineField->add("Ztar", StarStyle::Ztar); + miStarModeShineField->add("Shine", StarStyle::Shine); + miStarModeShineField->add("Multi Star", StarStyle::Multi); + miStarModeShineField->add("Random", StarStyle::Random); miStarModeShineField->setOutputPtr(&game_values.gamemodemenusettings.star.shine); miStarModeShineField->setCurrentValue(game_values.gamemodemenusettings.star.shine); diff --git a/src/smw/menu/ModeOptionsMenu.h b/src/smw/menu/ModeOptionsMenu.h index ea1b64e8..1285b843 100644 --- a/src/smw/menu/ModeOptionsMenu.h +++ b/src/smw/menu/ModeOptionsMenu.h @@ -1,6 +1,8 @@ #pragma once #include "uimenu.h" +#include "GameplayStyles.h" +#include "MatchTypes.h" class MI_Button; class MI_Image; @@ -9,7 +11,6 @@ class MI_PowerupSlider; class MI_SliderField; class MI_Text; template class MI_SelectField; -enum class Boss : unsigned char; class UI_ModeOptionsMenu : public UI_Menu { @@ -38,7 +39,7 @@ class UI_ModeOptionsMenu : public UI_Menu { UI_Menu mBossSettingsMenu; // Classic - MI_SelectField* miClassicModeStyleField; + MI_SelectField* miClassicModeStyleField; MI_SelectField* miClassicModeScoringField; MI_Button* miClassicModeBackButton; @@ -47,7 +48,7 @@ class UI_ModeOptionsMenu : public UI_Menu { MI_Text* miClassicModeHeaderText; // Frag - MI_SelectField* miFragModeStyleField; + MI_SelectField* miFragModeStyleField; MI_SelectField* miFragModeScoringField; MI_Button* miFragModeBackButton; @@ -56,7 +57,7 @@ class UI_ModeOptionsMenu : public UI_Menu { MI_Text* miFragModeHeaderText; // Time Limit - MI_SelectField* miTimeLimitModeStyleField; + MI_SelectField* miTimeLimitModeStyleField; MI_SelectField* miTimeLimitModeScoringField; MI_SliderField* miTimeLimitModePercentExtraTime; MI_Button* miTimeLimitModeBackButton; @@ -66,7 +67,7 @@ class UI_ModeOptionsMenu : public UI_Menu { MI_Text* miTimeLimitModeHeaderText; // Jail - MI_SelectField* miJailModeStyleField; + MI_SelectField* miJailModeStyleField; MI_SelectField* miJailModeTagFreeField; MI_SelectField* miJailModeTimeFreeField; MI_SliderField* miJailModeJailKeyField; @@ -128,7 +129,7 @@ class UI_ModeOptionsMenu : public UI_Menu { // Star MI_SelectField* miStarModeTimeField; - MI_SelectField* miStarModeShineField; + MI_SelectField* miStarModeShineField; MI_SliderField* miStarModePercentExtraTime; MI_Button* miStarModeBackButton; diff --git a/src/smw/player.cpp b/src/smw/player.cpp index b7361482..6ac11b43 100644 --- a/src/smw/player.cpp +++ b/src/smw/player.cpp @@ -862,9 +862,9 @@ void CPlayer::update_spriteColor() } else { if (game_values.gamemode->gamemode == game_mode_star) { CGM_Star * starmode = (CGM_Star*) game_values.gamemode; - short starmodetype = starmode->getcurrentmodetype(); - if (starmodetype != 2 && starmode->isplayerstar(this)) { - iSrcOffsetX = starmodetype ? 224 : 192; + StarStyle starmodetype = starmode->getcurrentmodetype(); + if (starmodetype != StarStyle::Multi && starmode->isplayerstar(this)) { + iSrcOffsetX = (starmodetype == StarStyle::Ztar) ? 192 : 224; fColorChosen = true; } } diff --git a/src/smw/player_components/PlayerJail.cpp b/src/smw/player_components/PlayerJail.cpp index b82c9e38..07d5b2c1 100644 --- a/src/smw/player_components/PlayerJail.cpp +++ b/src/smw/player_components/PlayerJail.cpp @@ -38,7 +38,7 @@ void PlayerJail::lockInBy(CPlayer& inflictor) timer = game_values.gamemodesettings.jail.timetofree; owner_teamID = inflictor.teamID; - if (game_values.gamemodesettings.jail.style == 1) + if (game_values.gamemodesettings.jail.style == JailStyle::Owned) color = inflictor.colorID; else color = -1; diff --git a/src/smw/world.cpp b/src/smw/world.cpp index 99de0751..07481025 100644 --- a/src/smw/world.cpp +++ b/src/smw/world.cpp @@ -1761,6 +1761,19 @@ short ReadTourStopSetting(short * iSetting, bool * fSetting, short iDefault, boo return 0; } +template +short ReadTourStopSetting(T& output, T defaultVal) +{ + char* tok = strtok(NULL, ",\n"); + if (tok) { + output = static_cast(atoi(tok)); + return 1; + } else { + output = defaultVal; + return 0; + } +} + TourStop * ParseTourStopLine(char * buffer, int32_t iVersion[4], bool fIsWorld) { TourStop * ts = new TourStop(); @@ -1945,21 +1958,21 @@ TourStop * ParseTourStopLine(char * buffer, int32_t iVersion[4], bool fIsWorld) if (ts->iMode == 0) { //classic ts->fUseSettings = true; - ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.classic.style, NULL, game_values.gamemodemenusettings.classic.style, false); + ts->iNumUsedSettings += ReadTourStopSetting(ts->gmsSettings.classic.style, game_values.gamemodemenusettings.classic.style); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.classic.scoring, NULL, game_values.gamemodemenusettings.classic.scoring, false); } else if (ts->iMode == 1) { //frag ts->fUseSettings = true; - ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.frag.style, NULL, game_values.gamemodemenusettings.frag.style, false); + ts->iNumUsedSettings += ReadTourStopSetting(ts->gmsSettings.frag.style, game_values.gamemodemenusettings.frag.style); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.frag.scoring, NULL, game_values.gamemodemenusettings.frag.scoring, false); } else if (ts->iMode == 2) { //time ts->fUseSettings = true; - ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.time.style, NULL, game_values.gamemodemenusettings.time.style, false); + ts->iNumUsedSettings += ReadTourStopSetting(ts->gmsSettings.time.style, game_values.gamemodemenusettings.time.style); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.time.scoring, NULL, game_values.gamemodemenusettings.time.scoring, false); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.time.percentextratime, NULL, game_values.gamemodemenusettings.time.percentextratime, false); } else if (ts->iMode == 3) { //jail ts->fUseSettings = true; - ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.jail.style, NULL, game_values.gamemodemenusettings.jail.style, false); + ts->iNumUsedSettings += ReadTourStopSetting(ts->gmsSettings.jail.style, game_values.gamemodemenusettings.jail.style); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.jail.timetofree, NULL, game_values.gamemodemenusettings.jail.timetofree, false); ts->iNumUsedSettings += ReadTourStopSetting(NULL, &ts->gmsSettings.jail.tagfree, 0, game_values.gamemodemenusettings.jail.tagfree); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.jail.percentkey, NULL, game_values.gamemodemenusettings.jail.percentkey, false); @@ -2008,7 +2021,7 @@ TourStop * ParseTourStopLine(char * buffer, int32_t iVersion[4], bool fIsWorld) ts->fUseSettings = true; ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.star.time, NULL, game_values.gamemodemenusettings.star.time, false); - ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.star.shine, NULL, game_values.gamemodemenusettings.star.shine, false); + ts->iNumUsedSettings += ReadTourStopSetting(ts->gmsSettings.star.shine, game_values.gamemodemenusettings.star.shine); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.star.percentextratime, NULL, game_values.gamemodemenusettings.star.percentextratime, false); } else if (ts->iMode == 11) { //domination ts->fUseSettings = true; @@ -2084,10 +2097,7 @@ TourStop * ParseTourStopLine(char * buffer, int32_t iVersion[4], bool fIsWorld) } else if (ts->iMode == 1001) { //boss minigame ts->fUseSettings = true; - short bosstype_val = 0; - ts->iNumUsedSettings += ReadTourStopSetting(&bosstype_val, NULL, static_cast(game_values.gamemodemenusettings.boss.bosstype), false); - ts->gmsSettings.boss.bosstype = static_cast(bosstype_val); // FIXME - + ts->iNumUsedSettings += ReadTourStopSetting(ts->gmsSettings.boss.bosstype, game_values.gamemodemenusettings.boss.bosstype); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.boss.difficulty, NULL, game_values.gamemodemenusettings.boss.difficulty, false); ts->iNumUsedSettings += ReadTourStopSetting(&ts->gmsSettings.boss.hitpoints, NULL, game_values.gamemodemenusettings.boss.hitpoints, false); } @@ -2211,7 +2221,7 @@ void WriteTourStopLine(TourStop * ts, char * buffer, bool fIsWorld) if (ts->fUseSettings) { if (ts->iMode == 0) { //classic if (ts->iNumUsedSettings > 0) { - sprintf(szTemp, ",%d", ts->gmsSettings.classic.style); + sprintf(szTemp, ",%d", static_cast(ts->gmsSettings.classic.style)); strcat(buffer, szTemp); } @@ -2221,7 +2231,7 @@ void WriteTourStopLine(TourStop * ts, char * buffer, bool fIsWorld) } } else if (ts->iMode == 1) { //frag if (ts->iNumUsedSettings > 0) { - sprintf(szTemp, ",%d", ts->gmsSettings.frag.style); + sprintf(szTemp, ",%d", static_cast(ts->gmsSettings.frag.style)); strcat(buffer, szTemp); } @@ -2231,7 +2241,7 @@ void WriteTourStopLine(TourStop * ts, char * buffer, bool fIsWorld) } } else if (ts->iMode == 2) { //time if (ts->iNumUsedSettings > 0) { - sprintf(szTemp, ",%d", ts->gmsSettings.time.style); + sprintf(szTemp, ",%d", static_cast(ts->gmsSettings.time.style)); strcat(buffer, szTemp); } @@ -2246,7 +2256,7 @@ void WriteTourStopLine(TourStop * ts, char * buffer, bool fIsWorld) } } else if (ts->iMode == 3) { //jail if (ts->iNumUsedSettings > 0) { - sprintf(szTemp, ",%d", ts->gmsSettings.jail.style); + sprintf(szTemp, ",%d", static_cast(ts->gmsSettings.jail.style)); strcat(buffer, szTemp); } @@ -2362,7 +2372,7 @@ void WriteTourStopLine(TourStop * ts, char * buffer, bool fIsWorld) } if (ts->iNumUsedSettings > 1) { - sprintf(szTemp, ",%d", ts->gmsSettings.star.shine); + sprintf(szTemp, ",%d", static_cast(ts->gmsSettings.star.shine)); strcat(buffer, szTemp); }