Java-based World of Warcraft search engine battle platform

Source: Internet
Author: User

Main UDP Packets:
Cable collection package:
Content: F7 2f 10 00 50 58 33 57 15 00 00 00 00 00 00
Function: sends a request to the host. Ask someone "What host are you creating ?"
When you enable Warcraft to enter the LAN, the package will be broadcast to the current CIDR Block (255.255.255.255. As long as the conditions are met, the host that receives the package will return a map information to him (HE: IP port of the cable package)
Renewal package:
Content: F7 32 10 00 00 00 00 00 01 00 00 00 00 00 00 00 00
Function: tell others: "I have built a host. Do you want to check it out ."
When the host is created, broadcast the package to the current CIDR block every 5 seconds. The customer who receives this package sends a search package.
Map package:
Content:
F7 30 8C 00 50 58 33 57 14 00 00 00 01 00 00
39 69 C2 00 E5 BD 93 E5 9C B0 E5 B1 80 E5 9f 9f
E7 BD 91 E5 86 85 E7 9A 84 E6 B8 B8 E6 88 8f 20
28 76 73 00 00 01 03 49 07 01 01 77 01 B9 79 01
99 D5 B9 31 4D CB 61 71 73 5d 45 6f 77 19 6f 6d
6f 61 65 5d 45 2B 6f 75 41 21 41 6D 6D 2B 73 75
61 73 73 21 77 B1 37 2f 37 31 63 2f 77 23 33 79
01 77 73 01 01 00 0a 00 00 00 01 00 00 01 00
00 00 0a 00 00 00 1B 00 00 E0 17
Function: "This is the graph I have built. It looks nice ."
After receiving the search package, the host returns the package to it, including all useful information.

Warcraft Workflow

When Warcraft enters the LAN, it broadcasts a search package and sends it only once. Only the current CIDR Block (255.255.255.255) is sent, so we can only see this dormitory, or several hosts in a few dormitories.

Once a host is created, Warcraft will send a package to it. This package is map information, including map information, Host Name, number of people added, and remaining locations, another important data is the game port. Generally, the port of warcraft is 6112.

The World of Warcraft that creates a host will send a local package, "I have created a host"

Warcraft that finds this message will send a search package to the host.

The host sends the map information.

After receiving this, We will parse the map. At this time, we will see someone who has built the master and click "add ·~ Establish a TCP connection to launch a host game

 

PS:For a game, the packet sent from the host is about 25 MB (half an hour). The packet sent from the host is 9*25 MB/30 min; // a 10-person game with a master + 9 clients is calculated based on Dota. In this way, we roughly estimate that the host's network speed requirement is 9*25*1024/30*60 = 128> 100 kb/s plus the communication package required by a few other programs. If you don't want to get stuck, you need to ensure the network speed of the host.

 


Key Technologies

1. Listen to the map information of the host (the machine that created the hosts map.

There are two ways to obtain map information. One is to capture packets and analyze all the packets related to port 6112. (I think this computer is too costly ). Most searchers are implemented in this way.
However, it is not easy to capture packets in Java. C ++ can implement this function. You can use C ++ to compile a DLL. Java call. Or use an open-source project. Search to find.

The method I used is to create a thread. Send a packet every five seconds to collect whether the host is set up. If you have created a host, a map information package is returned. After receiving the message, tell the other IP Address "I created the master ";
In this way, the client does not need to send the search package all the time.
Once you find the host, everything is fine.
2. tell someone I have built the host.
How can I tell someone that I have built a host. It's easy. Once a host is set up, Warcraft will send a package every five seconds to the current CIDR Block and tell others that I have built the host.
We only need to send this packet to port 6112 of other IP addresses. It is to tell others that "I have built the master", and the recipient will send a package: "Look at what figure", and then the host will reply to a package. That's right, this is the map information!

3. parse the map
Not parsing maps will not affect the game. Because Warcraft accepts the map package and parses it by itself, it understands what the map is. However, by parsing a map, you can know what the map is built on the host, what the host name is, how many people join the map, and how many computers there are. There are also several empty locations. The version of the host. This useful information is useful when it is displayed on the software!
There are many articles about UDP packets. You can search for the keyword Warcraft UDP on Google.
I would like to add a few points here.

This is online:

02 00 00: players are allowed in total.
01 00 00 00: Unknown, it seems to be the number of computers.
01 00 00 00: Unknown, it seems to be the number of players.
01 00 00 00: available space.
08 00 00 00: unknown. It seems to be a value.

E0 17 = 0x17e0 = 6112, game port.

 

 

02 00 00: players are allowed in total.
01 00 00 00: Unknown, which seems to be a fixed value.
01 00 00 00: known, this is the number of players.
01 00 00 00: it is known that all vacancies except computers are available.
08 00 00 00: unknown. Constantly changing .......

E0 17 = 0x17e0 = 6112, game port.

All = map [map. length-22]; <br/> unknown = map [map. length-18]; <br/> People = map [map. length-14]; <br/> besidescp = map [map. length-10]; // This number is calculated as follows: all locations except the computer, including the locations where someone already exists. For example, the total number is 10 and three computers are added, then the number is 7, not whether there are any people in the seven positions. <Br/>

// This number is calculated as follows: all locations except the computer, including the locations where there are already people. For example, if the total number is 10 and three computers are added, the number is 7, none of the seven locations.

 

Paste the resolution code of the map here.

/** <Br/> * Host node of World of Warcraft (in the game, "Build the master", that is, what map is created) <br/> * parse host information <br/> * generate a host node, including map information, version, number of people, and so on. <br/> * parameters: byte [] map information package, inetaddress package IP address, int latency <br/> */<br/> package xinyu126.common; <br/> Import Java. io. unsupportedencodingexception; <br/> Import java.net. inetaddress; <br/> Import Java. util. arrays; <br/> Import Java. util. vector; <br/>/** <br/> * @ author xinyu126 <br/> */<br/> public class warnode {< Br/> string servername; <br/> string serverinfo; <br/> string mapstr; <br/> int all; <br/> int besidescp; <br/> int people; <br/> int unknow; <br/> int version; <br/> int timedelay; <br/> Public inetaddress IP = NULL; <br/> Public Boolean checked = true; <br/> Public warnode (byte [] map, inetaddress IP, int delay) {<br/> int I = 0; <br/> If (Map [0]! = (Byte) 0xf7 | map [1]! = (Byte) 0x30) {<br/> // This is not the map information! <Br/> return; <br/>}< br/> This. IP = IP; <br/> This. timedelay = delay; <br/> // version 8, 1.20 (20) 1.21 (21) or something <br/> Version = map [8]; <br/> // starting from 20th <br/> // game information, most of which are: "local LAN games (X ......" <Br/> byte [] T = new byte [32]; <br/> for (I = 0; I <32; I ++) {<br/> T [I] = map [I + 20]; <br/>}< br/> try {<br/> serverinfo = new string (t, "UTF-8"); <br/>}catch (unsupportedencodingexception e) {<br/> E. printstacktrace (); <br/>}</P> <p> // parse the map path and host name now <br/> I = 69; <br/> byte [] mapstr = new byte [64]; <br/> T = new byte [32]; <br/> int V = 0; <br/> int n = 0; <br/> Boolean flag = true; <br/> do {<br/> St Ring Mm = "00000000" + integer. tobinarystring (~ Map [I]); <br/> // system. out. println (mm); <br/> for (Int J = 1; j <8; j ++) {<br/> int c = map [I + J]; <br/> If (C = 0) {<br/> // If 0x00 is encountered, it indicates that break has ended. <br/>; <br/>}< br/> int K = '1' = mm. charat (mm. length ()-J-1 )? 1: 0; <br/> // system. out. println (k); </P> <p> If (C = 1) {<br/> // when the first 0x01 is encountered, the map path is complete, start parsing host name <br/> flag = false; <br/>}< br/> If (FLAG) {<br/> // Add it to the Map <br/> mapstr [v] = (byte) (c-k); <br/> V ++; <br/>} else {<br/> // Add it to the name <br/> // Note: if the name is not long enough, the three bytes 01 01 00 cannot be put down in the eight bytes, and the two Chinese "D5" <br/> // F9 B1 D5 "will be added later ", then, set the remaining 8 bytes to 01 00. in this case, remove this "hegemony ". Prevent garbled characters <br/> // todo temporarily. I know there are still many questions <br/> If (C! = (Byte) 0xd5 & C! = (Byte) 0xf9 & C! = (Byte) 0xb1) {<br/> T [N] = (byte) (c-k); <br/> N ++; <br/>}< br/> I + = 8; <br/>}while (Map [I]! = 1 & I <map. length-25); <br/> This. mapstr = "M" + new string (arrays. copyof (mapstr, v); <br/> servername = new string (arrays. copyof (t, n); <br/> All = map [map. length-22]; <br/> unknow = map [map. length-18]; <br/> People = map [map. length-14]; // <br/> besidescp = map [map. length-10]; // This number is calculated as follows: all locations except the computer, including the locations where someone already exists. For example, the total number is 10 and three computers are added, then the number is 7, not whether there are any people in the seven positions. <Br/> // system. out. println (serverinfo + "" + servername + "" + this. mapstr <br/> // + all + "" + computer); <br/>}< br/> Public vector <string> getinfo () {<br/> vector <string> VV = new vector <string> (); <br/> vv. add ("1. "+ version); <br/> vv. add (IP. gethostaddress (); <br/> vv. add (servername); <br/> vv. add (serverinfo); <br/> vv. add (mapstr); <br/> vv. add ("" + (all-besidescp + people) + "|" + ALL); <br/> vv. add (string. valueof (all-besidescp); <br/> vv. add ("" + timedelay); <br/> return vv; <br/>}< br/> Public void settimedelay (INT delay) {<br/> This. timedelay = delay; <br/>}< br/>

 

 

Complete program code in open source http://code.google.com/p/warpuber

Welcome to development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.