Changeset 8e3cf9b4c2ca1641f6fffa569ea85a5309290daf

Show
Ignore:
Timestamp:
07/01/07 14:57:03 (1 year ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1183294623 +0200
git-parent:

[fdd9b7da5f3efa70d6ba2e2ede6d0cb28403831c]

git-author:
Christopher Jung <bktheg@web.de> 1183294623 +0200
Message:

Eine einfache Bauschlange fuer Werften eingebaut

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • db/updates.xml

    rc3ab33e r8e3cf9b  
    298298                ALTER TABLE werften ADD CONSTRAINT werften_fk_ships FOREIGN KEY (shipid) REFERENCES ships(id); 
    299299        ]]></update> 
     300        <update type="structure" datum="2007-07-01"><![CDATA[ 
     301                CREATE TABLE `werft_queues` ( 
     302                  werft int NOT NULL, 
     303                  `position` int NOT NULL, 
     304                  `building` int(11) default NULL, 
     305                  `item` smallint(6) NOT NULL default '-1', 
     306                  `remaining` tinyint(4) NOT NULL default '0', 
     307                  `flagschiff` tinyint(1) unsigned NOT NULL default '0', 
     308                  PRIMARY KEY  (`werft`,`position`) 
     309                ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 
     310                 
     311                ALTER TABLE werft_queues ADD CONSTRAINT werft_queues_fk_werften FOREIGN KEY (werft) REFERENCES werften(id); 
     312                ALTER TABLE werft_queues ADD CONSTRAINT werft_queues_fk_ship_types FOREIGN KEY (building) REFERENCES ship_types(id); 
     313                 
     314                ALTER TABLE `werften` 
     315                        DROP `building`, 
     316                        DROP `item`, 
     317                        DROP `remaining`; 
     318        ]]></update> 
    300319</updates> 
  • src/net/driftingsouls/ds2/server/bases/Kommandozentrale.java

    r283e6c7 r8e3cf9b  
    4242import net.driftingsouls.ds2.server.framework.db.SQLResultRow; 
    4343import net.driftingsouls.ds2.server.framework.templates.TemplateEngine; 
     44import net.driftingsouls.ds2.server.werften.BaseWerft; 
    4445 
    4546class Kommandozentrale extends DefaultBuilding { 
     
    5657                super.cleanup(context, base); 
    5758                 
    58                 Database db = context.getDatabase(); 
    59                  
    60                 db.update("UPDATE bases SET owner=0,autogtuacts='' WHERE id="+base.getID()); 
     59                org.hibernate.Session db = context.getDB(); 
     60                 
    6161                base.setAutoGTUActs(new ArrayList<AutoGTUAction>()); 
    6262                User nullUser = (User)context.getDB().get(User.class, 0); 
     
    6464                 
    6565                // TODO: Unschoen. Das sollte die Werft selbst machen 
    66                 db.update("UPDATE werften SET building=0,item=-1,remaining=0,flagschiff=0 WHERE col="+base.getID()); 
    67                 db.update("UPDATE werften SET linked=0 WHERE linked="+base.getID()); 
     66                BaseWerft werft = (BaseWerft)db.createQuery("from BaseWerft where col=?") 
     67                        .setEntity(0, base) 
     68                        .uniqueResult(); 
     69                werft.clearQueue(); 
     70                 
     71                db.createQuery("update ShipWerft set linked=null where linked=?") 
     72                        .setEntity(0, base) 
     73                        .executeUpdate(); 
    6874        } 
    6975 
  • src/net/driftingsouls/ds2/server/bases/Werft.java

    rc3ab33e r8e3cf9b  
    5555                super.build(base); 
    5656                 
    57                 ContextMap.getContext().getDatabase().update("INSERT INTO werften (type,col) VALUES(1,"+base.getID()+")"); 
     57                BaseWerft werft = new BaseWerft(base); 
     58                ContextMap.getContext().getDB().persist(werft); 
    5859        } 
    5960 
     
    6364                super.cleanup(context, base); 
    6465                 
    65                 context.getDatabase().update("DELETE FROM werften WHERE col="+base.getID()); 
     66                context.getDB().createQuery("delete from BaseWerft where col=?") 
     67                        .setEntity(0, base) 
     68                        .executeUpdate(); 
    6669        } 
    67  
    6870 
    6971        @Override 
  • src/net/driftingsouls/ds2/server/entities/User.java

    r4e34802 r8e3cf9b  
    311311                                } 
    312312                                else { 
    313                                         flagschiffSpace = fs.getBoolean("flagschiff") ? 1 : 0
     313                                        flagschiffSpace = 1
    314314                                } 
    315315                        } 
    316316                        else { 
    317                                 flagschiffSpace = fs.getBoolean("flagschiff") ? 1 : 0
     317                                flagschiffSpace = 1
    318318                        } 
    319319                } 
  • src/net/driftingsouls/ds2/server/modules/SchiffInfoController.java

    r283e6c7 r8e3cf9b  
    169169                t.set_var(      "shiptype.cost.energie",                shipBuildData.getInt("ekosten"), 
    170170                                        "shiptype.cost.crew",                   shipBuildData.getInt("crew"), 
    171                                         "shiptype.cost.dauer",                  shipBuildData.getInt("dauer"), 
    172                                         "shiptype.cost.linfactor",              shipBuildData.getInt("linfactor")*100 ); 
     171                                        "shiptype.cost.dauer",                  shipBuildData.getInt("dauer") ); 
    173172 
    174173                t.set_block("_SCHIFFINFO", "shiptype.werften.listitem", "shiptype.werften.list" ); 
  • src/net/driftingsouls/ds2/server/tick/regular/WerftTick.java

    r6b67f71 r8e3cf9b  
    4747                org.hibernate.Session db = getDB(); 
    4848                 
    49                 List werften = db.createQuery("from Werft where building!=0 order by id").list(); 
     49                List werften = db.createQuery("from WerftObject order by id").list(); 
    5050                for( Iterator iter=werften.iterator(); iter.hasNext(); ) { 
    5151                        WerftObject werft = (WerftObject)iter.next(); 
  • src/net/driftingsouls/ds2/server/werften/BaseWerft.java

    r6b67f71 r8e3cf9b  
    5454         
    5555        /** 
     56         * Erstellt eine neue Werft 
     57         * @param base Die Basis auf der die Werft stehen soll 
     58         */ 
     59        public BaseWerft(Base base) { 
     60                super(1); 
     61                this.base = base; 
     62        } 
     63         
     64        /** 
    5665         * Gibt die ID der Basis zurueck, auf dem die Werft steht 
    5766         * @return Die ID der Basis 
  • src/net/driftingsouls/ds2/server/werften/WerftGUI.java

    rfdd9b7d r8e3cf9b  
    8181         
    8282                int build = context.getRequest().getParameterInt("build"); 
    83                 String conf = context.getRequest().getParameterString("conf"); 
    8483                int ws = context.getRequest().getParameterInt("ws"); 
    85                 int item = context.getRequest().getParameterInt("item"); 
    8684                 
    8785                if( !t.set_file( "_WERFT.WERFTGUI", "werft.werftgui.html" ) ) { 
     
    9290                                        "werftgui.urlbase",             werft.getUrlBase() ); 
    9391                 
     92                // Baudialog 
    9493                if( build != 0 ) { 
    95                         if( werft.isBuilding() ) { 
    96                                 t.set_var("werftgui.msg", "Sie k&ouml;nnen nur ein Schiff zur selben Zeit bauen"); 
    97                         }  
    98                         else { 
    99                                 this.out_buildShip(build, item, werft, conf); 
    100                         } 
    101                 } 
     94                        final int item = context.getRequest().getParameterInt("item"); 
     95                        final String conf = context.getRequest().getParameterString("conf"); 
     96                         
     97                        this.out_buildShip(build, item, werft, conf); 
     98                } 
     99                // Werkstadt 
    102100                else if( ws != 0 ) { 
    103101                        if( werft.isBuilding() ) { 
     
    108106                        } 
    109107                } 
    110                 else if( werft.isBuilding() ) { 
    111                         this.out_werftbuilding( werft, conf ); 
    112                 }  
    113                 else if( !werft.isBuilding() ) {                 
     108                // Hauptseite 
     109                else { 
     110                        String show = context.getRequest().getParameterString("show"); 
     111                        if( show.length() == 0 ) { 
     112                                show = "build"; 
     113                        } 
     114                         
     115                        t.set_var("werftgui.main", 1); 
     116                         
    114117                        SQLResultRow[] shipdata = werft.getBuildShipList(); 
    115118                         
     
    122125                        this.out_ResourceList( werft, costs ); 
    123126                         
    124                         //Schiffsliste 
    125                         this.out_buildShipList( werft, shipdata ); 
    126                  
    127                         this.out_wsShipList(werft); 
    128                  
    129                         // Verbindung Base <-> Werft 
    130                         if( werft.getWerftType() == WerftObject.SHIP ) { 
    131                                 int shipid = ((ShipWerft)werft).getShipID(); 
    132                                 int linkedbaseID = ((ShipWerft)werft).getLinkedBase(); 
    133                                  
    134                                 ShipTypeData shiptype = Ship.getShipType( shipid, true ); 
    135                                 if( shiptype.getCost() == 0 ) { 
    136                                         t.set_block("_WERFT.WERFTGUI", "werftgui.linkedbase.listitem", "werftgui.linkedbase.list"); 
    137                  
    138                                         t.set_var(      "linkedbase.selected",  linkedbaseID == 0, 
    139                                                                 "linkedbase.value",             "-1", 
    140                                                                 "linkedbase.name",              (linkedbaseID != 0 ? "kein " : "")+"Ziel" ); 
    141                                                                                  
    142                                         t.parse("werftgui.linkedbase.list", "werftgui.linkedbase.listitem", true); 
    143                  
    144                                         List bases = db.createQuery("from Base " + 
    145                                                                 "where x=? and y=? and system=? and owner=? order by id") 
    146                                                                 .setInteger(0, werft.getX()) 
    147                                                                 .setInteger(1, werft.getY()) 
    148                                                                 .setInteger(2, werft.getSystem()) 
    149                                                                 .setInteger(3, werft.getOwner()) 
    150                                                                 .list(); 
    151                                         for( Iterator iter=bases.iterator(); iter.hasNext(); ) { 
    152                                                 Base base = (Base)iter.next(); 
    153                                                  
    154                                                 t.set_var(      "linkedbase.selected",  (linkedbaseID == base.getID()), 
    155                                                                         "linkedbase.value",             base.getID(), 
    156                                                                         "linkedbase.name",              base.getName()+" ("+base.getID()+")" ); 
    157                                                 t.parse("werftgui.linkedbase.list", "werftgui.linkedbase.listitem", true); 
     127                        if( "build".equals(show) ) { 
     128                                t.set_var("werftgui.main.build", 1); 
     129                                 
     130                                this.out_buildShipList( werft, shipdata ); 
     131                        } 
     132                        else if( "repair".equals(show) ) { 
     133                                t.set_var("werftgui.main.repair", 1); 
     134                                 
     135                                this.out_wsShipList(werft); 
     136                        } 
     137                        else if( "queue".equals(show) ) { 
     138                                t.set_var("werftgui.main.queue", 1); 
     139                                 
     140                                final int position = context.getRequest().getParameterInt("entry"); 
     141                                final String action = context.getRequest().getParameterString("werftact"); 
     142                                 
     143                                if( action.equals("canclebuild") ) { 
     144                                        WerftQueueEntry entry = werft.getBuildQueueEntry(position); 
     145                                        if( entry != null ) { 
     146                                                t.set_var( "werftgui.building.cancel", 1 ); 
     147                                         
     148                                                werft.cancelBuild(entry); 
    158149                                        } 
    159150                                } 
     151                                else if( action.equals("queuedown") ) { 
     152                                        WerftQueueEntry entry = werft.getBuildQueueEntry(position); 
     153                                        WerftQueueEntry entry2 = werft.getBuildQueueEntry(position+1); 
     154                                        if( (entry != null) && (entry2 != null) ) { 
     155                                                werft.swapQueueEntries(entry, entry2); 
     156                                        } 
     157                                } 
     158                                else if( action.equals("queueup") ) { 
     159                                        WerftQueueEntry entry = werft.getBuildQueueEntry(position); 
     160                                        WerftQueueEntry entry2 = werft.getBuildQueueEntry(position-1); 
     161                                        if( (entry != null) && (entry2 != null) ) { 
     162                                                werft.swapQueueEntries(entry, entry2); 
     163                                        } 
     164                                } 
     165                                 
     166                                out_queueShipList(werft, werft.getBuildQueue()); 
     167                        } 
     168                        else if( "options".equals(show) ) { 
     169                                t.set_var("werftgui.main.options", 1); 
     170                                 
     171                                // Verbindung Base <-> Werft 
     172                                if( werft.getWerftType() == WerftObject.SHIP ) { 
     173                                        int shipid = ((ShipWerft)werft).getShipID(); 
     174                                        int linkedbaseID = ((ShipWerft)werft).getLinkedBase(); 
     175                                         
     176                                        ShipTypeData shiptype = Ship.getShipType( shipid, true ); 
     177                                        if( shiptype.getCost() == 0 ) { 
     178                                                t.set_block("_WERFT.WERFTGUI", "werftgui.linkedbase.listitem", "werftgui.linkedbase.list"); 
     179                                                 
     180                                                if( linkedbaseID != 0 ) { 
     181                                                        t.set_var(      "linkedbase.selected",  false, 
     182                                                                                "linkedbase.value",             "-1", 
     183                                                                                "linkedbase.name",              "kein Ziel" ); 
     184                                                         
     185                                                        t.parse("werftgui.linkedbase.list", "werftgui.linkedbase.listitem", true); 
     186                                                } 
     187                         
     188                                                List bases = db.createQuery("from Base " + 
     189                                                                        "where x=? and y=? and system=? and owner=? order by id") 
     190                                                                        .setInteger(0, werft.getX()) 
     191                                                                        .setInteger(1, werft.getY()) 
     192                                                                        .setInteger(2, werft.getSystem()) 
     193                                                                        .setInteger(3, werft.getOwner()) 
     194                                                                        .list(); 
     195                                                for( Iterator iter=bases.iterator(); iter.hasNext(); ) { 
     196                                                        Base base = (Base)iter.next(); 
     197                                                         
     198                                                        t.set_var(      "linkedbase.selected",  (linkedbaseID == base.getID()), 
     199                                                                                "linkedbase.value",             base.getID(), 
     200                                                                                "linkedbase.name",              base.getName()+" ("+base.getID()+")" ); 
     201                                                        t.parse("werftgui.linkedbase.list", "werftgui.linkedbase.listitem", true); 
     202                                                } 
     203                                        } 
     204                                } 
    160205                        } 
    161206                } 
     
    170215                t.set_block("_WERFT.WERFTGUI", "wsshiplist.listitem", "wsshiplist.list"); 
    171216                 
    172                 List ships = db.createQuery("from Ship s inner join fetch s.owner as u " + 
     217                List ships = db.createQuery("from Ship s inner join fetch s.owner as u left join fetch s.modules " + 
    173218                                                                "where s.id>0 and (s.x between ? and ?) and (s.y between ? and ?) and s.system=? and " + 
    174219                                                                "locate('l ',s.docked)=0 and s.battle=0 order by u.id,s.id") 
     
    207252        } 
    208253 
     254        private void out_queueShipList(WerftObject werft, WerftQueueEntry[] queue) {             
     255                t.set_block("_WERFT.WERFTGUI", "queueshiplist.listitem", "queueshiplist.list"); 
     256                 
     257                int remaining = 0; 
     258                for( int i=0; i < queue.length; i++ ) { 
     259                        WerftQueueEntry entry = queue[i]; 
     260 
     261                        remaining += entry.getRemaining(); 
     262                         
     263                        t.set_var( 
     264                                        "queueship.position",   entry.getPosition(), 
     265                                        "queueship.type.image", entry.getBuilding().getPicture(), 
     266                                        "queueship.type.id",    entry.getBuilding().getTypeId(), 
     267                                        "queueship.type.name",  entry.getBuilding().getNickname(), 
     268                                        "queueship.remainingtotal",     remaining, 
     269                                        "queueship.building",   i == 0, 
     270                                        "queueship.uppossible", i > 0, 
     271                                        "queueship.downpossible",       i < queue.length-1); 
     272                         
     273                        t.parse("queueshiplist.list", "queueshiplist.listitem", true); 
     274                } 
     275        } 
     276         
    209277        private void out_buildShipList(WerftObject werft, SQLResultRow[] shipdata) {             
    210278                t.set_var("werftgui.buildshiplist", 1); 
     
    276344 
    277345        private void out_ResourceList(WerftObject werft, Cargo showonly) {               
    278                 t.set_var("werftgui.reslist", 1); 
    279346                t.set_block("_WERFT.WERFTGUI", "reslist.res.listitem", "reslist.res.list"); 
    280347                 
     
    298365                                        "res.cargo",            frei ); 
    299366                t.parse("reslist.res.list", "reslist.res.listitem", true); 
    300         } 
    301  
    302         private void out_werftbuilding(WerftObject werft, String conf) { 
    303                 String action = context.getRequest().getParameterString("werftact"); 
    304                          
    305                 ShipTypeData type = werft.getBuildShipType(); 
    306  
    307                 if( action.equals("canclebuild") && conf.equals("ok") ) { 
    308                         t.set_var( "werftgui.building.cancel", 1 ); 
    309                         werft.cancelBuild(); 
    310                         return; 
    311                 } 
    312                  
    313                 t.set_var(      "werftgui.building",            1, 
    314                                         "ship.type.image",                      type.getPicture(), 
    315                                         "ship.type.id",                         type.getTypeId(), 
    316                                         "ship.type.name",                       type.getNickname(), 
    317                                         "ship.build.remaining",         werft.getRemainingTime(), 
    318                                         "werftgui.building.cancel.conf",        action.equals("canclebuild") && !conf.equals("ok") ); 
    319  
    320                 if( werft.getRequiredItem() > -1 ) { 
    321                         t.set_var(      "ship.build.item",                              werft.getRequiredItem(), 
    322                                                 "ship.build.item.picture",              Items.get().item(werft.getRequiredItem()).getPicture(), 
    323                                                 "ship.build.item.name",                 Items.get().item(werft.getRequiredItem()).getName(), 
    324                                                 "ship.build.item.available",    werft.isBuildContPossible() ); 
    325                 } 
    326367        } 
    327368 
  • src/net/driftingsouls/ds2/server/werften/WerftObject.java

    rfdd9b7d r8e3cf9b  
    3232import javax.persistence.InheritanceType; 
    3333import javax.persistence.Table; 
     34import javax.persistence.Transient; 
    3435 
    3536import net.driftingsouls.ds2.server.ContextCommon; 
     
    8687        @Id @GeneratedValue 
    8788        private int id = 0; 
    88         private int building = 0; 
    89         @Column(name="item") 
    90         private int buildItem = -1; 
    91         private int remaining = 0; 
    9289        @Column(name="flagschiff") 
    9390        private boolean buildFlagschiff = false; 
     
    10299        } 
    103100         
    104         @Deprecated 
    105         protected WerftObject( SQLResultRow werftdata ) { 
    106                 this.id = werftdata.getInt("id"); 
    107                 this.type = werftdata.getInt("type"); 
    108                 this.building = werftdata.getInt("building"); 
    109                 this.buildItem = werftdata.getInt("item"); 
    110                 this.remaining = werftdata.getInt("remaining"); 
    111                 this.buildFlagschiff = werftdata.getBoolean("flagschiff"); 
     101        /** 
     102         * Erstellt eine neue Werft 
     103         * @param type Der Typ der Werft 
     104         */ 
     105        public WerftObject(int type) { 
     106                this.type = type; 
    112107        } 
    113108         
     
    117112         */ 
    118113        public final boolean isBuilding() { 
    119                 return building != 0; 
     114                return getQueueTopEntry() != null; 
     115        } 
     116         
     117        /** 
     118         * Gibt zurueck, ob sich in der Bauschlange ein Flagschiff befindet 
     119         * @return <code>true</code>, falls ein Flagschiff gebaut werden soll 
     120         */ 
     121        public final boolean isBuildFlagschiff() { 
     122                return this.buildFlagschiff; 
     123        } 
     124         
     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; 
    120139        } 
    121140         
     
    125144         */ 
    126145        public final ShipTypeData getBuildShipType() { 
    127                 if( building > 0 ) { 
    128                         return Ship.getShipType(building, false); 
     146                WerftQueueEntry entry = getQueueTopEntry(); 
     147                 
     148                if( entry != null ) { 
     149                        return entry.getBuilding(); 
    129150                } 
    130151                 
     
    136157         */ 
    137158        public final void decRemainingTime() { 
    138                 if( remaining <= 0 ) { 
     159                WerftQueueEntry entry = getQueueTopEntry(); 
     160                if( (entry == null) || (entry.getRemaining() <= 0) ) { 
    139161                        return; 
    140162                } 
    141                 remaining--; 
    142                 ContextMap.getContext().getDatabase().update("UPDATE werften SET remaining=remaining-1 WHERE id=",getWerftID()); 
     163                 
     164                entry.setRemaining(entry.getRemaining()-1); 
    143165        } 
    144166         
     
    147169         */ 
    148170        public final void incRemainingTime() { 
    149                 remaining++; 
    150                 ContextMap.getContext().getDatabase().update("UPDATE werften SET remaining=remaining+1 WHERE id=",getWerftID()); 
     171                WerftQueueEntry entry = getQueueTopEntry(); 
     172                if( entry == null ) { 
     173                        return; 
     174                } 
     175                entry.setRemaining(entry.getRemaining()+1); 
    151176        } 
    152177         
     
    156181         */ 
    157182        public final int getRemainingTime() { 
    158                 return remaining; 
     183                WerftQueueEntry entry = getQueueTopEntry(); 
     184                if( entry != null ) { 
     185                        return entry.getRemaining(); 
     186                } 
     187                return 0; 
    159188        } 
    160189         
     
    165194         */ 
    166195        public final int getRequiredItem() { 
    167                 return buildItem; 
     196                WerftQueueEntry entry = getQueueTopEntry(); 
     197                if( entry != null ) { 
     198                        return entry.getBuildItem(); 
     199                } 
     200                return -1; 
    168201        } 
    169202         
     
    185218                Context context = ContextMap.getContext(); 
    186219                org.hibernate.Session db = context.getDB(); 
     220                 
     221                if( !this.isBuilding() ) { 
     222                        return 0; 
     223                } 
    187224                 
    188225                ShipTypeData shipd = this.getBuildShipType(); 
     
    217254                        this.MESSAGE.get().append("\tWerft '"+shipd.getWerft()+"' in Liste der Werften eingetragen\n"); 
    218255                } 
    219                 if( this.buildFlagschiff ) { 
     256                 
     257                WerftQueueEntry entry = getQueueTopEntry(); 
     258                if( entry.isBuildFlagschiff() ) { 
    220259                        auser.setFlagschiff(id); 
    221260                        this.MESSAGE.get().append("\tFlagschiff eingetragen\n"); 
     
    278317                ship.recalculateShipStatus(); 
    279318                 
    280                 this.building = 0; 
    281                 this.remaining = 0; 
    282                 this.buildFlagschiff = false; 
    283                 this.buildItem = -1; 
     319                if( entry.isBuildFlagschiff() ) { 
     320                        this.buildFlagschiff = false; 
     321                } 
     322                 
     323                db.delete(entry); 
     324                db.createQuery("update WerftQueueEntry set id.position=id.position-1 where id.werft=?") 
     325                        .setInteger(0, this.getWerftID()) 
     326                        .executeUpdate(); 
     327                 
     328                topEntry = null; 
    284329                 
    285330                return id; 
     
    319364         
    320365        /** 
    321          * Bricht das aktuelle Bauvorhaben ab 
    322          */ 
    323         public void cancelBuild() { 
    324                 building = 0; 
    325                 remaining = 0; 
    326                 buildItem = -1; 
    327                 buildFlagschiff = false; 
     366         * Bricht das angegebene Bauvorhaben ab 
     367         * @param entry Ein Eintrag aus der Bauschlange 
     368         */ 
     369        public void cancelBuild(WerftQueueEntry entry) { 
     370                org.hibernate.Session db = ContextMap.getContext().getDB(); 
     371                 
     372                if( entry.isBuildFlagschiff() ) { 
     373                        this.buildFlagschiff = false; 
     374                } 
     375                db.delete(entry); 
     376                 
     377                db.createQuery("update WerftQueueEntry set id.position=id.position-1 where id.werft=? and id.position>?") 
     378                        .setInteger(0, this.getWerftID()) 
     379                        .setInteger(1, entry.getPosition()) 
     380                        .executeUpdate(); 
     381                 
     382                topEntry = null; 
     383        } 
     384         
     385        /** 
     386         * Entfernt alle Eintraege aus der Bauschlange 
     387         * 
     388         */ 
     389        public void clearQueue() { 
     390                org.hibernate.Session db = ContextMap.getContext().getDB(); 
     391                db.createQuery("delete from WerftQueueEntry where id.werft=?") 
     392                        .setInteger(0, this.getWerftID()) 
     393                        .executeUpdate(); 
     394                 
     395                this.buildFlagschiff = false; 
     396                this.topEntry = null; 
    328397        } 
    329398 
     
    10591128                        sysreqquery = "t1.systemreq=0 AND "; 
    10601129                } 
    1061                 String query = "SELECT t1.id,t1.race,t1.type,t1.dauer,t1.costs,t1.ekosten,t1.crew,t1.tr1,t1.tr2,t1.tr3,t1.flagschiff,t1.linfactor " + 
     1130                String query = "SELECT t1.id,t1.race,t1.type,t1.dauer,t1.costs,t1.ekosten,t1.crew,t1.tr1,t1.tr2,t1.tr3,t1.flagschiff " + 
    10621131                        "FROM ships_baubar t1 JOIN ship_types t2 ON t1.type=t2.id " + 
    10631132                        "WHERE "+sysreqquery+" LOCATE('"+this.getWerftTag()+"',t1.werftreq) "+fsquery+" " + 
     
    11081177 
    11091178                        Cargo costs = new Cargo( Cargo.Type.STRING, shipdata.getString("costs") ); 
    1110          
    1111                         // Kosten anpassen 
    1112                         if( shipdata.getDouble("linfactor") > 0 ) { 
    1113                                 int count = db.first("SELECT count(*) count FROM ships WHERE id>0 AND type=",shipdata.getInt("type")," AND owner=",user.getID()).getInt("count"); 
    1114                                 int count2 = db.first("SELECT count(t1.id) count FROM werften t1 JOIN bases t2 ON t1.col=t2.id WHERE t1.building=",shipdata.getInt("type")," AND t2.owner=",user.getID()).getInt("count"); 
    1115                                 int count3 = db.first("SELECT count(t1.id) count FROM werften t1 JOIN ships t2 ON t1.shipid=t2.id WHERE t2.id>0 AND t1.building=",shipdata.getInt("type")," AND t2.owner=",user.getID()).getInt("count"); 
    1116          
    1117                                 count = count + count2 + count3; 
    1118                                  
    1119                                 costs.multiply( count*shipdata.getDouble("linfactor")+1, Cargo.Round.NONE ); 
    1120                         } 
    11211179         
    11221180                        shipdata.put("costs", costs); 
     
    11601218                        shipdata.put("type", effect.getShipType()); 
    11611219                        shipdata.put("costs", cost); 
    1162                         shipdata.put("linfactor", 0); 
    11631220                        shipdata.put("crew", effect.getCrew()); 
    11641221                        shipdata.put("dauer", effect.getDauer()); 
     
    12081265                        shipdata.put("type", effect.getShipType()); 
    12091266                        shipdata.put("costs", cost); 
    1210                         shipdata.put("linfactor", 0); 
    12111267                        shipdata.put("crew", effect.getCrew()); 
    12121268                        shipdata.put("dauer", effect.getDauer()); 
     
    12571313                SQLResultRow shipdata = null; 
    12581314                if( build > 0 ) { 
    1259                         shipdata = db.first("SELECT type,costs,ekosten,crew,dauer,race,systemreq,tr1,tr2,tr3,werftreq,flagschiff,linfactor FROM ships_baubar WHERE id=",build); 
     1315                        shipdata = db.first("SELECT type,costs,ekosten,crew,dauer,race,systemreq,tr1,tr2,tr3,werftreq,flagschiff FROM ships_baubar WHERE id=",build); 
    12601316                        if( shipdata.isEmpty() ) { 
    12611317                                MESSAGE.get().append("Es wurde kein passender Schiffsbauplan gefunden"); 
     
    12641320                         
    12651321                        shipdata.put("costs", new Cargo(Cargo.Type.STRING, shipdata.getString("costs"))); 
    1266                          
    1267                         // Kosten anpassen 
    1268                         if( shipdata.getDouble("linfactor") > 0 ) { 
    1269                                 int count = db.first("SELECT count(*) count FROM ships WHERE id>0 AND type=",shipdata.getInt("type")," AND owner=",user.getID()).getInt("count"); 
    1270                                 int count2 = db.first("SELECT count(t1.id) count FROM werften t1 JOIN bases t2 ON t1.col=t2.id WHERE t1.building=",shipdata.getInt("type")," AND t2.owner=",user.getID()).getInt("count"); 
    1271                                 int count3 = db.first("SELECT count(t1.id) count FROM werften t1 JOIN ships t2 ON t1.shipid=t2.id WHERE t2.id>0 AND t1.building=",shipdata.getInt("type")," AND t2.owner=",user.getID()).getInt("count"); 
    1272                  
    1273                                 count = count + count2 + count3; 
    1274                                 ((Cargo)shipdata.get("costs")).multiply( shipdata.getDouble("linfactor")*count+1, Cargo.Round.NONE ); 
    1275                         } 
    12761322                } 
    12771323                else { 
     
    12911337                        shipdata.put("type", effect.getShipType()); 
    12921338