Mercurial > mm7
diff mm7_data.h @ 1657:51a74615d956
DamagePlayerFromMonster continuing cleanup, part 3
author | Grumpy7 |
---|---|
date | Wed, 18 Sep 2013 10:22:16 +0200 |
parents | b0a2b8525483 |
children | 55bdb9b043e3 |
line wrap: on
line diff
--- a/mm7_data.h Wed Sep 18 09:06:28 2013 +0200 +++ b/mm7_data.h Wed Sep 18 10:22:16 2013 +0200 @@ -3,6 +3,7 @@ #include "VectorTypes.h" #include "OSAPI.h" #include <array> +#include <assert.h> typedef char _UNKNOWN; typedef unsigned int uint; @@ -282,7 +283,44 @@ return uint64(x) > uint64(x+y); } +template<class _Ty, + size_t _Size> +class NZIArray : std::array<_Ty, _Size> +{ +public: + reference ZerothIndex() + { + return std::array<_Ty, _Size>::operator [](0); + } + reference operator[](size_type _Pos) + { // subscript nonmutable sequence +#if _ITERATOR_DEBUG_LEVEL == 2 + assert(_Pos != 0 && "not allowed to access zeroth element"); + +#elif _ITERATOR_DEBUG_LEVEL == 1 + _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); +#endif /* _ITERATOR_DEBUG_LEVEL */ + + __analysis_assume(_Pos != 0); + + return std::array<_Ty, _Size>::operator [](_Pos); + } + + const_reference operator[](size_type _Pos) const + { // subscript nonmutable sequence +#if _ITERATOR_DEBUG_LEVEL == 2 + assert(_Pos != 0 && "not allowed to access zeroth element"); + +#elif _ITERATOR_DEBUG_LEVEL == 1 + _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); +#endif /* _ITERATOR_DEBUG_LEVEL */ + + __analysis_assume(_Pos != 0); + + return std::array<_Ty, _Size>::operator [](_Pos); + } +}; //------------------------------------------------------------------------- // Data declarations @@ -975,7 +1013,7 @@ extern struct Texture *pTexture_PlayerFaceDead; extern std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces; extern int dword_A75070; // weak -extern std::array<struct Player *, 5> pPlayers; +extern NZIArray<struct Player *, 5> pPlayers; extern __int64 qword_A750D8; // weak extern enum PlayerSpeech PlayerSpeechID; extern int uSpeakingCharacter; // weak