Add graphic height support to npcs

This commit is contained in:
thispixel
2015-03-13 14:34:51 +00:00
parent 9c0cf17141
commit af4be4b916
5 changed files with 83 additions and 4 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
</rsa>
<ports>
<http>80</http>
<http>43596</http>
<service>43594</service>
<jaggrab>43595</jaggrab>
</ports>
+7
View File
@@ -67,5 +67,12 @@
<artifactId>scrypt</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5</version>
</dependency>
</dependencies>
</project>
@@ -194,8 +194,8 @@ public final class NpcSynchronizationMessageEncoder extends MessageEncoder<NpcSy
private static void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
Graphic graphic = block.getGraphic();
builder.put(DataType.SHORT, graphic.getId());
builder.put(DataType.INT, graphic.getDelay());
}
builder.put(DataType.INT, graphic.getHeight() << 16 | graphic.getDelay() & 0xFFFF);
}
/**
* Puts a hit update block into the specified builder.
@@ -194,7 +194,7 @@ public final class NpcSynchronizationMessageEncoder extends MessageEncoder<NpcSy
private static void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
Graphic graphic = block.getGraphic();
builder.put(DataType.SHORT, graphic.getId());
builder.put(DataType.INT, DataOrder.MIDDLE, graphic.getDelay());
builder.put(DataType.INT, graphic.getHeight() << 16 | graphic.getDelay() & 0xFFFF);
}
/**
+72
View File
@@ -0,0 +1,72 @@
package org.apollo.util;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apollo.util.xml.XmlNode;
import org.apollo.util.xml.XmlParser;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
/**
*
*
* @author Stuart
*/
public final class DatabaseUtil {
/**
*
*/
private static final ComboPooledDataSource pool = new ComboPooledDataSource();
static {
try(InputStream is = new FileInputStream("data/database.xml")) {
XmlNode config = new XmlParser().parse(is);
if(!config.getName().equals("database")) {
throw new IOException("Root node is not 'database'.");
}
XmlNode url = config.getChild("url"), username = config.getChild("username"), password = config.getChild("password");
if(url == null || username == null || password == null) {
throw new IOException("Root node must contain these three children - 'url', 'username', 'password'.");
}
pool.setJdbcUrl(url.getValue());
pool.setUser(username.getValue());
pool.setPassword(password.getValue());
// optional params
XmlNode initialPoolSize = config.getChild("initial_pool_size"), acquireIncrement = config.getChild("acquire_increment"),
maxPoolSize = config.getChild("max_pool_size"), minPoolSize = config.getChild("min_pool_size");
if(initialPoolSize != null) {
pool.setInitialPoolSize(Integer.parseInt(initialPoolSize.getValue()));
}
if(acquireIncrement != null) {
pool.setAcquireIncrement(Integer.parseInt(acquireIncrement.getValue()));
}
if(maxPoolSize != null) {
pool.setMaxPoolSize(Integer.parseInt(maxPoolSize.getValue()));
}
if(minPoolSize != null) {
pool.setMinPoolSize(Integer.parseInt(minPoolSize.getValue()));
}
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
/**
*
*
* @return
* @throws SQLException
*/
public static Connection getConnection() throws SQLException {
return pool.getConnection();
}
}