How to use getU8 method in wpt

Best JavaScript code snippet using wpt

protocolgame.ts

Source:protocolgame.ts Github

copy

Full Screen

...94 let opcode: number = -1;95 let prevOpcode: number = -1;96 try {97 while (msg.getUnreadSize() > 0) {98 opcode = msg.getU8();99 if (!g_game.getFeature(GameFeature.GameLoginPending)) {100 if (!this.m_gameInitialized && opcode > Proto.GameServerFirstGameOpcode) {101 g_game.processGameStart();102 this.m_gameInitialized = true;103 }104 }105 /*106 // try to parse in lua first107 int readPos = msg.getReadPos();108 if(callLuaField<bool>("onOpcode", opcode, msg))109 continue;110 else111 msg.setReadPos(readPos); // restore read pos112 */113 switch (opcode) {114 case Proto.GameServerLoginOrPendingState:115 /*116 if(g_game.getFeature(GameFeature.GameLoginPending))117 this.parsePendingGame(msg);118 else119 */120 this.parseLogin(msg);121 break;122 case Proto.GameServerGMActions:123 this.parseGMActions(msg);124 break;125 case Proto.GameServerUpdateNeeded:126 this.parseUpdateNeeded(msg);127 break;128 case Proto.GameServerLoginError:129 this.parseLoginError(msg);130 break;131 case Proto.GameServerLoginAdvice:132 this.parseLoginAdvice(msg);133 break;134 case Proto.GameServerLoginWait:135 this.parseLoginWait(msg);136 break;137 case Proto.GameServerLoginToken:138 this.parseLoginToken(msg);139 break;140 case Proto.GameServerPing:141 case Proto.GameServerPingBack:142 if ((opcode == Proto.GameServerPing && g_game.getFeature(GameFeature.GameClientPing)) ||143 (opcode == Proto.GameServerPingBack && !g_game.getFeature(GameFeature.GameClientPing)))144 this.parsePingBack(msg);145 else146 this.parsePing(msg);147 break;148 case Proto.GameServerChallenge:149 this.parseChallenge(msg);150 break;151 case Proto.GameServerDeath:152 this.parseDeath(msg);153 break;154 case Proto.GameServerFullMap:155 this.parseMapDescription(msg);156 break;157 case Proto.GameServerMapTopRow:158 this.parseMapMoveNorth(msg);159 break;160 case Proto.GameServerMapRightRow:161 this.parseMapMoveEast(msg);162 break;163 case Proto.GameServerMapBottomRow:164 this.parseMapMoveSouth(msg);165 break;166 case Proto.GameServerMapLeftRow:167 this.parseMapMoveWest(msg);168 break;169 case Proto.GameServerUpdateTile:170 this.parseUpdateTile(msg);171 break;172 case Proto.GameServerCreateOnMap:173 this.parseTileAddThing(msg);174 break;175 case Proto.GameServerChangeOnMap:176 this.parseTileTransformThing(msg);177 break;178 case Proto.GameServerDeleteOnMap:179 this.parseTileRemoveThing(msg);180 break;181 case Proto.GameServerMoveCreature:182 this.parseCreatureMove(msg);183 break;184 case Proto.GameServerOpenContainer:185 this.parseOpenContainer(msg);186 break;187 case Proto.GameServerCloseContainer:188 this.parseCloseContainer(msg);189 break;190 case Proto.GameServerCreateContainer:191 this.parseContainerAddItem(msg);192 break;193 case Proto.GameServerChangeInContainer:194 this.parseContainerUpdateItem(msg);195 break;196 case Proto.GameServerDeleteInContainer:197 this.parseContainerRemoveItem(msg);198 break;199 case Proto.GameServerSetInventory:200 this.parseAddInventoryItem(msg);201 break;202 case Proto.GameServerDeleteInventory:203 this.parseRemoveInventoryItem(msg);204 break;205 case Proto.GameServerOpenNpcTrade:206 this.parseOpenNpcTrade(msg);207 break;208 case Proto.GameServerPlayerGoods:209 this.parsePlayerGoods(msg);210 break;211 case Proto.GameServerCloseNpcTrade:212 this.parseCloseNpcTrade(msg);213 break;214 case Proto.GameServerOwnTrade:215 this.parseOwnTrade(msg);216 break;217 case Proto.GameServerCounterTrade:218 this.parseCounterTrade(msg);219 break;220 case Proto.GameServerCloseTrade:221 this.parseCloseTrade(msg);222 break;223 case Proto.GameServerAmbient:224 this.parseWorldLight(msg);225 break;226 case Proto.GameServerGraphicalEffect:227 this.parseMagicEffect(msg);228 break;229 case Proto.GameServerTextEffect:230 this.parseAnimatedText(msg);231 break;232 case Proto.GameServerMissleEffect:233 this.parseDistanceMissile(msg);234 break;235 case Proto.GameServerMarkCreature:236 this.parseCreatureMark(msg);237 break;238 case Proto.GameServerTrappers:239 this.parseTrappers(msg);240 break;241 case Proto.GameServerCreatureHealth:242 this.parseCreatureHealth(msg);243 break;244 case Proto.GameServerCreatureLight:245 this.parseCreatureLight(msg);246 break;247 case Proto.GameServerCreatureOutfit:248 this.parseCreatureOutfit(msg);249 break;250 case Proto.GameServerCreatureSpeed:251 this.parseCreatureSpeed(msg);252 break;253 case Proto.GameServerCreatureSkull:254 this.parseCreatureSkulls(msg);255 break;256 case Proto.GameServerCreatureParty:257 this.parseCreatureShields(msg);258 break;259 case Proto.GameServerCreatureUnpass:260 this.parseCreatureUnpass(msg);261 break;262 case Proto.GameServerEditText:263 this.parseEditText(msg);264 break;265 case Proto.GameServerEditList:266 this.parseEditList(msg);267 break;268 // PROTOCOL>=1038269 case Proto.GameServerPremiumTrigger:270 this.parsePremiumTrigger(msg);271 break;272 case Proto.GameServerPlayerData:273 this.parsePlayerStats(msg);274 break;275 case Proto.GameServerPlayerSkills:276 this.parsePlayerSkills(msg);277 break;278 case Proto.GameServerPlayerState:279 this.parsePlayerState(msg);280 break;281 case Proto.GameServerClearTarget:282 this.parsePlayerCancelAttack(msg);283 break;284 case Proto.GameServerPlayerModes:285 this.parsePlayerModes(msg);286 break;287 case Proto.GameServerTalk:288 this.parseTalk(msg);289 break;290 case Proto.GameServerChannels:291 this.parseChannelList(msg);292 break;293 case Proto.GameServerOpenChannel:294 this.parseOpenChannel(msg);295 break;296 case Proto.GameServerOpenPrivateChannel:297 this.parseOpenPrivateChannel(msg);298 break;299 case Proto.GameServerRuleViolationChannel:300 this.parseRuleViolationChannel(msg);301 break;302 case Proto.GameServerRuleViolationRemove:303 this.parseRuleViolationRemove(msg);304 break;305 case Proto.GameServerRuleViolationCancel:306 this.parseRuleViolationCancel(msg);307 break;308 case Proto.GameServerRuleViolationLock:309 this.parseRuleViolationLock(msg);310 break;311 case Proto.GameServerOpenOwnChannel:312 this.parseOpenOwnPrivateChannel(msg);313 break;314 case Proto.GameServerCloseChannel:315 this.parseCloseChannel(msg);316 break;317 case Proto.GameServerTextMessage:318 this.parseTextMessage(msg);319 break;320 case Proto.GameServerCancelWalk:321 this.parseCancelWalk(msg);322 break;323 case Proto.GameServerWalkWait:324 this.parseWalkWait(msg);325 break;326 case Proto.GameServerFloorChangeUp:327 this.parseFloorChangeUp(msg);328 break;329 case Proto.GameServerFloorChangeDown:330 this.parseFloorChangeDown(msg);331 break;332 case Proto.GameServerChooseOutfit:333 this.parseOpenOutfitWindow(msg);334 break;335 case Proto.GameServerVipAdd:336 this.parseVipAdd(msg);337 break;338 case Proto.GameServerVipState:339 this.parseVipState(msg);340 break;341 case Proto.GameServerVipLogout:342 this.parseVipLogout(msg);343 break;344 case Proto.GameServerTutorialHint:345 this.parseTutorialHint(msg);346 break;347 case Proto.GameServerAutomapFlag:348 this.parseAutomapFlag(msg);349 break;350 case Proto.GameServerQuestLog:351 this.parseQuestLog(msg);352 break;353 case Proto.GameServerQuestLine:354 this.parseQuestLine(msg);355 break;356 // PROTOCOL>=870357 case Proto.GameServerSpellDelay:358 this.parseSpellCooldown(msg);359 break;360 case Proto.GameServerSpellGroupDelay:361 this.parseSpellGroupCooldown(msg);362 break;363 case Proto.GameServerMultiUseDelay:364 this.parseMultiUseCooldown(msg);365 break;366 // PROTOCOL>=910367 case Proto.GameServerChannelEvent:368 this.parseChannelEvent(msg);369 break;370 case Proto.GameServerItemInfo:371 this.parseItemInfo(msg);372 break;373 case Proto.GameServerPlayerInventory:374 this.parsePlayerInventory(msg);375 break;376 // PROTOCOL>=950377 case Proto.GameServerPlayerDataBasic:378 this.parsePlayerInfo(msg);379 break;380 // PROTOCOL>=970381 case Proto.GameServerModalDialog:382 this.parseModalDialog(msg);383 break;384 // PROTOCOL>=980385 case Proto.GameServerLoginSuccess:386 this.parseLogin(msg);387 break;388 case Proto.GameServerEnterGame:389 this.parseEnterGame(msg);390 break;391 case Proto.GameServerPlayerHelpers:392 this.parsePlayerHelpers(msg);393 break;394 // PROTOCOL>=1000395 case Proto.GameServerCreatureMarks:396 this.parseCreaturesMark(msg);397 break;398 case Proto.GameServerCreatureType:399 this.parseCreatureType(msg);400 break;401 // PROTOCOL>=1055402 case Proto.GameServerBlessings:403 this.parseBlessings(msg);404 break;405 case Proto.GameServerUnjustifiedStats:406 this.parseUnjustifiedStats(msg);407 break;408 case Proto.GameServerPvpSituations:409 this.parsePvpSituations(msg);410 break;411 case Proto.GameServerPreset:412 this.parsePreset(msg);413 break;414 // PROTOCOL>=1080415 case Proto.GameServerCoinBalanceUpdating:416 this.parseCoinBalanceUpdating(msg);417 break;418 case Proto.GameServerCoinBalance:419 this.parseCoinBalance(msg);420 break;421 case Proto.GameServerRequestPurchaseData:422 this.parseRequestPurchaseData(msg);423 break;424 case Proto.GameServerStoreCompletePurchase:425 this.parseCompleteStorePurchase(msg);426 break;427 case Proto.GameServerStoreOffers:428 this.parseStoreOffers(msg);429 break;430 case Proto.GameServerStoreTransactionHistory:431 this.parseStoreTransactionHistory(msg);432 break;433 case Proto.GameServerStoreError:434 this.parseStoreError(msg);435 break;436 case Proto.GameServerStore:437 this.parseStore(msg);438 break;439 // PROTOCOL>=1097440 case Proto.GameServerStoreButtonIndicators:441 this.parseStoreButtonIndicators(msg);442 break;443 case Proto.GameServerSetStoreDeepLink:444 this.parseSetStoreDeepLink(msg);445 break;446 // otclient ONLY447 case Proto.GameServerExtendedOpcode:448 this.parseExtendedOpcode(msg);449 break;450 case Proto.GameServerChangeMapAwareRange:451 this.parseChangeMapAwareRange(msg);452 break;453 default:454 error("unhandled opcode %d", opcode);455 break;456 }457 prevOpcode = opcode;458 }459 }460 catch (e) {461 error("ProtocolGame parse message exception (%d bytes unread, last opcode is %d, prev opcode is %d): %s",462 msg.getUnreadSize(), opcode, prevOpcode, e);463 }464 }465 466 sendPingBack() {467 console.log('sendPingBack');468 let msg = new OutputMessage();469 msg.addU8(Proto.ClientPingBack);470 this.send(msg)471 }472 parseLogin(msg: InputMessage)473{474 let playerId = msg.getU32();475 let serverBeat = msg.getU16();476let canReportBugs = msg.getU8();477if(g_game.getClientVersion() >= 1054)478 msg.getU8(); // can change pvp frame option479if(g_game.getClientVersion() >= 1058) {480 let expertModeEnabled = msg.getU8();481 g_game.setExpertPvpMode(expertModeEnabled);482}483if(g_game.getFeature(GameFeature.GameIngameStore)) {484 // URL to ingame store images485 msg.getString();486 // premium coin package size487 // e.g you can only buy packs of 25, 50, 75, .. coins in the market488 msg.getU16();489}490this.m_localPlayer.setId(playerId);491g_game.setServerBeat(serverBeat);492g_game.setCanReportBugs(canReportBugs);493g_game.processLogin();494}495parsePendingGame(msg: InputMessage)496{497 //set player to pending game state498 g_game.processPendingGame();499}500parseEnterGame(msg: InputMessage)501{502 //set player to entered game state503 g_game.processEnterGame();504 if(!this.m_gameInitialized) {505 g_game.processGameStart();506 this.m_gameInitialized = true;507 }508}509parseStoreButtonIndicators(msg: InputMessage)510{511 msg.getU8(); // unknown512 msg.getU8(); // unknown513}514parseSetStoreDeepLink(msg: InputMessage)515{516 let currentlyFeaturedServiceType = msg.getU8();517}518parseBlessings(msg: InputMessage)519{520 let blessings = msg.getU16();521 this.m_localPlayer.setBlessings(blessings);522}523parsePreset(msg: InputMessage)524{525 let preset = msg.getU32();526}527parseRequestPurchaseData(msg: InputMessage)528{529 let transactionId = msg.getU32();530 let productType = msg.getU8();531}532parseStore(msg: InputMessage)533{534 this.parseCoinBalance(msg);535 // Parse all categories536 let count = msg.getU16();537 for(let i = 0; i < count; i++) {538 let category = msg.getString();539 let description = msg.getString();540 let highlightState = 0;541 if(g_game.getFeature(GameFeature.GameIngameStoreHighlights))542 highlightState = msg.getU8();543 let icons = [];544 let iconCount = msg.getU8();545 for(let i = 0; i < iconCount; i++) {546 let icon = msg.getString();547 icons.push(icon);548 }549 // If this is a valid category name then550 // the category we just parsed is a child of that551 let parentCategory = msg.getString();552}553}554parseCoinBalance(msg: InputMessage)555{556 let update = msg.getU8() == 1;557 let coins = -1;558 let transferableCoins = -1;559 if(update) {560 // amount of coins that can be used to buy prodcuts561 // in the ingame store562 coins = msg.getU32();563 // amount of coins that can be sold in market564 // or be transfered to another player565 transferableCoins = msg.getU32();566 }567}568parseCoinBalanceUpdating(msg: InputMessage)569{570 // coin balance can be updating and might not be accurate571 let isUpdating = msg.getU8() == 1;572}573parseCompleteStorePurchase(msg: InputMessage)574{575 // not used576 msg.getU8();577 let message = msg.getString();578 let coins = msg.getU32();579 let transferableCoins = msg.getU32();580 log("Purchase Complete: %s", message);581}582parseStoreTransactionHistory(msg: InputMessage)583{584 let currentPage;585 if(g_game.getClientVersion() <= 1096) {586 currentPage = msg.getU16();587 let hasNextPage = msg.getU8() == 1;588 } else {589 currentPage = msg.getU32();590 let pageCount = msg.getU32();591 }592let entries = msg.getU8();593 for(let i = 0; i < entries; i++) {594 let time = msg.getU16();595 let productType = msg.getU8();596 let coinChange = msg.getU32();597 let productName = msg.getString();598 log("Time %i, type %i, change %i, product name %s", time, productType, coinChange, productName);599}600}601parseStoreOffers(msg: InputMessage)602{603 let categoryName = msg.getString();604 let offers = msg.getU16();605 for(let i = 0; i < offers; i++) {606 let offerId = msg.getU32();607 let offerName = msg.getString();608 let offerDescription = msg.getString();609 let price = msg.getU32();610 let highlightState = msg.getU8();611 if(highlightState == 2 && g_game.getFeature(GameFeature.GameIngameStoreHighlights) && g_game.getClientVersion() >= 1097) {612 let saleValidUntilTimestamp = msg.getU32();613 let basePrice = msg.getU32();614 }615 let disabledState = msg.getU8();616 let disabledReason = "";617 if(g_game.getFeature(GameFeature.GameIngameStoreHighlights) && disabledState == 1) {618 disabledReason = msg.getString();619 }620 let icons = msg.getU8();621 for(let j = 0; j < icons; j++) {622 let icon = msg.getString();623 }624 let subOffers = msg.getU16();625 for(let j = 0; j < subOffers; j++) {626 let name = msg.getString();627 let description = msg.getString();628 let subIcons = msg.getU8();629 for(let k = 0; k < subIcons; k++) {630 let icon = msg.getString();631 }632 let serviceType = msg.getString();633 }634}635}636parseStoreError(msg: InputMessage)637{638 let errorType = msg.getU8();639 let message = msg.getString();640 error("Store Error: %s [%i]", message, errorType);641}642parseUnjustifiedStats(msg: InputMessage)643{644 let unjustifiedPoints: UnjustifiedPoints;645 unjustifiedPoints.killsDay = msg.getU8();646 unjustifiedPoints.killsDayRemaining = msg.getU8();647 unjustifiedPoints.killsWeek = msg.getU8();648 unjustifiedPoints.killsWeekRemaining = msg.getU8();649 unjustifiedPoints.killsMonth = msg.getU8();650 unjustifiedPoints.killsMonthRemaining = msg.getU8();651 unjustifiedPoints.skullTime = msg.getU8();652 g_game.setUnjustifiedPoints(unjustifiedPoints);653}654parsePvpSituations(msg: InputMessage)655{656 let openPvpSituations = msg.getU8();657 g_game.setOpenPvpSituations(openPvpSituations);658}659parsePlayerHelpers(msg: InputMessage)660{661 let id = msg.getU32();662 let helpers = msg.getU16();663 let creature = g_map.getCreatureById(id);664 if(creature)665 g_game.processPlayerHelpers(helpers);666 else667 error("could not get creature with id %d", id);668}669parseGMActions(msg: InputMessage)670{671 let actions: number[];672 let numViolationReasons;673 if(g_game.getClientVersion() >= 850)674 numViolationReasons = 20;675 else if(g_game.getClientVersion() >= 840)676 numViolationReasons = 23;677 else678 numViolationReasons = 32;679 for(let i = 0; i < numViolationReasons; ++i)680 actions.push(msg.getU8());681 g_game.processGMActions(actions);682}683parseUpdateNeeded(msg: InputMessage)684{685 let signature = msg.getString();686 g_game.processUpdateNeeded(signature);687}688parseLoginError(msg: InputMessage)689{690 let error = msg.getString();691 g_game.processLoginError(error);692}693parseLoginAdvice(msg: InputMessage)694{695 let message = msg.getString();696 g_game.processLoginAdvice(message);697}698parseLoginWait(msg: InputMessage)699{700 let message = msg.getString();701 let time = msg.getU8();702 g_game.processLoginWait(message, time);703}704parseLoginToken(msg: InputMessage)705{706 let unknown = (msg.getU8() == 0);707 g_game.processLoginToken(unknown);708}709parsePing(msg: InputMessage): void {710 this.sendPingBack();711}712parsePingBack(msg: InputMessage)713{714 g_game.processPingBack();715}716parseChallenge(msg: InputMessage): void {717 let timestamp = msg.getU32();718let random = msg.getU8();719this.sendLoginPacket(timestamp, random);720}721parseDeath(msg: InputMessage)722{723 let penality = 100;724 let deathType = DeathType.DeathRegular;725 if(g_game.getFeature(GameFeature.GameDeathType))726 deathType = msg.getU8();727 if(g_game.getFeature(GameFeature.GamePenalityOnDeath) && deathType == DeathType.DeathRegular)728 penality = msg.getU8();729 g_game.processDeath(deathType, penality);730}731parseMapDescription(msg: InputMessage)732{733 let pos = this.getPosition(msg);734 if(!this.m_mapKnown)735 this.m_localPlayer.setPosition(pos);736 g_map.setCentralPosition(pos);737 let range = g_map.getAwareRange();738 this.setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, range.horizontal(), range.vertical());739 if(!this.m_mapKnown) {740 this.m_mapKnown = true;741 }742 //g_dispatcher.addEvent([] { g_lua.callGlobalField("g_game", "onMapDescription"); });743}744parseMapMoveNorth(msg: InputMessage)745{746 let pos: Position;747 if(g_game.getFeature(GameFeature.GameMapMovePosition))748 pos = this.getPosition(msg);749else750 pos = g_map.getCentralPosition();751 pos.y--;752 let range = g_map.getAwareRange();753 this.setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, range.horizontal(), 1);754 g_map.setCentralPosition(pos);755}756parseMapMoveEast(msg: InputMessage)757{758 let pos: Position;759 if(g_game.getFeature(GameFeature.GameMapMovePosition))760 pos = this.getPosition(msg);761else762 pos = g_map.getCentralPosition();763 pos.x++;764 let range = g_map.getAwareRange();765 this.setMapDescription(msg, pos.x + range.right, pos.y - range.top, pos.z, 1, range.vertical());766 g_map.setCentralPosition(pos);767}768parseMapMoveSouth(msg: InputMessage)769{770 let pos: Position;771 if(g_game.getFeature(GameFeature.GameMapMovePosition))772 pos = this.getPosition(msg);773else774 pos = g_map.getCentralPosition();775 pos.y++;776 let range = g_map.getAwareRange();777 this.setMapDescription(msg, pos.x - range.left, pos.y + range.bottom, pos.z, range.horizontal(), 1);778 g_map.setCentralPosition(pos);779}780parseMapMoveWest(msg: InputMessage)781{782 let pos: Position;783 if(g_game.getFeature(GameFeature.GameMapMovePosition))784 pos = this.getPosition(msg);785else786 pos = g_map.getCentralPosition();787 pos.x--;788 let range = g_map.getAwareRange();789 this.setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, 1, range.vertical());790 g_map.setCentralPosition(pos);791}792parseUpdateTile(msg: InputMessage)793{794 let tilePos = this.getPosition(msg);795 this.setTileDescription(msg, tilePos);796}797parseTileAddThing(msg: InputMessage)798{799 let pos = this.getPosition(msg);800 let stackPos = -1;801 if(g_game.getClientVersion() >= 841)802 stackPos = msg.getU8();803 let thing = this.getThing(msg);804 g_map.addThing(thing, pos, stackPos);805}806parseTileTransformThing(msg: InputMessage)807{808 let thing = this.getMappedThing(msg);809 let newThing = this.getThing(msg);810 if(!thing) {811 error("no thing");812 return;813 }814 let pos = thing.getPosition();815 let stackpos = thing.getStackPos();816 if(!g_map.removeThing(thing)) {817 error("unable to remove thing");818 return;819 }820 g_map.addThing(newThing, pos, stackpos);821}822parseTileRemoveThing(msg: InputMessage)823{824 let thing = this.getMappedThing(msg);825 if(!thing) {826 error("no thing");827 return;828 }829 if(!g_map.removeThing(thing))830 error("unable to remove thing");831}832parseCreatureMove(msg: InputMessage)833{834 let thing = this.getMappedThing(msg);835 let newPos = this.getPosition(msg);836 if(!thing || !thing.isCreature()) {837 error("no creature found to move");838 return;839}840 if(!g_map.removeThing(thing)) {841 error("unable to remove creature");842 return;843 }844 let creature = <Creature> thing;845 creature.allowAppearWalk();846 g_map.addThing(thing, newPos, -1);847}848parseOpenContainer(msg: InputMessage)849{850 let containerId = msg.getU8();851 let containerItem = this.getItem(msg);852 let name = msg.getString();853 let capacity = msg.getU8();854 let hasParent = (msg.getU8() != 0);855 let isUnlocked = true;856 let hasPages = false;857 let containerSize = 0;858 let firstIndex = 0;859 if(g_game.getFeature(GameFeature.GameContainerPagination)) {860 isUnlocked = (msg.getU8() != 0); // drag and drop861 hasPages = (msg.getU8() != 0); // pagination862 containerSize = msg.getU16(); // container size863 firstIndex = msg.getU16(); // first index864}865 let itemCount = msg.getU8();866 let items: Item[] = [];867 for(let i = 0; i < itemCount; i++)868 items[i] = this.getItem(msg);869 g_game.processOpenContainer(containerId, containerItem, name, capacity, hasParent, items, isUnlocked, hasPages, containerSize, firstIndex);870}871parseCloseContainer(msg: InputMessage)872{873 let containerId = msg.getU8();874 g_game.processCloseContainer(containerId);875}876parseContainerAddItem(msg: InputMessage)877{878 let containerId = msg.getU8();879 let slot = 0;880 if(g_game.getFeature(GameFeature.GameContainerPagination)) {881 slot = msg.getU16(); // slot882 }883 let item = this.getItem(msg);884 g_game.processContainerAddItem(containerId, item, slot);885}886parseContainerUpdateItem(msg: InputMessage)887{888 let containerId = msg.getU8();889 let slot;890 if(g_game.getFeature(GameFeature.GameContainerPagination)) {891 slot = msg.getU16();892 } else {893 slot = msg.getU8();894 }895 let item = this.getItem(msg);896 g_game.processContainerUpdateItem(containerId, slot, item);897}898parseContainerRemoveItem(msg: InputMessage)899{900 let containerId = msg.getU8();901 let slot;902 let lastItem;903 if(g_game.getFeature(GameFeature.GameContainerPagination)) {904 slot = msg.getU16();905 let itemId = msg.getU16();906 if(itemId != 0)907 lastItem = this.getItem(msg, itemId);908} else {909 slot = msg.getU8();910}911 g_game.processContainerRemoveItem(containerId, slot, lastItem);912}913parseAddInventoryItem(msg: InputMessage)914{915 let slot = msg.getU8();916 let item = this.getItem(msg);917 g_game.processInventoryChange(slot, item);918}919parseRemoveInventoryItem(msg: InputMessage)920{921 let slot = msg.getU8();922 g_game.processInventoryChange(slot, new Item());923}924parseOpenNpcTrade(msg: InputMessage)925{926 let items = [];927 let npcName;928 if(g_game.getFeature(GameFeature.GameNameOnNpcTrade))929 npcName = msg.getString();930 let listCount;931 if(g_game.getClientVersion() >= 900)932 listCount = msg.getU16();933 else934 listCount = msg.getU8();935 for(let i = 0; i < listCount; ++i) {936 let itemId = msg.getU16();937 let count = msg.getU8();938 let item = new Item(itemId);939 item.setCountOrSubType(count);940 let name = msg.getString();941 let weight = msg.getU32();942 let buyPrice = msg.getU32();943 let sellPrice = msg.getU32();944 items.push([item, name, weight, buyPrice, sellPrice]);945}946 g_game.processOpenNpcTrade(items);947}948parsePlayerGoods(msg: InputMessage)949{950 let goods = [];951 let money;952 if(g_game.getClientVersion() >= 973)953 money = msg.getU64();954 else955 money = msg.getU32();956 let size = msg.getU8();957 for(let i = 0; i < size; i++) {958 let itemId = msg.getU16();959 let amount;960 if(g_game.getFeature(GameFeature.GameDoubleShopSellAmount))961 amount = msg.getU16();962 else963 amount = msg.getU8();964 goods.push([new Item(itemId), amount]);965 }966 g_game.processPlayerGoods(money, goods);967}968parseCloseNpcTrade(msg: InputMessage)969{970 g_game.processCloseNpcTrade();971}972parseOwnTrade(msg: InputMessage)973{974 let name = g_game.formatCreatureName(msg.getString());975 let count = msg.getU8();976 let items: Item[] = [];977 for(let i = 0; i < count; i++)978 items[i] = this.getItem(msg);979 g_game.processOwnTrade(name, items);980}981parseCounterTrade(msg: InputMessage)982{983 let name = g_game.formatCreatureName(msg.getString());984 let count = msg.getU8();985 let items: Item[] = [];986 for(let i = 0; i < count; i++)987 items[i] = this.getItem(msg);988 g_game.processCounterTrade(name, items);989}990parseCloseTrade(msg: InputMessage)991{992 g_game.processCloseTrade();993}994parseWorldLight(msg: InputMessage)995{996 let light = new Light();997 light.intensity = msg.getU8();998 light.color = msg.getU8();999 g_map.setLight(light);1000}1001parseMagicEffect(msg: InputMessage)1002{1003 let pos = this.getPosition(msg);1004 let effectId;1005 if(g_game.getFeature(GameFeature.GameMagicEffectU16))1006 effectId = msg.getU16();1007 else1008 effectId = msg.getU8();1009 if(!g_things.isValidDatId(effectId, ThingCategory.ThingCategoryEffect)) {1010 error("invalid effect id %d", effectId);1011 return;1012 }1013 let effect = new Effect();1014 effect.setId(effectId);1015 g_map.addThing(effect, pos);1016}1017parseAnimatedText(msg: InputMessage)1018{1019 let position: Position = this.getPosition(msg);1020 let color = msg.getU8();1021 let text = msg.getString();1022 let animatedText = new AnimatedText();1023 animatedText.setColor(color);1024 animatedText.setText(text);1025 g_map.addThing(animatedText, position);1026}1027parseDistanceMissile(msg: InputMessage)1028{1029 let fromPos = this.getPosition(msg);1030 let toPos = this.getPosition(msg);1031 let shotId = msg.getU8();1032 if(!g_things.isValidDatId(shotId, ThingCategory.ThingCategoryMissile)) {1033 error("invalid missile id %d", shotId);1034 return;1035 }1036 let missile = new Missile();1037 missile.setId(shotId);1038 missile.setPath(fromPos, toPos);1039 g_map.addThing(missile, fromPos);1040}1041parseCreatureMark(msg: InputMessage)1042{1043 let id = msg.getU32();1044 let color = msg.getU8();1045 let creature = g_map.getCreatureById(id);1046 if(creature)1047 creature.addTimedSquare(color);1048 else1049 error("could not get creature");1050}1051parseTrappers(msg: InputMessage)1052{1053 let numTrappers = msg.getU8();1054 if(numTrappers > 8)1055 error("too many trappers");1056 for(let i=0;i<numTrappers;++i) {1057 let id = msg.getU32();1058 let creature = g_map.getCreatureById(id);1059 if(creature) {1060 //TODO: set creature as trapper1061 } else1062 error("could not get creature");1063}1064}1065parseCreatureHealth(msg: InputMessage)1066{1067 let id = msg.getU32();1068 let healthPercent = msg.getU8();1069 let creature = g_map.getCreatureById(id);1070 if(creature)1071 creature.setHealthPercent(healthPercent);1072 // some servers has a bug in get spectators and sends unknown creatures updates1073 // so this code is disabled1074 /*1075 else1076 g_logger.traceError("could not get creature");1077 */1078}1079parseCreatureLight(msg: InputMessage)1080{1081 let id = msg.getU32();1082 let light = new Light();1083 light.intensity = msg.getU8();1084 light.color = msg.getU8();1085 let creature = g_map.getCreatureById(id);1086 if(creature)1087 creature.setLight(light);1088 else1089 error("could not get creature");1090}1091parseCreatureOutfit(msg: InputMessage)1092{1093 let id = msg.getU32();1094 let outfit = this.getOutfit(msg);1095 let creature = g_map.getCreatureById(id);1096 if(creature)1097 creature.setOutfit(outfit);1098 else1099 error("could not get creature");1100}1101parseCreatureSpeed(msg: InputMessage)1102{1103 let id = msg.getU32();1104 let baseSpeed = -1;1105 if(g_game.getClientVersion() >= 1059)1106 baseSpeed = msg.getU16();1107 let speed = msg.getU16();1108 let creature = g_map.getCreatureById(id);1109 if(creature) {1110 creature.setSpeed(speed);1111 if(baseSpeed != -1)1112 creature.setBaseSpeed(baseSpeed);1113 }1114 // some servers has a bug in get spectators and sends unknown creatures updates1115 // so this code is disabled1116 /*1117 else1118 g_logger.traceError("could not get creature");1119 */1120}1121parseCreatureSkulls(msg: InputMessage)1122{1123 let id = msg.getU32();1124 let skull = msg.getU8();1125 let creature = g_map.getCreatureById(id);1126 if(creature)1127 creature.setSkull(skull);1128 else1129 error("could not get creature");1130}1131parseCreatureShields(msg: InputMessage)1132{1133 let id = msg.getU32();1134 let shield = msg.getU8();1135 let creature = g_map.getCreatureById(id);1136 if(creature)1137 creature.setShield(shield);1138 else1139 error("could not get creature");1140}1141parseCreatureUnpass(msg: InputMessage)1142{1143 let id = msg.getU32();1144 let unpass = msg.getU8();1145 let creature = g_map.getCreatureById(id);1146 if(creature)1147 creature.setPassable(!unpass);1148 else1149 error("could not get creature");1150}1151parseEditText(msg: InputMessage)1152{1153 let id = msg.getU32();1154 let itemId;1155 if(g_game.getClientVersion() >= 1010) {1156 // TODO: processEditText with ItemPtr as parameter1157 let item = this.getItem(msg);1158 itemId = item.getId();1159 } else1160 itemId = msg.getU16();1161 let maxLength = msg.getU16();1162 let text = msg.getString();1163 let writer = msg.getString();1164 let date = "";1165 if(g_game.getFeature(GameFeature.GameWritableDate))1166 date = msg.getString();1167 //g_game.processEditText(id, itemId, maxLength, text, writer, date);1168}1169parseEditList(msg: InputMessage)1170{1171 let doorId = msg.getU8();1172 let id = msg.getU32();1173 let text = msg.getString();1174 //g_game.processEditList(id, doorId, text);1175}1176parsePremiumTrigger(msg: InputMessage)1177{1178 let triggerCount = msg.getU8();1179 let triggers;1180 for(let i=0;i<triggerCount;++i) {1181 triggers.push_back(msg.getU8());1182}1183 if(g_game.getClientVersion() <= 1096) {1184 let something = msg.getU8() == 1;1185 }1186}1187parsePlayerInfo(msg: InputMessage)1188{1189 let premium = msg.getU8(); // premium1190 if(g_game.getFeature(GameFeature.GamePremiumExpiration))1191 let premiumEx = msg.getU32(); // premium expiration used for premium advertisement1192 let vocation = msg.getU8(); // vocation1193 let spellCount = msg.getU16();1194 let spells;1195 for(let i=0;i<spellCount;++i)1196 spells.push(msg.getU8()); // spell id1197 //m_localPlayer.setPremium(premium);1198 //m_localPlayer.setVocation(vocation);1199 //m_localPlayer.setSpells(spells);1200}1201parsePlayerStats(msg: InputMessage)1202{1203 let health;1204 let maxHealth;1205 if(g_game.getFeature(GameFeature.GameDoubleHealth)) {1206 health = msg.getU32();1207 maxHealth = msg.getU32();1208} else {1209 health = msg.getU16();1210 maxHealth = msg.getU16();1211}1212 let freeCapacity;1213 if(g_game.getFeature(GameFeature.GameDoubleFreeCapacity))1214 freeCapacity = msg.getU32() / 100.0;1215else1216 freeCapacity = msg.getU16() / 100.0;1217 let totalCapacity = 0;1218 if(g_game.getFeature(GameFeature.GameTotalCapacity))1219 totalCapacity = msg.getU32() / 100.0;1220 let experience;1221 if(g_game.getFeature(GameFeature.GameDoubleExperience))1222 experience = msg.getU64();1223else1224 experience = msg.getU32();1225 let level = msg.getU16();1226 let levelPercent = msg.getU8();1227 if(g_game.getFeature(GameFeature.GameExperienceBonus)) {1228 if(g_game.getClientVersion() <= 1096) {1229 let experienceBonus = msg.getDouble();1230 } else {1231 let baseXpGain = msg.getU16();1232 let voucherAddend = msg.getU16();1233 let grindingAddend = msg.getU16();1234 let storeBoostAddend = msg.getU16();1235 let huntingBoostFactor = msg.getU16();1236 }1237}1238 let mana;1239 let maxMana;1240 if(g_game.getFeature(GameFeature.GameDoubleHealth)) {1241 mana = msg.getU32();1242 maxMana = msg.getU32();1243} else {1244 mana = msg.getU16();1245 maxMana = msg.getU16();1246}1247 let magicLevel = msg.getU8();1248 let baseMagicLevel;1249 if(g_game.getFeature(GameFeature.GameSkillsBase))1250 baseMagicLevel = msg.getU8();1251else1252 baseMagicLevel = magicLevel;1253 let magicLevelPercent = msg.getU8();1254 let soul = msg.getU8();1255 let stamina = 0;1256 if(g_game.getFeature(GameFeature.GamePlayerStamina))1257 stamina = msg.getU16();1258 let baseSpeed = 0;1259 if(g_game.getFeature(GameFeature.GameSkillsBase))1260 baseSpeed = msg.getU16();1261 let regeneration = 0;1262 if(g_game.getFeature(GameFeature.GamePlayerRegenerationTime))1263 regeneration = msg.getU16();1264 let training = 0;1265 if(g_game.getFeature(GameFeature.GameOfflineTrainingTime)) {1266 training = msg.getU16();1267 if(g_game.getClientVersion() >= 1097) {1268 let remainingStoreXpBoostSeconds = msg.getU16();1269 let canBuyMoreStoreXpBoosts = msg.getU8();1270 }1271}1272/*1273 m_localPlayer.setHealth(health, maxHealth);1274 m_localPlayer.setFreeCapacity(freeCapacity);1275 m_localPlayer.setTotalCapacity(totalCapacity);1276 m_localPlayer.setExperience(experience);1277 m_localPlayer.setLevel(level, levelPercent);1278 m_localPlayer.setMana(mana, maxMana);1279 m_localPlayer.setMagicLevel(magicLevel, magicLevelPercent);1280 m_localPlayer.setBaseMagicLevel(baseMagicLevel);1281 m_localPlayer.setStamina(stamina);1282 m_localPlayer.setSoul(soul);1283 m_localPlayer.setBaseSpeed(baseSpeed);1284 m_localPlayer.setRegenerationTime(regeneration);1285 m_localPlayer.setOfflineTrainingTime(training);1286 */1287}1288parsePlayerSkills(msg: InputMessage)1289{1290 let lastSkill = Skill.Fishing + 1;1291 if(g_game.getFeature(GameFeature.GameAdditionalSkills))1292 lastSkill = Skill.LastSkill;1293 for(let skill: Skill = 0; skill < lastSkill; skill++) {1294 let level;1295 if(g_game.getFeature(GameFeature.GameDoubleSkills))1296 level = msg.getU16();1297 else1298 level = msg.getU8();1299 let baseLevel;1300 if(g_game.getFeature(GameFeature.GameSkillsBase))1301 if(g_game.getFeature(GameFeature.GameBaseSkillU16))1302 baseLevel = msg.getU16();1303 else1304 baseLevel = msg.getU8();1305 else1306 baseLevel = level;1307 let levelPercent = 0;1308 // Critical, Life Leech and Mana Leech have no level percent1309 if(skill <= Skill.Fishing)1310 levelPercent = msg.getU8();1311 /*1312 m_localPlayer.setSkill(skill, level, levelPercent);1313 m_localPlayer.setBaseSkill(skill, baseLevel);1314 */1315 }1316}1317parsePlayerState(msg: InputMessage)1318{1319 let states;1320 if(g_game.getFeature(GameFeature.GamePlayerStateU16))1321 states = msg.getU16();1322else1323 states = msg.getU8();1324 //m_localPlayer.setStates(states);1325}1326parsePlayerCancelAttack(msg: InputMessage)1327{1328 let seq = 0;1329 if(g_game.getFeature(GameFeature.GameAttackSeq))1330 seq = msg.getU32();1331 //g_game.processAttackCancel(seq);1332}1333parsePlayerModes(msg: InputMessage)1334{1335 let fightMode = msg.getU8();1336 let chaseMode = msg.getU8();1337 let safeMode = msg.getU8();1338 let pvpMode = 0;1339 if(g_game.getFeature(GameFeature.GamePVPMode))1340 pvpMode = msg.getU8();1341 //g_game.processPlayerModes((Otc::FightModes)fightMode, (Otc::ChaseModes)chaseMode, safeMode, (Otc::PVPModes)pvpMode);1342}1343parseSpellCooldown(msg: InputMessage)1344{1345 let spellId = msg.getU8();1346 let delay = msg.getU32();1347 //g_lua.callGlobalField("g_game", "onSpellCooldown", spellId, delay);1348}1349parseSpellGroupCooldown(msg: InputMessage)1350{1351 let groupId = msg.getU8();1352 let delay = msg.getU32();1353 //g_lua.callGlobalField("g_game", "onSpellGroupCooldown", groupId, delay);1354}1355parseMultiUseCooldown(msg: InputMessage)1356{1357 let delay = msg.getU32();1358 //g_lua.callGlobalField("g_game", "onMultiUseCooldown", delay);1359}1360parseTalk(msg: InputMessage)1361{1362 if(g_game.getFeature(GameFeature.GameMessageStatements))1363 msg.getU32(); // channel statement guid1364 let name = g_game.formatCreatureName(msg.getString());1365 let level = 0;1366 if(g_game.getFeature(GameFeature.GameMessageLevel))1367 level = msg.getU16();1368 let mode: MessageMode = Proto.translateMessageModeFromServer(msg.getU8());1369 let channelId = 0;1370 let pos: Position;1371 switch(mode) {1372 case MessageMode.MessageSay:1373 case MessageMode.MessageWhisper:1374 case MessageMode.MessageYell:1375 case MessageMode.MessageMonsterSay:1376 case MessageMode.MessageMonsterYell:1377 case MessageMode.MessageNpcTo:1378 case MessageMode.MessageBarkLow:1379 case MessageMode.MessageBarkLoud:1380 case MessageMode.MessageSpell:1381 case MessageMode.MessageNpcFromStartBlock:1382 pos = this.getPosition(msg);1383 break;1384 case MessageMode.MessageChannel:1385 case MessageMode.MessageChannelManagement:1386 case MessageMode.MessageChannelHighlight:1387 case MessageMode.MessageGamemasterChannel:1388 channelId = msg.getU16();1389 break;1390 case MessageMode.MessageNpcFrom:1391 case MessageMode.MessagePrivateFrom:1392 case MessageMode.MessageGamemasterBroadcast:1393 case MessageMode.MessageGamemasterPrivateFrom:1394 case MessageMode.MessageRVRAnswer:1395 case MessageMode.MessageRVRContinue:1396 break;1397 case MessageMode.MessageRVRChannel:1398 msg.getU32();1399 break;1400 default:1401 error("unknown message mode %d", mode);1402 break;1403 }1404 let text = msg.getString();1405 //g_game.processTalk(name, level, mode, text, channelId, pos);1406}1407parseChannelList(msg: InputMessage)1408{1409 let count = msg.getU8();1410 let channelList = [];1411 for(let i = 0; i < count; i++) {1412 let id = msg.getU16();1413 let name = msg.getString();1414 channelList.push([id, name]);1415}1416 //g_game.processChannelList(channelList);1417}1418parseOpenChannel(msg: InputMessage)1419{1420 let channelId = msg.getU16();1421 let name = msg.getString();1422 if(g_game.getFeature(GameFeature.GameChannelPlayerList)) {1423 let joinedPlayers = msg.getU16();1424 for(let i=0;i<joinedPlayers;++i)1425 g_game.formatCreatureName(msg.getString()); // player name1426 let invitedPlayers = msg.getU16();1427 for(let i=0;i<invitedPlayers;++i)1428 g_game.formatCreatureName(msg.getString()); // player name1429}1430 //g_game.processOpenChannel(channelId, name);1431}1432parseOpenPrivateChannel(msg: InputMessage)1433{1434 let name = g_game.formatCreatureName(msg.getString());1435 //g_game.processOpenPrivateChannel(name);1436}1437parseOpenOwnPrivateChannel(msg: InputMessage)1438{1439 let channelId = msg.getU16();1440 let name = msg.getString();1441 //g_game.processOpenOwnPrivateChannel(channelId, name);1442}1443parseCloseChannel(msg: InputMessage)1444{1445 let channelId = msg.getU16();1446 //g_game.processCloseChannel(channelId);1447}1448parseRuleViolationChannel(msg: InputMessage)1449{1450 let channelId = msg.getU16();1451 //g_game.processRuleViolationChannel(channelId);1452}1453parseRuleViolationRemove(msg: InputMessage)1454{1455 let name = msg.getString();1456 //g_game.processRuleViolationRemove(name);1457}1458parseRuleViolationCancel(msg: InputMessage)1459{1460 let name = msg.getString();1461 //g_game.processRuleViolationCancel(name);1462}1463parseRuleViolationLock(msg: InputMessage)1464{1465 //g_game.processRuleViolationLock();1466}1467parseTextMessage(msg: InputMessage)1468{1469 let code = msg.getU8();1470 let mode: MessageMode = Proto.translateMessageModeFromServer(code);1471 let text;1472 switch(mode) {1473 case MessageMode.MessageChannelManagement: {1474 let channel = msg.getU16();1475 text = msg.getString();1476 break;1477 }1478 case MessageMode.MessageGuild:1479 case MessageMode.MessagePartyManagement:1480 case MessageMode.MessageParty: {1481 let channel = msg.getU16();1482 text = msg.getString();1483 break;1484 }1485 case MessageMode.MessageDamageDealed:1486 case MessageMode.MessageDamageReceived:1487 case MessageMode.MessageDamageOthers: {1488 let pos: Position = this.getPosition(msg);1489 let value = [];1490 let color = [];1491 // physical damage1492 value[0] = msg.getU32();1493 color[0] = msg.getU8();1494 // magic damage1495 value[1] = msg.getU32();1496 color[1] = msg.getU8();1497 text = msg.getString();1498 for(let i=0;i<2;++i) {1499 if(value[i] == 0)1500 continue;1501 let animatedText = new AnimatedText;1502 animatedText.setColor(color[i]);1503 animatedText.setText(value[i]);1504 g_map.addThing(animatedText, pos);1505 }1506 break;1507 }1508 case MessageMode.MessageHeal:1509 case MessageMode.MessageMana:1510 case MessageMode.MessageExp:1511 case MessageMode.MessageHealOthers:1512 case MessageMode.MessageExpOthers: {1513 let pos = this.getPosition(msg);1514 let value = msg.getU32();1515 let color = msg.getU8();1516 text = msg.getString();1517 let animatedText = new AnimatedText;1518 animatedText.setColor(color);1519 animatedText.setText(value.toString());1520 g_map.addThing(animatedText, pos);1521 break;1522 }1523 case MessageMode.MessageInvalid:1524 error("unknown message mode %d", mode);1525 break;1526 default:1527 text = msg.getString();1528 break;1529 }1530 //g_game.processTextMessage(mode, text);1531}1532parseCancelWalk(msg: InputMessage)1533{1534 let direction: Direction = msg.getU8();1535 //g_game.processWalkCancel(direction);1536}1537parseWalkWait(msg: InputMessage)1538{1539 let millis = msg.getU16();1540 //m_localPlayer.lockWalk(millis);1541}1542parseFloorChangeUp(msg: InputMessage)1543{1544 let pos: Position;1545 if(g_game.getFeature(GameFeature.GameMapMovePosition))1546 pos = this.getPosition(msg);1547else1548 pos = g_map.getCentralPosition();1549 let range = g_map.getAwareRange();1550 pos.z--;1551 let skip = 0;1552 if(pos.z == Otc.SEA_FLOOR)1553 for(let i = Otc.SEA_FLOOR - Otc.AWARE_UNDEGROUND_FLOOR_RANGE; i >= 0; i--)1554 skip = this.setFloorDescription(msg, pos.x - range.left, pos.y - range.top, i, range.horizontal(), range.vertical(), 8 - i, skip);1555else if(pos.z > Otc.SEA_FLOOR)1556 skip = this.setFloorDescription(msg, pos.x - range.left, pos.y - range.top, pos.z - Otc.AWARE_UNDEGROUND_FLOOR_RANGE, range.horizontal(), range.vertical(), 3, skip);1557 pos.x++;1558 pos.y++;1559 g_map.setCentralPosition(pos);1560}1561parseFloorChangeDown(msg: InputMessage)1562{1563 let pos: Position;1564 if(g_game.getFeature(GameFeature.GameMapMovePosition))1565 pos = this.getPosition(msg);1566else1567 pos = g_map.getCentralPosition();1568 let range = g_map.getAwareRange();1569 pos.z++;1570 let skip = 0;1571 if(pos.z == Otc.UNDERGROUND_FLOOR) {1572 let j, i;1573 for(i = pos.z, j = -1; i <= pos.z + Otc.AWARE_UNDEGROUND_FLOOR_RANGE; ++i, --j)1574 skip = this.setFloorDescription(msg, pos.x - range.left, pos.y - range.top, i, range.horizontal(), range.vertical(), j, skip);1575}1576else if(pos.z > Otc.UNDERGROUND_FLOOR && pos.z < Otc.MAX_Z-1)1577 skip = this.setFloorDescription(msg, pos.x - range.left, pos.y - range.top, pos.z + Otc.AWARE_UNDEGROUND_FLOOR_RANGE, range.horizontal(), range.vertical(), -3, skip);1578 pos.x--;1579 pos.y--;1580 g_map.setCentralPosition(pos);1581}1582parseOpenOutfitWindow(msg: InputMessage)1583{1584 let currentOutfit = this.getOutfit(msg);1585 let outfitList = [];1586 if(g_game.getFeature(GameFeature.GameNewOutfitProtocol)) {1587 let outfitCount = msg.getU8();1588 for(let i = 0; i < outfitCount; i++) {1589 let outfitId = msg.getU16();1590 let outfitName = msg.getString();1591 let outfitAddons = msg.getU8();1592 outfitList.push([outfitId, outfitName, outfitAddons]);1593 }1594} else {1595 let outfitStart, outfitEnd;1596 if(g_game.getFeature(GameFeature.GameLooktypeU16)) {1597 outfitStart = msg.getU16();1598 outfitEnd = msg.getU16();1599 } else {1600 outfitStart = msg.getU8();1601 outfitEnd = msg.getU8();1602 }1603 for(let i = outfitStart; i <= outfitEnd; i++)1604 outfitList.push([i, "", 0]);1605}1606 let mountList = [];1607 if(g_game.getFeature(GameFeature.GamePlayerMounts)) {1608 let mountCount = msg.getU8();1609 for(let i = 0; i < mountCount; ++i) {1610 let mountId = msg.getU16(); // mount type1611 let mountName = msg.getString(); // mount name1612 mountList.push([mountId, mountName]);1613 }1614}1615 //g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList);1616}1617parseVipAdd(msg: InputMessage)1618{1619 let id, iconId = 0, status;1620 let name, desc = "";1621 let notifyLogin = false;1622 id = msg.getU32();1623 name = g_game.formatCreatureName(msg.getString());1624 if(g_game.getFeature(GameFeature.GameAdditionalVipInfo)) {1625 desc = msg.getString();1626 iconId = msg.getU32();1627 notifyLogin = msg.getU8() > 0;1628}1629 status = msg.getU8();1630 //g_game.processVipAdd(id, name, status, desc, iconId, notifyLogin);1631}1632parseVipState(msg: InputMessage)1633{1634 let id = msg.getU32();1635 if(g_game.getFeature(GameFeature.GameLoginPending)) {1636 let status = msg.getU8();1637 //g_game.processVipStateChange(id, status);1638}1639else {1640 //g_game.processVipStateChange(id, 1);1641}1642}1643parseVipLogout(msg: InputMessage)1644{1645 let id = msg.getU32();1646 //g_game.processVipStateChange(id, 0);1647}1648parseTutorialHint(msg: InputMessage)1649{1650 let id = msg.getU8();1651 //g_game.processTutorialHint(id);1652}1653parseAutomapFlag(msg: InputMessage)1654{1655 let pos = this.getPosition(msg);1656 let icon = msg.getU8();1657 let description = msg.getString();1658 let remove = false;1659 if(g_game.getFeature(GameFeature.GameMinimapRemove))1660 remove = msg.getU8() != 0;1661 if(!remove) {1662 //g_game.processAddAutomapFlag(pos, icon, description);1663 }1664 else {1665 //g_game.processRemoveAutomapFlag(pos, icon, description);1666 }1667}1668parseQuestLog(msg: InputMessage)1669{1670 let questList = [];1671 let questsCount = msg.getU16();1672 for(let i = 0; i < questsCount; i++) {1673 let id = msg.getU16();1674 let name = msg.getString();1675 let completed = msg.getU8();1676 questList.push([id, name, completed]);1677}1678 //g_game.processQuestLog(questList);1679}1680parseQuestLine(msg: InputMessage)1681{1682 let questMissions = [];1683 let questId = msg.getU16();1684 let missionCount = msg.getU8();1685 for(let i = 0; i < missionCount; i++) {1686 let missionName = msg.getString();1687 let missionDescrition = msg.getString();1688 questMissions.push([missionName, missionDescrition]);1689}1690 //g_game.processQuestLine(questId, questMissions);1691}1692parseChannelEvent(msg: InputMessage)1693{1694 msg.getU16(); // channel id1695 g_game.formatCreatureName(msg.getString()); // player name1696 msg.getU8(); // event type1697}1698parseItemInfo(msg: InputMessage)1699{1700 let list = [];1701 let size = msg.getU8();1702 for(let i=0;i<size;++i) {1703 let item = new Item();1704 item.setId(msg.getU16());1705 item.setCountOrSubType(msg.getU8());1706 let desc = msg.getString();1707 list.push([item, desc]);1708}1709 //g_lua.callGlobalField("g_game", "onItemInfo", list);1710}1711parsePlayerInventory(msg: InputMessage)1712{1713 let size = msg.getU16();1714 for(let i=0;i<size;++i) {1715 msg.getU16(); // id1716 msg.getU8(); // subtype1717 msg.getU16(); // count1718}1719}1720parseModalDialog(msg: InputMessage)1721{1722 let id = msg.getU32();1723 let title = msg.getString();1724 let message = msg.getString();1725 let sizeButtons = msg.getU8();1726 let buttonList = [];1727 for(let i = 0; i < sizeButtons; ++i) {1728 let value = msg.getString();1729 let id = msg.getU8();1730 buttonList.push([id, value]);1731}1732 let sizeChoices = msg.getU8();1733 let choiceList;1734 for(let i = 0; i < sizeChoices; ++i) {1735 let value = msg.getString();1736 let id = msg.getU8();1737 choiceList.push_back([id, value]);1738}1739 let enterButton, escapeButton;1740 if(g_game.getClientVersion() > 970) {1741 escapeButton = msg.getU8();1742 enterButton = msg.getU8();1743 }1744 else {1745 enterButton = msg.getU8();1746 escapeButton = msg.getU8();1747 }1748 let priority = msg.getU8() == 0x01;1749 //g_game.processModalDialog(id, title, message, buttonList, enterButton, escapeButton, choiceList, priority);1750}1751parseExtendedOpcode(msg: InputMessage)1752{1753 let opcode = msg.getU8();1754 let buffer = msg.getString();1755/*1756 if(opcode == 0)1757 m_enableSendExtendedOpcode = true;1758 else if(opcode == 2)1759 parsePingBack(msg);1760 else {1761 callLuaField("onExtendedOpcode", opcode, buffer);1762 }1763*/1764}1765parseChangeMapAwareRange(msg: InputMessage)1766{1767 let xrange = msg.getU8();1768 let yrange = msg.getU8();1769 let range = new AwareRange();1770 range.left = xrange/2 - ((xrange+1) % 2);1771 range.right = xrange/2;1772 range.top = yrange/2 - ((yrange+1) % 2);1773 range.bottom = yrange/2;1774 g_map.setAwareRange(range);1775 //g_lua.callGlobalField("g_game", "onMapChangeAwareRange", xrange, yrange);1776}1777parseCreaturesMark(msg: InputMessage)1778{1779 let len;1780 if(g_game.getClientVersion() >= 1035) {1781 len = 1;1782 } else {1783 len = msg.getU8();1784 }1785 for(let i=0; i<len; ++i) {1786 let id = msg.getU32();1787 let isPermanent = msg.getU8() != 1;1788 let markType = msg.getU8();1789 let creature = g_map.getCreatureById(id);1790 if(creature) {1791 if(isPermanent) {1792 if(markType == 0xff)1793 creature.hideStaticSquare();1794 else1795 creature.showStaticSquare(Color.from8bit(markType));1796 } else1797 creature.addTimedSquare(markType);1798 } else1799 error("could not get creature");1800}1801}1802parseCreatureType(msg: InputMessage)1803{1804 let id = msg.getU32();1805 let type = msg.getU8();1806 let creature = g_map.getCreatureById(id);1807 if(creature)1808 creature.setType(type);1809 else1810 error("could not get creature");1811}1812 setMapDescription(msg: InputMessage, x: number, y: number, z: number, width: number, height: number) {1813 let startz;1814 let endz;1815 let zstep;1816 if (z > Otc.SEA_FLOOR) {1817 startz = z - Otc.AWARE_UNDEGROUND_FLOOR_RANGE;1818 endz = Math.min(z + Otc.AWARE_UNDEGROUND_FLOOR_RANGE, Otc.MAX_Z);1819 zstep = 1;1820 }1821 else {1822 startz = Otc.SEA_FLOOR;1823 endz = 0;1824 zstep = -1;1825 }1826 let skip = 0;1827 for (let nz = startz; nz != endz + zstep; nz += zstep)1828 skip = this.setFloorDescription(msg, x, y, nz, width, height, z - nz, skip);1829 }1830 setFloorDescription(msg: InputMessage, x: number, y: number, z: number, width: number, height: number, offset: number, skip: number): number {1831 for (let nx = 0; nx < width; nx++) {1832 for (let ny = 0; ny < height; ny++) {1833 let tilePos = new Position(x + nx + offset, y + ny + offset, z);1834 if (skip == 0)1835 skip = this.setTileDescription(msg, tilePos);1836 else {1837 g_map.cleanTile(tilePos);1838 skip--;1839 }1840 }1841 }1842 return skip;1843 }1844setTileDescription(msg: InputMessage, position: Position): number {1845 g_map.cleanTile(position);1846 let gotEffect = false;1847 for (let stackPos = 0; stackPos < 256; stackPos++) {1848 if (msg.peekU16() >= 0xff00)1849 return msg.getU16() & 0xff;1850 if (g_game.getFeature(GameFeature.GameEnvironmentEffect) && !gotEffect) {1851 msg.getU16(); // environment effect1852 gotEffect = true;1853 continue;1854 }1855 if (stackPos > 10)1856 error("too many things, pos=%s, stackpos=%d", position, stackPos);1857 let thing = this.getThing(msg);1858 g_map.addThing(thing, position, stackPos);1859 }1860 return 0;1861}1862getOutfit(msg: InputMessage): Outfit1863{1864 let outfit = new Outfit();1865 let lookType: number;1866 if(g_game.getFeature(GameFeature.GameLooktypeU16))1867 lookType = msg.getU16();1868else1869 lookType = msg.getU8();1870 if(lookType != 0) {1871 outfit.setCategory(ThingCategory.ThingCategoryCreature);1872 let head = msg.getU8();1873 let body = msg.getU8();1874 let legs = msg.getU8();1875 let feet = msg.getU8();1876 let addons = 0;1877 if(g_game.getFeature(GameFeature.GamePlayerAddons))1878 addons = msg.getU8();1879 if(!g_things.isValidDatId(lookType, ThingCategory.ThingCategoryCreature)) {1880 error("invalid outfit looktype %d", lookType);1881 lookType = 0;1882 }1883 outfit.setId(lookType);1884 outfit.setHead(head);1885 outfit.setBody(body);1886 outfit.setLegs(legs);1887 outfit.setFeet(feet);1888 outfit.setAddons(addons);1889 }1890 else {1891 let lookTypeEx = msg.getU16();1892 if(lookTypeEx == 0) {1893 outfit.setCategory(ThingCategory.ThingCategoryEffect);1894 outfit.setAuxId(13); // invisible effect id1895 }1896 else {1897 if(!g_things.isValidDatId(lookTypeEx, ThingCategory.ThingCategoryItem)) {1898 error("invalid outfit looktypeex %d", lookTypeEx);1899 lookTypeEx = 0;1900 }1901 outfit.setCategory(ThingCategory.ThingCategoryItem);1902 outfit.setAuxId(lookTypeEx);1903 }1904 }1905 if(g_game.getFeature(GameFeature.GamePlayerMounts)) {1906 let mount = msg.getU16();1907 outfit.setMount(mount);1908}1909 return outfit;1910}1911getThing(msg: InputMessage): Thing1912{1913 let thing = new Thing();1914 let id = msg.getU16();1915 if(id == 0)1916 error("invalid thing id");1917else if(id == Proto.UnknownCreature || id == Proto.OutdatedCreature || id == Proto.Creature)1918 thing = this.getCreature(msg, id);1919else if(id == Proto.StaticText) // otclient only1920 thing = this.getStaticText(msg, id);1921else // item1922 thing = this.getItem(msg, id);1923 return thing;1924}1925getMappedThing(msg: InputMessage): Thing1926{1927 let thing;1928 let x = msg.getU16();1929 if(x != 0xffff) {1930 let pos = new Position();1931 pos.x = x;1932 pos.y = msg.getU16();1933 pos.z = msg.getU8();1934 let stackpos = msg.getU8();1935 thing = g_map.getThing(pos, stackpos);1936 if(!thing)1937 error("no thing at pos:%s, stackpos:%d", pos, stackpos);1938 } else {1939 let id = msg.getU32();1940 thing = g_map.getCreatureById(id);1941 if(!thing)1942 error("no creature with id %u", id);1943 }1944 return thing;1945}1946getCreature(msg: InputMessage, type: number): Creature1947{1948 if(type == 0)1949 type = msg.getU16();1950 let creature;1951 let known = (type != Proto.UnknownCreature);1952 if(type == Proto.OutdatedCreature || type == Proto.UnknownCreature) {1953 if(known) {1954 let id = msg.getU32();1955 creature = g_map.getCreatureById(id);1956 if(!creature)1957 error("server said that a creature is known, but it's not");1958 } else {1959 let removeId = msg.getU32();1960 g_map.removeCreatureById(removeId);1961 let id = msg.getU32();1962 let creatureType;1963 if(g_game.getClientVersion() >= 910)1964 creatureType = msg.getU8();1965 else {1966 if(id >= Proto.PlayerStartId && id < Proto.PlayerEndId)1967 creatureType = Proto.CreatureTypePlayer;1968 else if(id >= Proto.MonsterStartId && id < Proto.MonsterEndId)1969 creatureType = Proto.CreatureTypeMonster;1970 else1971 creatureType = Proto.CreatureTypeNpc;1972 }1973 std::string name = g_game.formatCreatureName(msg.getString());1974 if(id == m_localPlayer.getId())1975 creature = m_localPlayer;1976 else if(creatureType == Proto.CreatureTypePlayer) {1977 // fixes a bug server side bug where GameInit is not sent and local player id is unknown1978 if(m_localPlayer.getId() == 0 && name == m_localPlayer.getName())1979 creature = m_localPlayer;1980 else1981 creature = PlayerPtr(new Player);1982 }1983 else if(creatureType == Proto.CreatureTypeMonster)1984 creature = MonsterPtr(new Monster);1985 else if(creatureType == Proto.CreatureTypeNpc)1986 creature = NpcPtr(new Npc);1987 else1988 g_logger.traceError("creature type is invalid");1989 if(creature) {1990 creature.setId(id);1991 creature.setName(name);1992 g_map.addCreature(creature);1993 }1994 }1995 int healthPercent = msg.getU8();1996 Otc::Direction direction = (Otc::Direction)msg.getU8();1997 Outfit outfit = getOutfit(msg);1998 Light light;1999 light.intensity = msg.getU8();2000 light.color = msg.getU8();2001 int speed = msg.getU16();2002 int skull = msg.getU8();2003 int shield = msg.getU8();2004 // emblem is sent only when the creature is not known2005 int8 emblem = -1;2006 int8 creatureType = -1;2007 int8 icon = -1;2008 bool unpass = true;2009 uint8 mark;2010 if(g_game.getFeature(GameFeature.GameCreatureEmblems) && !known)2011 emblem = msg.getU8();2012 if(g_game.getFeature(GameFeature.GameThingMarks)) {2013 creatureType = msg.getU8();2014 }2015 if(g_game.getFeature(GameFeature.GameCreatureIcons)) {2016 icon = msg.getU8();2017 }2018 if(g_game.getFeature(GameFeature.GameThingMarks)) {2019 mark = msg.getU8(); // mark2020 msg.getU16(); // helpers2021 if(creature) {2022 if(mark == 0xff)2023 creature.hideStaticSquare();2024 else2025 creature.showStaticSquare(Color::from8bit(mark));2026 }2027 }2028 if(g_game.getClientVersion() >= 854)2029 unpass = msg.getU8();2030 if(creature) {2031 creature.setHealthPercent(healthPercent);2032 creature.setDirection(direction);2033 creature.setOutfit(outfit);2034 creature.setSpeed(speed);2035 creature.setSkull(skull);2036 creature.setShield(shield);2037 creature.setPassable(!unpass);2038 creature.setLight(light);2039 if(emblem != -1)2040 creature.setEmblem(emblem);2041 if(creatureType != -1)2042 creature.setType(creatureType);2043 if(icon != -1)2044 creature.setIcon(icon);2045 if(creature == m_localPlayer && !m_localPlayer.isKnown())2046 m_localPlayer.setKnown(true);2047 }2048} else if(type == Proto.Creature) {2049 uint id = msg.getU32();2050 creature = g_map.getCreatureById(id);2051 if(!creature)2052 g_logger.traceError("invalid creature");2053 Otc::Direction direction = (Otc::Direction)msg.getU8();2054 if(creature)2055 creature.turn(direction);2056 if(g_game.getClientVersion() >= 953) {2057 bool unpass = msg.getU8();2058 if(creature)2059 creature.setPassable(!unpass);2060 }2061} else {2062 stdext::throw_exception("invalid creature opcode");2063}2064 return creature;2065}2066getItem(msg: InputMessage, id: number = 0): Item2067{2068 if(id == 0)2069 id = msg.getU16();2070 ItemPtr item = Item::create(id);2071 if(item.getId() == 0)2072 stdext::throw_exception(stdext::format("unable to create item with invalid id %d", id));2073 if(g_game.getFeature(GameFeature.GameThingMarks)) {2074 msg.getU8(); // mark2075}2076 if(item.isStackable() || item.isFluidContainer() || item.isSplash() || item.isChargeable())2077 item.setCountOrSubType(msg.getU8());2078 if(g_game.getFeature(GameFeature.GameItemAnimationPhase)) {2079 if(item.getAnimationPhases() > 1) {2080 // 0x00 => automatic phase2081 // 0xFE => random phase2082 // 0xFF => async phase2083 msg.getU8();2084 //item.setPhase(msg.getU8());2085 }2086}2087 return item;2088}2089getStaticText(msg: InputMessage, id: number): StaticText2090{2091 int colorByte = msg.getU8();2092 Color color = Color::from8bit(colorByte);2093 std::string fontName = msg.getString();2094 std::string text = msg.getString();2095 staticText: StaticText = StaticTextPtr(new StaticText);2096 staticText.setText(text);2097 staticText.setFont(fontName);2098 staticText.setColor(color);2099 return staticText;2100}2101getPosition(msg: InputMessage): Position2102{2103 let x = msg.getU16();2104 let y = msg.getU16();2105 let z = msg.getU8();2106 return Position(x, y, z);2107}...

Full Screen

Full Screen

onSocketPacket.ts

Source:onSocketPacket.ts Github

copy

Full Screen

...10 if (checksum === packet.adler32()) {11 packet.getU32()12 hasCheksum = true13 }14 const packetType = packet.getU8()15 // status check16 if (packetType === 0xff) {17 console.log(`status_check`)18 }19 if (packetType !== 0x01) {20 throw `Invalid packet type: ${packetType}, should be 1`21 }22 // onRecvFirstMessage start23 packet.getU16() // os24 const version = packet.getU16()25 if (version >= 980) {26 packet.getU32() // client version27 }28 if (version >= 1071) {29 packet.getU16() // content revision30 packet.getU16() // unknown, otclient sends 031 } else {32 packet.getU32() // data signature33 }34 packet.getU32() // spr signature35 packet.getU32() // pic signature36 if (version >= 980) {37 packet.getU8() // preview state38 }39 let decryptedPacket = packet40 let xtea: number[] | null = null41 if (version >= 770) {42 decryptedPacket = packet.rsaDecrypt()43 if (decryptedPacket.getU8() !== 0) {44 throw `Rsa decryption error (1)`45 }46 xtea = [47 decryptedPacket.getU32(),48 decryptedPacket.getU32(),49 decryptedPacket.getU32(),50 decryptedPacket.getU32()51 ]52 }53 const accountName =54 version >= 840 ? decryptedPacket.getString() : decryptedPacket.getU32()55 const accountPassword = decryptedPacket.getString()56 console.log(CONSOLE_COLORS.WHITE, { accountName, accountPassword })57 // otclient extended data58 //decryptedPacket.getString()59 if (version >= 1061) {60 packet.getU8() // ogl info 161 packet.getU8() // ogl info 262 packet.getString() // gpu63 packet.getString() // gpu version64 }65 let accountToken: string = ''66 let stayLogged = true67 if (version >= 1072) {68 // auth token69 const decryptAuthPacket = packet.rsaDecrypt()70 if (decryptAuthPacket.getU8() !== 0) {71 throw 'RSA decryption error (2)'72 }73 accountToken = decryptAuthPacket.getString()74 if (version >= 1074) {75 stayLogged = decryptAuthPacket.getU8() > 076 }77 }78 function disconnectClient(error: string, version: number, code?: number) {79 const output = new OutputMessage()80 if (code) {81 output.addU8(code)82 } else {83 output.addU8(version >= 1076 ? 0x0b : 0x0a)84 }85 output.addString(error)86 send(socket, output, hasCheksum, xtea)87 }88 if (version < VERSION_MIN || version > VERSION_MAX) {89 return disconnectClient(...

Full Screen

Full Screen

bit.js

Source:bit.js Github

copy

Full Screen

...53 this.left += CHAR_BIT;54 }55 56 if (this.left < CHAR_BIT) {57 this.cache = this.stream.getU8(this.offset);58 }59}60/*61 * NAME: bit.read()62 * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value63 */64Bit.prototype.read = function(len) {65 if(len > 16) {66 return this.readBig(len);67 }68 69 var value = 0;70 if (this.left == CHAR_BIT) {71 this.cache = this.stream.getU8(this.offset);72 }73 if (len < this.left) {74 value = (this.cache & ((1 << this.left) - 1)) >> (this.left - len);75 this.left -= len;76 77 return value;78 }79 80 /* remaining bits in current byte */81 value = this.cache & ((1 << this.left) - 1);82 len -= this.left;83 84 this.offset++;85 this.left = CHAR_BIT;86 87 /* more bytes */88 while (len >= CHAR_BIT) {89 value = (value << CHAR_BIT) | this.stream.getU8(this.offset++);90 len -= CHAR_BIT;91 }92 93 if (len > 0) {94 this.cache = this.stream.getU8(this.offset);95 96 value = (value << len) | (this.cache >> (CHAR_BIT - len));97 this.left -= len;98 }99 100 return value;101}102Bit.prototype.readBig = function(len) {103 var value = 0;104 105 if (this.left == CHAR_BIT) {106 this.cache = this.stream.getU8(this.offset);107 }108 109 if (len < this.left) {110 value = (this.cache & ((1 << this.left) - 1)) >> (this.left - len);111 this.left -= len;112 113 return value;114 }115 116 /* remaining bits in current byte */117 value = this.cache & ((1 << this.left) - 1);118 len -= this.left;119 120 this.offset++;121 this.left = CHAR_BIT;122 123 /* more bytes */124 while (len >= CHAR_BIT) {125 value = Mad.bitwiseOr(Mad.lshift(value, CHAR_BIT), this.stream.getU8(this.offset++));126 len -= CHAR_BIT;127 }128 129 if (len > 0) {130 this.cache = this.stream.getU8(this.offset);131 132 value = Mad.bitwiseOr(Mad.lshift(value, len), (this.cache >> (CHAR_BIT - len)));133 this.left -= len;134 }135 136 return value;137}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('webpagetest');2const test = async () => {3 const wptClient = await wpt('API_KEY');4 const data = await wptClient.getU8('TEST_ID');5 console.log(data);6};7test();8MIT © [Abhishek Kumar](

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'A.9f7c0f2b9c7b8c8b8d0e1c1d4a4f4c4b');3wpt.getU8(url, function(err, data) {4 if (err) throw err;5 console.log(data);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var wpt = new WebPageTest('webpagetest.org', 'A.4c4a4d4d0f7e0edf9a7c4d4a4d4d0f7e');5wpt.runTest(url, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPagetest for %s', url);8 console.log('Navigate to %sresult/%s/ to see the test results', wpt.testUrl, data.data.testId);9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('First View (ms):', data.data.average.firstView.loadTime);12 console.log('Repeat View (ms):', data.data.average.repeatView.loadTime);13 });14});15 if (err) return console.error(err);16 console.log('U8 data:', data);17});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful