diff --git a/scripts/commands/pvp.py b/scripts/commands/pvp.py index 93e9051b..0155c528 100644 --- a/scripts/commands/pvp.py +++ b/scripts/commands/pvp.py @@ -1,74 +1,72 @@ from resources.objects.creature import CreatureObject -from protocol.swg import UpdatePVPStatusMessage +from resources.common import PvpStatus +from resources.common import FactionStatus import sys +import time def setup(): return def run(core, actor, target, commandString): - actorFaction = actor.getFaction() - actorStatus = actor.getFactionStatus() - pvpStatus = UpdatePVPStatusMessage(actor.getObjectId()) - - if commandString == ('imperial') and actorFaction != "imperial": - actor.setFaction('imperial') - return - - if commandString == ('rebel') and actorFaction != "rebel": - actor.setFaction('rebel') - return - - if commandString == ('neutral') and actorFaction != "neutral": - actor.setFaction('neutral') - return - - if actorStatus == 0 and actorFaction == "imperial": - actor.setFactionStatus(1) - #print ("FactionStatus: " + str(actor.getFactionStatus())) - actor.sendSystemMessage('You are no longer On Leave.', 0) - return + faction = actor.getFaction() + factionStatus = actor.getFactionStatus() - if actorStatus == 0 and actorFaction == "rebel": - actor.setFactionStatus(1) - #print ("FactionStatus: " + str(actor.getFactionStatus())) - actor.sendSystemMessage('You are no longer On Leave.', 0) - return + if actor.getPvpStatus(PvpStatus.GoingOvert) or actor.getPvpStatus(PvpStatus.GoingCovert): + actor.sendSystemMessage('@faction_recruiter:pvp_status_changing', 0) + return - if actorStatus == 1 and actorFaction == "imperial": - actor.setFactionStatus(2) - pvpStatus.setFaction(UpdatePVPStatusMessage.factionCRC.Imperial) - pvpStatus.setStatus(55) - actor.notifyObservers(pvpStatus.serialize(), True) - actor.sendSystemMessage('@faction_recruiter:overt_complete', 0) - print ("FactionStatus: " + str(actor.getFactionStatus())) - return - - if actorStatus == 1 and actorFaction == "rebel": - actor.setFactionStatus(2) - pvpStatus.setFaction(UpdatePVPStatusMessage.factionCRC.Rebel) - pvpStatus.setStatus(55) - actor.notifyObservers(pvpStatus.serialize(), True) - actor.sendSystemMessage('@faction_recruiter:overt_complete', 0) - print ("FactionStatus: " + str(actor.getFactionStatus())) - return - - if actorStatus == 2 and actorFaction == "imperial": - actor.setFactionStatus(1) - pvpStatus.setFaction(UpdatePVPStatusMessage.factionCRC.Imperial) - pvpStatus.setStatus(16) - actor.notifyObservers(pvpStatus.serialize(), True) - actor.sendSystemMessage('@faction_recruiter:covert_complete', 0) - print ("FactionStatus: " + str(actor.getFactionStatus())) - return - - if actorStatus == 2 and actorFaction == "rebel": - actor.setFactionStatus(1) - pvpStatus.setFaction(UpdatePVPStatusMessage.factionCRC.Rebel) - pvpStatus.setStatus(16) - actor.notifyObservers(pvpStatus.serialize(), True) - actor.sendSystemMessage('@faction_recruiter:covert_complete', 0) - print ("FactionStatus: " + str(actor.getFactionStatus())) - return - - - return \ No newline at end of file + if commandString != '' and commandString != faction: + if commandString == 'rebel' or commandString == 'imperial' or commandString == 'neutral': + actor.sendSystemMessage('@faction_recruiter:sui_resig_complete_in_5', 0) + + if actor.getFactionStatus() == FactionStatus.SpecialForces: + actor.setPvpStatus(PvpStatus.GoingCovert, True) + time.sleep(300) + + actor.setPvpStatus(PvpStatus.GoingCovert | PvpStatus.Overt | PvpStatus.Attackable | PvpStatus.Aggressive | PvpStatus.Enemy, False) + actor.setFactionStatus(FactionStatus.OnLeave) + + if actor.getFaction() != '' and actor.getFaction() != 'neutral': + time.sleep(1) + actor.setFaction('') + actor.sendSystemMessage('@faction_recruiter:resign_complete', 0) + + + time.sleep(1) + actor.setFaction(commandString) + return + + if faction == 'neutral' or faction == '': + actor.sendSystemMessage('@faction_recruiter:not_aligned', 0) + return + + if factionStatus == FactionStatus.OnLeave: + actor.sendSystemMessage('@faction_recruiter:on_leave_to_covert', 0) + actor.setPvpStatus(PvpStatus.GoingCovert, True) + time.sleep(1) + actor.setFactionStatus(FactionStatus.Combatant) + actor.setPvpStatus(PvpStatus.GoingCovert, False) + actor.setPvpStatus(PvpStatus.Enemy, True) + actor.sendSystemMessage('@faction_recruiter:covert_complete', 0) + return + + if factionStatus == FactionStatus.Combatant: + actor.sendSystemMessage('@faction_recruiter:covert_to_overt', 0) + actor.setPvpStatus(PvpStatus.GoingOvert, True) + time.sleep(30) + actor.setFactionStatus(FactionStatus.SpecialForces) + actor.setPvpStatus(PvpStatus.GoingOvert, False) + actor.setPvpStatus(PvpStatus.Overt | PvpStatus.Attackable | PvpStatus.Aggressive, True) + actor.sendSystemMessage('@faction_recruiter:overt_complete', 0) + return + + if factionStatus == FactionStatus.SpecialForces: + actor.sendSystemMessage('@faction_recruiter:overt_to_covert', 0) + actor.setPvpStatus(PvpStatus.GoingCovert, True) + time.sleep(300) + actor.setFactionStatus(FactionStatus.Combatant) + actor.setPvpStatus(PvpStatus.GoingCovert | PvpStatus.Overt | PvpStatus.Attackable | PvpStatus.Aggressive, False) + actor.sendSystemMessage('@faction_recruiter:covert_complete', 0) + return + + return diff --git a/scripts/commands/setgodmode.py b/scripts/commands/setgodmode.py new file mode 100644 index 00000000..d8b9647d --- /dev/null +++ b/scripts/commands/setgodmode.py @@ -0,0 +1,39 @@ +import sys +from engine.resources.scene import Point3D + +def setup(): + return + +def run(core, actor, target, commandString): + + playerObject = actor.getSlottedObject('ghost') + + if not playerObject: + return + + commandArgs = commandString.split(' ') + command = commandArgs[0] + arg1 = commandArgs[1] + if commandArgs[2]: + arg2 = commandArgs[2] + if commandArgs[3]: + arg3 = commandArgs[3] + if commandArgs[4]: + arg4 = commandArgs[4] + + if not command: + return + + if command == 'giveExperience' and arg1: + core.playerService.giveExperience(actor, int(arg1)) + + if command == 'setSpeed' and arg1: + actor.sendSystemMessage('Your speed was ' + str(actor.getSpeedMultiplierBase()) + '. Don\'t forget to set this back or it\'ll permanently imbalance your speed. Default without buffs or mods is 1.', 2) + actor.setSpeedMultiplierBase(float(arg1)) + actor.sendSystemMessage('Your new speed is ' + str(actor.getSpeedMultiplierBase()) + '.', 2) + + if command == 'teleport' and arg2 and arg3 and arg4: + position = Point3D(float(arg2), float(arg3), float(arg4)) + core.simulationService.transferToPlanet(actor, core.terrainService.getPlanetByName(arg1), position, actor.getOrientation(), None) + + return diff --git a/scripts/starter_clothing/crafting_artisan_trandoshan_male.py b/scripts/starter_clothing/crafting_artisan_trandoshan_male.py index c6071a93..3862af73 100644 --- a/scripts/starter_clothing/crafting_artisan_trandoshan_male.py +++ b/scripts/starter_clothing/crafting_artisan_trandoshan_male.py @@ -5,7 +5,6 @@ def CraftingArtisanTrandoshanMale(core, object): vest = core.objectService.createObject('object/tangible/wearables/vest/shared_vest_s09.iff', object.getPlanet()) necklace = core.objectService.createObject('object/tangible/wearables/necklace/shared_necklace_primitive_03.iff', object.getPlanet()) pants = core.objectService.createObject('object/tangible/wearables/pants/shared_pants_s13.iff', object.getPlanet()) - inventory = object.getSlottedObject('inventory') object._add(shirt) object._add(vest) object._add(necklace) diff --git a/scripts/static_map_locations.py b/scripts/static_map_locations.py index 46efc478..62070749 100644 --- a/scripts/static_map_locations.py +++ b/scripts/static_map_locations.py @@ -59,11 +59,11 @@ def corelliaLocations(core, planet): # Cities mapService.addLocation(planet, 'Coronet', -178, -4504, 17, 0, 0) - mapService.addLocation(planet, 'Tyrena', -5140, 2450, 17, 0, 0) + mapService.addLocation(planet, 'Tyrena', -5140, -2450, 17, 0, 0) mapService.addLocation(planet, 'Bela Vistal', 6766, -5692, 17, 0, 0) mapService.addLocation(planet, 'Kor Vella', -3420, 3146, 17, 0, 0) mapService.addLocation(planet, 'Doaba Guerfel', 3274, 5582, 17, 0, 0) - mapService.addLocation(planet, 'Vreni Island', -5538, 6176, 17, 0, 0) + mapService.addLocation(planet, 'Vreni Island', -5538, -6176, 17, 0, 0) def nabooLocations(core, planet): @@ -158,4 +158,4 @@ def lokLocations(core, planet): #mapService.addLocation(planet, 'Pandath Spaceport', 0, 0, 17, 0, 0) - \ No newline at end of file + diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 1c03d1fb..06213f63 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -36,11 +36,6 @@ import java.util.concurrent.TimeUnit; import net.engio.mbassy.bus.config.BusConfiguration; - - - - - import resources.common.RadialOptions; import resources.common.ThreadMonitor; import resources.objects.creature.CreatureObject; @@ -61,9 +56,11 @@ import services.StaticService; import services.TerrainService; import services.WeatherService; import services.chat.ChatService; +import services.collections.CollectionService; import services.combat.CombatService; import services.command.CombatCommand; import services.command.CommandService; +import services.gcw.FactionService; import services.gcw.GCWService; import services.guild.GuildService; import services.map.MapService; @@ -118,6 +115,7 @@ public class NGECore { public ConnectionService connectionService; public CommandService commandService; public CharacterService characterService; + public FactionService factionService; public ObjectService objectService; public MapService mapService; public UpdateService updateService; @@ -139,6 +137,7 @@ public class NGECore { public SkillModService skillModService; public EquipmentService equipmentService; public TravelService travelService; + public CollectionService collectionService; public EntertainmentService entertainmentService; public WeatherService weatherService; @@ -197,7 +196,8 @@ public class NGECore { characterService = new CharacterService(this); mapService = new MapService(this); travelService = new TravelService(this); - + + factionService = new FactionService(this); objectService = new ObjectService(this); terrainService = new TerrainService(this); updateService = new UpdateService(this); @@ -235,6 +235,7 @@ public class NGECore { zoneDispatch = new NetworkDispatch(this, true); zoneDispatch.addService(connectionService); zoneDispatch.addService(characterService); + zoneDispatch.addService(factionService); zoneDispatch.addService(objectService); zoneDispatch.addService(commandService); zoneDispatch.addService(chatService); @@ -282,6 +283,9 @@ public class NGECore { gcwService = new GCWService(this); zoneDispatch.addService(gcwService); + + collectionService = new CollectionService(this); + zoneDispatch.addService(collectionService); tradeService = new TradeService(this); zoneDispatch.addService(tradeService); diff --git a/src/protocol/swg/objectControllerObjects/ShowFlyText.java b/src/protocol/swg/objectControllerObjects/ShowFlyText.java index b4f73d31..41325368 100644 --- a/src/protocol/swg/objectControllerObjects/ShowFlyText.java +++ b/src/protocol/swg/objectControllerObjects/ShowFlyText.java @@ -38,11 +38,12 @@ public class ShowFlyText extends ObjControllerObject { private int unknownInt2; private String stfFile; private String stfString; - private short unknownShort2; + private short xp; private float scale; private RGB color; private int displayType; private boolean alternativeStructure; + private String customText; public ShowFlyText(long recieverId, long objectId, String stfFile, String stfString, float scale, RGB color, int displayType) { this.recieverId = recieverId; @@ -55,7 +56,7 @@ public class ShowFlyText extends ObjControllerObject { this.alternativeStructure = false; } - public ShowFlyText(long recieverId, long objectId, int unknownInt1, int unknownShort1, int unknownByte1, int unknownInt2, String stfFile, String stfString, int unknownShort2, float scale, RGB color, int displayType) { + public ShowFlyText(long recieverId, long objectId, int unknownInt1, int unknownShort1, int unknownByte1, int unknownInt2, String stfFile, String stfString, String customText, int xp, float scale, RGB color, int displayType) { this.recieverId = recieverId; this.objectId = objectId; this.unknownInt1 = unknownInt1; @@ -64,7 +65,8 @@ public class ShowFlyText extends ObjControllerObject { this.unknownInt2 = unknownInt2; this.stfFile = stfFile; this.stfString = stfString; - this.unknownShort2 = (short) unknownShort2; + this.customText = customText; + this.xp = (short) xp; this.scale = scale; this.color = color; this.alternativeStructure = true; @@ -115,8 +117,8 @@ public class ShowFlyText extends ObjControllerObject { result.putLong(0); result.putLong(0); result.putLong(0); - result.putInt(0); - result.putShort((short) unknownShort2); + result.put(getUnicodeString(customText)); + result.putShort(xp); result.putLong(0); result.putFloat(scale); result.put(color.getBytes()); diff --git a/src/resources/common/Opcodes.java b/src/resources/common/Opcodes.java index 670abfde..7b9b948f 100644 --- a/src/resources/common/Opcodes.java +++ b/src/resources/common/Opcodes.java @@ -55,5 +55,6 @@ public class Opcodes { public static int ClientMfdStatusUpdateMessage = CRC.StringtoCRC("ClientMdfStatusUpdateMessage"); public static int PlayMusicMessage = CRC.StringtoCRC("PlayMusicMessage"); public static int PlanetTravelPointListRequest = 0x96405D4D; + public static int FactionRequestMessage = CRC.StringtoCRC("FactionRequestMessage"); } diff --git a/src/resources/common/Options.java b/src/resources/common/Options.java new file mode 100644 index 00000000..136c7462 --- /dev/null +++ b/src/resources/common/Options.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.common; + +public class Options { + + // Any uncommented ones are confirmed correct for NGE with detailed analysis + + public static int NONE = 0; + public static int SPACE_ATTACKABLE = 1; // Ships that are attackable in space. Includes everything except stations and asteroids so far + public static int USABLE = 2; // Vendors, collections (hand icon) + public static int INSURED = 4; // Unused in NGE + public static int CONVERSABLE = 8; // Conversable on ground / commable in space + //public static int FOLLOWINGWAYPOINT = 16; // Uncertain, could be "frozen" flag or "alert" flag or other. Seen on rare occasions on NPCs + public static int SOCKETED = 32; // Object has sockets + public static int AGGRESSIVE = 64; // Always aggressive no matter what regardless of faction standing. + public static int ATTACKABLE = 128; // Attackable + public static int INVULNERABLE = 256; // No HAM + public static int DISABLED = 512; // Disabled Vehicle + //public static int CRAFTED = 1024; // Wearable TANO objects. Isn't used for WEAOs (weapons), it's just for identifying if a TANO is a wearable probably as that's where this is seen. Also seen on naboo small house deed however... Could also be "crafted items" + public static int QUEST = 2048; // Quest icon + public static int MOUNT = 4096; // Vehicle and creature mounts + public static int SERIAL = 8192; // Has serial number + //public static int UNKNOWN = 16384; // Seen being requested by the client in objcontroller 0x02AB but probably not relevant + public static int PILOT = 32768; // Pilot trainers, chassis dealers + //public static int UNKNOWN = 65536; + //public static int UNKNOWN = 131072; + //public static int UNKNOWN = 262144; + //public static int UNKNOWN = 524288; + //public static int UNKNOWN = 1048576; + //public static int UNKNOWN = 2097152; + //public static int UNKNOWN = 4194304; + public static int STARTER_SHIP = 8388508; // Seen on player scyk fighters, but no others. Could also mean SPACE_OVERT + +} diff --git a/src/resources/common/PvpStatus.java b/src/resources/common/PvpStatus.java index 18365a58..e668ba56 100644 --- a/src/resources/common/PvpStatus.java +++ b/src/resources/common/PvpStatus.java @@ -23,6 +23,7 @@ package resources.common; public class PvpStatus { + public static int None = 0; public static int Attackable = 1; public static int Aggressive = 2; public static int Overt = 4; @@ -30,7 +31,7 @@ public class PvpStatus { public static int Player = 16; public static int Enemy = 32; public static int GoingOvert = 64; - public static int GoingCombatant = 128; + public static int GoingCovert = 128; public static int Dueling = 256; } diff --git a/src/resources/objects/Buff.java b/src/resources/objects/Buff.java index db19f967..ea55a20e 100644 --- a/src/resources/objects/Buff.java +++ b/src/resources/objects/Buff.java @@ -31,7 +31,6 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.SimpleBufferAllocator; -import resources.common.BuffBuilder; import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.NotPersistent; @@ -41,7 +40,7 @@ import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.resources.common.CRC; -@Persistent(version=7) +@Persistent(version=8) public class Buff implements IListObject { @NotPersistent @@ -53,6 +52,7 @@ public class Buff implements IListObject { private long ownerId; private String effect1Name, effect2Name, effect3Name, effect4Name, effect5Name; private float effect1Value, effect2Value, effect3Value, effect4Value, effect5Value; + private String callback; private String particleEffect; private boolean isDebuff; private boolean removeOnDeath; @@ -98,6 +98,7 @@ public class Buff implements IListObject { effect4Value = (Float) visitor.getObject(i, 14); effect5Name = (String) visitor.getObject(i, 15); effect5Value = (Float) visitor.getObject(i, 16); + callback = (String) visitor.getObject(i, 18); particleEffect = (String) visitor.getObject(i, 19); isDebuff = (Boolean) visitor.getObject(i, 22); removeOnDeath = (Integer) visitor.getObject(i, 25) != 0; @@ -266,6 +267,14 @@ public class Buff implements IListObject { public void setEffect5Value(float effect5Value) { this.effect5Value = effect5Value; } + + public String getCallback() { + return callback; + } + + public void setCallback(String callback) { + this.callback = callback; + } public String getParticleEffect() { return particleEffect; diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 20c1b928..ac7ceac5 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -97,14 +97,8 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.put(getAsciiString(creature.getStfName())); if (creature.getCustomName() == null) { creature.setCustomName(""); }//Not all CreatureObjects have CustomName (Shuttles) buffer.put(getUnicodeString(creature.getCustomName())); - buffer.putInt(0x000F4240); // unk - String factionCRC = creature.getFaction(); - if(factionCRC == null) - buffer.putInt(0); - else if(factionCRC.equals("neutral")) - buffer.putInt(0); - else - buffer.putInt(CRC.StringtoCRC(factionCRC)); + buffer.putInt(0x000F4240); // volume + buffer.putInt(CRC.StringtoCRC(creature.getFaction())); buffer.putInt(creature.getFactionStatus()); diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 3254289c..1e964681 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -31,8 +31,8 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ChatSystemMessage; import protocol.swg.ObjControllerMessage; import protocol.swg.PlayMusicMessage; -import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.UpdatePostureMessage; +import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.objectControllerObjects.Animation; import protocol.swg.objectControllerObjects.Posture; @@ -102,7 +102,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { // CREO6 private byte combatFlag = 0; - private short level = 1; + private short level = -1; private int grantedHealth = 0; private String currentAnimation; private String moodAnimation; @@ -258,7 +258,14 @@ public class CreatureObject extends TangibleObject implements IPersistent { } } - + + @Override + public int getOptionsBitmask() { + synchronized(objectMutex) { + return optionsBitmask; + } + } + @Override public void setOptionsBitmask(int optionBitmask) { synchronized(objectMutex) { @@ -270,6 +277,14 @@ public class CreatureObject extends TangibleObject implements IPersistent { notifyObservers(optionDelta, true); } + + public void addOption(int option) { + setOptionsBitmask(getOptionsBitmask() & option); + } + + public void removeOption(int option) { + setOptionsBitmask(getOptionsBitmask() |~ option); + } public byte getPosture() { synchronized(objectMutex) { @@ -295,10 +310,8 @@ public class CreatureObject extends TangibleObject implements IPersistent { this.faction = faction; } - IoBuffer factionDelta = messageBuilder.buildFactionDelta(faction); - - notifyObservers(factionDelta, true); - + notifyObservers(messageBuilder.buildFactionDelta(faction), true); + setPvpStatus(0, true); } public int getFactionStatus() { @@ -312,10 +325,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { this.factionStatus = factionStatus; } - IoBuffer factionStatusDelta = messageBuilder.buildFactionStatusDelta(factionStatus); - - notifyObservers(factionStatusDelta, true); - + notifyObservers(messageBuilder.buildFactionStatusDelta(factionStatus), true); } public float getHeight() { @@ -929,26 +939,48 @@ public class CreatureObject extends TangibleObject implements IPersistent { //destination.getSession().write(upm.serialize()); if(destination != getClient()) { - UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID()); - if (factionStatus == 1 && faction.equals("imperial")) { + UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID(), getPvPBitmask(), getFaction()); + + /* + if (factionStatus == 1 && faction == "imperial") { upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Imperial); upvpm.setStatus(16); - } else if (factionStatus == 1 && faction.equals("rebel")) { + if ((getOptionsBitmask() & 128) == 128) upvpm.setStatus(0); + if (getOwnerId() != 0) upvpm.setStatus(256); + } + + if (factionStatus == 1 && faction == "rebel") { upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Rebel); upvpm.setStatus(16); - } else if (factionStatus == 2 && faction.equals("imperial")) { + if ((getOptionsBitmask() & 128) == 128) upvpm.setStatus(0); + if (getOwnerId() != 0) upvpm.setStatus(256); + } + + if (factionStatus == 2 && faction == "imperial") { upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Imperial); upvpm.setStatus(55); - } else if (factionStatus == 2 && faction.equals("rebel")) { + if ((getOptionsBitmask() & 128) == 128) upvpm.setStatus(39); + if (getOwnerId() != 0) upvpm.setStatus(295); + } + if (factionStatus == 2 && faction == "rebel") { upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Rebel); upvpm.setStatus(55); - } else if(getSlottedObject("ghost") != null) { - upvpm.setFaction(CRC.StringtoCRC(faction)); + if ((getOptionsBitmask() & 128) == 128) upvpm.setStatus(39); + if (getOwnerId() != 0) upvpm.setStatus(295); + } + if(factionStatus == 0 && faction == "neutral") { + upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Neutral); upvpm.setStatus(16); + if ((getOptionsBitmask() & 128) == 128) upvpm.setStatus(0); + if (getOwnerId() != 0) upvpm.setStatus(256); } else { upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Neutral); - upvpm.setStatus(0); - } + upvpm.setStatus(16); + if ((getOptionsBitmask() & 128) == 128) upvpm.setStatus(0); + if (getOwnerId() != 0) upvpm.setStatus(256); + } + */ + destination.getSession().write(upvpm.serialize()); } } @@ -1265,4 +1297,16 @@ public class CreatureObject extends TangibleObject implements IPersistent { return this.staticNPC = staticNPC; } + @Override + public void setPvPBitmask(int pvpBitmask) { + super.setPvPBitmask(pvpBitmask); + notifyObservers(new UpdatePVPStatusMessage(getObjectID(), getPvPBitmask(), getFaction()), false); + } + + @Override + public void setPvpStatus(int pvpBitmask, boolean add) { + super.setPvpStatus(pvpBitmask, add); + notifyObservers(new UpdatePVPStatusMessage(getObjectID(), getPvPBitmask(), getFaction()), false); + } + } diff --git a/src/resources/objects/guild/GuildObject.java b/src/resources/objects/guild/GuildObject.java index 0107ff79..504a10e6 100644 --- a/src/resources/objects/guild/GuildObject.java +++ b/src/resources/objects/guild/GuildObject.java @@ -21,6 +21,7 @@ ******************************************************************************/ package resources.objects.guild; +import java.util.HashMap; import java.util.Map; import java.util.TreeMap; @@ -35,6 +36,7 @@ import resources.guild.Guild; import resources.objects.SWGList; import resources.objects.SWGMap; import resources.objects.SWGMultiMap; +import services.collections.ServerFirst; import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; @@ -54,7 +56,8 @@ public class GuildObject extends SWGObject implements IPersistent { protected NGECore core; @NotPersistent private GuildMessageBuilder messageBuilder = new GuildMessageBuilder(this); - + + private Map serverFirst = new HashMap(); private Map> zoneMap = new TreeMap>(); @NotPersistent private Transaction txn; @@ -260,6 +263,20 @@ public class GuildObject extends SWGObject implements IPersistent { } } + public Map getServerFirst() { + synchronized(objectMutex) { + return serverFirst; + } + } + + public void addServerFirst(String collectionName, ServerFirst player) { + synchronized(objectMutex) { + if (!serverFirst.containsKey(collectionName)) { + serverFirst.put(collectionName, player); + } + } + } + @Override public void sendBaselines(Client destination) { destination.getSession().write(messageBuilder.buildBaseline3()); diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index fc89c30b..452acc19 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -22,12 +22,14 @@ package resources.objects.player; import java.nio.ByteOrder; +import java.util.BitSet; import java.util.Map.Entry; import org.apache.mina.core.buffer.IoBuffer; import engine.resources.common.CRC; +import resources.common.StringUtilities; import resources.objects.ObjectMessageBuilder; import resources.objects.waypoint.WaypointObject; @@ -86,46 +88,18 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { buffer.putInt(getProfData(player.getProfession())); // prof icon buffer.put(getAsciiString(player.getProfession())); - buffer.putInt(0); // unk - buffer.putInt(0); // unk + buffer.putInt(0); // GCW + buffer.putInt(0); // PvP Kills + buffer.putLong(0); // Lifetime GCW + buffer.putInt(0); // Lifetime PvP Kills + buffer.putInt(player.getCollections().length); + buffer.putInt(player.getHighestSetBit()); + buffer.put(player.getCollections()); + buffer.putInt(0); // Unknown, part of one delta, maybe a list + buffer.putInt(0); // Unknown, part of one delta, maybe a list + buffer.put((byte) 0); // Unknown Boolean used in Tansarii + buffer.put((byte) 0); // Unknown Boolean used in Tansarii - byte[] data1 = new byte[] { - - 0x76, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xCF, (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x3E, (byte) 0x00, (byte) 0x00, (byte) 0x0F, (byte) 0x00, (byte) 0x60, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x41, (byte) 0x02, (byte) 0x88, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x1F, (byte) 0x20, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x84, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x28, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x40, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data1); - byte[] data2 = new byte[] { - - 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xC0, (byte) 0x05, (byte) 0x04, (byte) 0x78, (byte) 0x34, (byte) 0x78, (byte) 0x78, (byte) 0x08, (byte) 0x08, (byte) 0x14, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0A, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x40, (byte) 0x04, (byte) 0x00, (byte) 0x20, (byte) 0x81, (byte) 0x0A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x60, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0xC0, (byte) 0xFF, (byte) 0xC7, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x20, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data2); - byte[] data3 = new byte[] { - - 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0xCB, (byte) 0x32, (byte) 0x06, (byte) 0x18, (byte) 0x60, (byte) 0x0C, (byte) 0x30, (byte) 0x60, (byte) 0x2D, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data3); - byte[] data4 = new byte[] { - - 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data4); - byte[] data5 = new byte[] { - - 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xC0, (byte) 0xFF, (byte) 0x1F, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xD0, (byte) 0xD5, (byte) 0x68, (byte) 0x00, (byte) 0x1A, (byte) 0x46, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x30, (byte) 0x1A, (byte) 0x00, (byte) 0x00, (byte) 0x40, (byte) 0x03, (byte) 0xD0, (byte) 0x00, (byte) 0x34, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data5); - byte[] data6 = new byte[] { - - 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data6); - byte[] data7 = new byte[] { - - 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0xFF, (byte) 0x3F, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00 - }; - buffer.put(data7); - - int size = buffer.position(); buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); @@ -377,6 +351,18 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { } + public IoBuffer buildCollectionsDelta(byte[] collections, int highestSetBit) { + IoBuffer buffer = bufferPool.allocate(8 + collections.length, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(collections.length); + buffer.putInt(highestSetBit); + for (byte collection : collections) buffer.put(collection); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 16, buffer, size + 4); + System.out.println(StringUtilities.bytesToHex(buffer.array())); + return buffer; + } + public IoBuffer buildXPListDelta(String type, int amount, boolean alreadyExists) { PlayerObject player = (PlayerObject) object; player.setXpListUpdateCounter(player.getXpListUpdateCounter() + 1); diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 8e9dcfd0..5b679a34 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -22,9 +22,11 @@ package resources.objects.player; import java.util.ArrayList; +import java.util.BitSet; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import resources.objects.waypoint.WaypointObject; @@ -39,7 +41,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent +@Persistent(version=1) public class PlayerObject extends SWGObject { // PLAY 3 @@ -51,6 +53,8 @@ public class PlayerObject extends SWGObject { private List titleList = new ArrayList(); private int bornDate = 0; private int totalPlayTime = 0; + private byte[] collections = new byte[] { }; + private int highestSetBit = 0; // PLAY 6 @@ -116,7 +120,7 @@ public class PlayerObject extends SWGObject { @NotPersistent private long lastPlayTimeUpdate = System.currentTimeMillis(); - + private Map factionStandingMap = new TreeMap(); public PlayerObject() { super(); @@ -136,12 +140,13 @@ public class PlayerObject extends SWGObject { public void setTitle(String title) { synchronized(objectMutex) { - if(!getTitleList().isEmpty() && getTitleList().contains(title)) { this.title = title; - notifyObservers(messageBuilder.buildTitleDelta(title), true); } + } + + notifyObservers(messageBuilder.buildTitleDelta(title), true); } public String getProfession() { @@ -551,7 +556,30 @@ public class PlayerObject extends SWGObject { this.jediState = jediState; } } - + + public Map getFactionStandingMap() { + return factionStandingMap; + } + + public void setFactionStanding(String faction, int factionStanding) { + synchronized(objectMutex) { + factionStandingMap.put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); + } + } + + public void modifyFactionStanding(String faction, int modifier) { + synchronized(objectMutex) { + int factionStanding = (((factionStandingMap.containsKey(faction)) ? factionStandingMap.get(faction) : 0) + modifier); + factionStandingMap.put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); + } + } + + public int getFactionStanding(String faction) { + synchronized(objectMutex) { + return ((factionStandingMap.containsKey(faction)) ? factionStandingMap.get(faction) : 0); + } + } + @Override public void sendBaselines(Client destination) { @@ -583,9 +611,30 @@ public class PlayerObject extends SWGObject { public List getTitleList() { return titleList; } - + public void setTitleList(List titleList) { this.titleList = titleList; } + public void setCollections(byte[] collections) { + synchronized(objectMutex) { + this.collections = collections; + this.highestSetBit = BitSet.valueOf(collections).length(); + } + + notifyObservers(messageBuilder.buildCollectionsDelta(collections, getHighestSetBit()), true); + } + + public byte[] getCollections() { + synchronized(objectMutex) { + return collections; + } + } + + public int getHighestSetBit() { + synchronized(objectMutex) { + return highestSetBit; + } + } + } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index d35baf08..7a1ae89d 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -49,7 +49,6 @@ import engine.resources.scene.Quaternion; @Persistent public class TangibleObject extends SWGObject { - // TODO: Thread safety protected int incapTimer = 10; @@ -60,7 +59,7 @@ public class TangibleObject extends SWGObject { protected int optionsBitmask = 0; private int maxDamage = 1000; private boolean staticObject = false; - protected String faction = ""; + protected String faction = "neutral"; // Says you're "Imperial Special Forces" if it's 0 for some reason @NotPersistent private Vector defendersList = new Vector(); // unused in packets but useful for the server @NotPersistent @@ -69,15 +68,20 @@ public class TangibleObject extends SWGObject { private int respawnTime = 0; private Point3D spawnCoordinates = new Point3D(0, 0, 0); + @NotPersistent + private TangibleObject killer = null; + public TangibleObject(long objectID, Planet planet, String template) { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0), template); messageBuilder = new TangibleMessageBuilder(this); + if (this.getClass().getSimpleName().equals("TangibleObject")) setIntAttribute("volume", 1); } public TangibleObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) { super(objectID, planet, position, orientation, template); messageBuilder = new TangibleMessageBuilder(this); spawnCoordinates = position.clone(); + if (this.getClass().getSimpleName().equals("TangibleObject")) setIntAttribute("volume", 1); } public TangibleObject() { @@ -104,6 +108,9 @@ public class TangibleObject extends SWGObject { conditionDamage = getMaxDamage(); this.conditionDamage = conditionDamage; notifyObservers(messageBuilder.buildConditionDamageDelta(conditionDamage), false); + if (maxDamage > 0) { + this.setStringAttribute("condition", (maxDamage + "/" + (maxDamage - conditionDamage))); + } } public byte[] getCustomization() { @@ -129,13 +136,15 @@ public class TangibleObject extends SWGObject { public void setOptionsBitmask(int optionsBitmask) { this.optionsBitmask = optionsBitmask; } - + public int getMaxDamage() { return maxDamage; } public void setMaxDamage(int maxDamage) { this.maxDamage = maxDamage; + + this.setStringAttribute("condition", (maxDamage + "/" + (maxDamage - conditionDamage))); } public boolean isStaticObject() { @@ -158,6 +167,24 @@ public class TangibleObject extends SWGObject { } } + public boolean getPvpStatus(int pvpStatus) { + synchronized(objectMutex) { + return ((pvpBitmask & pvpStatus) != 0); + } + } + + public void setPvpStatus(int pvpBitmask, boolean add) { + synchronized(objectMutex) { + if (pvpBitmask != 0) { + if (add) { + this.pvpBitmask |= pvpBitmask; + } else { + this.pvpBitmask &= ~pvpBitmask; + } + } + } + } + public String getFaction() { synchronized(objectMutex) { return faction; @@ -251,15 +278,15 @@ public class TangibleObject extends SWGObject { } } - public void showFlyText(String stfFile, String stfString, int xp, float scale, RGB color, int displayType) { + public void showFlyText(String stfFile, String stfString, String customText, int xp, float scale, RGB color, int displayType) { Set observers = getObservers(); if (getClient() != null) { - getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), 56, 1, 1, -1, stfFile, stfString, xp, scale, color, displayType))).serialize()); + getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), 56, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize()); } for (Client client : observers) { - client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), 56, 1, 1, -1, stfFile, stfString, xp, scale, color, displayType))).serialize()); + client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), 56, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize()); } } @@ -283,6 +310,18 @@ public class TangibleObject extends SWGObject { } } + public TangibleObject getKiller() { + synchronized(objectMutex) { + return killer; + } + } + + public void setKiller(TangibleObject killer) { + synchronized(objectMutex) { + this.killer = killer; + } + } + @Override public void sendBaselines(Client destination) { diff --git a/src/resources/objects/weapon/WeaponObject.java b/src/resources/objects/weapon/WeaponObject.java index 9f0b8381..368ebb18 100644 --- a/src/resources/objects/weapon/WeaponObject.java +++ b/src/resources/objects/weapon/WeaponObject.java @@ -54,6 +54,7 @@ public class WeaponObject extends SWGObject { public WeaponObject(long objectID, Planet planet, String template) { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0), template); messageBuilder = new WeaponMessageBuilder(this); + if (this.getClass().getSimpleName().equals("WeaponObject")) setIntAttribute("volume", 1); calculateRange(); calculateAttackSpeed(); } @@ -61,6 +62,7 @@ public class WeaponObject extends SWGObject { public WeaponObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) { super(objectID, planet, position, orientation, template); messageBuilder = new WeaponMessageBuilder(this); + if (this.getClass().getSimpleName().equals("WeaponObject")) setIntAttribute("volume", 1); calculateRange(); calculateAttackSpeed(); } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index ef6fda27..1c2fd7a0 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -21,29 +21,22 @@ ******************************************************************************/ package services; -import java.nio.ByteOrder; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.session.IoSession; +import org.python.core.Py; +import org.python.core.PyObject; -import protocol.swg.ObjControllerMessage; -import protocol.swg.objectControllerObjects.BuffBuilderStartMessage; -import resources.common.Console; import resources.common.FileUtilities; -import resources.common.ObjControllerOpcodes; import resources.objects.Buff; -import resources.objects.BuffItem; import resources.objects.DamageOverTime; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.player.PlayerObject; import main.NGECore; -import engine.clients.Client; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -141,10 +134,21 @@ public class BuffService implements INetworkDispatch { creature.playEffectObject(effect, buff.getBuffName()); } + if (!buff.getCallback().equals("")) { + if (FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/buffs/", buff.getBuffName(), buff.getCallback()); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(buff)); + } + } + } + return buff; } + @SuppressWarnings("unused") public void removeBuffFromCreature(CreatureObject creature, Buff buff) { if(!creature.getBuffList().contains(buff)) @@ -158,8 +162,8 @@ public class BuffService implements INetworkDispatch { core.scriptService.callScript("scripts/buffs/", "removeBuff", buff.getBuffName(), core, creature, buff); creature.removeBuff(buff); - for (String effect : buff.getParticleEffect().split(",")) { - creature.stopEffectObject(buff.getBuffName()); + for (String effect : buff.getParticleEffect().split(",")) { + creature.stopEffectObject(buff.getBuffName()); } diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 4d60f425..5298d0da 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -38,6 +38,7 @@ import engine.resources.common.CRC; import engine.resources.container.CreatureContainerPermissions; import engine.resources.container.CreaturePermissions; import engine.resources.database.DatabaseConnection; +import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; import engine.resources.service.INetworkDispatch; @@ -220,6 +221,7 @@ public class CharacterService implements INetworkDispatch { object.setOptionsBitmask(0x80); //object.setPosition(new Point3D(0, 0, 0)); object.setOrientation(new Quaternion(1, 0, 0, 0)); + object.setLevel((short) 1); float luck = (((((float) (core.scriptService.getMethod("scripts/roadmap/", clientCreateCharacter.getProfession(), "getLuck").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", object.getStfName(), "getLuck").__call__().asInt())) / ((float) 90)) * ((float) object.getLevel())) - ((float) object.getSkillModBase("luck"))); float precision = (((((float) (core.scriptService.getMethod("scripts/roadmap/", clientCreateCharacter.getProfession(), "getPrecision").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", object.getStfName(), "getPrecision").__call__().asInt())) / ((float) 90)) * ((float) object.getLevel())) - ((float) object.getSkillModBase("precision"))); float strength = (((((float) (core.scriptService.getMethod("scripts/roadmap/", clientCreateCharacter.getProfession(), "getStrength").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", object.getStfName(), "getStrength").__call__().asInt())) / ((float) 90)) * ((float) object.getLevel())) - ((float) object.getSkillModBase("strength"))); @@ -302,7 +304,7 @@ public class CharacterService implements INetworkDispatch { session.write(core.loginService.getLoginClusterStatus().serialize()); session.write(success.serialize()); - session.write((new ClientMfdStatusUpdateMessage((float) 2, "/GroundHUD.MFDStatus.vsp.role.targetLevel")).serialize()); + session.write((new ClientMfdStatusUpdateMessage((float) 2, "/GroundHUD.MFDStatus.vsp.role.targetLevel")).serialize()); } }); diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index dc422aec..453c7945 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -109,6 +109,7 @@ public class PlayerService implements INetworkDispatch { PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); player.setTotalPlayTime(player.getTotalPlayTime() + 30); player.setLastPlayTimeUpdate(System.currentTimeMillis()); + core.collectionService.checkExplorationRegions(creature); } @@ -329,7 +330,7 @@ public class PlayerService implements INetworkDispatch { // 1. Add the experience. if (experience > 0) { - creature.showFlyText("base_player", "prose_flytext_xp", experience, (float) 2.5, new RGB(180, 60, 240), 1); + creature.showFlyText("base_player", "prose_flytext_xp", "", experience, (float) 2.5, new RGB(180, 60, 240), 1); } String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general")); diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index b52b2de9..35fa7d86 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -143,6 +143,7 @@ public class SimulationService implements INetworkDispatch { core.commandService.registerCommand("boardshuttle"); core.commandService.registerCommand("getplayerid"); core.commandService.registerCommand("inspire"); + core.commandService.registerCommand("setgodmode"); } diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java new file mode 100644 index 00000000..d86ee7ad --- /dev/null +++ b/src/services/collections/CollectionService.java @@ -0,0 +1,852 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.collections; + +import java.util.BitSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; + +import org.python.core.Py; +import org.python.core.PyObject; + +import resources.common.FileUtilities; +import resources.objects.creature.CreatureObject; +import resources.objects.player.PlayerObject; + +import main.NGECore; + +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.DatatableVisitor; +import engine.resources.scene.Point3D; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class CollectionService implements INetworkDispatch { + + private NGECore core; + + private Map> explorationLocations = new TreeMap>(); + + private class ExplorationRegion { + + public Point3D location; + public float range; + + public ExplorationRegion(Point3D location, float range) { + this.location = location; + this.range = range; + } + + } + + public CollectionService(NGECore core) { + this.core = core; + + if (FileUtilities.doesFileExist("scripts/collections/exploration_badges.py")) { + PyObject method = core.scriptService.getMethod("scripts/collections/", "exploration_badges", "setup"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(this)); + } + } + } + + /* + * @see datatables/collection/collections.iff + * + * Count and exploration count badges are added automatically. + * + * You can add a new exploration location in scripts/collections + * /exploration_badges.py by defining setup(collectionService) + * and using collectionService.registerExplorationBadge(badge, x, z). + * + * Scripts named collection's slotName or collectionName should be + * put in scripts/collections/ and can use the modify(core, actor, count) + * method upon modification or complete(core, actor, count) on completion. + * + * Please distinguish a slot from a collection. A slot could be + * a type of blacksun ship where you have to kill 25 of them, and a + * collection could be a row of different blacksun ships. + * + * You'll need to choose carefully whether you make a script for the + * collection, or the specific slots, or both. + * + * @param creature The player's CreatureObject instance. + * @param collection slotName of the collection you want to add. + * + * @return True if added successfully. + */ + @SuppressWarnings("unused") + public boolean addCollection(CreatureObject creature, String collection) { + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + DatatableVisitor collectionTable; + + if (player == null) { + return false; + } + + collection = collection.toLowerCase(); + + if (isComplete(creature, collection)) { + return false; + } + + try { + collectionTable = ClientFileManager.loadFile("datatables/collection/collection.iff", DatatableVisitor.class); + BitSet collections; + String bookName = ""; + String pageName = ""; + String collectionName = ""; + boolean titleOnComplete = false; + + collections = BitSet.valueOf(player.getCollections()); + + for (int c = 0; c < collectionTable.getRowCount(); c++) { + if (collectionTable.getObject(c, 0) != null) { + if (((String) collectionTable.getObject(c, 0)) != "") { + bookName = ((String) collectionTable.getObject(c, 0)); + pageName = ""; + collectionName = ""; + titleOnComplete = false; + } else if (((String) collectionTable.getObject(c, 1)) != "") { + pageName = ((String) collectionTable.getObject(c, 1)); + collectionName = ""; + titleOnComplete = false; + } else if (((String) collectionTable.getObject(c, 2)) != "") { + collectionName = ((String) collectionTable.getObject(c, 2)); + titleOnComplete = ((Boolean) collectionTable.getObject(c, 27)); + } else if (((String) collectionTable.getObject(c, 3)) != "") { + String slotName = ((String) collectionTable.getObject(c, 3)); + + if (slotName.equals(collection)) { + int bits = 0; + boolean noScriptOnModify = false; + boolean clearOnComplete = false; + boolean noMessage = true; + boolean grantIfPreReqMet = true; + boolean buddyCollection = false; + int numAltTitles = 0; + int beginSlotId = ((Integer) collectionTable.getObject(c, 4)); + int endSlotId = ((Integer) collectionTable.getObject(c, 5)); + int maxSlotValue = ((Integer) collectionTable.getObject(c, 6)); + String music = ((String) collectionTable.getObject(c, 24)); + boolean hidden = ((Boolean) collectionTable.getObject(c, 26)); + boolean title = ((Boolean) collectionTable.getObject(c, 27)); + boolean noReward = ((Boolean) collectionTable.getObject(c, 33)); + boolean trackServerFirst = ((Boolean) collectionTable.getObject(c, 34)); + + String[] categories = { + ((String) collectionTable.getObject(c, 7)), + ((String) collectionTable.getObject(c, 8)), + ((String) collectionTable.getObject(c, 9)), + ((String) collectionTable.getObject(c, 10)), + ((String) collectionTable.getObject(c, 11)), + ((String) collectionTable.getObject(c, 12)), + ((String) collectionTable.getObject(c, 13)), + ((String) collectionTable.getObject(c, 14)), + ((String) collectionTable.getObject(c, 15)), + ((String) collectionTable.getObject(c, 16)), + ((String) collectionTable.getObject(c, 17)) + }; + + String[] prereqSlotNames = { + ((String) collectionTable.getObject(c, 18)), + ((String) collectionTable.getObject(c, 19)), + ((String) collectionTable.getObject(c, 20)), + ((String) collectionTable.getObject(c, 21)), + ((String) collectionTable.getObject(c, 22)) + }; + + String[] alternateTitles = { + ((String) collectionTable.getObject(c, 28)), + ((String) collectionTable.getObject(c, 29)), + ((String) collectionTable.getObject(c, 30)), + ((String) collectionTable.getObject(c, 31)), + ((String) collectionTable.getObject(c, 32)) + }; + + if (bookName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a book"); + throw new Exception(); + } + + if (pageName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a page"); + throw new Exception(); + } + + if (collectionName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a collection"); + throw new Exception(); + } + + if (endSlotId != -1) { + if (beginSlotId >= endSlotId) { + System.out.println(slotName + ", row " + c + ": begin slot id " + beginSlotId + " must be < end slot id" + endSlotId); + throw new Exception(); + } + + bits = (endSlotId - beginSlotId); + + if (bits > 32) { + System.out.println(slotName + ", row " + c + ": counter-type slot uses " + bits + " bits which exceeds the limit of 32 bits for counter-type slot"); + throw new Exception(); + } + + if (maxSlotValue > -1) { + if (!(maxSlotValue > 1)) { + System.out.println(slotName + ", row " + c + ": max slot value " + maxSlotValue + " must be > 1"); + throw new Exception(); + } + + BitSet bitValue = new BitSet(64); + bitValue.set(64-bits, 64); + + BitSet maxValue = new BitSet(64); + maxValue.set(64-maxSlotValue, 64); + + if (bitValue.toLongArray()[0] < maxValue.toLongArray()[0]) { + System.out.println(slotName + ", row " + c + ": counter-type slot uses " + bits + " bits, which can only hold a max value of " + bitValue.toLongArray()[0] + ", which is less than the specified max value of " + maxValue.toLongArray()[0]); + throw new Exception(); + } + } + } else { + bits = 1; + } + + for (String prereqSlotName : prereqSlotNames) { + if (!prereqSlotName.equals("") && getCollection(creature, prereqSlotName) < 1) { + if (prereqSlotName.equals(slotName)) { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " cannot have itself as a prereq"); + throw new Exception(); + } + + return false; + } + } + + for (String category : categories) { + if (category.equals("noScriptOnModify")) { + noScriptOnModify = true; + } else if (category.equals("clearOnComplete")) { + clearOnComplete = true; + } else if (category.equals("noMessage")) { + noMessage = true; + } else if (category.equals("grantIfPreReqMet")) { + grantIfPreReqMet = true; + } else if (category.equals("buddyCollection")) { + buddyCollection = true; + } else if (category.startsWith("numAltTitles")) { + numAltTitles = new Integer(category.split(":")[1]); + } else if (category.startsWith("kill")) { + continue; + } else if (category.contains("showFullInformationToOthers")) { + continue; + } else if (category.contains("collection")) { + continue; + } else if (category.startsWith("updateOnCount")) { + continue; + } else if (category.equals("rewardOnUpdate")) { + continue; + } else if (category.equals("rewardOnComplete")) { + continue; + } else if (category.contains("relic")) { + break; + } else if (!category.equals("")){ + continue; + } + } + + if (title) { + player.getTitleList().add(slotName); + + if (alternateTitles.length > 0) { + for (String altTitle : alternateTitles) { + if (altTitle != "") { + player.getTitleList().add(altTitle); + } + } + } + } else { + if (numAltTitles > 0 || alternateTitles.length > 0) { + System.out.println(slotName + ": slot " + slotName + " cannot have any alternative titles unless it is defined as \"titleable\""); + } + } + + if (bits > 1) { + int nextBit = collections.get(beginSlotId, (endSlotId + 1)).previousClearBit(endSlotId); + + if (nextBit == -1) { + return false; + } + + collections.set((beginSlotId + nextBit)); + } else { + collections.set(beginSlotId); + } + + player.setCollections(collections.toByteArray()); + + if (!hidden && !noMessage) { + creature.sendSystemMessage("collection_n", collection, 0, 0); + } + + if (!music.equals("")) { + creature.playMusic(music); + } + + if (!noScriptOnModify) { + if (FileUtilities.doesFileExist("scripts/collections/" + slotName + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/collections/", slotName, "modify"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(getCollection(creature, slotName))); + } + } + + if (FileUtilities.doesFileExist("scripts/collections/" + collectionName + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/collections/", collectionName, "modify"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(getCollection(creature, collectionName))); + } + } + } + + if (isComplete(creature, slotName)) { + if (FileUtilities.doesFileExist("scripts/collections/" + slotName + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/collections/", slotName, "complete"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(getCollection(creature, collectionName))); + } + } + } + + if (!isComplete(creature, collectionName)) { + if (!noReward) { + if (FileUtilities.doesFileExist("scripts/collections/" + collectionName + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/collections/", collectionName, "complete"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(getCollection(creature, collectionName))); + } + } + } + + if (titleOnComplete) { + player.getTitleList().add(collectionName); + } + + if (trackServerFirst) { + core.guildService.getGuildObject().addServerFirst(collectionName, new ServerFirst(creature.getCustomName(), System.currentTimeMillis())); + } + + if (clearOnComplete) { + if (endSlotId > -1) { + if (collections.get(beginSlotId, (endSlotId + 1)).cardinality() == bits) { + clearCollection(creature, collectionName); + } + } + } + + if (bookName.equals("badge_book")) { + int badges = getCollection(creature, "badge_book"); + + switch (badges) { + case 5: + addCollection(creature, "count_5"); + case 10: + addCollection(creature, "count_10"); + default: + if (((badges % 25) == 0) && !(badges > 500)) { + addCollection(creature, "count_" + badges); + } + } + } + + if (pageName.equals("bdg_explore")) { + int badges = getCollection(creature, "bdg_explore"); + + switch (badges) { + case 10: + addCollection(creature, "bdg_exp_10_badges"); + case 20: + addCollection(creature, "bdg_exp_20_badges"); + case 30: + addCollection(creature, "bdg_exp_30_badges"); + case 40: + addCollection(creature, "bdg_exp_40_badges"); + case 45: + addCollection(creature, "bdg_exp_45_badges"); + } + } + } + + return true; + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + /* + * @param creature The player's CreatureObject instance. + * @param collection slotName or collectionName from collection.iff. + * + * @return True if the slot or collection is complete. + */ + public boolean isComplete(CreatureObject creature, String collection) { + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + DatatableVisitor collectionTable; + + if (player == null) { + return false; + } + + collection = collection.toLowerCase(); + + try { + collectionTable = ClientFileManager.loadFile("datatables/collection/collection.iff", DatatableVisitor.class); + BitSet collections; + String bookName = ""; + String pageName = ""; + String collectionName = ""; + boolean found = false; + boolean collectionComplete = false; + + collections = BitSet.valueOf(player.getCollections()); + + for (int c = 0; c < collectionTable.getRowCount(); c++) { + if (collectionTable.getObject(c, 0) != null) { + if (((String) collectionTable.getObject(c, 0)) != "") { + bookName = ((String) collectionTable.getObject(c, 0)); + pageName = ""; + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 1)) != "") { + pageName = ((String) collectionTable.getObject(c, 1)); + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 2)) != "") { + collectionName = ((String) collectionTable.getObject(c, 2)); + } else if (((String) collectionTable.getObject(c, 3)) != "") { + String slotName = ((String) collectionTable.getObject(c, 3)); + + if (slotName.equals(collection)) { + int beginSlotId = ((Integer) collectionTable.getObject(c, 4)); + + if (bookName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a book"); + throw new Exception(); + } + + if (pageName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a page"); + throw new Exception(); + } + + if (collectionName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a collection"); + throw new Exception(); + } + + if (collection == bookName) { + System.out.println("Checking if a book is complete is unsupported at this time."); + throw new Exception(); + } else if (collection == pageName) { + System.out.println("Checking if a page is complete is unsupported at this time."); + throw new Exception(); + } else if (collection == collectionName) { + collectionComplete = collections.get(beginSlotId); + found = true; + } else if (collection == slotName) { + return collections.get(beginSlotId); + } + + if (found && collectionName != collection) { + return collectionComplete; + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + /* + * Returns number of completed bits in a slot or the number of completed + * slots in a collection, page or book. + * + * @param creature The player's CreatureObject instance. + * @param collection slotName, collectionName, pageName or bookName from collection.iff. + * + * @return Number of completed collections within the slot, collection, page or book. + */ + public int getCollection(CreatureObject creature, String collection) { + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + DatatableVisitor collectionTable; + + if (player == null) { + return 0; + } + + collection = collection.toLowerCase(); + + try { + collectionTable = ClientFileManager.loadFile("datatables/collection/collection.iff", DatatableVisitor.class); + BitSet collections; + String bookName = ""; + String pageName = ""; + String collectionName = ""; + int found = 0; + + collections = BitSet.valueOf(player.getCollections()); + + for (int c = 0; c < collectionTable.getRowCount(); c++) { + if (collectionTable.getObject(c, 0) != null) { + if (((String) collectionTable.getObject(c, 0)) != "") { + bookName = ((String) collectionTable.getObject(c, 0)); + pageName = ""; + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 1)) != "") { + pageName = ((String) collectionTable.getObject(c, 1)); + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 2)) != "") { + collectionName = ((String) collectionTable.getObject(c, 2)); + } else if (((String) collectionTable.getObject(c, 3)) != "") { + String slotName = ((String) collectionTable.getObject(c, 3)); + + int beginSlotId = ((Integer) collectionTable.getObject(c, 4)); + int endSlotId = ((Integer) collectionTable.getObject(c, 5)); + int maxSlotValue = ((Integer) collectionTable.getObject(c, 6)); + int bits = 0; + + if (bookName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a book"); + throw new Exception(); + } + + if (pageName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a page"); + throw new Exception(); + } + + if (collectionName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a collection"); + throw new Exception(); + } + + if (collection == bookName) { + found += getCollection(creature, pageName); + continue; + } else if (collection == pageName) { + found += getCollection(creature, collectionName); + continue; + } else if (collection == collectionName) { + if (collections.get(beginSlotId)) { + found++; + } + + continue; + } else if (collection == slotName) { + if (endSlotId != -1) { + if (beginSlotId >= endSlotId) { + System.out.println(slotName + ", row " + c + ": begin slot id " + beginSlotId + " must be < end slot id" + endSlotId); + throw new Exception(); + } + + bits = (endSlotId - beginSlotId); + + if (bits > 32) { + System.out.println(slotName + ", row " + c + ": counter-type slot uses " + bits + " bits which exceeds the limit of 32 bits for counter-type slot"); + throw new Exception(); + } + + if (maxSlotValue > -1) { + if (!(maxSlotValue > 1)) { + System.out.println(slotName + ", row " + c + ": max slot value " + maxSlotValue + " must be > 1"); + throw new Exception(); + } + + BitSet bitValue = new BitSet(64); + bitValue.set(64-bits, 64); + + BitSet maxValue = new BitSet(64); + maxValue.set(64-maxSlotValue, 64); + + if (bitValue.toLongArray()[0] < maxValue.toLongArray()[0]) { + System.out.println(slotName + ", row " + c + ": counter-type slot uses " + bits + " bits, which can only hold a max value of " + bitValue.toLongArray()[0] + ", which is less than the specified max value of " + maxValue.toLongArray()[0]); + throw new Exception(); + } + + return collections.get(beginSlotId, (endSlotId + 1)).cardinality(); + } + } else { + return ((collections.get(beginSlotId)) ? 1 : 0); + } + } + + if (found > 0) { + return found; + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return 0; + } + + /* + * Registers an exploration badge location. + * + * @param planet Name from Planet.getName(). + * @param badgeName slotName from collection.iff. + * @param x The first 2d coordinate. + * @param z The second 2d coordinate. + * @param range The radius from the coordinates at which this will check for players and award them the badge. + */ + public void registerExplorationBadge(String planet, String badgeName, int x, int z, int range) { + if (!explorationLocations.containsKey(planet)) { + explorationLocations.put(planet, new TreeMap()); + } + + explorationLocations.get(planet).put(badgeName, new ExplorationRegion(new Point3D(x, 0, z), range)); + } + + /* + * Checks if the player is in range of any exploration regions + * and grants any ungranted badges. + * + * @param creature The player's CreatreObject instance. + */ + public void checkExplorationRegions(CreatureObject creature) { + String planet = creature.getPlanet().getName(); + + if (explorationLocations.containsKey(planet)) { + for (Entry badge : explorationLocations.get(planet).entrySet()) { + if (creature.inRange(badge.getValue().location, badge.getValue().range)) { + if (!isComplete(creature, badge.getKey())) { + addCollection(creature, badge.getKey()); + } + } + } + } + } + + /* + * Clears the specified slot, collection, page or book. + * + * @param creature The player's CreatureObject instance. + * @param collection slotName, collectionName, pageName or bookName from collection.iff + * + * @return True if successful. + */ + public boolean clearCollection(CreatureObject creature, String collection) { + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + DatatableVisitor collectionTable; + + if (player == null) { + return false; + } + + collection = collection.toLowerCase(); + + try { + collectionTable = ClientFileManager.loadFile("datatables/collection/collection.iff", DatatableVisitor.class); + BitSet collections; + String bookName = ""; + String pageName = ""; + String collectionName = ""; + boolean found = false; + + collections = BitSet.valueOf(player.getCollections()); + + for (int c = 0; c < collectionTable.getRowCount(); c++) { + if (collectionTable.getObject(c, 0) != null) { + if (((String) collectionTable.getObject(c, 0)) != "") { + bookName = ((String) collectionTable.getObject(c, 0)); + pageName = ""; + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 1)) != "") { + pageName = ((String) collectionTable.getObject(c, 1)); + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 2)) != "") { + collectionName = ((String) collectionTable.getObject(c, 2)); + } else if (((String) collectionTable.getObject(c, 3)) != "") { + String slotName = ((String) collectionTable.getObject(c, 3)); + + int beginSlotId = ((Integer) collectionTable.getObject(c, 4)); + int endSlotId = ((Integer) collectionTable.getObject(c, 5)); + + if (bookName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a book"); + throw new Exception(); + } + + if (pageName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a page"); + throw new Exception(); + } + + if (collectionName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a collection"); + throw new Exception(); + } + + if (collection == bookName || collection == pageName || + collection == collectionName || collection == slotName) { + found = true; + + if (collections.get(beginSlotId, endSlotId + 1).cardinality() > 0) { + collections.clear(beginSlotId, (endSlotId + 1)); + + if (player.getTitleList().contains(slotName)) { + player.getTitleList().remove(slotName); + } + + continue; + } + } + + if (found) { + player.setCollections(collections.toByteArray()); + return true; + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + /* + * Clears all collections. + * + * This must cycle through all the collections because + * it needs to remove titles and other such things. + * + * @param creature The player's CreatureObject instance. + * + * @return True if successful. + */ + public boolean clearCollections(CreatureObject creature) { + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + DatatableVisitor collectionTable; + + if (player == null) { + return false; + } + + try { + collectionTable = ClientFileManager.loadFile("datatables/collection/collection.iff", DatatableVisitor.class); + BitSet collections; + String bookName = ""; + String pageName = ""; + String collectionName = ""; + boolean found = false; + + collections = BitSet.valueOf(player.getCollections()); + + for (int c = 0; c < collectionTable.getRowCount(); c++) { + if (collectionTable.getObject(c, 0) != null) { + if (((String) collectionTable.getObject(c, 0)) != "") { + bookName = ((String) collectionTable.getObject(c, 0)); + pageName = ""; + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 1)) != "") { + pageName = ((String) collectionTable.getObject(c, 1)); + collectionName = ""; + } else if (((String) collectionTable.getObject(c, 2)) != "") { + collectionName = ((String) collectionTable.getObject(c, 2)); + } else if (((String) collectionTable.getObject(c, 3)) != "") { + String slotName = ((String) collectionTable.getObject(c, 3)); + + int beginSlotId = ((Integer) collectionTable.getObject(c, 4)); + int endSlotId = ((Integer) collectionTable.getObject(c, 5)); + + if (bookName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a book"); + throw new Exception(); + } + + if (pageName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a page"); + throw new Exception(); + } + + if (collectionName == "") { + System.out.println(slotName + ", row " + c + ": slot " + slotName + " must be in a collection"); + throw new Exception(); + } + + if (collections.get(beginSlotId, endSlotId + 1).cardinality() > 0) { + found = true; + + collections.clear(beginSlotId, (endSlotId + 1)); + + if (player.getTitleList().contains(slotName)) { + player.getTitleList().remove(slotName); + } + + continue; + } + + if (found) { + player.setCollections(collections.toByteArray()); + return true; + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return ((player.getCollections().length > 0) ? false : true); + } + + @Override + public void insertOpcodes(Map arg0, Map arg1) { + + } + + @Override + public void shutdown() { + + } + +} diff --git a/src/services/collections/ServerFirst.java b/src/services/collections/ServerFirst.java new file mode 100644 index 00000000..a11a01f6 --- /dev/null +++ b/src/services/collections/ServerFirst.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.collections; + +import resources.objects.ListObject; + +import com.sleepycat.persist.model.Persistent; + +@Persistent +public class ServerFirst extends ListObject { + + private String name; + private long time; + + public ServerFirst(String name, long time) { + this.name = name; + this.time = time; + } + + public ServerFirst() { + + } + + public String getName() { + return name; + } + + public long getTime() { + return time; + } + + @Override + public byte[] getBytes() { + return new byte[] { }; + } + +} diff --git a/src/services/gcw/FactionService.java b/src/services/gcw/FactionService.java new file mode 100644 index 00000000..5792f2cd --- /dev/null +++ b/src/services/gcw/FactionService.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.gcw; + +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; +import org.apache.mina.core.session.IoSession; +import org.python.core.Py; +import org.python.core.PyObject; + +import resources.common.FileUtilities; +import resources.common.Opcodes; +import resources.objects.creature.CreatureObject; +import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; + +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.DatatableVisitor; +import engine.resources.common.CRC; +import engine.resources.objects.SWGObject; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class FactionService implements INetworkDispatch { + + private NGECore core; + + private Map factionMap = new TreeMap(); + + public FactionService(NGECore core) { + DatatableVisitor factionTable; + + this.core = core; + + try { + factionTable = ClientFileManager.loadFile("strings/en/faction/faction_names.stf", DatatableVisitor.class); + + for (int s = 0; s < factionTable.getRowCount(); s++) { + if (factionTable.getObject(s, 0) != null) { + String faction = ((String) factionTable.getObject(s, 1)); + factionMap.put(faction, CRC.StringtoCRC(faction)); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public int getCRC(String faction) { + return CRC.StringtoCRC(faction); + } + + public String getName(int factionCrc) { + for (Entry entry : factionMap.entrySet()) { + if (factionCrc == entry.getValue()) { + return entry.getKey(); + } + } + + return ""; + } + + public void addFactionStanding(CreatureObject creature, String faction, int factionStanding) { + if (creature == null) { + return; + } + + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + + if (player == null) { + return; + } + + player.modifyFactionStanding(faction, factionStanding); + } + + public void removeFactionStanding(CreatureObject creature, String faction, int factionStanding) { + if (creature == null) { + return; + } + + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + + if (player == null) { + return; + } + + player.modifyFactionStanding(faction, factionStanding); + } + + public void updateFactionStanding(SWGObject killedObject) { + if (!(killedObject instanceof TangibleObject) || killedObject == null) { + return; + } + + TangibleObject target = (TangibleObject) killedObject; + + if (!(((TangibleObject) killedObject).getKiller() instanceof TangibleObject) || ((TangibleObject) killedObject).getKiller() == null) { + return; + } + + TangibleObject killer = ((TangibleObject) killedObject).getKiller(); + + if (killer != null && target != null && isFaction(target.getFaction())) { + if (FileUtilities.doesFileExist("scripts/faction/standing/" + target.getFaction() + ".py")) { + + PyObject method = core.scriptService.getMethod("scripts/faction/standing/", target.getFaction(), "update"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(killer), Py.java2py(target)); + } + } + } + } + + public boolean isFaction(String faction) { + if (factionMap.containsKey(faction)) { + return true; + } + + return false; + } + + public Map getFactionMap() { + return factionMap; + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + swgOpcodes.put(Opcodes.FactionRequestMessage, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { + + } + + }); + } + + @Override + public void shutdown() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index f09b694c..27d19d93 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -133,7 +133,7 @@ public class ObjectService implements INetworkDispatch { } } - public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation) { + public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation, String customServerTemplate) { SWGObject object = null; CrcStringTableVisitor crcTable; try { @@ -210,17 +210,51 @@ public class ObjectService implements INetworkDispatch { } object.setPlanetId(planet.getID()); + + object.setAttachment("serverTemplate", ((customServerTemplate != null) ? customServerTemplate : object.getTemplate())); + object.setisInSnapshot(isSnapshot); //loadServerTemplate(object); objectList.put(objectID, object); - + + // Set Default Tangible Options + /* + if (Template.startsWith("object/creature/") || Template.startsWith("object/mobile/")) { + ((CreatureObject) object).setOptionsBitmask(Options.MOBILE); + + if (Template.startsWith("object/mobile/beast_master/")) { + ((CreatureObject) object).setOptionsBitmask(Options.NONE); + } else if (Template.startsWith("object/mobile/vendor/")) { + ((CreatureObject) object).setOptionsBitmask(Options.INVULNERABLE | Options.USABLE); + } else if (Template.startsWith("object/mobile/vehicle/")) { + ((CreatureObject) object).addOption(Options.INVULNERABLE | Options.MOUNT); + } else if (Template.startsWith("object/mobile/hologram/")) { + ((CreatureObject) object).addOption(Options.INVULNERABLE); + } else if (Template.startsWith("object/creature/npc/theme_park/")) { + ((CreatureObject) object).addOption(Options.INVULNERABLE); + } else if (Template.startsWith("object/creature/general/")) { + ((CreatureObject) object).setOptionsBitmask(Options.INVULNERABLE | Options.CONVERSABLE); + } else if (Template.startsWith("object/creature/droid/")) { + ((CreatureObject) object).addOption(Options.INVULNERABLE); + } + } else if (object instanceof TangibleObject) { + ((TangibleObject) object).setOptionsBitmask(Options.INVULNERABLE); + + if (Template.startsWith("object/tangible/vendor/")) { + ((CreatureObject) object).addOption(Options.USABLE); + } else if (Template.startsWith("object/creature/droid/")) { + ((CreatureObject) object).addOption(Options.INVULNERABLE); + } + } + */ + return object; } public void loadServerTemplate(SWGObject object) { - String template = object.getTemplate(); + String template = ((object.getAttachment("serverTemplate") == null) ? object.getTemplate() : ((String) object.getAttachment("serverTemplate"))); String serverTemplate = template.replace(".iff", ""); // check if template is empty(4 default lines) to reduce RAM usage(saves about 500 MB of RAM) try { @@ -251,6 +285,10 @@ public class ObjectService implements INetworkDispatch { return createObject(Template, 0, planet, new Point3D(x, y, z), new Quaternion(1, 0, 0, 0)); } + public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation) { + return createObject(Template, objectID, planet, position, orientation, null); + } + public void addObjectToScene(SWGObject object) { core.simulationService.add(object, object.getPosition().x, object.getPosition().z); @@ -308,6 +346,18 @@ public class ObjectService implements INetworkDispatch { } } + if (object instanceof CreatureObject) { + if (core.factionService.getFactionMap().containsKey(((CreatureObject) object).getFaction())) { + if (FileUtilities.doesFileExist(filePath)) { + PyObject method = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "destroy"); + + if (method != null && method.isCallable()) { + method.__call__(Py.java2py(core), Py.java2py(((TangibleObject) object).getKiller()), Py.java2py(object)); + } + } + } + } + if (object == null) { return; } @@ -517,6 +567,7 @@ public class ObjectService implements INetworkDispatch { }); + /* objControllerOpcodes.put(ObjControllerOpcodes.USE_OBJECT, new INetworkRemoteEvent() { @Override @@ -540,6 +591,7 @@ public class ObjectService implements INetworkDispatch { } }); + */ }