vector2i.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWMath *
  23. * *
  24. * $Archive:: /Commando/Code/wwmath/vector2i.h $*
  25. * *
  26. * Author:: Eric Cosky *
  27. * *
  28. * $Modtime:: 5/10/01 11:37p $*
  29. * *
  30. * $Revision:: 4 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef VECTOR2I_H
  39. #define VECTOR2I_H
  40. #include "always.h"
  41. class Vector2i
  42. {
  43. public:
  44. int I;
  45. int J;
  46. WWINLINE Vector2i(void);
  47. WWINLINE Vector2i(int i,int j);
  48. WWINLINE void Set(int i, int j);
  49. WWINLINE void Swap(Vector2i & other);
  50. WWINLINE bool operator== (const Vector2i & v) const;
  51. WWINLINE bool operator!= (const Vector2i& v) const;
  52. WWINLINE const int& operator[] (int n) const;
  53. WWINLINE int& operator[] (int n);
  54. };
  55. WWINLINE Vector2i::Vector2i(void)
  56. {
  57. }
  58. WWINLINE Vector2i::Vector2i(int i,int j)
  59. {
  60. I = i; J = j;
  61. }
  62. WWINLINE bool Vector2i::operator == (const Vector2i & v) const
  63. {
  64. return (I == v.I && J == v.J );
  65. }
  66. WWINLINE bool Vector2i::operator != (const Vector2i& v) const
  67. {
  68. return !(I == v.I && J == v.J);
  69. }
  70. WWINLINE const int& Vector2i::operator[] (int n) const
  71. {
  72. return ((int*)this)[n];
  73. }
  74. WWINLINE int& Vector2i::operator[] (int n)
  75. {
  76. return ((int*)this)[n];
  77. }
  78. WWINLINE void Vector2i::Set(int i, int j) { I = i; J = j; }
  79. WWINLINE void Vector2i::Swap(Vector2i & other)
  80. {
  81. // this could use MMX..
  82. I ^= other.I;
  83. other.I ^= I;
  84. I ^= other.I;
  85. J ^= other.J;
  86. other.J ^= J;
  87. J ^= other.J;
  88. }
  89. #endif