mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Add graphic height support to npcs
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
</rsa>
|
||||
|
||||
<ports>
|
||||
<http>80</http>
|
||||
<http>43596</http>
|
||||
<service>43594</service>
|
||||
<jaggrab>43595</jaggrab>
|
||||
</ports>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user