Skip to content
Permalink
Browse files

micro-optimize Get*RulesParam (#443)

AllAccessTeam always succeeds the check at level "private" so there's no point checking it at level "allied".
  • Loading branch information...
sprunk authored and ashdnazg committed May 14, 2019
1 parent 26b617d commit 89fe0874411b30170ca9246081203a199ab6f421
Showing with 5 additions and 5 deletions.
  1. +5 −5 rts/Lua/LuaSyncedRead.cpp
@@ -1348,7 +1348,7 @@ int LuaSyncedRead::GetTeamRulesParams(lua_State* L)
if (IsAlliedTeam(L, team->teamNum) || game->IsGameOver()) {
losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK;
}
else if (teamHandler.AlliedTeams(team->teamNum, CLuaHandle::GetHandleReadTeam(L)) || ((CLuaHandle::GetHandleReadAllyTeam(L) < 0) && CLuaHandle::GetHandleFullRead(L))) {
else if (teamHandler.AlliedTeams(team->teamNum, CLuaHandle::GetHandleReadTeam(L))) {
losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK;
}

@@ -1367,7 +1367,7 @@ int LuaSyncedRead::GetTeamRulesParam(lua_State* L)
if (IsAlliedTeam(L, team->teamNum) || game->IsGameOver()) {
losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK;
}
else if (teamHandler.AlliedTeams(team->teamNum, CLuaHandle::GetHandleReadTeam(L)) || ((CLuaHandle::GetHandleReadAllyTeam(L) < 0) && CLuaHandle::GetHandleFullRead(L))) {
else if (teamHandler.AlliedTeams(team->teamNum, CLuaHandle::GetHandleReadTeam(L))) {
losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK;
}

@@ -4522,7 +4522,7 @@ static int GetUnitRulesParamLosMask(lua_State* L, const CUnit* unit)
{
if (IsAllyUnit(L, unit) || game->IsGameOver())
return LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK;
if (teamHandler.AlliedTeams(unit->team, CLuaHandle::GetHandleReadTeam(L)) || ((CLuaHandle::GetHandleReadAllyTeam(L) < 0) && CLuaHandle::GetHandleFullRead(L)))
if (teamHandler.AlliedTeams(unit->team, CLuaHandle::GetHandleReadTeam(L)))
return LuaRulesParams::RULESPARAMLOS_ALLIED_MASK;
if (CLuaHandle::GetHandleReadAllyTeam(L) < 0)
return LuaRulesParams::RULESPARAMLOS_PUBLIC_MASK;
@@ -4879,7 +4879,7 @@ int LuaSyncedRead::GetFeatureRulesParams(lua_State* L)
if (IsAlliedAllyTeam(L, feature->allyteam) || game->IsGameOver()) {
losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK;
}
else if (teamHandler.AlliedTeams(feature->team, CLuaHandle::GetHandleReadTeam(L)) || ((CLuaHandle::GetHandleReadAllyTeam(L) < 0) && CLuaHandle::GetHandleFullRead(L))) {
else if (teamHandler.AlliedTeams(feature->team, CLuaHandle::GetHandleReadTeam(L))) {
losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK;
}
else if (CLuaHandle::GetHandleReadAllyTeam(L) < 0) {
@@ -4907,7 +4907,7 @@ int LuaSyncedRead::GetFeatureRulesParam(lua_State* L)
if (IsAlliedAllyTeam(L, feature->allyteam) || game->IsGameOver()) {
losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK;
}
else if (teamHandler.AlliedTeams(feature->team, CLuaHandle::GetHandleReadTeam(L)) || ((CLuaHandle::GetHandleReadAllyTeam(L) < 0) && CLuaHandle::GetHandleFullRead(L))) {
else if (teamHandler.AlliedTeams(feature->team, CLuaHandle::GetHandleReadTeam(L))) {
losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK;
}
else if (CLuaHandle::GetHandleReadAllyTeam(L) < 0) {

0 comments on commit 89fe087

Please sign in to comment.
You can’t perform that action at this time.