summaryrefslogtreecommitdiff
path: root/NET/worlds/network/SMState.java
blob: 013855941723ab03aa44a68d491bf373f0a2ad01 (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
package NET.worlds.network;

import NET.worlds.core.IniFile;

class SMState {
   private int _state;
   private WorldServer _ws;
   private static int _debugLevel;

   static {
      try {
         _debugLevel = Integer.parseInt(IniFile.gamma().getIniString("netdebug", "0"));
      } catch (NumberFormatException var1) {
         _debugLevel = 0;
      }
   }

   public SMState(WorldServer ws, int state) {
      this._state = state;
      this._ws = ws;
   }

   public int getState() {
      return this._state;
   }

   public synchronized void setState(int state) {
      if ((_debugLevel & 8) > 0) {
         synchronized (System.out) {
            System.out.println(this._ws + ": *** new state: " + state);
            if ((_debugLevel & 16) > 0) {
               try {
                  throw new InterruptedException();
               } catch (InterruptedException var4) {
                  var4.printStackTrace(System.out);
                  System.out.println("******************************");
               }
            }
         }
      }

      this._state = state;
      this.notifyAll();
   }

   public synchronized void waitForState(int state) throws InfiniteWaitException {
      while (this._state != state) {
         try {
            this.wait();
         } catch (InterruptedException var3) {
            assert false;
         }

         if (this._state == -1) {
            throw new InfiniteWaitException();
         }
      }
   }
}