Changeset 89d279c3cd5e9c1635b8bae910ca1a9365cba062
- Timestamp:
- 07/11/07 16:20:16 (1 year ago)
- git-parent:
- Files:
-
- db/tables/werft_queues.sql (modified) (1 diff)
- db/updates.xml (modified) (1 diff)
- src/net/driftingsouls/ds2/server/bases/Werft.java (modified) (4 diffs)
- src/net/driftingsouls/ds2/server/modules/SchiffeController.java (modified) (3 diffs)
- src/net/driftingsouls/ds2/server/modules/schiffplugins/WerftDefault.java (modified) (2 diffs)
- src/net/driftingsouls/ds2/server/ships/Ship.java (modified) (2 diffs)
- src/net/driftingsouls/ds2/server/tick/regular/WerftTick.java (modified) (2 diffs)
- src/net/driftingsouls/ds2/server/werften/ShipWerft.java (modified) (1 diff)
- src/net/driftingsouls/ds2/server/werften/WerftGUI.java (modified) (2 diffs)
- src/net/driftingsouls/ds2/server/werften/WerftObject.java (modified) (13 diffs)
- src/net/driftingsouls/ds2/server/werften/WerftQueueEntry.java (modified) (14 diffs)
- templates/schiff.werft.default.html (modified) (1 diff)
- templates/schiffe.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
db/tables/werft_queues.sql
r07a80e0 r89d279c 8 8 `costsPerTick` varchar(300) NOT NULL default '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,', 9 9 `energyPerTick` int NOT NULL default '0', 10 `slots` INT NOT NULL DEFAULT '1', 11 `scheduled` TINYINT( 1 ) NOT NULL DEFAULT '0', 10 12 PRIMARY KEY (`werft`,`position`) 11 13 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; db/updates.xml
rbed664f r89d279c 342 342 -- Schiffe, welche Module mit Werfteffekt haben, beduerfen fuer eine korrekte Funktion ein Aus- und Wiedereinbau des Moduls 343 343 ]]></update> 344 <update type="structure" datum="2007-07-11"><![CDATA[ 345 ALTER TABLE `werft_queues` ADD `slots` INT NOT NULL DEFAULT '1', 346 ADD `scheduled` TINYINT( 1 ) NOT NULL DEFAULT '0'; 347 ]]></update> 344 348 </updates> src/net/driftingsouls/ds2/server/bases/Werft.java
rd230b2f r89d279c 22 22 import javax.persistence.Entity; 23 23 24 import net.driftingsouls.ds2.server.config.Items;25 24 import net.driftingsouls.ds2.server.framework.Common; 26 25 import net.driftingsouls.ds2.server.framework.Configuration; … … 28 27 import net.driftingsouls.ds2.server.framework.ContextMap; 29 28 import net.driftingsouls.ds2.server.framework.templates.TemplateEngine; 30 import net.driftingsouls.ds2.server.ships.ShipTypeData;31 29 import net.driftingsouls.ds2.server.werften.BaseWerft; 32 30 import net.driftingsouls.ds2.server.werften.WerftGUI; 31 import net.driftingsouls.ds2.server.werften.WerftQueueEntry; 33 32 34 33 import org.apache.commons.lang.StringEscapeUtils; … … 102 101 } 103 102 else { 104 ShipTypeData type = werft.getBuildShipType(); 105 106 StringBuilder popup = new StringBuilder(200); 107 popup.append(Common.tableBegin(420, "left").replace('"', '\'')); 108 popup.append("<img align='left' border='0' src='"); 109 popup.append(type.getPicture()); 110 popup.append("' alt='"); 111 popup.append(type.getNickname()); 112 popup.append("' />"); 113 popup.append(" Baut: "); 114 popup.append(type.getNickname()); 115 popup.append("<br />"); 116 popup.append(" Dauer: <img style='vertical-align:middle' src='"); 117 popup.append(Configuration.getSetting("URL")); 118 popup.append("data/interface/time.gif' alt='noch ' />"); 119 popup.append(werft.getRemainingTime()); 120 popup.append("<br />"); 121 if( werft.getRequiredItem() != -1 ) { 122 123 popup.append(" Benötigt: "); 124 popup.append("<img style='vertical-align:middle' src='"); 125 popup.append("../data/items/"); 126 popup.append(Items.get().item(werft.getRequiredItem()).getPicture()); 127 popup.append("' alt='' />"); 128 if( werft.isBuildContPossible() ) { 129 popup.append("<span style='color:green'>"); 103 final WerftQueueEntry[] entries = werft.getBuildQueue(); 104 final int totalSlots = werft.getWerftSlots(); 105 int usedSlots = 0; 106 int buildingCount = 0; 107 for( int i=0; i < entries.length; i++ ) { 108 usedSlots += entries[i].getSlots(); 109 if( entries[i].isScheduled() ) { 110 buildingCount++; 130 111 } 131 else {132 popup.append("<span style='color:red'>");133 }134 popup.append(Items.get().item(werft.getRequiredItem()).getName());135 popup.append("</span>");136 112 } 137 popup.append(Common.tableEnd().replace('"', '\'')); 138 String popupStr = StringEscapeUtils.escapeJavaScript(popup.toString()); 113 114 StringBuilder popup = new StringBuilder(100); 115 popup.append(Common.tableBegin(420, "left").replace( '"', '\'') ); 116 popup.append("Belegte Werftslots: <img style='vertical-align:middle;border:0px' src='"+Configuration.getSetting("URL")+"data/interface/schiffinfo/werftslots.png' alt='' />"+usedSlots+"/"+totalSlots+"<br />"); 117 popup.append("Im Bau: "+buildingCount+" Schiffe<br />"); 118 popup.append("In der Warteschlange: "+(entries.length - buildingCount)); 119 popup.append(Common.tableEnd().replace( '"', '\'' )); 120 String popupStr = StringEscapeUtils.escapeJavaScript(popup.toString().replace(">", ">").replace("<", "<")); 139 121 140 122 result.append("<a name=\"p"); … … 159 141 result.append(field); 160 142 result.append("\">[W]<span style=\"font-weight:normal\">"); 161 result.append( werft.getRemainingTime());143 result.append(entries.length); 162 144 result.append("</span></a>"); 163 145 } src/net/driftingsouls/ds2/server/modules/SchiffeController.java
rbed664f r89d279c 30 30 import net.driftingsouls.ds2.server.cargo.ResourceList; 31 31 import net.driftingsouls.ds2.server.cargo.Resources; 32 import net.driftingsouls.ds2.server.config.Items;33 32 import net.driftingsouls.ds2.server.entities.User; 34 33 import net.driftingsouls.ds2.server.framework.Common; … … 43 42 import net.driftingsouls.ds2.server.ships.Ships; 44 43 import net.driftingsouls.ds2.server.werften.ShipWerft; 44 import net.driftingsouls.ds2.server.werften.WerftQueueEntry; 45 45 46 46 import org.apache.commons.lang.StringEscapeUtils; … … 312 312 } 313 313 else { 314 ShipTypeData type = werft.getBuildShipType(); 315 if( type != null ) { 316 StringBuilder popup = new StringBuilder(100); 317 popup.append(Common.tableBegin(420, "left").replace( '"', '\'') ); 318 popup.append("<img align='left' border='0' src='"+type.getPicture()+"' alt='"+type.getNickname()+"' />"); 319 popup.append(" Baut: "+type.getNickname()+"<br />"); 320 popup.append(" Dauer: <img style='vertical-align:middle' src='"+Configuration.getSetting("URL")+"data/interface/time.gif' alt='noch ' />"+werft.getRemainingTime()+"<br />"); 321 if( werft.getRequiredItem() != -1 ) { 322 popup.append(" Benötigt: "); 323 popup.append("<img style='vertical-align:middle' src='../data/items/"+Items.get().item(werft.getRequiredItem()).getPicture()+"' alt='' />"); 324 if( werft.isBuildContPossible() ) { 325 popup.append("<span style='color:green'>"); 326 } 327 else { 328 popup.append("<span style='color:red'>"); 329 } 330 popup.append(Items.get().item(werft.getRequiredItem()).getName()+"</span>"); 314 final WerftQueueEntry[] entries = werft.getBuildQueue(); 315 final int totalSlots = werft.getWerftSlots(); 316 int usedSlots = 0; 317 int buildingCount = 0; 318 for( int i=0; i < entries.length; i++ ) { 319 usedSlots += entries[i].getSlots(); 320 if( entries[i].isScheduled() ) { 321 buildingCount++; 331 322 } 332 popup.append(Common.tableEnd().replace( '"', '\'' )); 333 String popupStr = StringEscapeUtils.escapeJavaScript(popup.toString().replace(">", ">").replace("<", "<")); 334 335 t.set_var( "ship.werft.popup", popupStr, 336 "ship.werft.dauer", werft.getRemainingTime(), 337 "ship.werft.building", 1 ); 338 } 323 } 324 325 StringBuilder popup = new StringBuilder(100); 326 popup.append(Common.tableBegin(420, "left").replace( '"', '\'') ); 327 popup.append("Belegte Werftslots: <img style='vertical-align:middle;border:0px' src='"+Configuration.getSetting("URL")+"data/interface/schiffinfo/werftslots.png' alt='' />"+usedSlots+"/"+totalSlots+"<br />"); 328 popup.append("Im Bau: "+buildingCount+" Schiffe<br />"); 329 popup.append("In der Warteschlange: "+(entries.length - buildingCount)); 330 popup.append(Common.tableEnd().replace( '"', '\'' )); 331 String popupStr = StringEscapeUtils.escapeJavaScript(popup.toString().replace(">", ">").replace("<", "<")); 332 333 t.set_var( "ship.werft.popup", popupStr, 334 "ship.werft.entries", entries.length, 335 "ship.werft.building", 1 ); 339 336 } 340 337 } src/net/driftingsouls/ds2/server/modules/schiffplugins/WerftDefault.java
rc3ab33e r89d279c 19 19 package net.driftingsouls.ds2.server.modules.schiffplugins; 20 20 21 import net.driftingsouls.ds2.server.config.Items;22 21 import net.driftingsouls.ds2.server.framework.templates.TemplateEngine; 23 22 import net.driftingsouls.ds2.server.modules.SchiffController; 24 23 import net.driftingsouls.ds2.server.ships.Ship; 25 import net.driftingsouls.ds2.server.ships.ShipTypeData;26 24 import net.driftingsouls.ds2.server.werften.ShipWerft; 25 import net.driftingsouls.ds2.server.werften.WerftQueueEntry; 27 26 28 27 /** … … 51 50 t.set_file("_PLUGIN_"+pluginid, "schiff.werft.default.html"); 52 51 53 if( werft.isBuilding() ) { 54 ShipTypeData type = werft.getBuildShipType(); 55 56 t.set_var( "global.pluginid", pluginid, 57 "ship.id", ship.getId(), 58 "schiff.werft.prod.dauer", werft.getRemainingTime(), 59 "schiff.werft.prod.type", type.getTypeId(), 60 "schiff.werft.prod.name", type.getNickname(), 61 "schiff.werft.prod.picture", type.getPicture() ); 62 63 if( werft.getRequiredItem() != -1 ) { 64 t.set_var( "schiff.werft.prod.item", werft.getRequiredItem(), 65 "schiff.werft.prod.item.name", Items.get().item(werft.getRequiredItem()).getName(), 66 "schiff.werft.prod.item.picture", Items.get().item(werft.getRequiredItem()).getPicture(), 67 "schiff.werft.prod.item.available", werft.isBuildContPossible() ); 52 final WerftQueueEntry[] entries = werft.getBuildQueue(); 53 final int totalSlots = werft.getWerftSlots(); 54 int usedSlots = 0; 55 int buildingCount = 0; 56 for( int i=0; i < entries.length; i++ ) { 57 usedSlots += entries[i].getSlots(); 58 if( entries[i].isScheduled() ) { 59 buildingCount++; 68 60 } 69 61 } 62 t.set_var( 63 "global.pluginid", pluginid, 64 "ship.id", ship.getId(), 65 "schiff.werft.usedslots", usedSlots, 66 "schiff.werft.totalslots", totalSlots, 67 "schiff.werft.scheduled", buildingCount, 68 "schiff.werft.waiting", entries.length-buildingCount 69 ); 70 70 71 71 t.parse(caller.target,"_PLUGIN_"+pluginid); src/net/driftingsouls/ds2/server/ships/Ship.java
raf70f40 r89d279c 72 72 import net.driftingsouls.ds2.server.tasks.Task; 73 73 import net.driftingsouls.ds2.server.tasks.Taskmanager; 74 import net.driftingsouls.ds2.server.werften.ShipWerft; 74 75 75 76 import org.apache.commons.lang.StringUtils; … … 2802 2803 .setInteger(0, this.id) 2803 2804 .executeUpdate(); 2804 2805 ContextMap.getContext().getDatabase().update("DELETE FROM werften WHERE shipid=",this.id); 2805 2806 ShipWerft werft = (ShipWerft)db.createQuery("from ShipWerft where shipid=?") 2807 .setInteger(0, this.id) 2808 .uniqueResult(); 2809 2810 if( werft != null ) { 2811 werft.clearQueue(); 2812 db.delete(werft); 2813 } 2806 2814 2807 2815 db.createQuery("delete from ShipModules where id=?") 2808 2816 .setInteger(0, this.id) 2809 2817 .executeUpdate(); 2818 2810 2819 db.delete(this); 2811 2820 } src/net/driftingsouls/ds2/server/tick/regular/WerftTick.java
r30f818d r89d279c 30 30 import net.driftingsouls.ds2.server.werften.ShipWerft; 31 31 import net.driftingsouls.ds2.server.werften.WerftObject; 32 import net.driftingsouls.ds2.server.werften.WerftQueueEntry; 32 33 33 34 /** … … 63 64 64 65 if( werft.isBuilding() ){ 65 ShipTypeData shipd = werft.getBuildShipType(); 66 67 this.log("\tAktueller Auftrag: "+shipd.getTypeId()+"; dauer: "+werft.getRemainingTime()); 68 69 if( werft.getRequiredItem() > -1 ) { 70 this.log("\tItem benoetigt: "+Items.get().item(werft.getRequiredItem()).getName()+" ("+werft.getRequiredItem()+")"); 71 } 72 if( werft.isBuildContPossible() ) { 73 werft.continueBuild(); 74 this.log("\tVoraussetzungen erfuellt - bau geht weiter"); 75 } 76 77 if( werft.getRemainingTime() <= 0 ) { 78 this.log("\tSchiff "+shipd.getTypeId()+" gebaut"); 79 80 int shipid = werft.finishBuildProcess(); 81 this.slog(werft.MESSAGE.getMessage()); 66 WerftQueueEntry[] entries = werft.getScheduledQueueEntries(); 67 for( int i=0; i < entries.length; i++ ) { 68 WerftQueueEntry entry = entries[i]; 82 69 83 if( shipid > 0 ) { 84 // MSG 85 String msg = "Auf "+werft.getName()+" wurde eine "+shipd.getNickname()+" gebaut. Sie steht bei "+werft.getSystem()+" : "+werft.getX()+"/"+werft.getY()+"."; 70 ShipTypeData shipd = entry.getBuildShipType(); 86 71 87 PM.send(getContext(), -1, werft.getOwner().getID(), "Schiff gebaut", msg); 72 this.log("\tAktueller Auftrag: "+shipd.getTypeId()+"; dauer: "+entry.getRemainingTime()); 73 74 if( entry.getRequiredItem() > -1 ) { 75 this.log("\tItem benoetigt: "+Items.get().item(entry.getRequiredItem()).getName()+" ("+entry.getRequiredItem()+")"); 76 } 77 if( entry.isBuildContPossible() ) { 78 entry.continueBuild(); 79 this.log("\tVoraussetzungen erfuellt - bau geht weiter"); 80 } 81 82 if( entry.getRemainingTime() <= 0 ) { 83 this.log("\tSchiff "+shipd.getTypeId()+" gebaut"); 84 85 int shipid = entry.finishBuildProcess(); 86 this.slog(entry.MESSAGE.getMessage()); 87 88 if( shipid > 0 ) { 89 // MSG 90 String msg = "Auf "+werft.getName()+" wurde eine "+shipd.getNickname()+" gebaut. Sie steht bei "+werft.getSystem()+" : "+werft.getX()+"/"+werft.getY()+"."; 91 92 PM.send(getContext(), -1, werft.getOwner().getID(), "Schiff gebaut", msg); 93 } 88 94 } 89 95 } src/net/driftingsouls/ds2/server/werften/ShipWerft.java
rbed664f r89d279c 358 358 359 359 @Override 360 public int finishBuildProcess() { 361 int id = super.finishBuildProcess(); 362 if( (id != 0) && (getType() == 2) ) { 360 public void onFinishedBuildProcess(int shipid) { 361 super.onFinishedBuildProcess(shipid); 362 363 // Falls es sich um eine Einwegwerft handelt, dann diese zerstoeren 364 if( getType() == 2 ) { 363 365 getShip().destroy(); 364 366 } 365 366 return id;367 367 } 368 368 src/net/driftingsouls/ds2/server/werften/WerftGUI.java
r30f818d r89d279c 141 141 t.set_var( "werftgui.building.cancel", 1 ); 142 142 143 werft.cancelBuild(entry);143 entry.cancelBuild(); 144 144 } 145 145 } … … 256 256 WerftQueueEntry entry = queue[i]; 257 257 258 remaining += entry.getRemaining ();258 remaining += entry.getRemainingTime(); 259 259 260 260 t.set_var( 261 261 "queueship.buildcosts.list", "", 262 262 "queueship.position", entry.getPosition(), 263 "queueship.type.image", entry.getBuild ing().getPicture(),264 "queueship.type.id", entry.getBuild ing().getTypeId(),265 "queueship.type.name", entry.getBuild ing().getNickname(),263 "queueship.type.image", entry.getBuildShipType().getPicture(), 264 "queueship.type.id", entry.getBuildShipType().getTypeId(), 265 "queueship.type.name", entry.getBuildShipType().getNickname(), 266 266 "queueship.remainingtotal", remaining, 267 "queueship.building", i == 0,267 "queueship.building", entry.isScheduled(), 268 268 "queueship.uppossible", i > 0, 269 269 "queueship.downpossible", i < queue.length-1); 270 270 271 if( entry.get BuildItem() != -1 ) {271 if( entry.getRequiredItem() != -1 ) { 272 272 t.set_var( 273 273 "queueship.reqitem", true, 274 "queueship.item.picture", Items.get().item(entry.get BuildItem()).getPicture(),275 "queueship.item.name", Items.get().item(entry.get BuildItem()).getName());274 "queueship.item.picture", Items.get().item(entry.getRequiredItem()).getPicture(), 275 "queueship.item.name", Items.get().item(entry.getRequiredItem()).getName()); 276 276 } 277 277 src/net/driftingsouls/ds2/server/werften/WerftObject.java
rbed664f r89d279c 32 32 import javax.persistence.InheritanceType; 33 33 import javax.persistence.Table; 34 import javax.persistence.Transient;35 34 36 35 import net.driftingsouls.ds2.server.ContextCommon; … … 40 39 import net.driftingsouls.ds2.server.cargo.Cargo; 41 40 import net.driftingsouls.ds2.server.cargo.ItemCargoEntry; 42 import net.driftingsouls.ds2.server.cargo.ItemID;43 41 import net.driftingsouls.ds2.server.cargo.ResourceEntry; 44 42 import net.driftingsouls.ds2.server.cargo.ResourceID; … … 108 106 109 107 /** 108 * Gibt die aktuell zum Bau vorgesehenen Bauschlangeneintraege zurueck 109 * @return Die Liste der zum Bauvorgesehenen Bauschlangeneintraege 110 */ 111 public WerftQueueEntry[] getScheduledQueueEntries() { 112 org.hibernate.Session db = ContextMap.getContext().getDB(); 113 List list = db.createQuery("from WerftQueueEntry where id.werft=? and scheduled=1 order by id.position") 114 .setInteger(0, this.getWerftID()) 115 .list(); 116 WerftQueueEntry[] entries = new WerftQueueEntry[list.size()]; 117 int index = 0; 118 for( Iterator iter=list.iterator(); iter.hasNext(); ) { 119 entries[index++] = (WerftQueueEntry)iter.next(); 120 } 121 122 return entries; 123 } 124 125 /** 110 126 * Gibt zurueck, ob in der Werft im Moment gebaut wird 111 127 * @return <code>true</code>, falls gebaut wird 112 128 */ 113 129 public final boolean isBuilding() { 114 return getQueueTopEntry() != null; 130 org.hibernate.Session db = ContextMap.getContext().getDB(); 131 132 return db.createQuery("from WerftQueueEntry where id.werft=?") 133 .setInteger(0, this.getWerftID()) 134 .iterate().hasNext(); 115 135 } 116 136 … … 123 143 } 124 144 125 @Transient 126 private WerftQueueEntry topEntry = null; 127 128 private WerftQueueEntry getQueueTopEntry() { 129 if( topEntry == null ) { 130 org.hibernate.Session db = ContextMap.getContext().getDB(); 131 132 topEntry = (WerftQueueEntry)db 133 .createQuery("from WerftQueueEntry where id.werft=? and id.position=1") 134 .setInteger(0, this.getWerftID()) 135 .uniqueResult(); 136 } 137 138 return topEntry; 139 } 140 141 /** 142 * Gibt den im Moment gebauten Schiffstyp zurueck 143 * @return Schiffstypdaten oder <code>null</code> 144 */ 145 public final ShipTypeData getBuildShipType() { 146 WerftQueueEntry entry = getQueueTopEntry(); 147 148 if( entry != null ) { 149 return entry.getBuilding(); 150 } 151 152 return null; 153 } 154 155 /** 156 * Dekrementiert die verbliebene Bauzeit um 1 157 */ 158 public final void decRemainingTime() { 159 WerftQueueEntry entry = getQueueTopEntry(); 160 if( (entry == null) || (entry.getRemaining() <= 0) ) { 161 return; 162 } 163 164 entry.setRemaining(entry.getRemaining()-1); 165 } 166 167 /** 168 * Inkrementiert die verbliebene Bauzeit um 1 169 */ 170 public final void incRemainingTime() { 171 WerftQueueEntry entry = getQueueTopEntry(); 172 if( entry == null ) { 173 return; 174 } 175 entry.setRemaining(entry.getRemaining()+1); 176 } 177 178 /** 179 * Liefert die noch verbleibende Bauzeit 180 * @return verbleibende Bauzeit 181 */ 182 public final int getRemainingTime() { 183 WerftQueueEntry entry = getQueueTopEntry(); 184 if( entry != null ) { 185 return entry.getRemaining(); 186 } 187 return 0; 188 } 189 190 /** 191 * Gibt das fuer den Bau benoetigte Item zurueck. 192 * Falls kein Item benoetigt wird, wird -1 zurueckgegeben. 193 * @return Item-ID oder -1 194 */ 195 public final int getRequiredItem() { 196 WerftQueueEntry entry = getQueueTopEntry(); 197 if( entry != null ) { 198 return entry.getBuildItem(); 199 } 200 return -1; 145 /** 146 * Gibt die Anzahl der aktuell belegten Slots zurueck 147 * @return Die Anzahl der belegten Slots 148 */ 149 public int getUsedSlots() { 150 org.hibernate.Session db = ContextMap.getContext().getDB(); 151 152 return ((Number)db.createQuery("select sum(slots) from WerftQueueEntry where id.werft=? and scheduled=1") 153 .setInteger(0, this.getWerftID()) 154 .iterate().next()).intValue(); 201 155 } 202 156 … … 210 164 211 165 /** 212 * Beendet den Bauprozess des aktuell gebauten Schiffes erfolgreich. 213 * Sollte dies nicht moeglich sein, wird 0 zurueckgegeben. 214 * 215 * @return die ID des gebauten Schiffes oder 0 216 */ 217 public int finishBuildProcess() { 218 Context context = ContextMap.getContext(); 219 org.hibernate.Session db = context.getDB(); 220 221 if( !this.isBuilding() ) { 222 return 0; 223 } 224 225 ShipTypeData shipd = this.getBuildShipType(); 226 227 int x = this.getX(); 228 int y = this.getY(); 229 int system = this.getSystem(); 230 231 Cargo cargo = new Cargo(); 232 User auser = this.getOwner(); 233 234 String currentTime = Common.getIngameTime(context.get(ContextCommon.class).getTick()); 235 String history = "Indienststellung am "+currentTime+" durch "+auser.getName()+" ("+auser.getID()+")\n"; 236 237 Ship ship = new Ship(auser); 238 ship.setBaseType((ShipType)db.get(ShipType.class, shipd.getTypeId())); 239 ship.setSystem(system); 240 ship.setX(x); 241 ship.setY(y); 242 ship.setCrew(shipd.getCrew()); 243 ship.setHull(shipd.getHull()); 244 ship.setCargo(cargo); 245 ship.setEnergy(shipd.getEps()); 246 ship.setHistory(history); 247 248 int id = (Integer)db.save(ship); 249 250 if( shipd.getWerft() != 0 ) { 251 ShipWerft werft = new ShipWerft(ship); 252 db.persist(werft); 253 this.MESSAGE.get().append("\tWerft '"+shipd.getWerft()+"' in Liste der Werften eingetragen\n"); 254 } 255 256 WerftQueueEntry entry = getQueueTopEntry(); 257 if( entry.isBuildFlagschiff() ) { 258 auser.setFlagschiff(id); 259 this.MESSAGE.get().append("\tFlagschiff eingetragen\n"); 260 } 261 262 // Item benutzen 263 if( this.getRequiredItem() > -1 ) { 264 cargo = this.getCargo(true); 265 List<ItemCargoEntry> itemlist = cargo.getItem(this.getRequiredItem()); 266 boolean ok = false; 267 for( int i=0; i < itemlist.size(); i++ ) { 268 if( itemlist.get(i).getMaxUses() == 0 ) { 269 ok = true; 270 break; 271 } 272 } 273 274 if( !ok ) { 275 User user = this.getOwner(); 166 * Wird von Bauschlangeneintraegen aufgerufen, nachdem sie erfolgreich abgeschlossen wurden. 167 * Der Bauschlangeneintrag ist zu diesem Zeitpunkt bereits entfernt. 168 * @param shipid Die ID des neugebauten Schiffes 169 */ 170 protected void onFinishedBuildProcess(int shipid) { 171 rescheduleQueue(); 172 } 173 174 /** 175 * Berechnet, welche Eintraege der Bauschlange im Moment gebaut werden und welche nicht 176 * 177 */ 178 protected void rescheduleQueue() { 179 int freeSlots = this.getWerftSlots(); 180 181 final WerftQueueEntry[] entries = getBuildQueue(); 182 for( int i=0; i < entries.length; i++ ) { 183 final WerftQueueEntry entry = entries[i]; 184 185 if( (entry.getSlots() <= freeSlots) && entry.isBuildContPossible() ) { 186 entry.setScheduled(true); 276 187 277 Cargo allyitems = null; 278 if( user.getAlly() != null ) { 279 allyitems = new Cargo( Cargo.Type.ITEMSTRING, user.getAlly().getItems() ); 280 itemlist = allyitems.getItem(this.getRequiredItem()); 281 for( int i=0; i < itemlist.size(); i++ ) { 282 if( itemlist.get(i).getMaxUses() == 0 ) { 283 ok = true; 284 break; 285 } 286 } 287 } 188 freeSlots -= entry.getSlots();
