summaryrefslogtreecommitdiff
path: root/NET/worlds/network/UserServer.java
blob: c3112e67d21709cc9ad7b48c71e1f2f097fa1baa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package NET.worlds.network;

import NET.worlds.console.Console;

public class UserServer extends AnonUserServer {
   @Override
   protected sessionInitCmd buildSessionInitCmd() {
      OldPropertyList props = new OldPropertyList();
      String name = this._galaxy.getChatname();
      this._galaxy.setChatname(Console.parseUnicode(name));
      props.addProperty(new netProperty(3, String.valueOf(this.getVersion())));
      props.addProperty(new netProperty(9, String.valueOf(this._clientVersion)));
      this._firstLogon = this._galaxy.addPendingServer(this);
      switch (this.getGalaxy().getLoginMode()) {
         case 1:
         case 2:
            assert this._galaxy.getChatname() != null;

            this.regShortID(1, Console.parseUnicode(this._galaxy.getChatname()));
            props.addProperty(new netProperty(2, Console.parseUnicode(this._galaxy.getChatname())));
            if (this._galaxy.getNewChatname() != null) {
               props.addProperty(new netProperty(28, this._galaxy.getNewChatname()));
            }

            if (this._galaxy.getPassword() != null) {
               props.addProperty(new netProperty(6, this._galaxy.getPassword()));
            }

            if (this._galaxy.getNewPassword() != null) {
               props.addProperty(new netProperty(20, this._galaxy.getNewPassword()));
            }

            if (this._galaxy.getLoginMode() == 1) {
               if (this._galaxy.getSerialNum() != null) {
                  props.addProperty(new netProperty(10, this._galaxy.getSerialNum()));
               }
            } else if (this._firstLogon) {
               props.addProperty(new netProperty(12, "1"));
            }
            break;
         case 3:
            assert this._galaxy.getGuestExpiration() != null;

            props.addProperty(new netProperty(14, this._galaxy.getGuestExpiration()));
            if (this._firstLogon) {
               props.addProperty(new netProperty(12, "1"));
            }
            break;
         default:
            assert false;
      }

      if ((getDebugLevel() & 4) > 0) {
         synchronized (System.out) {
            System.out.println(this._serverURL.getHost() + ": sending sessionInit.");
            System.out.println("  username = \"" + this._galaxy.getChatname() + "\"");
            if (this._galaxy.getPassword() != null) {
               System.out.println("  password = " + this._galaxy.getPassword());
            }

            if (this._galaxy.getLoginMode() == 1 && this._galaxy.getSerialNum() != null) {
               System.out.println("  serial # = " + this._galaxy.getSerialNum());
            }

            if (this._galaxy.getLoginMode() == 3) {
               System.out.println("             VAR_GUEST");
            }
         }
      }

      return new sessionInitCmd(props);
   }
}