mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-25 01:52:31 +00:00
Replace old GetState and SetState calls
966727b52e made the player state an enum and introduced more descriptive
functions to achieve the same thing, but it seems they were forgotten to
be replaced in a few places, which this patch fixes.
This commit is contained in:
@@ -370,8 +370,7 @@ Trigger.prototype.RemoveSpread = function()
|
||||
|
||||
Trigger.prototype.EndGame = function()
|
||||
{
|
||||
Engine.QueryInterface(3, IID_Player).SetState("defeated", "trigger");
|
||||
Engine.QueryInterface(4, IID_Player).SetState("won", "trigger");
|
||||
TriggerHelper.SetPlayerWon(3, "trigger", "trigger");
|
||||
};
|
||||
|
||||
var cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager);
|
||||
|
||||
@@ -433,8 +433,7 @@ Trigger.prototype.RunExperiment = function(data)
|
||||
|
||||
Trigger.prototype.EndGame = function()
|
||||
{
|
||||
Engine.QueryInterface(4, IID_Player).SetState("defeated", "trigger");
|
||||
Engine.QueryInterface(3, IID_Player).SetState("won", "trigger");
|
||||
TriggerHelper.SetPlayerWon(3, "trigger", "trigger");
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -119,7 +119,7 @@ Trigger.prototype.StartCaptureTheRelicCountdown = function(winningPlayers)
|
||||
for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID)
|
||||
{
|
||||
const cmpPlayer = QueryPlayerIDInterface(playerID);
|
||||
if (cmpPlayer.GetState() == "won")
|
||||
if (cmpPlayer.HasWon())
|
||||
return;
|
||||
|
||||
if (winningPlayers.indexOf(playerID) == -1)
|
||||
|
||||
@@ -23,7 +23,7 @@ Trigger.prototype.ConquestOwnershipChanged = function(msg)
|
||||
{
|
||||
const cmpPlayer = QueryPlayerIDInterface(msg.from);
|
||||
if (cmpPlayer)
|
||||
cmpPlayer.SetState("defeated", query.defeatReason);
|
||||
cmpPlayer.Defeat(query.defeatReason);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -315,7 +315,7 @@ TriggerHelper.DefeatPlayer = function(playerID, defeatReason)
|
||||
{
|
||||
const cmpPlayer = QueryPlayerIDInterface(playerID);
|
||||
if (cmpPlayer)
|
||||
cmpPlayer.SetState("defeated", defeatReason);
|
||||
cmpPlayer.Defeat(defeatReason);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ Trigger.prototype.WonderVictoryStartTimer = function(ent, player)
|
||||
for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID)
|
||||
{
|
||||
const cmpPlayer = QueryPlayerIDInterface(playerID);
|
||||
if (cmpPlayer.GetState() == "won")
|
||||
if (cmpPlayer.HasWon())
|
||||
return;
|
||||
if (allies.indexOf(playerID) == -1 && playerID != player)
|
||||
others.push(playerID);
|
||||
|
||||
+1
-1
@@ -495,7 +495,7 @@ bool CGame::IsGameFinished() const
|
||||
for (const std::pair<entity_id_t, IComponent*>& p : m_Simulation2->GetEntitiesWithInterface(IID_Player))
|
||||
{
|
||||
CmpPtr<ICmpPlayer> cmpPlayer(*m_Simulation2, p.first);
|
||||
if (cmpPlayer && cmpPlayer->GetState() == "won")
|
||||
if (cmpPlayer && cmpPlayer->HasWon())
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -88,9 +88,9 @@ public:
|
||||
return m_Script.Call<bool>("HasStartingCamera");
|
||||
}
|
||||
|
||||
std::string GetState() override
|
||||
bool HasWon() override
|
||||
{
|
||||
return m_Script.Call<std::string>("GetState");
|
||||
return m_Script.Call<bool>("HasWon");
|
||||
}
|
||||
|
||||
bool IsRemoved() override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
virtual bool HasStartingCamera() = 0;
|
||||
virtual bool IsRemoved() = 0;
|
||||
virtual std::string GetState() = 0;
|
||||
virtual bool HasWon() = 0;
|
||||
|
||||
// See the cpp file for why this is implemented in C++.
|
||||
virtual bool IsActive() = 0;
|
||||
|
||||
Reference in New Issue
Block a user