diff --git a/aoxp-server/src/main/java/com/ao/data/dao/ini/UserDAOIni.java b/aoxp-server/src/main/java/com/ao/data/dao/ini/UserDAOIni.java
index d3729fa..f77c6a4 100755
--- a/aoxp-server/src/main/java/com/ao/data/dao/ini/UserDAOIni.java
+++ b/aoxp-server/src/main/java/com/ao/data/dao/ini/UserDAOIni.java
@@ -33,6 +33,7 @@
import org.apache.log4j.Logger;
import org.ini4j.Ini;
+import com.ao.context.ApplicationContext;
import com.ao.data.dao.AccountDAO;
import com.ao.data.dao.UserCharacterDAO;
import com.ao.data.dao.exception.DAOException;
@@ -48,9 +49,11 @@
import com.ao.model.character.archetype.UserArchetype;
import com.ao.model.map.City;
import com.ao.model.map.Heading;
+import com.ao.model.map.Position;
import com.ao.model.user.Account;
import com.ao.model.user.AccountImpl;
import com.ao.model.user.LoggedUser;
+import com.ao.service.MapService;
import com.google.inject.Inject;
import com.google.inject.name.Named;
@@ -191,7 +194,11 @@ public class UserDAOIni implements AccountDAO, UserCharacterDAO {
protected static final int INITIAL_NOBLE_POINTS = 1000;
private static final Logger logger = Logger.getLogger(UserDAOIni.class);
-
+
+ /*---------FIXME awful workaround to be able to set char's position-----------*/
+ private MapService mapService = ApplicationContext.getInstance(MapService.class);
+ /*----------------------------------------------------------------------------*/
+
private String charfilesPath;
@Inject
@@ -285,6 +292,9 @@ public UserCharacter create(String name, Race race, Gender gender,
String positionKey = homeland.getMap() + "-" + homeland.getX() + "-" + homeland.getY();
chara.put(INIT_HEADER, POSITION_KEY, positionKey );
+
+ Position position= new Position(homeland.getX(), homeland.getY(), mapService.getMap(homeland.getMap()));
+
// TODO: Save last ip?
chara.put(FLAGS_HEADER, BANNED_KEY, 0);
@@ -380,8 +390,8 @@ public UserCharacter create(String name, Race race, Gender gender,
}
// TODO: Update this when hp, mana and hit points get updated!
- return new LoggedUser(rep, race, gender, archetype.getArchetype(),
- false, false, false, false, false, false, 0, 0, 0, 0,
+ return new LoggedUser(rep, race, gender, archetype.getArchetype(), homeland, position,
+ false, false, false, false, false, false, false, 0, 0, 0, 0,
100, 0, 100, 0, (byte) 1, name, "");
}
@@ -423,6 +433,18 @@ public UserCharacter load(String username) throws DAOException {
Archetype archetype = UserArchetype.get(Byte.parseByte(chara.get(INIT_HEADER, ARCHETYPE_KEY))).getArchetype();
+ int homeId= Integer.parseInt(chara.get(INIT_HEADER, HOMELAND_KEY));
+
+ City homeland= new City( homeId, mapService.getCity((byte)homeId).getX() , mapService.getCity((byte)homeId).getY());
+
+ String[] stringPos= chara.get(INIT_HEADER, POSITION_KEY).split("-");
+
+ Position position= new Position (
+ Byte.parseByte(stringPos[1]),
+ Byte.parseByte(stringPos[2]),
+ mapService.getMap(Integer.parseInt(stringPos[0]))
+ );
+
boolean poisoned = chara.get(FLAGS_HEADER, POISONED_KEY).equals("1");
boolean paralyzed = chara.get(FLAGS_HEADER, PARALYZED_KEY).equals("1");
@@ -450,9 +472,7 @@ public UserCharacter load(String username) throws DAOException {
String description = "";
// TODO : Validate character
- /* UserCharacter userCharacter = new LoggedUser(reputation, race, gender, archetype, poisoned, paralyzed, immobilized, invisible, mimetized, dumbed, hidden, maxMana, maxHitPoints, mana, hitpoints, thirstiness, hunger, lvl, username, description); */
-
- return null;
+ return new LoggedUser(reputation, race, gender, archetype, homeland, position, poisoned, paralyzed, immobilized, invisible, mimetized, dumbed, hidden, maxMana, mana, maxHitPoints, hitpoints, 100, thirstiness, 100, hunger, lvl, username, description);
}
private Ini readCharFile(String username) throws DAOException {
diff --git a/aoxp-server/src/main/java/com/ao/data/dao/map/WorldMapDAOImpl.java b/aoxp-server/src/main/java/com/ao/data/dao/map/WorldMapDAOImpl.java
index 20c15fb..c8a01c0 100644
--- a/aoxp-server/src/main/java/com/ao/data/dao/map/WorldMapDAOImpl.java
+++ b/aoxp-server/src/main/java/com/ao/data/dao/map/WorldMapDAOImpl.java
@@ -112,7 +112,12 @@ private void loadMap(int id, WorldMap[] maps) {
logger.error("Map " + id + " loading failed!", e);
throw new RuntimeException(e);
}
-
+ try {
+ dataInf.close();
+ dataMap.close();
+
+ } catch (IOException e) {}
+
ByteBuffer infBuffer = ByteBuffer.wrap(bufInf);
ByteBuffer mapBuffer = ByteBuffer.wrap(bufMap);
diff --git a/aoxp-server/src/main/java/com/ao/model/builder/UserCharacterBuilder.java b/aoxp-server/src/main/java/com/ao/model/builder/UserCharacterBuilder.java
index 2c1d199..3dfb853 100644
--- a/aoxp-server/src/main/java/com/ao/model/builder/UserCharacterBuilder.java
+++ b/aoxp-server/src/main/java/com/ao/model/builder/UserCharacterBuilder.java
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-*/
+ */
package com.ao.model.builder;
import java.util.Map;
@@ -44,6 +44,7 @@
*/
public class UserCharacterBuilder implements Builder {
+ //TODO we should mention what constitutes a valid name in this message.
public static final String INVALID_NAME_ERROR = "El nombre ingresado no es válido.";
public static final String INVALID_EMAIL_ERROR = "La dirección de e-mail ingresada no es válida.";
@@ -70,6 +71,7 @@ public class UserCharacterBuilder implements Builder {
protected boolean hidden = false;
protected boolean immobilized = false;
protected boolean invisible = false;
+ protected boolean mimetized = false;
protected byte lvl = 1;
protected boolean poisoned = false;
protected Guild guild;
@@ -122,6 +124,12 @@ public UserCharacterBuilder withInvisible(boolean invisible) {
return this;
}
+
+ public UserCharacterBuilder withMimetized(boolean mimetized) {
+ this.mimetized= mimetized;
+
+ return this;
+ }
public UserCharacterBuilder withDumbed(boolean dumbed) {
this.dumbed = dumbed;
@@ -238,7 +246,7 @@ public UserCharacterBuilder withMana(int minMana, int maxMana) {
public UserCharacterBuilder withSkills(Map skills) throws InvalidAttributeValueException {
Preconditions.checkContentsNotNull(skills.values());
- for (Skill skill : Skill.VALUES) {
+ for (Skill skill : Skill.values()) {
if (!skills.containsKey(skill)) {
throw new InvalidAttributeValueException();
}
@@ -324,8 +332,8 @@ public UserCharacter build() {
Preconditions.checkNotNull(reputation);
Preconditions.checkNotNull(position);
- LoggedUser user = new LoggedUser(reputation, race, gender, archetype.getArchetype(), poisoned,
- paralyzed, immobilized, invisible, dumbed, hidden, maxMana, minMana, maxHp, minHp,
+ LoggedUser user = new LoggedUser(reputation, race, gender, archetype.getArchetype(), homeland, position, poisoned,
+ paralyzed, immobilized, invisible, mimetized, dumbed, hidden, maxMana, minMana, maxHp, minHp,
maxThirstiness, minThirstiness, maxHunger, minHunger, lvl, name, description);
//TODO: Set everything!
diff --git a/aoxp-server/src/main/java/com/ao/model/character/Gender.java b/aoxp-server/src/main/java/com/ao/model/character/Gender.java
index a6f6857..8e08109 100755
--- a/aoxp-server/src/main/java/com/ao/model/character/Gender.java
+++ b/aoxp-server/src/main/java/com/ao/model/character/Gender.java
@@ -28,7 +28,7 @@ public enum Gender {
/**
* Enum values.
*/
- private static Gender[] values = Gender.values();
+ private static final Gender[] VALUES = Gender.values();
/**
* Retrieves the gender with the given index.
@@ -36,6 +36,6 @@ public enum Gender {
* @return The gender.
*/
public static Gender get(byte index) {
- return values[index];
+ return VALUES[index];
}
}
diff --git a/aoxp-server/src/main/java/com/ao/model/character/Skill.java b/aoxp-server/src/main/java/com/ao/model/character/Skill.java
index cb62574..9588606 100755
--- a/aoxp-server/src/main/java/com/ao/model/character/Skill.java
+++ b/aoxp-server/src/main/java/com/ao/model/character/Skill.java
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-*/
+ */
package com.ao.model.character;
@@ -22,33 +22,51 @@
* Defines available skills.
*/
public enum Skill {
- LUCK,
- MAGIC,
- STEAL,
- COMBAT_TACTICS,
- HAND_TO_HAND_COMBAT,
- MEDITATE,
- STAB,
- HIDING,
- SURVIVE,
- LUMBER,
- TRADE,
- DEFENSE,
- FISHING,
- MINING,
- WOODWORK,
- IRONWORK,
- LEADERSHIP,
- TAME,
- PROJECTILES,
- WRESTLING,
- SAILING;
-
- /**
- * The amount of existing skills.
- *
- * TODO: I don't really like this...any better alternative?
- */
- public static final int AMOUNT = Skill.values().length;
- public static final Skill[] VALUES = Skill.values();
+
+ //LUCK //no existe más
+ MAGIC,
+ STEALING,
+ COMBAT_TACTICS,
+ HAND_TO_HAND_COMBAT,
+ MEDITATION,
+ STABBING,
+ HIDING,
+ SURVIVAL,
+ LUMBER,
+ TRADE,
+ SHIELD_DEFENSE,
+ FISHING,
+ MINING,
+ WOODWORKING,
+ SMITHING,
+ LEADERSHIP,
+ TAMMING,
+ RANGED_COMBAT,
+ WRESTLING,
+ SAILING;
+
+ /**
+ * The amount of existing skills.
+ *
+ * TODO: I don't really like this...any better alternative?
+ */
+ public static final int AMOUNT = Skill.values().length;
+ private static final Skill[] VALUES = Skill.values();
+
+ /**
+ * Maximum amount of points a character can earn for any given skill
+ */
+ public static final int MAX_SKILL_POINT= 100;
+
+ /**
+ * Retrieves the skill for the given index
+ * @param index the index
+ * @return the skill at the given index
+ */
+ public Skill get(byte index) {
+ //TODO: must ensure index ranges between 0 and AMOUNT(not included)
+ return VALUES[index];
+ }
+
+
}
diff --git a/aoxp-server/src/main/java/com/ao/model/character/UserCharacter.java b/aoxp-server/src/main/java/com/ao/model/character/UserCharacter.java
index 4d57ec1..f72e42b 100755
--- a/aoxp-server/src/main/java/com/ao/model/character/UserCharacter.java
+++ b/aoxp-server/src/main/java/com/ao/model/character/UserCharacter.java
@@ -14,114 +14,148 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-*/
+ */
package com.ao.model.character;
import com.ao.model.character.archetype.Archetype;
+import com.ao.model.map.City;
public interface UserCharacter extends Character {
- /**
- * Retrieves the user's requested skill points.
- * @param skill The skill.
- * @return The amount of skill points.
- */
- int getSkill(Skill skill);
-
- /**
- * Adds points to the given user's skill.
- * @param skill The skill to add points.
- * @param points The points to add.
- */
- void addToSkill(Skill skill, byte points);
-
- /**
- * Checks if the user is doing some work.
- * @return True if the user is working, false other wise.
- */
- boolean isWorking();
-
- /**
- * Sets the user to work.
- */
- void work();
-
- /**
- * Retrieves the user's guild name.
- * @return The user's guild name.
- */
- String getGuildName();
-
- /**
- * Sets the user's guild name.
- * @param name The guild name to be setted.
- */
- void setGuildName(String name);
-
- /**
- * Retrieves the user's party id.
- * @return The user's party id if the user belongs to one, -1 otherwise.
- */
- int getPartyId();
-
- /**
- * Sets the user's party id.
- * @param id The party id to be setted.
- */
- void setPartyId(int id);
-
- /**
- * Retrieves the user's race.
- * @return The user's race.
- */
- Race getRace();
-
- /**
- * Retrieves the user's gender.
- * @return The user's gender.
- */
- Gender getGender();
-
- /**
- * Retrieves the user's archetype.
- * @return The user's archetype.
- */
- Archetype getArchetype();
-
- /**
- * Retrieves the user's stamina.
- * @return The user's stamina.
- */
- public int getStamina();
-
- /**
- * Sets the user's stamina.
- * @param stamina The stamina
- */
- public void setStamina(int stamina);
-
- /**
- * Retrieves the user's max stamina.
- * @return The user's max stamina.
- */
- public int getMaxStamina();
-
- /**
- * Sets the user's max stamina.
- * @param maxStamina The max stamina.
- */
- public void setMaxStamina(int maxStamina);
-
- /**
- * Checks if the user is meditating.
- * @return True if the user is meditating, false other wise.
- */
- boolean isMeditating();
-
- /**
- * Sets the user to meditate.
- * @param meditating The boolean value.
- */
- void setMeditate(boolean meditating);
+ /**
+ * Retrieves the user's requested skill points.
+ * @param skill The skill.
+ * @return The amount of skill points.
+ */
+ int getSkill(Skill skill);
+
+ /**
+ * Retrieves the experience needed to level up the skill.
+ * ELU stands for Experience Level Up.
+ * @param skill The skill.
+ * @return the experience needed to level up the skill.
+ */
+ int getSkillELU(Skill skill);
+
+ /**
+ * Retrieves the skill's accumulated experience.
+ * @param skill The skill.
+ * @return the skill's progress.
+ */
+ int getSkillExp(Skill skill);
+
+ /**
+ * Adds points to the given user's skill.
+ * @param skill The skill to add points.
+ * @param points The points to add.
+ */
+ void addToSkill(Skill skill, byte points);
+
+ /**
+ * Adds experience points to this skill.
+ * @param skill The skill.
+ * @param points the experience points to add.
+ */
+ void addToSkillExp(Skill skill, byte points);
+
+ /**
+ * Checks if the user is working.
+ * @return True if the user is working, false otherwise.
+ */
+ boolean isWorking();
+
+ /**
+ * Sets the user to work.
+ */
+ void work();
+
+ /**
+ * Retrieves the user's guild name.
+ * @return The user's guild name.
+ */
+ String getGuildName();
+
+ /**
+ * Sets the user's guild name.
+ * @param name The guild name to be set.
+ */
+ void setGuildName(String name);
+
+ /**
+ * Retrieves the user's party id.
+ * @return The user's party id if the user belongs to one, -1 otherwise.
+ */
+ int getPartyId();
+
+ /**
+ * Sets the user's party id.
+ * @param id The party id to be set.
+ */
+ void setPartyId(int id);
+
+ /**
+ * Retrieves the user's race.
+ * @return The user's race.
+ */
+ Race getRace();
+
+ /**
+ * Retrieves the user's gender.
+ * @return The user's gender.
+ */
+ Gender getGender();
+
+ /**
+ * Retrieves the user's archetype.
+ * @return The user's archetype.
+ */
+ Archetype getArchetype();
+
+ /**
+ * Retrieves the user's homeland.
+ * @return the user's homeland.
+ */
+ City getHomeland();
+
+ /**
+ * Sets user's new homeland.
+ * @param homeland the new homeland.
+ */
+ void setHomeland(City homeland);
+ /**
+ * Retrieves the user's stamina.
+ * @return The user's stamina.
+ */
+ public int getStamina();
+
+ /**
+ * Sets the user's stamina.
+ * @param stamina The stamina
+ */
+ public void setStamina(int stamina);
+
+ /**
+ * Retrieves the user's max stamina.
+ * @return The user's max stamina.
+ */
+ public int getMaxStamina();
+
+ /**
+ * Sets the user's max stamina.
+ * @param maxStamina The max stamina.
+ */
+ public void setMaxStamina(int maxStamina);
+
+ /**
+ * Checks if the user is meditating.
+ * @return True if the user is meditating, false otherwise.
+ */
+ boolean isMeditating();
+
+ /**
+ * Sets the user to meditate.
+ * @param meditating The boolean value.
+ */
+ void setMeditate(boolean meditating);
}
diff --git a/aoxp-server/src/main/java/com/ao/model/fonts/Font.java b/aoxp-server/src/main/java/com/ao/model/fonts/Font.java
index df49c3c..cce6e5b 100755
--- a/aoxp-server/src/main/java/com/ao/model/fonts/Font.java
+++ b/aoxp-server/src/main/java/com/ao/model/fonts/Font.java
@@ -19,7 +19,7 @@
package com.ao.model.fonts;
/**
- * Defines available skills.
+ * Defines available fonts.
*/
public enum Font {
TALK,
diff --git a/aoxp-server/src/main/java/com/ao/model/map/City.java b/aoxp-server/src/main/java/com/ao/model/map/City.java
index ba9f342..385f32a 100644
--- a/aoxp-server/src/main/java/com/ao/model/map/City.java
+++ b/aoxp-server/src/main/java/com/ao/model/map/City.java
@@ -29,9 +29,9 @@ public class City{
/**
* Creates a new city instance.
- * @param map The city map.
- * @param x The city x co-ordinate for users spawn.
- * @param y The city y co-ordinate for users spawn.
+ * @param map The city's map id.
+ * @param x City's x coordinate for users spawn.
+ * @param y City's y coordinate for users spawn.
*/
public City(int map, byte x, byte y){
this.map = map;
@@ -40,24 +40,24 @@ public City(int map, byte x, byte y){
}
/**
- * Retrieves the city map.
- * @return The city map.
+ * Retrieves the city's map id.
+ * @return The city's map id.
*/
public int getMap() {
return map;
}
/**
- * Retrieves the city x co-ordinate for users spawn.
- * @return The city x co-ordinate for users spawn.
+ * Retrieves city's X coordinate for users spawn.
+ * @return city's X coordinate for users spawn.
*/
public byte getX() {
return x;
}
/**
- * Retrieves the city y co-ordinate for users spawn.
- * @return The city y co-ordinate for users spawn.
+ * Retrieves city's Y coordinate for users spawn.
+ * @return city's Y coordinate for users spawn.
*/
public byte getY() {
return y;
diff --git a/aoxp-server/src/main/java/com/ao/model/user/Account.java b/aoxp-server/src/main/java/com/ao/model/user/Account.java
index 4154b2e..2de1ff2 100755
--- a/aoxp-server/src/main/java/com/ao/model/user/Account.java
+++ b/aoxp-server/src/main/java/com/ao/model/user/Account.java
@@ -47,7 +47,7 @@ public interface Account {
boolean hasCharacter(String name);
/**
- * Checks wether the account is banned or not.
+ * Checks whether the account is banned or not.
* @return True if the account is banned, false otherwise.
*/
boolean isBanned();
@@ -65,10 +65,22 @@ public interface Account {
*/
UserCharacter getCharacter(String name);
+ /**
+ * Retrieves this account's logged character.
+ * @return account's currently logged character.
+ */
+ LoggedUser getLoggedCharacter();
+
+ /**
+ * Sets this account's logged character.
+ * @param the logged character.
+ */
+ void setLoggedCharacter(LoggedUser loggedChar);
+
/**
* Try to authenticate the account with the given password.
* @param password The password used to authenticate.
- * @return True if the password matchs the account password, false otherwise.
+ * @return True if the password matches the account password, false otherwise.
*/
boolean authenticate(String password);
diff --git a/aoxp-server/src/main/java/com/ao/model/user/AccountImpl.java b/aoxp-server/src/main/java/com/ao/model/user/AccountImpl.java
index 0b0840e..b8113b9 100755
--- a/aoxp-server/src/main/java/com/ao/model/user/AccountImpl.java
+++ b/aoxp-server/src/main/java/com/ao/model/user/AccountImpl.java
@@ -36,13 +36,15 @@ public class AccountImpl implements Account {
protected Set characters;
private boolean banned;
+ private LoggedUser currentLoggedChar;
+
/**
* Creates a new account instance.
* @param name The name of the account.
* @param password The account's password.
* @param mail The account's email.
* @param characters The account's characters.
- * @param banned Wether the account is banned or not.
+ * @param banned Whether the account is banned or not.
*/
public AccountImpl(String name, String password, String mail, Set characters, boolean banned) {
this.name = name;
@@ -108,6 +110,25 @@ public UserCharacter getCharacter(String name) {
return ApplicationContext.getInstance(UserService.class).getCharacter(name);
}
+ /* (non-Javadoc)
+ * @see com.ao.model.user.Account#getLoggedCharacter()
+ */
+ public LoggedUser getLoggedCharacter() {
+ //TODO many NPEs may arise as a result of this method being called when no character is logged.
+ return this.currentLoggedChar;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ao.model.user.Account#setLoggedCharacter(com.ao.model.user.LoggedUser)
+ */
+ public void setLoggedCharacter(LoggedUser loggedChar) {
+
+ if (this.hasCharacter( loggedChar.getName()) )
+ this.currentLoggedChar= loggedChar;
+ else
+ this.currentLoggedChar= null;
+ }
+
/* (non-Javadoc)
* @see com.ao.model.user.Account#authenticate(java.lang.String)
*/
diff --git a/aoxp-server/src/main/java/com/ao/model/user/LoggedUser.java b/aoxp-server/src/main/java/com/ao/model/user/LoggedUser.java
index e1bd8e5..52ce045 100644
--- a/aoxp-server/src/main/java/com/ao/model/user/LoggedUser.java
+++ b/aoxp-server/src/main/java/com/ao/model/user/LoggedUser.java
@@ -28,6 +28,7 @@
import com.ao.model.character.UserCharacter;
import com.ao.model.character.archetype.Archetype;
import com.ao.model.inventory.Inventory;
+import com.ao.model.map.City;
import com.ao.model.map.Heading;
import com.ao.model.map.Position;
import com.ao.model.spell.Spell;
@@ -53,6 +54,7 @@ public class LoggedUser extends ConnectedUser implements UserCharacter {
private Race race;
private Gender gender;
private Archetype archetype;
+ private City homeland;
private Weapon weapon;
private Helmet helmet;
@@ -72,6 +74,7 @@ public class LoggedUser extends ConnectedUser implements UserCharacter {
private boolean hidden;
private boolean meditating;
private boolean sailing;
+ private boolean homecoming;
/*
* AdminFlags
@@ -94,10 +97,12 @@ public class LoggedUser extends ConnectedUser implements UserCharacter {
private byte level;
private String name;
private String description;
+ private Position position;
+ private Heading heading;
public LoggedUser(Reputation reputation, Race race, Gender gender,
- Archetype archetype, boolean poisoned, boolean paralyzed,
- boolean immobilized, boolean invisible, boolean dumbed, boolean hidden, int maxMana, int minMana, int maxHp,
+ Archetype archetype, City homeland, Position position, boolean poisoned, boolean paralyzed,
+ boolean immobilized, boolean invisible, boolean mimetized, boolean dumbed, boolean hidden, int maxMana, int minMana, int maxHp,
int minHp, int maxThirstiness, int minThirstiness , int maxHunger, int minHunger, byte lvl,
String name, String description) {
@@ -106,10 +111,13 @@ public LoggedUser(Reputation reputation, Race race, Gender gender,
this.race = race;
this.gender = gender;
this.archetype = archetype;
+ this.homeland = homeland;
+ this.position = position;
this.poisoned = poisoned;
this.paralyzed = paralyzed;
this.immobilized = immobilized;
this.invisible = invisible;
+ this.mimetized= mimetized;
this.dumbed = dumbed;
this.hidden = hidden;
this.maxMana = maxMana;
@@ -125,11 +133,6 @@ public LoggedUser(Reputation reputation, Race race, Gender gender,
this.description = description;
}
- @Override
- public void addToSkill(Skill skill, byte points) {
- // TODO Auto-generated method stub
-
- }
@Override
public Archetype getArchetype() {
@@ -163,6 +166,18 @@ public int getSkill(Skill skill) {
// TODO Auto-generated method stub
return 0;
}
+
+ @Override
+ public int getSkillELU(Skill skill) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getSkillExp(Skill skill) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
@Override
public boolean isWorking() {
@@ -239,7 +254,19 @@ public void addToThirstiness(int points) {
}
}
+
+ @Override
+ public void addToSkill(Skill skill, byte points) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void addToSkillExp(Skill skill, byte points) {
+ // TODO Auto-generated method stub
+
+ }
+
@Override
public void attack(Character character) {
// TODO Auto-generated method stub
@@ -381,11 +408,18 @@ public int getOriginalHead() {
// TODO Auto-generated method stub
return 0;
}
+
+ public City getHomeland() {
+ return homeland;
+ }
+
+ public void setHomeland(City homeland) {
+ this.homeland= homeland;
+ }
@Override
public Position getPosition() {
- // TODO Auto-generated method stub
- return null;
+ return position;
}
@Override
@@ -443,6 +477,10 @@ public boolean isParalyzed() {
public boolean isPoisoned() {
return poisoned;
}
+
+ public boolean isHomecoming() {
+ return homecoming;
+ }
@Override
public void setBody(int body) {
@@ -502,8 +540,7 @@ public void setPoisoned(boolean poisoned) {
@Override
public void setPosition(Position pos) {
- // TODO Auto-generated method stub
-
+ position= pos;
}
@Override
@@ -544,13 +581,12 @@ public int getMoney() {
@Override
public Heading getHeading() {
- // TODO Auto-generated method stub
- return Heading.EAST;
+ return heading;
}
@Override
public void setHeading(Heading heading) {
-
+ this.heading= heading;
}
@Override
@@ -705,7 +741,16 @@ public boolean isSailing() {
public void setSailing(boolean sailing) {
this.sailing = sailing;
}
-
+
+ /**
+ * Picks up a given item.
+ * @param item the Item to pick up
+ * @return true if item was successfully added to inventory, false otherwise.
+ */
+ public boolean pickUp(Item item) {
+ return false; //TODO to complete
+ }
+
@Override
public void moveTo(Heading heading) {
// TODO Auto-generated method stub
diff --git a/aoxp-server/src/main/java/com/ao/model/worldobject/AbstractItem.java b/aoxp-server/src/main/java/com/ao/model/worldobject/AbstractItem.java
index 8381b25..be53cc9 100644
--- a/aoxp-server/src/main/java/com/ao/model/worldobject/AbstractItem.java
+++ b/aoxp-server/src/main/java/com/ao/model/worldobject/AbstractItem.java
@@ -31,7 +31,7 @@
*/
public abstract class AbstractItem extends AbstractWorldObject implements Item {
- protected static final int MAX_STACKED_ITEMS = 10000;
+ public static final int MAX_STACKED_ITEMS = 10000; //TODO Why was this protected?
protected int amount;
diff --git a/aoxp-server/src/main/java/com/ao/network/ClientPacketsManager.java b/aoxp-server/src/main/java/com/ao/network/ClientPacketsManager.java
index 760100e..ab95c17 100755
--- a/aoxp-server/src/main/java/com/ao/network/ClientPacketsManager.java
+++ b/aoxp-server/src/main/java/com/ao/network/ClientPacketsManager.java
@@ -21,8 +21,11 @@
import java.io.UnsupportedEncodingException;
import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.incoming.DropPacket;
import com.ao.network.packet.incoming.LoginExistingCharacterPacket;
import com.ao.network.packet.incoming.LoginNewCharacterPacket;
+import com.ao.network.packet.incoming.PickUpPacket;
+import com.ao.network.packet.incoming.RequestPositionUpdatePacket;
import com.ao.network.packet.incoming.ThrowDicesPacket;
import com.ao.network.packet.incoming.WalkPacket;
@@ -41,8 +44,131 @@ private enum ClientPackets {
TALK(null),
YELL(null),
WHISPER(null),
- WALK(WalkPacket.class);
-
+ WALK(WalkPacket.class),
+ REQUEST_POSITION_UPDATE(RequestPositionUpdatePacket.class),
+ ATTACK(null),
+ PICK_UP(PickUpPacket.class),
+ SAFE_TOGGLE(null),
+ RESUCITATION_SAFE_TOGGLE(null), //RESURRECTION
+ REQUEST_GUILD_LEADER_INFO(null),
+ REQUEST_ATRIBUTES(null),
+ REQUEST_FAME(null),
+ REQUEST_SKILLS(null),
+ REQUEST_MINI_STATS(null),
+ COMMERCE_END(null),
+ USER_COMMERCE_END(null),
+ USER_COMMERCE_CONFIRM(null),
+ COMMERCE_CHAT(null),
+ BANK_END(null),
+ USER_COMMERCE_OK(null),
+ USER_COMMERCE_REJECT(null),
+ DROP(DropPacket.class),
+ CAST_SPELL(null),
+ LEFT_CLICK(null),
+ DOUBLE_CLICK(null),
+ WORK(null),
+ USE_SPELL_MACRO(null),
+ USE_ITEM(null),
+ CRAFT_BLACKSMITH(null),
+ CRAFT_CARPENTER(null),
+ WORK_LEFT_CLICK(null),
+ CREATE_NEW_GUILD(null),
+ SPELL_INFO(null),
+ EQUIP_ITEM(null), //RIG OUT
+ CHANGE_HEADING(null),
+ MODIFY_SKILLS(null),
+ TRAIN(null),
+ COMMERCE_BUY(null),
+ BANK_EXTRACT_ITEM(null), //WITHDRAW
+ COMMERCE_SELL(null),
+ BANK_DEPOSIT(null),
+ FORUM_POST(null),
+ MOVE_SPELL(null),
+ MOVE_BANK(null),
+ CLAN_CODEX_UPDATE(null),
+ USER_COMMERCE_OFFER(null),
+ GUILD_ACCEPT_PEACE(null),
+ GUILD_REJECT_ALLIANCE(null),
+ GUILD_REJECT_PEACE(null),
+ GUILD_ACCEPT_ALLIANCE(null),
+ GUILD_OFFER_PEACE(null),
+ GUILD_OFFER_ALLIANCE(null),
+ GUILD_ALLIANCE_DETAILS(null),
+ GUILD_PEACE_DETAILS(null),
+ GUILD_REQUEST_JOINER_INFO(null), //APPLICANT
+ GUILD_ALLIANCE_PROPOSAL_LIST(null),
+ GUILD_PEACE_PROPOSAL_LIST(null),
+ GUILD_DECLARE_WAR(null),
+ GUILD_NEW_WEBSITE(null),
+ GUILD_ACCEPT_NEW_MEMBER(null),
+ GUILD_REJECT_NEW_MEMBER(null),
+ GUILD_KICK_MEMBER(null),
+ GUILD_UPDATE_NEWS(null),
+ GUILD_MEMBER_INFO(null),
+ GUILD_OPEN_ELECTIONS(null),
+ GUILD_REQUEST_MEMBERSHIP(null),
+ GUILD_REQUEST_DETAILS(null),
+ ONLINE(null),
+ QUIT(null),
+ GUILD_LEAVE(null),
+ REQUEST_ACCOUNT_STATE(null),
+ PET_STAND(null),
+ PET_FOLLOW(null),
+ RELEASE_PET(null),
+ TRAIN_LIST(null),
+ REST(null),
+ MEDITATE(null),
+ RESUCITATE(null),
+ HEAL(null),
+ HELP(null),
+ REQUEST_STATS(null),
+ COMMERCE_START(null),
+ BANK_START(null),
+ ENLIST(null),
+ INFORMATION(null),
+ REWARD(null),
+ REQUEST_MOTD(null), //MOTD stands for 'message of the day'
+ UPTIME(null),
+ PARTY_LEAVE(null),
+ PARTY_CREATE(null),
+ PARTY_JOIN(null),
+ INQUIRY(null),
+ GUILD_MESSAGE(null),
+ PARTY_MESSAGE(null),
+ CENTINEL_REPORT(null),
+ GUILD_ONLINE(null),
+ PARTY_ONLINE(null),
+ COUNCIL_MESSAGE(null),
+ ROLEMASTER_REQUEST(null),
+ GM_REQUEST(null),
+ BUG_REPORT(null),
+ CHANGE_DESCRIPTION(null),
+ GUILD_VOTE(null),
+ PUNISHMENTS(null),
+ CHANGE_PASSWORD(null),
+ GAMBLE(null), //BET
+ INQUIRY_VOTE(null),
+ LEAVE_FACTION(null),
+ BANK_EXTRACT_GOLD(null), //WITHDRAW
+ BANK_DEPOSIT_GOLD(null),
+ DENOUNCE(null),
+ GUILD_FUNDATE(null),
+ GUILD_FUNDATION(null),
+ PARTY_KICK(null),
+ PARTY_SET_LEADER(null),
+ PARTY_ACCEPT_MEMBER(null),
+ PING(null),
+ REQUEST_PARTY_FORM(null),
+ ITEM_UPGRADE(null),
+ GM_COMMANDS(null),
+ INITIATE_CRAFTING(null),
+ HOME(null),
+ SHOW_GUILD_NEWS(null),
+ SHARE_NPC(null),
+ STOP_SHARING_NPC(null),
+ CONSULTATION(null),
+ MOVE_ITEM(null);
+
protected IncomingPacket handler;
private ClientPackets(Class extends IncomingPacket> handler) {
diff --git a/aoxp-server/src/main/java/com/ao/network/ServerPacketsManager.java b/aoxp-server/src/main/java/com/ao/network/ServerPacketsManager.java
index 7d28125..f9519a5 100755
--- a/aoxp-server/src/main/java/com/ao/network/ServerPacketsManager.java
+++ b/aoxp-server/src/main/java/com/ao/network/ServerPacketsManager.java
@@ -23,171 +23,201 @@
import java.util.Map;
import com.ao.network.packet.OutgoingPacket;
+import com.ao.network.packet.outgoing.BlockPositionPacket;
+import com.ao.network.packet.outgoing.ChangeInventorySlotPacket;
import com.ao.network.packet.outgoing.ChangeMapPacket;
+import com.ao.network.packet.outgoing.CharacterChangeNickNamePacket;
+import com.ao.network.packet.outgoing.CharacterChangePacket;
import com.ao.network.packet.outgoing.CharacterCreatePacket;
+import com.ao.network.packet.outgoing.CharacterForceMovePacket;
+import com.ao.network.packet.outgoing.CharacterMovePacket;
+import com.ao.network.packet.outgoing.CharacterRemovePacket;
+import com.ao.network.packet.outgoing.ChatOverHeadPacket;
+import com.ao.network.packet.outgoing.CommerceChatPacket;
+import com.ao.network.packet.outgoing.CommerceEndPacket;
import com.ao.network.packet.outgoing.ConsoleMessagePacket;
+import com.ao.network.packet.outgoing.CreateFXPacket;
import com.ao.network.packet.outgoing.DiceRollPacket;
+import com.ao.network.packet.outgoing.DisconnectPacket;
import com.ao.network.packet.outgoing.ErrorMessagePacket;
import com.ao.network.packet.outgoing.GuildChatPacket;
+import com.ao.network.packet.outgoing.MeditateTogglePacket;
+import com.ao.network.packet.outgoing.NavigateTogglePacket;
import com.ao.network.packet.outgoing.ObjectCreatePacket;
+import com.ao.network.packet.outgoing.ObjectDeletePacket;
import com.ao.network.packet.outgoing.PlayMidiPacket;
import com.ao.network.packet.outgoing.PlayWavePacket;
+import com.ao.network.packet.outgoing.RemoveAllDialogsPacket;
+import com.ao.network.packet.outgoing.RemoveCharDialogPacket;
+import com.ao.network.packet.outgoing.SendSkillsPacket;
+import com.ao.network.packet.outgoing.ShowMessageBoxPacket;
import com.ao.network.packet.outgoing.UpdateDexterityPacket;
+import com.ao.network.packet.outgoing.UpdateExperiencePacket;
+import com.ao.network.packet.outgoing.UpdateGoldPacket;
+import com.ao.network.packet.outgoing.UpdateHPPacket;
+import com.ao.network.packet.outgoing.UpdateManaPacket;
+import com.ao.network.packet.outgoing.UpdatePositionPacket;
+import com.ao.network.packet.outgoing.UpdateStaminaPacket;
import com.ao.network.packet.outgoing.UpdateStrengthAndDexterityPacket;
import com.ao.network.packet.outgoing.UpdateStrengthPacket;
+import com.ao.network.packet.outgoing.UpdateUserStatsPacket;
import com.ao.network.packet.outgoing.UserCharacterIndexInServerPacket;
+import com.ao.network.packet.outgoing.UserCommerceInitPacket;
import com.ao.network.packet.outgoing.UserIndexInServer;
-
+import com.ao.network.packet.outgoing.DumbPacket;
+import com.ao.network.packet.outgoing.DumbNoMorePacket;
+import com.ao.network.packet.outgoing.LoggedPacket;
+import com.ao.network.packet.outgoing.WorkRequestTargetPacket;
/**
* Manager for server-side packets.
*/
public class ServerPacketsManager {
- /**
- * Enumerates server packets.
- */
- private enum ServerPackets {
- LOGGED(null),
- REMOVE_ALL_DIALOGS(null),
- REMOVE_CHR_DIALOG(null),
- TOGGLE_NAVIGATE(null),
- DISCONNECT(null),
- COMMERCE_END(null),
- BANKING_END(null),
- COMMERCE_INIT(null),
- BANK_INIT(null),
- USER_COMMERCE_INIT(null),
- USER_COMMERCE_END(null),
- USER_OFFER_CONFIRM(null),
- COMMERCE_CHAT(null),
- SHOW_BLACKSMITH_FORM(null),
- SHOW_CARPENTER_FORM(null),
- UPDATE_STAMINA(null),
- UPDATE_MANA(null),
- UPDATE_HP(null),
- UPDATE_GOLD(null),
- UPDATE_BANK_GOLD(null),
- UPDATE_EXP(null),
- CHANGE_MAP(ChangeMapPacket.class),
- POSITION_UPDATE(null),
- CHAT_OVER_HEAD(null),
- CONSOLE_MESSAGE(ConsoleMessagePacket.class),
- GUILD_CHAT(GuildChatPacket.class),
- SHOW_MESSAGE_BOX(null),
- USER_INDEX_IN_SERVER(UserIndexInServer.class),
- USER_CHARACTER_INDEX_IN_SERVER(UserCharacterIndexInServerPacket.class),
- CHARACTER_CREATE(CharacterCreatePacket.class),
- CHARACTER_REMOVE(null),
- CHARACTER_CHANGE_NICKNAME(null),
- CHARACTER_MOVE(null),
- CHARACTER_FORCE_MOVE(null),
- CHARACTER_CHANGE(null),
- OBJECT_CREATE(ObjectCreatePacket.class),
- OBJECT_DEETE(null),
- BLOCK_POSITION(null),
- PLAY_MIDI(PlayMidiPacket.class),
- PLAY_WAVE(PlayWavePacket.class),
- GUILD_LIST(null),
- AREA_CHANGED(null),
- TOGGLE_PAUSE(null),
- TOGGLE_RAIN(null),
- CREATE_FX(null),
- UPDATE_USER_STATS(null),
- WORK_REQUEST_TARGET(null),
- CHANGE_INVENTORY_SLOT(null),
- CHANGE_BANK_SLOT(null),
- CHANGE_SPELL_SLOT(ChangeSpellSlotPacket.class),
- ATTRIBUTES(null),
- BLACKSMITH_WEAPONS(null),
- BLACKSMITH_ARMORS(null),
- CARPENTER_OBJECTS(null),
- REST_OK(null),
- ERROR_MESSAGE(ErrorMessagePacket.class),
- BLIND(null),
- DUMB(null),
- SHOW_SIGNAL(null),
- CHANGE_NPC_INVENTORY_SLOT(null),
- UPDATE_HUNGER_AND_THRIST(null),
- FAME(null),
- MINI_STATS(null),
- LEVEL_UP(null),
- ADD_FORUM_MESAGE(null),
- SHOW_FORUM_MESSAGE(null),
- SET_INVISIBLE(null),
- ROLL_DICE(DiceRollPacket.class),
- MEDITATE_TOGGLE(null),
- BLIND_NO_MORE(null),
- DUMB_NO_MORE(null),
- SEND_SKILLS(null),
- TRAINER_CREATURE_LIST(null),
- GUILD_NEWS(null),
- OFFER_DETAILS(null),
- ALIANCE_PROPOSALS_LIST(null),
- PEACE_PROPOSALS_LIST(null),
- CHARACTER_INFO(null),
- GUILD_LEADER_INFO(null),
- GUILD_MEMBER_INFO(null),
- GUILD_DETAILS(null),
- SHOW_GUILD_FUNDATION_FORM(null),
- PARALIZE_OK(null),
- SHOW_USER_REQUEST(null),
- TRADE_OK(null),
- BANK_OK(null),
- CHANGE_USER_TRADE_SLOT(null),
- SEND_NIGHT(null),
- PONG(null),
- UPDATE_TAG_AND_STATUS(null),
- SPAWN_LIST(null),
- SHOW_SOS_FORM(null),
- SHOW_MOTD_EDITION_FORM(null),
- SHOW_GM_PANEL_FORM(null),
- USER_NAME_LIST(null),
- SHOW_DENOUNCES(null),
- RECORD_LIST(null),
- RECORD_DETAILS(null),
- SHOW_GUILD_ALIGN(null),
- SHOW_PARTY_FORM(null),
- UPDATE_STRENGHT_AND_DEXTERITY(UpdateStrengthAndDexterityPacket.class),
- UPDATE_STRENGHT(UpdateStrengthPacket.class),
- UPDATE_DEXTERITY(UpdateDexterityPacket.class),
- ADD_SLOTS(null),
- MULTI_MESSAGE(null),
- STOP_WORKING(null),
- CANCEL_OFFER_ITEM(null);
+ /**
+ * Enumerates server packets.
+ */
+ private enum ServerPackets {
+ LOGGED(LoggedPacket.class),
+ REMOVE_ALL_DIALOGS(RemoveAllDialogsPacket.class), //sends no data
+ REMOVE_CHAR_DIALOG(RemoveCharDialogPacket.class),
+ TOGGLE_NAVIGATE(NavigateTogglePacket.class), //sends no data
+ DISCONNECT(DisconnectPacket.class), //sends no data
+ COMMERCE_END(CommerceEndPacket.class), //sends no data
+ BANKING_END(null), //sends no data
+ COMMERCE_INIT(null), //sends no data
+ BANK_INIT(null), //CANNOT BE DONE UNTIL VAULT GETTERS ARE DEFINED
+ USER_COMMERCE_INIT(UserCommerceInitPacket.class),
+ USER_COMMERCE_END(null), //sends no data
+ USER_OFFER_CONFIRM(null), //sends no data
+ COMMERCE_CHAT(CommerceChatPacket.class),
+ SHOW_BLACKSMITH_FORM(null), //sends no data
+ SHOW_CARPENTER_FORM(null), //sends no data
+ UPDATE_STAMINA(UpdateStaminaPacket.class),
+ UPDATE_MANA(UpdateManaPacket.class),
+ UPDATE_HP(UpdateHPPacket.class),
+ UPDATE_GOLD(UpdateGoldPacket.class),
+ UPDATE_BANK_GOLD(null), //CANNOT BE DONE UNTIL A GOLD-IN-BANK GETTER IS DEFINED
+ UPDATE_EXP(UpdateExperiencePacket.class),
+ CHANGE_MAP(ChangeMapPacket.class),
+ POSITION_UPDATE(UpdatePositionPacket.class),
+ CHAT_OVER_HEAD(ChatOverHeadPacket.class),
+ CONSOLE_MESSAGE(ConsoleMessagePacket.class),
+ GUILD_CHAT(GuildChatPacket.class),
+ SHOW_MESSAGE_BOX(ShowMessageBoxPacket.class),
+ USER_INDEX_IN_SERVER(UserIndexInServer.class),
+ USER_CHARACTER_INDEX_IN_SERVER(UserCharacterIndexInServerPacket.class),
+ CHARACTER_CREATE(CharacterCreatePacket.class),
+ CHARACTER_REMOVE(CharacterRemovePacket.class),
+ CHARACTER_CHANGE_NICKNAME(CharacterChangeNickNamePacket.class),
+ CHARACTER_MOVE(CharacterMovePacket.class),
+ CHARACTER_FORCE_MOVE(CharacterForceMovePacket.class),
+ CHARACTER_CHANGE(CharacterChangePacket.class),
+ OBJECT_CREATE(ObjectCreatePacket.class),
+ OBJECT_DELETE(ObjectDeletePacket.class),
+ BLOCK_POSITION(BlockPositionPacket.class),
+ PLAY_MIDI(PlayMidiPacket.class),
+ PLAY_WAVE(PlayWavePacket.class),
+ GUILD_LIST(null), //CAN'T BE DONE YET
+ AREA_CHANGED(null),
+ TOGGLE_PAUSE(null), //sends no data
+ TOGGLE_RAIN(null), //sends no data
+ CREATE_FX(CreateFXPacket.class),
+ UPDATE_USER_STATS(UpdateUserStatsPacket.class),
+ WORK_REQUEST_TARGET(WorkRequestTargetPacket.class),
+ CHANGE_INVENTORY_SLOT(ChangeInventorySlotPacket.class),
+ CHANGE_BANK_SLOT(null),
+ CHANGE_SPELL_SLOT(ChangeSpellSlotPacket.class),
+ ATTRIBUTES(null),
+ BLACKSMITH_WEAPONS(null),
+ BLACKSMITH_ARMORS(null),
+ CARPENTER_OBJECTS(null),
+ REST_OK(null),
+ ERROR_MESSAGE(ErrorMessagePacket.class),
+ BLIND(null),
+ DUMB(DumbPacket.class),
+ SHOW_SIGNAL(null),
+ CHANGE_NPC_INVENTORY_SLOT(null),
+ UPDATE_HUNGER_AND_THRIST(null),
+ FAME(null),
+ MINI_STATS(null),
+ LEVEL_UP(null),
+ ADD_FORUM_MESAGE(null),
+ SHOW_FORUM_MESSAGE(null),
+ SET_INVISIBLE(null),
+ ROLL_DICE(DiceRollPacket.class),
+ MEDITATE_TOGGLE(MeditateTogglePacket.class), //sends no data (was needed to continue implementing WalkPacket)
+ BLIND_NO_MORE(null),
+ DUMB_NO_MORE(DumbNoMorePacket.class),
+ SEND_SKILLS(SendSkillsPacket.class),
+ TRAINER_CREATURE_LIST(null),
+ GUILD_NEWS(null),
+ OFFER_DETAILS(null),
+ ALIANCE_PROPOSALS_LIST(null),
+ PEACE_PROPOSALS_LIST(null),
+ CHARACTER_INFO(null),
+ GUILD_LEADER_INFO(null),
+ GUILD_MEMBER_INFO(null),
+ GUILD_DETAILS(null),
+ SHOW_GUILD_FUNDATION_FORM(null),
+ PARALIZE_OK(null),
+ SHOW_USER_REQUEST(null),
+ TRADE_OK(null),
+ BANK_OK(null),
+ CHANGE_USER_TRADE_SLOT(null),
+ SEND_NIGHT(null),
+ PONG(null),
+ UPDATE_TAG_AND_STATUS(null),
+ SPAWN_LIST(null),
+ SHOW_SOS_FORM(null),
+ SHOW_MOTD_EDITION_FORM(null),
+ SHOW_GM_PANEL_FORM(null),
+ USER_NAME_LIST(null),
+ SHOW_DENOUNCES(null),
+ RECORD_LIST(null),
+ RECORD_DETAILS(null),
+ SHOW_GUILD_ALIGN(null),
+ SHOW_PARTY_FORM(null),
+ UPDATE_STRENGHT_AND_DEXTERITY(UpdateStrengthAndDexterityPacket.class),
+ UPDATE_STRENGHT(UpdateStrengthPacket.class),
+ UPDATE_DEXTERITY(UpdateDexterityPacket.class),
+ ADD_SLOTS(null),
+ MULTI_MESSAGE(null),
+ STOP_WORKING(null),
+ CANCEL_OFFER_ITEM(null);
- protected Class extends OutgoingPacket> packetClass;
+ protected Class extends OutgoingPacket> packetClass;
- private ServerPackets(Class extends OutgoingPacket> packet) {
- packetClass = packet;
- }
- }
+ private ServerPackets(Class extends OutgoingPacket> packet) {
+ packetClass = packet;
+ }
+ }
- /**
- * Maps packets ids to their classes.
- */
- protected static final ServerPackets[] packets = ServerPackets.values();
+ /**
+ * Maps packets ids to their classes.
+ */
+ protected static final ServerPackets[] packets = ServerPackets.values();
- /**
- * Maps packets classes to their ids.
- */
- protected static final Map, Integer> packetsMap = new HashMap, Integer>();
+ /**
+ * Maps packets classes to their ids.
+ */
+ protected static final Map, Integer> packetsMap = new HashMap, Integer>();
- static {
- for (ServerPackets packet : packets) {
- packetsMap.put(packet.packetClass, packet.ordinal());
- }
- }
+ static {
+ for (ServerPackets packet : packets) {
+ packetsMap.put(packet.packetClass, packet.ordinal());
+ }
+ }
- /**
- * Writes the given packet in the given buffer.
- * @param packet The packet to write.
- * @param buffer The buffer where to write the packet.
- * @throws UnsupportedEncodingException
- */
- public static void write(OutgoingPacket packet, DataBuffer buffer) throws UnsupportedEncodingException {
+ /**
+ * Writes the given packet in the given buffer.
+ * @param packet The packet to write.
+ * @param buffer The buffer where to write the packet.
+ * @throws UnsupportedEncodingException
+ */
+ public static void write(OutgoingPacket packet, DataBuffer buffer) throws UnsupportedEncodingException {
- // Put the packet id before the packet itself.
- buffer.put(packetsMap.get(packet.getClass()).byteValue());
- packet.write(buffer);
- }
+ // Put the packet id before the packet itself.
+ buffer.put(packetsMap.get(packet.getClass()).byteValue());
+ packet.write(buffer);
+ }
}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/incoming/DropPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/incoming/DropPacket.java
new file mode 100644
index 0000000..8fd7a9a
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/incoming/DropPacket.java
@@ -0,0 +1,81 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.incoming;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.fonts.Font;
+import com.ao.model.map.Tile;
+import com.ao.model.user.ConnectedUser;
+import com.ao.model.user.LoggedUser;
+import com.ao.model.worldobject.AbstractItem;
+import com.ao.model.worldobject.Item;
+import com.ao.network.Connection;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.outgoing.ConsoleMessagePacket;
+import com.ao.network.packet.outgoing.ObjectCreatePacket;
+
+public class DropPacket implements IncomingPacket{
+
+ @Override
+ public boolean handle(DataBuffer buffer, Connection connection)
+ throws IndexOutOfBoundsException, UnsupportedEncodingException {
+
+ if (buffer.getReadableBytes() < 3)
+ return false;
+
+ LoggedUser user= ((ConnectedUser)connection.getUser()).getAccount().getLoggedCharacter();
+
+ //TODO should we send a message to a counselor trying to pick up an item?
+ if (user.getPrivileges().isCouncelor() || user.isSailing()/*TODO or dead, or trading*/)
+ return true;
+
+ int amount = buffer.getInt();
+
+ if (amount > 0) {
+
+ byte slot= buffer.get();
+ Tile tile= user.getPosition().getMap().getTile(user.getPosition().getX(), user.getPosition().getY());
+
+ if (tile.getWorldObject() == null) {
+
+ tile.setWorldObject( user.getInventory().removeItem(slot, amount) );
+ connection.send( new ObjectCreatePacket(tile.getWorldObject(), user.getPosition()) );
+
+ return true;
+ }
+
+ if ( tile.getWorldObject().getId() == user.getInventory().getItem(slot).getId() &&
+ ((Item) tile.getWorldObject()).getAmount() + amount <= AbstractItem.MAX_STACKED_ITEMS ) {
+
+ user.getInventory().removeItem(slot, amount);
+
+ ( (Item) tile.getWorldObject() ).addAmount(amount);
+
+ return true;
+ }
+
+ connection.send (new ConsoleMessagePacket("No hay espacio en el piso", Font.INFO));
+ }
+
+ return true;
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginExistingCharacterPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginExistingCharacterPacket.java
index 92982d3..4ee3d6a 100755
--- a/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginExistingCharacterPacket.java
+++ b/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginExistingCharacterPacket.java
@@ -25,6 +25,7 @@
import com.ao.network.Connection;
import com.ao.network.DataBuffer;
import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.outgoing.CharacterCreatePacket;
import com.ao.network.packet.outgoing.ErrorMessagePacket;
import com.ao.security.SecurityManager;
import com.ao.service.LoginService;
@@ -48,11 +49,19 @@ public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutO
String version = buffer.get() + "." + buffer.get() + "." + buffer.get();
String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength());
+
+ ConnectedUser user= (ConnectedUser) connection.getUser();
+
try {
- loginService.connectExistingCharacter((ConnectedUser) connection.getUser(), username, password, version, clientHash);
+ loginService.connectExistingCharacter(user, username, password, version, clientHash);
+
} catch (LoginErrorException e) {
- loginError(connection, e.getMessage());
+
+ loginError(connection, e.getMessage());
+ return true;
}
+
+ connection.send( new CharacterCreatePacket(user.getAccount().getLoggedCharacter()));
return true;
}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginNewCharacterPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginNewCharacterPacket.java
index 401759a..59f598e 100755
--- a/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginNewCharacterPacket.java
+++ b/aoxp-server/src/main/java/com/ao/network/packet/incoming/LoginNewCharacterPacket.java
@@ -25,6 +25,7 @@
import com.ao.network.Connection;
import com.ao.network.DataBuffer;
import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.outgoing.CharacterCreatePacket;
import com.ao.network.packet.outgoing.ErrorMessagePacket;
import com.ao.security.SecurityManager;
import com.ao.service.LoginService;
@@ -58,14 +59,19 @@ public boolean handle(DataBuffer buffer, Connection connection) throws ArrayInde
String mail = buffer.getASCIIString();
byte homeland = buffer.get();
+ ConnectedUser user= (ConnectedUser) connection.getUser();
+
try {
- service.connectNewCharacter((ConnectedUser) connection.getUser(),
- nick, password, race, gender, archetype, head, mail,
- homeland, clientHash, version);
+ service.connectNewCharacter(user, nick, password, race, gender,
+ archetype, head, mail, homeland, clientHash, version);
} catch (LoginErrorException e) {
+
loginError(connection, e.getMessage());
+ return true;
}
+
+ connection.send( new CharacterCreatePacket( user.getAccount().getLoggedCharacter() ));
return true;
}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/incoming/PickUpPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/incoming/PickUpPacket.java
new file mode 100644
index 0000000..ee8adbc
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/incoming/PickUpPacket.java
@@ -0,0 +1,74 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.incoming;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.fonts.Font;
+import com.ao.model.map.Tile;
+import com.ao.model.user.LoggedUser;
+import com.ao.model.worldobject.Item;
+import com.ao.model.worldobject.WorldObject;
+import com.ao.network.Connection;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.outgoing.ConsoleMessagePacket;
+import com.ao.network.packet.outgoing.ObjectDeletePacket;
+
+public class PickUpPacket implements IncomingPacket{
+
+
+ @Override
+ public boolean handle(DataBuffer buffer, Connection connection)
+ throws IndexOutOfBoundsException, UnsupportedEncodingException {
+
+ LoggedUser user = ((LoggedUser)connection.getUser());
+
+ Tile tile = user.getPosition().getMap().getTile(user.getPosition().getX(), user.getPosition().getY());
+
+ WorldObject object = tile.getWorldObject();
+
+ /*TODO if (user is dead or user is trading) return true*/
+ if(object == null) {
+
+ connection.send(new ConsoleMessagePacket("No hay nada aquí.", Font.INFO));
+ return true;
+ }
+
+ if (user.getPrivileges().isCouncelor()) {
+
+ connection.send(
+ new ConsoleMessagePacket("No puedes tomar ningún objeto.", Font.INFO) );
+
+ return true;
+ }
+
+ if (object instanceof Item) {
+
+ if( user.pickUp((Item)object) ) {
+
+ tile.setWorldObject(null);
+
+ connection.send( new ObjectDeletePacket(user.getPosition()) );
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/incoming/RequestPositionUpdatePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/incoming/RequestPositionUpdatePacket.java
new file mode 100644
index 0000000..6aed963
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/incoming/RequestPositionUpdatePacket.java
@@ -0,0 +1,45 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.incoming;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.ConnectedUser;
+import com.ao.model.user.LoggedUser;
+import com.ao.network.Connection;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.outgoing.UpdatePositionPacket;
+
+/**
+ * Class to handle position update requests from client.
+ */
+public class RequestPositionUpdatePacket implements IncomingPacket{
+
+ @Override
+ public boolean handle(DataBuffer buffer, Connection connection)
+ throws IndexOutOfBoundsException, UnsupportedEncodingException {
+
+ LoggedUser user= ((ConnectedUser) connection.getUser()).getAccount().getLoggedCharacter();
+ connection.send( new UpdatePositionPacket(user) );
+
+ return true;
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/incoming/WalkPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/incoming/WalkPacket.java
index 84ac62a..f54c36c 100644
--- a/aoxp-server/src/main/java/com/ao/network/packet/incoming/WalkPacket.java
+++ b/aoxp-server/src/main/java/com/ao/network/packet/incoming/WalkPacket.java
@@ -1,99 +1,128 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
package com.ao.network.packet.incoming;
import java.io.UnsupportedEncodingException;
import com.ao.context.ApplicationContext;
-import com.ao.model.character.archetype.PirateArchetype;
import com.ao.model.fonts.Font;
import com.ao.model.map.Heading;
+import com.ao.model.user.ConnectedUser;
import com.ao.model.user.LoggedUser;
import com.ao.network.Connection;
import com.ao.network.DataBuffer;
import com.ao.network.packet.IncomingPacket;
+import com.ao.network.packet.outgoing.CharacterChangePacket;
+import com.ao.network.packet.outgoing.CharacterMovePacket;
import com.ao.network.packet.outgoing.ConsoleMessagePacket;
+import com.ao.network.packet.outgoing.CreateFXPacket;
+import com.ao.network.packet.outgoing.MeditateTogglePacket;
+import com.ao.network.packet.outgoing.SetInvisiblePacket;
import com.ao.service.MapService;
public class WalkPacket implements IncomingPacket {
- private MapService marService = ApplicationContext.getInstance(MapService.class);
+ private MapService mapService = ApplicationContext.getInstance(MapService.class);
+
+ @Override
+ public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException {
+
+ if (buffer.getReadableBytes() < 1) {
+ return false;
+ }
- @Override
- public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException {
+ LoggedUser user = ( (ConnectedUser)connection.getUser() ).getAccount().getLoggedCharacter();
- if (buffer.getReadableBytes() < 1) {
- return false;
- }
+ //TODO check security issues
- LoggedUser user = ((LoggedUser)connection.getUser());
+ Heading heading = Heading.get(buffer.get());
- //TODO check security issues
+ if (heading != null) {
- if (! user.isParalyzed()) {
- if (user.isMeditating()) {
- // Stop meditating, next action will start movement.
- user.setMeditate(false);
+ if ( !(user.isParalyzed() || user.isImmobilized()) ) {
- connection.send(
- new ConsoleMessagePacket("Dejas de meditar.", Font.INFO)
- );
+ if (user.isMeditating()) {
+ // Stop meditating, next action will start movement.
+ user.setMeditate(false);
- /* TODO
- * .Char.FX = 0
- * .Char.loops = 0
- * Call WriteMeditateToggle(UserIndex)
- * Call SendData(SendTa rget.ToPCArea, UserIndex, PrepareMessageCreateFX(.Char.CharIndex, 0, 0))
- */
+ connection.send(
+ new ConsoleMessagePacket("Dejas de meditar.", Font.INFO)
+ );
- } else {
- Heading heading = Heading.get(buffer.get());
- if (heading != null) {
+ user.getFx().setId(0);
+ user.getFx().setLoops(0);
- // Move user
- marService.moveCharacterTo(user, heading);
+ connection.send(
+ new MeditateTogglePacket());
- //TODO Stop resting if needed
+ connection.send(
+ new CreateFXPacket(user)); // Halts meditation FX with a no-effect FX
- } else {
- return true;
- }
+ } else if (!user.isHomecoming()) {
- }
- } else { //if paralized
- //TODO set last message flag
- //TODO aplicar seguridad contra SH
- }
+ mapService.moveCharacterTo(user, heading); // Move user
- // Check if hidden and can move while hidden
- if (user.isHidden() && !user.isAdminHidden() && !user.getArchetype().canWalkHidden()) {
- user.setHidden(false);
+ //TODO Stop resting if needed
- if (user.isSailing()) {
- // TODO : Find a nicer way to do this...
- if (user.getArchetype() instanceof PirateArchetype) {
+ connection.send(new CharacterMovePacket(user));
+ }
+ } else { //if paralyzed
+ //TODO set last message flag
+ //TODO aplicar seguridad contra SH
-// ' Pierde la apariencia de fragata fantasmal
-// Call ToggleBoatBody(UserIndex)
-
- connection.send(
- new ConsoleMessagePacket("¡Has recuperado tu apariencia normal!", Font.INFO)
- );
-// Call WriteConsoleMsg(UserIndex, "¡Has recuperado tu apariencia normal!", FontTypeNames.FONTTYPE_INFO)
+ user.setHeading(heading);
-// Call ChangeUserChar(UserIndex, .Char.body, .Char.Head, .Char.heading, NingunArma, _
-// NingunEscudo, NingunCasco)
- }
+ /* TODO client updates character's heading without
+ * server notification (doesn't it?) so no need to send anything.
+ * */
+ }
- } else if (user.isInvisible()) {
+ // Check if hidden and can move while hidden
+ if (user.isHidden() && !user.isAdminHidden() && !user.getArchetype().canWalkHidden()) {
+ user.setHidden(false);
- // If not under a spell effect, show character
- connection.send(
- new ConsoleMessagePacket("Has vuelto a ser visible.", Font.INFO)
- );
-// Call UsUaRiOs.SetInvisible(UserIndex, .Char.CharIndex, False)
- }
- }
-
- return true;
- }
+ if (user.isSailing()) {
+ //No need to check for pirate since any character hidden while sailing MUST be a pirate.
+ connection.send(
+ new ConsoleMessagePacket("¡Has recuperado tu apariencia normal!", Font.INFO)
+ );
+
+ connection.send(
+ new CharacterChangePacket(user)
+ );
+
+ } else if (!user.isInvisible()) {
+ // If not under a spell effect, show character
+ connection.send(
+ new ConsoleMessagePacket("Has vuelto a ser visible.", Font.INFO)
+ );
+
+ user.setHidden(false);
+
+ connection.send(
+ new SetInvisiblePacket(user, false)
+ );
+ }
+ }
+ }
+
+ return true;
+ }
}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/BlockPositionPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/BlockPositionPacket.java
new file mode 100644
index 0000000..e39c67b
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/BlockPositionPacket.java
@@ -0,0 +1,55 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.map.Position;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports a given position being blocked or unblocked
+ */
+public class BlockPositionPacket implements OutgoingPacket{
+
+ private Position position;
+
+ private boolean blocked;
+
+ /**
+ * Creates the packet
+ * @param position the position to block/unblock
+ * @param blocked true if the position is blocked, false if it's unblocked
+ */
+ public BlockPositionPacket(Position position, boolean blocked) {
+
+ this.position= position;
+ this.blocked= blocked;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.put(position.getX());
+ buffer.put(position.getY());
+ buffer.putBoolean(blocked);
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterChangeNickNamePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterChangeNickNamePacket.java
new file mode 100644
index 0000000..a0e65b3
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterChangeNickNamePacket.java
@@ -0,0 +1,53 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports a nickname change to client.
+ */
+public class CharacterChangeNickNamePacket implements OutgoingPacket{
+
+ private LoggedUser character;
+ private String newNick;
+
+ /**
+ *Creates the packet
+ *@param character character whose nickname was changed
+ *@param newNick character's new nickname
+ */
+ public CharacterChangeNickNamePacket(LoggedUser character, String newNick) {
+
+ this.character= character;
+ this.newNick= newNick;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getCharIndex());
+ buffer.putASCIIString(newNick);
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterChangePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterChangePacket.java
new file mode 100644
index 0000000..94a34b7
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterChangePacket.java
@@ -0,0 +1,57 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.Character;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports about a character's change.
+ */
+public class CharacterChangePacket implements OutgoingPacket{
+
+ private Character character;
+
+ /**
+ * Creates the packet
+ * @param character the character being changed
+ */
+ public CharacterChangePacket(Character character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getCharIndex());
+ buffer.putShort((short) character.getBody());
+ buffer.putShort((short) character.getHead());
+ buffer.put((byte) character.getHeading().ordinal() );
+ buffer.putShort((short) character.getWeapon().getId());
+ buffer.putShort((short) character.getShield().getId());
+ buffer.putShort((short) character.getHelmet().getId());
+ buffer.putShort((short) character.getFx().getId());
+ buffer.putShort((short) character.getFx().getLoops());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterForceMovePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterForceMovePacket.java
new file mode 100644
index 0000000..8e44e2c
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterForceMovePacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.map.Heading;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports about a character's forced move
+ */
+public class CharacterForceMovePacket implements OutgoingPacket{
+
+ private Heading direction;
+
+ /**
+ * Creates the packet
+ * @param direction the direction in which the character was forced to move
+ */
+ public CharacterForceMovePacket(Heading direction) {
+
+ this.direction= direction;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.put( (byte) direction.ordinal() );
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterMovePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterMovePacket.java
new file mode 100644
index 0000000..1f8f06a
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterMovePacket.java
@@ -0,0 +1,52 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+import com.ao.model.character.Character;
+
+/**
+ * Packet that reports a change in a character's position.
+ */
+public class CharacterMovePacket implements OutgoingPacket{
+
+ private Character character;
+
+ /**
+ * Creates the packet
+ * @param character the character that moved
+ */
+ public CharacterMovePacket(Character character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getCharIndex());
+
+ buffer.put(character.getPosition().getX());
+ buffer.put(character.getPosition().getY());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterRemovePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterRemovePacket.java
new file mode 100644
index 0000000..03db600
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CharacterRemovePacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.Character;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports a character removal.
+ */
+public class CharacterRemovePacket implements OutgoingPacket{
+
+ private Character character;
+
+ /**
+ *Creates the packet.
+ *@param character the character to remove
+ */
+ public CharacterRemovePacket (Character character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getCharIndex());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ChatOverHeadPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ChatOverHeadPacket.java
new file mode 100644
index 0000000..041777c
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ChatOverHeadPacket.java
@@ -0,0 +1,62 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.awt.Color;
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.Character;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that sends to client a message to display over a talking character's head.
+ */
+public class ChatOverHeadPacket implements OutgoingPacket{
+
+ private Character character;
+ private String text;
+ private Color color;
+
+
+ /**
+ * Creates the packet.
+ * @param character the character that spoke
+ * @param text what the character said
+ * @param color font color used to display the message
+ * */
+ public ChatOverHeadPacket (Character character, String text, Color color) {
+
+ this.character= character;
+ this.text= text;
+ this.color= color;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putASCIIString(text);
+ buffer.putShort((short) character.getCharIndex());
+
+ buffer.put( (byte) color.getRed() );
+ buffer.put( (byte) color.getGreen() );
+ buffer.put( (byte) color.getBlue() );
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CommerceChatPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CommerceChatPacket.java
new file mode 100644
index 0000000..ffd7b80
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CommerceChatPacket.java
@@ -0,0 +1,56 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+
+import com.ao.model.fonts.Font;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that sends a message to display on the commerce console chat.
+ */
+public class CommerceChatPacket implements OutgoingPacket{
+
+ private String chatMessage;
+ private Font font;
+
+ /**
+ * Creates the packet.
+ * @param chatMessage the message to display
+ * @param font the font for the chatMessage
+ */
+ public CommerceChatPacket (String chatMessage, Font font) {
+
+ this.chatMessage= chatMessage;
+ this.font= font;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putASCIIString(chatMessage);
+
+ buffer.put( (byte) font.ordinal() );
+ }
+
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CommerceEndPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CommerceEndPacket.java
new file mode 100644
index 0000000..02786f4
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CommerceEndPacket.java
@@ -0,0 +1,35 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client to close trade window.
+ */
+public class CommerceEndPacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CreateFXPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CreateFXPacket.java
new file mode 100644
index 0000000..42d485e
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/CreateFXPacket.java
@@ -0,0 +1,52 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.Character;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports an FX to be displayed over a character
+ */
+public class CreateFXPacket implements OutgoingPacket{
+
+ private Character character;
+
+
+ /**
+ * Creates the packet
+ * @param character the character the FX will be displayed over
+ */
+ public CreateFXPacket(Character character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getCharIndex());
+ buffer.putShort((short) character.getFx().getId());
+ buffer.putShort((short) character.getFx().getLoops());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DisconnectPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DisconnectPacket.java
new file mode 100644
index 0000000..e5356c2
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DisconnectPacket.java
@@ -0,0 +1,35 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client to disconnect the user.
+ */
+public class DisconnectPacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DumbNoMorePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DumbNoMorePacket.java
new file mode 100644
index 0000000..c74a13e
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DumbNoMorePacket.java
@@ -0,0 +1,34 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+
+/**
+ * Packet to tell the client the user is no longer dumb.
+ */
+public class DumbNoMorePacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DumbPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DumbPacket.java
new file mode 100644
index 0000000..5e091ff
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/DumbPacket.java
@@ -0,0 +1,35 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+
+/**
+ * Packet to tell the client the user is now dumb.
+ */
+public class DumbPacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/LoggedPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/LoggedPacket.java
new file mode 100644
index 0000000..d880ac7
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/LoggedPacket.java
@@ -0,0 +1,51 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.archetype.UserArchetype;
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client to proceed with user login.
+ */
+public class LoggedPacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+
+ /**
+ * Creates the packet.
+ * @param character the character that logged in
+ */
+ public LoggedPacket(LoggedUser character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.put((byte)UserArchetype.valueOf(character.getArchetype()).ordinal());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/MeditateTogglePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/MeditateTogglePacket.java
new file mode 100644
index 0000000..a267301
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/MeditateTogglePacket.java
@@ -0,0 +1,35 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client the user began or halted his meditation.
+ */
+public class MeditateTogglePacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+
+}
\ No newline at end of file
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/NavigateTogglePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/NavigateTogglePacket.java
new file mode 100644
index 0000000..8d6a947
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/NavigateTogglePacket.java
@@ -0,0 +1,35 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client the user sailed.
+ */
+public class NavigateTogglePacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ObjectDeletePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ObjectDeletePacket.java
new file mode 100644
index 0000000..60c2a88
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ObjectDeletePacket.java
@@ -0,0 +1,50 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.map.Position;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports the deletion of an object.
+ */
+public class ObjectDeletePacket implements OutgoingPacket{
+
+ private Position position;
+
+ /**
+ * Creates the packet
+ * @param position the object's position
+ */
+ public ObjectDeletePacket(Position position) {
+
+ this.position= position;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.put(position.getX());
+ buffer.put(position.getY());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/RemoveAllDialogsPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/RemoveAllDialogsPacket.java
new file mode 100644
index 0000000..ea515db
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/RemoveAllDialogsPacket.java
@@ -0,0 +1,35 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client to remove all dialogs
+ */
+public class RemoveAllDialogsPacket implements OutgoingPacket{
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {}
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/RemoveCharDialogPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/RemoveCharDialogPacket.java
new file mode 100644
index 0000000..398b23f
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/RemoveCharDialogPacket.java
@@ -0,0 +1,53 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.Character;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet to tell the client to remove a character's dialog.
+ */
+public class RemoveCharDialogPacket implements OutgoingPacket{
+
+ private Character character;
+
+ /**
+ * Creates the packet.
+ * @param character the character who's dialog will be removed.
+ */
+ public RemoveCharDialogPacket (Character character) {
+
+ this.character= character;
+ }
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getCharIndex());
+
+ }
+
+
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/SendSkillsPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/SendSkillsPacket.java
new file mode 100644
index 0000000..471e324
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/SendSkillsPacket.java
@@ -0,0 +1,54 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+import com.ao.model.character.Skill;
+import com.ao.model.character.UserCharacter;
+
+/**
+ * Packet to send user skill points and progress to the client
+ */
+public class SendSkillsPacket implements OutgoingPacket {
+
+ private UserCharacter user;
+
+
+ public SendSkillsPacket(UserCharacter user) {
+
+ super();
+ this.user= user;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ for (Skill skill : Skill.values()) {
+
+ buffer.put((byte)user.getSkill(skill));
+
+ if (user.getSkill(skill) < Skill.MAX_SKILL_POINT)
+ buffer.put( (byte) ( user.getSkillExp(skill) * 100 / user.getSkillELU(skill) ) );
+ else
+ buffer.put((byte)0);
+ }
+ }
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ShowMessageBoxPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ShowMessageBoxPacket.java
new file mode 100644
index 0000000..5a7a79b
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/ShowMessageBoxPacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that sends a message to display in a message box.
+ */
+public class ShowMessageBoxPacket implements OutgoingPacket{
+
+ private String message;
+
+
+ /**
+ * Creates the packet.
+ * @param message the message to display
+ */
+ public ShowMessageBoxPacket(String message) {
+
+ this.message= message;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putASCIIString(message);
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateExperiencePacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateExperiencePacket.java
new file mode 100644
index 0000000..ac23d55
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateExperiencePacket.java
@@ -0,0 +1,50 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that informs about an update in character's experience.
+ */
+public class UpdateExperiencePacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+ /**
+ * Creates the packet.
+ * @param character the character whose experience was updated.
+ */
+ public UpdateExperiencePacket (LoggedUser character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putInt(character.getExperience());
+ }
+
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateGoldPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateGoldPacket.java
new file mode 100644
index 0000000..88fab21
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateGoldPacket.java
@@ -0,0 +1,52 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that informs about an update in character's amount of gold.
+ */
+public class UpdateGoldPacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+ /**
+ * Creates the packet.
+ * @param character the character whose amount of gold was updated.
+ */
+ public UpdateGoldPacket (LoggedUser character) {
+
+ this.character= character;
+ }
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putInt(character.getMoney());
+
+ }
+
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateHPPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateHPPacket.java
new file mode 100644
index 0000000..ff1dd38
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateHPPacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports an update in character's HP.
+ */
+public class UpdateHPPacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+ /**
+ * Creates the packet.
+ * @param character the character whose HP was updated.
+ */
+ public UpdateHPPacket (LoggedUser character) {
+
+ this.character= character;
+ }
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getHitPoints());
+ }
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateManaPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateManaPacket.java
new file mode 100644
index 0000000..236612b
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateManaPacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports an update in character's mana.
+ */
+public class UpdateManaPacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+ /**
+ * Creates the packet.
+ * @param character the character whose mana was updated.
+ */
+ public UpdateManaPacket(LoggedUser character) {
+
+ this.character= character;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getMana());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdatePositionPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdatePositionPacket.java
new file mode 100644
index 0000000..7ce613b
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdatePositionPacket.java
@@ -0,0 +1,52 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports an update in character's position.
+ */
+public class UpdatePositionPacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+ /**
+ * Creates the packet.
+ * @param character the character whose position was updated.
+ */
+ public UpdatePositionPacket (LoggedUser character) {
+
+ this.character= character;
+ }
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.put(character.getPosition().getX());
+ buffer.put(character.getPosition().getY());
+ }
+
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStaminaPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStaminaPacket.java
new file mode 100644
index 0000000..f0ab23c
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStaminaPacket.java
@@ -0,0 +1,52 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that reports an update in character's stamina.
+ * */
+public class UpdateStaminaPacket implements OutgoingPacket{
+
+ private LoggedUser character;
+
+
+ /**
+ * Creates the packet.
+ * @param character the character whose stamina was updated.
+ */
+ public UpdateStaminaPacket(LoggedUser character) {
+
+ this.character= character;
+ }
+
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putShort((short) character.getStamina());
+ }
+
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStrengthPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStrengthPacket.java
index 0c9d8b4..dfde114 100644
--- a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStrengthPacket.java
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UpdateStrengthPacket.java
@@ -27,10 +27,10 @@
* @author mvanotti
*/
public class UpdateStrengthPacket implements OutgoingPacket {
+
protected byte strength;
-
/**
* Creates a new UpdateStrength packet
*
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UserCommerceInitPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UserCommerceInitPacket.java
new file mode 100644
index 0000000..d92f683
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/UserCommerceInitPacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.user.LoggedUser;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that prompts the client to initiate user-to-user trade console.
+ */
+public class UserCommerceInitPacket implements OutgoingPacket{
+
+ private LoggedUser trader;
+
+ /**
+ * Creates the packet.
+ * @param trader the character with which the trade begins
+ */
+ public UserCommerceInitPacket (LoggedUser trader) {
+
+ this.trader= trader;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.putASCIIString(trader.getName());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/network/packet/outgoing/WorkRequestTargetPacket.java b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/WorkRequestTargetPacket.java
new file mode 100644
index 0000000..56d50f9
--- /dev/null
+++ b/aoxp-server/src/main/java/com/ao/network/packet/outgoing/WorkRequestTargetPacket.java
@@ -0,0 +1,49 @@
+/*
+ AO-XP Server (XP stands for Cross Platform) is a Java implementation of Argentum Online's server
+ Copyright (C) 2009 Juan Martín Sotuyo Dodero.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+package com.ao.network.packet.outgoing;
+
+import java.io.UnsupportedEncodingException;
+
+import com.ao.model.character.Skill;
+import com.ao.network.DataBuffer;
+import com.ao.network.packet.OutgoingPacket;
+
+/**
+ * Packet that sends the client the data needed to properly prompt the user according to the tool being used.
+ */
+public class WorkRequestTargetPacket implements OutgoingPacket{
+
+ private Skill skill;
+
+ /**
+ * Creates the packet.
+ * @param skill the skill representing the activity the user intends to perform
+ */
+ public WorkRequestTargetPacket(Skill skill) {
+
+ this.skill= skill;
+ }
+
+ @Override
+ public void write(DataBuffer buffer) throws UnsupportedEncodingException {
+
+ buffer.put((byte) skill.ordinal());
+ }
+
+}
diff --git a/aoxp-server/src/main/java/com/ao/service/LoginService.java b/aoxp-server/src/main/java/com/ao/service/LoginService.java
index fb63d10..3298342 100644
--- a/aoxp-server/src/main/java/com/ao/service/LoginService.java
+++ b/aoxp-server/src/main/java/com/ao/service/LoginService.java
@@ -19,6 +19,7 @@
package com.ao.service;
import com.ao.model.user.ConnectedUser;
+import com.ao.model.user.LoggedUser;
import com.ao.service.login.LoginErrorException;
public interface LoginService {
@@ -50,7 +51,6 @@ void connectExistingCharacter(ConnectedUser user, String name, String password,
* @param homeland The character's homeland.
* @param clientHash The client's integrity check hash.
* @param version The client's version.
- * @return
* @throws LoginErrorException
*/
void connectNewCharacter(ConnectedUser user, String username, String password, byte race,
diff --git a/aoxp-server/src/main/java/com/ao/service/login/LoginServiceImpl.java b/aoxp-server/src/main/java/com/ao/service/login/LoginServiceImpl.java
index c5c6c10..433e577 100644
--- a/aoxp-server/src/main/java/com/ao/service/login/LoginServiceImpl.java
+++ b/aoxp-server/src/main/java/com/ao/service/login/LoginServiceImpl.java
@@ -33,6 +33,7 @@
import com.ao.model.map.City;
import com.ao.model.user.Account;
import com.ao.model.user.ConnectedUser;
+import com.ao.model.user.LoggedUser;
import com.ao.security.SecurityManager;
import com.ao.service.CharacterBodyService;
import com.ao.service.LoginService;
@@ -54,7 +55,7 @@ public class LoginServiceImpl implements LoginService {
public static final String CORRUPTED_CLIENT_ERROR = "El cliente está dañado, por favor descárguelo nuevamente desde http://www.argentumonline.com.ar/";
public static final String BANNED_CHARACTER_ERROR = "Se te ha prohibido la entrada a Argentum debido a tu mal comportamiento. Puedes consultar el reglamento y el sistema de soporte desde www.argentumonline.com.ar";
public static final String INCORRECT_PASSWORD_ERROR = "Contraseña incorrecta.";
- public static final String CHARACTER_CREATION_DISABLED_ERROR = "La creación de personajes en este servidor se ha deshabilitado.";
+ public static final String CHARACTER_CREATION_DISABLED_ERROR = "La creación de personajes en este servidor se ha deshabilitado momentaneamente.";
public static final String ONLY_ADMINS_ERROR = "Servidor restringido a administradores. Consulte la página oficial o el foro oficial para más información.";
public static final String MUST_THROW_DICES_BEFORE_ERROR = "Debe tirar los dados antes de poder crear un personaje.";
public static final String INVALID_RACE_ERROR = "La raza seleccionada no es válida.";
@@ -171,7 +172,7 @@ public void connectNewCharacter(ConnectedUser user, String username, String pass
// First, we have to create the new account.
Account acc;
-
+
try {
acc = accDAO.create(username, password, mail);
} catch(NameAlreadyTakenException e) {
@@ -185,24 +186,32 @@ public void connectNewCharacter(ConnectedUser user, String username, String pass
// Once we have the account, lets create the character itself!
+ UserCharacter chara;
+
try {
- UserCharacter chara = charDAO.create(username, race, gender, archetype,
- head, homeland, user.getAttribute(Attribute.STRENGTH),
+ chara= charDAO.create(username, race, gender, archetype,
+ head, homeland, user.getAttribute(Attribute.STRENGTH),
user.getAttribute(Attribute.AGILITY), user.getAttribute(Attribute.INTELLIGENCE),
user.getAttribute(Attribute.CHARISMA), user.getAttribute(Attribute.CONSTITUTION),
initialAvailableSkills, body);
+
} catch (DAOException e) {
accDAO.delete(username);
throw new LoginErrorException(e.getMessage());
}
-
- // Everything it's okay, associate the character with the account and the account with the user.
+
acc.addCharacter(username);
- user.setAccount(acc);
+ user.setAccount(acc);
+ acc.setLoggedCharacter((LoggedUser)chara);
- // TODO: Put it in the world!
+ userService.logIn(user); //logs the character in.
+
+
+// setPosition(new Position(homeland.getX(), homeland.getY(), mapService.getMap((byte)homeland.getMap())));
+
+ mapService.putCharacterAtPos(chara, chara.getPosition()); //places character in the world.
}
@Override
@@ -247,13 +256,24 @@ public void connectExistingCharacter(ConnectedUser user, String name, String pas
// TODO : Do something with the account!!!
- UserCharacter character = acc.getCharacter(name);
+ UserCharacter chara;
// TODO : send all data!
- user.setAccount(acc);
-
- userService.logIn(user);
+ user.setAccount(acc); //associates the account with the user
+
+ try {
+ chara= (LoggedUser) charDAO.load(name); // loads the character.
+
+ } catch (DAOException e) {
+ throw new LoginErrorException(e.getMessage());
+ }
+
+ acc.setLoggedCharacter((LoggedUser)chara);
+
+ userService.logIn(user); //adds character to list of logged characters.
+
+ mapService.putCharacterAtPos(chara, chara.getPosition()); //places character in the world.
}
/**
diff --git a/aoxp-server/src/main/java/com/ao/service/map/MapServiceImpl.java b/aoxp-server/src/main/java/com/ao/service/map/MapServiceImpl.java
index 03dc5f4..7986053 100644
--- a/aoxp-server/src/main/java/com/ao/service/map/MapServiceImpl.java
+++ b/aoxp-server/src/main/java/com/ao/service/map/MapServiceImpl.java
@@ -77,12 +77,11 @@ public City getCity(byte id) {
@Override
public void putCharacterAtPos(Character chara, Position pos) {
pos.getMap().putCharacterAtPos(chara, pos.getX(), pos.getY());
- //TODO Seteamos aca la nueva position en el character?
}
@Override
public void moveCharacterTo(Character chara, Heading heading) {
- //FIXME Metodo getPosition() de loggedUser no está implementado.
+
byte x = chara.getPosition().getX();
byte y = chara.getPosition().getY();
@@ -104,8 +103,24 @@ public void moveCharacterTo(Character chara, Heading heading) {
x--;
break;
}
+
+ //TODO How much of all this has to be done in Character.moveTo(Heading) method?
+
+ //TODO This doesn't take into account map crossing because it always use char current map.
+ Position newPos= new Position(x, y, chara.getPosition().getMap());
- putCharacterAtPos(chara, new Position(x, y, chara.getPosition().getMap()));
+ //Checks whether the destination tile is blocked or not.
+ if (!newPos.getMap().getTile(x, y).isBlocked()) {
+
+ putCharacterAtPos(chara, newPos); //puts character at his new tile in the map.
+
+ chara.getPosition().getMap().getTile( //deletes character from the tile it was at before.
+ chara.getPosition().getX(), chara.getPosition().getY()).setCharacter(null);
+
+ chara.setPosition(newPos); //updates character's position
+ }
+
+ chara.setHeading(heading); //heading is updated regardless of blocked tiles.
}
-}
\ No newline at end of file
+}
diff --git a/aoxp-server/src/test/java/com/ao/network/packet/incoming/LoginNewCharacterPacketTest.java b/aoxp-server/src/test/java/com/ao/network/packet/incoming/LoginNewCharacterPacketTest.java
index daebcc3..41a5342 100644
--- a/aoxp-server/src/test/java/com/ao/network/packet/incoming/LoginNewCharacterPacketTest.java
+++ b/aoxp-server/src/test/java/com/ao/network/packet/incoming/LoginNewCharacterPacketTest.java
@@ -90,6 +90,7 @@ public void setUp() throws Exception {
mapService = ApplicationContext.getInstance(MapService.class);
mapService.loadCities();
+ mapService.loadMaps();
config.setRestrictedToAdmins(false);
config.setCharacterCreationEnabled(true);