summaryrefslogtreecommitdiff
path: root/NET/worlds/network/sessionInitCmd.java
blob: 32b6b77db48f5be706c3d19184acb9af2e9f82a5 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package NET.worlds.network;

import NET.worlds.console.Console;
import java.util.Enumeration;

public class sessionInitCmd extends propCmd {
   public static final byte SESSIONINITCMD = 6;

   public sessionInitCmd() {
      this._commandType = 6;
   }

   public sessionInitCmd(String user, String pass, String proto, String avatars, String ver) {
      this._commandType = 6;

      assert user != null;

      this._propList.addProperty(new netProperty(2, user));
      if (pass != null) {
         this._propList.addProperty(new netProperty(6, pass));
      }

      this._propList.addProperty(new netProperty(3, proto));
      this._propList.addProperty(new netProperty(7, avatars));
      this._propList.addProperty(new netProperty(9, ver));
   }

   public sessionInitCmd(OldPropertyList props) {
      this._commandType = 6;
      this._propList = props;
   }

   @Override
   void process(WorldServer serv) throws Exception {
      if (serv.getState() == 8) {
         for (int i = 0; i < this._propList.size(); i++) {
            netProperty tmpProp = this._propList.elementAt(i);
            switch (tmpProp.property()) {
               case 1:
               case 3:
               case 8:
               case 13:
               case 15:
                  break;
               case 2:
                  serv.setUsername(tmpProp.value());
                  serv.getGalaxy().setNewChatname(null);
                  break;
               case 4:
                  try {
                     int errorval = Integer.parseInt(tmpProp.value());
                     if (errorval != 0) {
                        throw new VarErrorException(errorval);
                     }
                  } catch (NumberFormatException var7) {
                     System.err.println("sessionInitCmd: couldn't parse VAR_ERROR = " + tmpProp.value());
                  }
                  break;
               case 5:
                  serv.getGalaxy().setChannel(tmpProp.value());
                  break;
               case 6:
                  serv.getGalaxy().setPassword(tmpProp.value());
                  serv.getGalaxy().setNewPassword(null);
                  break;
               case 7:
               case 9:
               case 11:
               case 12:
               case 14:
               case 16:
               case 17:
               case 18:
               case 19:
               case 20:
               case 21:
               default:
                  System.out.println("sessionInitCmd: received unknown property: " + tmpProp.property());

                  assert false;
                  break;
               case 10:
                  serv.getGalaxy().setSerialNum(tmpProp.value());
                  break;
               case 22:
                  try {
                     int priv = Integer.parseInt(tmpProp.value());
                     Enumeration<NetworkObject> list = serv.getGalaxy().getConsoles();

                     while (list.hasMoreElements()) {
                        Console c = (Console)list.nextElement();
                        c.setVIP((priv & 8) != 0);
                        c.setFullVIP((priv & 16) != 0);
                        c.setSpecialGuest((priv & 64) != 0);
                     }

                     list = serv.getGalaxy().getConsoles();

                     while (list.hasMoreElements()) {
                        Console c = (Console)list.nextElement();
                        c.enableBroadcast((priv & 2) != 0);
                     }
                  } catch (NumberFormatException var8) {
                  }
            }
         }

         if (serv.getVersion() < 18) {
            serv.setState(9);
         } else {
            serv.setState(11);
         }
      }
   }

   @Override
   public String toString(WorldServer serv) {
      return "SESSINIT " + this._propList;
   }
}