public static copyTo ( byte sourceArray, int offsetB, byte destinationArray, int offsetA, int nBytes ) : void | ||
sourceArray | byte | |
offsetB | int | |
destinationArray | byte | |
offsetA | int | |
nBytes | int | |
return | void |
public void processTeamInviteAnswer(ref byte[] packet) { // read the important things byte[] unknownUint16_1 = new byte[2]; byte[] sizeString = new byte[2]; ArrayUtils.copyTo(packet, 3, unknownUint16_1, 0, 2); ArrayUtils.copyTo(packet, 7, sizeString, 0, 2); UInt16 sizeCharName = NumericalUtils.ByteArrayToUint16(sizeString, 1); byte[] characterNameBytes = new byte[sizeCharName]; ArrayUtils.copyTo(packet, 9, characterNameBytes, 0, sizeCharName); string characterName = StringUtils.charBytesToString(characterNameBytes); // if it is 0 - then he has accepted the request - otherwise decline and ..we dont care if (NumericalUtils.ByteArrayToUint16(unknownUint16_1, 1) == 0) { lock (WorldSocket.missionTeams) { foreach (MissionTeam team in WorldSocket.missionTeams) { if (team.characterMasterName.Equals(characterName)) { team.addMember(StringUtils.charBytesToString_NZ(Store.currentClient.playerInstance.CharacterName.getValue())); } } } } }
public void processLoadAbility(ref byte[] packet) { // read the values from the packet PacketReader reader = new PacketReader(packet); UInt32 staticObjectID = reader.readUInt32(1); UInt16 unloadFlag = reader.readUInt16(1); UInt16 loadFlag = reader.readUInt16(1); UInt16 countAbilities = reader.readUInt16(1); int pointer = 11; // Start at index 11 List <UInt16> abilitySlots = new List <UInt16>(); for (int i = 1; i <= countAbilities; i++) { // This must be looped byte[] slotByteID = new byte[2]; ArrayUtils.copyTo(packet, pointer, slotByteID, 0, 2); pointer = pointer + 2; byte[] abilityByteID = new byte[2]; ArrayUtils.copyTo(packet, pointer, abilityByteID, 0, 2); pointer = pointer + 4; byte[] abilityByteLevel = new byte[2]; ArrayUtils.copyTo(packet, pointer, abilityByteLevel, 0, 2); pointer = pointer + 3; UInt16 slotID = NumericalUtils.ByteArrayToUint16(slotByteID, 1); UInt16 AbilityID = NumericalUtils.ByteArrayToUint16(abilityByteID, 1); UInt16 AbilityLevel = NumericalUtils.ByteArrayToUint16(abilityByteLevel, 1); PacketContent pak = new PacketContent(); if (unloadFlag > 0) { pak.addUint16((UInt16)RPCResponseHeaders.SERVER_ABILITY_UNLOAD, 0); pak.addByteArray(abilityByteID); } else { pak.addUint16((UInt16)RPCResponseHeaders.SERVER_ABILITY_LOAD, 0); pak.addByteArray(abilityByteID); pak.addByteArray(abilityByteLevel); pak.addByteArray(slotByteID); } abilitySlots.Add(slotID); Store.currentClient.messageQueue.addRpcMessage(pak.returnFinalPacket()); } if (unloadFlag > 0) { Store.dbManager.WorldDbHandler.updateAbilityLoadOut(abilitySlots, 0); } else { Store.dbManager.WorldDbHandler.updateAbilityLoadOut(abilitySlots, 1); } }
public void processObjectDynamic(ref byte[] packet) { PacketReader reader = new PacketReader(packet); byte[] objectID = new byte[4]; byte[] sectorID = new byte[2]; ArrayUtils.copyTo(packet, 0, objectID, 0, 4); ArrayUtils.copyTo(objectID, 2, sectorID, 0, 2); UInt32 numericObjectId = NumericalUtils.ByteArrayToUint32(objectID, 1); // Ok sector Bytes are something like 30 39 (reversed but the result must be 39 03) UInt16 numericSectorId = NumericalUtils.ByteArrayToUint16(sectorID, 1); // strip out object id string id = StringUtils.bytesToString_NS(objectID); // get the type byte[] objectType = new byte[1]; ArrayUtils.copy(packet, 4, objectType, 0, 1); int objectTypeID = packet[4]; // create a new System message but fill it in the switch block ServerPackets pak = new ServerPackets(); #if DEBUG pak.sendSystemChatMessage(Store.currentClient, "Object Type ID IS " + objectTypeID.ToString() + " Dynamic Object RPC : " + StringUtils.bytesToString_NS(packet), "BROADCAST"); #endif switch (objectTypeID) { case (int)objectTypesDynamic.LOOT: UInt32[] theTestArrayLoots = new UInt32[2]; theTestArrayLoots[0] = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes("8e220000"), 1); pak.SendLootWindow(5000, Store.currentClient, theTestArrayLoots); break; default: pak.sendSystemChatMessage(Store.currentClient, "[OI HELPER] Unknown Object Type : " + objectTypeID.ToString() + "| Object ID :" + id, "MODAL"); break; } }
// This is for team and crew invites public void processInviteAnswer(ref byte[] packet) { // read the important things byte[] maybeType = new byte[2]; byte[] sizeString = new byte[2]; ArrayUtils.copyTo(packet, 3, maybeType, 0, 2); ArrayUtils.copyTo(packet, 7, sizeString, 0, 2); UInt16 sizeCharName = NumericalUtils.ByteArrayToUint16(sizeString, 1); byte[] characterNameBytes = new byte[sizeCharName]; ArrayUtils.copyTo(packet, 9, characterNameBytes, 0, sizeCharName); string characterName = StringUtils.charBytesToString(characterNameBytes); // if it is 0 - then he has accepted the request - otherwise decline and ..we dont care switch (NumericalUtils.ByteArrayToUint16(maybeType, 1)) { // Team Invites case 0: lock (WorldSocket.missionTeams) { foreach (MissionTeam team in WorldSocket.missionTeams) { if (team.characterMasterName.Equals(characterName)) { team.addMember(StringUtils.charBytesToString_NZ(Store.currentClient.playerInstance.CharacterName.getValue())); } } } break; // Crew Invites case 2: // ToDo: add to Crew and maybe to faction (if crew is part of faction) // ToDo: Generate Repsonse for all connected crew mates and the new member // ToDo: add to crew and figure out the responses that are necessary (like crew message , player update etc.) // ToDo: for this the "2_player_action" logs could be useful. break; } }
public void processObjectStatic(ref byte[] packet) { byte[] objectID = new byte[4]; byte[] sectorID = new byte[2]; ArrayUtils.copyTo(packet, 0, objectID, 0, 4); ArrayUtils.copyTo(objectID, 2, sectorID, 0, 2); UInt32 numericObjectId = NumericalUtils.ByteArrayToUint32(objectID, 1); // Ok sector Bytes are something like 30 39 (reversed but the result must be 39 03) UInt16 numericSectorId = NumericalUtils.ByteArrayToUint16(sectorID, 1); // strip out object id string id = StringUtils.bytesToString_NS(objectID); // get the type byte[] objectType = new byte[1]; ArrayUtils.copy(packet, 4, objectType, 0, 1); int objectTypeID = packet[4]; DataLoader objectLoader = DataLoader.getInstance(); StaticWorldObject objectValues = objectLoader.getObjectValues(NumericalUtils.ByteArrayToUint32(objectID, 1)); // create a new System message but fill it in the switch block ServerPackets pak = new ServerPackets(); switch (objectTypeID) { // Case 03 is not only a staticWorldObject ... case (int)objectTypesStatic.DOOR: Output.writeToLogForConsole("[OI HELPER] INTERACT WITH DOOR | Object ID :" + id + " Sector ID : " + numericSectorId); // just a test if (objectValues != null && objectValues.type != null) { GameObjectItem item = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1)); //Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("[OI HELPER] Door StrType: !" + item.getName() + " with Type ID " + StringUtils.bytesToString_NS(objectValues.type), Store.currentClient)); this.processObjectInteraction(objectValues, item); } break; case (int)objectTypesStatic.HARDLINE_SYNC: pak.sendSystemChatMessage(Store.currentClient, "Hardline Interaction(not done yet)!", "MODAL"); break; case (int)objectTypesStatic.HARDLINE_UPLOAD: Output.writeToLogForConsole("[OBJECT HELPER] Upload Hardline will be used for combat tests"); Store.currentClient.playerData.lastClickedObjectId = numericObjectId; new TestUnitHandler().processTestCombat(ref packet); break; case (int)objectTypesStatic.HARDLINE_LAEXIT: // Exit LA pak.sendSystemChatMessage(Store.currentClient, "Exit to LA Dialog should popup", "MODAL"); new TeleportHandler().processHardlineExitRequest(); break; case (int)objectTypesStatic.HUMAN_NPC: pak.sendSystemChatMessage(Store.currentClient, "Open Vendor Dialog for Object ID" + StringUtils.bytesToString_NS(objectID), "MODAL"); this.processVendorOpen(ref objectID); break; case (int)objectTypesStatic.COLLECTOR: pak.sendSystemChatMessage(Store.currentClient, "Collector Interaction (not done yet)!", "MODAL"); break; case (int)objectTypesStatic.ENVIROMENT: GameObjectItem enviromentItem = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1)); UInt16 enviromentTypeID = NumericalUtils.ByteArrayToUint16(objectValues.type, 1); switch (enviromentTypeID) { case 6952: // ToDo: implement Elevator Panel pak.sendElevatorPanel(Store.currentClient, objectValues); break; default: pak.sendSystemChatMessage(Store.currentClient, "Enviroment Type ID " + objectValues.type + " name " + enviromentItem.getName(), "MODAL"); break; } pak.sendSystemChatMessage(Store.currentClient, "Enviroment Type ID " + objectValues.type + " name " + enviromentItem.getName(), "MODAL"); break; default: pak.sendSystemChatMessage(Store.currentClient, "[OI HELPER] Unknown Object Type : " + objectTypeID.ToString() + "| Object ID :" + id, "MODAL"); break; } }