/************************************** **** EXAMPLE USAGE AT BOTTOM ******** **** PACKET 99 STRUCTURE AT BOTTOM *** *************************************** ** Accidentally turned this into a sep. class ***** ** This uses the stream class - remember! ******* ***************************************/ #import using namespace std; //This holds all of the packet IDs that are allowed to be sent and have been added compatibility int outPackets[] = { 0, 99 }; //Declares the Integer type variable currentPacket - stores the packet that will be handled int currentPacket; /* ** Declares the Integer Array type variable packetData - stores the data that will be sent with the packet ** [0] value represents the data to be sent using the writeWord method - assumedly its small endian ** [1] value represents the data to be sent using the writeWordBigEndian method ** [2] value represents the data to be sent using the writeByte method ** [3] value represents the data to be sent using the writeByteA method ** [4] value represents the data to be sent using the writeByteB method ** [5] value represents the data to be sent using the writeByteC method ** [6] value represents the data to be sent using the writeByteS method ** NOTE: Set any values to -1 for them to act as a null and not be sent along with the packet */ int packetData[]; //Creates a new object for the class OutgoingPackets public: OutgoingPackets(int setPacket, int[] dataArray) { //Sets the packet that we will be handling currentPacket = setPacket; //Sets the data needed to be sent with packet into an array for later use packetData = dataArray; } //Here is the core of the class - it makes the packet ready and sends it public: void processPacket() { //Creates a new object for the Stream class used in most private servers stream outGoing; //Checks if a way to handle the outgoing packet has been added if(packetCompatible) outGoing.createFrame(currentPacket); //If a way to handle the packet has not yet been added, it tells the user and terminates else if(!packetCompatible) cout << "Compatibility for the outgoing packet #" << currentPacket << " has not been added."; //The next few lines set the data needed for the packet when it is sent addDataToPacket(outGoing); //The next two lines update the player on most servers because they use the client class - change to your liking and add your own object updateRequired = true; appearanceUpdateRequired = true; //Tells the user the server is about to to send the outgoing packet cout << "Outgoing packet #" currentPacket << " has been sent."); } boolean packetCompatible() { for(int cValue = 0; cValue < outPackets.length; cValue++) if(outPackets[cValue] == currentPacket) return true; return false; } void addDataToPacket(stream outGoing) { //Self explanatory - see documentation at declaration of packetData[] if(packetData[0] != -1) outGoing.writeWord(packetData[0]); if(packetData[1] != -1) outGoing.writeWordBigEndian(packetData[1]); if(packetData[2] != -1) outGoing.writeByte(packetData[2]); if(packetData[3] != -1) outGoing.writeByteA(packetData[3]); if(packetData[4] != -1) outGoing.writeByteB(packetData[4]); if(packetData[5] != -1) outGoing.writeByteC(packetData[5]); if(packetData[6] != -1) outGoing.writeByteS(packetData[6]); } /*********************************** ************************************ EXAMPLE USAGE: int data[] = { -1, -1, 2, -1, -1, -1, -1 }; //Only data needed is writeByte which is set to 2 OutgoingPackets op(99, data); //Creates a new object of this class, setting the packet to 99 op.processPacket(); //Starts to send packet ************************************ Packet 99 Structure and Information Packet ID: 99 Referred To As: Map Status Packet Packet-Side Data Needed: One integer value. Send using writeByte(int). Packet-Side Data Possible Values: 0 - Unlock Map (Resets to normal state) 1 - Lock Map (Makes it non-clickable) 2 - Darken Map (Makes the map black with nonclickable state) 3 and above - Lock Map (Same as 2) ************************************* ************************************/