public void processCharacterAnimationSelf(UInt16 abilityID) { ServerPackets pak = new ServerPackets(); // 2904 0429 = Hacker_VirusLaunch_A // 2a04 042a = Hacker_VirusLaunch_D // see movementAnims.tx - its for codes something (0x31) if (currentAbility.getAbilityExecutionFX() > 0) { pak.sendCastAbilityOnEntityId(2, currentAbility.getAbilityExecutionFX(), 200); } if (currentAbility.getCastingTime() > 0) { byte[] castAnimStart = currentAbility.getCastAnimStart(); // Cast pak.sendSystemChatMessage(Store.currentClient, "Animation Starts with Byte ID " + StringUtils.bytesToString(castAnimStart), "BROADCAST"); pak.sendPlayerAnimation(Store.currentClient, StringUtils.bytesToString_NS(castAnimStart)); // And Time a "Damage" or "Buff" Animation int castingTime = (int)this.currentAbility.getCastingTime() * 1000; this.damageTimer = new Timer(abilityAnimateTheTarget, this, castingTime, 0); } }
public void testCloseCombat(ref byte[] packet) { byte[] targetViewWithSpawnId = new byte[4]; ArrayUtils.copy(packet, 0, targetViewWithSpawnId, 0, 4); string hexString = StringUtils.bytesToString_NS(targetViewWithSpawnId); string hexStringPak = StringUtils.bytesToString_NS(packet); Store.currentClient.messageQueue.addObjectMessage(StringUtils.hexStringToBytes("020003010C00808400808080800100001000"), false); // Make me combat mode "on" // The 55 View Packet PacketContent ilCombatHandler = new PacketContent(); ilCombatHandler.addHexBytes("01000C370036CDAB0205"); ilCombatHandler.addByteArray(Store.currentClient.playerInstance.Position.getValue()); ilCombatHandler.addHexBytes("cdec4023"); // Time starts i think ilCombatHandler.addHexBytes("fd0000"); // view ID fd00 Store.currentClient.messageQueue.addObjectMessage(ilCombatHandler.returnFinalPacket(), false); Store.currentClient.flushQueue(); // The other 03 Packet for combat PacketContent unknownCreatePak = new PacketContent(); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("010002A700")); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("FD00")); // ViewID from Combat Object unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("01")); unknownCreatePak.addByteArray(Store.currentClient.playerInstance.Position.getValue()); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("0100000003000000")); unknownCreatePak.addByteArray(targetViewWithSpawnId); unknownCreatePak.addUint16(2, 1); unknownCreatePak.addUint16(Store.currentClient.playerData.selfSpawnIdCounter, 1); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("01010207030000200BF5C2000020C19420B9C300000000000020C100000000070001001201000007037608E00603145200008B0B0024145200008B0B0024882300008B0B00240000000000000000000000000000000064000000640000000010001010000000020000001000000002000000000000000000000000")); Store.currentClient.messageQueue.addObjectMessage(unknownCreatePak.returnFinalPacket(), false); Store.currentClient.flushQueue(); }
private byte[] loadBackgroundInfo(int charID) { Hashtable charInfo = Store.dbManager.MarginDbHandler.getCharInfo(charID); // in margin packet firstname,lastname are everytime 32 bytes and background 1024 - so we must pad it string firstname = (string)charInfo["firstname"].ToString().PadRight(32, '\x00'); string lastname = (string)charInfo["lastname"].ToString().PadRight(32, '\x00'); string background = (string)charInfo["background"].ToString().PadRight(1024, '\x00'); string district = (string)charInfo["district"]; /* * string repMero = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repMero"], 1)); * string repMachine = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repMachine"], 1)); * string repNiobe = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repNiobe"], 1)); * string repGM = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repGM"], 1)); * string repZion = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repZion"], 1)); */ // Set the default value string worldFlag = "00"; // 01 = onWorld , 00 = LA . In World you have to take care to not spawn the Character in LA State if (district != "la") { worldFlag = "01"; } byte[] firstNameBytes = StringUtils.stringToBytes(firstname); byte[] lastNameBytes = StringUtils.stringToBytes(lastname); byte[] backgroundBytes = StringUtils.stringToBytes(background); string firstPart; if (isNewCreatedChar == false) { firstPart = "01000000640000007B0000006500000000000000000000006C000000000000002B010000"; } else { firstPart = ""; } string exp = "E7CBC012"; string cash = "FCBE4BEE"; string timestamp = "875D714A"; string repBytes = "ecfa" + "ecfb" + "ecfc" + "ecfd" + "ecfe" + "ecff"; // string repBytes = repMero + repMachine + repNiobe + repGM + repZion; string lastPart = exp + cash + "0105000000" + timestamp + repBytes + "000003" + worldFlag + "0301310000b402320000b403380000b403510000000400520000000b00540000000100"; string fullPacket = firstPart + StringUtils.bytesToString_NS(firstNameBytes) + StringUtils.bytesToString_NS(lastNameBytes) + StringUtils.bytesToString_NS(backgroundBytes) + lastPart; if (isNewCreatedChar == true) { Output.WriteLine("Load Background Reply for Created Char:\n" + fullPacket); } byte[] dataPak = StringUtils.hexStringToBytes(fullPacket); return(dataPak); }
public StaticWorldObject getObjectValues(UInt32 objectId) { Output.WriteLine("REQUEST OBJECT WITH ID :" + StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray(objectId, 0))); StaticWorldObject worldObject = null; worldObject = WorldObjectsDB.Find(delegate(StaticWorldObject temp) { return(temp.mxoId == objectId); }); if (worldObject == null) { worldObject = new StaticWorldObject(); } return(worldObject); }
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; } }
private void deleteCharName(byte[] packet, NetworkStream client) { // Response should something like : 0e 44 87 1f 00 00 00 00 00 00 00 00 00 // Get the charId from the packet byte[] charIDB = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ArrayUtils.copy(packet, 5, charIDB, 0, 8); //Offset for charID is 5 in request // Need for SQL Delete UInt64 charID = NumericalUtils.ByteArrayToUint32(charIDB, 1); Store.dbManager.MarginDbHandler.deleteCharacter(charID); // Create viewData string deleteRequestResponse = "0e" + StringUtils.bytesToString_NS(charIDB) + "0000000000000000"; sendMarginData(deleteRequestResponse, client); }
public void processWhereamiCommand(ref byte[] packet) { Output.WriteLine("[COMMAND HELPER] WHERE AM I "); double x = 0; double y = 0; double z = 0; byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue(); NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z); byte[] xPos = NumericalUtils.floatToByteArray((float)x, 1); byte[] yPos = NumericalUtils.floatToByteArray((float)y, 1); byte[] zPos = NumericalUtils.floatToByteArray((float)z, 1); string posHex = StringUtils.bytesToString_NS(xPos) + StringUtils.bytesToString_NS(yPos) + StringUtils.bytesToString_NS(zPos); ServerPackets serverpacket = new ServerPackets(); serverpacket.sendWhereami(Store.currentClient, xPos, yPos, zPos); }
private void charNameRequest(byte[] packet, NetworkStream client) { // Get the handle text byte[] handleSize = new byte[2]; handleSize[0] = packet[5]; handleSize[1] = packet[6]; int size = (int)NumericalUtils.ByteArrayToUint16(handleSize, 1); byte[] handleB = new byte[size - 1]; ArrayUtils.copy(packet, 7, handleB, 0, size - 1); string handleBStr = StringUtils.bytesToString_NS(handleB); // Handle as "414141" string handleStr = StringUtils.charBytesToString(handleB); // Handle as "AAA" // Process DB to answer the client - we directly create the character UInt32 dbResult = Store.dbManager.MarginDbHandler.getNewCharnameID(handleStr, userID); // Add the new charId so that we can work with it // Create the answer string nameRequestResponse = ""; if (dbResult == 0) { nameRequestResponse += "0b0f00010000110000000000000000"; nameRequestResponse += StringUtils.bytesToString_NS(handleSize); nameRequestResponse += handleBStr + "00"; } else { newCharID = dbResult; nameRequestResponse += "0b0f0000000000"; nameRequestResponse += StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray((UInt32)dbResult, 1)); nameRequestResponse += "0000000000"; nameRequestResponse += StringUtils.bytesToString_NS(handleSize); nameRequestResponse += handleBStr + "00"; } Output.writeToLogForConsole(nameRequestResponse); sendMarginData(nameRequestResponse, client); }
public void parseCommand(string data) { Output.WriteLine("[Chat Command helper] Chat command is: '" + data + "'"); string[] commands = data.Split(' '); string command = commands[0].ToLower(); try{ if (command.Equals("?fix") && commands.Length > 1) { int maxRPC = int.Parse(commands[1]); for (int i = 0; i < maxRPC; i++) { Store.currentClient.playerData.setRPCCounter((UInt16)i); Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Trying to fix! " + i, Store.currentClient)); } } if (command.Equals("?teleport") && commands.Length == 4) { // parse the coord parameters parameters as int Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().teleport(int.Parse(commands[1]), int.Parse(commands[2]), int.Parse(commands[3])), false); Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Teleported!", Store.currentClient)); } if (command.Equals("?rsi") && commands.Length == 3) { //parse the rsi part and value Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().changeRsi(commands[1], int.Parse(commands[2])), false); Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Rsi changed!", Store.currentClient)); } if (command.StartsWith("?message")) { Output.WriteLine("[COMMAND HELPER]MESSAGE RECEIVED"); byte[] theMessage = PacketsUtils.createSystemMessageWithoutRPC(commands[1]); Store.world.sendRPCToAllPlayers(theMessage); } if (command.Equals("?playanim")) { string animId = commands[1]; if (animId.Length == 4) { ServerPackets pak = new ServerPackets(); pak.sendPlayerAnimation(Store.currentClient, animId); } } if (command.StartsWith("?playfx")) { string fxHEDID = commands[1]; DynamicArray din = new DynamicArray(); byte[] animationId = StringUtils.hexStringToBytes(fxHEDID); byte[] viewID = { 0x02, 0x00 }; Random rand = new Random(); ushort updateViewCounter = (ushort)rand.Next(3, 200); byte[] updateCount = NumericalUtils.uint16ToByteArrayShort(updateViewCounter); Output.WriteLine("Check if its really one byte or two : " + StringUtils.bytesToString(updateCount)); din.append(viewID); din.append(0x02); din.append(0x80); din.append(0x80); din.append(0x80); din.append(0x90); din.append(0xed); din.append(0x00); din.append(0x30); din.append(animationId); din.append(updateCount); Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false); } if (command.Contains("?send")) { // Sends a packet from a file string filename = "packet.txt"; TextReader tr = new StreamReader(filename); string hexContent = tr.ReadToEnd(); hexContent = hexContent.Replace(" ", string.Empty); hexContent = hexContent.Replace(" ", Environment.NewLine); tr.Close(); if (hexContent.Length > 0) { Store.currentClient.messageQueue.addObjectMessage(StringUtils.hexStringToBytes(hexContent), false); Output.writeToLogForConsole("[SENDPACK FROM FILE] Content : " + hexContent); } } if (command.Contains("?combat")) { byte[] dummypak = new byte[4]; TestUnitHandler test = new TestUnitHandler(); test.testCloseCombat(ref dummypak); } if (command.Contains("?mob")) { UInt32[] rsiIDs = new UInt32[10]; rsiIDs[0] = 0xB7010058; rsiIDs[1] = 0x89090058; rsiIDs[2] = 0xB5010058; rsiIDs[3] = 0x3A030008; rsiIDs[4] = 0x32030008; rsiIDs[5] = 0xD0010058; rsiIDs[6] = 0xD4010058; rsiIDs[7] = 0xB8040004; // Smith rsiIDs[8] = 0x92010058; // Seraph rsiIDs[9] = 0x56050004; Random rand = new Random(); int index = rand.Next(0, 9); double x = 0; double y = 0; double z = 0; byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue(); NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z); byte[] xPos = NumericalUtils.floatToByteArray((float)x, 1); byte[] yPos = NumericalUtils.floatToByteArray((float)y, 1); byte[] zPos = NumericalUtils.floatToByteArray((float)z, 1); UInt64 currentEntityId = WorldSocket.entityIdCounter; WorldSocket.entityIdCounter++; uint rotation = 0; npc theMob = new npc(); theMob.setEntityId(currentEntityId); theMob.setDistrict(Convert.ToUInt16(data[0].ToString())); theMob.setDistrictName(Store.currentClient.playerData.getDistrict()); theMob.setName("HD Protector"); theMob.setLevel(255); theMob.setHealthM(UInt16.Parse(data[4].ToString())); theMob.setHealthC(UInt16.Parse(data[5].ToString())); theMob.setMobId((ushort)rsiIDs[index]); theMob.setRsiHex(StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray(rsiIDs[index], 1))); theMob.setXPos(x); theMob.setYPos(y); theMob.setZPos(z); theMob.xBase = x; theMob.yBase = y; theMob.zBase = z; theMob.setRotation(rotation); theMob.setIsDead(false); theMob.setIsLootable(false); WorldSocket.npcs.Add(theMob); // we use this for a test to see if we can spawn mobs and how we can handle them // We refactor this } if (command.Contains("?sendrpc")) { // sends a RPC Packet from a File string filename = "rpcpacket.txt"; TextReader tr = new StreamReader(filename); string hexContent = tr.ReadToEnd(); hexContent = hexContent.Replace(" ", string.Empty); hexContent = hexContent.Replace(" ", Environment.NewLine); Output.Write("SEND RPC COMMAND : CONTENT : " + hexContent); tr.Close(); if (hexContent.Length > 0) { Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(hexContent)); Output.writeToLogForConsole("[SENDRPC FROM FILE] Content : " + hexContent); } } if (command.Contains("?checkrpc")) { DynamicArray din = new DynamicArray(); din.append(StringUtils.hexStringToBytes("2E1000FF7D020024000000310000000000000000000000000000000000000000000000000B0053796E61707A65373737001D004F6E2079656168204920646F2072656D656D62657220796F75203A2900")); Store.currentClient.messageQueue.addRpcMessage(din.getBytes()); } if (command.Contains("?testrpc")) { UInt16 maxRPC = 33279; // Just to reference if (Store.currentClient.playerData.currentTestRPC <= maxRPC) { // Only if it is below we send it - we test with a 5 size packet DynamicArray din = new DynamicArray(); if (Store.currentClient.playerData.currentTestRPC < 127) { din.append(NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.currentTestRPC)); } else { din.append(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.currentTestRPC, 0)); } din.append(0x00); din.append(0x00); din.append(0x00); Store.currentClient.messageQueue.addRpcMessage(din.getBytes()); ServerPackets pak = new ServerPackets(); pak.sendSystemChatMessage(Store.currentClient, "Test RPC Header : " + Store.currentClient.playerData.currentTestRPC.ToString(), "MODAL"); Store.currentClient.playerData.currentTestRPC++; } } if (command.Equals("?save")) { new PlayerHelper().savePlayerInfo(Store.currentClient); ServerPackets pak = new ServerPackets(); pak.sendSaveCharDataMessage(Store.currentClient, StringUtils.charBytesToString_NZ(Store.currentClient.playerInstance.CharacterName.getValue())); } } catch (Exception e) { Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Error parsing command!", Store.currentClient)); Output.WriteLine("[CHAT COMMAND PARSER] Error parsing request: " + data); Output.WriteLine("[CHAT COMMAND PARSER] DEBUG: " + e.Message + "\n" + e.StackTrace); } }
/** * This handles all RPC requests for the client */ public void HandleRpc(int header, ref byte[] rpcData) { ServerPackets pak = new ServerPackets(); pak.sendSystemChatMessage(Store.currentClient, "Handle RPC Client Request Header " + StringUtils.bytesToString_NS(NumericalUtils.int32ToByteArray(header, 0)), "BROADCAST"); switch (header) { case (int)RPCRequestHeader.CLIENT_SPAWN_READY: new PlayerHandler().processSpawn(); new PlayerHandler().processAttributes(); break; case (int)RPCRequestHeader.CLIENT_CLOSE_COMBAT: Output.WriteRpcLog("CLOSE COMBAT REQUEST"); new TestUnitHandler().testCloseCombat(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_LEAVE_COMBAT: break; case (int)RPCRequestHeader.CLIENT_RANGE_COMBAT: Output.WriteRpcLog("RANGE COMBAT REQUEST"); new TestUnitHandler().testCloseCombat(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_CHAT: new ChatHandler().processChat(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_OBJECTINTERACTION_DYNAMIC: new ObjectInteractionHandler().processObjectDynamic(ref rpcData); Output.writeToLogForConsole("RPCMAIN : Handle OBJECTINTERACTION_DYNAMIC"); break; case (int)RPCRequestHeader.CLIENT_OBJECTINTERACTION_STATIC: new ObjectInteractionHandler().processObjectStatic(ref rpcData); Output.writeToLogForConsole("RPCMAIN : Handle OBJECTINTERACTION_STATIC"); break; case (int)RPCRequestHeader.CLIENT_JUMP: Output.writeToLogForConsole("RPCMAIN : Handle JUMP"); //ToDo: Split Jump and Hyperjump //new TestUnitHandler().processHyperJump(ref rpcData); new TestUnitHandler().processHyperJump(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_TARGET: new PlayerHelper().processTargetChange(ref rpcData, Store.currentClient); break; case (int)RPCRequestHeader.CLIENT_MISSION_REQUEST: new MissionHandler().processMissionList(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_INFO: new MissionHandler().processLoadMissionInfo(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_ACCEPT: new MissionHandler().processMissionaccept(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_ABORT: new MissionHandler().processAbortMission(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_PARTY_LEAVE: break; // Team case (int)RPCRequestHeader.CLIENT_HANDLE_MISSION_INVITE: new TeamHandler().processTeamInviteAnswer(ref rpcData); break; // Faction and Crews case (int)RPCRequestHeader.CLIENT_FACTION_INFO: new FCHandler().processLoadFactionName(ref rpcData); // ToDo: implement response with following format : // size + 80 f5 + uint32 factionId + String(40 size? unusual...) // Example: 30 80 f5 11 ba 00 00 48 79 50 6e 30 74 69 5a 65 44 20 4d 69 4e 64 5a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 break; // Abilitys case (int)RPCRequestHeader.CLIENT_UPGRADE_ABILITY_LEVEL: // ToDo: Research and implement^^ break; case (int)RPCRequestHeader.CLIENT_ABILITY_HANDLER: new AbilityHandler().processAbility(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_CHANGE_CT: new PlayerHelper().processUpdateExp(); break; case (int)RPCRequestHeader.CLIENT_ABILITY_LOADER: new PlayerHelper().processLoadAbility(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_HARDLINE_EXIT_LA_CONFIRM: new TeleportHandler().processHardlineExitConfirm(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_READY_WORLDCHANGE: Output.WriteLine("RPCMAIN : RESET_RPC detect"); new TeleportHandler().processTeleportReset(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_TELEPORT_HL: new TeleportHandler().processHardlineTeleport(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_HARDLINE_STATUS_REQUEST: new TeleportHandler().processHardlineStatusRequest(ref rpcData); break; // Inventory case (int)RPCRequestHeader.CLIENT_ITEM_MOVE_SLOT: new InventoryHandler().processItemMove(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_ITEM_RECYCLE: new InventoryHandler().processItemDelete(ref rpcData); break; // Vendor case (int)RPCRequestHeader.CLIENT_VENDOR_BUY: new VendorHandler().processBuyItem(ref rpcData); break; // MarketPlace case (int)RPCRequestHeader.CLIENT_MP_OPEN: new TestUnitHandler().processMarketTest(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MP_LIST_ITEMS: new MarketPlaceHandler().processMarketplaceList(ref rpcData); break; // Command Helper case (int)RPCRequestHeader.CLIENT_CMD_WHEREAMI: new CommandHandler().processWhereamiCommand(ref rpcData); break; // Emote and Mood Helpers case (int)RPCRequestHeader.CLIENT_CHANGE_MOOD: new PlayerHandler().processMood(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_EMOTE: new PlayerHandler().processEmote(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_REGION_LOADED: new RegionHandler().processRegionLoaded(ref rpcData); //new PlayerInitHelper().processRegionSettings(); break; default: //PASS :D byte[] headers = NumericalUtils.int32ToByteArray(header, 1); string message = "RPCMAIN : Unknown Header " + StringUtils.bytesToString_NS(new byte[] { headers[0], headers[1] }) + " \n Content:\n " + StringUtils.bytesToString_NS(rpcData); Output.WriteLine(message); Output.WriteRpcLog(message); break; } }
private void createCharacterRSI(byte[] packet, NetworkStream client) { // Instance the Data Loader DataLoader itemLoader = DataLoader.getInstance(); isNewCreatedChar = true; string debugHexPacket = StringUtils.bytesToString_NS(packet); // ToDo: Replace all with Packet Reader Instance PacketReader reader = new PacketReader(packet); reader.incrementOffsetByValue(3); UInt16 body = 0; UInt16 gender = 0; UInt16 skintone = reader.readUInt16(1); reader.setOffsetOverrideValue(7); UInt16 bodyTypeId = reader.readUInt16(1); reader.setOffsetOverrideValue(15); UInt16 hairId = reader.readUInt16(1); reader.setOffsetOverrideValue(19); UInt16 haircolor = reader.readUInt16(1); reader.setOffsetOverrideValue(23); UInt16 tattoo = reader.readUInt16(1); reader.setOffsetOverrideValue(27); UInt16 headId = reader.readUInt16(1); reader.setOffsetOverrideValue(31); UInt16 facialDetail = reader.readUInt16(1); reader.setOffsetOverrideValue(35); // ToDo: it has a bug - figure out correct position UInt16 facialDetailColor = reader.readUInt16(1); // ToDo: Remove this when facialDetailColor is parsed properly facialDetailColor = 0; reader.setOffsetOverrideValue(67); UInt16 profession = reader.readUInt16(1); // lets read the values // the IDs for the Appeareance is always uint16 goID // Extra Hint: there are no leggins in Char Creation Process reader.setOffsetOverrideValue(35); UInt16 hatId = reader.readUInt16(1); reader.setOffsetOverrideValue(39); UInt16 eyewearId = reader.readUInt16(1); reader.setOffsetOverrideValue(43); UInt16 shirtId = reader.readUInt16(1); reader.setOffsetOverrideValue(47); UInt16 glovesId = reader.readUInt16(1); reader.setOffsetOverrideValue(51); UInt16 outerwearId = reader.readUInt16(1); reader.setOffsetOverrideValue(55); UInt16 pantsId = reader.readUInt16(1); reader.setOffsetOverrideValue(63); UInt16 footwearId = reader.readUInt16(1); // Get Values by "NewRSI" IDs NewRSIItem hairItem = itemLoader.getNewRSIItemByTypeAndID("HAIR", hairId); NewRSIItem bodyItem = itemLoader.getNewRSIItemByTypeAndID("BODY", (ushort)bodyTypeId); NewRSIItem headItem = itemLoader.getNewRSIItemByTypeAndID("HEAD", headId); Store.dbManager.MarginDbHandler.updateRSIValue("body", bodyItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("sex", bodyItem.gender.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("face", headItem.internalId.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("hair", hairItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("haircolor", haircolor.ToString(), newCharID); // ToDo: check if it is correct Store.dbManager.MarginDbHandler.updateRSIValue("tattoo", tattoo.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("facialdetail", facialDetail.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("facialdetailcolor", facialDetailColor.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("skintone", skintone.ToString(), newCharID); // Clothing Items ClothingItem shirt = itemLoader.getItemValues(shirtId); ClothingItem pants = itemLoader.getItemValues(pantsId); ClothingItem outerwear = itemLoader.getItemValues(outerwearId); ClothingItem hat = itemLoader.getItemValues(hatId); ClothingItem eyewear = itemLoader.getItemValues(eyewearId); ClothingItem footwear = itemLoader.getItemValues(footwearId); ClothingItem gloves = itemLoader.getItemValues(glovesId); Store.dbManager.MarginDbHandler.updateRSIValue("hat", hat.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirt", shirt.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirtcolor", shirt.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coat", outerwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coatcolor", outerwear.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pants", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pantscolor", pants.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoes", footwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoecolor", footwear.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glasses", eyewear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glassescolor", eyewear.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("gloves", gloves.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(hatId, 0x61, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(eyewearId, 0x62, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(shirtId, 0x63, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(glovesId, 0x64, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(outerwearId, 0x65, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(pantsId, 0x66, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(footwearId, 0x68, newCharID); // FirstName UInt16 currentOffset = 79; byte[] firstNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, firstNameLenBytes, 0, 2); UInt16 firstNameLen = NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1); currentOffset += 2; byte[] firstNameBytes = new byte[NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, firstNameBytes, 0, firstNameLen - 1); string firstNameString = StringUtils.charBytesToString(firstNameBytes); currentOffset += firstNameLen; // LastName byte[] lastNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, lastNameLenBytes, 0, 2); UInt16 lastNameLen = NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1); currentOffset += 2; byte[] lastNameBytes = new byte[NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, lastNameBytes, 0, lastNameLen - 1); string lastNameString = StringUtils.charBytesToString(lastNameBytes); currentOffset += lastNameLen; // Description byte[] descriptionLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, descriptionLenBytes, 0, 2); UInt16 descriptionLen = NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1); currentOffset += 2; byte[] descriptionBytes = new byte[NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, descriptionBytes, 0, descriptionLen - 1); string descriptionString = StringUtils.charBytesToString(descriptionBytes); currentOffset += lastNameLen; // Update Characters values Store.dbManager.MarginDbHandler.updateCharacter(firstNameString, lastNameString, descriptionString, newCharID); // Add the Basic Abilitys... addStartAbilitys(newCharID); // we have all created - lets load the charData loadCharacter(packet, client, this.newCharID); }
public void loadWorldObjectsDb(string path) { Output.Write("Loading Static Objects from " + path + " - please wait..."); ArrayList staticWorldObjects = loadCSV(path, ','); StaticWorldObject worldObject = null; int linecount = 1; foreach (string[] data in staticWorldObjects) { if (linecount > 1) { //Output.WriteLine("Show Colums for Line : " + linecount.ToString() + " GOID: " + data[1].ToString() + " Name " + data[0].ToString()); worldObject = new StaticWorldObject(); worldObject.metrId = Convert.ToUInt16(data[0]); worldObject.sectorID = Convert.ToUInt16(data[1]); worldObject.mxoId = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes(data[2]), 1); worldObject.staticId = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes(data[3]), 1); worldObject.type = StringUtils.hexStringToBytes(data[4].Substring(0, 4)); worldObject.exterior = Convert.ToBoolean(data[5]); worldObject.pos_x = double.Parse(data[6], CultureInfo.InvariantCulture); worldObject.pos_y = double.Parse(data[7], CultureInfo.InvariantCulture); worldObject.pos_z = double.Parse(data[8], CultureInfo.InvariantCulture); worldObject.rot = double.Parse(data[9], CultureInfo.InvariantCulture); worldObject.quat = data[10]; if (data[3] == "01003039") { Output.writeToLogForConsole("[DEMO DOOR] 01003039, X: " + worldObject.pos_x + ", Y: " + worldObject.pos_y + ", Z: " + worldObject.pos_z + ", ROT: " + worldObject.rot + ", TypeId: " + StringUtils.bytesToString_NS(worldObject.type)); } WorldObjectsDB.Add(worldObject); worldObject = null; } linecount++; } }
public void processOpenDoor(StaticWorldObject door) { UInt16 typeId = NumericalUtils.ByteArrayToUint16(door.type, 1); byte[] masterViewId = { 0x01, 0x00 }; byte[] seperator = { 0xcd, 0xab }; Store.currentClient.playerData.newViewIdCounter++; // It is just for a test Later we will change this to have a List with Views and Object IDs byte[] disarmDifficultyMaybe = { 0x03, 0x84 }; byte[] endViewID = { 0x00, 0x00 }; byte[] spawnCounter = NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter()); Output.WriteLine("[DOOR]POS X : " + door.pos_x.ToString() + " POS Y: " + door.pos_y.ToString() + " POS Z: " + door.pos_z.ToString() + ", TypeId: " + StringUtils.bytesToString_NS(door.type)); switch (typeId) { case 417: case 419: // ToDo: Packet Format for Elevator // 02 03 01 00 // 08 // a3 01 // 6b 01 f0 3d be // cd ab 03 88 00 00 00 00 ff ff 7f 3f 00 00 00 00 f3 04 35 33 // 22 00 00 00 00 40 f4 fb 40 00 00 00 00 00 90 75 40 00 00 00 00 00 40 af 40 ff ff ff ff 19 00 00 // 11 00 01 00 04 61 97 e1 47 f0 bf 2d 44 de 30 35 45 00 00 PacketContent content = new PacketContent(); content.addByteArray(masterViewId); content.addByte(0x08); content.addByteArray(door.type); content.addByteArray(NumericalUtils.uint32ToByteArray(door.mxoId, 1)); content.addByteArray(spawnCounter); // Spawn Object Counter content.addByteArray(seperator); content.addByte(0x03); // Number of Attributes to parse (3) content.addByte(0x88); // GROUP 1 - more groups ON, Attribute 4 (305,Orientation,LTQuaternion,16) SET (10001000) content.addByteArray(StringUtils.hexStringToBytes(door.quat)); // ToDo: replace it later with the real LTQuaternion content.addByte(0x22); // GROUP 2 - more groups OFF, Attribute 2,6 SET (00100010) content.addDoubleLtVector3d(door.pos_x, door.pos_y, door.pos_z); content.addByteArray(new byte[] { 0xff, 0xff, 0xff, 0xff }); content.addByteArray(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.newViewIdCounter, 1)); content.addByteArray(endViewID); content.addByte(0x00); Store.currentClient.messageQueue.addObjectMessage(content.returnFinalPacket(), false); break; case 2506: // ToDo: Packet Format for Elevator break; default: PacketContent contentDefault = new PacketContent(); contentDefault.addByteArray(masterViewId); contentDefault.addByte(0x08); contentDefault.addByteArray(door.type); contentDefault.addByteArray(NumericalUtils.uint32ToByteArray(door.mxoId, 1)); contentDefault.addByteArray(spawnCounter); // Spawn Object Counter contentDefault.addByteArray(seperator); contentDefault.addByteArray(disarmDifficultyMaybe); contentDefault.addByte(0x00); // isZionAligned? contentDefault.addByteArray(StringUtils.hexStringToBytes("0000000000803F000000000000000041")); // ToDo: replace it later with the real values from the object contentDefault.addDoubleLtVector3d(door.pos_x, door.pos_y, door.pos_z); contentDefault.addByteArray(StringUtils.hexStringToBytes("34080000")); contentDefault.addByteArray(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.newViewIdCounter, 1)); contentDefault.addByteArray(endViewID); contentDefault.addByte(0x00); Store.currentClient.messageQueue.addObjectMessage(contentDefault.returnFinalPacket(), false); 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; } }
/** * This handles all RPC requests for the client */ public void HandleRpc(int header, ref byte[] rpcData) { ServerPackets pak = new ServerPackets(); #if DEBUG pak.sendSystemChatMessage(Store.currentClient, "Handle RPC Client Request Header " + StringUtils.bytesToString_NS(NumericalUtils.int32ToByteArray(header, 0)), "BROADCAST"); #endif switch (header) { case (int)RPCRequestHeader.CLIENT_SPAWN_READY: new PlayerHandler().processSpawn(); new PlayerHandler().processAttributes(); break; case (int)RPCRequestHeader.CLIENT_CLOSE_COMBAT: #if DEBUG Output.WriteRpcLog("CLOSE COMBAT REQUEST"); #endif new TestUnitHandler().testCloseCombat(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_LEAVE_COMBAT: break; case (int)RPCRequestHeader.CLIENT_RANGE_COMBAT: #if DEBUG Output.WriteRpcLog("RANGE COMBAT REQUEST"); #endif new TestUnitHandler().testCloseCombat(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_CHAT: new ChatHandler().processChat(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_OBJECTINTERACTION_DYNAMIC: new ObjectInteractionHandler().processObjectDynamic(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_OBJECTINTERACTION_STATIC: new ObjectInteractionHandler().processObjectStatic(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_JUMP_START: //ToDo: Split Jump and Hyperjump new AbilityHandler().processHyperJump(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_JUMP_CANCEL: // ToDo: new AbilityHandler().processHyperJumpCancel(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_TARGET: new PlayerHelper().processTargetChange(ref rpcData, Store.currentClient); break; case (int)RPCRequestHeader.CLIENT_MISSION_INVITE_PLAYER: new MissionHandler().processInvitePlayerToMissionTeam(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_REQUEST: new MissionHandler().processMissionList(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_INFO: new MissionHandler().processLoadMissionInfo(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_ACCEPT: new MissionHandler().processMissionaccept(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MISSION_ABORT: new MissionHandler().processAbortMission(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_PARTY_LEAVE: break; // Team case (int)RPCRequestHeader.CLIENT_HANDLE_MISSION_INVITE: new TeamHandler().processInviteAnswer(ref rpcData); break; // Faction and Crews case (int)RPCRequestHeader.CREW_INVITE_PLAYER: new FCHandler().processInvitePlayerToCrew(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_FACTION_INFO: new FCHandler().processLoadFactionName(ref rpcData); break; // Abilitys case (int)RPCRequestHeader.CLIENT_UPGRADE_ABILITY_LEVEL: // ToDo: Research and implement^^ break; case (int)RPCRequestHeader.CLIENT_ABILITY_HANDLER: new AbilityHandler().processAbility(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_CHANGE_CT: // ToDo: Implement Change of CT break; case (int)RPCRequestHeader.CLIENT_ABILITY_LOADER: new PlayerHelper().processLoadAbility(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_HARDLINE_EXIT_LA_CONFIRM: new TeleportHandler().processHardlineExitConfirm(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_EXIT_GAME_FINISH: new TeleportHandler().processGameFinish(); break; case (int)RPCRequestHeader.CLIENT_READY_WORLDCHANGE: new TeleportHandler().processTeleportReset(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_TELEPORT_HL: new TeleportHandler().processHardlineTeleport(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_HARDLINE_STATUS_REQUEST: new TeleportHandler().processHardlineStatusRequest(ref rpcData); break; // Inventory case (int)RPCRequestHeader.CLIENT_ITEM_MOUNT_RSI: new InventoryHandler().processMountItem(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_ITEM_UNMOUNT_RSI: new InventoryHandler().processUnmountItem(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_ITEM_MOVE_SLOT: new InventoryHandler().processItemMove(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_ITEM_RECYCLE: new InventoryHandler().processItemDelete(ref rpcData); break; // Vendor case (int)RPCRequestHeader.CLIENT_VENDOR_BUY: new VendorHandler().processBuyItem(ref rpcData); break; // MarketPlace case (int)RPCRequestHeader.CLIENT_MP_OPEN: new TestUnitHandler().processMarketTest(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_MP_LIST_ITEMS: new MarketPlaceHandler().processMarketplaceList(ref rpcData); break; // Player case (int)RPCRequestHeader.CLIENT_PLAYER_GET_BACKGROUND: new PlayerHandler().processGetBackgroundRequest(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_PLAYER_SET_BACKGROUND: new PlayerHandler().processSetBackgroundRequest(ref rpcData); break; // Command Helper case (int)RPCRequestHeader.CLIENT_CMD_WHEREAMI: new CommandHandler().processWhereamiCommand(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_CMD_WHO: new CommandHandler().processWhoCommand(ref rpcData); break; // Emote and Mood Helpers case (int)RPCRequestHeader.CLIENT_CHANGE_MOOD: new PlayerHandler().processMood(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_EMOTE: new PlayerHandler().processEmote(ref rpcData); break; case (int)RPCRequestHeader.CLIENT_REGION_LOADED: new RegionHandler().processRegionLoaded(ref rpcData); //new PlayerInitHelper().processRegionSettings(); break; case (int)RPCRequestHeader.CLIENT_LOOT_ACCEPT: new PlayerHandler().processLootAccepted(); break; default: //PASS :D byte[] headers = NumericalUtils.int32ToByteArray(header, 1); #if DEBUG string message = "RPCMAIN : Unknown Header " + StringUtils.bytesToString_NS(new byte[] { headers[0], headers[1] }) + " \n Content:\n " + StringUtils.bytesToString_NS(rpcData); Output.WriteRpcLog(message); #endif break; } }
private void loadCharacter(byte[] packet, NetworkStream client, UInt32 theCharId) { byte[] charIDB = new byte[4]; if (theCharId == 0) { ArrayUtils.copy(packet, 3, charIDB, 0, 4); //Offset for charID is 3 in request uint charId = (uint)NumericalUtils.ByteArrayToUint32(charIDB, 1); // Remove current instances for this character if (Store.margin.isAnotherClientActive(charId) == true) { CharacterAlreadyInUseReply(client); return; } this.newCharID = charId; } charIDB = NumericalUtils.uint32ToByteArray(this.newCharID, 1); //New harcoded sessionID is: ac 53 02 00 //Old is: 28 A9 02 00 string [] marginValues = new string[0x0e]; marginValues[8] = "000b10001e000700000001000800000000000a00000003000d00000000001c0000000100"; marginValues[0xc] = "000e10000000"; marginValues[0xd] = "010f10000000"; // Some Items string itemData = "0170A7000000000010" + "020B8F00000000001803B80200000000001804EE9900000000000005F399000000000000065F0900000000100007C80900000000000008D59D000000000C0009EA040000000000480AD61E0000000000380BF21800000000001C0C66900000000000140DB30400000000001C0E04A80000000018000F3743000000000028108D2200000000002411441A00000000004415808C00000000004462EB0300000000001C63CC5A00000000004464ECB2000000000048651CB3000000000038663E9500000000006868EA0400000000001C"; byte[] inventory = StringUtils.hexStringToBytes(itemData); // Loaded Abilities string loadedAbs = "000032080080070000E400800B0000E002800C00006403800E0000340180110032B400801600322C0080290032D404802B0000DC04802F00322800803000323000803E0001E404804200322005805D0000E800805E0032D000805F00327C01806B00008801806F00001C0580990001280580A40000A40080A60000AC0080AC0000EC0080B00000000180B10000040180B80032240180BB0032300180BC00004C0180C50000A00080D80001EC0480DD00012C0580EA0001E80480F400013005800D01013405801D0101680780200132740580280100E004802C01013805803601018C05803801017805803A01325C0780490100840180520100D8088056010124"; byte[] loadAbilitys = StringUtils.hexStringToBytes(loadedAbs); // Known Abilities string abilityData = "0000320800800100014800800200017C0080030000080280040000140380050001300480060001B40080070000E4008008000018038009000F9400800A0000E002800B0000E002800C00006403800D00009000800E00003401800F00018C00801000006C0080110032B40080120000E402801300001003801400016400801500322004801600322C0080170001AC09801800012C008019000F9400801A0032C401801B00010800801C00018400801D0000F803801E001A3802801F00010400802000006C0280210001240580220032B40980230032640680240001680080250087DF11842600000400802700001C0080280032540480290032D404802A003210"; byte[] knownAbilitiys = StringUtils.hexStringToBytes(abilityData); // Known Hardlines string hardlineData = "0207000000021f000000022300000002240000000225000000022600000002270000000229000000022b000000022f00000002300000000231000000023200000002340000000235000000023600000002370000000238000000023b000000023f000000024000000002410000000243000000024500000002480000000249000000024a000000024b000000024d000000024e000000024f000000025000000002510000000252000000025400000002550000000256000000025700000002580000000259000000025a000000025b000000025c000000025d000000025e000000025f000000026000000002610000000262000000026300000002640000000265000000026600000002670000000269000000026a000000026b000000026c000000026d000000026e000000026f000000027000000002710000000130000000013100000001370000000141000000014500000001480000000149000000014a000000014b000000014c000000014e000000014f0000000150000000015100000001520000000163000000016400000001650000000166000000016700000001680000000169000000016a000000016b000000016d000000016f00000001700000000171000000017200000001730000000174000000017700000001780000000179000000017a000000017b000000017c000000017d000000017e000000017f000000018000000001810000000182000000018300000001840000000185000000018600000001870000000188000000018a000000018b000000018c000000018d000000018e000000019000000001910000000192000000019300000001940000000195000000019600000001970000000198000000019900000003020000000303000000030400000003050000000306000000030700000003080000000309000000030a000000030b000000030c000000030d000000030e000000030f000000031000000003110000000312000000031300000003140000000315000000031600000003170000000318000000"; //string hardlineData = Store.dbManager.MarginDbHandler.loadAllHardlines(); byte[] knownHardlines = StringUtils.hexStringToBytes(hardlineData); // Contacts string missionContacts = "0700000001000800000000000a00000003000d00000000001c0000000100"; byte[] knownContacts = StringUtils.hexStringToBytes(missionContacts); byte[] codeArchiveTest = StringUtils.hexStringToBytes("04000000A7010000AC010000CC010000D1010000D60100001302000019020000650200006602000068020000B4020000B5020000B6020000BB020000BC020000C2020000C4020000D5020000D6020000DE020000E2020000E3020000E6020000E7020000E90200003F03000086030000A0030000AA030000E3030000FC030000FE030000030400000604000008040000090400000A040000270400004C0400004E040000BB040000C2040000CE040000EB040000EC040000EE040000F5040000F6040000F7040000F9040000540900005F09000082090000BE090000BF090000C1090000C4090000C7090000C8090000C9090000040A0000080A0000B0120000"); byte[] empty = new byte[0]; // New Margin Method to send Data // Pre-Load Abilities so that we just need to filter the result later loadAbilities((int)this.newCharID); sendMarginCharData(empty, 0x01, client); sendMarginCharData(loadBackgroundInfo((int)this.newCharID), 0x02, client); sendMarginCharData(empty, 0x03, client); // BuddyList (but old one) sendMarginCharData(empty, 0x04, client); // Unknown - no one has data there so ignore it //sendMarginCharData(loadInventory((int)this.newCharID), 0x05, client); // Inventory sendMarginCharData(StringUtils.hexStringToBytes(itemData), 0x05, client); // Inventory CR1 sendMarginCharData(loadEquippedAbilities(), 0x06, client); // Loaded Abilitys //sendMarginCharData(empty, 0x06, client); // Loaded Abilitys CR1 sendMarginCharData(loadKnownAbilities(), 0x07, client); // Known Abilities sendMarginCharData(knownHardlines, 0x08, client); // Hardlines sendMarginCharData(empty, 0x09, client); // Access Nodes? //sendMarginCharData(codeArchiveTest, 0x0a, client); // Code Storage sendMarginCharData(empty, 0x0a, client); // Code Storage CR1 sendMarginCharData(knownContacts, 0x0b, client); // Contacts sendMarginCharData(empty, 0x0e, client); // ModT (has a seperate format) sendMarginData("1000000000" + StringUtils.bytesToString_NS(charIDB) + "10270d010f10000000", client); /* This is the server MOTD announcement (its disabled now) */ /*DynamicArray announcement = new DynamicArray(); * byte[] header = {0x10,0x00,0x00,0x00,0x00,0xac,0x53,0x02,0x00,0x10,0x27,0x0E,0x01,0x0D,0x10,0x00}; * TimeUtils tim = new TimeUtils(); * byte[] currentTime = tim.getUnixTime(); * //Load motd from file * XmlParser xmlP = new XmlParser(); * string[] data=xmlP.loadDBParams("Config.xml"); * string motd=data[5]; * * if (!motd.Equals("")){ // if MOTD not empty * byte[] text = StringUtils.stringToBytes(motd); * byte[] size = NumericalUtils.uint16ToByteArray((UInt16)(currentTime.Length+text.Length),1); * * announcement.append(header); * announcement.append(size); * announcement.append(currentTime); * announcement.append(text); * * byte[] encryptedResponse14 = marginEncr.encrypt(announcement.getBytes()); * sendTCPVariableLenPacket(encryptedResponse14, client); * }*/ /* End of the MOTD */ //Output.WriteLine("[MARGIN] UserID "+this.userID+" waiting for session reply from world"); //waitForWorldReply(); //TODO: enabling this outputted the "no usage" bug //Output.WriteLine("[MARGIN] World Session Reply OK for UserID "+this.userID); //System.Threading.Thread.Sleep(1000); //EstablishUDPSessionReply(packet, client); }
private void sendMarginCharData(byte[] data, byte opcode, NetworkStream client) { // This Method will be used to send the real Data to the client // Format for general LoadCharacterReply Responses: // 10 00 00 00 <- everytime the same // 00 f9 76 04 <- uint32 Char ID // 00 00 00 09 <- uint32 number of Character Replys (just raise one up) // 00 05 <- viewData opcode (what data is inside) uint16 // 10 00 <- if it has Data it is 10 00 if not is just 00 00 (and no Data can follow up and packet ends here) // e1 00 <- short / uint16 data size // DATA byte[] header = { 0x10, 0x00, 0x00, 0x00 }; // Raise one up loadCharCounter++; // Add the counter byte[] counterByte = new byte[4]; counterByte = NumericalUtils.uint32ToByteArray(loadCharCounter, 1); // get the datasize for the packet byte[] dataSize = NumericalUtils.uint16ToByteArray((UInt16)data.Length, 1); // charId byte[] charID = NumericalUtils.uint32ToByteArray(this.newCharID, 0); // viewData code byte[] responseCode = { 0x00, opcode }; string pakData = StringUtils.bytesToString_NS(header) + StringUtils.bytesToString_NS(charID) + StringUtils.bytesToString_NS(counterByte) + StringUtils.bytesToString_NS(responseCode); string hasData; // this needs improvement... if (data.Length == 0 && opcode == 0x01) { hasData = "0000"; } else { hasData = "1000" + StringUtils.bytesToString_NS(dataSize) + StringUtils.bytesToString_NS(data); } pakData += hasData; PacketContent pak = new PacketContent(); // Dump the Packet Data to see whats in //Console.WriteLine("Response Load Pak : " + pakData); // Do the viewData byte[] response = StringUtils.hexStringToBytes(pakData); Output.WritePacketLog(StringUtils.bytesToString(response), "MARGINSERVER", "0", "0", "0"); Output.WriteDebugLog("[MARGIN SERVER RESPONSE] for OPCODE " + opcode + " : " + StringUtils.bytesToString(response)); byte[] encryptedResponse = marginEncr.encrypt(response); sendTCPVariableLenPacket(encryptedResponse, client); System.Threading.Thread.Sleep(50); }
private void createCharacterRSI(byte[] packet, NetworkStream client) { // Instance the Data Loader DataLoader ItemLoader = DataLoader.getInstance(); isNewCreatedChar = true; string debugHexPacket = StringUtils.bytesToString_NS(packet); // lets read the values // the IDs for the Appeareance is always uint16 goID byte[] bodyTypeIDByte = new byte[4]; byte[] professionByte = new byte[4]; byte[] facialdetailBytes = new byte[4]; byte[] facialdetailColorBytes = new byte[4]; byte[] hairBytes = new byte[4]; byte[] hairColorBytes = new byte[4]; byte[] skintoneBytes = new byte[4]; byte[] tatooBytes = new byte[4]; byte[] headIDBytes = new byte[4]; // Clothing byte[] shirtIDBytes = new byte[4]; byte[] pantsIDBytes = new byte[4]; byte[] outerwearIDBytes = new byte[4]; byte[] hatIDBytes = new byte[4]; byte[] eyewearIDBytes = new byte[4]; byte[] footwearIDBytes = new byte[4]; byte[] glovesIDBytes = new byte[4]; //byte[] legginsIDBytes = new byte[4]; // RSI ArrayUtils.copy(packet, 3, skintoneBytes, 0, 2); // Done! ArrayUtils.copy(packet, 7, bodyTypeIDByte, 0, 2); // Done! ArrayUtils.copy(packet, 15, hairBytes, 0, 2); // Done! ArrayUtils.copy(packet, 19, hairColorBytes, 0, 2); // Done! ArrayUtils.copy(packet, 23, tatooBytes, 0, 2); // Done! ArrayUtils.copy(packet, 27, headIDBytes, 0, 2); ArrayUtils.copy(packet, 31, facialdetailBytes, 0, 2); ArrayUtils.copy(packet, 35, facialdetailColorBytes, 0, 2); ArrayUtils.copy(packet, 67, professionByte, 0, 2); UInt16 body = 0; UInt16 gender = 0; UInt32 bodyTypeId = NumericalUtils.ByteArrayToUint32(bodyTypeIDByte, 1); UInt16 hairId = NumericalUtils.ByteArrayToUint16(hairBytes, 1); UInt16 haircolor = NumericalUtils.ByteArrayToUint16(hairColorBytes, 1); UInt16 tattoo = NumericalUtils.ByteArrayToUint16(tatooBytes, 1); UInt16 facialDetailColor = NumericalUtils.ByteArrayToUint16(facialdetailColorBytes, 1); UInt16 skintone = NumericalUtils.ByteArrayToUint16(skintoneBytes, 1); UInt16 headID = NumericalUtils.ByteArrayToUint16(headIDBytes, 1); // Get Values by "NewRSI" IDs NewRSIItem hairItem = ItemLoader.getNewRSIItemByTypeAndID("HAIR", hairId); NewRSIItem bodyItem = ItemLoader.getNewRSIItemByTypeAndID("BODY", (ushort)bodyTypeId); NewRSIItem headItem = ItemLoader.getNewRSIItemByTypeAndID("HEAD", headID); Store.dbManager.MarginDbHandler.updateRSIValue("body", bodyItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("sex", bodyItem.gender.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("face", headItem.internalId.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("hair", hairItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("haircolor", haircolor.ToString(), newCharID); // ToDo: check if it is correct Store.dbManager.MarginDbHandler.updateRSIValue("tattoo", tattoo.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("facialdetailcolor", facialDetailColor.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("skintone", skintone.ToString(), newCharID); // Clothing Items // ToDo: GLOVES ARE MISSING! ArrayUtils.copy(packet, 43, shirtIDBytes, 0, 2); ArrayUtils.copy(packet, 47, glovesIDBytes, 0, 2); ArrayUtils.copy(packet, 55, pantsIDBytes, 0, 2); ArrayUtils.copy(packet, 51, outerwearIDBytes, 0, 2); ArrayUtils.copy(packet, 34, hatIDBytes, 0, 2); ArrayUtils.copy(packet, 39, eyewearIDBytes, 0, 2); ArrayUtils.copy(packet, 63, footwearIDBytes, 0, 2); ClothingItem shirt = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(shirtIDBytes, 1)); ClothingItem pants = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(pantsIDBytes, 1)); ClothingItem outerwear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(outerwearIDBytes, 1)); ClothingItem hat = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(hatIDBytes, 1)); ClothingItem eyewear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(eyewearIDBytes, 1)); ClothingItem footwear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(footwearIDBytes, 1)); ClothingItem gloves = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(glovesIDBytes, 1)); Store.dbManager.MarginDbHandler.updateRSIValue("hat", hat.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirt", shirt.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirtcolor", shirt.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coat", outerwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coatcolor", outerwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pants", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pantscolor", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoes", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoecolor", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glasses", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glassescolor", pants.getModelId().ToString(), newCharID); // ToDO: Figre out the ITem Slots for "currentlyWearing" Items and add the ITems correctly to the Inventory // FirstName UInt16 currentOffset = 79; byte[] firstNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, firstNameLenBytes, 0, 2); UInt16 firstNameLen = NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1); currentOffset += 2; byte[] firstNameBytes = new byte[NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, firstNameBytes, 0, firstNameLen - 1); string firstNameString = StringUtils.charBytesToString(firstNameBytes); currentOffset += firstNameLen; // LastName byte[] lastNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, lastNameLenBytes, 0, 2); UInt16 lastNameLen = NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1); currentOffset += 2; byte[] lastNameBytes = new byte[NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, lastNameBytes, 0, lastNameLen - 1); string lastNameString = StringUtils.charBytesToString(lastNameBytes); currentOffset += lastNameLen; // Description byte[] descriptionLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, descriptionLenBytes, 0, 2); UInt16 descriptionLen = NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1); currentOffset += 2; byte[] descriptionBytes = new byte[NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, descriptionBytes, 0, descriptionLen - 1); string descriptionString = StringUtils.charBytesToString(descriptionBytes); currentOffset += lastNameLen; // Update Characters values Store.dbManager.MarginDbHandler.updateCharacter(firstNameString, lastNameString, descriptionString, newCharID); // Add the Basic Abilitys... Store.dbManager.MarginDbHandler.addAbility(-2147481600, 0, newCharID, 1, 1); Store.dbManager.MarginDbHandler.addAbility(-2147367936, 1, newCharID, 1, 1); Store.dbManager.MarginDbHandler.addAbility(-2147294208, 2, newCharID, 0, 1); Store.dbManager.MarginDbHandler.addAbility(-2147281920, 3, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147280896, 4, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147437568, 5, newCharID, 1, 1); Store.dbManager.MarginDbHandler.addAbility(-2147425280, 6, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147404800, 7, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147445760, 8, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2146493440, 9, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2146453504, 10, newCharID, 1, 0); // we have all created - lets load the charData loadCharacter(packet, client, this.newCharID); }