Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpRangeManager.cpp
Context not available. | |||||
#define LOS_TILES_RATIO 8 | #define LOS_TILES_RATIO 8 | ||||
#define DEBUG_RANGE_MANAGER_BOUNDS 0 | #define DEBUG_RANGE_MANAGER_BOUNDS 0 | ||||
#define MAX_NUMBER_OF_PLAYERS 16 | |||||
/** | /** | ||||
* Representation of a range query. | * Representation of a range query. | ||||
Context not available. | |||||
*/ | */ | ||||
static inline u32 CalcOwnerMask(player_id_t owner) | static inline u32 CalcOwnerMask(player_id_t owner) | ||||
{ | { | ||||
if (owner >= -1 && owner < 31) | if (owner >= -1 && owner < 2*MAX_NUMBER_OF_PLAYERS - 1) | ||||
Stan: It doesn't sound sane to do that.
Maybe introduce a constant called… | |||||
return 1 << (1+owner); | return 1 << (1+owner); | ||||
else | else | ||||
return 0; // owner was invalid | return 0; // owner was invalid | ||||
Context not available. | |||||
*/ | */ | ||||
static inline u32 CalcPlayerLosMask(player_id_t player) | static inline u32 CalcPlayerLosMask(player_id_t player) | ||||
{ | { | ||||
Done Inline Actions32 should be replaced by a named constant. vladislavbelov: `32` should be replaced by a named constant. | |||||
Done Inline ActionsOk. nani: Ok. | |||||
Not Done Inline ActionsDon't think it should. Here 32 is used because it's u32. It's also not 2 * max number of players, but it should be capped by max_players. elexis: Don't think it should. Here 32 is used because it's `u32`. It's also not 2 * max number of… | |||||
if (player > 0 && player <= 16) | if (player > 0 && player <= MAX_NUMBER_OF_PLAYERS) | ||||
return ICmpRangeManager::LOS_MASK << (2*(player-1)); | return ICmpRangeManager::LOS_MASK << (2*(player-1)); | ||||
return 0; | return 0; | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
static bool SetPlayerSharedDirtyVisibilityBit(u16& mask, player_id_t player, bool enable) | static bool SetPlayerSharedDirtyVisibilityBit(u16& mask, player_id_t player, bool enable) | ||||
{ | { | ||||
if (player <= 0 || player > 16) | if (player <= 0 || player > MAX_NUMBER_OF_PLAYERS) | ||||
return false; | return false; | ||||
u16 oldMask = mask; | u16 oldMask = mask; | ||||
Context not available. | |||||
*/ | */ | ||||
static inline u8 GetPlayerVisibility(u32 visibilities, player_id_t player) | static inline u8 GetPlayerVisibility(u32 visibilities, player_id_t player) | ||||
{ | { | ||||
if (player > 0 && player <= 16) | if (player > 0 && player <= MAX_NUMBER_OF_PLAYERS) | ||||
return (visibilities >> (2 *(player-1))) & 0x3; | return (visibilities >> (2 *(player-1))) & 0x3; | ||||
return 0; | return 0; | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
static inline bool IsVisibilityDirty(u16 dirty, player_id_t player) | static inline bool IsVisibilityDirty(u16 dirty, player_id_t player) | ||||
{ | { | ||||
if (player > 0 && player <= 16) | if (player > 0 && player <= MAX_NUMBER_OF_PLAYERS) | ||||
return (dirty >> (player - 1)) & 0x1; | return (dirty >> (player - 1)) & 0x1; | ||||
return false; | return false; | ||||
} | } | ||||
Context not available. | |||||
std::vector<entity_id_t> m_SubdivisionResults; | std::vector<entity_id_t> m_SubdivisionResults; | ||||
// LOS state: | // LOS state: | ||||
static const player_id_t MAX_LOS_PLAYER_ID = 16; | static const player_id_t MAX_LOS_PLAYER_ID = MAX_NUMBER_OF_PLAYERS; | ||||
std::vector<bool> m_LosRevealAll; | std::vector<bool> m_LosRevealAll; | ||||
bool m_LosCircular; | bool m_LosCircular; | ||||
Context not available. |
Wildfire Games · Phabricator
It doesn't sound sane to do that.
Maybe introduce a constant called ABSOLUTE_MAX_NUMBER_OF_PLAYERS that's 32