Skip to content

Commit

Permalink
Merge pull request #2201 from ivan-mogilko/ags4--removehardscore
Browse files Browse the repository at this point in the history
AGS 4: Remove built-in Score functionality
  • Loading branch information
ivan-mogilko authored Oct 28, 2023
2 parents c4e8e75 + cf5c525 commit 1060255
Show file tree
Hide file tree
Showing 29 changed files with 33 additions and 118 deletions.
3 changes: 1 addition & 2 deletions Common/ac/gamesetupstruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ using namespace AGS::Common;
GameSetupStruct::GameSetupStruct()
: filever(0)
, roomCount(0)
, scoreClipID(0)
{
memset(invinfo, 0, sizeof(invinfo));
memset(lipSyncFrameLetters, 0, sizeof(lipSyncFrameLetters));
Expand Down Expand Up @@ -235,7 +234,7 @@ HGameFileError GameSetupStruct::read_audio(Common::Stream *in, GameDataVersion d
audioClips.resize(audioclip_count);
ReadAudioClips(in, audioclip_count);

scoreClipID = in->ReadInt32();
in->ReadInt32(); // [DEPRECATED]
return HGameFileError::None();
}

Expand Down
3 changes: 0 additions & 3 deletions Common/ac/gamesetupstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ struct GameSetupStruct : public GameSetupStructBase
std::vector<Common::String> roomNames;
std::vector<ScriptAudioClip> audioClips;
std::vector<AudioClipType> audioClipTypes;
// A clip to play when player gains score in game
// TODO: find out why OPT_SCORESOUND option cannot be used to store this in >=3.2 games
int scoreClipID;
// number of accessible game audio channels (the ones under direct user control)
int numGameChannels = 0;
// backward-compatible channel limit that may be exported to script and reserved by audiotypes
Expand Down
5 changes: 2 additions & 3 deletions Common/ac/gamesetupstructbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ GameSetupStructBase::GameSetupStructBase()
: numviews(0)
, numcharacters(0)
, playercharacter(-1)
, totalscore(0)
, numinvitems(0)
, numdialog(0)
, numdlgmessage(0)
Expand Down Expand Up @@ -86,7 +85,7 @@ void GameSetupStructBase::ReadFromFile(Stream *in, GameDataVersion game_ver, Ser
numviews = in->ReadInt32();
numcharacters = in->ReadInt32();
playercharacter = in->ReadInt32();
totalscore = in->ReadInt32();
in->ReadInt32(); // [DEPRECATED]
numinvitems = in->ReadInt16();
in->ReadInt16(); // alignment padding to int32
numdialog = in->ReadInt32();
Expand Down Expand Up @@ -132,7 +131,7 @@ void GameSetupStructBase::WriteToFile(Stream *out, const SerializeInfo &info) co
out->WriteInt32(numviews);
out->WriteInt32(numcharacters);
out->WriteInt32(playercharacter);
out->WriteInt32(totalscore);
out->WriteInt32(0); // [DEPRECATED]
out->WriteInt16(numinvitems);
out->WriteInt16(0); // alignment padding to int32
out->WriteInt32(numdialog);
Expand Down
1 change: 0 additions & 1 deletion Common/ac/gamesetupstructbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct GameSetupStructBase
int numviews;
int numcharacters;
int playercharacter;
int totalscore;
short numinvitems;
int numdialog, numdlgmessage;
int numfonts;
Expand Down
2 changes: 1 addition & 1 deletion Common/ac/gamestructdefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// General game options
#define OPT_DEBUGMODE 0
#define OPT_SCORESOUND 1
#define OPT_OBSOLETE_SCORESOUND 1 // [DEPRECATED]
#define OPT_WALKONLOOK 2
#define OPT_DIALOGIFACE 3
#define OPT_ANTIGLIDE 4
Expand Down
5 changes: 0 additions & 5 deletions Common/game/main_game_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,6 @@ void UpgradeMouseCursors(GameSetupStruct &game, GameDataVersion data_ver)
{
}

// Adjusts score clip id, depending on game data version
void RemapLegacySoundNums(GameSetupStruct &game, std::vector<ViewStruct> &views, GameDataVersion data_ver)
{
}

void FixupSaveDirectory(GameSetupStruct &game)
{
// If the save game folder was not specified by game author, create one of
Expand Down
2 changes: 0 additions & 2 deletions Common/game/main_game_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ void PreReadGameData(GameSetupStruct &game, Stream *in, GameDataVe
HGameFileError UpdateGameData(LoadedGameEntities &ents, GameDataVersion data_ver);
// Ensures that the game saves directory path is valid
void FixupSaveDirectory(GameSetupStruct &game);
// Maps legacy sound numbers to real audio clips
void RemapLegacySoundNums(GameSetupStruct &game, std::vector<ViewStruct> &views, GameDataVersion data_ver);

} // namespace Common
} // namespace AGS
Expand Down
4 changes: 0 additions & 4 deletions Common/gui/guidefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ enum GUILabelMacro
kLabelMacro_None = 0,
kLabelMacro_Gamename = 0x01,
kLabelMacro_Overhotspot = 0x02,
kLabelMacro_Score = 0x04,
kLabelMacro_ScoreText = 0x08,
kLabelMacro_TotalScore = 0x10,

kLabelMacro_AllScore = kLabelMacro_Score | kLabelMacro_ScoreText,
kLabelMacro_All = 0xFFFF
};

Expand Down
2 changes: 1 addition & 1 deletion Common/gui/guilabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Rect GUILabel::CalcGraphicRect(bool clipped)
// TODO: need to find a way to text position, or there'll be some repetition
// have to precache text and size on some events:
// - translation change
// - macro value change (score, overhotspot etc)
// - macro value change (overhotspot etc)
Rect rc = RectWH(0, 0, _width, _height);
if (PrepareTextToDraw() == 0)
return rc;
Expand Down
2 changes: 1 addition & 1 deletion Common/gui/guilistbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Rect GUIListBox::CalcGraphicRect(bool clipped)
// TODO: need to find a way to text position, or there'll be some repetition
// have to precache text and size on some events:
// - translation change
// - macro value change (score, overhotspot etc)
// - macro value change (overhotspot etc)
Rect rc = RectWH(0, 0, _width, _height);
UpdateMetrics();
const int width = _width - 1;
Expand Down
6 changes: 0 additions & 6 deletions Common/gui/guimain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,12 +881,6 @@ GUILabelMacro FindLabelMacros(const String &text)
macro_flags |= kLabelMacro_Gamename;
else if (ags_strnicmp(macro_at, "overhotspot", macro_len) == 0)
macro_flags |= kLabelMacro_Overhotspot;
else if (ags_strnicmp(macro_at, "score", macro_len) == 0)
macro_flags |= kLabelMacro_Score;
else if (ags_strnicmp(macro_at, "scoretext", macro_len) == 0)
macro_flags |= kLabelMacro_ScoreText;
else if (ags_strnicmp(macro_at, "totalscore", macro_len) == 0)
macro_flags |= kLabelMacro_TotalScore;
macro_at = nullptr;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Editor/AGS.Editor/DataFileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ private static void WriteGameSetupStructBase(BinaryWriter writer, Game game)
writer.Write(game.ViewCount);
writer.Write(game.Characters.Count);
writer.Write(game.PlayerCharacter.ID);
writer.Write(game.Settings.MaximumScore);
writer.Write(0); // [DEPRECATED]
writer.Write((short)(game.InventoryItems.Count + 1));
writer.Write(new byte[2]); // alignment padding
writer.Write(game.Dialogs.Count);
Expand Down Expand Up @@ -1680,7 +1680,7 @@ public static bool SaveThisGameToFile(string fileName, Game game, CompileMessage
writer.Write(new byte[2]); // struct alignment padding
writer.Write(0); // reserved
}
writer.Write(game.GetAudioArrayIDFromFixedIndex(game.Settings.PlaySoundOnScore));
writer.Write(0); // [DEPRECATED]
if (game.Settings.DebugMode)
{
writer.Write(game.Rooms.Count);
Expand Down
10 changes: 4 additions & 6 deletions Editor/AGS.Editor/Resources/agsdefns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,6 @@ import int GetTextHeight(const string text, FontType, int width);
import int GetFontHeight(FontType);
/// Gets the default step between two lines of text for the specified font
import int GetFontLineSpacing(FontType);
/// Adds to the player's score and plays the score sound, if set.
import void GiveScore(int points);
/// Refreshes the on-screen inventory display.
import void UpdateInventory();
/// From within dialog_request, tells AGS not to return to the dialog after this function ends.
Expand Down Expand Up @@ -1193,7 +1191,7 @@ enum EventType {
eEventLeaveRoom = 1,
eEventEnterRoomBeforeFadein = 2,
// 3 is reserved by an obsolete "death" event
eEventGotScore = 4,
// 4 is reserved by an obsolete "got score" event
eEventGUIMouseDown = 5,
eEventGUIMouseUp = 6,
eEventAddInventory = 7,
Expand Down Expand Up @@ -2335,7 +2333,7 @@ builtin struct Game {
};
builtin struct GameState {
int score;
readonly int reserved__11; // $AUTOCOMPLETEIGNORE$
int used_mode;
int disabled_user_interface;
int gscript_timer;
Expand All @@ -2353,7 +2351,7 @@ builtin struct GameState {
int swap_portrait;
int speech_text_gui;
int following_room_timer;
int total_score;
int reserved__12; // $AUTOCOMPLETEIGNORE$
int skip_display;
int no_multiloop_repeat;
int roomscript_finished;
Expand All @@ -2371,7 +2369,7 @@ builtin struct GameState {
readonly int room_width;
readonly int room_height;
int game_speed_modifier; // $AUTOCOMPLETEIGNORE$
int score_sound;
int reserved__13; // $AUTOCOMPLETEIGNORE$
int previous_game_data;
readonly readonly int unused__041; // $AUTOCOMPLETEIGNORE$
int dialog_options_x;
Expand Down
1 change: 0 additions & 1 deletion Editor/AGS.Editor/Tasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ private void SetDefaultValuesForNewFeatures(Game game)
audioIDToIndex.Add(clip.ID, clip.Index);
}

game.Settings.PlaySoundOnScore = RemapAudioClipIDToFixedIndex(game.Settings.PlaySoundOnScore, audioIDToIndex);
foreach (Types.View view in game.RootViewFolder.AllItemsFlat)
{
foreach (Types.ViewLoop loop in view.Loops)
Expand Down
4 changes: 0 additions & 4 deletions Editor/AGS.Editor/Utils/DialogScriptConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ private void ConvertDialogScriptCommandToScript(string dlgScriptCommand, StringW
convertedScriptLine = ProcessSingleIntParameterCommand(dlgScriptCommand, "new-room", "player.ChangeRoom({0}); return RUN_DIALOG_STOP_DIALOG;") + "}";
_currentlyInsideCodeArea = false;
}
else if (dlgScriptCommand.StartsWith("give-score"))
{
convertedScriptLine = ProcessSingleIntParameterCommand(dlgScriptCommand, "give-score", "GiveScore({0});");
}
else
{
RaiseDialogScriptCompileError("Unknown command: " + dlgScriptCommand + ". The command may require parameters which you have not supplied.");
Expand Down
2 changes: 0 additions & 2 deletions Editor/AGS.Native/agsnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2360,10 +2360,8 @@ Game^ import_compiled_game_dta(const AGSString &filename)
game->Settings->UseGlobalSpeechAnimationDelay = true; // this was always on in pre-3.0 games
game->Settings->HandleInvClicksInScript = (thisgame.options[OPT_HANDLEINVCLICKS] != 0);
game->Settings->InventoryCursors = !thisgame.options[OPT_FIXEDINVCURSOR];
game->Settings->MaximumScore = thisgame.totalscore;
game->Settings->NumberDialogOptions = (thisgame.options[OPT_DIALOGNUMBERED] != 0) ? DialogOptionsNumbering::Normal : DialogOptionsNumbering::KeyShortcutsOnly;
game->Settings->PixelPerfect = (thisgame.options[OPT_PIXPERFECT] != 0);
game->Settings->PlaySoundOnScore = thisgame.options[OPT_SCORESOUND];
game->Settings->RoomTransition = (RoomTransitionStyle)thisgame.options[OPT_FADETYPE];
game->Settings->SaveScreenshots = (thisgame.options[OPT_SAVESCREENSHOT] != 0);
game->Settings->SkipSpeech = (SkipSpeechStyle)thisgame.options[OPT_NOSKIPTEXT];
Expand Down
27 changes: 6 additions & 21 deletions Editor/AGS.Types/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public Settings()
private ScriptAPIVersion _scriptCompatLevelReal = Utilities.GetActualAPI(ScriptAPIVersion.Highest);
private bool _oldKeyHandling = false;
private bool _scaleCharacterSpriteOffsets = true;
private int _playSoundOnScore = -1;
private int _dialogOptionsGUI = 0;
private int _dialogOptionsGap = 0;
private int _dialogBulletImage = 0;
Expand All @@ -97,7 +96,6 @@ public Settings()
private bool _backwardsText = false;
private int _uniqueID;
private Guid _guid;
private int _totalScore = 0;
private bool _runGameLoopsWhileDialogOptionsDisplayed = false;
private InventoryHotspotMarker _inventoryHotspotMarker = new InventoryHotspotMarker();
private int _defRoomMaskResolution = 1;
Expand Down Expand Up @@ -653,16 +651,9 @@ public bool UseOldKeyboardHandling
set { _oldKeyHandling = value; }
}

[DisplayName("Play sound when the player gets points")]
[Description("This sound number will be played whenever the player scores points (0 to disable)")]
[DefaultValue(AudioClip.FixedIndexNoValue)]
[Category("Sound")]
[TypeConverter(typeof(AudioClipTypeConverter))]
public int PlaySoundOnScore
{
get { return _playSoundOnScore; }
set { _playSoundOnScore = value; }
}
[Obsolete]
[Browsable(false)]
public int PlaySoundOnScore { get; }

[Obsolete]
[Browsable(false)]
Expand Down Expand Up @@ -882,14 +873,9 @@ public bool BackwardsText
set { _backwardsText = value; }
}

[DisplayName("Maximum possible score")]
[Description("The maximum score that the player can achieve (displayed by @TOTALSCORE@ on GUI labels)")]
[Category("(Basic properties)")]
public int MaximumScore
{
get { return _totalScore; }
set { _totalScore = value; }
}
[Obsolete]
[Browsable(false)]
public int MaximumScore { get; }

[Obsolete]
[Browsable(false)]
Expand Down Expand Up @@ -1069,7 +1055,6 @@ public void ToXml(XmlTextWriter writer)

public void FromXml(XmlNode node)
{
_totalScore = 0;
_guid = Guid.Empty;
_description = string.Empty;
_releaseDate = DateTime.Now;
Expand Down
12 changes: 6 additions & 6 deletions Engine/ac/dynobj/scriptgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int32_t CCScriptGame::ReadInt32(void *address, intptr_t offset)

switch (index)
{
case 0: return play.score;
case 0: return 0;// [DEPRECATED]
case 1: return play.usedmode;
case 2: return play.disabled_user_interface;
case 3: return play.gscript_timer;
Expand All @@ -54,7 +54,7 @@ int32_t CCScriptGame::ReadInt32(void *address, intptr_t offset)
case 67: return play.swap_portrait_side;
case 68: return play.speech_textwindow_gui;
case 69: return play.follow_change_room_timer;
case 70: return play.totalscore;
case 70: return 0;// [DEPRECATED]
case 71: return play.skip_display;
case 72: return play.no_multiloop_repeat;
case 73: return play.roomscript_finished;
Expand All @@ -72,7 +72,7 @@ int32_t CCScriptGame::ReadInt32(void *address, intptr_t offset)
case 85: return play.room_width;
case 86: return play.room_height;
case 87: return play.game_speed_modifier;
case 88: return play.score_sound;
case 88: return 0;// [DEPRECATED]
case 89: return play.takeover_data;
case 90: return 0;// [DEPRECATED]
case 91: return play.dialog_options_x;
Expand Down Expand Up @@ -127,7 +127,7 @@ void CCScriptGame::WriteInt32(void *address, intptr_t offset, int32_t val)

switch (index)
{
case 0: play.score = val; break;
case 0: break; // [DEPRECATED]
case 1: play.usedmode = val; break;
case 2: play.disabled_user_interface = val; break;
case 3: play.gscript_timer = val; break;
Expand All @@ -148,7 +148,7 @@ void CCScriptGame::WriteInt32(void *address, intptr_t offset, int32_t val)
case 67: play.swap_portrait_side = val; break;
case 68: play.speech_textwindow_gui = val; break;
case 69: play.follow_change_room_timer = val; break;
case 70: play.totalscore = val; break;
case 70: break; // [DEPRECATED]
case 71: play.skip_display = val; break;
case 72: play.no_multiloop_repeat = val; break;
case 73: play.roomscript_finished = val; break;
Expand All @@ -168,7 +168,7 @@ void CCScriptGame::WriteInt32(void *address, intptr_t offset, int32_t val)
debug_script_warn("ScriptGame: attempt to write in readonly variable at offset %d, value %d", offset, val);
break;
case 87: play.game_speed_modifier = val; break;
case 88: play.score_sound = val; break;
case 88: break; // [DEPRECATED]
case 89: play.takeover_data = val; break;
case 90: break; // [DEPRECATED]
case 91: play.dialog_options_x = val; break;
Expand Down
2 changes: 1 addition & 1 deletion Engine/ac/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define GE_LEAVE_ROOM 1
#define GE_ENTER_ROOM 2
// #define GE_MAN_DIES 3 // ancient obsolete event
#define GE_GOT_SCORE 4
// #define GE_GOT_SCORE 4 // deprecated
#define GE_GUI_MOUSEDOWN 5
#define GE_GUI_MOUSEUP 6
#define GE_ADD_INV 7
Expand Down
Loading

0 comments on commit 1060255

Please sign in to comment.