1 --- a/src/crypto/Keysearch2.java Tue Mar 24 00:48:47 2009 +0100
2 +++ b/src/crypto/Keysearch2.java Tue Mar 24 23:54:20 2009 +0100
3 @@ -26,14 +26,14 @@
4 import defines.Opcodes;
5
6 public class Keysearch2 {
7 -
8 +
9 // the calculated sessionkey, might be shuffled by 2*n bytes for n=0..9
10 - private byte[] sessionKey=new byte[defines.Constants.sessionKeyLength];
11 + private final byte[] sessionKey=new byte[defines.Constants.sessionKeyLength];
12
13 private byte[] unshuffledSessionKey;
14 -
15 - private ArrayList<TCPPacket> receivedPackets = new ArrayList<TCPPacket>();
16 -
17 +
18 + private final ArrayList<TCPPacket> receivedPackets = new ArrayList<TCPPacket>();
19 +
20 private int sessionKeyIndex, j;
21
22 private boolean initialized = false;
23 @@ -44,67 +44,65 @@
24
25 public void addTCPPacket(TCPPacket packet)
26 {
27 - receivedPackets.add(packet);
28 - if(!initialized || packet.getPayloadSize()<6)
29 + this.receivedPackets.add(packet);
30 + if(!this.initialized || (packet.getPayloadSize()<6))
31 {
32 - sessionKeyIndex = 0;
33 - j = packet.content[5];
34 - initialized=true;
35 + this.sessionKeyIndex = 0;
36 + this.j = packet.content[5];
37 + this.initialized=true;
38 return;
39 }
40 int payloadSize = packet.getPayloadSize()-2;
41 byte[] plainBytes = new byte[2];
42 for(int i=0; i<plainBytes.length; i++)
43 plainBytes[i]=(byte) (0xFF & (payloadSize>>((plainBytes.length-1-i)*8)));
44 -
45 +
46 byte[] encryptedBytes = new byte[2];
47 for(int i=0;i<encryptedBytes.length;i++)
48 encryptedBytes[i] = packet.content[i];
49 -
50 +
51 byte[] keyBytes = new byte[2];
52 for(int i=0; i<keyBytes.length; i++)
53 {
54 - keyBytes[i] = (byte) (0xFF&((encryptedBytes[i]-j)^plainBytes[i]));
55 + keyBytes[i] = (byte) (0xFF&((encryptedBytes[i]-this.j)^plainBytes[i]));
56 if(i != keyBytes.length-1)
57 - j=encryptedBytes[i];
58 + this.j=encryptedBytes[i];
59 }
60 -
61 +
62 //save retrieved keybytes
63 - for(int i=0; i<keyBytes.length;i++)
64 - {
65 - sessionKeyIndex += 1;
66 - sessionKey[sessionKeyIndex%sessionKey.length] = keyBytes[i];
67 + for (byte keyByte : keyBytes) {
68 + this.sessionKeyIndex += 1;
69 + this.sessionKey[this.sessionKeyIndex%this.sessionKey.length] = keyByte;
70 }
71 - sessionKeyIndex += 4;
72 - j = packet.content[5];
73 - if(analyzedEnoughPackets())
74 - performSessionkeyValidation();
75 + this.sessionKeyIndex += 4;
76 + this.j = packet.content[5];
77 + if(this.analyzedEnoughPackets())
78 + this.performSessionkeyValidation();
79 }
80 -
81 +
82 private void performSessionkeyValidation() {
83 System.out.println("got enough packets, verification started");
84 - for(int i=0; i<sessionKey.length; i++)
85 - {
86 - LiveDecryption ld = new LiveDecryption(sessionKey, 6);
87 - for(TCPPacket tcpPacket: receivedPackets)
88 + for (byte element : this.sessionKey) {
89 + LiveDecryption ld = new LiveDecryption(this.sessionKey, 6);
90 + for(TCPPacket tcpPacket: this.receivedPackets)
91 for(PlainPacket plainPacket:ld.Update(tcpPacket.content))
92 - if(plainPacket.opcode == VALIDATION_OPCODE)
93 + if(plainPacket.opcode == Keysearch2.VALIDATION_OPCODE)
94 {
95 - unshuffledSessionKey = sessionKey;
96 + this.unshuffledSessionKey = this.sessionKey;
97 return;
98 }
99 - shuffleSessionkey();
100 + this.shuffleSessionkey();
101 }
102 - System.err.println("performSessionkeyValidation: failed, packetcounter = "+receivedPackets.size());
103 + System.err.println("performSessionkeyValidation: failed, packetcounter = "+this.receivedPackets.size());
104 // oops, although we verified the sessionkey by reading it 2 times, something went wrong. reseting state
105 - initialized= false;
106 + this.initialized= false;
107 }
108
109 public boolean analyzedEnoughPackets() {
110 // *3= whole sessionkey
111 - return sessionKeyIndex >= sessionKey.length*3;
112 + return this.sessionKeyIndex >= this.sessionKey.length*3;
113 }
114 -/*
115 + /*
116 public void addTCPPackets(ArrayList<TCPPacket> receivedEncryptedPackets) {
117 for(TCPPacket packet: receivedEncryptedPackets)
118 {
119 @@ -115,24 +113,24 @@
120 return;
121 }
122 }
123 -*/
124 + */
125 public boolean hasValidSessionkey()
126 {
127 - return unshuffledSessionKey!=null;
128 + return this.unshuffledSessionKey!=null;
129 }
130
131 public byte[] getKey() {
132 - assert analyzedEnoughPackets() && hasValidSessionkey();
133 - return unshuffledSessionKey;
134 + assert this.analyzedEnoughPackets() && this.hasValidSessionkey();
135 + return this.unshuffledSessionKey;
136 }
137 -
138 +
139 private void shuffleSessionkey() {
140 - byte firstVal = sessionKey[0];
141 - for(int i=0; i<sessionKey.length-1; i++)
142 - sessionKey[i] = sessionKey[i+1];
143 - sessionKey[sessionKey.length-1] = firstVal;
144 + byte firstVal = this.sessionKey[0];
145 + for(int i=0; i<this.sessionKey.length-1; i++)
146 + this.sessionKey[i] = this.sessionKey[i+1];
147 + this.sessionKey[this.sessionKey.length-1] = firstVal;
148 }
149 -
150 +
151 /*
152 private int getNextPacketStart(int currentIndex)
153 {
154 @@ -141,5 +139,5 @@
155 currentIndex %= 6;
156 return additionArray[currentIndex];
157 }
158 - */
159 + */
160 }
1.1 --- a/src/crypto/LiveDecryption.java Tue Mar 24 00:48:47 2009 +0100
1.2 +++ b/src/crypto/LiveDecryption.java Tue Mar 24 23:54:20 2009 +0100
1.3 @@ -32,19 +32,19 @@
1.4 */
1.5 public class LiveDecryption {
1.6
1.7 - private byte[] sessionKey;
1.8 - private int headerLength;
1.9 - private ProcessByteBuffer buffer;
1.10 -
1.11 + private final byte[] sessionKey;
1.12 + private final int headerLength;
1.13 + private final ProcessByteBuffer buffer;
1.14 +
1.15 private int i, packetCounter;
1.16 private byte j;
1.17 -
1.18 +
1.19 public LiveDecryption(byte[] sessionKey, int headerLength) {
1.20 this.sessionKey = sessionKey;
1.21 this.headerLength = headerLength;
1.22 - if (sessionKey.length!=Constants.sessionKeyLength || (headerLength!=6 && headerLength!=4))
1.23 + if ((sessionKey.length!=Constants.sessionKeyLength) || ((headerLength!=6) && (headerLength!=4)))
1.24 throw new IllegalArgumentException();
1.25 - buffer= new ProcessByteBuffer();
1.26 + this.buffer= new ProcessByteBuffer();
1.27 }
1.28
1.29 public ArrayList<PlainPacket> Update(byte[] data)
1.30 @@ -70,21 +70,21 @@
1.31 // the first packet is always plain!
1.32 if (this.packetCounter >= 1)
1.33 {
1.34 - for(int cryptedIndex = 0; cryptedIndex< headerLength || additionalHeaderByte && cryptedIndex<= headerLength; cryptedIndex++)
1.35 + for(int cryptedIndex = 0; (cryptedIndex< this.headerLength) || (additionalHeaderByte && (cryptedIndex<= this.headerLength)); cryptedIndex++)
1.36 {
1.37 - i %= sessionKey.length;
1.38 + i %= this.sessionKey.length;
1.39 byte x = (byte) (0xFF&((((bufferCopy[index+cryptedIndex] - j)&0xFF)^
1.40 - (0xFF&sessionKey[i]))));
1.41 -
1.42 + (0xFF&this.sessionKey[i]))));
1.43 +
1.44 /// if the highest bit of the first size byte is set, the length is represented by 3 instead of 2 bytes!
1.45 /// thanks to TOM_RUS for telling me :)
1.46 - if(cryptedIndex == 0 && (x&0x80)!=0)
1.47 + if((cryptedIndex == 0) && ((x&0x80)!=0))
1.48 {
1.49 additionalHeaderByte=true;
1.50 }
1.51 i++;
1.52 j = (byte) (0xFF&bufferCopy[index+cryptedIndex]);
1.53 - bufferCopy[index+cryptedIndex] =(byte) x;
1.54 + bufferCopy[index+cryptedIndex] = x;
1.55 }
1.56 }
1.57 int headerIndex=0;
1.58 @@ -125,6 +125,6 @@
1.59 }
1.60
1.61 public int getDecryptedPacketCount() {
1.62 - return packetCounter;
1.63 + return this.packetCounter;
1.64 }
1.65 }
2.1 --- a/src/defines/Constants.java Tue Mar 24 00:48:47 2009 +0100
2.2 +++ b/src/defines/Constants.java Tue Mar 24 23:54:20 2009 +0100
2.3 @@ -30,27 +30,27 @@
2.4
2.5 static
2.6 {
2.7 - ChatMsg.put("WHISPER", new Integer(0x07));
2.8 + Constants.ChatMsg.put("WHISPER", Integer.valueOf(0x07));
2.9 }
2.10 -
2.11 +
2.12 static
2.13 {
2.14 - RealmAuthResults.put("SUCCESS", new Integer(0));
2.15 - RealmAuthResults.put("FAILURE", new Integer(0x01));
2.16 - RealmAuthResults.put("UNKNOWN1", new Integer(0x02));
2.17 - RealmAuthResults.put("ACCOUNT_BANNED", new Integer(0x03));
2.18 - RealmAuthResults.put("NO_MATCH", new Integer(0x04));
2.19 - RealmAuthResults.put("UNKNOWN2", new Integer(0x05));
2.20 - RealmAuthResults.put("ACCOUNT_IN_USE", new Integer(0x06));
2.21 - RealmAuthResults.put("PREPAID_TIME_LIMIT", new Integer(0x07));
2.22 - RealmAuthResults.put("SERVER_FULL", new Integer(0x08));
2.23 - RealmAuthResults.put("WRONG_BUILD_NUMBER", new Integer(0x09));
2.24 - RealmAuthResults.put("UPDATE_CLIENT", new Integer(0x0a));
2.25 - RealmAuthResults.put("UNKNOWN3", new Integer(0x0b));
2.26 - RealmAuthResults.put("ACCOUNT_FREEZED", new Integer(0x0c));
2.27 - RealmAuthResults.put("UNKNOWN4", new Integer(0x0d));
2.28 - RealmAuthResults.put("UNKNOWN5", new Integer(0x0e));
2.29 - RealmAuthResults.put("PARENTAL_CONTROL", new Integer(0x0f));
2.30 + Constants.RealmAuthResults.put("SUCCESS", Integer.valueOf(0));
2.31 + Constants.RealmAuthResults.put("FAILURE", Integer.valueOf(0x01));
2.32 + Constants.RealmAuthResults.put("UNKNOWN1", Integer.valueOf(0x02));
2.33 + Constants.RealmAuthResults.put("ACCOUNT_BANNED", Integer.valueOf(0x03));
2.34 + Constants.RealmAuthResults.put("NO_MATCH", Integer.valueOf(0x04));
2.35 + Constants.RealmAuthResults.put("UNKNOWN2", Integer.valueOf(0x05));
2.36 + Constants.RealmAuthResults.put("ACCOUNT_IN_USE", Integer.valueOf(0x06));
2.37 + Constants.RealmAuthResults.put("PREPAID_TIME_LIMIT", Integer.valueOf(0x07));
2.38 + Constants.RealmAuthResults.put("SERVER_FULL", Integer.valueOf(0x08));
2.39 + Constants.RealmAuthResults.put("WRONG_BUILD_NUMBER", Integer.valueOf(0x09));
2.40 + Constants.RealmAuthResults.put("UPDATE_CLIENT", Integer.valueOf(0x0a));
2.41 + Constants.RealmAuthResults.put("UNKNOWN3", Integer.valueOf(0x0b));
2.42 + Constants.RealmAuthResults.put("ACCOUNT_FREEZED", Integer.valueOf(0x0c));
2.43 + Constants.RealmAuthResults.put("UNKNOWN4", Integer.valueOf(0x0d));
2.44 + Constants.RealmAuthResults.put("UNKNOWN5", Integer.valueOf(0x0e));
2.45 + Constants.RealmAuthResults.put("PARENTAL_CONTROL", Integer.valueOf(0x0f));
2.46 }
2.47 }
2.48
3.1 --- a/src/gui/ChatFrame.java Tue Mar 24 00:48:47 2009 +0100
3.2 +++ b/src/gui/ChatFrame.java Tue Mar 24 23:54:20 2009 +0100
3.3 @@ -161,7 +161,7 @@
3.4 return;
3.5 }
3.6 sb.append(message.getMessage());
3.7 - sb.append("\n");
3.8 + sb.append('\n');
3.9
3.10 this.textArea.append(sb.toString());
3.11
4.1 --- a/src/gui/TargetFrame.java Tue Mar 24 00:48:47 2009 +0100
4.2 +++ b/src/gui/TargetFrame.java Tue Mar 24 23:54:20 2009 +0100
4.3 @@ -31,6 +31,7 @@
4.4 import processor.objects.InstancedObject;
4.5 import processor.objects.UpdateFields;
4.6 import processor.objects.WorldObject;
4.7 +import processor.tools.PackedGuid;
4.8 import processor.tools.Position;
4.9 import processor.tools.UpdateMask;
4.10
4.11 @@ -238,4 +239,8 @@
4.12 }
4.13 return ret;
4.14 }
4.15 +
4.16 + public void createObject(InstancedObject obj) {}
4.17 +
4.18 + public void removeObject(PackedGuid guid) {}
4.19 }
5.1 --- a/src/processor/ObjectManager.java Tue Mar 24 00:48:47 2009 +0100
5.2 +++ b/src/processor/ObjectManager.java Tue Mar 24 23:54:20 2009 +0100
5.3 @@ -43,9 +43,15 @@
5.4
5.5 public void putObject(InstancedObject wo) {
5.6 this.objectStore.put(wo.getGuid().getLong(), wo);
5.7 + for (ObjectListener ol : this.objListeners) {
5.8 + ol.createObject(wo);
5.9 + }
5.10 }
5.11
5.12 public void removeObject(PackedGuid guid) {
5.13 + for (ObjectListener ol : this.objListeners) {
5.14 + ol.removeObject(guid);
5.15 + }
5.16 this.objectStore.remove(guid.getLong());
5.17 }
5.18
5.19 @@ -75,7 +81,16 @@
5.20 this.objListeners.remove(ol);
5.21 }
5.22
5.23 + public void close() {
5.24 + this.objectStore.clear();
5.25 + this.objListeners.clear();
5.26 + this.playerNames.clear();
5.27 + }
5.28
5.29
5.30 + @Override
5.31 + protected void finalize() throws Throwable {
5.32 + System.out.println("Finalized ObjectManager");
5.33 + }
5.34
5.35 }
6.1 --- a/src/processor/Processor.java Tue Mar 24 00:48:47 2009 +0100
6.2 +++ b/src/processor/Processor.java Tue Mar 24 23:54:20 2009 +0100
6.3 @@ -139,9 +139,11 @@
6.4 synchronized (this) {
6.5 this.interrupt();
6.6 }
6.7 +
6.8 this.logger.stopLogging();
6.9 this.templateMgr.close();
6.10 this.chatMgr.close();
6.11 + this.objMgr.close();
6.12 try {
6.13 if(this.database != null)
6.14 this.database.close();
7.1 --- a/src/processor/TemplateManager.java Tue Mar 24 00:48:47 2009 +0100
7.2 +++ b/src/processor/TemplateManager.java Tue Mar 24 23:54:20 2009 +0100
7.3 @@ -182,13 +182,9 @@
7.4 CreatureTemplate ct = this.creatureTemplates.get(id);
7.5
7.6 if(ct == null) {
7.7 - try {
7.8 - ct = this.loadCreatureTemplate(id);
7.9 - if(ct != null)
7.10 - this.creatureTemplates.put(ct.entry, ct); // TODO: Get a working cache system!
7.11 - } catch (SQLException e) {
7.12 - e.printStackTrace();
7.13 - }
7.14 + ct = this.loadCreatureTemplate(id);
7.15 + if(ct != null)
7.16 + this.creatureTemplates.put(ct.entry, ct); // TODO: Get a working cache system!
7.17 }
7.18
7.19 return ct;
7.20 @@ -197,11 +193,7 @@
7.21 GameObjectTemplate got = this.goTemplates.get(id);
7.22
7.23 if(got == null) {
7.24 - try {
7.25 - got = this.loadGameObjectTemplate(id);
7.26 - } catch (SQLException e) {
7.27 - e.printStackTrace();
7.28 - }
7.29 + got = this.loadGameObjectTemplate(id);
7.30 }
7.31
7.32 return got;
7.33 @@ -210,201 +202,220 @@
7.34 ItemTemplate it = this.itemTemplates.get(id);
7.35
7.36 if(it == null) {
7.37 - try {
7.38 - it = this.loadItemTemplate(id);
7.39 - } catch (SQLException e) {
7.40 - e.printStackTrace();
7.41 - }
7.42 + it = this.loadItemTemplate(id);
7.43 }
7.44
7.45 return it;
7.46 }
7.47
7.48
7.49 - private CreatureTemplate loadCreatureTemplate(long entry) throws SQLException {
7.50 + private CreatureTemplate loadCreatureTemplate(long entry) {
7.51 if(this.loadCreatureTemplateStatement == null)
7.52 return null;
7.53
7.54 - ResultSet rs;
7.55 - synchronized (this.loadCreatureTemplateStatement) {
7.56 - this.loadCreatureTemplateStatement.setLong(1, entry);
7.57 - rs = this.loadCreatureTemplateStatement.executeQuery();
7.58 - }
7.59 + ResultSet rs = null;
7.60
7.61 - if(!rs.next()) {
7.62 + try {
7.63 + synchronized (this.loadCreatureTemplateStatement) {
7.64 + this.loadCreatureTemplateStatement.setLong(1, entry);
7.65 + rs = this.loadCreatureTemplateStatement.executeQuery();
7.66 + }
7.67 +
7.68 + if(!rs.next()) {
7.69 + rs.close();
7.70 + return null;
7.71 + }
7.72 +
7.73 + CreatureTemplate ct = new CreatureTemplate();
7.74 + ct.entry = rs.getLong(1);
7.75 +
7.76 + ct.name[0] = rs.getString(2);
7.77 + ct.name[1] = rs.getString(3);
7.78 + ct.name[2] = rs.getString(4);
7.79 + ct.name[3] = rs.getString(5);
7.80 +
7.81 + ct.subName = rs.getString(6);
7.82 + ct.iconName = rs.getString(7);
7.83 + ct.flag1 = rs.getLong(8);
7.84 + ct.type = rs.getLong(9);
7.85 + ct.family = rs.getLong(10);
7.86 + ct.rank = rs.getLong(11);
7.87 + ct.spellDataID = rs.getLong(12);
7.88 + ct.displayID_A = rs.getLong(13);
7.89 + ct.displayID_A2 = rs.getLong(14);
7.90 + ct.displayID_H = rs.getLong(15);
7.91 + ct.displayID_H2 = rs.getLong(16);
7.92 + ct.unk1 = rs.getFloat(17);
7.93 + ct.unk2 = rs.getFloat(18);
7.94 + ct.isRaceLeader = rs.getInt(19);
7.95 rs.close();
7.96 +
7.97 + return ct;
7.98 + } catch (SQLException e) {
7.99 + try {if(rs != null)rs.close();} catch (SQLException f) {}
7.100 +
7.101 + e.printStackTrace();
7.102 return null;
7.103 }
7.104 -
7.105 - CreatureTemplate ct = new CreatureTemplate();
7.106 - ct.entry = rs.getLong(1);
7.107 -
7.108 - ct.name[0] = rs.getString(2);
7.109 - ct.name[1] = rs.getString(3);
7.110 - ct.name[2] = rs.getString(4);
7.111 - ct.name[3] = rs.getString(5);
7.112 -
7.113 - ct.subName = rs.getString(6);
7.114 - ct.iconName = rs.getString(7);
7.115 - ct.flag1 = rs.getLong(8);
7.116 - ct.type = rs.getLong(9);
7.117 - ct.family = rs.getLong(10);
7.118 - ct.rank = rs.getLong(11);
7.119 - ct.spellDataID = rs.getLong(12);
7.120 - ct.displayID_A = rs.getLong(13);
7.121 - ct.displayID_A2 = rs.getLong(14);
7.122 - ct.displayID_H = rs.getLong(15);
7.123 - ct.displayID_H2 = rs.getLong(16);
7.124 - ct.unk1 = rs.getFloat(17);
7.125 - ct.unk2 = rs.getFloat(18);
7.126 - ct.isRaceLeader = rs.getInt(19);
7.127 - rs.close();
7.128 -
7.129 - return ct;
7.130 }
7.131 - private GameObjectTemplate loadGameObjectTemplate(long entry) throws SQLException {
7.132 + private GameObjectTemplate loadGameObjectTemplate(long entry) {
7.133 if(this.loadGameobjectTemplateStatement == null)
7.134 return null;
7.135
7.136 - ResultSet rs;
7.137 - synchronized (this.loadGameobjectTemplateStatement) {
7.138 - this.loadGameobjectTemplateStatement.setLong(1, entry);
7.139 - rs = this.loadGameobjectTemplateStatement.executeQuery();
7.140 - }
7.141 + ResultSet rs = null;
7.142
7.143 - if(!rs.next()) {
7.144 + try {
7.145 + synchronized (this.loadGameobjectTemplateStatement) {
7.146 + this.loadGameobjectTemplateStatement.setLong(1, entry);
7.147 + rs = this.loadGameobjectTemplateStatement.executeQuery();
7.148 + }
7.149 +
7.150 + if(!rs.next()) {
7.151 + rs.close();
7.152 + return null;
7.153 + }
7.154 +
7.155 + GameObjectTemplate got = new GameObjectTemplate();
7.156 + int counter = 1;
7.157 +
7.158 + got.entry = rs.getLong(counter++);
7.159 + got.type = rs.getLong(counter++);
7.160 + got.displayID = rs.getLong(counter++);
7.161 + for (int i = 0; i < got.name.length; i++) {
7.162 + got.name[i] = rs.getString(counter++);
7.163 + }
7.164 + for (int i = 0; i < got.data.length; i++) {
7.165 + got.data[i] = rs.getLong(counter++);
7.166 + }
7.167 + got.size = rs.getFloat(counter++);
7.168 + got.faction = rs.getLong(counter++);
7.169 + got.flags = rs.getLong(counter++);
7.170 +
7.171 rs.close();
7.172 + return got;
7.173 + } catch (SQLException e) {
7.174 + try {if(rs != null)rs.close();} catch (SQLException f) {}
7.175 +
7.176 + e.printStackTrace();
7.177 return null;
7.178 }
7.179 -
7.180 - GameObjectTemplate got = new GameObjectTemplate();
7.181 - int counter = 1;
7.182 -
7.183 - got.entry = rs.getLong(counter++);
7.184 - got.type = rs.getLong(counter++);
7.185 - got.displayID = rs.getLong(counter++);
7.186 - for (int i = 0; i < got.name.length; i++) {
7.187 - got.name[i] = rs.getString(counter++);
7.188 - }
7.189 - for (int i = 0; i < got.data.length; i++) {
7.190 - got.data[i] = rs.getLong(counter++);
7.191 - }
7.192 - got.size = rs.getFloat(counter++);
7.193 - got.faction = rs.getLong(counter++);
7.194 - got.flags = rs.getLong(counter++);
7.195 -
7.196 - rs.close();
7.197 - return got;
7.198 }
7.199 - private ItemTemplate loadItemTemplate(long entry) throws SQLException {
7.200 + private ItemTemplate loadItemTemplate(long entry) {
7.201 if(this.loadItemTemplateStatement== null)
7.202 return null;
7.203
7.204 - ResultSet rs;
7.205 - synchronized (this.loadItemTemplateStatement) {
7.206 - this.loadItemTemplateStatement.setLong(1, entry);
7.207 - rs = this.loadItemTemplateStatement.executeQuery();
7.208 - }
7.209 + ResultSet rs = null;
7.210 + try {
7.211 + synchronized (this.loadItemTemplateStatement) {
7.212 + this.loadItemTemplateStatement.setLong(1, entry);
7.213 + rs = this.loadItemTemplateStatement.executeQuery();
7.214 + }
7.215
7.216 - if(!rs.next()) {
7.217 + if(!rs.next()) {
7.218 + rs.close();
7.219 + return null;
7.220 + }
7.221 +
7.222 + ItemTemplate it = new ItemTemplate();
7.223 + int counter = 1;
7.224 +
7.225 + it.entry = rs.getLong(counter++);
7.226 + it.itemClass = rs.getLong(counter++);
7.227 + it.subClass = rs.getLong(counter++);
7.228 + it.unk1 = rs.getInt(counter++);
7.229 + it.name[0] = rs.getString(counter++);
7.230 + it.name[1] = rs.getString(counter++);
7.231 + it.name[2] = rs.getString(counter++);
7.232 + it.name[3] = rs.getString(counter++);
7.233 + it.displayid = rs.getLong(counter++);
7.234 + it.Quality = rs.getLong(counter++);
7.235 + it.Flags = rs.getLong(counter++);
7.236 + it.BuyPrice = rs.getLong(counter++);
7.237 + it.SellPrice = rs.getLong(counter++);
7.238 + it.InventoryType = rs.getLong(counter++);
7.239 + it.AllowableClass = rs.getInt(counter++);
7.240 + it.AllowableRace = rs.getInt(counter++);
7.241 + it.ItemLevel = rs.getLong(counter++);
7.242 + it.RequiredLevel = rs.getLong(counter++);
7.243 + it.RequiredSkill = rs.getLong(counter++);
7.244 + it.RequiredSkillRank = rs.getLong(counter++);
7.245 + it.RequiredSpell = rs.getLong(counter++);
7.246 + it.RequiredHonorRank = rs.getLong(counter++);
7.247 + it.RequiredCityRank = rs.getLong(counter++);
7.248 + it.RequiredReputationFaction = rs.getLong(counter++);
7.249 + it.RequiredReputationRank = rs.getLong(counter++);
7.250 + it.MaxCount = rs.getLong(counter++);
7.251 + it.Stackable = rs.getLong(counter++);
7.252 + it.ContainerSlots = rs.getLong(counter++);
7.253 + for (int i = 0; i < it.stat_type.length; i++) {
7.254 + it.stat_type[i] = rs.getLong(counter++);
7.255 + it.stat_value[i] = rs.getLong(counter++);
7.256 + }
7.257 + it.s1 = rs.getLong(counter++);
7.258 + it.s2 = rs.getLong(counter++);
7.259 + for (int i = 0; i < it.dmg_min.length; i++) {
7.260 + it.dmg_min[i] = rs.getLong(counter++);
7.261 + it.dmg_max[i] = rs.getLong(counter++);
7.262 + it.dmg_type[i] = rs.getLong(counter++);
7.263 + }
7.264 + it.Armor = rs.getLong(counter++);
7.265 + it.holy_res = rs.getLong(counter++);
7.266 + it.fire_res = rs.getLong(counter++);
7.267 + it.nature_res = rs.getLong(counter++);
7.268 + it.frost_res = rs.getLong(counter++);
7.269 + it.shadow_res = rs.getLong(counter++);
7.270 + it.arcane_res = rs.getLong(counter++);
7.271 + it.Delay = rs.getLong(counter++);
7.272 + it.Ammo_type = rs.getLong(counter++);
7.273 + it.RangedModRange = rs.getFloat(counter++);
7.274 + for (int i = 0; i < it.spellid_.length; i++) {
7.275 + it.spellid_[i] = rs.getLong(counter++);
7.276 + it.spelltrigger_[i] = rs.getLong(counter++);
7.277 + it.spellcharges_[i] = rs.getLong(counter++);
7.278 + it.spellcooldown_[i] = rs.getInt(counter++);
7.279 + it.spellcategory_[i] = rs.getLong(counter++);
7.280 + it.spellcategorycooldown_[i]= rs.getInt(counter++);
7.281 + }
7.282 +
7.283 + it.Bonding = rs.getLong(counter++);
7.284 + it.Description = rs.getString(counter++);
7.285 + it.PageText = rs.getLong(counter++);
7.286 + it.LanguageID = rs.getLong(counter++);
7.287 + it.PageMaterial = rs.getLong(counter++);
7.288 + it.StartQuest = rs.getLong(counter++);
7.289 + it.LockID = rs.getLong(counter++);
7.290 + it.Material = rs.getLong(counter++);
7.291 + it.Sheath = rs.getLong(counter++);
7.292 + it.RandomProperty = rs.getLong(counter++);
7.293 + it.RandomSuffix = rs.getLong(counter++);
7.294 + it.Block = rs.getLong(counter++);
7.295 + it.ItemSet = rs.getLong(counter++);
7.296 + it.MaxDurability = rs.getLong(counter++);
7.297 + it.Area = rs.getLong(counter++);
7.298 + it.Map = rs.getLong(counter++);
7.299 + it.BagFamily = rs.getLong(counter++);
7.300 + it.TotemCategory = rs.getLong(counter++);
7.301 + for (int i = 0; i < it.socketColor_.length; i++) {
7.302 + it.socketColor_[i] = rs.getLong(counter++);
7.303 + it.socketContent_[i] = rs.getLong(counter++);
7.304 + }
7.305 + it.socketBonus = rs.getLong(counter++);
7.306 + it.GemProperties = rs.getLong(counter++);
7.307 + it.RequiredDisenchantSkill = rs.getInt(counter++);
7.308 + it.ArmorDamageModifier = rs.getLong(counter++);
7.309 + it.DurationInSeconds = rs.getLong(counter++);
7.310 + it.unk2 = rs.getLong(counter++);
7.311 +
7.312 +
7.313 rs.close();
7.314 +
7.315 + return it;
7.316 + } catch (SQLException e) {
7.317 + try {if(rs != null)rs.close();} catch (SQLException f) {}
7.318 +
7.319 + e.printStackTrace();
7.320 return null;
7.321 }
7.322 -
7.323 - ItemTemplate it = new ItemTemplate();
7.324 - int counter = 1;
7.325 -
7.326 - it.entry = rs.getLong(counter++);
7.327 - it.itemClass = rs.getLong(counter++);
7.328 - it.subClass = rs.getLong(counter++);
7.329 - it.unk1 = rs.getInt(counter++);
7.330 - it.name[0] = rs.getString(counter++);
7.331 - it.name[1] = rs.getString(counter++);
7.332 - it.name[2] = rs.getString(counter++);
7.333 - it.name[3] = rs.getString(counter++);
7.334 - it.displayid = rs.getLong(counter++);
7.335 - it.Quality = rs.getLong(counter++);
7.336 - it.Flags = rs.getLong(counter++);
7.337 - it.BuyPrice = rs.getLong(counter++);
7.338 - it.SellPrice = rs.getLong(counter++);
7.339 - it.InventoryType = rs.getLong(counter++);
7.340 - it.AllowableClass = rs.getInt(counter++);
7.341 - it.AllowableRace = rs.getInt(counter++);
7.342 - it.ItemLevel = rs.getLong(counter++);
7.343 - it.RequiredLevel = rs.getLong(counter++);
7.344 - it.RequiredSkill = rs.getLong(counter++);
7.345 - it.RequiredSkillRank = rs.getLong(counter++);
7.346 - it.RequiredSpell = rs.getLong(counter++);
7.347 - it.RequiredHonorRank = rs.getLong(counter++);
7.348 - it.RequiredCityRank = rs.getLong(counter++);
7.349 - it.RequiredReputationFaction = rs.getLong(counter++);
7.350 - it.RequiredReputationRank = rs.getLong(counter++);
7.351 - it.MaxCount = rs.getLong(counter++);
7.352 - it.Stackable = rs.getLong(counter++);
7.353 - it.ContainerSlots = rs.getLong(counter++);
7.354 - for (int i = 0; i < it.stat_type.length; i++) {
7.355 - it.stat_type[i] = rs.getLong(counter++);
7.356 - it.stat_value[i] = rs.getLong(counter++);
7.357 - }
7.358 - it.s1 = rs.getLong(counter++);
7.359 - it.s2 = rs.getLong(counter++);
7.360 - for (int i = 0; i < it.dmg_min.length; i++) {
7.361 - it.dmg_min[i] = rs.getLong(counter++);
7.362 - it.dmg_max[i] = rs.getLong(counter++);
7.363 - it.dmg_type[i] = rs.getLong(counter++);
7.364 - }
7.365 - it.Armor = rs.getLong(counter++);
7.366 - it.holy_res = rs.getLong(counter++);
7.367 - it.fire_res = rs.getLong(counter++);
7.368 - it.nature_res = rs.getLong(counter++);
7.369 - it.frost_res = rs.getLong(counter++);
7.370 - it.shadow_res = rs.getLong(counter++);
7.371 - it.arcane_res = rs.getLong(counter++);
7.372 - it.Delay = rs.getLong(counter++);
7.373 - it.Ammo_type = rs.getLong(counter++);
7.374 - it.RangedModRange = rs.getFloat(counter++);
7.375 - for (int i = 0; i < it.spellid_.length; i++) {
7.376 - it.spellid_[i] = rs.getLong(counter++);
7.377 - it.spelltrigger_[i] = rs.getLong(counter++);
7.378 - it.spellcharges_[i] = rs.getLong(counter++);
7.379 - it.spellcooldown_[i] = rs.getInt(counter++);
7.380 - it.spellcategory_[i] = rs.getLong(counter++);
7.381 - it.spellcategorycooldown_[i]= rs.getInt(counter++);
7.382 - }
7.383 -
7.384 - it.Bonding = rs.getLong(counter++);
7.385 - it.Description = rs.getString(counter++);
7.386 - it.PageText = rs.getLong(counter++);
7.387 - it.LanguageID = rs.getLong(counter++);
7.388 - it.PageMaterial = rs.getLong(counter++);
7.389 - it.StartQuest = rs.getLong(counter++);
7.390 - it.LockID = rs.getLong(counter++);
7.391 - it.Material = rs.getLong(counter++);
7.392 - it.Sheath = rs.getLong(counter++);
7.393 - it.RandomProperty = rs.getLong(counter++);
7.394 - it.RandomSuffix = rs.getLong(counter++);
7.395 - it.Block = rs.getLong(counter++);
7.396 - it.ItemSet = rs.getLong(counter++);
7.397 - it.MaxDurability = rs.getLong(counter++);
7.398 - it.Area = rs.getLong(counter++);
7.399 - it.Map = rs.getLong(counter++);
7.400 - it.BagFamily = rs.getLong(counter++);
7.401 - it.TotemCategory = rs.getLong(counter++);
7.402 - for (int i = 0; i < it.socketColor_.length; i++) {
7.403 - it.socketColor_[i] = rs.getLong(counter++);
7.404 - it.socketContent_[i] = rs.getLong(counter++);
7.405 - }
7.406 - it.socketBonus = rs.getLong(counter++);
7.407 - it.GemProperties = rs.getLong(counter++);
7.408 - it.RequiredDisenchantSkill = rs.getInt(counter++);
7.409 - it.ArmorDamageModifier = rs.getLong(counter++);
7.410 - it.DurationInSeconds = rs.getLong(counter++);
7.411 - it.unk2 = rs.getLong(counter++);
7.412 -
7.413 -
7.414 - rs.close();
7.415 -
7.416 - return it;
7.417 }
7.418
7.419 private void saveCreatureTemplate(CreatureTemplate ct) throws SQLException {
8.1 --- a/src/processor/listener/ObjectListener.java Tue Mar 24 00:48:47 2009 +0100
8.2 +++ b/src/processor/listener/ObjectListener.java Tue Mar 24 23:54:20 2009 +0100
8.3 @@ -2,11 +2,14 @@
8.4
8.5 import processor.objects.InstancedObject;
8.6 import processor.objects.WorldObject;
8.7 +import processor.tools.PackedGuid;
8.8 import processor.tools.Position;
8.9 import processor.tools.UpdateMask;
8.10
8.11 public interface ObjectListener {
8.12
8.13 + public void createObject(InstancedObject obj);
8.14 + public void removeObject(PackedGuid guid);
8.15 public void valuesChanged(InstancedObject obj, UpdateMask uMask);
8.16 public void objectMoved(WorldObject obj, Position pos);
8.17 }