GameResPacket.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. *
  20. * FILE
  21. * $Archive: /Commando/Code/WWOnline/GameResPacket.h $
  22. *
  23. * DESCRIPTION
  24. *
  25. * PROGRAMMER
  26. * $Author: Denzil_l $
  27. *
  28. * VERSION INFO
  29. * $Revision: 5 $
  30. * $Modtime: 1/25/02 11:53a $
  31. *
  32. ******************************************************************************/
  33. #pragma once
  34. #ifndef __GAMERESPACKET_H__
  35. #define __GAMERESPACKET_H__
  36. #pragma warning(disable : 4711)
  37. #include "GameResField.h"
  38. namespace WWOnline {
  39. class GameResPacket {
  40. public:
  41. GameResPacket(short id = 0) :
  42. mSize(0),
  43. mID(id),
  44. mReserved(0),
  45. mHead(0)
  46. {}
  47. GameResPacket(unsigned char *cur_buf);
  48. ~GameResPacket(void);
  49. // This function allows us to add a field to the start of the list. As the field is just
  50. // a big linked list it makes no difference which end we add a member to.
  51. void Add_Field(GameResField *field);
  52. //
  53. // These conveniance functions allow us to add a field directly to the list without
  54. // having to worry about newing one first.
  55. //
  56. void Add_Field(char *field, char data) {Add_Field(new GameResField(field, data));};
  57. void Add_Field(char *field, unsigned char data) {Add_Field(new GameResField(field, data));};
  58. void Add_Field(char *field, short data) {Add_Field(new GameResField(field, data));};
  59. void Add_Field(char *field, unsigned short data) {Add_Field(new GameResField(field, data));};
  60. void Add_Field(char *field, long data) {Add_Field(new GameResField(field, data));};
  61. void Add_Field(char *field, unsigned long data) {Add_Field(new GameResField(field, data));};
  62. void Add_Field(char *field, char *data) {Add_Field(new GameResField(field, data));};
  63. void Add_Field(char *field, void *data, int length) {Add_Field(new GameResField(field, data, length));};
  64. //
  65. // These functions search for a field of a given name in the list and
  66. // return the data via a reference value.
  67. //
  68. GameResField *Find_Field(char *id);
  69. bool Get_Field(char *id, char &data);
  70. bool Get_Field(char *id, unsigned char &data);
  71. bool Get_Field(char *id, short &data);
  72. bool Get_Field(char *id, unsigned short &data);
  73. bool Get_Field(char *id, long &data);
  74. bool Get_Field(char *id, unsigned long &data);
  75. bool Get_Field(char *id, char *data);
  76. bool Get_Field(char *id, void *data, int &length);
  77. unsigned char* Create_Comms_Packet(unsigned long& size, char* sig_name, unsigned long& sig_offset);
  78. private:
  79. unsigned long mSize;
  80. unsigned short mID;
  81. unsigned short mReserved;
  82. GameResField* mHead;
  83. GameResField* mCurrent;
  84. };
  85. } // namespace WWOnline
  86. #endif