diff --git a/src/services/chat/Mail.java b/src/services/chat/Mail.java index c5f829b4..dbb0c1f5 100644 --- a/src/services/chat/Mail.java +++ b/src/services/chat/Mail.java @@ -41,7 +41,7 @@ public class Mail implements Serializable { private String senderName; private long recieverId; private String subject; - private String message; + private String message = ""; private byte status; private int timeStamp; private List attachments = new ArrayList(); diff --git a/src/services/playercities/PlayerCity.java b/src/services/playercities/PlayerCity.java index d7a52c6e..948bb0bc 100644 --- a/src/services/playercities/PlayerCity.java +++ b/src/services/playercities/PlayerCity.java @@ -99,8 +99,8 @@ public class PlayerCity implements Serializable { private long cityID = -1; private Point3D cityCenterPosition = new Point3D(0,0,0); private int cityRadius = 0; - private int cityRank = 0; - private int specialization = -1; + private int cityRank = 1; + private int specialization = 0; private long mayorID = 0L; private int cityTreasury = 0; private int maintenanceFee = 0; @@ -903,23 +903,9 @@ public class PlayerCity implements Serializable { actorMail.setRecieverId(citizen); actorMail.setStatus(Mail.NEW); actorMail.setTimeStamp((int) (new Date().getTime() / 1000)); - actorMail.setMessage("@city/city:new_city_citizen_body"); actorMail.setSubject("@city/city:new_city_citizen_subject"); actorMail.setSenderName("City " + this.cityName); - - List attachments = new ArrayList(); - WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", citizenObject.getPlanet(), citizenObject.getPosition().x, 0 ,citizenObject.getPosition().z); - WaypointAttachment attachment = new WaypointAttachment(); - attachment.active = false; - attachment.cellID = constructionWaypoint.getCellId(); - attachment.color = (byte)1; - attachment.name = "City"; - attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(citizenObject.getPlanet().getName()); - attachment.positionX = citizenObject.getPosition().x; - attachment.positionY = 0; - attachment.positionZ = citizenObject.getPosition().z; - attachments.add(attachment); - actorMail.setWaypointAttachments(attachments); + actorMail.addProseAttachment(new ProsePackage("@city/city:new_city_citizen_body", "TT", newCitizen.getCustomName())); NGECore.getInstance().chatService.storePersistentMessage(actorMail); if (newCitizen.getClient()!=null) @@ -928,34 +914,27 @@ public class PlayerCity implements Serializable { } } - public void sendNewCitizenMail(CreatureObject citizen) { + public void sendNewCitizenMail(CreatureObject citizen) { + + NGECore core = NGECore.getInstance(); + CreatureObject mayor = core.objectService.getObject(getMayorID()) == null ? core.objectService.getCreatureFromDB(getMayorID()) : (CreatureObject) core.objectService.getObject(getMayorID()); + if(mayor == null) + return; Mail actorMail = new Mail(); - actorMail.setMailId(NGECore.getInstance().chatService.generateMailId()); + actorMail.setMailId(core.chatService.generateMailId()); actorMail.setRecieverId(citizen.getObjectID()); actorMail.setStatus(Mail.NEW); actorMail.setTimeStamp((int) (new Date().getTime() / 1000)); - actorMail.setMessage("@city/city:new_city_citizen_other_body"); actorMail.setSubject("@city/city:new_city_citizen_other_subject"); actorMail.setSenderName("City " + this.cityName); - - List attachments = new ArrayList(); - WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", citizen.getPlanet(), citizen.getPosition().x, 0 ,citizen.getPosition().z); - WaypointAttachment attachment = new WaypointAttachment(); - attachment.active = false; - attachment.cellID = constructionWaypoint.getCellId(); - attachment.color = (byte)1; - attachment.name = "City"; - attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(citizen.getPlanet().getName()); - attachment.positionX = citizen.getPosition().x; - attachment.positionY = 0; - attachment.positionZ = citizen.getPosition().z; - attachments.add(attachment); - actorMail.setWaypointAttachments(attachments); + actorMail.addProseAttachment(new ProsePackage("@city/city:new_city_citizen_other_body", "TT", mayor.getCustomName(), "TU", cityName)); + - NGECore.getInstance().chatService.storePersistentMessage(actorMail); - NGECore.getInstance().chatService.sendPersistentMessageHeader(citizen.getClient(), actorMail); + core.chatService.storePersistentMessage(actorMail); + if (citizen.getClient()!=null) + core.chatService.sendPersistentMessageHeader(citizen.getClient(), actorMail); } public void sendCitizenLeftMailAll(CreatureObject newCitizen) { @@ -1084,13 +1063,15 @@ public class PlayerCity implements Serializable { } public String getSpecialisationStfValue() { + if(specialization == 0) + return ""; try { StfTable stf = new StfTable("clientdata/string/en/city/city.stf"); for (int s = 1; s < stf.getRowCount(); s++) { String stfKey = stf.getStringById(s).getKey(); - if (stfKey != null && stfKey != "" && stfKey.equals(specialisationSTFNames[specialization])) { + if (stfKey != null && stfKey != "" && stfKey.equals(specialisationSTFNames[specialization - 1])) { return stf.getStringById(s).getValue(); } } diff --git a/src/services/playercities/PlayerCityService.java b/src/services/playercities/PlayerCityService.java index 3751eac1..3ceb0a69 100644 --- a/src/services/playercities/PlayerCityService.java +++ b/src/services/playercities/PlayerCityService.java @@ -114,8 +114,7 @@ public class PlayerCityService implements INetworkDispatch { return; } - final SUIWindow window = core.suiService.createInputBox(2,"@city/city:city_name_t","@city/city:city_name_d", actor, null, 0); - core.suiService.openSUIWindow(window); + final SUIWindow window = core.suiService.createInputBox(2, "@city/city:city_name_t","@city/city:city_name_d", actor, null, 0); Vector returnList = new Vector(); returnList.add("txtInput:LocalText"); window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { @@ -141,6 +140,7 @@ public class PlayerCityService implements INetworkDispatch { } PlayerCity playerCity = addNewPlayerCity(actor, cityHall); + playerCity.setCityName(name); PlayerCityService.this.schedulePlayerCityUpdate(playerCity, PlayerCity.newCityGraceSpan); cityHall.setAttachment("structureCity", playerCity.getCityID()); actor.setAttachment("residentCity", playerCity.getCityID()); @@ -149,7 +149,7 @@ public class PlayerCityService implements INetworkDispatch { } }); - core.suiService.openSUIWindow(window); + core.suiService.openSUIWindow(window); } @@ -372,7 +372,7 @@ public class PlayerCityService implements INetworkDispatch { continue; core.housingService.destroyStructure(civicStructure); } - + core.simulationService.removeCollidable(city.getArea(), city.getArea().getCenter().x, city.getArea().getCenter().z); playerCities.remove(city); }