/ghost/gameslot.cpp

http://ghostcb.googlecode.com/ · C++ · 88 lines · 56 code · 10 blank · 22 comment · 3 complexity · 4ee2cd172b39f8971521596ed5c564a8 MD5 · raw file

  1. /*
  2. Copyright [2008] [Trevor Hogan]
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. CODE PORTED FROM THE ORIGINAL GHOST PROJECT: http://ghost.pwner.org/
  13. */
  14. #include "ghost.h"
  15. #include "gameslot.h"
  16. //
  17. // CGameSlot
  18. //
  19. CGameSlot :: CGameSlot( BYTEARRAY &n )
  20. {
  21. if( n.size( ) >= 7 )
  22. {
  23. m_PID = n[0];
  24. m_DownloadStatus = n[1];
  25. m_SlotStatus = n[2];
  26. m_Computer = n[3];
  27. m_Team = n[4];
  28. m_Colour = n[5];
  29. m_Race = n[6];
  30. if( n.size( ) >= 8 )
  31. m_ComputerType = n[7];
  32. else
  33. m_ComputerType = SLOTCOMP_NORMAL;
  34. if( n.size( ) >= 9 )
  35. m_Handicap = n[8];
  36. else
  37. m_Handicap = 100;
  38. }
  39. else
  40. {
  41. m_PID = 0;
  42. m_DownloadStatus = 255;
  43. m_SlotStatus = SLOTSTATUS_OPEN;
  44. m_Computer = 0;
  45. m_Team = 0;
  46. m_Colour = 1;
  47. m_Race = SLOTRACE_RANDOM;
  48. m_ComputerType = SLOTCOMP_NORMAL;
  49. m_Handicap = 100;
  50. }
  51. }
  52. CGameSlot :: CGameSlot( unsigned char nPID, unsigned char nDownloadStatus, unsigned char nSlotStatus, unsigned char nComputer, unsigned char nTeam, unsigned char nColour, unsigned char nRace, unsigned char nComputerType, unsigned char nHandicap )
  53. : m_PID( nPID ), m_DownloadStatus( nDownloadStatus ), m_SlotStatus( nSlotStatus ), m_Computer( nComputer ), m_Team( nTeam ), m_Colour( nColour ), m_Race( nRace ), m_ComputerType( nComputerType ), m_Handicap( nHandicap )
  54. {
  55. }
  56. CGameSlot :: ~CGameSlot( )
  57. {
  58. }
  59. BYTEARRAY CGameSlot :: GetByteArray( ) const
  60. {
  61. BYTEARRAY b;
  62. b.push_back( m_PID );
  63. b.push_back( m_DownloadStatus );
  64. b.push_back( m_SlotStatus );
  65. b.push_back( m_Computer );
  66. b.push_back( m_Team );
  67. b.push_back( m_Colour );
  68. b.push_back( m_Race );
  69. b.push_back( m_ComputerType );
  70. b.push_back( m_Handicap );
  71. return b;
  72. }