Author Topic: Support for separate packet definition files safe from TNet file updates?  (Read 1738 times)

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Quite minor problem, but I'm curious if it's possible to fix it. At the moment you are adding your custom packets directly into TNet code, which obviously becomes a problem if an update contains any of those files, as that will wipe your packets out. I'm on a relatively safe side with the version control, as I can check the old version again and copy the missing stuff, but that won't be the case for every user. Is there a way to separate custom packets into standalone files so that this situation won't arise no matter what TNet files are updated in the coming versions?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
When adding your custom packets, have them start at some high number, like 200.

  1. public enum Packet
  2. {
  3.  
  4.         /// <summary>
  5.         /// Empty packet. Can be used to keep the connection alive.
  6.         /// </summary>
  7.  
  8.         Empty,
  9.  
  10.         /// <summary>
  11.         /// This packet indicates that an error has occurred.
  12.         /// string: Description of the error.
  13.         /// </summary>
  14.  
  15.         Error,
  16. .....
  17.  
  18.         RequestActivateUDP,
  19.  
  20.         /// <summary>
  21.         /// Sync the specified player's 'data' property. This packet will be echoed to everyone except the sender.
  22.         /// int32: Player ID who's data should be synchronized.
  23.         /// object: Player's data.
  24.         /// </summary>
  25.  
  26.         SyncPlayerData,
  27.  
  28.         YourCustomPacket = 200,
  29.         YourSecondCustomPacket,
  30.         YourThirdCustomPacket,
  31. }